之前学习了xPatternSearchFracDIF函数,今天来学习其上层的xMotionEstimation函数,从字面就可以理解,功能是进行运动估计。
xMotionEstimation是运动估计的入口函数,通过调用xPatternSearch、xPatternSearchFast、xPatternSearchFracDIF进行运动搜索。主要工作流程是:进行一些初始化,设置搜索范围,然后通过整像素搜索得到一个最优点,将这个最优点作为起点进行亚像素搜索,最终得到以1/4精度为单位的MV。
Void TEncSearch::xMotionEstimation( TComDataCU* pcCU, TComYuv* pcYuvOrg, Int iPartIdx, RefPicList eRefPicList, TComMv* pcMvPred, Int iRefIdxPred, TComMv& rcMv, UInt& ruiBits, Distortion& ruiCost, Bool bBi )
{
UInt uiPartAddr;
Int iRoiWidth;
Int iRoiHeight;
TComMv cMvHalf, cMvQter; //定义1/2和1/4精度MV
TComMv cMvSrchRngLT;
TComMv cMvSrchRngRB;