Ignore:
Timestamp:
2 Jan 2014, 07:21:30 (11 years ago)
Author:
seregin
Message:

update to HM-12.1 base

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/SHM-4.1-dev/source/Lib/TLibEncoder/TEncSearch.cpp

    r494 r532  
    720720  Pel*  piRefPos;
    721721  Int iRefStride = m_filteredBlock[0][0].getStride();
    722 #if NS_HAD
    723   m_pcRdCost->setDistParam( pcPatternKey, m_filteredBlock[0][0].getLumaAddr(), iRefStride, 1, m_cDistParam, m_pcEncCfg->getUseHADME(), m_pcEncCfg->getUseNSQT() );
    724 #else
    725722  m_pcRdCost->setDistParam( pcPatternKey, m_filteredBlock[0][0].getLumaAddr(), iRefStride, 1, m_cDistParam, m_pcEncCfg->getUseHADME() );
    726 #endif
    727723 
    728724  const TComMv* pcMvRefine = (iFrac == 2 ? s_acMvRefineH : s_acMvRefineQ);
     
    737733    piRefPos = m_filteredBlock[ verVal & 3 ][ horVal & 3 ].getLumaAddr();
    738734    if ( horVal == 2 && ( verVal & 1 ) == 0 )
     735    {
    739736      piRefPos += 1;
     737    }
    740738    if ( ( horVal & 1 ) == 0 && verVal == 2 )
     739    {
    741740      piRefPos += iRefStride;
     741    }
    742742    cMvTest = pcMvRefine[i];
    743743    cMvTest += rcMvFrac;
     
    774774  UInt  uiLog2TrafoSize = g_aucConvertToBit[pcCU->getSlice()->getSPS()->getMaxCUWidth()] + 2 - uiFullDepth;
    775775
    776   {
    777     if( pcCU->getPredictionMode(0) == MODE_INTRA && pcCU->getPartitionSize(0) == SIZE_NxN && uiTrDepth == 0 )
    778     {
    779       assert( uiSubdiv );
    780     }
    781     else if( uiLog2TrafoSize > pcCU->getSlice()->getSPS()->getQuadtreeTULog2MaxSize() )
    782     {
    783       assert( uiSubdiv );
    784     }
    785     else if( uiLog2TrafoSize == pcCU->getSlice()->getSPS()->getQuadtreeTULog2MinSize() )
    786     {
    787       assert( !uiSubdiv );
    788     }
    789     else if( uiLog2TrafoSize == pcCU->getQuadtreeTULog2MinSizeInCU(uiAbsPartIdx) )
    790     {
    791       assert( !uiSubdiv );
    792     }
    793     else
    794     {
    795       assert( uiLog2TrafoSize > pcCU->getQuadtreeTULog2MinSizeInCU(uiAbsPartIdx) );
    796       if( bLuma )
    797       {
    798         m_pcEntropyCoder->encodeTransformSubdivFlag( uiSubdiv, 5 - uiLog2TrafoSize );
    799       }
     776  if( pcCU->getPredictionMode(0) == MODE_INTRA && pcCU->getPartitionSize(0) == SIZE_NxN && uiTrDepth == 0 )
     777  {
     778    assert( uiSubdiv );
     779  }
     780  else if( uiLog2TrafoSize > pcCU->getSlice()->getSPS()->getQuadtreeTULog2MaxSize() )
     781  {
     782    assert( uiSubdiv );
     783  }
     784  else if( uiLog2TrafoSize == pcCU->getSlice()->getSPS()->getQuadtreeTULog2MinSize() )
     785  {
     786    assert( !uiSubdiv );
     787  }
     788  else if( uiLog2TrafoSize == pcCU->getQuadtreeTULog2MinSizeInCU(uiAbsPartIdx) )
     789  {
     790    assert( !uiSubdiv );
     791  }
     792  else
     793  {
     794    assert( uiLog2TrafoSize > pcCU->getQuadtreeTULog2MinSizeInCU(uiAbsPartIdx) );
     795    if( bLuma )
     796    {
     797      m_pcEntropyCoder->encodeTransformSubdivFlag( uiSubdiv, 5 - uiLog2TrafoSize );
    800798    }
    801799  }
     
    806804    {
    807805      if( uiTrDepth==0 || pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_U, uiTrDepth-1 ) )
     806      {
    808807        m_pcEntropyCoder->encodeQtCbf( pcCU, uiAbsPartIdx, TEXT_CHROMA_U, uiTrDepth );
     808      }
    809809      if( uiTrDepth==0 || pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_V, uiTrDepth-1 ) )
     810      {
    810811        m_pcEntropyCoder->encodeQtCbf( pcCU, uiAbsPartIdx, TEXT_CHROMA_V, uiTrDepth );
     812      }
    811813    }
    812814  }
     
    822824  }
    823825 
    824   {
    825     //===== Cbfs =====
    826     if( bLuma )
    827     {
    828       m_pcEntropyCoder->encodeQtCbf( pcCU, uiAbsPartIdx, TEXT_LUMA,     uiTrMode );
    829     }
     826  //===== Cbfs =====
     827  if( bLuma )
     828  {
     829    m_pcEntropyCoder->encodeQtCbf( pcCU, uiAbsPartIdx, TEXT_LUMA,     uiTrMode );
    830830  }
    831831}
     
    944944    }
    945945  }
    946 
    947946  if( bChroma )
    948947  {
     
    13061305
    13071306#if RDOQ_CHROMA_LAMBDA
    1308     m_pcTrQuant->selectLambda      (TEXT_CHROMA); 
     1307    m_pcTrQuant->selectLambda(eText);
    13091308#endif
    13101309    m_pcTrQuant->transformNxN      ( pcCU, piResi, uiStride, pcCoeff,
     
    13581357 
    13591358  //===== update distortion =====
    1360 #if WEIGHTED_CHROMA_DISTORTION
    13611359  ruiDist += m_pcRdCost->getDistPart(g_bitDepthC, piReco, uiStride, piOrg, uiStride, uiWidth, uiHeight, eText );
    1362 #else
    1363   ruiDist += m_pcRdCost->getDistPart(g_bitDepthC, piReco, uiStride, piOrg, uiStride, uiWidth, uiHeight );
    1364 #endif
    13651360}
    13661361
     
    25392534     
    25402535      for( Int j=0; j < numCand; j++)
    2541 
    25422536      {
    25432537        Bool mostProbableModeIncluded = false;
     
    30393033                            pcYuvOrg->getLumaAddr( uiAbsPartIdx ), pcYuvOrg->getStride(),
    30403034                            m_tmpYuvPred .getLumaAddr( uiAbsPartIdx ), m_tmpYuvPred .getStride(),
    3041 #if NS_HAD
    3042                             iWidth, iHeight, m_pcEncCfg->getUseHADME(), m_pcEncCfg->getUseNSQT() );
    3043 #else
    30443035                            iWidth, iHeight, m_pcEncCfg->getUseHADME() );
    3045 #endif
    30463036  ruiErr = cDistParam.DistFunc( &cDistParam );
    30473037}
     
    32463236
    32473237    UInt          uiCostTempL0[MAX_NUM_REF];
    3248     for (Int iNumRef=0; iNumRef < MAX_NUM_REF; iNumRef++) uiCostTempL0[iNumRef] = MAX_UINT;
     3238    for (Int iNumRef=0; iNumRef < MAX_NUM_REF; iNumRef++)
     3239    {
     3240      uiCostTempL0[iNumRef] = MAX_UINT;
     3241    }
    32493242    UInt          uiBitsTempL0[MAX_NUM_REF];
    32503243
     
    37163709    {
    37173710      uiLastMode = 2;
    3718       {
    3719             pcCU->getCUMvField(REF_PIC_LIST_0)->setAllMv( cMvBi[0], ePartSize, uiPartAddr, 0, iPartIdx );
    3720             pcCU->getCUMvField(REF_PIC_LIST_0)->setAllRefIdx( iRefIdxBi[0], ePartSize, uiPartAddr, 0, iPartIdx );
    3721             pcCU->getCUMvField(REF_PIC_LIST_1)->setAllMv( cMvBi[1], ePartSize, uiPartAddr, 0, iPartIdx );
    3722             pcCU->getCUMvField(REF_PIC_LIST_1)->setAllRefIdx( iRefIdxBi[1], ePartSize, uiPartAddr, 0, iPartIdx );
    3723       }
    3724       {
    3725         TempMv = cMvBi[0] - cMvPredBi[0][iRefIdxBi[0]];
    3726             pcCU->getCUMvField(REF_PIC_LIST_0)->setAllMvd    ( TempMv,                 ePartSize, uiPartAddr, 0, iPartIdx );
    3727       }
    3728       {
    3729         TempMv = cMvBi[1] - cMvPredBi[1][iRefIdxBi[1]];
    3730             pcCU->getCUMvField(REF_PIC_LIST_1)->setAllMvd    ( TempMv,                 ePartSize, uiPartAddr, 0, iPartIdx );
    3731       }
     3711      pcCU->getCUMvField(REF_PIC_LIST_0)->setAllMv( cMvBi[0], ePartSize, uiPartAddr, 0, iPartIdx );
     3712      pcCU->getCUMvField(REF_PIC_LIST_0)->setAllRefIdx( iRefIdxBi[0], ePartSize, uiPartAddr, 0, iPartIdx );
     3713      pcCU->getCUMvField(REF_PIC_LIST_1)->setAllMv( cMvBi[1], ePartSize, uiPartAddr, 0, iPartIdx );
     3714      pcCU->getCUMvField(REF_PIC_LIST_1)->setAllRefIdx( iRefIdxBi[1], ePartSize, uiPartAddr, 0, iPartIdx );
     3715     
     3716      TempMv = cMvBi[0] - cMvPredBi[0][iRefIdxBi[0]];
     3717      pcCU->getCUMvField(REF_PIC_LIST_0)->setAllMvd    ( TempMv,                 ePartSize, uiPartAddr, 0, iPartIdx );
     3718     
     3719      TempMv = cMvBi[1] - cMvPredBi[1][iRefIdxBi[1]];
     3720      pcCU->getCUMvField(REF_PIC_LIST_1)->setAllMvd    ( TempMv,                 ePartSize, uiPartAddr, 0, iPartIdx );
    37323721     
    37333722      pcCU->setInterDirSubParts( 3, uiPartAddr, iPartIdx, pcCU->getDepth(0) );
     
    37433732    {
    37443733      uiLastMode = 0;
    3745           pcCU->getCUMvField(REF_PIC_LIST_0)->setAllMv( cMv[0], ePartSize, uiPartAddr, 0, iPartIdx );
    3746           pcCU->getCUMvField(REF_PIC_LIST_0)->setAllRefIdx( iRefIdx[0], ePartSize, uiPartAddr, 0, iPartIdx );
    3747       {
    3748         TempMv = cMv[0] - cMvPred[0][iRefIdx[0]];
    3749             pcCU->getCUMvField(REF_PIC_LIST_0)->setAllMvd    ( TempMv,                 ePartSize, uiPartAddr, 0, iPartIdx );
    3750       }
     3734      pcCU->getCUMvField(REF_PIC_LIST_0)->setAllMv( cMv[0], ePartSize, uiPartAddr, 0, iPartIdx );
     3735      pcCU->getCUMvField(REF_PIC_LIST_0)->setAllRefIdx( iRefIdx[0], ePartSize, uiPartAddr, 0, iPartIdx );
     3736      TempMv = cMv[0] - cMvPred[0][iRefIdx[0]];
     3737      pcCU->getCUMvField(REF_PIC_LIST_0)->setAllMvd    ( TempMv,                 ePartSize, uiPartAddr, 0, iPartIdx );
    37513738      pcCU->setInterDirSubParts( 1, uiPartAddr, iPartIdx, pcCU->getDepth(0) );
    37523739     
     
    37593746    {
    37603747      uiLastMode = 1;
    3761           pcCU->getCUMvField(REF_PIC_LIST_1)->setAllMv( cMv[1], ePartSize, uiPartAddr, 0, iPartIdx );
    3762           pcCU->getCUMvField(REF_PIC_LIST_1)->setAllRefIdx( iRefIdx[1], ePartSize, uiPartAddr, 0, iPartIdx );
    3763       {
    3764         TempMv = cMv[1] - cMvPred[1][iRefIdx[1]];
    3765             pcCU->getCUMvField(REF_PIC_LIST_1)->setAllMvd    ( TempMv,                 ePartSize, uiPartAddr, 0, iPartIdx );
    3766       }
     3748      pcCU->getCUMvField(REF_PIC_LIST_1)->setAllMv( cMv[1], ePartSize, uiPartAddr, 0, iPartIdx );
     3749      pcCU->getCUMvField(REF_PIC_LIST_1)->setAllRefIdx( iRefIdx[1], ePartSize, uiPartAddr, 0, iPartIdx );
     3750      TempMv = cMv[1] - cMvPred[1][iRefIdx[1]];
     3751      pcCU->getCUMvField(REF_PIC_LIST_1)->setAllMvd    ( TempMv,                 ePartSize, uiPartAddr, 0, iPartIdx );
    37673752      pcCU->setInterDirSubParts( 2, uiPartAddr, iPartIdx, pcCU->getDepth(0) );
    37683753     
     
    38163801        pcCU->setMergeIndexSubParts( uiMRGIndex,    uiPartAddr, iPartIdx, pcCU->getDepth( uiPartAddr ) );
    38173802        pcCU->setInterDirSubParts  ( uiMRGInterDir, uiPartAddr, iPartIdx, pcCU->getDepth( uiPartAddr ) );
    3818         {
    3819           pcCU->getCUMvField( REF_PIC_LIST_0 )->setAllMvField( cMRGMvField[0], ePartSize, uiPartAddr, 0, iPartIdx );
    3820           pcCU->getCUMvField( REF_PIC_LIST_1 )->setAllMvField( cMRGMvField[1], ePartSize, uiPartAddr, 0, iPartIdx );
    3821         }
     3803        pcCU->getCUMvField( REF_PIC_LIST_0 )->setAllMvField( cMRGMvField[0], ePartSize, uiPartAddr, 0, iPartIdx );
     3804        pcCU->getCUMvField( REF_PIC_LIST_1 )->setAllMvField( cMRGMvField[1], ePartSize, uiPartAddr, 0, iPartIdx );
    38223805
    38233806        pcCU->getCUMvField(REF_PIC_LIST_0)->setAllMvd    ( cMvZero,            ePartSize, uiPartAddr, 0, iPartIdx );
     
    38343817        pcCU->setMergeFlagSubParts( false,        uiPartAddr, iPartIdx, pcCU->getDepth( uiPartAddr ) );
    38353818        pcCU->setInterDirSubParts ( uiMEInterDir, uiPartAddr, iPartIdx, pcCU->getDepth( uiPartAddr ) );
    3836         {
    3837           pcCU->getCUMvField( REF_PIC_LIST_0 )->setAllMvField( cMEMvField[0], ePartSize, uiPartAddr, 0, iPartIdx );
    3838           pcCU->getCUMvField( REF_PIC_LIST_1 )->setAllMvField( cMEMvField[1], ePartSize, uiPartAddr, 0, iPartIdx );
    3839         }
     3819        pcCU->getCUMvField( REF_PIC_LIST_0 )->setAllMvField( cMEMvField[0], ePartSize, uiPartAddr, 0, iPartIdx );
     3820        pcCU->getCUMvField( REF_PIC_LIST_1 )->setAllMvField( cMEMvField[1], ePartSize, uiPartAddr, 0, iPartIdx );
    38403821      }
    38413822    }
     
    39443925 
    39453926  if (iNum == 1)
     3927  {
    39463928    return 0;
     3929  }
    39473930 
    39483931  UInt uiLength = 1;
     
    41234106                            pcOrgYuv->getLumaAddr(uiPartAddr), pcOrgYuv->getStride(),
    41244107                            pcTemplateCand->getLumaAddr(uiPartAddr), pcTemplateCand->getStride(),
    4125 #if NS_HAD
    4126                             iSizeX, iSizeY, m_pcEncCfg->getUseHADME(), m_pcEncCfg->getUseNSQT() );
    4127 #else
    41284108                            iSizeX, iSizeY, m_pcEncCfg->getUseHADME() );
    4129 #endif
    41304109  ruiDist = cDistParam.DistFunc( &cDistParam );
    41314110  uiCost = ruiDist + m_pcRdCost->getCost( m_auiMVPIdxCost[iMVPIdx][iMVPNum] );
    41324111#else
    4133 #if WEIGHTED_CHROMA_DISTORTION
    41344112  uiCost = m_pcRdCost->getDistPart(g_bitDepthY, pcTemplateCand->getLumaAddr(uiPartAddr), pcTemplateCand->getStride(), pcOrgYuv->getLumaAddr(uiPartAddr), pcOrgYuv->getStride(), iSizeX, iSizeY, TEXT_LUMA, DF_SAD );
    4135 #else
    4136   uiCost = m_pcRdCost->getDistPart(g_bitDepthY, pcTemplateCand->getLumaAddr(uiPartAddr), pcTemplateCand->getStride(), pcOrgYuv->getLumaAddr(uiPartAddr), pcOrgYuv->getStride(), iSizeX, iSizeY, DF_SAD );
    4137 #endif
    41384113  uiCost = (UInt) m_pcRdCost->calcRdCost( m_auiMVPIdxCost[iMVPIdx][iMVPNum], uiCost, false, DF_SAD );
    41394114#endif
     
    42284203  m_pcRdCost->getMotionCost( 1, 0 );
    42294204  m_pcRdCost->setCostScale ( 1 );
    4230  
    4231   {
     4205
    42324206#if REF_IDX_ME_ZEROMV
    4233     if( pcCU->getSlice()->getRefPic( eRefPicList, iRefIdxPred )->isILR(pcCU->getLayerId()))  //ILR reference pic
    4234     {
    4235       xPatternSearchFracDIFMv0( pcCU, pcPatternKey, piRefY, iRefStride, &rcMv, cMvHalf, cMvQter, ruiCost, bBi );
    4236     }
    4237     else    //non ILR reference pic
    4238     {
    4239       xPatternSearchFracDIF( pcCU, pcPatternKey, piRefY, iRefStride, &rcMv, cMvHalf, cMvQter, ruiCost, bBi );
    4240     }
     4207  if( pcCU->getSlice()->getRefPic( eRefPicList, iRefIdxPred )->isILR(pcCU->getLayerId()))  //ILR reference pic
     4208  {
     4209    xPatternSearchFracDIFMv0( pcCU, pcPatternKey, piRefY, iRefStride, &rcMv, cMvHalf, cMvQter, ruiCost, bBi );
     4210  }
     4211  else    //non ILR reference pic
     4212  {
     4213    xPatternSearchFracDIF( pcCU, pcPatternKey, piRefY, iRefStride, &rcMv, cMvHalf, cMvQter, ruiCost, bBi );
     4214  }
    42414215#else
    4242     xPatternSearchFracDIF( pcCU, pcPatternKey, piRefY, iRefStride, &rcMv, cMvHalf, cMvQter, ruiCost
    4243                           ,bBi
    4244                           );
    4245 #endif
    4246   }
    4247  
    4248  
    4249  
     4216  xPatternSearchFracDIF( pcCU, pcPatternKey, piRefY, iRefStride, &rcMv, cMvHalf, cMvQter, ruiCost,bBi );
     4217#endif
     4218
    42504219  m_pcRdCost->setCostScale( 0 );
    42514220  rcMv <<= 2;
     
    46014570    pcYuvPred->copyToPartYuv( rpcYuvRec, 0 );
    46024571   
    4603 #if WEIGHTED_CHROMA_DISTORTION
    46044572    uiDistortion = m_pcRdCost->getDistPart(g_bitDepthY, rpcYuvRec->getLumaAddr(), rpcYuvRec->getStride(),  pcYuvOrg->getLumaAddr(), pcYuvOrg->getStride(),  uiWidth,      uiHeight      )
    46054573    + m_pcRdCost->getDistPart(g_bitDepthC, rpcYuvRec->getCbAddr(),   rpcYuvRec->getCStride(), pcYuvOrg->getCbAddr(),   pcYuvOrg->getCStride(), uiWidth >> 1, uiHeight >> 1, TEXT_CHROMA_U )
    46064574    + m_pcRdCost->getDistPart(g_bitDepthC, rpcYuvRec->getCrAddr(),   rpcYuvRec->getCStride(), pcYuvOrg->getCrAddr(),   pcYuvOrg->getCStride(), uiWidth >> 1, uiHeight >> 1, TEXT_CHROMA_V );
    4607 #else
    4608     uiDistortion = m_pcRdCost->getDistPart(g_bitDepthY, rpcYuvRec->getLumaAddr(), rpcYuvRec->getStride(),  pcYuvOrg->getLumaAddr(), pcYuvOrg->getStride(),  uiWidth,      uiHeight      )
    4609     + m_pcRdCost->getDistPart(g_bitDepthC, rpcYuvRec->getCbAddr(),   rpcYuvRec->getCStride(), pcYuvOrg->getCbAddr(),   pcYuvOrg->getCStride(), uiWidth >> 1, uiHeight >> 1 )
    4610     + m_pcRdCost->getDistPart(g_bitDepthC, rpcYuvRec->getCrAddr(),   rpcYuvRec->getCStride(), pcYuvOrg->getCrAddr(),   pcYuvOrg->getCStride(), uiWidth >> 1, uiHeight >> 1 );
    4611 #endif
    46124575
    46134576    if( m_bUseSBACRD )
     4577    {
    46144578      m_pcRDGoOnSbacCoder->load(m_pppcRDSbacCoder[pcCU->getDepth(0)][CI_CURR_BEST]);
     4579    }
    46154580   
    46164581    m_pcEntropyCoder->resetBits();
     
    46284593   
    46294594    if( m_bUseSBACRD )
     4595    {
    46304596      m_pcRDGoOnSbacCoder->store(m_pppcRDSbacCoder[pcCU->getDepth(0)][CI_TEMP_BEST]);
     4597    }
    46314598   
    46324599    pcCU->setCbfSubParts( 0, 0, 0, 0, pcCU->getDepth( 0 ) );
     
    47994766 
    48004767  // update with clipped distortion and cost (qp estimation loop uses unclipped values)
    4801 #if WEIGHTED_CHROMA_DISTORTION
    48024768    uiDistortionBest = m_pcRdCost->getDistPart(g_bitDepthY, rpcYuvRec->getLumaAddr(), rpcYuvRec->getStride(),  pcYuvOrg->getLumaAddr(), pcYuvOrg->getStride(),  uiWidth,      uiHeight      )
    48034769    + m_pcRdCost->getDistPart(g_bitDepthC, rpcYuvRec->getCbAddr(),   rpcYuvRec->getCStride(), pcYuvOrg->getCbAddr(),   pcYuvOrg->getCStride(), uiWidth >> 1, uiHeight >> 1, TEXT_CHROMA_U )
    48044770    + m_pcRdCost->getDistPart(g_bitDepthC, rpcYuvRec->getCrAddr(),   rpcYuvRec->getCStride(), pcYuvOrg->getCrAddr(),   pcYuvOrg->getCStride(), uiWidth >> 1, uiHeight >> 1, TEXT_CHROMA_V );
    4805 #else
    4806   uiDistortionBest = m_pcRdCost->getDistPart(g_bitDepthY, rpcYuvRec->getLumaAddr(), rpcYuvRec->getStride(),  pcYuvOrg->getLumaAddr(), pcYuvOrg->getStride(),  uiWidth,      uiHeight      )
    4807   + m_pcRdCost->getDistPart(g_bitDepthC, rpcYuvRec->getCbAddr(),   rpcYuvRec->getCStride(), pcYuvOrg->getCbAddr(),   pcYuvOrg->getCStride(), uiWidth >> 1, uiHeight >> 1 )
    4808   + m_pcRdCost->getDistPart(g_bitDepthC, rpcYuvRec->getCrAddr(),   rpcYuvRec->getCStride(), pcYuvOrg->getCrAddr(),   pcYuvOrg->getCStride(), uiWidth >> 1, uiHeight >> 1 );
    4809 #endif
    48104771  dCostBest = m_pcRdCost->calcRdCost( uiBitsBest, uiDistortionBest );
    48114772 
     
    48324793  Bool bCheckFull;
    48334794  if ( SplitFlag && uiDepth == pcCU->getDepth(uiAbsPartIdx) && ( uiLog2TrSize >  pcCU->getQuadtreeTULog2MinSizeInCU(uiAbsPartIdx) ) )
     4795  {
    48344796     bCheckFull = false;
     4797  }
    48354798  else
     4799  {
    48364800     bCheckFull =  ( uiLog2TrSize <= pcCU->getSlice()->getSPS()->getQuadtreeTULog2MaxSize() );
     4801  }
    48374802
    48384803  const Bool bCheckSplit  = ( uiLog2TrSize >  pcCU->getQuadtreeTULog2MinSizeInCU(uiAbsPartIdx) );
     
    49324897
    49334898#if RDOQ_CHROMA_LAMBDA
    4934       m_pcTrQuant->selectLambda(TEXT_CHROMA);
     4899      m_pcTrQuant->selectLambda(TEXT_CHROMA_U);
    49354900#endif
    49364901
     
    49434908      curChromaQpOffset = pcCU->getSlice()->getPPS()->getChromaCrQpOffset() + pcCU->getSlice()->getSliceQpDeltaCr();
    49444909      m_pcTrQuant->setQPforQuant( pcCU->getQP( 0 ), TEXT_CHROMA, pcCU->getSlice()->getSPS()->getQpBDOffsetC(), curChromaQpOffset );
     4910     
     4911#if RDOQ_CHROMA_LAMBDA
     4912      m_pcTrQuant->selectLambda(TEXT_CHROMA_V);
     4913#endif
     4914
    49454915      m_pcTrQuant->transformNxN( pcCU, pcResi->getCrAddr(absTUPartIdxC), pcResi->getCStride(), pcCoeffCurrV,
    49464916#if ADAPTIVE_QP_SELECTION
     
    49554925    m_pcEntropyCoder->resetBits();
    49564926   
    4957     {
    4958       m_pcEntropyCoder->encodeQtCbf( pcCU, uiAbsPartIdx, TEXT_LUMA,     uiTrMode );
    4959     }
    4960    
     4927    m_pcEntropyCoder->encodeQtCbf( pcCU, uiAbsPartIdx, TEXT_LUMA,     uiTrMode );
     4928
    49614929    m_pcEntropyCoder->encodeCoeffNxN( pcCU, pcCoeffCurrY, uiAbsPartIdx,  trWidth,  trHeight,    uiDepth, TEXT_LUMA );
    49624930    const UInt uiSingleBitsY = m_pcEntropyCoder->getNumberOfWrittenBits();
     
    49664934    if( bCodeChroma )
    49674935    {
    4968       {
    4969         m_pcEntropyCoder->encodeQtCbf   ( pcCU, uiAbsPartIdx, TEXT_CHROMA_U, uiTrMode );
    4970       }
     4936      m_pcEntropyCoder->encodeQtCbf   ( pcCU, uiAbsPartIdx, TEXT_CHROMA_U, uiTrMode );
    49714937      m_pcEntropyCoder->encodeCoeffNxN( pcCU, pcCoeffCurrU, uiAbsPartIdx, trWidthC, trHeightC, uiDepth, TEXT_CHROMA_U );
    49724938      uiSingleBitsU = m_pcEntropyCoder->getNumberOfWrittenBits() - uiSingleBitsY;
    49734939     
    4974       {
    4975         m_pcEntropyCoder->encodeQtCbf   ( pcCU, uiAbsPartIdx, TEXT_CHROMA_V, uiTrMode );
    4976       }
     4940      m_pcEntropyCoder->encodeQtCbf   ( pcCU, uiAbsPartIdx, TEXT_CHROMA_V, uiTrMode );
    49774941      m_pcEntropyCoder->encodeCoeffNxN( pcCU, pcCoeffCurrV, uiAbsPartIdx, trWidthC, trHeightC, uiDepth, TEXT_CHROMA_V );
    49784942      uiSingleBitsV = m_pcEntropyCoder->getNumberOfWrittenBits() - ( uiSingleBitsY + uiSingleBitsU );
     
    50034967      assert(scalingListType < 6);     
    50044968      m_pcTrQuant->invtransformNxN( pcCU->getCUTransquantBypass(uiAbsPartIdx), TEXT_LUMA,REG_DCT, pcResiCurrY, m_pcQTTempTComYuv[uiQTTempAccessLayer].getStride(),  pcCoeffCurrY, trWidth, trHeight, scalingListType );//this is for inter mode only
     4969     
    50054970      const UInt uiNonzeroDistY = m_pcRdCost->getDistPart(g_bitDepthY, m_pcQTTempTComYuv[uiQTTempAccessLayer].getLumaAddr( absTUPartIdx ), m_pcQTTempTComYuv[uiQTTempAccessLayer].getStride(),
    50064971      pcResi->getLumaAddr( absTUPartIdx ), pcResi->getStride(), trWidth,trHeight );
     
    50595024    {
    50605025      uiDistU = m_pcRdCost->getDistPart(g_bitDepthC, m_pTempPel, trWidthC, pcResi->getCbAddr( absTUPartIdxC ), pcResi->getCStride(), trWidthC, trHeightC
    5061 #if WEIGHTED_CHROMA_DISTORTION
    50625026                                        , TEXT_CHROMA_U
    5063 #endif
    50645027                                        ); // initialized with zero residual destortion
    50655028      if ( puiZeroDist )
     
    50805043        const UInt uiNonzeroDistU = m_pcRdCost->getDistPart(g_bitDepthC, m_pcQTTempTComYuv[uiQTTempAccessLayer].getCbAddr( absTUPartIdxC), m_pcQTTempTComYuv[uiQTTempAccessLayer].getCStride(),
    50815044                                                            pcResi->getCbAddr( absTUPartIdxC), pcResi->getCStride(), trWidthC, trHeightC
    5082 #if WEIGHTED_CHROMA_DISTORTION
    50835045                                                            , TEXT_CHROMA_U
    5084 #endif
    50855046                                                            );
    50865047
     
    51185079      {
    51195080        m_pcEntropyCoder->resetBits();
    5120         m_pcEntropyCoder->encodeQtCbfZero( pcCU, TEXT_CHROMA_U, uiTrModeC );
     5081        m_pcEntropyCoder->encodeQtCbfZero( pcCU, TEXT_CHROMA_U, uiTrMode );
    51215082        const UInt uiNullBitsU = m_pcEntropyCoder->getNumberOfWrittenBits();
    51225083        minCostU = m_pcRdCost->calcRdCost( uiNullBitsU, uiDistU );
     
    51345095     
    51355096      uiDistV = m_pcRdCost->getDistPart(g_bitDepthC, m_pTempPel, trWidthC, pcResi->getCrAddr( absTUPartIdxC), pcResi->getCStride(), trWidthC, trHeightC
    5136 #if WEIGHTED_CHROMA_DISTORTION
    51375097                                        , TEXT_CHROMA_V
    5138 #endif
    51395098                                        ); // initialized with zero residual destortion
    51405099      if ( puiZeroDist )
     
    51545113        const UInt uiNonzeroDistV = m_pcRdCost->getDistPart(g_bitDepthC, m_pcQTTempTComYuv[uiQTTempAccessLayer].getCrAddr( absTUPartIdxC ), m_pcQTTempTComYuv[uiQTTempAccessLayer].getCStride(),
    51555114                                                            pcResi->getCrAddr( absTUPartIdxC ), pcResi->getCStride(), trWidthC, trHeightC
    5156 #if WEIGHTED_CHROMA_DISTORTION
    51575115                                                            , TEXT_CHROMA_V
    5158 #endif
    51595116                                                            );
    51605117        if (pcCU->isLosslessCoded(0))
     
    51915148      {
    51925149        m_pcEntropyCoder->resetBits();
    5193         m_pcEntropyCoder->encodeQtCbfZero( pcCU, TEXT_CHROMA_V, uiTrModeC );
     5150        m_pcEntropyCoder->encodeQtCbfZero( pcCU, TEXT_CHROMA_V, uiTrMode );
    51945151        const UInt uiNullBitsV = m_pcEntropyCoder->getNumberOfWrittenBits();
    51955152        minCostV = m_pcRdCost->calcRdCost( uiNullBitsV, uiDistV );
     
    53525309
    53535310#if RDOQ_CHROMA_LAMBDA
    5354       m_pcTrQuant->selectLambda(TEXT_CHROMA);
     5311      m_pcTrQuant->selectLambda(TEXT_CHROMA_U);
    53555312#endif
    53565313
     
    53625319      curChromaQpOffset = pcCU->getSlice()->getPPS()->getChromaCrQpOffset() + pcCU->getSlice()->getSliceQpDeltaCr();
    53635320      m_pcTrQuant->setQPforQuant( pcCU->getQP( 0 ), TEXT_CHROMA, pcCU->getSlice()->getSPS()->getQpBDOffsetC(), curChromaQpOffset );
     5321#if RDOQ_CHROMA_LAMBDA
     5322      m_pcTrQuant->selectLambda(TEXT_CHROMA_V);
     5323#endif
    53645324      m_pcTrQuant->transformNxN( pcCU, pcResi->getCrAddr(absTUPartIdxC), pcResi->getCStride(), pcCoeffCurrV,
    53655325#if ADAPTIVE_QP_SELECTION
     
    53915351        uiNonzeroDistU = m_pcRdCost->getDistPart(g_bitDepthC, m_pcQTTempTComYuv[uiQTTempAccessLayer].getCbAddr( absTUPartIdxC), m_pcQTTempTComYuv[uiQTTempAccessLayer].getCStride(),
    53925352                                                 pcResi->getCbAddr( absTUPartIdxC), pcResi->getCStride(), trWidthC, trHeightC
    5393 #if WEIGHTED_CHROMA_DISTORTION
    53945353                                                 , TEXT_CHROMA_U
    5395 #endif
    53965354                                                 );
    53975355
     
    54355393        uiNonzeroDistV = m_pcRdCost->getDistPart(g_bitDepthC, m_pcQTTempTComYuv[uiQTTempAccessLayer].getCrAddr( absTUPartIdxC ), m_pcQTTempTComYuv[uiQTTempAccessLayer].getCStride(),
    54365394                                                 pcResi->getCrAddr( absTUPartIdxC ), pcResi->getCStride(), trWidthC, trHeightC
    5437 #if WEIGHTED_CHROMA_DISTORTION
    54385395                                                 , TEXT_CHROMA_V
    5439 #endif
    54405396                                                 );
    54415397
     
    54745430    m_pcEntropyCoder->resetBits();
    54755431
    5476     {
    5477       if( uiLog2TrSize > pcCU->getQuadtreeTULog2MinSizeInCU(uiAbsPartIdx) )
    5478       {
    5479         m_pcEntropyCoder->encodeTransformSubdivFlag( 0, 5 - uiLog2TrSize );
    5480       }
    5481     }
    5482 
    5483     {
    5484       if( bCodeChroma )
    5485       {
    5486         m_pcEntropyCoder->encodeQtCbf( pcCU, uiAbsPartIdx, TEXT_CHROMA_U, uiTrMode );
    5487         m_pcEntropyCoder->encodeQtCbf( pcCU, uiAbsPartIdx, TEXT_CHROMA_V, uiTrMode );
    5488       }
    5489 
    5490       m_pcEntropyCoder->encodeQtCbf( pcCU, uiAbsPartIdx, TEXT_LUMA,     uiTrMode );
    5491     }
     5432    if( uiLog2TrSize > pcCU->getQuadtreeTULog2MinSizeInCU(uiAbsPartIdx) )
     5433    {
     5434      m_pcEntropyCoder->encodeTransformSubdivFlag( 0, 5 - uiLog2TrSize );
     5435    }
     5436
     5437    if( bCodeChroma )
     5438    {
     5439      m_pcEntropyCoder->encodeQtCbf( pcCU, uiAbsPartIdx, TEXT_CHROMA_U, uiTrMode );
     5440      m_pcEntropyCoder->encodeQtCbf( pcCU, uiAbsPartIdx, TEXT_CHROMA_V, uiTrMode );
     5441    }
     5442
     5443    m_pcEntropyCoder->encodeQtCbf( pcCU, uiAbsPartIdx, TEXT_LUMA,     uiTrMode );
    54925444
    54935445    m_pcEntropyCoder->encodeCoeffNxN( pcCU, pcCoeffCurrY, uiAbsPartIdx, trWidth, trHeight,    uiDepth, TEXT_LUMA );
     
    55465498    m_pcEntropyCoder->resetBits();
    55475499   
    5548     {
    5549       xEncodeResidualQT( pcCU, uiAbsPartIdx, uiDepth, true,  TEXT_LUMA );
    5550       xEncodeResidualQT( pcCU, uiAbsPartIdx, uiDepth, false, TEXT_LUMA );
    5551       xEncodeResidualQT( pcCU, uiAbsPartIdx, uiDepth, false, TEXT_CHROMA_U );
    5552       xEncodeResidualQT( pcCU, uiAbsPartIdx, uiDepth, false, TEXT_CHROMA_V );
    5553     }
    5554    
     5500    xEncodeResidualQT( pcCU, uiAbsPartIdx, uiDepth, true,  TEXT_LUMA );
     5501    xEncodeResidualQT( pcCU, uiAbsPartIdx, uiDepth, false, TEXT_LUMA );
     5502    xEncodeResidualQT( pcCU, uiAbsPartIdx, uiDepth, false, TEXT_CHROMA_U );
     5503    xEncodeResidualQT( pcCU, uiAbsPartIdx, uiDepth, false, TEXT_CHROMA_V );
     5504
    55555505    uiSubdivBits = m_pcEntropyCoder->getNumberOfWrittenBits();
    55565506    dSubdivCost  = m_pcRdCost->calcRdCost( uiSubdivBits, uiSubdivDist );
     
    56025552  const UInt uiLog2TrSize = g_aucConvertToBit[pcCU->getSlice()->getSPS()->getMaxCUWidth() >> uiDepth]+2;
    56035553
    5604   {
    5605     if( bSubdivAndCbf && uiLog2TrSize <= pcCU->getSlice()->getSPS()->getQuadtreeTULog2MaxSize() && uiLog2TrSize > pcCU->getQuadtreeTULog2MinSizeInCU(uiAbsPartIdx) )
    5606     {
    5607       m_pcEntropyCoder->encodeTransformSubdivFlag( bSubdiv, 5 - uiLog2TrSize );
    5608     }
    5609   }
    5610 
    5611   {
    5612     assert( pcCU->getPredictionMode(uiAbsPartIdx) != MODE_INTRA );
     5554  if( bSubdivAndCbf && uiLog2TrSize <= pcCU->getSlice()->getSPS()->getQuadtreeTULog2MaxSize() && uiLog2TrSize > pcCU->getQuadtreeTULog2MinSizeInCU(uiAbsPartIdx) )
     5555  {
     5556    m_pcEntropyCoder->encodeTransformSubdivFlag( bSubdiv, 5 - uiLog2TrSize );
     5557  }
     5558
     5559  assert( pcCU->getPredictionMode(uiAbsPartIdx) != MODE_INTRA );
    56135560    if( bSubdivAndCbf )
    56145561    {
     
    56315578      }
    56325579    }
    5633   }
    56345580 
    56355581  if( !bSubdiv )
     
    56555601    if( bSubdivAndCbf )
    56565602    {
    5657       {
    5658         m_pcEntropyCoder->encodeQtCbf( pcCU, uiAbsPartIdx, TEXT_LUMA,     uiTrMode );
    5659       }
     5603      m_pcEntropyCoder->encodeQtCbf( pcCU, uiAbsPartIdx, TEXT_LUMA,     uiTrMode );
    56605604    }
    56615605    else
     
    57255669      if( bCodeChroma )
    57265670      {
    5727         {
    5728           m_pcQTTempTComYuv[uiQTTempAccessLayer].copyPartToPartChroma( pcResi, uiAbsPartIdx, 1 << uiLog2TrSizeC, 1 << uiLog2TrSizeC );
    5729         }
     5671        m_pcQTTempTComYuv[uiQTTempAccessLayer].copyPartToPartChroma( pcResi, uiAbsPartIdx, 1 << uiLog2TrSizeC, 1 << uiLog2TrSizeC );
    57305672      }
    57315673    }
     
    58475789    m_pcEntropyCoder->encodePartSize( pcCU, 0, pcCU->getDepth(0), true );
    58485790    m_pcEntropyCoder->encodePredInfo( pcCU, 0, true );
    5849 
    58505791    Bool bDummy = false;
    58515792    m_pcEntropyCoder->encodeCoeff   ( pcCU, 0, pcCU->getDepth(0), pcCU->getWidth(0), pcCU->getHeight(0), bDummy );
Note: See TracChangeset for help on using the changeset viewer.