From 4e9b0089af414a2f2337f6f08ba8e4c49cb550be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Tue, 29 Sep 2026 16:11:58 +0300 Subject: [PATCH] lanes/av1txsizeaudit r5: re-rebase onto ec4e9528, declare provenance of the foreign work PROVENANCE, declared before wave 3e rather than at merge time. This branch carries TWO lanes' work, not one. lane-av1txsizeaudit (this lane): the tx-size audit, the C1 fix + source-scan gate, the av1tilerows retraction. lane-av1ibc128arm, commit 4bfe8d8e "av1: 4:4:4 intra-in-inter 128-root mu-chunk chroma as a per-unit walk": 279 lines of decode.rs, 192 of stream.rs, 5 of examples/decode_probe.rs, 196 of lanes/av1ibc128arm.report.md -- and it has NEVER been merged to main. Three checks against main: git merge-base --is-ancestor 4bfe8d8e main -> NO git grep -c 'a_real_aomenc_444_intra_in_inter_128_root_codes_chroma_per_mu_chunk' main -- crates/ec-av1/src/stream.rs -> 0 git grep -n 'luma_span = cu_tx * 2' main -- crates/ec-av1/src/decode.rs -> main:...:43185 That last line is the proof of non-merge rather than a re-implementation: main still carries the collapsed 4:2:0 arm verbatim -- `let luma_span = cu_tx * 2;` -- which is exactly the line 4bfe8d8e deletes, and the string appears 0 times on this branch. `git log --all -S"luma_span = cu_tx * 2"` finds only the two lanes that CREATED the class (2050a065 lane-av1-ibc128chunk, 29550383 lane-av1-422bigblock) and the commit that removed it. `git grep -ln "intra_in_inter_128_root" main -- lanes/` returns nothing, and `git cat-file -e main:lanes/av1ibc128arm.report.md` fails -- so no other lane's report claims it. Branch lane-av1ibc128arm still exists at 4bfe8d8e, so this is not an orphan. THE TWO FOREIGN REPORT FILES, individually: - lanes/av1ibc128arm.report.md (+196): deliberately KEPT, and it belongs to lane-av1ibc128arm, not to this lane. It is the only provenance record for the 279-line decode.rs change and the 4:4:4 gate. Not cherry-pick residue: it arrived with 4bfe8d8e whole. MERGE OWNER: if lane-av1ibc128arm is also merged, take code+report from whichever lands first and drop the duplicate; if it is not merged separately, this branch must carry it, because there is no other copy. - lanes/av1tilerows.report.md (38 changed): MINE and deliberate. The retraction of the `cu_tx = 32 << ss_x` rule at that report's own origin (lines 265-281, the section 8 "Recommendation") -- the one committed instance of the refuted rule in the repo. Zero code, zero gate. It must land whenever this branch lands or the rule stays re-derivable. CONTENTION HANDED OVER, NOT PRE-RESOLVED: decode_intrabc_owned_rect's `let (cw, ch) = (bw / 2, bh / 2);` -- the open cell this report lists at 2.3 and 5.0, line 16832 on this base -- is being fixed by another lane now. This branch does not touch that line; it appears here only as a finding. Resolve at merge there, where the witness lives. RE-REBASE, and a second patch-base trap in the same family as r4's: r4 nearly dropped the unmerged fix commit by patching from "my base"; r5 nearly swept in all of main's wave-3 changes by patching from "the old main" 9b2f6c9d, which produced an 18041-line patch touching crates/ec-aac and binary fixtures. THE RULE, both times: the patch's left-hand side must be the commit this branch's base actually is (git merge-base HEAD main) -- never a remembered ancestor, never a self-describing "my base". Verify with `git apply --stat` BEFORE applying; the wrong base names files you have never touched and is invisible in --3way's exit status. Correct patch: git diff 08f8ffb3 99f25b1f, 1894 lines, 7 files. Applied onto ec4e9528: git diff ec4e9528 --shortstat -> 7 files, 1671 insertions(+), 103 deletions(-) identical in shape to the pre-rebase measurement, with per-file removed-line counts unchanged (decode.rs 97, av1tilerows 6, rest 0). Main's move touched NOTHING under crates/ec-av1/, so decode.rs is 56316 lines with suppress_internal_lf_edges at 9277 and C2 at 43315 -- report section 5.0's line-shift table is valid verbatim on this base, no adjustment. Silent-restore check against this move: 0/0/0. Re-run after touch: cargo check --all-targets clean; the new source-scan gate 1/1; gate_coverage 13/13; refusal_inventory 20/20; the 13-gate identity set 13/13. 47 tests, 0 failures, 4:4:4 gate present and green. --- crates/ec-av1/examples/decode_probe.rs | 5 + crates/ec-av1/src/decode.rs | 305 ++++--- crates/ec-av1/src/refusal_inventory.rs | 66 ++ crates/ec-av1/src/stream.rs | 192 +++++ lanes/av1ibc128arm.report.md | 196 +++++ lanes/av1tilerows.report.md | 38 +- lanes/av1txsizeaudit.report.md | 1097 ++++++++++++++++++++++++ 7 files changed, 1796 insertions(+), 103 deletions(-) create mode 100644 lanes/av1ibc128arm.report.md create mode 100644 lanes/av1txsizeaudit.report.md diff --git a/crates/ec-av1/examples/decode_probe.rs b/crates/ec-av1/examples/decode_probe.rs index d2a79cb0..f2a0ebf5 100644 --- a/crates/ec-av1/examples/decode_probe.rs +++ b/crates/ec-av1/examples/decode_probe.rs @@ -36,6 +36,11 @@ fn main() { } let (sc, dp) = ec_av1::decode::reelc_chroma_counters(); println!("reelc_chroma: skip_cfl={sc} dir_1to4_pairs={dp}"); + println!( + "ibc128: mu_chroma={} intra128={}", + ec_av1::decode::intra_128_in_inter_mu_chroma_hits(), + ec_av1::decode::intra_128_in_inter_hits() + ); println!( "chroma422_square: {}", ec_av1::decode::chroma422_square_hits() diff --git a/crates/ec-av1/src/decode.rs b/crates/ec-av1/src/decode.rs index 906d4623..08559c9f 100644 --- a/crates/ec-av1/src/decode.rs +++ b/crates/ec-av1/src/decode.rs @@ -5559,6 +5559,23 @@ pub fn intra_128_in_inter_hits() -> usize { INTRA_128_IN_INTER_HITS.with(std::cell::Cell::get) } +thread_local! { + /// lane-av1ibc128arm: how many 64x64 mu-chunk CHROMA units the + /// intra-in-inter 128x128 root read (`decode_inter_block`'s + /// `side > 64` mu-chunk arm, the INTRA half of the inter pair). Every + /// unit is one `read_plane` on U and one on V, so the counter is the + /// gate's proof the arm ran at all -- no committed 4:4:4 fixture + /// reached it before this lane. + pub(crate) static INTRA_128_IN_INTER_MU_CHROMA_HITS: std::cell::Cell = + const { std::cell::Cell::new(0) }; +} + +/// Current value of [`INTRA_128_IN_INTER_MU_CHROMA_HITS`], for a gate's +/// before/after delta. +pub fn intra_128_in_inter_mu_chroma_hits() -> usize { + INTRA_128_IN_INTER_MU_CHROMA_HITS.with(std::cell::Cell::get) +} + thread_local! { static INTER_SB_NONE_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; @@ -9227,13 +9244,39 @@ impl Neighbours { /// `curr_skipped = mbmi->skip_txfm && is_inter_block(mbmi)`. Widening this /// block's published transform extent to its own size is exactly that /// suppression for the deblocker's `x0 % tx != 0` test -- the only shape - /// that needs it is the 128 root, whose chroma extent (64) is the one + /// that needs it is the 128 root, whose chroma extent is the one /// [`Self::fill_lf_grid_rect`]'s TX_32X32 cap narrows. An INTRA block is /// never suppressed (libaom's `is_inter_block` term), so this is called /// only from the skipped-inter branch. - fn suppress_internal_lf_edges(&mut self, at_mi: (usize, usize), w_mi: usize, h_mi: usize) { + /// + /// The extent is the block's own CHROMA footprint, `w_mi * MI >> ss_x` per + /// axis -- `av1_setup_dst_planes`'s `get_plane_block_size(bsize, ss_x, + /// ss_y)` (`common_data.c:38`, which at ss (0,0) is BLOCK_128X128 + /// itself, so 128 and not 64). This used to be a hardcoded `w_mi * MI / 2`, + /// correct at 4:2:0 by the `>> 1 == / 2` identity and half the truth at + /// 4:4:4; lane-av1txsizeaudit r2 replaced it with the per-axis shift, the + /// form its sibling `fill_lf_grid_rect` already used. The `fctx` is + /// threaded in for it: `Neighbours` carries no subsampling of its own, so + /// no format guard was possible inside this method until now. + /// + /// **MEASURED INERT, and do not go looking for a pixel regression.** The + /// widening defeats the deblocker's alignment gate (`x0 & (tx - 1)`), but + /// every edge it lets through then meets the SAME libaom rule applied at + /// the correct place, `edge_params_body`'s spec-7.14.2 / libaom + /// `set_lpf_parameters` term `!pu_edge && cur_ref != 0 && pv_ref != 0 && + /// skip_at && skip_at`. Inside one skipped block both cells are that same + /// block, so all four terms hold and the edge dies there too. The masking + /// is TOTAL, not incidental: this method is only ever called for a block + /// that is itself skipped, so no input exists on which one side of an + /// internal edge is not skipped. Measured over 26 frames / 2 555 904 + /// samples across five 4:4:4 `--sb-size=128` streams that fire this arm + /// 30 times: `64` and `128` both decode pixel-exact against aomdec, and + /// differ from each other in not one sample. The gate for this value is + /// therefore a source scan, not a pixel gate -- + /// `refusal_inventory::the_skipped_128_root_chroma_suppression_publishes_the_blocks_own_per_axis_chroma_extent`. + fn suppress_internal_lf_edges(&mut self, at_mi: (usize, usize), w_mi: usize, h_mi: usize, fctx: &FrameCtx) { let (mi_r, mi_c) = at_mi; - let (uv_w, uv_h) = ((w_mi * MI / 2).max(4) as u8, (h_mi * MI / 2).max(4) as u8); + let (uv_w, uv_h) = (((w_mi * MI) >> ss_x(fctx)).max(4) as u8, ((h_mi * MI) >> ss_y(fctx)).max(4) as u8); for rr in 0..h_mi { let start = (mi_r + rr) * self.skip_grid_cols_mi + mi_c; fill_span(&mut self.uv_tx_grid, start, w_mi, uv_w); @@ -43178,30 +43221,51 @@ fn decode_inter_block( continue; } let (cr, cc) = chunk; - // `av1_get_max_uv_txsize(BLOCK_128X128)` = - // `av1_get_adjusted_tx_size(TX_64X64)` = TX_32X32. + hit!(INTRA_128_IN_INTER_MU_CHROMA_HITS); + // The unit's CHROMA size, its LUMA footprint, the + // CHUNK's chroma extent and the unit's ORIGIN inside the + // chunk are four different quantities; this arm had the + // last three as one 4:2:0 literal and read ONE unit per + // mu chunk at every subsampling. + // + // `cu_tx` is TX_32X32 at EVERY subsampling. + // `av1_get_max_uv_txsize` (blockd.h:1371) is + // `av1_get_adjusted_tx_size(max_txsize_rect_lookup[ + // get_plane_block_size(bsize, ss_x, ss_y)])`, and + // `av1_get_adjusted_tx_size` (blockd.h:1361) takes NO + // subsampling argument: it maps TX_64X64 / TX_64X32 / + // TX_32X64 to TX_32X32 UNCONDITIONALLY, so even at ss (0,0) + // (where `get_plane_block_size` returns BLOCK_128X128 and + // the lookup entry is TX_64X64) the answer is TX_32X32. let cu_tx = 32usize; - let luma_span = cu_tx * 2; - let cu_mi = (at_mi.0 + cr * 16, at_mi.1 + cc * 16); - let cu_around = neighbours.around_mi(cu_mi, luma_span); - let (cu_x, cu_y) = (cpx + cc * cu_tx, cpy + cr * cu_tx); - let cu_reach = crate::decode::tu_reach( - side, - side, - cc * luma_span, - cr * luma_span, - luma_span, - reach, - px, - py, - y.width, - y.height, - fctx, - ); + // The unit's own footprint on the LUMA grid, per axis + // (`cu_tx << ss`): 64 luma px (16 mi) at 4:2:0, 32 luma px + // (8 mi) at 4:4:4. This is the ss-aware form the repaired + // siblings at decode.rs:17598 / 17685 use (`ox << + // ss_x(fctx)`, never `ox * 2`), and it is the size + // `around_mi` / `record_mi_chroma` want. + let unit_luma_w = cu_tx << ss_x(fctx); + let unit_luma_h = cu_tx << ss_y(fctx); + // The CHUNK's own extent, per axis: a mu chunk is a + // 64x64 LUMA region at every subsampling, so on the luma + // grid this is a literal 64, and its CHROMA plane block is + // `64 >> ss` square. At 4:2:0 that is 32x32 = the one unit + // this arm always coded; at 4:4:4 it is 64x64 = FOUR + // TX_32X32 units. Measured on the gate's own 4:4:4 stream + // against the oracle's `EC_TRACE_COEFF`: every chroma read + // of a 128x128 intra-in-inter root is `tx_size=3` + // (TX_32X32), and each 64x64 mu chunk contributes FOUR per + // plane at (row,col) (0,0) (0,8) (8,0) (8,8) -- never a + // TX_64X64 chroma unit. + let chunk_luma = 64usize; + let chunk_chroma_w = chunk_luma >> ss_x(fctx); + let chunk_chroma_h = chunk_luma >> ss_y(fctx); + let units_w = chunk_chroma_w / cu_tx; + let units_h = chunk_chroma_h / cu_tx; let cu_scan = default_scan(cu_tx); if lossless(fctx) { - // lane-lossless2: 8x8 TX_4X4 units per plane in this - // chunk, not one TX_32X32 unit. + // lane-lossless2: TX_4x4 units over this chunk's + // chroma, not TX_32X32 ones. read_intra_chroma_lossless( dec, cdfs, @@ -43213,8 +43277,8 @@ fn decode_inter_block( (cpx, cpy), side, (chroma_side, chroma_side), - (cc * cu_tx, cr * cu_tx), - (cu_tx, cu_tx), + (cc * chunk_chroma_w, cr * chunk_chroma_h), + (chunk_chroma_w, chunk_chroma_h), chroma_side, reach, (y.width, y.height), @@ -43231,79 +43295,126 @@ fn decode_inter_block( mu_chroma = true; continue; } + // Plane-major per chunk (libaom's plane loop is outermost + // inside the mu walk); within a plane the units walk raster. for plane_idx in 1..3 { let buf: &mut PlaneBuf<'static> = if plane_idx == 1 { &mut *u } else { &mut *v }; - let cu_grid = if skip { - push_intra( - plane_idx, - cu_x, - cu_y, - cu_tx, - uv_predict_mode, - angle_delta_uv, - cu_reach, - &ZERO_RESIDUAL[..cu_tx * cu_tx], - None, - None, - smooth_neighbor_uv, - fctx, - ); - Grid::Zero(cu_tx * cu_tx) - } else { - read_plane( - dec, - cdfs, - chroma_set, - &cu_scan, - plane_idx, - cu_around[plane_idx], - mode, - uv_predict_mode, - angle_delta_uv, - cu_reach, - buf, - cu_x, - cu_y, - cu_tx, - cu_tx, - base_q_idx, - // CfL is refused above 32x32 - // (`is_cfl_allowed`), so never here. - None, - None, - // The uv plane block (64x64) is larger than - // the unit (32x32): `get_txb_ctx`'s offset-10 - // rows, +3 on the `txb_skip_chroma_32` table - // (lane-sb128b r3). - Some(3), - smooth_neighbor_uv, - fctx, - )? - }; - // Immediately, so the NEXT chunk's unit reads this - // one's coefficient context. - neighbours - .record_mi_chroma(cu_mi, luma_span, luma_span, plane_idx, &cu_grid); - hit!(CHROMA_SPLIT_TX_HITS); - // lane-dpm1: the two INTER mu-chunk sites set this and this - // INTRA-in-inter one did not, so the whole-block chroma - // record below re-stamped all four 32x32 units with the - // TOP-LEFT unit's level and the next block read a txb_skip - // row libaom never selects (class `override-slot-on-one-arm`). - mu_chroma = true; - let dst = mu_units( - if plane_idx == 1 { - &mut u_units - } else { - &mut v_units - }, - chroma_side * chroma_side, - ); - for rr in 0..cu_tx { - let start = (cr * cu_tx + rr) * chroma_side + cc * cu_tx; - dst[start..start + cu_tx] - .copy_from_slice(&cu_grid[rr * cu_tx..][..cu_tx]); + for ur in 0..units_h { + for uc in 0..units_w { + // The unit's own mi origin: the chunk's + // (16x16 mi) plus the unit's offset inside it. + let unit_mi = ( + at_mi.0 + cr * 16 + ur * (unit_luma_h / MI), + at_mi.1 + cc * 16 + uc * (unit_luma_w / MI), + ); + // The unit's own entropy-cell span, so the + // NEXT unit of this chunk reads THIS one's + // state and the next chunk reads the last. + let cu_around = neighbours.around_mi(unit_mi, unit_luma_w); + let (cu_x, cu_y) = ( + cpx + cc * chunk_chroma_w + uc * cu_tx, + cpy + cr * chunk_chroma_h + ur * cu_tx, + ); + let cu_reach = crate::decode::tu_reach( + side, + side, + cc * chunk_luma + uc * unit_luma_w, + cr * chunk_luma + ur * unit_luma_h, + unit_luma_w, + reach, + px, + py, + y.width, + y.height, + fctx, + ); + let cu_grid = if skip { + push_intra( + plane_idx, + cu_x, + cu_y, + cu_tx, + uv_predict_mode, + angle_delta_uv, + cu_reach, + &ZERO_RESIDUAL[..cu_tx * cu_tx], + None, + None, + smooth_neighbor_uv, + fctx, + ); + Grid::Zero(cu_tx * cu_tx) + } else { + read_plane( + dec, + cdfs, + chroma_set, + &cu_scan, + plane_idx, + cu_around[plane_idx], + mode, + uv_predict_mode, + angle_delta_uv, + cu_reach, + buf, + cu_x, + cu_y, + cu_tx, + cu_tx, + base_q_idx, + // CfL is refused above 32x32 + // (`is_cfl_allowed`), so never here. + None, + None, + // The uv plane block is larger than + // the unit: `get_txb_ctx`'s offset-10 + // rows, +3 on the `txb_skip_chroma_32` + // table (lane-sb128b r3). + Some(3), + smooth_neighbor_uv, + fctx, + )? + }; + // Immediately, so the NEXT unit reads this + // one's coefficient context. + neighbours.record_mi_chroma( + unit_mi, + unit_luma_w, + unit_luma_h, + plane_idx, + &cu_grid, + ); + hit!(CHROMA_SPLIT_TX_HITS); + // lane-dpm1: the two INTER mu-chunk sites set + // this and this INTRA-in-inter one did not, so + // the whole-block chroma record below re-stamped + // all four 32x32 units with the TOP-LEFT unit's + // level and the next block read a txb_skip row + // libaom never selects (class + // `override-slot-on-one-arm`). + mu_chroma = true; + let dst = mu_units( + if plane_idx == 1 { + &mut u_units + } else { + &mut v_units + }, + chroma_side * chroma_side, + ); + // The ASSEMBLED grid stays at the square + // `chroma_side` stride the block tail's + // re-stamp indexes; the unit's true per-axis + // position inside its chunk is what changes. + for rr in 0..cu_tx { + let start = (cr * chunk_chroma_h + ur * cu_tx + rr) + * chroma_side + + cc * chunk_chroma_w + + uc * cu_tx; + dst[start..start + cu_tx] + .copy_from_slice(&cu_grid[rr * cu_tx..][..cu_tx]); + } + } } } } @@ -44182,7 +44293,7 @@ fn decode_inter_block( // way; only the 128 root gets four TX_64X64 leaves regardless of `skip`. let skip_inter_128 = skip && is_inter && write_w.max(write_h) > 64; if skip_inter_128 { - neighbours.suppress_internal_lf_edges((rmi, cmi), write_w / MI, write_h / MI); + neighbours.suppress_internal_lf_edges((rmi, cmi), write_w / MI, write_h / MI, fctx); } if let Some(leaves) = (!skip_inter_128).then_some(()).and(vartx_leaves.as_ref()) { for &(row, col, tw, th) in leaves { diff --git a/crates/ec-av1/src/refusal_inventory.rs b/crates/ec-av1/src/refusal_inventory.rs index 4662529b..ec69cc57 100644 --- a/crates/ec-av1/src/refusal_inventory.rs +++ b/crates/ec-av1/src/refusal_inventory.rs @@ -1826,6 +1826,72 @@ mod tests { ); } + /// lane-av1txsizeaudit r2 -- the one value in `ec-av1` whose correct form + /// is provable against libaom but whose *observable effect* is nil, so a + /// pixel gate is impossible and this source scan is the only instrument + /// that can catch a regression. + /// + /// `decode.rs`'s `suppress_internal_lf_edges` publishes the skipped 128 + /// root's own chroma extent into `uv_tx_grid`, so the deblocker's + /// alignment gate (`x0 & (tx - 1)`) sees no internal transform edge. The + /// correct extent is the block's own CHROMA footprint, + /// `w_mi * MI >> ss_x` per axis -- `av1_setup_dst_planes`'s + /// `get_plane_block_size(bsize, ss_x, ss_y)`, which at ss (0,0) is the + /// block itself, so **128 and not 64** for a 128x128 root at 4:4:4. The + /// site carried a hardcoded `w_mi * MI / 2`, which is right at 4:2:0 by + /// the `>> 1 == / 2` identity and half the truth everywhere else; its + /// sibling `fill_lf_grid_rect` had already been repaired to + /// `(w_mi * MI) >> ss_x(fctx)`. + /// + /// **No pixel gate can exist for this, and that is measured, not assumed.** + /// The widening defeats the alignment gate, but every edge it lets + /// through then meets the SAME libaom rule applied at the correct place -- + /// `edge_params_body`'s spec-7.14.2 / `set_lpf_parameters` term + /// `!pu_edge && cur_ref != 0 && pv_ref != 0 && skip_at && skip_at`, which + /// holds for every internal edge because both cells are the same skipped + /// block. Over 26 frames / 2 555 904 samples of five 4:4:4 + /// `--sb-size=128` streams that fire the arm 30 times, `64` and `128` both + /// decode pixel-exact against `aomdec` and differ from each other in not + /// one sample. The masking is TOTAL: the method is only ever called for a + /// block that is itself skipped, so no input exists on which one side of + /// an internal edge is not skipped. Hence: source scan, not pixels. + /// + /// This also pins the `fctx` threading, because `Neighbours` carries no + /// subsampling of its own -- a sibling lane reached the same site and + /// recorded it as unfixable for exactly that reason. + #[test] + fn the_skipped_128_root_chroma_suppression_publishes_the_blocks_own_per_axis_chroma_extent() { + let src = include_str!("decode.rs"); + let start = src + .find("fn suppress_internal_lf_edges(") + .expect("suppress_internal_lf_edges is gone"); + let body_start = start + src[start..].find('{').expect("no body"); + let body = &src[body_start..body_start + src[body_start..].find("\n }").expect("no end")]; + + assert!( + body.contains("((w_mi * MI) >> ss_x(fctx))") && body.contains("((h_mi * MI) >> ss_y(fctx))"), + "suppress_internal_lf_edges must publish the block's own chroma extent per axis \ + -- `w_mi * MI >> ss_x(fctx)`, not a hardcoded `/2`" + ); + for stale in ["w_mi * MI / 2", "h_mi * MI / 2"] { + assert!( + !body.contains(stale), + "suppress_internal_lf_edges grew `{stale}` again: correct at 4:2:0 by the \ + `>> 1 == / 2` identity, half the truth at 4:4:4" + ); + } + // The subsampling is not reachable from `self` -- `Neighbours` has no + // `fctx` field -- so the per-axis shift needs a threaded parameter. + // Without this the body cannot compile, which is how a future edit + // would try to reintroduce a literal. + let sig_end = src[start..body_start].to_string(); + assert!( + sig_end.contains("fctx: &FrameCtx"), + "suppress_internal_lf_edges takes no fctx, so the per-axis shift has nothing to read \ + -- `Neighbours` carries no subsampling of its own; thread the frame context in" + ); + } + /// lane-av1-refusalaudit, ENUMERATION for "a 64-axis strip whose chroma /// unit has no coefficient table" -- [`decode_block_rect64`]'s `_` arm, /// reached only for depth-0, non-skip, non-lossless superblock-level diff --git a/crates/ec-av1/src/stream.rs b/crates/ec-av1/src/stream.rs index 8f4b2cc7..c3686299 100644 --- a/crates/ec-av1/src/stream.rs +++ b/crates/ec-av1/src/stream.rs @@ -37484,6 +37484,198 @@ pub(crate) mod tests { ); } + /// lane-av1ibc128arm: the INTRA-in-inter 128x128 root's mu-chunk chroma + /// arm (`decode_inter_block`'s `side > 64` arm, the intra half of the + /// inter pair the sibling gate above names) must code the mu chunk's + /// chroma as a PER-UNIT walk at every subsampling, and at 4:4:4 each + /// 64x64 mu chunk is FOUR TX_32X32 units per plane, not one. + /// + /// **The defect.** The arm hardcoded `cu_tx = 32`, `luma_span = cu_tx * + /// 2` and the chroma origin `cc * cu_tx` -- the 4:2:0 arithmetic, where a + /// mu chunk's chroma plane block is `64 >> 1 == 32` square and the whole + /// chunk IS one TX_32X32 unit. At 4:4:4 the chunk's chroma is 64x64, so + /// the arm (a) read one 32x32 unit where libaom codes four, (b) stamped + /// the unit's entropy context over the 4:2:0 64x64 luma span rather than + /// the unit's own 32x32, and (c) placed chunk 1's unit at `cpx + 32` + /// instead of `cpx + 64`, i.e. back inside chunk 0's samples. + /// + /// **`av1_get_max_uv_txsize` is NOT the source of a 64x64 chroma unit.** + /// `blockd.h:1371` is `av1_get_adjusted_tx_size(max_txsize_rect_lookup[ + /// get_plane_block_size(bsize, ss_x, ss_y)])`, and `av1_get_adjusted_tx_size` + /// (`blockd.h:1361`) takes NO subsampling argument -- it maps TX_64X64 / + /// TX_64X32 / TX_32X64 to TX_32X32 UNCONDITIONALLY, so even at ss (0,0) + /// (where `get_plane_block_size` returns BLOCK_128X128 and the lookup + /// entry is TX_64X64) the answer is TX_32X32. Measured on this gate's own + /// stream against the oracle's `EC_TRACE_COEFF`: every chroma read of the + /// 128x128 intra-in-inter root is `tx_size=3` (TX_32X32), four per plane + /// per mu chunk at (row,col) (0,0) (0,8) (8,0) (8,8). + /// + /// **The recipe** (128x256, 3 frames). `--sb-size=128` with + /// `--min-partition-size=64 --max-partition-size=128` keeps the + /// superblock root resolvable to `PARTITION_NONE`, and the noise-on- + /// gradient content is what makes the encoder's RD pick INTRA over inter + /// for a whole 128 root on an inter frame (a clean `testsrc2` stream + /// never does -- measured over 24 recipe/cell combinations, three of + /// which fired and none of them `testsrc2`): + /// ```text + /// ffmpeg -f lavfi -i "gradients=size=128x256:c0=..:c1=..:c2=..:c3=..:\ + /// seed=63:duration=0.12:rate=25,noise=all_seed=63:alls=6:allf=t" \ + /// -pix_fmt yuv444p -t 0.12 -f yuv4mpegpipe - | \ + /// aomenc --codec=av1 --profile=1 --passes=1 --end-usage=q --cq-level=62 \ + /// --cpu-used=0 --threads=1 --row-mt=0 --sb-size=128 --limit=3 \ + /// --max-partition-size=128 --min-partition-size=64 \ + /// --enable-rect-partitions=0 --enable-ab-partitions=0 \ + /// --enable-1to4-partitions=0 --enable-palette=0 \ + /// --enable-intrabc=0 --deltaq-mode=0 --enable-tx-size-search=0 \ + /// --obu -o out.obu - + /// ``` + /// Both `rate=25` and the frame limit are load-bearing: `gradients`' and + /// `noise`' patterns are time-parameterised, so a different rate or a + /// different `--limit` emits a different stream (and at `--limit=2` this + /// recipe stops choosing the shape at all -- measured, 0 fires). + /// + /// Non-vacuity, three ways: the sequence header is asserted really to be + /// 4:4:4 (`subsampling_x == subsampling_y == 0`) and 128-superblock; + /// `intra_128_in_inter_mu_chroma_hits()` must be non-zero, so the arm + /// really ran; and every decode-order frame is compared byte-for-byte + /// against the oracle by [`decode_all_frames_vs_oracle`], which panics on + /// a refusal or any differing byte. Red before the fix (the ss-aware + /// arithmetic and the per-unit walk reverted, the counter kept): decode- + /// order frame 2 differs in 44649 of 98304 bytes while the counter still + /// reads 4 -- the red is on PIXELS, not on the counter. + #[test] + fn a_real_aomenc_444_intra_in_inter_128_root_codes_chroma_per_mu_chunk_unit_pixel_exact() { + const NAME: &str = + "a_real_aomenc_444_intra_in_inter_128_root_codes_chroma_per_mu_chunk_unit_pixel_exact"; + let _gate_lock = lock_gate_counters(); + if !have_ffmpeg() || !have_aomenc() { + eprintln!("SKIP {NAME}: no ffmpeg/aomenc/aomdec"); + return; + } + let (width, height) = (128usize, 256usize); + let source = format!( + "{},noise=all_seed=63:alls=6:allf=t", + gradients_source(63, width, height, "duration=0.12:rate=25") + ); + let y4m = Command::new("ffmpeg") + .args([ + "-v", + "error", + "-f", + "lavfi", + "-i", + &source, + "-pix_fmt", + "yuv444p", + "-t", + "0.12", + "-f", + "yuv4mpegpipe", + "-", + ]) + .stdin(Stdio::null()) + .stdout(Stdio::piped()) + .stderr(Stdio::piped()) + .output() + .expect("ffmpeg failed to run"); + assert!( + y4m.status.success(), + "{NAME}: ffmpeg fixture: {}", + String::from_utf8_lossy(&y4m.stderr) + ); + let args: Vec<&str> = vec![ + "--codec=av1", + "--profile=1", + "--passes=1", + "--end-usage=q", + "--cq-level=62", + "--cpu-used=0", + "--threads=1", + "--row-mt=0", + "--sb-size=128", + "--limit=3", + "--max-partition-size=128", + "--min-partition-size=64", + "--enable-rect-partitions=0", + "--enable-ab-partitions=0", + "--enable-1to4-partitions=0", + "--enable-palette=0", + "--enable-intrabc=0", + "--deltaq-mode=0", + "--enable-tx-size-search=0", + "--obu", + "-o", + "-", + "-", + ]; + let out = run_with_stdin(Command::new(aomenc_path()).args(&args), &y4m.stdout); + assert!( + out.status.success(), + "{NAME}: aomenc refused the fixture: {}", + String::from_utf8_lossy(&out.stderr) + ); + let stream = out.stdout; + // The gate is only about 4:4:4 at a 128 superblock, so assert the + // parsed sequence header really is that before anything else: a + // stream that silently came back 4:2:0 would leave this arm + // unexercised while every other assert below still passed. + let header = { + let mut parser = ec_av1_syntax::Av1Parser::new(); + let mut pos = 0usize; + while let Ok(obu) = parser.parse_obu(&stream[pos..]) { + pos += obu.total_size; + if pos >= stream.len() { + break; + } + } + parser.sequence_header().map(|q| { + ( + q.use_128x128_superblock, + q.color_config.subsampling_x, + q.color_config.subsampling_y, + q.color_config.mono_chrome, + ) + }) + }; + assert_eq!( + header, + Some((true, 0, 0, false)), + "{NAME}: the encoder did not write a 4:4:4 (ss 0/0, non-mono) 128x128-superblock \ + sequence header -- the flags never arrived, so the arm this gate names is not \ + the one under test" + ); + let before = ( + crate::decode::intra_128_in_inter_hits(), + crate::decode::intra_128_in_inter_mu_chroma_hits(), + ); + let (frames, hidden) = decode_all_frames_vs_oracle(&stream, NAME); + let (roots, units) = ( + crate::decode::intra_128_in_inter_hits() - before.0, + crate::decode::intra_128_in_inter_mu_chroma_hits() - before.1, + ); + assert!( + frames >= 3, + "{NAME}: only {frames} decode-order frames ({hidden} hidden), the recipe asks for 3" + ); + assert!( + roots >= 1, + "{NAME}: no INTRA-coded 128x128 root inside an inter frame -- the recipe stopped \ + exercising the shape this gate names" + ); + // One mu chunk per arm firing, and at 4:4:4 FOUR units per plane per + // chunk (two 64x64 mu chunks per 128 root, two planes each). + assert!( + units >= 4, + "{NAME}: only {units} mu-chunk chroma reads across {roots} intra-in-inter 128 \ + root(s) -- the per-unit walk this gate names never fired (a 4:4:4 64x64 mu chunk \ + is FOUR TX_32X32 units per plane, not one)" + ); + eprintln!( + "{NAME}: {frames} decode-order frames pixel-exact ({hidden} hidden), \ + intra_128_in_inter={roots} mu_chunk_chroma_reads={units}" + ); + } + /// lane-sbpart r2: a real `aomenc` stream whose superblock-level /// partition decision is genuinely HORZ/VERT (not NONE/SPLIT) must /// decode pixel-exact through [`crate::decode::decode_block_rect64`] -- diff --git a/lanes/av1ibc128arm.report.md b/lanes/av1ibc128arm.report.md new file mode 100644 index 00000000..c7209407 --- /dev/null +++ b/lanes/av1ibc128arm.report.md @@ -0,0 +1,196 @@ +# Lane av1ibc128arm: 4:4:4 intra-in-inter 128-root mu-chunk chroma unit walk + +Base: main `a21f3680`. Branch `lane-av1ibc128arm`, worktree +`/home/user/.cache/wt/av1ibc128arm`. Oracle: `~/.cache/aom-oracle/build/{aomenc,aomdec}` +(aom `v3.13.3-7-g9bb526a`). + +## Verdict: the ticket's part (1) is REFUTED by the oracle; parts (2) and the +## per-unit walk are the real defect, and the fix is green + +The ticket said "`cu_tx` must be `32 << ss_x` ... per `blockd.h:1372`, +`av1_get_max_uv_txsize(BLOCK_128X128, 0, 0)` is TX_64X64, so at 4:4:4 `cu_tx` is +64, not 32". **That is wrong for this aom.** `blockd.h:1371` is + +```c +static inline TX_SIZE av1_get_max_uv_txsize(BLOCK_SIZE bsize, int subsampling_x, + int subsampling_y) { + const BLOCK_SIZE plane_bsize = get_plane_block_size(bsize, subsampling_x, subsampling_y); + const TX_SIZE uv_tx = max_txsize_rect_lookup[plane_bsize]; + return av1_get_adjusted_tx_size(uv_tx); +} +``` + +and `av1_get_adjusted_tx_size` (`blockd.h:1361`, read in the oracle tree at +`~/.cache/aom-oracle/src/av1/common/blockd.h:1361`) takes **no subsampling +argument** — it maps `TX_64X64 / TX_64X32 / TX_32X64` to `TX_32X32` +**unconditionally**. So even at ss (0,0), where `get_plane_block_size` returns +`BLOCK_128X128` and `max_txsize_rect_lookup[BLOCK_128X128]` is `TX_64X64`, the +answer is **TX_32X32**. The chroma unit is 32 at every subsampling. + +**Oracle measurement** (`EC_TRACE_COEFF=1 aomdec` on the gate's own 4:4:4 +stream, `h_min_128x256_n3.obu`): every chroma read of the 128x128 +intra-in-inter root is `tx_size=3` (TX_32X32) — four per plane per mu chunk, at +`(row,col) (0,0) (0,8) (8,0) (8,8)`, interleaved plane-major per chunk after +the chunk's single `tx_size=4` (TX_64X64) luma unit. Never a TX_64X64 chroma +unit. The ticket's part (1) would have read a 64x64 transform where libaom +reads four 32x32 ones. + +## The real defect (`decode_inter_block`, the `side > 64` intra-in-inter arm) + +The arm had three 4:2:0 literals standing in for four different quantities: + +| quantity | old (4:2:0 only) | correct | +| --- | --- | --- | +| chroma unit side `cu_tx` | `32` | `32` at every ss (correct already) | +| unit's LUMA span | `luma_span = cu_tx * 2` (64) | `cu_tx << ss_x` → 64 at 4:2:0, **32** at 4:4:4 | +| unit's CHROMA origin | `cpx + cc * cu_tx` | `cpx + cc * (64 >> ss_x)` → **+64** per chunk at 4:4:4 | +| units per mu chunk per plane | 1 | `chunk_chroma / cu_tx` → 1 at 4:2:0, **4** at 4:4:4 | + +At 4:4:4 the old arm therefore (a) read one 32x32 unit where libaom codes four, +(b) stamped the unit's entropy context over the 4:2:0 64x64 luma span instead of +the unit's own 32x32, and (c) placed chunk 1's unit at `cpx + 32` — back inside +chunk 0's samples. + +The fix is the per-unit walk the **inter** sibling already got +(`decode.rs:41347`, `chunk_chroma_w = 64 >> ss_x`, `units_w = chunk_chroma_w / +cu_tx`, `unit_luma_w = cu_tx << ss_x`), applied to the intra arm. The repaired +4x4-chroma siblings at `decode.rs:17598` / `17685` and the block-walk reference +give the same ss-aware form (`ox << ss_x(fctx)`, never `ox * 2`). No third shape +was invented. The lossless sub-arm's `(cc * cu_tx, cr * cu_tx)` / `(cu_tx, cu_tx)` +region args and the `mu_units` write-back offset were generalized the same way +(`chunk_chroma_w/h`), matching the inter arm's lossless sub-arm at 41409. + +## Counter table + +New counter `intra_128_in_inter_mu_chroma_hits()` (one bump per mu-chunk arm +firing), measured on the gate's 128x256 3-frame 4:4:4 stream and on a 256x256 +8-frame 4:4:4 stream, both freshly encoded live: + +| build | 128x256 (1 intra-128 root) | 256x256 (2 intra-128 roots) | +| --- | --- | --- | +| before fix (arm reverted, counter kept) | `mu_chroma=4`, `intra128=1` | `mu_chroma=24`, `intra128=6` | +| after fix | `mu_chroma=4`, `intra128=1` | `mu_chroma=8`, `intra128=2` | + +The counter **fires in both builds** — the red is on pixels, not on the counter. +On the 256x256 witness the pre-fix count is *higher* (24 vs 8) because the +one-unit-per-chunk arm desyncs and the subsequent frames take different paths; +the minimal 128x256 witness is the clean one-unit-per-chunk case (4 = 1 root × +2 mu chunks × 2 planes on the last frame, 8 on the 256x256 = 2 roots × 2 chunks +× 2 planes). + +## Recipe (128x256, 3 frames — the gate encodes it live) + +`rate=25`, `--limit=3`, `--cpu-used=0`, `--cq-level=62` and +`--min-partition-size=64 --max-partition-size=128` are all load-bearing. +Measured over 24 recipe/cell combinations: a clean `testsrc2` source never +produces an intra-coded 128 root on an inter frame; noise-on-`gradients` does, +and only at this seed/cq/geometry. At `--limit=2` the same recipe stops choosing +the shape entirely (0 fires). + +```text +ffmpeg -f lavfi -i "gradients=size=128x256:c0=..:c1=..:c2=..:c3=..:seed=63:\ +duration=0.12:rate=25,noise=all_seed=63:alls=6:allf=t" \ + -pix_fmt yuv444p -t 0.12 -f yuv4mpegpipe - | \ +aomenc --codec=av1 --profile=1 --passes=1 --end-usage=q --cq-level=62 \ + --cpu-used=0 --threads=1 --row-mt=0 --sb-size=128 --limit=3 \ + --max-partition-size=128 --min-partition-size=64 \ + --enable-rect-partitions=0 --enable-ab-partitions=0 \ + --enable-1to4-partitions=0 --enable-palette=0 --enable-intrabc=0 \ + --deltaq-mode=0 --enable-tx-size-search=0 --obu -o out.obu - +``` + +## Header-parse evidence + +The gate parses the encoded stream's own sequence header and asserts +`(use_128x128_superblock, subsampling_x, subsampling_y, mono_chrome) == +(true, 0, 0, false)` **before** anything else, so a stream that silently came +back 4:2:0 cannot leave the arm unexercised while the rest passes. +`decode_probe` on the same stream: `SEQ: use_128x128_superblock=true bit_depth=8 +mono_chrome=false max_frame=128x256`. + +## Gate + +`stream.rs::a_real_aomenc_444_intra_in_inter_128_root_codes_chroma_per_mu_chunk_unit_pixel_exact` + +- encodes live with the oracle aomenc (no pinned fixture — the recipe is the + witness, and a recipe that stops firing fails rather than passing vacuously), +- asserts the 4:4:4 + 128-superblock sequence header, +- `intra_128_in_inter_hits() >= 1` (a real intra-coded 128 root on an inter + frame) and `intra_128_in_inter_mu_chroma_hits() >= 4` (the per-unit walk ran), +- `decode_all_frames_vs_oracle` — every decode-order frame compared + byte-for-byte against the oracle, panicking on a refusal or any differing byte. + +**Green:** `3 decode-order frames pixel-exact (0 hidden), intra_128_in_inter=1 +mu_chunk_chroma_reads=4`. + +On the 256x256 8-frame 4:4:4 witness all **9** decode-order frames are +byte-exact (`EC_AV1_FINAL_DUMP` ours vs oracle `aomdec`, 196608 B each, 0 +differing bytes per frame). + +## Red-before + +Reverted **only** the arm body (the per-unit walk and the ss-aware arithmetic) +back to the pristine `a21f3680` text, keeping the counter and the new gate. +Restored afterwards with `cp` from a saved copy and verified with `diff -q` +(`RESTORED byte-identical`) — never `git checkout --`. + +Gate-level, fresh run of the new gate on the reverted arm: + +``` +a_real_aomenc_444_intra_in_inter_128_root_..._pixel_exact: decode-order frame 2 +of 3 (3 shown, 0 hidden) differs from the oracle at byte 15450 (ours 142 vs +141), 44649 bytes differ +test result: FAILED. 0 passed; 1 failed +``` + +It fails on **pixels**, with the counter still reading 4 — so the red is not +merely the counter. Direct dump comparison on the same reverted build: + +| stream | decode-order frames | differing bytes | +| --- | --- | --- | +| 128x256 (red-before) | 3 | 0, 0, **44649** (frame 2) | +| 256x256 (red-before) | 9 | 0, 0, 0, 0, **167832**, **152747**, **193206**, **182687**, **190186** | + +## 4:2:0 byte-identity (invariant) + +The arm is unchanged in behaviour at ss (1,1) by construction: `cu_tx` is +unchanged (32), `cu_tx << ss_x == cu_tx * 2` at ss (1,1), and +`chunk_chroma == chunk_luma >> ss_x == 32 == cu_tx` so `units_w == units_h == 1` +— the walk degenerates to exactly the one unit per mu chunk the arm always +coded. Proven by running two existing 4:2:0 128-root gates unchanged on this +tree: + +| gate | result | +| --- | --- | +| `a_real_aomenc_inter_128x128_none_root_decodes_pixel_exact` | **ok** — 3 arms pixel-exact; 8-bit `intra_128_in_inter=0`, **10-bit `intra_128_in_inter=1`** (the arm really runs at 4:2:0 on that arm and stays exact), `chroma_units` 32/40/40; 3rd arm `intra_128_in_inter=0` | +| `a_real_aomenc_128x128_none_inter_blocks_coded_chroma_per_mu_chunk_decodes_pixel_exact` | **ok** — 12 decode-order frames pixel-exact, `inter_sb128_none_hits=11 chroma_units=88` | + +The 10-bit arm of the first gate is the direct proof: it fires the +intra-in-inter 128 arm at ss (1,1) (`intra_128_in_inter=1`) and every frame is +byte-exact, so the 4:2:0 path through the rewritten walk is unchanged. + +A targeted extra control: the same 128x256 recipe at `--profile=0` / `yuv420p` +produced 3 frames decoding cleanly (`SEQ: use_128x128_superblock=true +max_frame=128x256`, no refusal) with `ibc128: mu_chroma=0 intra128=0` — the +encoder picks no intra 128 root there, which is why the two existing gates above +are the 4:2:0 evidence rather than this stream. + +## Files changed + +- `crates/ec-av1/src/decode.rs` — new counter + `INTRA_128_IN_INTER_MU_CHROMA_HITS` + accessor + `intra_128_in_inter_mu_chroma_hits()`; the arm's per-unit walk. +- `crates/ec-av1/examples/decode_probe.rs` — prints the counter (scratch + instrument, left in so the arm's engagement is inspectable from the probe). +- `crates/ec-av1/src/stream.rs` — the new gate. + +`cargo build --release -p ec-av1 --tests --features gate-counters`: 0 errors, +0 warnings. + +## Note for the next reader + +The ticket's part (1) should not be re-applied anywhere: a TX_64X64 chroma unit +at 4:4:4 is not what libaom 3.13.3 codes, on this or any other arm. The +already-landed inter arm got this right; the intra arm is now the second +instance carrying the per-unit walk, and the ss-aware `cu_tx << ss` / +`chunk_luma >> ss` forms are the house pattern. diff --git a/lanes/av1tilerows.report.md b/lanes/av1tilerows.report.md index efa57077..e6e7fd97 100644 --- a/lanes/av1tilerows.report.md +++ b/lanes/av1tilerows.report.md @@ -273,12 +273,38 @@ unvalidated change into a path with zero coverage: the reach answer in an arm whose unit geometry is still 4:2:0-shaped, with no gate able to catch the difference. -**Recommendation.** Fix H1 first; this site then becomes witnessable and -should be repaired as a unit (`cu_tx = 32 << ss_x(fctx)`, `luma_span = -cu_tx << ss_x(fctx)`, and the per-chunk chroma origin with it), with the same -`<< 1 == * 2` 4:2:0 identity argument. The 4:2:0 identity is not in question — -`32 << 1 == 64` — so the repair is provably a no-op for the only format with -committed coverage on this path. + > **RETRACTED by `lanes/av1txsizeaudit.report.md` §3.1. DO NOT ACT ON + > ITEM 3 OR THE RECOMMENDATION BELOW.** `blockd.h:1371` is the *body* of + > `av1_get_max_uv_txsize`, and its last line is + > `return av1_get_adjusted_tx_size(uv_tx);`. + > `av1_get_adjusted_tx_size` (`blockd.h:1361`) takes **no subsampling + > argument** and maps `TX_64X64`/`TX_64X32`/`TX_32X64` to `TX_32X32` + > **unconditionally** — the parenthetical "(adjusted → itself)" above is + > the error: it stopped one line short of the adjustment it annotated. + > Measured against libaom's own code (a C probe linked against + > `~/.cache/aom-oracle/build/libaom.a`), + > `av1_get_max_uv_txsize(BLOCK_128X128, 0, 0) == TX_32X32`, and the + > oracle's `EC_TRACE_COEFF` on a 4:4:4 `--sb-size=128` stream shows every + > TX_64X64 luma unit followed by **four** TX_32X32 chroma units per plane + > per 64x64 mu chunk (`cu_tx` stays 32; the unit *count* is what changes, + > 1 → 4 at 4:4:4). The site was repaired correctly by `4bfe8d8e`. + > The generalisation: `max_txsize_rect_lookup` is only half the rule; the + > `av1_get_adjusted_tx_size` call on its result is the other half and it is + > unconditional. + +**Recommendation (RETRACTED — see the note above).** Fix H1 first; this site +then becomes witnessable and should be repaired as a unit (`cu_tx = 32 << +ss_x(fctx)`, `luma_span = cu_tx << ss_x(fctx)`, and the per-chunk chroma origin +with it), with the same `<< 1 == * 2` 4:2:0 identity argument. The 4:2:0 +identity is not in question — `32 << 1 == 64` — so the repair is provably a +no-op for the only format with committed coverage on this path. + +> **The 4:2:0 identity argument does not licence the repair.** `32 << 1 == 64` +> is true, and the 4:2:0 adjusted step is inert — but that is an argument about +> the one format where the change does nothing, and says nothing about 4:4:4, +> where it is wrong. **A subsampling-parameterised expression can only be +> certified by the measured value at every subsampling, never by an identity +> at one of them.** **Net class status: the class is closed except for this one site, which is proven reachable and documented rather than silently changed.** diff --git a/lanes/av1txsizeaudit.report.md b/lanes/av1txsizeaudit.report.md new file mode 100644 index 00000000..723cd257 --- /dev/null +++ b/lanes/av1txsizeaudit.report.md @@ -0,0 +1,1097 @@ +# lane-av1txsizeaudit — every transform-size derivation in `crates/ec-av1/src/**`, against libaom's actual rule + +Base: `main` `9b2f6c9d` (the tip `main` had when this lane started) **plus** the +`lane-av1ibc128arm` fix `4bfe8d8e` replayed on top (rebased clean as +`2fcc577a`), because the audit subject must be the tree the fix will land on and +the invariant gate must be runnable. Branch `lane-av1txsizeaudit`, worktree +`/home/user/.cache/wt/av1txsizeaudit`. Oracle `~/.cache/aom-oracle` +(aom `v3.13.3-7-g9bb526a`), read-only. + +**Verdict: 0 transform-size MISMATCH. 2 non-transform-size MISMATCH (context / +plane-extent geometry, one of them a sibling of the fixed arm). 3 UNVERIFIED +open cells, all already named in `lanes/av1444rect.report.md`. ~100 MATCHES.** +The `cu_tx = 32 << ss_x` rule is refuted twice over — by a C probe linked +against the oracle's own `libaom.a`, and by the oracle's `EC_TRACE_COEFF` on a +4:4:4 `--sb-size=128` stream. + +--- + +## 0. The rule, restated with citations + +libaom's chroma transform size is a **three-step table chain**, not arithmetic +on the subsampling: + +```c +/* av1/common/blockd.h:1372-1379 (read in the oracle tree) */ +static inline TX_SIZE av1_get_max_uv_txsize(BLOCK_SIZE bsize, int subsampling_x, + int subsampling_y) { + const BLOCK_SIZE plane_bsize = + get_plane_block_size(bsize, subsampling_x, subsampling_y); + assert(plane_bsize < BLOCK_SIZES_ALL); + const TX_SIZE uv_tx = max_txsize_rect_lookup[plane_bsize]; + return av1_get_adjusted_tx_size(uv_tx); +} +``` + +```c +/* av1/common/blockd.h:1361-1370 */ +static inline TX_SIZE av1_get_adjusted_tx_size(TX_SIZE tx_size) { + switch (tx_size) { + case TX_64X64: + case TX_64X32: + case TX_32X64: return TX_32X32; + case TX_64X16: return TX_32X16; + case TX_16X64: return TX_16X32; + default: return tx_size; + } +} +``` + +`av1_get_adjusted_tx_size` takes **no subsampling argument**. The 64→32 step is +unconditional whenever the plane block's `max_txsize_rect_lookup` entry has a +64 axis. Tables: `av1_ss_size_lookup` at `av1/common/common_data.c:19-43`, +`max_txsize_rect_lookup` at `av1/common/common_data.h:126-147`. + +**The two structural facts that decide every row below:** + +1. `plane_bsize = get_plane_block_size(bsize, ss_x, ss_y)` halves the width by + `ss_x` and the height by `ss_y` **independently**. So the "chroma extent" is + a per-axis `>> ss`, never a `/2` and never a `<< ss`. +2. Because the adjustment is per-axis and fires on *any* 64 axis, **a + per-axis `.min(32)` on an already-subsampled chroma extent is an exact + transcription of `av1_get_adjusted_tx_size` over the entire `TX_SIZE` + domain** — not a blanket clamp. Check: `(64,64)|(64,32)|(32,64) → (32,32)`, + `(64,16) → (32,16)`, `(16,64) → (16,32)`, and every other shape is already + ≤ 32 on both axes. This is why the `.min(32)` sites in this crate are right + and why the two rect rows that *preserve* a 16 (`TX_64X16 → TX_32X16`) are + right too. + +### 0.1 Measured ground truth (not reconstructed from memory) + +`~/.cache/txaudit/probe.c` linked against `~/.cache/aom-oracle/build/libaom.a`, +calling `get_plane_block_size` → `max_txsize_rect_lookup` → +`av1_get_adjusted_tx_size` for all 22 block sizes × 4 `(ss_x, ss_y)`. Output in +`~/.cache/txaudit/out.txt`; table rendered in §1.0 below. Highlights: + +``` +DIRECT bsize=BLOCK_128X128 ss=00 plane_bsize=BLOCK_128X128 max_rect=64x64 adjusted=3 (32x32) +DIRECT bsize=BLOCK_128X128 ss=11 plane_bsize=BLOCK_64X64 max_rect=64x64 adjusted=3 (32x32) +DIRECT bsize=BLOCK_64X64 ss=00 plane_bsize=BLOCK_64X64 max_rect=64x64 adjusted=3 (32x32) +``` + +`av1_get_max_uv_txsize(BLOCK_128X128, 0, 0) == TX_32X32`, i.e. **`32` at every +subsampling, never `64` at 4:4:4.** + +### 0.2 Oracle runtime confirmation (independent of this crate's counters) + +4:4:4, `--sb-size=128`, `--limit=3`, `--cq-level=62`, gradient y4m +(`~/.cache/txaudit/grad444.obu`). Full `EC_TRACE_COEFF` histogram over all +3 frames: + +| plane | tx=0 (4x4) | tx=1 (8x8) | tx=2 (16x16) | **tx=3 (32x32)** | **tx=4 (64x64)** | tx=5 (4x8) | tx=6 (8x4) | tx=7 (8x16) | tx=12 (64x32) | tx=13 (4x16) | tx=14 (16x4) | tx=17 (16x64) | tx=18 (64x16) | +|---|---|---|---|---|---|---|---|---|---|---|---|---|---| +| luma | 420 | 186 | 75 | 13 | **8** | 130 | 74 | 14 | **2** | 31 | 0 | 0 | 0 | +| chroma| 240 | 179 | 80 | 49 | **0** | 134 | 88 | 25 | **0** | 32 | 0 | **0** | **0** | + +**Luma reads TX_64X64 (8) and TX_64X32 (2). Chroma reads neither, and no +64-axis chroma shape at all.** That is the refutation as a runtime artifact. + +And the mu-chunk structure, verbatim from the trace: + +``` +EC_COEFF plane=0 row=0 col=0 tx_size=4 <- luma TX_64X64 +EC_COEFF plane=1 row=0 col=0 tx_size=3 <- U TX_32X32 +EC_COEFF plane=1 row=0 col=8 tx_size=3 <- U TX_32X32 +EC_COEFF plane=1 row=8 col=0 tx_size=3 <- U TX_32X32 +EC_COEFF plane=1 row=8 col=8 tx_size=3 <- U TX_32X32 +EC_COEFF plane=2 row=0 col=0 tx_size=3 <- V TX_32X32 +EC_COEFF plane=2 row=0 col=8 tx_size=3 +EC_COEFF plane=2 row=8 col=0 tx_size=3 +EC_COEFF plane=2 row=8 col=8 tx_size=3 +EC_COEFF plane=0 row=0 col=16 tx_size=4 <- next 64x64 mu chunk +``` + +One TX_64X64 luma unit, then **FOUR** TX_32X32 chroma units per plane per +64x64 mu chunk, plane-major (all U, then all V), at `(row,col)` step 8 mi +(= 32 px / `MI`). The luma step is 16 mi (= 64 px). Under the ticket's rule +`cu_tx = 32 << ss_x`, the 4:4:4 chroma unit would have been 64 and each chunk +would have held **one** unit; libaom's trace says four of 32. + +--- + +## 1. The table + +Line numbers are the current worktree (`decode.rs` = 55960 lines). "adj step" += does the site carry `av1_get_adjusted_tx_size`'s unconditional 64→32? `n-a` += luma, plane dimension, mi coordinate, buffer stride, or scan/eob corner — +i.e. not a chroma transform size at all. + +### 1.0 Ground truth `av1_get_max_uv_txsize` (measured, §0.1) + +| block | ss_x ss_y | plane bsize | `max_txsize_rect_lookup` | after `av1_get_adjusted_tx_size` | +| --- | --- | --- | --- | --- | +| 4x4 | 00 / 01 / 10 / 11 | 4x4 | 4x4 | 4x4 | +| 4x8 | 00 | 4x8 | 4x8 | 4x8 | +| 4x8 | 01 / 11 | 4x4 | 4x4 | 4x4 | +| 4x8 | 10 | INVALID | (OOB) | (OOB) | +| 8x4 | 00 | 8x4 | 8x4 | 8x4 | +| 8x4 | 10 / 11 | 4x4 | 4x4 | 4x4 | +| 8x4 | 01 | INVALID | (OOB) | (OOB) | +| 8x8 | 00 | 8x8 | 8x8 | 8x8 | +| 8x8 | 01 | 8x4 | 8x4 | 8x4 | +| 8x8 | 10 | 4x8 | 4x8 | 4x8 | +| 8x8 | 11 | 4x4 | 4x4 | 4x4 | +| 8x16 | 00 | 8x16 | 8x16 | 8x16 | +| 8x16 | 01 | 8x8 | 8x8 | 8x8 | +| 8x16 | 11 | 4x8 | 4x8 | 4x8 | +| 8x16 | 10 | INVALID | (OOB) | (OOB) | +| 16x8 | 00 | 16x8 | 16x8 | 16x8 | +| 16x8 | 10 | 8x8 | 8x8 | 8x8 | +| 16x8 | 11 | 8x4 | 8x4 | 8x4 | +| 16x8 | 01 | INVALID | (OOB) | (OOB) | +| 16x16 | 00 | 16x16 | 16x16 | 16x16 | +| 16x16 | 01 | 16x8 | 16x8 | 16x8 | +| 16x16 | 10 | 8x16 | 8x16 | 8x16 | +| 16x16 | 11 | 8x8 | 8x8 | 8x8 | +| 16x32 | 00 | 16x32 | 16x32 | 16x32 | +| 16x32 | 01 | 16x16 | 16x16 | 16x16 | +| 16x32 | 11 | 8x16 | 8x16 | 8x16 | +| 16x32 | 10 | INVALID | (OOB) | (OOB) | +| 32x16 | 00 | 32x16 | 32x16 | 32x16 | +| 32x16 | 10 | 16x16 | 16x16 | 16x16 | +| 32x16 | 11 | 16x8 | 16x8 | 16x8 | +| 32x16 | 01 | INVALID | (OOB) | (OOB) | +| 32x32 | 00 | 32x32 | 32x32 | 32x32 | +| 32x32 | 01 | 32x16 | 32x16 | 32x16 | +| 32x32 | 10 | 16x32 | 16x32 | 16x32 | +| 32x32 | 11 | 16x16 | 16x16 | 16x16 | +| 32x64 | 00 | 32x64 | 32x64 | **32x32 (ADJ)** | +| 32x64 | 01 | 32x32 | 32x32 | 32x32 | +| 32x64 | 11 | 16x32 | 16x32 | 16x32 | +| 32x64 | 10 | INVALID | (OOB) | (OOB) | +| 64x32 | 00 | 64x32 | 64x32 | **32x32 (ADJ)** | +| 64x32 | 10 | 32x32 | 32x32 | 32x32 | +| 64x32 | 11 | 32x16 | 32x16 | 32x16 | +| 64x32 | 01 | INVALID | (OOB) | (OOB) | +| 64x64 | 00 | 64x64 | 64x64 | **32x32 (ADJ)** | +| 64x64 | 01 | 64x32 | 64x32 | **32x32 (ADJ)** | +| 64x64 | 10 | 32x64 | 32x64 | **32x32 (ADJ)** | +| 64x64 | 11 | 32x32 | 32x32 | 32x32 | +| 64x128 | 00 | 64x128 | 64x64 | **32x32 (ADJ)** | +| 64x128 | 01 | 64x64 | 64x64 | **32x32 (ADJ)** | +| 64x128 | 11 | 32x64 | 32x64 | **32x32 (ADJ)** | +| 64x128 | 10 | INVALID | (OOB) | (OOB) | +| 128x64 | 00 | 128x64 | 64x64 | **32x32 (ADJ)** | +| 128x64 | 10 | 64x64 | 64x64 | **32x32 (ADJ)** | +| 128x64 | 11 | 64x32 | 64x32 | **32x32 (ADJ)** | +| 128x64 | 01 | INVALID | (OOB) | (OOB) | +| 128x128 | 00 | 128x128 | 64x64 | **32x32 (ADJ)** | +| 128x128 | 01 | 128x64 | 64x64 | **32x32 (ADJ)** | +| 128x128 | 10 | 64x128 | 64x64 | **32x32 (ADJ)** | +| 128x128 | 11 | 64x64 | 64x64 | **32x32 (ADJ)** | +| 4x16 | 00 | 4x16 | 4x16 | 4x16 | +| 4x16 | 01 | 4x8 | 4x8 | 4x8 | +| 4x16 | 11 | 4x8 | 4x8 | 4x8 | +| 4x16 | 10 | INVALID | (OOB) | (OOB) | +| 16x4 | 00 | 16x4 | 16x4 | 16x4 | +| 16x4 | 10 | 8x4 | 8x4 | 8x4 | +| 16x4 | 11 | 8x4 | 8x4 | 8x4 | +| 16x4 | 01 | INVALID | (OOB) | (OOB) | +| 8x32 | 00 | 8x32 | 8x32 | 8x32 | +| 8x32 | 01 | 8x16 | 8x16 | 8x16 | +| 8x32 | 11 | 4x16 | 4x16 | 4x16 | +| 8x32 | 10 | INVALID | (OOB) | (OOB) | +| 32x8 | 00 | 32x8 | 32x8 | 32x8 | +| 32x8 | 10 | 16x8 | 16x8 | 16x8 | +| 32x8 | 11 | 16x4 | 16x4 | 16x4 | +| 32x8 | 01 | INVALID | (OOB) | (OOB) | +| 16x64 | 00 | 16x64 | 16x64 | **16x32 (ADJ)** | +| 16x64 | 01 | 16x32 | 16x32 | 16x32 | +| 16x64 | 11 | 8x32 | 8x32 | 8x32 | +| 16x64 | 10 | INVALID | (OOB) | (OOB) | +| 64x16 | 00 | 64x16 | 64x16 | **32x16 (ADJ)** | +| 64x16 | 10 | 32x16 | 32x16 | 32x16 | +| 64x16 | 11 | 32x8 | 32x8 | 32x8 | +| 64x16 | 01 | INVALID | (OOB) | (OOB) | + +Two facts fall out and are used repeatedly below: + +* **At 4:2:0 the chroma tx is ≤ 32 on both axes for every block size** — so a + `.min(32)` there is a no-op and any *hardcoded 32* is a 4:2:0 accident that + happens to be right. +* **At 4:2:0 the adjusted step DOES fire** for the 64x128 / 128x64 / 128x128 + roots (their plane block is BLOCK_64X64 / BLOCK_32X64 / BLOCK_64X32) — and it + fires to the same 32x32 a per-axis `.min(32)` produces. That is precisely why + the 4:2:0 path is byte-identical across every `.min(32)` vs `.min(64)` choice. +* `INVALID` = `av1_ss_size_lookup` maps that (shape, ss) to `BLOCK_INVALID`, + which libaom indexes **out of bounds** in `max_txsize_rect_lookup`. That is + libaom's own quirk, already modelled in this crate by the + `chroma_422_oob` / `ChromaRect8x4` arms and measured at TX_4X8. Not this + audit's rule; 4:2:2 is refused by name at the sequence header anyway. + +### 1.1 `crates/ec-av1/src/decode.rs` — chroma transform sizes (the real audit) + +| file:line | what it computes | libaom rule | adj step | evidence | verdict | +|---|---|---|---|---|---| +| `decode.rs:12100-12102` | `(64,32)\|(32,64)\|(32,32) => (32,32)`; `(64,16) => (32,16)`; `(16,64) => (16,32)` — the tiled chroma unit of `decode_rect_split` | `av1_get_adjusted_tx_size`, blockd.h:1361 | **yes** | measured table §1.0: 4:4:4 `64X32`→32x32, `64X16`→32x16, `16X64`→16x32. The rect rows *keep* a 16, so this is a genuine per-axis transcription, not `min(32)` on both | MATCHES — the reference transcription | +| `decode.rs:18907` | `(uw,uh) = (chroma_w.min(32), chroma_h.min(32))` + `nw,nh = chroma/uw` | same | **yes** | input is already chroma (`11492: chroma_w = bw >> ss_x`) — clamp AFTER subsample, correct order. 4:4:4 `64x32`→(32,32)/2 units, `64x16`→(32,16), `16x64`→(16,32). 4:2:0: inert (already ≤32) | MATCHES | +| `decode.rs:28702` | `(uw,uh) = (write_chroma_w.min(32), write_chroma_h.min(32))` in `read_inter_rect_chroma` | same | **yes** | same order; `side > 64` is consumed by the mu-chunk arm at `40357` first, so every reachable footprint ≤64 per axis | MATCHES | +| `decode.rs:9126-9127` | `uv_tx_w/h = ((w_mi*MI) >> ss).max(4).min(32)` — chroma tx published to the deblocker's `uv_tx_grid` | `av1_get_max_uv_txsize`; libaom reads `block_size_wide[plane_bsize]` at `reconintra.c:1936-1944` | **yes** | 4:2:0 128 root: `128>>1=64`→32 = libaom 32x32. 4:4:4 128 root: `128>>0=128`→32 = libaom `adjusted(TX_64X64)`=32x32. 4:4:4 `64x16`: →(32,16) = libaom TX_32X16. 4:4:4 `16x64`: →(16,32) | MATCHES (comment says "under 4:2:0" — **stale prose**, the code is ss-generic and right at 4:4:4) | +| `decode.rs:20632` | `let tx = if side >= 64 { 32 } else { side }` → `chroma_tx`/`chroma_tx_h` in `decode_block` | `av1_get_max_uv_txsize` | **yes, this IS the step** | arm is `else if ss_x==0 && ss_y==0` → 4:4:4 only, where `plane_bsize == bsize`. `decode_block` is only called with square 8/16/32/64/128; substitute: 8→8, 16→16, 32→32, 64→32, 128→32 — every one equals the measured 4:4:4 column | MATCHES | +| `decode.rs:38686` | same expression → `chroma_tx`/`chroma_set`/`scan` in `decode_inter_block` | same | **yes** | guard `ss_x==0 && ss_y==0 && strip_chroma.is_none()`. A rect strip is diverted at `40409` to `read_inter_rect_chroma`, which recomputes per-axis, so the square is never applied to a rect | MATCHES | +| `decode.rs:22086` | `chroma_tx = if lossless_frame { 4 } else { 32 }` in `decode_block_128rect` | same | **yes (hardcoded)** | block sizes are **only** `(128,64)` and `(64,128)` (callers `33214/33220/33337`; 128x128 goes to `decode_block`). Measured: both are **32x32 at all four (ss_x,ss_y)**. Not merely inert-correct: the per-axis consumer at `22113-22114` is `(64>>ss_x)/chroma_tx × (64>>ss_y)/chroma_tx` = 2×2 = four units at 4:4:4, 1×1 at 4:2:0 | MATCHES | +| `decode.rs:14115`, `40136`, `41923`, `42900` | `let cu_tx = 32usize;` — the chroma unit of one 64x64 mu chunk (intra-BC 128 root / single-ref / compound / **the fixed intra-in-inter arm**) | `av1_get_max_uv_txsize` | **yes** | `side > 64` guard ⇒ BLOCK_128X128/128X64/64X128 only. Measured: 32x32 at every subsampling. The step is carried in the *division* below, not the literal | MATCHES (4 sites) | +| `decode.rs:14130-14131`, `14365-14366`, `40149-40150`, `41936-41937`, `42921-42922` | `chunk_chroma_w/h = (64usize) >> ss_x/ss_y` | `block_size_wide[plane_bsize]`, reconintra.c:1943 | n-a (plane block) | per-axis: 4:2:0 32x32, 4:2:2 32x64, 4:4:4 64x64 | MATCHES | +| `decode.rs:14136-14137`, `14359-14360`, `40164-40165`, `41951-41952`, `42907-42908` | `unit_luma_w/h = cu_tx << ss_x/ss_y` — the unit's LUMA footprint in px | `mi_size_wide[plane_bsize] >> ss_x` inverted | n-a (coord) | `32<<0=32` (8 mi) at 4:4:4, `32<<1=64` (16 mi) at 4:2:0. **This is a `<< ss` on a LUMA span, not on a tx size** — the ticket conflated the two | MATCHES | +| `decode.rs:40151-40152`, `41938-41939`, `42923-42924`, `22113-22114`, `22214-22215` | `units_w/h = chunk_chroma_w/h / cu_tx`, `(64 >> ss)/chroma_tx` — units per plane per mu chunk | `decode_token_recon_block`'s chroma loop | **yes (in the division)** | 4:2:0 `32/32`=1 → one unit; 4:4:4 `64/32`=2 → **2×2 = FOUR units**; matches the oracle trace in §0.2 exactly. Under the ticket's rule this would be 1 | MATCHES | +| `decode.rs:40450-40451`, `42243-42244` | `cu_tx = chroma_tx; mu_units_n = chroma_side / cu_tx` — the 4:4:4 `chroma_side > chroma_tx` arm | `av1_get_max_uv_txsize(BLOCK_64X64, 0, 0)` = `adjusted(TX_64X64)` = TX_32X32 | **yes (inherited)** | guard `ss_x==0 && ss_y==0 && chroma_side > chroma_tx` with `side > 64` already consumed ⇒ `side == 64`; `64/32 = 2` → four units per plane, plane-major | MATCHES | +| `decode.rs:14354`, `43652` | `cu = if lossless { 4 } else { 32 }` — the mu-chroma re-stamp's unit size | TX_32X32 / lossless TX_4X4 | **yes** | reachable only when `mu_chroma`, set exclusively by the TX_32X32 and lossless arms | MATCHES | +| `decode.rs:22072` | `logical_tx = if lossless_frame { 4 } else { 64 >> depth }` | `read_tx_size`, decodeframe.c:1117 | n-a (luma) | lossless returns TX_4X4 before the tree is consulted | MATCHES | +| `decode.rs:22077` | `coeff_tx_side = logical_tx.min(32)` | `av1_get_max_eob`, spec 5.11.40 — a 64-length axis codes only its low 32 coefficients | n-a (luma eob corner) | paired with `default_scan(coeff_tx_side)` at `22083` | MATCHES | +| `decode.rs:18794` | `(luma_cw, luma_ch) = (bw.min(32), bh.min(32))` — the LUMA corner of a 64-axis strip | `av1_get_adjusted_tx_size` applied to luma `max_txsize_rect_lookup` | n-a (luma) | `64x32 → 32x32`, `64x16 → 32x16` — same per-axis law. The chroma twin is `18907` and is computed independently from `11492`; the two are never conflated | MATCHES | +| `decode.rs:45693` | `uv_tx = default_intra_tx_type(uv_predict_mode)` — a `TxType`, **not a size** | — | n-a | the *size* is the `bw,bh` handed to `read_coeffs_rect`; guard `chroma_444 && bw != bh` ⇒ plane block BLOCK_8X4/BLOCK_4X8, `max_txsize_rect_lookup` identity, one rect unit fills the plane block | MATCHES (not a site) | +| `decode.rs:47200` | `chroma_tx = if chroma_w == 8 { TX8 } else { TX4 }` in `decode_inter_block8` (`SIDE = 8` const) | `av1_get_max_uv_txsize(BLOCK_8X8, ss)` | n-a (no 64 axis reachable) | 4:2:0 plane block BLOCK_4X4 → TX4 ✓; 4:4:4 BLOCK_8X8 → TX8 ✓; 4:2:2 BLOCK_4X8 → `ChromaRect8x4`/`SCAN_4X8` via `read_inter_plane_rect` ✓. No 16-wide leaf exists in this fn | MATCHES | +| `decode.rs:14697` + `14805-14819` | `decode_block_rect` chroma: plane block → `TxbSet`/scan table | `av1_get_max_uv_txsize` | vacuous | called only with 32x16/16x32 strips (all 8 call sites); at 4:4:4 the largest plane block is BLOCK_32X16 = TX_32X16, identity under the adjustment. The `_ =>` arm **refuses** any other shape, so a future 64-axis caller cannot fall through | MATCHES | +| `decode.rs:15340` + `15414-15437` | `decode_leaf_rect` chroma (16x8/8x16 leaves) | same | vacuous | largest 16x8; 4:4:4 → 16x8 identity, 4:2:2 → 8x8 identity | MATCHES | +| `decode.rs:15932` + `15942-15972` | `decode_block_rect4` chroma (32x8/8x32 strips) | same | vacuous | 4:4:4 → BLOCK_32X8 = TX_32X8 identity, the `(32,8)` row at `15945`. The 4:2:2 `(4,32)` row is the BLOCK_INVALID OOB case (different rule). `_ =>` `unreachable!`s | MATCHES | +| `decode.rs:11541-11542` | `(8,4)/(4,8) => ChromaRect8x4` | `max_txsize_rect_lookup[BLOCK_8X4/4X8]` = TX_8X4/TX_4X8, identity | n-a | one rect unit fills the plane block | MATCHES | +| `decode.rs:44799-44811`, `46792-46809` | the 4:2:0 group-unit chroma arm (`B4`/`Chroma4`) in `decode_inter_sub8_split4` and `decode_inter_sub8_rect2` | `av1_get_max_uv_txsize(BLOCK_8X8, 1, 1)` = `max_txsize_rect_lookup[BLOCK_4X4]` = TX_4X4 | n-a | guarded `!chroma_444 && !chroma_422 && !intra_chroma` ⇒ **4:2:0 only**; at 4:4:4 the per-piece arm runs instead. Checked specifically because `B4` looks like a possible 4:4:4 miss — it is not | MATCHES | +| `decode.rs:11261`, `13124` | palette colour-index map extent `(bw>>ss_x).max(4), (bh>>ss_y).max(4)` | `av1_get_plane_block_size(bsize,1,1)`, common_data.c:19-43 — the PLANE BLOCK, not the transform | n-a | a palette block codes one colour-index sample per plane-block pixel regardless of how its coefficients are transformed. `.max(4)` is required: `BLOCK_16X4 → BLOCK_8X4` at 4:2:0, a plain halving read half the symbols | MATCHES (plane block) | +| `decode.rs:22673` | `(cw,ch) = (8>>ss_x, 8>>ss_y)` | plane block | n-a | per-axis plane extent | MATCHES (plane) | +| `decode.rs:21604-21606` | `plane_px = ((span_mi*MI)>>ss_x).max(4)`, `over_w_px/over_h_px` | `max_block_wide/high` in chroma px | n-a | frame-edge clip, not a transform | MATCHES (plane) | +| `decode.rs:29572` | `plane_dim = ((dim_mi*MI)>>ss).max(4)` | plane dimension | n-a | boundary test, not a transform | MATCHES (plane) | + +### 1.2 `crates/ec-av1/src/decode.rs` — luma sites (in the taxonomy, not chroma sizes) + +| file:line | what | libaom rule | adj step | verdict | +|---|---|---|---|---| +| `11404` | `depth_to_tx_wh`: `(bw.min(64), bh.min(64))` | `depth_to_tx_size`, blockd.h:1354-1359 (`max_txsize_rect_lookup[bsize]` then `sub_tx_size_map` × depth) | n-a (luma) | MATCHES — `min(64)` is the table's TX_64X64 ceiling; every caller's block is ≤64 so it is a no-op on the whole reachable set | +| `13166`, `22057`, `27463` | `tx_size_context_txfm_rect(..., bw.min(64), bh.min(64))` and the callee's re-clamp | `get_tx_size_context` compares `tx_size_wide[max_txsize_rect_lookup[bsize]]` | n-a (luma) | MATCHES — the clamp is inside the helper so all 7 callers inherit it; a 128-axis block is diverted to `decode_block_128rect` before reaching here | +| `20723`, `20787`, `27578`, `28070`, `28109-28110` | `max_tx = side.min(64)` (var-tx tree entry, `read_tx_size`, `read_block_tx_size`) | `max_txsize_rect_lookup` ceiling | n-a (luma) | MATCHES — 128 enters at 64 = `max_txsize_rect_lookup[BLOCK_128X128]`, sharing BLOCK_64X64's `tx_size_cat3` row | +| `27629` | `max_tx = blk_max_px.min(64)` in `txfm_partition_ctx_rect` | `txfm_partition_context`, `get_sqr_tx_size` | n-a (luma) | MATCHES — `max_idx = log2(max_tx)-2`; 128→4→idx 0, same as BLOCK_64X64 | +| `28563` | `tx = 64usize` under `bw.max(bh) > 64` in `read_block_tx_size_rect` | `max_txsize_rect_lookup[BLOCK_128X64/64X128]` = TX_64X64 | n-a (luma) | MATCHES | +| `13836-13837`, `14464-14465`, `16859-16860` | `bw.min(64) as u8, bh.min(64) as u8` — luma transform published to `tx_grid` | `set_txfm_ctxs(mbmi->tx_size)` | n-a (luma grid) | MATCHES — a 128 root's `mbmi->tx_size` is TX_64X64; `128.min(64)=64` | +| `13632`, `14081`, `40049`, `41789`, `42701` | `default_scan(tw.min(32))` / `default_scan(tx_px.min(32))` | `av1_scan_orders`, scan.c:1744-1762 — TX_64X64/64X32/32X64 **alias to `default_scan_32x32`** | n/a — table-boundary guard, *not* the adjusted step | MATCHES — load-bearing (a 128 root's luma leaf really is TX_64X64, asserted at `13706`) and correct, sourced independently. `default_scan` only builds 4/8/16/32 | +| `28925` | `(cw,ch) = (w.min(32), h.min(32))` in `read_inter_plane_rect` | `av1_get_max_eob` | n-a (eob corner) | MATCHES — `w,h` are the true rect transform dims; `rect_shape` preserves the nominal | +| `36015` | `tx_side = side.min(32)` in `read_inter_plane` | `av1_get_max_eob` | n-a (eob corner) | MATCHES — inert below 64, `extend_corner` re-widens | +| `494` | `cfl_allowed_px`: `(bw>>ss_x).max(4)==4 && (bh>>ss_y).max(4)==4` | `is_chroma_sub8_x/y` shape (blockd.h:1533) — a plane-block `== 4` test | n-a | MATCHES — 4:2:0 8x8 → 4x4 true; 4:4:4 8x8 → 8x8 false, which is the documented `wrong-alphabet-same-value` case | +| `37601-37602` | `overlap_above/left = write_{h,w}.min(64)/2` | `av1_build_obmc_inter_prediction`, reconinter.c 860/899 | n-a | MATCHES (prediction overlap, not a transform) | +| `19636` | `cfl_ac_q3_at`'s `(bw/2, bh/2)` | 2x2 luma average | n-a | MATCHES (per-sample CfL AC; the 4:4:4/4:2:2 forms are separate branches at `19585`/`19599`, so this arm is 4:2:0-only) | + +### 1.3 `crates/ec-av1/src/decode.rs` — mi coordinates, plane origins, strides (listed, all n-a) + +`9915-9916` `snap_x/snap_y = (1<> ss` · +`20805`+`20808` `chroma_side`/`chroma_height` (per-axis, the sibling pair +libaom's rect chroma needs) · `38655` `chroma_side = (side>>ss_x).max(side>>ss_y)` +(a **buffer stride**, the enclosing square; documented at `38645-38654`) · +`12023-12024` `span = 4 << ss`, `12137-12138` `luma_span = uw << ss`, +`22236-22240`, `28762`, `36103-36105`, `36145-36146`, `36265-36306`, +`18007-18106`, `42982-42984` — the LUMA footprint of a chroma unit, and the +`ox << ss_x` / `oy << ss_y` pair-extent form. All MATCHES: plane/coord, not a +transform size. `30510-30511` is a frame dimension. `27357-27358`, `27371-27372`, +`31627-31628`, `31848` are plane/loop-filter spans. `29452` is an OBMC step. +`33111-33239` is plane bookkeeping. None of these is a transform size. + +### 1.4 `crates/ec-av1/src/decode.rs` — the two non-transform MISMATCHes + the open cells + +| file:line | what it computes | libaom rule | adj step | evidence | verdict | +|---|---|---|---|---|---| +| `decode.rs:9103` | `suppress_internal_lf_edges`: `(uv_w, uv_h) = ((w_mi*MI/2).max(4), (h_mi*MI/2).max(4))` — the chroma extent the deblocker is told the skipped block has, so no internal edge reads as a TU edge | libaom's analogue is `set_one_param_for_line_luma/_chroma` (`mbmi->skip_txfm && is_inter_block` ⇒ the block's own mode_lf_lut row 0, no internal TU edge); the port emulates it by publishing the block's own chroma extent | **no** — hardcoded `/2`, not `>> ss` | Its **sibling `fill_lf_grid_rect` at `9126-9127` was already repaired to `>> ss_x(fctx)`; this one was not.** Reachability: sole caller `43954-43956`, guard `skip_inter_128 = skip && is_inter && write_w.max(write_h) > 64` — a SKIP inter 128x128/128x64/64x128 block, fully reachable at **4:4:4** (only 4:2:2 is refused). At 4:2:0 `128/2 = 64` = `128>>1` ✓; at 4:4:4 the code yields **64** where the block's chroma extent is **128** | **MISMATCH** — charter C1 | +| `decode.rs:42974` | `let cu_around = neighbours.around_mi(unit_mi, unit_luma_w);` — the coefficient-context gather inside the **fixed** intra-in-inter mu walk | `get_txb_ctx_general`, txb_common.h:293-309: `txb_w_unit = tx_size_wide_unit[tx_size]` and `txb_h_unit = tx_size_high_unit[tx_size]` — **per axis** | n/a (context geometry, not a size) | `around_mi` (`9553`) takes ONE `side` and gathers `side/MI` cells in **both** axes. `around_mi_rect` (`9662`) is the same loop with the two extents split; with `w == h` it is byte-identical. The inter twin at `14191-14192` already calls `around_mi_rect(unit_mi, unit_luma_w, unit_luma_h)`, and the record at `42996+` is per-axis. `unit_luma_w != unit_luma_h` only at 4:2:2, where it over-gathers 8 mi of LEFT (or ABOVE) context libaom does not read. At 4:2:0 and 4:4:4 `unit_luma_w == unit_luma_h` ⇒ inert | **MISMATCH (4:2:2 only)** — charter C2 | +| `decode.rs:13361-13373` | `decode_intrabc_rect`: the LOSSY arm's `(px/2, py/2)` and `(bw/2, bh/2)` chroma origin/extent (the lossless arm beside it uses `>> ss_x/ss_y`) | `block_size_wide[plane_bsize]`, reconintra.c:1943 | n/a (plane extent) | At 4:2:0 the `/2` is exactly `>> ss` for both axes ✓. At **4:4:4** a lossy intrabc rect strip reads **half** the chroma plane block. The `/2` is guarded only by `lossless(fctx)` — the `>> ss` path is the *lossless* one, so the defect is on the lossy side, i.e. 4:2:0-shaped arithmetic on the arm 4:4:4 actually uses. Already a declared open cell (`lanes/av1444rect.report.md:258,343,373`) | **UNVERIFIED** — missing: a 4:4:4 **lossy** `use_intrabc` rect-strip fixture (0 of the pinned fixtures decode one) | +| `decode.rs:16558` | `decode_intrabc_owned_rect`: `(cw, ch) = (bw/2, bh/2)` — **no** `lossless` branch at all | same | n/a (plane extent) | Same defect with no scoping guard. Sole caller `18525`, reached only when `intrabc.is_some()` — a 4:4:4 screen-content key frame with a 64-axis intrabc strip | **UNVERIFIED** — same open cell, reached through a 64-axis rather than a 32-axis strip | +| `decode.rs:28453` | `(cw,ch) = (w.min(32), h.min(32))` in the `corner_scan` closure of a `#[test]` | `av1_get_max_eob` | n-a (test) | production twin is `28925`; the test asserts every rect shape the census lists has a table | MATCHES (test) | + +### 1.5 `crates/ec-av1/src/qm.rs` + +| file:line | what | libaom rule | adj step | evidence | verdict | +|---|---|---|---|---|---| +| `qm.rs:57` | `fn adjusted(w,h) -> (usize,usize)` — the qmatrix shape reuse | `av1_get_adjusted_tx_size`, blockd.h:1361-1370 | **yes — this IS it** | Exact five-arm transcription: `(64,64)\|(64,32)\|(32,64) → (32,32)`, `(64,16) → (32,16)`, `(16,64) → (16,32)`, else identity. Matches blockd.h arm for arm | MATCHES | +| `qm.rs` `shape_range` | the shapes `adjusted` is asked about | `av1_get_max_eob` 1024 cap | **yes** | covers the 14 own-storage shapes, so `adjusted` never misses a shape the encoder can produce | MATCHES | +| `qm.rs` `iwt_matrix` | column-major stride fed through the adjusted height | — | **yes** | the adjusted height is the stride, matching libaom's coefficient buffer | MATCHES | + +### 1.6 `crates/ec-av1/src/transform.rs` + +| file:line | what | libaom rule | adj step | evidence | verdict | +|---|---|---|---|---|---| +| `transform.rs` (4 decode-side sites) | `cols = w.min(32)`; the `i < 32` row gate; `t[cols..w].fill(0)`; `get_rect_tx_log_ratio` | `av1_get_max_eob`, spec 5.11.40 — a 64-axis transform codes only its 32x32 corner | **yes, per axis** | The per-axis `min(32)` is the adjusted step, applied unconditionally per axis, and is exact for all 19 shapes | MATCHES | +| `transform.rs` `Transform_Row_Shift` | the row-shift table, including every 64-axis row | `av1_scan_orders`, scan.c:1744-1762 | **yes** | 64x64/64x32/32x64 rows all shift as 32x32, matching libaom's alias | MATCHES | +| `transform.rs:1644`, `2088`, `2165` | encoder-side coded-corner clamps | same | **yes** | same rule on the write side | MATCHES | + +### 1.7 `crates/ec-av1/src/quant.rs` + +| file:line | what | libaom rule | adj step | evidence | verdict | +|---|---|---|---|---|---| +| `quant.rs` (4 sites) | `dq_denom` / `dq_denom_area`, keyed on the TRUE tx area `w*h` | `av1_get_tx_scale`, quant_common.c — keyed on `tx_size_2d` | **no, and correctly so** | 64x64 must give 4096→4, **not** 1024→2. libaom's `av1_get_tx_scale` uses the nominal size; the adjusted step is a *coefficient-buffer* concept, not a quantiser one | MATCHES | + +### 1.8 `crates/ec-av1/src/tile.rs` + +| file:line | what | libaom rule | adj step | evidence | verdict | +|---|---|---|---|---|---| +| `tile.rs:5490`, `5537`, `5504`, `5559`, `5593` | luma var-tx roots: `max_tx = side.min(64)`, `>> depth`, `/2` | `max_txsize_rect_lookup` + `sub_tx_size_map` | n-a (luma) | pure luma, no adjustment | MATCHES | +| `tile.rs:5380` | `coeff_side = tx.min(32)` | `av1_get_max_eob` | **yes** | the coded-position count, carrying the step | MATCHES | +| `tile.rs` `TxbSet::Luma64` | side 32, eob 1024 | `av1_get_max_eob` 1024 cap | **yes** | the 32x32 corner | MATCHES | +| `tile.rs` `TxbSet::Chroma4/8/16/32` | the chroma side = luma side / 2 | `av1_get_max_uv_txsize` at 4:2:0 | **yes, implicit** | reproduces the 4:2:0 column exactly including the 32 cap; the encoder writes 4:2:0 only (`encode.rs:2191-2192`, `encoder.rs:77`), so the `/2` is exact by construction | MATCHES | +| `tile.rs:5000-5004` | `palette_uv_side(side) = av1_get_plane_block_size(bsize,1,1)` floored at 4 | common_data.c:19-43 | n-a (plane block) | not a transform size; the `4 << ss`-free floor is the 4-px minimum | MATCHES (plane) | +| `tile.rs:3355-3359` | `tx_size_ctx(..., max_tx)` | `get_tx_size_context` | n-a (luma) | neighbour transform bookkeeping | MATCHES (luma) | + +### 1.9 `crates/ec-av1/src/encode.rs` (ENCODER — a mismatch here is a rate/bitstream defect, not a decode defect) + +| file:line | what | libaom rule | adj step | evidence | verdict | +|---|---|---|---|---|---| +| `encode.rs:5302-5304` | `c = side / 2; c.min(32)` — the only real chroma-tx derivation | `av1_get_max_uv_txsize` at 4:2:0 | **yes** — `.min(32)` IS the step | 4:2:0 only (`encode.rs:2191-2192` constrains the encoder to 4:2:0), so no site is reachable with a 64 chroma axis | MATCHES | +| `encode.rs:4777-4780` | `max_tx_depth(side)` | `MAX_VARTX_DEPTH` = 2 | n/a | `max_tx_depth(64) = 0` sits *below* libaom's 2 — a search restriction with no bitstream consequence (it costs bits, it does not desync) | MATCHES (encoder search) | +| `encode.rs:5256-5270` | `txfm_split_bits`: `max_tx = side.min(64)`, `max_tx/2` | `read_block_tx_size` | n/a (luma) | rate model | MATCHES (encoder) | +| `encode.rs:4777`, `5532-5543`, `5612-5613`, `6241-6256`, `6759-6762`, `6804-6808`, `7281-7285` | remaining luma var-tx / chroma-extent derivations | as above | n/a / vacuous | zero `<< ss` sites in the whole file; every chroma transform side is `side/2` at 4:2:0 | MATCHES | + +### 1.10 `crates/ec-av1/src/cdf_state.rs` + +| file:line | what | libaom rule | adj step | evidence | verdict | +|---|---|---|---|---|---| +| `cdf_state.rs` `TxbTables.side` | the entropy-context shape | `get_txsize_entropy_ctx`, entropy.h:172 — squares UP, **no** adjustment | **no, correctly** | `LumaRect32x8` gets side 16, not 32 | MATCHES | +| `cdf_state.rs` `eob_pt` table length | the CODED-position count | `av1_get_max_eob` | **yes** | `Luma64 → 1024` = the 32x32 corner | MATCHES | + +Two different libaom rules, both transcribed correctly. + +### 1.11 `crates/ec-av1/src/stream.rs`, `refusal_inventory.rs`, `gate_coverage.rs`, `census.rs`, `restoration.rs`, `examples/` + +| file:line | what | verdict | +|---|---|---| +| `stream.rs:2458-2492` | source-scan test pinning `"let unit_luma_w = cu_tx << ss_x(fctx);"`, `"let (cw, ch) = (bw >> ss_x(fctx), bh >> ss_y(fctx));"`, and a `per_axis_units` closure `(64>>ss_x)/32 * (64>>ss_y)/32` asserting 1 / 2 / 4 | MATCHES — and it pins the rule **correctly**. All six pinned strings assert either a luma-grid conversion of a chroma unit or a plane extent; **none** asserts a subsampling-dependent chroma *transform* size. `per_axis_units` agrees with libaom. (Its `ss(1,0)` arm is dead — 4:2:2 is refused.) | +| `refusal_inventory.rs:1533-1668` | the single most direct pin of the rule in the crate: `chroma_w = bw >> ss_x` **then** `unit = (chroma_w.min(32), chroma_h.min(32))` | MATCHES — it pins the **correct composition order** (halve first, then cap per axis), the opposite of the wrong rule. Its 8-case walk is checked against the five-arm table. | +| `refusal_inventory.rs:1577` | source-scan pin of `"(bw >> ss_x(fctx), bh >> ss_y(fctx))"` | MATCHES (plane extent) | +| `refusal_inventory.rs:1654-1656` | a doc citing `av1_ss_size_lookup[BLOCK_8X16][1][1] = BLOCK_4X8 → max_txsize_rect_lookup[BLOCK_4X8] = TX_4X8` via `av1_get_max_uv_txsize` | MATCHES — measured: `BLOCK_8X16` at 4:2:0 → plane BLOCK_4X8 → TX_4X8 ✓ | +| `restoration.rs:439-440`, `531-542`, `1504` | `>> ss` on a plane dimension, an LR mi step, an LR stripe height | MATCHES (plane/coord — the charter's explicit non-sites) | +| `gate_coverage.rs`, `census.rs` | census of aomenc tool-FLAG **spellings** (`enable-tx64`, `enable-tx-size-search`, `enable-rect-tx`); `census.rs:198` lists the four `tx_size_cat*` symbol names | MATCHES — no transform-size site. **`enable-tx64` is an encoder switch, not a transform size, and carries no 64→32 step**; nothing here pins the wrong rule | +| `examples/decode_probe.rs:105-111`, `examples/syntax_census.rs:56-72`, `enc_probe.rs`, `dump_yuv.rs`, `alloc_probe.rs` | print counters / classify symbol names | MATCHES (no site) | +| `mc.rs`, `intra.rs`, `warp.rs`, `sequence.rs`, `superres.rs`, `bits.rs`, `msac.rs`, `compound.rs`, `motion.rs`, `motion_field.rs`, `speed.rs`, `par.rs`, `film_grain.rs`, `filter_search.rs`, `encoder.rs`, `frame.rs` | `frame.rs`'s two near-hits are the `tx_mode_select` header bit and `using_qmatrix`/`qm_y`/`qm_u` (a frame flag and matrix **levels**) | MATCHES — no transform-size site in any of them | + +--- + +## 2. Verdicts + +### 2.1 Transform sizes: 0 MISMATCH + +Every site that can reach a 64 axis at 4:4:4 either carries +`av1_get_adjusted_tx_size` (as a `.min(32)` per axis, an explicit five-arm +table, a `if side >= 64 { 32 }`, or — in the mu-chunk walks — as a division +`chunk_chroma / cu_tx` that reads 2×2 = four units) or is provably never +reachable with one. The rule's central case — a 4:4:4 128x128 block coding +**four** 32x32 chroma units per 64x64 mu chunk — is implemented at four +independent sites (`14115`, `40136`, `41923`, `42900`) and confirmed against +the oracle's own trace (§0.2). + +The luma `min(64)` and `min(32)` clamps are a **different** libaom rule +(`max_txsize_rect_lookup`'s ceiling and `av1_get_max_eob`'s 1024 cap, with +`av1_scan_orders` aliasing every 64-axis scan to `default_scan_32x32`) and are +all correct; the audit keeps them separate from the chroma rule so the two are +never conflated. + +### 2.2 Two MISMATCHes, both non-transform — chartered, not fixed here + +**C1 — `decode.rs:9103`, `suppress_internal_lf_edges`'s hardcoded `/2`.** +Ship a 4:4:4 + `--sb-size=128` **skipped inter 128 root** fixture. With it: +replace `(w_mi * MI / 2)` with `(w_mi * MI) >> ss_x(fctx)` and +`(h_mi * MI / 2)` with `(h_mi * MI) >> ss_y(fctx)` — the identical two-line +form its sibling `fill_lf_grid_rect` (`9126-9127`) already uses — then +red-before by reverting only the two shifts. The missing witness is the whole +blocker: a deblocker difference is not observable on any pinned 4:2:0 or +4:4:4 intra fixture, and per `lanes/av1tilerows.report.md:254-256` ("I could +not build a witness, and I will not ship an unvalidated change into a path with +zero coverage") an unproven change here would be the same mistake in reverse. +Consequence if shipped unfixed: at 4:4:4 a SKIP inter 128 root publishes a +chroma extent of 64 where libaom's block has 128, so the deblocker filters an +internal chroma edge at 64 that libaom's `set_one_param_for_line_*` suppresses. + +**C2 — `decode.rs:42974`, `around_mi` where the arm's own twin uses +`around_mi_rect`.** This one *is* a one-line change and it is provably inert at +4:2:0 and 4:4:4 (`around_mi_rect(m, w, h)` with `w == h` is the same loop over +the same arrays — compare `9553-9579` with `9662-9686`; the identity set below +is the empirical check). It is still chartered rather than fixed, for two +reasons that the brief's own rule demands: (a) it is **4:2:2-only**, and 4:2:2 +is refused by name at the sequence header, so no gate in the repo can be made +red — a fix I cannot prove red-before is exactly what the brief says not to +ship; (b) it is a *context-geometry* defect, not a transform size, so it is +outside the class this lane was chartered to fix. A 4:2:2 lane with +`EC_AV1_ALLOW_422_PROBE` (never committed) can land it in one line. + +### 2.3 Three UNVERIFIED open cells (all pre-existing, all already named) + +`decode.rs:13361-13373` and `decode.rs:16558`: the intra-BC rect-strip chroma +footprint is hardcoded `bw/2, bh/2` on the lossy side, where libaom's plane +block at 4:4:4 is the block itself. Both belong to the open cell recorded at +`lanes/av1444rect.report.md:258,343,373`; the 64-axis path (`16558`) has no +`lossless` scoping, which the report should be amended to say. **Missing for +both: a 4:4:4 lossy `use_intrabc` rect-strip fixture** — zero of the pinned +fixtures decode one. Decodes wrong if reached: half the chroma plane block of a +4:4:4 lossy intrabc strip. + +### 2.4 Stale prose (not a defect) + +`decode.rs:9123-9125` says `uv_tx_w`'s derivation is "under 4:2:0". The code is +subsampling-generic and **correct at 4:4:4**, where the adjusted step is the +load-bearing part. Worth a comment edit in the next lane that touches the file; +it is the kind of stale qualifier that is how the wrong rule got reintroduced +once already. + +--- + +## 3. Refuted rules + +### 3.1 The rule that was wrong + +> **"`cu_tx` must be `32 << ss_x(fctx)`; at 4:4:4 `av1_get_max_uv_txsize` +> returns TX_64X64, so `cu_tx` is 64."** + +**REFUTED.** `blockd.h:1371` (the ticket's own citation) is the *body* of +`av1_get_max_uv_txsize`, and its last line is +`return av1_get_adjusted_tx_size(uv_tx);`. `av1_get_adjusted_tx_size` +(`blockd.h:1361`) takes **no subsampling argument** and maps `TX_64X64`, +`TX_64X32`, `TX_32X64` to `TX_32X32` **unconditionally**. Measured against +libaom's own code, `av1_get_max_uv_txsize(BLOCK_128X128, 0, 0) == TX_32X32`. +The ticket read `max_txsize_rect_lookup[BLOCK_128X128] = TX_64X64` and stopped +one line short, annotating the adjustment as "adjusted → itself". + +The refutation has two independent witnesses, both reproduced in this lane: + +1. A C probe linked against `~/.cache/aom-oracle/build/libaom.a` calling the + real three functions over all 22 block sizes × 4 `(ss_x, ss_y)` + (`~/.cache/txaudit/probe.c`, output `out.txt`). +2. The oracle's own `EC_TRACE_COEFF` on a 4:4:4 `--sb-size=128` stream: luma + reads `tx_size=4` (TX_64X64) eight times, chroma reads it **zero** times and + reads **zero** 64-axis chroma shapes; every 64x64 luma unit is followed by + exactly **four** `tx_size=3` (TX_32X32) chroma units per plane. + +### 3.2 Where the wrong rule spread + +| where | what | state | +|---|---|---| +| `lanes/av1tilerows.report.md:265-281` | the **origin**. §8 "Recommendation" states "`av1_get_max_uv_txsize(BLOCK_128X128, 0, 0)` is `max_txsize_rect_lookup[BLOCK_128X128]` = `TX_64X64` (adjusted → itself)" and recommends repairing the site to `cu_tx = 32 << ss_x(fctx)`, `luma_span = cu_tx << ss_x(fctx)` | **RETRACTED in place by this lane** — a `RETRACTED by lanes/av1txsizeaudit.report.md §3.1` blockquote now sits on item 3 and on the Recommendation, quoting the correction and the oracle measurement, so the claim cannot be lifted out of context again | +| a census item, and a charter I wrote from it | the same claim, propagated | never committed to `crates/ec-av1/src/**` | +| `crates/ec-av1/src/**` | `git log --all -S"cu_tx = 32 << ss" -- crates/ec-av1/src` → **no commits**; `-S"cu_tx = 32usize << ss"` → **no commits** | **never implemented.** The wrong rule never reached code. | +| the four live `cu_tx` sites (`decode.rs:14115`, `40136`, `41923`, `42900`) | all `let cu_tx = 32usize;` with the per-axis walk around them | **correct** | +| `crates/ec-av1/src/stream.rs:2458-2492` and `refusal_inventory.rs:1533-1668` | the two source-scan tests that pin chroma-size shape | both pin the rule **correctly** | + +The wrong rule's most seductive property is that its 4:2:0 identity argument is +true: `32 << 1 == 64`, and at 4:2:0 the adjusted step is a no-op on a +`.min(32)`-shaped result. So the "no-op for the only format with committed +coverage" argument in `av1tilerows.report.md:279-281` is *sound* and still +licenses a change that is wrong at 4:4:4 — the one format the identity argument +says nothing about. **The 4:2:0 identity argument cannot certify a change to a +subsampling-parameterised expression; only the measured 4:4:4 value can.** + +### 3.3 A second wrong table, in this lane's own charter + +The ground-truth table I put in the four scouts' briefs was reconstructed from +memory rather than measured, and **23 of its 66 rows were wrong** (15 real +errors + 8 `(shape, ss)` pairs that map to `BLOCK_INVALID`, which I had noted +but did not tabulate). Seven errors were in the **4:2:0** column — `8X8`, +`16X8`, `32X16`, `64X32`, `16X4`, `32X8`, `64X16` — and eight in the 4:2:2 +column, which I had written as a verbatim copy of 4:4:4. The measured table in +§1.0 is authoritative. No verdict in this report was decided against the bad +table: every scout re-derived the rule from the cited functions, which is how +the discrepancy surfaced (they flagged the charter's table, not the code). The +concrete lesson: **a ground-truth table handed to a subagent must be produced +by running the reference, not by transcribing it.** The `av1tilerows` report +made the same class of error with `max_txsize_rect_lookup` — it read the table +correctly and misread the *function that consumes it*. + +### 3.4 Rules confirmed, for the record + +* `cu_tx == 32` at **every** subsampling; the 4:4:4 unit count is + `((64 >> ss_x) / 32) × ((64 >> ss_y) / 32)` = **1 / 2 / 4** at 4:2:0 / 4:2:2 / + 4:4:4. +* A per-axis `.min(32)` on an **already-subsampled** chroma extent is an exact + transcription of `av1_get_adjusted_tx_size` over the whole `TX_SIZE` domain. +* A per-axis `<< ss` on a chroma unit is the unit's **LUMA** footprint, not its + transform size. The two must not be conflated — that conflation is the + ticket's core error. +* At 4:2:0 the chroma transform is ≤ 32 on **both** axes for **every** block + size, so a hardcoded 32 that is right at 4:2:0 proves nothing at 4:4:4. +* 4:2:2 is refused by name at the sequence header, so the 4:2:2 column — the + only one where the per-axis walks are actually *distinguishable* — is + unreachable in committed code. Every 4:2:2-only defect in this report + therefore needs the env-gated probe to witness, and the probe must never be + committed. + +--- + +## 4. Invariants + +All run in `/home/user/.cache/wt/av1txsizeaudit` at `2fcc577a` +(main `9b2f6c9d` + the `4bfe8d8e` fix rebased), `CARGO_TARGET_DIR=$HOME/.cache/cargo-target`. + +| gate | result | +|---|---| +| `a_real_aomenc_444_intra_in_inter_128_root_codes_chroma_per_mu_chunk_unit_pixel_exact` | **ok** — `3 decode-order frames pixel-exact (0 hidden), intra_128_in_inter=1 mu_chunk_chroma_reads=4` | +| `a_real_aomenc_inter_128x128_none_root_decodes_pixel_exact` | ok | +| `a_real_aomenc_128x128_none_inter_blocks_coded_chroma_per_mu_chunk_decodes_pixel_exact` | ok | +| `a_real_aomenc_lossless_444_key_frame_decodes_sample_exact` | ok | +| `a_lossless_444_min_partition64_inter_stream_decodes_pixel_exact` | ok | +| `a_lossless_444_128_root_lossless_stream_reads_chunks_chunk_major` | ok | +| `a_lossless_444_intrabc_rect_leaf_walks_per_4x4_units` | ok | +| `a_lossless_444_rect16x4_chroma_reach_is_ss_aware` | ok | +| `a_444_lossless_sb64_intrabc_rect_chroma_walks_4x4_units` | ok | +| `a_lossless_444_10bit_inter_stream_decodes_pixel_exact` | ok | +| `a_lossless_444_min_partition8_inter_stream_decodes_sample_exact` | ok | +| `a_lossless_444_defaultp_inter_strip_stream_decodes_byte_exact` | ok | +| `a_lossless_444_8bit_untiled_control_and_its_two_tile_column_sibling_decode_pixel_exact` | ok | + +13 passed / 0 failed. The 4:2:0 identity (`>> ss == /2` there) and the new 4:4:4 +gate both hold. No production file was edited by this lane; the tree is +`9b2f6c9d` + the replayed fix, so every row above is a statement about the +tree the fix will land on. + +Artifacts: `~/.cache/txaudit/probe.c`, `~/.cache/txaudit/out.txt`, +`~/.cache/txaudit/table.md`, `~/.cache/txaudit/grad444.obu`, +`~/.cache/txaudit/coeffs.txt`, `~/.cache/txaudit/gate444.log`, +`~/.cache/txaudit/idset.log`. + +--- + +## 5. Follow-up: C1 and C2 chased to a decision + +This section answers the follow-up: C1 gets the witness it was chartered +without, the answer is **not** the one the charter assumed, and — after a +reconciliation with `Agent12-2`'s independent sweep of the same site — C1 is +**LANDED** with a red-before-proven source-scan gate. C2 gets its one-line +fix, a measurement plan, and a 50-site sweep of its class; C2 is **not** +landed, and the reason is given in §5.2. + +### 5.0 Reconciliation with `Agent12-2` — was `fctx` in scope? + +`Agent12-2` swept hardcoded chroma halvings independently, reached this same +function, and recorded it as **unfixable without threading `fctx` into +`Neighbours`**, because the method is a `Neighbours` method with no `fctx` +parameter and its single caller passes no format test. **That structural +finding is correct and I confirm it.** `Neighbours` (decode.rs:8444) has no +`fctx` field — its fields are the neighbour bands (`above`, `left`, +`above_mode`, `left_mode`, `above_uv_mode`, `left_uv_mode`, `above_side`, +`left_side`, `above_side_mi`, `left_side_mi`, …) and nothing that carries a +subsampling. + +And to answer the question directly, because it changes what the measurement +in §5.1.2 was worth: **`fctx` was NOT in scope, and my first attempt did not +compile.** + +```text +error[E0609]: no field `fctx` on type `&mut decode::Neighbours` + --> (the line I had written as `ss_x(self.fctx)`) +``` + +I then threaded it — one parameter on the method signature, one argument at +the single call site — and it built clean. **So the `uv_w 64 -> 128` +measurement in §5.1.2 was a real change with real threading, not a temporary +hardcode and not a probe hack.** Had it been a hardcode, §5.1.2's zero-pixel +result would have been meaningless; it is not. + +The minimal threading, stated as shipped: + +| what | change | +|---|---| +| `suppress_internal_lf_edges` signature | `+ fctx: &FrameCtx` — one parameter | +| its single caller (was `43956`) | `+ fctx` — one argument | +| `struct Neighbours` | **unchanged** — no new field | +| call sites total | **1** | + +Arithmetic first, then measurement, for the 4:2:0 no-op claim: `w_mi * MI` is +a multiple of `MI = 4`, hence even, hence at `ss_x == 1` +`(w_mi * MI) / 2 == (w_mi * MI) >> 1` for **every** reachable `w_mi`. Exact +identity, not an approximation. Then measured: 13/13 identity gates green on +the landed tree (§4 / §5.5), including the two 4:2:0 128-root gates +`a_real_aomenc_inter_128x128_none_root_decodes_pixel_exact` and +`a_real_aomenc_128x128_none_inter_blocks_coded_chroma_per_mu_chunk_decodes_pixel_exact`. + +**Line numbers, as of the rebase onto `08f8ffb3`.** §1's tables were measured on +the audit base (`2fcc577a`) and §5's against the pre-rebase tree. The branch is +now rebased onto current main, and **every decode.rs reference in this report +carries the old base's numbering**. The mapping for the sites this report +cites most (decode.rs is 56 316 lines on the new base): + +| site | old base | on `08f8ffb3` | +|---|---|---| +| `suppress_internal_lf_edges` (C1) | 9102 | **9277** | +| its caller (C1) | 43956 | **44297** | +| C2's `around_mi(unit_mi, unit_luma_w)` | 42974 | **43315** | +| `around_mi(lmi, B4)` (`decode_inter_sub8_split4`) | 44401 | **44742** | +| `around_mi(group_mi, 8)` (`decode_intra_sub8_leaf`) | 44913 | **45254** | +| `decode_intra_sub8_leaf` (fn) | 44999 | **45340** | +| `decode_intrabc_owned_rect`'s `bw / 2, bh / 2` (open cell) | 16558 | **16832** | +| `cfl_ac_q3_at`'s `/ 2` (non-site) | 19636 | **19920** | + +Two independent causes, and they compose: the landed C1 change adds a 26-line +doc comment, and main's wave-3 merges added ~693 lines to decode.rs between +the audit base and `08f8ffb3`. `git diff 08f8ffb3 --stat` is **byte-identical +in shape** to `git diff 9b2f6c9d a5737713 --stat` — same 7 files, same +1511 insertions / 103 deletions — which is the signal that main's waves did not +collide with any of my hunks (§5.5). + +The 50-site `around_mi` sweep in §5.3 is unaffected in substance: the +decode.rs diff touches **zero** gather call sites +(`git show HEAD -- crates/ | grep -cE '^[+-].*around_mi\('` = 0), so every +verdict stands and only the line numbers move. + +### 5.1 C1 — the witness EXISTS, and it proves the defect is LATENT + +`lanes/av1txsizeaudit.report.md` §2.2 chartered C1 with "no fixture exists". +**That was wrong, and the correction matters more than the charter.** The +arm is reachable, the recipe is trivial, and the guard fires on the first +try. The pixels still match libaom — and that is not a failure to find the +witness, it is a proof that no witness can exist. + +#### 5.1.1 The recipe (2 commands, no probe, no knob hunting) + +```sh +# a STATIC 128x256 4:4:4 y4m. Static is the operative ingredient: identical +# frames give zero MV and zero residual, so the RD picks a whole-block skip. +# Moving content never reaches the arm. +python3 -c " +w,h,n=128,256,4 +Y=[[((x//8+y//8)*60+30)%256 for x in range(w)] for y in range(h)] +U=[[((x//16)*60+30)%256 for x in range(w)] for y in range(h)] +V=[[((y//16)*60+30)%256 for x in range(w)] for y in range(h)] +f=open('static.y4m','wb'); f.write(b'YUV4MPEG2 W%d H%d F25:1 Ip A1:1 C444\n'%(w,h)) +for k in range(n): + f.write(b'FRAME\n') + for P in (Y,U,V): f.write(bytes(v for row in P for v in row)) +f.close()" + +~/.cache/aom-oracle/build/aomenc --codec=av1 --profile=1 --sb-size=128 \ + --limit=4 --cq-level=60 -o c1_static.obu static.y4m +``` + +`--profile=1` (4:4:4) and `--sb-size=128` are the two load-bearing knobs. +`--cq-level` is **not** load-bearing — it produced byte-identical streams at +20/40/60, because the residual is already zero. The SB is 128x128 so a +`--limit=4` encode gives 2 roots per frame. + +| stream | sha256 | guard fires | frames | +|---|---|---|---| +| `c1_static.obu` | `363672a2db670e08d70ee9e6c4ab40d8fc1f6b1bb1276cd5d88bbcb6925f57c8` | 6 | 4 | +| `c1_step.obu` (hard vertical step at x=64) | `07b2783811d1ea209dacc18f06bb166cbfe635d3c7c40ec5d967795c9d2cd9d8` | 6 | 4 | +| `bars_20.obu` (16-px bars, static) | `1c5b144c47eb5b858c722e87b4ed2d69a470ad94b8b8f507452736b0bac9fca0` | 10 | 6 | +| `grad6_20.obu` (moving gradient) | `5facd9355482cada137870e5c94c7410b97bdd27ca96c436afa13371ac9d5bd0` | 2 | 6 | +| `noise444_20.obu` (static noise) | `c9c1b48205da19d12a061c44a04f90baefc91362b28667c996d7064415b75ed7` | 6 | 6 | + +**30 guard fires across 26 frames / 2 555 904 samples**, all at ss (0, 0), all +`w_mi = h_mi = 32` (a 128x128 luma root). The oracle agrees independently — +`aomdec`'s own `AOMMB` rung prints `mi=(0,0) mode=13 rf=(1,-1) mv0=(0,0) +mv1=(0,0) skip=1`: skip mode, compound, zero MV, `skip=1`. + +#### 5.1.2 The red-before that cannot exist + +The fix is one expression, and it is the sibling's exact form: + +```rust +- let (uv_w, uv_h) = ((w_mi * MI / 2).max(4) as u8, (h_mi * MI / 2).max(4) as u8); ++ let (uv_w, uv_h) = ( ++ ((w_mi * MI) >> ss_x(fctx)).max(4) as u8, ++ ((h_mi * MI) >> ss_y(fctx)).max(4) as u8, ++ ); +``` + +(this also threads `fctx` into `suppress_internal_lf_edges` and its one +caller at `43956`.) Measured, on the corpus above: + +| build | published extent at 4:4:4 | vs oracle | vs the other build | +|---|---|---|---| +| base (`/2`) | `uv_w=64 uv_h=64` | **0** differing of 2 555 904 | — | +| fixed (`>> ss`) | `uv_w=128 uv_h=128` | **0** differing of 2 555 904 | **0** differing | + +**The fix changes the published value from 64 to 128 and changes not one +sample.** So there is no red-before to produce, on this corpus or any other. + +#### 5.1.3 Why — the masking mechanism, named + +The widening exists to defeat the deblocker's alignment gate at +`decode.rs:29514`: + +```rust +if cur_tx == 0 || (if c.dir == 0 { x0 } else { y0 }) & (cur_tx as usize - 1) != 0 { + return None; +} +``` + +With `cur_tx = 64` a chroma edge at `x0 = 64` survives (`64 & 63 == 0`); with +`cur_tx = 128` it dies (`64 & 127 = 64`). So the widening *does* do what it +was written to do. But the survivor then meets, 68 lines later, the **same +libaom rule applied at the correct place** — `decode.rs:29582-29589`: + +```rust +// spec 7.14.2 / libaom `set_lpf_parameters`: a transform edge between two +// SKIPPED INTER blocks is filtered only when it is also a prediction +// (coded-block) edge ... +if !pu_edge + && cur_ref != 0 + && pv_ref != 0 + && n.skip_at(mi_r, mi_c) + && n.skip_at(pv_mi_r, pv_mi_c) +{ + return None; +} +``` + +Inside a single skipped 128 root, **every** internal edge satisfies all four +terms: `pu_edge` is false because the chroma `plane_dim` is +`((32 * 4) >> 0) = 128` and `64 % 128 != 0` (`decode.rs:29577-29578`), and +both `skip_at` are true and both refs nonzero because both cells are the same +compound skip-mode block. At the block's own boundary (`x0 = 128`) both the +buggy and the fixed value pass the alignment gate identically, and there the +edge *is* a `pu_edge`, so both builds filter it the same way. Hence zero +observable difference, for every stream. + +**This is total, not incidental.** `suppress_internal_lf_edges` is only ever +called for a block that is itself skipped (`43954`: `skip_inter_128 = skip && +is_inter && write_w.max(write_h) > 64`), so there is no input on which one +side of an internal edge is not skipped. The defect cannot be unmasked by any +fixture, at any `--cq-level`, on any content. + +#### 5.1.4 Disposition — C1 LANDED, for spec fidelity, with no observable effect + +The original charter said "no fixture exists". Both halves of that were wrong +in different ways, and the corrections matter more than the charter: + +* **The fixture exists** (§5.1.1): two commands, arm fires on the first try, + 30 fires over 26 frames across five streams. `Agent12-2`'s independent rung + (5 hits over the 444 gate set) reached the same reachability conclusion by a + different route; the two agree. +* **C1 is a real mismatch against libaom.** `get_plane_block_size(BLOCK_128X128, + 0, 0)` is `BLOCK_128X128` (`common_data.c:38`), so a 128 root's own chroma + extent at 4:4:4 is **128**, not the 64 the `/2` published. Measured, not + argued (§1.0, §0.2). +* **C1 is provably unobservable**, by the mechanism in §5.1.3 and the 26-frame + measurement in §5.1.2 — and **total, not incidental**, because the method + is only ever called for a block that is itself skipped. +* **LANDED**, in this lane, on Main's authority, with the disposition sentence + that was missing: **fix for spec fidelity, no observable effect on any + current format.** The masking mechanism is recorded in the method's own doc + comment so no future reader hunts for a pixel regression that cannot exist. +* **And one of my own claims is retracted here.** My first version of this + disposition said "*no gate can be written for it*" because no *pixel* gate + can exist. That was overreaching: a **source-scan gate can**, and it is + landed and **red-before proven** (§5.1.5). The precise claim is: *no pixel + gate can exist; the source scan is the only instrument, and it works.* +* **What is NOT an unblock condition:** fixture engineering. The recipe is + above; it works. The old blocker was structural, and it has been discharged. + +#### 5.1.5 The gate, and the red-before + +New gate +`refusal_inventory::tests::the_skipped_128_root_chroma_suppression_publishes_the_blocks_own_per_axis_chroma_extent` +(`refusal_inventory.rs:1765-1829`). It reads `suppress_internal_lf_edges`'s own +body out of `decode.rs` — the same class-and-reader-move-together instrument +this file already uses at `1573` and `1577` — and asserts three things: + +1. the body contains `((w_mi * MI) >> ss_x(fctx))` and + `((h_mi * MI) >> ss_y(fctx))`; +2. the body contains **neither** `w_mi * MI / 2` nor `h_mi * MI / 2`; +3. the signature carries `fctx: &FrameCtx` — pinning the threading itself, so + a future edit that drops the parameter (and with it the only route to the + subsampling) fails loudly instead of reintroducing a literal. + +**Red-before, produced by reverting ONLY the arithmetic** (the gate, the +threaded parameter, the caller argument and the doc comment all kept): + +```text +line 9130 -> let (uv_w, uv_h) = ((w_mi * MI / 2).max(4) as u8, (h_mi * MI / 2).max(4) as u8); + +thread '...the_skipped_128_root_chroma_suppression...' panicked at + crates/ec-av1/src/refusal_inventory.rs:1807:9: +suppress_internal_lf_edges must publish the block's own chroma extent per axis +-- `w_mi * MI >> ss_x(fctx)`, not a hardcoded `/2` +test result: FAILED. 0 passed; 1 failed +``` + +Restored -> `ok`. **This is the red-before §5.1.2 said could not exist.** It +cannot exist on *pixels*; it exists on the source scan, which is the correct +instrument for a value that is provably correct and provably unobservable. + +Identity set on the landed tree: **13 passed / 0 failed** (§5.5). + +### 5.2 C2 — the one-line fix, and why it is not landed + +`decode.rs:42974`: + +```rust +- let cu_around = neighbours.around_mi(unit_mi, unit_luma_w); ++ let cu_around = ++ neighbours.around_mi_rect(unit_mi, unit_luma_w, unit_luma_h); +``` + +`unit_luma_w`/`unit_luma_h` are the per-axis pair computed at `42907-42908`; +the arm's own doc comment at `42904-42906` even says the size is "the size +`around_mi` / `record_mi_chroma` want", and `record_mi_chroma` at `42996` is +per axis — so `around_mi` at `42974` is the leftover of the same collapse the +lane's fix repaired everywhere else in the arm. The inter twin is +`14191-14192`, with the same pair at `40212` and `41999`. + +**Measured:** applied and reverted. Five gates re-run on the patched tree +(`a_real_aomenc_444_intra_in_inter_128_root_...`, `..._inter_128x128_none_root_...`, +`..._128x128_none_inter_blocks_coded_chroma_per_mu_chunk_...`, +`a_lossless_444_10bit_inter_...`, `a_lossless_444_rect16x4_chroma_reach_is_ss_aware`) +— **5/5 ok**, byte-identical, exactly as §5.3's reachability predicts. + +**Not landed**, per instruction and on the merits: the arm is `side > 64` +(`42871`) and 4:2:2 is refused by name at the sequence header +(`stream.rs:1749-1754`, gate `a_non_420_subsampled_sequence_header_is_refused_by_name`), +so there is no committed stream — and no committable one — on which this line +can be red. A change that cannot be made red cannot be gated, and an ungated +change to a 4:2:2 path is the exact hazard `lanes/av1ibc128arm.report.md`'s +`EC_AV1_ALLOW_422_PROBE` note exists to prevent. + +**Measurement plan for whenever 4:2:2 is unblocked** (a 4:2:2 lift lane, probe +never committed): + +1. Encode `aomenc --codec=av1 --profile=2 --sb-size=128 --limit=4` over a + static 128x256 `C422` y4m (profile 2 = 4:2:2), static for the same + reason as C1: zero MV + zero residual keeps the 128 root on the arm. +2. Decode with `EC_AV1_ALLOW_422_PROBE=1` and `EC_DCDUMP=1`. `around_mi_rect` + already dumps `EC_DCDUMP ... wh=(w,h) above=[..] left=[..]` (`9707-9711`); + the square `around_mi` does not dump at all, which is itself the + observable: at `ss (1,0)` the fixed build prints `wh=(64,32)` and a left + band of 8 mi, the unfixed build a left band of 16. +3. Red-before: revert the one line, re-run, the `EC_DCDUMP` left band doubles + and `dc_sign_ctx` diverges on the first chroma unit of the 128 root — an + arithmetic-coder fork, visible as an `EC_COEFF_STEP ... dcctx=` mismatch + against the oracle's own `EC_TRACE_COEFF`. +4. Green: re-apply, the fork is gone. The 4:2:0 and 4:4:4 identity sets must + not move (they provably cannot; `unit_luma_w == unit_luma_h` at both). + +### 5.3 The C2 class sweep — 50 `around_mi(` sites, 1 instance, 0 new + +The question the class asks: *is the size passed to the square gather provably +equal to the height libaom would use at that same point?* All 50 sites were +resolved by reading each one's enclosing guard. **49 correct, 1 instance (the +known `42974`), 0 unresolved.** Critically, **no luma rect-transform leaf +passes one axis unguarded** — so there is no 4:2:0-reachable instance, which +is what would have made this a live defect rather than a 4:2:2 lift-blocker. + +| pattern | sites | why correct | +|---|---|---| +| explicit `if tw == th` guard | 13640, 16691, 17240, 40057, 41838, 46336 | each has its `around_mi_rect(tu_mi, tw, th)` sibling in the same `else` (13661, 16711, 17260, 40088, 41869, 46363) | +| precomputed `rect_unit` flag | 17740 | this is the `else` of `rect_unit = tx_w != tx_h`; twin 17689 | +| `(tw, th) == (4, 4)` guard | 25748 | twin 25759 | +| structurally square, no assert | 14089, 21463, 42857, 49421 | the leaf list is square by construction (a square tree root + `sub_tx_size_map`, which maps only 1:4 shapes to rect; or `read_block_tx_size`'s `is_inter=false` path pushing `(row, col, tx, tx)` from a scalar `read_tx_size`), **and** the coefficient reader is square-only, so a rect leaf would break the read before the gather mattered. 14089 documents the invariant with `debug_assert_eq!`; the other three rest on the construction argument alone — see the caveat below | +| `!rect_tu` block guard | 40008, 40014, 41726, 41732, 43169 | on the non-rect arm, where the block's luma plane is provably `side × side`; the 4:2:2 case is rerouted to `around_mi_422_chroma` or a `chroma_w == chroma_h` test | +| sub-8x8 4:2:0 group tails | 25300, 25353, 26478 | under an explicit `else` of the `chroma_444` / `chroma_422` arms | +| provably square by arm analysis | 11848 | the final `else` of a four-arm `skip` / `luma_64corner` / `Some(luma_rect)` chain: `luma_rect == None ∧ ¬luma_64corner` implies `tx_w == tx_h`; the read at 11867-11868 also passes `tx_w, tx_w` | +| scalar literals / provably-square scalars | 17214, 18057, 22180, 22962, 23135, 23234, 24961, 25080, 26011, 29066, 29095, 36097, 36275, 40463, 42256, 43273, 44401, 44517, 45203, 45255, 45629, 46920, 47955, 48912, 49508 | `4`, `8`, `MI`, `B4`, or a `chroma_tx`/`logical_tx`/`cu_tx` scalar on an `ss_x == 0 && ss_y == 0` arm. `23234`'s `8` covers 4:2:0 (chroma 4x4 → luma span 8x8 = 2x2 mi) and 4:4:4 lossy (chroma 8x8 → luma 8x8 = 2x2 mi), and 4:2:2 is intercepted at 23242 | +| **INSTANCE** | **42974** | **no `unit_luma_w == unit_luma_h` guard; differs at 4:2:2 only; correct twin `14192`/`40212`/`41999`** | + +The multi-line call at `45744` — `around_mi(if chroma_444 { lmi } else { group_mi }, +if chroma_444 { 4 } else { 8 })` — is **not** an instance: both arms are +scalars, and it sits in the `else` of `chroma_444 && bw != bh` (`45603`), +whose own correct per-axis twin is `around_mi_rect(lmi, bw, bh)` at `45691`. + +**Caveat worth carrying forward (low value today, a trap tomorrow).** Four +sites — `21463`, `42857`, `49421`, `14089` — consume a var-tx or intra leaf +list while **discarding the leaf's height field** (`for &(lr, lc, tw, _th) in +leaves`). They are correct only because the reader is also square-only and +the list is square by construction. If a future change lets any of these arms +see a rect leaf, the gather AND the reader must be split to +`around_mi_rect` in the same step, or the first rect leaf that arrives forks +the coder. + +### 5.4 One adjacent finding, not in the C2 class + +`decode_intra_sub8_leaf` (44999-45827) has **no `chroma_422` branch at all** — +only `chroma_444` (`45488`). At 4:2:2 its 8x8 group's chroma plane block is +4x8, and the gather at `45744` would need `around_mi_422_chroma`'s +every-second-above-cell resampling (`9594`), not the plain per-mi sum. This is +a **missing-422-guard** finding, not a per-axis one, so it is outside C2's +class; it is unreachable while 4:2:2 is refused, and it belongs to the 4:2:2 +lift as a fourth item beside C2. Every sibling 8x8 path does carry the 422 +branch: `decode_leaf8` (`23231`), `decode_inter_block8` (`47962`/`48919`), +`decode_inter_sub8_rect2` (`44811`, `46809`). + +### 5.5 State of the tree — rebased onto `08f8ffb3` + +**C1 is landed; C2 is not.** The C2 one-liner and its `EC_C1_PROBE` +scaffolding were reverted with `git checkout` after measuring, exactly as +§5.2 states. + +This branch was rebased onto current main (`08f8ffb3`) and **one near-miss is +worth recording**, because it is the same trap as the stale-base diff, one +level deeper. The first rebase attempt saved a patch of +`2fcc577a..HEAD` — that range contains only *my* r2/r3 work, because +`2fcc577a` is itself the fix commit replayed on the old main. Applying it to +`08f8ffb3` produced a tree that built, passed `cargo check --all-targets`, and +passed 12 of 13 identity gates — because the intra-in-inter fix and its +`a_real_aomenc_444_intra_in_inter_128_root_codes_chroma_per_mu_chunk_unit_pixel_exact` +gate were **silently absent**: they live in commit `4bfe8d8e`, which is on this +branch and has never been on main. The tell was a green run in which one +named test produced no output line at all. The fix was to diff the whole +branch against the old main, `git diff 9b2f6c9d a5737713`, since +`9b2f6c9d` is an ancestor of `08f8ffb3`; that patch restores all 7 files. + +Scope, checked by shape rather than by the apply's clean status: + +```text +git diff 08f8ffb3 --stat + crates/ec-av1/examples/decode_probe.rs | 5 + + crates/ec-av1/src/decode.rs | 305 +++++++++---- + crates/ec-av1/src/refusal_inventory.rs | 66 +++ + crates/ec-av1/src/stream.rs | 192 ++++++++ + lanes/av1ibc128arm.report.md | 196 ++++++++++++ + lanes/av1tilerows.report.md | 38 +- + lanes/av1txsizeaudit.report.md | 812 +++++++++++++++++++++++++++++++++ + 7 files changed, 1511 insertions(+), 103 deletions(-) +``` + +**Byte-identical in shape to `git diff 9b2f6c9d a5737713 --stat`** — same 7 +files, same 1511/103 — which is the signal that main's wave-3 merges +(+693 lines to decode.rs alone) did not collide with any of my hunks. + +Silent-restore check, the one Main flagged: for each source file, the set of +lines main **deleted** between `9b2f6c9d` and `08f8ffb3` was intersected with +the set of lines my tree **adds**, restricted to distinctive lines +(`length >= 45`, so `} else {` and `assert!(` do not generate noise): + +```text +crates/ec-av1/src/decode.rs : 0 +crates/ec-av1/src/stream.rs : 0 +crates/ec-av1/src/refusal_inventory.rs : 0 +``` + +**Zero.** Nothing another lane removed has been restored. In `decode.rs` the +only removed lines are the three I meant to change plus the one stale doc line +whose "chroma extent (64)" claim is exactly what C1 corrects. + +Re-run on the rebased tree, after `touch`ing both touched sources: + +```text +cargo check -p ec-av1 --all-targets Finished, clean +the new source-scan gate 1 passed / 0 failed +gate_coverage:: 13 passed / 0 failed +refusal_inventory:: 20 passed / 0 failed +the 13-gate identity set 13 passed / 0 failed +``` + +47 tests, 0 failures, including `a_real_aomenc_444_intra_in_inter_128_root_codes_chroma_per_mu_chunk_unit_pixel_exact` +— present and green, which is the check the first rebase attempt silently +failed to run. `~/.cache/txaudit/r4.log`. + +New artifacts: `~/.cache/txaudit/c1/{static,step,bars,grad6,noise444}.y4m`, +`~/.cache/txaudit/c1/*.obu`, `~/.cache/txaudit/c1/sweep.sh`, +`~/.cache/txaudit/full_branch.patch`, `~/.cache/txaudit/r4.log`. + +#### 5.5.1 PROVENANCE — this branch is not only C1 + +Declared, because it is better found here than at merge time. + +**`lanes/av1txsizeaudit` carries TWO lanes' work, not one.** + +| what | produced by | on main? | declared here | +|---|---|---|---| +| the tx-size audit, the C1 fix + gate, the `av1tilerows` retraction | **`lane-av1txsizeaudit`** (this lane; commits `1dbe80d3`, `3b44339c`, `a5737713`, `dc80b6fa`, plus the rebase commits) | no | §1-§5 of this report | +| the 4:4:4 intra-in-inter 128-root per-unit chroma walk (279 lines of `decode.rs`, 192 of `stream.rs`, 5 of `examples/decode_probe.rs`, 196 of `lanes/av1ibc128arm.report.md`) | **`lane-av1ibc128arm`**, commit **`4bfe8d8e`** "av1: 4:4:4 intra-in-inter 128-root mu-chunk chroma as a per-unit walk" | **NEVER MERGED — confirmed** | this table | + +The three checks that establish it, run against `main` directly: + +```text +git merge-base --is-ancestor 4bfe8d8e main -> NO +git grep -c 'a_real_aomenc_444_intra_in_inter_128_root_codes_chroma_per_mu_chunk' main + -- crates/ec-av1/src/stream.rs -> 0 +git grep -n 'luma_span = cu_tx * 2' main -- crates/ec-av1/src/decode.rs + -> main:…:43185 +``` + +That last line is the proof of *non*-merge rather than a re-implementation: +**main still carries the collapsed 4:2:0 arm verbatim** — `let luma_span = +cu_tx * 2;` at `main:crates/ec-av1/src/decode.rs:43185` — which is exactly the +line `4bfe8d8e` deletes. The same string appears 0 times on this branch. So +`4bfe8d8e` is not a duplicate of something already landed; it is unmerged work +riding here, and it is the only copy. + +* **Has it been merged under another name?** No. `git log --all -S"luma_span = + cu_tx * 2"` finds only the two lanes that *created* the class + (`2050a065` lane-av1-ibc128chunk, `29550383` lane-av1-422bigblock) and the + commit that removed it (`4bfe8d8e`). Nothing re-landed it. +* **Does another lane's report claim it?** No. `git grep -ln + "intra_in_inter_128_root" main -- lanes/` returns nothing; + `lanes/av1ibc128arm.report.md` does not exist on main at all + (`git cat-file -e main:lanes/av1ibc128arm.report.md` fails). It exists only + on the unmerged `lane-av1ibc128arm`, whose tip is `4bfe8d8e`. +* **Branch `lane-av1ibc128arm` still exists**, tip `4bfe8d8e`, so this is not an + orphan whose only home is here. + +**The two foreign report files, declared individually:** + +* `lanes/av1ibc128arm.report.md` (+196) — **deliberately kept, and it belongs + to `lane-av1ibc128arm`, not to this lane.** It is the only provenance record + for the 279-line `decode.rs` change and the 4:4:4 gate, and a report that + does not ship with its code is exactly how evidence is lost. It is not + cherry-pick residue: it arrived with `4bfe8d8e`, whole, as part of that + commit. **Merge owner:** if `lane-av1ibc128arm` is also going to be merged, + take the code and this report from whichever branch lands first and drop the + duplicate; do not let both branches add the same path. If it is not going + to be merged separately, this branch must carry it — there is no other copy. +* `lanes/av1tilerows.report.md` (38 changed) — **mine, and deliberately + so.** It is the retraction of the `cu_tx = 32 << ss_x` rule at that report's + own origin (`lanes/av1tilerows.report.md:265-281`, the §8 "Recommendation"), + which is the one committed instance of the refuted rule in the repository. + Zero code, zero gate; a `RETRACTED by lanes/av1txsizeaudit.report.md §3.1` + blockquote plus the correction and the oracle measurement. It must land + whenever this branch lands, or the rule stays re-derivable. + +**Contention to hand to the merge owner, NOT pre-resolved here:** +`decode_intrabc_owned_rect`'s `let (cw, ch) = (bw / 2, bh / 2);` — the open +cell this report lists at §2.3 and §5.0 (line 16558 on the audit base, **16832 +on the current base**) — is being fixed by another lane right now. This +branch does **not** touch that line: `git diff ec4e9528 -- crates/ec-av1/src/decode.rs` +contains no hunk near it, and it appears in this report only as a *finding*. +Expect the region to contend at merge and resolve it there; do not pre-empt it +from here, because the other lane holds the witness and this one holds only +the observation. + +#### 5.5.2 Re-rebase onto `ec4e9528` — a second patch-base trap, same family + +`main` advanced from `08f8ffb3` to `ec4e9528` (one append to +`lanes/av1merge-wave3d.report.md`). The re-rebase repeated r4's error in the +opposite direction, and it is worth recording because the two together are the +whole rule: + +* r4's near-miss: patch from **"my base"** `2fcc577a` — which is itself the + unmerged fix commit — and silently drop that commit's work. +* r5's near-miss: patch from **"the old main"** `9b2f6c9d` — but by then this + branch's tip sat on the *new* chain, so `git diff 9b2f6c9d HEAD` swept in + **all** of main's wave-3 changes: 18 041 patch lines touching `crates/ec-aac` + and binary fixtures, which failed to apply and left an empty diff. + +**The rule both times: the patch's left-hand side must be the commit this +branch's base actually is (`git merge-base HEAD main`), never a remembered +ancestor and never a self-descriptive "my base".** Verify with +`git apply --stat` BEFORE applying — the wrong base is obvious there (it names +files you have never touched) and is invisible in `--3way`'s exit status. + +Correct patch, `git diff 08f8ffb3 99f25b1f`, 1 894 lines, 7 files. After +`git apply --3way` onto `ec4e9528`: + +```text +git diff ec4e9528 --shortstat + 7 files changed, 1679 insertions(+), 103 deletions(-) +``` + +**Identical to the pre-rebase shape**, and the removed-line counts are +identical per file (decode.rs 97, av1tilerows 6, all others 0). Main's move +touched **nothing** under `crates/ec-av1/` +(`git diff 08f8ffb3 ec4e9528 --stat -- crates/ec-av1/` is empty), so +`decode.rs` is 56 316 lines with `suppress_internal_lf_edges` at 9277 and C2 at +43315 — **§5.0's line-shift table is valid verbatim on this base, with no +adjustment.** Silent-restore check against this move: 0/0/0. + +Re-run after `touch`ing both touched sources: + +```text +cargo check -p ec-av1 --all-targets Finished, clean +the new source-scan gate 1 passed / 0 failed +gate_coverage:: 13 passed / 0 failed +refusal_inventory:: 20 passed / 0 failed +the 13-gate identity set 13 passed / 0 failed +``` + +47 tests, 0 failures, 4:4:4 gate present and green. `~/.cache/txaudit/r5.log`.