put a flag calculation in higher-level to save calculation in MB level

This commit is contained in:
Sijia Chen 2015-03-02 17:36:55 +08:00
parent 303bf77e42
commit 63926a3d10
5 changed files with 23 additions and 12 deletions

View File

@ -122,7 +122,7 @@ uint8_t* pHalfPixHV;
uint8_t* pQuarPixBest;
uint8_t* pQuarPixTmp;
PCopyFunc pfCopyBlockByMode;
PCopyFunc pfCopyBlockByMode;
} SMeRefinePointer;
void FillNeighborCacheIntra (SMbCache* pMbCache, SMB* pCurMb, int32_t iMbWidth/*, bool constrained_intra_pred_flag*/);

View File

@ -93,6 +93,8 @@ int16_t iMbWidth; // MB width of this picture, equal to pSps.iMbWidth
int16_t iMbHeight; // MB height of this picture, equal to pSps.iMbHeight;
bool bBaseLayerAvailableFlag; // whether base layer is available for prediction?
bool bSatdInMdFlag; // whether SATD is calculated in ME and integer-pel MD
uint8_t iLoopFilterDisableIdc; // 0: on, 1: off, 2: on except for slice boundaries
int8_t iLoopFilterAlphaC0Offset;// AlphaOffset: valid range [-6, 6], default 0
int8_t iLoopFilterBetaOffset; // BetaOffset: valid range [-6, 6], default 0

View File

@ -3046,6 +3046,10 @@ void PreprocessSliceCoding (sWelsEncCtx* pCtx) {
pCurLayer->pFeatureSearchPreparation->uiFMEGoodFrameCount = FMESWITCH_DEFAULT_GOODFRAME_NUM;
}
}
// update some layer dependent variable to save judgements in mb-level
pCurLayer->bSatdInMdFlag = ((pFuncList->sSampleDealingFuncs.pfMeCost == pFuncList->sSampleDealingFuncs.pfSampleSatd)
&& (pFuncList->sSampleDealingFuncs.pfMdCost == pFuncList->sSampleDealingFuncs.pfSampleSatd));
}
/*!

View File

@ -598,8 +598,7 @@ void MeRefineFracPixel (sWelsEncCtx* pEncCtx, uint8_t* pMemPredInterMb, SWelsME*
int32_t iCurCost;
int32_t iBestHalfPix;
if ((pFunc->sSampleDealingFuncs.pfMeCost == pFunc->sSampleDealingFuncs.pfSampleSatd)
&& (pFunc->sSampleDealingFuncs.pfMdCost == pFunc->sSampleDealingFuncs.pfSampleSatd)) {
if (pEncCtx->pCurDqLayer->bSatdInMdFlag) {
iBestCost = pMe->uSadPredISatd.uiSatd + COST_MVD (pMe->pMvdCost, iMvx - pMe->sMvp.iMvX, iMvy - pMe->sMvp.iMvY);
} else {
iBestCost = pFunc->sSampleDealingFuncs.pfMeCost[pMe->uiBlockSize] (pEncData, kiStrideEnc, pRef, kiStrideRef) +
@ -765,8 +764,8 @@ void MeRefineFracPixel (sWelsEncCtx* pEncCtx, uint8_t* pMemPredInterMb, SWelsME*
pBestPredInter = pRef;
iInterBlk4Stride = kiStrideRef;
}
pMeRefine->pfCopyBlockByMode(pMemPredInterMb, MB_WIDTH_LUMA, pBestPredInter,
iInterBlk4Stride);
pMeRefine->pfCopyBlockByMode (pMemPredInterMb, MB_WIDTH_LUMA, pBestPredInter,
iInterBlk4Stride);
}
void InitBlkStrideWithRef (int32_t* pBlkStride, const int32_t kiStrideRef) {

View File

@ -1148,7 +1148,8 @@ void WelsMdInterFinePartition (sWelsEncCtx* pEncCtx, SWelsMD* pWelsMd, SSlice* p
}
}
void WelsMdInterFinePartitionVaa (sWelsEncCtx* pEncCtx, SWelsMD* pWelsMd, SSlice* pSlice, SMB* pCurMb, int32_t iBestCost) {
void WelsMdInterFinePartitionVaa (sWelsEncCtx* pEncCtx, SWelsMD* pWelsMd, SSlice* pSlice, SMB* pCurMb,
int32_t iBestCost) {
SDqLayer* pCurDqLayer = pEncCtx->pCurDqLayer;
// SMbCache *pMbCache = &pSlice->sMbCacheInfo;
int32_t iCostP8x16, iCostP16x8, iCostP8x8;
@ -1428,6 +1429,7 @@ const int32_t g_kiPixStrideIdx8x8[4] = { 0,
void WelsMdInterMbRefinement (sWelsEncCtx* pEncCtx, SWelsMD* pWelsMd, SMB* pCurMb, SMbCache* pMbCache) {
SDqLayer* pCurDqLayer = pEncCtx->pCurDqLayer;
SWelsFuncPtrList* pFunc = pEncCtx->pFuncList;
uint8_t* pTmpRefCb, *pTmpRefCr, *pTmpDstCb, *pTmpDstCr;
int32_t iMvStride, iRefBlk4Stride, iDstBlk4Stride;
SMVUnitXY* pMv;
@ -1448,7 +1450,8 @@ void WelsMdInterMbRefinement (sWelsEncCtx* pEncCtx, SWelsMD* pWelsMd, SMB* pCurM
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
sMeRefine.pfCopyBlockByMode =
pFunc->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);
@ -1475,7 +1478,8 @@ void WelsMdInterMbRefinement (sWelsEncCtx* pEncCtx, SWelsMD* pWelsMd, SMB* pCurM
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
sMeRefine.pfCopyBlockByMode =
pFunc->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;
@ -1505,7 +1509,7 @@ void WelsMdInterMbRefinement (sWelsEncCtx* pEncCtx, SWelsMD* pWelsMd, SMB* pCurM
case MB_TYPE_8x16:
iPixStride = 0;
sMeRefine.pfCopyBlockByMode = pEncCtx->pFuncList->pfCopy8x16Aligned;
sMeRefine.pfCopyBlockByMode = pFunc->pfCopy8x16Aligned;
for (i = 0; i < 2; i++) {
//luma
iIdx = i << 2;
@ -1532,7 +1536,7 @@ void WelsMdInterMbRefinement (sWelsEncCtx* pEncCtx, SWelsMD* pWelsMd, SMB* pCurM
}
break;
case MB_TYPE_8x8:
sMeRefine.pfCopyBlockByMode = pEncCtx->pFuncList->pfCopy8x8Aligned;
sMeRefine.pfCopyBlockByMode = pFunc->pfCopy8x8Aligned;
for (i = 0; i < 4; i++) {
int32_t iBlk8Idx = i << 2; //0, 4, 8, 12
int32_t iBlk4X, iBlk4Y;
@ -1561,8 +1565,10 @@ void WelsMdInterMbRefinement (sWelsEncCtx* pEncCtx, SWelsMD* pWelsMd, SMB* pCurM
pTmpDstCb = pDstCb + iDstBlk4Stride;
pTmpRefCr = pRefCr + iRefBlk4Stride;
pTmpDstCr = pDstCr + iDstBlk4Stride;
pEncCtx->pFuncList->sMcFuncs.pMcChromaFunc (pTmpRefCb + iMvStride, iLineSizeRefUV, pTmpDstCb, 8, pMv->iMvX, pMv->iMvY, 4, 4); //Cb
pEncCtx->pFuncList->sMcFuncs.pMcChromaFunc (pTmpRefCr + iMvStride, iLineSizeRefUV, pTmpDstCr, 8, pMv->iMvX, pMv->iMvY, 4, 4); //Cr
pEncCtx->pFuncList->sMcFuncs.pMcChromaFunc (pTmpRefCb + iMvStride, iLineSizeRefUV, pTmpDstCb, 8, pMv->iMvX, pMv->iMvY,
4, 4); //Cb
pEncCtx->pFuncList->sMcFuncs.pMcChromaFunc (pTmpRefCr + iMvStride, iLineSizeRefUV, pTmpDstCr, 8, pMv->iMvX, pMv->iMvY,
4, 4); //Cr
}
break;