From 43f767d06ed79d9950178622f52cd9e64adec5bd Mon Sep 17 00:00:00 2001 From: Haibo Zhu Date: Thu, 17 Mar 2016 10:39:22 +0800 Subject: [PATCH] Diable assert in release with -DNDEBUG macro Update the code to avoid the function unused warning --- Makefile | 1 + codec/encoder/core/src/ref_list_mgr_svc.cpp | 74 ++++++++++----------- 2 files changed, 37 insertions(+), 38 deletions(-) diff --git a/Makefile b/Makefile index 6090d0a1..d580f6ef 100644 --- a/Makefile +++ b/Makefile @@ -51,6 +51,7 @@ endif # Configurations ifeq ($(BUILDTYPE), Release) CFLAGS += $(CFLAGS_OPT) +CFLAGS += -DNDEBUG USE_ASM = Yes ifeq ($(DEBUGSYMBOLS), True) CFLAGS += -g diff --git a/codec/encoder/core/src/ref_list_mgr_svc.cpp b/codec/encoder/core/src/ref_list_mgr_svc.cpp index baa21d6a..68a0538d 100644 --- a/codec/encoder/core/src/ref_list_mgr_svc.cpp +++ b/codec/encoder/core/src/ref_list_mgr_svc.cpp @@ -155,7 +155,7 @@ static inline void DeleteInvalidLTR (sWelsEncCtx* pCtx) { SLTRState* pLtr = &pCtx->pLtr[pCtx->uiDependencyId]; int32_t iMaxFrameNumPlus1 = (1 << pCtx->pSps->uiLog2MaxFrameNum); int32_t i; - SSpatialLayerInternal *pParamInternal = &pCtx->pSvcParam->sDependencyLayers[pCtx->uiDependencyId]; + SSpatialLayerInternal* pParamInternal = &pCtx->pSvcParam->sDependencyLayers[pCtx->uiDependencyId]; SLogContext* pLogCtx = & (pCtx->sLogCtx); for (i = 0; i < LONG_TERM_REF_NUM; i++) { @@ -196,7 +196,7 @@ static inline void HandleLTRMarkFeedback (sWelsEncCtx* pCtx) { SRefList* pRefList = pCtx->ppRefPicListExt[pCtx->uiDependencyId]; SPicture** pLongRefList = pRefList->pLongRefList; SLTRState* pLtr = &pCtx->pLtr[pCtx->uiDependencyId]; - SSpatialLayerInternal *pParamInternal = &pCtx->pSvcParam->sDependencyLayers[pCtx->uiDependencyId]; + SSpatialLayerInternal* pParamInternal = &pCtx->pSvcParam->sDependencyLayers[pCtx->uiDependencyId]; int32_t i, j; if (pLtr->uiLtrMarkState == LTR_MARKING_SUCCESS) { @@ -258,7 +258,7 @@ static inline void LTRMarkProcess (sWelsEncCtx* pCtx) { int32_t i = 0; int32_t j = 0; bool bMoveLtrFromShortToLong = false; - SSpatialLayerInternal *pParamInternal = &pCtx->pSvcParam->sDependencyLayers[pCtx->uiDependencyId]; + SSpatialLayerInternal* pParamInternal = &pCtx->pSvcParam->sDependencyLayers[pCtx->uiDependencyId]; if (pCtx->eSliceType == I_SLICE) { i = 0; @@ -436,7 +436,7 @@ bool CheckCurMarkFrameNumUsed (sWelsEncCtx* pCtx) { SPicture** pLongRefList = pRefList->pLongRefList; int32_t iGoPFrameNumInterval = ((pCtx->pSvcParam->uiGopSize >> 1) > 1) ? (pCtx->pSvcParam->uiGopSize >> 1) : (1); int32_t iMaxFrameNumPlus1 = (1 << pCtx->pSps->uiLog2MaxFrameNum); - SSpatialLayerInternal *pParamInternal = &pCtx->pSvcParam->sDependencyLayers[pCtx->uiDependencyId]; + SSpatialLayerInternal* pParamInternal = &pCtx->pSvcParam->sDependencyLayers[pCtx->uiDependencyId]; int32_t i; for (i = 0; i < pRefList->uiLongRefCount; i++) { @@ -449,8 +449,8 @@ bool CheckCurMarkFrameNumUsed (sWelsEncCtx* pCtx) { return true; } -void WlesMarkMMCORefInfo(sWelsEncCtx* pCtx, SLTRState* pLtr, - SSlice* pSliceList, const int32_t kiCountSliceNum) { +void WlesMarkMMCORefInfo (sWelsEncCtx* pCtx, SLTRState* pLtr, + SSlice* pSliceList, const int32_t kiCountSliceNum) { int32_t iSliceIdx = 0; int32_t iGoPFrameNumInterval = ((pCtx->pSvcParam->uiGopSize >> 1) > 1) ? (pCtx->pSvcParam->uiGopSize >> 1) : (1); @@ -459,7 +459,7 @@ void WlesMarkMMCORefInfo(sWelsEncCtx* pCtx, SLTRState* pLtr, SSliceHeader* pSliceHdr = &pSliceHdrExt->sSliceHeader; SRefPicMarking* pRefPicMark = &pSliceHdr->sRefMarking; - memset(pRefPicMark, 0, sizeof(SRefPicMarking)); + memset (pRefPicMark, 0, sizeof (SRefPicMarking)); if (pCtx->pSvcParam->bEnableLongTermReference && pLtr->bLTRMarkingFlag) { if (pLtr->iLTRMarkMode == LTR_DIRECT_MARK) { @@ -471,8 +471,7 @@ void WlesMarkMMCORefInfo(sWelsEncCtx* pCtx, SLTRState* pLtr, pRefPicMark->SMmcoRef[pRefPicMark->uiMmcoCount].iLongTermFrameIdx = pLtr->iCurLtrIdx; pRefPicMark->SMmcoRef[pRefPicMark->uiMmcoCount++].iMmcoType = MMCO_LONG; - } - else if (pLtr->iLTRMarkMode == LTR_DELAY_MARK) { + } else if (pLtr->iLTRMarkMode == LTR_DELAY_MARK) { pRefPicMark->SMmcoRef[pRefPicMark->uiMmcoCount].iDiffOfPicNum = iGoPFrameNumInterval; pRefPicMark->SMmcoRef[pRefPicMark->uiMmcoCount].iLongTermFrameIdx = pLtr->iCurLtrIdx; pRefPicMark->SMmcoRef[pRefPicMark->uiMmcoCount++].iMmcoType = MMCO_SHORT2LONG; @@ -505,11 +504,10 @@ void WelsMarkPic (sWelsEncCtx* pCtx) { if (pCtx->iActiveThreadsNum > 1) { //will replace with thread-base pslice buffer later pSliceList = pCtx->pCurDqLayer->sLayerInfo.pSliceInLayer; - WlesMarkMMCORefInfo(pCtx, pLtr, pSliceList, kiCountSliceNum); - } - else { + WlesMarkMMCORefInfo (pCtx, pLtr, pSliceList, kiCountSliceNum); + } else { pSliceList = pCtx->pCurDqLayer->sLayerInfo.pSliceInLayer; - WlesMarkMMCORefInfo(pCtx, pLtr, pSliceList, kiCountSliceNum); + WlesMarkMMCORefInfo (pCtx, pLtr, pSliceList, kiCountSliceNum); } } @@ -643,13 +641,13 @@ static void UpdateBlockStatic (sWelsEncCtx* pCtx) { } } -void WelsUpdateSliceHeaderSyntax(sWelsEncCtx* pCtx, const int32_t iAbsDiffPicNumMinus1, - SSlice* pSliceList, const int32_t uiFrameType) { - const int32_t kiCountSliceNum = GetCurrentSliceNum(pCtx->pCurDqLayer); +void WelsUpdateSliceHeaderSyntax (sWelsEncCtx* pCtx, const int32_t iAbsDiffPicNumMinus1, + SSlice* pSliceList, const int32_t uiFrameType) { + const int32_t kiCountSliceNum = GetCurrentSliceNum (pCtx->pCurDqLayer); SLTRState* pLtr = &pCtx->pLtr[pCtx->uiDependencyId]; int32_t iIdx = 0; - assert(kiCountSliceNum > 0); + assert (kiCountSliceNum > 0); for (iIdx = 0; iIdx < kiCountSliceNum; iIdx++) { SSliceHeaderExt* pSliceHdrExt = &pSliceList[iIdx].sSliceHeaderExt; @@ -664,8 +662,7 @@ void WelsUpdateSliceHeaderSyntax(sWelsEncCtx* pCtx, const int32_t iAbsDiffPicNu pRefReorder->SReorderingSyntax[0].uiReorderingOfPicNumsIdc = 0; pRefReorder->SReorderingSyntax[0].uiAbsDiffPicNumMinus1 = iAbsDiffPicNumMinus1; pRefReorder->SReorderingSyntax[1].uiReorderingOfPicNumsIdc = 3; - } - else { + } else { pRefReorder->SReorderingSyntax[0].uiReorderingOfPicNumsIdc = 2; pRefReorder->SReorderingSyntax[0].iLongTermPicNum = pCtx->pRefList0[0]->iLongTermPicNum; pRefReorder->SReorderingSyntax[1].uiReorderingOfPicNumsIdc = 3; @@ -676,13 +673,12 @@ void WelsUpdateSliceHeaderSyntax(sWelsEncCtx* pCtx, const int32_t iAbsDiffPicNu if (videoFrameTypeIDR == uiFrameType) { pRefPicMark->bNoOutputOfPriorPicsFlag = false; pRefPicMark->bLongTermRefFlag = pCtx->pSvcParam->bEnableLongTermReference; - } - else { + } else { if (pCtx->pSvcParam->iUsageType == SCREEN_CONTENT_REAL_TIME) pRefPicMark->bAdaptiveRefPicMarkingModeFlag = pCtx->pSvcParam->bEnableLongTermReference; else pRefPicMark->bAdaptiveRefPicMarkingModeFlag = (pCtx->pSvcParam->bEnableLongTermReference - && pLtr->bLTRMarkingFlag) ? (true) : (false); + && pLtr->bLTRMarkingFlag) ? (true) : (false); } } } @@ -696,25 +692,25 @@ void WelsUpdateRefSyntax (sWelsEncCtx* pCtx, const int32_t iPOC, const int32_t u SSlice* pSliceList = NULL; SSpatialLayerInternal* pParamD = &pCtx->pSvcParam->sDependencyLayers[pCtx->uiDependencyId]; /*syntax for ref_pic_list_reordering()*/ - if (pCtx->iNumRef0 > 0){ + if (pCtx->iNumRef0 > 0) { iAbsDiffPicNumMinus1 = pParamD->iFrameNum - (pCtx->pRefList0[0]->iFrameNum) - 1; if (iAbsDiffPicNumMinus1 < 0) { - WelsLog(&(pCtx->sLogCtx), WELS_LOG_INFO, "WelsUpdateRefSyntax():::uiAbsDiffPicNumMinus1:%d", iAbsDiffPicNumMinus1); - iAbsDiffPicNumMinus1 += (1 << (pCtx->pSps->uiLog2MaxFrameNum)); - WelsLog(&(pCtx->sLogCtx), WELS_LOG_INFO, "WelsUpdateRefSyntax():::uiAbsDiffPicNumMinus1< 0, update as:%d", - iAbsDiffPicNumMinus1); - } + WelsLog (& (pCtx->sLogCtx), WELS_LOG_INFO, "WelsUpdateRefSyntax():::uiAbsDiffPicNumMinus1:%d", iAbsDiffPicNumMinus1); + iAbsDiffPicNumMinus1 += (1 << (pCtx->pSps->uiLog2MaxFrameNum)); + WelsLog (& (pCtx->sLogCtx), WELS_LOG_INFO, "WelsUpdateRefSyntax():::uiAbsDiffPicNumMinus1< 0, update as:%d", + iAbsDiffPicNumMinus1); } + } - if (pCtx->iActiveThreadsNum >0) { + if (pCtx->iActiveThreadsNum > 0) { // to do: will replace with thread based buffer later pSliceList = pCtx->pCurDqLayer->sLayerInfo.pSliceInLayer; } else { pSliceList = pCtx->pCurDqLayer->sLayerInfo.pSliceInLayer; } - WelsUpdateSliceHeaderSyntax(pCtx, iAbsDiffPicNumMinus1,pSliceList, uiFrameType); + WelsUpdateSliceHeaderSyntax (pCtx, iAbsDiffPicNumMinus1, pSliceList, uiFrameType); } @@ -882,8 +878,8 @@ static inline bool IsValidFrameNum (const int32_t kiFrameNum) { return (kiFrameNum < (1 << 30)); // TODO: use the original judge first, may be improved } -void WlesMarkMMCORefInfoScreen(sWelsEncCtx* pCtx, SLTRState* pLtr, - SSlice* pSliceList, const int32_t kiCountSliceNum) { +void WlesMarkMMCORefInfoScreen (sWelsEncCtx* pCtx, SLTRState* pLtr, + SSlice* pSliceList, const int32_t kiCountSliceNum) { const int32_t iMaxLtrIdx = pCtx->pSvcParam->iNumRefFrame - STR_ROOM - 1; for (int32_t iSliceIdx = 0; iSliceIdx < kiCountSliceNum; iSliceIdx++) { @@ -891,7 +887,7 @@ void WlesMarkMMCORefInfoScreen(sWelsEncCtx* pCtx, SLTRState* pLtr, SSliceHeader* pSliceHdr = &pSliceHdrExt->sSliceHeader; SRefPicMarking* pRefPicMark = &pSliceHdr->sRefMarking; - memset(pRefPicMark, 0, sizeof(SRefPicMarking)); + memset (pRefPicMark, 0, sizeof (SRefPicMarking)); if (pCtx->pSvcParam->bEnableLongTermReference) { pRefPicMark->SMmcoRef[pRefPicMark->uiMmcoCount].iMaxLongTermFrameIdx = iMaxLtrIdx; pRefPicMark->SMmcoRef[pRefPicMark->uiMmcoCount++].iMmcoType = MMCO_SET_MAX_LONG; @@ -957,7 +953,10 @@ void WelsMarkPicScreen (sWelsEncCtx* pCtx) { for (i = 0 ; i < pRefList->uiLongRefCount ; ++i) { if (ppLongRefList[i]->bUsedAsRef && ppLongRefList[i]->bIsLongRef && (!ppLongRefList[i]->bIsSceneLTR) && iMaxMultiRefTid == ppLongRefList[i]->uiTemporalId) { - assert (IsValidFrameNum (ppLongRefList[i]->iFrameNum)); // pLtr->iCurLtrIdx must have a value + if (!IsValidFrameNum (ppLongRefList[i]->iFrameNum)) { // pLtr->iCurLtrIdx must have a value + WelsLog (& (pCtx->sLogCtx), WELS_LOG_ERROR, "WelsMarkPicScreen, Invalid Frame Number"); + return; + } int32_t iDeltaFrameNum = (pParamD->iFrameNum >= ppLongRefList[i]->iFrameNum) ? (pParamD->iFrameNum - ppLongRefList[i]->iFrameNum) : (pParamD->iFrameNum + iMaxFrameNum - ppLongRefList[i]->iFrameNum); @@ -978,16 +977,15 @@ void WelsMarkPicScreen (sWelsEncCtx* pCtx) { } } - const int32_t iSliceNum = GetCurrentSliceNum(pCtx->pCurDqLayer); + const int32_t iSliceNum = GetCurrentSliceNum (pCtx->pCurDqLayer); if (pCtx->iActiveThreadsNum > 1) { // to do: will replace with thread based buffer later pSliceList = pCtx->pCurDqLayer->sLayerInfo.pSliceInLayer; - } - else { + } else { pSliceList = pCtx->pCurDqLayer->sLayerInfo.pSliceInLayer; } - WlesMarkMMCORefInfoScreen(pCtx, pLtr, pSliceList, iSliceNum); + WlesMarkMMCORefInfoScreen (pCtx, pLtr, pSliceList, iSliceNum); return; }