1
0

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>
This commit is contained in:
Andreas Rheinhardt 2023-09-18 00:48:06 +02:00
parent 98e1e848ef
commit 259234b46f
2 changed files with 7 additions and 12 deletions

View File

@ -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);

View File

@ -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 */