VTM1.0代码阅读:xEncodeInterResidual函数

xEncodeInterResidual在merge和inter_ME中扮演关键角色,用于根据预测运动信息进行运动补偿,计算失真和成本。此函数在MC后调用,比较不同模式并为bestCS选择最优解。它通过encodeResAndCalcRdInterCU函数计算inter模式的cost,并在xCheckBestMode中更新最佳模式信息。
摘要由CSDN通过智能技术生成

xEncodeInterResidual在merge和inter_ME中都会被调用,xCheckRDCostMerge2Nx2N函数和xCheckRDCostInter函数,都会在函数末尾根据预测得到的运动信息进行运动补偿MC,来获取预测像素信息。MC之后就会调用xEncodeInterResidual函数,根据预测像素计算失真和cost,最后将最优模式信息赋给bestCS。
xEncodeInterResidual函数计算inter预测模式的失真和cost,之后赋给bestCS最优模式信息。
tempCS中存储有当前inter_ME或merge模式的最优mv和预测信息,bestCS存储之前test过的各种模式中的最优模式信息。
函数中调用encodeResAndCalcRdInterCU函数根据得到的预测像素计算当前inter模式的cost,函数最后调用xCheckBestMode函数将最优模式信息赋给bestCS。

void EncCu::xEncodeInterResidual( CodingStructure *&tempCS, CodingStructure *&bestCS, Partitioner &partitioner, const EncTestMode& encTestMode, int residualPass, bool* bestHasNonResi )
{
   
  if( residualPass == 1 && encTestMode.lossless )
  {
   
    return;
  }

  CodingUnit*            cu        = tempCS->getCU( partitioner.chType );
  double   bestCostInternal        = MAX_DOUBLE;
  
  {
   
    cu->skip    = false;

    const bool skipResidual = residualPass == 1;		//是否为skip模式,没有残差
    m_pcInterSearch->encodeResAndCalcRdInterCU( *tempCS, partitioner, skipResidual );
												//计算当前模式的最优运动信息下的cost
    xCheckDQP( *tempCS, partitioner );

    if( NULL != bestHasNonResi && (bestCostInternal > tempCS->cost) )
    {
   
      bestCostInternal = tempCS->cost;
      *bestHasNonResi  = !cu->rootCbf;
    }

    DTRACE_MODE_COST( *tempCS, m_pcRdCost->getLambda() );
												//根据cost,将最优模式信息赋给bestCS
    xCheckBestMode( tempCS, bestCS, partitioner, encTestMode );
	
  }//end emt loop 
}

encodeResAndCalcRdInterCU函数计算当前inter模式的最优运动信息下的cost,
函数中分别对skip模式和有残差的inter模式,进行cost的计算。

Void InterSearch::encodeResAndCalcRdInterCU(CodingStructure &cs, Partitioner &partitioner, const Bool &skipResidual)
{
   
  CodingUnit &cu = *cs.getCU( partitioner.chType );

  const ChromaFormat format     = cs.area.chromaFormat;;
  const Int  numValidComponents = getNumberValidComponents(format);
  const SPS &
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值