Skip to content

Commit fa6d099

Browse files
authored
Fix frame-decode errors. (#3723)
* Enable ReorderRefList2() which was added by the commit 1b8caef. ... and fix trivial issue of that function. This solves the some frame decode error. * Add workaround for frame decode error due to emulation byte. * Fix a bug which seems due to a typo in WelsReorderRefList2() This fixes the fuzzing test failure. Addresses: #3772
1 parent e0bbb7f commit fa6d099

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

codec/decoder/core/src/decoder.cpp

+3-4
Original file line numberDiff line numberDiff line change
@@ -797,14 +797,13 @@ int32_t WelsDecodeBs (PWelsDecoderContext pCtx, const uint8_t* kpBsBuf, const in
797797
bNalStartBytes = true;
798798
} else if (pSrcNal[2 + iSrcIdx] == 0x03) {
799799
if ((3 + iSrcConsumed < iSrcLength) && pSrcNal[3 + iSrcIdx] > 0x03) {
800-
pCtx->iErrorCode |= dsBitstreamError;
801-
return pCtx->iErrorCode;
800+
/* Just skip */
802801
} else {
803802
ST16 (pDstNal + iDstIdx, 0);
804803
iDstIdx += 2;
805-
iSrcIdx += 3;
806-
iSrcConsumed += 3;
807804
}
805+
iSrcIdx += 3;
806+
iSrcConsumed += 3;
808807
} else { // 0x01
809808
bNalStartBytes = false;
810809

codec/decoder/core/src/decoder_core.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -2440,7 +2440,7 @@ int32_t InitRefPicList (PWelsDecoderContext pCtx, const uint8_t kuiNRi, int32_t
24402440
} else
24412441
iRet = WelsInitRefList (pCtx, iPoc);
24422442
if ((pCtx->eSliceType != I_SLICE && pCtx->eSliceType != SI_SLICE)) {
2443-
#if 0
2443+
#if 1
24442444
if (pCtx->pSps->uiProfileIdc != 66 && pCtx->pPps->bEntropyCodingModeFlag)
24452445
iRet = WelsReorderRefList2 (pCtx);
24462446
else

codec/decoder/core/src/manage_dec_ref.cpp

+5-2
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,10 @@ int32_t WelsReorderRefList2 (PWelsDecoderContext pCtx) {
494494
int32_t i = 0;
495495
int32_t j = 0;
496496
int32_t k = 0;
497-
int32_t iMaxRefIdx = pCtx->pSps->iNumRefFrames;
497+
int32_t iMaxRefIdx = pCtx->iPicQueueNumber;
498+
if (iMaxRefIdx > MAX_REF_PIC_COUNT) {
499+
iMaxRefIdx = MAX_REF_PIC_COUNT;
500+
}
498501
const int32_t iCurFrameNum = pSliceHeader->iFrameNum;
499502
const int32_t iMaxPicNum = 1 << pSliceHeader->pSps->uiLog2MaxFrameNum;
500503
int32_t iListCount = 1;
@@ -563,7 +566,7 @@ int32_t WelsReorderRefList2 (PWelsDecoderContext pCtx) {
563566
k = iCount;
564567
for (j = k; j <= iRefCount; j++) {
565568
if (ppRefList[j] != NULL) {
566-
if (!ppRefList[j]->bIsLongRef || ppLongRefList[j]->uiLongTermPicNum != (uint32_t)iPredFrameNum)
569+
if (!ppRefList[j]->bIsLongRef || ppRefList[j]->uiLongTermPicNum != (uint32_t)iPredFrameNum)
567570
ppRefList[k++] = ppRefList[j];
568571
}
569572
}

0 commit comments

Comments
 (0)