History

Merge pull request #616 from sijchen/fme_merge81

[Encoder ME] add function pointer for search methods

Licai Guo committed 12 years ago

Commit c12edef2 parents ea5b6b4 f6952277 files · +36 −32Browse files

Unified · Split

7 files
  1. codec/encoder/core/inc/svc_motion_estimate.h +1 −2
  2. codec/encoder/core/inc/wels_func_ptr_def.h +5 −2
  3. codec/encoder/core/src/encoder_ext.cpp +6 −1
  4. codec/encoder/core/src/svc_base_layer_md.cpp +4 −6
  5. codec/encoder/core/src/svc_motion_estimate.cpp +17 −19
  6. codec/processing/interface/IWelsVP.h +1 −0
  7. test/encoder/EncUT_MotionEstimate.cpp +2 −2
codec/encoder/core/inc/svc_motion_estimate.h+1−2
@@ -179,8 +179,7 @@ bool WelsMotionEstimateInitialPoint (SWelsFuncPtrList* pFuncList, SWelsME* pMe, · 178 unmodified lines
179179 *
180180 * \return NONE
181181 */
182−void WelsMotionEstimateIterativeSearch (SWelsFuncPtrList* pFuncList, SWelsME* pMe, const int32_t kiStrideEnc,
183− const int32_t kiStrideRef, uint8_t* pRef);
182+void WelsDiamondSearch (SWelsFuncPtrList* pFuncList, void* pLpme, void* pLpslice, const int32_t kiEncStride, const int32_t kiRefStride);
184183
185184 bool WelsMeSadCostSelect (int32_t* pSadCost, const uint16_t* kpMvdCost, int32_t* pBestCost, const int32_t kiDx,
186185 const int32_t kiDy, int32_t* pIx, int32_t* pIy);
codec/encoder/core/inc/wels_func_ptr_def.h+5−2
@@ -43,6 +43,7 @@ · 42 unmodified lines
4343 #include "svc_enc_frame.h"
4444 #include "expand_pic.h"
4545 #include "rc.h"
46+#include "IWelsVP.h"
4647
4748 namespace WelsSVCEnc {
4849
@@ -135,7 +136,8 @@ typedef int32_t (*PIntraPred8x8Combined3Func) (uint8_t*, int32_t, uint8_t*, int3 · 86 unmodified lines
135136
136137 typedef void (*PMotionSearchFunc) (SWelsFuncPtrList* pFuncList, void* pCurDqLayer, void* pMe,
137138 void* pSlice);
138−typedef void (*PCalculateSatdFunc) ( PSampleSadSatdCostFunc pSatd, void * vpMe, const int32_t kiEncStride, const int32_t kiRefStride );
139+typedef void (*PSearchMethodFunc) (SWelsFuncPtrList* pFuncList, void* pMe, void* pSlice, const int32_t kiEncStride, const int32_t kiRefStride);
140+typedef void (*PCalculateSatdFunc) ( PSampleSadSatdCostFunc pSatd, void * vpMe, const int32_t kiEncStride, const int32_t kiRefStride);
139141 typedef bool (*PCheckDirectionalMv) (PSampleSadSatdCostFunc pSad, void * vpMe,
140142 const SMVUnitXY ksMinMv, const SMVUnitXY ksMaxMv, const int32_t kiEncStride, const int32_t kiRefStride,
141143 int32_t& iBestSadCost);
@@ -198,7 +200,8 @@ struct TagWelsFuncPointerList { · 56 unmodified lines
198200 PGetIntraPredFunc pfGetChromaPred[C_PRED_A];
199201
200202 PMotionSearchFunc
201− pfMotionSearch; //svc_encode_slice.c svc_mode_decision.c svc_enhance_layer_md.c svc_base_layer_md.c
203+ pfMotionSearch[BLOCK_STATIC_IDC_ALL]; //svc_encode_slice.c svc_mode_decision.c svc_enhance_layer_md.c svc_base_layer_md.c
204+ PSearchMethodFunc pfSearchMethod[BLOCK_SIZE_ALL];
202205 PCalculateSatdFunc pfCalculateSatd;
203206 PCheckDirectionalMv pfCheckDirectionalMv;
204207 PLineFullSearchFunc pfLineFullSearch;
codec/encoder/core/src/encoder_ext.cpp+6−1
@@ -2366,7 +2366,12 @@ void PreprocessSliceCoding (sWelsEncCtx* pCtx) { · 2365 unmodified lines
23662366 }
23672367
23682368 if (P_SLICE == pCtx->eSliceType) {
2369− pFuncList->pfMotionSearch = WelsMotionEstimateSearch;
2369+ pFuncList->pfMotionSearch[0] = WelsMotionEstimateSearch;
2370+ pFuncList->pfSearchMethod[BLOCK_16x16] =
2371+ pFuncList->pfSearchMethod[BLOCK_16x8] =
2372+ pFuncList->pfSearchMethod[BLOCK_8x16] =
2373+ pFuncList->pfSearchMethod[BLOCK_8x8] =
2374+ pFuncList->pfSearchMethod[BLOCK_4x4] = WelsDiamondSearch;
23702375 pFuncList->pfFirstIntraMode = WelsMdFirstIntraMode;
23712376 pFuncList->sSampleDealingFuncs.pfMeCost = pCtx->pFuncList->sSampleDealingFuncs.pfSampleSatd;
23722377 if (kbHighestSpatialLayer) {
codec/encoder/core/src/svc_base_layer_md.cpp+4−6
@@ -1018,8 +1018,7 @@ int32_t WelsMdP16x16 (SWelsFuncPtrList* pFunc, SDqLayer* pCurLayer, SWelsMD* pWe · 1017 unmodified lines
10181018 }
10191019
10201020 PredMv (&pMbCache->sMvComponents, 0, 4, 0, & (pMe16x16->sMvp));
1021− pFunc->pfMotionSearch (pFunc, pCurLayer, pMe16x16, pSlice);
1022−// update_p16x16_motion2cache(pMbCache, pWelsMd->uiRef, &(pMe16x16->mv));
1021+ pFunc->pfMotionSearch[0] (pFunc, pCurLayer, pMe16x16, pSlice);
10231022
10241023 pCurMb->sP16x16Mv = pMe16x16->sMv;
10251024 pCurLayer->pDecPic->sMvList[pCurMb->iMbXY] = pMe16x16->sMv;
@@ -1048,7 +1047,7 @@ int32_t WelsMdP16x8 (SWelsFuncPtrList* pFunc, SDqLayer* pCurDqLayer, SWelsMD* pW · 22 unmodified lines
10481047 pSlice->uiMvcNum = 1;
10491048
10501049 PredInter16x8Mv (pMbCache, i << 3, 0, & (sMe16x8->sMvp));
1051− pFunc->pfMotionSearch (pFunc, pCurDqLayer, sMe16x8, pSlice);
1050+ pFunc->pfMotionSearch[0] (pFunc, pCurDqLayer, sMe16x8, pSlice);
10521051 UpdateP16x8Motion2Cache (pMbCache, i << 3, pWelsMd->uiRef, & (sMe16x8->sMv));
10531052 iCostP16x8 += sMe16x8->uiSatdCost;
10541053 ++i;
@@ -1075,10 +1074,9 @@ int32_t WelsMdP8x16 (SWelsFuncPtrList* pFunc, SDqLayer* pCurLayer, SWelsMD* pWel · 20 unmodified lines
10751074 pSlice->uiMvcNum = 1;
10761075
10771076 PredInter8x16Mv (pMbCache, i << 2, 0, & (sMe8x16->sMvp));
1078− pFunc->pfMotionSearch (pFunc, pCurLayer, sMe8x16, pSlice);
1077+ pFunc->pfMotionSearch[0] (pFunc, pCurLayer, sMe8x16, pSlice);
10791078 UpdateP8x16Motion2Cache (pMbCache, i << 2, pWelsMd->uiRef, & (sMe8x16->sMv));
10801079 iCostP8x16 += sMe8x16->uiSatdCost;
1081−// sMe8x16++;
10821080 ++i;
10831081 } while (i < 2);
10841082 return iCostP8x16;
@@ -1113,7 +1111,7 @@ int32_t WelsMdP8x8 (SWelsFuncPtrList* pFunc, SDqLayer* pCurDqLayer, SWelsMD* pWe · 28 unmodified lines
11131111 pSlice->uiMvcNum = 1;
11141112
11151113 PredMv (&pMbCache->sMvComponents, i << 2, 2, pWelsMd->uiRef, & (sMe8x8->sMvp));
1116− pFunc->pfMotionSearch (pFunc, pCurDqLayer, sMe8x8, pSlice);
1114+ pFunc->pfMotionSearch[0] (pFunc, pCurDqLayer, sMe8x8, pSlice);
11171115 UpdateP8x8Motion2Cache (pMbCache, i << 2, pWelsMd->uiRef, & (sMe8x8->sMv));
11181116 iCostP8x8 += sMe8x8->uiSatdCost;
11191117 // sMe8x8++;
codec/encoder/core/src/svc_motion_estimate.cpp+17−19
@@ -83,16 +83,16 @@ void WelsMotionEstimateSearch (SWelsFuncPtrList* pFuncList, void* pLplayer, void · 82 unmodified lines
8383 SDqLayer* pCurDqLayer = (SDqLayer*)pLplayer;
8484 SWelsME* pMe = (SWelsME*)pLpme;
8585 SSlice* pSlice = (SSlice*)pLpslice;
86− int32_t iStrideEnc = pCurDqLayer->iEncStride[0];
87− int32_t iStrideRef = pCurDqLayer->pRefPic->iLineSize[0];
86+ const int32_t kiStrideEnc = pCurDqLayer->iEncStride[0];
87+ const int32_t kiStrideRef = pCurDqLayer->pRefPic->iLineSize[0];
8888
8989 // Step 1: Initial point prediction
90− if ( !WelsMotionEstimateInitialPoint (pFuncList, pMe, pSlice, iStrideEnc, iStrideRef) ) {
91− WelsMotionEstimateIterativeSearch (pFuncList, pMe, iStrideEnc, iStrideRef, pMe->pRefMb);
90+ if ( !WelsMotionEstimateInitialPoint (pFuncList, pMe, pSlice, kiStrideEnc, kiStrideRef) ) {
91+ pFuncList->pfSearchMethod[pMe->uiBlockSize] (pFuncList, pMe, pSlice, kiStrideEnc, kiStrideRef);
9292 MeEndIntepelSearch(pMe);
9393 }
9494
95− pFuncList->pfCalculateSatd( pFuncList->sSampleDealingFuncs.pfSampleSatd[pMe->uiBlockSize], pMe, iStrideEnc, iStrideRef );
95+ pFuncList->pfCalculateSatd( pFuncList->sSampleDealingFuncs.pfSampleSatd[pMe->uiBlockSize], pMe, kiStrideEnc, kiStrideRef );
9696 }
9797
9898 /*!
@@ -219,10 +219,12 @@ bool WelsMeSadCostSelect (int32_t* iSadCost, const uint16_t* kpMvdCost, int32_t* · 120 unmodified lines
219219 return (*pBestCost == iInputSadCost);
220220 }
221221
222−void WelsMotionEstimateIterativeSearch (SWelsFuncPtrList* pFuncList, SWelsME* pMe, const int32_t kiStrideEnc,
223− const int32_t kiStrideRef, uint8_t* pFref) {
222+void WelsDiamondSearch (SWelsFuncPtrList* pFuncList, void* pLpme, void* pLpslice,
223+ const int32_t kiStrideEnc, const int32_t kiStrideRef) {
224+ SWelsME* pMe = (SWelsME*)pLpme;
224225 PSample4SadCostFunc pSad = pFuncList->sSampleDealingFuncs.pfSample4Sad[pMe->uiBlockSize];
225226
227+ uint8_t* pFref = pMe->pRefMb;
226228 uint8_t* const kpEncMb = pMe->pEncMb;
227229 const uint16_t* kpMvdCost = pMe->pMvdCost;
228230
@@ -334,12 +336,10 @@ void LineFullSearch_c( void *pFunc, void *vpMe, · 105 unmodified lines
334336 }
335337 }
336338
337−void WelsMotionCrossSearch(SWelsFuncPtrList *pFuncList, SDqLayer* pCurLayer, SWelsME * pMe,
338− const SSlice* pSlice) {
339+void WelsMotionCrossSearch(SWelsFuncPtrList *pFuncList, SWelsME * pMe,
340+ const SSlice* pSlice, const int32_t kiEncStride, const int32_t kiRefStride) {
339341 PLineFullSearchFunc pfVerticalFullSearchFunc = pFuncList->pfLineFullSearch;
340342 PLineFullSearchFunc pfHorizontalFullSearchFunc = pFuncList->pfLineFullSearch;
341− const int32_t kiEncStride = pCurLayer->iEncStride[0];
342− const int32_t kiRefStride = pCurLayer->pRefPic->iLineSize[0];
343343
344344 const int32_t iCurMeBlockPixX = pMe->iCurMeBlockPixX;
345345 const int32_t iCurMeBlockQpelPixX = ((iCurMeBlockPixX)<<2);
@@ -564,28 +564,26 @@ void MotionEstimateFeatureFullSearch( SFeatureSearchIn &sFeatureSearchIn, · 218 unmodified lines
564564 /////////////////////////
565565 // Search function options
566566 /////////////////////////
567−void WelsDiamondCrossSearch(SWelsFuncPtrList *pFunc, void* vpLayer, void* vpMe, void* vpSlice) {
568− SDqLayer* pCurLayer = static_cast<SDqLayer *>(vpLayer);
567+void WelsDiamondCrossSearch(SWelsFuncPtrList *pFunc, void* vpMe, void* vpSlice, const int32_t kiEncStride, const int32_t kiRefStride) {
569568 SWelsME* pMe = static_cast<SWelsME *>(vpMe);
570569 SSlice* pSlice = static_cast<SSlice *>(vpSlice);
571570
572571 // Step 1: diamond search
573− WelsMotionEstimateIterativeSearch(pFunc, pMe, pCurLayer->iEncStride[0], pCurLayer->pRefPic->iLineSize[0], pMe->pRefMb);
572+ WelsDiamondSearch(pFunc, vpMe, vpSlice, kiEncStride, kiRefStride);
574573
575574 // Step 2: CROSS search
576575 SScreenBlockFeatureStorage pRefBlockFeature; //TODO: use this structure from Ref
577576 pMe->uiSadCostThreshold = pRefBlockFeature.uiSadCostThreshold[pMe->uiBlockSize];
578577 if (pMe->uiSadCost >= pMe->uiSadCostThreshold) {
579− WelsMotionCrossSearch(pFunc, pCurLayer, pMe, pSlice);
578+ WelsMotionCrossSearch(pFunc, pMe, pSlice, kiEncStride, kiRefStride);
580579 }
581580 }
582−void WelsDiamondCrossFeatureSearch(SWelsFuncPtrList *pFunc, void* vpLayer, void* vpMe, void* vpSlice) {
583− SDqLayer* pCurLayer = static_cast<SDqLayer *>(vpLayer);
581+void WelsDiamondCrossFeatureSearch(SWelsFuncPtrList *pFunc, void* vpMe, void* vpSlice, const int32_t kiEncStride, const int32_t kiRefStride) {
584582 SWelsME* pMe = static_cast<SWelsME *>(vpMe);
585583 SSlice* pSlice = static_cast<SSlice *>(vpSlice);
586584
587585 // Step 1: diamond search + cross
588− WelsDiamondCrossSearch(pFunc, pCurLayer, pMe, pSlice);
586+ WelsDiamondCrossSearch(pFunc, pMe, pSlice, kiEncStride, kiRefStride);
589587
590588 // Step 2: FeatureSearch
591589 if (pMe->uiSadCost >= pMe->uiSadCostThreshold) {
@@ -595,7 +593,7 @@ void WelsDiamondCrossFeatureSearch(SWelsFuncPtrList *pFunc, void* vpLayer, void* · 3 unmodified lines
595593 uint32_t uiMaxSearchPoint = INT_MAX;//TODO: change it according to computational-complexity setting
596594 SFeatureSearchIn sFeatureSearchIn = {0};
597595 SetFeatureSearchIn(pFunc, *pMe, pSlice, &tmpScreenBlockFeatureStorage,
598− pCurLayer->iEncStride[0], pCurLayer->pRefPic->iLineSize[0],
596+ kiEncStride, kiRefStride,
599597 &sFeatureSearchIn);
600598 MotionEstimateFeatureFullSearch( sFeatureSearchIn, uiMaxSearchPoint, pMe);
601599
codec/processing/interface/IWelsVP.h+1−0
@@ -148,6 +148,7 @@ typedef enum { · 147 unmodified lines
148148 NO_STATIC, // motion block
149149 COLLOCATED_STATIC, // collocated static block
150150 SCROLLED_STATIC, // scrolled static block
151+ BLOCK_STATIC_IDC_ALL,
151152 } EStaticBlockIdc;
152153
153154 typedef struct {
test/encoder/EncUT_MotionEstimate.cpp+2−2
@@ -75,6 +75,7 @@ TEST_F(MotionEstimateTest, TestDiamondSearch) { · 74 unmodified lines
7575 const int32_t kiMaxBlock16Sad = 72000;//a rough number
7676 SWelsFuncPtrList sFuncList;
7777 SWelsME sMe;
78+ SSlice sSlice;
7879
7980 srand((uint32_t)time(NULL));
8081 const uint8_t kuiQp = rand()%52;
@@ -106,8 +107,7 @@ TEST_F(MotionEstimateTest, TestDiamondSearch) { · 25 unmodified lines
106107 sMe.pRefMb = pRefPicCenter;
107108 sMe.sMv.iMvX = sMe.sMv.iMvY = 0;
108109 sMe.uiSadCost = sMe.uiSatdCost = kiMaxBlock16Sad;
109− WelsMotionEstimateIterativeSearch (&sFuncList, &sMe, m_iMaxSearchBlock,
110− m_iWidth, pRefPicCenter);
110+ WelsDiamondSearch (&sFuncList, &sMe, &sSlice, m_iMaxSearchBlock, m_iWidth);
111111
112112 //the last selection may be affected by MVDcost, that is when (0,0) will be better
113113 //when comparing (1,1) and (1,0), due to the difference between MVD cost, it is possible that (1,0) is selected while the best match is (1,1)

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t