[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 | * |
---|
[56] | 6 | * Copyright (c) 2010-2012, 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" |
---|
| 45 | |
---|
[56] | 46 | //! \ingroup TLibCommon |
---|
| 47 | //! \{ |
---|
| 48 | |
---|
[2] | 49 | // ==================================================================================================================== |
---|
| 50 | // Type definition |
---|
| 51 | // ==================================================================================================================== |
---|
| 52 | |
---|
| 53 | /// parameters for AMVP |
---|
| 54 | typedef struct _AMVPInfo |
---|
| 55 | { |
---|
[56] | 56 | TComMv m_acMvCand[ AMVP_MAX_NUM_CANDS_MEM ]; ///< array of motion vector predictor candidates |
---|
[2] | 57 | Int iN; ///< number of motion vector predictor candidates |
---|
| 58 | } AMVPInfo; |
---|
| 59 | |
---|
| 60 | // ==================================================================================================================== |
---|
[296] | 61 | #if H3D_NBDV |
---|
[100] | 62 | typedef struct _DisCand |
---|
| 63 | { |
---|
| 64 | TComMv m_acMvCand[ DIS_CANS ]; ///< array of motion vector predictor candidates |
---|
| 65 | Int m_aVIdxCan[ DIS_CANS ]; ///< array of motion vector predictor candidates |
---|
[443] | 66 | #if QC_CU_NBDV_D0181 |
---|
| 67 | Bool bDV; |
---|
| 68 | #if MERL_VSP_C0152 |
---|
| 69 | TComMv m_acMvCandNoRef[ DIS_CANS ]; |
---|
| 70 | #endif |
---|
| 71 | #endif |
---|
[100] | 72 | Int iN; ///< number of motion vector predictor candidates |
---|
[443] | 73 | #if MERL_VSP_NBDV_RefVId_Fix_D0166 |
---|
| 74 | Int m_aListIdx[ DIS_CANS ]; ///< array of reference list of derived NBDV |
---|
| 75 | Int m_aRefIdx [ DIS_CANS ]; ///< array of reference frame index corresponding to either RefList0/1 |
---|
| 76 | #endif |
---|
[100] | 77 | } DisInfo; |
---|
[332] | 78 | |
---|
| 79 | typedef struct _McpDisCand |
---|
| 80 | { |
---|
| 81 | TComMv m_acMvCand[2][ MCP_DIS_CANS ]; ///< array of motion vector predictor candidates |
---|
| 82 | Int m_aVIdxCan[2][ MCP_DIS_CANS ]; ///< array of motion vector predictor candidates |
---|
| 83 | Bool m_bAvailab[2][ MCP_DIS_CANS ]; |
---|
| 84 | Bool m_bFound; ///< number of motion vector predictor candidates |
---|
| 85 | } McpDisInfo; |
---|
| 86 | |
---|
[100] | 87 | #endif |
---|
[2] | 88 | // Class definition |
---|
| 89 | // ==================================================================================================================== |
---|
| 90 | |
---|
| 91 | /// class for motion vector with reference index |
---|
| 92 | class TComMvField |
---|
| 93 | { |
---|
| 94 | private: |
---|
| 95 | TComMv m_acMv; |
---|
| 96 | Int m_iRefIdx; |
---|
| 97 | |
---|
| 98 | public: |
---|
[56] | 99 | TComMvField() : m_iRefIdx( NOT_VALID ) {} |
---|
[2] | 100 | |
---|
[56] | 101 | Void setMvField( TComMv const & cMv, Int iRefIdx ) |
---|
[2] | 102 | { |
---|
| 103 | m_acMv = cMv; |
---|
| 104 | m_iRefIdx = iRefIdx; |
---|
| 105 | } |
---|
| 106 | |
---|
[56] | 107 | Void setRefIdx( Int refIdx ) { m_iRefIdx = refIdx; } |
---|
[2] | 108 | |
---|
[56] | 109 | TComMv const & getMv() const { return m_acMv; } |
---|
| 110 | TComMv & getMv() { return m_acMv; } |
---|
| 111 | |
---|
| 112 | Int getRefIdx() const { return m_iRefIdx; } |
---|
| 113 | Int getHor () const { return m_acMv.getHor(); } |
---|
| 114 | Int getVer () const { return m_acMv.getVer(); } |
---|
[296] | 115 | #if H3D_IVMP |
---|
[189] | 116 | Bool operator== ( const TComMvField& rcMv ) const |
---|
| 117 | { |
---|
| 118 | return (m_acMv.getHor()==rcMv.getHor() && m_acMv.getVer()==rcMv.getVer() && m_iRefIdx == rcMv.getRefIdx()); |
---|
| 119 | } |
---|
| 120 | #endif |
---|
[2] | 121 | }; |
---|
| 122 | |
---|
| 123 | /// class for motion information in one CU |
---|
| 124 | class TComCUMvField |
---|
| 125 | { |
---|
| 126 | private: |
---|
| 127 | TComMv* m_pcMv; |
---|
| 128 | TComMv* m_pcMvd; |
---|
[56] | 129 | Char* m_piRefIdx; |
---|
[2] | 130 | UInt m_uiNumPartition; |
---|
| 131 | AMVPInfo m_cAMVPInfo; |
---|
[56] | 132 | |
---|
| 133 | template <typename T> |
---|
| 134 | Void setAll( T *p, T const & val, PartSize eCUMode, Int iPartAddr, UInt uiDepth, Int iPartIdx ); |
---|
| 135 | |
---|
[2] | 136 | public: |
---|
[56] | 137 | TComCUMvField() : m_pcMv(NULL), m_pcMvd(NULL), m_piRefIdx(NULL), m_uiNumPartition(0) {} |
---|
| 138 | ~TComCUMvField() {} |
---|
| 139 | |
---|
[2] | 140 | // ------------------------------------------------------------------------------------------------------------------ |
---|
| 141 | // create / destroy |
---|
| 142 | // ------------------------------------------------------------------------------------------------------------------ |
---|
| 143 | |
---|
[56] | 144 | Void create( UInt uiNumPartition ); |
---|
| 145 | Void destroy(); |
---|
[2] | 146 | |
---|
| 147 | // ------------------------------------------------------------------------------------------------------------------ |
---|
| 148 | // clear / copy |
---|
| 149 | // ------------------------------------------------------------------------------------------------------------------ |
---|
[56] | 150 | |
---|
| 151 | Void clearMvField(); |
---|
[2] | 152 | |
---|
[56] | 153 | Void copyFrom( TComCUMvField const * pcCUMvFieldSrc, Int iNumPartSrc, Int iPartAddrDst ); |
---|
| 154 | Void copyTo ( TComCUMvField* pcCUMvFieldDst, Int iPartAddrDst ) const; |
---|
| 155 | Void copyTo ( TComCUMvField* pcCUMvFieldDst, Int iPartAddrDst, UInt uiOffset, UInt uiNumPart ) const; |
---|
[2] | 156 | |
---|
| 157 | // ------------------------------------------------------------------------------------------------------------------ |
---|
| 158 | // get |
---|
| 159 | // ------------------------------------------------------------------------------------------------------------------ |
---|
| 160 | |
---|
[56] | 161 | TComMv const & getMv ( Int iIdx ) const { return m_pcMv [iIdx]; } |
---|
| 162 | TComMv const & getMvd ( Int iIdx ) const { return m_pcMvd [iIdx]; } |
---|
| 163 | Int getRefIdx( Int iIdx ) const { return m_piRefIdx[iIdx]; } |
---|
[2] | 164 | |
---|
| 165 | AMVPInfo* getAMVPInfo () { return &m_cAMVPInfo; } |
---|
[56] | 166 | |
---|
[2] | 167 | // ------------------------------------------------------------------------------------------------------------------ |
---|
| 168 | // set |
---|
| 169 | // ------------------------------------------------------------------------------------------------------------------ |
---|
| 170 | |
---|
[56] | 171 | Void setAllMv ( TComMv const & rcMv, PartSize eCUMode, Int iPartAddr, UInt uiDepth, Int iPartIdx=0 ); |
---|
| 172 | Void setAllMvd ( TComMv const & rcMvd, PartSize eCUMode, Int iPartAddr, UInt uiDepth, Int iPartIdx=0 ); |
---|
| 173 | Void setAllRefIdx ( Int iRefIdx, PartSize eMbMode, Int iPartAddr, UInt uiDepth, Int iPartIdx=0 ); |
---|
| 174 | Void setAllMvField( TComMvField const & mvField, PartSize eMbMode, Int iPartAddr, UInt uiDepth, Int iPartIdx=0 ); |
---|
| 175 | |
---|
| 176 | Void setNumPartition( Int iNumPart ) |
---|
| 177 | { |
---|
| 178 | m_uiNumPartition = iNumPart; |
---|
| 179 | } |
---|
[2] | 180 | |
---|
[56] | 181 | Void linkToWithOffset( TComCUMvField const * src, Int offset ) |
---|
| 182 | { |
---|
| 183 | m_pcMv = src->m_pcMv + offset; |
---|
| 184 | m_pcMvd = src->m_pcMvd + offset; |
---|
| 185 | m_piRefIdx = src->m_piRefIdx + offset; |
---|
| 186 | } |
---|
[2] | 187 | |
---|
[56] | 188 | #if HHI_MPI |
---|
| 189 | Void compress(Char* pePredMode, UChar* puhInterDir, Int scale); |
---|
| 190 | #else |
---|
| 191 | Void compress(Char* pePredMode, Int scale); |
---|
| 192 | #endif |
---|
| 193 | #if HHI_FULL_PEL_DEPTH_MAP_MV_ACC |
---|
| 194 | Void decreaseMvAccuracy( Int iPartAddr, Int iNumPart, Int iShift ); |
---|
| 195 | #endif |
---|
[189] | 196 | |
---|
| 197 | #if MTK_UNCONSTRAINED_MVI_B0083 |
---|
| 198 | Void setUndefinedMv( Int iPartAddr, Int iNumPart, Char* pePredMode, UChar* puhInterDir, Int refIdx, Int InterDir ); |
---|
| 199 | #endif |
---|
[2] | 200 | }; |
---|
| 201 | |
---|
[56] | 202 | //! \} |
---|
| 203 | |
---|
[2] | 204 | #endif // __TCOMMOTIONINFO__ |
---|