Commits
Commits on
58e23aa550ad65ebd1fa0c608a993fb1ce7d8b772026-08-20
feat(ec-hw): route coded-size-mismatched encode_frame sources through VPP region copyAhmet Kaan Gümüş · 58e23aa
feat(ec-hw): route coded-size-mismatched encode_frame sources through VPP region copy Encoder::encode_frame refused any source whose coded_size differed from the encoder's block-rounded one (HEVC rounds to 32, so a 3840x2160 source's 2160 stayed unrounded while the HEVC coded height became 2176). Add Vpp::convert_region (crates/ec-va/src/vpp.rs) — a VAProcPipelineParameterBuffer submission with explicit surface_region/output_region rectangles, no scaling — and route both 10-bit (P010) and now 8-bit coded-size-mismatched sources through it into the encoder's own NV12 pool, placed at (0,0) using frame.display_size. Encoder's own SPS conformance window / frame_cropping (already sized from EncoderConfig.width/height, independent of the source frame) makes the produced stream report the true visible size, not the padded coded one. The pool is painted black/neutral-chroma once on creation (Encoder::fill_black) so the padding rows a region copy never touches are deterministic rather than driver-fresh-allocation garbage. Real 4K HEVC Main10 mkv (3840x2160): - encode_frame_accepts_p010_via_vpp: HEVC now accepted and round-trips (worst Y inf dB, worst UV 96.2 dB vs the CPU path; H264 worst Y/UV inf dB), and ffprobe confirms the produced stream is 3840x2160 for both targets. - p010_zero_copy_encode_is_realtime (--release): H264 zero-copy 6.52 ms/frame median (CPU path 18.80), HEVC zero-copy 5.29 ms/frame median (CPU path 16.95) — both under the 20 ms/frame target. cargo test -p ec-va -- --test-threads=1: 13 + 6 doctests, all green. cargo test -p ec-hw --release --test gpu -- --test-threads=1: 27 passed.
test(ec-va,ec-hw): verify VPP filter probe, struct layout, and P010 zero-copy encode against a real 4K HEVC HDR fileAhmet Kaan Gümüş · cffd9af
test(ec-va,ec-hw): verify VPP filter probe, struct layout, and P010 zero-copy encode against a real 4K HEVC HDR file
ec-va/tests/gpu.rs: vpp_filters_probe (vaQueryVideoProcFilters on the real
display — radeonsi advertises only VAProcFilterDeinterlacing (2), no
HighDynamicRangeToneMapping) and vpp_converts_p010_to_nv12 (Vpp::convert
end to end).
ec-va/src/sys.rs: a const size_of/offset_of assert block for
VAProcPipelineParameterBuffer against va_vpp.h:886 (224 bytes on this
target, field offsets checked through va_reserved) plus
VAProcColorProperties — the layout was already correct, this just pins it.
ec-hw/tests/gpu.rs, against a real HEVC Main10 P010 4K HDR mkv:
- encode_frame_accepts_p010_via_vpp: encode_frame (zero-copy, P010 via VPP)
vs to_i420()+encode (CPU path), decoded back and compared. H.264: worst Y
and UV PSNR both infinite (byte-identical after decode). H.265 is refused
by encode_frame's own documented contract ("frame's coded size does not
match this encoder's ... the VPP conversion pass does not resize") because
this file's SPS pic_height_in_luma_samples (2160) is a multiple of the
H.264 encode block size (16) but not the HEVC one (32) — an existing,
intentional design choice, not a defect this round touched.
- p010_zero_copy_encode_is_realtime: median 6.14 ms/frame for
decode+encode_frame (H.264, the target that isn't refused on this file)
vs 22.55 ms/frame for decode+to_i420+encode — zero-copy is ~3.7x faster
and well inside the 20 ms budget.
cargo test -p ec-va -- --test-threads=1: 13 passed (+2 doctests, +4
compile-fail doctests).
cargo test -p ec-hw --release --test gpu -- --test-threads=1: 27 passed, 0
failed (most non-P010 tests skip: no generated bitstream fixtures on this
checkout).diag(aac-sbr): add a header/frame-feature discriminator table; fix two self-check instruments' stale/wrong lag conventionsAhmet Kaan Gümüş · 2b4d691
diag(aac-sbr): add a header/frame-feature discriminator table; fix two self-check instruments' stale/wrong lag conventions Task A: sbr_header_feature_table (tests/sbr_real_library.rs) prints one row per stream (reeln, FMJ, all 8 synthetic HE fixtures) of sbr_header()/ frame-level features (kx/k2, xover/start/stop freq, freq_scale, alter_scale, noise_bands, limiter_bands/gains, interpol_freq, smoothing_mode, per-frame num_env histogram, invf modes seen, add_harmonic usage, df_env/df_noise delta-coding rate, patch geometry) next to each stream's pass/fail correlation. Needed df_env/df_noise plumbed through SbrChannel and header params + patch lengths added to SbrSideInfoRow (src change, no behaviour change). Key finding: FMJ (fail, corr 0.036) and synth-48000-64k (pass, corr 1.000) share IDENTICAL kx/k2 (27/59), IDENTICAL header config, and IDENTICAL patch geometry [26,1,5] -- the only differences in the table are per-frame entropy (envelope-count histogram, invf-mode diversity), which is exactly what differing real-vs-synthetic CONTENT should produce on its own. This directly refutes "a per-stream SBR header/config feature separates pass from fail" (the standing hypothesis this task was chartered to test): no such feature exists in what sbr_header()/sbr_data() actually carries. Whatever breaks FMJ must be in the payload's numeric content or the container/extraction path, not the SBR sideinfo shape. Task B: full_chain_low_band_matches_own_core no longer hardcodes a stale QMF delay (-897); it now runs the same wide lag search `synthetic_heaac_matrix` uses and asserts corr >= 0.99 at the MEASURED lag. Confirms reeln's true lag is -576 (matches the ledger) at corr 0.997, and turns FMJ's already-known low-band self-inconsistency (round-51) into a real failing assertion instead of a silent print. synthetic_heaac_matrix's `ours_v_core`/`core_v_ref` columns: replaced the naive 2x-nearest-neighbor-upsample-then-lowpass-at-full-rate convention (which read a flat ~-0.12 regardless of file) with the native-core-rate decimate/`ffmpeg_decode_at_rate` convention `core_only_matches_reference` already trusts. This measurably fixed the 44100 family (core_v_ref now 0.44-0.995, proving the core decode itself is correct there even though the full chain fails at 0.07) but the 48000 family's core_v_ref is still flat/ negative despite `full`/`below` proving near-perfect correctness at native rate -- left open, most likely a remaining artifact in this resampling- domain comparison itself (ffmpeg's -ar downsample phase vs the wide-lag search), not a real SBR defect, since `below` already disproves it at the rate that matters. Correcting the charter's premise: core_v_ref did NOT read 0.9999 before this fix (measured 0.22-0.40 on 48000, near 0 on 44100) -- both self-check columns were broken, not one healthy one to copy.
feat(ec-hw): P010 encode_frame goes through a GPU-resident VAProfileNone/VideoProc VPP pass, not CPU read-backAhmet Kaan Gümüş · 67c8428
feat(ec-hw): P010 encode_frame goes through a GPU-resident VAProfileNone/VideoProc VPP pass, not CPU read-back encode_frame previously refused any 10-bit (P010) frame outright, forcing a consumer's HDR->proxy export onto to_i420()+re-upload for the whole path. This adds ec_va::Vpp (Config/Context/Buffer/Picture — all the existing generic VA-API machinery, no new unsafe outside ec-va) wrapping VAProfileNone/VAEntrypointVideoProc, and wires a lazily-built 2-surface NV12 pool + Vpp into ec_hw::Encoder: a 10-bit frame is converted P010->NV12 on the GPU (VAProcPipelineParameterBuffer, whole-surface, no filters) and then submitted through the exact same encode_surface() path as an 8-bit frame. radeonsi capability check (vainfo): VAProfileNone/VAEntrypointVideoProc is advertised on this GPU, confirming the entrypoint this crate now uses is real hardware support, not a driver gap. HDR->SDR tonemap (VAProcFilterHighDynamicRangeToneMapping) was NOT wired: sys.rs carries the filter-type constants and Vpp::filters() (vaQueryVideoProcFilters) to check for it, but the charter's own gpu.rs tests (PSNR/bench harness) were not written this round — see the ledger DELTA for the honest state of that gap. Scoped compiles green: `cargo check -p ec-va[--tests]`, `cargo check -p ec-hw[--tests]`. The 23-test `ec-hw --test gpu` regression and a live P010 decode+encode_frame+decode-back PSNR run were NOT executed this round (budget) — next round's first move.
fix(ec-matroska): derive laced-frame pts from the codec's own frame duration when the file states noneAhmet Kaan Gümüş · 73735ec
fix(ec-matroska): derive laced-frame pts from the codec's own frame duration when the file states none DefaultDuration absent on a track (e.g. an A_OPUS track laced 8 frames per SimpleBlock) collapsed every frame in a lace onto the block's base pts, so a seek landing mid-lace reported a pts up to ~145ms early. emit_block now steps each laced frame by, in order: DefaultDuration, an even split of BlockDuration, or a codec-derived duration (Opus TOC byte per RFC 6716, AAC's fixed 1024-sample frame) -- falling back to 0 only when none apply. Also fixes a distinct scale bug this surfaced: emit_block was dividing a codec-derived nanosecond duration by TimeBase::num(), which TimeBase reduces against 1e9 and is not the file's raw TimestampScale; the real TimestampScale is now kept on MatroskaDemuxer itself.
fix(aac-sbr): port the numpy-verified normative 64-band QMF bank into sbr_qmf.rs; delete the fitted Kaiser bankAhmet Kaan Gümüş · ddccd80
fix(aac-sbr): port the numpy-verified normative 64-band QMF bank into sbr_qmf.rs; delete the fitted Kaiser bank
Part (A)/(B) bisection (numpy, scripts/aac-tables/qmf_check.py):
zero-stuffing 32 core samples into the VERIFIED 64-band analysis
(x64[2m]=2*x32[m], odd=0), keeping bands 0..32 and dropping the
zero-stuffing image in bands 32..64, reaches corr=0.9994 against an
ideal band-limited 2x upsample (scipy resample reference) -- short of
the 0.9999 numpy target but a real, spec-traceable near-PR bank. The
per-k ratio probe (Analysis32 vs zero-stuff+Analysis64) showed the two
converge to a near-constant per-band complex factor after a few slots'
transient, consistent with the charter's predicted decimation identity,
but does not by itself explain Analysis32's/Synthesis32Downsampled's own
0.70-corr ceiling in isolation -- left as an open dead end, sidestepped
per charter option (B) instead of chased further.
crates/ec-aac/src/sbr_qmf.rs: `Analysis` and `HfAnalysis` now share one
`QmfAnalysis64` core (ISO/IEC 14496-3 4.6.18.4, the window-checksum-pinned
640-tap table from `sbr_qmf_window`); `Analysis` zero-stuffs its 32 core
samples into a 64-sample slot before running the shared core and keeps
the low 32 bands. `Synthesis` is the verified 4.6.18.8.2 64-band bank
directly. Deleted: `prototype`/`theta`/`modulation_tables`/
`analytic_gain`/`bessel_i0`/`sinc`/`KAISER_BETA`/`SYNTH_TRIM` (the fitted
Kaiser-window machinery this design used to build coefficients from).
crates/ec-aac/src/sbr_hf.rs: `band_shift_correction` returns 0
unconditionally -- the normative bank carries its own correct phase from
the spec equations directly, no per-slot quarter-turn patch-site
correction needed.
Removed 7 unit tests that encoded the fitted bank's own assumptions
(flat per-band synthesis gain, a specific band-index-to-frequency
mapping, the old patch-rotation convention) and no longer apply to the
literal spec equations' own indexing; kept/added: window checksum
(`qmf_window_checksum_matches_the_pinned_source`),
`round_trip_reconstructs_the_passband` (noise round-trip, unchanged,
still clears its native >=0.9999 bar for the multitone-passband case),
`synthesis_energy_gain_for_{white_noise,lowpassed_noise}_excitation`,
patch-map determinism (`sbr_hf::patch_map_is_deterministic_...`). Did
NOT add the charter's requested standalone "all-k passthrough tone" and
"patch p->p+8 coherence" tests -- out of this round's remaining budget,
left as a gap (see ledger).
GATE (cargo test -p ec-aac --lib): 44/44 pass (down from 50/50 pre-round;
6 net removed, see above).
GATE (cargo test -p ec-aac --test sbr_real_library):
reeln ch0 full-band corr 0.972474 -> 0.987006 (IMPROVED)
reeln ch1 full-band corr 0.969785 -> 0.986222 (IMPROVED)
FMJ ch0 full-band corr -0.024 -> -0.025253 (unchanged, pre-existing
documented defect per ledger round-46, unrelated to this bank)
full_chain_low_band_matches_own_core: PASS
sbr_real_library_matches_reference: FAILS on FMJ's worst_full>=0.999
bar (pre-existing, not caused or fixed by this round)
Did not merge main / run synthetic_heaac_matrix -- out of this round's
remaining tool-call budget; next round should do that first.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).fix(h264): drop leading pictures after a seek's open-GOP recovery pointAhmet Kaan Gümüş · 03dc6e9
fix(h264): drop leading pictures after a seek's open-GOP recovery point Root cause (crates/ec-h264/src/dpb.rs, crates/ec-h264/src/decoder.rs; mirrored in crates/ec-hw/src/dec/dpb264.rs, crates/ec-hw/src/dec/h264.rs): an open-GOP I picture is not an IDR — it is a plain I slice whose predecessors in decode order can still be referenced by pictures that follow it. A decoder started fresh at that I (exactly what a seek does) has none of those earlier references, so `build_ref_lists` pads the missing entries with whatever it has. The old code decoded and output those leading pictures anyway, handing back frames predicted from padded (garbage) references before the stream ever reaches a picture whose references are all real. Annex D.2.8 defines a `recovery_point` SEI whose absence (the common case, and this fixture's case) defaults `recovery_frame_cnt` to 0: the recovery point is the RAP's own POC, i.e. only pictures with a POC at or after the leading I's own POC are guaranteed fully referenced. The SEI itself is deliberately not parsed — the default already gives the correct threshold for the case that matters (mid-GOP seek), and a real non-zero `recovery_frame_cnt` is out of scope for this fix. `build_ref_lists` now returns whether it had to pad a list ((lists, padded)); `Decoder`/`H264Decoder` OR that per-slice into `cur_ref_padded`/`Current::ref_padded`, latch the first post-reset picture's POC into `recovery_poc` on `end_picture`/`finish_picture`, and compute `output_ok = !(ref_padded && poc < recovery_poc)`. `Dpb::store` takes that flag and marks the picture `Mark::Unused`-eligible for output gating (`pic.output = output_ok`) — it still joins the DPB as a reference and for bookkeeping, but a gated picture is never handed to a caller. `reset_pictures` clears `recovery_poc` so a later seek gets its own threshold. New test `h264_seek_matches_linear_open_gop` in both suites drives this through the real entry surface: fixtures/video/h264-open-gop.mp4 (x264 open-GOP, generated via scripts/gen-fixtures.sh) primes a fresh decoder with the leading IDR's parameter sets, resets picture state (a seek's exact contract), feeds it from the open-GOP I access unit before display frame 30, and asserts the first decoded picture matches a linear decode of frame 30. Confirmed failing before this fix (forcing output_ok true reproduces the mismatch) and passing after, on both the software decoder (crates/ec-h264/tests/conformance.rs) and the VA-API path (crates/ec-hw/tests/gpu.rs, real hardware). cargo test -p ec-h264: 70 lib + 23 conformance + 8 encode passed, 0 failed. cargo test -p ec-hw --test gpu -- --test-threads=1: 19 passed (18 pre-existing + the new one), 0 failed.
diag(aac-sbr): bisect the 0.62 cross-family QMF corr with same-rate 64->64 and 32->32 round-trips; cross-checks T1/T2/T3 refutedAhmet Kaan Gümüş · 4de6175
diag(aac-sbr): bisect the 0.62 cross-family QMF corr with same-rate 64->64 and 32->32 round-trips; cross-checks T1/T2/T3 refuted
64->64 (4.6.18.4 analysis, x of 640, newest at x[0] reversed, Z[n]=x[n]*c[n],
u folded by 5x128, X[k]=sum u[n]*exp(j*pi/128*(k+0.5)*(2n-1)) -> the existing
4.6.18.8.2 synthesis unchanged) round-trips at corr=0.999999, amp_ratio~1.0,
confirming the ORIGINAL hand-written equations (no sign flip, +j, (2n-1),
(2n-255), 1/64 scale) are correct for that pairing. This is exactly the
convention the first round already had.
Cross-check T1 (shift direction: both x/v buffers growing at the TOP,
forward-order new samples, vs the charter's reverse/newest-at-index-0) and
T2 ((2n+1) modulation index instead of (2n-1)/(2n-255)) are both REFUTED
under the 64->64 witness: every T1 (forward-shift) variant collapses to
corr 0.03-0.05 regardless of T2; every T2 (2n+1) variant with the correct
T1 shift stays close (0.9998-0.9999) but never beats the baseline (2n-1)/
(2n-255) config. T3 (drop the 1/64 synthesis scale) only rescales energy
(amp_ratio jumps to ~64x) and does not change corr, as expected -- the
window does NOT carry the normalization; the 1/64 factor is required.
32->32 downsampled (4.6.18.8.3: v of 640, shift 64, pi/64*(2n-63), w=g*c[2n])
tops out at corr=0.702744 (amp_ratio 0.807, energy 0.631) with the SAME
newest-at-x[0]/c[2n]/(2n-1) convention that gave 64->64 a clean pass --
i.e. the 32-band analysis or 32-band downsampled-synthesis half of the
bank (the c[2n]-subsampled / 320-tap path) is itself imperfect, not just
the 32-band-analysis-into-64-band-synthesis pairing.
Feeding 32-band analysis output (bands 0..31) into the CONFIRMED-correct
64-band synthesis (zero bands 32..63) drops further, to corr~0.05, across
every scale_k in {1,2,0.5,sqrt2} and both conjugate/non-conjugate X[k] --
worse than the earlier same-round ad-hoc 0.624 best (which used a
non-normative ssign/re_only combination, not this confirmed-correct
synthesis). The zero-stuffing-gain hypothesis (charter step 3) is REFUTED
under the correct-64-synthesis witness: scaling alone does not fix it.
Net: the 64-band same-rate pairing is spec-correct and verified; the
32-band analysis and/or 32-band downsampled-synthesis equations
(4.6.18.4.1 / 4.6.18.8.3, both built on the c[2n]/320-tap subsampled
window) are the remaining open defect, and the 32-band-analysis-into-
64-band-synthesis cross-family bridge used by real SBR HF generation is
not simple zero-padding -- something in the 32<->64 band correspondence
itself needs a different treatment than tested here. Still below the
0.999 numpy gate; no Rust changes this round either.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.
diag(aac-sbr): numpy round-trip of the normative 4.6.18.4.1/4.6.18.8.2 32/64-band QMF exhausts all listed carrier variants, dead endAhmet Kaan Gümüş · 93d147f
diag(aac-sbr): numpy round-trip of the normative 4.6.18.4.1/4.6.18.8.2 32/64-band QMF exhausts all listed carrier variants, dead end
scripts/aac-tables/qmf_check.py implements the analysis (32-band, ISO/IEC
14496-3 4.6.18.4.1) and synthesis (64-band, 4.6.18.8.2) equations exactly as
specified against the checksum-pinned 640-tap window, then round-trips 8192
white-noise samples through analysis -> zero-upper-32 -> synthesis and
correlates the decimated-by-2 output against the original at the best lag.
Impulse-response probe confirms the cascade is not garbage (a clean
symmetric twin-peak decaying kernel centred near the expected group delay),
but the broadband round-trip correlation tops out at 0.624 (newest-sample-
at-x[0], Z[n]=x[n]*c[2n], across both analysis and synthesis phase-sign
choices, Re-only vs Re+Im) -- far under the 0.999 gate. All four binary
alternatives from the charter (newest-sample position, c[2n] vs c[n],
analysis exp sign, synthesis Re-vs-both) were cross-producted (32 trials,
full table in run output); "scaling" is correlation-invariant so not a
separate axis. Output energy ratio is also off (~0.5x input energy where a
true PR interpolator should read ~2x), pointing at a real normalization/
equation bug beyond the four listed axes, not a coefficient tie-break.
Per the charter's gate ("only once numpy >=0.999: port to Rust"), this
round does not touch sbr_qmf.rs / sbr_hf.rs -- no Rust changes, no test
gate re-run. Recorded as a dead end for the next round.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.
diag(aac-sbr): normative 640-tap QMF window embedded, checksum-pinned; bank replacement reverted, dead end recordedAhmet Kaan Gümüş · 2928bfe
diag(aac-sbr): normative 640-tap QMF window embedded, checksum-pinned; bank replacement reverted, dead end recorded
Charter: replace sbr_qmf's fitted Kaiser bank with the normative ISO/IEC
14496-3 4.6.18.4/4.6.18.8 analysis/synthesis pair built from the provided
640-tap prototype table.
Embedded the table verbatim as crate::sbr_qmf_window::QMF_WINDOW with a
checksum test (sum/sum-of-squares/max/argmax) -- passes, table transcription
confirmed correct.
Implemented and empirically tried, in order, against a broadband-noise
round-trip correlation probe (independent of any real file):
1. The literal folded reading of 4.6.18.4/4.6.18.8 an external spec review
produced (320-sample analysis buffer folded 5-way to 64 taps, carrier
exp(j*pi/64*(k+0.5)*(2n-1)); 1280-sample synthesis overlap-add, carrier
exp(j*pi/64*(k+0.5)*(2n-255)), synthesis window built by mirroring the
640-tap table to 1280 samples) -- broadband round-trip correlation
plateaued at ~0.03-0.05 regardless of a grid search over analysis/
synthesis phase-intercept sign and offset (tried +-1, +-63, +-65, +-127,
+-129, +-255, +-511, 0) and an alternating-sign fold variant. Not a
near-miss: this structure does not reconstruct at all.
2. The prior fitted bank's own direct (unfolded) 640-tap-dot-product
structure, with the real QMF_WINDOW table substituted for the fitted
Kaiser prototype (no fold, theta = omega_step*(k+0.5)*(n+offset), one
omega_step per bank) -- best found ~0.697 correlation (offset=bands/2,
omega_step=pi/64 analysis / pi/128 synthesis, the fitted bank's own
convention), well short of the fitted bank's own 0.9998 achieved only
through its Kaiser-beta + cutoff fit. A grid over omega_step in
{pi/64, pi/128} x2 banks and offset in {+-16, +-32} never exceeded ~0.70.
Both avenues ruled out a fold-based reading of the reviewed equations
outright, and showed the review's exact phase-intercept constants (-1,
-255) are not simply a typo away from working with either window-derivation
guess. Given no access to the literal ISO text (only a review's paraphrase,
itself flagged "review, not ground truth") and no reference decoder's QMF
internals to cross-check against, further correction is a guess-and-check
search over an open constant space, not a bounded fix.
Reverted crates/ec-aac/src/sbr_qmf.rs and sbr_hf.rs to HEAD (4346f31) to
avoid shipping a QMF pair that round-trips at ~0.03-0.70 in place of one
that round-trips the passband at ~0.9998 -- verified unchanged real-file
numbers below.
DONE-GATE, unchanged from baseline (revert confirmed exact):
cargo test -p ec-aac --lib: 51 passed (50 baseline + 1 new window
checksum test), 0 failed.
reeln (44.1k): ch0 full-band corr 0.972474, ch1 0.969785 (both
unchanged); below 5000Hz 0.992799/0.992329, above 5000Hz
0.761967/0.746352; whole-file windowed mean 0.955717/0.951577.
FMJ (48k, kx=27): ch0 full-band corr -0.024069, ch1 0.010887 (both
unchanged, pre-existing catastrophic decorrelation, separately tracked).
sbr_qmf_window.rs's QMF_WINDOW is not wired into sbr_qmf (module doc there
states why); kept for the next attempt, which needs either the literal ISO
text or a reference decoder's QMF stage to check phase/window hypotheses
against instead of guessing.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).