expand structure of MD and ME

This commit is contained in:
sijchen 2014-03-18 09:47:05 +08:00
parent e8d5108dbc
commit 7f0c7daad9
4 changed files with 30 additions and 9 deletions

View File

@ -89,6 +89,10 @@ uint16_t uiReserved;
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 {

View File

@ -59,14 +59,20 @@ uint16_t* pMvdCost;
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;

View File

@ -977,6 +977,8 @@ int32_t WelsMdP16x16 (SWelsFuncPtrList* pFunc, SDqLayer* pCurLayer, SWelsMD* pWe
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 WelsMdP8x8 (SWelsFuncPtrList* pFunc, SDqLayer* pCurDqLayer, SWelsMD* pWe
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;

View File

@ -918,6 +918,14 @@ bool DynSlcJudgeSliceBoundaryStepBack (void* pCtx, void* pSlice, SSliceCtx* pSli
///////////////
// 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 @@ int32_t WelsMdInterMbLoop (sWelsEncCtx* pEncCtx, SSlice* pSlice, void* pWelsMd,
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 @@ int32_t WelsMdInterMbLoopOverDynamicSlice (sWelsEncCtx* pEncCtx, SSlice* 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