PR #25677 opened by romainhedouin URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/25677 Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/25677.patch
The data buffer was allocated with 18 bytes per pixel, but the block data regions set up by init_blocks() add up to 6 bytes per pixel, which is also the most that encode_block() lets zlib write. This allocates that size. The output is unchanged. | compiler | size | RSS before | RSS after | RAM saved | |---|---|---|---|---| | clang 21 | 1280x720 testsrc2 | 63.7 MiB | 53.1 MiB | 10.6 MiB (16.6%) | clang 21 | 1280x720 noise | 65.3 MiB | 54.8 MiB | 10.6 MiB (16.2%) | clang 21 | 1920x1080 testsrc2 | 133.2 MiB | 109.5 MiB | 23.8 MiB (17.8%) | clang 21 | 1920x1080 noise | 136.9 MiB | 113.2 MiB | 23.8 MiB (17.3%) | clang 21 | 1920x1080 real video | 133.7 MiB | 109.9 MiB | 23.8 MiB (17.8%) | clang 21 | 3840x2160 testsrc2 | 508.6 MiB | 413.6 MiB | 95.0 MiB (18.7%) | clang 21 | 3840x2160 noise | 523.0 MiB | 428.1 MiB | 94.9 MiB (18.2%) | GCC 16.2 | 1280x720 testsrc2 | 63.4 MiB | 52.8 MiB | 10.5 MiB (16.6%) | GCC 16.2 | 1280x720 noise | 65.0 MiB | 54.4 MiB | 10.5 MiB (16.2%) | GCC 16.2 | 1920x1080 testsrc2 | 132.9 MiB | 109.2 MiB | 23.7 MiB (17.8%) | GCC 16.2 | 1920x1080 noise | 136.5 MiB | 112.8 MiB | 23.7 MiB (17.4%) | GCC 16.2 | 1920x1080 real video | 133.3 MiB | 109.6 MiB | 23.7 MiB (17.8%) | GCC 16.2 | 3840x2160 testsrc2 | 508.2 MiB | 413.3 MiB | 94.9 MiB (18.7%) | GCC 16.2 | 3840x2160 noise | 522.6 MiB | 427.8 MiB | 94.9 MiB (18.2%) Noticed during a review sweep of ffmpeg using an LLM. Signed-off-by: romainhedouin <[email protected]> <!-- If this PR requires new FATE test samples, attach them to the PR and list their target paths below (relative to the fate-suite root). Attached filenames must match the sample's filename: ```fate-samples # e.g. vorbis/new-sample.ogg ``` --> >From 2a1ee35951483d085eaf2caf2eb1ee7b12c55feb Mon Sep 17 00:00:00 2001 From: romainhedouin <[email protected]> Date: Mon, 2 Nov 2026 01:26:27 +0100 Subject: [PATCH] avcodec/flashsv2enc: allocate a smaller data buffer The data buffer was allocated with 18 bytes per pixel, but the block data regions set up by init_blocks() add up to 6 bytes per pixel, which is also the most that encode_block() lets zlib write. Allocate that size. The output is unchanged. Noticed during a review sweep of ffmpeg using an LLM. Signed-off-by: romainhedouin <[email protected]> --- libavcodec/flashsv2enc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/flashsv2enc.c b/libavcodec/flashsv2enc.c index 17e0bc1b3c6..26249b5a608 100644 --- a/libavcodec/flashsv2enc.c +++ b/libavcodec/flashsv2enc.c @@ -249,7 +249,7 @@ static av_cold int flashsv2_encode_init(AVCodecContext * avctx) s->encbuffer = av_mallocz(s->frame_size); s->keybuffer = av_mallocz(s->frame_size); - s->databuffer = av_mallocz(s->frame_size * 6); + s->databuffer = av_mallocz(s->frame_size * 2); s->current_frame = av_mallocz(s->frame_size); s->key_frame = av_mallocz(s->frame_size); if (!s->encbuffer || !s->keybuffer || !s->databuffer -- 2.54.0 _______________________________________________ ffmpeg-devel mailing list -- [email protected] To unsubscribe send an email to [email protected]
