HTM-16.2代码(10)——xPatternSearch和xPatternSearchFast
2016-12-27 17:19
489 查看
xPatternSearch进行整像素搜索
xPatternSearchFast的主要部分见xTZSearch
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; } }
相关文章推荐
- HEVC代码追踪(十一。四):运动估计/补偿之xPatternSearch和xPatternSearchFast
- HEVC代码追踪(十一。四):运动估计/补偿之xPatternSearch和xPatternSearchFast
- Void TEncSearch::xPatternSearchFast()èxTZSearch()
- HEVC代码学习20:xPatternSearchFast函数
- Clustering by fast search and find of density peaks代码详解
- HTM-16.2代码(11)——xTZSearch
- HTM-16.2代码(12)——xTZ8PointDiamondSearch和xTZ2PointSearch
- HTM-16.2代码(13)——getInterMergeCandidates
- HTM-16.2代码(7)——motionCompensation
- HTM-16.2代码(1)——编码端一些函数的说明
- HTM-16.2代码(3)——xCompressCU
- HTM-16.2代码(9)——fillMvpCand
- HTM-16.2代码(4)——xCheckRDCostInter
- HEVC代码学习7:xPatternSearchFracDIF函数
- HTM-16.2代码(2)——帧间预测(理论)
- 用XP做服务器突破10人限制
- 发现Python的源代码中关于字符串fastsearch算法的一个笔误!
- XP风格的按钮代码