[FFmpeg-cvslog] avcodec/av1dec: Make av1_frame_replace() out of av1_frame_ref()

Andreas Rheinhardt git at videolan.org
Sun Apr 21 18:17:59 EEST 2024


ffmpeg | branch: master | Andreas Rheinhardt <andreas.rheinhardt at outlook.com> | Fri Apr 19 16:48:45 2024 +0200| [20206e14d7480d514b5e9cdda179dedd2742d4dd] | committer: Andreas Rheinhardt

avcodec/av1dec: Make av1_frame_replace() out of av1_frame_ref()

Reviewed-by: James Almer <jamrial at gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at outlook.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=20206e14d7480d514b5e9cdda179dedd2742d4dd
---

 libavcodec/av1dec.c | 21 ++++++++-------------
 1 file changed, 8 insertions(+), 13 deletions(-)

diff --git a/libavcodec/av1dec.c b/libavcodec/av1dec.c
index 2a1a249bc4..21ba9d475d 100644
--- a/libavcodec/av1dec.c
+++ b/libavcodec/av1dec.c
@@ -683,16 +683,15 @@ static void av1_frame_unref(AV1Frame *f)
     f->coded_lossless = 0;
 }
 
-static void av1_frame_ref(AVCodecContext *avctx, AV1Frame *dst, const AV1Frame *src)
+static void av1_frame_replace(AV1Frame *dst, const AV1Frame *src)
 {
+    av_assert1(dst != src);
+
     ff_refstruct_replace(&dst->header_ref, src->header_ref);
 
     dst->raw_frame_header = src->raw_frame_header;
 
-    if (!src->f)
-        return;
-
-    ff_progress_frame_ref(&dst->pf, &src->pf);
+    ff_progress_frame_replace(&dst->pf, &src->pf);
 
     ff_refstruct_replace(&dst->hwaccel_picture_private,
                           src->hwaccel_picture_private);
@@ -1191,10 +1190,8 @@ static void update_reference_list(AVCodecContext *avctx)
     const AV1RawFrameHeader *header = s->raw_frame_header;
 
     for (int i = 0; i < AV1_NUM_REF_FRAMES; i++) {
-        if (header->refresh_frame_flags & (1 << i)) {
-            av1_frame_unref(&s->ref[i]);
-            av1_frame_ref(avctx, &s->ref[i], &s->cur_frame);
-        }
+        if (header->refresh_frame_flags & (1 << i))
+            av1_frame_replace(&s->ref[i], &s->cur_frame);
     }
 }
 
@@ -1324,10 +1321,8 @@ static int av1_receive_frame_internal(AVCodecContext *avctx, AVFrame *frame)
                 s->raw_frame_header = &obu->obu.frame_header;
 
             if (s->raw_frame_header->show_existing_frame) {
-                av1_frame_unref(&s->cur_frame);
-
-                av1_frame_ref(avctx, &s->cur_frame,
-                              &s->ref[s->raw_frame_header->frame_to_show_map_idx]);
+                av1_frame_replace(&s->cur_frame,
+                                  &s->ref[s->raw_frame_header->frame_to_show_map_idx]);
 
                 update_reference_list(avctx);
 



More information about the ffmpeg-cvslog mailing list