[FFmpeg-devel] [PATCH 2/2] avcdec: move setting decode_error_flags from h264 decoder to error concealment code

Michael Niedermayer michael at niedermayer.cc
Mon May 24 23:43:55 EEST 2021


This should fix some minor race condition
Untested (no testcase, the flag is not tested by fate)

Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>
---
 libavcodec/error_resilience.c | 3 +++
 libavcodec/h264dec.c          | 5 -----
 2 files changed, 3 insertions(+), 5 deletions(-)

diff --git a/libavcodec/error_resilience.c b/libavcodec/error_resilience.c
index 68bc10ac31..e880efcc51 100644
--- a/libavcodec/error_resilience.c
+++ b/libavcodec/error_resilience.c
@@ -907,6 +907,9 @@ void ff_er_frame_end(ERContext *s)
     int is_intra_likely;
     int size = s->b8_stride * 2 * s->mb_height;
 
+    if (s->error_occurred && s->cur_pic.f)
+        s->cur_pic.f->decode_error_flags |= FF_DECODE_ERROR_DECODE_SLICES;
+
     /* We do not support ER of field pictures yet,
      * though it should not crash if enabled. */
     if (!s->avctx->error_concealment || !atomic_load(&s->error_count)  ||
diff --git a/libavcodec/h264dec.c b/libavcodec/h264dec.c
index 38f8967265..05e46cb456 100644
--- a/libavcodec/h264dec.c
+++ b/libavcodec/h264dec.c
@@ -716,11 +716,6 @@ static int decode_nal_units(H264Context *h, const uint8_t *buf, int buf_size)
     if (ret < 0 && (h->avctx->err_recognition & AV_EF_EXPLODE))
         goto end;
 
-    // set decode_error_flags to allow users to detect concealed decoding errors
-    if ((ret < 0 || h->slice_ctx->er.error_occurred) && h->cur_pic_ptr) {
-        h->cur_pic_ptr->f->decode_error_flags |= FF_DECODE_ERROR_DECODE_SLICES;
-    }
-
     ret = 0;
 end:
 
-- 
2.17.1



More information about the ffmpeg-devel mailing list