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