Src_HM/source/Lib/TLibEncoder/TEncSearch.cpp
//Note: pcResi seems to be only used when bSpatial is true! bSpatial seems NOT to correspond to intra related stuff
pcResi seems to be only used when bSpatial is true. bSpatial seems NOT to correspond to intra related stuff
pcResi seems to be only used when bSpatial is true . bSpatial seems NOT to correspond to intra related stuff
Void TEncSearch::xSetResidualQTData( TComDataCU* pcCU, UInt uiQuadrant, UInt uiAbsPartIdx, UInt absTUPartIdx, TComYuv* pcResi, UInt uiDepth, Bool bSpatial )
{
  assert( pcCU->getDepth( 0 ) == pcCU->getDepth( uiAbsPartIdx ) );
  const UInt uiCurrTrMode = uiDepth - pcCU->getDepth( 0 );
  const UInt uiTrMode = pcCU->getTransformIdx( uiAbsPartIdx );
  if( uiCurrTrMode == uiTrMode )
  {
    const UInt uiLog2TrSize = g_aucConvertToBit[pcCU->getSlice()->getSPS()->getMaxCUWidth() >> uiDepth]+2;
    const UInt uiQTTempAccessLayer = pcCU->getSlice()->getSPS()->getQuadtreeTULog2MaxSize() - uiLog2TrSize;
    Bool  bCodeChroma   = true;
    UInt  uiTrModeC     = uiTrMode;
    UInt  uiLog2TrSizeC = uiLog2TrSize-1;
    if( uiLog2TrSize == 2 )
    {
      uiLog2TrSizeC++;
      uiTrModeC    --;
      UInt  uiQPDiv = pcCU->getPic()->getNumPartInCU() >> ( ( pcCU->getDepth( 0 ) + uiTrModeC ) << 1 );
      bCodeChroma   = ( ( uiAbsPartIdx % uiQPDiv ) == 0 );
    }
    if( bSpatial )
    {      
      Int trWidth  = 1 << uiLog2TrSize;
      Int trHeight = 1 << uiLog2TrSize;
      m_pcQTTempTComYuv[uiQTTempAccessLayer].copyPartToPartLuma    ( pcResi, absTUPartIdx, trWidth , trHeight );
      if( bCodeChroma )
      {
        m_pcQTTempTComYuv[uiQTTempAccessLayer].copyPartToPartChroma( pcResi, uiAbsPartIdx, 1 << uiLog2TrSizeC, 1 << uiLog2TrSizeC );
      }
    }
    else
    {
      UInt    uiNumCoeffPerAbsPartIdxIncrement = pcCU->getSlice()->getSPS()->getMaxCUWidth() * pcCU->getSlice()->getSPS()->getMaxCUHeight() >> ( pcCU->getSlice()->getSPS()->getMaxCUDepth() << 1 );
      UInt    uiNumCoeffY = ( 1 << ( uiLog2TrSize << 1 ) );
      TCoeff* pcCoeffSrcY = m_ppcQTTempCoeffY [uiQTTempAccessLayer] +  uiNumCoeffPerAbsPartIdxIncrement * uiAbsPartIdx;
      TCoeff* pcCoeffDstY = pcCU->getCoeffY() + uiNumCoeffPerAbsPartIdxIncrement * uiAbsPartIdx;
      ::memcpy( pcCoeffDstY, pcCoeffSrcY, sizeof( TCoeff ) * uiNumCoeffY );
#if ADAPTIVE_QP_SELECTION
      Int* pcArlCoeffSrcY = m_ppcQTTempArlCoeffY [uiQTTempAccessLayer] +  uiNumCoeffPerAbsPartIdxIncrement * uiAbsPartIdx;
      Int* pcArlCoeffDstY = pcCU->getArlCoeffY() + uiNumCoeffPerAbsPartIdxIncrement * uiAbsPartIdx;
      ::memcpy( pcArlCoeffDstY, pcArlCoeffSrcY, sizeof( Int ) * uiNumCoeffY );
#endif
      if( bCodeChroma )
      {
        UInt    uiNumCoeffC = ( 1 << ( uiLog2TrSizeC << 1 ) );
        TCoeff* pcCoeffSrcU = m_ppcQTTempCoeffCb[uiQTTempAccessLayer] + (uiNumCoeffPerAbsPartIdxIncrement * uiAbsPartIdx>>2);
        TCoeff* pcCoeffSrcV = m_ppcQTTempCoeffCr[uiQTTempAccessLayer] + (uiNumCoeffPerAbsPartIdxIncrement * uiAbsPartIdx>>2);
        TCoeff* pcCoeffDstU = pcCU->getCoeffCb() + (uiNumCoeffPerAbsPartIdxIncrement * uiAbsPartIdx>>2);
        TCoeff* pcCoeffDstV = pcCU->getCoeffCr() + (uiNumCoeffPerAbsPartIdxIncrement * uiAbsPartIdx>>2);
        ::memcpy( pcCoeffDstU, pcCoeffSrcU, sizeof( TCoeff ) * uiNumCoeffC );
        ::memcpy( pcCoeffDstV, pcCoeffSrcV, sizeof( TCoeff ) * uiNumCoeffC );
#if ADAPTIVE_QP_SELECTION
        Int* pcArlCoeffSrcU = m_ppcQTTempArlCoeffCb[uiQTTempAccessLayer] + (uiNumCoeffPerAbsPartIdxIncrement * uiAbsPartIdx>>2);
        Int* pcArlCoeffSrcV = m_ppcQTTempArlCoeffCr[uiQTTempAccessLayer] + (uiNumCoeffPerAbsPartIdxIncrement * uiAbsPartIdx>>2);
        Int* pcArlCoeffDstU = pcCU->getArlCoeffCb() + (uiNumCoeffPerAbsPartIdxIncrement * uiAbsPartIdx>>2);
        Int* pcArlCoeffDstV = pcCU->getArlCoeffCr() + (uiNumCoeffPerAbsPartIdxIncrement * uiAbsPartIdx>>2);
        ::memcpy( pcArlCoeffDstU, pcArlCoeffSrcU, sizeof( Int ) * uiNumCoeffC );
        ::memcpy( pcArlCoeffDstV, pcArlCoeffSrcV, sizeof( Int ) * uiNumCoeffC );
#endif
      }
    }
  }
  else
  {
    const UInt uiQPartNumSubdiv = pcCU->getPic()->getNumPartInCU() >> ((uiDepth + 1 ) << 1);
    for( UInt ui = 0; ui < 4; ++ui )
    {
      UInt nsAddr = uiAbsPartIdx + ui * uiQPartNumSubdiv;
      xSetResidualQTData( pcCU, ui, uiAbsPartIdx + ui * uiQPartNumSubdiv, nsAddr, pcResi, uiDepth + 1, bSpatial );
    }
  }
}
Void TEncSearch :: xSetResidualQTData ( TComDataCU * pcCU , UInt uiQuadrant , UInt uiAbsPartIdx , UInt absTUPartIdx , TComYuv * pcResi , UInt uiDepth , Bool bSpatial ) { assert ( pcCU -> getDepth ( 0 ) == pcCU -> getDepth ( uiAbsPartIdx ) ) ; const UInt uiCurrTrMode = uiDepth - pcCU -> getDepth ( 0 ) ; const UInt uiTrMode = pcCU -> getTransformIdx ( uiAbsPartIdx ) ; if ( uiCurrTrMode == uiTrMode ) { const UInt uiLog2TrSize = g_aucConvertToBit [ pcCU -> getSlice ( ) -> getSPS ( ) -> getMaxCUWidth ( ) >> uiDepth ] + 2 ; const UInt uiQTTempAccessLayer = pcCU -> getSlice ( ) -> getSPS ( ) -> getQuadtreeTULog2MaxSize ( ) - uiLog2TrSize ; Bool bCodeChroma = true ; UInt uiTrModeC = uiTrMode ; UInt uiLog2TrSizeC = uiLog2TrSize - 1 ; if ( uiLog2TrSize == 2 ) { uiLog2TrSizeC ++ ; uiTrModeC -- ; UInt uiQPDiv = pcCU -> getPic ( ) -> getNumPartInCU ( ) >> ( ( pcCU -> getDepth ( 0 ) + uiTrModeC ) << 1 ) ; bCodeChroma = ( ( uiAbsPartIdx % uiQPDiv ) == 0 ) ; } if ( bSpatial ) { Int trWidth = 1 << uiLog2TrSize ; Int trHeight = 1 << uiLog2TrSize ; m_pcQTTempTComYuv [ uiQTTempAccessLayer ] . copyPartToPartLuma ( pcResi , absTUPartIdx , trWidth , trHeight ) ; if ( bCodeChroma ) { m_pcQTTempTComYuv [ uiQTTempAccessLayer ] . copyPartToPartChroma ( pcResi , uiAbsPartIdx , 1 << uiLog2TrSizeC , 1 << uiLog2TrSizeC ) ; } } else { UInt uiNumCoeffPerAbsPartIdxIncrement = pcCU -> getSlice ( ) -> getSPS ( ) -> getMaxCUWidth ( ) * pcCU -> getSlice ( ) -> getSPS ( ) -> getMaxCUHeight ( ) >> ( pcCU -> getSlice ( ) -> getSPS ( ) -> getMaxCUDepth ( ) << 1 ) ; UInt uiNumCoeffY = ( 1 << ( uiLog2TrSize << 1 ) ) ; TCoeff * pcCoeffSrcY = m_ppcQTTempCoeffY [ uiQTTempAccessLayer ] + uiNumCoeffPerAbsPartIdxIncrement * uiAbsPartIdx ; TCoeff * pcCoeffDstY = pcCU -> getCoeffY ( ) + uiNumCoeffPerAbsPartIdxIncrement * uiAbsPartIdx ; :: memcpy ( pcCoeffDstY , pcCoeffSrcY , sizeof ( TCoeff ) * uiNumCoeffY ) ; #if ADAPTIVE_QP_SELECTION Int * pcArlCoeffSrcY = m_ppcQTTempArlCoeffY [ uiQTTempAccessLayer ] + uiNumCoeffPerAbsPartIdxIncrement * uiAbsPartIdx ; Int * pcArlCoeffDstY = pcCU -> getArlCoeffY ( ) + uiNumCoeffPerAbsPartIdxIncrement * uiAbsPartIdx ; :: memcpy ( pcArlCoeffDstY , pcArlCoeffSrcY , sizeof ( Int ) * uiNumCoeffY ) ; #endif if ( bCodeChroma ) { UInt uiNumCoeffC = ( 1 << ( uiLog2TrSizeC << 1 ) ) ; TCoeff * pcCoeffSrcU = m_ppcQTTempCoeffCb [ uiQTTempAccessLayer ] + ( uiNumCoeffPerAbsPartIdxIncrement * uiAbsPartIdx >> 2 ) ; TCoeff * pcCoeffSrcV = m_ppcQTTempCoeffCr [ uiQTTempAccessLayer ] + ( uiNumCoeffPerAbsPartIdxIncrement * uiAbsPartIdx >> 2 ) ; TCoeff * pcCoeffDstU = pcCU -> getCoeffCb ( ) + ( uiNumCoeffPerAbsPartIdxIncrement * uiAbsPartIdx >> 2 ) ; TCoeff * pcCoeffDstV = pcCU -> getCoeffCr ( ) + ( uiNumCoeffPerAbsPartIdxIncrement * uiAbsPartIdx >> 2 ) ; :: memcpy ( pcCoeffDstU , pcCoeffSrcU , sizeof ( TCoeff ) * uiNumCoeffC ) ; :: memcpy ( pcCoeffDstV , pcCoeffSrcV , sizeof ( TCoeff ) * uiNumCoeffC ) ; #if ADAPTIVE_QP_SELECTION Int * pcArlCoeffSrcU = m_ppcQTTempArlCoeffCb [ uiQTTempAccessLayer ] + ( uiNumCoeffPerAbsPartIdxIncrement * uiAbsPartIdx >> 2 ) ; Int * pcArlCoeffSrcV = m_ppcQTTempArlCoeffCr [ uiQTTempAccessLayer ] + ( uiNumCoeffPerAbsPartIdxIncrement * uiAbsPartIdx >> 2 ) ; Int * pcArlCoeffDstU = pcCU -> getArlCoeffCb ( ) + ( uiNumCoeffPerAbsPartIdxIncrement * uiAbsPartIdx >> 2 ) ; Int * pcArlCoeffDstV = pcCU -> getArlCoeffCr ( ) + ( uiNumCoeffPerAbsPartIdxIncrement * uiAbsPartIdx >> 2 ) ; :: memcpy ( pcArlCoeffDstU , pcArlCoeffSrcU , sizeof ( Int ) * uiNumCoeffC ) ; :: memcpy ( pcArlCoeffDstV , pcArlCoeffSrcV , sizeof ( Int ) * uiNumCoeffC ) ; #endif } } } else { const UInt uiQPartNumSubdiv = pcCU -> getPic ( ) -> getNumPartInCU ( ) >> ( ( uiDepth + 1 ) << 1 ) ; for ( UInt ui = 0 ; ui < 4 ; ++ ui ) { UInt nsAddr = uiAbsPartIdx + ui * uiQPartNumSubdiv ; xSetResidualQTData ( pcCU , ui , uiAbsPartIdx + ui * uiQPartNumSubdiv , nsAddr , pcResi , uiDepth + 1 , bSpatial ) ; } } }
Note: pcResi seems to be only used when bSpatial is true!
Note : pcResi seems to be only used when bSpatial is true!
//------------------------------------- // IF: NO MORE RECURSIVE SUBDIVISION //------------------------------------- //------------------------------------- // IF: bSpatial IS TRUE (CALLER DECIDES) //------------------------------------- //src is m_pcQTTempTComYuv, data is copied to YuvResi //------------------------------------- // ELSE: bSpatial IS FALSE (CALLER DECIDES) //------------------------------------- //------------------------------------- // ELSE: DIVE INTO RECURSIVE SUBDIVISION //-------------------------------------