Commits
Commits on
2cccf178a8bb4ba04fa845f4a9ed002c6a135fe3Filtered to crates/ec-aac/src/decode.rsClear filter2026-08-19
fix(aac): SBR frames without a fresh FIL payload now reuse the last envelopeAhmet Kaan Gümüş · f505821
fix(aac): SBR frames without a fresh FIL payload now reuse the last envelope The windowed lag-drift diagnostic (new EC_AAC_SBR_DRIFT test knob) showed discrete lag PLATEAUS jumping by exactly 1024 samples -- the core frame length -- rather than a smooth per-sample drift. Root cause: raw_data_block only doubled an SCE/CPE's plane when its immediately-following FIL element carried a fresh SBR payload this frame; any access unit whose FIL was missing, non-SBR, or failed to parse silently left that one AU at core (1024-sample) length, permanently shifting every sample after it out of alignment with a reference that stayed at doubled rate throughout. 67 such skips were happening across the two-file sweep. SbrChain now caches each element's last successfully parsed SbrData and apply_last() re-runs the chain with it whenever a frame's own payload is unavailable (Amd 4.6.18's documented "hold state" behavior), so every AU still doubles. reeln ch0: -0.034 -> 0.973 full-band, 0.995 below crossover (bar 0.999 full / 0.9999 below still open). ch1: 0.014 -> 0.772 full-band (plateau structure now flat, remaining gap not yet root-caused). FMJ unchanged (separate pre-existing 11/1500-AU decode failure, documented dead end, left for last per the queue). Added a unit test (sbr_chain::tests) that runs two adjacent synthetic AUs through one SbrChain element and asserts both double to the full 2048 samples with no discontinuity at the junction -- the coverage hole the continuous-stream QMF round trip never exercised.
fix(aac-sbr): two real scale bugs behind the SBR catastrophic blowupAhmet Kaan Gümüş · 92f96f7
fix(aac-sbr): two real scale bugs behind the SBR catastrophic blowup Root cause 1: sbr_chain fed the SBR QMF analysis bank core PCM already at decode::OUTPUT_SCALE (1/65536), but the transmitted envelope/noise data is calibrated against the core's un-normalized internal PCM domain. Undo OUTPUT_SCALE before analysis and reapply it once after synthesis so the gain match (target vs. measured QMF energy) compares like against like. Root cause 2: the hand-designed 32/64-band QMF pair's own round-trip amplitude gain was never checked -- only shape (scale-invariant correlation). It measured ~1% of unity (a real tone demodulates to half its amplitude in a cosine/sine-modulated analysis bank, and this prototype's polyphase overlap-add doesn't sum to a flat constant on its own). Added analytic_gain() (exact 2/sum(h) per-tap correction, applied to both banks) plus a measured SYNTH_TRIM for synthesis's remaining overlap-add shortfall; round-trip amplitude ratio is now 0.999999 (was ~0.01), locked by a new amplitude-ratio assertion in round_trip_reconstructs_the_passband and a new analysis_alone_reads_back_the_input_tones_own_amplitude test. Real-file sweep (crates/ec-aac/tests/sbr_real_library.rs) improved substantially but has not cleared the 0.999/0.9999 bar yet: reeln ch1 full-band corr rose from 0.001 to 0.834, FMJ ch1 remains blown up (rms ~700x too large), suggesting at least one more, channel-specific bug remains. Debug instrumentation stays env-gated (EC_AAC_SBR_DEBUG=1) behind sbr_chain::debug_dump.
feat(aac): wire SBR HF gen + envelope adjustment into the decode chainAhmet Kaan Gümüş · 5206266
feat(aac): wire SBR HF gen + envelope adjustment into the decode chain sbr_chain.rs ties sbr_payload/_hf/_env/_qmf together per element: a FIL element's sbr_extension_data (explicit ASC signaling only, no implicit ADTS detection yet) drives 32-band analysis of the preceding SCE/CPE's core PCM, HF generation, envelope adjustment, and 64-band resynthesis, replacing that element's plane with double-rate PCM. SbrSupport gains a V1 variant (PS still reports CoreOnly); output_sample_rate now reports the extension rate for a reconstructed stream. sbr_is_reported_not_silently_upsampled is updated (not deleted) to pin the new contract, plus a PS case. Not yet exercised: real-file oracle correlation (next commit), implicit ADTS SBR signaling (deferred, named follow-up per charter), filterbank delay compensation for packet timestamps (open -- see report).
2026-08-14
feat(aac): AAC-LC decoder, encoder and rusty_aac shimAhmet Kaan Gümüş · 9a848b4
feat(aac): AAC-LC decoder, encoder and rusty_aac shim Decoder covers AAC-LC end to end: AudioSpecificConfig and ADTS framing, all four window sequences and both window shapes, section and scalefactor data, every spectral codebook including the escape one, pulse data, TNS, M/S and intensity stereo, PNS, and SCE/CPE/LFE/DSE/PCE/FIL elements. Output is film order FL, FR, FC, LFE, BL, BR (SL, SR), which is the order the downmix in this family folds, so a 5.1 track needs no caller-side permutation. HE-AAC's SBR is not reconstructed: such a stream decodes to its AAC-LC core and reports the core rate rather than claiming the extension's. Encoder is a full two-loop search: 2048-point FFT masking with spectral flatness for tonality, bark-ish spreading, a relative hearing-threshold floor, transient-driven window switching, per-band mid/side, exact Huffman bit counts for codebook choice, and a bit reservoir against a CBR target. Both ADTS and bare raw_data_block output. The normative tables were derived rather than transcribed: access units with a chosen spectral payload were decoded by a reference decoder and read back through the inverse MDCT, which enumerates each codebook by a binary tree walk. Every one came out with a Kraft sum of exactly 1 and the entry count the standard prescribes. forbid(unsafe_code) in both crates.