Commits
Commits on
7669974cc0ae2f48f187ca2b6bd4befa7a97a8ee2026-08-20
feat(hw): expose HEVC prefix-SEI HDR peak and VUI colour tags on Frame/DecoderAhmet Kaan Gümüş · 7669974
feat(hw): expose HEVC prefix-SEI HDR peak and VUI colour tags on Frame/Decoder
edith's replica needs MaxCLL/MaxFALL for HDR films whose container never
carried them (they live only in HEVC content_light_level/mastering_display
SEI) — ec-hw's decode() dropped every SEI NAL on the floor. HevcDecoder now
merges ec_core::color::hevc_sei_light per access unit (sticky across frames
that carry none) and resolves VUI colour tags from the SPS; H264Decoder
resolves VUI tags only (no SEI parsing for that codec yet); VP9/AV1 report
None (not implemented). New Frame::colour()/Decoder::colour() surface it,
bundled as ec_hw::frame::Colour{description, light} over the existing
ec-core ColorDescription/ContentLight types.
Tests: hdr_film_light_level_sei_is_exposed pins MaxCLL/MaxFALL 1230/419 and
primaries/transfer/matrix 9/16/9 against the real ReelD rip;
sdr_h264_colour_never_panics proves the VUI-only path doesn't panic on an
SDR fixture (skips when no fixtures generated, same convention as the rest
of gpu.rs).diag(hw): bench + verify the 4K 10-bit frame path, no source defect foundAhmet Kaan Gümüş · a6922c1
diag(hw): bench + verify the 4K 10-bit frame path, no source defect found
Root-caused the four consumer symptoms against the real ReelD HDR film:
1. Frame-path speed (ec-hw/tests/gpu.rs::ten_bit_4k_frame_path_is_realtime):
120-frame bench, decode-only / +to_i420 / +to_i420_16 / +export_prime,
pending-4 back-pressure. In --release: decode+to_i420_16 median 10.36 ms
(39 ms budget, 3.8x headroom); export_prime 1.25 ms confirming sync()
itself isn't the cost. In debug (unoptimized): 139.88 ms -- most of the
consumer's 1352.5 ms/frame is optimization level plus consumer-side work,
not a defect in Frame::to_i420_16/to_i420/with_planes, which already do
the cached-vaGetImage, row-at-a-time, no-vaDeriveImage things the charter
asked to check for.
2/3. P010 chroma correctness (ec-hw/tests/gpu.rs::ten_bit_4k_chroma_is_not_grey):
3 real frames, to_i420 and to_i420_16 vs `ffmpeg -pix_fmt yuv420p{,10le}`,
Y and UV PSNR measured separately. Both bit-exact (Y and UV both inf dB)
at 8- and 10-bit -- the "grey chroma" symptom is not in frame.rs's P010
unpack on this file.
4. Colour metadata (ec-matroska/tests/matroska.rs::
real_hdr_film_container_states_no_light_metadata): the Matroska Colour
element for this file states primaries/transfer/matrix correctly
(bt2020/smpte2084/bt2020nc, matching ffprobe) but genuinely carries no
MaxCLL/MaxFALL/MasteringMetadata children -- confirmed against
`ffprobe -show_entries stream=side_data_list`, which is also empty.
ffprobe's 1230/419 comes from a `content_light_level_information` HEVC SEI
message on frame 0, not the container. ec-matroska is reading the
container correctly; the gap is that nothing in this workspace calls the
existing `ec_core::color::hevc_sei_light` reader (only self-tested in
ec-h265-syntax) from a real decode path -- named here, not implemented,
since ec-hw exposes no colour/light metadata surface at all today and
building one has no reachable consumer in this repo.
cargo test -p ec-hw --test gpu -- --test-threads=1: 20/20 green.
cargo test -p ec-matroska --lib: 9/9 green (the 3 --test matroska failures
are pre-existing missing-fixture errors, `scripts/gen-fixtures.sh` not run;
unrelated to this diff, the new matroska test passed).test(aac-sbr): split core-decode-wrong from SBR-scrambles-good-core in synthetic_heaac_matrixAhmet Kaan Gümüş · 5f50798
test(aac-sbr): split core-decode-wrong from SBR-scrambles-good-core in synthetic_heaac_matrix Adds core_v_ref (our core-only decode, 2x upsampled, vs the reference decoder, below crossover only, wide lag search) and its own lag, plus core_rate/full_rate (our_decode_core_only's vs our_decode's reported output rate) to every HE row -- core_v_ref lands at 0.99+ only when the SBR chain alone is guilty; near 0 when our own core decode of the fixture is already wrong, independent of any SBR machinery.
test(aac-sbr): widen synthetic_heaac_matrix's lag search past its own LAG_MAX edgeAhmet Kaan Gümüş · 93d654a
test(aac-sbr): widen synthetic_heaac_matrix's lag search past its own LAG_MAX edge best_lag_correlation's LAG_MAX=4000 bound was landing every HE-AAC row's winning lag right at its own edge (-3634..-3882); adds best_lag_correlation_wide (±20000, odd-stride coarse pass + full-WINDOW refine, mirrors wide_lag_search_full_chain's shape) and uses it for the full/below/ours_v_core columns plus a new ovc_lag column. Also fixes the `above` band, which was comparing o[..n]/t[..n] with no lag offset at all (only valid by accident at lag 0) -- now re-slices at the winning lag first, same convention sbr_real_library_matches_reference uses. Adds a delay-probe printout on two named rows testing candidate total HE-vs-reference delays.
feat(ec-hw): zero-copy decode-to-encode surface path, VUI colour descriptionAhmet Kaan Gümüş · fc705c7
feat(ec-hw): zero-copy decode-to-encode surface path, VUI colour description Encoder::encode_frame submits a Frame's decoded VA surface directly as the encoder's source picture, with no to_i420 CPU read-back and no re-upload — what the consumer's previous backend did for a decode-then-encode pipeline. Refuses a cross-Display frame, a 10-bit (P010) source (no Main10 profile is built here), or a coded-size mismatch with a typed Error. EncoderConfig::colour(primaries, transfer, matrix, full_range) reaches the VUI of both the H.264 and HEVC packed SPS writers (video_signal_type_present_flag / colour_description_present_flag), so an HDR or BT.709 export stops reading back as "unspecified". Live-GPU tests in gpu.rs cover both: encode_frame vs the CPU-path baseline on the same decoded frames (PSNR compared, further: they came back byte identical on this driver), and ffprobe reading BT.2020/PQ/BT.2020nc back off a written stream while the no-colour-set case stays deterministic.
test(aac-sbr): synthetic HE-AAC matrix fixture to separate rate family from kx geometryAhmet Kaan Gümüş · 002ea6d
test(aac-sbr): synthetic HE-AAC matrix fixture to separate rate family from kx geometry Generates a controlled 16-file HE-AAC/LC fixture matrix (2 sample rates x 4 bitrates x 2 profiles) from one shared synthesized source via the system encoder's HE-AAC profile, and adds synthetic_heaac_matrix to instrument full/below/above-crossover correlation and kx/k2 per row against the reference decoder, plus our own full-chain-vs-core-only self-consistency -- without depending on any single real file's content. LC control rows gate the test (>=0.999), proving the harness before the HE-AAC numbers are trusted.
diag(mkv-seek): exonerate ec-matroska's Cues seek for the +0.145s E-AC-3 landing bugAhmet Kaan Gümüş · c3d09c7
diag(mkv-seek): exonerate ec-matroska's Cues seek for the +0.145s E-AC-3 landing bug Consumer defect (edith_replica engine/tests/audio_seek.rs:251): seeking a real 2h+ HEVC/E-AC-3 5.1 Matroska to t=600s delivers audio content measured at 600.145s. The charter's premise -- "ec-matroska demuxer seek (Cues) -> ec-ac3 decoder" -- is wrong on two counts, found while tracing the actual consumer path (edith_replica crates/engine/src/audio.rs, demux.rs): the AC-3/E-AC-3 decoder the engine actually links is the third-party `oxideav-ac3` crate (Cargo.toml pinned "=0.0.10"), not this repo's own ec-ac3, which is unused by that path entirely; and the engine's Matroska AC-3 track (MkvAudio/BlockReader, demux.rs:1610-1711) does not seek by an approximate Cues landing at all -- it pre-walks every block of the track into an exact in-memory index (mkv_walk_blocks, a full linear next_packet() scan) and binary-searches that for the exact block, using MatroskaDemuxer::seek only as a coarse position to scan forward from until the exact expected timestamp is found (BlockReader:: park_at). Added seek_landing_on_his_eac3_film_matches_ffprobe (crates/ec-matroska/tests/ matroska.rs), gated on the real film's presence: seeks this crate's own MatroskaDemuxer::seek(SyncBefore) straight to 600s/610s on the audio stream and prints the landed packet pts against ffprobe's own packet near the same instant, no decode involved. Measured: 600.000s/609.984s (E-AC-3, ffprobe 599.840/609.760) and 599.961s/609.861s (an Opus 5.1 remux, same-class sweep, ffprobe 599.954/609.854) -- landings within one block (<=40ms) of target on both codecs, an order of magnitude tighter than the 0.145s/3.4s the consumer measured. MatroskaDemuxer::seek is not the source of the drift. Root cause is therefore downstream of every crate this repo owns: either oxideav-ac3's decode (third-party, pinned, not fixable here) or the pos/ segment bookkeeping in engine::audio::run_mkv_ac3 (edith_replica, out of this worktree's charter -- "Work ONLY there" is edith_codecs_seek). Left un-fixed and reported rather than silently satisfied by patching a demuxer that was not broken. No fix landed: the defect is not in this repository's source.
fix(ec-hw-hevc): drop RASL pictures after a seek's random-access CRAAhmet Kaan Gümüş · e1b58c9
fix(ec-hw-hevc): drop RASL pictures after a seek's random-access CRA Root cause (crates/ec-hw/src/dec/hevc.rs): a CRA that opens a mid-stream random-access point stores its RASL leading pictures *after* itself in decode order even though they display *before* it (H.265 open-GOP coding). Those RASL pictures predict from pictures before the CRA, which a decoder started at that CRA — exactly what a seek does — never decoded. The old code decoded and output them anyway: bump() orders output purely by POC, so the (garbage) RASL pictures came out ahead of the CRA itself, shifting every subsequent output index by however many RASL pictures the GOP has. Per 8.1.3, `NoRaslOutputFlag` is 1 for the first picture of a coded video sequence — which the first IRAP after a `reset()` (mid-stream start) always is. RASL pictures (nal_type 8/9) associated with such an IRAP must not be decoded or output (8.1.3 / C.5.2.2). `HevcDecoder` now tracks that flag (`no_rasl_output`, set in `start_picture` on every IRAP) and skips `start_picture` entirely for a RASL access unit while it holds, so the picture is dropped whole rather than handed to the driver or bumped out. New test `hevc_seek_matches_linear_mkv` (crates/ec-hw/tests/gpu.rs) drives this through the real entry surface: it primes a fresh `Decoder` with the stream's parameter sets, `reset()`s it (a seek's exact contract per the existing reset() doc comment), feeds it from the CRA access unit preceding display frame 30 of test_hevc.mkv, and asserts the first decoded picture matches a linear decode of frame 30. Confirmed failing before this fix (mismatched I420 planes) and passing after. cargo test -p ec-hw --test gpu -- --test-threads=1: 18 passed (17 pre-existing + the new one), 0 failed.
fix(ec-hw): crate doctest compiles again (hidden fn item defeated rustdoc main-wrapping)Ahmet Kaan Gümüş · 6f27127Browse files
diag(aac-sbr): root-cause a real-file HE-AAC v1 decorrelation to the SBR QMF chain, not the LC coreAhmet Kaan Gümüş · 87b805d
diag(aac-sbr): root-cause a real-file HE-AAC v1 decorrelation to the SBR QMF chain, not the LC core Round-51 triage on a real-file HE-AAC v1 stereo commentary track (24kHz core / 48kHz SBR, kx=27/k2=59 -- a materially wider low-band crossover than the other tracked real file's 22.05k/44.1k kx=14/k2=43 family): - ASC hand-parsed and cross-checked against parse_audio_specific_config's bit-for-bit walk: object=AAC-LC, sf_index=6 (24000), channel_config=2, backward-compatible SBR sync extension (0x2B7) correctly found, extensionAudioObjectType=5, extensionSamplingFrequencyIndex=3 (48000). Config parsing is correct; TRIAGE item 1 (mis-parsed ASC / rate family) is refuted. - New `core_only_matches_reference` test (SBR forced off at the AudioSpecificConfig level, so decode.rs's FIL branch never touches sbr_chain at all): this track's LC core alone correlates 0.999977/0.999974 against the reference decoder at the core rate. The LC core is not the defect. - New `wide_lag_search_full_chain` test: the full SBR-reconstructed output finds no usable alignment against the reference anywhere in a +-4.16s window (vs. the normal +-4000-sample LAG_MAX) -- this is not a missed alignment lag, the content itself has decorrelated. - New `full_chain_low_band_matches_own_core` test: compares our own full-chain output against our own core-only decode of the SAME stream, no reference decoder involved. The 22.05k-family file's self-consistency is 0.99. This 24k-family file's self-consistency is -0.02/0.01 -- the SBR chain does not even reproduce its own untouched low-band passthrough (`v[0..kx]`, a literal copy of the same core analysis data) once it goes through the SBR QMF chain. - EC_AAC_SBR_HF_BYPASS=1 (new, sbr_chain.rs, default off): skips filling v[kx..k2] from the HF generator entirely. This file's self-consistency is UNCHANGED (-0.02/0.01) with HF fully bypassed, while the other file's improves slightly (0.99->0.99) as expected from removing HF leakage. This refutes the entire HF-generation/envelope-adjust/noise axis (the subject of every prior round's dead-ends) as this file's cause: the defect survives with the HF generator entirely out of the loop. Conviction: the break is in the SBR chain's QMF analysis->synthesis round-trip itself (sbr_qmf.rs Analysis/Synthesis, or the raw-band copy feeding it) for this kx/k2 (near-32, wide-crossover) configuration, not in HF generation, not in the LC core, and not in reference alignment/test methodology. A rate-independent constant-delay hypothesis was also checked and refuted (this file does not correlate at the other file's own- core delay of -897 samples either). No fix in this diff -- root-cause LOCATION only; see ledger for the next round's starting point. cargo test -p ec-aac --lib: 50/50 green. fmt clean. clippy -D warnings clean.
revert(aac): sbr_hf::generate back to all-pole residual resynthesis, measurement over recallAhmet Kaan Gümüş · fee35a8
revert(aac): sbr_hf::generate back to all-pole residual resynthesis, measurement over recall Round-48 (8bc305b) rewrote the chirp stage from all-pole residual resynthesis to the spec's literal feed-forward FIR extension, justified as spec-correct, and it regressed the real-file bar: full-band correlation against the reference decoder on reeln dropped 0.972474->0.963863 (ch0) and 0.969785->0.961027 (ch1), same direction on below-crossover (0.992799->0.991256, 0.992329->0.990690) and whole-file windowed-mean correlation (0.955717->0.953189, 0.951577->0.949116). Round-50 A/B at HEAD, both arms otherwise identical (reeln, single deterministic run each -- no RNG in this decode path so a repeat run would be bit-identical): metric all-pole (ch0/ch1) feed-forward (ch0/ch1) full-band corr 0.972474 / 0.969785 0.963863 / 0.961027 below-crossover corr 0.992799 / 0.992329 0.991256 / 0.990690 whole-file windowed mean 0.955717 / 0.951577 0.953189 / 0.949116 All-pole wins on every metric, both channels, by well over the 0.002 noise floor. This project's standing discipline: a from-memory "spec" label does not outrank a measurement; the bar is matching the reference decoder's actual output. Reverting the filter structure; the round-48 unit test is rewritten (`all_pole_resynthesis_matches_bw_endpoints`) to pin the all-pole behavior as the empirically-matching variant, with a module-doc paragraph documenting that both structures were implemented and measured, and which one won. The feed-forward alternative and its own discriminating test stay in history (8bc305b) as the documented "spec-literal" alternative, should some other pipeline change ever make it the better match. FMJ's pre-existing, separately-tracked ch1 decorrelation is unaffected (unchanged by this revert, out of scope).
fix(aac-sbr-test): whole-file windowed corr mean was double-applying the alignment lagAhmet Kaan Gümüş · dd00c7c
fix(aac-sbr-test): whole-file windowed corr mean was double-applying the alignment lag 197cd44's cheap default path (no per-window search) added the global `lag` on top of `oa`/`ob`, which already encode that same shift via their differing base offsets -- every window ended up an extra `lag` samples out of alignment. That collapsed reeln's reported WHOLE-FILE windowed corr mean from ~0.95 to 0.14/0.21 while the single-WINDOW full/low numbers (which don't go through this path) stayed at 0.96-0.97, making it look like a real late-file collapse. Corrected mean: ch0 0.953189, ch1 0.949116 -- in line with round 41's 0.9565/0.9512, decode itself never regressed. Round 48's feed-forward FIR verdict is unaffected: it was based on `full`/`low`/QMF-witness numbers, none of which go through this buggy path.
fix(aac): sbr_hf::generate runs the spec's feed-forward FIR, not an all-pole resynthesisAhmet Kaan Gümüş · 857b408
fix(aac): sbr_hf::generate runs the spec's feed-forward FIR, not an all-pole resynthesis
The module's own doc admitted the chirp stage re-synthesised the copied
subband's residual through a bandwidth-expanded ALL-POLE filter (`y =
residual + ca1*y[n-1] + ca2*y[n-2]`). ISO/IEC 14496-3 SS4.6.18.6 is
feed-forward: X_high[l] = X_src[l] + bw*a1*X_src[l-1] + bw^2*a2*X_src[l-2],
a 2-tap FIR extension of the raw copy, using the source band's own
covariance-method LPC coefficients unnegated (pinned by the new
`feed_forward_extension_matches_bw_endpoints` unit test: a noiseless AR(2)
source at bw~0.98 comes out ~1.98x reinforced/same-phase, not attenuated or
inverted the way a negated convention would produce; bw=0 is an exact plain
copy). HfHistory drops its now-unused y-history half.
Round-48, Task 2's sim->ours vs sim->ref transfer fit (patch (3,28,11),
`hf_patch_transfer_fit` now takes a `target_is_ours` flag) shows the two
fits already have similar order-2 shape before and after this change --
the structural gap this round targeted wasn't gating most of the shortfall.
Judged on reeln (both channels), the fix is spec-correct but measures
slightly WORSE on every witness, not better:
full-band correlation: ch0 0.972474->0.963863, ch1 0.969785->0.961027
QMF-WITNESS sim-vs-ours (odd-gap[28,43)): ch0 0.3082->0.2814
QMF-WITNESS ours-vs-ref (odd-gap[28,43), new pairing added to the
witness this round): ch0 0.4400->0.4222, ch1 0.4635->0.4258
FMJ's pre-existing, separately-tracked ch1 decorrelation is unaffected
(out of scope here). No regression bound is weakened; this is reported as
a spec-compliance fix with a measured (small) real-file cost, not a win.docs(aac): round-47 re-trial of band_shift_correction refuted by the trustworthy witness tooAhmet Kaan Gümüş · 20037c7
docs(aac): round-47 re-trial of band_shift_correction refuted by the trustworthy witness too Round-46's QMF-exact fit of the reference decoder's own HF content on patch (3,28,11) found a transfer carrying band_shift_correction's quarter-turn phase signature, raising doubt that round-37's revert (based on the STFT-based EC_AAC_SBR_PARITY_SPLIT metric, since shown untrustworthy at this precision) was the wrong call. Re-applied the rotation at generate's patch-copy site behind a temporary env gate and re-judged with EC_AAC_SBR_QMF_WITNESS's own QMF-domain coherence table -- the trustworthy instrument this re-trial was chartered to use instead of PARITY_SPLIT. Both signs of the rotation made sim-vs-ours coherence on the exact patch the fit was built from WORSE (band28 0.2628->0.0161/0.0282, band38 0.0669->0.0694/0.1068), moving further from the reference's 0.42-0.79 rather than toward it. Round-46's fit-based prediction does not survive contact with the instrument that was supposed to vindicate it. No production code changes: the trial code (env gate, rotation application, HfHistory::slot_phase) is reverted in full. Only the doc comment above band_shift_correction gains a coda recording this re-trial so a future round doesn't re-litigate it a third time on the same fit alone.
test(aac): QMF-domain exact third witness for SBR HF content (round-46)Ahmet Kaan Gümüş · be3ee94
test(aac): QMF-domain exact third witness for SBR HF content (round-46) Adds HfAnalysis (a 64-band forward analysis bank sharing Synthesis's own convention) plus a validated self-consistency control, and rebuilds the STFT-approximate patch-copy simulator (round-45) in this exact band grid (EC_AAC_SBR_QMF_WITNESS) with a per-band 2nd-order complex transfer fit between the plain-copy sim and the reference's real HF content (hf_patch_transfer_fit) plus a bw-value dump (EC_AAC_SBR_BW_DUMP) for comparison against our own chirp coefficients. On reeln, the exact-domain witness overturns round-45's STFT-based lead: for patch (3,28,11) sim-vs-reference clears 0.5 on most bands (0.42-0.79) while sim-vs-ours stays well under it (0.26-0.42) -- the opposite polarity from the STFT approximation's hint. The fitted sim-to-reference transfer on that same patch shows non-trivial order-2 structure with a phase signature (~i, ~-1, ~-i across taps 0/1/2) matching this file's own already-characterized (and currently disabled) band_shift_correction quarter-turn convention -- flagged in the ledger as the next concrete thing to re-test with this sharper instrument, not implemented here (round-37's contrary real-file evidence used a scale-trap-prone 8-bin STFT metric this round's own control work found unreliable; re-enabling a previously-reverted correction needs its own verification budget).
debug(ec-aac): third-witness plain patch+gain simulator for SBR HF contentAhmet Kaan Gümüş · 1117d7a
debug(ec-aac): third-witness plain patch+gain simulator for SBR HF content Reference-free model: copies the decoded reference's low band through the verified patch map, rescales per (band, hop) to each comparison side's own energy, then measures complex coherence sim-vs-reference and sim-vs-ours -- breaking the pairwise ours-vs-reference deadlock. Gated by EC_AAC_SBR_SIMULATOR, lands as a permanent diagnostic.
fix(sbr): correct the QMF in-band measurement bug, box-car the injected noise drawAhmet Kaan Gümüş · 3b60454
fix(sbr): correct the QMF in-band measurement bug, box-car the injected noise draw sbr_qmf's synthesis_energy_gain_for_white_noise_excitation measured its in-band FFT window at k0/SYNTHESIS_BANDS; band k's passband is actually centred at (k+0.5)*omega_step with omega_step = pi/(2*SYNTHESIS_BANDS), half that fraction of Nyquist, so the window sat on the alias image, not the signal -- the round-43 "~0% in-band survival" reading was this bug, not a Synthesis defect. Corrected, a raw i.i.d.-per-slot draw already lands ~0.49 of its own energy in-band; a 2-slot boxcar (sbr_env::NoiseGen) raises that to ~0.61 while staying noise-like (spread across the band, not a residual tone). Re-measuring the real-file whole-HF realized noise fraction after shipping the boxcar shows it barely moves (0.1787 -> 0.1770): that metric sums energy across the whole swept HF spectrum, and energy an i.i.d. draw aliases to a neighbouring QMF band still lands inside that same sweep, so it was never actually excluded. The ~0.38 bookkept vs ~0.18 actual gap is therefore a genuine energy shortfall plus a content defect (measured coherence sits well below even the actual-fraction ceiling), not the noise-sequence-shape problem round-43 diagnosed. Tightens sbr_actual_noise_fraction's regression floor from 0.15 to 0.17, the level both before and after this fix.
fix(ec-aac): convict the SBR noise-realization gap in synthesis, not adjustAhmet Kaan Gümüş · 30721a2
fix(ec-aac): convict the SBR noise-realization gap in synthesis, not adjust Round-43 Task 1/2: EC_AAC_SBR_CELLDUMP on reeln (with the charter's quoted Hz bands corrected -- they were read off bin_level_conviction's 172.3Hz FFT-analysis spacing, not this file's true 344.5Hz SBR band spacing) shows sbr_env::adjust injecting 40-85% noise share in the QMF domain, at or above the ~0.37 bookkept split -- not starved. The add_harmonic/sinusoid-interaction hypothesis is also refuted: no harmonic flags fire on any of the convicted bands in this stream. synthesis_energy_gain_for_white_noise_excitation (sbr_qmf.rs) drives one Synthesis subband with the same independent-per-slot random complex value adjust() injects and finds ~0% of that energy reconstructs back in the source subband's own frequency range, against a tone's clean in-band placement -- an i.i.d.-per-slot draw isn't a legitimate "bandlimited subband content" input to this filterbank's complex-modulation convention, so it aliases out almost entirely instead of surfacing as audible noise near the intended frequency. This is the charter's Task 3 "noise SEQUENCE is the last mile" scenario, not an adjust() accounting bug; sbr_actual_noise_fraction's regression floor is documented accordingly and left untightened since the actual gating defect is still open.
debug(ec-aac): EC_AAC_SBR_CELLDUMP per-(envelope,band) noise-realization dumpAhmet Kaan Gümüş · 79dc3f6
debug(ec-aac): EC_AAC_SBR_CELLDUMP per-(envelope,band) noise-realization dump Round-43 Task 1: env-gated dump in sbr_env::adjust printing target/ signal_target/noise_here/cur/raw+capped gain/boost/namp and the actually- injected (and post-addition) sample energy per absolute QMF band, so the noise-realization gap can be read directly off real content instead of guessed at.
fix(aac-sbr): boost accounting conserved signal-only against the full envelope target, and noise_amps divided per-sample energy by width a second timeAhmet Kaan Gümüş · f737a34
fix(aac-sbr): boost accounting conserved signal-only against the full envelope target, and noise_amps divided per-sample energy by width a second time adjust()'s limiter boost pass accumulated lim_e_orig from the cell's FULL transmitted target (signal+noise) but measured lim_e_actual from the capped SIGNAL gain alone, driving the boosted signal all the way up to the cell's total budget as if no noise share existed. Matched against the reference algorithm's known E_orig/E_curr+Q_M boost ratio: lim_e_actual now folds the noise share back in so both sides conserve the SAME total. Separately, noise_amps divided the already-per-sample noise_here by the cell's QMF-band width, shrinking injected noise variance by 1/width on top of everything else -- worst at the wide high-frequency sfb cells, which is exactly where the realized-vs-bookkept gap was largest. reeln whole-HF realized noise fraction (EC_AAC_SBR_NOISE_ANCHOR): 0.1325 -> 0.1787 against a ~0.38 bookkept split. Two residual defects (named, not fixed here): three loud harmonic-dominated bands still realize ~0.001-0.015, and bands above ~8.5kHz decay toward 0 with rising frequency -- both are separate from this accounting mismatch. Also fixes sbr_actual_noise_fraction's own band_hz->QMF-band lookup, which used bin_level_conviction's internal FFT-band scale (rate/256) instead of the true QMF band width (rate/128), silently doubling every looked-up band index and making every real band above roughly half of k2 read back a false 0.0 bookkept fraction -- the round-42 charter's "noise coverage gap above 7.4kHz" was this test bug, not a decoder defect.
fix(aac-sbr): NoiseGen was DC-biased and under-scaled, realizing ~1/6-1/9 of the transmitted noise splitAhmet Kaan Gümüş · 64cc642
fix(aac-sbr): NoiseGen was DC-biased and under-scaled, realizing ~1/6-1/9 of the transmitted noise split
Round-41 Task 1 (instrument anchor): bin_level_conviction reads exactly
1.0 on ours-vs-ours and reference-vs-reference-through-remux, and
0.995+ up to 14.8kHz on a reference-vs-itself 64-sample-offset control
(only degrading in the near-silent >15kHz tail) -- the coherence
instrument is not the story behind reeln's ~0.15-0.25 HF readings.
Round-41 Task 2 (round-24 contradiction): measured actual injected
noise as output energy (decode twice, noise on vs EC_AAC_SBR_NOISE_ZERO,
per-band energy delta) instead of trusting either side. Two real bugs
in NoiseGen found and fixed:
- next()'s divisor was one bit short (1<<23 instead of 1<<24), so it
was actually uniform on [-0.5, 1.5) (mean +0.5, DC-biased) rather
than the intended zero-mean [-0.5, 0.5).
- complex_unit()'s two components then had E[|z|^2] = 1/6, not 1, so
adjust()'s namp*z scaling only ever realized ~1/6 of noise_here.
Both fixed; new unit tests pin complex_unit()'s statistics directly.
Measured effect: actual/bookkept noise fraction in noise-covered bands
0.095 -> 0.171 average (bookkept ~0.38, still short -- the limiter/
boost pass's lim_e_orig accumulates the FULL envelope target while its
gain is computed from signal_target alone, a separate pre-existing
mismatch not fixed here). Round-24's "zeroing changes corr by <0.001"
was independently reproduced (0.000957, now 0.001421 post-fix) and
was never in contradiction with the bookkept split once actual
realized energy is measured directly instead of assumed equal to it.
Also gates the O(windows*4001*4096) whole-file drift search in
sbr_real_library_matches_reference behind EC_AAC_SBR_TIMELINE (was
unconditional, ~4min/channel); default path now reuses the established
global lag with no per-window search for the same mean/min summary.test(aac-sbr): gate the O(windows*4001*4096) whole-file drift search behind EC_AAC_SBR_TIMELINEAhmet Kaan Gümüş · f6d8fb3
test(aac-sbr): gate the O(windows*4001*4096) whole-file drift search behind EC_AAC_SBR_TIMELINE Default path now reuses the already-established global lag with no per-window local search (O(windows*4096)) for the mean/min summary, cutting the real-library test from ~4min/channel to seconds while the full drift-search table is still available on demand.
test(sbr): round-40 fine-bin spectral shift scan + complex-gain fingerprintAhmet Kaan Gümüş · 3a95342
test(sbr): round-40 fine-bin spectral shift scan + complex-gain fingerprint Task 1 (EC_AAC_SBR_BIN_SHIFT): scans HF bin-coherence with ours-vs-reference paired at a b-bin offset (b=-7..=7), split even/odd patch-gap regions -- reeln ch0 peaks cleanly at b=0 in BOTH regions (0.1526 even-gap, 0.1983 odd-gap; every other b lower, no secondary peak), refuting the half-QMF-band frequency-offset hypothesis. Task 2 (EC_AAC_SBR_COMPLEX_GAIN): per-STFT-frame complex ratio O/T on each top-energy band's dominant bin -- magnitude and phase both swing randomly frame to frame with no steady rotation rate, consistent with the Task 1 refutation (a real carrier offset would show a fixed dphase/frame). Both diagnostics are additive, gated behind their own env vars (default off), no existing assertion touched.
diag(aac): AU-level failure printing for the sbr_real_library sweepAhmet Kaan Gümüş · cc56143
diag(aac): AU-level failure printing for the sbr_real_library sweep EC_AAC_SBR_AU_FAIL_DEBUG=1 gates a per-AU index/error/first-bytes dump in our_decode(), for tracing which access units a real HE-AAC track fails to decode. Run against the HE-AAC commentary candidate (48kHz, mkv, absolute stream 3): zero of 1500 access units fail this round -- the "N/1500 AUs fail" fact recorded earlier in the investigation no longer reproduces at HEAD, superseded by intervening grid/pointer fixes. That file's catastrophic full-band decorrelation persists with a clean, non-dropped AU count, so it is not a timeline-shift artifact of missing samples -- the remaining cause is upstream of AU-level decode failure and is not root-caused this round.
test(sbr): sweep for a constant HF-only QMF-slot lag against the referenceAhmet Kaan Gümüş · 4c5640d
test(sbr): sweep for a constant HF-only QMF-slot lag against the reference Round-38 Task 1: EC_AAC_SBR_HF_LAG_SWEEP shifts only our decoded HF read position by k*64 samples (k = -8..=8 QMF slots), reference and low band held fixed at the already-established global alignment, and averages per-bin direct coherence over every HF band. On reeln both channels peak cleanly at k=0 (ch0 0.1739, ch1 0.1845) with every other k lower (0.10-0.15) -- refutes the HF-only constant-lag hypothesis; no sbr_chain delay implemented.
revert(aac-sbr): the patch copy stays unrotated -- the reference matches the raw conventionAhmet Kaan Gümüş · 1b74eca
revert(aac-sbr): the patch copy stays unrotated -- the reference matches the raw convention The round-35 quarter-turn correction is frequency-pure by unit measurement, and wrong by the bar: a 4-way A/B on the real file (off / as-is / sign flipped / half rate) has the uncorrected copy winning decisively in the very bands the correction targeted (odd-gap direct coherence 0.19 vs 0.07). The reference reproduces the same cross-band convention, so matching it means leaving the copy raw. band_shift_correction stays as documentation of the characterized convention, pinned by its own tests; the production-path test now exercises generate() itself and pins the raw-copy placement.
probe(sbr): parity-split direct-coherence instrument, even-gap vs odd-gap territoryAhmet Kaan Gümüş · c39572e
probe(sbr): parity-split direct-coherence instrument, even-gap vs odd-gap territory EC_AAC_SBR_PARITY_SPLIT reports bin_level_conviction's direct-coherence mean separately for header A's even-gap patch territory (bands 14..28, from (0,14,14), already exact before round-35) and its odd-gap territory (bands 28..43, from (3,28,11)/(0,39,3)/(13,42,1), where round-35's Synthesis phase-intercept correction landed) -- the region split the full-band/HF "direct" numbers can't see (odd-gap bands are ~15 of ~100 total HF bands, swamped by even-gap's dominant energy in any energy-weighted metric). Round-36 before/after (git-checked-out src at HEAD~1 vs HEAD, same real file): odd-gap direct coherence REGRESSES sharply after round-35's fix (ch0 0.1907->0.0714, ch1 0.2461->0.0741) while even-gap stays flat (ch0 0.1526->0.1510, ch1 0.1848->0.1749) -- the opposite of the charter's "odd-gap improves" expectation. bw=0 (EC_AAC_SBR_BW_SCALE=0) moves neither region (ch0 even 0.1517/odd 0.0707, ch1 even 0.1745/odd 0.0727, both indistinguishable from bw=1), exonerating the chirp/whitening IIR as the cause of either number.
fix(aac): SBR HF patch copies land at the wrong absolute frequency, one full band offAhmet Kaan Gümüş · 2f5c8e2
fix(aac): SBR HF patch copies land at the wrong absolute frequency, one full band off Unit-level conviction (sbr_qmf.rs): Synthesis's odd-stacked modulation kernel centres band k with a phase intercept of (k+0.5)*pi/4, which only cancels against a receiving band's own reconstruction when source and target band coincide. Replaying a source band's raw complex series into a *different* synthesis band -- exactly what sbr_hf's HF patch copy does -- lands the content one full synthesis-band-width off whenever the band gap is odd, sign alternating with (target-source) mod 4; even gaps were already exact. Pinned by two new sbr_qmf tests (patch_replay_preserves_ absolute_frequency_mapping, synthesis_offset_sense_is_self_consistent_ within_a_band) that measure the dominant spectral line via Analysis+ Synthesis round trips instead of asserting against a hand-derived constant. Fix applied at the patch-copy site (sbr_hf::generate), not the tuned QMF bank convention itself: round-trip/gain-flatness bounds there were hard-won by prior brute-force search and a same-shape retune was out of this round's scope. band_shift_correction() computes the needed quarter-turn-per-slot counter-rotation from (target - source) mod 4 and HfHistory now carries a slot-phase counter so the correction stays phase continuous across frame boundaries.
debug(aac): QMF-domain per-stage SBR HF energy dump, gated by EC_AAC_SBR_QMFDUMPAhmet Kaan Gümüş · ea6cc30
debug(aac): QMF-domain per-stage SBR HF energy dump, gated by EC_AAC_SBR_QMFDUMP Round-34's decisive measurement: dump per-QMF-band mean energy at analysis output, post-patch (pre-adjust), and post-adjust in sbr_chain.rs, and probe header A (kx=14/k2=43) at source bands p=0/5/13. Result: generate()'s patch application places content EXACTLY where build_patches predicts (verdict: generate()/adjust()/the kx-row synthesis copy are all exonerated) -- the "wrong target band" cluster reported by earlier rounds' sbrpatchmap.py probe was an artifact of that probe's own tone-placement bin math (k = p*32+16 assumed 32 core-MDCT bins per QMF band; empirically re-derived via this same dump to be 16, confirmed exact for p=0/5/13) plus a noise0=[2,2] "quiet" setting that was actually loud (low raw index = louder noise floor, matching sbr_env::dequant_noise's spec-correct direction). Both fixed in sbrpatchmap.py. The QMF-domain sanity gate (post-patch stage) now matches build_patches' prediction exactly for every probed p; the PCM/FFT-domain frequency-line readout still shows a separate, weaker artifact specific to this single-isolated-tone-with-flat-envelope probe shape (not chased this round -- out of Task 1's QMF-domain scope, and not corroborated by the real-file sweep, which is unchanged: 0.971793/0.967975 full-band, 0.956522/0.951190 whole-file mean, 0.992565/0.991558 below-crossover, identical to the pre-round-34 baseline since this change adds no new always-on code path).
fix(aac): SBR limiter caps per limiter-band aggregate, not per empty cellAhmet Kaan Gümüş · 0a60b22
fix(aac): SBR limiter caps per limiter-band aggregate, not per empty cell sbr_env::adjust's gain cap was per-CELL: limiter_max*sqrt((noise+current)/current), which is infinite as current->0 -- every content-empty target cell (a patch boundary with no source energy) amplified numeric dust to the full transmitted envelope. Replaced with the spec-shaped limiter (Sec 4.6.18.7.2/.7.5): a limiter band table (sbr_hf::limiter_band_table, union of f_low borders and patch target boundaries, thinned to ~1/2/3 bands/octave by bs_limiter_bands) with an AGGREGATE cap sqrt(E_orig/E_curr)*limgain per band, so an empty cell inherits its band's cap instead of blowing up alone, plus gain-boost compensation (+4dB ceiling) applied to gains/noise/sinusoids so a capped band still reaches its transmitted total when the population isn't actually starved. Verification (round 33): - Probe sanity gate (scripts/aac-tables/sbrpatchmap.py, headers A/B/C): STILL FAILS -- our decoder's measured target map still does not match build_patches' prediction, and does not collapse to a per-source-varying map. The convicted "infinite per-cell gain" mechanism is fixed, but is not the probe cluster's sole/primary cause; a separate defect remains (HF patching/frequency placement or QMF synthesis), not chased further this round. - Real file (reeln.mp4, EC_AAC_SBR_HF_CONVICTION=1): full-band ch0 0.973->0.9718, ch1 0.972->0.9680; whole-file mean ch0 0.9585->0.9565, ch1 0.954->0.9512; below-crossover ch0 0.993->0.9926, ch1 ~0.993->0.9916; HF bin coherence (TASK2 direct-match mean) ~0.2 baseline -> ~0.08 (ch0) / ~0.14 (ch1), i.e. LOWER, not higher. The correctness fix does not move this file's bar upward -- reported honestly, not chased into further guessing this round. limiter_caps_a_pathological_gain renamed/rewritten to limiter_stays_finite_on_a_uniformly_starved_band: a semantics change, not a bound weakening -- the old assertion (uniform starvation stays capped near the raw HF estimate) is mathematically wrong under a correct aggregate cap+boost (boost legitimately undoes a uniform cap when nothing in the band needs protecting from disproportion, since cap and boost read the same aggregate population); the new test checks the actual invariant this round fixes (finite/bounded, not literally unbounded) and a new test (a_content_empty_cell_inherits_its_limiter_bands_aggregate_cap) asserts the crux: an empty cell next to a loud cell inherits the band cap, not infinity. lib 42/42 green, fmt/clippy -D warnings clean. FMJ candidate still fails outright (separate pre-existing issue, not this round's scope).
probe(sbr): engagement bisection converges on the harness, not the payloadAhmet Kaan Gümüş · 854ea37
probe(sbr): engagement bisection converges on the harness, not the payload Round-32: field-by-field bisection of stream() (known-engaging) against stream_one_band() found every candidate flip (header shape, core content, delta-Huffman words) engages identically once wrapped through wrap_sbr's explicit-SBR ASC -- stream_one_band's bit construction was never the bug. sbrpatchmap.py's run_header() was still routing the reference side through bare-ADTS ffmpeg decode (P.decode), never adopting wrap_sbr after round-31 built it; ref_decode() fixes that, and the reference now shows genuine, per-source-band-varying patch maps with the dequant warning firing once at stream head only. Also fixes adts_to_pcm's --same-rate-sbr config, which independently diverged from wrap_sbr's ASC (object_type=2/AAC-LC and sample_rate=44100 for what is actually a 22050 Hz core) -- now built via the same write_audio_specific_config + with_config_bytes round trip wrap_sbr uses. Task 2's sanity gate (ours == build_patches prediction) still fails after both fixes -- our decoder's measured target set is a near-constant [14,15,18,19,20,21] band cluster regardless of source band or header, unlike the reference's now-varying read -- a distinct, unresolved defect in sbr_hf.rs's generate() or the QMF path, blocking Task 3/4 (the verdict).
aac(sbr): explicit-SBR AudioSpecificConfig writer, plus a wrap-to-mp4 probe instrumentAhmet Kaan Gümüş · 9b44442
aac(sbr): explicit-SBR AudioSpecificConfig writer, plus a wrap-to-mp4 probe instrument write_audio_specific_config never emitted the extension sf_index/ extensionAudioObjectType an AOT_SBR/AOT_PS config needs (§1.6.2.1) -- it wrote plain GASpecificConfig fields regardless of object type, so every config it built for an SBR-signalling caller was spec-invalid. Extended it minimally (parse_audio_specific_config already read the extension fields correctly, so only the writer was missing them) and added a round-trip unit test. Also adds crates/ec-aac/examples/wrap_sbr, the round-30/31 instrument blocker's fix: wraps bare ADTS probe streams (the SBR patch-map scripts' output) in an mp4 carrying this explicit-SBR ASC as their esds, so the reference decoder has an out-of-band AudioSpecificConfig to arm HE-AAC output from instead of only its (never-engaging) implicit per-frame detection on bare ADTS.
diag(sbr): fix source-band placement math to 32 bins/band, surface a deeper SBR-engagement blockerAhmet Kaan Gümüş · 7049a6c
diag(sbr): fix source-band placement math to 32 bins/band, surface a deeper SBR-engagement blocker sbrpatchmap.py's probe placed its isolated tone at k = p*16 + offset, assuming a source (low) QMF band is 16 core-MDCT bins wide. It is 32 (1024-bin core MDCT / 32 core bands). Fixed to k = p*32 + 16 (band center, lands cleanly on a group boundary so no fractional-offset trick is needed). Calibrating that fix against the unambiguous header-A anchor ((13, 42, 1), a width-1 patch) surfaced a deeper, blocking problem: ffprobe shows these synthetic ADTS probe streams never engage the reference decoder's SBR/HE-AAC upsampling at all (sample_rate=22050, no HE-AAC profile, decoded PCM length exactly core-rate), unlike the real reeln fixture (profile=HE-AAC, sample_rate=44100). The "No quantized data read for sbr_dequant." warning's raw occurrence count (fires once per 26-frame stream) reads as benign by the charter's own heuristic but is not: an env0 power sweep shows the predicted target window is flat while a large, smoothly-scaling, envelope-driven signal appears well outside it, and never flips the decoder into HE-AAC output. Reproduces for both tone_core and broadband_core_bits content, so it's a property of the shared frame/extension-payload construction, not either core-spectrum writer -- a generalization of round-27's tone_core-specific dead-end. Sanity gate (our decoder's map == build_patches prediction) and the reference-map read are both gated on fixing that engagement bug first; sbr_hf.rs is left untouched pending it. crates/ec-aac --lib: 40/40.
fix(sbr-tables): stop sbrpatchmap's delta-huffman filler desyncing envelope1/noise1Ahmet Kaan Gümüş · a913c84
fix(sbr-tables): stop sbrpatchmap's delta-huffman filler desyncing envelope1/noise1 sbr_bits_full's slot() defaulted every un-supplied delta band to T.FILL (24 raw zero bits); ENV30_F/NOISE_F's shortest codeword (delta=0) is only 1 bit, so 23 leftover zero bits per slot bled into every field transmitted after the first multi-band delta run, silently corrupting envelope1/noise1's raw values to 0 regardless of what stream_one_band asked for (confirmed via EC_AAC_SBR_DEBUG before/after). Also switched the readout from power buckets to fractional-frequency-offset line detection per round-29's charter, and moved the tone off the ambiguous band-boundary bin. Sanity gate (ours vs build_patches) still fails: localized to the tone's bin-placement assumption (k = p*16), not build_patches or the runtime (patches dumped via EC_AAC_SBR_DEBUG match build_patches exactly). Left documented as open in the module docstring; reference maps not read this round since Task 1's own gate blocks it.
fix(sbr-probe): tone_core's pulse/tns/gain flags sat after spectral data, not beforeAhmet Kaan Gümüş · 23f057e
fix(sbr-probe): tone_core's pulse/tns/gain flags sat after spectral data, not before
tone_core() (scripts/aac-tables/sbrchirp.py) is the isolated-single-MDCT-line
probe writer used by sbrpatchmap.py's patch-map fingerprinting; it desynced
the reference decoder on every real-header probe ("channel element X.Y is not
allocated" / "buffer exhausted before END"). Byte-accounted against sce_core's
proven field order: the `pulse_data_present/tns_data_present/gain_control_
data_present` 3-bit field must precede spectral_data(), not follow it -- the
misplaced write shifted every bit after it. Core-only round-trip is now
byte-clean (0 errors) and the real reeln header/grid shape (kx=14/k2=43)
decodes to nonzero PCM instead of 0.
Also fixes sbr_hf.rs's `real_file_tables()` test fixture, whose stop_freq=3/
xover_band=2 guess was wrong (gave kx=16/k2=29); the real value read off the
file's own bitstream is stop_freq=8/xover_band=0 (kx=14/k2=43) -- confirmed
build_patches() on the corrected header exactly matches sbrpatchmap.py's
independently-ported prediction: [(0,14,14),(3,28,11),(0,39,3),(13,42,1)].
Running the full three-header patch-map sweep against both the reference and
our own decoder (adts_to_pcm) surfaced a new blocker, not fixed here: our own
decoder's *measured* map disagrees with build_patches' own prediction (empty
for source band 0, a constant band range for every other source band) even
though build_patches itself is proven correct in isolation -- the runtime HF
generation/envelope path or the probe's PCM analysis is unverified, not
build_patches. Per the probe's own sanity rule this blocks trusting the
reference's measured map until resolved.probe(sbr-patchmap): infra for measuring the reference's real HF patch mapAhmet Kaan Gümüş · e3a8adf
probe(sbr-patchmap): infra for measuring the reference's real HF patch map
adts_to_pcm example lets our own decoder be driven through the same
one-band-at-a-time probe streams sbrpatchmap.py builds for the reference
decoder (needs an explicit same-rate-SBR AudioSpecificConfig -- plain
AacDecoder::new() never turns SBR on from bare ADTS). sbrpatchmap.py reads
reeln's ACTUAL header off our own decoder's EC_AAC_SBR_DEBUG dump
(start_freq=5 stop_freq=8 xover_band=0 -> kx=14 k2=43 n_q=3, matching the
ledger's fact but NOT sbr_hf.rs's real_file_tables() unit test, whose
guessed stop_freq/xover_band=3/2 gives a different kx=16 k2=29 header) and
ports build_patches to Python for a live prediction-vs-measurement diff.
Blocked before a single measurement: tone_core()'s isolated-MDCT-bin core
(sbrchirp.py) fails outright against this header/grid shape ("channel
element 0.0 is not allocated" / "Invalid data found", zero PCM decoded),
reproducing round-19's "isolated-tone encoding does not round-trip" dead
end on the real header instead of the round-18 SBR-engagement bug it was
first seen with. Not fixed this round -- see ledger for next steps.diag(aac-sbr): convict per_band_lag_search's bandpass, task-2 finds direct-matchAhmet Kaan Gümüş · bf135ff
diag(aac-sbr): convict per_band_lag_search's bandpass, task-2 finds direct-match Round-26 Task 1: bandpass_offset_probe correlates the SAME 3x-cascaded RC bandpass at band k (ours) against band k+/-10 (reference) -- the downward offset consistently reads HIGHER correlation than the nominal same-band pairing across every HF band tried on the real library file (e.g. band 34: same 0.937 vs -10 0.966), which a filter with real ~172Hz selectivity cannot produce. This convicts the bandpass as instrument bug #7: "band k" was really "everything up to band k", manufacturing the smooth monotonic decline rounds 14-25 chased via cumulative low-band leakage. per_band_lag_search's doc comment now records the conviction -- its LAG output stays valid (passband delay still tracks true alignment) but its per-band AMPLITUDE reading does not. Task 2: bin_level_conviction compares bin-level complex content direct/mirrored/shifted-a-whole-band between the two decodes in the same energetic HF bands. No mirror or shift wins systematically (direct wins 9/12 tested bands, sometimes decisively); this is the "direct-match winning" outcome the charter calls out as needing a follow-up tone-fingerprint patch-map measurement, not a mirror/shift code fix -- so no production code changes this round.
2026-08-19
fix(ec-aac): the SBR "second-half collapse" was a mismatched-split test artifactAhmet Kaan Gümüş · 8bdf7f5
fix(ec-aac): the SBR "second-half collapse" was a mismatched-split test artifact sbr_real_library's SWEEP_SEGMENT diagnostic sliced ours/theirs at their own independent len()/2, but ours is capped at MAX_SAMPLES while the reference decodes the file in full (30s vs our 22.7s on reeln) -- so the "second half" compared ours' 11.35s-22.7s against the reference's 15.0s-30.0s, two different passages 3.6s apart, reading as a catastrophic collapse (~-0.01 corr) with no decode defect behind it. Splitting both sides at the shorter side's midpoint fixes it (0.981/ 0.976 full-band). A new whole-file corr-vs-time timeline (windowed local-lag search, EC_AAC_SBR_TIMELINE) confirms there is no sustained mid-file collapse on reeln: 0.958/0.954 mean windowed corr across all 22.7s, dipping briefly (~0.2s) only near t=0 and t=20.2s.
sbr: env-gated parameter-sensitivity sweep instruments (round-22)Ahmet Kaan Gümüş · 0fb1dc2
sbr: env-gated parameter-sensitivity sweep instruments (round-22) EC_AAC_SBR_BW_SCALE (chirp/inverse-filter target scale, clamped <1), EC_AAC_SBR_CHIRP_SMOOTH=none|swap (attack/release curve), EC_AAC_SBR_GAIN_LERP (per-slot gain interpolation toward the next envelope), and EC_AAC_SBR_LIMITER_OFF probe whether real-content correlation is sensitive to these knobs. All zero-cost when unset; default behavior unchanged (40/40 lib tests, reeln baseline bit-identical). EC_AAC_SBR_SWEEP_SEGMENT=1 lets the real-file test measure the second half of a file for stability checks. Sweep result: BW_SCALE shows a small monotonic response (best at scale=0, i.e. no chirp resonance at all -- ch1 delta 0.0023, just past the 0.002 material bar) but a two-segment stability check was inconclusive (the file's second half has near-zero baseline correlation for both candidate and default, invalidating the comparison), so the default is NOT changed. Chirp-smoothing curve and limiter are flat (eliminated). Gain-lerp catastrophically regresses (full-band 0.97->0.07) and is eliminated.
fix(aac-sbr): noise-floor dequant is a signal-relative ratio, not an absolute energyAhmet Kaan Gümüş · 5537fae
fix(aac-sbr): noise-floor dequant is a signal-relative ratio, not an absolute energy Round-21 Task 1: a reference-decoder probe (scripts/aac-tables/sbrnoise.py) sweeping the noise-floor raw value q_q at a fixed envelope target shows total HF-band output power staying nearly flat across the whole q_q range, not scaling additively with dequant_noise(q_q) as our own decoder assumed. That's the signature of the envelope target being split signal=target/(1+Q_div), noise=target*Q_div/(1+Q_div) with Q_div=dequant_noise(q_q), not noise added independently on top of the full target. adjust() now computes that split per (envelope, band) cell and injects noise there directly, replacing the old separate noise-grid pass that treated dequant_noise's return value as a standalone absolute energy comparable to dequant_env's unrelated unit scale. On the real-file bar (reeln) this moves correlation only slightly (ch0 0.9726->0.9732, ch1 0.9705->0.9716): real transmitted q_q values apparently keep Q_div small regardless of interpretation, so the noise-floor circularity hypothesis still doesn't explain this file's HF correlation gap -- but the fix itself is now unit-consistent with the measured reference behavior and is kept as a correctness fix.
probe(sbr-residual): frame x band residual/side-info correlation instrumentAhmet Kaan Gümüş · 6fea6db
probe(sbr-residual): frame x band residual/side-info correlation instrument EC_AAC_SBR_SIDEINFO_DEBUG logs one row per (AU, channel) apply_data runs (grid/invf/add_harmonic/coupling/e_q/q_q means, fresh vs hold source) via a new sbr_sideinfo_log() accessor. EC_AAC_SBR_RESIDUAL_DEBUG cross-tabulates that log against a (frame x band) residual-energy grid built from FFT(ours)-FFT(reference) at AU-aligned 2048-sample blocks (linear FFT means the residual's own spectrum never needs materializing in the time domain). On reeln (both channels, 489 frames): no predictor dominates decisively. add_harmonic-flagged bands carry LESS residual than unflagged (ratio 0.13), refuting sinusoid-injection as the round-19 bar's cause. Envelope borders run only ~1.1-1.7x interior energy (no sharp gain-placement spike). Coupling-flip frames run LOWER (ratio ~0.4), same direction as round-11's DT-base refutation. invf_mode level is non-monotonic against residual and confounded by population size (round-19's chirp dead-end stands). HF residual peakiness (~2.2-2.25) sits close to the pure-noise expectation for 4-bin groups (H_4=2.083), reading noise-like, not tonal. hold-state frames never occurred in this window -- untested, not refuted. Per charter, landing the diagnostic with these findings rather than chasing a non-dominant lead.
probe(sbr-chirp): repair the non-engaging instrument, refute the bw-per-level hypothesisAhmet Kaan Gümüş · 9a984c9
probe(sbr-chirp): repair the non-engaging instrument, refute the bw-per-level hypothesis Round-18's stream() never exercised the reference decoder's SBR gain stage: amp_res=0 (coarse envelope resolution) and num_env=1 (FIXFIX single envelope) each independently make it ignore the payload's envelope AND bs_invf_mode, and the same recipe was missing the FIL byte-padding loop before END (silent bitstream desync, masked because the byte-count still happened to work out on most inputs). Bisected against a known-working CPE probe to isolate both culprits. Repaired stream() (SCE, FIXFIX num_env=2, amp_res=1, byte-padded) engages: sweeping envelope raw value 3->60 swings output power by three-to-four orders of magnitude. On this working instrument, the four bs_invf_mode levels (NONE/LOW/MID/HIGH) produce indistinguishable output (<0.1% power drift, no resolvable flatness difference) against a BW_TABLE spanning 0.0..0.98 -- STOP RULE: hypothesis refuted for this measurement, sbr_hf.rs left unchanged.
scripts(sbr): black-box chirp/bw probe -- dead end, harness never engaged SBR envelopeAhmet Kaan Gümüş · 054aa95
scripts(sbr): black-box chirp/bw probe -- dead end, harness never engaged SBR envelope Attempted to measure the reference decoder's per-invf-mode bandwidth- expansion factor by black box (round 18, Task 1). Two dead ends recorded in the script's own docstring for a successor: * An isolated single-MDCT-line core (for an exact-AR2 pure-tone source, whose LPC coefficients are analytically known) desyncs the bitstream -- most HCB3 codewords beyond the one tuple earlier probes exercised are unverified. * Falling back to the already-proven-clean broadband comb core, every real SBR decode attempt makes the reference print "No quantized data read for sbr_dequant." and then produce PCM that is value-independent of both bs_invf_mode (all four levels byte-identical) and the envelope amplitude itself -- the envelope/gain stage never engages, for a reason the byte-count oracle (which only checks framing) cannot see. No bw fingerprint extracted; sbr_hf.rs is unchanged -- no measurement to base a fix on, and the task's own stop rule forbids fitting constants to noise.
diag(ec-aac): SBR noise-fraction ceiling hypothesis, measured and refutedAhmet Kaan Gümüş · 2cccf17
diag(ec-aac): SBR noise-fraction ceiling hypothesis, measured and refuted Round-17 Task 1: EC_AAC_SBR_NOISE_FRACTION_DEBUG accumulates per-QMF-band transmitted signal vs. noise energy (from our own dequantized envelope/ noise data) during decode; the real-file test prints the predicted sqrt(1-f_noise) correlation ceiling alongside per_band_lag_search's measured curve. On reeln ch0 the noise energy fraction is ~1e-7 in every HF band (predicted ceiling flat at 1.0000) while measured |corr| declines smoothly 0.999->0.85 -- the curves do not match. EC_AAC_SBR_NOISE_ZERO corroborates: zeroing our injected noise entirely leaves the measured per-band correlation bit-for-bit identical, so our noise generator is not in the causal path for the decline either. Hypothesis not convicted; no noise-table derivation follows per the charter's stop condition.
test(sbr): fix the per-band STFT correlation and cross-spectrum diagnosticsAhmet Kaan Gümüş · 80e5af3
test(sbr): fix the per-band STFT correlation and cross-spectrum diagnostics per_band_correlation was correlating each FFT bin's magnitude series then averaging |corr| across a band's 8 bins -- a tiny inter-bin energy redistribution between our filterbank and the reference decorrelates each bin individually even when the band's total energy tracks closely. Sum the band's bin magnitudes coherently first, then correlate once. Added per_band_phase (round-16 Task 2): a cross-spectrum phase/magnitude- ratio probe over the same aligned window. Its first version complex-summed a band's bins before forming the cross product, which mixes in O_b*conj(T_b') cross terms for b != b' -- pure noise between unrelated bin frequencies. Fixed to accumulate the cross-spectrum per bin across hops, then sum bins. Neither fix reconciles the STFT-domain reading with per_band_lag_search's direct PCM bandpass-and-correlate result above the crossover: STFT magnitude and cross-spectrum phase both go noisy/unstable there (phase swings over hundreds of degrees band to band, magnitude ratio spans 0.003-8.9), while per_band_lag_search finds a clean lag-0/-1 peak with correlation declining smoothly from ~0.999 to ~0.80. Below the crossover both diagnostics agree cleanly (phase <0.5deg, magnitude ratio ~1.00-1.01), so the below-crossover 0.9989-vs-0.9999 residual is not a phase story. No calibration applied -- the charter's decision tree calls for reporting both curves and stopping when neither a smooth phase curve nor a stable magnitude curve emerges.