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

James Almer jamrial at gmail.com
Mon May 31 16:52:36 EEST 2021


On 5/24/2021 5:43 PM, Michael Niedermayer wrote:
> 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 is accessed unconditionally right below this chunk, so no 
need for that check.

> +        s->cur_pic.f->decode_error_flags |= FF_DECODE_ERROR_DECODE_SLICES;

You may want to merge or group setting this flag with the 
FF_DECODE_ERROR_CONCEALMENT_ACTIVE one a couple hundred lines into the 
function.

> +
>       /* 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:
>   
> 



More information about the ffmpeg-devel mailing list