ref: c24c967c65e652bdbdc39800f1f1e7261ff067f7
parent: 4f527a0fb6ce8c96e431fc9323c99eb95fc40540
author: Haibo Zhu <[email protected]>
date: Wed Apr 22 15:58:39 EDT 2015
Fix the possible infinite loop bug and Fix the judgement condition
--- a/codec/decoder/core/src/manage_dec_ref.cpp
+++ b/codec/decoder/core/src/manage_dec_ref.cpp
@@ -423,6 +423,10 @@
int32_t i = 0;
if (pCtx->sRefPic.uiShortRefCount[LIST_0] + pCtx->sRefPic.uiLongRefCount[LIST_0] >= pCtx->pSps->iNumRefFrames) {
+ if (pCtx->sRefPic.uiShortRefCount[LIST_0] == 0) {
+ WelsLog (& (pCtx->sLogCtx), WELS_LOG_ERROR, "No reference picture in short term list when sliding window");
+ return ERR_INFO_INVALID_MMCO_REF_NUM_NOT_ENOUGH;
+ }
for (i = pRefPic->uiShortRefCount[LIST_0] - 1; i >= 0; i--) {
pPic = WelsDelShortFromList (pRefPic, pRefPic->pShortRefList[LIST_0][i]->iFrameNum);
if (pPic) {
@@ -573,20 +577,20 @@
if (pRefPic->uiShortRefCount[0] > 0) {
iRet = SlidingWindow (pCtx);
} else { //all LTR, remove the smallest long_term_frame_idx
- uint32_t uiLongTermFrameIdx = 0;
- uint32_t uiMaxLongTermFrameIdx = pRefPic->iMaxLongTermFrameIdx;
+ int32_t iLongTermFrameIdx = 0;
+ int32_t iMaxLongTermFrameIdx = pRefPic->iMaxLongTermFrameIdx;
#ifdef LONG_TERM_REF
- uint32_t uiCurrLTRFrameIdx = GetLTRFrameIndex (pRefPic, pCtx->iFrameNumOfAuMarkedLtr);
+ int32_t iCurrLTRFrameIdx = GetLTRFrameIndex (pRefPic, pCtx->iFrameNumOfAuMarkedLtr);
#endif
- while ((pRefPic->uiLongRefCount[0] >= pCtx->pSps->iNumRefFrames) && (uiLongTermFrameIdx <= uiMaxLongTermFrameIdx)) {
+ while ((pRefPic->uiLongRefCount[0] >= pCtx->pSps->iNumRefFrames) && (iLongTermFrameIdx <= iMaxLongTermFrameIdx)) {
#ifdef LONG_TERM_REF
- if (uiLongTermFrameIdx == uiCurrLTRFrameIdx) {
- uiLongTermFrameIdx++;
+ if (iLongTermFrameIdx == iCurrLTRFrameIdx) {
+ iLongTermFrameIdx++;
continue;
}
#endif
- WelsDelLongFromListSetUnref (pRefPic, uiLongTermFrameIdx);
- uiLongTermFrameIdx++;
+ WelsDelLongFromListSetUnref (pRefPic, iLongTermFrameIdx);
+ iLongTermFrameIdx++;
}
}
if (pRefPic->uiShortRefCount[0] + pRefPic->uiLongRefCount[0] >=