HM/JEM检查当前CU的模式是否是最优模式

本文介绍HM/JEM中TEncCu::xCheckBestMode函数的作用及实现细节,该函数用于检查并更新当前最佳编码模式,通过比较不同模式下的CU代价来确定最优模式。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

在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
  }
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值