您的位置:首页 > 编程语言

FVC/JEM代码学习22:xCheckRDCostInterKLT

2018-04-01 20:47 369 查看
在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
b94b
_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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: