Motion Estimation and Prediction

20
Motion Estimation and Prediction Present by :fakewen

description

Motion Estimation and Prediction. Present by : fakewen. Motion Estimation and Prediction. 主要分布位置 Tcomprediction.cpp TEncSearch.cpp. predInterSearch. I frame. - PowerPoint PPT Presentation

Transcript of Motion Estimation and Prediction

Page 1: Motion Estimation and Prediction

Motion Estimation and Prediction

Present by :fakewen

Page 2: Motion Estimation and Prediction

Motion Estimation and Prediction

• 主要分布位置• Tcomprediction.cpp• TEncSearch.cpp

Page 3: Motion Estimation and Prediction

predInterSearch

Page 4: Motion Estimation and Prediction

I frame

I frame

xMotionEstimation ( pcCU, pcOrgYuv, iPartIdx, eRefPicList, &cMvPred[iRefList][iRefIdxTemp], iRefIdxTemp, cMvTemp[iRefList][iRefIdxTemp], uiBitsTemp, uiCostTemp );I frame自己重算motion vector

Page 5: Motion Estimation and Prediction

P frame

P frame

I frame

如果很 smooth且 cost不高->SKIP MODE直接拿之前的Motion vector來用

pcCU->getSlice()->getNoBackPredFlag()==1

enum RefPicList{ REF_PIC_LIST_0 = 0, ///< reference list 0 REF_PIC_LIST_1 = 1, ///< reference list 1#if DCM_COMB_LIST REF_PIC_LIST_C = 2, ///< combined reference list for uni-prediction in B-Slices#endif REF_PIC_LIST_X = 100 ///< special mark};否則再從他的 ref

frame list裡找

Page 6: Motion Estimation and Prediction

B frameI frame

P frame

如果很 smooth且 cost不高->SKIP MODE直接拿之前的Motion vector來用

否則再從他的 ref frame list裡找

Page 7: Motion Estimation and Prediction
Page 8: Motion Estimation and Prediction

Advanced motion vector prediction

• AMVP• It allows the selection of the best predictor

from – three spatially adjacent motion vectors(a,b,c)– their median– temporal motion vector.

xCheckBestMVP計算哪種的 cost較低

Page 9: Motion Estimation and Prediction

xEstimateMvPredAMVPStep 1checkAMVP mode還有 number of motion vector predictor candidates

for ( i = 0 ; i < pcAMVPInfo->iN; i++)算 uiBestCost

rcMvPred = pcAMVPInfo->m_acMvCand[pcCU->getMVPIdx(eRefPicList,uiPartAddr)];從裡面選一個最像的當Mvpredict並記錄 cost還有選到的鄰居

Page 10: Motion Estimation and Prediction

Merge

xMergeEstimation(…); UInt uiMRGCost = uiMRGError + m_pcRdCost->getCost( uiMRGBits );

xMergeEstimation算出最小的 cost的合併方式

if ( bMergeValid && uiMRGCost < uiMECost )合併 !

Page 11: Motion Estimation and Prediction

xMotionEstimation

if ( !m_iFastSearch || bBi )

xPatternSearch xPatternSearchFastMv初始值用傳入參數

xTZSearchxPatternSearchFracDIF( pcCU, pcPatternKey, piRefY, iRefStride, &rcMv, cMvHalf, cMvQter, ruiCost )

Page 12: Motion Estimation and Prediction

xTZSearchtest whether one of PRED_A, PRED_B, PRED_C MV is better start point than Median predictor

range

PK

P.s. 若 idist==1 則只考慮上下左右

idistraster search if distance is too big

raster refinement

Page 13: Motion Estimation and Prediction

raster refinement

Idist too big

Page 14: Motion Estimation and Prediction

motionCompensationStep 1Check iPartIdx >= 0

Step 2eRefPicList!= REF_PIC_LIST_X(B frame)

xPredInterUnixPredInterBi

xPredInterLumaBlk

xPredInterChromaBlk

xPredInterLumaBlk_ha

xPredInterChromaBlk_ha

Page 15: Motion Estimation and Prediction

motionCompensation

MotionCompensation

getPartIndexAndSize

iPartIdx >= 0?

eRefPicList != REF_PIC_LIST_X ?

xPredInterUni xPredInterBieRefPicList看是 I還是 P frame

For(pcCU->getNumPartInter())

Void motionCompensation ( TComDataCU* pcCU, TComYuv* pcYuvPred, RefPicList eRefPicList = REF_PIC_LIST_X, Int iPartIdx = -1 );初始

pcCU->getPartIndexAndSize( iPartIdx, uiPartAddr, iRoiWidth, iRoiHeight );

Page 16: Motion Estimation and Prediction

predInterSearch

pcCU->getPartIndexAndSize( iPartIdx, uiPartAddr, iRoiWidth, iRoiHeight );得到這個 block的 info

predInterSearch

if (pcCU->getWidth( 0 ) > 8 && iNumPart == 2 && iPartIdx == 0) bTestNormalMC = false;

RefPicList eRefPicList = ( iRefList ? REF_PIC_LIST_1 : REF_PIC_LIST_0 );

For(iNumPredDir)iNumPredDir = pcCU->getSlice()->isInterP() ? 1 : 2;P是 1 B是 2 enum RefPicList

{ REF_PIC_LIST_0 = 0, ///< reference list 0 REF_PIC_LIST_1 = 1, ///< reference list 1#if DCM_COMB_LIST REF_PIC_LIST_C = 2, ///< combined reference list for uni-prediction in B-Slices#endif REF_PIC_LIST_X = 100 ///< special mark};

RefPicList 標示現在是 IPB

SPS: sequence parameter set

iRefList//若是 I frame則 0 pcCU->getSlice()->getNoBackPredFlag()…

判斷式pcCU->getSlice()->getNoBackPredFlag() || pcCU->getSlice()->getSPS()->getUseLDC()

cMvTemp[1][iRefIdxTemp] = cMvTemp[0][iRefIdxTemp];SKIP MODE

FOR(pcCU->getSlice()->getNumRefIdx(eRefPicList)

Page 17: Motion Estimation and Prediction

predInterSearch(cont.)// set motion cMv[iRefList] = cMvTemp[iRefList][iRefIdxTemp]; iRefIdx[iRefList] = iRefIdxTemp; pcCU->getCUMvField(eRefPicList)->setAllMvField( cMv[iRefList], iRefIdx[iRefList], ePartSize, uiPartAddr, iPartIdx, 0 );紀錄最後結果

for( UInt ui = 0; ui < MRG_MAX_NUM_CANDS; ui++ ) { pcCU->setNeighbourCandIdxSubParts( ui, ucNeighCand[ui], uiPartAddr, iPartIdx, pcCU->getDepth( uiPartAddr ) ); } if ( bMergeValid && uiMRGCost < uiMECost ) {

// 可以merge且merge cost較低 >>set Merge result}

else { // set ME result記錄自己的motion estimation }

Page 18: Motion Estimation and Prediction

xEstimateMvPredAMVP

if( pcCU->getAMVPMode(uiPartAddr) == AM_NONE || (pcAMVPInfo->iN <= 1 && pcCU->getAMVPMode(uiPartAddr) == AM_EXPL) )no AMVP mode或是 number of motion vector predictor candidates小於一

來亂的 if (pcCU->getAMVPMode(uiPartAddr) == AM_EXPL && bFilled)

rcMvPred = pcAMVPInfo->m_acMvCand[pcCU->getMVPIdx(eRefPicList,uiPartAddr)];從裡面選一個最像的當Mvpredict並記錄 cost還有選到的鄰居

for ( i = 0 ; i < pcAMVPInfo->iN; i++)算 uiBestCost

Page 19: Motion Estimation and Prediction

xMotionEstimation

xSetSearchRange ( pcCU, cMvPred, iSrchRng, cMvSrchRngLT, cMvSrchRngRB );先設定一下 range(P frame)

if ( !m_iFastSearch || bBi )

xPatternSearch xPatternSearchFastMv初始值用傳入參數

rcMv <<= 2; rcMv += (cMvHalf <<= 1); rcMv += cMvQter;紀錄結果

xPatternSearchFracDIF( pcCU, pcPatternKey, piRefY, iRefStride, &rcMv, cMvHalf, cMvQter, ruiCost )

Page 20: Motion Estimation and Prediction

motionCompensation

MotionCompensation

getPartIndexAndSize

iPartIdx >= 0?

eRefPicList != REF_PIC_LIST_X ?

xPredInterUni xPredInterBieRefPicList看是 I還是 P frame

For(pcCU->getNumPartInter())

Void motionCompensation ( TComDataCU* pcCU, TComYuv* pcYuvPred, RefPicList eRefPicList = REF_PIC_LIST_X, Int iPartIdx = -1 );初始

pcCU->getPartIndexAndSize( iPartIdx, uiPartAddr, iRoiWidth, iRoiHeight );