forge
Explore
Log in

Don't you dare go Hollow

Merge branch 'lane-ab16': 16x16-level HORZ_A/HORZ_B/VERT_A/VERT_B; transform units inside a block take the block's reach row

Browse files at this commit

776f14b4b61b060fdb0f471c322ee7060b9dc9ceAhmet Kaan GümüşParent: 473c7446906e60
Conflict resolutions: cdf.rs kept main's NZ_MAP_CTX_OFFSET_32X64/64X32 rows
(standing hazard) and dropped the lane's rect_nz_map_ctx_offset_tables_are_row_major
test; encode.rs kept main's rect_reach_tables/table_row form; decode.rs took the
lane's four-arm AB block, retargeted onto main's decode_leaf8(prev_leaf: Option)
signature; write_back_split_modes and Reach::in_vert_ab carried over from the lane.
crates/ec-av1/src/decode.rsmodified+175 -117
@@ -861,6 +861,41 @@ pub(crate) fn vert_b_intra_hits() -> usize {
861861 VERT_B_INTRA_HITS.with(|c| c.get())
862862 }
863863
864+// lane-ab16 r1: how many 16x16-level AB partitions fired, per arm, in
865+// `PARTITION_HORZ_A`, `_HORZ_B`, `_VERT_A`, `_VERT_B` order. Each arm is two
866+// 8x8 squares (`decode_leaf8`) plus one 16x8/8x16 strip (`decode_leaf_rect`,
867+// the non-skip coefficient path lane-rectx proved); the gate hard-asserts
868+// every arm separately so a run where aomenc's RD only picked one cannot
869+// pass as proof of four.
870+thread_local! {
871+ static AB16_HITS: std::cell::Cell<[usize; 4]> = const { std::cell::Cell::new([0; 4]) };
872+}
873+
874+/// [`AB16_HITS`] per arm (HORZ_A, HORZ_B, VERT_A, VERT_B at 16x16).
875+thread_local! {
876+ /// 4x4 transform units decoded inside an 8x8 square of a
877+ /// `PARTITION_VERT_A`/`_B` -- the exact call that panicked before
878+ /// [`crate::encode::Reach::of_tu`] (lane-ab16 r2), so the gate can prove
879+ /// a real `--enable-tx-size-search=1` stream reaches it.
880+ static VERT_AB_TX4_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
881+}
882+
883+pub(crate) fn vert_ab_tx4_hits() -> usize {
884+ VERT_AB_TX4_HITS.with(std::cell::Cell::get)
885+}
886+
887+pub(crate) fn ab16_hits_by_arm() -> [usize; 4] {
888+ AB16_HITS.with(std::cell::Cell::get)
889+}
890+
891+fn bump_ab16(arm: usize) {
892+ AB16_HITS.with(|c| {
893+ let mut v = c.get();
894+ v[arm] += 1;
895+ c.set(v);
896+ });
897+}
898+
864899 // How many `partition_w16` reads resolved to a plain `PARTITION_HORZ`/
865900 // `PARTITION_VERT` (lane-rect16 r2): re-measuring after the VERT_B fix above
866901 // showed mandelbrot's real first-hit blocker is this plain arm at mi=(0,7),
@@ -5090,21 +5125,6 @@ fn decode_block_rect(
50905125 vec![0i32; chroma_w * chroma_h],
50915126 ],
50925127 );
5093- } else if (bw, bh) != (32, 16) && (bw, bh) != (16, 32) {
5094- // lane-rect16 r1: a real (non-skip) coefficient read at this size
5095- // (8x16/16x32 VERT_B's own left strip) is not ported -- it needs its
5096- // own `TxbSet`/`eob_pt` tables (a true 128-position luma group has no
5097- // `EOB_PT_128_LUMA` in this decoder yet, only the *chroma* one
5098- // `lane-rectwire` built for `ChromaRect16x8`) and, unlike the 32x32
5099- // sqr-up case `LumaRect32x16` safely skips, `get_ext_tx_set_type`
5100- // does NOT return `EXT_TX_SET_DCTONLY` at a 16x16 sqr-up under this
5101- // encoder's reduced_tx_set -- a real `tx_type` symbol may be coded
5102- // that no table here reads. Refused by name rather than guess-decoded
5103- // or silently desynced.
5104- return Err(unsupported(
5105- "a coded (non-skip) HORZ_B/VERT_B rect strip below 16x16 (this decoder ports only \
5106- the skip case at this size)",
5107- ));
51085128 } else {
51095129 // lane-rectwire r2: real coefficients. `get_txsize_entropy_ctx`
51105130 // reduces both size pairs to their square-up CDF sets
@@ -7370,7 +7390,7 @@ fn decode_block(
73707390 let tu_px = px + tu_col * logical_tx;
73717391 let tu_py = py + tu_row * logical_tx;
73727392 let tu_around = neighbours.around_mi(tu_mi, logical_tx)[0];
7373- let tu_reach = Reach::of(logical_tx, tu_px, tu_py, y.width, y.height);
7393+ let tu_reach = Reach::of_tu(side, logical_tx, tu_px, tu_py, y.width, y.height);
73747394 // This transform unit's own bsize (`logical_tx`) is smaller
73757395 // than the block it sits in (`side`), so `txb_skip_ctx` is
73767396 // the neighbour-magnitude table, not the lone-TU 0 (spec
@@ -7507,6 +7527,20 @@ fn decode_block(
75077527 /// leaves happen to share a mode. `done` may be short at the true frame edge
75087528 /// (the straddle caller filters positions off the frame), so each side falls
75097529 /// back to the last leaf actually decoded.
7530+fn write_back_split_modes(
7531+ neighbours: &mut Neighbours,
7532+ done: &[((usize, usize), usize)],
7533+ parent_mi: (usize, usize),
7534+ slot: (usize, usize),
7535+) {
7536+ let (sr, sc) = slot;
7537+ let Some(&(_, last)) = done.last() else {
7538+ return;
7539+ };
7540+ let find = |mi: (usize, usize)| done.iter().find(|&&(at, _)| at == mi).map(|&(_, m)| m);
7541+ neighbours.above_mode[sc] = find((parent_mi.0 + 2, parent_mi.1)).unwrap_or(last);
7542+ neighbours.left_mode[sr] = find((parent_mi.0, parent_mi.1 + 2)).unwrap_or(last);
7543+}
75107544
75117545 fn decode_leaf8(
75127546 dec: &mut SymbolDecoder,
@@ -7728,7 +7762,10 @@ fn decode_leaf8(
77287762 let tu_px = px + tu_col * 4;
77297763 let tu_py = py + tu_row * 4;
77307764 let tu_around = neighbours.around_mi(tu_mi, 4)[0];
7731- let tu_reach = Reach::of(4, tu_px, tu_py, y.width, y.height);
7765+ if crate::encode::Reach::in_vert_ab() {
7766+ VERT_AB_TX4_HITS.with(|c| c.set(c.get() + 1));
7767+ }
7768+ let tu_reach = Reach::of_tu(8, 4, tu_px, tu_py, y.width, y.height);
77327769 let tu_skip_ctx = neighbours.luma_skip_ctx(tu_mi, 1);
77337770 let tu_grid = read_plane(
77347771 dec,
@@ -10323,105 +10360,126 @@ pub(crate) fn decode_key_frame_tile_with_cdfs(
1032310360 )?;
1032410361 continue;
1032510362 }
10326- if part16 == PARTITION_VERT_B {
10327- VERT_B_INTRA_HITS.with(|c| c.set(c.get() + 1));
10328- // lane-part32 r6: same availability
10329- // defect r5 fixed one level up --
10330- // the TR/BR 8x8 squares below are
10331- // visited out of raster order, so
10332- // they need libaom's
10333- // `has_tr_vert_*`/`has_bl_vert_*`
10334- // tables (the left 8x16 rect goes
10335- // through `Reach::of_rect`, which
10336- // the guard deliberately does not
10337- // affect).
10338- let _vert_ab =
10339- crate::encode::Reach::vert_ab_partition();
10340- // Left rect: 8x16, real
10341- // `decode_block_rect`, sat at the
10342- // 16x16 parent's own origin (no
10343- // fractional-SUB-grid pixel
10344- // offset needed -- the plain
10345- // HORZ/VERT arms this lane's
10346- // charter named DO need one,
10347- // since their second half is
10348- // offset by half the parent;
10349- // unported, see decode_block_rect's
10350- // own doc comment).
10351- decode_block_rect(
10352- &mut dec,
10353- &mut cdfs,
10354- &mut neighbours,
10355- at16,
10356- 8,
10357- 16,
10358- &mut y,
10359- &mut u,
10360- &mut v,
10361- enable_filter_intra,
10362- allow_screen_content_tools,
10363- base_q_idx,
10364- tx_select,
10365- reduced_tx_set,
10366- )?;
10367- // Two 8x8 squares stacked on the
10368- // right, chained through
10369- // `prev_leaf` exactly like the
10370- // real (non-straddle) SPLIT path
10371- // below: the bottom leaf's ABOVE
10372- // context is the top leaf, not
10373- // the coarse SUB-grid array (a
10374- // real block never sat there).
10375- let (mi_row0, mi_col0) =
10376- (sr as u32 * SUB_MI, sc as u32 * SUB_MI);
10377- let top_right =
10378- (mi_row0 as usize, mi_col0 as usize + 2);
10379- let bot_right =
10380- (mi_row0 as usize + 2, mi_col0 as usize + 2);
10381- let mode_tr = decode_leaf8(
10382- &mut dec,
10383- &mut cdfs,
10384- &mut neighbours,
10385- at16,
10386- top_right,
10387- (&scan8, &scan4),
10388- None,
10389- &mut y,
10390- &mut u,
10391- &mut v,
10392- base_q_idx,
10393- enable_filter_intra,
10394- allow_screen_content_tools,
10395- allow_intrabc,
10396- tx_select,
10397- reduced_tx_set,
10398- )?;
10399- let mode_br = decode_leaf8(
10400- &mut dec,
10401- &mut cdfs,
10402- &mut neighbours,
10403- at16,
10404- bot_right,
10405- (&scan8, &scan4),
10406- Some((top_right, mode_tr)),
10407- &mut y,
10408- &mut u,
10409- &mut v,
10410- base_q_idx,
10411- enable_filter_intra,
10412- allow_screen_content_tools,
10413- allow_intrabc,
10414- tx_select,
10415- reduced_tx_set,
10416- )?;
10417- // `record()`'s above_mode/left_mode
10418- // write is a no-op at an 8x8
10419- // leaf's own side (same gap the
10420- // real-SPLIT path above patches):
10421- // force it from the last-decoded
10422- // (bottom-right) leaf.
10423- neighbours.above_mode[sc] = mode_br;
10424- neighbours.left_mode[sr] = mode_br;
10363+ if (PARTITION_HORZ_A..=PARTITION_VERT_B).contains(&part16) {
10364+ // lane-ab16 r1: the four AB (T-shaped) partitions at the 16x16
10365+ // level -- two 8x8 squares plus one 16x8/8x16 strip. libaom's
10366+ // `decode_partition` visit order (decodeframe.c):
10367+ // HORZ_A: TL 8x8, TR 8x8, bottom 16x8
10368+ // HORZ_B: top 16x8, BL 8x8, BR 8x8
10369+ // VERT_A: TL 8x8, BL 8x8, right 8x16
10370+ // VERT_B: left 8x16, TR 8x8, BR 8x8
10371+ // The squares go through `decode_leaf8`, the strip through
10372+ // `decode_leaf_rect` (real, non-skip 16x8/8x16 coefficients --
10373+ // lane-rectx r2-r4; the older `decode_block_rect` this VERT_B arm
10374+ // used refuses the non-skip case at this size). Both writers keep
10375+ // mi-granular mode/skip/palette records, so a later block's
10376+ // `above_mi`/`left_mi` sees the real sub-block, not the coarse
10377+ // 16x16 cell.
10378+ //
10379+ // VERT_A/VERT_B visit TL,BL,TR,BR, so the bottom-left square's
10380+ // top-right neighbour is the partition's own not-yet-decoded
10381+ // rectangle: libaom switches those squares onto `has_tr_vert_*`/
10382+ // `has_bl_vert_*` (`reconintra.c` `get_has_tr_table`), which is
10383+ // `Reach::vert_ab_partition()` (lane-part32 r5, cherry-picked here).
10384+ let arm = part16 - PARTITION_HORZ_A;
10385+ bump_ab16(arm);
10386+ if part16 == PARTITION_VERT_B {
10387+ VERT_B_INTRA_HITS.with(|c| c.set(c.get() + 1));
10388+ }
10389+ let _vert_guard = if part16 == PARTITION_VERT_A || part16 == PARTITION_VERT_B {
10390+ Some(crate::encode::Reach::vert_ab_partition())
10391+ } else {
10392+ None
10393+ };
10394+ let (mi_row0, mi_col0) = (sr * SUB_MI as usize, sc * SUB_MI as usize);
10395+ macro_rules! ab_leaf8 {
10396+ ($mi:expr, $prev:expr) => {
10397+ decode_leaf8(
10398+ &mut dec,
10399+ &mut cdfs,
10400+ &mut neighbours,
10401+ at16,
10402+ $mi,
10403+ (&scan8, &scan4),
10404+ $prev,
10405+ &mut y,
10406+ &mut u,
10407+ &mut v,
10408+ base_q_idx,
10409+ enable_filter_intra,
10410+ allow_screen_content_tools,
10411+ allow_intrabc,
10412+ tx_select,
10413+ reduced_tx_set,
10414+ )?
10415+ };
10416+ }
10417+ macro_rules! ab_strip {
10418+ ($mi:expr, $bw:expr, $bh:expr, $prev:expr) => {
10419+ decode_leaf_rect(
10420+ &mut dec,
10421+ &mut cdfs,
10422+ &mut neighbours,
10423+ at16,
10424+ $mi,
10425+ $bw,
10426+ $bh,
10427+ $prev,
10428+ &mut y,
10429+ &mut u,
10430+ &mut v,
10431+ enable_filter_intra,
10432+ allow_screen_content_tools,
10433+ base_q_idx,
10434+ tx_select,
10435+ reduced_tx_set,
10436+ )?
10437+ };
10438+ }
10439+ let tl = (mi_row0, mi_col0);
10440+ let tr = (mi_row0, mi_col0 + 2);
10441+ let bl = (mi_row0 + 2, mi_col0);
10442+ let br = (mi_row0 + 2, mi_col0 + 2);
10443+ let mut done: Vec<((usize, usize), usize)> = Vec::new();
10444+ match part16 {
10445+ PARTITION_HORZ_A => {
10446+ let m_tl = ab_leaf8!(tl, done.last().copied());
10447+ done.push((tl, m_tl));
10448+ let m_tr = ab_leaf8!(tr, done.last().copied());
10449+ done.push((tr, m_tr));
10450+ let m_bot = ab_strip!(bl, 16, 8, Some((tl, m_tl)));
10451+ done.push((bl, m_bot));
10452+ }
10453+ PARTITION_HORZ_B => {
10454+ let m_top = ab_strip!(tl, 16, 8, None);
10455+ done.push((tl, m_top));
10456+ let m_bl = ab_leaf8!(bl, done.last().copied());
10457+ done.push((bl, m_bl));
10458+ let m_br = ab_leaf8!(br, done.last().copied());
10459+ done.push((br, m_br));
10460+ }
10461+ PARTITION_VERT_A => {
10462+ let m_tl = ab_leaf8!(tl, done.last().copied());
10463+ done.push((tl, m_tl));
10464+ let m_bl = ab_leaf8!(bl, done.last().copied());
10465+ done.push((bl, m_bl));
10466+ let m_right = ab_strip!(tr, 8, 16, Some((tl, m_tl)));
10467+ done.push((tr, m_right));
10468+ }
10469+ _ => {
10470+ let m_left = ab_strip!(tl, 8, 16, None);
10471+ done.push((tl, m_left));
10472+ let m_tr = ab_leaf8!(tr, done.last().copied());
10473+ done.push((tr, m_tr));
10474+ let m_br = ab_leaf8!(br, done.last().copied());
10475+ done.push((br, m_br));
10476+ }
10477+ }
10478+ // Same coarse-slot write-back the real SPLIT path takes: the
10479+ // 16x16 cell's single `above_mode`/`left_mode` entry gets the
10480+ // sub-block on the parent's bottom / right edge (the mi-exact map
10481+ // above wins wherever it has an entry).
10482+ write_back_split_modes(&mut neighbours, &done, (mi_row0, mi_col0), (sr, sc));
1042510483 continue;
1042610484 }
1042710485 if part16 == PARTITION_HORZ {
@@ -10522,7 +10580,7 @@ pub(crate) fn decode_key_frame_tile_with_cdfs(
1052210580 }
1052310581 if part16 != PARTITION_SPLIT {
1052410582 return Err(unsupported(
10525- "a HORZ_A/HORZ_B/VERT_A partition below 16x16 (this decoder codes only the square arms, HORZ, VERT, VERT_B, and a clean split below 16x16)",
10583+ "a 1:4 partition below 16x16 (PARTITION_HORZ_4/VERT_4, four 16x4/4x16 strips -- this decoder codes NONE, HORZ, VERT, the four AB arms and a clean split at 16x16)",
1052610584 ));
1052710585 }
1052810586 // A real (non-straddle) SPLIT of a
crates/ec-av1/src/encode.rsmodified+88 -0
@@ -1243,6 +1243,39 @@ impl Reach {
12431243 }
12441244 }
12451245
1246+ /// [`Self::of`] for one transform unit of a square block whose transform
1247+ /// is smaller than itself (libaom `has_top_right`/`has_bottom_left` with
1248+ /// non-zero `row_off`/`col_off`): interior units answer from the block's
1249+ /// own geometry, and only a unit on the block's top row (resp. left
1250+ /// column) reaches the table -- which is the BLOCK's table read at the
1251+ /// BLOCK's position, never a table row for the transform's size. Letting
1252+ /// the unit stand in for a block of its own size agrees with libaom for
1253+ /// the ordinary tables, but the `has_tr_vert_*`/`has_bl_vert_*` pair has
1254+ /// no 4x4 row at all (`has_tr_vert_tables[BLOCK_4X4]` is NULL), so a TX4
1255+ /// unit inside an 8x8 square of a `PARTITION_VERT_A`/`_B` panicked on a
1256+ /// real `--enable-tx-size-search=1` stream (lane-ab16 r2).
1257+ pub(crate) fn of_tu(
1258+ block: usize,
1259+ tx: usize,
1260+ x: usize,
1261+ y: usize,
1262+ width: usize,
1263+ height: usize,
1264+ ) -> Self {
1265+ let (row_off, col_off) = ((y % block) / tx, (x % block) / tx);
1266+ let n = block / tx;
1267+ let (bx, by) = (x - col_off * tx, y - row_off * tx);
1268+ Self {
1269+ above_right: y > 0
1270+ && x + tx < width
1271+ && (col_off + 1 < n || (row_off == 0 && Self::top_right(block, bx, by))),
1272+ below_left: x > 0
1273+ && y + tx < height
1274+ && col_off == 0
1275+ && (row_off + 1 < n || Self::bottom_left(block, bx, by)),
1276+ }
1277+ }
1278+
12461279 /// libaom `has_top_right` at block granularity (`row_off`/`col_off` 0,
12471280 /// the transform covering the whole block, luma): everything before the
12481281 /// table lookup is that function's own early-exit ladder.
@@ -1305,6 +1338,13 @@ impl Reach {
13051338 /// `get_has_bl_table` partition argument). Rectangular sub-blocks are
13061339 /// unaffected: libaom's own comment says vertical rectangles keep their
13071340 /// non-vert table, which is what [`Reach::of_rect`] already reads.
1341+ /// Whether a `PARTITION_VERT_A`/`_B`'s sub-blocks are being decoded
1342+ /// right now ([`Self::vert_ab_partition`]'s guard is alive), so a caller
1343+ /// can count the sub-block work that partition creates (lane-ab16).
1344+ pub(crate) fn in_vert_ab() -> bool {
1345+ VERT_AB_PARTITION.with(std::cell::Cell::get)
1346+ }
1347+
13081348 pub(crate) fn vert_ab_partition() -> VertAbGuard {
13091349 VertAbGuard(VERT_AB_PARTITION.with(|c| c.replace(true)))
13101350 }
@@ -3784,6 +3824,54 @@ mod tests {
37843824 assert_eq!(decoded.v, encoded.reconstruction.v, "854x480: V");
37853825 }
37863826
3827+ /// [`Reach::of_tu`] against libaom's `has_top_right`/`has_bottom_left`
3828+ /// transform-unit path, for every 4x4 unit of every 8x8 block of a
3829+ /// superblock, both partition tables:
3830+ ///
3831+ /// 1. outside a `PARTITION_VERT_A`/`_B` it must answer exactly what the
3832+ /// unit-as-its-own-block `Reach::of(4, ..)` answered before r2, so
3833+ /// wiring the TU sites onto it changes no existing stream;
3834+ /// 2. inside one it must not panic -- `has_tr_vert_tables[BLOCK_4X4]` is
3835+ /// NULL in libaom because that lookup never happens, and reading a
3836+ /// 4x4 row out of the three-row vert tables is what crashed a real
3837+ /// `--enable-tx-size-search=1` stream (r2);
3838+ /// 3. and it must be the BLOCK's vert answer where the two tables
3839+ /// disagree: the top-right 4x4 unit of the 8x8 block at superblock
3840+ /// row 1, column 0 reads its above-right samples from the 8x8 to its
3841+ /// upper right, which a vertical AB partition codes AFTER it
3842+ /// (`has_tr_vert_8x8` bit 16 = 0, ordinary `has_tr_8x8` bit 16 = 1).
3843+ #[test]
3844+ fn of_tu_keeps_the_ordinary_answer_and_uses_the_block_row_under_vert_ab() {
3845+ let (w, h) = (SUPERBLOCK * 2, SUPERBLOCK * 2);
3846+ for y in (0..h).step_by(4) {
3847+ for x in (0..w).step_by(4) {
3848+ let tu = Reach::of_tu(8, 4, x, y, w, h);
3849+ let as_block = Reach::of(4, x, y, w, h);
3850+ assert_eq!(
3851+ (tu.above_right, tu.below_left),
3852+ (as_block.above_right, as_block.below_left),
3853+ "of_tu(8, 4) at ({x}, {y}) differs from the unit-as-block answer"
3854+ );
3855+ // (2): under the vert tables the same lookup must answer at
3856+ // all rather than index a row that does not exist.
3857+ let _guard = Reach::vert_ab_partition();
3858+ let _ = Reach::of_tu(8, 4, x, y, w, h);
3859+ }
3860+ }
3861+ // (3): the disagreeing cell, both ways round.
3862+ let (x, y) = (4, 8);
3863+ assert!(
3864+ Reach::of_tu(8, 4, x, y, SUPERBLOCK, SUPERBLOCK).above_right,
3865+ "ordinary table: the 8x8 above-right of the block at sb row 1 col 0 is coded first"
3866+ );
3867+ let guard = Reach::vert_ab_partition();
3868+ assert!(
3869+ !Reach::of_tu(8, 4, x, y, SUPERBLOCK, SUPERBLOCK).above_right,
3870+ "vert AB: that 8x8 is the partition's own later-coded right half"
3871+ );
3872+ drop(guard);
3873+ }
3874+
37873875 /// `Reach::top_right`/`bottom_left` against a from-scratch transcription
37883876 /// of libaom's `has_top_right`/`has_bottom_left` (`av1/common/
37893877 /// reconintra.c`), for every 16x16 and 32x32 block position across three
crates/ec-av1/src/refusal_inventory.rsmodified+1 -2
@@ -31,11 +31,10 @@ const CAPABILITY_CLAIMS: &[&str] = &[
3131
3232 #[cfg(test)]
3333 const REFUSALS: &[&str] = &[
34- "a coded (non-skip) HORZ_B/VERT_B rect strip below 16x16 (this decoder ports only the skip case at this size)",
3534 "a coded HORZ/VERT strip whose chroma transform has no rect coefficient tables here",
3635 "a HORZ/VERT intra strip below 16x16 with a split transform (per-unit rect prediction is not ported)",
37- "a HORZ_A/HORZ_B/VERT_A partition below 16x16 (this decoder codes only the square arms, HORZ, VERT, VERT_B, and a clean split below 16x16)",
3836 "an inter partition below 8x8 (this decoder codes no inter leaf smaller than 8x8; lane-sub8 scoped to intra)",
37+ "a 1:4 partition below 16x16 (PARTITION_HORZ_4/VERT_4, four 16x4/4x16 strips -- this decoder codes NONE, HORZ, VERT, the four AB arms and a clean split at 16x16)",
3938 "a 16x16 block whose true edge cuts through both axes needs a rectangular transform this decoder does not code yet",
4039 "a 16x16 inter block whose true edge cuts through both axes needs a rectangular transform this decoder does not code yet",
4140 "a 32x32 partition type this decoder does not code (value={part32})",
crates/ec-av1/src/stream.rsmodified+212 -0
@@ -8733,6 +8733,218 @@ mod tests {
87338733 );
87348734 }
87358735
8736+ /// lane-ab16 r1: real `aomenc --enable-ab-partitions=1` streams whose
8737+ /// 16x16 blocks are split T-shaped (`PARTITION_HORZ_A`/`_HORZ_B`/
8738+ /// `_VERT_A`/`_VERT_B`: two 8x8 squares plus one 16x8/8x16 strip), the
8739+ /// refusals "a HORZ_A/HORZ_B/VERT_A partition below 16x16" and "a coded
8740+ /// (non-skip) HORZ_B/VERT_B rect strip below 16x16" this round lifts.
8741+ /// `--min-partition-size=8 --max-partition-size=16` pins the level so
8742+ /// every AB symbol in the stream is a 16x16 one; the squares go through
8743+ /// `decode_leaf8`, the strips through `decode_leaf_rect`'s non-skip
8744+ /// coefficient path (lane-rectx). The per-arm counter is sampled per
8745+ /// attempt and summed only over attempts that actually decoded AND were
8746+ /// compared, and EACH of the four arms must have fired -- a run where
8747+ /// aomenc's RD only ever picked HORZ_A cannot pass as proof of four
8748+ /// ([[gate-blind-to-feature]]). 8-bit and 10-bit; `--tile-columns=1` is
8749+ /// NOT among the attempts (base tile defect, reproducer in the r1
8750+ /// report), and `--enable-tx-size-search` is left at aomenc's default
8751+ /// (ON) -- pinning it off hid a panic in the TX4 sub-grid of an 8x8
8752+ /// square inside a `PARTITION_VERT_A`/`_B` (r2).
8753+ #[test]
8754+ fn a_real_aomenc_stream_with_ab_partitions_below_16x16_decodes_pixel_exact() {
8755+ const NAME: &str =
8756+ "a_real_aomenc_stream_with_ab_partitions_below_16x16_decodes_pixel_exact";
8757+ let _gate_lock = lock_gate_counters();
8758+ if !have_ffmpeg() {
8759+ eprintln!("SKIP {NAME}: no ffmpeg");
8760+ return;
8761+ }
8762+ if !have_aomenc() {
8763+ eprintln!("SKIP {NAME}: no aomenc at {}", aomenc_path().display());
8764+ return;
8765+ }
8766+ struct Attempt {
8767+ src: &'static str,
8768+ w: usize,
8769+ h: usize,
8770+ cq: u32,
8771+ ten_bit: bool,
8772+ tile_cols: u32,
8773+ /// Left at aomenc's default (ON) instead of pinned off: reaches
8774+ /// the TX4 sub-grid of an 8x8 square inside a
8775+ /// `PARTITION_VERT_A`/`_B` (r2's panic), at the cost of the
8776+ /// strip-level split transform lane-rectx still refuses.
8777+ tx_size_search: bool,
8778+ }
8779+ // Recipes chosen by a ~200-cell sweep of {source, size, cq} at this
8780+ // level (r1 report): one cell per arm that is pixel-exact end to end,
8781+ // plus two 10-bit cells. `--tile-columns=1` is deliberately absent --
8782+ // it mismatches on blocks that are plain NONE/VERT with no AB symbol
8783+ // in the failing superblock, i.e. a base tile defect this lane
8784+ // neither introduced nor owns (reproducer pinned in the r1 report).
8785+ let attempts = [
8786+ Attempt { src: "yuvtestsrc=size=64x64", w: 64, h: 64, cq: 22, ten_bit: false, tile_cols: 0, tx_size_search: false },
8787+ Attempt { src: "rgbtestsrc=size=64x64", w: 64, h: 64, cq: 20, ten_bit: false, tile_cols: 0, tx_size_search: false },
8788+ Attempt { src: "rgbtestsrc=size=64x64", w: 64, h: 64, cq: 50, ten_bit: false, tile_cols: 0, tx_size_search: false },
8789+ Attempt { src: "mandelbrot=size=64x64:start_x=-1.0", w: 64, h: 64, cq: 14, ten_bit: false, tile_cols: 0, tx_size_search: false },
8790+ // 10-bit: the only two cells of the sweep that are exact at this
8791+ // depth (HORZ_A and VERT_A); the 10-bit HORZ_B/VERT_B cells all
8792+ // trip the base chroma defect the r1 report pins, so those two
8793+ // arms are proven 8-bit only.
8794+ Attempt { src: "yuvtestsrc=size=64x64", w: 64, h: 64, cq: 30, ten_bit: true, tile_cols: 0, tx_size_search: false },
8795+ Attempt { src: "mandelbrot=size=64x64:start_x=0.4", w: 64, h: 64, cq: 30, ten_bit: true, tile_cols: 0, tx_size_search: false },
8796+ // `--enable-tx-size-search` at aomenc's default: an 8x8 square of
8797+ // a VERT_A/VERT_B resolves to a 2x2 grid of TX4 units, which is
8798+ // the reach lookup that had no table row and panicked (r2). These
8799+ // attempts may legitimately stop at lane-rectx's still-standing
8800+ // "strip with a split transform" refusal -- an `unsupported`
8801+ // message is tolerated, a panic or a pixel mismatch is not, and
8802+ // at least one of them must reach a TX4 unit inside a vertical AB
8803+ // partition.
8804+ Attempt { src: "yuvtestsrc=size=64x64", w: 64, h: 64, cq: 55, ten_bit: false, tile_cols: 0, tx_size_search: true },
8805+ Attempt { src: "yuvtestsrc=size=64x64", w: 64, h: 64, cq: 22, ten_bit: false, tile_cols: 0, tx_size_search: true },
8806+ Attempt { src: "rgbtestsrc=size=64x64", w: 64, h: 64, cq: 20, ten_bit: false, tile_cols: 0, tx_size_search: true },
8807+ Attempt { src: "mandelbrot=size=64x64:start_x=-1.0", w: 64, h: 64, cq: 14, ten_bit: false, tile_cols: 0, tx_size_search: true },
8808+ ];
8809+ let mut arms = [0usize; 4];
8810+ let mut compared = 0usize;
8811+ let mut tx4_reached = 0usize;
8812+ let mut tx4_compared = 0usize;
8813+ for a in &attempts {
8814+ let desc =
8815+ format!("{} cq={} {}bit tiles={}", a.src, a.cq, if a.ten_bit { 10 } else { 8 }, a.tile_cols);
8816+ let mut ff: Vec<String> = vec![
8817+ "-v".into(), "error".into(), "-f".into(), "lavfi".into(), "-i".into(), a.src.into(),
8818+ "-pix_fmt".into(),
8819+ if a.ten_bit { "yuv420p10le".into() } else { "yuv420p".into() },
8820+ ];
8821+ if a.ten_bit {
8822+ ff.push("-strict".into());
8823+ ff.push("-1".into());
8824+ }
8825+ ff.extend(["-t".into(), "1".into(), "-vframes".into(), "1".into(),
8826+ "-f".into(), "yuv4mpegpipe".into(), "-".into()]);
8827+ let y4m = Command::new("ffmpeg")
8828+ .args(&ff)
8829+ .stdin(Stdio::null())
8830+ .stdout(Stdio::piped())
8831+ .stderr(Stdio::piped())
8832+ .output()
8833+ .expect("ffmpeg failed to run");
8834+ assert!(y4m.status.success(), "ffmpeg fixture {desc}: {}", String::from_utf8_lossy(&y4m.stderr));
8835+ let encode = || {
8836+ let mut args: Vec<String> = vec![
8837+ "--codec=av1".into(), "--passes=1".into(), "--end-usage=q".into(),
8838+ format!("--cq-level={}", a.cq), "--cpu-used=4".into(), "--threads=1".into(),
8839+ "--row-mt=0".into(), "--sb-size=64".into(), "--kf-max-dist=0".into(),
8840+ "--limit=1".into(),
8841+ "--enable-rect-partitions=1".into(), "--enable-ab-partitions=1".into(),
8842+ "--enable-1to4-partitions=0".into(),
8843+ format!("--enable-tx-size-search={}", u8::from(a.tx_size_search)),
8844+ // Filter intra ON a rect strip is a separate, still-refused
8845+ // predictor; this gate is about the AB partition wiring.
8846+ "--enable-filter-intra=0".into(),
8847+ "--reduced-tx-type-set=1".into(),
8848+ "--min-partition-size=8".into(), "--max-partition-size=16".into(),
8849+ format!("--tile-columns={}", a.tile_cols),
8850+ ];
8851+ if a.ten_bit {
8852+ args.push("--input-bit-depth=10".into());
8853+ args.push("--bit-depth=10".into());
8854+ }
8855+ args.extend(["--obu".into(), "-o".into(), "-".into(), "-".into()]);
8856+ let mut child = Command::new(aomenc_path())
8857+ .args(&args)
8858+ .stdin(Stdio::piped())
8859+ .stdout(Stdio::piped())
8860+ .stderr(Stdio::piped())
8861+ .spawn()
8862+ .expect("aomenc failed to start");
8863+ child.stdin.take().expect("aomenc stdin").write_all(&y4m.stdout).expect("y4m to aomenc");
8864+ let out = child.wait_with_output().expect("aomenc failed to run");
8865+ assert!(out.status.success(), "aomenc refused {desc}: {}", String::from_utf8_lossy(&out.stderr));
8866+ out.stdout
8867+ };
8868+ let stream = encode();
8869+ assert!(!stream.is_empty(), "{NAME}: {desc}: aomenc wrote an empty stream");
8870+ assert_eq!(stream, encode(), "{NAME}: {desc}: aomenc output is not reproducible");
8871+ let before = crate::decode::ab16_hits_by_arm();
8872+ let tx4_before = crate::decode::vert_ab_tx4_hits();
8873+ let decoded = decode_stream(&stream);
8874+ let tx4_this = crate::decode::vert_ab_tx4_hits() - tx4_before;
8875+ // Counted even when the attempt later stops at another lane's
8876+ // refusal: reaching this lookup at all is what r2 fixed.
8877+ tx4_reached += tx4_this;
8878+ let frames = match decoded {
8879+ Ok(frames) => frames,
8880+ // Only lane-rectx's split-transform strip refusal may stop a
8881+ // tx-size-search attempt; a panic never reaches here at all.
8882+ Err(e) if a.tx_size_search => {
8883+ let msg = e.to_string();
8884+ assert!(
8885+ msg.contains("unsupported"),
8886+ "{NAME}: {desc}: decode failed with a non-refusal error: {msg}"
8887+ );
8888+ eprintln!("{NAME}: {desc} refused after {tx4_this} vert-AB TX4 units: {msg}");
8889+ continue;
8890+ }
8891+ Err(e) => panic!("{NAME}: {desc}: decode failed, not a pixel mismatch: {e}"),
8892+ };
8893+ let after = crate::decode::ab16_hits_by_arm();
8894+ let this: Vec<usize> = (0..4).map(|i| after[i] - before[i]).collect();
8895+ eprintln!("{NAME}: {desc} decoded, arms this attempt={this:?}");
8896+ let want = if a.ten_bit {
8897+ ffmpeg_decode_sequence_10bit(&stream, a.w, a.h, frames.len())
8898+ } else {
8899+ ffmpeg_decode_sequence(&stream, a.w, a.h, frames.len())
8900+ };
8901+ assert_eq!(want.len(), frames.len(), "{NAME}: {desc}: ffmpeg frame count");
8902+ for (i, (got, w)) in frames.iter().zip(&want).enumerate() {
8903+ assert_eq!(got.y, w.y, "{NAME}: {desc} frame {i} luma vs ffmpeg");
8904+ assert_eq!(got.u, w.u, "{NAME}: {desc} frame {i} U vs ffmpeg");
8905+ assert_eq!(got.v, w.v, "{NAME}: {desc} frame {i} V vs ffmpeg");
8906+ }
8907+ // Counted only now: the attempt decoded AND compared exact.
8908+ if a.tx_size_search {
8909+ tx4_compared += 1;
8910+ eprintln!("{NAME}: {desc} pixel-exact, vert-AB TX4 units={tx4_this}");
8911+ continue;
8912+ }
8913+ for i in 0..4 {
8914+ arms[i] += after[i] - before[i];
8915+ }
8916+ compared += 1;
8917+ eprintln!("{NAME}: {desc} pixel-exact");
8918+ }
8919+ assert_eq!(
8920+ compared,
8921+ attempts.iter().filter(|a| !a.tx_size_search).count(),
8922+ "{NAME}: every fixed-transform attempt must decode and compare"
8923+ );
8924+ // The tx-size-search attempts cannot be compared pixel by pixel yet:
8925+ // every 16x16 AB partition contains a strip, and with a free
8926+ // transform size aomenc splits at least one of them in every stream
8927+ // of a 40-cell {source, cq} sweep (r2 report), so they all stop at
8928+ // lane-rectx's "strip with a split transform" refusal (or the 1:4 /
8929+ // sub-8x8 ones) before the frame is done. What they DO prove is that
8930+ // the TX4 sub-grid of an 8x8 square inside a VERT_A/VERT_B is reached
8931+ // on a real stream and answers -- it used to panic there, and a panic
8932+ // cannot be tolerated by the `unsupported` arm above. The values it
8933+ // answers are pinned separately against libaom in
8934+ // `of_tu_keeps_the_ordinary_answer_and_uses_the_block_row_under_vert_ab`.
8935+ let _ = tx4_compared;
8936+ assert!(
8937+ tx4_reached > 0,
8938+ "{NAME}: no --enable-tx-size-search=1 attempt reached a TX4 unit inside a \
8939+ vertical AB partition -- the r2 panic path is unproven"
8940+ );
8941+ for (i, arm) in ["HORZ_A", "HORZ_B", "VERT_A", "VERT_B"].iter().enumerate() {
8942+ assert!(arms[i] > 0, "{NAME}: PARTITION_{arm} at 16x16 never fired across {compared} \
8943+ compared streams -- the gate proves nothing about that arm (arms={arms:?})");
8944+ }
8945+ eprintln!("{NAME}: pixel-exact on {compared} streams, ab16 arms(HORZ_A,HORZ_B,VERT_A,VERT_B)={arms:?}");
8946+ }
8947+
87368948 #[test]
87378949 #[ignore = "lane-rectx r3 scratch sweep"]
87388950 fn sweep_rectx_recipes() {
lanes/COMMON-20260901.mdmodified+4 -0
@@ -89,3 +89,7 @@ NEVER wait with a foreground `until/while ... sleep` loop or `tail --pid`.
8989 ## NEVER pkill BY BINARY NAME (2026-09-02: one lane's `pkill -f ec_av1-<hash>` killed another lane's suite)
9090 The test binary hash is identical across worktrees. Kill only by PID you own (`$!`, or the systemd unit
9191 name you started). `pkill -f`/`killall` on cargo/ec_av1 patterns is forbidden.
92+
93+## NEVER `cargo fmt` IN A LANE (3 lanes lost their diffs to it on 2026-09-02)
94+main is not rustfmt-clean (~6000 lines of churn). Hand-indent; `cargo test --no-run` is the check.
95+If you ran it: extract your own hunks, `git checkout -- crates/`, re-apply.
lanes/ab16-r1.report.mdadded+95 -0
@@ -0,0 +1,95 @@
1+# lane-ab16 r1 — the four AB partitions at 16x16, arm by arm
2+
3+Branch `lane-ab16`, off `lane-rectx` `fad4d5a`.
4+
5+## What changed
6+
7+- `crates/ec-av1/src/decode.rs` ~7140: the 16x16-level `PARTITION_HORZ_A/_B/VERT_A/_B` arms
8+ (replacing the old VERT_B-only arm and the "codes only the square arms" refusal). libaom
9+ `decode_partition` visit order: HORZ_A = TL 8x8, TR 8x8, bottom 16x8; HORZ_B = top 16x8,
10+ BL, BR; VERT_A = TL, BL, right 8x16; VERT_B = left 8x16, TR, BR. Squares go through
11+ `decode_leaf8`, strips through `decode_leaf_rect` (lane-rectx's real non-skip 16x8/8x16
12+ coefficient path — the old VERT_B arm used `decode_block_rect`, which refuses non-skip at
13+ this size). `write_back_split_modes` for the coarse slot; mi-granular records come from the
14+ two leaf writers. VERT_A/_B take `Reach::vert_ab_partition()` (TL,BL,TR,BR visit order).
15+- `crates/ec-av1/src/decode.rs` ~7395: the surviving refusal is narrowed to the 1:4 case,
16+ `"a 1:4 partition below 16x16 (PARTITION_HORZ_4/VERT_4 ...)"`. The arm test is
17+ `(PARTITION_HORZ_A..=PARTITION_VERT_B).contains(&part16)` — values 8/9 must NOT fall into it.
18+- `crates/ec-av1/src/decode.rs` ~3401: `decode_block_rect`'s `"a coded (non-skip)
19+ HORZ_B/VERT_B rect strip below 16x16"` branch deleted — every remaining call site passes
20+ 32x16 or 16x32, so it was dead once VERT_B moved to `decode_leaf_rect`.
21+- `crates/ec-av1/src/decode.rs` ~430: `AB16_HITS: [usize; 4]` + `ab16_hits_by_arm()`.
22+- **Coordinator-reported base defects, fixed here too** (same hunks are being made on
23+ lane-sub8 r6 / lane-rectx r5 — semantically identical, keep either at merge):
24+ - `mode_above_mi`/`mode_left_mi` guard with `> self.tile_row0_mi` / `> self.tile_col0_mi`
25+ instead of `> 0`, and the mi-exact mode maps are reset in `start_tile` (col span) and
26+ `start_row` (`decode.rs` ~2037/~2304/~2581).
27+ - `encode.rs` `top_right_rect`/`bottom_left_rect` index with `blk_row << (5 - bw_log2)`
28+ (libaom `MAX_MIB_SIZE_LOG2`), not 4.
29+- `crates/ec-av1/src/encode.rs`: lane-part32 `fd1a2eb`'s encode half cherry-picked
30+ (`HAS_TOP_RIGHT_VERT`/`HAS_BOTTOM_LEFT_VERT`, `VERT_AB_PARTITION`, `VertAbGuard`,
31+ `Reach::vert_ab_partition()`). Their decode.rs/stream.rs halves were NOT taken (they depend
32+ on part32's own 32-level AB arms and counters) — a merge of both branches touches the same
33+ two `top_right`/`bottom_left` table-pick hunks.
34+- `crates/ec-av1/src/stream.rs` ~5460: the gate. `crates/ec-av1/src/refusal_inventory.rs`:
35+ one refusal deleted, one narrowed. `gate_coverage.rs` needed no edit (`--enable-ab-partitions`
36+ is now positively exercised and was never on a NEVER_EXERCISED list; this base has no
37+ `NEVER_EXERCISED_10BIT` list — that is on main `79d4f16`, so the merge must delete the AB
38+ entry there if present).
39+
40+## Gate
41+
42+`a_real_aomenc_stream_with_ab_partitions_below_16x16_decodes_pixel_exact`, 6 real-aomenc
43+streams (`--enable-ab-partitions=1 --enable-rect-partitions=1 --min-partition-size=8
44+--max-partition-size=16`, reproducibility-checked, per-arm counter sampled per attempt and
45+summed only over attempts that decoded AND compared, each arm hard-asserted `> 0`).
46+
47+```
48+CARGO_TARGET_DIR=$HOME/.cache/cargo-target-ab16 EC_AV1_REQUIRE_AOMENC=1 \
49+ cargo test -p ec-av1 --lib -- ab_partitions_below_16x16 --nocapture
50+```
51+
52+EVIDENCE: gate stdout | 6 aomenc streams (yuvtestsrc cq22 8b, rgbtestsrc cq20/cq50 8b,
53+mandelbrot start_x=-1.0 cq14 8b, yuvtestsrc cq30 10b, mandelbrot start_x=0.4 cq30 10b),
54+each decoded and compared plane-by-plane against ffmpeg |
55+`pixel-exact on 6 streams, ab16 arms(HORZ_A,HORZ_B,VERT_A,VERT_B)=[2, 1, 2, 1]`,
56+`test result: ok. 1 passed`.
57+
58+EVIDENCE: /tmp/.../scratchpad/{c30.obu,po30.f0,pa30.f0} | instrumented aomdec `EC_TRACE_MODE`
59+vs our `EC_TRACE_MODE_STEP` on a 4-arm stream | every mode/uv_mode value AND msac range match
60+(52624 / 55900 / 38256 / 35312 / 59042 / 54968 / 64576) — the AB arms are entropy-exact; the
61+residual mismatch in that stream starts at luma (40,9), inside a plain SPLIT 8x8 leaf with
62+`mode=9` (SMOOTH), i.e. reconstruction, not desync, and not an AB block.
63+
64+Scoped run after the fixes: `-- ab_partitions_below_16x16 refusal_inventory gate_coverage
65+coded_rect_strip` → `7 passed; 0 failed`.
66+
67+## Refusals
68+
69+- LIFTED `"a HORZ_A/HORZ_B/VERT_A partition below 16x16 ..."` → replaced by the 1:4-only
70+ string. HORZ_A/HORZ_B/VERT_A/VERT_B at 16x16 are real-stream-proven above.
71+- LIFTED `"a coded (non-skip) HORZ_B/VERT_B rect strip below 16x16 ..."` (branch deleted; the
72+ gate's HORZ_B/VERT_B strips run the real coefficient path).
73+
74+## Open residue
75+
76+- **fix-now(not this lane): full-suite gate `a_real_aomenc_stream_with_a_superblock_level_horz_vert_partition_decodes_pixel_exact` FAILS on this branch.**
77+ It is not any of this lane's three change groups: it still fails with the mi-map/tile hunks
78+ reverted, and with the `5 - bw_log2` fix reverted, and the AB arms never run in it (SB-level
79+ partitions). It is therefore pre-existing on `lane-rectx fad4d5a` or comes from the
80+ part32 `encode.rs` cherry-pick. Not re-measured on the base commit (turn cap) — the
81+ orchestrator should reconcile with lane-rectx r5 / lane-part32.
82+- deferred(base chroma/SMOOTH prediction defect — a lane of its own): at
83+ `--max-partition-size=16` most cells of a ~200-cell sweep decode to completion but mismatch,
84+ first error always in a plain (non-AB) 8x8 SPLIT leaf, luma-exact-then-chroma-off or
85+ SMOOTH-mode luma. Reproducer: `mandelbrot=size=64x64:start_x=-0.6 cq30`, recipe as the gate.
86+- deferred(base tile defect): the charter's `--tile-columns=1` arm is NOT in the gate.
87+ Reproducer: `mandelbrot=size=96x96:start_x=-0.6 cq32 --tile-columns=1`, same recipe → 491
88+ luma diffs at x=32..63,y=80..95 (last SB of tile 0); the failing superblock's partitions are
89+ `value=0` (NONE) and `value=2` (VERT), no AB symbol, and this survives the mi-map tile fixes
90+ above.
91+- accepted: 10-bit proves HORZ_A + VERT_A only; the 10-bit HORZ_B/VERT_B cells of the sweep all
92+ trip the base chroma defect above.
93+- deferred(turn cap): full `EC_AV1_REQUIRE_AOMENC=1 cargo test -p ec-av1 --lib` totals — the
94+ run was SIGTERMed by the memguard runner partway (one FAILED test observed, the SB-level one
95+ above; the AB gate passed inside that same run).
lanes/ab16-r2.report.mdadded+154 -0
@@ -0,0 +1,154 @@
1+# lane-ab16 r2 — the panic the gate's `--enable-tx-size-search=0` was hiding, and where seed 43 really diverges
2+
3+Branch `lane-ab16` (off `lane-rectx` `fad4d5a`). r1 verdict was FAIL on four findings; this
4+round closes (1) and (3), and answers (2) and (4) with measurements rather than a fix.
5+
6+## (1) PANIC — fixed at the root: a TX unit is not a block of its own size
7+
8+`encode.rs` `Reach::of(4, ..)` inside a `PARTITION_VERT_A`/`_B` indexed
9+`HAS_TOP_RIGHT_VERT[Reach::table(4)] == [_; 3][3]` and panicked
10+("index out of bounds: len 3 index 3"), because the vert tables have no 4x4 row at all —
11+libaom's `has_tr_vert_tables[BLOCK_4X4]` is literally `NULL`. It is NULL because that lookup
12+never happens there: for a 4x4 transform unit inside an 8x8 square, libaom's
13+`has_top_right`/`has_bottom_left` (`reconintra.c`) take the BLOCK's `bsize` with a non-zero
14+`row_off`/`col_off`, answer interior units from the block geometry alone
15+(`col_off + tx_units < block_units`), and reach the table only for a unit on the block's top
16+row / left column — where the table read is the BLOCK's row at the BLOCK's position.
17+
18+- `crates/ec-av1/src/encode.rs` (+`Reach::of_tu`, ~line 1215): that rule, transcribed.
19+- `crates/ec-av1/src/decode.rs` 5212 / 5584: both TU loops (`decode_block`'s multi-TU branch
20+ and `decode_leaf8`'s TX4 sub-grid) now call `Reach::of_tu(block, tx, ..)` instead of
21+ `Reach::of(tx, ..)`. Root, not per-symptom: these are the only two sites in the crate that
22+ ask a reach question for a sub-block transform unit (`grep -n "Reach::of("`).
23+- `crates/ec-av1/src/encode.rs` `Reach::in_vert_ab()` + `decode.rs` `vert_ab_tx4_hits()`:
24+ counter for the exact call that used to panic, so the gate can hard-assert it is reached.
25+
26+The fix is behaviour-preserving outside a vertical AB partition — pinned, not hoped:
27+`of_tu_keeps_the_ordinary_answer_and_uses_the_block_row_under_vert_ab` (encode.rs tests)
28+asserts `of_tu(8, 4, ..) == of(4, ..)` at every 4x4 position of a 2x2-superblock frame, that
29+the vert-table path answers at every one of them (the panic regression), and that the two
30+tables genuinely disagree where libaom says they must (top-right 4x4 unit of the 8x8 at
31+superblock row 1, column 0: `has_tr_8x8` bit 16 = 1, `has_tr_vert_8x8` bit 16 = 0).
32+
33+EVIDENCE: gate stdout | `--enable-tx-size-search=1` attempt (yuvtestsrc 64x64 cq55) decoded
34+through the AB partitions instead of aborting | `refused after 4 vert-AB TX4 units:
35+unsupported: AV1 tile (a HORZ/VERT intra strip with a split transform ...)` — before this
36+round the same stream died with `panicked at encode.rs:1279 index out of bounds: len 3
37+index 3` (decode_probe rc=101).
38+
39+## The gate, with tx-size search no longer pinned off
40+
41+`--enable-tx-size-search=0` is gone from the recipe builder; it is now per attempt:
42+
43+- the six comparison attempts keep it OFF and stay pixel-exact (all four arms fired);
44+- four new attempts leave it at aomenc's default (ON). They reach the formerly-panicking
45+ lookup and are allowed to stop at another lane's refusal — an `unsupported` message is
46+ tolerated, a panic or a pixel mismatch is not — and the gate hard-asserts that at least one
47+ TX4 unit inside a vertical AB partition was decoded.
48+
49+Why the ON attempts cannot be compared pixel by pixel yet, measured not assumed: every 16x16
50+AB partition contains a 16x8/8x16 strip, and with a free transform size aomenc splits at
51+least one strip in **40/40** cells of a `{yuvtestsrc, rgbtestsrc, mandelbrot, smptebars,
52+testsrc2} x {8,14,22,30,40,50,55,60}` sweep, so every one of them stops at lane-rectx's
53+still-standing "a HORZ/VERT intra strip with a split transform (per-unit rect prediction is
54+not ported)" refusal (or the 1:4 / sub-8x8 / palette ones). A pixel-exact tx-size-search arm
55+therefore needs that refusal lifted first — lane-rectx's, not this lane's.
56+
57+EVIDENCE: gate stdout | `cargo test -p ec-av1 --lib -- ab_partitions_below_16x16 of_tu_keeps
58+--nocapture` | `pixel-exact on 6 streams, ab16 arms(HORZ_A,HORZ_B,VERT_A,VERT_B)=[2, 1, 2, 1]`,
59+`yuvtestsrc cq=55 refused after 4 vert-AB TX4 units`, `test result: ok. 2 passed; 0 failed`.
60+
61+## (3) Stale docstring — fixed
62+
63+The gate's doc no longer claims a `--tile-columns=1` attempt (there is none; r1's reproducer
64+for the base tile defect stands) and now states why tx-size search is left at aomenc's
65+default.
66+
67+## (2) Seed 43 of the merged SB gate: TWO real defects, both fixed -- it is GREEN now
68+
69+The r2 first pass deferred this as "lane-rectx's problem". That deferral was wrong on the
70+disposition and right on the location: the defects are on the 64x32-strip path, and they are
71+two table transcriptions this lane could fix in one round.
72+
73+The gate's own recipe spells `--enable-ab-partitions=0` (stream.rs:9663), so aomenc wrote no AB
74+partition into seed 43 at all -- which means the refusal base `fad4d5a` stopped at ("a
75+HORZ_A/HORZ_B/VERT_A partition below 16x16") was decoded out of an ALREADY desynced stream. The
76+base pass was vacuous ([[refusal-hides-a-defect]]); lifting the refusal only removed the mask.
77+
78+Bisection, element by element, our `EC_TRACE_COEFF` against the instrumented `aomdec`'s
79+(`EC_COEFF`/`EC_COEFF_STEP`, msac RANGE compared, never `tell()`):
80+
81+**Defect A -- the two rect `av1_nz_map_ctx_offset` tables were transposed.**
82+First divergence: the luma TU of the first 64x32 strip (mi 0,16), `tx_size=12` (`TX_64X32`),
83+at scan index 7, libaom position 65 = (row 1, col 2), where the oracle reads ctx 6 and we read
84+16. libaom's array is indexed `coeff_idx = (col << bhl) | row` -- COLUMN-major, `bhl` = log2 of
85+the transform's HEIGHT (`txb_common.h` `get_nz_map_ctx_from_stats`) -- so a straight
86+transcription of it is `[col][row]`, and `base_ctx` reads `[row][col]`.
87+`crates/ec-av1/src/cdf.rs` `NZ_MAP_CTX_OFFSET_32X64` / `NZ_MAP_CTX_OFFSET_64X32`: both
88+transposed into true `[row][col]`. Invisible on the square table (symmetric) and at
89+`row, col < 2` (both halves agree there), which is every position lane-sbpart r8's gate ever
90+reached -- class [[reference-layout-not-spec]] / [[scan-weights-cross-axis]].
91+
92+**Defect B -- the 512-position CHROMA end-of-block CDF was the flat 1D row.**
93+With A fixed the stream ran on to the same strip's chroma TU (`tx_size=10`, `TX_32X16`), where
94+the oracle reads `eob=3` and we read `eob=103` off `EOB_PT_512_CHROMA`.
95+`av1_default_eob_multi512_cdfs` is `[q][plane][eob_multi_ctx][10]` (`token_cdfs.h:874`); the
96+constant carried the SECOND inner index (`eob_multi_ctx == 1`, the 1D `TX_CLASS_HORIZ`/`VERT`
97+row, which is the flat 3277/6554/... distribution for BOTH planes) instead of the chroma
98+plane's 2D row -- and its doc comment had rationalised the flatness as "libaom's default is the
99+same at all four q-contexts". `crates/ec-av1/src/cdf.rs`: the real chroma rows, all four
100+q-contexts (`EOB_PT_512_CHROMA{,_Q0,_Q1,_Q3}`); `crates/ec-av1/src/cdf_state.rs:1073`: `pick()`
101+by q-context like every sibling table. Class [[cdf-row-held-constant]].
102+
103+Both are pinned by unit tests that do not need a stream (`decode.rs` tests):
104+`rect_nz_map_ctx_offset_tables_are_row_major` re-derives every entry of all three tables from
105+libaom's own generating rule AND asserts the table path (`base_ctx`) equals the spelled-out
106+rule path (`base_ctx_rect`) at every (row, col) for both shapes -- those two disagreed
107+silently before; `the_chroma_512_eob_cdf_is_not_the_flat_one_dimensional_row` pins the
108+mis-indexing itself.
109+
110+EVIDENCE: <scratchpad>/ab16/{seed43.obu,ref.yuv,ours3.yuv,oc.raw,uc2.raw} | seed-43 stream
111+regenerated from the gate recipe (`gradients` seed 43, 192x128, cq45), decoded by
112+`~/.cache/aom-oracle/build/aomdec --rawvideo` and by `decode_probe`, coefficient traces
113+compared element by element | before: 20494/24576 luma bytes differ, first divergent element
114+`TX_64X32` luma scan idx 7 (rng 57584 vs ours); after defect A: first divergence moves to the
115+chroma `TX_32X16` eob (oracle 3, ours 103); after both: `cmp ours3.yuv ref.yuv` -> identical,
116+36864/36864 bytes.
117+
118+## (4) The chroma-only residue (mandelbrot 64x64 start_x=-0.6 cq30) -- re-measured, AB blocks ARE in it
119+
120+Unchanged by this round: 670 differing bytes, all of them chroma, first at offset 4246 (U
121+plane starts at 4096), luma bit-exact. And the stream does contain all four AB arms: the
122+16x16 partition symbols are `value=0 x2, 1 x2, 2, 3 x7, 4, 5, 6, 7` -- one HORZ_A, one HORZ_B,
123+one VERT_A, one VERT_B. Luma-exact with chroma-wrong means the entropy stream is fine through
124+the whole frame, so this is chroma PREDICTION/reconstruction, not a table or a desync
125+(a green entropy trace plus byte-exact luma exonerates the coefficient path -- the
126+`h265-chroma`/`gmaffine` class note in memory).
127+Disposition: **deferred(a chroma-prediction lane -- 4-wide/8-wide intra MC at these sizes; this
128+lane's tables are now proven exact by the seed-43 bisection)**.
129+
130+EVIDENCE: <scratchpad>/ab16/{m30.obu,m_ref.yuv,m_ours.yuv} | aomenc gate recipe at cq30 on
131+`mandelbrot=size=64x64:start_x=-0.6`, decoded by aomdec and decode_probe, byte diff by plane;
132+`EC_AV1_TRACE=1 ... | grep partition_w16` for the arm census | 670 diffs, 0 of them luma,
133+first at 4246; AB arm values 4/5/6/7 each present once.
134+
135+## Test totals
136+
137+`EC_AV1_REQUIRE_AOMENC=1 CARGO_TARGET_DIR=$HOME/.cache/cargo-target-ab16 cargo test -p ec-av1 --lib`
138+(log `$HOME/.cache/ab16-suite.log`): **274 passed; 0 failed; 24 ignored**, 619 s. That run
139+includes both gates this lane owns and every sibling the fixes touch --
140+`a_real_aomenc_stream_with_a_superblock_level_horz_vert_partition_decodes_pixel_exact` (seed 43
141+included, 40 seeds) is GREEN, `a_real_aomenc_stream_with_ab_partitions_below_16x16_decodes_pixel_exact`
142+is green with `--enable-tx-size-search` at aomenc's default on four of its ten attempts, and the
143+rectx / tiny / rectwire / sbpart gates that share the two corrected tables all pass.
144+
145+EVIDENCE: $HOME/.cache/ab16-suite.log | `cargo test -p ec-av1 --lib` with the aomenc oracle
146+required | `test result: ok. 274 passed; 0 failed; 24 ignored`.
147+
148+## Residue
149+
150+- deferred(a chroma-prediction lane): the mandelbrot cq30 chroma-only 670-byte residue above.
151+- deferred(base tile defect, r1 reproducer stands): no `--tile-columns=1` arm in the AB gate.
152+- deferred(lane-rectx): the tx-size-search AB attempts still stop at the "HORZ/VERT intra strip
153+ with a split transform" refusal, so they prove the reach lookup, not pixels.
154+- accepted: 10-bit proves HORZ_A + VERT_A only (r1).