forge
Explore
Log in

Don't you dare go Hollow

The H1 report -- root cause, the class sweep, the measured red/green, the gate's two mutation directions, and the residue handed on

Browse files at this commit

ea4a14d529276517b5bba05e21dbb817ff4b90fcAhmet Kaan GümüşParent: 9470822
  • docs
    • the H1 report -- root cause, the class sweep, the measured red/green, the gate's two mutation directions, and the residue handed on
Show full message
docs(av1444rect): the H1 report -- root cause, the class sweep, the measured red/green, the gate's two mutation directions, and the residue handed on
lanes/av1444rect.report.mdadded+240 -0
@@ -0,0 +1,240 @@
1+# lane-av1444rect — H1: 4:4:4 lossy + a 1:4 (RECT) partition
2+
3+**Tree.** `lane-av1444rect` off `4155c7c7`, worktree `~/.cache/wt/av1444rect`.
4+Fix commit `f92776ba`. One decode.rs hunk, one gate, one pinned fixture.
5+
6+## 1. Root cause
7+
8+`decode_inter_block`'s `around_c` — the gather that decides a 1:4 inter
9+strip's chroma **coefficient context** — chose the 4:2:0 PAIR extent with no
10+`ss` gate:
11+
12+```rust
13+// crates/ec-av1/src/decode.rs, decode_inter_block
14+let around_c = match strip_chroma {
15+ Some(s) if s.has_chroma => {
16+ let (pw, ph) = if s.horz {
17+ if ss_x(fctx) == 1 && ss_y(fctx) == 0 { (16, 4) } else { (16, 8) }
18+ } else { (8, 16) };
19+ ...
20+ neighbours.around_mi_rect(s.pair_mi, pw, ph)
21+ }
22+ _ => around,
23+};
24+```
25+
26+At ss (0,0) no pair exists. `is_chroma_reference` (av1_common_int.h:1454):
27+
28+```c
29+int ref_pos = ((mi_row & 0x01) || !(bh & 0x01) || !subsampling_y) &&
30+ ((mi_col & 0x01) || !(bw & 0x01) || !subsampling_x);
31+```
32+
33+At 4:4:4 `!subsampling_y` and `!subsampling_x` are both true, so `ref_pos`
34+is **unconditionally true**: every block is its own chroma reference. A
35+HORZ_4 16x4 strip codes its OWN 16x4 chroma (the `strip_chroma` setter at
36+`decode.rs:50840` already gives it `pair_mi == at_mi` for exactly this
37+reason), and its context extent is the strip's own 4 px.
38+
39+The pair gather used `ph = 8`, which makes `around_mi_rect` walk
40+`left[mi_r]` **and** `left[mi_r + 1]`. The strip's own 4-px extent walks
41+`left[mi_r]` only. So the U unit's `get_txb_ctx` OR-ed in a left chroma
42+neighbour that does not exist, `txb_skip_ctx` came out 1 where libaom's is
43+offset-7 row 7, and the arithmetic coder forked.
44+
45+**The fix** is one match arm, gated on the same `ss` the plane geometry is:
46+
47+```rust
48+Some(_) if ss_x(fctx) == 0 => { hit!(RECT4_INTER_OWN_CHROMA444_HITS); around }
49+```
50+
51+`around` is the block's own `around_mi_rect(at_mi, write_w, write_h)`, which
52+at ss 0 IS the chroma block's extent. The horz `(16, 4)` sub-branch also
53+loses its now-redundant `ss_x == 1 &&` conjunct (it is unreachable at
54+ss_x 0, where the new arm has already returned).
55+
56+**Class: `ss-gate-missing-on-a-4:2:0-pair-geometry`.** A 4:2:0 pair extent
57+(or anchor) hardcoded on a path that also runs at ss (0,0), where
58+`is_chroma_reference` makes the pair non-existent. The 4:2:0 reduction of
59+the expression is the tell.
60+
61+### Class sweep (same batch)
62+
63+| site | verdict |
64+|---|---|
65+| `decode_inter_block` `around_c` | **the defect** — fixed |
66+| `decode_rect4_16_strip` (intra key-frame 1:4), `decode.rs:17308` | already ss-gated (`if ss_x == 0 && ss_y == 0 { (lmi, bw, bh) }`, the `lane-av1-444` row) |
67+| `decode_rect4_16_intrabc` (`decode.rs:16466`) | **same class, still open** — see §6 |
68+| `read_inter_rect_chroma`, `decode_block_rect4/64`, the 128-root mu-chunk arm | already ss-parameterised (`uw << ss_x`, `chunk_chroma_w = 64 >> ss_x`) |
69+
70+## 2. Localization, measured
71+
72+**Fixture.** `aomenc --codec=av1 --profile=1 --passes=1 --end-usage=q
73+--cq-level=20 --cpu-used=2 --threads=1 --row-mt=0 --lag-in-frames=0
74+--kf-max-dist=100 --limit=2` over `ffmpeg -f lavfi -i
75+"testsrc2=size=128x96:rate=25" -frames:v 2 -pix_fmt yuv444p -f
76+yuv4mpegpipe`.
77+
78+6441 B, sha256 `77f727e76d81fe48cd03709f799131677c04869b163e18d78e96bc742ec69153`,
79+FNV-1a64 `0x04368b2d2e9172b0`. Pinned at
80+`crates/ec-av1/fixtures/444_lossy_rect4_inter_witness.obu`.
81+
82+`rate=25` is load-bearing and the sweep report did not say so: `testsrc2`'s
83+pattern is time-parameterised, so `rate=1` yields a different 8121-byte
84+stream that decodes exactly. The report's 6441 B / 8884-wrong / Y(91,32)
85+numbers reproduce only at `rate=25`.
86+
87+**Red before.** frame 0 exact; frame 1: 8884 of 36864 samples wrong, first at
88+Y(91,32).
89+
90+**Symbol fork.** `EC_SYMR` both sides, aligned 1:1 on
91+`(nsymbs, symbol, post_rng, 32768 - our_icdf0)`: reads 0..26262 pair
92+exactly, read **26263** diverges, both sides at mi (8,16):
93+
94+| | site | read |
95+|---|---|---|
96+| oracle | `decodetxb.c:158` (the `txb_skip` read) | plane 1 (U), `txb_skip_ctx` **7**, symbol 1 (all-zero) |
97+| ours | `read_inter_plane_rect` (a 16x4 **chroma** unit) | re-indexed ctx **1**, symbol 0 |
98+
99+**The report's "ours reads a second LUMA unit" is refuted.** That came from
100+`read_coeffs_rect`'s `tag=all_zero plane=0` label, which the report itself
101+flagged as hardcoded. A per-unit trace (`plane`, `w`, `h`, `txb_skip_ctx`,
102+`around`) shows the block is a **16x4 inter strip** at (64,32) and our
103+decoder reads exactly the unit the oracle reads — one luma 16x4 at bit 3706,
104+then one U 16x4 at bit 3719. The fork is a **context row**, not a unit
105+count. Same conclusion Agent06-3 reached independently on H5 from the other
106+half of the same formula.
107+
108+**Root-of-context, measured** with `EC_DCDUMP` + `EC_CHROMA_PUB`: at the
109+U unit our gather reported `left[9][plane 1].level = 7` (one extra luma mi
110+row). The oracle's `get_txb_ctx` there reads `ctx_base 0` →
111+`txb_skip_ctx = 0 + 7`.
112+
113+## 3. The fix, measured
114+
115+| | frame 0 | frame 1 |
116+|---|---|---|
117+| before | exact | 8884/36864 wrong, first Y(91,32) |
118+| after | exact | **byte-exact** |
119+
120+2/2 frames byte-exact against the instrumented `aomdec`
121+(`EC_AV1_FINAL_DUMP`, decode order).
122+
123+**Counter.** `decode::rect4_inter_own_chroma444_hits()` — 9 on the pinned
124+witness, 0 on the 4:2:0 control of the same source and flags.
125+
126+## 4. Gate
127+
128+`a_444_lossy_rect4_inter_stream_decodes_pixel_exact`
129+(`crates/ec-av1/src/stream.rs`). The first exactness gate for the 4:4:4
130+**LOSSY** cell — the whole committed 4:4:4 base was lossless 8-bit.
131+
132+- pinned fixture, length + FNV asserted;
133+- chroma planes asserted full resolution (the 4:4:4 shape claim, stated
134+ rather than left to the byte compare to imply);
135+- byte-for-byte through `decode_all_frames_vs_oracle` (oracle aomdec);
136+- non-vacuity: the counter must be non-zero, so the corrected route ran;
137+- specificity: the same source and flags at 4:2:0 code 16 HORZ_4 + 28 VERT_4
138+ strips (asserted, so the arm cannot pass for the wrong reason), leave the
139+ counter at 0, and are themselves compared byte-for-byte against aomdec —
140+ the arm that goes red if the new arm is ever widened past `ss_x == 0`.
141+
142+**Mutation proof.** Restoring the old pair arm with the counter left in
143+place:
144+
145+```
146+decode-order frame 1 of 2 differs from the oracle at byte 4187
147+(ours 35 vs 38), 8884 bytes differ
148+```
149+
150+— the same 8884 and the same Y(91,32) as the original red, so the gate
151+catches this defect and not a near-miss of it.
152+
153+Second direction: widening the arm to `Some(_)` leaves the 4:2:0 control at
154+0 gathers, because at ss_x 1 a 1:4 strip's chroma reaches
155+`decode_inter_block` through a different caller and never sets
156+`inter_strip_chroma`. That is why the identity proof is the 4:2:0 **oracle
157+compare**, not the counter: the counter proves the 4:4:4 route fired, the
158+oracle compare proves nothing else moved.
159+
160+## 5. Identity and the sweep's other divergences
161+
162+Green against this `decode.rs`:
163+
164+- the crate's whole `444` family — 9 tests;
165+- `rect_strip` family — 10 tests;
166+- `a_real_aomenc_inter_sequence_with_a_16_level_rect_leaf_decodes_pixel_exact`;
167+- all **three new chroma-format-sweep gates**, run in the sweep worktree
168+ `~/.cache/wt/av1fmt` with this `decode.rs` copied in and the sweep tree
169+ restored afterwards:
170+ `a_lossless_444_10bit_inter_stream_decodes_pixel_exact`,
171+ `a_444_12bit_inter_sequence_decodes_pixel_exact`,
172+ `a_real_aomenc_odd_coded_dimension_streams_decode_pixel_exact`.
173+
174+Same-class recipes re-measured:
175+
176+| recipe | size | before | after |
177+|---|---|---|---|
178+| **H1** 4:4:4 lossy cq20 `--limit=2` | 6441 B | frame 1: 8884 wrong | **byte-exact** |
179+| H1 control `--enable-rect-partitions=0` | 6529 B | exact | exact |
180+| **H2** 4:4:4 lossy `--sb-size=64 --min/max-partition-size=64`, 4 f | 21830 B | frames 0-1 exact, from frame 2 608 wrong, U/V only, first U(2,31) | **unchanged** — still 608 wrong, U/V only |
181+| **H3** 4:4:4 lossless `--tile-columns=1` 256x128, 6 f | 77847 B | sweep reported 90 chroma wrong in frame 0 | **byte-exact, 6/6** |
182+
183+**H2 is not this class and is not fixed here.** Its entropy decode is
184+bit-identical over 140820 reads (the sweep measured it), so it is
185+reconstruction arithmetic, not a context: the `av1_get_adjusted_tx_size`
186+clamp on a 4:4:4 chroma TX_32X64 is still the prime suspect. Re-measured
187+here to prove the class claim above: H2's numbers are bit-identical before
188+and after, so this fix neither caused nor cured it.
189+
190+**H3**: with the sweep's full flag set
191+(`--profile=1 --passes=1 --lossless=1 --end-usage=q --cq-level=20
192+--cpu-used=2 --threads=1 --row-mt=0 --lag-in-frames=0 --kf-max-dist=100
193+--limit=6 --tile-columns=1`) the 6-frame 77847-byte stream is byte-exact.
194+Without those flags the same source diverges hard, so the sweep's H3 recipe
195+was under-specified; the tile-column defect does not reproduce on the
196+recipe as re-derived here. Flagging, not claiming.
197+
198+**H5 (lane-av1h5, Agent06-3): out of scope and structurally disjoint.** The
199+new arm lives inside `match strip_chroma`, which is `Some` only from the
200+single setter the PARTITION_HORZ_4 / VERT_4 16x4 / 4x16 `inter_piece` loop
201+runs; a BLOCK_128X128 unsplit root never reaches it.
202+
203+## 6. Residue handed on, not fixed here
204+
205+- **`decode_rect4_16_intrabc` (`decode.rs:16466`) — same class, still
206+ open.** The intra-BC 16x4 / 4x16 strip reader hardcodes the 4:2:0 pair
207+ with no `ss` gate at all:
208+ `let (pw, ph) = if horz { (16, 8) } else { (8, 16) };`,
209+ `pair_mi = (lmi.0 - 1, lmi.1) | (lmi.0, lmi.1 - 1)`, and
210+ `cpx = pair_mi.1 * MI / 2` (a literal 4:2:0 halving). At ss (0,0) that
211+ decodes an 8x4 chroma block at a halved anchor where libaom codes a
212+ 16x4 at the strip's own. I did not fix it: it needs a 4:4:4 witness with
213+ screen-content tools on (aomenc sets `allow_screen_content_tools` for
214+ `testsrc2` yuv444p by default), which I had no budget to produce, and
215+ fixing an unreproduced branch here would be a guess. The pinned H1 fixture
216+ decodes exactly, so it does not reach that reader.
217+- **H2** — 4:4:4 lossy + tx-size-search chroma ±1, entropy-clean. Own lane.
218+- **H4** — 4:4:4 lossless + tile rows, hard divergence. Own lane; untouched.
219+- **H5** — 4:4:4 10-bit lossless 128 root, chroma band/offset term. Agent06-3.
220+- **H6** — 12-bit 4:4:4 needs a smoothed source. Coverage caveat, not a
221+ defect.
222+
223+## 7. Method notes for the next lane
224+
225+- `testsrc2` is time-parameterised: any sweep recipe quoting it must pin
226+ `rate`, or the fixture is not reproducible. `rate=1` vs `rate=25` on
227+ 128x96 yuv444p is the difference between an 8121-byte exact stream and
228+ the 6441-byte divergent one.
229+- `read_coeffs_rect`'s `EC_COEFF_STEP tag=all_zero` prints a hardcoded
230+ `plane=0`. It has now mis-attributed a chroma read as a luma one in two
231+ independent reports. The oracle's `EC_COEFF_STEP` prints the real plane.
232+ Pair the two traces by the msac `post_rng` (both sides print it after the
233+ read) rather than by line index.
234+- `EC_AV1_TELL ... label=block_entry` prints the msac bit position at each
235+ `decode_inter_block` entry, and the oracle's `EC_SYMR` `pre` third field
236+ is our bit position minus a constant 15. That pair joins the two symbol
237+ streams to a block without any new instrumentation.
238+- `EC_DCDUMP` already dumps the above/left entropy contexts per plane;
239+ `#[track_caller]` on `Neighbours::around_mi_rect` names the gather site
240+ in one line if you ever need to attribute one again.