Changeset 1404 in SHVCSoftware
- Timestamp:
- 4 Aug 2015, 04:07:09 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified branches/SHM-dev/source/Lib/TLibEncoder/TEncSearch.cpp ¶
r1403 r1404 346 346 Distortion uiBitCost = m_pcRdCost->getCost( iSearchX, iSearchY ); 347 347 348 if ( m_cDistParam.iRows > 32 ) 349 { 350 m_cDistParam.iSubShift = 4; 351 } 352 else if ( m_cDistParam.iRows > 16 ) 353 { 354 m_cDistParam.iSubShift = 3; 355 } 356 else if ( m_cDistParam.iRows > 8 ) 357 { 358 m_cDistParam.iSubShift = 2; 359 } 360 else 361 { 362 m_cDistParam.iSubShift = 1; 363 } 364 365 Distortion uiTempSad = m_cDistParam.DistFunc( &m_cDistParam ); 366 if((uiTempSad + uiBitCost) < rcStruct.uiBestSad) 367 { 368 uiSad += uiTempSad >> m_cDistParam.iSubShift; 369 while(m_cDistParam.iSubShift > 0) 370 { 371 isubShift = m_cDistParam.iSubShift -1; 372 m_cDistParam.pOrg = pcPatternKey->getROIY() + (pcPatternKey->getPatternLStride() << isubShift); 373 m_cDistParam.pCur = piRefSrch + (rcStruct.iYStride << isubShift); 374 uiTempSad = m_cDistParam.DistFunc( &m_cDistParam ); 348 // Skip search if bit cost is already larger than best SAD 349 if (uiBitCost < rcStruct.uiBestSad) 350 { 351 if ( m_cDistParam.iRows > 32 ) 352 { 353 m_cDistParam.iSubShift = 4; 354 } 355 else if ( m_cDistParam.iRows > 16 ) 356 { 357 m_cDistParam.iSubShift = 3; 358 } 359 else if ( m_cDistParam.iRows > 8 ) 360 { 361 m_cDistParam.iSubShift = 2; 362 } 363 else 364 { 365 m_cDistParam.iSubShift = 1; 366 } 367 368 Distortion uiTempSad = m_cDistParam.DistFunc( &m_cDistParam ); 369 if((uiTempSad + uiBitCost) < rcStruct.uiBestSad) 370 { 375 371 uiSad += uiTempSad >> m_cDistParam.iSubShift; 376 if(((uiSad << isubShift) + uiBitCost) > rcStruct.uiBestSad) 377 { 378 break; 379 } 380 381 m_cDistParam.iSubShift--; 382 } 383 384 if(m_cDistParam.iSubShift == 0) 385 { 386 uiSad += uiBitCost; 387 if( uiSad < rcStruct.uiBestSad ) 388 { 389 rcStruct.uiBestSad = uiSad; 390 rcStruct.iBestX = iSearchX; 391 rcStruct.iBestY = iSearchY; 392 rcStruct.uiBestDistance = uiDistance; 393 rcStruct.uiBestRound = 0; 394 rcStruct.ucPointNr = ucPointNr; 395 m_cDistParam.m_maximumDistortionForEarlyExit = uiSad; 372 while(m_cDistParam.iSubShift > 0) 373 { 374 isubShift = m_cDistParam.iSubShift -1; 375 m_cDistParam.pOrg = pcPatternKey->getROIY() + (pcPatternKey->getPatternLStride() << isubShift); 376 m_cDistParam.pCur = piRefSrch + (rcStruct.iYStride << isubShift); 377 uiTempSad = m_cDistParam.DistFunc( &m_cDistParam ); 378 uiSad += uiTempSad >> m_cDistParam.iSubShift; 379 if(((uiSad << isubShift) + uiBitCost) > rcStruct.uiBestSad) 380 { 381 break; 382 } 383 384 m_cDistParam.iSubShift--; 385 } 386 387 if(m_cDistParam.iSubShift == 0) 388 { 389 uiSad += uiBitCost; 390 if( uiSad < rcStruct.uiBestSad ) 391 { 392 rcStruct.uiBestSad = uiSad; 393 rcStruct.iBestX = iSearchX; 394 rcStruct.iBestY = iSearchY; 395 rcStruct.uiBestDistance = uiDistance; 396 rcStruct.uiBestRound = 0; 397 rcStruct.ucPointNr = ucPointNr; 398 m_cDistParam.m_maximumDistortionForEarlyExit = uiSad; 399 } 396 400 } 397 401 } … … 411 415 uiSad = m_cDistParam.DistFunc( &m_cDistParam ); 412 416 413 // motion cost 414 uiSad += m_pcRdCost->getCost( iSearchX, iSearchY ); 415 417 // only add motion cost if uiSad is smaller than best. Otherwise pointless 418 // to add motion cost. 416 419 if( uiSad < rcStruct.uiBestSad ) 417 420 { 418 rcStruct.uiBestSad = uiSad; 419 rcStruct.iBestX = iSearchX; 420 rcStruct.iBestY = iSearchY; 421 rcStruct.uiBestDistance = uiDistance; 422 rcStruct.uiBestRound = 0; 423 rcStruct.ucPointNr = ucPointNr; 424 m_cDistParam.m_maximumDistortionForEarlyExit = uiSad; 421 422 // motion cost 423 uiSad += m_pcRdCost->getCost( iSearchX, iSearchY ); 424 425 if( uiSad < rcStruct.uiBestSad ) 426 { 427 rcStruct.uiBestSad = uiSad; 428 rcStruct.iBestX = iSearchX; 429 rcStruct.iBestY = iSearchY; 430 rcStruct.uiBestDistance = uiDistance; 431 rcStruct.uiBestRound = 0; 432 rcStruct.ucPointNr = ucPointNr; 433 m_cDistParam.m_maximumDistortionForEarlyExit = uiSad; 434 } 425 435 } 426 436 } … … 3185 3195 #endif 3186 3196 3187 // Bi- directional prediction3197 // Bi-predictive Motion estimation 3188 3198 #if REF_IDX_ME_ZEROMV 3189 3199 if ( (pcCU->getSlice()->isInterB()) && (pcCU->isBipredRestriction(iPartIdx) == false) && !(pcCU->getSlice()->getMvdL1ZeroFlag() && bestBiPDist == MAX_INT) ) … … 3825 3835 3826 3836 3827 3828 3829 3837 Void TEncSearch::xMotionEstimation( TComDataCU* pcCU, TComYuv* pcYuvOrg, Int iPartIdx, RefPicList eRefPicList, TComMv* pcMvPred, Int iRefIdxPred, TComMv& rcMv, UInt& ruiBits, Distortion& ruiCost, Bool bBi ) 3830 3838 { … … 3850 3858 pcCU->getPartIndexAndSize( iPartIdx, uiPartAddr, iRoiWidth, iRoiHeight ); 3851 3859 3852 if ( bBi ) 3860 if ( bBi ) // Bipredictive ME 3853 3861 { 3854 3862 TComYuv* pcYuvOther = &m_acYuvPred[1-(Int)eRefPicList]; … … 3952 3960 3953 3961 3954 3955 3956 3962 Void TEncSearch::xSetSearchRange ( const TComDataCU* const pcCU, const TComMv& cMvPred, const Int iSrchRng, 3957 3963 TComMv& rcMvSrchRngLT, TComMv& rcMvSrchRngRB ) … … 3977 3983 #endif 3978 3984 } 3985 3979 3986 3980 3987 Void TEncSearch::xPatternSearch( const TComPattern* const pcPatternKey, … … 4040 4047 return; 4041 4048 } 4042 4043 4049 4044 4050 … … 4073 4079 } 4074 4080 } 4075 4076 4077 4081 4078 4082 … … 4132 4136 cMv >>= 2; 4133 4137 #endif 4134 xTZSearchHelp( pcPatternKey, cStruct, cMv.getHor(), cMv.getVer(), 0, 0 ); 4138 if (cMv != rcMv && (cMv.getHor() != cStruct.iBestX && cMv.getVer() != cStruct.iBestY)) 4139 { 4140 // only test cMV if not obviously previously tested. 4141 xTZSearchHelp( pcPatternKey, cStruct, cMv.getHor(), cMv.getVer(), 0, 0 ); 4142 } 4135 4143 } 4136 4144 } … … 4139 4147 if ( bTestZeroVector ) 4140 4148 { 4141 xTZSearchHelp( pcPatternKey, cStruct, 0, 0, 0, 0 ); 4149 if ((rcMv.getHor() != 0 || rcMv.getVer() != 0) && 4150 (0 != cStruct.iBestX || 0 != cStruct.iBestY)) 4151 { 4152 // only test 0-vector if not obviously previously tested. 4153 xTZSearchHelp( pcPatternKey, cStruct, 0, 0, 0, 0 ); 4154 } 4142 4155 } 4143 4156 … … 4157 4170 integerMv2Nx2NPred >>= 2; 4158 4171 #endif 4159 xTZSearchHelp(pcPatternKey, cStruct, integerMv2Nx2NPred.getHor(), integerMv2Nx2NPred.getVer(), 0, 0); 4172 if ((rcMv != integerMv2Nx2NPred) && 4173 (integerMv2Nx2NPred.getHor() != cStruct.iBestX || integerMv2Nx2NPred.getVer() != cStruct.iBestY)) 4174 { 4175 // only test integerMv2Nx2NPred if not obviously previously tested. 4176 xTZSearchHelp(pcPatternKey, cStruct, integerMv2Nx2NPred.getHor(), integerMv2Nx2NPred.getVer(), 0, 0); 4177 } 4160 4178 4161 4179 // reset search range … … 4265 4283 } 4266 4284 4267 // star trefinement4285 // star refinement 4268 4286 if ( bStarRefinementEnable && cStruct.uiBestDistance > 0 ) 4269 4287 {
Note: See TracChangeset for help on using the changeset viewer.