Repository navigation
Description
The decoder is wrong on an ISO conformance vector
l3-si_huff — MPEG-1 Layer III side-info/Huffman stress, part of the upstream conformance suite — decodes at 26.58 dB against its reference PCM. The float build gets 107.95 dB. The ISO limited-accuracy floor is 60 dB, so the fixed-point decoder fails a conformance vector outright, by 33 dB.
Every existing test passes. That is the more interesting half of this report.
Cause
mp3d_clamp_sample clamped dequantised samples to ±1.0 (MP3D_ONE), and mp3d_dequant returned ±1.0 when the shift went non-positive. The justification was in the header:
Measured (tests/fl/codec/mp3_fixed_point.hpp, "stage dynamic range") the float pipeline peaks near 0.65 at every stage across the conformance corpus and real encoded music ... dequantised samples are clamped to +/-1 besides
The measurement was correct. The corpus it was measured over was 2 of the 83 reference vectors upstream ships. Stage peaks:
| measured over | huffman peak |
|---|---|
| the 2 vendored vectors | 0.14 |
| all 83 upstream vectors | 3.89 (l3-si_huff) |
l3-si_huff reaches 2.44 at the huffman stage in frames 4–7 of 75. The clamp truncated it to exactly 1.0 and the error propagated through IMDCT and the polyphase.
Localised by instrumentation rather than inspection: per-frame PSNR isolated frames 4–7; a saturation counter in mp3d_sat64 showed zero clamping events there, ruling out the first hypothesis; the stage-dump hook then showed the divergence originating at the huffman stage with float 2.441406 against fixed exactly 1.000000 — which is 1 << 26, the clamp constant.
Fix
Clamp to the Q26 representable range (MP3D_SAT_MIN/MP3D_SAT_MAX, i.e. ±32) instead of ±1.0, and saturate rather than return 1.0 in the non-positive-shift branch of mp3d_dequant.
Q26 keeps 8x headroom over the true 3.89 peak, so the format itself was never the problem — only the artificial clamp sitting well below it.
| before | after | float | |
|---|---|---|---|
l3-si_huff |
26.58 dB | 100.00 dB | 107.95 dB |
| vectors clearing the 60 dB floor | 68/70 | 69/70 | 69/70 |
No regressions: all 70 comparable vectors measured before and after, none moved down. The pass rate now matches float exactly, and the one remaining shared failure is a LAME VBR-tag container issue that scores identically on both builds.
Why no test caught it
This is the part worth fixing structurally.
- The fixed-vs-float gates (PSNR >= 90 dB, <= 8 LSB) compare the two pipelines across the vendored corpus. A divergence only present in a vector nobody vendored is invisible to them by construction.
- The SIMD bit-exactness gate compares vector against scalar — both wrong in the same way here.
- The differential fuzzer mutates vendored bitstreams; it cannot invent a stream with this dynamic range.
- The stage dynamic range test is the one that set the ±1.0 bound in the first place, over the same 2 vectors.
Every one of those is an internal consistency check. The only external ground truth was 2 vectors, and neither exercised this path. One vector, l3-nonstandard-big-iscf, drives the pipeline to 230767 — but it is a deliberately malformed stream with no reference, where saturating is the intended behaviour.
Also fixed
l3-si_huffis vendored (181 KB) sobash testcatches this regression without a network.ci/codec_conformance/run.pyfetches all 83 reference vectors from the pinned upstream revision and asserts every one clears the 60 dB floor, for both the fixed and float builds. 19 MB of reference PCM is cached rather than vendored, so the repo stays clonable..github/workflows/mp3_conformance.ymlruns it on any change undersrc/third_party/minimp3/**orsrc/fl/codec/mp3*.- The headroom comment now cites the measurement over the full suite, and says which sample the old figure was taken over.
Known exception, tracked separately
l3-nonstandard-sin1k0db_lame_vbrtag scores 2.85 dB on both fixed and float. The raw mp3dec_decode_frame_r loop — which fl::Mp3Decoder also uses — does not skip the Xing/LAME header frame or apply its encoder delay, so the output is offset against a reference that assumes gapless trimming. That is a container-metadata gap in the caller, not an arithmetic defect, and it means FastLED currently emits the encoder delay and tag frame as audio when playing LAME-encoded MP3s. Worth its own issue.
Found by asking whether the decoder is actually verified against a gold reference, and then checking instead of assuming.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
fix(mp3): close the conformance gate's own blind spots
fix(mp3): widen operands before the polyphase add/sub (#4133)
fix(mp3): skip the VBR tag frame and encoder priming (#4129)
fix(mp3): stop clamping dequantised samples to 1.0 (#4127) (#4128)
perf(mp3): find the gap with Callgrind -- saturation is 24% of the de…
perf(mp3): the DCT saturation defends exactly one malformed vector
perf(mp3): drop the DCT/IMDCT butterfly clamp -- 28% faster on the C6