VVC/JEM代码学习22:xCheckRDCostInterKLT

26 篇文章 2 订阅

在JEM中新加入了KLT模式,暂时还没看出来哪里体现出了KLT,但是此函数是在执行完帧间,帧内,PCM模式后才会执行。与帧间,帧内,PCM也形成了竞争关系。

#if VCEG_AZ08_INTER_KLT
#if VCEG_AZ08_USE_KLT
	  if (sps.getUseInterKLT())//JEM中新加的;
	  {
#endif
		  if (!rpcBestCU->isIntra(0) && rpcBestCU->getQtRootCbf(0) != 0)//如果最优CU的预测模式不是帧内且cbf不等于0
		  {
			  //Only check from the best modes for speeding up,为了速度,只check最好的模式;
			  g_bEnableCheck = true;
			  Int iQP = rpcBestCU->getQP(0);
#if JVET_C0024_QTBT
			  xCheckRDCostInterKLT(rpcBestCU, rpcTempCU, SIZE_2Nx2N);//JEM里新加的技术;
#else
			  PartSize eSize = rpcBestCU->getPartitionSize(0);
			  xCheckRDCostInterKLT(rpcBestCU, rpcTempCU, eSize);
#endif
			  rpcTempCU->initEstData(uiDepth, iQP, false);
		  }
#if VCEG_AZ08_USE_KLT
	  }
#endif
#endif
#if VCEG_AZ08_INTER_KLT
Void TEncCu::xCheckRDCostInterKLT(TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU, PartSize ePartSize)
{
    DEBUG_STRING_NEW(sTest)

#if JVET_C0024_QTBT
    if( rpcTempCU->getWidth(0) != rpcTempCU->getHeight(0) )//KLT只适用于正方形??
    {
      return;
    }
#endif

    if(getFastDeltaQp())
    {
        const TComSPS &sps=*( rpcTempCU->getSlice()->getSPS());
#if JVET_C0024_QTBT
        const UInt fastDeltaQPCuMaxSize = Clip3(sps.getMinQTSize(rpcBestCU->getSlice()->getSliceType(), rpcBestCU->getTextType()), sps.getCTUSize(), 32u);
#else
        const UInt fastDeltaQPCuMaxSize = Clip3(sps.getMaxCUHeight()>>(sps.getLog2DiffMaxMinCodingBlockSize()), sps.getMaxCUHeight(), 32u);
#endif
        if(ePartSize != SIZE_2Nx2N || rpcTempCU->getWidth( 0 ) > fastDeltaQPCuMaxSize)
        {
            return; // only check necessary 2Nx2N Inter in fast deltaqp mode
        }
    }

    // prior to this, rpcTempCU will have just been reset using rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode );
    UChar uhDepth = rpcTempCU->getDepth(0);

#if COM16_C806_LARGE_CTU
    if (m_pcEncCfg->getUseFastLCTU())//如果使用快速LCTU
    {
        if (ePartSize != SIZE_2Nx2N && rpcTempCU->getWidth(0) > 64)//如果块不为2N*2N且块的宽大于64
        {
            rpcTempCU->getTotalCost() = MAX_DOUBLE / 4;//直接将TempCU的代价赋为MAX_DOUBLE / 4
            rpcTempCU->getTotalDistortion() = MAX_INT;//直接将TempCU的失真赋为MAX_INT
            xCheckBestMode(rpcBestCU, rpcTempCU, uhDepth);//然后将TempCU与BestCU进行比较
            return;
        }
    }
#endif

    Bool bSkipPossible = false;
    rpcTempCU->copySameSizeCUFrom(rpcBestCU, 0, uhDepth);
    UInt uiWidth = rpcTempCU->getWidth(0);
    UInt uiHeigh = rpcTempCU->getHeight(0);
#if JVET_C0024_QTBT
    UInt uiWIdx = g_aucConvertToBit[uiWidth];
    UInt uiHIdx = g_aucConvertToBit[uiHeigh];
    Pel *pYSrc = m_pppcPredYuvBest[uiWIdx][uiHIdx]->getAddr(COMPONENT_Y);
    Pel *pYDst = m_pppcPredYuvTemp[uiWIdx][uiHIdx]->getAddr(COMPONENT_Y);
#else
    Pel *pYSrc = m_ppcPredYuvBest[uhDepth]->getAddr(COMPONENT_Y);
    Pel *pYDst = m_ppcPredYuvTemp[uhDepth]->getAddr(COMPONENT_Y);
#endif
    memcpy(pYDst, pYSrc, sizeof(Pel)*uiWidth*uiHeigh);//将 m_pppcPredYuvBest的亮度分量复制给m_pppcPredYuvTemp
    const UInt componentShiftCb = rpcTempCU->getPic()->getComponentScaleX(COMPONENT_Cb) + rpcTempCU->getPic()->getComponentScaleY(COMPONENT_Cb);
#if JVET_C0024_QTBT
    pYSrc = m_pppcPredYuvBest[uiWIdx][uiHIdx]->getAddr(COMPONENT_Cb);
    pYDst = m_pppcPredYuvTemp[uiWIdx][uiHIdx]->getAddr(COMPONENT_Cb);
#else
    pYSrc = m_ppcPredYuvBest[uhDepth]->getAddr(COMPONENT_Cb);
    pYDst = m_ppcPredYuvTemp[uhDepth]->getAddr(COMPONENT_Cb);
#endif
    memcpy(pYDst, pYSrc, sizeof(Pel)* uiWidth * uiHeigh >> componentShiftCb);//将 m_pppcPredYuvBest的色度分量Cb复制给m_pppcPredYuvTemp
    const UInt componentShiftCr = rpcTempCU->getPic()->getComponentScaleX(COMPONENT_Cb) + rpcTempCU->getPic()->getComponentScaleY(COMPONENT_Cb);
#if JVET_C0024_QTBT
    pYSrc = m_pppcPredYuvBest[uiWIdx][uiHIdx]->getAddr(COMPONENT_Cr);
    pYDst = m_pppcPredYuvTemp[uiWIdx][uiHIdx]->getAddr(COMPONENT_Cb);
#else
    pYSrc = m_ppcPredYuvBest[uhDepth]->getAddr(COMPONENT_Cr);
    pYDst = m_ppcPredYuvTemp[uhDepth]->getAddr(COMPONENT_Cb);
#endif
    memcpy(pYDst, pYSrc, sizeof(Pel)*uiWidth*uiHeigh >> componentShiftCr);//将 m_pppcPredYuvBest的色度分量Cr复制给m_pppcPredYuvTemp
    bSkipPossible = rpcBestCU->getSkipFlag(0);
#if AMP_MRG && !JVET_C0024_QTBT
    if (!rpcTempCU->getMergeAMP())
    {
        return;
    }
#endif

#if COM16_C806_OBMC //QC_OBMC
#if JVET_C0024_QTBT
    m_pcPredSearch->motionCompensation(rpcTempCU, m_pppcPredYuvTemp[uiWIdx][uiHIdx]);//执行运动补偿
    rpcTempCU->setOBMCFlagSubParts(true, 0, uhDepth);
    m_pcPredSearch->subBlockOBMC(rpcTempCU, 0, m_pppcPredYuvTemp[uiWIdx][uiHIdx], m_pppcTmpYuv1[uiWIdx][uiHIdx], m_pppcTmpYuv2[uiWIdx][uiHIdx]);//重叠块运动补偿
#else
    m_pcPredSearch->motionCompensation(rpcTempCU, m_ppcPredYuvTemp[uhDepth]);
    rpcTempCU->setOBMCFlagSubParts(true, 0, uhDepth);
    m_pcPredSearch->subBlockOBMC(rpcTempCU, 0, m_ppcPredYuvTemp[uhDepth], m_ppcTmpYuv1[uhDepth], m_ppcTmpYuv2[uhDepth]);
#endif
#endif

#if JVET_C0024_QTBT
    m_pcPredSearch->encodeResAndCalcRdInterCU( rpcTempCU, m_pppcOrigYuv[uiWIdx][uiHIdx], 
        m_pppcPredYuvTemp[uiWIdx][uiHIdx], m_pppcResiYuvTemp[uiWIdx][uiHIdx], m_pppcResiYuvBest[uiWIdx][uiHIdx], m_pppcRecoYuvTemp[uiWIdx][uiHIdx], false
#else
    m_pcPredSearch->encodeResAndCalcRdInterCU( rpcTempCU, m_ppcOrigYuv[uhDepth], 
        m_ppcPredYuvTemp[uhDepth], m_ppcResiYuvTemp[uhDepth], m_ppcResiYuvBest[uhDepth], m_ppcRecoYuvTemp[uhDepth], false
#endif
#if COM16_C806_EMT
        , rpcBestCU->getTotalCost()
#endif
        DEBUG_STRING_PASS_INTO(sTest)
        );//编码残差并计算失真
    if (bSkipPossible)
    {
        rpcTempCU->setSkipFlagSubParts(rpcTempCU->getQtRootCbf(0) == 0, 0, uhDepth);//如果Cbf等于0,则将SkipFlag设置为1,否则为0;
    }
    xCheckDQP(rpcTempCU);
    xCheckBestMode(rpcBestCU, rpcTempCU, uhDepth);
}
#endif


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值