[313] | 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 |
---|
[1029] | 4 | * granted under this license. |
---|
[313] | 5 | * |
---|
[1259] | 6 | * Copyright (c) 2010-2015, ITU/ISO/IEC |
---|
[313] | 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. |
---|
| 17 | * * Neither the name of the ITU/ISO/IEC nor the names of its contributors may |
---|
| 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 | */ |
---|
| 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 | |
---|
| 46 | //! \ingroup TLibCommon |
---|
| 47 | //! \{ |
---|
| 48 | |
---|
| 49 | // ==================================================================================================================== |
---|
| 50 | // Type definition |
---|
| 51 | // ==================================================================================================================== |
---|
| 52 | |
---|
| 53 | /// parameters for AMVP |
---|
| 54 | typedef struct _AMVPInfo |
---|
| 55 | { |
---|
[1465] | 56 | TComMv m_acMvCand[ AMVP_MAX_NUM_CANDS ]; ///< array of motion vector predictor candidates |
---|
[313] | 57 | Int iN; ///< number of motion vector predictor candidates |
---|
| 58 | } AMVPInfo; |
---|
| 59 | |
---|
| 60 | // ==================================================================================================================== |
---|
| 61 | // Class definition |
---|
| 62 | // ==================================================================================================================== |
---|
| 63 | |
---|
| 64 | /// class for motion vector with reference index |
---|
| 65 | class TComMvField |
---|
| 66 | { |
---|
| 67 | private: |
---|
| 68 | TComMv m_acMv; |
---|
| 69 | Int m_iRefIdx; |
---|
[1029] | 70 | |
---|
[313] | 71 | public: |
---|
| 72 | TComMvField() : m_iRefIdx( NOT_VALID ) {} |
---|
[1029] | 73 | |
---|
[313] | 74 | Void setMvField( TComMv const & cMv, Int iRefIdx ) |
---|
| 75 | { |
---|
| 76 | m_acMv = cMv; |
---|
| 77 | m_iRefIdx = iRefIdx; |
---|
| 78 | } |
---|
[1029] | 79 | |
---|
[313] | 80 | Void setRefIdx( Int refIdx ) { m_iRefIdx = refIdx; } |
---|
[1029] | 81 | |
---|
[313] | 82 | TComMv const & getMv() const { return m_acMv; } |
---|
| 83 | TComMv & getMv() { return m_acMv; } |
---|
[1029] | 84 | |
---|
[313] | 85 | Int getRefIdx() const { return m_iRefIdx; } |
---|
| 86 | Int getHor () const { return m_acMv.getHor(); } |
---|
| 87 | Int getVer () const { return m_acMv.getVer(); } |
---|
| 88 | }; |
---|
| 89 | |
---|
| 90 | /// class for motion information in one CU |
---|
| 91 | class TComCUMvField |
---|
| 92 | { |
---|
| 93 | private: |
---|
| 94 | TComMv* m_pcMv; |
---|
| 95 | TComMv* m_pcMvd; |
---|
[1442] | 96 | SChar* m_piRefIdx; |
---|
[313] | 97 | UInt m_uiNumPartition; |
---|
| 98 | AMVPInfo m_cAMVPInfo; |
---|
[1029] | 99 | |
---|
[313] | 100 | template <typename T> |
---|
| 101 | Void setAll( T *p, T const & val, PartSize eCUMode, Int iPartAddr, UInt uiDepth, Int iPartIdx ); |
---|
| 102 | |
---|
| 103 | public: |
---|
| 104 | TComCUMvField() : m_pcMv(NULL), m_pcMvd(NULL), m_piRefIdx(NULL), m_uiNumPartition(0) {} |
---|
| 105 | ~TComCUMvField() {} |
---|
| 106 | |
---|
| 107 | // ------------------------------------------------------------------------------------------------------------------ |
---|
| 108 | // create / destroy |
---|
| 109 | // ------------------------------------------------------------------------------------------------------------------ |
---|
[1029] | 110 | |
---|
[313] | 111 | Void create( UInt uiNumPartition ); |
---|
| 112 | Void destroy(); |
---|
[1029] | 113 | |
---|
[313] | 114 | // ------------------------------------------------------------------------------------------------------------------ |
---|
| 115 | // clear / copy |
---|
| 116 | // ------------------------------------------------------------------------------------------------------------------ |
---|
| 117 | |
---|
| 118 | Void clearMvField(); |
---|
[1029] | 119 | |
---|
[313] | 120 | Void copyFrom( TComCUMvField const * pcCUMvFieldSrc, Int iNumPartSrc, Int iPartAddrDst ); |
---|
| 121 | Void copyTo ( TComCUMvField* pcCUMvFieldDst, Int iPartAddrDst ) const; |
---|
| 122 | Void copyTo ( TComCUMvField* pcCUMvFieldDst, Int iPartAddrDst, UInt uiOffset, UInt uiNumPart ) const; |
---|
[1029] | 123 | |
---|
[313] | 124 | // ------------------------------------------------------------------------------------------------------------------ |
---|
| 125 | // get |
---|
| 126 | // ------------------------------------------------------------------------------------------------------------------ |
---|
[1029] | 127 | |
---|
[313] | 128 | TComMv const & getMv ( Int iIdx ) const { return m_pcMv [iIdx]; } |
---|
| 129 | TComMv const & getMvd ( Int iIdx ) const { return m_pcMvd [iIdx]; } |
---|
| 130 | Int getRefIdx( Int iIdx ) const { return m_piRefIdx[iIdx]; } |
---|
[1029] | 131 | |
---|
[313] | 132 | AMVPInfo* getAMVPInfo () { return &m_cAMVPInfo; } |
---|
[1029] | 133 | |
---|
[313] | 134 | // ------------------------------------------------------------------------------------------------------------------ |
---|
| 135 | // set |
---|
| 136 | // ------------------------------------------------------------------------------------------------------------------ |
---|
[1029] | 137 | |
---|
[313] | 138 | Void setAllMv ( TComMv const & rcMv, PartSize eCUMode, Int iPartAddr, UInt uiDepth, Int iPartIdx=0 ); |
---|
| 139 | Void setAllMvd ( TComMv const & rcMvd, PartSize eCUMode, Int iPartAddr, UInt uiDepth, Int iPartIdx=0 ); |
---|
| 140 | Void setAllRefIdx ( Int iRefIdx, PartSize eMbMode, Int iPartAddr, UInt uiDepth, Int iPartIdx=0 ); |
---|
| 141 | Void setAllMvField( TComMvField const & mvField, PartSize eMbMode, Int iPartAddr, UInt uiDepth, Int iPartIdx=0 ); |
---|
| 142 | |
---|
| 143 | Void setNumPartition( Int iNumPart ) |
---|
| 144 | { |
---|
| 145 | m_uiNumPartition = iNumPart; |
---|
| 146 | } |
---|
[1029] | 147 | |
---|
[313] | 148 | Void linkToWithOffset( TComCUMvField const * src, Int offset ) |
---|
| 149 | { |
---|
| 150 | m_pcMv = src->m_pcMv + offset; |
---|
| 151 | m_pcMvd = src->m_pcMvd + offset; |
---|
| 152 | m_piRefIdx = src->m_piRefIdx + offset; |
---|
| 153 | } |
---|
| 154 | |
---|
[1442] | 155 | Void compress(SChar* pePredMode, Int scale); |
---|
[1029] | 156 | |
---|
[1226] | 157 | #if SVC_EXTENSION |
---|
[313] | 158 | Void setMvField( TComMvField const& mvField, Int iIdx ) |
---|
| 159 | { |
---|
| 160 | m_pcMv[iIdx] = mvField.getMv(); |
---|
| 161 | m_piRefIdx[iIdx] = mvField.getRefIdx(); |
---|
| 162 | return; |
---|
| 163 | } |
---|
| 164 | |
---|
| 165 | Void setMvField( TComMv cMv, Int iRefIdx, Int iIdx ) |
---|
| 166 | { |
---|
| 167 | m_pcMv[iIdx] = cMv; |
---|
| 168 | m_piRefIdx[iIdx] = iRefIdx; |
---|
| 169 | return; |
---|
| 170 | } |
---|
| 171 | #endif |
---|
| 172 | }; |
---|
| 173 | |
---|
| 174 | //! \} |
---|
| 175 | |
---|
| 176 | #endif // __TCOMMOTIONINFO__ |
---|