* [FFmpeg-devel] [PATCH 1/2] avcodec/av1dec: use av_frame_replace()
@ 2023-05-18 14:10 James Almer
2023-05-18 14:10 ` [FFmpeg-devel] [PATCH 2/2] avcodec/h264dec: remove the last few ff_h264_ref_picture() calls James Almer
2023-05-20 12:46 ` [FFmpeg-devel] [PATCH 1/2] avcodec/av1dec: use av_frame_replace() James Almer
0 siblings, 2 replies; 3+ messages in thread
From: James Almer @ 2023-05-18 14:10 UTC (permalink / raw)
To: ffmpeg-devel
Signed-off-by: James Almer <jamrial@gmail.com>
---
libavcodec/av1dec.c | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/libavcodec/av1dec.c b/libavcodec/av1dec.c
index d46ee48335..f900a6d0ed 100644
--- a/libavcodec/av1dec.c
+++ b/libavcodec/av1dec.c
@@ -596,10 +596,13 @@ static void av1_frame_unref(AVCodecContext *avctx, AV1Frame *f)
f->coded_lossless = 0;
}
-static int av1_frame_ref(AVCodecContext *avctx, AV1Frame *dst, const AV1Frame *src)
+static int av1_frame_replace(AVCodecContext *avctx, AV1Frame *dst, const AV1Frame *src)
{
int ret;
+ if (!src->f->buf[0])
+ av1_frame_unref(avctx, dst);
+
ret = av_buffer_replace(&dst->header_ref, src->header_ref);
if (ret < 0)
return ret;
@@ -609,13 +612,13 @@ static int av1_frame_ref(AVCodecContext *avctx, AV1Frame *dst, const AV1Frame *s
if (!src->f->buf[0])
return 0;
- ret = av_frame_ref(dst->f, src->f);
+ ret = av_frame_replace(dst->f, src->f);
if (ret < 0)
goto fail;
if (src->hwaccel_picture_private) {
- dst->hwaccel_priv_buf = av_buffer_ref(src->hwaccel_priv_buf);
- if (!dst->hwaccel_priv_buf)
+ ret = av_buffer_replace(&dst->hwaccel_priv_buf, src->hwaccel_priv_buf);
+ if (ret < 0)
goto fail;
dst->hwaccel_picture_private = dst->hwaccel_priv_buf->data;
}
@@ -1092,8 +1095,7 @@ static int update_reference_list(AVCodecContext *avctx)
for (int i = 0; i < AV1_NUM_REF_FRAMES; i++) {
if (header->refresh_frame_flags & (1 << i)) {
- av1_frame_unref(avctx, &s->ref[i]);
- if ((ret = av1_frame_ref(avctx, &s->ref[i], &s->cur_frame)) < 0) {
+ if ((ret = av1_frame_replace(avctx, &s->ref[i], &s->cur_frame)) < 0) {
av_log(avctx, AV_LOG_ERROR,
"Failed to update frame %d in reference list\n", i);
return ret;
@@ -1236,10 +1238,8 @@ static int av1_decode_frame(AVCodecContext *avctx, AVFrame *frame,
s->raw_frame_header = &obu->obu.frame_header;
if (s->raw_frame_header->show_existing_frame) {
- av1_frame_unref(avctx, &s->cur_frame);
-
- ret = av1_frame_ref(avctx, &s->cur_frame,
- &s->ref[s->raw_frame_header->frame_to_show_map_idx]);
+ ret = av1_frame_replace(avctx, &s->cur_frame,
+ &s->ref[s->raw_frame_header->frame_to_show_map_idx]);
if (ret < 0) {
av_log(avctx, AV_LOG_ERROR, "Failed to get reference frame.\n");
goto end;
--
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".
^ permalink raw reply [flat|nested] 3+ messages in thread
* [FFmpeg-devel] [PATCH 2/2] avcodec/h264dec: remove the last few ff_h264_ref_picture() calls
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
2023-05-20 12:46 ` [FFmpeg-devel] [PATCH 1/2] avcodec/av1dec: use av_frame_replace() James Almer
1 sibling, 0 replies; 3+ messages in thread
From: James Almer @ 2023-05-18 14:10 UTC (permalink / raw)
To: ffmpeg-devel
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".
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [FFmpeg-devel] [PATCH 1/2] avcodec/av1dec: use av_frame_replace()
2023-05-18 14:10 [FFmpeg-devel] [PATCH 1/2] avcodec/av1dec: use av_frame_replace() James Almer
2023-05-18 14:10 ` [FFmpeg-devel] [PATCH 2/2] avcodec/h264dec: remove the last few ff_h264_ref_picture() calls James Almer
@ 2023-05-20 12:46 ` James Almer
1 sibling, 0 replies; 3+ messages in thread
From: James Almer @ 2023-05-20 12:46 UTC (permalink / raw)
To: ffmpeg-devel
On 5/18/2023 11:10 AM, James Almer wrote:
> Signed-off-by: James Almer <jamrial@gmail.com>
> ---
> libavcodec/av1dec.c | 20 ++++++++++----------
> 1 file changed, 10 insertions(+), 10 deletions(-)
Will apply set.
_______________________________________________
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".
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-05-20 12:46 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-18 14:10 [FFmpeg-devel] [PATCH 1/2] avcodec/av1dec: use av_frame_replace() James Almer
2023-05-18 14:10 ` [FFmpeg-devel] [PATCH 2/2] avcodec/h264dec: remove the last few ff_h264_ref_picture() calls James Almer
2023-05-20 12:46 ` [FFmpeg-devel] [PATCH 1/2] avcodec/av1dec: use av_frame_replace() James Almer
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