* [FFmpeg-devel] [PATCH] avcodec/decode: Only use ff_progress_frame_get_buffer() with blank input
@ 2025-04-11 11:57 Andreas Rheinhardt
2025-04-13 6:16 ` Andreas Rheinhardt
0 siblings, 1 reply; 2+ messages in thread
From: Andreas Rheinhardt @ 2025-04-11 11:57 UTC (permalink / raw)
To: FFmpeg development discussions and patches
[-- Attachment #1: Type: text/plain, Size: 27 bytes --]
Patch attached.
- Andreas
[-- Attachment #2: 0001-avcodec-decode-Only-use-ff_progress_frame_get_buffer.patch --]
[-- Type: text/x-patch, Size: 3630 bytes --]
From 90d34e5d87a390b6e0058426a1f0b1168eb5ebeb Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Date: Fri, 11 Apr 2025 11:01:01 +0200
Subject: [PATCH] avcodec/decode: Only use ff_progress_frame_get_buffer() with
blank input
All users (namely HEVC) that use ff_progress_frame_alloc()
should just use ff_thread_get_buffer(). Using
ff_progress_frame_get_buffer() is not a must; it is merely
a convenience wrapper.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/decode.c | 11 +++--------
libavcodec/hevc/refs.c | 6 +++---
libavcodec/progressframe.h | 10 ++++------
3 files changed, 10 insertions(+), 17 deletions(-)
diff --git a/libavcodec/decode.c b/libavcodec/decode.c
index 14702fb041..c2b2dd6e3b 100644
--- a/libavcodec/decode.c
+++ b/libavcodec/decode.c
@@ -1761,14 +1761,9 @@ int ff_progress_frame_alloc(AVCodecContext *avctx, ProgressFrame *f)
int ff_progress_frame_get_buffer(AVCodecContext *avctx, ProgressFrame *f, int flags)
{
- int ret;
-
- check_progress_consistency(f);
- if (!f->f) {
- ret = ff_progress_frame_alloc(avctx, f);
- if (ret < 0)
- return ret;
- }
+ int ret = ff_progress_frame_alloc(avctx, f);
+ if (ret < 0)
+ return ret;
ret = ff_thread_get_buffer(avctx, f->progress->f, flags);
if (ret < 0) {
diff --git a/libavcodec/hevc/refs.c b/libavcodec/hevc/refs.c
index 6f291bbf79..ab2e075af0 100644
--- a/libavcodec/hevc/refs.c
+++ b/libavcodec/hevc/refs.c
@@ -29,6 +29,7 @@
#include "hevc.h"
#include "hevcdec.h"
#include "progressframe.h"
+#include "thread.h"
#include "libavutil/refstruct.h"
void ff_hevc_unref_frame(HEVCFrame *frame, int flags)
@@ -157,10 +158,9 @@ static HEVCFrame *alloc_frame(HEVCContext *s, HEVCLayerContext *l)
}
}
- ret = ff_progress_frame_get_buffer(s->avctx, &frame->tf,
- AV_GET_BUFFER_FLAG_REF);
+ ret = ff_thread_get_buffer(s->avctx, frame->f, AV_GET_BUFFER_FLAG_REF);
if (ret < 0)
- return NULL;
+ goto fail;
frame->rpl = av_refstruct_allocz(s->pkt.nb_nals * sizeof(*frame->rpl));
if (!frame->rpl)
diff --git a/libavcodec/progressframe.h b/libavcodec/progressframe.h
index 32a345beec..e3cb83c5b4 100644
--- a/libavcodec/progressframe.h
+++ b/libavcodec/progressframe.h
@@ -102,10 +102,9 @@ void ff_progress_frame_report(ProgressFrame *f, int progress);
void ff_progress_frame_await(const ProgressFrame *f, int progress);
/**
- * This function allocates ProgressFrame.f
- * May be called before ff_progress_frame_get_buffer() in the cases where the
- * AVFrame needs to be accessed before the ff_thread_get_buffer() call in
- * ff_progress_frame_alloc().
+ * This function sets up the ProgressFrame, i.e. ProgressFrame.f
+ * and ProgressFrame.progress. ProgressFrame.f will be blank
+ * (as if from av_frame_alloc() or av_frame_unref()) on success.
*
* @note: This must only be called by codecs with the
* FF_CODEC_CAP_USES_PROGRESSFRAMES internal cap.
@@ -113,8 +112,7 @@ void ff_progress_frame_await(const ProgressFrame *f, int progress);
int ff_progress_frame_alloc(struct AVCodecContext *avctx, ProgressFrame *f);
/**
- * This function sets up the ProgressFrame, i.e. allocates ProgressFrame.f
- * if needed, and also calls ff_thread_get_buffer() on the frame.
+ * Wrapper around ff_progress_frame_alloc() and ff_thread_get_buffer().
*
* @note: This must only be called by codecs with the
* FF_CODEC_CAP_USES_PROGRESSFRAMES internal cap.
--
2.45.2
[-- Attachment #3: Type: text/plain, Size: 251 bytes --]
_______________________________________________
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] 2+ messages in thread
* Re: [FFmpeg-devel] [PATCH] avcodec/decode: Only use ff_progress_frame_get_buffer() with blank input
2025-04-11 11:57 [FFmpeg-devel] [PATCH] avcodec/decode: Only use ff_progress_frame_get_buffer() with blank input Andreas Rheinhardt
@ 2025-04-13 6:16 ` Andreas Rheinhardt
0 siblings, 0 replies; 2+ messages in thread
From: Andreas Rheinhardt @ 2025-04-13 6:16 UTC (permalink / raw)
To: ffmpeg-devel
Andreas Rheinhardt:
> Patch attached.
>
> - Andreas
>
Will apply this patch tomorrow unless there are objections.
- Andreas
_______________________________________________
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] 2+ messages in thread
end of thread, other threads:[~2025-04-13 6:16 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-04-11 11:57 [FFmpeg-devel] [PATCH] avcodec/decode: Only use ff_progress_frame_get_buffer() with blank input Andreas Rheinhardt
2025-04-13 6:16 ` Andreas Rheinhardt
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