forge
Explore
Log in

Don't you dare go Hollow

4:4:4 2x1/1x2 chroma grids: each unit takes its OWN above-right reach

Browse files at this commit

e4e6f939dfa00027db443f9a8d0a5f2fb83f98f0Ahmet Kaan GümüşParent: 91004d1
The ticket's headline defect -- a 4:4:4 64x64 square block whose 64x64 chroma
plane block is a 2x2 Chroma32 grid, second unit reconstructing its sibling's
flat DC -- was ALREADY FIXED on main by e05a6ceb ("4:4:4 2x2 chroma walk: window
the intra-BC/palette override per unit", merged 2c0fd2b9 at 02:12), 15 minutes
AFTER lanes/av1chromarect-r2.report.md was merged with numbers measured on the
older base 5324a685. `git merge-base --is-ancestor e05a6ceb 5324a685` is false.
This commit does not redo that fix; it re-measures it (below) and fixes the one
cell of the class sweep that was still broken.

Also: the ticket's stated mechanism is wrong for this witness. The seed is
skip=1 on an INTRA-BC block, and libaom never sends an intra-BC block through
av1_predict_intra_block at all. decodeframe.c:1146 folds is_intrabc_block into
inter_block_tx; decodeframe.c:847 predict_inter_block -> :676
dec_build_inter_predictor calls dec_build_inter_predictors ONCE per plane with
bw = xd->plane[plane].width (decodeframe.c:686-688), i.e. the whole chroma
plane block, and reconinter_template.inc:228 makes the intra-BC reference the
destination buffer itself. So the prediction is one whole-plane-block motion
copy with no per-unit DC and no per-unit above/left; the units are then
reconstructed in place on top of it. The crate's whole-plane-block PALETTE_PRED
override IS that copy, and PlaneBuf::reconstruct (decode.rs:20939/21087) uses
the buffer it is handed as the UNIT's own chroma_tx x chroma_tx_h prediction --
which is what e05a6ceb's chroma_window fixes.

RE-MEASURED HERE (mutation M1: chroma_window back to the whole buffer, gate
a_444_skipped_64x64_square_block_windows_its_chroma_override_per_unit):

  test result: FAILED. 0 passed; 1 failed
  frame 0 plane U first divergence at sample 229728 of 262144 (x=352, y=448),
  7488 samples wrong

  f0  Y 0 | U 7488  | V 8128      f1  Y 0 | U 22571 | V 41782
  f2  Y 0 | U 0     | V 0        total 79969 of 2359296
  seed [320,384)x[448,512)  U 864/2048  V 1024/2048  first (352,448)
  victim [448,512)x[448,512) U 4096/4096 V 4096/4096 first (448,448)
  f0 U y=448, x=320..512 step 16:
    oracle 241 239 202 202 202 202 203 165 166 166 166 166
    ours   241 239 241 239 202 202 202 202 175 175 171 171

  AFTER the fix: 0 wrong on Y, U and V of all three frames, 0 of 2359296, and
  0 in all three named regions. Pin unchanged, already committed:
  fixtures/r512.obu, 6948 B, sha256 f587f0f980f149abce905e3ef66f2f1634f050c854
  30626eafb9c30a1e25bc21.

  (Correction to the ticket: [384,448)x[448,512) is NOT a clean control under
  this defect -- 1664 U and 1984 V wrong, first (416,448). What r2 measured was
  that its EDGE samples are all ~202, so any DC rule reproduces it; its pixels
  still move because an intra-BC block's reference is the current frame's own
  reconstruction.)

THE CLASS SWEEP, and the cell this commit fixes. Three sites walk a 4:4:4
chroma plane block as Chroma32 units:

  1 decode_block skip arm   (21897) 2x2  window: chroma_window (e05a6ceb)  reach: tu_reach_rect OK
  2 decode_block coded arm  (22182) 2x2  window: palette_window           reach: tu_reach_rect OK
  3 decode_rect_split       (12721) 2x1/1x2/2x2  window: palette_window   reach: BLOCK reach  <-- WRONG

Sites 1 and 2 can never be 2x1/1x2: a square luma block has
chroma_side == chroma_height at every supported subsampling and chroma_tx ==
chroma_tx_h, so cn_cols == cn_rows always. A 2x1/1x2 needs a rect luma block,
which only site 3 walks -- and it passed the BLOCK reach to every unit.

libaom resolves has_top_right PER TRANSFORM UNIT (defined reconintra.c:196,
called from av1_build_intra_predictors at reconintra.c:1847 with the chroma txb
walk's own blk_col/blk_row). The row_off == 0 arm is
`col_off + top_right_count_unit < plane_bw_unit`, so the FIRST unit of a 2-wide
grid reads its above-right out of the already-reconstructed block ABOVE even
when the block's own right edge is the frame's. PlaneBuf::edges (decode.rs:
20840) truncates the above row at own_across when above_right is false, so a
directional unit with angle < 90 (need_right, intra.rs:546) predicted from a
32-sample above row where libaom used 64.

NEW WITNESS fixtures/r512_rect2x1_1x2_444.obu, 2697 B, sha256 a009ec580a1ff
24250be53e11b8d09616da71e095cefd5eb621c941d40a8688b (recipe in the gate's doc
comment): 4:4:4 8-bit 256x256, one key frame, reaching BOTH shapes -- a 64x32
chroma plane block as nw=2 nh=1 of 32x32 and a 32x64 one as nw=1 nh=2.

  RED-BEFORE, per plane, own compare script over EC_AV1_FINAL_DUMP:
    f0  Y 0 wrong   U 130 wrong   V 30 wrong   (of 65536 per plane)
  All 160 sit in the right 6 columns of the cu=(0,0) unit at mi=(48,48)
  px=(192,192). Oracle vs ours for that unit:
    EC_PRED     mi_row=48 mi_col=48 plane=1 row_off=0 col_off=0 txw=32 txh=32
                mode=1 p_angle=84 n_top=32 n_left=32 n_tr=32 n_bl=-1 bsize=11
    EC_PREDOUT8 sum=172662  row0=179,185,190,195,197,198,197,194
    OUR_PRED    sum=171512  row0=[179,185,190,195,197,198,197,194]
  row0 and col0 match exactly and only the SUM differs, so the residual read is
  bit-identical and the divergence is prediction-side, not entropy. Same 130/30
  wrong in the oracle's EC_AV1_PREFILT_DUMP as in EC_AV1_FINAL_DUMP, so it is
  pre-loop-filter. The U per-column delta -1,-5,-9,-14,-18,-19 grows rightward,
  which is a directional prediction reaching further right as it goes.

THE FIX: one expression, both unit readers in that walk (the square read_plane
and the rect push_intra_rect) get the unit's own reach, from the crate's
EXISTING per-unit port -- the same call sites 1 and 2 already use:

  let cu_reach = tu_reach_rect(bw, bh,
      (cu_col * uw) << ss_x(fctx), (cu_row * uh) << ss_y(fctx),
      uw << ss_x(fctx), uh << ss_y(fctx),
      reach, px, py, y.width, y.height, fctx);

AFTER: 0 wrong on all three planes.

GATES, both aomdec-oracle with no silent skip, counters asserted before a
single sample is compared:

  a_444_rect_strip_chroma_tiled_2x1_and_1x2_units_take_their_own_above_right_reach
    asserts >= 4 units in a 2x1 grid AND >= 4 in a 1x2 grid, >= 1 unit whose
    per-unit reach differs from the block's, then full byte-exactness of all
    three planes. Pin fnv1a64 0x2751ccaa079cc422.
  a_444_rect_strip_chroma_tiled_1x2_palette_grid_decodes_byte_exact
    the UV-PALETTE cell lanes/av1chromadc.report.md section 5 left explicitly
    UNMEASURED ("its arm of the sweep is argued from the shared code path, not
    witnessed"). Pin fixtures/r512_rect1x2_444_palette.obu, 2250 B, sha256
    fad03c69087f316c1a117e8d8a70769d161b332bce7b2998e646312bb78fb067, which
    puts a UV-palette block on a 1x2 16x64 chroma grid at mi=(32,12).

MUTATION: M1, both readers back to the block reach -- RED at sample 49374
(x=222, y=192), 130 samples wrong. M2, cu_col/cu_row transposed -- GREEN, and
that is a real limit of the gate, not a pass: this witness's second/bottom
units sit flush against the frame edge, so the Reach clamp truncates the extra
reach back to nothing. The gates pin the reach VALUE, not the offset spelling;
no claim is made about the spelling.

CLASS SWEEP, all 19 set_palette_pred sites: every one is already windowed per
unit (12633, 12784, 16685, 16955, 21953/21975) or is a genuine single-unit read
where the whole buffer IS the window (decode_block_rect 15378/15396/15559/15607,
decode_leaf_rect 15996/16014/16175/16220, decode_block_rect4 16825/16859 which
loops PLANES of a 4x4 block). The one unwindowed site inside a unit loop,
decode.rs:12525's 4:2:2 (4,8) units, is unreachable -- both
chroma_422_pair_wide and chroma_422_oob require ss_x == 1 && ss_y == 0, the
4:2:2 that stream.rs:1783 refuses by name.

RE-QUOTES. cargo check -p ec-av1 --all-targets: 0 errors, 0 warnings.
  a_444 lossless_444 intrabc_rect 444_lossless 420_intrabc_rect4
    ok. 39 passed; 0 failed; 0 ignored  (4:4:4-lossless, intrabc_rect, 4:2:0 twin)
  rect intrabc ibc chroma 444 420 subsampl, once per tree, private target dir:
    base 70ed5601 (detached)  ok. 145 passed; 0 failed; 5 ignored; 623 filtered out
    this tip                  ok. 147 passed; 0 failed; 5 ignored; 623 filtered out
  The delta is exactly these two gates (775 tests on both trees by --list). No
  test renamed, dropped or newly ignored; no floor lowered anywhere.

Report: lanes/av1dcunit.report.md. NOT DONE is listed there in six items, the
first being that the 2x1/1x2 offset spelling is unproven (M2).
crates/ec-av1/fixtures/r512_rect1x2_444_palette.obuadded+0 -0

Binary file changed

crates/ec-av1/fixtures/r512_rect2x1_1x2_444.obuadded+0 -0

Binary file changed

crates/ec-av1/src/decode.rsmodified+105 -2
@@ -2743,6 +2743,57 @@ pub(crate) fn reset_palette_sb_strip_hits() {
2743 PALETTE_SB_STRIP_HITS.with(|c| c.set(0));2743 PALETTE_SB_STRIP_HITS.with(|c| c.set(0));
2744 }2744 }
2745 2745
2746+thread_local! {
2747+ /// lane-av1rectreach: units of `decode_rect_split`'s `chroma_tiled` walk
2748+ /// whose PER-UNIT reach ([`tu_reach_rect`], libaom's per-unit
2749+ /// `has_top_right` / `has_bottom_left`) DIFFERS from the block-level
2750+ /// `reach` this walk used to hand every unit -- i.e. units for which the
2751+ /// two answers are not interchangeable. This is what a gate needs before
2752+ /// it compares the walk byte-exactly: if the two agreed everywhere, the
2753+ /// substitution could not change a single predicted sample and the
2754+ /// exactness assert would be measuring a witness the fix cannot touch.
2755+ ///
2756+ /// What it does NOT prove is that the argument handed to the unit reader
2757+ /// is the per-unit one -- the count is taken from the same expression
2758+ /// either way, so deleting the substitution reds the exactness assert
2759+ /// rather than this counter. That is the right way round: the assert is
2760+ /// the claim, this is only the floor under it.
2761+ static RECT_TILED_CHROMA_UNIT_REACH_HITS: std::cell::Cell<usize> =
2762+ const { std::cell::Cell::new(0) };
2763+ /// Chroma units of the same walk whose grid is exactly 2x1 (a 4:4:4
2764+ /// 64x32 chroma plane block as two 32x32 units).
2765+ static RECT_TILED_CHROMA_2X1_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
2766+ /// Chroma units of the same walk whose grid is exactly 1x2 (4:4:4 32x64,
2767+ /// or 16x64 as two 16x32s).
2768+ static RECT_TILED_CHROMA_1X2_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
2769+ /// Chroma units of the same walk in any other multi-unit grid (2x2 and up
2770+ /// -- only reachable at 4:2:2, which is refused, so this stays 0 on
2771+ /// every admitted stream; kept so the match above is exhaustive).
2772+ static RECT_TILED_CHROMA_NXN_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
2773+}
2774+
2775+/// Current values of the four `RECT_TILED_CHROMA_*` counters, in the order
2776+/// `(unit_reach_differs, 2x1, 1x2, other multi-unit)`.
2777+#[allow(dead_code)] // read only from the `#[cfg(test)]` gates
2778+pub(crate) fn rect_tiled_chroma_grid_hits() -> (usize, usize, usize, usize) {
2779+ (
2780+ RECT_TILED_CHROMA_UNIT_REACH_HITS.with(|c| c.get()),
2781+ RECT_TILED_CHROMA_2X1_HITS.with(|c| c.get()),
2782+ RECT_TILED_CHROMA_1X2_HITS.with(|c| c.get()),
2783+ RECT_TILED_CHROMA_NXN_HITS.with(|c| c.get()),
2784+ )
2785+}
2786+
2787+/// Zeroes the four `RECT_TILED_CHROMA_*` counters (gate tests call this
2788+/// before their own decode).
2789+#[allow(dead_code)] // read only from the `#[cfg(test)]` gates
2790+pub(crate) fn reset_rect_tiled_chroma_grid_hits() {
2791+ RECT_TILED_CHROMA_UNIT_REACH_HITS.with(|c| c.set(0));
2792+ RECT_TILED_CHROMA_2X1_HITS.with(|c| c.set(0));
2793+ RECT_TILED_CHROMA_1X2_HITS.with(|c| c.set(0));
2794+ RECT_TILED_CHROMA_NXN_HITS.with(|c| c.set(0));
2795+}
2796+
2746 // lane-t900 r22: palette blocks reconstructed inside an INTER frame (the2797 // lane-t900 r22: palette blocks reconstructed inside an INTER frame (the
2747 // intra-in-inter path, `decode_inter_block`/`decode_inter_block8`) -- counted2798 // intra-in-inter path, `decode_inter_block`/`decode_inter_block8`) -- counted
2748 // apart from [`PALETTE_HITS`] so a witness gate can prove the INTER-frame2799 // apart from [`PALETTE_HITS`] so a witness gate can prove the INTER-frame
@@ -12786,6 +12837,58 @@ fn decode_rect_split(
12786 fctx,12837 fctx,
12787 );12838 );
12788 }12839 }
12840+ // libaom computes `has_top_right` PER TRANSFORM UNIT (defined
12841+ // reconintra.c:196, called from `av1_build_intra_predictors` at
12842+ // reconintra.c:1847 with the txb walk's own
12843+ // `blk_col`/`blk_row`), never per block: the
12844+ // `row_off == 0` arm asks `col_off + top_right_count_unit
12845+ // < plane_bw_unit`, so the FIRST unit of a 2-wide chroma
12846+ // grid reads its above-right out of the already-reconstructed
12847+ // block ABOVE even when the block's own right edge is the
12848+ // frame's. Passing this walk's block-level `reach` gave
12849+ // every unit the same answer, and `PlaneBuf::edges`
12850+ // (decode.rs:20840) truncates the above row at
12851+ // `own_across` when `above_right` is false -- so a
12852+ // directional unit whose angle is below 90
12853+ // (`need_right`, intra.rs:546) predicted with a 32-sample
12854+ // above row where libaom used 64.
12855+ // MEASURED on `fixtures/r512_rect2x1_1x2_444.obu`
12856+ // (4:4:4 8-bit 256x256, one frame): frame 0 plane U 130
12857+ // samples and plane V 30 samples wrong, every one of them
12858+ // in the right 6 columns of the `cu=(0,0)` unit at
12859+ // `mi=(48,48)` `px=(192,192)` -- the unit whose above-right
12860+ // the block reach denied. Row0 and col0 of the prediction
12861+ // matched the oracle exactly and the prediction SUM did
12862+ // not (172662 vs 171512 on U, 125978 vs 126008 on V), so
12863+ // the residual read is bit-identical and the divergence is
12864+ // prediction-side, not entropy. Gate:
12865+ // `a_444_rect_strip_chroma_tiled_2x1_and_1x2_units_take_their_own_above_right_reach`.
12866+ let cu_reach = tu_reach_rect(
12867+ bw,
12868+ bh,
12869+ (cu_col * uw) << ss_x(fctx),
12870+ (cu_row * uh) << ss_y(fctx),
12871+ uw << ss_x(fctx),
12872+ uh << ss_y(fctx),
12873+ reach,
12874+ px,
12875+ py,
12876+ y.width,
12877+ y.height,
12878+ fctx,
12879+ );
12880+ if cu_reach.above_right != reach.above_right
12881+ || cu_reach.below_left != reach.below_left
12882+ {
12883+ hit!(RECT_TILED_CHROMA_UNIT_REACH_HITS);
12884+ }
12885+ if nw * nh > 1 {
12886+ match (nw, nh) {
12887+ (2, 1) => hit!(RECT_TILED_CHROMA_2X1_HITS),
12888+ (1, 2) => hit!(RECT_TILED_CHROMA_1X2_HITS),
12889+ _ => hit!(RECT_TILED_CHROMA_NXN_HITS),
12890+ }
12891+ }
12789 // 32x32 does not fit read_coeffs_rect's scratch (768). The12892 // 32x32 does not fit read_coeffs_rect's scratch (768). The
12790 // square reader is the path every other 32x32 chroma unit uses.12893 // square reader is the path every other 32x32 chroma unit uses.
12791 let levels = if uw == uh {12894 let levels = if uw == uh {
@@ -12800,7 +12903,7 @@ fn decode_rect_split(
12800 m.mode,12903 m.mode,
12801 m.uv_predict_mode,12904 m.uv_predict_mode,
12802 m.angle_delta_uv,12905 m.angle_delta_uv,
12803- reach,12906+ cu_reach,
12804 plane,12907 plane,
12805 cu_x,12908 cu_x,
12806 cu_y,12909 cu_y,
@@ -12848,7 +12951,7 @@ fn decode_rect_split(
12848 uh,12951 uh,
12849 m.uv_predict_mode,12952 m.uv_predict_mode,
12850 m.angle_delta_uv,12953 m.angle_delta_uv,
12851- reach,12954+ cu_reach,
12852 &residual,12955 &residual,
12853 cfl,12956 cfl,
12854 None,12957 None,
crates/ec-av1/src/stream.rsmodified+279 -0
@@ -171,6 +171,18 @@ pub fn reset_skip_chroma_override_window_hits() {
171 crate::decode::reset_skip_chroma_override_window_hits()171 crate::decode::reset_skip_chroma_override_window_hits()
172 }172 }
173 173
174+/// lane-av1rectreach: the `chroma_tiled` walk's per-unit reach and grid-shape
175+/// counters, as `(unit_reach_differs_from_block, 2x1 units, 1x2 units, other
176+/// multi-unit units)`. See [`crate::decode::rect_tiled_chroma_grid_hits`].
177+pub fn rect_tiled_chroma_grid_hits() -> (usize, usize, usize, usize) {
178+ crate::decode::rect_tiled_chroma_grid_hits()
179+}
180+
181+/// Gate-side reset for the lane-av1rectreach counters above.
182+pub fn reset_rect_tiled_chroma_grid_hits() {
183+ crate::decode::reset_rect_tiled_chroma_grid_hits()
184+}
185+
174 /// `(y, uv)` palette blocks RECONSTRUCTED inside an inter frame (lane-t900186 /// `(y, uv)` palette blocks RECONSTRUCTED inside an inter frame (lane-t900
175 /// r22) -- the counter a screen-content witness gate reads to prove it187 /// r22) -- the counter a screen-content witness gate reads to prove it
176 /// exercises the inter-frame palette path, not the key frame's.188 /// exercises the inter-frame palette path, not the key frame's.
@@ -49938,4 +49950,271 @@ pub(crate) mod tests {
49938 }49950 }
49939 let _ = std::fs::remove_dir_all(&dir);49951 let _ = std::fs::remove_dir_all(&dir);
49940 }49952 }
49953+
49954+ /// lane-av1rectreach, the 2x1 / 1x2 half of the class sweep
49955+ /// `a_444_skipped_64x64_square_block_windows_its_chroma_override_per_unit`
49956+ /// opened: `decode_rect_split`'s `chroma_tiled` walk is the THIRD site that
49957+ /// walks a 4:4:4 chroma plane block as a grid of Chroma32 units, and the
49958+ /// only one that handed every unit the BLOCK's reach.
49959+ ///
49960+ /// The other two are already per-unit and are not touched by this gate:
49961+ /// `decode_block`'s skip arm (`chroma_window`, lane-av1chromadc) and
49962+ /// `decode_block`'s coded arm (its own `tu_reach_rect`) both resolve
49963+ /// `has_top_right` per transform unit, the way libaom's
49964+ /// `av1_build_intra_predictors` does
49965+ /// (`has_top_right`, defined reconintra.c:196, called from
49966+ /// `av1_build_intra_predictors` at reconintra.c:1847),
49967+ /// fed the chroma txb walk's own `blk_col`/`blk_row`).
49968+ ///
49969+ /// Witness `fixtures/r512_rect2x1_1x2_444.obu`, 2697 B,
49970+ /// sha256 `a009ec580a1ff24250be53e11b8d09616da71e095cefd5eb621c941d40a8688b`:
49971+ ///
49972+ /// ```text
49973+ /// ffmpeg -f lavfi -i testsrc2=size=256x256:rate=1:duration=1 -pix_fmt yuv444p \
49974+ /// -f rawvideo in.yuv
49975+ /// aomenc --codec=av1 -w 256 -h 256 --i444 --sb-size=64 --enable-palette=1 \
49976+ /// --enable-rect-partitions=1 --enable-1to4-partitions=1 \
49977+ /// --min-partition-size=32 --cq-level=40 --profile=1 --obu --limit=1 \
49978+ /// -o r512_rect2x1_1x2_444.obu in.yuv
49979+ /// ```
49980+ ///
49981+ /// (aom-affine aomenc, one key frame, 4:4:4 8-bit 256x256.) It reaches
49982+ /// BOTH grid shapes: a 64x32 chroma plane block as `nw=2 nh=1` of 32x32
49983+ /// and a 32x64 one as `nw=1 nh=2`.
49984+ ///
49985+ /// RED-BEFORE, on the unpatched tree, measured with `EC_AV1_FINAL_DUMP`
49986+ /// (aomdec) against `set_final_dump_prefix` (ours), 786432 B per frame:
49987+ /// frame 0 plane Y 0 wrong, plane U 130 wrong, plane V 30 wrong -- all of
49988+ /// them in the right 6 columns of the `cu=(0,0)` unit at `mi=(48,48)`
49989+ /// `px=(192,192)`, a 64x32 block whose right edge IS the frame's, so the
49990+ /// block-level reach denied an above-right that libaom's per-unit
49991+ /// `col_off + top_right_count_unit < plane_bw_unit` (0 + 8 < 16) grants.
49992+ /// After: 0 wrong on all three planes.
49993+ #[test]
49994+ fn a_444_rect_strip_chroma_tiled_2x1_and_1x2_units_take_their_own_above_right_reach() {
49995+ const NAME: &str =
49996+ "a_444_rect_strip_chroma_tiled_2x1_and_1x2_units_take_their_own_above_right_reach";
49997+ const FILE: &str = "r512_rect2x1_1x2_444.obu";
49998+ const LEN: usize = 2697;
49999+ const SHA: &str = "a009ec580a1ff24250be53e11b8d09616da71e095cefd5eb621c941d40a8688b";
50000+ const W: usize = 256;
50001+ const PLANE: usize = W * W;
50002+ let path =
50003+ std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR")).join(format!("fixtures/{FILE}"));
50004+ let stream = std::fs::read(&path)
50005+ .unwrap_or_else(|e| panic!("{NAME}: pinned fixture {FILE} missing: {e}"));
50006+ assert_eq!(stream.len(), LEN, "{NAME}: {FILE} length moved");
50007+ assert_444_header(&stream, NAME, 8);
50008+ // The byte pin is fnv1a64, the same load-bearing-identity hash every
50009+ // other pinned gate here uses; the sha256 in this test's comment is
50010+ // the provenance half. A silent stream swap under the same name
50011+ // cannot stay green.
50012+ assert_eq!(
50013+ fnv1a64(&stream),
50014+ 0x2751ccaa079cc422,
50015+ "{NAME}: {FILE} bytes drifted from the fnv1a64 pin above (provenance sha256 \
50016+ {SHA}) -- regenerate the stream with the recipe in this test's comment and \
50017+ re-pin the length, the fnv1a64 and the sha256 together"
50018+ );
50019+
50020+ let _guard = lock_gate_counters();
50021+ reset_rect_tiled_chroma_grid_hits();
50022+ let dir = std::env::temp_dir().join(format!("ec-av1-{NAME}-{}", std::process::id()));
50023+ let _ = std::fs::remove_dir_all(&dir);
50024+ std::fs::create_dir_all(&dir).expect("scratch dir");
50025+ let obu = dir.join("in.obu");
50026+ std::fs::write(&obu, &stream).expect("writing the stream");
50027+ let aom_prefix = dir.join("aom");
50028+ let out = Command::new(aomdec_path())
50029+ .args(["--codec=av1", "-o"])
50030+ .arg(dir.join("out.y4m"))
50031+ .arg(&obu)
50032+ .env("EC_AV1_FINAL_DUMP", &aom_prefix)
50033+ .stdin(Stdio::null())
50034+ .stdout(Stdio::piped())
50035+ .stderr(Stdio::piped())
50036+ .output()
50037+ .expect("aomdec failed to run");
50038+ assert!(
50039+ out.status.success(),
50040+ "{NAME}: the oracle aomdec refused the stream: {}",
50041+ String::from_utf8_lossy(&out.stderr)
50042+ );
50043+ let ours_prefix = dir.join("ours");
50044+ set_final_dump_prefix(Some(ours_prefix.display().to_string()));
50045+ if let Err(e) = decode_stream(&stream) {
50046+ panic!("{NAME}: this decoder refused the witness: {e}");
50047+ }
50048+ set_final_dump_prefix(None);
50049+
50050+ // Non-vacuity, in the order the claim depends on it: the walk must
50051+ // have reached a 2x1 AND a 1x2 grid, and at least one unit must have
50052+ // a per-unit reach that DIFFERS from the block-level one. Without the
50053+ // last one the two answers would be interchangeable everywhere and
50054+ // the exactness below would be measuring a witness the fix cannot
50055+ // touch. (It does not check the argument identity -- see
50056+ // `RECT_TILED_CHROMA_UNIT_REACH_HITS`; the exactness assert below is
50057+ // what reds when the substitution is deleted.)
50058+ let (reach_hits, h2x1, h1x2, h_nxn) = rect_tiled_chroma_grid_hits();
50059+ assert!(
50060+ h2x1 >= 4 && h1x2 >= 4,
50061+ "{NAME}: the walk reached {h2x1} unit(s) in a 2x1 grid and {h1x2} in a 1x2 grid \
50062+ (other multi-unit shapes: {h_nxn}), expected at least 4 of each -- the witness \
50063+ stopped exercising one of the two grid shapes, so half the claim is vacuous"
50064+ );
50065+ assert!(
50066+ reach_hits >= 1,
50067+ "{NAME}: {reach_hits} chroma unit(s) had a per-unit reach differing from the \
50068+ block-level one, expected at least 1 -- on the unpatched tree every unit took \
50069+ the block's reach, so the exactness below is vacuous"
50070+ );
50071+
50072+ let aom_dump = std::fs::read(format!("{}.f0", aom_prefix.display()))
50073+ .unwrap_or_else(|e| panic!("{NAME}: oracle dump f0 missing: {e}"));
50074+ let our_dump = std::fs::read(format!("{}.f0", ours_prefix.display()))
50075+ .unwrap_or_else(|e| panic!("{NAME}: our dump f0 missing: {e}"));
50076+ assert_eq!(
50077+ our_dump.len(),
50078+ 3 * PLANE,
50079+ "{NAME}: frame 0 is not 8-bit 4:4:4 256x256"
50080+ );
50081+ for (plane, pname) in [(0usize, "Y"), (1, "U"), (2, "V")] {
50082+ let at = plane * PLANE;
50083+ if our_dump[at..at + PLANE] == aom_dump[at..at + PLANE] {
50084+ continue;
50085+ }
50086+ let first = (0..PLANE)
50087+ .find(|&s| our_dump[at + s] != aom_dump[at + s])
50088+ .unwrap_or(PLANE);
50089+ let wrong = (0..PLANE)
50090+ .filter(|&s| our_dump[at + s] != aom_dump[at + s])
50091+ .count();
50092+ panic!(
50093+ "{NAME}: frame 0 plane {pname} is byte-exact nowhere -- first divergence at \
50094+ sample {first} of {PLANE} (x={}, y={}), {wrong} samples wrong. Each unit of \
50095+ this walk must resolve `has_top_right` over ITS OWN extent \
50096+ (reconintra.c:196/1847), not the block's: the seed unit is cu=(0,0) of \
50097+ 64x32 chroma grid at mi=(48,48) px=(192,192), whose right 6 columns are the \
50098+ ones the truncated above row moved.",
50099+ first % W,
50100+ first / W
50101+ );
50102+ }
50103+ let _ = std::fs::remove_dir_all(&dir);
50104+ }
50105+
50106+ /// The UV-PALETTE half of the same class, and the cell
50107+ /// `lanes/av1chromadc.report.md` §5 left explicitly UNMEASURED ("every
50108+ /// multi-unit walk on this witness is `src=intrabc`; the UV-palette source
50109+ /// never reaches a multi-unit chroma walk here, so its arm of the sweep is
50110+ /// argued from the shared code path, not witnessed"). This witness is the
50111+ /// measurement: it puts a UV-palette block on a 1x2 16x64 chroma grid
50112+ /// (`mi=(32,12)`) as well as plenty of non-palette ones.
50113+ ///
50114+ /// Witness `fixtures/r512_rect1x2_444_palette.obu`, 2250 B,
50115+ /// sha256 `fad03c69087f316c1a117e8d8a70769d161b332bce7b2998e646312bb78fb067`:
50116+ ///
50117+ /// ```text
50118+ /// ffmpeg -f lavfi -i testsrc2=size=256x256:rate=1:duration=1 -pix_fmt yuv444p \
50119+ /// -f rawvideo in.yuv
50120+ /// aomenc --codec=av1 -w 256 -h 256 --i444 --sb-size=64 --enable-palette=1 \
50121+ /// --enable-rect-partitions=1 --enable-1to4-partitions=1 \
50122+ /// --min-partition-size=16 --cq-level=40 --profile=1 --obu --limit=1 \
50123+ /// -o r512_rect1x2_444_palette.obu in.yuv
50124+ /// ```
50125+ ///
50126+ /// (`--min-partition-size=16` is what puts the 16x64 chroma grid on a
50127+ /// strip at all; at 32 the encoder only ever picks 32x64 / 64x32.) The
50128+ /// per-unit reach the fix installs is the same line for the palette and
50129+ /// the non-palette unit -- the palette only supplies the PREDICTION
50130+ /// (`palette_window`, decode.rs:12784), never the reach -- so this gate
50131+ /// exists to pin the prediction source down, not to re-prove the reach.
50132+ #[test]
50133+ fn a_444_rect_strip_chroma_tiled_1x2_palette_grid_decodes_byte_exact() {
50134+ const NAME: &str = "a_444_rect_strip_chroma_tiled_1x2_palette_grid_decodes_byte_exact";
50135+ const FILE: &str = "r512_rect1x2_444_palette.obu";
50136+ const LEN: usize = 2250;
50137+ const SHA: &str = "fad03c69087f316c1a117e8d8a70769d161b332bce7b2998e646312bb78fb067";
50138+ const W: usize = 256;
50139+ const PLANE: usize = W * W;
50140+ let path =
50141+ std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR")).join(format!("fixtures/{FILE}"));
50142+ let stream = std::fs::read(&path)
50143+ .unwrap_or_else(|e| panic!("{NAME}: pinned fixture {FILE} missing: {e}"));
50144+ assert_eq!(stream.len(), LEN, "{NAME}: {FILE} length moved");
50145+ assert_444_header(&stream, NAME, 8);
50146+ assert_eq!(
50147+ fnv1a64(&stream),
50148+ 0x7759753a0d3f75a2,
50149+ "{NAME}: {FILE} bytes drifted from the fnv1a64 pin above (provenance sha256 \
50150+ {SHA}) -- regenerate the stream with the recipe in this test's comment and \
50151+ re-pin the length, the fnv1a64 and the sha256 together"
50152+ );
50153+
50154+ let _guard = lock_gate_counters();
50155+ reset_rect_tiled_chroma_grid_hits();
50156+ let dir = std::env::temp_dir().join(format!("ec-av1-{NAME}-{}", std::process::id()));
50157+ let _ = std::fs::remove_dir_all(&dir);
50158+ std::fs::create_dir_all(&dir).expect("scratch dir");
50159+ let obu = dir.join("in.obu");
50160+ std::fs::write(&obu, &stream).expect("writing the stream");
50161+ let aom_prefix = dir.join("aom");
50162+ let out = Command::new(aomdec_path())
50163+ .args(["--codec=av1", "-o"])
50164+ .arg(dir.join("out.y4m"))
50165+ .arg(&obu)
50166+ .env("EC_AV1_FINAL_DUMP", &aom_prefix)
50167+ .stdin(Stdio::null())
50168+ .stdout(Stdio::piped())
50169+ .stderr(Stdio::piped())
50170+ .output()
50171+ .expect("aomdec failed to run");
50172+ assert!(
50173+ out.status.success(),
50174+ "{NAME}: the oracle aomdec refused the stream: {}",
50175+ String::from_utf8_lossy(&out.stderr)
50176+ );
50177+ let ours_prefix = dir.join("ours");
50178+ set_final_dump_prefix(Some(ours_prefix.display().to_string()));
50179+ if let Err(e) = decode_stream(&stream) {
50180+ panic!("{NAME}: this decoder refused the witness: {e}");
50181+ }
50182+ set_final_dump_prefix(None);
50183+
50184+ let (_reach_hits, h2x1, h1x2, _h_nxn) = rect_tiled_chroma_grid_hits();
50185+ assert!(
50186+ h1x2 >= 4,
50187+ "{NAME}: the walk reached {h1x2} unit(s) in a 1x2 grid ({h2x1} in a 2x1), expected \
50188+ at least 4 of the 1x2 -- the witness stopped exercising the arm"
50189+ );
50190+
50191+ let aom_dump = std::fs::read(format!("{}.f0", aom_prefix.display()))
50192+ .unwrap_or_else(|e| panic!("{NAME}: oracle dump f0 missing: {e}"));
50193+ let our_dump = std::fs::read(format!("{}.f0", ours_prefix.display()))
50194+ .unwrap_or_else(|e| panic!("{NAME}: our dump f0 missing: {e}"));
50195+ assert_eq!(
50196+ our_dump.len(),
50197+ 3 * PLANE,
50198+ "{NAME}: frame 0 is not 8-bit 4:4:4 256x256"
50199+ );
50200+ for (plane, pname) in [(0usize, "Y"), (1, "U"), (2, "V")] {
50201+ let at = plane * PLANE;
50202+ if our_dump[at..at + PLANE] == aom_dump[at..at + PLANE] {
50203+ continue;
50204+ }
50205+ let first = (0..PLANE)
50206+ .find(|&s| our_dump[at + s] != aom_dump[at + s])
50207+ .unwrap_or(PLANE);
50208+ let wrong = (0..PLANE)
50209+ .filter(|&s| our_dump[at + s] != aom_dump[at + s])
50210+ .count();
50211+ panic!(
50212+ "{NAME}: frame 0 plane {pname} is byte-exact nowhere -- first divergence at \
50213+ sample {first} of {PLANE} (x={}, y={}), {wrong} samples wrong.",
50214+ first % W,
50215+ first / W
50216+ );
50217+ }
50218+ let _ = std::fs::remove_dir_all(&dir);
50219+ }
49941 }50220 }
lanes/av1dcunit.report.mdadded+311 -0
@@ -0,0 +1,311 @@
1+# lane-av1dcunit — the assigned defect was already fixed; the 2x1/1x2 class cell was not
2+
3+Worktree `~/.cache/wt/av1dcunit`, branch `lane-av1dcunit`, base `70ed5601`
4+("Merge lane-av1txctxband"). Two commits: one read-only verification of the
5+assigned defect, one fix for the class-sweep cell the verification found.
6+
7+## 1. Headline: the assigned defect is NOT on `70ed5601` — it was fixed 55 minutes before this lane started
8+
9+`lanes/av1chromarect-r2.report.md` (the ticket's source) measured its 79969
10+samples on base `5324a685`. The fix landed on main **after** that base and
11+**before** the r2 report was even merged:
12+
13+| sha | time | what |
14+| --- | --- | --- |
15+| `5324a685` | 01:36 | r2's base — 79969 chroma samples wrong |
16+| `57834ee2` | 01:49 | r2's report merged (numbers measured on `5324a685`) |
17+| `e05a6ceb` | **02:04** | **the fix**: "4:4:4 2x2 chroma walk: window the intra-BC/palette override per unit" |
18+| `2c0fd2b9` | 02:12 | merge of `lane-av1chromadc` — 79969 → 0 |
19+| `70ed5601` | 02:58 | this lane's base |
20+
21+`git merge-base --is-ancestor e05a6ceb 5324a685` → false. The r2 report and the
22+fix were two lanes working the same residual from two bases; the fix won by 15
23+minutes. So there was nothing to fix for the ticket as written, and this lane
24+verified that rather than re-doing it.
25+
26+## 2. The assigned defect, re-measured here (red-before included)
27+
28+**Mechanism, and it is NOT the one the ticket names.** The ticket (following
29+r2 §3) says libaom "builds the DC from THAT UNIT's own above row and left
30+column (`av1_build_dc_predictor_sb`)". For this witness that is wrong, and the
31+seed proves it: the seed is `skip=1` on an **intra-BC** block, and an intra-BC
32+block never reaches `av1_predict_intra_block` at all. libaom's decoder routes
33+it through the inter path instead:
34+
35+* `decodeframe.c:1146` — `int inter_block_tx = is_inter_block(mbmi) || is_intrabc_block(mbmi);`
36+* `decodeframe.c:847` `predict_inter_block` → `decodeframe.c:676` `dec_build_inter_predictor`
37+* `decodeframe.c:686-688` — one `dec_build_inter_predictors` call per plane with
38+ `bw = xd->plane[plane].width, bh = xd->plane[plane].height`, i.e. the WHOLE
39+ chroma plane block at once, not per transform unit
40+* `reconinter_template.inc:228` — `const struct buf_2d *const pre_buf = is_intrabc ? dst_buf : &pd->pre[ref];`
41+ the intra-BC reference **is the destination buffer**, so the prediction is a
42+ motion-compensated copy of the current frame's own reconstruction
43+* the units are then reconstructed in place on top of it, with no edge read
44+
45+So there is no per-unit DC and no per-unit above/left on this path. What the
46+crate's whole-plane-block `PALETTE_PRED` override buffer is, in libaom's terms,
47+is that single whole-plane-block motion prediction — and
48+`PlaneBuf::reconstruct` consumes the buffer it is handed as the **unit's own**
49+`chroma_tx x chroma_tx_h` prediction (`decode.rs:20939` and `21087`,
50+`let prediction = if let Some(buf) = pred { buf } else { … }`). Handing the whole
51+buffer to every unit of a 2x2 grid makes all four units predict from the
52+top-left one. That is the defect, and `e05a6ceb`'s `chroma_window` is the
53+correct fix for it.
54+
55+**Red-before, measured in THIS worktree** by mutating `chroma_window` back to
56+the pre-fix whole-buffer shape (that is mutation M1 of §5) and running the
57+landed gate `a_444_skipped_64x64_square_block_windows_its_chroma_override_per_unit`:
58+
59+```
60+decode-order frame 0 plane U is byte-exact nowhere -- first divergence at
61+sample 229728 of 262144 (x=352, y=448), 7488 samples wrong.
62+test result: FAILED. 0 passed; 1 failed
63+```
64+
65+Full per-plane counts, from my own compare script outside the repo
66+(`~/.cache/cmp444.py`, reading the `EC_AV1_FINAL_DUMP` dumps of both sides):
67+
68+| frame | Y | U | V |
69+| --- | --- | --- | --- |
70+| 0 | 0 | **7488** | **8128** |
71+| 1 | 0 | **22571** | **41782** |
72+| 2 | 0 | 0 | 0 |
73+
74+Total **79969 of 2359296** — r2's number exactly. The three regions the ticket
75+names, frame 0:
76+
77+| region | U wrong | V wrong | first wrong |
78+| --- | --- | --- | --- |
79+| seed `[320,384)x[448,512)` | 864 / 2048 | 1024 / 2048 | (352,448) |
80+| sibling `[384,448)x[448,512)` | 1664 / 4096 | 1984 / 4096 | (416,448) |
81+| victim `[448,512)x[448,512)` | **4096 / 4096** | **4096 / 4096** | (448,448) |
82+
83+f0 U, row y=448, every 16th sample from x=320 (the 2x2 grid boundary is
84+x = 352 = 320+32):
85+
86+```
87+oracle: 241 239 202 202 202 202 203 165 166 166 166 166
88+ours : 241 239 241 239 202 202 202 202 175 175 171 171
89+```
90+
91+The seed's `cu=(1,0)` is a flat 241 — its sibling's value — exactly as the
92+ticket describes, and the victim is wrong on every sample.
93+
94+**After (fix in place, same oracle, same script): 0 wrong on all three planes
95+of all three frames, 0 of 2359296.** All three named regions are 0/2048 and
96+0/4096. The f0 U row above matches the oracle in all 12 samples.
97+
98+One correction to the ticket's "clean sibling control": `[384,448)x[448,512)`
99+is **not** clean under this defect — 1664 U and 1984 V samples wrong, first at
100+(416,448). What r2 measured clean was that block's *edge samples* are all ≈202,
101+so "any DC rule reproduces the oracle" for it (r2 §3); its pixels still move
102+because an intra-BC block's reference is the current frame's own
103+reconstruction, so the seed's error propagates one block to the right. The
104+first dirty cell is x=416, not x=352, for that block.
105+
106+## 3. Acceptance
107+
108+1. **Red-before per plane** — §2, 7488 / 8128 / 22571 / 41782, total 79969,
109+ dumped with `EC_AV1_FINAL_DUMP` and compared by `~/.cache/cmp444.py`.
110+2. **After** — 0 wrong on Y, U, V of all three frames; all three named regions
111+ exact. Nothing remains in the regions the seed/victim cover.
112+3. **Gate** — `a_444_skipped_64x64_square_block_windows_its_chroma_override_per_unit`
113+ (landed by `e05a6ceb`, aomdec oracle required, no silent skip). Pin
114+ `fixtures/r512.obu`, 6948 B, sha256
115+ `f587f0f980f149abce905e3ef66f2f1634f050c85430626eafb9c30a1e25bc21`,
116+ already committed — no regeneration needed.
117+4. **Mutation** — M1 below.
118+5. **Re-quotes, unchanged** — §4.
119+6. **Class sweep** — §5, and it found a real second defect, which this lane
120+ fixed.
121+
122+## 4. Re-quotes on this branch (nothing in §2's path changed)
123+
124+```
125+$ cargo check -p ec-av1 --all-targets # 0 errors, 0 warnings
126+$ cargo test -p ec-av1 --lib -- a_444 lossless_444 intrabc_rect 444_lossless 420_intrabc_rect4
127+test result: ok. 39 passed; 0 failed; 0 ignored; 0 measured; 736 filtered out; finished in 12.44s
128+```
129+
130+The 39 carry the 4:4:4-lossless family (`a_lossless_444_*`,
131+`a_444_lossless_sb64_intrabc_rect_chroma_walks_4x4_units`,
132+`a_real_aomenc_lossless_444_key_frame_decodes_sample_exact`), the intrabc_rect
133+family (`a_444_intrabc_owned_rect_*`, `a_444_intrabc_rect4_*`), and the 4:2:0
134+twin (`a_444_intrabc_rect_chroma_plane_block_is_the_block_footprint`, which
135+runs its `420_intrabc_rect4_witness.obu` sibling through
136+`decode_all_frames_vs_oracle`).
137+
138+Wider family, once per tree, same filter string, same env, private
139+`CARGO_TARGET_DIR`:
140+
141+```
142+$ cargo test -p ec-av1 --lib -- rect intrabc ibc chroma 444 420 subsampl
143+base 70ed5601 (clean, detached) ok. 145 passed; 0 failed; 5 ignored; 0 measured; 623 filtered out; finished in 272.43s
144+this branch tip ok. 147 passed; 0 failed; 5 ignored; 0 measured; 623 filtered out; finished in 273.28s
145+```
146+
147+145 -> 147: the delta is exactly this lane's two new gates and nothing else
148+(`--list` reads 775 tests on both trees). Same 5 `#[ignore]`d in both. **No
149+test was renamed, dropped or `#[ignore]`d.** **No floor was lowered anywhere**; the only new asserts are the two
150+gates of §5.
151+
152+## 5. Class sweep — and the 2x1 / 1x2 cell was broken
153+
154+Every site in the crate that walks a 4:4:4 chroma plane block as a grid of
155+`Chroma32` units, and what it hands each unit:
156+
157+| # | site | grid reachable at 4:4:4 | per-unit **window** | per-unit **reach** |
158+| --- | --- | --- | --- | --- |
159+| 1 | `decode_block` skip arm (decode.rs:21897) | 2x2 (NxN) | `chroma_window` — fixed by `e05a6ceb` | `tu_reach_rect` ✓ |
160+| 2 | `decode_block` coded arm (decode.rs:22182) | 2x2 (NxN) | `palette_window` ✓ | `tu_reach_rect` ✓ |
161+| 3 | `decode_rect_split` `chroma_tiled` (decode.rs:12721) | **2x1, 1x2, and 2x2** | `palette_window` ✓ | **block `reach` — WRONG** |
162+
163+Site 3 is the only one that can produce a **2x1 or 1x2** grid at all, and it
164+was the only one passing the block's `reach` to every unit. Sites 1 and 2 can
165+never be 2x1/1x2: a square luma block's chroma plane block has
166+`chroma_side == chroma_height` at every supported subsampling (4:2:0 → `>>1,>>1`;
167+4:4:4 → identity; 4:2:2 is the only asymmetric one and is refused by name at
168+the sequence header, `stream.rs:1783`), and `chroma_tx == chroma_tx_h`, so
169+`cn_cols == cn_rows` always. A 2x1/1x2 needs a rect luma block, i.e. site 3.
170+
171+**The defect, measured.** `decode_rect_split`'s `chroma_tiled` walk passed the
172+block-level `reach` to every unit. libaom computes `has_top_right` PER
173+TRANSFORM UNIT — `av1_build_intra_predictors` calls it with the chroma txb
174+walk's own `blk_col`/`blk_row` (defined `reconintra.c:196`, called from
175+`av1_build_intra_predictors` at `reconintra.c:1847`), and the `row_off == 0`
176+arm is `col_off + top_right_count_unit < plane_bw_unit`, so the FIRST unit of a
177+2-wide grid reads its above-right out of the already-reconstructed block ABOVE
178+even when the block's own right edge is the frame's. `PlaneBuf::edges`
179+(`decode.rs:20840`) truncates the above row at `own_across` when
180+`above_right` is false, so a directional unit whose angle is below 90
181+(`need_right`, `intra.rs:546`) predicted from a 32-sample above row where libaom
182+used 64.
183+
184+Witness encoded here (recipe and sha256 in the gate's doc comment):
185+`fixtures/r512_rect2x1_1x2_444.obu`, 2697 B, sha256
186+`a009ec580a1ff24250be53e11b8d09616da71e095cefd5eb621c941d40a8688b` — 4:4:4 8-bit
187+256x256, one key frame, and it reaches BOTH shapes: a 64x32 chroma plane block
188+as `nw=2 nh=1` of 32x32 and a 32x64 one as `nw=1 nh=2`.
189+
190+Red-before, per plane, my own script:
191+
192+```
193+f0: Y 0 wrong U 130 wrong V 30 wrong (of 65536 per plane)
194+```
195+
196+All 160 wrong samples are in the right 6 columns of the `cu=(0,0)` unit at
197+`mi=(48,48)` `px=(192,192)` — a 64x32 block whose right edge IS the frame's.
198+Oracle `EC_PRED` for that unit vs ours:
199+
200+```
201+oracle EC_PRED mi_row=48 mi_col=48 plane=1 row_off=0 col_off=0 txw=32 txh=32
202+ mode=1 p_angle=84 have_top=1 have_left=1 n_top=32 n_left=32
203+ n_tr=32 n_bl=-1 bsize=11 part=1 ft=1
204+oracle EC_PREDOUT8 ... sum=172662 row0=179,185,190,195,197,198,197,194 col0=179,180,181,181,182,182,183,183
205+ours OUR_PRED x=192 y=192 plane=1 side=32 mode=1 ad=-2 ft=1
206+ sum=171512 row0=[179,185,190,195,197,198,197,194] col0=[179,180,181,181,182,182,183,183]
207+```
208+
209+`bsize=11` is `BLOCK_64X32`; `n_tr=32` against our `above_right = false` is the
210+whole defect in one number. `row0` and `col0` match exactly and only the SUM
211+differs (172662 vs 171512, and 125978 vs 126008 on V), so the divergence is
212+prediction-side, not entropy. Stage-attributed against the oracle's own rungs:
213+the same 130/30 wrong appear in `EC_AV1_PREFILT_DUMP` and in
214+`EC_AV1_FINAL_DUMP` — pre-loop-filter, so not deblock/CDEF/LR. `n_tr=32` also
215+explains the shape of the error: the U delta per column is
216+-1, -5, -9, -14, -18, -19, growing monotonically rightward, which is a
217+directional prediction reaching further right as it goes.
218+
219+**The fix.** One expression, both unit readers in the walk (the square
220+`read_plane` and the rect `push_intra_rect`), each given the unit's own reach:
221+
222+```rust
223+let cu_reach = tu_reach_rect(
224+ bw, bh,
225+ (cu_col * uw) << ss_x(fctx),
226+ (cu_row * uh) << ss_y(fctx),
227+ uw << ss_x(fctx), uh << ss_y(fctx),
228+ reach, px, py, y.width, y.height, fctx,
229+);
230+```
231+
232+`tu_reach_rect` is the crate's existing port of the per-unit rule (it is what
233+sites 1 and 2 already call), so this is site 3 joining the other two, not a new
234+rule. `cu_reach` is also what `of_tu` needs at 4:4:4: the ss shifts are
235+identity there and the per-axis spelling is what makes the same call correct at
236+4:2:0 and at 4:2:2 if 4:2:2 is ever ported.
237+
238+**After: 0 wrong on all three planes.** Every region the sweep covers.
239+
240+**Gates** (both aomdec-oracle, no silent skip, both with the counters asserted
241+before a single sample is compared):
242+
243+* `a_444_rect_strip_chroma_tiled_2x1_and_1x2_units_take_their_own_above_right_reach`
244+ — asserts `>= 4` units in a 2x1 grid AND `>= 4` in a 1x2 grid, and
245+ `>= 1` unit whose per-unit reach differs from the block's, then full
246+ byte-exactness of all three planes of frame 0. Pin
247+ `fixtures/r512_rect2x1_1x2_444.obu`, fnv1a64 `0x2751ccaa079cc422`, sha256
248+ `a009ec58…`, recipe in the doc comment.
249+* `a_444_rect_strip_chroma_tiled_1x2_palette_grid_decodes_byte_exact`
250+ — the **UV-palette cell that `lanes/av1chromadc.report.md` §5 left explicitly
251+ unmeasured** ("every multi-unit walk on this witness is `src=intrabc`; the
252+ UV-palette source never reaches a multi-unit chroma walk here, so its arm of
253+ the sweep is argued from the shared code path, not witnessed"). Pin
254+ `fixtures/r512_rect1x2_444_palette.obu`, fnv1a64 `0x7759753a0d3f75a2`,
255+ sha256 `fad03c69…` — it puts a UV-palette block on a 1x2 16x64 chroma grid at
256+ `mi=(32,12)` (measured with a throwaway probe, since removed) as well as
257+ non-palette ones.
258+
259+**Mutation proofs, each reverted:**
260+
261+| # | mutation | result |
262+| --- | --- | --- |
263+| M1 | both unit readers back to the block `reach` (the pre-fix shape) | **RED** — `frame 0 plane U … first divergence at sample 49374 (x=222, y=192), 130 samples wrong` |
264+| M2 | `cu_col`/`cu_row` transposed in the `tu_reach_rect` offsets | **GREEN — and this is a real limit of the gate, not a pass** |
265+
266+M2 is worth stating plainly. On this witness the second/bottom unit of each
267+grid sits flush against the frame's right/bottom edge, so
268+`Reach`'s `.min(self.width)` clamp in `edges`/`edges_rect` truncates the extra
269+reach back to nothing and the transposition becomes unobservable. The
270+transposed expression is still wrong, and no witness in this lane distinguishes
271+it. A gate that claimed to cover it would be a false claim, so neither gate
272+does: they pin the reach VALUE (M1 bites), not the offset spelling.
273+
274+## 6. The other multi-unit `set_palette_pred` sites, for the record
275+
276+All 19 `set_palette_pred` call sites were enumerated and each classified by its
277+enclosing loop. Every one is either already windowed per unit
278+(`palette_window` at decode.rs:12633, 12784, 16685, 16955; `chroma_window` at
279+21953/21975) or is a genuinely single-unit read where the whole buffer IS the
280+unit's window (`decode_block_rect` 15378/15396/15559/15607 and
281+`decode_leaf_rect` 15996/16014/16175/16220 read `chroma_w x chroma_h` once per
282+plane; `decode_block_rect4` 16825/16859 loops over PLANES of a 4x4 block, not
283+units). One site is unwindowed inside a unit loop —
284+`decode_rect_split` 12525, the `(4,8)` chroma units of a 4:2:2 `BLOCK_INVALID`
285+plane — and it is unreachable: `chroma_422_oob` and `chroma_422_pair_wide` both
286+require `ss_x == 1 && ss_y == 0`, i.e. the 4:2:2 that `stream.rs:1783` refuses
287+by name.
288+
289+## 7. Not done
290+
291+1. **The 2x1/1x2 offset spelling is unproven** (M2, §5). Closing it needs a
292+ witness whose 2x1/1x2 unit is NOT against a frame edge — a wider frame, or
293+ `--sb-size=128` with a 64x64 mu chunk boundary, where `of_tu`'s `wide`
294+ branch (`col_off % 64`) becomes reachable. Not encoded here.
295+2. **`decode_rect_split`'s 2x2 / `NxN` cell is unreachable**, so
296+ `RECT_TILED_CHROMA_NXN_HITS` is 0 on every admitted stream. It is kept so
297+ the `match` over grid shapes is exhaustive rather than silently
298+ default-shaped; it is not a coverage claim.
299+3. **The 4:2:2 `(4,8)` unwindowed site (decode.rs:12525) is argued unreachable,
300+ not proven so** — the argument is the sequence header's named refusal, and I
301+ did not run a 4:2:2 stream through the refusal to watch it fire on this
302+ branch.
303+4. **No 4:2:2 stream was encoded**, so nothing here re-verifies the
304+ `EC_AV1_ALLOW_422_PROBE` bypass or any 4:2:2 arm.
305+5. **The 4:4:4-LOSSY 2x2 cell of site 1 and site 2** (i.e. a skipped 64x64
306+ intra-BC block with a residual rather than pure prediction) is not
307+ distinguished from the skip cell by any pin here; `r512.obu`'s two
308+ multi-unit blocks are both `skip=1`.
309+6. **No server run.** Everything above is local: one gate at a time plus two
310+ ~250 s wide-family runs. Per the project's standing rule the full suite
311+ belongs on the fleet; I did not request or consume a fleet slot.