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&


Void TEncSearch::xPatternSearch( TComPattern* pcPatternKey, Pel* piRefY, Int iRefStride, TComMv* pcMvSrchRngLT, TComMv* pcMvSrchRngRB, TComMv& rcMv, UInt& ruiSAD )
{
  Int   iSrchRngHorLeft   = pcMvSrchRngLT->getHor();
  Int   iSrchRngHorRight  = pcMvSrchRngRB->getHor();
  Int   iSrchRngVerTop    = pcMvSrchRngLT->getVer();
  Int   iSrchRngVerBottom = pcMvSrchRngRB->getVer();
  
  UInt  uiSad;
  UInt  uiSadBest         = MAX_UINT;
  Int   iBestX = 0;
  Int   iBestY = 0;
  
  Pel*  piRefSrch;
  
  //-- jclee for using the SAD function pointer
  m_pcRdCost->setDistParam( pcPatternKey, piRefY, iRefStride,  m_cDistParam );
  
  // fast encoder decision: use subsampled SAD for integer ME
  if ( m_pcEncCfg->getUseFastEnc() )
  {
    if ( m_cDistParam.iRows > 8 )
    {
      m_cDistParam.iSubShift = 1;
    }
  }
  
  piRefY += (iSrchRngVerTop * iRefStride);
  for ( Int y = iSrchRngVerTop; y <= iSrchRngVerBottom; y++ )
  {
    for ( Int x = iSrchRngHorLeft; x <= iSrchRngHorRight; x++ )
    {
      //  find min. distortion position
      piRefSrch = piRefY + x;
      m_cDistParam.pCur = piRefSrch;

      setDistParamComp(0);

      m_cDistParam.bitDepth = g_bitDepthY;
      uiSad = m_cDistParam.DistFunc( &m_cDistParam );
      
      // motion cost
      uiSad += m_pcRdCost->getCost( x, y );
      
      if ( uiSad < uiSadBest )
      {
        uiSadBest = uiSad;
        iBestX    = x;
        iBestY    = y;
      }
    }
    piRefY += iRefStride;
  }
  
  rcMv.set( iBestX, iBestY );
  
  ruiSAD = uiSadBest - m_pcRdCost->getCost( iBestX, iBestY );
  return;
}


//先考虑整像素搜索的情况,进入到xPatternSearchFast中去
//先是获得预测的运动矢量,接着调用xTZSearch进行搜索,xTZSearch这个函数相对比较长,里面调用了很多子函数
Void TEncSearch::xPatternSearchFast( TComDataCU* pcCU, TComPattern* pcPatternKey, Pel* piRefY, Int iRefStride, TComMv* pcMvSrchRngLT, TComMv* pcMvSrchRngRB, TComMv& rcMv, UInt& ruiSAD )
{//!< 获取相邻PU: A, B, C的运动矢量,作为预测运动矢量
  pcCU->getMvPredLeft       ( m_acMvPredictors[0] );
  pcCU->getMvPredAbove      ( m_acMvPredictors[1] );
  pcCU->getMvPredAboveRight ( m_acMvPredictors[2] );
  
  switch ( m_iFastSearch )
  {
    case 1:
      xTZSearch( pcCU, pcPatternKey, piRefY, iRefStride, pcMvSrchRngLT, pcMvSrchRngRB, rcMv, ruiSAD );
      break;
      
    default:
      break;
  }
}




目录
相关文章
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代码追踪(十一。七):运动估计/补偿之xTZ8PointDiamondSearch
<p>xTZSearch调用了2个最为主要的函数:xTZ8PointDiamondSearch和xTZ2PointSearch,值得一提的是,HM中还提供了另外一个搜索函数xTZ8PointSquareSearch,但由于实际并没有使用这个函数,且它其实跟钻石搜索只是搜索点的选择略有不同,分析起来基本上也是一样的。</p> <p><br></p> <p></p> <pre code_s
1201 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代码追踪(十一。九):运动估计/补偿之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
1088 0
HEVC代码追踪(十一。六):运动估计/补偿之xTZSearchHelp
<p><br></p> <p></p> <pre name="code" class="cpp">/* 分析xTZSearch这个函数,xTZSearchHelp是当中最为重要的子函数之一。它实现最基本的功能:根据输入的搜索点坐标, 参考图像首地址,原始图像首地址,以及当前PU大小等相关信息,计算出SAD,并与之前保存的最佳值进行比较,更新到 目前为止的最佳值相关参数,如uiBestSa
1855 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代码追踪(十五):解码之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
HEVC代码追踪(十四):解码之xDecodeSlice
<p><br></p> <p></p> <pre name="code" class="cpp">Bool TDecTop::decode(InputNALUnit&amp; nalu, Int&amp; iSkipFrame, Int&amp; iPOCLastDisplay) { // Initialize entropy decoder m_cEntropyDecoder
2498 0