PR #25205 opened by Forgejo_Fairy URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/25205 Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/25205.patch
Backport the dimension rounding from upstream 96449cfeaeb9 for #22764. This is the two-line fix submitted in the [mailing-list patch](https://patchwork.ffmpeg.org/project/ffmpeg/patch/[email protected]/), with the patch author and sign-off retained. A one-pixel chroma dimension currently rounds down to zero. In the same-stride input-copy path, that makes the `memcpy()` length negative. An ASan build of release/6.0 reports `negative-size-param (size=-24)` when given a 1×1 YUV420P API frame with 24-byte plane strides. The parent of dce4cf6871a9 succeeds with this reproducer; dce4cf6871a9 and the release/6.0 tip fail. After this backport, the ASan reproducer encodes successfully. The patched build also encodes 1×2, 2×1, 3×3, and 16×16 frames without ASan diagnostics. From 4e391c3c664ce8544392b400948058733a3791d9 Mon Sep 17 00:00:00 2001 From: "lizhixuan.HUST" <[email protected]> Date: Mon, 19 Oct 2026 00:37:54 +0000 Subject: [PATCH] avcodec/mpegvideo_enc: round up copied chroma dimensions on release/6.0 The input copy must retain the final chroma row and column for odd frame dimensions. Truncating a one-pixel dimension to zero can make the same-stride memcpy length negative. Backport of the patch submitted for issue #22764. (cherry picked from commit 96449cfeaeb95fcfd7a2b8d9ccf7719e97471ed1) Signed-off-by: lizhixuan.HUST <[email protected]> Assisted-by: Fairy --- libavcodec/mpegvideo_enc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c index 86a9dd7188..d405f698fe 100644 --- a/libavcodec/mpegvideo_enc.c +++ b/libavcodec/mpegvideo_enc.c @@ -1181,8 +1181,8 @@ static int load_input_picture(MpegEncContext *s, const AVFrame *pic_arg) ptrdiff_t dst_stride = i ? s->uvlinesize : s->linesize; int h_shift = i ? h_chroma_shift : 0; int v_shift = i ? v_chroma_shift : 0; - int w = s->width >> h_shift; - int h = s->height >> v_shift; + int w = AV_CEIL_RSHIFT(s->width , h_shift); + int h = AV_CEIL_RSHIFT(s->height, v_shift); const uint8_t *src = pic_arg->data[i]; uint8_t *dst = pic->f->data[i]; int vpad = 16; -- 2.54.0 _______________________________________________ ffmpeg-devel mailing list -- [email protected] To unsubscribe send an email to [email protected]
