HEVC代码追踪(十一。九):运动估计/补偿之xTZ2PointSearch

简介: <p><br></p> <p></p><pre code_snippet_id="539592" snippet_file_name="blog_20141202_1_5458888" name="code" class="cpp">__inline Void TEncSearch::xTZ2PointSearch( TComPattern* pcPatternKey, IntTZSe


__inline Void TEncSearch::xTZ2PointSearch( TComPattern* pcPatternKey, IntTZSearchStruct& rcStruct, TComMv* pcMvSrchRngLT, TComMv* pcMvSrchRngRB )
{
  Int   iSrchRngHorLeft   = pcMvSrchRngLT->getHor();
  Int   iSrchRngHorRight  = pcMvSrchRngRB->getHor();
  Int   iSrchRngVerTop    = pcMvSrchRngLT->getVer();
  Int   iSrchRngVerBottom = pcMvSrchRngRB->getVer();
  
  // 2 point search,                   //   1 2 3
  // check only the 2 untested points  //   4 0 5
  // around the start point            //   6 7 8
//!< 注意到,这里的1,3,6,8实际上是搜索步长iDist==2的时候由iDist>>1进行赋值的,实际距离以1计算,
//!< 在前面经过xTZ8PointSearch确定最佳步长为1后,会在这里对以最佳点为中心、周围没搜索过的点进行运动估计
  Int iStartX = rcStruct.iBestX;
  Int iStartY = rcStruct.iBestY;
  switch( rcStruct.ucPointNr )//!< 主要思想是根据该最佳点的位置处理未搜索过的点
  {
    case 1:
    {
      if ( (iStartX - 1) >= iSrchRngHorLeft )
      {
        xTZSearchHelp( pcPatternKey, rcStruct, iStartX - 1, iStartY, 0, 2 );//!< 左
      }
      if ( (iStartY - 1) >= iSrchRngVerTop )
      {
        xTZSearchHelp( pcPatternKey, rcStruct, iStartX, iStartY - 1, 0, 2 );//!< 上
      }
    }
      break;
    case 2:
    {
      if ( (iStartY - 1) >= iSrchRngVerTop )
      {
        if ( (iStartX - 1) >= iSrchRngHorLeft )
        {
          xTZSearchHelp( pcPatternKey, rcStruct, iStartX - 1, iStartY - 1, 0, 2 );//!< 左上  
        }
        if ( (iStartX + 1) <= iSrchRngHorRight )
        {
          xTZSearchHelp( pcPatternKey, rcStruct, iStartX + 1, iStartY - 1, 0, 2 );//!< 右上  
        }
      }
    }
      break;
    case 3:
    {
      if ( (iStartY - 1) >= iSrchRngVerTop )
      {
        xTZSearchHelp( pcPatternKey, rcStruct, iStartX, iStartY - 1, 0, 2 );//!< 上
      }
      if ( (iStartX + 1) <= iSrchRngHorRight )
      {
        xTZSearchHelp( pcPatternKey, rcStruct, iStartX + 1, iStartY, 0, 2 );//!< 右
      }
    }
      break;
    case 4:
    {
      if ( (iStartX - 1) >= iSrchRngHorLeft )
      {
        if ( (iStartY + 1) <= iSrchRngVerBottom )
        {
          xTZSearchHelp( pcPatternKey, rcStruct, iStartX - 1, iStartY + 1, 0, 2 );//!< 左下  
        }
        if ( (iStartY - 1) >= iSrchRngVerTop )
        {
          xTZSearchHelp( pcPatternKey, rcStruct, iStartX - 1, iStartY - 1, 0, 2 );//!< 左上  
        }
      }
    }
      break;
    case 5:
    {
      if ( (iStartX + 1) <= iSrchRngHorRight )
      {
        if ( (iStartY - 1) >= iSrchRngVerTop )
        {
          xTZSearchHelp( pcPatternKey, rcStruct, iStartX + 1, iStartY - 1, 0, 2 );//!< 右上  
        }
        if ( (iStartY + 1) <= iSrchRngVerBottom )
        {
          xTZSearchHelp( pcPatternKey, rcStruct, iStartX + 1, iStartY + 1, 0, 2 );//!< 右下  
        }
      }
    }
      break;
    case 6:
    {
      if ( (iStartX - 1) >= iSrchRngHorLeft )
      {
        xTZSearchHelp( pcPatternKey, rcStruct, iStartX - 1, iStartY , 0, 2 );//!< 左
      }
      if ( (iStartY + 1) <= iSrchRngVerBottom )
      {
        xTZSearchHelp( pcPatternKey, rcStruct, iStartX, iStartY + 1, 0, 2 );//!< 下
      }
    }
      break;
    case 7:
    {
      if ( (iStartY + 1) <= iSrchRngVerBottom )
      {
        if ( (iStartX - 1) >= iSrchRngHorLeft )
        {
          xTZSearchHelp( pcPatternKey, rcStruct, iStartX - 1, iStartY + 1, 0, 2 );//!< 左下  
        }
        if ( (iStartX + 1) <= iSrchRngHorRight )
        {
          xTZSearchHelp( pcPatternKey, rcStruct, iStartX + 1, iStartY + 1, 0, 2 );//!< 右下  
        }
      }
    }
      break;
    case 8:
    {
      if ( (iStartX + 1) <= iSrchRngHorRight )
      {
        xTZSearchHelp( pcPatternKey, rcStruct, iStartX + 1, iStartY, 0, 2 );//!< 右
      }
      if ( (iStartY + 1) <= iSrchRngVerBottom )
      {
        xTZSearchHelp( pcPatternKey, rcStruct, iStartX, iStartY + 1, 0, 2 );//!< 下
      }
    }
      break;
    default:
    {
      assert( false );
    }
      break;
  } // switch( rcStruct.ucPointNr )
}




目录
相关文章
HEVC代码追踪(十一。六):运动估计/补偿之xTZSearchHelp
<p><br></p> <p></p> <pre name="code" class="cpp">/* 分析xTZSearch这个函数,xTZSearchHelp是当中最为重要的子函数之一。它实现最基本的功能:根据输入的搜索点坐标, 参考图像首地址,原始图像首地址,以及当前PU大小等相关信息,计算出SAD,并与之前保存的最佳值进行比较,更新到 目前为止的最佳值相关参数,如uiBestSa
1855 0
HEVC代码追踪(十一。二):运动估计/补偿之predInterSearch
<p><br></p> <p></p> <pre name="code" class="cpp">/** search of the best candidate for inter prediction * \param pcCU * \param pcOrgYuv * \param rpcPredYuv * \param rpcResiYuv * \param rpcRec
1678 0
HEVC代码追踪(十一。八):运动估计/补偿之xTZ8PointSquareSearch
<p><br></p> <p></p> <pre code_snippet_id="539588" snippet_file_name="blog_20141202_1_7201235" name="code" class="cpp">__inline Void TEncSearch::xTZ8PointSquareSearch( TComPattern* pcPatternKey,
1129 0
HEVC代码追踪(十一。七):运动估计/补偿之xTZ8PointDiamondSearch
<p>xTZSearch调用了2个最为主要的函数:xTZ8PointDiamondSearch和xTZ2PointSearch,值得一提的是,HM中还提供了另外一个搜索函数xTZ8PointSquareSearch,但由于实际并没有使用这个函数,且它其实跟钻石搜索只是搜索点的选择略有不同,分析起来基本上也是一样的。</p> <p><br></p> <p></p> <pre code_s
1201 0
HEVC代码追踪(十一。五):运动估计/补偿之xTZSearch
<p><br></p> <p></p> <pre name="code" class="cpp">Void TEncSearch::xTZSearch( TComDataCU* pcCU, TComPattern* pcPatternKey, Pel* piRefY, Int iRefStride, TComMv* pcMvSrchRngLT, TComMv* pcMvSrchRngR
1791 0
HEVC代码追踪(十一。一):运动估计/补偿之xCheckRDCostInter
<p><br></p> <p></p> <pre code_snippet_id="539245" snippet_file_name="blog_20141202_1_7049848" name="code" class="cpp">#if AMP_MRG Void TEncCu::xCheckRDCostInter( TComDataCU*&amp; rpcBestCU, TComD
1639 0
HEVC代码追踪(十一。三):运动估计/补偿之xMotionEstimation
<p><br></p> <p></p> <pre name="code" class="cpp">//!&lt; 运动估计(基本思想就是用TZSearch算法先进行整像素搜索,确定一个局部的最佳值,然后以这个最佳点为中心再进行精度更高的分像素搜索。) Void TEncSearch::xMotionEstimation( TComDataCU* pcCU,
2217 0
HEVC代码追踪(十一。四):运动估计/补偿之xPatternSearch和xPatternSearchFast
<p><br></p> <p></p> <pre name="code" class="cpp">Void TEncSearch::xPatternSearch( TComPattern* pcPatternKey, Pel* piRefY, Int iRefStride, TComMv* pcMvSrchRngLT, TComMv* pcMvSrchRngRB, TComMv&amp;
1826 0
|
编解码 缓存 存储
HEVC代码追踪(十一):运动估计/补偿之理论知识
<p>运动估计的英文名称是Motion Estimation,是视频编码和视频处理(例如去交织)中广泛使用的一种技术。</p> <p><br></p> <p>运动估计的<strong><span style="color:#ff0000">基本思想</span></strong>是将图像序列的每一帧分成许多互不重叠的宏块,并认为宏块内所有像素的位移量都相同,然后对每个宏块到参考帧某一给
2313 0
HEVC代码追踪(十五):解码之decompressSlice
<p><br></p> <p></p> <pre name="code" class="cpp">Void TDecGop::decompressSlice(TComInputBitstream* pcBitstream, TComPic*&amp; rpcPic) { TComSlice* pcSlice = rpcPic-&gt;getSlice(rpcPic-&gt;getC
1213 0