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