forge
Explore
Log in

Don't you dare go Hollow

Merge lane-av1444d10: a 32-capped 4:4:4 chroma palette walk handed every unit the WHOLE block's palette buffer

Browse files at this commit

57ac17ea11404468166ea3173bf6eac84ca7936bAhmet Kaan GümüşParent: 323c24276c5a85
The cell the census flagged (s444_352x242_10b) diverged 0/1166/1413 and is now byte-exact on all 17
decode-order frames; the 106-fixture corpus goes 95 exact / 1 diverging -> 96 exact / 0 diverging, with no
other fixture moving and no sample count moving on any exact cell. Gated with a mutation proof and a
reachability counter; regression 178 passed / 0 failed / 2 pre-existing ignored.

ROOT CAUSE, and the census's own "geometry-sensitive" framing was the wrong axis: 352x242's distinction is
not frame width or height but the NUMBER OF CHROMA TRANSFORM UNITS in one block. A 32x64 luma strip's
chroma plane block is also 32x64 at ss(0,0), so decode_block_rect tiles it into nh=2 chroma units of 32x32,
and BOTH arms of that tiled walk handed every unit the whole block's palette prediction buffer. The read
side indexes prediction[..side*side], i.e. always the buffer's top-left corner, so unit (0,1) at pixel
(64,224) reconstructed the block's row-192 palette values (flat 209) where libaom writes row 224's (216).
The neighbouring 32x32 PAETH block at (96,224) had that pixel as its LEFT edge, so paeth() returned "left"
for 19 more columns of its own top row -- the halo was a consequence, not a second defect. libaom hands
av1_predict_intra_block a ref at the UNIT's own origin (reconintra.c:1707) and read_coeffs walks the plane
block with each unit's own blk_row/blk_col. Fix = window the buffer per unit via palette_window (already
used by the 4x4 lossless chroma units and the luma split-transform walk; this 32-capped 4:4:4 walk was the
one still un-windowed) at decode.rs:20106-20113 and :20164-20172.

CLASS SWEEP, done by the lane: all ~100 set_palette_pred sites audited -- every other site either hands a
whole-block buffer to exactly ONE push (correct by construction) or already windows; these two were the
only whole-buffer hand-offs inside a tiled unit loop. Corpus-wide sweep of all 106 committed fixtures on
both states, the five same-depth controls (320x242/320x250/352x250/416x242/416x250) 0/0/0 before and after.
Filter stages exonerated by measurement, not assumption: the oracle's pre-filter dump equals its final dump
on every sample of frame 0 (deblock/CDEF/LR/superres inert), and our pre-filter diff set is EXACTLY our
final diff set, so the defect is pre-filter prediction.

ATTACK SURFACE, stated rather than hidden: the counter's floor of 4 is a reachability floor from one
stream, not a census; the horizontal windowing (nw>1) and a 12-bit variant were NOT built, so nw>1 is
unmeasured; the 4:2:2 header guard and the known-broken 4:2:0 group-tail SKIP arm were not touched.
crates/ec-av1/fixtures/444_lossy_palette_chroma_352x242_10b.obuadded+0 -0

Binary file changed

crates/ec-av1/src/decode.rsmodified+35 -2
@@ -2719,6 +2719,29 @@ pub(crate) fn palette_split_tx_hits() -> usize {
2719 PALETTE_SPLIT_TX_HITS.with(|c| c.get())2719 PALETTE_SPLIT_TX_HITS.with(|c| c.get())
2720 }2720 }
2721 2721
2722+thread_local! {
2723+ /// lane-av1444d10: chroma PREDICTION units on the 32-capped tiled chroma
2724+ /// walk (`decode_block_rect`'s `uw/uh = min(chroma, 32)` units) that were
2725+ /// handed a WINDOWED slice of their block's palette buffer -- i.e. the
2726+ /// units that are NOT the block's top-left corner. Counts units, not
2727+ /// blocks, and only units whose block actually has a UV palette, so a
2728+ /// stream without a tiled palette chroma block leaves it at zero.
2729+ static CHROMA_PALETTE_WINDOW_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
2730+}
2731+
2732+/// Current value of [`CHROMA_PALETTE_WINDOW_HITS`].
2733+#[allow(dead_code)] // read only from the `#[cfg(test)]` gates
2734+pub(crate) fn chroma_palette_window_hits() -> usize {
2735+ CHROMA_PALETTE_WINDOW_HITS.with(|c| c.get())
2736+}
2737+
2738+/// Zeroes [`CHROMA_PALETTE_WINDOW_HITS`] so a gate can read it as a DELTA
2739+/// (it is process-wide, like every counter here).
2740+#[allow(dead_code)] // read only from the `#[cfg(test)]` gates
2741+pub(crate) fn reset_chroma_palette_window_hits() {
2742+ CHROMA_PALETTE_WINDOW_HITS.with(|c| c.set(0));
2743+}
2744+
2722 thread_local! {2745 thread_local! {
2723 /// lane-pal8 r1: square 8x8 LEAVES ([`decode_leaf8`]) that actually use a2746 /// lane-pal8 r1: square 8x8 LEAVES ([`decode_leaf8`]) that actually use a
2724 /// palette (Y or UV) -- the shape every 8-bit `--tune-content=screen`2747 /// palette (Y or UV) -- the shape every 8-bit `--tune-content=screen`
@@ -20082,7 +20105,12 @@ fn decode_block_rect64(
20082 let levels = if uw == uh {20105 let levels = if uw == uh {
20083 let plane = if plane_idx == 1 { &mut *u } else { &mut *v };20106 let plane = if plane_idx == 1 { &mut *u } else { &mut *v };
20084 if let Some((ub, vb)) = &palette_uv_bufs {20107 if let Some((ub, vb)) = &palette_uv_bufs {
20085- set_palette_pred((if plane_idx == 1 { ub } else { vb }).clone(), fctx);20108+ let pbuf = if plane_idx == 1 { ub } else { vb };
20109+ set_palette_pred(
20110+ palette_window(pbuf, chroma_w, cu_col * uw, cu_row * uh, uw, uh),
20111+ fctx,
20112+ );
20113+ hit!(CHROMA_PALETTE_WINDOW_HITS);
20086 }20114 }
20087 read_plane(20115 read_plane(
20088 dec,20116 dec,
@@ -20136,7 +20164,12 @@ fn decode_block_rect64(
20136 block_iqmatrix(fctx, plane_idx, uw, uh, tx_type),20164 block_iqmatrix(fctx, plane_idx, uw, uh, tx_type),
20137 );20165 );
20138 if let Some((ub, vb)) = &palette_uv_bufs {20166 if let Some((ub, vb)) = &palette_uv_bufs {
20139- set_palette_pred((if plane_idx == 1 { ub } else { vb }).clone(), fctx);20167+ let pbuf = if plane_idx == 1 { ub } else { vb };
20168+ set_palette_pred(
20169+ palette_window(pbuf, chroma_w, cu_col * uw, cu_row * uh, uw, uh),
20170+ fctx,
20171+ );
20172+ hit!(CHROMA_PALETTE_WINDOW_HITS);
20140 }20173 }
20141 push_intra_rect(20174 push_intra_rect(
20142 plane_idx,20175 plane_idx,
crates/ec-av1/src/stream.rsmodified+110 -0
@@ -50712,6 +50712,116 @@ exit 0
50712 }50712 }
50713 }50713 }
50714 50714
50715+ /// lane-av1444d10: the 10-bit 4:4:4 352x242 cell the 4:2:2 census
50716+ /// (`lanes/av1422census.report.md` §4 class D) found diverging on chroma
50717+ /// only -- 0 / 1166 / 1413 over 17 of 17 decode frames, first bad sample
50718+ /// at decode frame 0 plane U row 224 col 64 -- and the fix for it, a byte
50719+ /// exact gate. 4:4:4 is a format this decoder claims to support, so the
50720+ /// cell is not probe-only evidence.
50721+ ///
50722+ /// **Why this cell and not its five same-depth controls.** `s444_*_10b`
50723+ /// at 320x242, 320x250, 352x250, 416x242 and 416x250, same encoder recipe,
50724+ /// same 10-bit depth, were all byte-exact before the fix and still are; only
50725+ /// 352x242 diverged. What 352x242 has is the first block of the cell whose
50726+ /// chroma is TALLER than the 32-pixel unit cap at ss (0,0): a 32x64 luma
50727+ /// strip keeps its 32x64 chroma, and `decode_block_rect`'s tiled chroma
50728+ /// walk splits it into `nh = 2` units of 32x32. Every other cell's chroma
50729+ /// blocks are <= 32 on both axes, so `nw * nh == 1` and the whole-block
50730+ /// buffer IS the unit's window -- the bug is invisible there. That is why
50731+ /// the census could report "geometry-sensitive" without the mechanism:
50732+ /// the sensitive axis is chroma UNIT COUNT, not frame width or height.
50733+ ///
50734+ /// **The defect.** Both tiled arms handed the unit the WHOLE block's
50735+ /// palette prediction buffer, and `PlaneBuf::reconstruct` reads its first
50736+ /// `side * side` entries, so unit (0,1) at pixel (64, 224) reconstructed
50737+ /// the block's row-192 palette values (flat 209) where libaom writes
50738+ /// row 224's (216). The neighbouring 32x32 `PAETH_PRED` block at
50739+ /// (96, 224), whose left edge sample IS that pixel, then propagated 19
50740+ /// more wrong columns along its own top row -- which is why the census saw
50741+ /// 53 wrong columns rather than 32.
50742+ ///
50743+ /// **Red before the fix, by this gate's own name:** with the two
50744+ /// `palette_window` calls reverted the first wrong sample is decode frame
50745+ /// 0 plane U row 224 col 64 (ours 209, oracle 216) and the totals are
50746+ /// 0 / 1166 / 1413 over 17 decode frames.
50747+ ///
50748+ /// **Non-vacuity, four ways.** (1) The pinned bytes: length 24875 and
50749+ /// FNV-1a64 `0x7fda_dbb4_3bbf_9af3`, sha256
50750+ /// `84df2f37cc7982f9a572443d85dfcc13bf366a64f3fb567391dcd5acd58a0ad2`.
50751+ /// (2) 17 decode-order frames at 352x242 with FULL-RESOLUTION chroma, so
50752+ /// a decoder that kept the 4:2:0 extent cannot pass the compare.
50753+ /// (3) `decode::chroma_palette_window_hits()` read as a delta must be at
50754+ /// least 1: the fixed lines are the only thing that increments it, so a
50755+ /// gate that passes without them running would be
50756+ /// gate-blind-to-feature. (4) The oracle comparator this gate leans on has
50757+ /// its own per-plane one-byte-flip liveness control in the crate
50758+ /// (`every_oracle_comparator_reds_on_a_one_byte_wrong_oracle`).
50759+ #[test]
50760+ fn a_444_lossy_palette_chroma_unit_window_is_byte_exact_at_352x242_10bit() {
50761+ const NAME: &str = "a_444_lossy_palette_chroma_unit_window_is_byte_exact_at_352x242_10bit";
50762+ const FIXTURE: &str = "fixtures/444_lossy_palette_chroma_352x242_10b.obu";
50763+ const LEN: usize = 24875;
50764+ const FNV: u64 = 0x7fda_dbb4_3bbf_9af3;
50765+ const W: usize = 352;
50766+ const H: usize = 242;
50767+ // 16 SHOWN frames (`--limit=16`); the oracle compare below is the one
50768+ // that walks all 17 DECODE-order pictures (16 shown + 1 hidden altref).
50769+ const FRAMES: usize = 16;
50770+ // measured 4 on this stream (two tiled palette chroma blocks x U and V)
50771+ const MIN_WINDOWED_UNITS: usize = 4;
50772+ let _guard = lock_gate_counters();
50773+ let obu = std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR")).join(FIXTURE);
50774+ let stream = std::fs::read(&obu).unwrap_or_else(|e| {
50775+ panic!(
50776+ "{NAME}: pinned fixture {} is missing ({e}) -- the gate cannot run, \
50777+ which is a failure, not a skip",
50778+ obu.display()
50779+ )
50780+ });
50781+ assert_eq!(stream.len(), LEN, "{NAME}: {FIXTURE} length moved");
50782+ assert_eq!(fnv1a64(&stream), FNV, "{NAME}: {FIXTURE} bytes moved");
50783+
50784+ // Process-wide with no reset: read as a DELTA, or a full-suite run
50785+ // leaves residue that would make the reachability assert vacuous.
50786+ crate::decode::reset_chroma_palette_window_hits();
50787+ let frames = decode_stream(&stream)
50788+ .unwrap_or_else(|e| panic!("{NAME}: {FIXTURE} no longer decodes cleanly: {e}"));
50789+ let windowed = crate::decode::chroma_palette_window_hits();
50790+ assert!(
50791+ windowed >= MIN_WINDOWED_UNITS,
50792+ "{NAME}: {FIXTURE} ran {windowed} windowed palette chroma unit(s), \
50793+ expected at least {MIN_WINDOWED_UNITS} -- the tiled chroma walk did \
50794+ not reach a palette block, so the fixed lines never ran and this \
50795+ gate is blind to the defect (class gate-blind-to-feature)"
50796+ );
50797+ assert_eq!(
50798+ frames.len(),
50799+ FRAMES,
50800+ "{NAME}: {FIXTURE} decode-order frame count"
50801+ );
50802+ for (i, f) in frames.iter().enumerate() {
50803+ assert_eq!(
50804+ (f.width, f.height),
50805+ (W, H),
50806+ "{NAME}: {FIXTURE} frame {i} dimensions"
50807+ );
50808+ assert_eq!(
50809+ f.u.len(),
50810+ W * H,
50811+ "{NAME}: {FIXTURE} frame {i} chroma plane is {} samples; at 4:4:4 \
50812+ it must be full resolution ({W}x{H})",
50813+ f.u.len()
50814+ );
50815+ }
50816+ if aomdec_available(NAME) {
50817+ let (decoded, hidden) = decode_all_frames_vs_oracle(&stream, NAME);
50818+ eprintln!(
50819+ "{NAME}: {FIXTURE} {decoded} decode-order frame(s) ({hidden} hidden) \
50820+ byte-exact vs aomdec, {windowed} windowed palette chroma unit(s)"
50821+ );
50822+ }
50823+ }
50824+
50715 /// lane-av1cfl: the 4:4:4 CfL AC body is a DIFFERENT function from the50825 /// lane-av1cfl: the 4:4:4 CfL AC body is a DIFFERENT function from the
50716 /// 4:2:0 one, and this gate is the proof that the format-blind50826 /// 4:2:0 one, and this gate is the proof that the format-blind
50717 /// `cfl_ac_q3_at` (`bw / 2, bh / 2`, a 2x2 luma average per chroma50827 /// `cfl_ac_q3_at` (`bw / 2, bh / 2`, a 2x2 luma average per chroma
lanes/av1444d10.report.mdadded+373 -0
@@ -0,0 +1,373 @@
1+# lane-av1444d10 — the 10-bit 4:4:4 352x242 chroma divergence is a chroma PALETTE PREDICTION window, fixed, and gated byte-exact
2+
3+**Status: FIXED and GATED.** The census cell `s444_352x242_10b` is byte-exact on all
4+17 decode-order frames against the instrumented aomdec, and so are all 106 committed
5+fixtures except the nine 4:2:2 ones that refuse by name. Two commits:
6+`f3afa5b7` (the fix) and `eb73ef89` (the fixture + the byte-exact gate + the
7+reachability counter). Base `ed7c99bc`.
8+
9+The census was right that this cell diverged and right that it was outside the 4:2:2
10+question. It was not, however, "geometry-sensitive" in the way its own framing
11+implies: **352x242's distinction is not frame width or height at all — it is the
12+number of CHROMA TRANSFORM UNITS in one block.**
13+
14+---
15+
16+## 0. The cell, pinned
17+
18+| field | value |
19+|---|---|
20+| name | `s444_352x242_10b` (census) → `fixtures/444_lossy_palette_chroma_352x242_10b.obu` (committed) |
21+| sha256 | `84df2f37cc7982f9a572443d85dfcc13bf366a64f3fb567391dcd5acd58a0ad2` |
22+| size | 24 875 B |
23+| FNV-1a64 | `0x7fda_dbb4_3bbf_9af3` |
24+| shape | 352x242, `ss_x = ss_y = 0` (4:4:4), 10-bit, profile 1 |
25+| frames | 17 decode-order (16 shown + 1 hidden altref) |
26+
27+Recipe — the census's own sweep driver, re-run here and byte-reproduced (the sha256
28+matched the census cell exactly, so the recipe is the census's, not a re-derivation):
29+
30+```text
31+ffmpeg -v error -f lavfi -i "testsrc2=size=352x242:rate=25" -frames:v 16 \
32+ -pix_fmt yuv444p10le -f rawvideo cell.raw -y
33+# y4m built by hand: header line, then "FRAME\n" + 352*242*3*2 bytes per frame
34+# (libaom's y4minput.c:1163-1171 requires the six bytes "FRAME\n" before EVERY frame)
35+aomenc --codec=av1 --profile=1 --input-bit-depth=10 --bit-depth=10 --limit=16 \
36+ --lag-in-frames=25 --auto-alt-ref=1 --enable-global-motion=1 --pass=1 \
37+ --cq-level=24 --threads=4 --kf-min-dist=0 --kf-max-dist=999999 \
38+ --width=352 --height=242 --cpu-used=0 --obu -o cell.obu cell.y4m
39+```
40+
41+Driver: `~/.cache/lanes/av1444d10/mksweep.sh` (a copy of the census's, unmodified),
42+invoked as `OUT=... DEPTHS=10 WIDTHS="320 352 416" HEIGHTS="242 250" bash mksweep.sh`.
43+The four other 4:4:4 10-bit cells named as controls reproduce byte-identically too
44+(sha256 in §4).
45+
46+Instrument: my own driver, `~/.cache/lanes/av1444d10/run.py` /
47+`corpus.py`, over the census's `cmp422.py` comparator — geometry parsed from
48+**aomdec's own y4m header**, never from a file size; per-plane spans from each
49+frame's own plane lengths; wrong sample counted at the stream's own sample depth
50+(2 B here, so a 10-bit difference in the top bits cannot hide); hard error on an
51+empty frame set. Both sides are `EC_AV1_FINAL_DUMP` (`.f<N>` indexed by DECODE index,
52+hidden alt-refs included), so every total below is on the **decode-order** basis.
53+
54+---
55+
56+## 1. Reproduction on my tip
57+
58+The census measured at its own parent. Nothing moved. `repro_before.json`:
59+
60+| cell | status | frames | Y | U | V | first bad (decode frame, plane, row, col, ours, oracle) |
61+|---|---|---|---|---|---|---|
62+| `s444_320x242_10b` | BYTE-EXACT | 17 | 0 | 0 | 0 | — |
63+| `s444_320x250_10b` | BYTE-EXACT | 17 | 0 | 0 | 0 | — |
64+| **`s444_352x242_10b`** | **DIVERGES** | 17 | **0** | **1166** | **1413** | **0, U, 224, 64, 209, 216** |
65+| `s444_352x250_10b` | BYTE-EXACT | 17 | 0 | 0 | 0 | — |
66+| `s444_416x242_10b` | BYTE-EXACT | 17 | 0 | 0 | 0 | — |
67+| `s444_416x250_10b` | BYTE-EXACT | 17 | 0 | 0 | 0 | — |
68+
69+17 of 17 decode frames carry at least one wrong sample, first bad at decode frame 0
70+— identical to the census. **Comparator liveness, three planes, one run each:** with
71+the tip build the cell is `0/0/0`, and flipping bit 0 of the low byte of ONE oracle
72+sample per plane at decode frame 0 (so `+1` is exact by construction) moves the
73+count by exactly `+1` in that plane and leaves the other two at 0:
74+
75+```
76+baseline (tip build) Y/U/V: 0 0 0
77+flip Y (frame 0): Y +1 U +0 V +0 (abs 1/0/0)
78+flip U (frame 0): Y +0 U +1 V +0 (abs 0/1/0)
79+flip V (frame 0): Y +0 U +0 V +1 (abs 0/0/1)
80+```
81+
82+Per-decode-frame Y/U/V, before (all 17 frames, every one bad):
83+
84+| frame | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 |
85+|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
86+| U | 53 | 54 | 54 | 54 | 170 | 54 | 162 | 54 | 58 | 54 | 61 | 54 | 54 | 61 | 61 | 54 | 54 |
87+| V | 51 | 51 | 51 | 52 | 160 | 52 | 158 | 52 | 58 | 52 | 158 | 52 | 51 | 156 | 156 | 52 | 51 |
88+
89+Y is 0 in every frame. The per-plane wrong-sample bounding box over all 17 frames is
90+`U rows 222..226, cols 63..118` and `V rows 222..226, cols 63..114`.
91+
92+---
93+
94+## 2. PREDICTION or RESIDUAL: the filter chain is exonerated, and it is a PREDICTION defect
95+
96+The brief asked me to check the frame header before assuming the filter chain is
97+inert. It is inert here, and the check does not need the header: **the oracle's own
98+pre-filter dump equals the oracle's own final dump.**
99+
100+| oracle rung | what it is | frame-0 size | vs FINAL (low byte), every sample |
101+|---|---|---|---|
102+| `EC_AV1_PREFILT_DUMP` | after tile decode, before ANY loop filter, `p[c] & 0xFF` | 255 552 B (352x242x3, 1 B/sample) | **0 differences** |
103+| `EC_AV1_FINAL_DUMP` | after CDEF + superres + LR, u16 LE | 511 104 B | (the reference) |
104+
105+Both rungs narrow to the same projection (`narrow[c] = p[c] & 0xFF`, per the
106+rung's own `ec_dump_narrow_row`), so the comparison is apples to apples: **deblock,
107+CDEF, loop restoration and superres changed no low byte anywhere in this cell.**
108+
109+Ours, same way: our `EC_AV1_PREFILT_DUMP` (352x256 aligned, 1 B/sample) against the
110+oracle's over the crop region has **exactly 104 differences — U row 224 cols 64..116
111+(53) and V row 224 cols 64..114 (51)** — i.e. the *same set* as our FINAL diff set,
112+and not one more. The defect is therefore pre-filter: **reconstruction**, and inside
113+reconstruction, **prediction, not residual**:
114+
115+| stage | measured | what it rules out |
116+|---|---|---|
117+| entropy decode | in lockstep: 17/17 frames on both sides, no desync, byte-identical bitstream parse | syntax / mode / coefficient read |
118+| residual (probe) | `res0 = [0,0,0,0,0,0,0,0]`, `rescol0 = [0,…]` on the owning unit; the residual is read identically on both sides | inverse transform, dequant |
119+| **prediction (probe)** | **the owning unit's prediction buffer is wrong**: see §3 | — |
120+| deblock / CDEF / LR / superres | oracle PREFILT == oracle FINAL, low byte, every sample | all four |
121+
122+`EC_PRED=1` on our side (the `OUR_PRED` / `OUR_RECON` rungs, `decode.rs:4650`) prints,
123+for the owning unit:
124+
125+```text
126+OUR_PRED x=64 y=224 plane=1 side=32 mode=0 sum=442144 row0=[209 x32] col0=[209,216,216,…]
127+```
128+
129+against the oracle's, which for that block prints **nothing at all** — because the
130+oracle's `EC_PREDND` only fires for non-directional predictions and a palette block
131+returns before it. Aligning the two traces by `(plane, txw, txh, sum)` (the oracle's
132+`mi_row`/`mi_col` in that print are not pixel/8, so coordinates do not align) the
133+sides agree on every event until this one, where ours has TWO extra
134+`plane=1 txw=32 txh=32 mode=0` events the oracle does not have.
135+
136+---
137+
138+## 3. The owning block, and the named expression
139+
140+**Block.** A 32x64 luma strip at pixel (64, 192) — the oracle's own rung says
141+`plane=0 row_off=0 col_off=0 txw=32 txh=64`. At `ss_x = ss_y = 0` its chroma plane
142+block is **also 32x64**, which `decode_block_rect` tiles into `nh = 2` units of 32x32
143+at pixel (64, 192) and **(64, 224)**.
144+
145+**Chroma mode: PALETTE.** `EC_DEBUG_PAL=1` shows the unit at (64, 224) consuming a
146+2048-entry (= 32x64, the whole plane block) palette prediction buffer handed over by
147+`set_palette_pred` at `decode.rs:20086`, with `stale=false`. `EC_PRED=1` on our side
148+confirms the `pred: Option<Vec<u16>>` override was taken (`pred_opt=true`) while the
149+neighbouring block at (96, 224) took the ordinary `PAETH_PRED` path
150+(`pred_opt=false`).
151+
152+**THE EXPRESSION — ours vs libaom.**
153+
154+| | libaom | ours (before) |
155+|---|---|---|
156+| where a palette chroma unit's prediction comes from | `av1_visit_palette` → `av1_predict_intra_block_palette` (`reconintra.c:1707`) hands `av1_predict_intra_block` a `ref` pointer at the unit's own origin, and `read_coeffs` walks the plane block with each unit's own `blk_row`/`blk_col` | `FrameCtx::palette_pred` (thread-local `Option<Vec<u16>>`), `decode.rs:20086`, handed **the whole block buffer** |
157+| the read | the unit's pixels are the unit's | `PlaneBuf::reconstruct` (`decode.rs:21336`) does `prediction[idx]` for `idx in 0..side*side` (write loop at `decode.rs:21406-21433`) — **the first `side*side` entries, i.e. always the buffer's top-left corner** |
158+
159+So on the 32-capped tiled chroma walk, unit (0, 1) at pixel (64, 224) reconstructed
160+**the block's row-192 palette values** (flat 209) where libaom writes **row 224's**
161+(216). Both arms were wrong: the `uw == uh` square-unit arm (`decode.rs:20086`) and
162+the rect-unit arm (`decode.rs:20140`) — both line numbers PRE-fix, quoted as they stood
163+at `ed7c99bc`.
164+
165+`palette_window` already existed for exactly this (`decode.rs:2968-2974`: "A unit reads
166+its prediction at ITS OWN stride, so handing it the whole-block buffer makes every
167+unit reconstruct the block's top-left corner … the luma split-transform paths already
168+window; the chroma ones did not"). Its doc comment records the 4x4 **lossless** chroma
169+instance as fixed. The 32-capped 4:4:4 instance was still un-windowed: the same
170+defect, a second walk.
171+
172+**Why 53 wrong columns and not 32 — the halo is the same bug, not a second one.**
173+Unit (0,1) writes 209 at col 95, row 224. The neighbouring 32x32 `PAETH_PRED` block at
174+(96, 224) has that pixel as its left edge, and `EC_DEBUG_EDGES=1` prints its edges as
175+
176+```text
177+above=[216 x18, 215, 220, 228, 185, 95, 49, 59, 63, 63, 64, 64, 65, 64, 63]
178+left =[209, 216, 216, …] corner=216
179+```
180+
181+`paeth(above, left[0], corner)` with `left[0]=209` returns `left` exactly where
182+`|above − corner| <= |above + left − 2·corner|`, i.e. for `above ∈ {216, 215}` — 19
183+columns — and returns `above` for `above ∈ {220, 228}` (the two columns where it is
184+wrong for the other reason) and from col 117 on. That reproduces our observed row
185+`[209 x19, 216, 216, 185, 95, …]` term for term, and the 53 = 32 + 19 + 2 span the
186+census measured. **One defect, one fix, both symptoms.** I did not chase the halo as a
187+second bug, and §4 shows the fix removes it.
188+
189+**The fix** (post-commit `decode.rs:20106-20113` and `:20164-20172`):
190+
191+```rust
192+let pbuf = if plane_idx == 1 { ub } else { vb };
193+set_palette_pred(
194+ palette_window(pbuf, chroma_w, cu_col * uw, cu_row * uh, uw, uh),
195+ fctx,
196+);
197+```
198+
199+---
200+
201+## 4. The geometry question, answered
202+
203+The brief asked what 352x242 has that 320x242 / 352x250 / 416x242 / 416x250 do not.
204+Measured, it is **not** a partial column at a block or tile boundary, not a plane
205+extent landing on a 4:4:4 granularity edge, and not a sub-8x8 leaf at the right edge.
206+It is:
207+
208+> **a block whose CHROMA is taller than the 32-pixel unit cap at `ss (0,0)`, so
209+> `decode_block_rect`'s chroma walk has `nh = 2` and every unit after the first is
210+> handed the wrong window.**
211+
212+`352 = 5.5 superblocks at 64` and `242` odd were the census's tells, and both are real
213+facts about the frame — but neither is the discriminator, which is why the census could
214+only say "geometry-sensitive". The 416x250 cell has an odd height too and is exact;
215+the 352x250 cell has the same width and is exact; 320x242 has the same odd height and
216+is exact. What separates 352x242 is that its partition happens to contain a 32x64
217+chroma plane block with a UV palette.
218+
219+Same recipe, same 10-bit depth, six cells, before → after:
220+
221+| cell | sha256 (16) | before | after |
222+|---|---|---|---|
223+| `s444_320x242_10b` | `e73548ca94270469` | 0 / 0 / 0 | **0 / 0 / 0** |
224+| `s444_320x250_10b` | `a6dfbd67f3ff662f` | 0 / 0 / 0 | **0 / 0 / 0** |
225+| **`s444_352x242_10b`** | `84df2f37cc7982f9` | **0 / 1166 / 1413** | **0 / 0 / 0** |
226+| `s444_352x250_10b` | `a46036e9926dc0db` | 0 / 0 / 0 | **0 / 0 / 0** |
227+| `s444_416x242_10b` | `48a48fa8596887d4` | 0 / 0 / 0 | **0 / 0 / 0** |
228+| `s444_416x250_10b` | `5973d87cc934cbb7` | 0 / 0 / 0 | **0 / 0 / 0** |
229+
230+(The five controls were already exact before the fix and are unchanged after it, so the
231+fix is not "the comparator got weaker" — the cell that moved is the only one that
232+could.)
233+
234+---
235+
236+## 5. The gate
237+
238+Committed, reachable, and it bites.
239+
240+```text
241+fixture crates/ec-av1/fixtures/444_lossy_palette_chroma_352x242_10b.obu
242+sha256 84df2f37cc7982f9a572443d85dfcc13bf366a64f3fb567391dcd5acd58a0ad2
243+size 24875 B
244+FNV-1a64 0x7fda_dbb4_3bbf_9af3
245+gate stream::tests::a_444_lossy_palette_chroma_unit_window_is_byte_exact_at_352x242_10bit
246+reach decode::chroma_palette_window_hits() (reset_chroma_palette_window_hits() first)
247+```
248+
249+Four non-vacuity arms, all required to pass:
250+
251+1. the pinned bytes — length 24 875 and FNV-1a64 `0x7fda_dbb4_3bbf_9af3` (a missing
252+ file is a **failure**, not a skip);
253+2. 16 shown frames at 352x242 with `f.u.len() == 352*242` — full-resolution chroma, so
254+ a decoder that kept the 4:2:0 extent cannot pass the byte compare;
255+3. `chroma_palette_window_hits()` read as a **delta** with a **measured floor of 4**
256+ (two tiled palette chroma blocks x U and V). It is incremented on the two fixed
257+ lines and nowhere else, so a gate that passed without them running would be
258+ gate-blind-to-feature, not byte-exact;
259+4. the oracle comparator has its own per-plane one-byte-flip liveness control in the
260+ crate (`every_oracle_comparator_reds_on_a_one_byte_wrong_oracle`), and my own
261+ three-plane flip run above.
262+
263+**Green:**
264+
265+```text
266+a_444_lossy_palette_chroma_unit_window_is_byte_exact_at_352x242_10bit:
267+ fixtures/444_lossy_palette_chroma_352x242_10b.obu 17 decode-order frame(s)
268+ (1 hidden) byte-exact vs aomdec, 4 windowed palette chroma unit(s)
269+test result: ok. 1 passed; 0 failed
270+```
271+
272+**Mutation proof — red, by name, then green.** The two `palette_window` calls were
273+replaced by the whole-buffer hand-off, the `hit!` left in place so the reachability arm
274+still fires (the gate must bite on the BYTES, not on the counter):
275+
276+```text
277+thread 'stream::tests::a_444_lossy_palette_chroma_unit_window_is_byte_exact_at_352x242_10bit'
278+panicked at crates/ec-av1/src/stream.rs:10848:17:
279+a_444_lossy_palette_chroma_unit_window_is_byte_exact_at_352x242_10bit:
280+ decode-order frame 0 of 17 (16 shown, 1 hidden) differs from the oracle at
281+ byte 328192 (ours 209 vs 216), 104 bytes differ
282+test result: FAILED. 0 passed; 1 failed
283+```
284+
285+Byte 328192 = frame 0, past the 170 368-byte Y plane, `157824 / 2 = 78 912` samples
286+in = `row 224, col 64` — **the census's own first bad sample**, from a gate written
287+after the fix. Restored: green (the message above).
288+
289+---
290+
291+## 6. Corpus-wide, every committed fixture
292+
293+All 106 `.obu` files under `crates/ec-av1/fixtures/`, both binaries, same instrument,
294+same comparator, decode-order basis. Base = `ed7c99bc` build; tip = this lane.
295+
296+| | BYTE-EXACT | DIVERGES | REFUSES (by name) | oracle refused |
297+|---|---|---|---|---|
298+| base `ed7c99bc` | 95 | **1** | 9 | 1 |
299+| tip `eb73ef89` | **96** | **0** | 9 | 1 |
300+
301+The single status change is `444_lossy_palette_chroma_352x242_10b`: `DIVERGES
302+(0/1166/1413)` → `BYTE-EXACT`. No fixture changed status in the other direction and no
303+sample count moved on any exact cell.
304+
305+The 9 refusals are the 4:2:2 fixtures, all with the sequence-header refusal string
306+(`unsupported: AV1 decode_stream (a chroma format of 4:2:2 (su…`) — untouched by this
307+lane; the 4:2:2 header guard was not read for edit and is not in either diff. The one
308+oracle refusal is `440_request_is_422.obu`, a request-only file aomdec itself rejects.
309+
310+---
311+
312+## 7. Regression
313+
314+```text
315+cargo test -p ec-av1 --lib -- 444 420 lossless warp intra \
316+ --skip bitrate_target_lands_within_5_percent_over_48_frames
317+test result: ok. 178 passed; 0 failed; 2 ignored; 0 measured; 623 filtered out; 302.41s
318+```
319+
320+The two ignored are pre-existing `#[ignore]`d gates, not new ones — this lane adds no
321+`#[ignore]`.
322+
323+---
324+
325+## 8. What I did NOT do, and what a reviewer should attack
326+
327+* **Not a superblock/tile-boundary, odd-dimension or sub-8 defect.** I checked the
328+ three hypotheses the brief named and refuted all three on the controls: same-depth
329+ same-width (352x250), same-depth same-height (320x242, 416x242) and wider 4:4:4 at
330+ the same odd height are all exact. The discriminator is chroma unit count.
331+* **No filter stage involved**, and that is measured, not assumed (§2).
332+* **Not the 4:2:0 group-tail chroma SKIP arm** — different format, different write
333+ path, and that arm is left exactly as it was.
334+* **The 4:2:2 sequence-header guard was not touched.** Both diffs are
335+ `decode.rs` (the two `palette_window` arms + the counter) and `stream.rs` (the gate),
336+ plus one new binary fixture.
337+* **The mutation proof is the strongest single check here and it is honest**: the
338+ windowing was removed while the counter stayed, so the byte compare — not the
339+ reachability assert — is what reddened.
340+* **What a reviewer should attack first.** The counter's floor of 4 is measured on this
341+ one stream. It is a *reachability* floor, not a census: a second palette-chroma
342+ fixture would move it, and the gate would then need its floor re-measured. The
343+ byte-exactness arm is the one that carries the exactness claim and it does not
344+ depend on the number.
345+* **Not swept beyond the one walk.** I audited every `set_palette_pred` call site in
346+ `decode.rs` (~100). All the others either pass a whole-block buffer to exactly ONE
347+ push (correct by construction) or already window with `palette_window`. The two I
348+ changed were the only whole-buffer hand-offs inside a tiled unit loop. I did not
349+ build a 4:4:4 12-bit or a `nw > 1` variant to prove the `nw > 1` arm; on this
350+ stream `nw == 1` always and the horizontal windowing is unmeasured.
351+
352+---
353+
354+## 9. Handover
355+
356+* Fixed lines: `crates/ec-av1/src/decode.rs:20106-20113` and `:20164-20172`
357+ (`palette_window` in the two arms of `decode_block_rect`'s 32-capped tiled chroma
358+ walk).
359+* Counter: `decode.rs:2721-2743` (`CHROMA_PALETTE_WINDOW_HITS`,
360+ `chroma_palette_window_hits` at `:2734`, `reset_chroma_palette_window_hits` at
361+ `:2741`).
362+* Gate: `crates/ec-av1/src/stream.rs:50715-50823`.
363+* Fixture: `crates/ec-av1/fixtures/444_lossy_palette_chroma_352x242_10b.obu`.
364+* Driver + instruments (not committed; probe evidence):
365+ `~/.cache/lanes/av1444d10/{run.py,corpus.py,cmp422.py,mksweep.sh,sweep/,work/,stage/}`,
366+ results `repro_before.json`, `after.json`, `corpus_base.json`, `corpus_tip.json`,
367+ `flipctl.txt`.
368+
369+The census was right that this cell diverged and right that it was outside the 4:2:2
370+question. It was not, however, "geometry-sensitive" in the way its own framing
371+implies: **352x242's distinction is not frame width or height at all — it is the
372+number of CHROMA TRANSFORM UNITS in one block.**
373+