HTM-16.2代码(10)——xPatternSearch和xPatternSearchFast

来源:互联网 发布:娇女轻抚琴,绕梁知其音 编辑:程序博客网 时间:2024/05/16 01:44

xPatternSearch进行整像素搜索

Void TEncSearch::xPatternSearch( const TComPattern* const pcPatternKey,                                 const Pel*               piRefY,                                 const Int                iRefStride,                                 const TComMv* const      pcMvSrchRngLT,                                 const TComMv* const      pcMvSrchRngRB,                                 TComMv&      rcMv,                                 Distortion&  ruiSAD ){//在pcMvSrchRngLT和pcMvSrchRngRB的范围内进行整像素搜索,其中最优的mv存入rcMv中,失真存入ruiSAD  Int   iSrchRngHorLeft   = pcMvSrchRngLT->getHor();  Int   iSrchRngHorRight  = pcMvSrchRngRB->getHor();  Int   iSrchRngVerTop    = pcMvSrchRngLT->getVer();  Int   iSrchRngVerBottom = pcMvSrchRngRB->getVer();  Distortion  uiSad;  Distortion  uiSadBest = std::numeric_limits<Distortion>::max();  Int         iBestX = 0;  Int         iBestY = 0;  //-- 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->getFastInterSearchMode()==FASTINTERSEARCH_MODE1 || m_pcEncCfg->getFastInterSearchMode()==FASTINTERSEARCH_MODE3 )  {    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      m_cDistParam.pCur = piRefY + x;      setDistParamComp(COMPONENT_Y);      m_cDistParam.bitDepth = pcPatternKey->getBitDepthY();#if NH_3D_IC      m_cDistParam.bUseIC = pcPatternKey->getICFlag();#endif#if NH_3D_SDC_INTER      m_cDistParam.bUseSDCMRSAD = pcPatternKey->getSDCMRSADFlag();#endif      uiSad = m_cDistParam.DistFunc( &m_cDistParam );      // motion cost      uiSad += m_pcRdCost->getCostOfVectorWithPredictor( x, y );      if ( uiSad < uiSadBest )      {        uiSadBest = uiSad;        iBestX    = x;        iBestY    = y;        m_cDistParam.m_maximumDistortionForEarlyExit = uiSad;      }    }    piRefY += iRefStride;  }  rcMv.set( iBestX, iBestY );  ruiSAD = uiSadBest - m_pcRdCost->getCostOfVectorWithPredictor( iBestX, iBestY );  return;}

xPatternSearchFast的主要部分见xTZSearch

Void TEncSearch::xPatternSearchFast( const TComDataCU* const  pcCU,                                     const TComPattern* const pcPatternKey,                                     const Pel* const         piRefY,                                     const Int                iRefStride,                                     const TComMv* const      pcMvSrchRngLT,                                     const TComMv* const      pcMvSrchRngRB,                                     TComMv       &rcMv,                                     Distortion   &ruiSAD,                                     const TComMv* const      pIntegerMv2Nx2NPred ){  assert (MD_LEFT < NUM_MV_PREDICTORS);  pcCU->getMvPredLeft       ( m_acMvPredictors[MD_LEFT] );  assert (MD_ABOVE < NUM_MV_PREDICTORS);  pcCU->getMvPredAbove      ( m_acMvPredictors[MD_ABOVE] );  assert (MD_ABOVE_RIGHT < NUM_MV_PREDICTORS);  pcCU->getMvPredAboveRight ( m_acMvPredictors[MD_ABOVE_RIGHT] );  switch ( m_motionEstimationSearchMethod )  {    case MESEARCH_DIAMOND:      xTZSearch( pcCU, pcPatternKey, piRefY, iRefStride, pcMvSrchRngLT, pcMvSrchRngRB, rcMv, ruiSAD, pIntegerMv2Nx2NPred, false );      break;    case MESEARCH_SELECTIVE:      xTZSearchSelective( pcCU, pcPatternKey, piRefY, iRefStride, pcMvSrchRngLT, pcMvSrchRngRB, rcMv, ruiSAD, pIntegerMv2Nx2NPred );      break;    case MESEARCH_DIAMOND_ENHANCED:      xTZSearch( pcCU, pcPatternKey, piRefY, iRefStride, pcMvSrchRngLT, pcMvSrchRngRB, rcMv, ruiSAD, pIntegerMv2Nx2NPred, true );      break;    case MESEARCH_FULL: // shouldn't get here.    default:      break;  }}
0 0