Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Frame decode error. #3710

Open
tyan0 opened this issue Dec 8, 2023 · 1 comment
Open

Frame decode error. #3710

tyan0 opened this issue Dec 8, 2023 · 1 comment

Comments

@tyan0
Copy link
Contributor

tyan0 commented Dec 8, 2023

Frame decode error occurs if playing the following video file.
https://tyan0.yr32.net/openh264/decode_frame_error.mp4

I am not sure this is the right thing, but the following patch solves the issue.

diff --git a/codec/decoder/core/src/manage_dec_ref.cpp b/codec/decoder/core/src/manage_dec_ref.cpp
index c3c98312..8281b087 100644
--- a/codec/decoder/core/src/manage_dec_ref.cpp
+++ b/codec/decoder/core/src/manage_dec_ref.cpp
@@ -460,7 +460,8 @@ int32_t WelsReorderRefList (PWelsDecoderContext pCtx) {
           }
         }
         if (i < 0) {
-          return ERR_INFO_REFERENCE_PIC_LOST;
+          iReorderingIndex++;
+          continue;
         }
         pPic = ppRefList[i];
         if (i > iReorderingIndex) {

Could maintainer please have a look?


Edit: patch revised. (11 Dec 2023)

@tyan0
Copy link
Contributor Author

tyan0 commented Dec 12, 2023

Sorry, I noticed above patch causes test failure. I'd like to propose alternative fix below.
New patch enables the function WelsReorderRefList2() which was introduced by the commit 1b8caef, and fixes trivial issue of that function. The two patches are completely different, but, both solve the issue.

diff --git a/codec/decoder/core/src/decoder_core.cpp b/codec/decoder/core/src/decoder_core.cpp
index 106d0d41..48e03a0d 100644
--- a/codec/decoder/core/src/decoder_core.cpp
+++ b/codec/decoder/core/src/decoder_core.cpp
@@ -2432,7 +2432,7 @@ int32_t InitRefPicList (PWelsDecoderContext pCtx, const uint8_t kuiNRi, int32_t
   } else
     iRet = WelsInitRefList (pCtx, iPoc);
   if ((pCtx->eSliceType != I_SLICE && pCtx->eSliceType != SI_SLICE)) {
-#if 0
+#if 1
     if (pCtx->pSps->uiProfileIdc != 66 && pCtx->pPps->bEntropyCodingModeFlag)
       iRet = WelsReorderRefList2 (pCtx);
     else
diff --git a/codec/decoder/core/src/manage_dec_ref.cpp b/codec/decoder/core/src/manage_dec_ref.cpp
index 410b9c47..fe3e033a 100644
--- a/codec/decoder/core/src/manage_dec_ref.cpp
+++ b/codec/decoder/core/src/manage_dec_ref.cpp
@@ -495,7 +495,10 @@ int32_t WelsReorderRefList2 (PWelsDecoderContext pCtx) {
   int32_t i = 0;
   int32_t j = 0;
   int32_t k = 0;
-  int32_t iMaxRefIdx = pCtx->pSps->iNumRefFrames;
+  int32_t iMaxRefIdx = pCtx->iPicQueueNumber;
+  if (iMaxRefIdx > MAX_REF_PIC_COUNT) {
+    iMaxRefIdx = MAX_REF_PIC_COUNT;
+  }
   const int32_t iCurFrameNum = pSliceHeader->iFrameNum;
   const int32_t iMaxPicNum = 1 << pSliceHeader->pSps->uiLog2MaxFrameNum;
   int32_t iListCount = 1;

This was referenced Jan 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant