Changeset 54 in SHVCSoftware for branches/HM-10.0-dev-SHM/source/Lib/TLibEncoder/TEncSearch.cpp
- Timestamp:
- 2 Mar 2013, 09:25:00 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HM-10.0-dev-SHM/source/Lib/TLibEncoder/TEncSearch.cpp
r51 r54 906 906 m_pcEntropyCoder->encodePredMode( pcCU, 0, true ); 907 907 } 908 908 #if INTRA_BL 909 m_pcEntropyCoder->encodeIntraBLFlag ( pcCU, 0, true ); 910 if( pcCU->isIntraBL( 0 ) ) 911 { 912 return; 913 } 914 #endif 909 915 m_pcEntropyCoder ->encodePartSize( pcCU, 0, pcCU->getDepth(0), true ); 910 916 … … 944 950 } 945 951 } 952 #if INTRA_BL 953 if( pcCU->isIntraBL( 0 ) ) 954 { 955 return; 956 } 957 #endif 946 958 if( bChroma ) 947 959 { … … 1043 1055 pcCU->getPattern()->initAdiPattern( pcCU, uiAbsPartIdx, uiTrDepth, m_piYuvExt, m_iYuvExtStride, m_iYuvExtHeight, bAboveAvail, bLeftAvail ); 1044 1056 //===== get prediction signal ===== 1057 #if INTRA_BL && !NO_RESIDUAL_FLAG_FOR_BLPRED 1058 if(pcCU->isIntraBL ( uiAbsPartIdx ) ) 1059 { 1060 pcCU->getBaseLumaBlk( uiWidth, uiHeight, uiAbsPartIdx, piPred, uiStride ); 1061 } 1062 else 1063 #endif 1045 1064 predIntraLumaAng( pcCU->getPattern(), uiLumaPredMode, piPred, uiStride, uiWidth, uiHeight, bAboveAvail, bLeftAvail ); 1046 1065 // save prediction … … 1228 1247 1229 1248 //===== get prediction signal ===== 1249 #if INTRA_BL && !NO_RESIDUAL_FLAG_FOR_BLPRED 1250 if(pcCU->isIntraBL ( uiAbsPartIdx ) ) 1251 { 1252 pcCU->getBaseChromaBlk( uiWidth, uiHeight, uiAbsPartIdx, piPred, uiStride, uiChromaId ); 1253 } 1254 else 1255 #endif 1230 1256 { 1231 1257 predIntraChromaAng( pPatChroma, uiChromaPredMode, piPred, uiStride, uiWidth, uiHeight, bAboveAvail, bLeftAvail ); … … 3039 3065 Int iHeight = 0; 3040 3066 3067 #if REF_IDX_FRAMEWORK // HM bug fix 3068 for( UInt uiMergeCand = 0; uiMergeCand < pcCU->getSlice()->getMaxNumMergeCand(); ++uiMergeCand ) 3069 { 3070 uhInterDirNeighbours[uiMergeCand] = 0; 3071 cMvFieldNeighbours[0 + 2*uiMergeCand].setMvField(TComMv(), NOT_VALID); 3072 cMvFieldNeighbours[1 + 2*uiMergeCand].setMvField(TComMv(), NOT_VALID); 3073 } 3074 #endif 3041 3075 pcCU->getPartIndexAndSize( iPUIdx, uiAbsPartIdx, iWidth, iHeight ); 3042 3076 UInt uiDepth = pcCU->getDepth( uiAbsPartIdx ); … … 3060 3094 for( UInt uiMergeCand = 0; uiMergeCand < numValidMergeCand; ++uiMergeCand ) 3061 3095 { 3062 { 3096 #if REF_IDX_ME_ZEROMV 3097 Bool bZeroMVILR = pcCU->xCheckZeroMVILRMerge(uhInterDirNeighbours[uiMergeCand], cMvFieldNeighbours[0 + 2*uiMergeCand], cMvFieldNeighbours[1 + 2*uiMergeCand]); 3098 if(bZeroMVILR) 3099 { 3100 #endif 3063 3101 UInt uiCostCand = MAX_UINT; 3064 3102 UInt uiBitsCand = 0; … … 3084 3122 uiMergeIndex = uiMergeCand; 3085 3123 } 3086 } 3124 #if REF_IDX_ME_ZEROMV 3125 } 3126 #endif 3087 3127 } 3088 3128 } … … 3209 3249 UInt uiBitsTempL0[MAX_NUM_REF]; 3210 3250 3251 #if (ENCODER_FAST_MODE) 3252 Bool testILR; 3253 #endif 3254 3211 3255 xGetBlkBits( ePartSize, pcCU->getSlice()->isInterP(), iPartIdx, uiLastMode, uiMbBits); 3212 3256 … … 3230 3274 RefPicList eRefPicList = ( iRefList ? REF_PIC_LIST_1 : REF_PIC_LIST_0 ); 3231 3275 3276 #if (ENCODER_FAST_MODE) 3277 if (pcCU->getSlice()->getNumRefIdx(eRefPicList) > 1) 3278 { 3279 testILR = false; 3280 } 3281 else 3282 { 3283 testILR = true; 3284 } 3285 #endif 3286 3232 3287 for ( Int iRefIdxTemp = 0; iRefIdxTemp < pcCU->getSlice()->getNumRefIdx(eRefPicList); iRefIdxTemp++ ) 3233 3288 { 3289 #if (ENCODER_FAST_MODE) 3290 TComPic* pcPic = pcCU->getSlice()->getRefPic( eRefPicList, iRefIdxTemp ); 3291 if( !testILR && pcPic->getIsILR() && (ePartSize == SIZE_2Nx2N) ) 3292 { 3293 continue; 3294 } 3295 #endif 3296 3234 3297 uiBitsTemp = uiMbBits[iRefList]; 3235 3298 if ( pcCU->getSlice()->getNumRefIdx(eRefPicList) > 1 ) … … 3248 3311 if(pcCU->getSlice()->getMvdL1ZeroFlag() && iRefList==1 && biPDistTemp < bestBiPDist) 3249 3312 { 3313 #if REF_IDX_ME_ZEROMV 3314 Bool bZeroMVILR = pcCU->xCheckZeroMVILRMvdL1Zero(iRefList, iRefIdxTemp, aaiMvpIdx[iRefList][iRefIdxTemp]); 3315 if(bZeroMVILR) 3316 { 3317 #endif 3250 3318 bestBiPDist = biPDistTemp; 3251 3319 bestBiPMvpL1 = aaiMvpIdx[iRefList][iRefIdxTemp]; 3252 3320 bestBiPRefIdxL1 = iRefIdxTemp; 3321 #if REF_IDX_ME_ZEROMV 3322 } 3323 #endif 3253 3324 } 3254 3325 … … 3343 3414 } 3344 3415 3416 #if ENCODER_BUGFIX 3417 if ( ( iRefList == 0 && uiCostTemp < uiCost[iRefList] ) || 3418 ( iRefList == 1 && pcCU->getSlice()->getNoBackPredFlag() && iRefIdxTemp == iRefIdx[0] ) || 3419 ( iRefList == 1 && !pcCU->getSlice()->getNoBackPredFlag() && uiCostTemp < uiCost[iRefList] ) ) 3420 #else 3345 3421 if ( ( iRefList == 0 && uiCostTemp < uiCost[iRefList] ) || 3346 3422 ( iRefList == 1 && pcCU->getSlice()->getNoBackPredFlag() && iRefIdxTemp == iRefIdx[0] ) || 3347 3423 ( iRefList == 1 && (pcCU->getSlice()->getNumRefIdx(REF_PIC_LIST_C) > 0) && (iRefIdxTemp==0 || iRefIdxTemp == iRefIdx[0]) && !pcCU->getSlice()->getNoBackPredFlag() && (iRefIdxTemp == pcCU->getSlice()->getRefIdxOfL0FromRefIdxOfL1(iRefIdxTemp)) ) || 3348 3424 ( iRefList == 1 && !pcCU->getSlice()->getNoBackPredFlag() && uiCostTemp < uiCost[iRefList] ) ) 3425 #endif 3349 3426 { 3350 3427 uiCost[iRefList] = uiCostTemp; … … 3375 3452 } 3376 3453 // Bi-directional prediction 3454 #if REF_IDX_ME_ZEROMV 3455 if ( (pcCU->getSlice()->isInterB()) && (pcCU->isBipredRestriction(iPartIdx) == false) && !(pcCU->getSlice()->getMvdL1ZeroFlag() && bestBiPDist == MAX_INT) ) 3456 #else 3377 3457 if ( (pcCU->getSlice()->isInterB()) && (pcCU->isBipredRestriction(iPartIdx) == false) ) 3458 #endif 3378 3459 { 3379 3460 … … 3449 3530 Bool bChanged = false; 3450 3531 3532 #if (ENCODER_FAST_MODE) 3533 Bool testIter = true; 3534 TComPic* pcPic = pcCU->getSlice()->getRefPic( RefPicList(1 - iRefList), iRefIdxBi[1 - iRefList] ); 3535 if(pcPic->getIsILR() && (ePartSize == SIZE_2Nx2N)) 3536 testIter = false; //the fixed part is ILR, skip this iteration 3537 if(testIter) 3538 { 3539 #endif 3451 3540 iRefStart = 0; 3452 3541 iRefEnd = pcCU->getSlice()->getNumRefIdx(eRefPicList)-1; … … 3454 3543 for ( Int iRefIdxTemp = iRefStart; iRefIdxTemp <= iRefEnd; iRefIdxTemp++ ) 3455 3544 { 3545 #if (ENCODER_FAST_MODE) 3546 Bool testRefIdx = true; 3547 pcPic = pcCU->getSlice()->getRefPic( RefPicList(iRefList) , iRefIdxTemp ); 3548 if(pcPic->getIsILR() && (ePartSize == SIZE_2Nx2N)) 3549 testRefIdx = false; //the refined part is ILR, skip this reference pic 3550 if(testRefIdx) 3551 { 3552 #endif 3456 3553 uiBitsTemp = uiMbBits[2] + uiMotBits[1-iRefList]; 3457 3554 if ( pcCU->getSlice()->getNumRefIdx(eRefPicList) > 1 ) … … 3487 3584 } 3488 3585 } 3586 #if (ENCODER_FAST_MODE) 3587 } 3588 #endif 3589 } 3590 #if (ENCODER_FAST_MODE) 3489 3591 } // for loop-iRefIdxTemp 3592 #endif 3490 3593 3491 3594 if ( !bChanged ) … … 4104 4207 setWpScalingDistParam( pcCU, iRefIdxPred, eRefPicList ); 4105 4208 // Do integer search 4209 #if REF_IDX_ME_AROUND_ZEROMV || REF_IDX_ME_ZEROMV 4210 #if REF_IDX_ME_AROUND_ZEROMV 4211 if( pcCU->getSlice()->getRefPic(eRefPicList, iRefIdxPred )->getIsILR()) //ILR reference pic 4212 { 4213 xPatternSearchILR ( pcCU, pcPatternKey, piRefY, iRefStride, rcMv, ruiCost ); 4214 } 4215 else //non ILR reference pic 4216 { 4106 4217 if ( !m_iFastSearch || bBi ) 4107 4218 { … … 4112 4223 rcMv = *pcMvPred; 4113 4224 xPatternSearchFast ( pcCU, pcPatternKey, piRefY, iRefStride, &cMvSrchRngLT, &cMvSrchRngRB, rcMv, ruiCost ); 4114 } 4225 } 4226 } 4227 #endif 4228 #if REF_IDX_ME_ZEROMV 4229 if( pcCU->getSlice()->getRefPic( eRefPicList, iRefIdxPred )->getIsILR()) //ILR reference pic 4230 { 4231 rcMv.setZero(); //use Mv(0, 0) for integer ME 4232 } 4233 else //non ILR reference pic 4234 { 4235 if ( !m_iFastSearch || bBi ) 4236 { 4237 xPatternSearch ( pcPatternKey, piRefY, iRefStride, &cMvSrchRngLT, &cMvSrchRngRB, rcMv, ruiCost ); 4238 } 4239 else 4240 { 4241 rcMv = *pcMvPred; 4242 xPatternSearchFast ( pcCU, pcPatternKey, piRefY, iRefStride, &cMvSrchRngLT, &cMvSrchRngRB, rcMv, ruiCost ); 4243 } 4244 } 4245 #endif 4246 #else 4247 if ( !m_iFastSearch || bBi ) 4248 { 4249 xPatternSearch ( pcPatternKey, piRefY, iRefStride, &cMvSrchRngLT, &cMvSrchRngRB, rcMv, ruiCost ); 4250 } 4251 else 4252 { 4253 rcMv = *pcMvPred; 4254 xPatternSearchFast ( pcCU, pcPatternKey, piRefY, iRefStride, &cMvSrchRngLT, &cMvSrchRngRB, rcMv, ruiCost ); 4255 } 4256 #endif 4115 4257 4116 4258 m_pcRdCost->getMotionCost( 1, 0 ); … … 4118 4260 4119 4261 { 4262 #if REF_IDX_ME_ZEROMV 4263 if( pcCU->getSlice()->getRefPic( eRefPicList, iRefIdxPred )->getIsILR()) //ILR reference pic 4264 { 4265 xPatternSearchFracDIFMv0( pcCU, pcPatternKey, piRefY, iRefStride, &rcMv, cMvHalf, cMvQter, ruiCost, bBi ); 4266 } 4267 else //non ILR reference pic 4268 { 4269 xPatternSearchFracDIF( pcCU, pcPatternKey, piRefY, iRefStride, &rcMv, cMvHalf, cMvQter, ruiCost, bBi ); 4270 } 4271 #else 4120 4272 xPatternSearchFracDIF( pcCU, pcPatternKey, piRefY, iRefStride, &rcMv, cMvHalf, cMvQter, ruiCost 4121 4273 ,bBi 4122 4274 ); 4275 #endif 4123 4276 } 4124 4277 … … 4457 4610 Void TEncSearch::encodeResAndCalcRdInterCU( TComDataCU* pcCU, TComYuv* pcYuvOrg, TComYuv* pcYuvPred, TComYuv*& rpcYuvResi, TComYuv*& rpcYuvResiBest, TComYuv*& rpcYuvRec, Bool bSkipRes ) 4458 4611 { 4612 #if NO_RESIDUAL_FLAG_FOR_BLPRED 4613 if ( pcCU->isIntra(0) && !pcCU->isIntraBL(0)) 4614 #else 4459 4615 if ( pcCU->isIntra(0) ) 4616 #endif 4460 4617 { 4461 4618 return; … … 4568 4725 pcCU->setTransformSkipSubParts ( 0, 0, 0, 0, pcCU->getDepth(0) ); 4569 4726 } 4727 #if NO_RESIDUAL_FLAG_FOR_BLPRED 4728 else if(pcCU->getLayerId() > 0 && pcCU->isIntraBL(0) && uiZeroDistortion == uiDistortion) // all zeros 4729 { 4730 const UInt uiQPartNum = pcCU->getPic()->getNumPartInCU() >> (pcCU->getDepth(0) << 1); 4731 ::memset( pcCU->getTransformIdx() , 0, uiQPartNum * sizeof(UChar) ); 4732 ::memset( pcCU->getCbf( TEXT_LUMA ) , 0, uiQPartNum * sizeof(UChar) ); 4733 ::memset( pcCU->getCbf( TEXT_CHROMA_U ), 0, uiQPartNum * sizeof(UChar) ); 4734 ::memset( pcCU->getCbf( TEXT_CHROMA_V ), 0, uiQPartNum * sizeof(UChar) ); 4735 ::memset( pcCU->getCoeffY() , 0, uiWidth * uiHeight * sizeof( TCoeff ) ); 4736 ::memset( pcCU->getCoeffCb() , 0, uiWidth * uiHeight * sizeof( TCoeff ) >> 2 ); 4737 ::memset( pcCU->getCoeffCr() , 0, uiWidth * uiHeight * sizeof( TCoeff ) >> 2 ); 4738 pcCU->setTransformSkipSubParts ( 0, 0, 0, 0, pcCU->getDepth(0) ); 4739 } 4740 #endif 4570 4741 else 4571 4742 { … … 4866 5037 Int scalingListType = 3 + g_eTTable[(Int)TEXT_LUMA]; 4867 5038 assert(scalingListType < 6); 5039 #if NO_RESIDUAL_FLAG_FOR_BLPRED 5040 if(pcCU->isIntraBL(uiAbsPartIdx) ) 5041 { 5042 m_pcTrQuant->invtransformNxN( pcCU->getCUTransquantBypass(uiAbsPartIdx), TEXT_LUMA,DC_IDX, pcResiCurrY, m_pcQTTempTComYuv[uiQTTempAccessLayer].getStride(), pcCoeffCurrY, trWidth, trHeight, scalingListType );//this is for inter mode only 5043 } 5044 else 5045 { 5046 m_pcTrQuant->invtransformNxN( pcCU->getCUTransquantBypass(uiAbsPartIdx), TEXT_LUMA,REG_DCT, pcResiCurrY, m_pcQTTempTComYuv[uiQTTempAccessLayer].getStride(), pcCoeffCurrY, trWidth, trHeight, scalingListType );//this is for inter mode only 5047 } 5048 #else 4868 5049 m_pcTrQuant->invtransformNxN( pcCU->getCUTransquantBypass(uiAbsPartIdx), TEXT_LUMA,REG_DCT, pcResiCurrY, m_pcQTTempTComYuv[uiQTTempAccessLayer].getStride(), pcCoeffCurrY, trWidth, trHeight, scalingListType );//this is for inter mode only 5050 #endif 4869 5051 4870 5052 const UInt uiNonzeroDistY = m_pcRdCost->getDistPart(g_bitDepthY, m_pcQTTempTComYuv[uiQTTempAccessLayer].getLumaAddr( absTUPartIdx ), m_pcQTTempTComYuv[uiQTTempAccessLayer].getStride(), … … 5136 5318 assert(scalingListType < 6); 5137 5319 5320 #if NO_RESIDUAL_FLAG_FOR_BLPRED 5321 if(pcCU->isIntraBL(uiAbsPartIdx) ) 5322 { 5323 m_pcTrQuant->invtransformNxN( pcCU->getCUTransquantBypass(uiAbsPartIdx), TEXT_LUMA,DC_IDX, pcResiCurrY, m_pcQTTempTComYuv[uiQTTempAccessLayer].getStride(), pcCoeffCurrY, trWidth, trHeight, scalingListType, true ); 5324 } 5325 else 5326 { 5327 m_pcTrQuant->invtransformNxN( pcCU->getCUTransquantBypass(uiAbsPartIdx), TEXT_LUMA,REG_DCT, pcResiCurrY, m_pcQTTempTComYuv[uiQTTempAccessLayer].getStride(), pcCoeffCurrY, trWidth, trHeight, scalingListType, true ); 5328 } 5329 #else 5138 5330 m_pcTrQuant->invtransformNxN( pcCU->getCUTransquantBypass(uiAbsPartIdx), TEXT_LUMA,REG_DCT, pcResiCurrY, m_pcQTTempTComYuv[uiQTTempAccessLayer].getStride(), pcCoeffCurrY, trWidth, trHeight, scalingListType, true ); 5331 #endif 5139 5332 5140 5333 uiNonzeroDistY = m_pcRdCost->getDistPart(g_bitDepthY, m_pcQTTempTComYuv[uiQTTempAccessLayer].getLumaAddr( absTUPartIdx ), m_pcQTTempTComYuv[uiQTTempAccessLayer].getStride(), … … 5467 5660 5468 5661 { 5662 #if INTRA_BL 5663 #if NO_RESIDUAL_FLAG_FOR_BLPRED 5664 assert( !pcCU->isIntra(uiAbsPartIdx) || pcCU->isIntraBL(uiAbsPartIdx)); 5665 #else 5666 assert( !pcCU->isIntra(uiAbsPartIdx) ); 5667 #endif 5668 #else 5469 5669 assert( pcCU->getPredictionMode(uiAbsPartIdx) != MODE_INTRA ); 5670 #endif 5470 5671 if( bSubdivAndCbf ) 5471 5672 { … … 5701 5902 } 5702 5903 m_pcEntropyCoder->encodeSkipFlag ( pcCU, 0, true ); 5904 #if INTRA_BL 5905 if(m_pcEncCfg->getLayerId()) 5906 { 5907 m_pcEntropyCoder->encodeIntraBLFlag(pcCU, 0, true); 5908 #if !NO_RESIDUAL_FLAG_FOR_BLPRED 5909 assert( pcCU->isIntraBL( 0 ) == false ); 5910 #endif 5911 } 5912 #endif 5913 #if NO_RESIDUAL_FLAG_FOR_BLPRED 5914 if( !pcCU->isIntraBL(0)) 5915 { 5916 #endif 5703 5917 m_pcEntropyCoder->encodePredMode( pcCU, 0, true ); 5704 5918 m_pcEntropyCoder->encodePartSize( pcCU, 0, pcCU->getDepth(0), true ); 5705 5919 m_pcEntropyCoder->encodePredInfo( pcCU, 0, true ); 5920 #if NO_RESIDUAL_FLAG_FOR_BLPRED 5921 } 5922 #endif 5706 5923 Bool bDummy = false; 5707 5924 m_pcEntropyCoder->encodeCoeff ( pcCU, 0, pcCU->getDepth(0), pcCU->getWidth(0), pcCU->getHeight(0), bDummy ); … … 5952 6169 } 5953 6170 6171 #if REF_IDX_ME_ZEROMV 6172 Void TEncSearch::xPatternSearchFracDIFMv0(TComDataCU* pcCU, 6173 TComPattern* pcPatternKey, 6174 Pel* piRefY, 6175 Int iRefStride, 6176 TComMv* pcMvInt, 6177 TComMv& rcMvHalf, 6178 TComMv& rcMvQter, 6179 UInt& ruiCost, 6180 Bool biPred 6181 ) 6182 { 6183 assert(pcMvInt->getHor() == 0 && pcMvInt->getVer() == 0); 6184 Int iOffset = pcMvInt->getHor() + pcMvInt->getVer() * iRefStride; 6185 m_pcRdCost->setDistParam( pcPatternKey, piRefY + iOffset, iRefStride, 1, m_cDistParam, m_pcEncCfg->getUseHADME() ); 6186 m_pcRdCost->setCostScale ( 2 ); 6187 setDistParamComp(0); 6188 ruiCost = m_cDistParam.DistFunc( &m_cDistParam ); //SATD 6189 ruiCost += m_pcRdCost->getCost( pcMvInt->getHor(), pcMvInt->getVer() ); //SATD rdCost 6190 rcMvHalf.setZero(); 6191 rcMvQter.setZero(); 6192 } 6193 #endif 6194 6195 #if REF_IDX_ME_AROUND_ZEROMV 6196 //ILR integer pixel motion estimation search 6197 //pcCU is CU pointer 6198 //pcPatterney contains target PU infor 6199 //piRefY is the PU at the same position as the source PU, but in the reference pic 6200 //iRefStride is the reference stride 6201 //rcMv output best integer MV 6202 //ruiSAD outputs the SAD of best integer MV 6203 Void TEncSearch::xPatternSearchILR( TComDataCU* pcCU, TComPattern* pcPatternKey, Pel* piRefY, Int iRefStride, TComMv& rcMv, UInt& ruiSAD ) 6204 { 6205 Int candMvX[5] = {0, -1, 1, 0, 0}; 6206 Int candMvY[5] = {0, 0, 0, -1, 1}; 6207 Int numCand = 1; 6208 Int iBestX = 0; 6209 Int iBestY = 0; 6210 Int uiSadBest = MAX_UINT; 6211 UInt uiSad; 6212 6213 Pel* piRefSrch; 6214 6215 //-- jclee for using the SAD function pointer 6216 m_pcRdCost->setDistParam( pcPatternKey, piRefY, iRefStride, m_cDistParam ); 6217 6218 // fast encoder decision: use subsampled SAD for integer ME 6219 if ( m_pcEncCfg->getUseFastEnc() ) 6220 { 6221 if ( m_cDistParam.iRows > 8 ) 6222 { 6223 m_cDistParam.iSubShift = 1; 6224 } 6225 } 6226 6227 for(Int candId = 0; candId < numCand; candId++) 6228 { 6229 piRefSrch = piRefY + (candMvY[candId] * iRefStride) + candMvX[candId]; 6230 m_cDistParam.pCur = piRefSrch; 6231 6232 setDistParamComp(0); 6233 6234 uiSad = m_cDistParam.DistFunc( &m_cDistParam ); //SAD 6235 6236 //motion cost 6237 uiSad += m_pcRdCost->getCost( candMvX[candId], candMvY[candId] ); //SAD rdCost 6238 6239 if(uiSad < uiSadBest) 6240 { 6241 uiSadBest = uiSad; 6242 iBestX = candMvX[candId]; 6243 iBestY = candMvY[candId]; 6244 } 6245 } 6246 6247 rcMv.set( iBestX, iBestY ); 6248 6249 ruiSAD = uiSadBest - m_pcRdCost->getCost( iBestX, iBestY ); 6250 return; 6251 } 6252 #endif 6253 6254 #if ENCODER_FAST_MODE 6255 Bool TEncSearch::predInterSearchILRUni( TComDataCU* pcCU, TComYuv* pcOrgYuv, TComYuv*& rpcPredYuv, TComYuv*& rpcResiYuv, TComYuv*& rpcRecoYuv ) 6256 { 6257 rpcPredYuv->clear(); 6258 rpcRecoYuv->clear(); 6259 6260 Int iNumPredDir = pcCU->getSlice()->isInterP() ? 1 : 2; 6261 6262 TComMv cMv[2]; 6263 TComMv cMvPred[2][33]; 6264 TComMv cMvTemp[2][33]; 6265 TComMv TempMv; 6266 6267 Int iRefIdx[2]={0,0}; 6268 6269 Int aaiMvpIdx[2][33]; 6270 Int aaiMvpNum[2][33]; 6271 6272 UInt uiMbBits[3] = {1, 1, 0}; 6273 UInt uiLastMode = 0; 6274 6275 UInt uiCost[2] = { MAX_UINT, MAX_UINT }; //uni, rdCost 6276 UInt uiCostTemp; 6277 UInt biPDistTemp = MAX_INT; 6278 UInt uiBitsTemp; 6279 6280 PartSize ePartSize = pcCU->getPartitionSize( 0 ); //2Nx2N 6281 Int iPartIdx = 0; //one PU in CU 6282 UInt uiPartAddr; 6283 Int iRoiWidth, iRoiHeight; 6284 6285 xGetBlkBits( ePartSize, pcCU->getSlice()->isInterP(), iPartIdx, uiLastMode, uiMbBits); 6286 pcCU->getPartIndexAndSize( iPartIdx, uiPartAddr, iRoiWidth, iRoiHeight ); 6287 6288 for( Int iRefList = 0; iRefList < iNumPredDir; iRefList++) //list 6289 { 6290 RefPicList eRefPicList = ( iRefList ? REF_PIC_LIST_1 : REF_PIC_LIST_0 ); 6291 6292 Int iRefIdxTemp = -1; 6293 Bool foundILR = false; 6294 for( Int refIdx = 0; refIdx < pcCU->getSlice()->getNumRefIdx(eRefPicList); refIdx++ ) 6295 if( pcCU->getSlice()->getRefPic(eRefPicList, refIdx)->getIsILR() ) 6296 { 6297 iRefIdxTemp = refIdx; 6298 foundILR = true; 6299 break; 6300 } 6301 6302 if(!foundILR) //no ILR in eRefPiclist 6303 continue; 6304 6305 uiBitsTemp = uiMbBits[iRefList]; 6306 if ( pcCU->getSlice()->getNumRefIdx(eRefPicList) > 1 ) 6307 { 6308 uiBitsTemp += iRefIdxTemp+1; 6309 if ( iRefIdxTemp == pcCU->getSlice()->getNumRefIdx(eRefPicList)-1 ) uiBitsTemp--; 6310 } 6311 6312 xEstimateMvPredAMVP( pcCU, pcOrgYuv, iPartIdx, eRefPicList, iRefIdxTemp, cMvPred[iRefList][iRefIdxTemp], false, &biPDistTemp); 6313 aaiMvpIdx[iRefList][iRefIdxTemp] = pcCU->getMVPIdx(eRefPicList, uiPartAddr); 6314 aaiMvpNum[iRefList][iRefIdxTemp] = pcCU->getMVPNum(eRefPicList, uiPartAddr); 6315 6316 uiBitsTemp += m_auiMVPIdxCost[aaiMvpIdx[iRefList][iRefIdxTemp]][AMVP_MAX_NUM_CANDS]; 6317 6318 xMotionEstimation ( pcCU, pcOrgYuv, iPartIdx, eRefPicList, &cMvPred[iRefList][iRefIdxTemp], iRefIdxTemp, cMvTemp[iRefList][iRefIdxTemp], uiBitsTemp, uiCostTemp ); 6319 xCheckBestMVP(pcCU, eRefPicList, cMvTemp[iRefList][iRefIdxTemp], cMvPred[iRefList][iRefIdxTemp], aaiMvpIdx[iRefList][iRefIdxTemp], uiBitsTemp, uiCostTemp); 6320 6321 if( uiCostTemp < uiCost[iRefList] ) 6322 { 6323 uiCost[iRefList] = uiCostTemp; 6324 6325 cMv[iRefList] = cMvTemp[iRefList][iRefIdxTemp]; 6326 iRefIdx[iRefList] = iRefIdxTemp; 6327 6328 pcCU->getCUMvField(eRefPicList)->setAllMv( cMv[iRefList], ePartSize, uiPartAddr, 0, iPartIdx ); 6329 pcCU->getCUMvField(eRefPicList)->setAllRefIdx( iRefIdx[iRefList], ePartSize, uiPartAddr, 0, iPartIdx ); 6330 } 6331 } 6332 6333 if( uiCost[0] == MAX_UINT && uiCost[1] == MAX_UINT ) //no ILR in both list0 and list1 6334 return false; 6335 6336 // Clear Motion Field 6337 pcCU->getCUMvField(REF_PIC_LIST_0)->setAllMvField( TComMvField(), ePartSize, uiPartAddr, 0, iPartIdx ); 6338 pcCU->getCUMvField(REF_PIC_LIST_1)->setAllMvField( TComMvField(), ePartSize, uiPartAddr, 0, iPartIdx ); 6339 pcCU->getCUMvField(REF_PIC_LIST_0)->setAllMvd ( TComMv(), ePartSize, uiPartAddr, 0, iPartIdx ); 6340 pcCU->getCUMvField(REF_PIC_LIST_1)->setAllMvd ( TComMv(), ePartSize, uiPartAddr, 0, iPartIdx ); 6341 6342 pcCU->setMVPIdxSubParts( -1, REF_PIC_LIST_0, uiPartAddr, iPartIdx, pcCU->getDepth(uiPartAddr)); 6343 pcCU->setMVPNumSubParts( -1, REF_PIC_LIST_0, uiPartAddr, iPartIdx, pcCU->getDepth(uiPartAddr)); 6344 pcCU->setMVPIdxSubParts( -1, REF_PIC_LIST_1, uiPartAddr, iPartIdx, pcCU->getDepth(uiPartAddr)); 6345 pcCU->setMVPNumSubParts( -1, REF_PIC_LIST_1, uiPartAddr, iPartIdx, pcCU->getDepth(uiPartAddr)); 6346 6347 if( uiCost[0] <= uiCost[1] ) //list0 ILR 6348 { 6349 pcCU->getCUMvField(REF_PIC_LIST_0)->setAllMv ( cMv[0], ePartSize, uiPartAddr, 0, iPartIdx ); 6350 pcCU->getCUMvField(REF_PIC_LIST_0)->setAllRefIdx( iRefIdx[0], ePartSize, uiPartAddr, 0, iPartIdx ); 6351 6352 TempMv = cMv[0] - cMvPred[0][iRefIdx[0]]; 6353 pcCU->getCUMvField(REF_PIC_LIST_0)->setAllMvd( TempMv, ePartSize, uiPartAddr, 0, iPartIdx ); 6354 6355 pcCU->setInterDirSubParts( 1, uiPartAddr, iPartIdx, pcCU->getDepth(0) ); 6356 6357 pcCU->setMVPIdxSubParts( aaiMvpIdx[0][iRefIdx[0]], REF_PIC_LIST_0, uiPartAddr, iPartIdx, pcCU->getDepth(uiPartAddr)); 6358 pcCU->setMVPNumSubParts( aaiMvpNum[0][iRefIdx[0]], REF_PIC_LIST_0, uiPartAddr, iPartIdx, pcCU->getDepth(uiPartAddr)); 6359 } 6360 else if( uiCost[1] < uiCost[0] ) //list1 ILR 6361 { 6362 pcCU->getCUMvField(REF_PIC_LIST_1)->setAllMv ( cMv[1], ePartSize, uiPartAddr, 0, iPartIdx ); 6363 pcCU->getCUMvField(REF_PIC_LIST_1)->setAllRefIdx( iRefIdx[1], ePartSize, uiPartAddr, 0, iPartIdx ); 6364 6365 TempMv = cMv[1] - cMvPred[1][iRefIdx[1]]; 6366 pcCU->getCUMvField(REF_PIC_LIST_1)->setAllMvd( TempMv, ePartSize, uiPartAddr, 0, iPartIdx ); 6367 6368 pcCU->setInterDirSubParts( 2, uiPartAddr, iPartIdx, pcCU->getDepth(0) ); 6369 6370 pcCU->setMVPIdxSubParts( aaiMvpIdx[1][iRefIdx[1]], REF_PIC_LIST_1, uiPartAddr, iPartIdx, pcCU->getDepth(uiPartAddr)); 6371 pcCU->setMVPNumSubParts( aaiMvpNum[1][iRefIdx[1]], REF_PIC_LIST_1, uiPartAddr, iPartIdx, pcCU->getDepth(uiPartAddr)); 6372 } 6373 else 6374 assert(0); 6375 6376 pcCU->setMergeFlagSubParts( false, uiPartAddr, iPartIdx, pcCU->getDepth( uiPartAddr ) ); 6377 6378 motionCompensation ( pcCU, rpcPredYuv, REF_PIC_LIST_X, iPartIdx ); 6379 6380 setWpScalingDistParam( pcCU, -1, REF_PIC_LIST_X ); 6381 6382 return true; 6383 } 6384 6385 6386 #endif 6387 6388 #if INTRA_BL 6389 Void 6390 TEncSearch::estIntraBLPredQT( TComDataCU* pcCU, 6391 TComYuv* pcOrgYuv, 6392 TComYuv* pcPredYuv, 6393 TComYuv* pcResiYuv, 6394 TComYuv* pcRecoYuv ) 6395 { 6396 UInt uiDepth = pcCU->getDepth(0); 6397 UInt uiOverallDistY = 0; 6398 UInt uiOverallDistC = 0; 6399 6400 //===== set QP and clear Cbf ===== 6401 if ( pcCU->getSlice()->getPPS()->getUseDQP() == true) 6402 { 6403 pcCU->setQPSubParts( pcCU->getQP(0), 0, uiDepth ); 6404 } 6405 else 6406 { 6407 pcCU->setQPSubParts( pcCU->getSlice()->getSliceQp(), 0, uiDepth ); 6408 } 6409 6410 //===== init pattern for luma prediction ===== 6411 Bool bAboveAvail = false; 6412 Bool bLeftAvail = false; 6413 pcCU->getPattern()->initPattern ( pcCU, 0, 0 ); 6414 pcCU->getPattern()->initAdiPattern( pcCU, 0, 0, m_piYuvExt, m_iYuvExtStride, m_iYuvExtHeight, bAboveAvail, bLeftAvail ); 6415 6416 pcCU->setLumaIntraDirSubParts ( DC_IDX, 0, uiDepth ); 6417 6418 // set context models 6419 if( m_bUseSBACRD ) 6420 { 6421 m_pcRDGoOnSbacCoder->load( m_pppcRDSbacCoder[uiDepth][CI_CURR_BEST] ); 6422 } 6423 6424 // determine residual for partition 6425 Double dPUCost = 0.0; 6426 xRecurIntraCodingQT( pcCU, 0, 0, false, pcOrgYuv, pcPredYuv, pcResiYuv, uiOverallDistY, uiOverallDistC, false, dPUCost ); 6427 xSetIntraResultQT( pcCU, 0, 0, false, pcRecoYuv ); 6428 6429 //=== update PU data ==== 6430 pcCU->copyToPic( uiDepth, 0, 0 ); 6431 6432 //===== reset context models ===== 6433 if(m_bUseSBACRD) 6434 { 6435 m_pcRDGoOnSbacCoder->load(m_pppcRDSbacCoder[uiDepth][CI_CURR_BEST]); 6436 } 6437 6438 //===== set distortion (rate and r-d costs are determined later) ===== 6439 pcCU->getTotalDistortion() = uiOverallDistY + uiOverallDistC; 6440 } 6441 6442 #endif 5954 6443 //! \}
Note: See TracChangeset for help on using the changeset viewer.