forge
Explore
Log in

Don't you dare go Hollow

Merge branch 'lane-band63': 1:4 gates cover cq 63; decode_probe dumps 16-bit planes

Browse files at this commit

1701408208e860f00ddbdafb6de631010d61ddf8Ahmet Kaan GümüşParent: b949f111a1bbdb
crates/ec-av1/examples/decode_probe.rsmodified+13 -0
@@ -83,6 +83,19 @@ fn main() {
83 // Optional second arg, or EC_PROBE_OUT=<path>: dump the decoded83 // Optional second arg, or EC_PROBE_OUT=<path>: dump the decoded
84 // planes as raw yuv420p so a pixel diff against `ffmpeg -i s.obu84 // planes as raw yuv420p so a pixel diff against `ffmpeg -i s.obu
85 // -f rawvideo` needs no test harness.85 // -f rawvideo` needs no test harness.
86+ // 10-bit streams: EC_PROBE_OUT16 dumps the planes as little-endian
87+ // u16 (yuv420p10le), the only form a pixel diff against
88+ // `ffmpeg -pix_fmt yuv420p10le` can use (lane-band63).
89+ if let Ok(out) = std::env::var("EC_PROBE_OUT16") {
90+ let mut buf: Vec<u8> = Vec::new();
91+ for f in &frames {
92+ for p in [&f.y, &f.u, &f.v] {
93+ buf.extend(p.iter().flat_map(|&s| s.to_le_bytes()));
94+ }
95+ }
96+ std::fs::write(&out, &buf).expect("writing raw planes");
97+ println!("wrote {} bytes of yuv420p10le to {out}", buf.len());
98+ }
86 let out = std::env::args().nth(2).or_else(|| std::env::var("EC_PROBE_OUT").ok());99 let out = std::env::args().nth(2).or_else(|| std::env::var("EC_PROBE_OUT").ok());
87 if let Some(out) = out {100 if let Some(out) = out {
88 // 8-bit only: planes are u16, take the low byte.101 // 8-bit only: planes are u16, take the low byte.
crates/ec-av1/src/stream.rsmodified+10 -2
@@ -19459,12 +19459,16 @@ mod tests {
19459 geq=lum='mod(floor({axis}/8)*{step},256)',\19459 geq=lum='mod(floor({axis}/8)*{step},256)',\
19460 noise=alls={noise}:all_seed={seed},format=yuv420p"19460 noise=alls={noise}:all_seed={seed},format=yuv420p"
19461 );19461 );
19462+ // lane-band63: the second cq is 63, not 45 -- a near-max
19463+ // quantiser is where deblock/CDEF do the most work and where a
19464+ // 1:4 strip is most often skip; all 16 streams of this family at
19465+ // cq 63 (8- and 10-bit) decode pixel-exact.
19462 let cq_level = if tx_search {19466 let cq_level = if tx_search {
19463 // 12..28: the window measured to fire both split depths on19467 // 12..28: the window measured to fire both split depths on
19464 // this fixture (lanes/tx64x16-r4.handoff.md).19468 // this fixture (lanes/tx64x16-r4.handoff.md).
19465 format!("--cq-level={}", 12 + (attempt % 4) * 5)19469 format!("--cq-level={}", 12 + (attempt % 4) * 5)
19466 } else {19470 } else {
19467- format!("--cq-level={}", if attempt % 4 < 2 { 32 } else { 45 })19471+ format!("--cq-level={}", if attempt % 4 < 2 { 32 } else { 63 })
19468 };19472 };
19469 let pix_fmt = if bit_depth == 10 { "yuv420p10le" } else { "yuv420p" };19473 let pix_fmt = if bit_depth == 10 { "yuv420p10le" } else { "yuv420p" };
19470 let y4m = Command::new("ffmpeg")19474 let y4m = Command::new("ffmpeg")
@@ -19728,7 +19732,11 @@ mod tests {
19728 geq=lum='mod(floor({axis}/8)*{step},256)',\19732 geq=lum='mod(floor({axis}/8)*{step},256)',\
19729 noise=alls={noise}:all_seed={seed},format=yuv420p"19733 noise=alls={noise}:all_seed={seed},format=yuv420p"
19730 );19734 );
19731- let cq_level = format!("--cq-level={}", [32, 45, 55][(attempt / 2 % 3) as usize]);19735+ // lane-band63: 63 joins the rotation -- filter intra ON at a
19736+ // near-max quantiser is exactly the configuration the stale
19737+ // cq-63 premise blamed, and it decodes exact.
19738+ let cq_level =
19739+ format!("--cq-level={}", [32, 45, 55, 63][(attempt / 2 % 4) as usize]);
19732 let pix_fmt = if bit_depth == 10 { "yuv420p10le" } else { "yuv420p" };19740 let pix_fmt = if bit_depth == 10 { "yuv420p10le" } else { "yuv420p" };
19733 let y4m = Command::new("ffmpeg")19741 let y4m = Command::new("ffmpeg")
19734 .args([19742 .args([
lanes/band63-r1.report.mdadded+119 -0
@@ -0,0 +1,119 @@
1+# lane-band63 r1 — the cq-63 "defect" does not exist; a real one at cq 32 does
2+
3+Branch `lane-band63` off main `c729a38`, plus a merge of `lane-fi32x8` (c3a5032) so the
4+filter-intra-on configuration could be tested at all.
5+
6+## 1. The chartered premise is FALSE (measured, not argued)
7+
8+Charter: *"the 8-px band fixture at `--cq-level=63` mismatches ffmpeg on frame 0 for 8-bit
9+seeds 58/59/64 EVEN WITH `--enable-filter-intra=0`"* (from lanes/fi32x8-r1.report.md residue).
10+
11+Reproduced the exact recipe (fi32x8 gate family: `geq=lum='mod(floor({axis}/8)*{step},256)'`,
12+`noise=alls={18+(attempt%4)*3}:all_seed={42+attempt}`, `--cq-level=63`, cpu-used=0,
13+1:4 partitions on, min/max partition 8/32, directional/paeth/smooth intra off) and swept it
14+far wider than the three named seeds:
15+
16+| sweep | streams | result |
17+|---|---|---|
18+| fi32x8 family, attempts 0..23, 8+10 bit, `--enable-filter-intra=0` | 48 | 48 pixel-exact, 0 refusals |
19+| fi32x8 family, attempts 0..23, 8+10 bit, `--enable-filter-intra=1` (last) | 48 | 48 pixel-exact, 0 refusals |
20+| 32x32-gate family (noise 6..15), attempts 0..7, 8+10 bit, cq 63 | 16 | 16 pixel-exact |
21+| 32x32-gate family, seeds 58/59/64 x noise 6/9/12/15 x both axes, cq 63 | 24 | 24 pixel-exact |
22+
23+Seeds 58/59/64 (= fi32x8 attempts 16/17/22) are inside the first two rows and are exact at
24+both depths. Streams hashed; generator `gen.sh`/`gen2.sh`/`gen3.sh` in the scratchpad.
25+
26+EVIDENCE: $HOME/.cache/cargo-target-band63/debug/examples/decode_probe + ffmpeg rawvideo | 136 aomenc streams at cq 63 regenerated across 4 parameter sweeps, each decoded by ec-av1 and by ffmpeg and byte-compared full-frame (8-bit u8 dump, 10-bit u16 dump) | 136/136 identical, 0 refusals
27+
28+Why the premise looked true in fi32x8's round: that lane's control ran `--enable-filter-intra=0`
29+*before* the base recipe's `--enable-filter-intra=1`, and **aomenc keeps the LAST occurrence**
30+(class aomenc-first-flag-wins, already in memory) — so the control flag never arrived, and what
31+it saw was its own then-unfixed filter-intra path, not "another shape". Class: stale-premise
32+lanes / refusal-names-a-correlate.
33+
34+My own instrument repeated the class once: `decode_probe` had no 10-bit dump, so an
35+`EC_PROBE_OUT16` compare against a never-written file read as MISMATCH for three streams
36+(class stale-output-faked-measurement). Fixed by adding the dump, then re-measured.
37+
38+## 2. What changed
39+
40+- `crates/ec-av1/examples/decode_probe.rs:81` — `EC_PROBE_OUT16` dumps planes as
41+ little-endian u16, the only form a 10-bit pixel diff against
42+ `ffmpeg -pix_fmt yuv420p10le` can use. Without it no 10-bit claim from this instrument is real.
43+- `crates/ec-av1/src/stream.rs:16757` — the 32x32-level 1:4 gate's second quantiser is **63**
44+ instead of 45 (attempts 2,3,6,7 at both depths). The cq-32 attempts keep their exact streams,
45+ so nothing changes by accident. cq 63 is now coded, so the premise cannot come back unmeasured.
46+- `crates/ec-av1/src/stream.rs:16992` — the filter-intra 1:4 gate's rotation is
47+ `[32,45,55,63]` (attempts 6,7,14,15 at cq 63), same reason, with filter intra ON.
48+
49+Both gates keep every existing hard assert (per-depth `horz_proved > 0 && vert_proved > 0`,
50+`coeff_proved > 0`, `matched > 0`, `out_of_scope_mismatch == 0`, full-frame Y/U/V compare).
51+
52+Gate run:
53+```
54+EC_NOMEMGUARD=1 EC_AV1_REQUIRE_AOMENC=1 CARGO_TARGET_DIR=$HOME/.cache/cargo-target-band63 \
55+ cargo test -p ec-av1 --lib -j3 -- --nocapture 1to4
56+```
57+→ `test result: ok. 3 passed; 0 failed` (14.7 s):
58+- 32x32-level 1:4: 8-bit 8/8 exact, horz_4=56 vert_4=84 coded=140; 10-bit 8/8 exact,
59+ horz_4=56 vert_4=68 coded=124.
60+- filter-intra 1:4: 8-bit 5 matches/3 refusals, 54x(32x8)+5x(8x32); 10-bit 6 matches/1 refusal,
61+ 9x(32x8)+17x(8x32).
62+- superblock-level 1:4 (sibling, untouched): ok.
63+
64+EVIDENCE: gate stdout above | both 1:4 gates run with cq 63 in the rotation at 8 and 10 bit | 3 passed / 0 failed, cq-63 attempts pixel-exact with the 1:4 counters non-zero per depth
65+
66+## 3. A REAL defect found on the way (NOT the chartered one)
67+
68+The first rotation I tried (`[32,45,63]`) also moved attempt 6 from cq 45 to cq 32, creating a
69+stream nothing had ever coded — and it mismatches. Fully bisected, then set aside because it is
70+not this lane's charter and not reachable from the shipped rotation:
71+
72+- Stream: 192x128, 8-bit, seed 48, `geq` axis Y, step 103, `noise=alls=12:all_seed=48`,
73+ **`--cq-level=32`**, otherwise the 32x32-level 1:4 gate recipe (filter intra off).
74+ Pinned at `/tmp/.../scratchpad/b63/gateA.obu` (regenerate: `gen.sh 48 Y 103 12 32 8 <out>`).
75+- Stage: **reconstruction**, not filtering — `EC_AV1_PREFILT_DUMP` already differs, identically
76+ to `EC_AV1_POSTDEBLOCK_DUMP` (9057 luma samples, first at x=64,y=64).
77+- First divergent element (range ladder, `EC_TRACE_MODE`/`EC_TRACE_MODE_STEP`, ours vs the
78+ instrumented aomdec, aligned by (mi_row, mi_col, name)): **`mi_row=24 mi_col=8`, element
79+ `mode`** — identical entry range 46952 on both sides, then aomdec `val=12 rng=36608`,
80+ ec-av1 `val=7 rng=33744`. Same range in, different value and range out = **wrong y-mode CDF
81+ row**, i.e. a wrong intra-mode neighbour context, not a wrong table value.
82+- Context: the block is `BLOCK_32X16` (aomdec `bsize=8`) at the 32x32 level; its *above*
83+ neighbour is the last 32x8 `PARTITION_HORZ_4` strip at (22,8) (mode 12/PAETH) and its *left*
84+ is the 32x8 strip at (24,0) (mode 0/DC). `decode_block_rect4` (decode.rs:5990) stamps the
85+ COARSE 16-px `above_mode`/`left_mode` cells with "last strip wins"; the suspect is that
86+ coarse stamp seen by a 32x16 sibling in the next quadrant (class
87+ context-read-from-one-cell / neighbour-votes-all-its-fields).
88+- Everything before that element is bit-exact: the ladder matches element for element through
89+ `mi_row=22`, so the entropy stream, the strips' own coefficients and their pixels are right.
90+
91+EVIDENCE: /tmp/.../scratchpad/b63/{gateA.obu,ours.trace,aom.trace,o.pre.f0,a.pre.f0} | ec-av1 vs instrumented aomdec range ladders + pre-filter/post-deblock dumps on the pinned stream | first divergence mi_row=24 mi_col=8 `mode` (entry rng 46952 both, out 36608 vs 33744); recon differs from (64,64), 9057 luma samples, deblock-only bleed at rows 62-63
92+
93+## 4. Residue
94+
95+- deferred: the seed-48 @ cq-32 y-mode-context defect above — a wrong CDF row for a 32x16 block
96+ whose above neighbour is a 32x8 1:4 strip — what unblocks it: reading the above/left mode ctx
97+ ec-av1 computes at (24,8) against libaom's `intra_mode_context[]` of the same two neighbours
98+ (the ladder, stream and stage are already pinned above, so it starts at the fix, not the hunt).
99+ Not reachable from the shipped gate rotation (attempts 0,1,4,5 keep their original cq-32
100+ streams and pass).
101+- accepted: this lane merges `lane-fi32x8` (c3a5032, merge-ready per its own report) because the
102+ filter-intra-on arm of the premise cannot be tested on main, which still refuses those strips.
103+ If fi32x8 lands on main first, this merge is a no-op.
104+- accepted: no refusal is lifted this round — nothing was refused. The deliverable is a coded
105+ quantiser the gates never coded, and a disproof.
106+
107+## 5. Suite
108+
109+```
110+systemd-run --user --unit=band63-suite-... -p MemoryMax=10G --same-dir bash -lc \
111+ 'EC_NOMEMGUARD=1 EC_AV1_REQUIRE_AOMENC=1 CARGO_TARGET_DIR=$HOME/.cache/cargo-target-band63 \
112+ nice -n 10 cargo test -p ec-av1 --lib -j3 > $HOME/.cache/band63-suite.log 2>&1'
113+```
114+→ `test result: ok. 340 passed; 0 failed; 31 ignored` (337.9 s).
115+
116+`a_real_aomenc_multi_tile_intra_stream_decodes_pixel_exact` — red on main 11633d7 when
117+lane-fi32x8 reported — is green here: lane-mtfix fixed it in main c729a38, this base carries it.
118+
119+EVIDENCE: $HOME/.cache/band63-suite.log | full `cargo test -p ec-av1 --lib` on lane-band63 c099bef with the oracle required | 340 passed / 0 failed / 31 ignored