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 17, 2023
1 parent 10d0998 commit 58658ef
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 21 deletions.
1 change: 1 addition & 0 deletions codec/decoder/core/inc/picture.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ struct SPicture {
bool bUsedAsRef; //for ref pic management
bool bIsLongRef; // long term reference frame flag //for ref pic management
int8_t iRefCount;
void (*pSetUnRef)(WelsDec::SPicture*);

bool bIsComplete; // indicate whether current picture is complete, not from EC
/*******************************for future use****************************/
Expand Down
2 changes: 2 additions & 0 deletions codec/decoder/core/src/decoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ static int32_t IncreasePicBuff (PWelsDecoderContext pCtx, PPicBuff* ppPicBuf, co
pPicNewBuf->ppPic[i]->bUsedAsRef = false;
pPicNewBuf->ppPic[i]->bIsLongRef = false;
pPicNewBuf->ppPic[i]->iRefCount = 0;
pPicNewBuf->ppPic[i]->pSetUnRef = NULL;
pPicNewBuf->ppPic[i]->bIsComplete = false;
}
// remove old PicBuf
Expand Down Expand Up @@ -240,6 +241,7 @@ static int32_t DecreasePicBuff (PWelsDecoderContext pCtx, PPicBuff* ppPicBuf, co
pPicNewBuf->ppPic[i]->bUsedAsRef = false;
pPicNewBuf->ppPic[i]->bIsLongRef = false;
pPicNewBuf->ppPic[i]->iRefCount = 0;
pPicNewBuf->ppPic[i]->pSetUnRef = NULL;
pPicNewBuf->ppPic[i]->bIsComplete = false;
}
// remove old PicBuf
Expand Down
33 changes: 16 additions & 17 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 All @@ -83,20 +83,19 @@ static void SetUnRef (PPicture pRef, bool bNewSeqBegin) {
pRef->iSpsId = -1;
pRef->bIsComplete = false;
pRef->iRefCount = 0;
}
pRef->pSetUnRef = NULL;

if (pRef->eSliceType == I_SLICE) {
return;
}
int32_t lists = pRef->eSliceType == P_SLICE ? 1 : 2;
for (int32_t i = 0; i < MAX_DPB_COUNT; ++i) {
for (int32_t list = 0; list < lists; ++list) {
if (pRef->pRefPic[list][i] != NULL) {
if (pRef->pRefPic[list][i]->iRefCount > 0) continue;
pRef->pRefPic[list][i]->iRefCount = 0;
if (pRef->eSliceType == I_SLICE) {
return;
}
int32_t lists = pRef->eSliceType == P_SLICE ? 1 : 2;
for (int32_t i = 0; i < MAX_DPB_COUNT; ++i) {
for (int32_t list = 0; list < lists; ++list) {
pRef->pRefPic[list][i] = NULL;
}
}
} else {
pRef->pSetUnRef = SetUnRef;
}
}

Expand All @@ -114,15 +113,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 +769,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 +805,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 +834,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
10 changes: 6 additions & 4 deletions codec/decoder/plus/src/welsDecoderExt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1084,8 +1084,8 @@ void CWelsDecoder::ReleaseBufferedReadyPictureReorder (PWelsDecoderContext pCtx,
if (pPicBuff != NULL) {
PPicture pPic = pPicBuff->ppPic[m_sPictInfoList[m_sReoderingStatus.iPictInfoIndex].iPicBuffIdx];
--pPic->iRefCount;
if (m_sPictInfoList[m_sReoderingStatus.iPictInfoIndex].bLastGOP)
pPic->bUsedAsRef = false;
if (pPic->iRefCount <= 0 && pPic->pSetUnRef)
pPic->pSetUnRef(pPic);
}
m_sPictInfoList[m_sReoderingStatus.iPictInfoIndex].bLastGOP = false;
m_sReoderingStatus.iMinPOC = IMinInt32;
Expand Down Expand Up @@ -1142,6 +1142,8 @@ void CWelsDecoder::ReleaseBufferedReadyPictureReorder (PWelsDecoderContext pCtx,
{
PPicture pPic = pPicBuff->ppPic[iPicBuffIdx];
--pPic->iRefCount;
if (pPic->iRefCount <= 0 && pPic->pSetUnRef)
pPic->pSetUnRef(pPic);
}
}
m_sPictInfoList[m_sReoderingStatus.iPictInfoIndex].bLastGOP = false;
Expand Down Expand Up @@ -1189,8 +1191,8 @@ void CWelsDecoder::ReleaseBufferedReadyPictureNoReorder(PWelsDecoderContext pCtx
PPicBuff pPicBuff = pCtx ? pCtx->pPicBuff : m_pPicBuff;
PPicture pPic = pPicBuff->ppPic[m_sPictInfoList[m_sReoderingStatus.iPictInfoIndex].iPicBuffIdx];
--pPic->iRefCount;
if (m_sPictInfoList[m_sReoderingStatus.iPictInfoIndex].bLastGOP)
pPic->bUsedAsRef = false;
if (pPic->iRefCount <= 0 && pPic->pSetUnRef)
pPic->pSetUnRef(pPic);
}
if (m_sPictInfoList[m_sReoderingStatus.iPictInfoIndex].bLastGOP) {
--m_sReoderingStatus.iLastGOPRemainPicts;
Expand Down

0 comments on commit 58658ef

Please sign in to comment.