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/h264_picture.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/h264_picture.c')
-rw-r--r-- | libavcodec/h264_picture.c | 19 |
1 files changed, 5 insertions, 14 deletions
diff --git a/libavcodec/h264_picture.c b/libavcodec/h264_picture.c index 25d0d96ddb..9353e4b445 100644 --- a/libavcodec/h264_picture.c +++ b/libavcodec/h264_picture.c @@ -46,7 +46,7 @@ void ff_h264_unref_picture(H264Context *h, H264Picture *pic) ff_thread_release_ext_buffer(h->avctx, &pic->tf); ff_thread_release_buffer(h->avctx, pic->f_grain); - av_buffer_unref(&pic->hwaccel_priv_buf); + ff_refstruct_unref(&pic->hwaccel_picture_private); av_buffer_unref(&pic->qscale_table_buf); av_buffer_unref(&pic->mb_type_buf); @@ -129,14 +129,8 @@ int ff_h264_ref_picture(H264Context *h, H264Picture *dst, H264Picture *src) } } - if (src->hwaccel_picture_private) { - dst->hwaccel_priv_buf = av_buffer_ref(src->hwaccel_priv_buf); - if (!dst->hwaccel_priv_buf) { - ret = AVERROR(ENOMEM); - goto fail; - } - dst->hwaccel_picture_private = dst->hwaccel_priv_buf->data; - } + ff_refstruct_replace(&dst->hwaccel_picture_private, + src->hwaccel_picture_private); ret = av_buffer_replace(&dst->decode_error_flags, src->decode_error_flags); if (ret < 0) @@ -185,11 +179,8 @@ int ff_h264_replace_picture(H264Context *h, H264Picture *dst, const H264Picture goto fail; } - ret = av_buffer_replace(&dst->hwaccel_priv_buf, src->hwaccel_priv_buf); - if (ret < 0) - goto fail; - - dst->hwaccel_picture_private = src->hwaccel_picture_private; + ff_refstruct_replace(&dst->hwaccel_picture_private, + src->hwaccel_picture_private); ret = av_buffer_replace(&dst->decode_error_flags, src->decode_error_flags); if (ret < 0) |