rockbox/lib/rbcodec/codecs/libwma
Michael Giacomelli 9477e371a3 wma: fix overflow in the LSP exponent curve
Very low bitrate WMA files send their spectral envelope as LSP
coefficients. The curve computed from them squares two products
whose value can reach about a million, in 16.16 fixed point. Where
the envelope should be lowest the squares overflowed, and those
points came out near the curve's maximum instead: bands at the top
of the spectrum up to 17 dB too loud, and everything else a few dB
low, as levels are taken relative to the maximum.

Sum the squares in 64 bits, and let pow_m1_4() take a value above
the 16.16 range.

Checked with perfsim (Sansa e200v1 build). The curve is within
0.2 dB of ffmpeg's formula at all 57600 points of 80 blocks traced
from two files. Against ffmpeg's decode, as the mean difference in
band levels over the whole file, with the noise coding fix applied
before and after:

  StutteringFile (22 kHz mono, 20 kbps)    1.6 dB -> 0.3 dB
  shoujicomcn2117164 (same)                0.2 dB -> 0.1 dB
  terra8k (11 kHz mono, 8 kbps)            0.3 dB -> 0.0 dB

Only the five files that use LSP exponents change; the other 23
are byte-identical.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-05 20:47:12 -04:00
..
libwma.make chore: Get rid of *all* vestigal CVS '$Id:$' tags 2026-06-01 16:01:18 -04:00
SOURCES Fix race conditions in parallel build. 2016-05-28 17:41:32 +02:00
types.h Add codecs to librbcodec. 2012-04-25 22:13:20 +02:00
wmadata.h cleanup: Get rid of erroneous execututable bit on various source files 2026-02-19 07:54:35 -05:00
wmadec.h Rename CPU_S5L870X to CPU_S5L87XX 2024-11-20 10:58:32 -05:00
wmadeci.c wma: fix overflow in the LSP exponent curve 2026-10-05 20:47:12 -04:00
wmafixed.c Add codecs to librbcodec. 2012-04-25 22:13:20 +02:00
wmafixed.h Add codecs to librbcodec. 2012-04-25 22:13:20 +02:00