Showing the changes to codec/encoder/core/src/encoder_ext.cpp (1 of 7 files). Show all
Unified · Split
| @@ -708,7 +708,7 @@ static inline int32_t InitDqLayers (sWelsEncCtx** ppCtx) { · 707 unmodified lines | |||
| 708 | iDlayerCount = pParam->iSpatialLayerNum; | 708 | iDlayerCount = pParam->iSpatialLayerNum; |
| 709 | iNumRef = pParam->iNumRefFrame; | 709 | iNumRef = pParam->iNumRefFrame; |
| 710 | 710 | ||
| 711 | const int32_t kiFeatureStrategyIndex = 0; | 711 | const int32_t kiFeatureStrategyIndex = FME_DEFAULT_FEATURE_INDEX; |
| 712 | const int32_t kiMe16x16 = ME_DIA_CROSS; | 712 | const int32_t kiMe16x16 = ME_DIA_CROSS; |
| 713 | const int32_t kiMe8x8 = ME_DIA_CROSS_FME; | 713 | const int32_t kiMe8x8 = ME_DIA_CROSS_FME; |
| 714 | const int32_t kiNeedFeatureStorage = (pParam->iUsageType != SCREEN_CONTENT_REAL_TIME)?0: | 714 | 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 | |||
| 733 | pRefList = (SRefList*)pMa->WelsMallocz (sizeof (SRefList), "pRefList"); | 733 | pRefList = (SRefList*)pMa->WelsMallocz (sizeof (SRefList), "pRefList"); |
| 734 | WELS_VERIFY_RETURN_PROC_IF (1, (NULL == pRefList), FreeMemorySvc (ppCtx)) | 734 | WELS_VERIFY_RETURN_PROC_IF (1, (NULL == pRefList), FreeMemorySvc (ppCtx)) |
| 735 | do { | 735 | 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 |
| 737 | WELS_VERIFY_RETURN_PROC_IF (1, (NULL == pRefList->pRef[i]), FreeMemorySvc (ppCtx)) | 737 | WELS_VERIFY_RETURN_PROC_IF (1, (NULL == pRefList->pRef[i]), FreeMemorySvc (ppCtx)) |
| 738 | ++ i; | 738 | ++ i; |
| 739 | } while (i < 1 + iNumRef); | 739 | } while (i < 1 + iNumRef); |
| @@ -830,6 +830,18 @@ static inline int32_t InitDqLayers (sWelsEncCtx** ppCtx) { · 90 unmodified lines | |||
| 830 | } | 830 | } |
| 831 | } | 831 | } |
| 832 | 832 | ||
| 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 | |||
| 833 | (*ppCtx)->ppDqLayerList[iDlayerIndex] = pDqLayer; | 845 | (*ppCtx)->ppDqLayerList[iDlayerIndex] = pDqLayer; |
| 834 | 846 | ||
| 835 | ++ iDlayerIndex; | 847 | ++ iDlayerIndex; |
| @@ -1572,6 +1584,12 @@ void FreeMemorySvc (sWelsEncCtx** ppCtx) { · 736 unmodified lines | |||
| 1572 | pDq->pLastMbIdxOfPartition = NULL; | 1584 | pDq->pLastMbIdxOfPartition = NULL; |
| 1573 | } | 1585 | } |
| 1574 | 1586 | ||
| 1587 | if (pDq->pFeatureSearchPreparation) { | ||
| 1588 | ReleaseFeatureSearchPreparation(pMa, pDq->pFeatureSearchPreparation->pFeatureOfBlock); | ||
| 1589 | pMa->WelsFree (pDq->pFeatureSearchPreparation, "pFeatureSearchPreparation"); | ||
| 1590 | pDq->pFeatureSearchPreparation = NULL; | ||
| 1591 | } | ||
| 1592 | |||
| 1575 | pMa->WelsFree (pDq, "pDq"); | 1593 | pMa->WelsFree (pDq, "pDq"); |
| 1576 | pDq = NULL; | 1594 | pDq = NULL; |
| 1577 | pCtx->ppDqLayerList[ilayer] = NULL; | 1595 | pCtx->ppDqLayerList[ilayer] = NULL; |
| @@ -2427,8 +2445,41 @@ void PreprocessSliceCoding (sWelsEncCtx* pCtx) { · 849 unmodified lines | |||
| 2427 | pFuncList->pfCalculateSatd = CalculateSatdCost; | 2445 | pFuncList->pfCalculateSatd = CalculateSatdCost; |
| 2428 | pFuncList->pfInterFineMd = WelsMdInterFinePartition; | 2446 | pFuncList->pfInterFineMd = WelsMdInterFinePartition; |
| 2429 | } | 2447 | } |
| 2448 | } | ||
| 2430 | 2449 | ||
| 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 | } | ||
| 2431 | 2472 | ||
| 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 | } | ||
| 2432 | } | 2483 | } |
| 2433 | } | 2484 | } |
| 2434 | 2485 | ||