ref: 3956a32d416850ed240785a704e44ad5125a3bca
parent: 37fa5f554e81ef7fae826507c1b710eaae900bda
parent: 7f0c7daad97af475f6c89e76fb2cd2bf4111efcf
author: Licai Guo <[email protected]>
date: Tue Mar 18 08:51:05 EDT 2014
Merge pull request #524 from sijchen/me_refactor33 Expand structure of MD and ME
--- a/codec/encoder/core/inc/md.h
+++ b/codec/encoder/core/inc/md.h
@@ -89,6 +89,10 @@
int32_t iCostSkipMb;
int32_t iSadPredSkip;
+int32_t iMbPixX; // pixel position of MB in horizontal axis
+int32_t iMbPixY; // pixel position of MB in vertical axis
+int32_t iBlock8x8StaticIdc[4];
+
//NO B frame in our Wels, we can ignore list1
struct {
--- a/codec/encoder/core/inc/svc_motion_estimate.h
+++ b/codec/encoder/core/inc/svc_motion_estimate.h
@@ -59,14 +59,20 @@
union SadPredISatdUnit uSadPredISatd; //reuse the sad_pred as a temp pData
uint32_t uiSadCost; //used by ME and RC //max SAD should be max_delta*size+lambda*mvdsize = 255*256+91*33*2 = 65280 + 6006 = 71286 > (2^16)-1 = 65535
uint32_t uiSatdCost; /* satd + lm * nbits */
+uint32_t uiSadCostThreshold;
+int32_t iCurMeBlockPixX;
+int32_t iCurMeBlockPixY;
uint8_t uiPixel; /* PIXEL_WxH */
uint8_t uiReserved;
uint8_t* pEncMb;
uint8_t* pRefMb;
+uint8_t* pColoRefMb;
SMVUnitXY sMvp;
SMVUnitXY sMvBase;
+SMVUnitXY sDirectionalMv;
+
/* output */
SMVUnitXY sMv;
} SWelsME;
--- a/codec/encoder/core/src/svc_base_layer_md.cpp
+++ b/codec/encoder/core/src/svc_base_layer_md.cpp
@@ -977,6 +977,8 @@
const int32_t kiMbWidth = pCurLayer->iMbWidth; // for assign once
const int32_t kiMbHeight = pCurLayer->iMbHeight;
+ sMe16x16->iCurMeBlockPixX = pWelsMd->iMbPixX;
+ sMe16x16->iCurMeBlockPixY = pWelsMd->iMbPixY;
sMe16x16->uiPixel = BLOCK_16x16;
sMe16x16->pMvdCost = pWelsMd->pMvdCost;
@@ -1078,18 +1080,22 @@
int32_t iLineSizeEnc = pCurDqLayer->iEncStride[0];
int32_t iLineSizeRef = pCurDqLayer->pRefPic->iLineSize[0];
SWelsME* sMe8x8;
- int32_t i, iIdxX, iIdxY, iStrideEnc, iStrideRef;
+ int32_t i, iIdxX, iIdxY, iPixelX, iPixelY, iStrideEnc, iStrideRef;
int32_t iCostP8x8 = 0;
for (i = 0; i < 4; i++) {
iIdxX = i & 1;
iIdxY = i >> 1;
- iStrideEnc = (iIdxX << 3) + ((iIdxY << 3) * iLineSizeEnc);
- iStrideRef = (iIdxX << 3) + ((iIdxY << 3) * iLineSizeRef);
+ iPixelX = (iIdxX << 3);
+ iPixelY = (iIdxY << 3);
+ iStrideEnc = iPixelX + ( iPixelY * iLineSizeEnc);
+ iStrideRef = iPixelX + ( iPixelY * iLineSizeRef);
sMe8x8 = &pWelsMd->sMe.sMe8x8[i];
+ sMe8x8->iCurMeBlockPixX = pWelsMd->iMbPixX + iPixelX;
+ sMe8x8->iCurMeBlockPixY = pWelsMd->iMbPixY + iPixelY;
sMe8x8->uiPixel = BLOCK_8x8;
- sMe8x8->pMvdCost = pWelsMd->pMvdCost;
+ sMe8x8->pMvdCost = pWelsMd->pMvdCost;
sMe8x8->pEncMb = pMbCache->SPicData.pEncMb[0] + iStrideEnc;
sMe8x8->pRefMb = pMbCache->SPicData.pRefMb[0] + iStrideRef;
--- a/codec/encoder/core/src/svc_encode_slice.cpp
+++ b/codec/encoder/core/src/svc_encode_slice.cpp
@@ -918,6 +918,14 @@
///////////////
// pMb loop
///////////////
+inline void WelsInitInterMDStruc(const SMB* pCurMb, uint16_t *pMvdCostTableInter, const int32_t kiMvdInterTableStride, SWelsMD* pMd )
+{
+ pMd->iLambda = g_kiQpCostTable[pCurMb->uiLumaQp];
+ pMd->pMvdCost = &pMvdCostTableInter[pCurMb->uiLumaQp * kiMvdInterTableStride];
+ pMd-> iMbPixX = (pCurMb->iMbX<<4);
+ pMd-> iMbPixY = (pCurMb->iMbY<<4);
+ memset( &pMd->iBlock8x8StaticIdc[0], 0, sizeof(pMd->iBlock8x8StaticIdc) );
+}
// for inter non-dynamic pSlice
int32_t WelsMdInterMbLoop (sWelsEncCtx* pEncCtx, SSlice* pSlice, void* pWelsMd, const int32_t kiSliceFirstMbXY) {
SWelsMD* pMd = (SWelsMD*)pWelsMd;
@@ -948,10 +956,9 @@
pEncCtx->pFuncList->pfRc.pfWelsRcMbInit (pEncCtx, pCurMb, pSlice);
//step (2). save some vale for future use, initial pWelsMd
- pMd->iLambda = g_kiQpCostTable[pCurMb->uiLumaQp];
- pMd->pMvdCost = &pMvdCostTableInter[pCurMb->uiLumaQp * kiMvdInterTableStride];
WelsMdIntraInit (pEncCtx, pCurMb, pMbCache, kiSliceFirstMbXY);
WelsMdInterInit (pEncCtx, pSlice, pCurMb, kiSliceFirstMbXY);
+ WelsInitInterMDStruc(pCurMb, pMvdCostTableInter, kiMvdInterTableStride, pMd );
pEncCtx->pFuncList->pfInterMd (pEncCtx, pMd, pSlice, pCurMb, pMbCache);
//mb_qp
@@ -1047,11 +1054,9 @@
}
//step (2). save some vale for future use, initial pWelsMd
- pMd->iLambda = g_kiQpCostTable[pCurMb->uiLumaQp];
- pMd->pMvdCost = &pMvdCostTableInter[pCurMb->uiLumaQp * kiMvdInterTableStride];
-
WelsMdIntraInit (pEncCtx, pCurMb, pMbCache, kiSliceFirstMbXY);
WelsMdInterInit (pEncCtx, pSlice, pCurMb, kiSliceFirstMbXY);
+ WelsInitInterMDStruc(pCurMb, pMvdCostTableInter, kiMvdInterTableStride, pMd );
pEncCtx->pFuncList->pfInterMd (pEncCtx, pMd, pSlice, pCurMb, pMbCache);
//mb_qp