VTM3.0代码阅读:motionCompensation函数

本文详细探讨了VTM3.0中的motionCompensation函数,该函数用于根据运动向量mv进行帧间预测,包括单向和双向预测。通过亚像素插值获取预测像素,实现运动补偿。在VTM3.0中,函数新增了对CPR模式的支持,并区分了Affine模式与其他模式(如Merge和inter_ME)的运动补偿处理方式。
摘要由CSDN通过智能技术生成

motionCompensation运动补偿,在帧间各种模式中,根据之前获取到的亚像素精度的mv,就能在参考帧中得到pu的参考块,在pu的参考块位置处,通过亚像素插值来得到亚像素位置的pu的预测像素pred。
总之,MC运动补偿,就是根据运动向量mv,得到当前pu的预测像素。
motionCompensation调用了xPredInterUni函数进行单向预测的运动补偿,调用xPredInterBi函数进行双向预测的运动补偿。
VTM中,调用motionCompensation时,参数eRefPicList只有三种情况:REF_PIC_LIST_0、REF_PIC_LIST_1、REF_PIC_LIST_X,表示前向、后向、不确定。

相比VTM1,motionCompensation函数中多了CPR模式相关的一些代码。
对Affine模式的运动补偿,与Merge以及inter_ME模式的运动补偿过程是不同的:
Affine模式运动补偿时xPredAffineBlk函数
Merge及inter_ME模式运动补偿时xPredInterBlk函数

void InterPrediction::motionCompensation( PredictionUnit &pu, PelUnitBuf &predBuf, const RefPicList &eRefPicList 
#if JVET_L0293_CPR
  , const bool luma, const bool chroma
#endif
)
{
   
#if JVET_L0293_CPR
  // dual tree handling for CPR as the only ref
  if (!luma || !chroma)				//CPR模式相关的一些代码
  {
   
    if (!luma && chroma)
    {
   
      xChromaMC(pu, predBuf);
      return;
    }
    else // (luma && !chroma)
    {
   
      xPredInterUni(pu, eRefPicList, predBuf, false
#if JVET_L0256_BIO
        , false
#endif
        , luma, chroma);
      return;
    }
  }
  // else, go with regular MC below
#endif
        CodingStructure &cs = *pu.cs;
  const PPS &pps            = *cs.pps;
  const SliceType sliceType =  cs.slice->getSliceType();

  if( eRefPicList != REF_PIC_LIST_X )		//指明了pu的参考列表,单向预测
  {
   
    if( ( ( sliceType == P_SLICE && pps.getUseWP() ) || ( sliceType == B_SLICE && pps.getWPBiPred() ) ) )//使用加权预测
    {
   
      xPredInterUni         ( pu,          eRefPicList, predBuf, true );	//单向预测	最后一个参数为true表示之后还要进行加权预测
      xWeightedPredictionUni( pu, predBuf, eRefPicList, predBuf, -1, m_maxCompIDToPred );	//单向加权预测
    }
    else			//不使用加权预测
    {
   
      xPredInterUni( pu, eRefPicList, predBuf, false );	//单向预测
    }
  }
  else				//没有指明参考列表,当作Bi处理
  {
   
#if JVET_L0293_CPR
    if (pu.mergeType != MRG_TYPE_DEFAULT_N && pu.mergeType != MRG_TYPE_CPR)
#else
    if( pu.mergeType != MRG_TYPE_DEFAULT_N )
#endif
    {
   
      xSubPuMC( pu, predBuf, eRefPicList );
    }
    else if( xCheckIdenticalMotion( pu ) )		//如果前后两个方向的参考poc相同,mv相同,则归为单向处理
    {
   
      xPredInterUni( pu, REF_PIC_LIST_0, predBuf, false );	//前向预测
    }
    else
    {
   
      xPredInterBi( pu, predBuf );		//双向预测	其中会进行双向预测的加权预测
    }
  }
  return;
}
//单向预测的运动补偿算法
//xPredInterUni调用xPredInterBlk函数进行pu的每个通道的预测像素的获取
//相比VTM1,其中多了xPredAffineBlk函数进行Affine模式时pu的运动补偿,获取预测像素
void InterPrediction::xPredInterUni(const PredictionUnit
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值