[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" |
---|
[56] | 45 | //! \ingroup TLibCommon |
---|
| 46 | //! \{ |
---|
| 47 | |
---|
[2] | 48 | // ==================================================================================================================== |
---|
| 49 | // Type definition |
---|
| 50 | // ==================================================================================================================== |
---|
| 51 | |
---|
[773] | 52 | #if H_3D_SPIVMP |
---|
[724] | 53 | class TComDataCU; |
---|
| 54 | #endif |
---|
[2] | 55 | /// parameters for AMVP |
---|
| 56 | typedef struct _AMVPInfo |
---|
| 57 | { |
---|
[56] | 58 | TComMv m_acMvCand[ AMVP_MAX_NUM_CANDS_MEM ]; ///< array of motion vector predictor candidates |
---|
[2] | 59 | Int iN; ///< number of motion vector predictor candidates |
---|
| 60 | } AMVPInfo; |
---|
| 61 | |
---|
[1210] | 62 | #if NH_3D_NBDV |
---|
[608] | 63 | typedef struct _DisCand |
---|
[100] | 64 | { |
---|
[608] | 65 | TComMv m_acNBDV; // DV from NBDV |
---|
[1217] | 66 | #if NH_3D_NBDV_REF |
---|
[608] | 67 | TComMv m_acDoNBDV; // DV from DoNBDV |
---|
| 68 | #endif |
---|
| 69 | Int m_aVIdxCan; // View order index (the same with the NBDV and the DoNBDV) |
---|
[100] | 70 | } DisInfo; |
---|
[332] | 71 | |
---|
[608] | 72 | typedef struct _IDVCand // IDV |
---|
[332] | 73 | { |
---|
[608] | 74 | TComMv m_acMvCand[2][ IDV_CANDS ]; |
---|
| 75 | Int m_aVIdxCan[2][ IDV_CANDS ]; |
---|
| 76 | Bool m_bAvailab[2][ IDV_CANDS ]; |
---|
| 77 | Bool m_bFound; |
---|
| 78 | } IDVInfo; |
---|
| 79 | #endif |
---|
[1084] | 80 | |
---|
[608] | 81 | // ==================================================================================================================== |
---|
[2] | 82 | // Class definition |
---|
| 83 | // ==================================================================================================================== |
---|
| 84 | |
---|
| 85 | /// class for motion vector with reference index |
---|
| 86 | class TComMvField |
---|
| 87 | { |
---|
| 88 | private: |
---|
| 89 | TComMv m_acMv; |
---|
| 90 | Int m_iRefIdx; |
---|
| 91 | |
---|
| 92 | public: |
---|
[56] | 93 | TComMvField() : m_iRefIdx( NOT_VALID ) {} |
---|
[2] | 94 | |
---|
[56] | 95 | Void setMvField( TComMv const & cMv, Int iRefIdx ) |
---|
[2] | 96 | { |
---|
| 97 | m_acMv = cMv; |
---|
| 98 | m_iRefIdx = iRefIdx; |
---|
| 99 | } |
---|
| 100 | |
---|
[56] | 101 | Void setRefIdx( Int refIdx ) { m_iRefIdx = refIdx; } |
---|
[2] | 102 | |
---|
[56] | 103 | TComMv const & getMv() const { return m_acMv; } |
---|
| 104 | TComMv & getMv() { return m_acMv; } |
---|
| 105 | |
---|
| 106 | Int getRefIdx() const { return m_iRefIdx; } |
---|
| 107 | Int getHor () const { return m_acMv.getHor(); } |
---|
| 108 | Int getVer () const { return m_acMv.getVer(); } |
---|
[608] | 109 | #if H_3D_IV_MERGE |
---|
[189] | 110 | Bool operator== ( const TComMvField& rcMv ) const |
---|
| 111 | { |
---|
| 112 | return (m_acMv.getHor()==rcMv.getHor() && m_acMv.getVer()==rcMv.getVer() && m_iRefIdx == rcMv.getRefIdx()); |
---|
| 113 | } |
---|
| 114 | #endif |
---|
[2] | 115 | }; |
---|
| 116 | |
---|
| 117 | /// class for motion information in one CU |
---|
| 118 | class TComCUMvField |
---|
| 119 | { |
---|
| 120 | private: |
---|
| 121 | TComMv* m_pcMv; |
---|
| 122 | TComMv* m_pcMvd; |
---|
[56] | 123 | Char* m_piRefIdx; |
---|
[2] | 124 | UInt m_uiNumPartition; |
---|
| 125 | AMVPInfo m_cAMVPInfo; |
---|
[56] | 126 | |
---|
| 127 | template <typename T> |
---|
| 128 | Void setAll( T *p, T const & val, PartSize eCUMode, Int iPartAddr, UInt uiDepth, Int iPartIdx ); |
---|
| 129 | |
---|
[2] | 130 | public: |
---|
[56] | 131 | TComCUMvField() : m_pcMv(NULL), m_pcMvd(NULL), m_piRefIdx(NULL), m_uiNumPartition(0) {} |
---|
| 132 | ~TComCUMvField() {} |
---|
| 133 | |
---|
[2] | 134 | // ------------------------------------------------------------------------------------------------------------------ |
---|
| 135 | // create / destroy |
---|
| 136 | // ------------------------------------------------------------------------------------------------------------------ |
---|
| 137 | |
---|
[56] | 138 | Void create( UInt uiNumPartition ); |
---|
| 139 | Void destroy(); |
---|
[2] | 140 | |
---|
| 141 | // ------------------------------------------------------------------------------------------------------------------ |
---|
| 142 | // clear / copy |
---|
| 143 | // ------------------------------------------------------------------------------------------------------------------ |
---|
[56] | 144 | |
---|
| 145 | Void clearMvField(); |
---|
[2] | 146 | |
---|
[56] | 147 | Void copyFrom( TComCUMvField const * pcCUMvFieldSrc, Int iNumPartSrc, Int iPartAddrDst ); |
---|
| 148 | Void copyTo ( TComCUMvField* pcCUMvFieldDst, Int iPartAddrDst ) const; |
---|
| 149 | Void copyTo ( TComCUMvField* pcCUMvFieldDst, Int iPartAddrDst, UInt uiOffset, UInt uiNumPart ) const; |
---|
[2] | 150 | |
---|
| 151 | // ------------------------------------------------------------------------------------------------------------------ |
---|
| 152 | // get |
---|
| 153 | // ------------------------------------------------------------------------------------------------------------------ |
---|
| 154 | |
---|
[56] | 155 | TComMv const & getMv ( Int iIdx ) const { return m_pcMv [iIdx]; } |
---|
| 156 | TComMv const & getMvd ( Int iIdx ) const { return m_pcMvd [iIdx]; } |
---|
| 157 | Int getRefIdx( Int iIdx ) const { return m_piRefIdx[iIdx]; } |
---|
[2] | 158 | |
---|
| 159 | AMVPInfo* getAMVPInfo () { return &m_cAMVPInfo; } |
---|
[56] | 160 | |
---|
[2] | 161 | // ------------------------------------------------------------------------------------------------------------------ |
---|
| 162 | // set |
---|
| 163 | // ------------------------------------------------------------------------------------------------------------------ |
---|
| 164 | |
---|
[56] | 165 | Void setAllMv ( TComMv const & rcMv, PartSize eCUMode, Int iPartAddr, UInt uiDepth, Int iPartIdx=0 ); |
---|
| 166 | Void setAllMvd ( TComMv const & rcMvd, PartSize eCUMode, Int iPartAddr, UInt uiDepth, Int iPartIdx=0 ); |
---|
| 167 | Void setAllRefIdx ( Int iRefIdx, PartSize eMbMode, Int iPartAddr, UInt uiDepth, Int iPartIdx=0 ); |
---|
| 168 | Void setAllMvField( TComMvField const & mvField, PartSize eMbMode, Int iPartAddr, UInt uiDepth, Int iPartIdx=0 ); |
---|
[773] | 169 | #if H_3D_SPIVMP |
---|
[724] | 170 | Void setMvFieldSP ( TComDataCU* pcCU, UInt uiAbsPartIdx, TComMvField cMvField, Int iWidth, Int iHeight ); |
---|
| 171 | #endif |
---|
[884] | 172 | #if H_3D_VSP |
---|
[833] | 173 | Void setMv ( Int iIdx, TComMv const & rcMv ) { m_pcMv[iIdx] = rcMv; } |
---|
| 174 | Void setRefIdx ( Int iIdx, Int iRefIdx ) { m_piRefIdx[iIdx] = iRefIdx; } |
---|
| 175 | #endif |
---|
[56] | 176 | |
---|
| 177 | Void setNumPartition( Int iNumPart ) |
---|
| 178 | { |
---|
| 179 | m_uiNumPartition = iNumPart; |
---|
| 180 | } |
---|
[2] | 181 | |
---|
[56] | 182 | Void linkToWithOffset( TComCUMvField const * src, Int offset ) |
---|
| 183 | { |
---|
| 184 | m_pcMv = src->m_pcMv + offset; |
---|
| 185 | m_pcMvd = src->m_pcMvd + offset; |
---|
| 186 | m_piRefIdx = src->m_piRefIdx + offset; |
---|
| 187 | } |
---|
[2] | 188 | |
---|
[56] | 189 | Void compress(Char* pePredMode, Int scale); |
---|
[2] | 190 | }; |
---|
| 191 | |
---|
[56] | 192 | //! \} |
---|
| 193 | |
---|
[1233] | 194 | #if NH_3D_MLC |
---|
| 195 | /// class for container of merge candidate |
---|
[950] | 196 | class TComMotionCand |
---|
| 197 | { |
---|
| 198 | public: |
---|
| 199 | Bool m_bAvailable; |
---|
| 200 | TComMvField m_cMvField[2]; |
---|
| 201 | UChar m_uDir; |
---|
| 202 | #if H_3D_VSP |
---|
| 203 | Int m_iVspFlag; |
---|
| 204 | #endif |
---|
[1233] | 205 | #if H_3D_SPIVMP |
---|
[950] | 206 | Bool m_bSPIVMPFlag; |
---|
[1233] | 207 | #endif |
---|
[950] | 208 | |
---|
| 209 | public: |
---|
| 210 | TComMotionCand() |
---|
| 211 | { |
---|
| 212 | m_bAvailable = false; |
---|
| 213 | m_uDir = 0; |
---|
| 214 | #if H_3D_VSP |
---|
| 215 | m_iVspFlag = 0; |
---|
| 216 | #endif |
---|
[1233] | 217 | #if H_3D_SPIVMP |
---|
[950] | 218 | m_bSPIVMPFlag = false; |
---|
[1233] | 219 | #endif |
---|
[950] | 220 | } |
---|
| 221 | |
---|
| 222 | ~TComMotionCand() |
---|
| 223 | { |
---|
| 224 | |
---|
| 225 | } |
---|
| 226 | |
---|
| 227 | Void init() |
---|
| 228 | { |
---|
| 229 | TComMv cZeroMv; |
---|
| 230 | |
---|
| 231 | m_bAvailable = false; |
---|
| 232 | m_uDir = 0; |
---|
| 233 | #if H_3D_VSP |
---|
| 234 | m_iVspFlag = 0; |
---|
| 235 | #endif |
---|
[1233] | 236 | #if H_3D_SPIVMP |
---|
[950] | 237 | m_bSPIVMPFlag = false; |
---|
[1233] | 238 | #endif |
---|
[950] | 239 | m_cMvField[0].setMvField(cZeroMv, NOT_VALID); |
---|
| 240 | m_cMvField[1].setMvField(cZeroMv, NOT_VALID); |
---|
| 241 | } |
---|
| 242 | |
---|
| 243 | Void setCand(TComMvField* pcMvFieldNeighbours, UChar uhInterDirNeighbours |
---|
| 244 | #if H_3D_VSP |
---|
| 245 | , Int vspFlag |
---|
| 246 | #endif |
---|
[1233] | 247 | #if H_3D_SPIVMP |
---|
[950] | 248 | , Bool bSPIVMPFlag |
---|
[1233] | 249 | #endif |
---|
[950] | 250 | ) |
---|
| 251 | { |
---|
| 252 | m_bAvailable = true; |
---|
| 253 | m_cMvField[0] = pcMvFieldNeighbours[0]; |
---|
| 254 | m_cMvField[1] = pcMvFieldNeighbours[1]; |
---|
| 255 | m_uDir = uhInterDirNeighbours; |
---|
| 256 | #if H_3D_VSP |
---|
| 257 | m_iVspFlag = vspFlag; |
---|
| 258 | #endif |
---|
[1233] | 259 | #if H_3D_SPIVMP |
---|
[950] | 260 | m_bSPIVMPFlag = bSPIVMPFlag; |
---|
[1233] | 261 | #endif |
---|
[950] | 262 | } |
---|
[1233] | 263 | |
---|
[950] | 264 | Void getCand(Int iCount, TComMvField* pcMvFieldNeighbours, UChar* puhInterDirNeighbours |
---|
| 265 | #if H_3D_VSP |
---|
| 266 | , Int* vspFlag |
---|
| 267 | #endif |
---|
[1233] | 268 | #if H_3D_SPIVMP |
---|
[950] | 269 | , Bool* pbSPIVMPFlag |
---|
[1233] | 270 | #endif |
---|
[950] | 271 | ) |
---|
| 272 | { |
---|
| 273 | pcMvFieldNeighbours[iCount<<1] = m_cMvField[0]; |
---|
| 274 | pcMvFieldNeighbours[(iCount<<1) + 1] = m_cMvField[1]; |
---|
| 275 | puhInterDirNeighbours[iCount] = m_uDir; |
---|
| 276 | #if H_3D_VSP |
---|
| 277 | vspFlag[iCount] = m_iVspFlag; |
---|
| 278 | #endif |
---|
[1233] | 279 | #if H_3D_SPIVMP |
---|
[950] | 280 | pbSPIVMPFlag[iCount] = m_bSPIVMPFlag; |
---|
[1233] | 281 | #endif |
---|
[950] | 282 | } |
---|
| 283 | }; |
---|
| 284 | #endif |
---|
| 285 | |
---|
| 286 | |
---|
[2] | 287 | #endif // __TCOMMOTIONINFO__ |
---|