forge
Explore
Log in

Don't you dare go Hollow

Merge lane-av1chromadc: the skipped-block chroma override is windowed per unit (79969 -> 0)

Browse files at this commit

8c19a274fd2a06ebdfc980ac2725f574ba7edf92Ahmet Kaan GümüşParent: 06be46669d5cc5
decode_block's SKIP arm handed the whole chroma_side x chroma_height override buffer to EVERY unit,
and PlaneBuf::reconstruct uses the buffer it is given as that unit's own chroma_tx x chroma_tx_h
prediction - so the right and bottom units of a 2x2 chroma plane block predicted from the top-left
one. Invisible at 4:2:0 (a 64x64 block's chroma plane block is a SINGLE 32x32 unit, so the whole
buffer is that unit's window - which is why every 4:2:0 gate stayed green). Measured on the pinned
r512.obu: frame 1's skipped 64x64 intra-BC block at mi=(112,80) reconstructed cu=(1,0) as a flat 241
where the oracle has 202, byte-identical to cu=(0,0). EC_PRED showed identical sums and identical
row0/col0 for the two units and EC_DEBUG_EDGES printed nothing (the prediction came from the
override, not the edges). Fix: one windowing closure used for both planes, whole buffer when single
unit so every 4:2:0 and sub-64 4:4:4 path is byte-for-byte unchanged. Result: 79969 wrong samples ->
0 (2359296/2359296 byte-exact), red-before run on the unpatched tree.
crates/ec-av1/src/decode.rsmodified+57 -2
@@ -2710,6 +2710,15 @@ pub fn skip_split_tx_hits() -> usize {
27102710 // witness this path, so a gate that wants it needs the counter.
27112711 thread_local! {
27122712 static SKIP_SPLIT_TX_OVERRIDE_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
2713+ /// lane-av1chromadc: chroma units of a skipped block whose intra-BC /
2714+ /// UV-palette override had to be WINDOWED to the unit's own extent --
2715+ /// i.e. `cn_cols * cn_rows > 1`, which at 4:2:0 never happens (the chroma
2716+ /// plane block is one 32x32 unit) and at 4:4:4 is every block of 64 and
2717+ /// above. Counts UNITS, not blocks. EXCLUSIVE to this walk: the other two
2718+ /// override sites (the luma slot and `decode_intrabc_owned_rect`) have
2719+ /// their own windows.
2720+ static SKIP_CHROMA_OVERRIDE_WINDOW_HITS: std::cell::Cell<usize> =
2721+ const { std::cell::Cell::new(0) };
27132722 }
27142723
27152724 /// Current value of [`SKIP_SPLIT_TX_OVERRIDE_HITS`] (blocks).
@@ -2717,6 +2726,18 @@ pub fn skip_split_tx_override_hits() -> usize {
27172726 SKIP_SPLIT_TX_OVERRIDE_HITS.with(|c| c.get())
27182727 }
27192728
2729+/// lane-av1chromadc: [`SKIP_CHROMA_OVERRIDE_WINDOW_HITS`].
2730+#[allow(dead_code)] // read only from the `#[cfg(test)]` gates
2731+pub fn skip_chroma_override_window_hits() -> usize {
2732+ SKIP_CHROMA_OVERRIDE_WINDOW_HITS.with(|c| c.get())
2733+}
2734+
2735+/// Zeroes [`SKIP_CHROMA_OVERRIDE_WINDOW_HITS`] before a gate's own decode.
2736+#[allow(dead_code)] // read only from the `#[cfg(test)]` gates
2737+pub fn reset_skip_chroma_override_window_hits() {
2738+ SKIP_CHROMA_OVERRIDE_WINDOW_HITS.with(|c| c.set(0));
2739+}
2740+
27202741 /// Zeroes [`SKIP_SPLIT_TX_OVERRIDE_HITS`] before a gate's own decode attempt.
27212742 pub fn reset_skip_split_tx_override_hits() {
27222743 SKIP_SPLIT_TX_OVERRIDE_HITS.with(|c| c.set(0));
@@ -21671,8 +21692,42 @@ fn decode_block(
2167121692 )
2167221693 };
2167321694 let (cu_x, cu_y) = (cpx + cu_col * chroma_tx, cpy + cu_row * chroma_tx_h);
21695+ // lane-av1chromadc: the chroma override is a whole
21696+ // `chroma_side x chroma_height` buffer and
21697+ // `PlaneBuf::reconstruct` uses the buffer it takes as the
21698+ // UNIT's own `chroma_tx x chroma_tx_h` prediction, so a
21699+ // multi-unit plane block must hand each unit its own window of
21700+ // it. Handing the whole buffer (the pre-fix shape) made every
21701+ // unit predict from the top-left one: at 4:2:0 the chroma plane
21702+ // block is a single 32x32 unit, so the whole buffer IS that
21703+ // unit's window and the bug is invisible -- which is why every
21704+ // 4:2:0 gate stayed green -- and at 4:4:4 a 64x64 block's 64x64
21705+ // plane block is a 2x2 grid whose right and bottom columns were
21706+ // a copy of its top-left unit.
21707+ // MEASURED on `fixtures/r512.obu` (4:4:4 8-bit 512x512, three
21708+ // frames): frame 0's skipped 64x64 intra-BC block at
21709+ // `mi=(112,80)` `px=(320,448)` reconstructed its `cu=(1,0)`
21710+ // unit at `px=(352,448)` as a flat 241 where the oracle has
21711+ // 202 -- byte-identical to its `cu=(0,0)` prediction, sum
21712+ // 882176 and all -- and the coded 64x64 to its right then read
21713+ // 202/175 against the oracle's 165/166. Gate:
21714+ // `a_444_skipped_64x64_square_block_windows_its_chroma_override_per_unit`.
21715+ let chroma_window = |buf: &[u16]| -> Vec<u16> {
21716+ if cn_cols == 1 && cn_rows == 1 {
21717+ return buf.to_vec();
21718+ }
21719+ let mut window = Vec::with_capacity(chroma_tx * chroma_tx_h);
21720+ for row in 0..chroma_tx_h {
21721+ let at = (cu_row * chroma_tx_h + row) * chroma_side + cu_col * chroma_tx;
21722+ window.extend_from_slice(&buf[at..at + chroma_tx]);
21723+ }
21724+ window
21725+ };
2167421726 if let Some((ub, _)) = &palette_uv_bufs {
21675- set_palette_pred(ub.clone(), fctx);
21727+ if cn_cols * cn_rows > 1 {
21728+ hit!(SKIP_CHROMA_OVERRIDE_WINDOW_HITS);
21729+ }
21730+ set_palette_pred(chroma_window(ub), fctx);
2167621731 }
2167721732 push_intra_unit(
2167821733 1,
@@ -21690,7 +21745,7 @@ fn decode_block(
2169021745 fctx,
2169121746 );
2169221747 if let Some((_, vb)) = &palette_uv_bufs {
21693- set_palette_pred(vb.clone(), fctx);
21748+ set_palette_pred(chroma_window(vb), fctx);
2169421749 }
2169521750 push_intra_unit(
2169621751 2,
crates/ec-av1/src/stream.rsmodified+142 -19
@@ -157,6 +157,20 @@ pub fn reset_ibc_owned_rect_chroma_footprint_444_hits() {
157157 crate::decode::reset_ibc_owned_rect_chroma_footprint_444_hits()
158158 }
159159
160+/// lane-av1chromadc: chroma units of a skipped block whose intra-BC / UV
161+/// palette override had to be windowed to the unit's own extent -- `cn_cols *
162+/// cn_rows > 1`, which at 4:2:0 never happens and at 4:4:4 is every block of
163+/// 64 and above. Counts UNITS. EXCLUSIVE to `decode_block`'s skipped square
164+/// block chroma walk.
165+pub fn skip_chroma_override_window_hits() -> usize {
166+ crate::decode::skip_chroma_override_window_hits()
167+}
168+
169+/// Gate-side reset for the lane-av1chromadc counter above.
170+pub fn reset_skip_chroma_override_window_hits() {
171+ crate::decode::reset_skip_chroma_override_window_hits()
172+}
173+
160174 /// `(y, uv)` palette blocks RECONSTRUCTED inside an inter frame (lane-t900
161175 /// r22) -- the counter a screen-content witness gate reads to prove it
162176 /// exercises the inter-frame palette path, not the key frame's.
@@ -49282,19 +49296,21 @@ pub(crate) mod tests {
4928249296 /// was deleted: `rect_inter_chroma_set` still refuses (32, 64) and the
4928349297 /// string is still in the source, it is just not on this path any more.
4928449298 ///
49285- /// The assertion is a per-(frame, plane) EXACT PREFIX against the
49286- /// instrumented aomdec, the same shape as the sibling
49287- /// `a_444_intrabc_rect_chroma_plane_block_is_the_block_footprint`. The
49288- /// floors are MEASURED, and each one only grows:
49289- ///
49290- /// * luma is byte-exact on ALL THREE frames (786432/786432 samples).
49291- /// Before the fix frame 0 luma was 166229 samples wrong from 65728 --
49292- /// the halving's chroma misread desynced the tile.
49293- /// * frame 2 is byte-exact on all three planes. Before the fix it was
49294- /// 9216 U + 8192 V wrong.
49295- /// * frames 0 and 1 carry an OPEN chroma fork at a DIFFERENT site (see
49296- /// lanes/av1chromarect.report.md); the floors below are the exact
49297- /// prefixes, not a claim that the tail is right.
49299+ /// The floors were RAISED to full byte-exactness on all three planes of
49300+ /// all three frames by lane-av1chromadc, which closed the "open chroma
49301+ /// fork" this gate used to carry: a skipped 64x64 square block at 4:4:4
49302+ /// has a 64x64 chroma plane block, libaom walks it as a 2x2 grid of
49303+ /// `TX_32X32` units, and the intra-BC chroma override was handed to every
49304+ /// unit whole instead of windowed per unit (see
49305+ /// `a_444_skipped_64x64_square_block_windows_its_chroma_override_per_unit`
49306+ /// and lanes/av1chromadc.report.md). The history of these floors:
49307+ ///
49308+ /// * lane-av1chromarect, after the ss-derived extent and the multi-unit
49309+ /// walk: `[[262144, 229728, 229728], [262144, 65704, 65704],
49310+ /// [262144, 262144, 262144]]` -- luma exact on all three frames, frame 2
49311+ /// exact on all three planes, 79969 chroma samples still wrong.
49312+ /// * lane-av1chromadc: `[[262144; 3]; 3]` -- every plane of every frame
49313+ /// byte-exact against aomdec. Floors only ever grow.
4929849314 #[test]
4929949315 fn a_444_intrabc_owned_rect_strip_sizes_its_chroma_plane_block_and_decodes() {
4930049316 const NAME: &str =
@@ -49303,12 +49319,9 @@ pub(crate) mod tests {
4930349319 const LEN: usize = 6948;
4930449320 /// 512x512 8-bit 4:4:4, one plane.
4930549321 const PLANE: usize = 512 * 512;
49306- /// First differing sample per (frame, plane), decode order.
49307- const EXACT_PREFIX: [[usize; 3]; 3] = [
49308- [PLANE, 229728, 229728],
49309- [PLANE, 65704, 65704],
49310- [PLANE, PLANE, PLANE],
49311- ];
49322+ /// Exact prefix per (frame, plane), decode order. FULL: every plane of
49323+ /// every frame is byte-exact against the oracle.
49324+ const EXACT_PREFIX: [[usize; 3]; 3] = [[PLANE; 3]; 3];
4931249325 let path =
4931349326 std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR")).join(format!("fixtures/{FILE}"));
4931449327 let stream = std::fs::read(&path)
@@ -49398,4 +49411,114 @@ pub(crate) mod tests {
4939849411 }
4939949412 let _ = std::fs::remove_dir_all(&dir);
4940049413 }
49414+
49415+ /// lane-av1chromadc: a SKIPPED 64x64 square block at 4:4:4 has a 64x64
49416+ /// chroma plane block, which libaom walks as a 2x2 grid of `TX_32X32` units
49417+ /// (`get_vartx_max_txsize`: `av1_get_adjusted_tx_size(TX_64X64) =
49418+ /// TX_32X32`). The intra-BC / UV-palette chroma override
49419+ /// ([`decode_block`]'s `intrabc_bufs` / `palette_uv_bufs`, the
49420+ /// `PALETTE_PRED` slot) is a whole-`chroma_side x chroma_height` buffer and
49421+ /// must be WINDOWED per unit: `PlaneBuf::reconstruct` uses the buffer it
49422+ /// takes as the unit's own `side x side` prediction. At 4:2:0 the chroma
49423+ /// plane block is one 32x32 unit, so the whole buffer IS that unit's
49424+ /// window and the bug is invisible -- which is why it survived every 4:2:0
49425+ /// gate. At 4:4:4 every unit was handed the buffer's FIRST 32x32, so the
49426+ /// block's right and bottom chroma columns were a copy of its top-left
49427+ /// unit.
49428+ ///
49429+ /// The witness: `fixtures/r512.obu`, 4:4:4 8-bit 512x512, three frames. The
49430+ /// seed is frame 0, `mi=(112,80)`, `px=(320,448)`, `side=64`, `skip=1`,
49431+ /// `mode=0`, `uv_mode=0` -- a skipped intra-BC block at the frame's bottom
49432+ /// edge. Its chroma unit `cu=(1,0)` at `px=(352,448)` reconstructs a flat
49433+ /// 241 (U) / 110 (V) where the oracle has 202 / 222, because it read the
49434+ /// same override window as `cu=(0,0)`.
49435+ ///
49436+ /// This gate asserts FULL frame exactness on all three planes of all three
49437+ /// frames. It is the red-before: on the unpatched tree it fails at
49438+ /// `(352,448)` of frame 0, which is the seed's second chroma unit.
49439+ #[test]
49440+ fn a_444_skipped_64x64_square_block_windows_its_chroma_override_per_unit() {
49441+ const NAME: &str = "a_444_skipped_64x64_square_block_windows_its_chroma_override_per_unit";
49442+ const FILE: &str = "r512.obu";
49443+ const LEN: usize = 6948;
49444+ const PLANE: usize = 512 * 512;
49445+ let path =
49446+ std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR")).join(format!("fixtures/{FILE}"));
49447+ let stream = std::fs::read(&path)
49448+ .unwrap_or_else(|e| panic!("{NAME}: pinned fixture {FILE} missing: {e}"));
49449+ assert_eq!(stream.len(), LEN, "{NAME}: {FILE} length moved");
49450+ assert_444_header(&stream, NAME, 8);
49451+
49452+ let _guard = lock_gate_counters();
49453+ reset_skip_chroma_override_window_hits();
49454+ let dir = std::env::temp_dir().join(format!("ec-av1-{NAME}-{}", std::process::id()));
49455+ let _ = std::fs::remove_dir_all(&dir);
49456+ std::fs::create_dir_all(&dir).expect("scratch dir");
49457+ let obu = dir.join("in.obu");
49458+ std::fs::write(&obu, &stream).expect("writing the stream");
49459+ let aom_prefix = dir.join("aom");
49460+ let out = Command::new(aomdec_path())
49461+ .args(["--codec=av1", "-o"])
49462+ .arg(dir.join("out.y4m"))
49463+ .arg(&obu)
49464+ .env("EC_AV1_FINAL_DUMP", &aom_prefix)
49465+ .stdin(Stdio::null())
49466+ .stdout(Stdio::piped())
49467+ .stderr(Stdio::piped())
49468+ .output()
49469+ .expect("aomdec failed to run");
49470+ assert!(
49471+ out.status.success(),
49472+ "{NAME}: the oracle aomdec refused the stream: {}",
49473+ String::from_utf8_lossy(&out.stderr)
49474+ );
49475+ let ours_prefix = dir.join("ours");
49476+ set_final_dump_prefix(Some(ours_prefix.display().to_string()));
49477+ if let Err(e) = decode_stream(&stream) {
49478+ panic!("{NAME}: this decoder refused the witness: {e}");
49479+ }
49480+ set_final_dump_prefix(None);
49481+ // Non-vacuity: the windowed arm must have run, or the exactness below
49482+ // is measuring a witness that never reached the 2x2 chroma walk.
49483+ let windows = skip_chroma_override_window_hits();
49484+ assert!(
49485+ windows >= 8,
49486+ "{NAME}: {windows} windowed chroma override unit(s) on this witness, expected at \
49487+ least 8 (two skipped 64x64 intra-BC blocks x 2x2 units x 2 planes) -- the witness \
49488+ stopped exercising the arm, so the exactness below is vacuous"
49489+ );
49490+ for f in 0..3 {
49491+ let aom_dump = std::fs::read(format!("{}.f{f}", aom_prefix.display()))
49492+ .unwrap_or_else(|e| panic!("{NAME}: oracle dump f{f} missing: {e}"));
49493+ let our_dump = std::fs::read(format!("{}.f{f}", ours_prefix.display()))
49494+ .unwrap_or_else(|e| panic!("{NAME}: our dump f{f} missing: {e}"));
49495+ assert_eq!(
49496+ our_dump.len(),
49497+ 3 * PLANE,
49498+ "{NAME}: frame {f} is not 8-bit 4:4:4 512x512"
49499+ );
49500+ for (plane, name) in [(0usize, "Y"), (1, "U"), (2, "V")] {
49501+ let at = plane * PLANE;
49502+ if our_dump[at..at + PLANE] == aom_dump[at..at + PLANE] {
49503+ continue;
49504+ }
49505+ let first = (0..PLANE)
49506+ .find(|&s| our_dump[at + s] != aom_dump[at + s])
49507+ .unwrap_or(PLANE);
49508+ let wrong = (0..PLANE)
49509+ .filter(|&s| our_dump[at + s] != aom_dump[at + s])
49510+ .count();
49511+ panic!(
49512+ "{NAME}: decode-order frame {f} plane {name} is byte-exact nowhere -- first \
49513+ divergence at sample {first} of {PLANE} (x={}, y={}), {wrong} samples \
49514+ wrong. The seed is frame 0, mi=(112,80) px=(320,448) side=64 skip=1, whose \
49515+ chroma unit cu=(1,0) at px=(352,448) must be the SECOND 32x32 window of \
49516+ the block's chroma override and not a copy of cu=(0,0)'s.",
49517+ first % 512,
49518+ first / 512
49519+ );
49520+ }
49521+ }
49522+ let _ = std::fs::remove_dir_all(&dir);
49523+ }
4940149524 }
lanes/av1chromadc.report.mdadded+205 -0
@@ -0,0 +1,205 @@
1+# lane-av1chromadc — the 4:4:4 2x2 chroma override window (79969 → 0)
2+
3+Worktree `~/.cache/wt/av1chromadc`, branch `lane-av1chromadc`, base `57834ee2`
4+("Merge lane-av1chromarect-r2"). All edits absolute-pathed inside this worktree;
5+`git -C ~/Documents/Code/Rust/edith_codecs status --porcelain` printed nothing
6+after every edit batch.
7+
8+Fixes the residual `lanes/av1chromarect-r2.report.md` narrowed, in
9+`decode_block`'s SQUARE path, and closes the witness to **full byte-exactness on
10+every plane of every frame**. `decode_intrabc_owned_rect` (the strip arm) is not
11+touched.
12+
13+## 1. Red-before, on the UNPATCHED tree
14+
15+Gate `a_444_skipped_64x64_square_block_windows_its_chroma_override_per_unit`
16+(`crates/ec-av1/src/stream.rs`), added first, asserting full frame exactness on
17+`fixtures/r512.obu` against the instrumented aomdec:
18+
19+ $ EC_AV1_REQUIRE_AOMDEC=1 cargo test -p ec-av1 --lib a_444_skipped_64x64 -- --nocapture
20+ thread 'stream::tests::a_444_skipped_64x64_square_block_windows_its_chroma_override_per_unit' panicked:
21+ a_444_skipped_64x64_square_block_windows_its_chroma_override_per_unit: decode-order frame 0
22+ plane U is byte-exact nowhere -- first divergence at sample 229728 of 262144 (x=352, y=448),
23+ 7488 samples wrong. The seed is frame 0, mi=(112,80) px=(320,448) side=64 skip=1, whose
24+ chroma unit cu=(1,0) at px=(352,448) must be the SECOND 32x32 window of the block's chroma
25+ override and not a copy of cu=(0,0)'s.
26+ test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 768 filtered out
27+
28+That is the unpatched decode diverging at the seed's exact sample, not a mutation
29+red. The 79969 total from r2 is the same measurement: 7488 + 8128 on frame 0,
30+22571 + 41782 on frame 1, 0 on frame 2.
31+
32+## 2. The defect
33+
34+A skipped 64x64 square block at 4:4:4 has a **64x64 chroma plane block**, which
35+libaom walks as a 2x2 grid of `TX_32X32` units (`get_vartx_max_txsize` →
36+`av1_get_adjusted_tx_size(TX_64X64) = TX_32X32`, decodeframe.c:994-1004).
37+
38+Its chroma prediction is not edge-derived: it is the intra-BC / UV-palette
39+**override**, a whole-`chroma_side x chroma_height` buffer carried on the
40+`PALETTE_PRED` slot (`decode_block`'s `intrabc_bufs` / `palette_uv_bufs` →
41+`set_palette_pred` → `PlaneBuf::reconstruct`'s `pred`). `reconstruct` uses the
42+buffer it takes as the **unit's own** `chroma_tx x chroma_tx_h` prediction --
43+`let prediction = if let Some(buf) = pred { buf } else { … }` -- so a multi-unit
44+plane block must hand each unit its own WINDOW of that buffer.
45+
46+The pre-fix call was `set_palette_pred(ub.clone(), fctx)`: the whole buffer, for
47+every unit. At 4:2:0 the chroma plane block of a 64x64 block is a single 32x32
48+unit, so the whole buffer IS that unit's window and the bug is **invisible** --
49+which is why every 4:2:0 gate stayed green. At 4:4:4 every unit took the buffer's
50+first 32x32.
51+
52+The code already said so, at the site, for LUMA: *"its per-TU windowing is the
53+non-skip loop's own `palette_y_buf` slice, untested for skip and unreachable in
54+these streams"*, and `lane-svt1` had armed the whole-block luma buffer on the
55+skip arm for a related reason. The chroma half never got the same treatment, and
56+`r512.obu` is the stream that makes it reachable.
57+
58+**Measured proof, before the fix** (`EC_PRED`, the per-unit prediction trace;
59+identical sums and identical `row0`/`col0` are the signature of a copied window):
60+
61+ OUR_PRED x=320 y=448 plane=1 side=32 mode=0 sum=882176 row0=[241,241,241,241,241,241,241,241] col0=[241,202,241,202,241,202,241,202]
62+ OUR_PRED x=352 y=448 plane=1 side=32 mode=0 sum=882176 row0=[241,241,241,241,241,241,241,241] col0=[241,202,241,202,241,202,241,202]
63+ OUR_PRED x=320 y=448 plane=2 side=32 mode=0 sum=751936 row0=[110,110,110,110,110,110,110,110] col0=[110,222,110,222,110,222,110,222]
64+ OUR_PRED x=352 y=448 plane=2 side=32 mode=0 sum=751936 row0=[110,110,110,110,110,110,110,110] col0=[110,222,110,222,110,222,110,222]
65+
66+and `EC_DEBUG_EDGES` printed **nothing** for x=320/352 at y=448, i.e. `edges()`
67+was never called -- the prediction came from the override, not from the edges.
68+(`EDGES_SQ` DOES print for the coded sibling at x=448, whose units therefore went
69+through the per-unit DC path and were already right.)
70+
71+## 3. The fix
72+
73+`decode_block`'s skip-arm chroma unit loop, both planes: one `chroma_window`
74+closure that returns the buffer whole when the plane block is a single unit and
75+otherwise slices rows `cu_row*chroma_tx_h .. +chroma_tx_h` × cols
76+`cu_col*chroma_tx .. +chroma_tx` at the buffer's own `chroma_side` stride.
77+
78+Nothing else changes: the single-unit case (every 4:2:0 shape, every 4:4:4 shape
79+below 64) takes the identical path it took before, and the strip arm is
80+untouched.
81+
82+## 4. Result
83+
84+ $ EC_AV1_REQUIRE_AOMDEC=1 cargo test -p ec-av1 --lib -- a_444_intrabc_owned_rect a_444_skipped_64x64
85+ test stream::tests::a_444_skipped_64x64_square_block_windows_its_chroma_override_per_unit ... ok
86+ test stream::tests::a_444_intrabc_owned_rect_strip_sizes_its_chroma_plane_block_and_decodes ... ok
87+ test result: ok. 2 passed; 0 failed; 0 ignored; 0 measured; 767 filtered out
88+
89+Per (frame, plane), wrong samples, before → after:
90+
91+| frame | Y | U | V |
92+| --- | --- | --- | --- |
93+| 0 | 0 → 0 | 7488 → **0** | 8128 → **0** |
94+| 1 | 0 → 0 | 22571 → **0** | 41782 → **0** |
95+| 2 | 0 → 0 | 0 → 0 | 0 → 0 |
96+
97+**79969 → 0.** Every plane of every frame is byte-exact against the aomdec
98+oracle, 2359296/2359296 samples. The floors in
99+`a_444_intrabc_owned_rect_strip_sizes_its_chroma_plane_block_and_decodes` were
100+RAISED from `[[262144, 229728, 229728], [262144, 65704, 65704], [262144, 262144,
101+262144]]` to `[[262144; 3]; 3]`; both floors' history is recorded in the test's
102+doc comment. No floor was lowered.
103+
104+## 5. Class sweep — all four unit positions, and which were already right
105+
106+Every multi-unit chroma-override walk on the witness, with the window head the fix
107+now hands each unit (temporary `EC_ZZSRC` probe, removed before the commit;
108+`win_head` = the unit window's first eight samples):
109+
110+| frame | block | skip | source | cu(0,0) | cu(1,0) | cu(0,1) | cu(1,1) | pre-fix state |
111+| --- | --- | --- | --- | --- | --- | --- | --- | --- |
112+| 0 | px=(320,448) side=64 | true | intrabc | 241 | 202 | 241 | 202 | **(1,0) and (1,1) WRONG** (both got 241) |
113+| 0 | px=(384,448) side=64 | true | intrabc | 202 | 203 | 202 | 203 | all four right -- the buffer is flat, so the copy was indistinguishable |
114+| 1 | px=(128,128) side=64 | true | intrabc | 54 | 54 | 54 | 54 | (1,0)/(1,1) wrong further into the window -- see §6 |
115+| 1 | px=(320,448) side=64 | true | intrabc | 240 | 202 | 240 | 202 | **(1,0) and (1,1) WRONG** |
116+| 1 | px=(448,384) side=64 | true | intrabc | 166 | 166 | 166 | 166 | all four right -- flat buffer |
117+
118+The rule the sweep establishes: the bug is invisible when the override buffer is
119+constant across the plane block (rows 2 and 5 above, and both `cu_col == 0`
120+positions always), and wrong at exactly the `(1,0)` and `(1,1)` positions
121+whenever the buffer varies. `(0,0)` and `(0,1)` were never wrong -- they read
122+offset 0, which is their own window. That is why the dirty map in r2 §1 starts at
123+x=352 = 320 + 32 and not at x=320.
124+
125+**Both edge families:** the intra-BC and UV-palette sources share one line
126+(`palette_uv_bufs` is `intrabc_bufs`' chroma half when intrabc is present, else
127+the palette map), so the fix is structurally shared. MEASURED, though: every
128+multi-unit walk on this witness is `src=intrabc`; the UV-palette source never
129+reaches a multi-unit chroma walk here, so its arm of the sweep is argued from
130+the shared code path, not witnessed. That is the one cell of the class this lane
131+does not have a measurement for.
132+
133+Non-vacuity: new counter `SKIP_CHROMA_OVERRIDE_WINDOW_HITS` counts chroma units
134+whose override had to be windowed (`cn_cols * cn_rows > 1`), exclusive to this
135+walk. The gate asserts `>= 8` (two skipped 64x64 intra-BC blocks × 2×2 units × 2
136+planes) before it compares a single sample, so the exactness cannot be vacuous.
137+
138+## 6. The f1 hypothesis: CONFIRMED
139+
140+r2 §5 predicted f1's dirty column `x=128..192` (first dirty cell `(168,128)`,
141+56 of 64 samples wrong) was the skipped 64x64 at `px=(128,128)`. It is. That is
142+the only multi-unit override walk in that column, it is `skip=1 side=64 src=intrabc`,
143+and frame 1 goes from 22571 U + 41782 V wrong to **0** with this fix and no other
144+change. Its four windows' first eight samples are all `54`, so the difference is
145+further into the unit window than the head I printed — the block is flat near its
146+top-left and not flat at `(168,128)`, which is exactly the invisible-until-it-isn't
147+shape the sweep above describes.
148+
149+## 7. Gates
150+
151+`cargo check -p ec-av1 --all-targets` clean (0 errors, 0 warnings) before every
152+run, on a private `CARGO_TARGET_DIR`; a green gate next to a build error would
153+have been a stale binary.
154+
155+ $ EC_AV1_REQUIRE_AOMDEC=1 EC_AV1_REQUIRE_AOMENC=1 \
156+ cargo test -p ec-av1 --lib -- a_444 lossless_444 intrabc_rect 444_lossless -- --nocapture
157+ test result: ok. 34 passed; 0 failed; 0 ignored; 0 measured; 735 filtered out
158+
159+34 = the 33 of lane-av1chromarect's r5 quote plus this lane's new gate. The set
160+carries the 4:4:4-lossless family (`a_lossless_444_*`,
161+`a_444_lossless_sb64_intrabc_rect_chroma_walks_4x4_units`,
162+`a_real_aomenc_lossless_444_key_frame_decodes_sample_exact`), the intrabc_rect
163+family, and the 4:2:0 identity arm
164+(`a_444_intrabc_rect_chroma_plane_block_is_the_block_footprint`, whose
165+`420_intrabc_rect4_witness.obu` twin goes through `decode_all_frames_vs_oracle`).
166+
167+One filtered run per tree, same filter string, same env, private
168+`CARGO_TARGET_DIR` each:
169+
170+ $ EC_AV1_REQUIRE_AOMDEC=1 EC_AV1_REQUIRE_AOMENC=1 cargo test -p ec-av1 --lib \
171+ -- rect intrabc ibc chroma 444 420 subsampl -- --nocapture
172+
173+| tree | result |
174+| --- | --- |
175+| base `57834ee2` (`~/.cache/wt/av1chromadc-base`, detached) | `ok. 140 passed; 0 failed; 5 ignored; 0 measured; 623 filtered out; finished in 284.66s` |
176+| tip `lane-av1chromadc` | `ok. 141 passed; 0 failed; 5 ignored; 0 measured; 623 filtered out; finished in 288.94s` |
177+
178+The set difference of the two passing-test lists is exactly this lane's new
179+gate and nothing else:
180+
181+```
182+> test stream::tests::a_444_skipped_64x64_square_block_windows_its_chroma_override_per_unit
183+```
184+
185+The same 5 tests are `#[ignore]`d in both trees.
186+
187+### Mutation proofs, each reverted
188+
189+| # | mutation | result |
190+| --- | --- | --- |
191+| M1 | `chroma_window` returns the whole buffer unconditionally (the pre-fix shape) | **RED** — `frame 0 plane U … first divergence at sample 229728 (x=352, y=448), 7488 samples wrong` |
192+| M2 | the window's row stride `chroma_side` → `chroma_tx` | **RED** — `frame 0 plane U … first divergence at sample 229824 (x=448, y=448), 7488 samples wrong` |
193+| M3 | `cu_row`/`cu_col` transposed in the window offset | **RED** — `frame 0 plane U … first divergence at sample 229728 (x=352, y=448), 7488 samples wrong` |
194+
195+## 8. Not done
196+
197+1. The UV-palette arm of the class sweep has no witness here (§5). It shares the
198+ fixed line, but a 4:4:4 `--enable-palette=1` stream with a skipped block of 64
199+ and above would be the measurement, and I did not encode one.
200+2. `decode_intrabc_rect` (decode.rs:13646) and the other rect paths read their
201+ chroma through `read_inter_rect_chroma` / the intrabc split walk, which
202+ already window per unit; I did not re-verify each of them against a
203+ multi-unit override, only that the wide family is unchanged.
204+3. No heavy encodes: the witness came from the pin and the gate families are
205+ fixture-driven. No server fleet run was requested or consumed.