From 5303eaaeb9366b83b4ee8f913996bb71ade1ebf5 Mon Sep 17 00:00:00 2001 From: Licai Guo Date: Wed, 26 Feb 2014 20:00:32 -0800 Subject: [PATCH] remove store_ref_base_pic_flag related codes in reference picture management --- codec/decoder/core/inc/manage_dec_ref.h | 8 +- codec/decoder/core/inc/picture.h | 1 - codec/decoder/core/src/decoder_core.cpp | 25 +-- codec/decoder/core/src/manage_dec_ref.cpp | 182 +++++----------------- 4 files changed, 50 insertions(+), 166 deletions(-) diff --git a/codec/decoder/core/inc/manage_dec_ref.h b/codec/decoder/core/inc/manage_dec_ref.h index f686baa6..e8a77296 100644 --- a/codec/decoder/core/inc/manage_dec_ref.h +++ b/codec/decoder/core/inc/manage_dec_ref.h @@ -47,16 +47,10 @@ namespace WelsDec { -typedef enum TagRemoveFlag { -REMOVE_TARGET = 0, -REMOVE_BASE = 1, -REMOVE_BASE_FIRST = 2 -} ERemoveFlag; - void WelsResetRefPic (PWelsDecoderContext pCtx); int32_t WelsInitRefList (PWelsDecoderContext pCtx, int32_t iPoc); int32_t WelsReorderRefList (PWelsDecoderContext pCtx); -int32_t WelsMarkAsRef (PWelsDecoderContext pCtx, const bool kbRefBaseMarkingFlag); +int32_t WelsMarkAsRef (PWelsDecoderContext pCtx); } // namespace WelsDec diff --git a/codec/decoder/core/inc/picture.h b/codec/decoder/core/inc/picture.h index 2d6e2ac4..69cbbd9e 100644 --- a/codec/decoder/core/inc/picture.h +++ b/codec/decoder/core/inc/picture.h @@ -67,7 +67,6 @@ bool bAvailableFlag; // indicate whether it is available in this picture memory uint8_t uiTemporalId; uint8_t uiSpatialId; uint8_t uiQualityId; -bool bRefBaseFlag; int32_t iFrameNum; // frame number //for ref pic management int32_t iLongTermFrameIdx; //id for long term ref pic diff --git a/codec/decoder/core/src/decoder_core.cpp b/codec/decoder/core/src/decoder_core.cpp index c4982ad3..8c72a2ce 100644 --- a/codec/decoder/core/src/decoder_core.cpp +++ b/codec/decoder/core/src/decoder_core.cpp @@ -101,10 +101,8 @@ static inline int32_t DecodeFrameConstruction (PWelsDecoderContext pCtx, uint8_t return 0; } -inline bool CheckSliceNeedReconstruct (int16_t iCurDid, int16_t iCurQid, bool bStoreRefBasePicFlag, - uint8_t uiDidMax, uint8_t uiLayerDqId, uint8_t uiTargetDqId) { - return ((iCurDid == uiDidMax) && (iCurQid == BASE_QUALITY_ID) && (bStoreRefBasePicFlag)) // store base - || (uiLayerDqId == uiTargetDqId); // target layer +inline bool CheckSliceNeedReconstruct (uint8_t uiLayerDqId, uint8_t uiTargetDqId) { + return (uiLayerDqId == uiTargetDqId); // target layer } inline uint8_t GetTargetDqId (uint8_t uiTargetDqId, SDecodingParam* psParam) { @@ -1863,8 +1861,7 @@ int32_t DecodeCurrentAccessUnit (PWelsDecoderContext pCtx, uint8_t** ppDst, int3 pSh = &pNalCur->sNalData.sVclNal.sSliceHeaderExt.sSliceHeader; pShExt = &pNalCur->sNalData.sVclNal.sSliceHeaderExt; - bReconstructSlice = CheckSliceNeedReconstruct (iCurrIdD, iCurrIdQ, pShExt->bStoreRefBasePicFlag, - kuiDependencyIdMax, pNalCur->sNalHeaderExt.uiLayerDqId, kuiTargetLayerDqId); + bReconstructSlice = CheckSliceNeedReconstruct (pNalCur->sNalHeaderExt.uiLayerDqId, kuiTargetLayerDqId); memcpy (&pLayerInfo.sNalHeaderExt, &pNalCur->sNalHeaderExt, sizeof (SNalUnitHeaderExt)); //confirmed_safe_unsafe_usage @@ -1995,25 +1992,15 @@ int32_t DecodeCurrentAccessUnit (PWelsDecoderContext pCtx, uint8_t** ppDst, int3 #endif } - if ((uiNalRefIdc > 0) && (iCurrIdQ || (!dq_cur->bStoreRefBasePicFlag))) { - WelsMarkAsRef (pCtx, false); - ExpandReferencingPicture (pCtx->pDec, pCtx->sExpandPicFunc.pExpandLumaPicture, - pCtx->sExpandPicFunc.pExpandChromaPicture); - pCtx->pDec = NULL; - } - } - - if ((iCurrIdD == kuiDependencyIdMax) && (iCurrIdQ == BASE_QUALITY_ID) && (dq_cur->bStoreRefBasePicFlag)) { - pStoreBasePic = pCtx->pDec; - if (uiNalRefIdc > 0) { - WelsMarkAsRef (pCtx, true); + WelsMarkAsRef (pCtx); ExpandReferencingPicture (pCtx->pDec, pCtx->sExpandPicFunc.pExpandLumaPicture, pCtx->sExpandPicFunc.pExpandChromaPicture); pCtx->pDec = NULL; } } - // need update frame_num due current frame is well decoded + + // need update frame_num due current frame is well decoded pCtx->iPrevFrameNum = pSh->iFrameNum; if (pCtx->bLastHasMmco5) pCtx->iPrevFrameNum = 0; diff --git a/codec/decoder/core/src/manage_dec_ref.cpp b/codec/decoder/core/src/manage_dec_ref.cpp index cc48d84e..c414d33e 100644 --- a/codec/decoder/core/src/manage_dec_ref.cpp +++ b/codec/decoder/core/src/manage_dec_ref.cpp @@ -44,20 +44,18 @@ namespace WelsDec { -static PPicture WelsDelShortFromList (PRefPic pRefPic, int32_t iFrameNum, ERemoveFlag eRemoveFlag); -static PPicture WelsDelLongFromList (PRefPic pRefPic, uint32_t uiLongTermFrameIdx, ERemoveFlag eRemoveFlag); -static PPicture WelsDelShortFromListSetUnref (PRefPic pRefPic, int32_t iFrameNum, ERemoveFlag eRemoveFlag); -static PPicture WelsDelLongFromListSetUnref (PRefPic pRefPic, uint32_t uiLongTermFrameIdx, ERemoveFlag eRemoveFlag); +static PPicture WelsDelShortFromList (PRefPic pRefPic, int32_t iFrameNum); +static PPicture WelsDelLongFromList (PRefPic pRefPic, uint32_t uiLongTermFrameIdx); +static PPicture WelsDelShortFromListSetUnref (PRefPic pRefPic, int32_t iFrameNum); +static PPicture WelsDelLongFromListSetUnref (PRefPic pRefPic, uint32_t uiLongTermFrameIdx); -static int32_t MMCOBase (PWelsDecoderContext pCtx, PRefBasePicMarking pRefPicBaseMarking); static int32_t MMCO (PWelsDecoderContext pCtx, PRefPicMarking pRefPicMarking); -static int32_t MMCOProcess (PWelsDecoderContext pCtx, uint32_t uiMmcoType, bool bRefBasePic, +static int32_t MMCOProcess (PWelsDecoderContext pCtx, uint32_t uiMmcoType, int32_t iShortFrameNum, uint32_t uiLongTermPicNum, int32_t iLongTermFrameIdx, int32_t iMaxLongTermFrameIdx); static int32_t SlidingWindow (PWelsDecoderContext pCtx); static int32_t AddShortTermToList (PRefPic pRefPic, PPicture pPic); static int32_t AddLongTermToList (PRefPic pRefPic, PPicture pPic, int32_t iLongTermFrameIdx); -static int32_t AssignLongTermIdx (PRefPic pRefPic, int32_t iFrameNum, int32_t iLongTermFrameIdx); static int32_t MarkAsLongTerm (PRefPic pRefPic, int32_t iFrameNum, int32_t iLongTermFrameIdx); static void SetUnRef (PPicture pRef) { @@ -67,7 +65,6 @@ static void SetUnRef (PPicture pRef) { pRef->iFrameNum = -1; pRef->iFramePoc = 0; pRef->iLongTermFrameIdx = -1; - pRef->bRefBaseFlag = 0; pRef->uiQualityId = -1; pRef->uiTemporalId = -1; pRef->uiSpatialId = -1; @@ -114,37 +111,13 @@ int32_t WelsInitRefList (PWelsDecoderContext pCtx, int32_t iPoc) { memset (pCtx->sRefPic.pRefList[LIST_0], 0, MAX_REF_PIC_COUNT * sizeof (PPicture)); //short for (i = 0; i < pCtx->sRefPic.uiShortRefCount[LIST_0]; ++i) { - if (kbUseRefBasePicFlag == ppShoreRefList[i]->bRefBaseFlag) { - pCtx->sRefPic.pRefList[LIST_0][iCount++ ] = ppShoreRefList[i]; - } else { - for (j = 0; j < pCtx->sRefPic.uiShortRefCount[LIST_0]; ++j) { - if (ppShoreRefList[j]->iFrameNum == ppShoreRefList[i]->iFrameNum - && ppShoreRefList[j]->bRefBaseFlag == kbUseRefBasePicFlag) { - break; - } - } - if (j == pCtx->sRefPic.uiShortRefCount[LIST_0]) { - pCtx->sRefPic.pRefList[LIST_0][iCount++] = ppShoreRefList[i]; - } - } + pCtx->sRefPic.pRefList[LIST_0][iCount++ ] = ppShoreRefList[i]; } //long j = 0; for (i = 0; i < pCtx->sRefPic.uiLongRefCount[LIST_0] ; ++i) { - if (kbUseRefBasePicFlag == ppLongRefList[i]->bRefBaseFlag) { - pCtx->sRefPic.pRefList[LIST_0][iCount++ ] = ppLongRefList[i]; - } else { - for (j = 0; j < pCtx->sRefPic.uiLongRefCount[LIST_0]; ++j) { - if (ppLongRefList[j]->iLongTermFrameIdx == ppLongRefList[i]->iLongTermFrameIdx - && ppLongRefList[j]->bRefBaseFlag == kbUseRefBasePicFlag) { - break; - } - } - if (j == pCtx->sRefPic.uiLongRefCount[LIST_0]) { - pCtx->sRefPic.pRefList[LIST_0][iCount++] = ppLongRefList[i]; - } - } + pCtx->sRefPic.pRefList[LIST_0][iCount++ ] = ppLongRefList[i]; } pCtx->sRefPic.uiRefCount[LIST_0] = iCount; @@ -231,7 +204,7 @@ int32_t WelsReorderRefList (PWelsDecoderContext pCtx) { return ERR_NONE; } -int32_t WelsMarkAsRef (PWelsDecoderContext pCtx, const bool kbRefBaseMarkingFlag) { +int32_t WelsMarkAsRef (PWelsDecoderContext pCtx) { PRefPic pRefPic = &pCtx->sRefPic; PRefPicMarking pRefPicMarking = pCtx->pCurDqLayer->pRefPicMarking; PRefBasePicMarking pRefPicBaseMarking = pCtx->pCurDqLayer->pRefPicBaseMarking; @@ -240,14 +213,10 @@ int32_t WelsMarkAsRef (PWelsDecoderContext pCtx, const bool kbRefBaseMarkingFlag uint32_t j; int32_t iRet = ERR_NONE; - if (pCtx->pCurDqLayer->bStoreRefBasePicFlag && (pCtx->pSps->iNumRefFrames < 2)) { - return ERR_INFO_INVALID_MMCO_REF_NUM_NOT_ENOUGH; - } pCtx->pDec->bUsedAsRef = true; pCtx->pDec->uiQualityId = pCtx->pCurDqLayer->sLayerInfo.sNalHeaderExt.uiQualityId; pCtx->pDec->uiTemporalId = pCtx->pCurDqLayer->sLayerInfo.sNalHeaderExt.uiTemporalId; - pCtx->pDec->bRefBaseFlag = kbRefBaseMarkingFlag; for (j = pCurAU->uiStartPos; j <= pCurAU->uiEndPos; j++) { if (pCurAU->pNalUnitsList[j]->sNalHeaderExt.sNalUnitHeader.eNalUnitType == NAL_UNIT_CODED_SLICE_IDR @@ -264,14 +233,6 @@ int32_t WelsMarkAsRef (PWelsDecoderContext pCtx, const bool kbRefBaseMarkingFlag pCtx->sRefPic.iMaxLongTermFrameIdx = -1; } } else { - if (pRefPicBaseMarking->bAdaptiveRefBasePicMarkingModeFlag) { - iRet = MMCOBase (pCtx, pRefPicBaseMarking); - } - - if (iRet != ERR_NONE) { - return iRet; - } - if (pRefPicMarking->bAdaptiveRefPicMarkingModeFlag) { iRet = MMCO (pCtx, pRefPicMarking); if (pCtx->bLastHasMmco5) { @@ -293,29 +254,6 @@ int32_t WelsMarkAsRef (PWelsDecoderContext pCtx, const bool kbRefBaseMarkingFlag return iRet; } -static int32_t MMCOBase (PWelsDecoderContext pCtx, PRefBasePicMarking pRefPicBaseMarking) { - PSps pSps = pCtx->pCurDqLayer->sLayerInfo.pSps; - int32_t i = 0; - int32_t iRet = ERR_NONE; - - for (i = 0 ; pRefPicBaseMarking->mmco_base[i].uiMmcoType != MMCO_END; i++) { - uint32_t uiMmcoType = pRefPicBaseMarking->mmco_base[i].uiMmcoType; - int32_t iShortFrameNum = (pCtx->iFrameNum - pRefPicBaseMarking->mmco_base[i].uiDiffOfPicNums) & (( - 1 << pSps->uiLog2MaxFrameNum) - 1); - uint32_t uiLongTermPicNum = pRefPicBaseMarking->mmco_base[i].uiLongTermPicNum; - if (uiMmcoType > MMCO_LONG2UNUSED) { - return ERR_INFO_INVALID_MMCO_OPCODE_BASE; - } - iRet = MMCOProcess (pCtx, uiMmcoType, true, iShortFrameNum, uiLongTermPicNum, 0, 0); - - if (iRet != ERR_NONE) { - return iRet; - } - } - - return ERR_NONE; -} - static int32_t MMCO (PWelsDecoderContext pCtx, PRefPicMarking pRefPicMarking) { PSps pSps = pCtx->pCurDqLayer->sLayerInfo.pSps; int32_t i = 0; @@ -330,7 +268,7 @@ static int32_t MMCO (PWelsDecoderContext pCtx, PRefPicMarking pRefPicMarking) { if (uiMmcoType > MMCO_LONG) { return ERR_INFO_INVALID_MMCO_OPCODE_BASE; } - iRet = MMCOProcess (pCtx, uiMmcoType, false, iShortFrameNum, uiLongTermPicNum, iLongTermFrameIdx, iMaxLongTermFrameIdx); + iRet = MMCOProcess (pCtx, uiMmcoType, iShortFrameNum, uiLongTermPicNum, iLongTermFrameIdx, iMaxLongTermFrameIdx); if (iRet != ERR_NONE) { return iRet; } @@ -338,7 +276,7 @@ static int32_t MMCO (PWelsDecoderContext pCtx, PRefPicMarking pRefPicMarking) { return ERR_NONE; } -static int32_t MMCOProcess (PWelsDecoderContext pCtx, uint32_t uiMmcoType, bool bRefBasePic, +static int32_t MMCOProcess (PWelsDecoderContext pCtx, uint32_t uiMmcoType, int32_t iShortFrameNum, uint32_t uiLongTermPicNum , int32_t iLongTermFrameIdx, int32_t iMaxLongTermFrameIdx) { PRefPic pRefPic = &pCtx->sRefPic; PPicture pPic = NULL; @@ -347,20 +285,17 @@ static int32_t MMCOProcess (PWelsDecoderContext pCtx, uint32_t uiMmcoType, bool switch (uiMmcoType) { case MMCO_SHORT2UNUSED: - pPic = WelsDelShortFromListSetUnref (pRefPic, iShortFrameNum, (ERemoveFlag) bRefBasePic); + pPic = WelsDelShortFromListSetUnref (pRefPic, iShortFrameNum); break; case MMCO_LONG2UNUSED: - pPic = WelsDelLongFromListSetUnref (pRefPic, uiLongTermPicNum, (ERemoveFlag) bRefBasePic); + pPic = WelsDelLongFromListSetUnref (pRefPic, uiLongTermPicNum); break; case MMCO_SHORT2LONG: if (iLongTermFrameIdx > pRefPic->iMaxLongTermFrameIdx) { return ERR_INFO_INVALID_MMCO_LONG_TERM_IDX_EXCEED_MAX; } - pPic = WelsDelShortFromList (pRefPic, iShortFrameNum, REMOVE_TARGET); - WelsDelLongFromListSetUnref (pRefPic, iLongTermFrameIdx, REMOVE_TARGET); - - WelsDelShortFromList (pRefPic, iShortFrameNum, REMOVE_BASE); - WelsDelLongFromListSetUnref (pRefPic, iLongTermFrameIdx, REMOVE_BASE); + pPic = WelsDelShortFromList (pRefPic, iShortFrameNum); + WelsDelLongFromListSetUnref (pRefPic, iLongTermFrameIdx); #ifdef LONG_TERM_REF pCtx->bCurAuContainLtrMarkSeFlag = true; pCtx->iFrameNumOfAuMarkedLtr = iShortFrameNum; @@ -374,7 +309,7 @@ static int32_t MMCOProcess (PWelsDecoderContext pCtx, uint32_t uiMmcoType, bool pRefPic->iMaxLongTermFrameIdx = iMaxLongTermFrameIdx; for (i = 0 ; i < pRefPic->uiLongRefCount[LIST_0]; i++) { if (pRefPic->pLongRefList[LIST_0][i]->iLongTermFrameIdx > pRefPic->iMaxLongTermFrameIdx) { - WelsDelLongFromListSetUnref (pRefPic, pRefPic->pLongRefList[LIST_0][i]->iLongTermFrameIdx, REMOVE_BASE_FIRST); + WelsDelLongFromListSetUnref (pRefPic, pRefPic->pLongRefList[LIST_0][i]->iLongTermFrameIdx); } } break; @@ -391,8 +326,7 @@ static int32_t MMCOProcess (PWelsDecoderContext pCtx, uint32_t uiMmcoType, bool pCtx->iFrameNumOfAuMarkedLtr = pCtx->iFrameNum; WelsLog (pCtx, WELS_LOG_INFO, "ex_mark_avc():::MMCO_LONG:::LTR marking....iFrameNum: %d\n", pCtx->iFrameNum); #endif - WelsDelLongFromListSetUnref (pRefPic, iLongTermFrameIdx, REMOVE_TARGET); - WelsDelLongFromListSetUnref (pRefPic, iLongTermFrameIdx, REMOVE_BASE); + WelsDelLongFromListSetUnref (pRefPic, iLongTermFrameIdx); iRet = AddLongTermToList (pRefPic, pCtx->pDec, iLongTermFrameIdx); break; default : @@ -409,7 +343,7 @@ static int32_t SlidingWindow (PWelsDecoderContext pCtx) { if (pCtx->sRefPic.uiShortRefCount[LIST_0] + pCtx->sRefPic.uiLongRefCount[LIST_0] >= pCtx->pSps->iNumRefFrames) { for (i = pRefPic->uiShortRefCount[LIST_0] - 1; i >= 0; i--) { - pPic = WelsDelShortFromList (pRefPic, pRefPic->pShortRefList[LIST_0][i]->iFrameNum, REMOVE_BASE_FIRST); + pPic = WelsDelShortFromList (pRefPic, pRefPic->pShortRefList[LIST_0][i]->iFrameNum); if (pPic) { SetUnRef (pPic); break; @@ -421,68 +355,61 @@ static int32_t SlidingWindow (PWelsDecoderContext pCtx) { return ERR_NONE; } -static PPicture WelsDelShortFromList (PRefPic pRefPic, int32_t iFrameNum, ERemoveFlag eRemoveFlag) { +static PPicture WelsDelShortFromList (PRefPic pRefPic, int32_t iFrameNum) { int32_t i = 0; int32_t iMoveSize = 0; PPicture pPic = NULL; for (i = 0; i < pRefPic->uiShortRefCount[LIST_0]; i++) { if (pRefPic->pShortRefList[LIST_0][i]->iFrameNum == iFrameNum) { - if ((eRemoveFlag == REMOVE_TARGET && !pRefPic->pShortRefList[LIST_0][i]->bRefBaseFlag) - || (eRemoveFlag == REMOVE_BASE && pRefPic->pShortRefList[LIST_0][i]->bRefBaseFlag) - || (eRemoveFlag == REMOVE_BASE_FIRST)) { - iMoveSize = pRefPic->uiShortRefCount[LIST_0] - i - 1; - pRefPic->pShortRefList[LIST_0][i]->bUsedAsRef = false; - pPic = pRefPic->pShortRefList[LIST_0][i]; - pRefPic->pShortRefList[LIST_0][i] = NULL; - if (iMoveSize > 0) { - memmove (&pRefPic->pShortRefList[LIST_0][i], &pRefPic->pShortRefList[LIST_0][i + 1], - iMoveSize * sizeof (PPicture)); //confirmed_safe_unsafe_usage - } - pRefPic->uiShortRefCount[LIST_0]--; - pRefPic->pShortRefList[LIST_0][pRefPic->uiShortRefCount[0]] = NULL; - break; + iMoveSize = pRefPic->uiShortRefCount[LIST_0] - i - 1; + pRefPic->pShortRefList[LIST_0][i]->bUsedAsRef = false; + pPic = pRefPic->pShortRefList[LIST_0][i]; + pRefPic->pShortRefList[LIST_0][i] = NULL; + if (iMoveSize > 0) { + memmove (&pRefPic->pShortRefList[LIST_0][i], &pRefPic->pShortRefList[LIST_0][i + 1], + iMoveSize * sizeof (PPicture)); //confirmed_safe_unsafe_usage } + pRefPic->uiShortRefCount[LIST_0]--; + pRefPic->pShortRefList[LIST_0][pRefPic->uiShortRefCount[0]] = NULL; + break; } } return pPic; } -static PPicture WelsDelShortFromListSetUnref (PRefPic pRefPic, int32_t iFrameNum, ERemoveFlag eRemoveFlag) { - PPicture pPic = WelsDelShortFromList (pRefPic, iFrameNum, eRemoveFlag); +static PPicture WelsDelShortFromListSetUnref (PRefPic pRefPic, int32_t iFrameNum) { + PPicture pPic = WelsDelShortFromList (pRefPic, iFrameNum); if (pPic) { SetUnRef (pPic); } return pPic; } -static PPicture WelsDelLongFromList (PRefPic pRefPic, uint32_t uiLongTermFrameIdx, ERemoveFlag eRemoveFlag) { +static PPicture WelsDelLongFromList (PRefPic pRefPic, uint32_t uiLongTermFrameIdx) { PPicture pPic = NULL; int32_t i = 0; for (i = 0; i < pRefPic->uiLongRefCount[LIST_0]; i++) { pPic = pRefPic->pLongRefList[LIST_0][i]; if (pPic->iLongTermFrameIdx == (int32_t)uiLongTermFrameIdx) { - if (((eRemoveFlag == REMOVE_TARGET) && ! (pPic->bRefBaseFlag)) || ((eRemoveFlag == REMOVE_BASE) - && pPic->bRefBaseFlag)) { - int32_t iMoveSize = pRefPic->uiLongRefCount[LIST_0] - i - 1; - pPic->bUsedAsRef = false; - pPic->bIsLongRef = false; - if (iMoveSize > 0) { - memmove (&pRefPic->pLongRefList[LIST_0][i], &pRefPic->pLongRefList[LIST_0][i + 1], - iMoveSize * sizeof (PPicture)); //confirmed_safe_unsafe_usage - } - pRefPic->uiLongRefCount[LIST_0]--; - pRefPic->pLongRefList[LIST_0][pRefPic->uiLongRefCount[LIST_0]] = NULL; - return pPic; + int32_t iMoveSize = pRefPic->uiLongRefCount[LIST_0] - i - 1; + pPic->bUsedAsRef = false; + pPic->bIsLongRef = false; + if (iMoveSize > 0) { + memmove (&pRefPic->pLongRefList[LIST_0][i], &pRefPic->pLongRefList[LIST_0][i + 1], + iMoveSize * sizeof (PPicture)); //confirmed_safe_unsafe_usage } + pRefPic->uiLongRefCount[LIST_0]--; + pRefPic->pLongRefList[LIST_0][pRefPic->uiLongRefCount[LIST_0]] = NULL; + return pPic; } } return NULL; } -static PPicture WelsDelLongFromListSetUnref (PRefPic pRefPic, uint32_t uiLongTermFrameIdx, ERemoveFlag eRemoveFlag) { - PPicture pPic = WelsDelLongFromList (pRefPic, uiLongTermFrameIdx, eRemoveFlag); +static PPicture WelsDelLongFromListSetUnref (PRefPic pRefPic, uint32_t uiLongTermFrameIdx) { + PPicture pPic = WelsDelLongFromList (pRefPic, uiLongTermFrameIdx); if (pPic) { SetUnRef (pPic); } @@ -528,34 +455,11 @@ static int32_t AddLongTermToList (PRefPic pRefPic, PPicture pPic, int32_t iLongT return ERR_NONE; } -static int32_t AssignLongTermIdx (PRefPic pRefPic, int32_t iFrameNum, int32_t iLongTermFrameIdx) { - PPicture pPic = NULL; - int32_t iRet = ERR_NONE; - WelsDelLongFromListSetUnref (pRefPic, iLongTermFrameIdx, REMOVE_TARGET); - WelsDelLongFromListSetUnref (pRefPic, iLongTermFrameIdx, REMOVE_BASE); - - pPic = WelsDelShortFromList (pRefPic, iFrameNum, REMOVE_TARGET); - if (pPic) { - iRet = AddLongTermToList (pRefPic, pPic, iLongTermFrameIdx); - } else { - return ERR_INFO_INVALID_REF_MARKING; - } - - pPic = NULL; - pPic = WelsDelShortFromList (pRefPic, iFrameNum, REMOVE_BASE); - if (pPic) { - iRet = AddLongTermToList (pRefPic, pPic, iLongTermFrameIdx); - } - - return iRet; -} - static int32_t MarkAsLongTerm (PRefPic pRefPic, int32_t iFrameNum, int32_t iLongTermFrameIdx) { PPicture pPic = NULL; int32_t i = 0; int32_t iRet = ERR_NONE; - WelsDelLongFromListSetUnref (pRefPic, iLongTermFrameIdx, REMOVE_TARGET); - WelsDelLongFromListSetUnref (pRefPic, iLongTermFrameIdx, REMOVE_BASE); + WelsDelLongFromListSetUnref (pRefPic, iLongTermFrameIdx); for (i = 0; i < pRefPic->uiRefCount[LIST_0]; i++) { pPic = pRefPic->pRefList[LIST_0][i];