From: James Almer <jamrial@gmail.com>
To: ffmpeg-devel@ffmpeg.org
Subject: [FFmpeg-devel] [PATCH 2/2] avcodec/h264dec: remove the last few ff_h264_ref_picture() calls
Date: Thu, 18 May 2023 11:10:51 -0300
Message-ID: <20230518141051.59761-2-jamrial@gmail.com> (raw)
In-Reply-To: <20230518141051.59761-1-jamrial@gmail.com>
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 --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);
--
2.40.1
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
next prev parent reply other threads:[~2023-05-18 14:11 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-18 14:10 [FFmpeg-devel] [PATCH 1/2] avcodec/av1dec: use av_frame_replace() James Almer
2023-05-18 14:10 ` James Almer [this message]
2023-05-20 12:46 ` James Almer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230518141051.59761-2-jamrial@gmail.com \
--to=jamrial@gmail.com \
--cc=ffmpeg-devel@ffmpeg.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
This inbox may be cloned and mirrored by anyone:
git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
ffmpegdev@gitmailbox.com
public-inbox-index ffmpegdev
Example config snippet for mirrors.
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git