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
711711 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;
714− const int32_t kiNeedFeatureStorage = (pParam->iUsageType != SCREEN_CONTENT_REAL_TIME)?0:
715− ((kiFeatureStrategyIndex<<16) + ((kiMe16x16 & 0x00FF)<<8) + (kiMe8x8 & 0x00FF));
714+ const int32_t kiNeedFeatureStorage = (pParam->iUsageType != SCREEN_CONTENT_REAL_TIME) ? 0 :
715+ ((kiFeatureStrategyIndex << 16) + ((kiMe16x16 & 0x00FF) << 8) + (kiMe8x8 & 0x00FF));
716716
717717 iDlayerIndex = 0;
718718 while (iDlayerIndex < iDlayerCount) {
@@ -733,7 +733,8 @@ static inline int32_t InitDqLayers (sWelsEncCtx** ppCtx) { · 14 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, (iDlayerIndex == iDlayerCount-1)?kiNeedFeatureStorage:0); // to use actual size of current layer
736+ pRefList->pRef[i] = AllocPicture (pMa, kiWidth, kiHeight, true,
737+ (iDlayerIndex == iDlayerCount - 1) ? kiNeedFeatureStorage : 0); // to use actual size of current layer
737738 WELS_VERIFY_RETURN_PROC_IF (1, (NULL == pRefList->pRef[i]), FreeMemorySvc (ppCtx))
738739 ++ i;
739740 } while (i < 1 + iNumRef);
@@ -831,13 +832,14 @@ static inline int32_t InitDqLayers (sWelsEncCtx** ppCtx) { · 91 unmodified lines
831832 }
832833
833834 //
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));
835+ if (kiNeedFeatureStorage && iDlayerIndex == iDlayerCount - 1) {
836+ pDqLayer->pFeatureSearchPreparation = static_cast<SFeatureSearchPreparation*> (pMa->WelsMallocz (sizeof (
837+ SFeatureSearchPreparation), "pFeatureSearchPreparation"));
838+ WELS_VERIFY_RETURN_PROC_IF (1, NULL == pDqLayer->pFeatureSearchPreparation, FreeMemorySvc (ppCtx));
839+ int32_t iReturn = RequestFeatureSearchPreparation (pMa, pDlayer->iFrameWidth, pDlayer->iFrameHeight,
840+ kiNeedFeatureStorage,
841+ pDqLayer->pFeatureSearchPreparation);
842+ WELS_VERIFY_RETURN_PROC_IF (1, ENC_RETURN_SUCCESS != iReturn, FreeMemorySvc (ppCtx));
841843 } else {
842844 pDqLayer->pFeatureSearchPreparation = NULL;
843845 }
@@ -1363,19 +1365,19 @@ int32_t RequestMemorySvc (sWelsEncCtx** ppCtx) { · 519 unmodified lines
13631365 WELS_VERIFY_RETURN_PROC_IF (1, (NULL == (*ppCtx)->pWelsSvcRc), FreeMemorySvc (ppCtx))
13641366 //End of Rate control module memory allocation
13651367
1366− //pVaa memory allocation
1367− if (pParam->iUsageType == SCREEN_CONTENT_REAL_TIME) {
1368− (*ppCtx)->pVaa = (SVAAFrameInfoExt*)pMa->WelsMallocz (sizeof (SVAAFrameInfoExt), "pVaa");
1369− WELS_VERIFY_RETURN_PROC_IF (1, (NULL == (*ppCtx)->pVaa), FreeMemorySvc (ppCtx))
1370− if(RequestMemoryVaaScreen ((*ppCtx)->pVaa, pMa, (*ppCtx)->pSvcParam->iNumRefFrame, iCountMaxMbNum << 2)){
1371− WelsLog (*ppCtx, WELS_LOG_WARNING, "RequestMemorySvc(), RequestMemoryVaaScreen failed!");
1372− FreeMemorySvc (ppCtx);
1373− 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))
1368+ //pVaa memory allocation
1369+ if (pParam->iUsageType == SCREEN_CONTENT_REAL_TIME) {
1370+ (*ppCtx)->pVaa = (SVAAFrameInfoExt*)pMa->WelsMallocz (sizeof (SVAAFrameInfoExt), "pVaa");
1371+ WELS_VERIFY_RETURN_PROC_IF (1, (NULL == (*ppCtx)->pVaa), FreeMemorySvc (ppCtx))
1372+ if (RequestMemoryVaaScreen ((*ppCtx)->pVaa, pMa, (*ppCtx)->pSvcParam->iNumRefFrame, iCountMaxMbNum << 2)) {
1373+ WelsLog (*ppCtx, WELS_LOG_WARNING, "RequestMemorySvc(), RequestMemoryVaaScreen failed!");
1374+ FreeMemorySvc (ppCtx);
1375+ return 1;
13781376 }
1377+ } else {
1378+ (*ppCtx)->pVaa = (SVAAFrameInfo*)pMa->WelsMallocz (sizeof (SVAAFrameInfo), "pVaa");
1379+ WELS_VERIFY_RETURN_PROC_IF (1, (NULL == (*ppCtx)->pVaa), FreeMemorySvc (ppCtx))
1380+ }
13791381
13801382 if ((*ppCtx)->pSvcParam->bEnableAdaptiveQuant) { //malloc mem
13811383 (*ppCtx)->pVaa->sAdaptiveQuantParam.pMotionTextureUnit = static_cast<SMotionTextureUnit*>
@@ -1585,7 +1587,7 @@ void FreeMemorySvc (sWelsEncCtx** ppCtx) { · 203 unmodified lines
15851587 }
15861588
15871589 if (pDq->pFeatureSearchPreparation) {
1588− ReleaseFeatureSearchPreparation(pMa, pDq->pFeatureSearchPreparation->pFeatureOfBlock);
1590+ ReleaseFeatureSearchPreparation (pMa, pDq->pFeatureSearchPreparation->pFeatureOfBlock);
15891591 pMa->WelsFree (pDq->pFeatureSearchPreparation, "pFeatureSearchPreparation");
15901592 pDq->pFeatureSearchPreparation = NULL;
15911593 }
@@ -1663,8 +1665,8 @@ void FreeMemorySvc (sWelsEncCtx** ppCtx) { · 71 unmodified lines
16631665 pMa->WelsFree (pCtx->pVaa->sVaaCalcInfo.pMad8x8, "pVaa->sVaaCalcInfo.pMad8x8");
16641666 pCtx->pVaa->sVaaCalcInfo.pMad8x8 = NULL;
16651667 }
1666− if(pCtx->pSvcParam->iUsageType == SCREEN_CONTENT_REAL_TIME)
1667− ReleaseMemoryVaaScreen(pCtx->pVaa, pMa,pCtx->pSvcParam->iNumRefFrame);
1668+ if (pCtx->pSvcParam->iUsageType == SCREEN_CONTENT_REAL_TIME)
1669+ ReleaseMemoryVaaScreen (pCtx->pVaa, pMa, pCtx->pSvcParam->iNumRefFrame);
16681670 pMa->WelsFree (pCtx->pVaa, "pVaa");
16691671 pCtx->pVaa = NULL;
16701672 }
@@ -2456,19 +2458,20 @@ void PreprocessSliceCoding (sWelsEncCtx* pCtx) { · 785 unmodified lines
24562458
24572459 if (P_SLICE == pCtx->eSliceType) {
24582460 //calculate bFMESwitchFlag
2459− SVAAFrameInfoExt *pVaaExt = static_cast<SVAAFrameInfoExt *>(pCtx->pVaa);
2460− const int32_t kiMbSize = pCurLayer->iMbHeight*pCurLayer->iMbWidth;
2461− pFeatureSearchPreparation->bFMESwitchFlag = CalcFMESwitchFlag( pFeatureSearchPreparation->uiFMEGoodFrameCount,
2462− pFeatureSearchPreparation->iHighFreMbCount*100/kiMbSize, pCtx->pVaa->sVaaCalcInfo.iFrameSad/kiMbSize,
2463− pVaaExt->sScrollDetectInfo.bScrollDetectFlag);
2461+ SVAAFrameInfoExt* pVaaExt = static_cast<SVAAFrameInfoExt*> (pCtx->pVaa);
2462+ const int32_t kiMbSize = pCurLayer->iMbHeight * pCurLayer->iMbWidth;
2463+ pFeatureSearchPreparation->bFMESwitchFlag = CalcFMESwitchFlag (pFeatureSearchPreparation->uiFMEGoodFrameCount,
2464+ pFeatureSearchPreparation->iHighFreMbCount * 100 / kiMbSize, pCtx->pVaa->sVaaCalcInfo.iFrameSad / kiMbSize,
2465+ pVaaExt->sScrollDetectInfo.bScrollDetectFlag);
24642466
24652467 //PerformFMEPreprocess
24662468 SScreenBlockFeatureStorage* pScreenBlockFeatureStorage = pCurLayer->pRefPic->pScreenBlockFeatureStorage;
24672469 pFeatureSearchPreparation->pRefBlockFeature = pScreenBlockFeatureStorage;
24682470 if (pFeatureSearchPreparation->bFMESwitchFlag
2469− && !pScreenBlockFeatureStorage->bRefBlockFeatureCalculated) {
2470− //TODO: use ORIGIN of reference when preprocessing is ready
2471− PerformFMEPreprocess( pFuncList, pCurLayer->pRefPic,pFeatureSearchPreparation->pFeatureOfBlock,pScreenBlockFeatureStorage);
2471+ && !pScreenBlockFeatureStorage->bRefBlockFeatureCalculated) {
2472+ //TODO: use ORIGIN of reference when preprocessing is ready
2473+ PerformFMEPreprocess (pFuncList, pCurLayer->pRefPic, pFeatureSearchPreparation->pFeatureOfBlock,
2474+ pScreenBlockFeatureStorage);
24722475 }
24732476
24742477 //assign ME pointer
@@ -3011,9 +3014,10 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo* pFbi, const SSour · 536 unmodified lines
30113014 #ifdef LONG_TERM_REF_DUMP
30123015 DumpRef (pCtx);
30133016 #endif
3014− 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,
3016− iCurDid,pSvcParam->bEnableBackgroundDetection);
3017+ if ((pSvcParam->iUsageType == SCREEN_CONTENT_REAL_TIME) && (pSvcParam->iRCMode != RC_OFF_MODE))
3018+ pCtx->pVpp->AnalyzePictureComplexity (pCtx, pCtx->pEncPic, ((pCtx->eSliceType == P_SLICE)
3019+ && (pCtx->iNumRef0 > 0)) ? pCtx->pRefList0[0] : NULL,
3020+ iCurDid, pSvcParam->bEnableBackgroundDetection);
30173021
30183022 WelsUpdateRefSyntax (pCtx, pCtx->iPOC,
30193023 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
30933097 pCtx->iActiveThreadsNum = iSliceCount;
30943098 // to fire slice coding threads
30953099 iRet = FiredSliceThreads (&pCtx->pSliceThreading->pThreadPEncCtx[0], &pCtx->pSliceThreading->pReadySliceCodingEvent[0],
3096− &pCtx->pSliceThreading->pThreadMasterEvent[0],
3097− pLayerBsInfo, iSliceCount, pCtx->pCurDqLayer->pSliceEncCtx, false);
3100+ &pCtx->pSliceThreading->pThreadMasterEvent[0],
3101+ pLayerBsInfo, iSliceCount, pCtx->pCurDqLayer->pSliceEncCtx, false);
30983102 if (iRet) {
30993103 WelsLog (pCtx, WELS_LOG_ERROR,
31003104 "[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
31323136 iNumThreadsRunning = iNumThreadsScheduled;
31333137 // to fire slice coding threads
31343138 iRet = FiredSliceThreads (&pCtx->pSliceThreading->pThreadPEncCtx[0], &pCtx->pSliceThreading->pReadySliceCodingEvent[0],
3135− &pCtx->pSliceThreading->pThreadMasterEvent[0],
3136− pLayerBsInfo, iNumThreadsRunning, pCtx->pCurDqLayer->pSliceEncCtx, false);
3139+ &pCtx->pSliceThreading->pThreadMasterEvent[0],
3140+ pLayerBsInfo, iNumThreadsRunning, pCtx->pCurDqLayer->pSliceEncCtx, false);
31373141 if (iRet) {
31383142 WelsLog (pCtx, WELS_LOG_ERROR,
31393143 "[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
31783182
31793183 // to fire slice coding threads
31803184 iRet = FiredSliceThreads (&pCtx->pSliceThreading->pThreadPEncCtx[0], &pCtx->pSliceThreading->pReadySliceCodingEvent[0],
3181− &pCtx->pSliceThreading->pThreadMasterEvent[0],
3182− pLayerBsInfo, kiPartitionCnt, pCtx->pCurDqLayer->pSliceEncCtx, true);
3185+ &pCtx->pSliceThreading->pThreadMasterEvent[0],
3186+ pLayerBsInfo, kiPartitionCnt, pCtx->pCurDqLayer->pSliceEncCtx, true);
31833187 if (iRet) {
31843188 WelsLog (pCtx, WELS_LOG_ERROR,
31853189 "[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