* [FFmpeg-devel] [PR] avfilter/af_loudnorm: fix limiter buffer over-allocation (PR #21452)
@ 2026-01-13 17:51 realies via ffmpeg-devel
0 siblings, 0 replies; only message in thread
From: realies via ffmpeg-devel @ 2026-01-13 17:51 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: realies
PR #21452 opened by realies
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/21452
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/21452.patch
The limiter_buf was being allocated with buf_size (3000ms worth of
samples) instead of limiter_buf_size (210ms worth of samples).
This resulted in allocating approximately 14x more memory than needed
for the limiter buffer.
## Memory profiling results (valgrind massif, 192kHz stereo)
| Version | Peak Heap Allocation |
|---------|---------------------|
| Before | 87,415,378 bytes (~83.4 MB) |
| After | 79,075,138 bytes (~75.4 MB) |
| **Saved** | **8,340,240 bytes (~8.0 MB)** |
## Details
At 192kHz stereo:
- buf_size: 1,152,000 samples = 9.2 MB
- limiter_buf_size: 80,640 samples = 0.6 MB
- Wasted per instance: ~8.6 MB
The bug was introduced when the limiter buffer was added but the
wrong size variable was used in av_malloc_array().
>From e413d357c0b8a250ccf4efb4b61fc4fd323db297 Mon Sep 17 00:00:00 2001
From: realies <ffmpeg@reali.es>
Date: Tue, 13 Jan 2026 19:34:00 +0200
Subject: [PATCH] avfilter/af_loudnorm: fix limiter buffer over-allocation
The limiter_buf was being allocated with buf_size (3000ms worth of
samples) instead of limiter_buf_size (210ms worth of samples).
This resulted in allocating approximately 14x more memory than needed
for the limiter buffer. At 192kHz stereo:
- buf_size: 1,152,000 samples = 9.2 MB
- limiter_buf_size: 80,640 samples = 0.6 MB
- Wasted: ~8.2 MB per filter instance
The bug was introduced when the limiter buffer was added but the
wrong size variable was used in av_malloc_array().
---
libavfilter/af_loudnorm.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libavfilter/af_loudnorm.c b/libavfilter/af_loudnorm.c
index 432b9710a5..00d0a145ae 100644
--- a/libavfilter/af_loudnorm.c
+++ b/libavfilter/af_loudnorm.c
@@ -774,7 +774,7 @@ static int config_input(AVFilterLink *inlink)
return AVERROR(ENOMEM);
s->limiter_buf_size = frame_size(inlink->sample_rate, 210) * inlink->ch_layout.nb_channels;
- s->limiter_buf = av_malloc_array(s->buf_size, sizeof(*s->limiter_buf));
+ s->limiter_buf = av_malloc_array(s->limiter_buf_size, sizeof(*s->limiter_buf));
if (!s->limiter_buf)
return AVERROR(ENOMEM);
--
2.49.1
_______________________________________________
ffmpeg-devel mailing list -- ffmpeg-devel@ffmpeg.org
To unsubscribe send an email to ffmpeg-devel-leave@ffmpeg.org
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-01-13 17:54 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-01-13 17:51 [FFmpeg-devel] [PR] avfilter/af_loudnorm: fix limiter buffer over-allocation (PR #21452) realies via ffmpeg-devel
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