From: James Almer <jamrial@gmail.com>
To: ffmpeg-devel@ffmpeg.org
Subject: [FFmpeg-devel] [PATCH 1/2] avcodec/av1dec: use av_frame_replace()
Date: Thu, 18 May 2023 11:10:50 -0300
Message-ID: <20230518141051.59761-1-jamrial@gmail.com> (raw)
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".
next 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 James Almer [this message]
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
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-1-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