当前位置: 代码迷 >> 综合 >> HM中的TComDataCU和VTM中的CodingStructure和 CodingUnit的代码解释
  详细解决方案

HM中的TComDataCU和VTM中的CodingStructure和 CodingUnit的代码解释

热度:2   发布时间:2024-02-09 02:27:22.0

在HM中 TEncCU.cpp的文件中

xCompressCU( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU, UInt uiDepth DEBUG_STRING_FN_DECLARE(sDebug_), PartSize eParentPartSize )

代码中每个深度的预测用的都是temp,
预测完后跟best比较并交换。best保留作为当前深度的预测数据,
而temp再次初始化。在下一深度的4个子CU预测中用的是subtemp,
每预测完一个子CU,就跟subbest比较交换,再把subbest的数据复制到已经初始化的temp的相应位置。
当temp获取完4个子CU的subbest的数据后,就代表了整个下一深度的数据,这时再与代表当前深度数据的best比较交换

 

其中TComDataCU里面的确存放了大量信息,在日常使用中从这样一个cu对象就可以取到大部分所需要的信息

class TComTU; // forward declarationstatic const UInt NUM_MOST_PROBABLE_MODES=3; // NOTE: RExt - new definition// ====================================================================================================================
// Class definition
// ====================================================================================================================/// CU data structure class
class TComDataCU
{
private:// -------------------------------------------------------------------------------------------------------------------// class pointers// -------------------------------------------------------------------------------------------------------------------TComPic*      m_pcPic;              ///< picture class pointerTComSlice*    m_pcSlice;            ///< slice header pointer// -------------------------------------------------------------------------------------------------------------------// CU description// -------------------------------------------------------------------------------------------------------------------UInt          m_uiCUAddr;           ///< CU address in a sliceUInt          m_uiAbsIdxInLCU;      ///< absolute address in a CU. It's Z scan orderUInt          m_uiCUPelX;           ///< CU position in a pixel (X)UInt          m_uiCUPelY;           ///< CU position in a pixel (Y)UInt          m_uiNumPartition;     ///< total number of minimum partitions in a CUUChar*        m_puhWidth;           ///< array of widthsUChar*        m_puhHeight;          ///< array of heightsUChar*        m_puhDepth;           ///< array of depthsInt           m_unitSize;           ///< size of a "minimum partition"// -------------------------------------------------------------------------------------------------------------------// CU data// -------------------------------------------------------------------------------------------------------------------Bool*          m_skipFlag;           ///< array of skip flagsChar*          m_pePartSize;         ///< array of partition sizesChar*          m_pePredMode;         ///< array of prediction modesChar*          m_crossComponentPredictionAlpha[MAX_NUM_COMPONENT]; ///< array of cross-component prediction alpha valuesBool*          m_CUTransquantBypass; ///< array of cu_transquant_bypass flagsChar*          m_phQP;               ///< array of QP valuesUChar*         m_ChromaQpAdj;        ///< array of chroma QP adjustments (indexed)UInt           m_codedChromaQpAdj;UChar*         m_puhTrIdx;           ///< array of transform indicesUChar*         m_puhTransformSkip[MAX_NUM_COMPONENT];///< array of transform skipping flagsUChar*         m_puhCbf[MAX_NUM_COMPONENT];          ///< array of coded block flags (CBF)TComCUMvField  m_acCUMvField[NUM_REF_PIC_LIST_CU_MV_FIELD];    ///< array of motion vectors, and includes intra block copying vector field.
#if SCM__R0309_INTRABC_BVPTComMv         m_lastIntraBCMv[2];    ///< last 2 Intra Block Copy Mv used.
#elseTComMv         m_lastIntraBCMv;       ///< last Intra Block Copy Mv used. (0,0) indicates that the vector has not been used within the CU.
#endif TCoeff*        m_pcTrCoeff[MAX_NUM_COMPONENT];       ///< array of transform coefficient buffers (0->Y, 1->Cb, 2->Cr)
#if ADAPTIVE_QP_SELECTIONTCoeff*        m_pcArlCoeff[MAX_NUM_COMPONENT];  // ARL coefficient buffer (0->Y, 1->Cb, 2->Cr)static TCoeff* m_pcGlbArlCoeff[MAX_NUM_COMPONENT]; // global ARL bufferBool           m_ArlCoeffIsAliasedAllocation;  ///< ARL coefficient buffer is an alias of the global buffer and must not be free()'d
#endifPel*           m_pcIPCMSample[MAX_NUM_COMPONENT];    ///< PCM sample buffer (0->Y, 1->Cb, 2->Cr)
#if SCM__R0147_ADAPTIVE_COLOR_TRANSFORMBool*          m_ColorTransform; 
#endif// -------------------------------------------------------------------------------------------------------------------// neighbour access variables// -------------------------------------------------------------------------------------------------------------------TComDataCU*   m_pcCUAboveLeft;      ///< pointer of above-left CUTComDataCU*   m_pcCUAboveRight;     ///< pointer of above-right CUTComDataCU*   m_pcCUAbove;          ///< pointer of above CUTComDataCU*   m_pcCULeft;           ///< pointer of left CUTComDataCU*   m_apcCUColocated[NUM_REF_PIC_LIST_01];  ///< pointer of temporally colocated CU's for both directionsTComMvField   m_cMvFieldA;          ///< motion vector of position ATComMvField   m_cMvFieldB;          ///< motion vector of position BTComMvField   m_cMvFieldC;          ///< motion vector of position CTComMv        m_cMvPred;            ///< motion vector predictor// -------------------------------------------------------------------------------------------------------------------// coding tool information// -------------------------------------------------------------------------------------------------------------------Bool*         m_pbMergeFlag;        ///< array of merge flagsUChar*        m_puhMergeIndex;      ///< array of merge candidate indices
#if AMP_MRGBool          m_bIsMergeAMP;
#endifUChar*        m_puhIntraDir[MAX_NUM_CHANNEL_TYPE]; // 0-> Luma, 1-> ChromaUChar*        m_puhInterDir;        ///< array of inter directionsChar*         m_apiMVPIdx[NUM_REF_PIC_LIST_01];       ///< array of motion vector predictor candidatesChar*         m_apiMVPNum[NUM_REF_PIC_LIST_01];       ///< array of number of possible motion vectors predictorsBool*         m_pbIPCMFlag;         ///< array of intra_pcm flags
#if SCM__R0348_PALETTE_MODEUChar*        m_piSPoint[MAX_NUM_COMPONENT];            ///< 0: left run mode; 1: above run modeBool*         m_pbPLTModeFlag;                          ///< array of intra_pcm flagsPel*          m_piPLT[MAX_NUM_COMPONENT];               ///< PaletteUChar*        m_bPrevPLTReusedFlag[MAX_NUM_COMPONENT];  ///< PaletteUChar *       m_puhPLTEscape[MAX_NUM_COMPONENT];Pel*          m_piLastPLTInLcuFinal[MAX_NUM_COMPONENT]; ///< PaletteUChar         m_uhLastPLTSizeFinal[MAX_NUM_COMPONENT];UChar         m_uhLastPLTUsedSizeFinal[MAX_NUM_COMPONENT];Bool*         m_pbPLTSharingModeFlag;Bool*         m_pbPLTScanRotationModeFlag;Bool*         m_pbPLTScanTraverseModeFlag;
#endif// -------------------------------------------------------------------------------------------------------------------// misc. variables// -------------------------------------------------------------------------------------------------------------------Bool          m_bDecSubCu;          ///< indicates decoder-modeDouble        m_dTotalCost;         ///< sum of partition RD costsDistortion    m_uiTotalDistortion;  ///< sum of partition distortionUInt          m_uiTotalBits;        ///< sum of partition bitsUInt          m_uiTotalBins;        ///< sum of partition binsUInt*         m_sliceStartCU;       ///< Start CU address of current sliceUInt*         m_sliceSegmentStartCU;///< Start CU address of current sliceChar          m_codedQP;UChar*        m_explicitRdpcmMode[MAX_NUM_COMPONENT]; ///< Stores the explicit RDPCM mode for all TUs belonging to this CUprotected:/// add possible motion vector predictor candidatesBool          xAddMVPCand           ( AMVPInfo* pInfo, RefPicList eRefPicList, Int iRefIdx, UInt uiPartUnitIdx, MVP_DIR eDir );Bool          xAddMVPCandOrder      ( AMVPInfo* pInfo, RefPicList eRefPicList, Int iRefIdx, UInt uiPartUnitIdx, MVP_DIR eDir );Void          deriveRightBottomIdx        ( UInt uiPartIdx, UInt& ruiPartIdxRB );Bool          xGetColMVP( RefPicList eRefPicList, Int uiCUAddr, Int uiPartUnitIdx, TComMv& rcMv, Int& riRefIdx );/// compute required bits to encode MVD (used in AMVP)UInt          xGetMvdBits           ( TComMv cMvd );UInt          xGetComponentBits     ( Int iVal );/// compute scaling factor from POC differenceInt           xGetDistScaleFactor   ( Int iCurrPOC, Int iCurrRefPOC, Int iColPOC, Int iColRefPOC );Void xDeriveCenterIdx( UInt uiPartIdx, UInt& ruiPartIdxCenter );public:
#if SCM__R0147_ADAPTIVE_COLOR_TRANSFORMDouble        tmpIntraBCRDCost;Double        tmpInterRDCost;Bool          bIntraBCCSCEnabled;Bool          bInterCSCEnabled; 
#endifTComDataCU();virtual ~TComDataCU();// -------------------------------------------------------------------------------------------------------------------// create / destroy / initialize / copy// -------------------------------------------------------------------------------------------------------------------Void          create                ( ChromaFormat chromaFormatIDC, UInt uiNumPartition, UInt uiWidth, UInt uiHeight, Bool bDecSubCu, Int unitSize
#if ADAPTIVE_QP_SELECTION, Bool bGlobalRMARLBuffer = false
#endif);Void          destroy               ();Void          initCU                ( TComPic* pcPic, UInt uiCUAddr );Void          initEstData           ( const UInt uiDepth, const Int qp, const Bool bTransquantBypass );Void          initSubCU             ( TComDataCU* pcCU, UInt uiPartUnitIdx, UInt uiDepth, Int qp );
#if SCM__R0147_ADAPTIVE_COLOR_TRANSFORMVoid          initRQTData           ( const UInt uiDepth, TComDataCU* pSrcCU, Bool bCopySrc, Bool bResetIntraMode, Bool bResetTUSplit );
#endifVoid          setOutsideCUPart      ( UInt uiAbsPartIdx, UInt uiDepth );Void          copySubCU             ( TComDataCU* pcCU, UInt uiPartUnitIdx, UInt uiDepth );Void          copyInterPredInfoFrom ( TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefPicList );Void          copyPartFrom          ( TComDataCU* pcCU, UInt uiPartUnitIdx, UInt uiDepth );Void          copyToPic             ( UChar uiDepth );Void          copyToPic             ( UChar uiDepth, UInt uiPartIdx, UInt uiPartDepth );// -------------------------------------------------------------------------------------------------------------------// member functions for CU description// -------------------------------------------------------------------------------------------------------------------TComPic*        getPic              ()                        { return m_pcPic;           }const TComPic*  getPic              ()   const                { return m_pcPic;           }TComSlice*       getSlice           ()                        { return m_pcSlice;         }const TComSlice* getSlice           ()   const                { return m_pcSlice;         }UInt&         getAddr               ()                        { return m_uiCUAddr;        }UInt&         getZorderIdxInCU      ()                        { return m_uiAbsIdxInLCU; }UInt          getSCUAddr            ();UInt          getCUPelX             ()                        { return m_uiCUPelX;        }UInt          getCUPelY             ()                        { return m_uiCUPelY;        }UChar*        getDepth              ()                        { return m_puhDepth;        }UChar         getDepth              ( UInt uiIdx ) const      { return m_puhDepth[uiIdx]; }Void          setDepth              ( UInt uiIdx, UChar  uh ) { m_puhDepth[uiIdx] = uh;   }Void          setDepthSubParts      ( UInt uiDepth, UInt uiAbsPartIdx );// -------------------------------------------------------------------------------------------------------------------// member functions for CU data// -------------------------------------------------------------------------------------------------------------------#if SCM__R0309_INTRABC_BVPVoid          getIntraBCMVPs(UInt uiAbsPartIdx, TComMv* MvPred, TComMv* MvLast);
#endifChar*         getPartitionSize      ()                        { return m_pePartSize;        }PartSize      getPartitionSize      ( UInt uiIdx )            { return static_cast<PartSize>( m_pePartSize[uiIdx] ); }Void          setPartitionSize      ( UInt uiIdx, PartSize uh){ m_pePartSize[uiIdx] = uh;   }Void          setPartSizeSubParts   ( PartSize eMode, UInt uiAbsPartIdx, UInt uiDepth );Void          setCUTransquantBypassSubParts( Bool flag, UInt uiAbsPartIdx, UInt uiDepth );Bool*         getSkipFlag            ()                        { return m_skipFlag;          }Bool          getSkipFlag            (UInt idx)                { return m_skipFlag[idx];     }Void          setSkipFlag           ( UInt idx, Bool skip)     { m_skipFlag[idx] = skip;   }Void          setSkipFlagSubParts   ( Bool skip, UInt absPartIdx, UInt depth );Char*         getPredictionMode     ()                        { return m_pePredMode;        }PredMode      getPredictionMode     ( UInt uiIdx )            { return static_cast<PredMode>( m_pePredMode[uiIdx] ); }Void          setPredictionMode     ( UInt uiIdx, PredMode uh){ m_pePredMode[uiIdx] = uh;   }Void          setPredModeSubParts   ( PredMode eMode, UInt uiAbsPartIdx, UInt uiDepth );#if SCM__R0147_ADAPTIVE_COLOR_TRANSFORMBool*         getColorTransform( )                              { return m_ColorTransform;         }Bool          getColorTransform( UInt uiIdx)                    { return m_ColorTransform[uiIdx];  }
#endifChar*         getCrossComponentPredictionAlpha( ComponentID compID )             { return m_crossComponentPredictionAlpha[compID];         }Char          getCrossComponentPredictionAlpha( UInt uiIdx, ComponentID compID ) { return m_crossComponentPredictionAlpha[compID][uiIdx];  }Bool*         getCUTransquantBypass ()                        { return m_CUTransquantBypass;        }Bool          getCUTransquantBypass( UInt uiIdx )             { return m_CUTransquantBypass[uiIdx]; }UChar*        getWidth              ()                        { return m_puhWidth;          }UChar         getWidth              ( UInt uiIdx )            { return m_puhWidth[uiIdx];   }Void          setWidth              ( UInt uiIdx, UChar  uh ) { m_puhWidth[uiIdx] = uh;     }UChar*        getHeight             ()                        { return m_puhHeight;         }UChar         getHeight             ( UInt uiIdx )            { return m_puhHeight[uiIdx];  }Void          setHeight             ( UInt uiIdx, UChar  uh ) { m_puhHeight[uiIdx] = uh;    }Void          setSizeSubParts       ( UInt uiWidth, UInt uiHeight, UInt uiAbsPartIdx, UInt uiDepth );Char*         getQP                 ()                        { return m_phQP;              }Char          getQP                 ( UInt uiIdx ) const      { return m_phQP[uiIdx];       }Void          setQP                 ( UInt uiIdx, Char value ){ m_phQP[uiIdx] =  value;     }Void          setQPSubParts         ( Int qp,   UInt uiAbsPartIdx, UInt uiDepth );Int           getLastValidPartIdx   ( Int iAbsPartIdx );Char          getLastCodedQP        ( UInt uiAbsPartIdx );Void          setQPSubCUs           ( Int qp, TComDataCU* pcCU, UInt absPartIdx, UInt depth, Bool &foundNonZeroCbf );Void          setCodedQP            ( Char qp )               { m_codedQP = qp;             }Char          getCodedQP            ()                        { return m_codedQP;           }UChar*        getChromaQpAdj        ()                        { return m_ChromaQpAdj;       }UChar         getChromaQpAdj        (Int idx)           const { return m_ChromaQpAdj[idx];  }Void          setChromaQpAdj        (Int idx, UChar val)      { m_ChromaQpAdj[idx] = val;   }Void          setChromaQpAdjSubParts( UChar val, Int absPartIdx, Int depth );Void          setCodedChromaQpAdj   ( Char qp )               { m_codedChromaQpAdj = qp;    }Char          getCodedChromaQpAdj   ()                        { return m_codedChromaQpAdj;  }Bool          isLosslessCoded       ( UInt absPartIdx );UChar*        getTransformIdx       ()                        { return m_puhTrIdx;          }UChar         getTransformIdx       ( UInt uiIdx )            { return m_puhTrIdx[uiIdx];   }Void          setTrIdxSubParts      ( UInt uiTrIdx, UInt uiAbsPartIdx, UInt uiDepth );UChar*        getTransformSkip      ( ComponentID compID )    { return m_puhTransformSkip[compID];}UChar         getTransformSkip      ( UInt uiIdx, ComponentID compID)    { return m_puhTransformSkip[compID][uiIdx];}Void          setTransformSkipSubParts  ( UInt useTransformSkip, ComponentID compID, UInt uiAbsPartIdx, UInt uiDepth);Void          setTransformSkipSubParts  ( const UInt useTransformSkip[MAX_NUM_COMPONENT], UInt uiAbsPartIdx, UInt uiDepth );UChar*        getExplicitRdpcmMode      ( ComponentID component ) { return m_explicitRdpcmMode[component]; }UChar         getExplicitRdpcmMode      ( ComponentID component, UInt partIdx ) {return m_explicitRdpcmMode[component][partIdx]; }Void          setExplicitRdpcmModePartRange ( UInt rdpcmMode, ComponentID compID, UInt uiAbsPartIdx, UInt uiCoveredPartIdxes );Bool          isRDPCMEnabled         ( UInt uiAbsPartIdx )  { return getSlice()->getSPS()->getUseResidualDPCM(isIntra(uiAbsPartIdx) ? RDPCM_SIGNAL_IMPLICIT : RDPCM_SIGNAL_EXPLICIT); }#if SCM__R0147_ADAPTIVE_COLOR_TRANSFORMVoid          setColorTransformSubParts ( Bool ColorTransform, UInt uiAbsPartIdx, UInt uiDepth);
#endifVoid          setCrossComponentPredictionAlphaPartRange    ( Char alphaValue, ComponentID compID, UInt uiAbsPartIdx, UInt uiCoveredPartIdxes );Void          setTransformSkipPartRange                    ( UInt useTransformSkip, ComponentID compID, UInt uiAbsPartIdx, UInt uiCoveredPartIdxes );UInt          getQuadtreeTULog2MinSizeInCU( UInt uiIdx );TComCUMvField* getCUMvField         ( RefPicList e )          { return  &m_acCUMvField[e];  }
#if SCM__R0309_INTRABC_BVPTComMv        getLastIntraBCMv(Int idx=0) {return m_lastIntraBCMv[idx]; }Void          setLastIntraBCMv(TComMv mv, Int idx=0 ) { m_lastIntraBCMv[idx] = mv; }
#elseTComMv        getLastIntraBCMv() {return m_lastIntraBCMv; }Void          setLastIntraBCMv(TComMv mv ) { m_lastIntraBCMv = mv; }
#endif
#if SCM__FLEXIBLE_INTRABC_SEARCHUInt          getIntraBCSearchAreaWidth( UInt uiMaxSearchWidthToLeftInCTUs );
#elseUInt          getIntraBCSearchAreaWidth();
#endifTCoeff*&      getCoeff              (ComponentID component)   { return m_pcTrCoeff[component]; }#if ADAPTIVE_QP_SELECTIONTCoeff*&      getArlCoeff           ( ComponentID component ) { return m_pcArlCoeff[component]; }
#endifPel*&         getPCMSample          ( ComponentID component ) { return m_pcIPCMSample[component]; }UChar         getCbf    ( UInt uiIdx, ComponentID eType )                  { return m_puhCbf[eType][uiIdx];  }UChar*        getCbf    ( ComponentID eType )                              { return m_puhCbf[eType];         }UChar         getCbf    ( UInt uiIdx, ComponentID eType, UInt uiTrDepth )  { return ( ( getCbf( uiIdx, eType ) >> uiTrDepth ) & 0x1 ); }Void          setCbf    ( UInt uiIdx, ComponentID eType, UChar uh )        { m_puhCbf[eType][uiIdx] = uh;    }Void          clearCbf  ( UInt uiIdx, ComponentID eType, UInt uiNumParts );UChar         getQtRootCbf          ( UInt uiIdx );Void          setCbfSubParts        ( const UInt uiCbf[MAX_NUM_COMPONENT],  UInt uiAbsPartIdx, UInt uiDepth           );Void          setCbfSubParts        ( UInt uiCbf, ComponentID compID, UInt uiAbsPartIdx, UInt uiDepth                    );Void          setCbfSubParts        ( UInt uiCbf, ComponentID compID, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth    );Void          setCbfPartRange       ( UInt uiCbf, ComponentID compID, UInt uiAbsPartIdx, UInt uiCoveredPartIdxes      );Void          bitwiseOrCbfPartRange ( UInt uiCbf, ComponentID compID, UInt uiAbsPartIdx, UInt uiCoveredPartIdxes      );// -------------------------------------------------------------------------------------------------------------------// member functions for coding tool information// -------------------------------------------------------------------------------------------------------------------Bool*         getMergeFlag          ()                        { return m_pbMergeFlag;               }Bool          getMergeFlag          ( UInt uiIdx )            { return m_pbMergeFlag[uiIdx];        }Void          setMergeFlag          ( UInt uiIdx, Bool b )    { m_pbMergeFlag[uiIdx] = b;           }Void          setMergeFlagSubParts  ( Bool bMergeFlag, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth );UChar*        getMergeIndex         ()                        { return m_puhMergeIndex;                         }UChar         getMergeIndex         ( UInt uiIdx )            { return m_puhMergeIndex[uiIdx];                  }Void          setMergeIndex         ( UInt uiIdx, UInt uiMergeIndex ) { m_puhMergeIndex[uiIdx] = uiMergeIndex;  }Void          setMergeIndexSubParts ( UInt uiMergeIndex, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth );template <typename T>Void          setSubPart            ( T bParameter, T* pbBaseLCU, UInt uiCUAddr, UInt uiCUDepth, UInt uiPUIdx );#if AMP_MRGVoid          setMergeAMP( Bool b )      { m_bIsMergeAMP = b; }Bool          getMergeAMP( )             { return m_bIsMergeAMP; }
#endifUChar*        getIntraDir         ( const ChannelType channelType )                   const { return m_puhIntraDir[channelType];         }UChar         getIntraDir         ( const ChannelType channelType, const UInt uiIdx ) const { return m_puhIntraDir[channelType][uiIdx];  }Void          setIntraDirSubParts ( const ChannelType channelType,const UInt uiDir,const UInt uiAbsPartIdx,const UInt uiDepth );UChar*        getInterDir           ()                        { return m_puhInterDir;               }UChar         getInterDir           ( UInt uiIdx )            { return m_puhInterDir[uiIdx];        }Void          setInterDir           ( UInt uiIdx, UChar  uh ) { m_puhInterDir[uiIdx] = uh;          }Void          setInterDirSubParts   ( UInt uiDir,  UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth );Bool*         getIPCMFlag           ()                        { return m_pbIPCMFlag;               }Bool          getIPCMFlag           (UInt uiIdx )             { return m_pbIPCMFlag[uiIdx];        }Void          setIPCMFlag           (UInt uiIdx, Bool b )     { m_pbIPCMFlag[uiIdx] = b;           }Void          setIPCMFlagSubParts   (Bool bIpcmFlag, UInt uiAbsPartIdx, UInt uiDepth);
#if SCM__R0348_PALETTE_MODEUChar*        getSPoint             (ComponentID component)   { return m_piSPoint[component];      }Pel*          getLevel              (ComponentID component)   { return m_pcIPCMSample[component];  }TCoeff*       getRun                (ComponentID component)   { return m_pcTrCoeff[component];     }Bool*         getPLTModeFlag        ()                        { return m_pbPLTModeFlag;            }Bool          getPLTModeFlag        (UInt uiIdx)              { return m_pbPLTModeFlag[uiIdx];     }Void          setRLModeFlag         (UInt uiIdx, Bool b)      { m_pbPLTModeFlag[uiIdx] = b;        }Void          setPLTModeFlagSubParts(Bool bRLModeFlag, UInt uiAbsPartIdx, UInt uiDepth);Pel*          getPLT                (UChar ucCh)                                         { return m_piPLT[ucCh]; }Pel*          getPLT                (UChar ucCh, UInt uiIdx)                             { return m_piPLT[ucCh] + (uiIdx >> 2) * MAX_PLT_SIZE; }Pel           getPLT                (UChar ucCh, UInt uiIdx, UInt uiPLTIdx)              { return m_piPLT[ucCh][(uiIdx >> 2) * MAX_PLT_SIZE + uiPLTIdx]; }Void          setPLT                (UChar ucCh, UInt uiIdx, Pel uiValue, UInt uiPLTIdx) { m_piPLT[ucCh][(uiIdx >> 2) * MAX_PLT_SIZE + uiPLTIdx] = uiValue; }Void          setPLTSubParts        (UChar ucCh, Pel uiValue, UInt uiPLTIdx, UInt uiAbsPartIdx, UInt uiDepth);UChar*        getPLTSize            (UChar ucCh)                          { return m_puhTransformSkip[ucCh];               }UChar         getPLTSize            (UChar ucCh, UInt uiIdx )             { return m_puhTransformSkip[ucCh][uiIdx];        }Void          setPLTSize            (UChar ucCh, UInt uiIdx, Bool b )     { m_puhTransformSkip[ucCh][uiIdx] = b;           }Void          setPLTSizeSubParts    (UChar ucCh, UChar ucRLDictSize, UInt uiAbsPartIdx, UInt uiDepth);UChar*        getPLTEscape          (UChar ucCh)                          { return m_puhPLTEscape[ucCh];        }UChar         getPLTEscape          (UChar ucCh, UInt uiIdx)              { return m_puhPLTEscape[ucCh][uiIdx]; }Void          setPLTEscape          (UChar ucCh, UInt uiIdx, Bool b)      { m_puhPLTEscape[ucCh][uiIdx] = b;    }Void          setPLTEscapeSubParts  (UChar ucCh, UChar ucUseEscape, UInt uiAbsPartIdx, UInt uiDepth);UChar*        getPrevPLTReusedFlag  (UChar ucCh)                                           { return m_bPrevPLTReusedFlag[ucCh]; }UChar*        getPrevPLTReusedFlag  (UChar ucCh, UInt uiIdx)                               { return m_bPrevPLTReusedFlag[ucCh] + (uiIdx >> 2) * MAX_PLT_PRED_SIZE; }UChar         getPrevPLTReusedFlag  (UChar ucCh, UInt uiIdx, UInt uiPLTIdx)                { return m_bPrevPLTReusedFlag[ucCh][(uiIdx >> 2) * MAX_PLT_PRED_SIZE + uiPLTIdx]; }Void          setPrevPLTReusedFlag  (UChar ucCh, UInt uiIdx, UChar uiValue, UInt uiPLTIdx) { m_bPrevPLTReusedFlag[ucCh][(uiIdx >> 2) * MAX_PLT_PRED_SIZE + uiPLTIdx] = uiValue; }Void          setPrevPLTReusedFlagSubParts(UChar ucCh, UChar uiValue, UInt uiPLTIdx, UInt uiAbsPartIdx, UInt uiDepth);Bool*         getPLTSharingModeFlag      ()                        { return m_pbPLTSharingModeFlag;        }Bool          getPLTSharingModeFlag      (UInt uiIdx)              { return m_pbPLTSharingModeFlag[uiIdx]; }Void          setPLTSharingModeFlag      (UInt uiIdx, Bool b)      { m_pbPLTSharingModeFlag[uiIdx] = b;    }Void          setPLTSharingFlagSubParts  (Bool bPLTSharingFlag, UInt uiAbsPartIdx, UInt uiDepth);Pel*          getPLTPred(TComDataCU* pcCU, UInt uiAbsPartIdx, UInt ch, UInt &uiPLTSizePrev, UInt &uiPLTUsedSizePrev);UInt          getCtxScanRotationModeFlag( UInt uiAbsPartIdx);UChar         getLastPLTInLcuUsedSizeFinal (UChar ucCh)             { return m_uhLastPLTUsedSizeFinal[ucCh]; }Void          setLastPLTInLcuUsedSizeFinal (UChar ucCh, UChar uh)   { m_uhLastPLTUsedSizeFinal[ucCh] = uh;   }UChar         getLastPLTInLcuSizeFinal     (UChar ucCh)           { return m_uhLastPLTSizeFinal[ucCh]; }Void          setLastPLTInLcuSizeFinal     (UChar ucCh, UChar uh) { m_uhLastPLTSizeFinal[ucCh] = uh;   }Pel*          getLastPLTInLcuFinal         (UChar ucCh)                             { return m_piLastPLTInLcuFinal[ucCh];              }Pel           getLastPLTInLcuFinal         (UChar ucCh, UInt uiPLTIdx)              { return m_piLastPLTInLcuFinal[ucCh][uiPLTIdx];    }Void          setLastPLTInLcuFinal         (UChar ucCh, Pel uiValue, UInt uiPLTIdx) { m_piLastPLTInLcuFinal[ucCh][uiPLTIdx] = uiValue; }Void          saveLastPLTInLcuFinal( TComDataCU *pcSrc, UInt uiAbsPartIdx, UInt numValidComp );Void          xCalcMaxBits(TComDataCU *pcCU, UInt uiMaxBit[3]);Int           xCalcMaxVals(TComDataCU *pcCU, ComponentID compID);Bool          getPLTScanRotationModeFlag (UInt uiIdx )             { return m_pbPLTScanRotationModeFlag[uiIdx]; }Bool*         getPLTScanRotationModeFlag ()                        { return m_pbPLTScanRotationModeFlag;        }Void          setPLTScanRotationModeFlagSubParts (Bool bPLTScanRotationModeFlag, UInt uiAbsPartIdx, UInt uiDepth);
#endif// -------------------------------------------------------------------------------------------------------------------// member functions for accessing partition information// -------------------------------------------------------------------------------------------------------------------Void          getPartIndexAndSize   ( UInt uiPartIdx, UInt& ruiPartAddr, Int& riWidth, Int& riHeight );UChar         getNumPartitions      ( const UInt uiAbsPartIdx = 0 );Bool          isFirstAbsZorderIdxInDepth (UInt uiAbsPartIdx, UInt uiDepth);// -------------------------------------------------------------------------------------------------------------------// member functions for motion vector// -------------------------------------------------------------------------------------------------------------------Void          getMvField            ( TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefPicList, TComMvField& rcMvField );Void          fillMvpCand           ( UInt uiPartIdx, UInt uiPartAddr, RefPicList eRefPicList, Int iRefIdx, AMVPInfo* pInfo );Bool          isDiffMER             ( Int xN, Int yN, Int xP, Int yP);Void          getPartPosition       ( UInt partIdx, Int& xP, Int& yP, Int& nPSW, Int& nPSH);Void          setMVPIdx             ( RefPicList eRefPicList, UInt uiIdx, Int iMVPIdx)  { m_apiMVPIdx[eRefPicList][uiIdx] = iMVPIdx;  }Int           getMVPIdx             ( RefPicList eRefPicList, UInt uiIdx)               { return m_apiMVPIdx[eRefPicList][uiIdx];     }Char*         getMVPIdx             ( RefPicList eRefPicList )                          { return m_apiMVPIdx[eRefPicList];            }Void          setMVPNum             ( RefPicList eRefPicList, UInt uiIdx, Int iMVPNum ) { m_apiMVPNum[eRefPicList][uiIdx] = iMVPNum;  }Int           getMVPNum             ( RefPicList eRefPicList, UInt uiIdx )              { return m_apiMVPNum[eRefPicList][uiIdx];     }Char*         getMVPNum             ( RefPicList eRefPicList )                          { return m_apiMVPNum[eRefPicList];            }Void          setMVPIdxSubParts     ( Int iMVPIdx, RefPicList eRefPicList, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth );Void          setMVPNumSubParts     ( Int iMVPNum, RefPicList eRefPicList, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth );Void          clipMv                ( TComMv&     rcMv     );Void          getMvPredLeft         ( TComMv&     rcMvPred )   { rcMvPred = m_cMvFieldA.getMv(); }Void          getMvPredAbove        ( TComMv&     rcMvPred )   { rcMvPred = m_cMvFieldB.getMv(); }Void          getMvPredAboveRight   ( TComMv&     rcMvPred )   { rcMvPred = m_cMvFieldC.getMv(); }Void          compressMV            ();// -------------------------------------------------------------------------------------------------------------------// utility functions for neighbouring information// -------------------------------------------------------------------------------------------------------------------TComDataCU*   getCULeft                   () { return m_pcCULeft;       }TComDataCU*   getCUAbove                  () { return m_pcCUAbove;      }TComDataCU*   getCUAboveLeft              () { return m_pcCUAboveLeft;  }TComDataCU*   getCUAboveRight             () { return m_pcCUAboveRight; }TComDataCU*   getCUColocated              ( RefPicList eRefPicList ) { return m_apcCUColocated[eRefPicList]; }TComDataCU*   getPULeft                   ( UInt&  uiLPartUnitIdx,UInt uiCurrPartUnitIdx,Bool bEnforceSliceRestriction=true,Bool bEnforceTileRestriction=true );TComDataCU*   getPUAbove                  ( UInt&  uiAPartUnitIdx,UInt uiCurrPartUnitIdx,Bool bEnforceSliceRestriction=true,Bool planarAtLCUBoundary = false,Bool bEnforceTileRestriction=true );TComDataCU*   getPUAboveLeft              ( UInt&  uiALPartUnitIdx, UInt uiCurrPartUnitIdx, Bool bEnforceSliceRestriction=true );TComDataCU*   getPUAboveRight             ( UInt&  uiARPartUnitIdx, UInt uiCurrPartUnitIdx, Bool bEnforceSliceRestriction=true );TComDataCU*   getPUBelowLeft              ( UInt&  uiBLPartUnitIdx, UInt uiCurrPartUnitIdx, Bool bEnforceSliceRestriction=true );TComDataCU*   getQpMinCuLeft              ( UInt&  uiLPartUnitIdx , UInt uiCurrAbsIdxInLCU );TComDataCU*   getQpMinCuAbove             ( UInt&  uiAPartUnitIdx , UInt uiCurrAbsIdxInLCU );Char          getRefQP                    ( UInt   uiCurrAbsIdxInLCU                       );TComDataCU*   getPUAboveRightAdi          ( UInt&  uiARPartUnitIdx, UInt uiCurrPartUnitIdx, UInt uiPartUnitOffset = 1, Bool bEnforceSliceRestriction=true );TComDataCU*   getPUBelowLeftAdi           ( UInt&  uiBLPartUnitIdx, UInt uiCurrPartUnitIdx, UInt uiPartUnitOffset = 1, Bool bEnforceSliceRestriction=true );Void          deriveLeftRightTopIdx       ( UInt uiPartIdx, UInt& ruiPartIdxLT, UInt& ruiPartIdxRT );Void          deriveLeftBottomIdx         ( UInt uiPartIdx, UInt& ruiPartIdxLB );Void          deriveLeftRightTopIdxAdi    ( UInt& ruiPartIdxLT, UInt& ruiPartIdxRT, UInt uiPartOffset, UInt uiPartDepth );Void          deriveLeftBottomIdxAdi      ( UInt& ruiPartIdxLB, UInt  uiPartOffset, UInt uiPartDepth );Bool          hasEqualMotion              ( UInt uiAbsPartIdx, TComDataCU* pcCandCU, UInt uiCandAbsPartIdx );Void          getInterMergeCandidates       ( UInt uiAbsPartIdx, UInt uiPUIdx, TComMvField* pcMFieldNeighbours, UChar* puhInterDirNeighbours, Int& numValidMergeCand, Int mrgCandIdx = -1 );Void          deriveLeftRightTopIdxGeneral  ( UInt uiAbsPartIdx, UInt uiPartIdx, UInt& ruiPartIdxLT, UInt& ruiPartIdxRT );Void          deriveLeftBottomIdxGeneral    ( UInt uiAbsPartIdx, UInt uiPartIdx, UInt& ruiPartIdxLB );// -------------------------------------------------------------------------------------------------------------------// member functions for modes// -------------------------------------------------------------------------------------------------------------------Bool          isIntraBC          ( UInt uiPartIdx )  const { return m_pePredMode[ uiPartIdx ] == MODE_INTRABC;                                            }Bool          isConstrainedIntra ( UInt uiPartIdx )  const { return m_pePredMode[ uiPartIdx ] == MODE_INTRA || m_pePredMode[ uiPartIdx ] == MODE_INTRABC; }Bool          isLoopFilterIntra  ( UInt uiPartIdx )  const { return m_pePredMode[ uiPartIdx ] == MODE_INTRA || m_pePredMode[ uiPartIdx ] == MODE_INTRABC; }Bool          isIntra            ( UInt uiPartIdx )  const { return m_pePredMode[ uiPartIdx ] == MODE_INTRA;                                              }Bool          isInter            ( UInt uiPartIdx )  const { return m_pePredMode[ uiPartIdx ] == MODE_INTER;                                              }Bool          isSkipped          ( UInt uiPartIdx );                                                     ///< SKIP (no residual)Bool          isBipredRestriction( UInt puIdx );// -------------------------------------------------------------------------------------------------------------------// member functions for symbol prediction (most probable / mode conversion)// -------------------------------------------------------------------------------------------------------------------UInt          getIntraSizeIdx                 ( UInt uiAbsPartIdx                                       );Void          getAllowedChromaDir             ( UInt uiAbsPartIdx, UInt* uiModeList );Int           getIntraDirPredictor            ( UInt uiAbsPartIdx, Int uiIntraDirPred[NUM_MOST_PROBABLE_MODES], const ComponentID compID, Int* piMode = NULL );// -------------------------------------------------------------------------------------------------------------------// member functions for SBAC context// -------------------------------------------------------------------------------------------------------------------UInt          getCtxSplitFlag                 ( UInt   uiAbsPartIdx, UInt uiDepth                   );UInt          getCtxQtCbf                     ( TComTU &rTu, const ChannelType chType );
#if SCM__R0348_PALETTE_MODEUInt          getCtxEscapeFlag                ( UInt   uiAbsPartIdx, UInt uiIdx,  Pel *pEscapeFlag  );UInt          getCtxSPoint                    ( UInt   uiAbsPartIdx, UInt uiIdx,  UChar *SPoint     );
#endifUInt          getCtxSkipFlag                  ( UInt   uiAbsPartIdx                                 );UInt          getCtxInterDir                  ( UInt   uiAbsPartIdx                                 );UInt          getSliceStartCU         ( UInt pos )                  { return m_sliceStartCU[pos-m_uiAbsIdxInLCU];        }UInt          getSliceSegmentStartCU  ( UInt pos )                  { return m_sliceSegmentStartCU[pos-m_uiAbsIdxInLCU]; }UInt&         getTotalBins            ()                            { return m_uiTotalBins;                              }// -------------------------------------------------------------------------------------------------------------------// member functions for RD cost storage// -------------------------------------------------------------------------------------------------------------------Double&       getTotalCost()                  { return m_dTotalCost;        }Distortion&   getTotalDistortion()            { return m_uiTotalDistortion; }UInt&         getTotalBits()                  { return m_uiTotalBits;       }UInt&         getTotalNumPart()               { return m_uiNumPartition;    }UInt          getCoefScanIdx(const UInt uiAbsPartIdx, const UInt uiWidth, const UInt uiHeight, const ComponentID compID) const ;};namespace RasterAddress
{/** Check whether 2 addresses point to the same column* \param addrA          First address in raster scan order* \param addrB          Second address in raters scan order* \param numUnitsPerRow Number of units in a row* \return Result of test*/static inline Bool isEqualCol( Int addrA, Int addrB, Int numUnitsPerRow ){// addrA % numUnitsPerRow == addrB % numUnitsPerRowreturn (( addrA ^ addrB ) &  ( numUnitsPerRow - 1 ) ) == 0;}/** Check whether 2 addresses point to the same row* \param addrA          First address in raster scan order* \param addrB          Second address in raters scan order* \param numUnitsPerRow Number of units in a row* \return Result of test*/static inline Bool isEqualRow( Int addrA, Int addrB, Int numUnitsPerRow ){// addrA / numUnitsPerRow == addrB / numUnitsPerRowreturn (( addrA ^ addrB ) &~ ( numUnitsPerRow - 1 ) ) == 0;}/** Check whether 2 addresses point to the same row or column* \param addrA          First address in raster scan order* \param addrB          Second address in raters scan order* \param numUnitsPerRow Number of units in a row* \return Result of test*/static inline Bool isEqualRowOrCol( Int addrA, Int addrB, Int numUnitsPerRow ){return isEqualCol( addrA, addrB, numUnitsPerRow ) | isEqualRow( addrA, addrB, numUnitsPerRow );}/** Check whether one address points to the first column* \param addr           Address in raster scan order* \param numUnitsPerRow Number of units in a row* \return Result of test*/static inline Bool isZeroCol( Int addr, Int numUnitsPerRow ){// addr % numUnitsPerRow == 0return ( addr & ( numUnitsPerRow - 1 ) ) == 0;}/** Check whether one address points to the first row* \param addr           Address in raster scan order* \param numUnitsPerRow Number of units in a row* \return Result of test*/static inline Bool isZeroRow( Int addr, Int numUnitsPerRow ){// addr / numUnitsPerRow == 0return ( addr &~ ( numUnitsPerRow - 1 ) ) == 0;}/** Check whether one address points to a column whose index is smaller than a given value* \param addr           Address in raster scan order* \param val            Given column index value* \param numUnitsPerRow Number of units in a row* \return Result of test*/static inline Bool lessThanCol( Int addr, Int val, Int numUnitsPerRow ){// addr % numUnitsPerRow < valreturn ( addr & ( numUnitsPerRow - 1 ) ) < val;}/** Check whether one address points to a row whose index is smaller than a given value* \param addr           Address in raster scan order* \param val            Given row index value* \param numUnitsPerRow Number of units in a row* \return Result of test*/static inline Bool lessThanRow( Int addr, Int val, Int numUnitsPerRow ){// addr / numUnitsPerRow < valreturn addr < val * numUnitsPerRow;}
}//! \}#endif

 

但是在VVC的VTM中

CU信息存储在CodingUnit中,CodingUnit有两个兄弟结构:PredictionUnit和TranformUnit,用于存放预测和变换的信息。大致可以看做把TComDataCU拆分成了CodingUnit、PredictionUnit、TranformUnit三个结构体。

coding unit
// ---------------------------------------------------------------------------#include "Buffer.h"struct TransformUnit;
struct PredictionUnit;
class  CodingStructure;struct CodingUnit : public UnitArea
{CodingStructure *cs;Slice *slice;ChannelType    chType;PredMode       predMode;uint8_t          depth;   // number of all splits, applied with generalized splits    定义了所有深度包括四叉树  二叉树  三插树uint8_t          qtDepth; // number of applied quad-splits, before switching to the multi-type-tree (mtt)// a triple split would increase the mtDepth by 1, but the qtDepth by 2 in the first and last part and by 1 in the middle part (because of the 1-2-1 split proportions)uint8_t          btDepth; // number of applied binary splits, after switching to the mtt (or it's equivalent)uint8_t          mtDepth; // the actual number of splits after switching to mtt (equals btDepth if only binary splits are allowed)int8_t          chromaQpAdj;int8_t          qp;SplitSeries    splitSeries;
#if JVET_O0050_LOCAL_DUAL_TREETreeType       treeType;ModeType       modeType;ModeTypeSeries modeTypeSeries;
#endifbool           skip;bool           mmvdSkip;bool           affine;int            affineType;bool           triangle;bool           transQuantBypass;int            bdpcmMode;bool           ipcm;uint8_t          imv;bool           rootCbf;uint8_t        sbtInfo;uint32_t           tileIdx;uint8_t         mtsFlag;uint32_t        lfnstIdx;uint8_t         GBiIdx;int             refIdxBi[2];bool           mipFlag;// needed for fast imv mode decisionsint8_t          imvNumCand;Position       shareParentPos;Size           shareParentSize;uint8_t          smvdMode;uint8_t        ispMode;
#if JVET_O0119_BASE_PALETTE_444bool           useEscape[MAX_NUM_COMPONENT];bool           useRotation[MAX_NUM_COMPONENT];bool           reuseflag[MAX_NUM_COMPONENT][MAXPLTPREDSIZE];uint32_t       lastPLTSize[MAX_NUM_COMPONENT];uint32_t       reusePLTSize[MAX_NUM_COMPONENT];uint32_t       curPLTSize[MAX_NUM_COMPONENT];Pel            curPLT[MAX_NUM_COMPONENT][MAXPLTSIZE];
#endifCodingUnit() : chType( CH_L ) { }CodingUnit(const UnitArea &unit);CodingUnit(const ChromaFormat _chromaFormat, const Area &area);CodingUnit& operator=( const CodingUnit& other );void initData();unsigned    idx;CodingUnit *next;PredictionUnit *firstPU;PredictionUnit *lastPU;TransformUnit *firstTU;TransformUnit *lastTU;
#if ENABLE_SPLIT_PARALLELISM || ENABLE_WPP_PARALLELISMint64_t cacheId;bool    cacheUsed;
#endifconst uint8_t     getSbtIdx() const { assert( ( ( sbtInfo >> 0 ) & 0xf ) < NUMBER_SBT_IDX ); return ( sbtInfo >> 0 ) & 0xf; }const uint8_t     getSbtPos() const { return ( sbtInfo >> 4 ) & 0x3; }void              setSbtIdx( uint8_t idx ) { CHECK( idx >= NUMBER_SBT_IDX, "sbt_idx wrong" ); sbtInfo = ( idx << 0 ) + ( sbtInfo & 0xf0 ); }void              setSbtPos( uint8_t pos ) { CHECK( pos >= 4, "sbt_pos wrong" ); sbtInfo = ( pos << 4 ) + ( sbtInfo & 0xcf ); }uint8_t           getSbtTuSplit() const;const uint8_t     checkAllowedSbt() const;
#if JVET_O1124_ALLOW_CCLM_CONDconst bool        checkCCLMAllowed() const;
#endif
#if JVET_O0050_LOCAL_DUAL_TREEconst bool        isSepTree() const;const bool        isConsInter() const { return modeType == MODE_TYPE_INTER; }const bool        isConsIntra() const { return modeType == MODE_TYPE_INTRA; }
#endif
};// ---------------------------------------------------------------------------
// prediction unit  描述UnitArea的区域的预测信号的生成方式。
// ---------------------------------------------------------------------------struct IntraPredictionData
{uint32_t  intraDir[MAX_NUM_CHANNEL_TYPE];int       multiRefIdx;
};struct InterPredictionData
{bool      mergeFlag;bool      regularMergeFlag;uint8_t     mergeIdx;uint8_t     triangleSplitDir;uint8_t     triangleMergeIdx0;uint8_t     triangleMergeIdx1;bool           mmvdMergeFlag;uint32_t       mmvdMergeIdx;uint8_t     interDir;uint8_t     mvpIdx  [NUM_REF_PIC_LIST_01];uint8_t     mvpNum  [NUM_REF_PIC_LIST_01];Mv        mvd     [NUM_REF_PIC_LIST_01];Mv        mv      [NUM_REF_PIC_LIST_01];int16_t     refIdx  [NUM_REF_PIC_LIST_01];MergeType mergeType;bool      mvRefine;Mv        mvdL0SubPu[MAX_NUM_SUBCU_DMVR];Mv        mvdAffi [NUM_REF_PIC_LIST_01][3];Mv        mvAffi[NUM_REF_PIC_LIST_01][3];bool      mhIntraFlag;Position  shareParentPos;Size      shareParentSize;Mv        bv;                             // block vector for IBCMv        bvd;                            // block vector difference for IBCuint8_t   mmvdEncOptMode;                  // 0: no action 1: skip chroma MC for MMVD candidate pre-selection 2: skip chroma MC and BIO for MMVD candidate pre-selection
};struct PredictionUnit : public UnitArea, public IntraPredictionData, public InterPredictionData
{CodingUnit      *cu;CodingStructure *cs;ChannelType      chType;// constructorsPredictionUnit(): chType( CH_L ) { }PredictionUnit(const UnitArea &unit);PredictionUnit(const ChromaFormat _chromaFormat, const Area &area);void initData();PredictionUnit& operator=(const IntraPredictionData& predData);PredictionUnit& operator=(const InterPredictionData& predData);PredictionUnit& operator=(const PredictionUnit& other);PredictionUnit& operator=(const MotionInfo& mi);unsigned        idx;Position shareParentPos;Size     shareParentSize;PredictionUnit *next;// for accessing motion information, which can have higher resolution than PUs (should always be used, when accessing neighboring motion information)const MotionInfo& getMotionInfo() const;const MotionInfo& getMotionInfo( const Position& pos ) const;MotionBuf         getMotionBuf();CMotionBuf        getMotionBuf() const;#if ENABLE_SPLIT_PARALLELISM || ENABLE_WPP_PARALLELISMint64_t cacheId;bool    cacheUsed;
#endif
};// ---------------------------------------------------------------------------
// transform unit
// ---------------------------------------------------------------------------struct TransformUnit : public UnitArea
{CodingUnit      *cu;CodingStructure *cs;ChannelType      chType;int              m_chromaResScaleInv;uint8_t        depth;uint8_t        mtsIdx;bool           noResidual;uint8_t        jointCbCr;uint8_t        cbf        [ MAX_NUM_TBLOCKS ];RDPCMMode    rdpcm        [ MAX_NUM_TBLOCKS ];int8_t        compAlpha   [ MAX_NUM_TBLOCKS ];TransformUnit() : chType( CH_L ) { }TransformUnit(const UnitArea& unit);TransformUnit(const ChromaFormat _chromaFormat, const Area &area);void initData();unsigned       idx;TransformUnit *next;TransformUnit *prev;#if JVET_O0119_BASE_PALETTE_444void init(TCoeff **coeffs, Pel **pcmbuf, Pel **runLength, bool **runType);
#elsevoid init(TCoeff **coeffs, Pel **pcmbuf);
#endifTransformUnit& operator=(const TransformUnit& other);void copyComponentFrom  (const TransformUnit& other, const ComponentID compID);void checkTuNoResidual( unsigned idx );
#if JVET_O0052_TU_LEVEL_CTX_CODED_BIN_CONSTRAINTint  getTbAreaAfterCoefZeroOut(ComponentID compID) const;
#endifCoeffBuf getCoeffs(const ComponentID id);const CCoeffBuf getCoeffs(const ComponentID id) const;PelBuf   getPcmbuf(const ComponentID id);const CPelBuf   getPcmbuf(const ComponentID id) const;int       getChromaAdj( )                 const;void      setChromaAdj(int i);
#if JVET_O0119_BASE_PALETTE_444PelBuf   getcurPLTIdx(const ComponentID id);const CPelBuf   getcurPLTIdx(const ComponentID id) const;PelBuf   getrunLength(const ComponentID id);const CPelBuf   getrunLength(const ComponentID id) const;PLTtypeBuf   getrunType(const ComponentID id);const CPLTtypeBuf   getrunType(const ComponentID id) const;PLTescapeBuf getescapeValue(const ComponentID id);const CPLTescapeBuf getescapeValue(const ComponentID id) const;Pel*      getPLTIndex(const ComponentID id);Pel*      getRunLens(const ComponentID id);bool*     getRunTypes(const ComponentID id);
#endif#if ENABLE_SPLIT_PARALLELISM || ENABLE_WPP_PARALLELISMint64_t cacheId;bool    cacheUsed;#endif
private:TCoeff *m_coeffs[ MAX_NUM_TBLOCKS ];Pel    *m_pcmbuf[ MAX_NUM_TBLOCKS ];
#if JVET_O0119_BASE_PALETTE_444bool   *m_runType[MAX_NUM_TBLOCKS];Pel    *m_runLength[MAX_NUM_TBLOCKS];
#endif
};// ---------------------------------------------------------------------------
// Utility class for easy for-each like unit traversing
// ---------------------------------------------------------------------------#include <iterator>template<typename T>
class UnitIterator : public std::iterator<std::forward_iterator_tag, T>
{
private:T* m_punit;public:UnitIterator(           ) : m_punit( nullptr ) { }UnitIterator( T* _punit ) : m_punit( _punit  ) { }typedef T&       reference;typedef T const& const_reference;typedef T*       pointer;typedef T const* const_pointer;reference        operator*()                                      { return *m_punit; }const_reference  operator*()                                const { return *m_punit; }pointer          operator->()                                     { return  m_punit; }const_pointer    operator->()                               const { return  m_punit; }UnitIterator<T>& operator++()                                     { m_punit = m_punit->next; return *this; }UnitIterator<T>  operator++( int )                                { auto x = *this; ++( *this ); return x; }bool             operator!=( const UnitIterator<T>& other ) const { return m_punit != other.m_punit; }bool             operator==( const UnitIterator<T>& other ) const { return m_punit == other.m_punit; }
};template<typename T>
class UnitTraverser
{
private:T* m_begin;T* m_end;public:UnitTraverser(                    ) : m_begin( nullptr ), m_end( nullptr ) { }UnitTraverser( T* _begin, T* _end ) : m_begin( _begin  ), m_end( _end    ) { }typedef T                     value_type;typedef size_t                size_type;typedef T&                    reference;typedef T const&              const_reference;typedef T*                    pointer;typedef T const*              const_pointer;typedef UnitIterator<T>       iterator;typedef UnitIterator<const T> const_iterator;iterator        begin()        { return UnitIterator<T>( m_begin ); }const_iterator  begin()  const { return UnitIterator<T>( m_begin ); }const_iterator  cbegin() const { return UnitIterator<T>( m_begin ); }iterator        end()          { return UnitIterator<T>( m_end   ); }const_iterator  end()    const { return UnitIterator<T>( m_end   ); }const_iterator  cend()   const { return UnitIterator<T>( m_end   ); }
};typedef UnitTraverser<CodingUnit>     CUTraverser;
typedef UnitTraverser<PredictionUnit> PUTraverser;
typedef UnitTraverser<TransformUnit>  TUTraverser;typedef UnitTraverser<const CodingUnit>     cCUTraverser;
typedef UnitTraverser<const PredictionUnit> cPUTraverser;
typedef UnitTraverser<const TransformUnit>  cTUTraverser;#endif

为了便于管理,新增了一个类CodingStructure把一帧中的CU全都放在了这里,这样对CU的操作变得更加方便。

class CodingStructure
{
public:UnitArea         area;// CodingStructure 所包含的区域Picture         *picture;  // 与picture的映射CodingStructure *parent;// 上层csCodingStructure *bestCS;Slice           *slice;UnitScale        unitScale[MAX_NUM_COMPONENT];int         baseQP;int         prevQP[MAX_NUM_CHANNEL_TYPE];int         currQP[MAX_NUM_CHANNEL_TYPE];int         chromaQpAdj;#if Count_CU_Depuint8_t *        m_puhDepth;          #endifPosition    sharedBndPos;Size        sharedBndSize;bool        isLossless;const SPS *sps;const PPS *pps;
#if JVET_O_MAX_NUM_ALF_APS_8APS*       alfApss[ALF_CTB_MAX_NUM_APS];
#elseAPS*       alfApss[MAX_NUM_APS];
#endifAPS *      lmcsAps;const VPS *vps;const PreCalcValues* pcv;CodingStructure(CUCache&, PUCache&, TUCache&);void create( const UnitArea &_unit, const bool isTopLayer );void create( const ChromaFormat &_chromaFormat, const Area& _area, const bool isTopLayer );void destroy();void releaseIntermediateData();void rebindPicBufs();void createCoeffs();void destroyCoeffs();void allocateVectorsAtPicLevel();// ---------------------------------------------------------------------------// global accessors// ---------------------------------------------------------------------------bool isDecomp (const Position &pos, const ChannelType _chType) const;bool isDecomp (const Position &pos, const ChannelType _chType);void setDecomp(const CompArea &area, const bool _isCoded = true);void setDecomp(const UnitArea &area, const bool _isCoded = true);const CodingUnit     *getCU(const Position &pos, const ChannelType _chType) const;const PredictionUnit *getPU(const Position &pos, const ChannelType _chType) const;const TransformUnit  *getTU(const Position &pos, const ChannelType _chType, const int subTuIdx = -1) const;CodingUnit     *getCU(const Position &pos, const ChannelType _chType);
#if JVET_O0050_LOCAL_DUAL_TREECodingUnit     *getLumaCU( const Position &pos );
#endifPredictionUnit *getPU(const Position &pos, const ChannelType _chType);TransformUnit  *getTU(const Position &pos, const ChannelType _chType, const int subTuIdx = -1);const CodingUnit     *getCU(const ChannelType &_chType) const { return getCU(area.blocks[_chType].pos(), _chType); }const PredictionUnit *getPU(const ChannelType &_chType) const { return getPU(area.blocks[_chType].pos(), _chType); }const TransformUnit  *getTU(const ChannelType &_chType) const { return getTU(area.blocks[_chType].pos(), _chType); }CodingUnit     *getCU(const ChannelType &_chType ) { return getCU(area.blocks[_chType].pos(), _chType); }PredictionUnit *getPU(const ChannelType &_chType ) { return getPU(area.blocks[_chType].pos(), _chType); }TransformUnit  *getTU(const ChannelType &_chType ) { return getTU(area.blocks[_chType].pos(), _chType); }const CodingUnit     *getCURestricted(const Position &pos, const Position curPos, const unsigned curSliceIdx, const unsigned curTileIdx, const ChannelType _chType) const;const CodingUnit     *getCURestricted(const Position &pos, const CodingUnit& curCu,                               const ChannelType _chType) const;const PredictionUnit *getPURestricted(const Position &pos, const PredictionUnit& curPu,                           const ChannelType _chType) const;const TransformUnit  *getTURestricted(const Position &pos, const TransformUnit& curTu,                            const ChannelType _chType) const;CodingUnit&     addCU(const UnitArea &unit, const ChannelType _chType);PredictionUnit& addPU(const UnitArea &unit, const ChannelType _chType);TransformUnit&  addTU(const UnitArea &unit, const ChannelType _chType);CUTraverser     traverseCUs(const UnitArea& _unit, const ChannelType _chType);PUTraverser     traversePUs(const UnitArea& _unit, const ChannelType _chType);TUTraverser     traverseTUs(const UnitArea& _unit, const ChannelType _chType);cCUTraverser    traverseCUs(const UnitArea& _unit, const ChannelType _chType) const;cPUTraverser    traversePUs(const UnitArea& _unit, const ChannelType _chType) const;cTUTraverser    traverseTUs(const UnitArea& _unit, const ChannelType _chType) const;
#if !JVET_O0258_REMOVE_CHROMA_IBC_FOR_DUALTREEIbcLumaCoverage getIbcLumaCoverage(const CompArea& chromaArea) const;
#endif// ---------------------------------------------------------------------------// encoding search utilities// ---------------------------------------------------------------------------static_vector<double, NUM_ENC_FEATURES> features;double      cost;bool        useDbCost;double      costDbOffset;double      lumaCost;uint64_t      fracBits;Distortion  dist;Distortion  interHad;
#if JVET_O0050_LOCAL_DUAL_TREETreeType    treeType; //because partitioner can not go deep to tu and cu coding (e.g., addCU()), need another variable for indicating treeTypeModeType    modeType;
#endifvoid initStructData  (const int &QP = MAX_INT, const bool &_isLosses = false, const bool &skipMotBuf = false);void initSubStructure(      CodingStructure& cs, const ChannelType chType, const UnitArea &subArea, const bool &isTuEnc);void copyStructure   (const CodingStructure& cs, const ChannelType chType, const bool copyTUs = false, const bool copyRecoBuffer = false);void useSubStructure (const CodingStructure& cs, const ChannelType chType, const UnitArea &subArea, const bool cpyPred, const bool cpyReco, const bool cpyOrgResi, const bool cpyResi);void useSubStructure (const CodingStructure& cs, const ChannelType chType,                          const bool cpyPred, const bool cpyReco, const bool cpyOrgResi, const bool cpyResi) { useSubStructure(cs, chType, cs.area, cpyPred, cpyReco, cpyOrgResi, cpyResi); }void clearTUs();void clearPUs();void clearCUs();
#if JVET_O0050_LOCAL_DUAL_TREEconst int signalModeCons( const PartSplit split, Partitioner &partitioner, const ModeType modeTypeParent ) const;void clearCuPuTuIdxMap  ( const UnitArea &_area, uint32_t numCu, uint32_t numPu, uint32_t numTu, uint32_t* pOffset );void getNumCuPuTuOffset ( uint32_t* pArray ){pArray[0] = m_numCUs;     pArray[1] = m_numPUs;     pArray[2] = m_numTUs;pArray[3] = m_offsets[0]; pArray[4] = m_offsets[1]; pArray[5] = m_offsets[2];}
#endifprivate:void createInternals(const UnitArea& _unit, const bool isTopLayer);public:std::vector<    CodingUnit*> cus;std::vector<PredictionUnit*> pus;std::vector< TransformUnit*> tus;LutMotionCand motionLut;void addMiToLut(static_vector<MotionInfo, MAX_NUM_HMVP_CANDS>& lut, const MotionInfo &mi);#if JVET_O0119_BASE_PALETTE_444PLTBuf prevPLT;void resetPrevPLT(PLTBuf& prevPLT);void reorderPrevPLT(PLTBuf& prevPLT, uint32_t curPLTSize[MAX_NUM_COMPONENT], Pel curPLT[MAX_NUM_COMPONENT][MAXPLTSIZE], bool reuseflag[MAX_NUM_COMPONENT][MAXPLTPREDSIZE], uint32_t compBegin, uint32_t numComp, bool jointPLT);
#endif
private:// needed for TU encodingbool m_isTuEnc;unsigned *m_cuIdx   [MAX_NUM_CHANNEL_TYPE];unsigned *m_puIdx   [MAX_NUM_CHANNEL_TYPE];unsigned *m_tuIdx   [MAX_NUM_CHANNEL_TYPE];bool     *m_isDecomp[MAX_NUM_CHANNEL_TYPE];unsigned m_numCUs;unsigned m_numPUs;unsigned m_numTUs;CUCache& m_cuCache;PUCache& m_puCache;TUCache& m_tuCache;std::vector<SAOBlkParam> m_sao;PelStorage m_pred;PelStorage m_resi;PelStorage m_reco;PelStorage m_orgr;TCoeff *m_coeffs [ MAX_NUM_COMPONENT ];Pel    *m_pcmbuf [ MAX_NUM_COMPONENT ];
#if JVET_O0119_BASE_PALETTE_444bool   *m_runType  [MAX_NUM_COMPONENT];Pel    *m_runLength[MAX_NUM_COMPONENT];
#endifint     m_offsets[ MAX_NUM_COMPONENT ];MotionInfo *m_motionBuf;public:
#if JVET_O0070_PROFCodingStructure *bestParent;
#endif
#if JVET_O1170_CHECK_BV_AT_DECODERbool resetIBCBuffer;
#endifMotionBuf getMotionBuf( const     Area& _area );MotionBuf getMotionBuf( const UnitArea& _area ) { return getMotionBuf( _area.Y() ); }MotionBuf getMotionBuf()                        { return getMotionBuf(  area.Y() ); }const CMotionBuf getMotionBuf( const     Area& _area ) const;const CMotionBuf getMotionBuf( const UnitArea& _area ) const { return getMotionBuf( _area.Y() ); }const CMotionBuf getMotionBuf()                        const { return getMotionBuf(  area.Y() ); }MotionInfo& getMotionInfo( const Position& pos );const MotionInfo& getMotionInfo( const Position& pos ) const;public:// ---------------------------------------------------------------------------// temporary (shadowed) data accessors// ---------------------------------------------------------------------------PelBuf       getPredBuf(const CompArea &blk);const CPelBuf       getPredBuf(const CompArea &blk) const;PelUnitBuf   getPredBuf(const UnitArea &unit);const CPelUnitBuf   getPredBuf(const UnitArea &unit) const;PelBuf       getResiBuf(const CompArea &blk);const CPelBuf       getResiBuf(const CompArea &blk) const;PelUnitBuf   getResiBuf(const UnitArea &unit);const CPelUnitBuf   getResiBuf(const UnitArea &unit) const;PelBuf       getRecoBuf(const CompArea &blk);const CPelBuf       getRecoBuf(const CompArea &blk) const;PelUnitBuf   getRecoBuf(const UnitArea &unit);const CPelUnitBuf   getRecoBuf(const UnitArea &unit) const;PelUnitBuf&  getRecoBufRef() { return m_reco; }PelBuf       getOrgResiBuf(const CompArea &blk);const CPelBuf       getOrgResiBuf(const CompArea &blk) const;PelUnitBuf   getOrgResiBuf(const UnitArea &unit);const CPelUnitBuf   getOrgResiBuf(const UnitArea &unit) const;PelBuf       getOrgBuf(const CompArea &blk);const CPelBuf       getOrgBuf(const CompArea &blk) const;PelUnitBuf   getOrgBuf(const UnitArea &unit);const CPelUnitBuf   getOrgBuf(const UnitArea &unit) const;PelBuf       getOrgBuf(const ComponentID &compID);const CPelBuf       getOrgBuf(const ComponentID &compID) const;PelUnitBuf   getOrgBuf();const CPelUnitBuf   getOrgBuf() const;// pred bufferPelBuf       getPredBuf(const ComponentID &compID)       { return m_pred.get(compID); }const CPelBuf       getPredBuf(const ComponentID &compID) const { return m_pred.get(compID); }PelUnitBuf   getPredBuf()                                { return m_pred; }const CPelUnitBuf   getPredBuf()                          const { return m_pred; }// resi bufferPelBuf       getResiBuf(const ComponentID compID)        { return m_resi.get(compID); }const CPelBuf       getResiBuf(const ComponentID compID)  const { return m_resi.get(compID); }PelUnitBuf   getResiBuf()                                { return m_resi; }const CPelUnitBuf   getResiBuf()                          const { return m_resi; }// org-resi bufferPelBuf       getOrgResiBuf(const ComponentID &compID)       { return m_orgr.get(compID); }const CPelBuf       getOrgResiBuf(const ComponentID &compID) const { return m_orgr.get(compID); }PelUnitBuf   getOrgResiBuf()                                { return m_orgr; }const CPelUnitBuf   getOrgResiBuf()                          const { return m_orgr; }// reco bufferPelBuf       getRecoBuf(const ComponentID compID)         { return m_reco.get(compID); }const CPelBuf       getRecoBuf(const ComponentID compID)   const { return m_reco.get(compID); }PelUnitBuf   getRecoBuf()                                 { return m_reco; }const CPelUnitBuf   getRecoBuf()                           const { return m_reco; }private:inline        PelBuf       getBuf(const CompArea &blk,  const PictureType &type);inline const CPelBuf       getBuf(const CompArea &blk,  const PictureType &type) const;inline        PelUnitBuf   getBuf(const UnitArea &unit, const PictureType &type);inline const CPelUnitBuf   getBuf(const UnitArea &unit, const PictureType &type) const;
};static inline uint32_t getNumberValidTBlocks(const PreCalcValues& pcv) { return (pcv.chrFormat==CHROMA_400) ? 1 : ( pcv.multiBlock422 ? MAX_NUM_TBLOCKS : MAX_NUM_COMPONENT ); }#endif

 

  相关解决方案