Changeset 1407 in SHVCSoftware


Ignore:
Timestamp:
4 Aug 2015, 04:21:59 (9 years ago)
Author:
seregin
Message:

port rev 4560

Location:
branches/SHM-dev/source
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/SHM-dev/source/App/TAppEncoder/TAppEncCfg.cpp

    r1406 r1407  
    12841284  // motion search options
    12851285  ("DisableIntraInInter",                             m_bDisableIntraPUsInInterSlices,                  false, "Flag to disable intra PUs in inter slices")
    1286   ("FastSearch",                                      tmpMotionEstimationSearchMethod,  Int(MESEARCH_DIAMOND), "0:Full search 1:Diamond 2:Selective")
     1286  ("FastSearch",                                      tmpMotionEstimationSearchMethod,  Int(MESEARCH_DIAMOND), "0:Full search 1:Diamond 2:Selective 3:Enhanced Diamond")
    12871287  ("SearchRange,-sr",                                 m_iSearchRange,                                      96, "Motion search range")
    12881288  ("BipredSearchRange",                               m_bipredSearchRange,                                  4, "Motion search range for bipred refinement")
  • branches/SHM-dev/source/Lib/TLibCommon/TypeDef.h

    r1406 r1407  
    508508  MESEARCH_DIAMOND           = 1,
    509509  MESEARCH_SELECTIVE         = 2,
    510   MESEARCH_NUMBER_OF_METHODS   = 3
     510  MESEARCH_DIAMOND_ENHANCED  = 3,
     511  MESEARCH_NUMBER_OF_METHODS = 4
    511512};
    512513
  • branches/SHM-dev/source/Lib/TLibEncoder/TEncSearch.cpp

    r1406 r1407  
    419419    if( uiSad < rcStruct.uiBestSad )
    420420    {
    421 
    422421      // motion cost
    423422      uiSad += m_pcRdCost->getCost( iSearchX, iSearchY );
     
    634633                                                  const Int iStartX,
    635634                                                  const Int iStartY,
    636                                                   const Int iDist)
     635                                                  const Int iDist,
     636                                                  const Bool bCheckCornersAtDist1 )
    637637{
    638638  const Int   iSrchRngHorLeft   = pcMvSrchRngLT->getHor();
     
    655655    if ( iTop >= iSrchRngVerTop ) // check top
    656656    {
    657       xTZSearchHelp( pcPatternKey, rcStruct, iStartX, iTop, 2, iDist );
     657      if (bCheckCornersAtDist1)
     658      {
     659        if ( iLeft >= iSrchRngHorLeft) // check top-left
     660        {
     661          xTZSearchHelp( pcPatternKey, rcStruct, iLeft, iTop, 1, iDist );
     662        }
     663        xTZSearchHelp( pcPatternKey, rcStruct, iStartX, iTop, 2, iDist );
     664        if ( iRight <= iSrchRngHorRight ) // check middle right
     665        {
     666          xTZSearchHelp( pcPatternKey, rcStruct, iRight, iTop, 3, iDist );
     667        }
     668      }
     669      else
     670      {
     671        xTZSearchHelp( pcPatternKey, rcStruct, iStartX, iTop, 2, iDist );
     672      }
    658673    }
    659674    if ( iLeft >= iSrchRngHorLeft ) // check middle left
     
    667682    if ( iBottom <= iSrchRngVerBottom ) // check bottom
    668683    {
    669       xTZSearchHelp( pcPatternKey, rcStruct, iStartX, iBottom, 7, iDist );
     684      if (bCheckCornersAtDist1)
     685      {
     686        if ( iLeft >= iSrchRngHorLeft) // check top-left
     687        {
     688          xTZSearchHelp( pcPatternKey, rcStruct, iLeft, iBottom, 6, iDist );
     689        }
     690        xTZSearchHelp( pcPatternKey, rcStruct, iStartX, iBottom, 7, iDist );
     691        if ( iRight <= iSrchRngHorRight ) // check middle right
     692        {
     693          xTZSearchHelp( pcPatternKey, rcStruct, iRight, iBottom, 8, iDist );
     694        }
     695      }
     696      else
     697      {
     698        xTZSearchHelp( pcPatternKey, rcStruct, iStartX, iBottom, 7, iDist );
     699      }
    670700    }
    671701  }
     
    40694099  {
    40704100    case MESEARCH_DIAMOND:
    4071       xTZSearch( pcCU, pcPatternKey, piRefY, iRefStride, pcMvSrchRngLT, pcMvSrchRngRB, rcMv, ruiSAD, pIntegerMv2Nx2NPred );
     4101      xTZSearch( pcCU, pcPatternKey, piRefY, iRefStride, pcMvSrchRngLT, pcMvSrchRngRB, rcMv, ruiSAD, pIntegerMv2Nx2NPred, false );
    40724102      break;
    40734103
    40744104    case MESEARCH_SELECTIVE:
    40754105      xTZSearchSelective( pcCU, pcPatternKey, piRefY, iRefStride, pcMvSrchRngLT, pcMvSrchRngRB, rcMv, ruiSAD, pIntegerMv2Nx2NPred );
     4106      break;
     4107
     4108    case MESEARCH_DIAMOND_ENHANCED:
     4109      xTZSearch( pcCU, pcPatternKey, piRefY, iRefStride, pcMvSrchRngLT, pcMvSrchRngRB, rcMv, ruiSAD, pIntegerMv2Nx2NPred, true );
    40764110      break;
    40774111
     
    40914125                            TComMv&                  rcMv,
    40924126                            Distortion&              ruiSAD,
    4093                             const TComMv* const      pIntegerMv2Nx2NPred )
     4127                            const TComMv* const      pIntegerMv2Nx2NPred,
     4128                            const Bool               bExtendedSettings)
    40944129{
    4095   const Int  iRaster                  = 5;
    4096   const Bool bTestOtherPredictedMV    = false;
    4097   const Bool bTestZeroVector          = true;
    4098   const Bool bTestZeroVectorStart     = false;
    4099   const Bool bTestZeroVectorStop      = false;
    4100   const Bool bFirstSearchDiamond      = true;   // 1 = xTZ8PointDiamondSearch   0 = xTZ8PointSquareSearch
    4101   const Bool bFirstSearchStop         = m_pcEncCfg->getFastMEAssumingSmootherMVEnabled();
    4102   const UInt uiFirstSearchRounds      = 3;      // first search stop X rounds after best match (must be >=1)
    4103   const Bool bEnableRasterSearch      = true;
    4104   const Bool bAlwaysRasterSearch      = 0;      // ===== 1: BETTER but factor 2 slower =====
    4105   const Bool bRasterRefinementEnable  = false;  // enable either raster refinement or star refinement
    4106   const Bool bRasterRefinementDiamond = false;  // 1 = xTZ8PointDiamondSearch   0 = xTZ8PointSquareSearch
    4107   const Bool bStarRefinementEnable    = true;   // enable either star refinement or raster refinement
    4108   const Bool bStarRefinementDiamond   = true;   // 1 = xTZ8PointDiamondSearch   0 = xTZ8PointSquareSearch
    4109   const Bool bStarRefinementStop      = false;
    4110   const UInt uiStarRefinementRounds   = 2;      // star refinement stop X rounds after best match (must be >=1)
     4130  const Bool bUseAdaptiveRaster                      = bExtendedSettings;
     4131  const Int  iRaster                                 = 5;
     4132  const Bool bTestOtherPredictedMV                   = bExtendedSettings;
     4133  const Bool bTestZeroVector                         = true;
     4134  const Bool bTestZeroVectorStart                    = bExtendedSettings;
     4135  const Bool bTestZeroVectorStop                     = false;
     4136  const Bool bFirstSearchDiamond                     = true;  // 1 = xTZ8PointDiamondSearch   0 = xTZ8PointSquareSearch
     4137  const Bool bFirstCornersForDiamondDist1            = bExtendedSettings;
     4138  const Bool bFirstSearchStop                        = m_pcEncCfg->getFastMEAssumingSmootherMVEnabled();
     4139  const UInt uiFirstSearchRounds                     = 3;     // first search stop X rounds after best match (must be >=1)
     4140  const Bool bEnableRasterSearch                     = true;
     4141  const Bool bAlwaysRasterSearch                     = bExtendedSettings;  // true: BETTER but factor 2 slower
     4142  const Bool bRasterRefinementEnable                 = false; // enable either raster refinement or star refinement
     4143  const Bool bRasterRefinementDiamond                = false; // 1 = xTZ8PointDiamondSearch   0 = xTZ8PointSquareSearch
     4144  const Bool bRasterRefinementCornersForDiamondDist1 = bExtendedSettings;
     4145  const Bool bStarRefinementEnable                   = true;  // enable either star refinement or raster refinement
     4146  const Bool bStarRefinementDiamond                  = true;  // 1 = xTZ8PointDiamondSearch   0 = xTZ8PointSquareSearch
     4147  const Bool bStarRefinementCornersForDiamondDist1   = bExtendedSettings;
     4148  const Bool bStarRefinementStop                     = false;
     4149  const UInt uiStarRefinementRounds                  = 2;  // star refinement stop X rounds after best match (must be >=1)
     4150  const Bool bNewZeroNeighbourhoodTest               = bExtendedSettings;
    41114151
    41124152  UInt uiSearchRange = m_iSearchRange;
     
    41974237  Int  iStartY = cStruct.iBestY;
    41984238
    4199   // first search
     4239  const Bool bBestCandidateZero = (cStruct.iBestX == 0) && (cStruct.iBestY == 0);
     4240
     4241  // first search around best position up to now.
     4242  // The following works as a "subsampled/log" window search around the best candidate
    42004243  for ( iDist = 1; iDist <= (Int)uiSearchRange; iDist*=2 )
    42014244  {
    42024245    if ( bFirstSearchDiamond == 1 )
    42034246    {
    4204       xTZ8PointDiamondSearch ( pcPatternKey, cStruct, pcMvSrchRngLT, pcMvSrchRngRB, iStartX, iStartY, iDist );
     4247      xTZ8PointDiamondSearch ( pcPatternKey, cStruct, pcMvSrchRngLT, pcMvSrchRngRB, iStartX, iStartY, iDist, bFirstCornersForDiamondDist1 );
    42054248    }
    42064249    else
     
    42154258  }
    42164259
    4217   // test whether zero Mv is a better start point than Median predictor
    4218   if ( bTestZeroVectorStart && ((cStruct.iBestX != 0) || (cStruct.iBestY != 0)) )
    4219   {
    4220     xTZSearchHelp( pcPatternKey, cStruct, 0, 0, 0, 0 );
    4221     if ( (cStruct.iBestX == 0) && (cStruct.iBestY == 0) )
    4222     {
    4223       // test its neighborhood
    4224       for ( iDist = 1; iDist <= (Int)uiSearchRange; iDist*=2 )
    4225       {
    4226         xTZ8PointDiamondSearch( pcPatternKey, cStruct, pcMvSrchRngLT, pcMvSrchRngRB, 0, 0, iDist );
    4227         if ( bTestZeroVectorStop && (cStruct.uiBestRound > 0) ) // stop criterion
     4260  if (!bNewZeroNeighbourhoodTest)
     4261  {
     4262    // test whether zero Mv is a better start point than Median predictor
     4263    if ( bTestZeroVectorStart && ((cStruct.iBestX != 0) || (cStruct.iBestY != 0)) )
     4264    {
     4265      xTZSearchHelp( pcPatternKey, cStruct, 0, 0, 0, 0 );
     4266      if ( (cStruct.iBestX == 0) && (cStruct.iBestY == 0) )
     4267      {
     4268        // test its neighborhood
     4269        for ( iDist = 1; iDist <= (Int)uiSearchRange; iDist*=2 )
     4270        {
     4271          xTZ8PointDiamondSearch( pcPatternKey, cStruct, pcMvSrchRngLT, pcMvSrchRngRB, 0, 0, iDist, false );
     4272          if ( bTestZeroVectorStop && (cStruct.uiBestRound > 0) ) // stop criterion
     4273          {
     4274            break;
     4275          }
     4276        }
     4277      }
     4278    }
     4279  }
     4280  else
     4281  {
     4282    // Test also zero neighbourhood but with half the range
     4283    // It was reported that the original (above) search scheme using bTestZeroVectorStart did not
     4284    // make sense since one would have already checked the zero candidate earlier
     4285    // and thus the conditions for that test would have not been satisfied
     4286    if (bTestZeroVectorStart == true && bBestCandidateZero != true)
     4287    {
     4288      for ( iDist = 1; iDist <= ((Int)uiSearchRange >> 1); iDist*=2 )
     4289      {
     4290        xTZ8PointDiamondSearch( pcPatternKey, cStruct, pcMvSrchRngLT, pcMvSrchRngRB, 0, 0, iDist, false );
     4291        if ( bTestZeroVectorStop && (cStruct.uiBestRound > 2) ) // stop criterion
    42284292        {
    42294293          break;
     
    42414305
    42424306  // raster search if distance is too big
    4243   if ( bEnableRasterSearch && ( ((Int)(cStruct.uiBestDistance) > iRaster) || bAlwaysRasterSearch ) )
    4244   {
    4245     cStruct.uiBestDistance = iRaster;
    4246     for ( iStartY = iSrchRngVerTop; iStartY <= iSrchRngVerBottom; iStartY += iRaster )
    4247     {
    4248       for ( iStartX = iSrchRngHorLeft; iStartX <= iSrchRngHorRight; iStartX += iRaster )
    4249       {
    4250         xTZSearchHelp( pcPatternKey, cStruct, iStartX, iStartY, 0, iRaster );
     4307  if (bUseAdaptiveRaster)
     4308  {
     4309    int iWindowSize = iRaster;
     4310    Int   iSrchRngRasterLeft   = iSrchRngHorLeft;
     4311    Int   iSrchRngRasterRight  = iSrchRngHorRight;
     4312    Int   iSrchRngRasterTop    = iSrchRngVerTop;
     4313    Int   iSrchRngRasterBottom = iSrchRngVerBottom;
     4314
     4315    if (!(bEnableRasterSearch && ( ((Int)(cStruct.uiBestDistance) > iRaster))))
     4316    {
     4317      iWindowSize ++;
     4318      iSrchRngRasterLeft /= 2;
     4319      iSrchRngRasterRight /= 2;
     4320      iSrchRngRasterTop /= 2;
     4321      iSrchRngRasterBottom /= 2;
     4322    }
     4323    cStruct.uiBestDistance = iWindowSize;
     4324    for ( iStartY = iSrchRngRasterTop; iStartY <= iSrchRngRasterBottom; iStartY += iWindowSize )
     4325    {
     4326      for ( iStartX = iSrchRngRasterLeft; iStartX <= iSrchRngRasterRight; iStartX += iWindowSize )
     4327      {
     4328        xTZSearchHelp( pcPatternKey, cStruct, iStartX, iStartY, 0, iWindowSize );
     4329      }
     4330    }
     4331  }
     4332  else
     4333  {
     4334    if ( bEnableRasterSearch && ( ((Int)(cStruct.uiBestDistance) > iRaster) || bAlwaysRasterSearch ) )
     4335    {
     4336      cStruct.uiBestDistance = iRaster;
     4337      for ( iStartY = iSrchRngVerTop; iStartY <= iSrchRngVerBottom; iStartY += iRaster )
     4338      {
     4339        for ( iStartX = iSrchRngHorLeft; iStartX <= iSrchRngHorRight; iStartX += iRaster )
     4340        {
     4341          xTZSearchHelp( pcPatternKey, cStruct, iStartX, iStartY, 0, iRaster );
     4342        }
    42514343      }
    42524344    }
     
    42544346
    42554347  // raster refinement
     4348
    42564349  if ( bRasterRefinementEnable && cStruct.uiBestDistance > 0 )
    42574350  {
     
    42654358        if ( bRasterRefinementDiamond == 1 )
    42664359        {
    4267           xTZ8PointDiamondSearch ( pcPatternKey, cStruct, pcMvSrchRngLT, pcMvSrchRngRB, iStartX, iStartY, iDist );
     4360          xTZ8PointDiamondSearch ( pcPatternKey, cStruct, pcMvSrchRngLT, pcMvSrchRngRB, iStartX, iStartY, iDist, bRasterRefinementCornersForDiamondDist1 );
    42684361        }
    42694362        else
     
    42984391        if ( bStarRefinementDiamond == 1 )
    42994392        {
    4300           xTZ8PointDiamondSearch ( pcPatternKey, cStruct, pcMvSrchRngLT, pcMvSrchRngRB, iStartX, iStartY, iDist );
     4393          xTZ8PointDiamondSearch ( pcPatternKey, cStruct, pcMvSrchRngLT, pcMvSrchRngRB, iStartX, iStartY, iDist, bStarRefinementCornersForDiamondDist1 );
    43014394        }
    43024395        else
     
    44434536    {
    44444537      xTZSearchHelp( pcPatternKey, cStruct, iStartX, iStartY, 0, 0 );
    4445       xTZ8PointDiamondSearch ( pcPatternKey, cStruct, pcMvSrchRngLT, pcMvSrchRngRB, iStartX, iStartY, 1 );
    4446       xTZ8PointDiamondSearch ( pcPatternKey, cStruct, pcMvSrchRngLT, pcMvSrchRngRB, iStartX, iStartY, 2 );
     4538      xTZ8PointDiamondSearch ( pcPatternKey, cStruct, pcMvSrchRngLT, pcMvSrchRngRB, iStartX, iStartY, 1, false );
     4539      xTZ8PointDiamondSearch ( pcPatternKey, cStruct, pcMvSrchRngLT, pcMvSrchRngRB, iStartX, iStartY, 2, false );
    44474540    }
    44484541  }
     
    44754568        if ( bStarRefinementDiamond == 1 )
    44764569        {
    4477           xTZ8PointDiamondSearch ( pcPatternKey, cStruct, pcMvSrchRngLT, pcMvSrchRngRB, iStartX, iStartY, iDist );
     4570          xTZ8PointDiamondSearch ( pcPatternKey, cStruct, pcMvSrchRngLT, pcMvSrchRngRB, iStartX, iStartY, iDist, false );
    44784571        }
    44794572        else
  • branches/SHM-dev/source/Lib/TLibEncoder/TEncSearch.h

    r1406 r1407  
    172172  __inline Void xTZ2PointSearch       ( const TComPattern* const pcPatternKey, IntTZSearchStruct& rcStruct, const TComMv* const pcMvSrchRngLT, const TComMv* const pcMvSrchRngRB );
    173173  __inline Void xTZ8PointSquareSearch ( const TComPattern* const pcPatternKey, IntTZSearchStruct& rcStruct, const TComMv* const pcMvSrchRngLT, const TComMv* const pcMvSrchRngRB, const Int iStartX, const Int iStartY, const Int iDist );
    174   __inline Void xTZ8PointDiamondSearch( const TComPattern* const pcPatternKey, IntTZSearchStruct& rcStruct, const TComMv* const pcMvSrchRngLT, const TComMv* const pcMvSrchRngRB, const Int iStartX, const Int iStartY, const Int iDist );
     174  __inline Void xTZ8PointDiamondSearch( const TComPattern* const pcPatternKey, IntTZSearchStruct& rcStruct, const TComMv* const pcMvSrchRngLT, const TComMv* const pcMvSrchRngRB, const Int iStartX, const Int iStartY, const Int iDist, const Bool bCheckCornersAtDist1 );
    175175
    176176  Void xGetInterPredictionError( TComDataCU* pcCU, TComYuv* pcYuvOrg, Int iPartIdx, Distortion& ruiSAD, Bool Hadamard );
     
    402402                                    TComMv&                  rcMv,
    403403                                    Distortion&              ruiSAD,
    404                                     const TComMv* const      pIntegerMv2Nx2NPred
     404                                    const TComMv* const      pIntegerMv2Nx2NPred,
     405                                    const Bool               bExtendedSettings
    405406                                    );
    406407
Note: See TracChangeset for help on using the changeset viewer.