forge
Explore
Log in

Don't you dare go Hollow

probe(sbr-chirp): repair the non-engaging instrument, refute the bw-per-level hypothesis

Browse files at this commit

9a984c9aaa3d09104f40adf72be51571b97841b9Ahmet Kaan GümüşParent: 054aa95
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/aac-tables/sbrchirp.pymodified+46 -25
@@ -14,27 +14,42 @@ decays geometrically as `g^n` per QMF slot -- `g` *is* the chirp factor
14 (pole radius), directly recoverable from the decay rate with no analysis of14 (pole radius), directly recoverable from the decay rate with no analysis of
15 our own decoder involved.15 our own decoder involved.
16 16
17-STATUS (dead end, not chased further): the isolated-single-MDCT-line core17+STATUS (round-19): the round-18 non-engagement was `stream()`'s own recipe
18-(`tone_core`) does not round-trip -- most HCB3 codewords beyond the one18+shape, not a framing bug -- bisected field-by-field against a known-working
19-tuple earlier probes happened to exercise are unverified and desync the19+CPE probe (see project ledger) and isolated to TWO independent culprits,
20-bitstream ("Input buffer exhausted before END element found"); see the20+either one sufficient alone to make the reference decoder's SBR gain stage
21-`(2,0,0,0)`/`(2,0,2,2)`/`(0,0,0,0)` isolation test in the project ledger.21+not engage (envelope amplitude and `bs_invf_mode` both become powerless,
22-Falling back to the already-proven-clean broadband `sce_core` comb content22+`"No quantized data read for sbr_dequant."` fires either way -- that
23-(`broadband_core_bits`) decodes without framing errors, but every real SBR23+message is a red herring, printed on this SCE probe shape regardless of
24-sweep built on top of it (`stream()`, any `n_low`/`n_high`/`n_q` combination24+engagement, not diagnostic of it):
25-tried, any `env0`/`noise0` magnitude) makes the reference decoder print25+
26-"No quantized data read for sbr_dequant." and then produce PCM that is26+ 1. `bs_amp_res=0` (coarse, 7-bit raw envelope resolution). Sweeping the
27-*value-independent* of both `bs_invf_mode` (all four levels byte-identical)27+ full raw range (0..127) still gives <0.03% output-power change; fine
28-and the envelope amplitude itself (`env0=0` vs `env0=100`: power differs by28+ resolution (`bs_amp_res=1`, 6-bit raw) with the same header gives
29-<0.02%, when a real amp_res=0 dequant law would differ by orders of29+ three-to-four-orders-of-magnitude power swings for a mid-range raw
30-magnitude) -- i.e. the reference's SBR envelope/gain stage is not engaging30+ sweep (3 -> 60). Pure probe-construction quirk, not implicating our
31-with this harness's `sbr_data` payload at all, for a reason not yet31+ parser/writer: real encoders emit both resolutions routinely and nothing
32-isolated (framing/byte-count is provably correct per `oracle_check`, so the32+ here says our AAC parser mishandles coarse-resolution streams -- it is
33-fault is in a field *value* or ordering `oracle_check`'s byte-count-only33+ specifically *this reference build's* dequant path refusing these raw
34-check cannot see). No bw fingerprint could be extracted; Task 1 could not be34+ values under `amp_res=0`, for a reason not chased further (plausibly an
35-completed this round. Do not reuse `stream()`'s SCE/FIXFIX(num_env=1) recipe35+ offset/table-range mismatch in how this probe's raw codewords map,
36-believing it produces a working real decode -- it does not, despite passing36+ unrelated to any of our own code).
37-the byte-count oracle.37+ 2. `bs_num_env=1` (FIXFIX single envelope). Independent of amp_res: even
38+ requesting `amp_res=1` explicitly, a single-envelope frame still fails
39+ to engage here.
40+
41+`stream()` below now uses the repaired shape: SCE, FIXFIX with `num_env=2`,
42+`amp_res=1`, envelope held constant across `bs_invf_mode` sweeps. Task 2 (a
43+four-level `bs_invf_mode` sweep plus a HIGH->NONE transition, `n_q=1`
44+narrow HF target) on this repaired instrument found only a ~0.1% output
45+power drift across all four levels and no resolvable flatness difference,
46+against a `BW_TABLE` that nominally spans `bw=0.0..0.98` -- STOP RULE
47+applies: fingerprints are indistinguishable on the working instrument, so
48+the bw-per-level hypothesis is refuted for this measurement and `sbr_hf.rs`
49+was left unchanged. (The HIGH->NONE transition run showed a >200x power
50+spike two frames from the stream's end; that coincides with the trailing
51+silence frame and reads as a decoder-side reset artifact of this probe's
52+framing, not a chirp-smoothing signal -- not chased further.)
38 """53 """
39 import os54 import os
40 import sys55 import sys
@@ -105,13 +120,16 @@ def broadband_core_bits(w, gain=200):
105 120
106 121
107 def stream(cfg, tables, n_frames, invf_seq):122 def stream(cfg, tables, n_frames, invf_seq):
108- """`n_frames` FIXFIX/1-env frames, header on the first, `bs_invf_mode`123+ """`n_frames` FIXFIX/2-env, `amp_res=1` frames (the repaired, engaging
109- taken from `invf_seq[i]` (repeats last if shorter)."""124+ shape -- see module docstring), header on the first, `bs_invf_mode`
110- grid = dict(frame_class=0, num_env=1, freq_res=0)125+ taken from `invf_seq[i]` (repeats last if shorter), envelope held fixed
126+ across the sweep."""
127+ grid = dict(frame_class=0, num_env=2, freq_res=0)
111 frames = [P.silent(SF_INDEX)]128 frames = [P.silent(SF_INDEX)]
112 for i in range(n_frames):129 for i in range(n_frames):
113 mode = invf_seq[min(i, len(invf_seq) - 1)]130 mode = invf_seq[min(i, len(invf_seq) - 1)]
114- c = dict(cfg, invf=mode, header=1)131+ c = dict(cfg, invf=mode, header=1, amp_res=1, element="sce", coupling=0,
132+ df_env=[0] * 8, df_noise=[0, 0], env0=[40] * 8, noise0=[2, 2])
115 w = P.BitW()133 w = P.BitW()
116 broadband_core_bits(w)134 broadband_core_bits(w)
117 body = F.sbr_bits_full(c, tables, grid, [])135 body = F.sbr_bits_full(c, tables, grid, [])
@@ -122,8 +140,11 @@ def stream(cfg, tables, n_frames, invf_seq):
122 w.w(cnt - 15 + 1, 8)140 w.w(cnt - 15 + 1, 8)
123 else:141 else:
124 w.w(cnt, 4)142 w.w(cnt, 4)
143+ start = len(w)
125 w.w(13, 4)144 w.w(13, 4)
126 w.wbits(body.bits)145 w.wbits(body.bits)
146+ while len(w) - start < cnt * 8:
147+ w.w(0, 1)
127 w.w(7, 3)148 w.w(7, 3)
128 frames.append(P.adts(w.pack(pad=0), SF_INDEX))149 frames.append(P.adts(w.pack(pad=0), SF_INDEX))
129 frames.append(P.silent(SF_INDEX))150 frames.append(P.silent(SF_INDEX))