Changeset 282 in SHVCSoftware for branches/SHM-2.1-dev/source/Lib/TLibEncoder/TEncSearch.cpp
- Timestamp:
- 11 Jun 2013, 02:30:21 (11 years ago)
- Location:
- branches/SHM-2.1-dev/source
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/SHM-2.1-dev/source
- Property svn:mergeinfo changed
/branches/SHM-2.1-multilayers-dev/source (added) merged: 253-257,259-275,277-280
- Property svn:mergeinfo changed
-
branches/SHM-2.1-dev/source/Lib/TLibEncoder/TEncSearch.cpp
r212 r282 3287 3287 #endif 3288 3288 3289 #if (ENCODER_FAST_MODE)3290 Bool testILR;3291 #endif3292 3293 3289 xGetBlkBits( ePartSize, pcCU->getSlice()->isInterP(), iPartIdx, uiLastMode, uiMbBits); 3294 3290 … … 3312 3308 RefPicList eRefPicList = ( iRefList ? REF_PIC_LIST_1 : REF_PIC_LIST_0 ); 3313 3309 3314 #if (ENCODER_FAST_MODE)3315 if (pcCU->getSlice()->getNumRefIdx(eRefPicList) > 1)3316 {3317 testILR = false;3318 }3319 else3320 {3321 testILR = true;3322 }3323 #endif3324 3325 3310 for ( Int iRefIdxTemp = 0; iRefIdxTemp < pcCU->getSlice()->getNumRefIdx(eRefPicList); iRefIdxTemp++ ) 3326 3311 { 3327 3312 #if (ENCODER_FAST_MODE) 3328 3313 TComPic* pcPic = pcCU->getSlice()->getRefPic( eRefPicList, iRefIdxTemp ); 3329 if( !testILR &&pcPic->isILR(pcCU->getLayerId()) && (ePartSize == SIZE_2Nx2N) )3314 if( pcPic->isILR(pcCU->getLayerId()) && (ePartSize == SIZE_2Nx2N) ) 3330 3315 { 3331 3316 continue; … … 6305 6290 6306 6291 #if ENCODER_FAST_MODE 6307 Bool TEncSearch::predInterSearchILRUni( TComDataCU* pcCU, TComYuv* pcOrgYuv, TComYuv*& rpcPredYuv, TComYuv*& rpcResiYuv, TComYuv*& rpcRecoYuv )6292 Bool TEncSearch::predInterSearchILRUni( TComDataCU* pcCU, TComYuv* pcOrgYuv, TComYuv*& rpcPredYuv, TComYuv*& rpcResiYuv, TComYuv*& rpcRecoYuv, UInt refLayerId ) 6308 6293 { 6309 rpcPredYuv->clear(); 6310 rpcRecoYuv->clear(); 6311 6312 Int iNumPredDir = pcCU->getSlice()->isInterP() ? 1 : 2; 6313 6314 TComMv cMv[2]; 6315 TComMv cMvPred[2][33]; 6316 TComMv cMvTemp[2][33]; 6317 TComMv TempMv; 6318 6319 Int iRefIdx[2]={0,0}; 6320 6321 Int aaiMvpIdx[2][33]; 6322 Int aaiMvpNum[2][33]; 6323 6324 UInt uiMbBits[3] = {1, 1, 0}; 6325 UInt uiLastMode = 0; 6326 6327 UInt uiCost[2] = { MAX_UINT, MAX_UINT }; //uni, rdCost 6328 UInt uiCostTemp; 6329 UInt biPDistTemp = MAX_INT; 6330 UInt uiBitsTemp; 6331 6332 PartSize ePartSize = pcCU->getPartitionSize( 0 ); //2Nx2N 6333 Int iPartIdx = 0; //one PU in CU 6334 UInt uiPartAddr; 6335 Int iRoiWidth, iRoiHeight; 6336 6337 xGetBlkBits( ePartSize, pcCU->getSlice()->isInterP(), iPartIdx, uiLastMode, uiMbBits); 6338 pcCU->getPartIndexAndSize( iPartIdx, uiPartAddr, iRoiWidth, iRoiHeight ); 6339 6340 for( Int iRefList = 0; iRefList < iNumPredDir; iRefList++) //list 6341 { 6342 RefPicList eRefPicList = ( iRefList ? REF_PIC_LIST_1 : REF_PIC_LIST_0 ); 6343 6344 Int iRefIdxTemp = -1; 6345 Bool foundILR = false; 6346 for( Int refIdx = 0; refIdx < pcCU->getSlice()->getNumRefIdx(eRefPicList); refIdx++ ) 6347 { 6348 if( pcCU->getSlice()->getRefPic(eRefPicList, refIdx)->isILR(pcCU->getLayerId()) ) 6349 { 6350 iRefIdxTemp = refIdx; 6351 foundILR = true; 6352 break; 6353 } 6354 } 6355 6356 if(!foundILR) //no ILR in eRefPiclist 6357 { 6358 continue; 6359 } 6360 6361 uiBitsTemp = uiMbBits[iRefList]; 6362 if ( pcCU->getSlice()->getNumRefIdx(eRefPicList) > 1 ) 6363 { 6364 uiBitsTemp += iRefIdxTemp+1; 6365 if ( iRefIdxTemp == pcCU->getSlice()->getNumRefIdx(eRefPicList)-1 ) uiBitsTemp--; 6366 } 6367 6368 xEstimateMvPredAMVP( pcCU, pcOrgYuv, iPartIdx, eRefPicList, iRefIdxTemp, cMvPred[iRefList][iRefIdxTemp], false, &biPDistTemp); 6369 aaiMvpIdx[iRefList][iRefIdxTemp] = pcCU->getMVPIdx(eRefPicList, uiPartAddr); 6370 aaiMvpNum[iRefList][iRefIdxTemp] = pcCU->getMVPNum(eRefPicList, uiPartAddr); 6371 6372 uiBitsTemp += m_auiMVPIdxCost[aaiMvpIdx[iRefList][iRefIdxTemp]][AMVP_MAX_NUM_CANDS]; 6373 6374 xMotionEstimation ( pcCU, pcOrgYuv, iPartIdx, eRefPicList, &cMvPred[iRefList][iRefIdxTemp], iRefIdxTemp, cMvTemp[iRefList][iRefIdxTemp], uiBitsTemp, uiCostTemp ); 6375 xCheckBestMVP(pcCU, eRefPicList, cMvTemp[iRefList][iRefIdxTemp], cMvPred[iRefList][iRefIdxTemp], aaiMvpIdx[iRefList][iRefIdxTemp], uiBitsTemp, uiCostTemp); 6376 6377 if( uiCostTemp < uiCost[iRefList] ) 6378 { 6379 uiCost[iRefList] = uiCostTemp; 6380 6381 cMv[iRefList] = cMvTemp[iRefList][iRefIdxTemp]; 6382 iRefIdx[iRefList] = iRefIdxTemp; 6383 6384 pcCU->getCUMvField(eRefPicList)->setAllMv( cMv[iRefList], ePartSize, uiPartAddr, 0, iPartIdx ); 6385 pcCU->getCUMvField(eRefPicList)->setAllRefIdx( iRefIdx[iRefList], ePartSize, uiPartAddr, 0, iPartIdx ); 6386 } 6387 } 6388 6389 if( uiCost[0] == MAX_UINT && uiCost[1] == MAX_UINT ) //no ILR in both list0 and list1 6390 { 6391 return false; 6392 } 6393 6394 // Clear Motion Field 6395 pcCU->getCUMvField(REF_PIC_LIST_0)->setAllMvField( TComMvField(), ePartSize, uiPartAddr, 0, iPartIdx ); 6396 pcCU->getCUMvField(REF_PIC_LIST_1)->setAllMvField( TComMvField(), ePartSize, uiPartAddr, 0, iPartIdx ); 6397 pcCU->getCUMvField(REF_PIC_LIST_0)->setAllMvd ( TComMv(), ePartSize, uiPartAddr, 0, iPartIdx ); 6398 pcCU->getCUMvField(REF_PIC_LIST_1)->setAllMvd ( TComMv(), ePartSize, uiPartAddr, 0, iPartIdx ); 6399 6400 pcCU->setMVPIdxSubParts( -1, REF_PIC_LIST_0, uiPartAddr, iPartIdx, pcCU->getDepth(uiPartAddr)); 6401 pcCU->setMVPNumSubParts( -1, REF_PIC_LIST_0, uiPartAddr, iPartIdx, pcCU->getDepth(uiPartAddr)); 6402 pcCU->setMVPIdxSubParts( -1, REF_PIC_LIST_1, uiPartAddr, iPartIdx, pcCU->getDepth(uiPartAddr)); 6403 pcCU->setMVPNumSubParts( -1, REF_PIC_LIST_1, uiPartAddr, iPartIdx, pcCU->getDepth(uiPartAddr)); 6404 6405 if( uiCost[0] <= uiCost[1] ) //list0 ILR 6406 { 6407 pcCU->getCUMvField(REF_PIC_LIST_0)->setAllMv ( cMv[0], ePartSize, uiPartAddr, 0, iPartIdx ); 6408 pcCU->getCUMvField(REF_PIC_LIST_0)->setAllRefIdx( iRefIdx[0], ePartSize, uiPartAddr, 0, iPartIdx ); 6409 6410 TempMv = cMv[0] - cMvPred[0][iRefIdx[0]]; 6411 pcCU->getCUMvField(REF_PIC_LIST_0)->setAllMvd( TempMv, ePartSize, uiPartAddr, 0, iPartIdx ); 6412 6413 pcCU->setInterDirSubParts( 1, uiPartAddr, iPartIdx, pcCU->getDepth(0) ); 6414 6415 pcCU->setMVPIdxSubParts( aaiMvpIdx[0][iRefIdx[0]], REF_PIC_LIST_0, uiPartAddr, iPartIdx, pcCU->getDepth(uiPartAddr)); 6416 pcCU->setMVPNumSubParts( aaiMvpNum[0][iRefIdx[0]], REF_PIC_LIST_0, uiPartAddr, iPartIdx, pcCU->getDepth(uiPartAddr)); 6417 } 6418 else if( uiCost[1] < uiCost[0] ) //list1 ILR 6419 { 6420 pcCU->getCUMvField(REF_PIC_LIST_1)->setAllMv ( cMv[1], ePartSize, uiPartAddr, 0, iPartIdx ); 6421 pcCU->getCUMvField(REF_PIC_LIST_1)->setAllRefIdx( iRefIdx[1], ePartSize, uiPartAddr, 0, iPartIdx ); 6422 6423 TempMv = cMv[1] - cMvPred[1][iRefIdx[1]]; 6424 pcCU->getCUMvField(REF_PIC_LIST_1)->setAllMvd( TempMv, ePartSize, uiPartAddr, 0, iPartIdx ); 6425 6426 pcCU->setInterDirSubParts( 2, uiPartAddr, iPartIdx, pcCU->getDepth(0) ); 6427 6428 pcCU->setMVPIdxSubParts( aaiMvpIdx[1][iRefIdx[1]], REF_PIC_LIST_1, uiPartAddr, iPartIdx, pcCU->getDepth(uiPartAddr)); 6429 pcCU->setMVPNumSubParts( aaiMvpNum[1][iRefIdx[1]], REF_PIC_LIST_1, uiPartAddr, iPartIdx, pcCU->getDepth(uiPartAddr)); 6430 } 6431 else 6432 { 6433 assert(0); 6434 } 6435 6436 pcCU->setMergeFlagSubParts( false, uiPartAddr, iPartIdx, pcCU->getDepth( uiPartAddr ) ); 6437 6438 motionCompensation ( pcCU, rpcPredYuv, REF_PIC_LIST_X, iPartIdx ); 6439 6440 setWpScalingDistParam( pcCU, -1, REF_PIC_LIST_X ); 6441 6442 return true; 6294 rpcPredYuv->clear(); 6295 rpcRecoYuv->clear(); 6296 6297 Int iNumPredDir = pcCU->getSlice()->isInterP() ? 1 : 2; 6298 6299 TComMv cMv[2]; 6300 TComMv cMvPred[2][33]; 6301 TComMv cMvTemp[2][33]; 6302 TComMv TempMv; 6303 6304 Int iRefIdx[2]={0,0}; 6305 6306 Int aaiMvpIdx[2][33]; 6307 Int aaiMvpNum[2][33]; 6308 6309 UInt uiMbBits[3] = {1, 1, 0}; 6310 UInt uiLastMode = 0; 6311 6312 UInt uiCost[2] = { MAX_UINT, MAX_UINT }; //uni, rdCost 6313 UInt uiCostTemp; 6314 UInt biPDistTemp = MAX_INT; 6315 UInt uiBitsTemp; 6316 6317 PartSize ePartSize = pcCU->getPartitionSize( 0 ); //2Nx2N 6318 Int iPartIdx = 0; //one PU in CU 6319 UInt uiPartAddr; 6320 Int iRoiWidth, iRoiHeight; 6321 Bool bILRSearched = false; 6322 6323 xGetBlkBits( ePartSize, pcCU->getSlice()->isInterP(), iPartIdx, uiLastMode, uiMbBits); 6324 pcCU->getPartIndexAndSize( iPartIdx, uiPartAddr, iRoiWidth, iRoiHeight ); 6325 6326 for( Int iRefList = 0; iRefList < iNumPredDir; iRefList++) //list 6327 { 6328 if(bILRSearched) 6329 continue; 6330 6331 RefPicList eRefPicList = ( iRefList ? REF_PIC_LIST_1 : REF_PIC_LIST_0 ); 6332 6333 Int iRefIdxTemp = -1; 6334 Bool foundILR = false; 6335 6336 for( Int refIdx = 0; refIdx < pcCU->getSlice()->getNumRefIdx(eRefPicList); refIdx++ ) 6337 { 6338 if( pcCU->getSlice()->getRefPic(eRefPicList, refIdx)->isILR(pcCU->getLayerId()) && pcCU->getSlice()->getRefPic(eRefPicList, refIdx)->getLayerId() == refLayerId ) 6339 { 6340 iRefIdxTemp = refIdx; 6341 foundILR = true; 6342 bILRSearched = true; 6343 break; 6344 } 6345 } 6346 6347 if(!foundILR) //no ILR in eRefPiclist 6348 { 6349 continue; 6350 } 6351 6352 uiBitsTemp = uiMbBits[iRefList]; 6353 if ( pcCU->getSlice()->getNumRefIdx(eRefPicList) > 1 ) 6354 { 6355 uiBitsTemp += iRefIdxTemp+1; 6356 if ( iRefIdxTemp == pcCU->getSlice()->getNumRefIdx(eRefPicList)-1 ) uiBitsTemp--; 6357 } 6358 6359 xEstimateMvPredAMVP( pcCU, pcOrgYuv, iPartIdx, eRefPicList, iRefIdxTemp, cMvPred[iRefList][iRefIdxTemp], false, &biPDistTemp); 6360 aaiMvpIdx[iRefList][iRefIdxTemp] = pcCU->getMVPIdx(eRefPicList, uiPartAddr); 6361 aaiMvpNum[iRefList][iRefIdxTemp] = pcCU->getMVPNum(eRefPicList, uiPartAddr); 6362 6363 uiBitsTemp += m_auiMVPIdxCost[aaiMvpIdx[iRefList][iRefIdxTemp]][AMVP_MAX_NUM_CANDS]; 6364 6365 xMotionEstimation ( pcCU, pcOrgYuv, iPartIdx, eRefPicList, &cMvPred[iRefList][iRefIdxTemp], iRefIdxTemp, cMvTemp[iRefList][iRefIdxTemp], uiBitsTemp, uiCostTemp ); 6366 xCheckBestMVP(pcCU, eRefPicList, cMvTemp[iRefList][iRefIdxTemp], cMvPred[iRefList][iRefIdxTemp], aaiMvpIdx[iRefList][iRefIdxTemp], uiBitsTemp, uiCostTemp); 6367 6368 if( uiCostTemp < uiCost[iRefList] ) 6369 { 6370 uiCost[iRefList] = uiCostTemp; 6371 6372 cMv[iRefList] = cMvTemp[iRefList][iRefIdxTemp]; 6373 iRefIdx[iRefList] = iRefIdxTemp; 6374 6375 pcCU->getCUMvField(eRefPicList)->setAllMv( cMv[iRefList], ePartSize, uiPartAddr, 0, iPartIdx ); 6376 pcCU->getCUMvField(eRefPicList)->setAllRefIdx( iRefIdx[iRefList], ePartSize, uiPartAddr, 0, iPartIdx ); 6377 } 6378 } 6379 6380 if( uiCost[0] == MAX_UINT && uiCost[1] == MAX_UINT ) //no ILR in both list0 and list1 6381 { 6382 return false; 6383 } 6384 6385 // Clear Motion Field 6386 pcCU->getCUMvField(REF_PIC_LIST_0)->setAllMvField( TComMvField(), ePartSize, uiPartAddr, 0, iPartIdx ); 6387 pcCU->getCUMvField(REF_PIC_LIST_1)->setAllMvField( TComMvField(), ePartSize, uiPartAddr, 0, iPartIdx ); 6388 pcCU->getCUMvField(REF_PIC_LIST_0)->setAllMvd ( TComMv(), ePartSize, uiPartAddr, 0, iPartIdx ); 6389 pcCU->getCUMvField(REF_PIC_LIST_1)->setAllMvd ( TComMv(), ePartSize, uiPartAddr, 0, iPartIdx ); 6390 6391 pcCU->setMVPIdxSubParts( -1, REF_PIC_LIST_0, uiPartAddr, iPartIdx, pcCU->getDepth(uiPartAddr)); 6392 pcCU->setMVPNumSubParts( -1, REF_PIC_LIST_0, uiPartAddr, iPartIdx, pcCU->getDepth(uiPartAddr)); 6393 pcCU->setMVPIdxSubParts( -1, REF_PIC_LIST_1, uiPartAddr, iPartIdx, pcCU->getDepth(uiPartAddr)); 6394 pcCU->setMVPNumSubParts( -1, REF_PIC_LIST_1, uiPartAddr, iPartIdx, pcCU->getDepth(uiPartAddr)); 6395 6396 if( uiCost[0] <= uiCost[1] ) //list0 ILR 6397 { 6398 pcCU->getCUMvField(REF_PIC_LIST_0)->setAllMv ( cMv[0], ePartSize, uiPartAddr, 0, iPartIdx ); 6399 pcCU->getCUMvField(REF_PIC_LIST_0)->setAllRefIdx( iRefIdx[0], ePartSize, uiPartAddr, 0, iPartIdx ); 6400 6401 TempMv = cMv[0] - cMvPred[0][iRefIdx[0]]; 6402 pcCU->getCUMvField(REF_PIC_LIST_0)->setAllMvd( TempMv, ePartSize, uiPartAddr, 0, iPartIdx ); 6403 6404 pcCU->setInterDirSubParts( 1, uiPartAddr, iPartIdx, pcCU->getDepth(0) ); 6405 6406 pcCU->setMVPIdxSubParts( aaiMvpIdx[0][iRefIdx[0]], REF_PIC_LIST_0, uiPartAddr, iPartIdx, pcCU->getDepth(uiPartAddr)); 6407 pcCU->setMVPNumSubParts( aaiMvpNum[0][iRefIdx[0]], REF_PIC_LIST_0, uiPartAddr, iPartIdx, pcCU->getDepth(uiPartAddr)); 6408 } 6409 else if( uiCost[1] < uiCost[0] ) //list1 ILR 6410 { 6411 pcCU->getCUMvField(REF_PIC_LIST_1)->setAllMv ( cMv[1], ePartSize, uiPartAddr, 0, iPartIdx ); 6412 pcCU->getCUMvField(REF_PIC_LIST_1)->setAllRefIdx( iRefIdx[1], ePartSize, uiPartAddr, 0, iPartIdx ); 6413 6414 TempMv = cMv[1] - cMvPred[1][iRefIdx[1]]; 6415 pcCU->getCUMvField(REF_PIC_LIST_1)->setAllMvd( TempMv, ePartSize, uiPartAddr, 0, iPartIdx ); 6416 6417 pcCU->setInterDirSubParts( 2, uiPartAddr, iPartIdx, pcCU->getDepth(0) ); 6418 6419 pcCU->setMVPIdxSubParts( aaiMvpIdx[1][iRefIdx[1]], REF_PIC_LIST_1, uiPartAddr, iPartIdx, pcCU->getDepth(uiPartAddr)); 6420 pcCU->setMVPNumSubParts( aaiMvpNum[1][iRefIdx[1]], REF_PIC_LIST_1, uiPartAddr, iPartIdx, pcCU->getDepth(uiPartAddr)); 6421 } 6422 else 6423 { 6424 assert(0); 6425 } 6426 6427 pcCU->setMergeFlagSubParts( false, uiPartAddr, iPartIdx, pcCU->getDepth( uiPartAddr ) ); 6428 6429 motionCompensation ( pcCU, rpcPredYuv, REF_PIC_LIST_X, iPartIdx ); 6430 setWpScalingDistParam( pcCU, -1, REF_PIC_LIST_X ); 6431 6432 return true; 6443 6433 } 6444 6445 6446 6434 #endif 6447 6435
Note: See TracChangeset for help on using the changeset viewer.