ref: 303bf77e42f84e3744c6ceac7b7f3164d289999c
parent: 2da0ce64519c6648d6d4d28c8d7ee35b86fa138a
author: Sijia Chen <sijchen@cisco.com>
date: Mon Mar 2 12:11:11 EST 2015
replace conditional judgements with function pointer for acceleration
--- a/codec/encoder/core/inc/md.h
+++ b/codec/encoder/core/inc/md.h
@@ -122,6 +122,7 @@
uint8_t* pQuarPixBest;
uint8_t* pQuarPixTmp;
+PCopyFunc pfCopyBlockByMode;
} SMeRefinePointer;
void FillNeighborCacheIntra (SMbCache* pMbCache, SMB* pCurMb, int32_t iMbWidth/*, bool constrained_intra_pred_flag*/);
--- a/codec/encoder/core/src/md.cpp
+++ b/codec/encoder/core/src/md.cpp
@@ -765,17 +765,8 @@
pBestPredInter = pRef;
iInterBlk4Stride = kiStrideRef;
}
- if (MB_WIDTH_LUMA == iWidth && MB_HEIGHT_LUMA == iHeight) { //P16x16
- pFunc->pfCopy16x16NotAligned (pMemPredInterMb, MB_WIDTH_LUMA, pBestPredInter,
- iInterBlk4Stride); // dst can be align with 16 bytes, but not sure at pSrc, 12/29/2011
- } else if (MB_WIDTH_LUMA == iWidth && MB_HEIGHT_CHROMA == iHeight) { //P16x8
- pFunc->pfCopy16x8NotAligned (pMemPredInterMb, MB_WIDTH_LUMA, pBestPredInter,
- iInterBlk4Stride); // dst can be align with 16 bytes, but not sure at pSrc, 12/29/2011
- } else if (MB_WIDTH_CHROMA == iWidth && MB_HEIGHT_LUMA == iHeight) { //P8x16
- pFunc->pfCopy8x16Aligned (pMemPredInterMb, MB_WIDTH_LUMA, pBestPredInter, iInterBlk4Stride);
- } else { //P8x8
- pFunc->pfCopy8x8Aligned (pMemPredInterMb, MB_WIDTH_LUMA, pBestPredInter, iInterBlk4Stride);
- }
+ pMeRefine->pfCopyBlockByMode(pMemPredInterMb, MB_WIDTH_LUMA, pBestPredInter,
+ iInterBlk4Stride);
}
void InitBlkStrideWithRef (int32_t* pBlkStride, const int32_t kiStrideRef) {
--- a/codec/encoder/core/src/svc_base_layer_md.cpp
+++ b/codec/encoder/core/src/svc_base_layer_md.cpp
@@ -1448,6 +1448,7 @@
case MB_TYPE_16x16:
//luma
InitMeRefinePointer (&sMeRefine, pMbCache, 0);
+ sMeRefine.pfCopyBlockByMode = pEncCtx->pFuncList->pfCopy16x16NotAligned; // dst can be align with 16 bytes, but not sure at pSrc, 12/29/2011
MeRefineFracPixel (pEncCtx, pDstLuma, &pWelsMd->sMe.sMe16x16, &sMeRefine, 16, 16);
UpdateP16x16MotionInfo (pMbCache, pCurMb, pWelsMd->uiRef, &pWelsMd->sMe.sMe16x16.sMv);
@@ -1474,6 +1475,7 @@
case MB_TYPE_16x8:
iPixStride = 0;
+ sMeRefine.pfCopyBlockByMode = pEncCtx->pFuncList->pfCopy16x8NotAligned; // dst can be align with 16 bytes, but not sure at pSrc, 12/29/2011
for (i = 0; i < 2; i++) {
//luma
iIdx = i << 3;
@@ -1503,6 +1505,7 @@
case MB_TYPE_8x16:
iPixStride = 0;
+ sMeRefine.pfCopyBlockByMode = pEncCtx->pFuncList->pfCopy8x16Aligned;
for (i = 0; i < 2; i++) {
//luma
iIdx = i << 2;
@@ -1528,8 +1531,8 @@
pEncCtx->pFuncList->sMcFuncs.pMcChromaFunc (pTmpRefCr, iLineSizeRefUV, pTmpDstCr, 8, pMv->iMvX, pMv->iMvY, 4, 8); //Cr
}
break;
-
case MB_TYPE_8x8:
+ sMeRefine.pfCopyBlockByMode = pEncCtx->pFuncList->pfCopy8x8Aligned;
for (i = 0; i < 4; i++) {
int32_t iBlk8Idx = i << 2; //0, 4, 8, 12
int32_t iBlk4X, iBlk4Y;