aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec
diff options
context:
space:
mode:
authorAndreas Rheinhardt <andreas.rheinhardt@outlook.com>2023-09-18 00:48:06 +0200
committerAndreas Rheinhardt <andreas.rheinhardt@outlook.com>2024-04-19 13:18:04 +0200
commit259234b46ff867b42df27c7801012eace071e6ad (patch)
tree977da1b1bc16c6af10eae386143d6a8cef9e46d2 /libavcodec
parent98e1e848ef68f00d6d120413b263a76f5d07cf65 (diff)
downloadffmpeg-259234b46ff867b42df27c7801012eace071e6ad.tar.gz
avcodec/vp9: Simplify replacing VP9Frame
ff_thread_progress_replace() can handle a blank ProgressFrame as src (in which case it simply unreferences dst), but not a NULL one. So add a blank frame to be used as source for this case, so that we can use the replace functions to simplify vp9_frame_replace(). Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Diffstat (limited to 'libavcodec')
-rw-r--r--libavcodec/vp9.c16
-rw-r--r--libavcodec/vp9shared.h3
2 files changed, 7 insertions, 12 deletions
diff --git a/libavcodec/vp9.c b/libavcodec/vp9.c
index bdfa543188..443eb74c3c 100644
--- a/libavcodec/vp9.c
+++ b/libavcodec/vp9.c
@@ -147,11 +147,11 @@ fail:
return ret;
}
-static void vp9_frame_ref(VP9Frame *dst, const VP9Frame *src)
+static void vp9_frame_replace(VP9Frame *dst, const VP9Frame *src)
{
- ff_progress_frame_ref(&dst->tf, &src->tf);
+ ff_progress_frame_replace(&dst->tf, &src->tf);
- dst->extradata = ff_refstruct_ref(src->extradata);
+ ff_refstruct_replace(&dst->extradata, src->extradata);
dst->segmentation_map = src->segmentation_map;
dst->mv = src->mv;
@@ -161,13 +161,6 @@ static void vp9_frame_ref(VP9Frame *dst, const VP9Frame *src)
src->hwaccel_picture_private);
}
-static void vp9_frame_replace(VP9Frame *dst, const VP9Frame *src)
-{
- vp9_frame_unref(dst);
- if (src && src->tf.f)
- vp9_frame_ref(dst, src);
-}
-
static int update_size(AVCodecContext *avctx, int w, int h)
{
#define HWACCEL_MAX (CONFIG_VP9_DXVA2_HWACCEL + \
@@ -1584,7 +1577,8 @@ static int vp9_decode_frame(AVCodecContext *avctx, AVFrame *frame,
data += ret;
size -= ret;
- src = !s->s.h.keyframe && !s->s.h.intraonly && !s->s.h.errorres ? &s->s.frames[CUR_FRAME] : NULL;
+ src = !s->s.h.keyframe && !s->s.h.intraonly && !s->s.h.errorres ?
+ &s->s.frames[CUR_FRAME] : &s->s.frames[BLANK_FRAME];
if (!retain_segmap_ref || s->s.h.keyframe || s->s.h.intraonly)
vp9_frame_replace(&s->s.frames[REF_FRAME_SEGMAP], src);
vp9_frame_replace(&s->s.frames[REF_FRAME_MVPAIR], src);
diff --git a/libavcodec/vp9shared.h b/libavcodec/vp9shared.h
index 805668416f..8a450c26a6 100644
--- a/libavcodec/vp9shared.h
+++ b/libavcodec/vp9shared.h
@@ -168,7 +168,8 @@ typedef struct VP9SharedContext {
#define CUR_FRAME 0
#define REF_FRAME_MVPAIR 1
#define REF_FRAME_SEGMAP 2
- VP9Frame frames[3];
+#define BLANK_FRAME 3
+ VP9Frame frames[4];
} VP9SharedContext;
#endif /* AVCODEC_VP9SHARED_H */