Skip to content

Commit

Permalink
Fix test failure due to the issue of the previous commit.
Browse files Browse the repository at this point in the history
  • Loading branch information
tyan0 committed Dec 13, 2023
1 parent 10d0998 commit f82abc0
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
14 changes: 7 additions & 7 deletions codec/decoder/core/src/manage_dec_ref.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@ int32_t GetLTRFrameIndex (PRefPic pRefPic, int32_t iAncLTRFrameNum);
#endif
static int32_t RemainOneBufferInDpbForEC (PWelsDecoderContext pCtx, PRefPic pRefPic);

static void SetUnRef (PPicture pRef, bool bNewSeqBegin) {
static void SetUnRef (PPicture pRef) {
if (pRef == NULL) return;

if (pRef->iRefCount <= 0 && (!pRef->bUsedAsRef || bNewSeqBegin)) {
if (pRef->iRefCount <= 0) {
pRef->bUsedAsRef = false;
pRef->bIsLongRef = false;
pRef->iFrameNum = -1;
Expand Down Expand Up @@ -114,15 +114,15 @@ void WelsResetRefPic (PWelsDecoderContext pCtx) {

for (i = 0; i < MAX_DPB_COUNT; i++) {
if (pRefPic->pShortRefList[LIST_0][i] != NULL) {
SetUnRef (pRefPic->pShortRefList[LIST_0][i], pCtx->bNewSeqBegin);
SetUnRef (pRefPic->pShortRefList[LIST_0][i]);
pRefPic->pShortRefList[LIST_0][i] = NULL;
}
}
pRefPic->uiShortRefCount[LIST_0] = 0;

for (i = 0; i < MAX_DPB_COUNT; i++) {
if (pRefPic->pLongRefList[LIST_0][i] != NULL) {
SetUnRef (pRefPic->pLongRefList[LIST_0][i], pCtx->bNewSeqBegin);
SetUnRef (pRefPic->pLongRefList[LIST_0][i]);
pRefPic->pLongRefList[LIST_0][i] = NULL;
}
}
Expand Down Expand Up @@ -770,7 +770,7 @@ static int32_t SlidingWindow (PWelsDecoderContext pCtx, PRefPic pRefPic) {
for (i = pRefPic->uiShortRefCount[LIST_0] - 1; i >= 0; i--) {
pPic = WelsDelShortFromList (pRefPic, pRefPic->pShortRefList[LIST_0][i]->iFrameNum);
if (pPic) {
SetUnRef (pPic, pCtx->bNewSeqBegin);
SetUnRef (pPic);
break;
} else {
return ERR_INFO_INVALID_MMCO_REF_NUM_OVERFLOW;
Expand Down Expand Up @@ -806,7 +806,7 @@ static PPicture WelsDelShortFromList (PRefPic pRefPic, int32_t iFrameNum) {
static PPicture WelsDelShortFromListSetUnref (PRefPic pRefPic, int32_t iFrameNum) {
PPicture pPic = WelsDelShortFromList (pRefPic, iFrameNum);
if (pPic) {
SetUnRef (pPic, false);
SetUnRef (pPic);
}
return pPic;
}
Expand Down Expand Up @@ -835,7 +835,7 @@ static PPicture WelsDelLongFromList (PRefPic pRefPic, uint32_t uiLongTermFrameId
static PPicture WelsDelLongFromListSetUnref (PRefPic pRefPic, uint32_t uiLongTermFrameIdx) {
PPicture pPic = WelsDelLongFromList (pRefPic, uiLongTermFrameIdx);
if (pPic) {
SetUnRef (pPic, false);
SetUnRef (pPic);
}
return pPic;
}
Expand Down
9 changes: 7 additions & 2 deletions codec/decoder/plus/src/welsDecoderExt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1083,8 +1083,9 @@ void CWelsDecoder::ReleaseBufferedReadyPictureReorder (PWelsDecoderContext pCtx,
m_sPictInfoList[m_sReoderingStatus.iPictInfoIndex].iPOC = IMinInt32;
if (pPicBuff != NULL) {
PPicture pPic = pPicBuff->ppPic[m_sPictInfoList[m_sReoderingStatus.iPictInfoIndex].iPicBuffIdx];
bool bLastGOP = m_sPictInfoList[m_sReoderingStatus.iPictInfoIndex].bLastGOP;
--pPic->iRefCount;
if (m_sPictInfoList[m_sReoderingStatus.iPictInfoIndex].bLastGOP)
if (pPic->iRefCount <= 0 && bLastGOP)
pPic->bUsedAsRef = false;
}
m_sPictInfoList[m_sReoderingStatus.iPictInfoIndex].bLastGOP = false;
Expand Down Expand Up @@ -1141,7 +1142,10 @@ void CWelsDecoder::ReleaseBufferedReadyPictureReorder (PWelsDecoderContext pCtx,
if (iPicBuffIdx >= 0 && iPicBuffIdx < pPicBuff->iCapacity)
{
PPicture pPic = pPicBuff->ppPic[iPicBuffIdx];
bool bLastGOP = m_sPictInfoList[m_sReoderingStatus.iPictInfoIndex].bLastGOP;
--pPic->iRefCount;
if (pPic->iRefCount <= 0 && bLastGOP)
pPic->bUsedAsRef = false;
}
}
m_sPictInfoList[m_sReoderingStatus.iPictInfoIndex].bLastGOP = false;
Expand Down Expand Up @@ -1188,8 +1192,9 @@ void CWelsDecoder::ReleaseBufferedReadyPictureNoReorder(PWelsDecoderContext pCtx
if (pCtx || m_pPicBuff) {
PPicBuff pPicBuff = pCtx ? pCtx->pPicBuff : m_pPicBuff;
PPicture pPic = pPicBuff->ppPic[m_sPictInfoList[m_sReoderingStatus.iPictInfoIndex].iPicBuffIdx];
bool bLastGOP = m_sPictInfoList[m_sReoderingStatus.iPictInfoIndex].bLastGOP;
--pPic->iRefCount;
if (m_sPictInfoList[m_sReoderingStatus.iPictInfoIndex].bLastGOP)
if (pPic->iRefCount <= 0 && bLastGOP)
pPic->bUsedAsRef = false;
}
if (m_sPictInfoList[m_sReoderingStatus.iPictInfoIndex].bLastGOP) {
Expand Down

0 comments on commit f82abc0

Please sign in to comment.