[FFmpeg-devel] [PATCH 1/2] avcodec/pthread_frame: Remove ff_thread_release_buffer()

Anton Khirnov anton at khirnov.net
Fri Oct 20 18:23:29 EEST 2023


Quoting Andreas Rheinhardt (2023-10-20 16:33:06)
> diff --git a/libavcodec/av1dec.c b/libavcodec/av1dec.c
> index c02408548c..1a4339b346 100644
> --- a/libavcodec/av1dec.c
> +++ b/libavcodec/av1dec.c
> @@ -636,9 +636,9 @@ static int get_pixel_format(AVCodecContext *avctx)
>      return 0;
>  }
>  
> -static void av1_frame_unref(AVCodecContext *avctx, AV1Frame *f)
> +static void av1_frame_unref(AV1Frame *f)
>  {
> -    ff_thread_release_buffer(avctx, f->f);
> +    av_frame_unref(f->f);
>      ff_refstruct_unref(&f->hwaccel_picture_private);
>      ff_refstruct_unref(&f->header_ref);
>      f->raw_frame_header = NULL;
> @@ -689,7 +689,7 @@ static int av1_frame_ref(AVCodecContext *avctx, AV1Frame *dst, const AV1Frame *s
>      return 0;
>  
>  fail:
> -    av1_frame_unref(avctx, dst);
> +    av1_frame_unref(dst);
>      return AVERROR(ENOMEM);
>  }
>  
> @@ -699,12 +699,15 @@ static av_cold int av1_decode_free(AVCodecContext *avctx)
>      AV1RawMetadataITUTT35 itut_t35;
>  
>      for (int i = 0; i < FF_ARRAY_ELEMS(s->ref); i++) {
> -        av1_frame_unref(avctx, &s->ref[i]);
> -        av_frame_free(&s->ref[i].f);
> +        if (s->ref[i].f) {

Wouldn't it be simpler and more consistent to check for the frame's
existence in av1_frame_unref()?

> +            av1_frame_unref(&s->ref[i]);
> +            av_frame_free(&s->ref[i].f);
> +        }
> +    }
> +    if (s->cur_frame.f) {
> +        av1_frame_unref(&s->cur_frame);
> +        av_frame_free(&s->cur_frame.f);
>      }
> -    av1_frame_unref(avctx, &s->cur_frame);
> -    av_frame_free(&s->cur_frame.f);
> -
>      ff_refstruct_unref(&s->seq_ref);
>      ff_refstruct_unref(&s->header_ref);
>      ff_refstruct_unref(&s->cll_ref);

LGTM otherwise.

-- 
Anton Khirnov


More information about the ffmpeg-devel mailing list