aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/vp9.c
diff options
context:
space:
mode:
authorAndreas Rheinhardt <andreas.rheinhardt@outlook.com>2022-08-04 16:21:03 +0200
committerAndreas Rheinhardt <andreas.rheinhardt@outlook.com>2023-10-07 22:35:22 +0200
commitf8252d6ce3ff7f306f7f7689c8c1c0c02126c70d (patch)
treee37bed3b2eea908606c9950c631bb988708b4a73 /libavcodec/vp9.c
parent3ba4f9c21e8bd78386738324d8767d74d75eec53 (diff)
downloadffmpeg-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/vp9.c')
-rw-r--r--libavcodec/vp9.c15
1 files changed, 5 insertions, 10 deletions
diff --git a/libavcodec/vp9.c b/libavcodec/vp9.c
index 3cc27aa812..c9cc81ec94 100644
--- a/libavcodec/vp9.c
+++ b/libavcodec/vp9.c
@@ -30,6 +30,7 @@
#include "hwaccel_internal.h"
#include "hwconfig.h"
#include "profiles.h"
+#include "refstruct.h"
#include "thread.h"
#include "threadframe.h"
#include "pthread_internal.h"
@@ -100,9 +101,8 @@ static void vp9_frame_unref(AVCodecContext *avctx, VP9Frame *f)
{
ff_thread_release_ext_buffer(avctx, &f->tf);
av_buffer_unref(&f->extradata);
- av_buffer_unref(&f->hwaccel_priv_buf);
+ ff_refstruct_unref(&f->hwaccel_picture_private);
f->segmentation_map = NULL;
- f->hwaccel_picture_private = NULL;
}
static int vp9_frame_alloc(AVCodecContext *avctx, VP9Frame *f)
@@ -135,8 +135,7 @@ static int vp9_frame_alloc(AVCodecContext *avctx, VP9Frame *f)
f->segmentation_map = f->extradata->data;
f->mv = (VP9mvrefPair *) (f->extradata->data + sz);
- 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;
@@ -163,12 +162,8 @@ static int vp9_frame_ref(AVCodecContext *avctx, VP9Frame *dst, VP9Frame *src)
dst->mv = src->mv;
dst->uses_2pass = src->uses_2pass;
- 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);
return 0;