Motion Estimation and Prediction

Report
Motion Estimation and
Prediction
Present by :fakewen
Motion Estimation and Prediction
• 主要分布位置
• Tcomprediction.cpp
• TEncSearch.cpp
predInterSearch
I frame
xMotionEstimation ( pcCU, pcOrgYuv, iPartIdx,
eRefPicList, &cMvPred[iRefList][iRefIdxTemp],
iRefIdxTemp, cMvTemp[iRefList][iRefIdxTemp],
uiBitsTemp, uiCostTemp );
I frame自己重算motion vector
I frame
P frame
I frame
pcCU->getSlice()->getNoBackPredFlag()==1
P frame
如果很smooth且cost不高
->SKIP MODE
直接拿之前的Motion
vector來用
否則再從他的ref
frame list裡找
enum RefPicList
{
REF_PIC_LIST_0 = 0, ///< reference
REF_PIC_LIST_1 = 1, ///< reference
#if DCM_COMB_LIST
REF_PIC_LIST_C = 2, ///< combined
#endif
REF_PIC_LIST_X = 100 ///< special m
};
B frame
I frame
P frame
如果很smooth且cost不高
->SKIP MODE
直接拿之前的Motion
vector來用
否則再從他的ref
frame list裡找
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較低
xEstimateMvPredAMVP
Step 1
check
AMVP 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還有選到的鄰居
Merge
xMergeEstimation
算出最小的cost的合
併方式
xMergeEstimation(…);
UInt uiMRGCost = uiMRGError + m_pcRdCost->getCost( uiMRGBits );
if ( bMergeValid && uiMRGCost < uiMECost )
合併!
xMotionEstimation
if ( !m_iFastSearch || bBi )
xPatternSearch
xPatternSearchFast
Mv初始值用傳入參數
xTZSearch
xPatternSearchFracDIF( pcCU, pcPatternKey, piRefY, iRefStride,
&rcMv, cMvHalf, cMvQter, ruiCost )
xTZSearch
range
test whether one of PRED_A, PRED_B, PRED_C
MV is better start point than Median predictor
PK
idist
raster search if distance is too big
raster refinement
P.s. 若idist==1 則只考慮上下左右
raster refinement
Idist too big
motionCompensation
Step 1
Check iPartIdx >= 0
Step 2
eRefPicList!= REF_PIC_LIST_X(B frame)
xPredInterBi
xPredInterLumaBlk_ha
xPredInterChromaBlk_ha
xPredInterUni
xPredInterLumaBlk
xPredInterChromaBlk
motionCompensation
Void motionCompensation ( TComDataCU* pcCU, TComYuv* pcYuvPred, RefPicList eRefPicList =
REF_PIC_LIST_X, Int iPartIdx = -1 );初始
Motion
Compensation
pcCU->getPartIndexAndSize( iPartIdx,
uiPartAddr, iRoiWidth, iRoiHeight );
iPartIdx >=
0?
getPartIndexAndSize
eRefPicList != REF_PIC_LIST_X ?
是I還是P frame
xPredInterUni
xPredInterBi
For(pcCU->getNumPartInter())
parameter set
標
B
predInterSearch
predInterSearch
pcCU->getPartIndexAndSize( iPartIdx, uiPartAddr, iRoiWidth,
iRoiHeight );得到這個block的info
if (pcCU->getWidth( 0 ) > 8 && iNumPart == 2 && iPartIdx == 0)
bTestNormalMC = false;
For(iNumPredDir)
FOR(pcCU->getSlice()->getNumRefIdx(eRefPicList)
iNumPredDir = pcCU->getSlice()->
P是1 B是2
enum RefPicList
RefPicList eRefPicList = ( iRefList ? REF_PIC_LIST_1 : REF_PIC_LIST_0 );
判斷式
iRefList//若是I frame則0
pcCU->getSlice()->getNoBackPredFlag()…
Slice()->getNoBackPredFlag() ||
Slice()->getSPS()->getUseLDC()
{
REF_PIC_LIST_0 =
REF_PIC_LIST_1 =
#if DCM_COMB_LI
REF_PIC_LIST_C =
#endif
REF_PIC_LIST_X =
};
predInterSearch(cont.)
/ set motion
cMv[iRefList] = cMvTemp[iRefList][iRefIdxTemp];
iRefIdx[iRefList] = iRefIdxTemp;
pcCU->getCUMvField(eRefPicList)->setAllMvField( cMv[iRefList], iRefIdx[iRefList], ePartSize,
uiPartAddr, iPartIdx, 0 );
紀錄最後結果
< MRG_MAX_NUM_CANDS; ui++ )
ghbourCandIdxSubParts( ui, ucNeighCand[ui], uiPartAddr, iPartIdx, pcCU->getDepth( uiPartAddr ) );
d && uiMRGCost < uiMECost )
merge且merge cost較低>>set Merge result
lt記錄自己的motion estimation
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)
for ( i = 0 ; i < pcAMVPInfo->iN; i++)
算uiBestCost
rcMvPred = pcAMVPInfo->m_acMvCand[pcCU>getMVPIdx(eRefPicList,uiPartAddr)];
從裡面選一個最像的當Mvpredict
並記錄cost還有選到的鄰居
xMotionEstimation
xSetSearchRange ( pcCU, cMvPred, iSrchRng,
cMvSrchRngLT, cMvSrchRngRB );
先設定一下range(P frame)
if ( !m_iFastSearch || bBi )
xPatternSearch
xPatternSearchFast
Mv初始值用傳入參數
xPatternSearchFracDIF( pcCU, pcPatternKey, piRefY, iRefStride,
&rcMv, cMvHalf, cMvQter, ruiCost )
rcMv <<= 2;
rcMv += (cMvHalf <<= 1);
rcMv += cMvQter;
紀錄結果
motionCompensation
Void motionCompensation ( TComDataCU* pcCU, TComYuv* pcYuvPred, RefPicList eRefPicList =
REF_PIC_LIST_X, Int iPartIdx = -1 );初始
Motion
Compensation
pcCU->getPartIndexAndSize( iPartIdx,
uiPartAddr, iRoiWidth, iRoiHeight );
iPartIdx >= 0?
getPartIndexAndSize
eRefPicList != REF_PIC_LIST_X ?
是I還是P frame
xPredInterUni
xPredInterBi
For(pcCU->getNumPartInter())

similar documents