History

Add calling of FME preprocess calculation

sijchen committed 12 years ago

Commit 11400501 parent cab66c97 files · +193 −95Browse files

Showing the changes to codec/encoder/core/src/encoder_ext.cpp (1 of 7 files). Show all

Unified · Split

codec/encoder/core/src/encoder_ext.cpp+53−2
@@ -708,7 +708,7 @@ static inline int32_t InitDqLayers (sWelsEncCtx** ppCtx) { · 707 unmodified lines
708708 iDlayerCount = pParam->iSpatialLayerNum;
709709 iNumRef = pParam->iNumRefFrame;
710710
711− const int32_t kiFeatureStrategyIndex = 0;
711+ const int32_t kiFeatureStrategyIndex = FME_DEFAULT_FEATURE_INDEX;
712712 const int32_t kiMe16x16 = ME_DIA_CROSS;
713713 const int32_t kiMe8x8 = ME_DIA_CROSS_FME;
714714 const int32_t kiNeedFeatureStorage = (pParam->iUsageType != SCREEN_CONTENT_REAL_TIME)?0:
@@ -733,7 +733,7 @@ static inline int32_t InitDqLayers (sWelsEncCtx** ppCtx) { · 18 unmodified lines
733733 pRefList = (SRefList*)pMa->WelsMallocz (sizeof (SRefList), "pRefList");
734734 WELS_VERIFY_RETURN_PROC_IF (1, (NULL == pRefList), FreeMemorySvc (ppCtx))
735735 do {
736− pRefList->pRef[i] = AllocPicture (pMa, kiWidth, kiHeight, true, kiNeedFeatureStorage); // to use actual size of current layer
736+ pRefList->pRef[i] = AllocPicture (pMa, kiWidth, kiHeight, true, (iDlayerIndex == iDlayerCount-1)?kiNeedFeatureStorage:0); // to use actual size of current layer
737737 WELS_VERIFY_RETURN_PROC_IF (1, (NULL == pRefList->pRef[i]), FreeMemorySvc (ppCtx))
738738 ++ i;
739739 } while (i < 1 + iNumRef);
@@ -830,6 +830,18 @@ static inline int32_t InitDqLayers (sWelsEncCtx** ppCtx) { · 90 unmodified lines
830830 }
831831 }
832832
833+ //
834+ if (kiNeedFeatureStorage && iDlayerIndex==iDlayerCount-1)
835+ {
836+ pDqLayer->pFeatureSearchPreparation = static_cast<SFeatureSearchPreparation*> (pMa->WelsMallocz (sizeof (SFeatureSearchPreparation), "pFeatureSearchPreparation"));
837+ WELS_VERIFY_RETURN_PROC_IF (1, NULL==pDqLayer->pFeatureSearchPreparation, FreeMemorySvc (ppCtx));
838+ int32_t iReturn = RequestFeatureSearchPreparation(pMa, pDlayer->iFrameWidth, pDlayer->iFrameHeight, kiNeedFeatureStorage,
839+ pDqLayer->pFeatureSearchPreparation);
840+ WELS_VERIFY_RETURN_PROC_IF (1, ENC_RETURN_SUCCESS!=iReturn, FreeMemorySvc (ppCtx));
841+ } else {
842+ pDqLayer->pFeatureSearchPreparation = NULL;
843+ }
844+
833845 (*ppCtx)->ppDqLayerList[iDlayerIndex] = pDqLayer;
834846
835847 ++ iDlayerIndex;
@@ -1572,6 +1584,12 @@ void FreeMemorySvc (sWelsEncCtx** ppCtx) { · 736 unmodified lines
15721584 pDq->pLastMbIdxOfPartition = NULL;
15731585 }
15741586
1587+ if (pDq->pFeatureSearchPreparation) {
1588+ ReleaseFeatureSearchPreparation(pMa, pDq->pFeatureSearchPreparation->pFeatureOfBlock);
1589+ pMa->WelsFree (pDq->pFeatureSearchPreparation, "pFeatureSearchPreparation");
1590+ pDq->pFeatureSearchPreparation = NULL;
1591+ }
1592+
15751593 pMa->WelsFree (pDq, "pDq");
15761594 pDq = NULL;
15771595 pCtx->ppDqLayerList[ilayer] = NULL;
@@ -2427,8 +2445,41 @@ void PreprocessSliceCoding (sWelsEncCtx* pCtx) { · 849 unmodified lines
24272445 pFuncList->pfCalculateSatd = CalculateSatdCost;
24282446 pFuncList->pfInterFineMd = WelsMdInterFinePartition;
24292447 }
2448+ }
24302449
2450+ //to init at each frame will be needed when dealing with hybrid content (camera+screen)
2451+ if (pCtx->pSvcParam->iUsageType == SCREEN_CONTENT_REAL_TIME) {
2452+ SFeatureSearchPreparation* pFeatureSearchPreparation = pCurLayer->pFeatureSearchPreparation;
2453+ if (pFeatureSearchPreparation) {
2454+ pFeatureSearchPreparation->iHighFreMbCount = 0;
2455+
2456+ if (P_SLICE == pCtx->eSliceType) {
2457+ //calculate bFMESwitchFlag
2458+ SVAAFrameInfoExt *pVaaExt = static_cast<SVAAFrameInfoExt *>(pCtx->pVaa);
2459+ const int32_t kiMbSize = pCurLayer->iMbHeight*pCurLayer->iMbWidth;
2460+ pFeatureSearchPreparation->bFMESwitchFlag = CalcFMESwitchFlag( pFeatureSearchPreparation->uiFMEGoodFrameCount,
2461+ pFeatureSearchPreparation->iHighFreMbCount*100/kiMbSize, pCtx->pVaa->sVaaCalcInfo.iFrameSad/kiMbSize,
2462+ pVaaExt->sScrollDetectInfo.bScrollDetectFlag);
2463+
2464+ //PerformFMEPreprocess
2465+ SScreenBlockFeatureStorage* pScreenBlockFeatureStorage = pCurLayer->pRefPic->pScreenBlockFeatureStorage;
2466+ pFeatureSearchPreparation->pRefBlockFeature = pScreenBlockFeatureStorage;
2467+ if (pFeatureSearchPreparation->bFMESwitchFlag
2468+ && !pScreenBlockFeatureStorage->bRefBlockFeatureCalculated) {
2469+ pScreenBlockFeatureStorage->pFeatureOfBlockPointer = pFeatureSearchPreparation->pFeatureOfBlock;
2470+ PerformFMEPreprocess( pFuncList, pCurLayer->pRefPic, pScreenBlockFeatureStorage );
2471+ }
24312472
2473+ //assign ME pointer
2474+ if (pScreenBlockFeatureStorage->bRefBlockFeatureCalculated) {
2475+ //TBC int32_t iIs16x16 = pScreenBlockFeatureStorage->iIs16x16;
2476+ }
2477+ } else {
2478+ //reset some status when at I_SLICE
2479+ pFeatureSearchPreparation->bFMESwitchFlag = true;
2480+ pFeatureSearchPreparation->uiFMEGoodFrameCount = FME_DEFAULT_GOOD_FRAME_NUM;
2481+ }
2482+ }
24322483 }
24332484 }
24342485

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