PR #22648 opened by James Almer (jamrial) URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/22648 Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/22648.patch
Leave the existing one for non decoder-specific, post processing usage. With this, scenarios like nvdec decoding should work algonside lcevc enhancement application. >From 543f38a93a3ec125fc47ab6bc091b254e1cbeeec Mon Sep 17 00:00:00 2001 From: James Almer <[email protected]> Date: Fri, 27 Mar 2026 19:31:38 -0300 Subject: [PATCH 1/2] avcodec/decode: add a hwaccel specific post_process callback to FrameDecodeData Leave the existing one for non decoder-specific, post processing usage. With this, scenarios like nvdec decoding can work algonside lcevc enhancement application. Signed-off-by: James Almer <[email protected]> --- libavcodec/decode.c | 8 ++++++++ libavcodec/decode.h | 4 ++++ libavcodec/nvdec.c | 2 +- libavcodec/videotoolbox.c | 2 +- 4 files changed, 14 insertions(+), 2 deletions(-) diff --git a/libavcodec/decode.c b/libavcodec/decode.c index 5de5a84038..6c5964db7c 100644 --- a/libavcodec/decode.c +++ b/libavcodec/decode.c @@ -692,6 +692,14 @@ static int decode_receive_frame_internal(AVCodecContext *avctx, AVFrame *frame, if (frame->private_ref) { FrameDecodeData *fdd = frame->private_ref; + if (fdd->hwaccel_priv_post_process) { + ret = fdd->hwaccel_priv_post_process(avctx, frame); + if (ret < 0) { + av_frame_unref(frame); + return ret; + } + } + if (fdd->post_process) { ret = fdd->post_process(avctx, frame); if (ret < 0) { diff --git a/libavcodec/decode.h b/libavcodec/decode.h index 561dc6a69c..5e3b78a3bd 100644 --- a/libavcodec/decode.h +++ b/libavcodec/decode.h @@ -47,7 +47,11 @@ typedef struct FrameDecodeData { /** * Per-frame private data for hwaccels. + * + * Same as @ref post_process, but used only by some hwaccels to retrieve or + * finalize frames, and executed first. */ + int (*hwaccel_priv_post_process)(void *logctx, AVFrame *frame); void *hwaccel_priv; void (*hwaccel_priv_free)(void *priv); } FrameDecodeData; diff --git a/libavcodec/nvdec.c b/libavcodec/nvdec.c index 60becd2733..911fc336c7 100644 --- a/libavcodec/nvdec.c +++ b/libavcodec/nvdec.c @@ -600,7 +600,7 @@ int ff_nvdec_start_frame(AVCodecContext *avctx, AVFrame *frame) fdd->hwaccel_priv = cf; fdd->hwaccel_priv_free = nvdec_fdd_priv_free; - fdd->post_process = nvdec_retrieve_data; + fdd->hwaccel_priv_post_process = nvdec_retrieve_data; return 0; fail: diff --git a/libavcodec/videotoolbox.c b/libavcodec/videotoolbox.c index 2cd22cba1a..7d68a3cd4f 100644 --- a/libavcodec/videotoolbox.c +++ b/libavcodec/videotoolbox.c @@ -168,7 +168,7 @@ int ff_videotoolbox_alloc_frame(AVCodecContext *avctx, AVFrame *frame) frame->buf[0] = buf; fdd = frame->private_ref; - fdd->post_process = videotoolbox_postproc_frame; + fdd->hwaccel_priv_post_process = videotoolbox_postproc_frame; frame->width = avctx->width; frame->height = avctx->height; -- 2.52.0 >From 564bc73f5d07584082a4af1e9834590b495edc5c Mon Sep 17 00:00:00 2001 From: James Almer <[email protected]> Date: Fri, 27 Mar 2026 19:34:11 -0300 Subject: [PATCH 2/2] avcodec/decode: don't try to apply LCEVC enhancements if some other kind of post processing is active Signed-off-by: James Almer <[email protected]> --- libavcodec/decode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/decode.c b/libavcodec/decode.c index 6c5964db7c..e2be853050 100644 --- a/libavcodec/decode.c +++ b/libavcodec/decode.c @@ -1711,7 +1711,7 @@ static int attach_post_process_data(AVCodecContext *avctx, AVFrame *frame) FFLCEVCFrame *frame_ctx; int ret; - if (!dc->lcevc.width || !dc->lcevc.height) { + if (fdd->post_process || !dc->lcevc.width || !dc->lcevc.height) { dc->lcevc.frame = 0; return 0; } -- 2.52.0 _______________________________________________ ffmpeg-devel mailing list -- [email protected] To unsubscribe send an email to [email protected]
