diff options
author | Andreas Rheinhardt <andreas.rheinhardt@outlook.com> | 2022-08-04 16:21:03 +0200 |
---|---|---|
committer | Andreas Rheinhardt <andreas.rheinhardt@outlook.com> | 2023-10-07 22:35:22 +0200 |
commit | f8252d6ce3ff7f306f7f7689c8c1c0c02126c70d (patch) | |
tree | e37bed3b2eea908606c9950c631bb988708b4a73 /libavcodec/av1dec.c | |
parent | 3ba4f9c21e8bd78386738324d8767d74d75eec53 (diff) | |
download | ffmpeg-f8252d6ce3ff7f306f7f7689c8c1c0c02126c70d.tar.gz |
avcodec/decode: Use RefStruct API for hwaccel_picture_private
Avoids allocations and therefore error checks: Syncing
hwaccel_picture_private across threads can't fail any more.
Also gets rid of an unnecessary pointer in structures and
in the parameter list of ff_hwaccel_frame_priv_alloc().
Reviewed-by: Anton Khirnov <anton@khirnov.net>
Reviewed-by: Lynne <dev@lynne.ee>
Tested-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Diffstat (limited to 'libavcodec/av1dec.c')
-rw-r--r-- | libavcodec/av1dec.c | 15 |
1 files changed, 4 insertions, 11 deletions
diff --git a/libavcodec/av1dec.c b/libavcodec/av1dec.c index 87056520dd..c02408548c 100644 --- a/libavcodec/av1dec.c +++ b/libavcodec/av1dec.c @@ -27,7 +27,6 @@ #include "libavutil/opt.h" #include "avcodec.h" #include "av1_parse.h" -#include "decode.h" #include "av1dec.h" #include "atsc_a53.h" #include "bytestream.h" @@ -640,8 +639,7 @@ static int get_pixel_format(AVCodecContext *avctx) static void av1_frame_unref(AVCodecContext *avctx, AV1Frame *f) { ff_thread_release_buffer(avctx, f->f); - av_buffer_unref(&f->hwaccel_priv_buf); - f->hwaccel_picture_private = NULL; + ff_refstruct_unref(&f->hwaccel_picture_private); ff_refstruct_unref(&f->header_ref); f->raw_frame_header = NULL; f->spatial_id = f->temporal_id = 0; @@ -666,12 +664,8 @@ static int av1_frame_ref(AVCodecContext *avctx, AV1Frame *dst, const AV1Frame *s if (ret < 0) goto fail; - if (src->hwaccel_picture_private) { - dst->hwaccel_priv_buf = av_buffer_ref(src->hwaccel_priv_buf); - if (!dst->hwaccel_priv_buf) - goto fail; - dst->hwaccel_picture_private = dst->hwaccel_priv_buf->data; - } + ff_refstruct_replace(&dst->hwaccel_picture_private, + src->hwaccel_picture_private); dst->spatial_id = src->spatial_id; dst->temporal_id = src->temporal_id; @@ -915,8 +909,7 @@ static int av1_frame_alloc(AVCodecContext *avctx, AV1Frame *f) break; } - ret = ff_hwaccel_frame_priv_alloc(avctx, &f->hwaccel_picture_private, - &f->hwaccel_priv_buf); + ret = ff_hwaccel_frame_priv_alloc(avctx, &f->hwaccel_picture_private); if (ret < 0) goto fail; |