[5] | 1 | /* The copyright in this software is being made available under the BSD |
---|
| 2 | * License, included below. This software may be subject to other third party |
---|
| 3 | * and contributor rights, including patent rights, and no such rights are |
---|
[56] | 4 | * granted under this license. |
---|
[5] | 5 | * |
---|
[1179] | 6 | * Copyright (c) 2010-2015, ITU/ISO/IEC |
---|
[5] | 7 | * All rights reserved. |
---|
| 8 | * |
---|
| 9 | * Redistribution and use in source and binary forms, with or without |
---|
| 10 | * modification, are permitted provided that the following conditions are met: |
---|
| 11 | * |
---|
| 12 | * * Redistributions of source code must retain the above copyright notice, |
---|
| 13 | * this list of conditions and the following disclaimer. |
---|
| 14 | * * Redistributions in binary form must reproduce the above copyright notice, |
---|
| 15 | * this list of conditions and the following disclaimer in the documentation |
---|
| 16 | * and/or other materials provided with the distribution. |
---|
[56] | 17 | * * Neither the name of the ITU/ISO/IEC nor the names of its contributors may |
---|
[5] | 18 | * be used to endorse or promote products derived from this software without |
---|
| 19 | * specific prior written permission. |
---|
| 20 | * |
---|
| 21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
---|
| 22 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
---|
| 23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
---|
| 24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS |
---|
| 25 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
---|
| 26 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
---|
| 27 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
---|
| 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
---|
| 29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
---|
| 30 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF |
---|
| 31 | * THE POSSIBILITY OF SUCH DAMAGE. |
---|
| 32 | */ |
---|
[2] | 33 | |
---|
| 34 | /** \file TComMotionInfo.h |
---|
| 35 | \brief motion information handling classes (header) |
---|
| 36 | \todo TComMvField seems to be better to be inherited from TComMv |
---|
| 37 | */ |
---|
| 38 | |
---|
| 39 | #ifndef __TCOMMOTIONINFO__ |
---|
| 40 | #define __TCOMMOTIONINFO__ |
---|
| 41 | |
---|
| 42 | #include <memory.h> |
---|
| 43 | #include "CommonDef.h" |
---|
| 44 | #include "TComMv.h" |
---|
[1321] | 45 | |
---|
[56] | 46 | //! \ingroup TLibCommon |
---|
| 47 | //! \{ |
---|
| 48 | |
---|
[2] | 49 | // ==================================================================================================================== |
---|
| 50 | // Type definition |
---|
| 51 | // ==================================================================================================================== |
---|
| 52 | |
---|
[1313] | 53 | #if NH_3D_SPIVMP |
---|
[724] | 54 | class TComDataCU; |
---|
| 55 | #endif |
---|
[2] | 56 | /// parameters for AMVP |
---|
| 57 | typedef struct _AMVPInfo |
---|
| 58 | { |
---|
[56] | 59 | TComMv m_acMvCand[ AMVP_MAX_NUM_CANDS_MEM ]; ///< array of motion vector predictor candidates |
---|
[2] | 60 | Int iN; ///< number of motion vector predictor candidates |
---|
| 61 | } AMVPInfo; |
---|
| 62 | |
---|
[1313] | 63 | #if NH_3D_NBDV |
---|
[608] | 64 | typedef struct _DisCand |
---|
[100] | 65 | { |
---|
[608] | 66 | TComMv m_acNBDV; // DV from NBDV |
---|
[1313] | 67 | #if NH_3D_NBDV_REF |
---|
[608] | 68 | TComMv m_acDoNBDV; // DV from DoNBDV |
---|
| 69 | #endif |
---|
| 70 | Int m_aVIdxCan; // View order index (the same with the NBDV and the DoNBDV) |
---|
[100] | 71 | } DisInfo; |
---|
[332] | 72 | |
---|
[608] | 73 | typedef struct _IDVCand // IDV |
---|
[332] | 74 | { |
---|
[608] | 75 | TComMv m_acMvCand[2][ IDV_CANDS ]; |
---|
| 76 | Int m_aVIdxCan[2][ IDV_CANDS ]; |
---|
| 77 | Bool m_bAvailab[2][ IDV_CANDS ]; |
---|
| 78 | Bool m_bFound; |
---|
| 79 | } IDVInfo; |
---|
| 80 | #endif |
---|
[1084] | 81 | |
---|
[608] | 82 | // ==================================================================================================================== |
---|
[2] | 83 | // Class definition |
---|
| 84 | // ==================================================================================================================== |
---|
| 85 | |
---|
| 86 | /// class for motion vector with reference index |
---|
| 87 | class TComMvField |
---|
| 88 | { |
---|
| 89 | private: |
---|
| 90 | TComMv m_acMv; |
---|
| 91 | Int m_iRefIdx; |
---|
| 92 | |
---|
| 93 | public: |
---|
[56] | 94 | TComMvField() : m_iRefIdx( NOT_VALID ) {} |
---|
[2] | 95 | |
---|
[56] | 96 | Void setMvField( TComMv const & cMv, Int iRefIdx ) |
---|
[2] | 97 | { |
---|
| 98 | m_acMv = cMv; |
---|
| 99 | m_iRefIdx = iRefIdx; |
---|
| 100 | } |
---|
| 101 | |
---|
[56] | 102 | Void setRefIdx( Int refIdx ) { m_iRefIdx = refIdx; } |
---|
[2] | 103 | |
---|
[56] | 104 | TComMv const & getMv() const { return m_acMv; } |
---|
| 105 | TComMv & getMv() { return m_acMv; } |
---|
| 106 | |
---|
| 107 | Int getRefIdx() const { return m_iRefIdx; } |
---|
| 108 | Int getHor () const { return m_acMv.getHor(); } |
---|
| 109 | Int getVer () const { return m_acMv.getVer(); } |
---|
[1313] | 110 | #if NH_3D_IV_MERGE |
---|
[189] | 111 | Bool operator== ( const TComMvField& rcMv ) const |
---|
| 112 | { |
---|
| 113 | return (m_acMv.getHor()==rcMv.getHor() && m_acMv.getVer()==rcMv.getVer() && m_iRefIdx == rcMv.getRefIdx()); |
---|
| 114 | } |
---|
| 115 | #endif |
---|
[2] | 116 | }; |
---|
| 117 | |
---|
| 118 | /// class for motion information in one CU |
---|
| 119 | class TComCUMvField |
---|
| 120 | { |
---|
| 121 | private: |
---|
| 122 | TComMv* m_pcMv; |
---|
| 123 | TComMv* m_pcMvd; |
---|
[56] | 124 | Char* m_piRefIdx; |
---|
[2] | 125 | UInt m_uiNumPartition; |
---|
| 126 | AMVPInfo m_cAMVPInfo; |
---|
[56] | 127 | |
---|
| 128 | template <typename T> |
---|
| 129 | Void setAll( T *p, T const & val, PartSize eCUMode, Int iPartAddr, UInt uiDepth, Int iPartIdx ); |
---|
| 130 | |
---|
[2] | 131 | public: |
---|
[56] | 132 | TComCUMvField() : m_pcMv(NULL), m_pcMvd(NULL), m_piRefIdx(NULL), m_uiNumPartition(0) {} |
---|
| 133 | ~TComCUMvField() {} |
---|
| 134 | |
---|
[2] | 135 | // ------------------------------------------------------------------------------------------------------------------ |
---|
| 136 | // create / destroy |
---|
| 137 | // ------------------------------------------------------------------------------------------------------------------ |
---|
| 138 | |
---|
[56] | 139 | Void create( UInt uiNumPartition ); |
---|
| 140 | Void destroy(); |
---|
[2] | 141 | |
---|
| 142 | // ------------------------------------------------------------------------------------------------------------------ |
---|
| 143 | // clear / copy |
---|
| 144 | // ------------------------------------------------------------------------------------------------------------------ |
---|
[56] | 145 | |
---|
| 146 | Void clearMvField(); |
---|
[2] | 147 | |
---|
[56] | 148 | Void copyFrom( TComCUMvField const * pcCUMvFieldSrc, Int iNumPartSrc, Int iPartAddrDst ); |
---|
| 149 | Void copyTo ( TComCUMvField* pcCUMvFieldDst, Int iPartAddrDst ) const; |
---|
| 150 | Void copyTo ( TComCUMvField* pcCUMvFieldDst, Int iPartAddrDst, UInt uiOffset, UInt uiNumPart ) const; |
---|
[2] | 151 | |
---|
| 152 | // ------------------------------------------------------------------------------------------------------------------ |
---|
| 153 | // get |
---|
| 154 | // ------------------------------------------------------------------------------------------------------------------ |
---|
| 155 | |
---|
[56] | 156 | TComMv const & getMv ( Int iIdx ) const { return m_pcMv [iIdx]; } |
---|
| 157 | TComMv const & getMvd ( Int iIdx ) const { return m_pcMvd [iIdx]; } |
---|
| 158 | Int getRefIdx( Int iIdx ) const { return m_piRefIdx[iIdx]; } |
---|
[2] | 159 | |
---|
| 160 | AMVPInfo* getAMVPInfo () { return &m_cAMVPInfo; } |
---|
[56] | 161 | |
---|
[2] | 162 | // ------------------------------------------------------------------------------------------------------------------ |
---|
| 163 | // set |
---|
| 164 | // ------------------------------------------------------------------------------------------------------------------ |
---|
| 165 | |
---|
[56] | 166 | Void setAllMv ( TComMv const & rcMv, PartSize eCUMode, Int iPartAddr, UInt uiDepth, Int iPartIdx=0 ); |
---|
| 167 | Void setAllMvd ( TComMv const & rcMvd, PartSize eCUMode, Int iPartAddr, UInt uiDepth, Int iPartIdx=0 ); |
---|
| 168 | Void setAllRefIdx ( Int iRefIdx, PartSize eMbMode, Int iPartAddr, UInt uiDepth, Int iPartIdx=0 ); |
---|
| 169 | Void setAllMvField( TComMvField const & mvField, PartSize eMbMode, Int iPartAddr, UInt uiDepth, Int iPartIdx=0 ); |
---|
[1313] | 170 | #if NH_3D_SPIVMP |
---|
[724] | 171 | Void setMvFieldSP ( TComDataCU* pcCU, UInt uiAbsPartIdx, TComMvField cMvField, Int iWidth, Int iHeight ); |
---|
| 172 | #endif |
---|
[1313] | 173 | #if NH_3D_VSP |
---|
[833] | 174 | Void setMv ( Int iIdx, TComMv const & rcMv ) { m_pcMv[iIdx] = rcMv; } |
---|
| 175 | Void setRefIdx ( Int iIdx, Int iRefIdx ) { m_piRefIdx[iIdx] = iRefIdx; } |
---|
| 176 | #endif |
---|
[56] | 177 | |
---|
| 178 | Void setNumPartition( Int iNumPart ) |
---|
| 179 | { |
---|
| 180 | m_uiNumPartition = iNumPart; |
---|
| 181 | } |
---|
[2] | 182 | |
---|
[56] | 183 | Void linkToWithOffset( TComCUMvField const * src, Int offset ) |
---|
| 184 | { |
---|
| 185 | m_pcMv = src->m_pcMv + offset; |
---|
| 186 | m_pcMvd = src->m_pcMvd + offset; |
---|
| 187 | m_piRefIdx = src->m_piRefIdx + offset; |
---|
| 188 | } |
---|
[2] | 189 | |
---|
[56] | 190 | Void compress(Char* pePredMode, Int scale); |
---|
[1321] | 191 | #if NH_MV |
---|
| 192 | Void print (Char* pePredMode); |
---|
| 193 | #endif |
---|
[2] | 194 | }; |
---|
| 195 | |
---|
[56] | 196 | //! \} |
---|
| 197 | |
---|
[1313] | 198 | #if NH_3D_MLC |
---|
| 199 | /// class for container of merge candidate |
---|
[950] | 200 | class TComMotionCand |
---|
| 201 | { |
---|
| 202 | public: |
---|
| 203 | Bool m_bAvailable; |
---|
| 204 | TComMvField m_cMvField[2]; |
---|
| 205 | UChar m_uDir; |
---|
[1313] | 206 | #if NH_3D_VSP |
---|
[950] | 207 | Int m_iVspFlag; |
---|
[1313] | 208 | #endif |
---|
| 209 | #if NH_3D_SPIVMP |
---|
[950] | 210 | Bool m_bSPIVMPFlag; |
---|
[1313] | 211 | #endif |
---|
[950] | 212 | |
---|
| 213 | public: |
---|
| 214 | TComMotionCand() |
---|
| 215 | { |
---|
| 216 | m_bAvailable = false; |
---|
| 217 | m_uDir = 0; |
---|
[1313] | 218 | #if NH_3D_VSP |
---|
[950] | 219 | m_iVspFlag = 0; |
---|
| 220 | #endif |
---|
[1313] | 221 | #if NH_3D_SPIVMP |
---|
[950] | 222 | m_bSPIVMPFlag = false; |
---|
[1313] | 223 | #endif |
---|
[950] | 224 | } |
---|
| 225 | |
---|
| 226 | ~TComMotionCand() |
---|
| 227 | { |
---|
| 228 | |
---|
| 229 | } |
---|
| 230 | |
---|
| 231 | Void init() |
---|
| 232 | { |
---|
| 233 | TComMv cZeroMv; |
---|
| 234 | |
---|
| 235 | m_bAvailable = false; |
---|
| 236 | m_uDir = 0; |
---|
[1313] | 237 | #if NH_3D_VSP |
---|
[950] | 238 | m_iVspFlag = 0; |
---|
| 239 | #endif |
---|
[1313] | 240 | #if NH_3D_SPIVMP |
---|
[950] | 241 | m_bSPIVMPFlag = false; |
---|
[1313] | 242 | #endif |
---|
[950] | 243 | m_cMvField[0].setMvField(cZeroMv, NOT_VALID); |
---|
| 244 | m_cMvField[1].setMvField(cZeroMv, NOT_VALID); |
---|
| 245 | } |
---|
| 246 | |
---|
| 247 | Void setCand(TComMvField* pcMvFieldNeighbours, UChar uhInterDirNeighbours |
---|
[1313] | 248 | #if NH_3D_VSP |
---|
[950] | 249 | , Int vspFlag |
---|
| 250 | #endif |
---|
[1313] | 251 | #if NH_3D_SPIVMP |
---|
[950] | 252 | , Bool bSPIVMPFlag |
---|
[1313] | 253 | #endif |
---|
[950] | 254 | ) |
---|
| 255 | { |
---|
| 256 | m_bAvailable = true; |
---|
| 257 | m_cMvField[0] = pcMvFieldNeighbours[0]; |
---|
| 258 | m_cMvField[1] = pcMvFieldNeighbours[1]; |
---|
| 259 | m_uDir = uhInterDirNeighbours; |
---|
[1313] | 260 | #if NH_3D_VSP |
---|
[950] | 261 | m_iVspFlag = vspFlag; |
---|
| 262 | #endif |
---|
[1313] | 263 | #if NH_3D_SPIVMP |
---|
[950] | 264 | m_bSPIVMPFlag = bSPIVMPFlag; |
---|
[1313] | 265 | #endif |
---|
[950] | 266 | } |
---|
[1313] | 267 | |
---|
[950] | 268 | Void getCand(Int iCount, TComMvField* pcMvFieldNeighbours, UChar* puhInterDirNeighbours |
---|
[1313] | 269 | #if NH_3D_VSP |
---|
[950] | 270 | , Int* vspFlag |
---|
| 271 | #endif |
---|
[1313] | 272 | #if NH_3D_SPIVMP |
---|
[950] | 273 | , Bool* pbSPIVMPFlag |
---|
[1313] | 274 | #endif |
---|
[950] | 275 | ) |
---|
| 276 | { |
---|
| 277 | pcMvFieldNeighbours[iCount<<1] = m_cMvField[0]; |
---|
| 278 | pcMvFieldNeighbours[(iCount<<1) + 1] = m_cMvField[1]; |
---|
| 279 | puhInterDirNeighbours[iCount] = m_uDir; |
---|
[1313] | 280 | #if NH_3D_VSP |
---|
[950] | 281 | vspFlag[iCount] = m_iVspFlag; |
---|
| 282 | #endif |
---|
[1313] | 283 | #if NH_3D_SPIVMP |
---|
[950] | 284 | pbSPIVMPFlag[iCount] = m_bSPIVMPFlag; |
---|
[1313] | 285 | #endif |
---|
[950] | 286 | } |
---|
[1321] | 287 | |
---|
| 288 | |
---|
| 289 | Void print( Int i ); |
---|
| 290 | |
---|
[950] | 291 | }; |
---|
[1321] | 292 | |
---|
| 293 | |
---|
[950] | 294 | #endif |
---|
| 295 | |
---|
| 296 | |
---|
[2] | 297 | #endif // __TCOMMOTIONINFO__ |
---|