diff mbox series

[FFmpeg-devel,2/2] avcodec/h264dec: remove the last few ff_h264_ref_picture() calls

Message ID 20230518141051.59761-2-jamrial@gmail.com
State New
Headers show
Series [FFmpeg-devel,1/2] avcodec/av1dec: use av_frame_replace() | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished

Commit Message

James Almer May 18, 2023, 2:10 p.m. UTC
Replace them with ff_h264_replace_picture().

Signed-off-by: James Almer <jamrial@gmail.com>
---
 libavcodec/h264_picture.c | 53 ---------------------------------------
 libavcodec/h264_refs.c    |  3 +--
 libavcodec/h264_slice.c   |  3 +--
 libavcodec/h264dec.h      |  1 -
 4 files changed, 2 insertions(+), 58 deletions(-)
diff mbox series

Patch

diff --git a/libavcodec/h264_picture.c b/libavcodec/h264_picture.c
index dcaf0fdb0a..9da3b06ce1 100644
--- a/libavcodec/h264_picture.c
+++ b/libavcodec/h264_picture.c
@@ -89,59 +89,6 @@  static void h264_copy_picture_params(H264Picture *dst, const H264Picture *src)
     dst->needs_fg      = src->needs_fg;
 }
 
-int ff_h264_ref_picture(H264Context *h, H264Picture *dst, H264Picture *src)
-{
-    int ret, i;
-
-    av_assert0(!dst->f->buf[0]);
-    av_assert0(src->f->buf[0]);
-    av_assert0(src->tf.f == src->f);
-
-    dst->tf.f = dst->f;
-    ret = ff_thread_ref_frame(&dst->tf, &src->tf);
-    if (ret < 0)
-        goto fail;
-
-    if (src->needs_fg) {
-        ret = av_frame_ref(dst->f_grain, src->f_grain);
-        if (ret < 0)
-            goto fail;
-    }
-
-    dst->qscale_table_buf = av_buffer_ref(src->qscale_table_buf);
-    dst->mb_type_buf      = av_buffer_ref(src->mb_type_buf);
-    dst->pps_buf          = av_buffer_ref(src->pps_buf);
-    if (!dst->qscale_table_buf || !dst->mb_type_buf || !dst->pps_buf) {
-        ret = AVERROR(ENOMEM);
-        goto fail;
-    }
-
-    for (i = 0; i < 2; i++) {
-        dst->motion_val_buf[i] = av_buffer_ref(src->motion_val_buf[i]);
-        dst->ref_index_buf[i]  = av_buffer_ref(src->ref_index_buf[i]);
-        if (!dst->motion_val_buf[i] || !dst->ref_index_buf[i]) {
-            ret = AVERROR(ENOMEM);
-            goto fail;
-        }
-    }
-
-    if (src->hwaccel_picture_private) {
-        dst->hwaccel_priv_buf = av_buffer_ref(src->hwaccel_priv_buf);
-        if (!dst->hwaccel_priv_buf) {
-            ret = AVERROR(ENOMEM);
-            goto fail;
-        }
-        dst->hwaccel_picture_private = dst->hwaccel_priv_buf->data;
-    }
-
-    h264_copy_picture_params(dst, src);
-
-    return 0;
-fail:
-    ff_h264_unref_picture(h, dst);
-    return ret;
-}
-
 int ff_h264_replace_picture(H264Context *h, H264Picture *dst, const H264Picture *src)
 {
     int ret, i;
diff --git a/libavcodec/h264_refs.c b/libavcodec/h264_refs.c
index 50bbe94917..d876a19f73 100644
--- a/libavcodec/h264_refs.c
+++ b/libavcodec/h264_refs.c
@@ -571,8 +571,7 @@  void ff_h264_remove_all_refs(H264Context *h)
     assert(h->long_ref_count == 0);
 
     if (h->short_ref_count && !h->last_pic_for_ec.f->data[0]) {
-        ff_h264_unref_picture(h, &h->last_pic_for_ec);
-        ff_h264_ref_picture(h, &h->last_pic_for_ec, h->short_ref[0]);
+        ff_h264_replace_picture(h, &h->last_pic_for_ec, h->short_ref[0]);
     }
 
     for (i = 0; i < h->short_ref_count; i++) {
diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c
index be7a8e0b5a..0520473dc7 100644
--- a/libavcodec/h264_slice.c
+++ b/libavcodec/h264_slice.c
@@ -521,12 +521,11 @@  FF_ENABLE_DEPRECATION_WARNINGS
         return ret;
 
     h->cur_pic_ptr = pic;
-    ff_h264_unref_picture(h, &h->cur_pic);
     if (CONFIG_ERROR_RESILIENCE) {
         ff_h264_set_erpic(&h->er.cur_pic, NULL);
     }
 
-    if ((ret = ff_h264_ref_picture(h, &h->cur_pic, h->cur_pic_ptr)) < 0)
+    if ((ret = ff_h264_replace_picture(h, &h->cur_pic, h->cur_pic_ptr)) < 0)
         return ret;
 
     for (i = 0; i < h->nb_slice_ctx; i++) {
diff --git a/libavcodec/h264dec.h b/libavcodec/h264dec.h
index 9a1ec1bace..f9b806e7c6 100644
--- a/libavcodec/h264dec.h
+++ b/libavcodec/h264dec.h
@@ -781,7 +781,6 @@  static av_always_inline int get_dct8x8_allowed(const H264Context *h, H264SliceCo
 
 int ff_h264_field_end(H264Context *h, H264SliceContext *sl, int in_setup);
 
-int ff_h264_ref_picture(H264Context *h, H264Picture *dst, H264Picture *src);
 int ff_h264_replace_picture(H264Context *h, H264Picture *dst, const H264Picture *src);
 void ff_h264_unref_picture(H264Context *h, H264Picture *pic);