PR #25073 opened by romainhedouin URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/25073 Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/25073.patch
In psy_3gpp_analyze_channel(), the spread energy of the first band was always stored in spread_en[0] instead of spread_en[w], unlike every other access to spread_en[w+g]. For short windows, windows 1-7 thus started spreading from an unset value instead of their own first band energy. This only affects the hole avoidance decision. Tested: make fate passes (5875 tests). Encoder output was bit-identical before and after on luckynight_2ch_44kHz_s16.wav and on a synthetic transient signal at 24k, 32k, 48k, 64k and 128k, so the practical effect seems small. 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 ad01a032a16a818d512d50116f6b8b02c9baa715 Mon Sep 17 00:00:00 2001 From: romainhedouin <[email protected]> Date: Wed, 14 Oct 2026 20:42:24 +0200 Subject: [PATCH] avcodec/aacpsy: fix spread energy index for short windows In psy_3gpp_analyze_channel(), the spread energy of the first band was always stored in spread_en[0] instead of spread_en[w], unlike every other access to spread_en[w+g]. For short windows, windows 1-7 thus started spreading from an unset value instead of their own first band energy. This only affects the hole avoidance decision. Tested: make fate passes (5875 tests). Encoder output was bit-identical before and after on luckynight_2ch_44kHz_s16.wav and on a synthetic transient signal at 24k, 32k, 48k, 64k and 128k, so the practical effect seems small. Found with the help of an AI code review; verified by hand. Signed-off-by: romainhedouin <[email protected]> --- libavcodec/aacpsy.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/aacpsy.c b/libavcodec/aacpsy.c index ac0e17de5b..e730e621b9 100644 --- a/libavcodec/aacpsy.c +++ b/libavcodec/aacpsy.c @@ -769,7 +769,7 @@ static void psy_3gpp_analyze_channel(FFPsyContext *ctx, int channel, AacPsyBand *bands = &pch->band[w]; /* 5.4.2.3 "Spreading" & 5.4.3 "Spread Energy Calculation" */ - spread_en[0] = bands[0].energy; + spread_en[w] = bands[0].energy; for (g = 1; g < num_bands; g++) { bands[g].thr = FFMAX(bands[g].thr, bands[g-1].thr * coeffs[g].spread_hi[0]); spread_en[w+g] = FFMAX(bands[g].energy, spread_en[w+g-1] * coeffs[g].spread_hi[1]); -- 2.52.0 _______________________________________________ ffmpeg-devel mailing list -- [email protected] To unsubscribe send an email to [email protected]
