avcodec/x86/sbcdsp: Fix calculating four-subbands stereo scalefactors

sbc_calc_scalefactors uses an int32_t [16/*max blocks*/][2/*max
channels*/][8/*max subbands*/] array. The MMX version of this code
treats the two inner arrays as one [2*8] array to process
and it processes subbands*channels of them. But when subbands
is < 8 and channels is two, the entries to process are not
contiguous: One has to process 0..subbands-1 and 8..7+subbands,
yet the code processed 0..2*subbands-1.
This commit fixes this by processing entries 0..7+subbands
if there are two channels.

Before this commit, the following command line triggered an
av_assert2() in put_bits():
ffmpeg_g -i tests/data/asynth-44100-2.wav -c sbc -b:a 200k \
-sbc_delay 0.003 -f null -

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
This commit is contained in:
Andreas Rheinhardt
2026-03-23 20:52:31 +01:00
parent 1c9f56f969
commit 0a81a1ce66
+1 -1
View File
@@ -126,7 +126,7 @@ cglobal sbc_calc_scalefactors, 5, 7, 4, sb_sample_f, scale_factor, blocks, chann
shl subbandsd, 2
cmp channelsd, 2
jl .loop_1
shl subbandsd, 1
add subbandsd, 32
.loop_1:
sub subbandsq, 8