Changeset 1407 in SHVCSoftware
- Timestamp:
- 4 Aug 2015, 04:21:59 (9 years ago)
- Location:
- branches/SHM-dev/source
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/SHM-dev/source/App/TAppEncoder/TAppEncCfg.cpp
r1406 r1407 1284 1284 // motion search options 1285 1285 ("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") 1287 1287 ("SearchRange,-sr", m_iSearchRange, 96, "Motion search range") 1288 1288 ("BipredSearchRange", m_bipredSearchRange, 4, "Motion search range for bipred refinement") -
branches/SHM-dev/source/Lib/TLibCommon/TypeDef.h
r1406 r1407 508 508 MESEARCH_DIAMOND = 1, 509 509 MESEARCH_SELECTIVE = 2, 510 MESEARCH_NUMBER_OF_METHODS = 3 510 MESEARCH_DIAMOND_ENHANCED = 3, 511 MESEARCH_NUMBER_OF_METHODS = 4 511 512 }; 512 513 -
branches/SHM-dev/source/Lib/TLibEncoder/TEncSearch.cpp
r1406 r1407 419 419 if( uiSad < rcStruct.uiBestSad ) 420 420 { 421 422 421 // motion cost 423 422 uiSad += m_pcRdCost->getCost( iSearchX, iSearchY ); … … 634 633 const Int iStartX, 635 634 const Int iStartY, 636 const Int iDist) 635 const Int iDist, 636 const Bool bCheckCornersAtDist1 ) 637 637 { 638 638 const Int iSrchRngHorLeft = pcMvSrchRngLT->getHor(); … … 655 655 if ( iTop >= iSrchRngVerTop ) // check top 656 656 { 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 } 658 673 } 659 674 if ( iLeft >= iSrchRngHorLeft ) // check middle left … … 667 682 if ( iBottom <= iSrchRngVerBottom ) // check bottom 668 683 { 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 } 670 700 } 671 701 } … … 4069 4099 { 4070 4100 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 ); 4072 4102 break; 4073 4103 4074 4104 case MESEARCH_SELECTIVE: 4075 4105 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 ); 4076 4110 break; 4077 4111 … … 4091 4125 TComMv& rcMv, 4092 4126 Distortion& ruiSAD, 4093 const TComMv* const pIntegerMv2Nx2NPred ) 4127 const TComMv* const pIntegerMv2Nx2NPred, 4128 const Bool bExtendedSettings) 4094 4129 { 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; 4111 4151 4112 4152 UInt uiSearchRange = m_iSearchRange; … … 4197 4237 Int iStartY = cStruct.iBestY; 4198 4238 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 4200 4243 for ( iDist = 1; iDist <= (Int)uiSearchRange; iDist*=2 ) 4201 4244 { 4202 4245 if ( bFirstSearchDiamond == 1 ) 4203 4246 { 4204 xTZ8PointDiamondSearch ( pcPatternKey, cStruct, pcMvSrchRngLT, pcMvSrchRngRB, iStartX, iStartY, iDist );4247 xTZ8PointDiamondSearch ( pcPatternKey, cStruct, pcMvSrchRngLT, pcMvSrchRngRB, iStartX, iStartY, iDist, bFirstCornersForDiamondDist1 ); 4205 4248 } 4206 4249 else … … 4215 4258 } 4216 4259 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 4228 4292 { 4229 4293 break; … … 4241 4305 4242 4306 // 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 } 4251 4343 } 4252 4344 } … … 4254 4346 4255 4347 // raster refinement 4348 4256 4349 if ( bRasterRefinementEnable && cStruct.uiBestDistance > 0 ) 4257 4350 { … … 4265 4358 if ( bRasterRefinementDiamond == 1 ) 4266 4359 { 4267 xTZ8PointDiamondSearch ( pcPatternKey, cStruct, pcMvSrchRngLT, pcMvSrchRngRB, iStartX, iStartY, iDist );4360 xTZ8PointDiamondSearch ( pcPatternKey, cStruct, pcMvSrchRngLT, pcMvSrchRngRB, iStartX, iStartY, iDist, bRasterRefinementCornersForDiamondDist1 ); 4268 4361 } 4269 4362 else … … 4298 4391 if ( bStarRefinementDiamond == 1 ) 4299 4392 { 4300 xTZ8PointDiamondSearch ( pcPatternKey, cStruct, pcMvSrchRngLT, pcMvSrchRngRB, iStartX, iStartY, iDist );4393 xTZ8PointDiamondSearch ( pcPatternKey, cStruct, pcMvSrchRngLT, pcMvSrchRngRB, iStartX, iStartY, iDist, bStarRefinementCornersForDiamondDist1 ); 4301 4394 } 4302 4395 else … … 4443 4536 { 4444 4537 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 ); 4447 4540 } 4448 4541 } … … 4475 4568 if ( bStarRefinementDiamond == 1 ) 4476 4569 { 4477 xTZ8PointDiamondSearch ( pcPatternKey, cStruct, pcMvSrchRngLT, pcMvSrchRngRB, iStartX, iStartY, iDist );4570 xTZ8PointDiamondSearch ( pcPatternKey, cStruct, pcMvSrchRngLT, pcMvSrchRngRB, iStartX, iStartY, iDist, false ); 4478 4571 } 4479 4572 else -
branches/SHM-dev/source/Lib/TLibEncoder/TEncSearch.h
r1406 r1407 172 172 __inline Void xTZ2PointSearch ( const TComPattern* const pcPatternKey, IntTZSearchStruct& rcStruct, const TComMv* const pcMvSrchRngLT, const TComMv* const pcMvSrchRngRB ); 173 173 __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 ); 175 175 176 176 Void xGetInterPredictionError( TComDataCU* pcCU, TComYuv* pcYuvOrg, Int iPartIdx, Distortion& ruiSAD, Bool Hadamard ); … … 402 402 TComMv& rcMv, 403 403 Distortion& ruiSAD, 404 const TComMv* const pIntegerMv2Nx2NPred 404 const TComMv* const pIntegerMv2Nx2NPred, 405 const Bool bExtendedSettings 405 406 ); 406 407
Note: See TracChangeset for help on using the changeset viewer.