From a4ae5e3747468e6e74bb676d0379af4f3afe376b Mon Sep 17 00:00:00 2001 From: Sijia Chen Date: Fri, 9 Jan 2015 16:17:51 +0800 Subject: [PATCH] add fix for the valgrid warning of issue#1362 --- codec/encoder/core/inc/encoder_context.h | 2 +- codec/encoder/core/src/encoder_ext.cpp | 7 +------ codec/encoder/core/src/ref_list_mgr_svc.cpp | 9 +++++++-- codec/encoder/core/src/wels_preprocess.cpp | 4 ++-- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/codec/encoder/core/inc/encoder_context.h b/codec/encoder/core/inc/encoder_context.h index f15bb205..26a46e30 100644 --- a/codec/encoder/core/inc/encoder_context.h +++ b/codec/encoder/core/inc/encoder_context.h @@ -201,7 +201,7 @@ typedef struct TagWelsEncCtx { SSpatialPicIndex sSpatialIndexMap[MAX_DEPENDENCY_LAYER]; - bool bLongTermRefFlag[MAX_DEPENDENCY_LAYER][MAX_TEMPORAL_LEVEL + 1/*+LONG_TERM_REF_NUM*/]; + bool bRefOfCurTidIsLtr[MAX_DEPENDENCY_LAYER][MAX_TEMPORAL_LEVEL]; uint16_t uiIdrPicId; // IDR picture id: [0, 65535], this one is used for LTR int16_t iMaxSliceCount;// maximal count number of slices for all layers observation diff --git a/codec/encoder/core/src/encoder_ext.cpp b/codec/encoder/core/src/encoder_ext.cpp index 89ec26ce..c47b8401 100644 --- a/codec/encoder/core/src/encoder_ext.cpp +++ b/codec/encoder/core/src/encoder_ext.cpp @@ -3727,11 +3727,6 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo* pFbi, const SSour WelsSwapDqLayers (pCtx); } - if (pSvcParam->bEnableLongTermReference && (pCtx->pLtr[pCtx->uiDependencyId].bLTRMarkingFlag - && (pCtx->pLtr[pCtx->uiDependencyId].iLTRMarkMode == LTR_DELAY_MARK))) { - pCtx->bLongTermRefFlag[iDidIdx][0] = true; - } - if (pCtx->pVpp->UpdateSpatialPictures (pCtx, pSvcParam, iCurTid, iDidIdx) != 0) { ForceCodingIDR (pCtx); WelsLog (pLogCtx, WELS_LOG_WARNING, "WelsEncoderEncodeExt(), Logic Error Found in temporal level. ForceCodingIDR!"); @@ -3742,7 +3737,7 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo* pFbi, const SSour if (pSvcParam->bEnableLongTermReference && ((pCtx->pLtr[pCtx->uiDependencyId].bLTRMarkingFlag && (pCtx->pLtr[pCtx->uiDependencyId].iLTRMarkMode == LTR_DIRECT_MARK)) || eFrameType == videoFrameTypeIDR)) { - pCtx->bLongTermRefFlag[iDidIdx][iCurTid] = true; + pCtx->bRefOfCurTidIsLtr[iDidIdx][iCurTid] = true; } } diff --git a/codec/encoder/core/src/ref_list_mgr_svc.cpp b/codec/encoder/core/src/ref_list_mgr_svc.cpp index 7c1510d7..597d6451 100644 --- a/codec/encoder/core/src/ref_list_mgr_svc.cpp +++ b/codec/encoder/core/src/ref_list_mgr_svc.cpp @@ -289,8 +289,10 @@ static inline void LTRMarkProcess (sWelsEncCtx* pCtx) { } } - if ((pLtr->iLTRMarkMode == LTR_DELAY_MARK && pLtr->bLTRMarkingFlag) || ((pLtr->iLTRMarkMode == LTR_DIRECT_MARK) - && (bMoveLtrFromShortToLong))) { + if ((pLtr->iLTRMarkMode == LTR_DELAY_MARK && pLtr->bLTRMarkingFlag) + || ((pLtr->iLTRMarkMode == LTR_DIRECT_MARK) && (bMoveLtrFromShortToLong))) { + pCtx->bRefOfCurTidIsLtr[pCtx->uiDependencyId][pCtx->uiTemporalId] = true; + if (pRefList->uiLongRefCount > 0) { memmove (&pRefList->pLongRefList[1], &pRefList->pLongRefList[0], pRefList->uiLongRefCount * sizeof (SPicture*)); // confirmed_safe_unsafe_usage @@ -595,6 +597,9 @@ bool WelsBuildRefList (sWelsEncCtx* pCtx, const int32_t iPOC, int32_t iBestLtrRe } else { // safe for IDR WelsResetRefList (pCtx); //for IDR, SHOULD reset pRef list. ResetLtrState (&pCtx->pLtr[pCtx->uiDependencyId]); //SHOULD update it when IDR. + for (int32_t k = 0; k < MAX_TEMPORAL_LEVEL; k++) { + pCtx->bRefOfCurTidIsLtr[pCtx->uiDependencyId][k] = false; + } pCtx->pRefList0[0] = NULL; } diff --git a/codec/encoder/core/src/wels_preprocess.cpp b/codec/encoder/core/src/wels_preprocess.cpp index a4ddfb09..160890f6 100644 --- a/codec/encoder/core/src/wels_preprocess.cpp +++ b/codec/encoder/core/src/wels_preprocess.cpp @@ -269,11 +269,11 @@ int32_t CWelsPreProcess::UpdateSpatialPictures (sWelsEncCtx* pCtx, SWelsSvcCodin InitLastSpatialPictures (pCtx); return 1; } - if (pParam->bEnableLongTermReference && pCtx->bLongTermRefFlag[kiDidx][iCurTid]) { + if (pCtx->bRefOfCurTidIsLtr[kiDidx][iCurTid]) { const int32_t kiAvailableLtrPos = m_uiSpatialLayersInTemporal[kiDidx] + pCtx->pVaa->uiMarkLongTermPicIdx; WelsExchangeSpatialPictures (&m_pSpatialPic[kiDidx][kiAvailableLtrPos], &m_pSpatialPic[kiDidx][iCurTid]); - pCtx->bLongTermRefFlag[kiDidx][iCurTid] = false; + pCtx->bRefOfCurTidIsLtr[kiDidx][iCurTid] = false; } WelsExchangeSpatialPictures (&m_pSpatialPic[kiDidx][kiCurPos], &m_pSpatialPic[kiDidx][iCurTid]);