[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 |
---|
| 4 | * granted under this license. |
---|
| 5 | * |
---|
[595] | 6 | * Copyright (c) 2010-2014, 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 TComDataCU.h |
---|
| 35 | \brief CU data structure (header) |
---|
| 36 | \todo not all entities are documented |
---|
| 37 | */ |
---|
| 38 | |
---|
| 39 | #ifndef _TCOMDATACU_ |
---|
| 40 | #define _TCOMDATACU_ |
---|
| 41 | |
---|
| 42 | #include <assert.h> |
---|
| 43 | |
---|
| 44 | // Include files |
---|
| 45 | #include "CommonDef.h" |
---|
| 46 | #include "TComMotionInfo.h" |
---|
| 47 | #include "TComSlice.h" |
---|
| 48 | #include "TComRdCost.h" |
---|
| 49 | #include "TComPattern.h" |
---|
| 50 | |
---|
| 51 | #include <algorithm> |
---|
| 52 | #include <vector> |
---|
| 53 | |
---|
| 54 | //! \ingroup TLibCommon |
---|
| 55 | //! \{ |
---|
| 56 | |
---|
| 57 | // ==================================================================================================================== |
---|
| 58 | // Class definition |
---|
| 59 | // ==================================================================================================================== |
---|
| 60 | |
---|
| 61 | /// CU data structure class |
---|
| 62 | class TComDataCU |
---|
| 63 | { |
---|
| 64 | private: |
---|
| 65 | |
---|
| 66 | // ------------------------------------------------------------------------------------------------------------------- |
---|
| 67 | // class pointers |
---|
| 68 | // ------------------------------------------------------------------------------------------------------------------- |
---|
| 69 | |
---|
| 70 | TComPic* m_pcPic; ///< picture class pointer |
---|
| 71 | TComSlice* m_pcSlice; ///< slice header pointer |
---|
| 72 | TComPattern* m_pcPattern; ///< neighbour access class pointer |
---|
| 73 | |
---|
| 74 | // ------------------------------------------------------------------------------------------------------------------- |
---|
| 75 | // CU description |
---|
| 76 | // ------------------------------------------------------------------------------------------------------------------- |
---|
| 77 | |
---|
| 78 | UInt m_uiCUAddr; ///< CU address in a slice |
---|
| 79 | UInt m_uiAbsIdxInLCU; ///< absolute address in a CU. It's Z scan order |
---|
| 80 | UInt m_uiCUPelX; ///< CU position in a pixel (X) |
---|
| 81 | UInt m_uiCUPelY; ///< CU position in a pixel (Y) |
---|
| 82 | UInt m_uiNumPartition; ///< total number of minimum partitions in a CU |
---|
| 83 | UChar* m_puhWidth; ///< array of widths |
---|
| 84 | UChar* m_puhHeight; ///< array of heights |
---|
| 85 | UChar* m_puhDepth; ///< array of depths |
---|
| 86 | Int m_unitSize; ///< size of a "minimum partition" |
---|
| 87 | |
---|
| 88 | #if SVC_EXTENSION |
---|
| 89 | UInt m_layerId; ///< layer id |
---|
| 90 | #endif |
---|
| 91 | |
---|
| 92 | // ------------------------------------------------------------------------------------------------------------------- |
---|
| 93 | // CU data |
---|
| 94 | // ------------------------------------------------------------------------------------------------------------------- |
---|
| 95 | Bool* m_skipFlag; ///< array of skip flags |
---|
| 96 | Char* m_pePartSize; ///< array of partition sizes |
---|
| 97 | Char* m_pePredMode; ///< array of prediction modes |
---|
| 98 | Bool* m_CUTransquantBypass; ///< array of cu_transquant_bypass flags |
---|
| 99 | Char* m_phQP; ///< array of QP values |
---|
| 100 | UChar* m_puhTrIdx; ///< array of transform indices |
---|
| 101 | UChar* m_puhTransformSkip[3];///< array of transform skipping flags |
---|
| 102 | UChar* m_puhCbf[3]; ///< array of coded block flags (CBF) |
---|
| 103 | TComCUMvField m_acCUMvField[2]; ///< array of motion vectors |
---|
| 104 | TCoeff* m_pcTrCoeffY; ///< transformed coefficient buffer (Y) |
---|
| 105 | TCoeff* m_pcTrCoeffCb; ///< transformed coefficient buffer (Cb) |
---|
| 106 | TCoeff* m_pcTrCoeffCr; ///< transformed coefficient buffer (Cr) |
---|
| 107 | #if ADAPTIVE_QP_SELECTION |
---|
| 108 | Int* m_pcArlCoeffY; ///< ARL coefficient buffer (Y) |
---|
| 109 | Int* m_pcArlCoeffCb; ///< ARL coefficient buffer (Cb) |
---|
| 110 | Int* m_pcArlCoeffCr; ///< ARL coefficient buffer (Cr) |
---|
| 111 | Bool m_ArlCoeffIsAliasedAllocation; ///< ARL coefficient buffer is an alias of the global buffer and must not be free()'d |
---|
| 112 | |
---|
| 113 | static Int* m_pcGlbArlCoeffY; ///< ARL coefficient buffer (Y) |
---|
| 114 | static Int* m_pcGlbArlCoeffCb; ///< ARL coefficient buffer (Cb) |
---|
| 115 | static Int* m_pcGlbArlCoeffCr; ///< ARL coefficient buffer (Cr) |
---|
| 116 | #endif |
---|
| 117 | |
---|
| 118 | Pel* m_pcIPCMSampleY; ///< PCM sample buffer (Y) |
---|
| 119 | Pel* m_pcIPCMSampleCb; ///< PCM sample buffer (Cb) |
---|
| 120 | Pel* m_pcIPCMSampleCr; ///< PCM sample buffer (Cr) |
---|
| 121 | |
---|
| 122 | // ------------------------------------------------------------------------------------------------------------------- |
---|
| 123 | // neighbour access variables |
---|
| 124 | // ------------------------------------------------------------------------------------------------------------------- |
---|
| 125 | |
---|
| 126 | TComDataCU* m_pcCUAboveLeft; ///< pointer of above-left CU |
---|
| 127 | TComDataCU* m_pcCUAboveRight; ///< pointer of above-right CU |
---|
| 128 | TComDataCU* m_pcCUAbove; ///< pointer of above CU |
---|
| 129 | TComDataCU* m_pcCULeft; ///< pointer of left CU |
---|
| 130 | TComDataCU* m_apcCUColocated[2]; ///< pointer of temporally colocated CU's for both directions |
---|
| 131 | TComMvField m_cMvFieldA; ///< motion vector of position A |
---|
| 132 | TComMvField m_cMvFieldB; ///< motion vector of position B |
---|
| 133 | TComMvField m_cMvFieldC; ///< motion vector of position C |
---|
| 134 | TComMv m_cMvPred; ///< motion vector predictor |
---|
| 135 | |
---|
| 136 | // ------------------------------------------------------------------------------------------------------------------- |
---|
| 137 | // coding tool information |
---|
| 138 | // ------------------------------------------------------------------------------------------------------------------- |
---|
| 139 | |
---|
| 140 | Bool* m_pbMergeFlag; ///< array of merge flags |
---|
| 141 | UChar* m_puhMergeIndex; ///< array of merge candidate indices |
---|
| 142 | #if AMP_MRG |
---|
| 143 | Bool m_bIsMergeAMP; |
---|
| 144 | #endif |
---|
| 145 | UChar* m_puhLumaIntraDir; ///< array of intra directions (luma) |
---|
| 146 | UChar* m_puhChromaIntraDir; ///< array of intra directions (chroma) |
---|
| 147 | UChar* m_puhInterDir; ///< array of inter directions |
---|
| 148 | Char* m_apiMVPIdx[2]; ///< array of motion vector predictor candidates |
---|
| 149 | Char* m_apiMVPNum[2]; ///< array of number of possible motion vectors predictors |
---|
| 150 | Bool* m_pbIPCMFlag; ///< array of intra_pcm flags |
---|
| 151 | |
---|
| 152 | // ------------------------------------------------------------------------------------------------------------------- |
---|
| 153 | // misc. variables |
---|
| 154 | // ------------------------------------------------------------------------------------------------------------------- |
---|
| 155 | |
---|
| 156 | Bool m_bDecSubCu; ///< indicates decoder-mode |
---|
| 157 | Double m_dTotalCost; ///< sum of partition RD costs |
---|
| 158 | UInt m_uiTotalDistortion; ///< sum of partition distortion |
---|
| 159 | UInt m_uiTotalBits; ///< sum of partition bits |
---|
| 160 | UInt m_uiTotalBins; ///< sum of partition bins |
---|
| 161 | UInt* m_sliceStartCU; ///< Start CU address of current slice |
---|
| 162 | UInt* m_sliceSegmentStartCU; ///< Start CU address of current slice |
---|
| 163 | Char m_codedQP; |
---|
| 164 | protected: |
---|
| 165 | |
---|
| 166 | /// add possible motion vector predictor candidates |
---|
| 167 | Bool xAddMVPCand ( AMVPInfo* pInfo, RefPicList eRefPicList, Int iRefIdx, UInt uiPartUnitIdx, MVP_DIR eDir ); |
---|
| 168 | Bool xAddMVPCandOrder ( AMVPInfo* pInfo, RefPicList eRefPicList, Int iRefIdx, UInt uiPartUnitIdx, MVP_DIR eDir ); |
---|
| 169 | |
---|
| 170 | Void deriveRightBottomIdx ( UInt uiPartIdx, UInt& ruiPartIdxRB ); |
---|
| 171 | Bool xGetColMVP( RefPicList eRefPicList, Int uiCUAddr, Int uiPartUnitIdx, TComMv& rcMv, Int& riRefIdx ); |
---|
| 172 | |
---|
| 173 | /// compute required bits to encode MVD (used in AMVP) |
---|
| 174 | UInt xGetMvdBits ( TComMv cMvd ); |
---|
| 175 | UInt xGetComponentBits ( Int iVal ); |
---|
| 176 | |
---|
| 177 | /// compute scaling factor from POC difference |
---|
| 178 | Int xGetDistScaleFactor ( Int iCurrPOC, Int iCurrRefPOC, Int iColPOC, Int iColRefPOC ); |
---|
| 179 | |
---|
| 180 | Void xDeriveCenterIdx( UInt uiPartIdx, UInt& ruiPartIdxCenter ); |
---|
| 181 | |
---|
| 182 | public: |
---|
| 183 | TComDataCU(); |
---|
| 184 | virtual ~TComDataCU(); |
---|
| 185 | |
---|
| 186 | // ------------------------------------------------------------------------------------------------------------------- |
---|
| 187 | // create / destroy / initialize / copy |
---|
| 188 | // ------------------------------------------------------------------------------------------------------------------- |
---|
| 189 | |
---|
| 190 | Void create ( UInt uiNumPartition, UInt uiWidth, UInt uiHeight, Bool bDecSubCu, Int unitSize |
---|
| 191 | #if ADAPTIVE_QP_SELECTION |
---|
| 192 | , Bool bGlobalRMARLBuffer = false |
---|
| 193 | #endif |
---|
| 194 | ); |
---|
| 195 | Void destroy (); |
---|
| 196 | |
---|
| 197 | Void initCU ( TComPic* pcPic, UInt uiCUAddr ); |
---|
[595] | 198 | Void initEstData ( UInt uiDepth, Int qp, Bool bTransquantBypass ); |
---|
[313] | 199 | Void initSubCU ( TComDataCU* pcCU, UInt uiPartUnitIdx, UInt uiDepth, Int qp ); |
---|
| 200 | Void setOutsideCUPart ( UInt uiAbsPartIdx, UInt uiDepth ); |
---|
| 201 | |
---|
| 202 | Void copySubCU ( TComDataCU* pcCU, UInt uiPartUnitIdx, UInt uiDepth ); |
---|
| 203 | Void copyInterPredInfoFrom ( TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefPicList ); |
---|
| 204 | Void copyPartFrom ( TComDataCU* pcCU, UInt uiPartUnitIdx, UInt uiDepth ); |
---|
| 205 | |
---|
| 206 | Void copyToPic ( UChar uiDepth ); |
---|
| 207 | Void copyToPic ( UChar uiDepth, UInt uiPartIdx, UInt uiPartDepth ); |
---|
| 208 | |
---|
| 209 | // ------------------------------------------------------------------------------------------------------------------- |
---|
| 210 | // member functions for CU description |
---|
| 211 | // ------------------------------------------------------------------------------------------------------------------- |
---|
| 212 | |
---|
| 213 | TComPic* getPic () { return m_pcPic; } |
---|
| 214 | TComSlice* getSlice () { return m_pcSlice; } |
---|
| 215 | UInt& getAddr () { return m_uiCUAddr; } |
---|
| 216 | UInt& getZorderIdxInCU () { return m_uiAbsIdxInLCU; } |
---|
| 217 | UInt getSCUAddr (); |
---|
| 218 | UInt getCUPelX () { return m_uiCUPelX; } |
---|
| 219 | UInt getCUPelY () { return m_uiCUPelY; } |
---|
| 220 | TComPattern* getPattern () { return m_pcPattern; } |
---|
| 221 | |
---|
| 222 | UChar* getDepth () { return m_puhDepth; } |
---|
| 223 | UChar getDepth ( UInt uiIdx ) { return m_puhDepth[uiIdx]; } |
---|
| 224 | Void setDepth ( UInt uiIdx, UChar uh ) { m_puhDepth[uiIdx] = uh; } |
---|
| 225 | |
---|
| 226 | Void setDepthSubParts ( UInt uiDepth, UInt uiAbsPartIdx ); |
---|
| 227 | |
---|
| 228 | // ------------------------------------------------------------------------------------------------------------------- |
---|
| 229 | // member functions for CU data |
---|
| 230 | // ------------------------------------------------------------------------------------------------------------------- |
---|
| 231 | |
---|
| 232 | Char* getPartitionSize () { return m_pePartSize; } |
---|
| 233 | PartSize getPartitionSize ( UInt uiIdx ) { return static_cast<PartSize>( m_pePartSize[uiIdx] ); } |
---|
| 234 | Void setPartitionSize ( UInt uiIdx, PartSize uh){ m_pePartSize[uiIdx] = uh; } |
---|
| 235 | Void setPartSizeSubParts ( PartSize eMode, UInt uiAbsPartIdx, UInt uiDepth ); |
---|
| 236 | Void setCUTransquantBypassSubParts( Bool flag, UInt uiAbsPartIdx, UInt uiDepth ); |
---|
| 237 | |
---|
| 238 | Bool* getSkipFlag () { return m_skipFlag; } |
---|
| 239 | Bool getSkipFlag (UInt idx) { return m_skipFlag[idx]; } |
---|
| 240 | Void setSkipFlag ( UInt idx, Bool skip) { m_skipFlag[idx] = skip; } |
---|
| 241 | Void setSkipFlagSubParts ( Bool skip, UInt absPartIdx, UInt depth ); |
---|
| 242 | |
---|
| 243 | Char* getPredictionMode () { return m_pePredMode; } |
---|
| 244 | PredMode getPredictionMode ( UInt uiIdx ) { return static_cast<PredMode>( m_pePredMode[uiIdx] ); } |
---|
| 245 | Bool* getCUTransquantBypass () { return m_CUTransquantBypass; } |
---|
| 246 | Bool getCUTransquantBypass( UInt uiIdx ) { return m_CUTransquantBypass[uiIdx]; } |
---|
| 247 | Void setPredictionMode ( UInt uiIdx, PredMode uh){ m_pePredMode[uiIdx] = uh; } |
---|
| 248 | Void setPredModeSubParts ( PredMode eMode, UInt uiAbsPartIdx, UInt uiDepth ); |
---|
| 249 | |
---|
| 250 | UChar* getWidth () { return m_puhWidth; } |
---|
| 251 | UChar getWidth ( UInt uiIdx ) { return m_puhWidth[uiIdx]; } |
---|
| 252 | Void setWidth ( UInt uiIdx, UChar uh ) { m_puhWidth[uiIdx] = uh; } |
---|
| 253 | |
---|
| 254 | UChar* getHeight () { return m_puhHeight; } |
---|
| 255 | UChar getHeight ( UInt uiIdx ) { return m_puhHeight[uiIdx]; } |
---|
| 256 | Void setHeight ( UInt uiIdx, UChar uh ) { m_puhHeight[uiIdx] = uh; } |
---|
| 257 | |
---|
| 258 | Void setSizeSubParts ( UInt uiWidth, UInt uiHeight, UInt uiAbsPartIdx, UInt uiDepth ); |
---|
| 259 | |
---|
| 260 | Char* getQP () { return m_phQP; } |
---|
| 261 | Char getQP ( UInt uiIdx ) { return m_phQP[uiIdx]; } |
---|
| 262 | Void setQP ( UInt uiIdx, Char value ){ m_phQP[uiIdx] = value; } |
---|
| 263 | Void setQPSubParts ( Int qp, UInt uiAbsPartIdx, UInt uiDepth ); |
---|
| 264 | Int getLastValidPartIdx ( Int iAbsPartIdx ); |
---|
| 265 | Char getLastCodedQP ( UInt uiAbsPartIdx ); |
---|
| 266 | Void setQPSubCUs ( Int qp, TComDataCU* pcCU, UInt absPartIdx, UInt depth, Bool &foundNonZeroCbf ); |
---|
| 267 | Void setCodedQP ( Char qp ) { m_codedQP = qp; } |
---|
| 268 | Char getCodedQP () { return m_codedQP; } |
---|
| 269 | |
---|
| 270 | Bool isLosslessCoded(UInt absPartIdx); |
---|
| 271 | |
---|
| 272 | UChar* getTransformIdx () { return m_puhTrIdx; } |
---|
| 273 | UChar getTransformIdx ( UInt uiIdx ) { return m_puhTrIdx[uiIdx]; } |
---|
| 274 | Void setTrIdxSubParts ( UInt uiTrIdx, UInt uiAbsPartIdx, UInt uiDepth ); |
---|
| 275 | |
---|
| 276 | UChar* getTransformSkip ( TextType eType) { return m_puhTransformSkip[g_aucConvertTxtTypeToIdx[eType]];} |
---|
| 277 | UChar getTransformSkip ( UInt uiIdx,TextType eType) { return m_puhTransformSkip[g_aucConvertTxtTypeToIdx[eType]][uiIdx];} |
---|
| 278 | Void setTransformSkipSubParts ( UInt useTransformSkip, TextType eType, UInt uiAbsPartIdx, UInt uiDepth); |
---|
| 279 | Void setTransformSkipSubParts ( UInt useTransformSkipY, UInt useTransformSkipU, UInt useTransformSkipV, UInt uiAbsPartIdx, UInt uiDepth ); |
---|
| 280 | |
---|
| 281 | UInt getQuadtreeTULog2MinSizeInCU( UInt absPartIdx ); |
---|
| 282 | |
---|
| 283 | TComCUMvField* getCUMvField ( RefPicList e ) { return &m_acCUMvField[e]; } |
---|
| 284 | |
---|
| 285 | TCoeff*& getCoeffY () { return m_pcTrCoeffY; } |
---|
| 286 | TCoeff*& getCoeffCb () { return m_pcTrCoeffCb; } |
---|
| 287 | TCoeff*& getCoeffCr () { return m_pcTrCoeffCr; } |
---|
| 288 | #if ADAPTIVE_QP_SELECTION |
---|
| 289 | Int*& getArlCoeffY () { return m_pcArlCoeffY; } |
---|
| 290 | Int*& getArlCoeffCb () { return m_pcArlCoeffCb; } |
---|
| 291 | Int*& getArlCoeffCr () { return m_pcArlCoeffCr; } |
---|
| 292 | #endif |
---|
| 293 | |
---|
| 294 | Pel*& getPCMSampleY () { return m_pcIPCMSampleY; } |
---|
| 295 | Pel*& getPCMSampleCb () { return m_pcIPCMSampleCb; } |
---|
| 296 | Pel*& getPCMSampleCr () { return m_pcIPCMSampleCr; } |
---|
| 297 | |
---|
| 298 | UChar getCbf ( UInt uiIdx, TextType eType ) { return m_puhCbf[g_aucConvertTxtTypeToIdx[eType]][uiIdx]; } |
---|
| 299 | UChar* getCbf ( TextType eType ) { return m_puhCbf[g_aucConvertTxtTypeToIdx[eType]]; } |
---|
| 300 | UChar getCbf ( UInt uiIdx, TextType eType, UInt uiTrDepth ) { return ( ( getCbf( uiIdx, eType ) >> uiTrDepth ) & 0x1 ); } |
---|
| 301 | Void setCbf ( UInt uiIdx, TextType eType, UChar uh ) { m_puhCbf[g_aucConvertTxtTypeToIdx[eType]][uiIdx] = uh; } |
---|
| 302 | Void clearCbf ( UInt uiIdx, TextType eType, UInt uiNumParts ); |
---|
| 303 | UChar getQtRootCbf ( UInt uiIdx ) { return getCbf( uiIdx, TEXT_LUMA, 0 ) || getCbf( uiIdx, TEXT_CHROMA_U, 0 ) || getCbf( uiIdx, TEXT_CHROMA_V, 0 ); } |
---|
| 304 | |
---|
| 305 | Void setCbfSubParts ( UInt uiCbfY, UInt uiCbfU, UInt uiCbfV, UInt uiAbsPartIdx, UInt uiDepth ); |
---|
| 306 | Void setCbfSubParts ( UInt uiCbf, TextType eTType, UInt uiAbsPartIdx, UInt uiDepth ); |
---|
| 307 | Void setCbfSubParts ( UInt uiCbf, TextType eTType, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth ); |
---|
| 308 | |
---|
| 309 | // ------------------------------------------------------------------------------------------------------------------- |
---|
| 310 | // member functions for coding tool information |
---|
| 311 | // ------------------------------------------------------------------------------------------------------------------- |
---|
| 312 | |
---|
| 313 | Bool* getMergeFlag () { return m_pbMergeFlag; } |
---|
| 314 | Bool getMergeFlag ( UInt uiIdx ) { return m_pbMergeFlag[uiIdx]; } |
---|
| 315 | Void setMergeFlag ( UInt uiIdx, Bool b ) { m_pbMergeFlag[uiIdx] = b; } |
---|
| 316 | Void setMergeFlagSubParts ( Bool bMergeFlag, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth ); |
---|
| 317 | |
---|
| 318 | UChar* getMergeIndex () { return m_puhMergeIndex; } |
---|
| 319 | UChar getMergeIndex ( UInt uiIdx ) { return m_puhMergeIndex[uiIdx]; } |
---|
| 320 | Void setMergeIndex ( UInt uiIdx, UInt uiMergeIndex ) { m_puhMergeIndex[uiIdx] = uiMergeIndex; } |
---|
| 321 | Void setMergeIndexSubParts ( UInt uiMergeIndex, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth ); |
---|
| 322 | template <typename T> |
---|
| 323 | Void setSubPart ( T bParameter, T* pbBaseLCU, UInt uiCUAddr, UInt uiCUDepth, UInt uiPUIdx ); |
---|
| 324 | |
---|
| 325 | #if AMP_MRG |
---|
| 326 | Void setMergeAMP( Bool b ) { m_bIsMergeAMP = b; } |
---|
| 327 | Bool getMergeAMP( ) { return m_bIsMergeAMP; } |
---|
| 328 | #endif |
---|
| 329 | |
---|
| 330 | UChar* getLumaIntraDir () { return m_puhLumaIntraDir; } |
---|
| 331 | UChar getLumaIntraDir ( UInt uiIdx ) { return m_puhLumaIntraDir[uiIdx]; } |
---|
| 332 | Void setLumaIntraDir ( UInt uiIdx, UChar uh ) { m_puhLumaIntraDir[uiIdx] = uh; } |
---|
| 333 | Void setLumaIntraDirSubParts( UInt uiDir, UInt uiAbsPartIdx, UInt uiDepth ); |
---|
| 334 | |
---|
| 335 | UChar* getChromaIntraDir () { return m_puhChromaIntraDir; } |
---|
| 336 | UChar getChromaIntraDir ( UInt uiIdx ) { return m_puhChromaIntraDir[uiIdx]; } |
---|
| 337 | Void setChromaIntraDir ( UInt uiIdx, UChar uh ) { m_puhChromaIntraDir[uiIdx] = uh; } |
---|
| 338 | Void setChromIntraDirSubParts( UInt uiDir, UInt uiAbsPartIdx, UInt uiDepth ); |
---|
| 339 | |
---|
| 340 | UChar* getInterDir () { return m_puhInterDir; } |
---|
| 341 | UChar getInterDir ( UInt uiIdx ) { return m_puhInterDir[uiIdx]; } |
---|
| 342 | Void setInterDir ( UInt uiIdx, UChar uh ) { m_puhInterDir[uiIdx] = uh; } |
---|
| 343 | Void setInterDirSubParts ( UInt uiDir, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth ); |
---|
| 344 | Bool* getIPCMFlag () { return m_pbIPCMFlag; } |
---|
| 345 | Bool getIPCMFlag (UInt uiIdx ) { return m_pbIPCMFlag[uiIdx]; } |
---|
| 346 | Void setIPCMFlag (UInt uiIdx, Bool b ) { m_pbIPCMFlag[uiIdx] = b; } |
---|
| 347 | Void setIPCMFlagSubParts (Bool bIpcmFlag, UInt uiAbsPartIdx, UInt uiDepth); |
---|
| 348 | |
---|
| 349 | // ------------------------------------------------------------------------------------------------------------------- |
---|
| 350 | // member functions for accessing partition information |
---|
| 351 | // ------------------------------------------------------------------------------------------------------------------- |
---|
| 352 | |
---|
| 353 | Void getPartIndexAndSize ( UInt uiPartIdx, UInt& ruiPartAddr, Int& riWidth, Int& riHeight ); |
---|
| 354 | UChar getNumPartInter (); |
---|
| 355 | Bool isFirstAbsZorderIdxInDepth (UInt uiAbsPartIdx, UInt uiDepth); |
---|
| 356 | |
---|
| 357 | // ------------------------------------------------------------------------------------------------------------------- |
---|
| 358 | // member functions for motion vector |
---|
| 359 | // ------------------------------------------------------------------------------------------------------------------- |
---|
| 360 | |
---|
| 361 | Void getMvField ( TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefPicList, TComMvField& rcMvField ); |
---|
| 362 | |
---|
| 363 | Void fillMvpCand ( UInt uiPartIdx, UInt uiPartAddr, RefPicList eRefPicList, Int iRefIdx, AMVPInfo* pInfo ); |
---|
| 364 | Bool isDiffMER ( Int xN, Int yN, Int xP, Int yP); |
---|
| 365 | Void getPartPosition ( UInt partIdx, Int& xP, Int& yP, Int& nPSW, Int& nPSH); |
---|
| 366 | Void setMVPIdx ( RefPicList eRefPicList, UInt uiIdx, Int iMVPIdx) { m_apiMVPIdx[eRefPicList][uiIdx] = iMVPIdx; } |
---|
| 367 | Int getMVPIdx ( RefPicList eRefPicList, UInt uiIdx) { return m_apiMVPIdx[eRefPicList][uiIdx]; } |
---|
| 368 | Char* getMVPIdx ( RefPicList eRefPicList ) { return m_apiMVPIdx[eRefPicList]; } |
---|
| 369 | |
---|
| 370 | Void setMVPNum ( RefPicList eRefPicList, UInt uiIdx, Int iMVPNum ) { m_apiMVPNum[eRefPicList][uiIdx] = iMVPNum; } |
---|
| 371 | Int getMVPNum ( RefPicList eRefPicList, UInt uiIdx ) { return m_apiMVPNum[eRefPicList][uiIdx]; } |
---|
| 372 | Char* getMVPNum ( RefPicList eRefPicList ) { return m_apiMVPNum[eRefPicList]; } |
---|
| 373 | |
---|
| 374 | Void setMVPIdxSubParts ( Int iMVPIdx, RefPicList eRefPicList, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth ); |
---|
| 375 | Void setMVPNumSubParts ( Int iMVPNum, RefPicList eRefPicList, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth ); |
---|
| 376 | |
---|
| 377 | Void clipMv ( TComMv& rcMv ); |
---|
| 378 | Void getMvPredLeft ( TComMv& rcMvPred ) { rcMvPred = m_cMvFieldA.getMv(); } |
---|
| 379 | Void getMvPredAbove ( TComMv& rcMvPred ) { rcMvPred = m_cMvFieldB.getMv(); } |
---|
| 380 | Void getMvPredAboveRight ( TComMv& rcMvPred ) { rcMvPred = m_cMvFieldC.getMv(); } |
---|
| 381 | |
---|
| 382 | Void compressMV (); |
---|
| 383 | |
---|
| 384 | // ------------------------------------------------------------------------------------------------------------------- |
---|
| 385 | // utility functions for neighbouring information |
---|
| 386 | // ------------------------------------------------------------------------------------------------------------------- |
---|
| 387 | |
---|
| 388 | TComDataCU* getCULeft () { return m_pcCULeft; } |
---|
| 389 | TComDataCU* getCUAbove () { return m_pcCUAbove; } |
---|
| 390 | TComDataCU* getCUAboveLeft () { return m_pcCUAboveLeft; } |
---|
| 391 | TComDataCU* getCUAboveRight () { return m_pcCUAboveRight; } |
---|
| 392 | TComDataCU* getCUColocated ( RefPicList eRefPicList ) { return m_apcCUColocated[eRefPicList]; } |
---|
| 393 | |
---|
| 394 | |
---|
| 395 | TComDataCU* getPULeft ( UInt& uiLPartUnitIdx, |
---|
| 396 | UInt uiCurrPartUnitIdx, |
---|
| 397 | Bool bEnforceSliceRestriction=true, |
---|
| 398 | Bool bEnforceTileRestriction=true ); |
---|
| 399 | TComDataCU* getPUAbove ( UInt& uiAPartUnitIdx, |
---|
| 400 | UInt uiCurrPartUnitIdx, |
---|
| 401 | Bool bEnforceSliceRestriction=true, |
---|
| 402 | Bool planarAtLCUBoundary = false, |
---|
| 403 | Bool bEnforceTileRestriction=true ); |
---|
| 404 | TComDataCU* getPUAboveLeft ( UInt& uiALPartUnitIdx, UInt uiCurrPartUnitIdx, Bool bEnforceSliceRestriction=true ); |
---|
| 405 | TComDataCU* getPUAboveRight ( UInt& uiARPartUnitIdx, UInt uiCurrPartUnitIdx, Bool bEnforceSliceRestriction=true ); |
---|
| 406 | TComDataCU* getPUBelowLeft ( UInt& uiBLPartUnitIdx, UInt uiCurrPartUnitIdx, Bool bEnforceSliceRestriction=true ); |
---|
| 407 | |
---|
| 408 | TComDataCU* getQpMinCuLeft ( UInt& uiLPartUnitIdx , UInt uiCurrAbsIdxInLCU ); |
---|
| 409 | TComDataCU* getQpMinCuAbove ( UInt& aPartUnitIdx , UInt currAbsIdxInLCU ); |
---|
| 410 | Char getRefQP ( UInt uiCurrAbsIdxInLCU ); |
---|
| 411 | |
---|
| 412 | TComDataCU* getPUAboveRightAdi ( UInt& uiARPartUnitIdx, UInt uiCurrPartUnitIdx, UInt uiPartUnitOffset = 1, Bool bEnforceSliceRestriction=true ); |
---|
| 413 | TComDataCU* getPUBelowLeftAdi ( UInt& uiBLPartUnitIdx, UInt uiCurrPartUnitIdx, UInt uiPartUnitOffset = 1, Bool bEnforceSliceRestriction=true ); |
---|
| 414 | |
---|
| 415 | Void deriveLeftRightTopIdx ( UInt uiPartIdx, UInt& ruiPartIdxLT, UInt& ruiPartIdxRT ); |
---|
| 416 | Void deriveLeftBottomIdx ( UInt uiPartIdx, UInt& ruiPartIdxLB ); |
---|
| 417 | |
---|
| 418 | Void deriveLeftRightTopIdxAdi ( UInt& ruiPartIdxLT, UInt& ruiPartIdxRT, UInt uiPartOffset, UInt uiPartDepth ); |
---|
| 419 | Void deriveLeftBottomIdxAdi ( UInt& ruiPartIdxLB, UInt uiPartOffset, UInt uiPartDepth ); |
---|
| 420 | |
---|
| 421 | Bool hasEqualMotion ( UInt uiAbsPartIdx, TComDataCU* pcCandCU, UInt uiCandAbsPartIdx ); |
---|
| 422 | Void getInterMergeCandidates ( UInt uiAbsPartIdx, UInt uiPUIdx, TComMvField* pcMFieldNeighbours, UChar* puhInterDirNeighbours, Int& numValidMergeCand, Int mrgCandIdx = -1 ); |
---|
| 423 | Void deriveLeftRightTopIdxGeneral ( UInt uiAbsPartIdx, UInt uiPartIdx, UInt& ruiPartIdxLT, UInt& ruiPartIdxRT ); |
---|
| 424 | Void deriveLeftBottomIdxGeneral ( UInt uiAbsPartIdx, UInt uiPartIdx, UInt& ruiPartIdxLB ); |
---|
| 425 | |
---|
[595] | 426 | |
---|
[313] | 427 | // ------------------------------------------------------------------------------------------------------------------- |
---|
| 428 | // member functions for modes |
---|
| 429 | // ------------------------------------------------------------------------------------------------------------------- |
---|
| 430 | |
---|
| 431 | Bool isIntra ( UInt uiPartIdx ) { return m_pePredMode[ uiPartIdx ] == MODE_INTRA; } |
---|
| 432 | Bool isSkipped ( UInt uiPartIdx ); ///< SKIP (no residual) |
---|
| 433 | Bool isBipredRestriction( UInt puIdx ); |
---|
| 434 | |
---|
| 435 | // ------------------------------------------------------------------------------------------------------------------- |
---|
| 436 | // member functions for symbol prediction (most probable / mode conversion) |
---|
| 437 | // ------------------------------------------------------------------------------------------------------------------- |
---|
| 438 | |
---|
| 439 | UInt getIntraSizeIdx ( UInt uiAbsPartIdx ); |
---|
| 440 | |
---|
| 441 | Void getAllowedChromaDir ( UInt uiAbsPartIdx, UInt* uiModeList ); |
---|
| 442 | Int getIntraDirLumaPredictor ( UInt uiAbsPartIdx, Int* uiIntraDirPred, Int* piMode = NULL ); |
---|
| 443 | |
---|
| 444 | // ------------------------------------------------------------------------------------------------------------------- |
---|
| 445 | // member functions for SBAC context |
---|
| 446 | // ------------------------------------------------------------------------------------------------------------------- |
---|
| 447 | |
---|
| 448 | UInt getCtxSplitFlag ( UInt uiAbsPartIdx, UInt uiDepth ); |
---|
| 449 | UInt getCtxQtCbf ( TextType eType, UInt uiTrDepth ); |
---|
| 450 | |
---|
| 451 | UInt getCtxSkipFlag ( UInt uiAbsPartIdx ); |
---|
| 452 | UInt getCtxInterDir ( UInt uiAbsPartIdx ); |
---|
| 453 | |
---|
| 454 | UInt getSliceStartCU ( UInt pos ) { return m_sliceStartCU[pos-m_uiAbsIdxInLCU]; } |
---|
| 455 | UInt getSliceSegmentStartCU ( UInt pos ) { return m_sliceSegmentStartCU[pos-m_uiAbsIdxInLCU]; } |
---|
| 456 | UInt& getTotalBins () { return m_uiTotalBins; } |
---|
| 457 | |
---|
[442] | 458 | #if SVC_EXTENSION |
---|
[595] | 459 | Void setLayerId (UInt layerId) { m_layerId = layerId; } |
---|
| 460 | UInt getLayerId () { return m_layerId; } |
---|
| 461 | #if N0383_IL_CONSTRAINED_TILE_SETS_SEI |
---|
| 462 | Bool isInterLayerReference(UChar uhInterDir, TComMvField& cMvFieldL0, TComMvField& cMvFieldL1); |
---|
| 463 | #endif |
---|
[313] | 464 | #if FAST_INTRA_SHVC |
---|
| 465 | Int reduceSetOfIntraModes ( UInt uiAbsPartIdx, Int* uiIntraDirPred, Int &fullSetOfModes ); |
---|
| 466 | #endif |
---|
| 467 | #if REF_IDX_ME_ZEROMV |
---|
| 468 | Bool xCheckZeroMVILRMerge(UChar uhInterDir, TComMvField& cMvFieldL0, TComMvField& cMvFieldL1); |
---|
| 469 | Bool xCheckZeroMVILRMvdL1Zero(Int iRefList, Int iRefIdx, Int MvpIdx); |
---|
| 470 | #endif |
---|
[595] | 471 | TComDataCU* getBaseColCU( UInt refLayerIdc, UInt uiCuAbsPartIdx, UInt &uiCUAddrBase, UInt &uiAbsPartIdxBase, Int iMotionMapping = 0 ); |
---|
| 472 | TComDataCU* getBaseColCU( UInt refLayerIdc, UInt uiPelX, UInt uiPelY, UInt &uiCUAddrBase, UInt &uiAbsPartIdxBase, Int iMotionMapping = 0 ); |
---|
| 473 | Void scaleBaseMV( UInt refLayerIdc, TComMvField& rcMvFieldEnhance, TComMvField& rcMvFieldBase ); |
---|
[345] | 474 | #endif |
---|
[313] | 475 | |
---|
| 476 | // ------------------------------------------------------------------------------------------------------------------- |
---|
| 477 | // member functions for RD cost storage |
---|
| 478 | // ------------------------------------------------------------------------------------------------------------------- |
---|
| 479 | |
---|
| 480 | Double& getTotalCost() { return m_dTotalCost; } |
---|
| 481 | UInt& getTotalDistortion() { return m_uiTotalDistortion; } |
---|
| 482 | UInt& getTotalBits() { return m_uiTotalBits; } |
---|
| 483 | UInt& getTotalNumPart() { return m_uiNumPartition; } |
---|
| 484 | |
---|
| 485 | UInt getCoefScanIdx(UInt uiAbsPartIdx, UInt uiWidth, Bool bIsLuma, Bool bIsIntra); |
---|
| 486 | |
---|
| 487 | }; |
---|
| 488 | |
---|
| 489 | namespace RasterAddress |
---|
| 490 | { |
---|
| 491 | /** Check whether 2 addresses point to the same column |
---|
| 492 | * \param addrA First address in raster scan order |
---|
| 493 | * \param addrB Second address in raters scan order |
---|
| 494 | * \param numUnitsPerRow Number of units in a row |
---|
| 495 | * \return Result of test |
---|
| 496 | */ |
---|
| 497 | static inline Bool isEqualCol( Int addrA, Int addrB, Int numUnitsPerRow ) |
---|
| 498 | { |
---|
| 499 | // addrA % numUnitsPerRow == addrB % numUnitsPerRow |
---|
| 500 | return (( addrA ^ addrB ) & ( numUnitsPerRow - 1 ) ) == 0; |
---|
| 501 | } |
---|
| 502 | |
---|
| 503 | /** Check whether 2 addresses point to the same row |
---|
| 504 | * \param addrA First address in raster scan order |
---|
| 505 | * \param addrB Second address in raters scan order |
---|
| 506 | * \param numUnitsPerRow Number of units in a row |
---|
| 507 | * \return Result of test |
---|
| 508 | */ |
---|
| 509 | static inline Bool isEqualRow( Int addrA, Int addrB, Int numUnitsPerRow ) |
---|
| 510 | { |
---|
| 511 | // addrA / numUnitsPerRow == addrB / numUnitsPerRow |
---|
| 512 | return (( addrA ^ addrB ) &~ ( numUnitsPerRow - 1 ) ) == 0; |
---|
| 513 | } |
---|
| 514 | |
---|
| 515 | /** Check whether 2 addresses point to the same row or column |
---|
| 516 | * \param addrA First address in raster scan order |
---|
| 517 | * \param addrB Second address in raters scan order |
---|
| 518 | * \param numUnitsPerRow Number of units in a row |
---|
| 519 | * \return Result of test |
---|
| 520 | */ |
---|
| 521 | static inline Bool isEqualRowOrCol( Int addrA, Int addrB, Int numUnitsPerRow ) |
---|
| 522 | { |
---|
| 523 | return isEqualCol( addrA, addrB, numUnitsPerRow ) | isEqualRow( addrA, addrB, numUnitsPerRow ); |
---|
| 524 | } |
---|
| 525 | |
---|
| 526 | /** Check whether one address points to the first column |
---|
| 527 | * \param addr Address in raster scan order |
---|
| 528 | * \param numUnitsPerRow Number of units in a row |
---|
| 529 | * \return Result of test |
---|
| 530 | */ |
---|
| 531 | static inline Bool isZeroCol( Int addr, Int numUnitsPerRow ) |
---|
| 532 | { |
---|
| 533 | // addr % numUnitsPerRow == 0 |
---|
| 534 | return ( addr & ( numUnitsPerRow - 1 ) ) == 0; |
---|
| 535 | } |
---|
| 536 | |
---|
| 537 | /** Check whether one address points to the first row |
---|
| 538 | * \param addr Address in raster scan order |
---|
| 539 | * \param numUnitsPerRow Number of units in a row |
---|
| 540 | * \return Result of test |
---|
| 541 | */ |
---|
| 542 | static inline Bool isZeroRow( Int addr, Int numUnitsPerRow ) |
---|
| 543 | { |
---|
| 544 | // addr / numUnitsPerRow == 0 |
---|
| 545 | return ( addr &~ ( numUnitsPerRow - 1 ) ) == 0; |
---|
| 546 | } |
---|
| 547 | |
---|
| 548 | /** Check whether one address points to a column whose index is smaller than a given value |
---|
| 549 | * \param addr Address in raster scan order |
---|
| 550 | * \param val Given column index value |
---|
| 551 | * \param numUnitsPerRow Number of units in a row |
---|
| 552 | * \return Result of test |
---|
| 553 | */ |
---|
| 554 | static inline Bool lessThanCol( Int addr, Int val, Int numUnitsPerRow ) |
---|
| 555 | { |
---|
| 556 | // addr % numUnitsPerRow < val |
---|
| 557 | return ( addr & ( numUnitsPerRow - 1 ) ) < val; |
---|
| 558 | } |
---|
| 559 | |
---|
| 560 | /** Check whether one address points to a row whose index is smaller than a given value |
---|
| 561 | * \param addr Address in raster scan order |
---|
| 562 | * \param val Given row index value |
---|
| 563 | * \param numUnitsPerRow Number of units in a row |
---|
| 564 | * \return Result of test |
---|
| 565 | */ |
---|
| 566 | static inline Bool lessThanRow( Int addr, Int val, Int numUnitsPerRow ) |
---|
| 567 | { |
---|
| 568 | // addr / numUnitsPerRow < val |
---|
| 569 | return addr < val * numUnitsPerRow; |
---|
| 570 | } |
---|
| 571 | }; |
---|
| 572 | |
---|
| 573 | //! \} |
---|
| 574 | |
---|
| 575 | #endif |
---|