History

astyle all files

huili2 committed 12 years ago

Commit 5ed24f21 parent 0c24686120 files · +3967 −3886Browse files

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

Unified · Split

codec/encoder/core/src/encoder_ext.cpp+46−42
@@ -711,8 +711,8 @@ static inline int32_t InitDqLayers (sWelsEncCtx** ppCtx) { · 710 unmodified lines
711 const int32_t kiFeatureStrategyIndex = FME_DEFAULT_FEATURE_INDEX;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 :
715 ((kiFeatureStrategyIndex<<16) + ((kiMe16x16 & 0x00FF)<<8) + (kiMe8x8 & 0x00FF));715 ((kiFeatureStrategyIndex << 16) + ((kiMe16x16 & 0x00FF) << 8) + (kiMe8x8 & 0x00FF));
716 716
717 iDlayerIndex = 0;717 iDlayerIndex = 0;
718 while (iDlayerIndex < iDlayerCount) {718 while (iDlayerIndex < iDlayerCount) {
@@ -733,7 +733,8 @@ static inline int32_t InitDqLayers (sWelsEncCtx** ppCtx) { · 14 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, (iDlayerIndex == iDlayerCount-1)?kiNeedFeatureStorage:0); // to use actual size of current layer736 pRefList->pRef[i] = AllocPicture (pMa, kiWidth, kiHeight, true,
737 (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))738 WELS_VERIFY_RETURN_PROC_IF (1, (NULL == pRefList->pRef[i]), FreeMemorySvc (ppCtx))
738 ++ i;739 ++ i;
739 } while (i < 1 + iNumRef);740 } while (i < 1 + iNumRef);
@@ -831,13 +832,14 @@ static inline int32_t InitDqLayers (sWelsEncCtx** ppCtx) { · 91 unmodified lines
831 }832 }
832 833
833 //834 //
834 if (kiNeedFeatureStorage && iDlayerIndex==iDlayerCount-1)835 if (kiNeedFeatureStorage && iDlayerIndex == iDlayerCount - 1) {
835 {836 pDqLayer->pFeatureSearchPreparation = static_cast<SFeatureSearchPreparation*> (pMa->WelsMallocz (sizeof (
836 pDqLayer->pFeatureSearchPreparation = static_cast<SFeatureSearchPreparation*> (pMa->WelsMallocz (sizeof (SFeatureSearchPreparation), "pFeatureSearchPreparation"));837 SFeatureSearchPreparation), "pFeatureSearchPreparation"));
837 WELS_VERIFY_RETURN_PROC_IF (1, NULL==pDqLayer->pFeatureSearchPreparation, FreeMemorySvc (ppCtx));838 WELS_VERIFY_RETURN_PROC_IF (1, NULL == pDqLayer->pFeatureSearchPreparation, FreeMemorySvc (ppCtx));
838 int32_t iReturn = RequestFeatureSearchPreparation(pMa, pDlayer->iFrameWidth, pDlayer->iFrameHeight, kiNeedFeatureStorage,839 int32_t iReturn = RequestFeatureSearchPreparation (pMa, pDlayer->iFrameWidth, pDlayer->iFrameHeight,
839 pDqLayer->pFeatureSearchPreparation);840 kiNeedFeatureStorage,
840 WELS_VERIFY_RETURN_PROC_IF (1, ENC_RETURN_SUCCESS!=iReturn, FreeMemorySvc (ppCtx));841 pDqLayer->pFeatureSearchPreparation);
842 WELS_VERIFY_RETURN_PROC_IF (1, ENC_RETURN_SUCCESS != iReturn, FreeMemorySvc (ppCtx));
841 } else {843 } else {
842 pDqLayer->pFeatureSearchPreparation = NULL;844 pDqLayer->pFeatureSearchPreparation = NULL;
843 }845 }
@@ -1363,19 +1365,19 @@ int32_t RequestMemorySvc (sWelsEncCtx** ppCtx) { · 519 unmodified lines
1363 WELS_VERIFY_RETURN_PROC_IF (1, (NULL == (*ppCtx)->pWelsSvcRc), FreeMemorySvc (ppCtx))1365 WELS_VERIFY_RETURN_PROC_IF (1, (NULL == (*ppCtx)->pWelsSvcRc), FreeMemorySvc (ppCtx))
1364 //End of Rate control module memory allocation1366 //End of Rate control module memory allocation
1365 1367
1366 //pVaa memory allocation1368 //pVaa memory allocation
1367 if (pParam->iUsageType == SCREEN_CONTENT_REAL_TIME) {1369 if (pParam->iUsageType == SCREEN_CONTENT_REAL_TIME) {
1368 (*ppCtx)->pVaa = (SVAAFrameInfoExt*)pMa->WelsMallocz (sizeof (SVAAFrameInfoExt), "pVaa");1370 (*ppCtx)->pVaa = (SVAAFrameInfoExt*)pMa->WelsMallocz (sizeof (SVAAFrameInfoExt), "pVaa");
1369 WELS_VERIFY_RETURN_PROC_IF (1, (NULL == (*ppCtx)->pVaa), FreeMemorySvc (ppCtx))1371 WELS_VERIFY_RETURN_PROC_IF (1, (NULL == (*ppCtx)->pVaa), FreeMemorySvc (ppCtx))
1370 if(RequestMemoryVaaScreen ((*ppCtx)->pVaa, pMa, (*ppCtx)->pSvcParam->iNumRefFrame, iCountMaxMbNum << 2)){1372 if (RequestMemoryVaaScreen ((*ppCtx)->pVaa, pMa, (*ppCtx)->pSvcParam->iNumRefFrame, iCountMaxMbNum << 2)) {
1371 WelsLog (*ppCtx, WELS_LOG_WARNING, "RequestMemorySvc(), RequestMemoryVaaScreen failed!");1373 WelsLog (*ppCtx, WELS_LOG_WARNING, "RequestMemorySvc(), RequestMemoryVaaScreen failed!");
1372 FreeMemorySvc (ppCtx);1374 FreeMemorySvc (ppCtx);
1373 return 1;1375 return 1;
1374 }
1375 } else {
1376 (*ppCtx)->pVaa = (SVAAFrameInfo*)pMa->WelsMallocz (sizeof (SVAAFrameInfo), "pVaa");
1377 WELS_VERIFY_RETURN_PROC_IF (1, (NULL == (*ppCtx)->pVaa), FreeMemorySvc (ppCtx))
1378 }1376 }
1377 } else {
1378 (*ppCtx)->pVaa = (SVAAFrameInfo*)pMa->WelsMallocz (sizeof (SVAAFrameInfo), "pVaa");
1379 WELS_VERIFY_RETURN_PROC_IF (1, (NULL == (*ppCtx)->pVaa), FreeMemorySvc (ppCtx))
1380 }
1379 1381
1380 if ((*ppCtx)->pSvcParam->bEnableAdaptiveQuant) { //malloc mem1382 if ((*ppCtx)->pSvcParam->bEnableAdaptiveQuant) { //malloc mem
1381 (*ppCtx)->pVaa->sAdaptiveQuantParam.pMotionTextureUnit = static_cast<SMotionTextureUnit*>1383 (*ppCtx)->pVaa->sAdaptiveQuantParam.pMotionTextureUnit = static_cast<SMotionTextureUnit*>
@@ -1585,7 +1587,7 @@ void FreeMemorySvc (sWelsEncCtx** ppCtx) { · 203 unmodified lines
1585 }1587 }
1586 1588
1587 if (pDq->pFeatureSearchPreparation) {1589 if (pDq->pFeatureSearchPreparation) {
1588 ReleaseFeatureSearchPreparation(pMa, pDq->pFeatureSearchPreparation->pFeatureOfBlock);1590 ReleaseFeatureSearchPreparation (pMa, pDq->pFeatureSearchPreparation->pFeatureOfBlock);
1589 pMa->WelsFree (pDq->pFeatureSearchPreparation, "pFeatureSearchPreparation");1591 pMa->WelsFree (pDq->pFeatureSearchPreparation, "pFeatureSearchPreparation");
1590 pDq->pFeatureSearchPreparation = NULL;1592 pDq->pFeatureSearchPreparation = NULL;
1591 }1593 }
@@ -1663,8 +1665,8 @@ void FreeMemorySvc (sWelsEncCtx** ppCtx) { · 71 unmodified lines
1663 pMa->WelsFree (pCtx->pVaa->sVaaCalcInfo.pMad8x8, "pVaa->sVaaCalcInfo.pMad8x8");1665 pMa->WelsFree (pCtx->pVaa->sVaaCalcInfo.pMad8x8, "pVaa->sVaaCalcInfo.pMad8x8");
1664 pCtx->pVaa->sVaaCalcInfo.pMad8x8 = NULL;1666 pCtx->pVaa->sVaaCalcInfo.pMad8x8 = NULL;
1665 }1667 }
1666 if(pCtx->pSvcParam->iUsageType == SCREEN_CONTENT_REAL_TIME)1668 if (pCtx->pSvcParam->iUsageType == SCREEN_CONTENT_REAL_TIME)
1667 ReleaseMemoryVaaScreen(pCtx->pVaa, pMa,pCtx->pSvcParam->iNumRefFrame);1669 ReleaseMemoryVaaScreen (pCtx->pVaa, pMa, pCtx->pSvcParam->iNumRefFrame);
1668 pMa->WelsFree (pCtx->pVaa, "pVaa");1670 pMa->WelsFree (pCtx->pVaa, "pVaa");
1669 pCtx->pVaa = NULL;1671 pCtx->pVaa = NULL;
1670 }1672 }
@@ -2456,19 +2458,20 @@ void PreprocessSliceCoding (sWelsEncCtx* pCtx) { · 785 unmodified lines
2456 2458
2457 if (P_SLICE == pCtx->eSliceType) {2459 if (P_SLICE == pCtx->eSliceType) {
2458 //calculate bFMESwitchFlag2460 //calculate bFMESwitchFlag
2459 SVAAFrameInfoExt *pVaaExt = static_cast<SVAAFrameInfoExt *>(pCtx->pVaa);2461 SVAAFrameInfoExt* pVaaExt = static_cast<SVAAFrameInfoExt*> (pCtx->pVaa);
2460 const int32_t kiMbSize = pCurLayer->iMbHeight*pCurLayer->iMbWidth;2462 const int32_t kiMbSize = pCurLayer->iMbHeight * pCurLayer->iMbWidth;
2461 pFeatureSearchPreparation->bFMESwitchFlag = CalcFMESwitchFlag( pFeatureSearchPreparation->uiFMEGoodFrameCount,2463 pFeatureSearchPreparation->bFMESwitchFlag = CalcFMESwitchFlag (pFeatureSearchPreparation->uiFMEGoodFrameCount,
2462 pFeatureSearchPreparation->iHighFreMbCount*100/kiMbSize, pCtx->pVaa->sVaaCalcInfo.iFrameSad/kiMbSize,2464 pFeatureSearchPreparation->iHighFreMbCount * 100 / kiMbSize, pCtx->pVaa->sVaaCalcInfo.iFrameSad / kiMbSize,
2463 pVaaExt->sScrollDetectInfo.bScrollDetectFlag);2465 pVaaExt->sScrollDetectInfo.bScrollDetectFlag);
2464 2466
2465 //PerformFMEPreprocess2467 //PerformFMEPreprocess
2466 SScreenBlockFeatureStorage* pScreenBlockFeatureStorage = pCurLayer->pRefPic->pScreenBlockFeatureStorage;2468 SScreenBlockFeatureStorage* pScreenBlockFeatureStorage = pCurLayer->pRefPic->pScreenBlockFeatureStorage;
2467 pFeatureSearchPreparation->pRefBlockFeature = pScreenBlockFeatureStorage;2469 pFeatureSearchPreparation->pRefBlockFeature = pScreenBlockFeatureStorage;
2468 if (pFeatureSearchPreparation->bFMESwitchFlag2470 if (pFeatureSearchPreparation->bFMESwitchFlag
2469 && !pScreenBlockFeatureStorage->bRefBlockFeatureCalculated) {2471 && !pScreenBlockFeatureStorage->bRefBlockFeatureCalculated) {
2470 //TODO: use ORIGIN of reference when preprocessing is ready2472 //TODO: use ORIGIN of reference when preprocessing is ready
2471 PerformFMEPreprocess( pFuncList, pCurLayer->pRefPic,pFeatureSearchPreparation->pFeatureOfBlock,pScreenBlockFeatureStorage);2473 PerformFMEPreprocess (pFuncList, pCurLayer->pRefPic, pFeatureSearchPreparation->pFeatureOfBlock,
2474 pScreenBlockFeatureStorage);
2472 }2475 }
2473 2476
2474 //assign ME pointer2477 //assign ME pointer
@@ -3011,9 +3014,10 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo* pFbi, const SSour · 536 unmodified lines
3011#ifdef LONG_TERM_REF_DUMP3014#ifdef LONG_TERM_REF_DUMP
3012 DumpRef (pCtx);3015 DumpRef (pCtx);
3013#endif3016#endif
3014 if((pSvcParam->iUsageType == SCREEN_CONTENT_REAL_TIME)&&(pSvcParam->iRCMode != RC_OFF_MODE))3017 if ((pSvcParam->iUsageType == SCREEN_CONTENT_REAL_TIME) && (pSvcParam->iRCMode != RC_OFF_MODE))
3015 pCtx->pVpp->AnalyzePictureComplexity(pCtx,pCtx->pEncPic,((pCtx->eSliceType == P_SLICE)&&(pCtx->iNumRef0>0))?pCtx->pRefList0[0]:NULL,3018 pCtx->pVpp->AnalyzePictureComplexity (pCtx, pCtx->pEncPic, ((pCtx->eSliceType == P_SLICE)
3016 iCurDid,pSvcParam->bEnableBackgroundDetection);3019 && (pCtx->iNumRef0 > 0)) ? pCtx->pRefList0[0] : NULL,
3020 iCurDid, pSvcParam->bEnableBackgroundDetection);
3017 3021
3018 WelsUpdateRefSyntax (pCtx, pCtx->iPOC,3022 WelsUpdateRefSyntax (pCtx, pCtx->iPOC,
3019 eFrameType); //get reordering syntax used for writing slice header and transmit to encoder.3023 eFrameType); //get reordering syntax used for writing slice header and transmit to encoder.
@@ -3093,8 +3097,8 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo* pFbi, const SSour · 73 unmodified lines
3093 pCtx->iActiveThreadsNum = iSliceCount;3097 pCtx->iActiveThreadsNum = iSliceCount;
3094 // to fire slice coding threads3098 // to fire slice coding threads
3095 iRet = FiredSliceThreads (&pCtx->pSliceThreading->pThreadPEncCtx[0], &pCtx->pSliceThreading->pReadySliceCodingEvent[0],3099 iRet = FiredSliceThreads (&pCtx->pSliceThreading->pThreadPEncCtx[0], &pCtx->pSliceThreading->pReadySliceCodingEvent[0],
3096 &pCtx->pSliceThreading->pThreadMasterEvent[0],3100 &pCtx->pSliceThreading->pThreadMasterEvent[0],
3097 pLayerBsInfo, iSliceCount, pCtx->pCurDqLayer->pSliceEncCtx, false);3101 pLayerBsInfo, iSliceCount, pCtx->pCurDqLayer->pSliceEncCtx, false);
3098 if (iRet) {3102 if (iRet) {
3099 WelsLog (pCtx, WELS_LOG_ERROR,3103 WelsLog (pCtx, WELS_LOG_ERROR,
3100 "[MT] WelsEncoderEncodeExt(), FiredSliceThreads return(%d) failed and exit encoding frame, iCountThreadsNum= %d, iSliceCount= %d, uiSliceMode= %d, iMultipleThreadIdc= %d!!\n",3104 "[MT] WelsEncoderEncodeExt(), FiredSliceThreads return(%d) failed and exit encoding frame, iCountThreadsNum= %d, iSliceCount= %d, uiSliceMode= %d, iMultipleThreadIdc= %d!!\n",
@@ -3132,8 +3136,8 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo* pFbi, const SSour · 31 unmodified lines
3132 iNumThreadsRunning = iNumThreadsScheduled;3136 iNumThreadsRunning = iNumThreadsScheduled;
3133 // to fire slice coding threads3137 // to fire slice coding threads
3134 iRet = FiredSliceThreads (&pCtx->pSliceThreading->pThreadPEncCtx[0], &pCtx->pSliceThreading->pReadySliceCodingEvent[0],3138 iRet = FiredSliceThreads (&pCtx->pSliceThreading->pThreadPEncCtx[0], &pCtx->pSliceThreading->pReadySliceCodingEvent[0],
3135 &pCtx->pSliceThreading->pThreadMasterEvent[0],3139 &pCtx->pSliceThreading->pThreadMasterEvent[0],
3136 pLayerBsInfo, iNumThreadsRunning, pCtx->pCurDqLayer->pSliceEncCtx, false);3140 pLayerBsInfo, iNumThreadsRunning, pCtx->pCurDqLayer->pSliceEncCtx, false);
3137 if (iRet) {3141 if (iRet) {
3138 WelsLog (pCtx, WELS_LOG_ERROR,3142 WelsLog (pCtx, WELS_LOG_ERROR,
3139 "[MT] WelsEncoderEncodeExt(), FiredSliceThreads return(%d) failed and exit encoding frame, iCountThreadsNum= %d, iSliceCount= %d, uiSliceMode= %d, iMultipleThreadIdc= %d!!\n",3143 "[MT] WelsEncoderEncodeExt(), FiredSliceThreads return(%d) failed and exit encoding frame, iCountThreadsNum= %d, iSliceCount= %d, uiSliceMode= %d, iMultipleThreadIdc= %d!!\n",
@@ -3178,8 +3182,8 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo* pFbi, const SSour · 38 unmodified lines
3178 3182
3179 // to fire slice coding threads3183 // to fire slice coding threads
3180 iRet = FiredSliceThreads (&pCtx->pSliceThreading->pThreadPEncCtx[0], &pCtx->pSliceThreading->pReadySliceCodingEvent[0],3184 iRet = FiredSliceThreads (&pCtx->pSliceThreading->pThreadPEncCtx[0], &pCtx->pSliceThreading->pReadySliceCodingEvent[0],
3181 &pCtx->pSliceThreading->pThreadMasterEvent[0],3185 &pCtx->pSliceThreading->pThreadMasterEvent[0],
3182 pLayerBsInfo, kiPartitionCnt, pCtx->pCurDqLayer->pSliceEncCtx, true);3186 pLayerBsInfo, kiPartitionCnt, pCtx->pCurDqLayer->pSliceEncCtx, true);
3183 if (iRet) {3187 if (iRet) {
3184 WelsLog (pCtx, WELS_LOG_ERROR,3188 WelsLog (pCtx, WELS_LOG_ERROR,
3185 "[MT] WelsEncoderEncodeExt(), FiredSliceThreads return(%d) failed and exit encoding frame, iCountThreadsNum= %d, iSliceCount= %d, uiSliceMode= %d, iMultipleThreadIdc= %d!!\n",3189 "[MT] WelsEncoderEncodeExt(), FiredSliceThreads return(%d) failed and exit encoding frame, iCountThreadsNum= %d, iSliceCount= %d, uiSliceMode= %d, iMultipleThreadIdc= %d!!\n",

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