ref: 2dd41096d50429cd6c90dafcb3d2f1e16d07a43b
parent: 3d47b7847d6e8a6f5c186f87d40058c839234995
parent: e902f0fea45e95a2e4f9aa5a62559bba4a557690
author: huili2 <huili2@cisco.com>
date: Fri Feb 28 09:08:41 EST 2014
Merge pull request #366 from licaiguo/refine-rpl-pr refine rpl
--- a/codec/decoder/core/src/decoder_core.cpp
+++ b/codec/decoder/core/src/decoder_core.cpp
@@ -1993,7 +1993,11 @@
}
if (uiNalRefIdc > 0) {
- WelsMarkAsRef (pCtx);
+ iRet = WelsMarkAsRef (pCtx);
+ if (iRet != ERR_NONE) {
+ pCtx->pDec = NULL;
+ return iRet;
+ }
ExpandReferencingPicture (pCtx->pDec, pCtx->sExpandPicFunc.pExpandLumaPicture,
pCtx->sExpandPicFunc.pExpandChromaPicture);
pCtx->pDec = NULL;
--- a/codec/decoder/core/src/manage_dec_ref.cpp
+++ b/codec/decoder/core/src/manage_dec_ref.cpp
@@ -79,7 +79,7 @@
void WelsResetRefPic (PWelsDecoderContext pCtx) {
int32_t i = 0;
PRefPic pRefPic = &pCtx->sRefPic;
- pCtx->sRefPic.uiLongRefCount[0] = pCtx->sRefPic.uiShortRefCount[0] = 0;
+ pCtx->sRefPic.uiLongRefCount[LIST_0] = pCtx->sRefPic.uiShortRefCount[LIST_0] = 0;
pRefPic->uiRefCount[LIST_0] = 0;
@@ -104,7 +104,7 @@
* fills the pRefPic.pRefList.
*/
int32_t WelsInitRefList (PWelsDecoderContext pCtx, int32_t iPoc) {
- int32_t i, j, iCount = 0;
+ int32_t i, iCount = 0;
const bool kbUseRefBasePicFlag = pCtx->pCurDqLayer->bUseRefBasePicFlag;
PPicture* ppShoreRefList = pCtx->sRefPic.pShortRefList[LIST_0];
PPicture* ppLongRefList = pCtx->sRefPic.pLongRefList[LIST_0];
@@ -115,7 +115,6 @@
}
//long
- j = 0;
for (i = 0; i < pCtx->sRefPic.uiLongRefCount[LIST_0] ; ++i) {
pCtx->sRefPic.pRefList[LIST_0][iCount++ ] = ppLongRefList[i];
}
@@ -235,19 +234,24 @@
} else {
if (pRefPicMarking->bAdaptiveRefPicMarkingModeFlag) {
iRet = MMCO (pCtx, pRefPicMarking);
+ if (iRet != ERR_NONE)
+ return iRet;
if (pCtx->bLastHasMmco5) {
pCtx->pDec->iFrameNum = 0;
pCtx->pDec->iFramePoc = 0;
}
- if (pRefPic->uiLongRefCount[LIST_0] + pRefPic->uiShortRefCount[LIST_0] > pCtx->pSps->iNumRefFrames) {
- return ERR_INFO_INVALID_MMCO_REF_NUM_OVERFLOW;
- }
+
} else {
iRet = SlidingWindow (pCtx);
+ if (iRet != ERR_NONE)
+ return iRet;
}
}
if (!pCtx->pDec->bIsLongRef) {
+ if (pRefPic->uiLongRefCount[LIST_0] + pRefPic->uiShortRefCount[LIST_0] >= WELS_MAX(1,pCtx->pSps->iNumRefFrames)) {
+ return ERR_INFO_INVALID_MMCO_REF_NUM_OVERFLOW;
+ }
AddShortTermToList (pRefPic, pCtx->pDec);
}
@@ -286,9 +290,15 @@
switch (uiMmcoType) {
case MMCO_SHORT2UNUSED:
pPic = WelsDelShortFromListSetUnref (pRefPic, iShortFrameNum);
+ if (pPic == NULL) {
+ WelsLog (pCtx, WELS_LOG_WARNING, "MMCO_SHORT2UNUSED: delete a empty entry from short term list\n");
+ }
break;
case MMCO_LONG2UNUSED:
pPic = WelsDelLongFromListSetUnref (pRefPic, uiLongTermPicNum);
+ if (pPic == NULL) {
+ WelsLog (pCtx, WELS_LOG_WARNING, "MMCO_LONG2UNUSED: delete a empty entry from long term list\n");
+ }
break;
case MMCO_SHORT2LONG:
if (iLongTermFrameIdx > pRefPic->iMaxLongTermFrameIdx) {
@@ -295,6 +305,10 @@
return ERR_INFO_INVALID_MMCO_LONG_TERM_IDX_EXCEED_MAX;
}
pPic = WelsDelShortFromList (pRefPic, iShortFrameNum);
+ if (pPic == NULL) {
+ WelsLog (pCtx, WELS_LOG_WARNING, "MMCO_LONG2LONG: delete a empty entry from short term list\n");
+ break;
+ }
WelsDelLongFromListSetUnref (pRefPic, iLongTermFrameIdx);
#ifdef LONG_TERM_REF
pCtx->bCurAuContainLtrMarkSeFlag = true;
@@ -327,6 +341,9 @@
WelsLog (pCtx, WELS_LOG_INFO, "ex_mark_avc():::MMCO_LONG:::LTR marking....iFrameNum: %d\n", pCtx->iFrameNum);
#endif
WelsDelLongFromListSetUnref (pRefPic, iLongTermFrameIdx);
+ if (pRefPic->uiLongRefCount[LIST_0] + pRefPic->uiShortRefCount[LIST_0] >= WELS_MAX(1,pCtx->pSps->iNumRefFrames)) {
+ return ERR_INFO_INVALID_MMCO_REF_NUM_OVERFLOW;
+ }
iRet = AddLongTermToList (pRefPic, pCtx->pDec, iLongTermFrameIdx);
break;
default :
@@ -371,7 +388,7 @@
iMoveSize * sizeof (PPicture)); //confirmed_safe_unsafe_usage
}
pRefPic->uiShortRefCount[LIST_0]--;
- pRefPic->pShortRefList[LIST_0][pRefPic->uiShortRefCount[0]] = NULL;
+ pRefPic->pShortRefList[LIST_0][pRefPic->uiShortRefCount[LIST_0]] = NULL;
break;
}
}
@@ -437,7 +454,7 @@
pPic->iLongTermFrameIdx = iLongTermFrameIdx;
if (pRefPic->uiLongRefCount[LIST_0] == 0) {
pRefPic->pLongRefList[LIST_0][pRefPic->uiLongRefCount[LIST_0]] = pPic;
- } else if (pRefPic->uiLongRefCount[LIST_0] > 0) {
+ } else {
for (i = 0; i < pRefPic->uiLongRefCount[LIST_0]; i++) {
if (pRefPic->pLongRefList[LIST_0][i]->iLongTermFrameIdx > pPic->iLongTermFrameIdx) {
break;
@@ -446,11 +463,8 @@
memmove (&pRefPic->pLongRefList[LIST_0][i + 1], &pRefPic->pLongRefList[LIST_0][i],
(pRefPic->uiLongRefCount[LIST_0] - i)*sizeof (PPicture)); //confirmed_safe_unsafe_usage
pRefPic->pLongRefList[LIST_0][i] = pPic;
- } else {
- return ERR_INFO_REF_COUNT_OVERFLOW;
}
-
pRefPic->uiLongRefCount[LIST_0]++;
return ERR_NONE;
}
@@ -465,6 +479,7 @@
pPic = pRefPic->pRefList[LIST_0][i];
if (pPic->iFrameNum == iFrameNum && !pPic->bIsLongRef) {
iRet = AddLongTermToList (pRefPic, pPic, iLongTermFrameIdx);
+ break;
}
}