VTM3.0代码阅读:xMotionEstimation函数

inter_ME模式中,xMotionEstimation函数实现运动估计,利用得到的AMVP最优候选为起点,搜索范围内的最佳匹配块,从而确定mv。

IntTZSearchStruct结构体在ME过程中很重要,包含了搜索匹配过程的所有关键数据:

typedef struct
  {
   
    SearchRange searchRange;		//搜素范围
    const CPelBuf* pcPatternKey;	//匹配模板像素,orig
    const Pel*  piRefY;				//参考帧像素,即搜索区域的像素
    Int         iRefStride;			//搜索区域像素的stride
    Int         iBestX;
    Int         iBestY;				//搜索范围内的最佳匹配点
    UInt        uiBestRound;
    UInt        uiBestDistance;		//搜索点距起点的距离
    Distortion  uiBestSad;			//匹配失真
    UChar       ucPointNr;			//搜索点相对于起始点的位置的标号
    Int         subShiftMode;		//搜索模式
	unsigned    imvShift;		//相比VTM1多了以下三项
    bool        inCtuSearch;
    bool        zeroMV;
	
  } IntTZSearchStruct;

入口参数rcMvPred是当前参考帧通过AMVP得到的最优的mvp,用于ME。
基于AMVP的mvp,ME最终得到精度为Qter像素的mv,即rcMv。
大致流程为:
构建IntTZSearchStruct,其中确定模板像素,搜索参考像素;
分搜索类型,调用不同的搜索匹配函数进行块的匹配和mv的搜索,确定整数mv;
若iMV为false,进行亚像素和Qter像素的mv的搜索,通过插值,搜索匹配得到,最终得到Qter像素精度mv;
若iMV为true,即ME在整像素和4像素精度进行时,调用xPatternSearchIntRefine。

void InterSearch::xMotionEstimation(PredictionUnit& pu, PelUnitBuf& origBuf, RefPicList eRefPicList, Mv& rcMvPred, int iRefIdxPred, Mv& rcMv, int& riMVPIdx, uint32_t& ruiBits, Distortion& ruiCost, const AMVPInfo& amvpInfo, bool bBi)
{
   
#if JVET_L0646_GBI
  if( pu.cu->cs->sps->getSpsNext().getUseGBi() && pu.cu->GBiIdx != GBI_DEFAULT && !bBi && xReadBufferedUniMv(pu, eRefPicList, iRefIdxPred, rcMvPred, rcMv, ruiBits, ruiCost) )
  {
   
    return;
  }
#endif

  Mv cMvHalf, cMvQter;		//1/2精度和1/4精度mv

  CHECK(eRefPicList >= MAX_NUM_REF_LIST_ADAPT_SR || iRefIdxPred>=int(MAX_IDX_ADAPT_SR), "Invalid reference picture list");
  m_iSearchRange = m_aaiAdaptSR[eRefPicList][iRefIdxPred];

  int    iSrchRng   = (bBi ? m_bipredSearchRange : m_iSearchRange);	//搜索范围
  double fWeight    = 1.0;
										//m_tmpStorageLCU,这个东西好像经常见到。原来的org像素都是保存在cs中的
  PelUnitBuf  origBufTmp = m_tmpStorageLCU.getBuf( UnitAreaRelative(*pu.cu, pu) );
  PelUnitBuf* pBuf       = &origBuf;	//orig像素信息

  if(bBi) // Bi-predictive ME		双向预测中的运动估计时
  {
   
    // NOTE: Other buf contains predicted signal from another direction	//另外一个方向的orig像素
    PelUnitBuf otherBuf = m_tmpPredStorage[1 - (int)eRefPicList]
  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值