在HM/JEM中,TEncCu::xCheckBestMode函数用于检验当前模式是否是到目前为止最优的模式,如果当前模式的CU的代价小于之前的最优模式,则做相应的处理,整个函数就是一条if语句(没有else子句)。
/** check whether current try is the best with identifying the depth of current try
* \param rpcBestCU
* \param rpcTempCU
* \param uiDepth
*/
#if JVET_C0024_QTBT
Void TEncCu::xCheckBestMode( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU, UInt uiDepth, UInt uiWidth, UInt uiHeight DEBUG_STRING_FN_DECLARE(sParent) DEBUG_STRING_FN_DECLARE(sTest) DEBUG_STRING_PASS_INTO(Bool bAddSizeInfo) )
#else
Void TEncCu::xCheckBestMode( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU, UInt uiDepth DEBUG_STRING_FN_DECLARE(sParent) DEBUG_STRING_FN_DECLARE(sTest) DEBUG_STRING_PASS_INTO(Bool bAddSizeInfo) )
#endif
{
if( rpcTempCU->getTotalCost() < rpcBestCU->getTotalCost() )
{
TComYuv* pcYuv;
// Change Information data
TComDataCU* pcCU = rpcBestCU;
rpcBestCU = rpcTempCU;
rpcTempCU = pcCU;
#if JVET_C0024_QTBT
if (uiWidth==0 || uiHeight==0)
{
uiWidth = rpcTempCU->getWidth(0);
uiHeight = rpcTempCU->getHeight(0);
}
UInt uiWIdx = g_aucConvertToBit[uiWidth];
UInt uiHIdx = g_aucConvertToBit[uiHeight];
// Change Prediction data
pcYuv = m_pppcPredYuvBest[uiWIdx][uiHIdx];
m_pppcPredYuvBest[uiWIdx][uiHIdx] = m_pppcPredYuvTemp[uiWIdx][uiHIdx];
m_pppcPredYuvTemp[uiWIdx][uiHIdx] = pcYuv;
// Change Reconstruction data
pcYuv = m_pppcRecoYuvBest[uiWIdx][uiHIdx];
m_pppcRecoYuvBest[uiWIdx][uiHIdx] = m_pppcRecoYuvTemp[uiWIdx][uiHIdx];
m_pppcRecoYuvTemp[uiWIdx][uiHIdx] = pcYuv;
#else
// Change Prediction data
pcYuv = m_ppcPredYuvBest[uiDepth];
m_ppcPredYuvBest[uiDepth] = m_ppcPredYuvTemp[uiDepth];
m_ppcPredYuvTemp[uiDepth] = pcYuv;
// Change Reconstruction data
pcYuv = m_ppcRecoYuvBest[uiDepth];
m_ppcRecoYuvBest[uiDepth] = m_ppcRecoYuvTemp[uiDepth];
m_ppcRecoYuvTemp[uiDepth] = pcYuv;
#endif
pcYuv = NULL;
pcCU = NULL;
// store temp best CI for next CU coding
#if JVET_C0024_QTBT
m_ppppcRDSbacCoder[uiWIdx][uiHIdx][CI_TEMP_BEST]->store(m_ppppcRDSbacCoder[uiWIdx][uiHIdx][CI_NEXT_BEST]);
#else
m_pppcRDSbacCoder[uiDepth][CI_TEMP_BEST]->store(m_pppcRDSbacCoder[uiDepth][CI_NEXT_BEST]);
#endif
#if DEBUG_STRING
DEBUG_STRING_SWAP(sParent, sTest)
const PredMode predMode=rpcBestCU->getPredictionMode(0);
if ((DebugOptionList::DebugString_Structure.getInt()&DebugStringGetPredModeMask(predMode)) && bAddSizeInfo)
{
std::stringstream ss(stringstream::out);
ss <<"###: " << (predMode==MODE_INTRA?"Intra ":"Inter ") << partSizeToString[rpcBestCU->getPartitionSize(0)] << " CU at " << rpcBestCU->getCUPelX() << ", " << rpcBestCU->getCUPelY() << " width=" << UInt(rpcBestCU->getWidth(0)) << std::endl;
sParent+=ss.str();
}
#endif
}
}