[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 | * |
---|
[872] | 6 | * Copyright (c) 2010-2014, 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 | |
---|
[608] | 62 | #if H_3D_NBDV |
---|
| 63 | typedef struct _DisCand |
---|
[100] | 64 | { |
---|
[443] | 65 | Bool bDV; |
---|
[608] | 66 | TComMv m_acNBDV; // DV from NBDV |
---|
| 67 | #if H_3D_NBDV_REF |
---|
| 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(); } |
---|
[608] | 110 | #if H_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 ); |
---|
[773] | 170 | #if H_3D_SPIVMP |
---|
[724] | 171 | Void setMvFieldSP ( TComDataCU* pcCU, UInt uiAbsPartIdx, TComMvField cMvField, Int iWidth, Int iHeight ); |
---|
| 172 | #endif |
---|
[884] | 173 | #if H_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); |
---|
[2] | 191 | }; |
---|
| 192 | |
---|
[56] | 193 | //! \} |
---|
| 194 | |
---|
[976] | 195 | #if H_3D_IV_MERGE |
---|
[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 |
---|
| 205 | Bool m_bSPIVMPFlag; |
---|
| 206 | |
---|
| 207 | public: |
---|
| 208 | TComMotionCand() |
---|
| 209 | { |
---|
| 210 | m_bAvailable = false; |
---|
| 211 | m_uDir = 0; |
---|
| 212 | #if H_3D_VSP |
---|
| 213 | m_iVspFlag = 0; |
---|
| 214 | #endif |
---|
| 215 | m_bSPIVMPFlag = false; |
---|
| 216 | } |
---|
| 217 | |
---|
| 218 | ~TComMotionCand() |
---|
| 219 | { |
---|
| 220 | |
---|
| 221 | } |
---|
| 222 | |
---|
| 223 | Void init() |
---|
| 224 | { |
---|
| 225 | TComMv cZeroMv; |
---|
| 226 | |
---|
| 227 | m_bAvailable = false; |
---|
| 228 | m_uDir = 0; |
---|
| 229 | #if H_3D_VSP |
---|
| 230 | m_iVspFlag = 0; |
---|
| 231 | #endif |
---|
| 232 | m_bSPIVMPFlag = false; |
---|
| 233 | m_cMvField[0].setMvField(cZeroMv, NOT_VALID); |
---|
| 234 | m_cMvField[1].setMvField(cZeroMv, NOT_VALID); |
---|
| 235 | } |
---|
| 236 | |
---|
| 237 | Void setCand(TComMvField* pcMvFieldNeighbours, UChar uhInterDirNeighbours |
---|
| 238 | #if H_3D_VSP |
---|
| 239 | , Int vspFlag |
---|
| 240 | #endif |
---|
| 241 | , Bool bSPIVMPFlag |
---|
| 242 | ) |
---|
| 243 | { |
---|
| 244 | m_bAvailable = true; |
---|
| 245 | m_cMvField[0] = pcMvFieldNeighbours[0]; |
---|
| 246 | m_cMvField[1] = pcMvFieldNeighbours[1]; |
---|
| 247 | m_uDir = uhInterDirNeighbours; |
---|
| 248 | #if H_3D_VSP |
---|
| 249 | m_iVspFlag = vspFlag; |
---|
| 250 | #endif |
---|
| 251 | m_bSPIVMPFlag = bSPIVMPFlag; |
---|
| 252 | } |
---|
| 253 | |
---|
| 254 | |
---|
| 255 | Void getCand(Int iCount, TComMvField* pcMvFieldNeighbours, UChar* puhInterDirNeighbours |
---|
| 256 | #if H_3D_VSP |
---|
| 257 | , Int* vspFlag |
---|
| 258 | #endif |
---|
| 259 | , Bool* pbSPIVMPFlag |
---|
| 260 | ) |
---|
| 261 | { |
---|
| 262 | pcMvFieldNeighbours[iCount<<1] = m_cMvField[0]; |
---|
| 263 | pcMvFieldNeighbours[(iCount<<1) + 1] = m_cMvField[1]; |
---|
| 264 | puhInterDirNeighbours[iCount] = m_uDir; |
---|
| 265 | #if H_3D_VSP |
---|
| 266 | vspFlag[iCount] = m_iVspFlag; |
---|
| 267 | #endif |
---|
| 268 | pbSPIVMPFlag[iCount] = m_bSPIVMPFlag; |
---|
| 269 | } |
---|
| 270 | }; |
---|
| 271 | #endif |
---|
| 272 | |
---|
| 273 | |
---|
[2] | 274 | #endif // __TCOMMOTIONINFO__ |
---|