ffmpeg | branch: master | Andreas Rheinhardt <andreas.rheinha...@outlook.com> | Mon Sep 18 00:48:06 2023 +0200| [259234b46ff867b42df27c7801012eace071e6ad] | committer: Andreas Rheinhardt
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.rheinha...@outlook.com> > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=259234b46ff867b42df27c7801012eace071e6ad --- libavcodec/vp9.c | 16 +++++----------- libavcodec/vp9shared.h | 3 ++- 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 */ _______________________________________________ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".