PR #23637 opened by nyanmisaka URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/23637 Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/23637.patch
# Summary of changes Odd-height yuv420p result in incorrect calculations of the U-plane address offset. The last row of the V-plane overlapped with and was overwritten by the first row of the U-plane, leading to chroma artifacts. ``` ffmpeg -init_hw_device cuda=cu -filter_hw_device cu -f lavfi -i \ testsrc=s=1920x1081,format=yuv420p -vf hwupload -c:v hevc_nvenc \ -vframes 1 -y <OUTPUT> ``` Signed-off-by: nyanmisaka <[email protected]> Inspired by ffe0104 <img src="/attachments/7abec1e4-9608-4a0a-a423-e3a6347a6795" height="250"> >From 209747824d9862be43c2c09ce6571e35a692074f Mon Sep 17 00:00:00 2001 From: nyanmisaka <[email protected]> Date: Mon, 29 Jun 2026 15:32:00 +0800 Subject: [PATCH] avutil/hwcontext_cuda: fix yuv420p V/U plane overlap in cuda_get_buffer() Odd-height yuv420p result in incorrect calculations of the U-plane address offset. The last row of the V-plane overlapped with and was overwritten by the first row of the U-plane, leading to chroma artifacts. ``` ffmpeg -init_hw_device cuda=cu -filter_hw_device cu -f lavfi -i \ testsrc=s=1920x1081,format=yuv420p -vf hwupload -c:v hevc_nvenc \ -vframes 1 -y <OUTPUT> ``` Signed-off-by: nyanmisaka <[email protected]> --- libavutil/hwcontext_cuda.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavutil/hwcontext_cuda.c b/libavutil/hwcontext_cuda.c index 6342683a17..f93bdcab9c 100644 --- a/libavutil/hwcontext_cuda.c +++ b/libavutil/hwcontext_cuda.c @@ -209,7 +209,7 @@ static int cuda_get_buffer(AVHWFramesContext *ctx, AVFrame *frame) if (ctx->sw_format == AV_PIX_FMT_YUV420P) { frame->linesize[1] = frame->linesize[2] = frame->linesize[0] / 2; frame->data[2] = frame->data[1]; - frame->data[1] = frame->data[2] + frame->linesize[2] * (ctx->height / 2); + frame->data[1] = frame->data[2] + frame->linesize[2] * AV_CEIL_RSHIFT(ctx->height, 1); } frame->format = AV_PIX_FMT_CUDA; -- 2.52.0 _______________________________________________ ffmpeg-devel mailing list -- [email protected] To unsubscribe send an email to [email protected]
