forge
Explore
Log in

Don't you dare go Hollow

Merge branch 'lane-sb128c' (4e65b8a): the 128 partition root's inter arms and gathered 128 edges

Browse files at this commit

ec3d7929820c93645e009a3c3cc587f54dd11235Ahmet Kaan GümüşParent: 361f8bece0a01c
Inter 128x128 NONE roots, intra-128-in-inter, and the gathered-edge HORZ/VERT
128x64 / 64x128 blocks, with the 17-row MOTION_MODE/OBMC tables and
has_top_right size-half gating. Conflicts resolved keeping both sides
everywhere they added; main's NOCFL counter kept over the lane's identical
is_cfl_allowed fix, the lane's skip-inter-128 loop-filter suppression kept, and
the chroma tail is now `!has_chroma` / `side > 64` / `rect_tu` in that order.
cdf.rs NZ_MAP*/FILTER_INTRA* unchanged (only OBMC/MOTION_MODE go 14 -> 17 rows).

Gates: 128x128 / superblock / gathered_edge_horz / ab_partitions /
free_partitions / 1to4_streams / mvstack:: / refusal_inventory /
gate_coverage / base_ctx_rect_offsets -- 75 passed, 0 failed, 1 ignored.

Known cross-product reds carried into this tree (owned by the mergefix lane,
reported by the batch coordinator on an equivalent merged tree):
a_frame_edge_straddling_band_decodes_pixel_exact and
a_real_aomenc_10bit_inter_sequence_with_a_split_transform_intra_block_decodes_pixel_exact.
crates/ec-av1/examples/decode_probe.rsmodified+5 -0
@@ -67,6 +67,11 @@ fn main() {
67 println!(67 println!(
68 "rect_wedge(8x16,16x8,16x32,32x16,8x32,32x8): compound={rw:?} interintra={rwi:?}"68 "rect_wedge(8x16,16x8,16x32,32x16,8x32,32x8): compound={rw:?} interintra={rwi:?}"
69 );69 );
70+ let sb = ec_av1::stream::sb128_rect_counters();
71+ println!(
72+ "sb128_rect: edge_horz={} edge_vert={} inter_128x64={} inter_64x128={}",
73+ sb.0, sb.1, sb.2, sb.3
74+ );
70 let ir = ec_av1::stream::inter_rect_counters();75 let ir = ec_av1::stream::inter_rect_counters();
71 println!(76 println!(
72 "inter_rect: 32x8={} 8x32={} 64x32={} 32x64={} 64x16={} 16x64={}",77 "inter_rect: 32x8={} 8x32={} 64x32={} 32x64={} 64x16={} 16x64={}",
crates/ec-av1/src/cdf.rsmodified+14 -2
@@ -1645,7 +1645,7 @@ pub const SKIP_MODE: [[u16; 3]; 3] = [[32621, 32768, 0], [20708, 32768, 0], [812
1645 /// `motion_mode_allowed` (spec 5.11.24's `read_motion_mode`) offers1645 /// `motion_mode_allowed` (spec 5.11.24's `read_motion_mode`) offers
1646 /// `OBMC_CAUSAL` rather than `WARPED_CAUSAL` -- lane-motionmode round 11646 /// `OBMC_CAUSAL` rather than `WARPED_CAUSAL` -- lane-motionmode round 1
1647 /// never reaches the three-way `motion_mode_cdf`, see `decode.rs`.1647 /// never reaches the three-way `motion_mode_cdf`, see `decode.rs`.
1648-pub const OBMC: [[u16; 3]; 14] = [1648+pub const OBMC: [[u16; 3]; 17] = [
1649 [10437, 32768, 0],1649 [10437, 32768, 0],
1650 [17432, 32768, 0],1650 [17432, 32768, 0],
1651 [25817, 32768, 0],1651 [25817, 32768, 0],
@@ -1669,6 +1669,11 @@ pub const OBMC: [[u16; 3]; 14] = [
1669 // BLOCK_8X16 (4) and BLOCK_16X8 (5) of libaom's `default_obmc_cdf`.1669 // BLOCK_8X16 (4) and BLOCK_16X8 (5) of libaom's `default_obmc_cdf`.
1670 [9371, 32768, 0],1670 [9371, 32768, 0],
1671 [9301, 32768, 0],1671 [9301, 32768, 0],
1672+ // lane-sb128c r5: the 128-root rows -- BLOCK_64X128 (13), BLOCK_128X64
1673+ // (14), BLOCK_128X128 (15) of libaom's `default_obmc_cdf`.
1674+ [31014, 32768, 0],
1675+ [31560, 32768, 0],
1676+ [32638, 32768, 0],
1672 ];1677 ];
1673 1678
1674 /// `default_motion_mode_cdf` (spec 9.4, `entropymode.c`), the square-bsize1679 /// `default_motion_mode_cdf` (spec 9.4, `entropymode.c`), the square-bsize
@@ -1678,7 +1683,7 @@ pub const OBMC: [[u16; 3]; 14] = [
1678 /// `read_motion_mode` reads instead of [`OBMC`] whenever `motion_mode_allowed`1683 /// `read_motion_mode` reads instead of [`OBMC`] whenever `motion_mode_allowed`
1679 /// (spec 5.11.24) resolves to `WARPED_CAUSAL`-eligible (`num_proj_ref >= 1`1684 /// (spec 5.11.24) resolves to `WARPED_CAUSAL`-eligible (`num_proj_ref >= 1`
1680 /// under `allow_warped_motion`) -- lane-warp round 1.1685 /// under `allow_warped_motion`) -- lane-warp round 1.
1681-pub const MOTION_MODE: [[u16; 4]; 14] = [1686+pub const MOTION_MODE: [[u16; 4]; 17] = [
1682 [7651, 24760, 32768, 0],1687 [7651, 24760, 32768, 0],
1683 [19419, 26810, 32768, 0],1688 [19419, 26810, 32768, 0],
1684 [26260, 29116, 32768, 0],1689 [26260, 29116, 32768, 0],
@@ -1698,6 +1703,13 @@ pub const MOTION_MODE: [[u16; 4]; 14] = [
1698 // `default_motion_mode_cdf` indices 4 and 5).1703 // `default_motion_mode_cdf` indices 4 and 5).
1699 [4738, 24765, 32768, 0],1704 [4738, 24765, 32768, 0],
1700 [5391, 25528, 32768, 0],1705 [5391, 25528, 32768, 0],
1706+ // lane-sb128c r5: BLOCK_64X128 / 128X64 / 128X128 rows (libaom
1707+ // `default_motion_mode_cdf` indices 13, 14, 15). Without them a 128x128
1708+ // inter block fell through `w == h => trailing_zeros - 3` to row 4 (the
1709+ // BLOCK_16X32 row) and narrowed the msac by the wrong interval.
1710+ [28898, 30397, 32768, 0],
1711+ [30878, 31335, 32768, 0],
1712+ [32507, 32558, 32768, 0],
1701 ];1713 ];
1702 1714
1703 /// `default_interintra_cdf` (spec 9.4): `interintra`, indexed by1715 /// `default_interintra_cdf` (spec 9.4): `interintra`, indexed by
crates/ec-av1/src/cdf_state.rsmodified+2 -2
@@ -551,13 +551,13 @@ pub(crate) struct Cdfs {
551 /// `BLOCK_8X8`, 1 = `BLOCK_16X16`, 2 = `BLOCK_32X32`, 3 = `BLOCK_64X64`551 /// `BLOCK_8X8`, 1 = `BLOCK_16X16`, 2 = `BLOCK_32X32`, 3 = `BLOCK_64X64`
552 /// (`default_obmc_cdf`'s own `BLOCK_SIZES_ALL` indices 3/6/9/12 --552 /// (`default_obmc_cdf`'s own `BLOCK_SIZES_ALL` indices 3/6/9/12 --
553 /// this decoder only ever codes those four square sizes).553 /// this decoder only ever codes those four square sizes).
554- pub obmc: [[u16; 3]; 14],554+ pub obmc: [[u16; 3]; 17],
555 /// `motion_mode` (spec 5.11.24's `read_motion_mode`), the 3-symbol555 /// `motion_mode` (spec 5.11.24's `read_motion_mode`), the 3-symbol
556 /// `SIMPLE_TRANSLATION`/`OBMC_CAUSAL`/`WARPED_CAUSAL` alphabet read556 /// `SIMPLE_TRANSLATION`/`OBMC_CAUSAL`/`WARPED_CAUSAL` alphabet read
557 /// instead of [`Self::obmc`] whenever `motion_mode_allowed` resolves to557 /// instead of [`Self::obmc`] whenever `motion_mode_allowed` resolves to
558 /// `WARPED_CAUSAL`-eligible -- same square-bsize indexing as `obmc`.558 /// `WARPED_CAUSAL`-eligible -- same square-bsize indexing as `obmc`.
559 /// lane-warp round 1.559 /// lane-warp round 1.
560- pub motion_mode: [[u16; 4]; 14],560+ pub motion_mode: [[u16; 4]; 17],
561 /// `interintra`, indexed by `size_group_lookup[bsize]` -- see561 /// `interintra`, indexed by `size_group_lookup[bsize]` -- see
562 /// `cdf::INTERINTRA`'s own doc.562 /// `cdf::INTERINTRA`'s own doc.
563 pub interintra: [[u16; 3]; 4],563 pub interintra: [[u16; 3]; 4],
crates/ec-av1/src/decode.rsmodified+696 -42
@@ -2119,6 +2119,42 @@ pub(crate) fn rect_partition_hits() -> usize {
2119 // lane-inter8 r1: how many superblocks an inter tile coded as a single2119 // lane-inter8 r1: how many superblocks an inter tile coded as a single
2120 // whole-SB `PARTITION_NONE` 64x64 inter block (the case aomenc picks for2120 // whole-SB `PARTITION_NONE` 64x64 inter block (the case aomenc picks for
2121 // static content, previously a named refusal).2121 // static content, previously a named refusal).
2122+thread_local! {
2123+ /// lane-sb128c r1: how many 128x128 `PARTITION_NONE` roots this INTER tile
2124+ /// path decoded as one whole block (its gate's own witness).
2125+ pub(crate) static INTER_SB128_NONE_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
2126+ /// 128x64 / 64x128 INTER blocks decoded at the 128 root (lane-sb128c r7).
2127+ pub(crate) static INTER_SB128_HORZ_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
2128+ pub(crate) static INTER_SB128_VERT_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
2129+}
2130+
2131+/// Current value of [`INTER_SB128_HORZ_HITS`], for a gate's before/after delta.
2132+pub(crate) fn inter_sb128_horz_hits() -> usize {
2133+ INTER_SB128_HORZ_HITS.with(std::cell::Cell::get)
2134+}
2135+
2136+/// Current value of [`INTER_SB128_VERT_HITS`], for a gate's before/after delta.
2137+pub(crate) fn inter_sb128_vert_hits() -> usize {
2138+ INTER_SB128_VERT_HITS.with(std::cell::Cell::get)
2139+}
2140+
2141+/// Current value of [`INTER_SB128_NONE_HITS`], for a gate's before/after delta.
2142+pub fn inter_sb128_none_hits() -> usize {
2143+ INTER_SB128_NONE_HITS.with(std::cell::Cell::get)
2144+}
2145+
2146+thread_local! {
2147+ /// lane-sb128c r3: how many INTRA-coded 128x128 blocks inside an INTER
2148+ /// frame this decoder reconstructed (mu-chunk chroma, four TX_64X64 luma
2149+ /// units) -- the gate's witness that the lifted refusal's case fired.
2150+ pub(crate) static INTRA_128_IN_INTER_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
2151+}
2152+
2153+/// Current value of [`INTRA_128_IN_INTER_HITS`], for a gate's before/after delta.
2154+pub fn intra_128_in_inter_hits() -> usize {
2155+ INTRA_128_IN_INTER_HITS.with(std::cell::Cell::get)
2156+}
2157+
2122 thread_local! {2158 thread_local! {
2123 static INTER_SB_NONE_HITS: std::cell::Cell<usize> =2159 static INTER_SB_NONE_HITS: std::cell::Cell<usize> =
2124 const { std::cell::Cell::new(0) };2160 const { std::cell::Cell::new(0) };
@@ -4255,6 +4291,18 @@ impl Neighbours {
4255 /// `cols`/`rows` are in [`SUB`] units; `mi_cols`/`mi_rows` are the frame's4291 /// `cols`/`rows` are in [`SUB`] units; `mi_cols`/`mi_rows` are the frame's
4256 /// true (unpadded) size in 4x4 mode-info units.4292 /// true (unpadded) size in 4x4 mode-info units.
4257 fn new(cols: usize, rows: usize, mi_cols: usize, mi_rows: usize) -> Self {4293 fn new(cols: usize, rows: usize, mi_cols: usize, mi_rows: usize) -> Self {
4294+ // lane-sb128c r7: a 128x64 block at the bottom frame edge records its
4295+ // neighbour state over the whole 64-row extent, past the frame's last
4296+ // mi row (mi_rows 198, block rows 192..208). libaom's own context
4297+ // buffers are superblock-aligned for exactly that reason
4298+ // (`av1_alloc_context_buffers` rounds to `MAX_MIB_SIZE`), so pad the
4299+ // side arrays to a superblock multiple and leave those cells unread --
4300+ // every availability check uses the true `mi_rows`/`mi_cols` below.
4301+ let sb_sub = (sb_mi_cur() as usize) / (SUB / MI);
4302+ let (cols, rows) = (
4303+ cols.next_multiple_of(sb_sub),
4304+ rows.next_multiple_of(sb_sub),
4305+ );
4258 Self {4306 Self {
4259 above: vec![[Neighbour::default(); 3]; cols * (SUB / MI)],4307 above: vec![[Neighbour::default(); 3]; cols * (SUB / MI)],
4260 left: vec![[Neighbour::default(); 3]; rows * (SUB / MI)],4308 left: vec![[Neighbour::default(); 3]; rows * (SUB / MI)],
@@ -4583,6 +4631,31 @@ impl Neighbours {
4583 /// existing corner-cut, `Neighbours::tx_grid`'s own doc comment -- a4631 /// existing corner-cut, `Neighbours::tx_grid`'s own doc comment -- a
4584 /// rectangular strip's transform is `TX_32X16`/`TX_16X32`, not tracked4632 /// rectangular strip's transform is `TX_32X16`/`TX_16X32`, not tracked
4585 /// per-axis, matching lane-warp r5's `HORZ_B` top-strip precedent).4633 /// per-axis, matching lane-warp r5's `HORZ_B` top-strip precedent).
4634+ /// libaom `set_one_param_for_line_luma`/`_chroma`: an edge that is a
4635+ /// transform-unit edge but NOT a prediction-unit edge is not filtered when
4636+ /// `curr_skipped = mbmi->skip_txfm && is_inter_block(mbmi)`. Widening this
4637+ /// block's published transform extent to its own size is exactly that
4638+ /// suppression for the deblocker's `x0 % tx != 0` test -- the only shape
4639+ /// that needs it is the 128 root, whose chroma extent (64) is the one
4640+ /// [`Self::fill_lf_grid_rect`]'s TX_32X32 cap narrows. An INTRA block is
4641+ /// never suppressed (libaom's `is_inter_block` term), so this is called
4642+ /// only from the skipped-inter branch.
4643+ fn suppress_internal_lf_edges(&mut self, at_mi: (usize, usize), w_mi: usize, h_mi: usize) {
4644+ let (mi_r, mi_c) = at_mi;
4645+ let (uv_w, uv_h) = ((w_mi * MI / 2).max(4) as u8, (h_mi * MI / 2).max(4) as u8);
4646+ for rr in 0..h_mi {
4647+ for cc in 0..w_mi {
4648+ let idx = (mi_r + rr) * self.skip_grid_cols_mi + (mi_c + cc);
4649+ if let Some(cell) = self.uv_tx_grid.get_mut(idx) {
4650+ *cell = uv_w;
4651+ }
4652+ if let Some(cell) = self.uv_tx_h_grid.get_mut(idx) {
4653+ *cell = uv_h;
4654+ }
4655+ }
4656+ }
4657+ }
4658+
4586 fn fill_lf_grid_rect(4659 fn fill_lf_grid_rect(
4587 &mut self,4660 &mut self,
4588 at_mi: (usize, usize),4661 at_mi: (usize, usize),
@@ -5349,7 +5422,14 @@ impl Neighbours {
5349 round_up_even(self.mi_cols),5422 round_up_even(self.mi_cols),
5350 ];5423 ];
5351 for cell in 0..h_mi {5424 for cell in 0..h_mi {
5352- self.left[mi_r + cell] = std::array::from_fn(|plane| {5425+ // lane-sb128c r7: a 128x64 at the bottom frame edge names mi rows
5426+ // past the padded side arrays (mi_rows 198, block rows 192..208);
5427+ // libaom's own arrays are superblock-sized, so those cells simply
5428+ // have no reader. Same guard the `left_side_mi` loop above uses.
5429+ let Some(left_slot) = self.left.get_mut(mi_r + cell) else {
5430+ break;
5431+ };
5432+ *left_slot = std::array::from_fn(|plane| {
5353 if cell < h_mi.min(bound_h[plane].saturating_sub(mi_r)) {5433 if cell < h_mi.min(bound_h[plane].saturating_sub(mi_r)) {
5354 states[plane]5434 states[plane]
5355 } else {5435 } else {
@@ -5358,7 +5438,10 @@ impl Neighbours {
5358 });5438 });
5359 }5439 }
5360 for cell in 0..w_mi {5440 for cell in 0..w_mi {
5361- self.above[mi_c + cell] = std::array::from_fn(|plane| {5441+ let Some(above_slot) = self.above.get_mut(mi_c + cell) else {
5442+ break;
5443+ };
5444+ *above_slot = std::array::from_fn(|plane| {
5362 if cell < w_mi.min(bound_w[plane].saturating_sub(mi_c)) {5445 if cell < w_mi.min(bound_w[plane].saturating_sub(mi_c)) {
5363 states[plane]5446 states[plane]
5364 } else {5447 } else {
@@ -6074,6 +6157,14 @@ fn read_intra_mode_rect(
6074 06157 0
6075 };6158 };
6076 istep!("angle_y", angle_delta_y);6159 istep!("angle_y", angle_delta_y);
6160+ // lane-sb128c r3 (class sweep): libaom `read_intra_mode_uv(.., is_cfl_allowed(xd), ..)`
6161+ // and `is_cfl_allowed` (blockd.h) is `block_size_wide[bsize] <= 32 &&
6162+ // block_size_high[bsize] <= 32` on the LUMA bsize. Deciding the alphabet
6163+ // here, from the block's own size, is the single point every caller routes
6164+ // through -- a caller passing `true` for a >32 strip used to pick the
6165+ // 14-symbol CFL CDF, same value but a different range (class
6166+ // wrong-alphabet-same-value).
6167+ let cfl = cfl && bw <= 32 && bh <= 32;
6077 let uv_mode = if !has_chroma {6168 let uv_mode = if !has_chroma {
6078 DC_PRED6169 DC_PRED
6079 } else if cfl {6170 } else if cfl {
@@ -9299,6 +9390,10 @@ fn read_intra_mode(
9299 09390 0
9300 };9391 };
9301 istep!("angle_y", angle_delta_y);9392 istep!("angle_y", angle_delta_y);
9393+ // lane-sb128c r3 (class sweep): `is_cfl_allowed` on the luma bsize, decided
9394+ // here so every `decode_block` caller (64x64 and 128x128 roots included)
9395+ // picks the right alphabet -- see [`read_intra_mode_rect`]'s twin.
9396+ let cfl = cfl && side <= 32;
9302 let uv_mode = if cfl {9397 let uv_mode = if cfl {
9303 dec.symbol(&mut cdfs.uv_mode_cfl[mode])9398 dec.symbol(&mut cdfs.uv_mode_cfl[mode])
9304 } else {9399 } else {
@@ -12388,6 +12483,21 @@ fn read_block_tx_size(
12388 skip: bool,12483 skip: bool,
12389 ) -> Result<(usize, Option<Vec<(usize, usize, usize, usize)>>)> {12484 ) -> Result<(usize, Option<Vec<(usize, usize, usize, usize)>>)> {
12390 if !TX_SELECT_INTER.with(std::cell::Cell::get) {12485 if !TX_SELECT_INTER.with(std::cell::Cell::get) {
12486+ // lane-sb128c r1: `max_txsize_rect_lookup[BLOCK_128X128]` is TX_64X64,
12487+ // so a 128x128 inter block is FOUR luma units even with `tx_mode ==
12488+ // TX_MODE_LARGEST` -- the same leaf shape the var-tx tree hands back.
12489+ // lane-sb128c r3: intra too -- an INTRA 128x128 block under
12490+ // `TX_MODE_LARGEST` also resolves to TX_64X64, i.e. four luma units.
12491+ if side > 64 {
12492+ let step = 64 / MI;
12493+ let mut leaves = Vec::new();
12494+ for row in (0..side / MI).step_by(step) {
12495+ for col in (0..side / MI).step_by(step) {
12496+ leaves.push((row, col, 64, 64));
12497+ }
12498+ }
12499+ return Ok((64, Some(leaves)));
12500+ }
12391 return Ok((side, None));12501 return Ok((side, None));
12392 }12502 }
12393 let side_mi = side / MI;12503 let side_mi = side / MI;
@@ -12415,7 +12525,12 @@ fn read_block_tx_size(
12415 }12525 }
12416 }12526 }
12417 let single = leaves.len() == 1 && leaves[0].2 == side && leaves[0].3 == side;12527 let single = leaves.len() == 1 && leaves[0].2 == side && leaves[0].3 == side;
12418- if !single && leaves.iter().any(|leaf| leaf.2.max(leaf.3) > 32) {12528+ // lane-sb128c r6: below the 128 root the ceiling is main's TX_32X32
12529+ // ([`inter_txbset_for`] has no 64-point *inter* table set); a 128x128
12530+ // block's own var-tx tree legitimately bottoms out at TX_64X64 leaves,
12531+ // which the mu-chunk reader above codes as their 32x32 coded corner.
12532+ let leaf_ceiling = if side > 64 { 64 } else { 32 };
12533+ if !single && leaves.iter().any(|leaf| leaf.2.max(leaf.3) > leaf_ceiling) {
12419 // Only a block wider than a superblock's own 64x64 max transform12534 // Only a block wider than a superblock's own 64x64 max transform
12420 // reaches here; this crate has no 64-point *inter* coefficient12535 // reaches here; this crate has no 64-point *inter* coefficient
12421 // table set ([`inter_txbset_for`] stops at 32).12536 // table set ([`inter_txbset_for`] stops at 32).
@@ -12435,7 +12550,10 @@ fn read_block_tx_size(
12435 n,12550 n,
12436 at_mi,12551 at_mi,
12437 side,12552 side,
12438- Some(tx_size_context_txfm(n, at_mi, side)),12553+ // lane-sb128c r3: `get_tx_size_context` compares the neighbour txfm
12554+ // contexts against `tx_size_wide[max_txsize_rect_lookup[bsize]]`,
12555+ // which is 64 for BLOCK_128X128 -- never the block's own 128 side.
12556+ Some(tx_size_context_txfm(n, at_mi, side.min(64))),
12439 )12557 )
12440 };12558 };
12441 set_txfm_ctxs(n, at_mi, tx, side_mi, side_mi, skip && is_inter);12559 set_txfm_ctxs(n, at_mi, tx, side_mi, side_mi, skip && is_inter);
@@ -12497,6 +12615,12 @@ fn rect_inter_residual_supported(w: usize, h: usize) -> bool {
12497 // Only reachable as a var-tx LEAF -- an 8x4/4x8 inter BLOCK is12615 // Only reachable as a var-tx LEAF -- an 8x4/4x8 inter BLOCK is
12498 // refused earlier ("an inter partition below 8x8").12616 // refused earlier ("an inter partition below 8x8").
12499 | (8, 4) | (4, 8)12617 | (8, 4) | (4, 8)
12618+ // lane-sb128c r7: the 128 root's HORZ/VERT halves. These are NOT
12619+ // one rectangular transform -- `max_txsize_rect_lookup
12620+ // [BLOCK_128X64]` is TX_64X64, so the block tiles into two square
12621+ // TX_64X64 units read through the mu-chunk loop, same as the
12622+ // 128x128 NONE block's four.
12623+ | (128, 64) | (64, 128)
12500 )12624 )
12501 }12625 }
12502 12626
@@ -12655,6 +12779,55 @@ fn read_block_tx_size_rect(
12655 }12779 }
12656 // `max_txsize_rect_lookup` is the block's own size, capped at 64 -- and12780 // `max_txsize_rect_lookup` is the block's own size, capped at 64 -- and
12657 // `rect_inter_residual_supported` has already excluded everything above 32.12781 // `rect_inter_residual_supported` has already excluded everything above 32.
12782+ // lane-sb128c r7: except at the 128 root. `max_txsize_rect_lookup
12783+ // [BLOCK_128X64] == TX_64X64` (libaom `common_data.h`), so a 128x64 block
12784+ // is TWO square top-level transform units side by side and a 64x128 one is
12785+ // two stacked -- exactly what libaom `read_block_tx_size`
12786+ // (decodeframe.c:1140) codes with its `idy/idx` loop over
12787+ // `tx_size_high_unit/tx_size_wide_unit[max_tx_size]`. Each unit reads its
12788+ // own `txfm_partition` symbol at depth 0.
12789+ if bw.max(bh) > 64 {
12790+ let tx = 64usize;
12791+ let (max_w_mi, max_h_mi) = (
12792+ (bw / MI).min(mi_cols.saturating_sub(at_mi.1)),
12793+ (bh / MI).min(mi_rows.saturating_sub(at_mi.0)),
12794+ );
12795+ let mut leaves = Vec::new();
12796+ if !TX_SELECT_INTER.with(std::cell::Cell::get) {
12797+ for row in (0..bh / MI).step_by(tx / MI) {
12798+ for col in (0..bw / MI).step_by(tx / MI) {
12799+ leaves.push((row, col, tx, tx));
12800+ }
12801+ }
12802+ for &(row, col, tw, th) in &leaves {
12803+ txfm_partition_update_rect(n, (at_mi.0 + row, at_mi.1 + col), (tw, th), (tw, th));
12804+ }
12805+ return Ok(Some(leaves));
12806+ }
12807+ for row in (0..bh / MI).step_by(tx / MI) {
12808+ for col in (0..bw / MI).step_by(tx / MI) {
12809+ read_var_tx_size(
12810+ dec,
12811+ cdfs,
12812+ n,
12813+ at_mi,
12814+ bw.max(bh),
12815+ (max_w_mi, max_h_mi),
12816+ (tx, tx),
12817+ 0,
12818+ row,
12819+ col,
12820+ &mut leaves,
12821+ );
12822+ }
12823+ }
12824+ if leaves.iter().any(|l| l.2.max(l.3) > 64) {
12825+ return Err(unsupported(
12826+ "an inter var-tx tree with a leaf transform larger than 64x64",
12827+ ));
12828+ }
12829+ return Ok(Some(leaves));
12830+ }
12658 let (tx_w, tx_h) = (bw, bh);12831 let (tx_w, tx_h) = (bw, bh);
12659 if !TX_SELECT_INTER.with(std::cell::Cell::get) {12832 if !TX_SELECT_INTER.with(std::cell::Cell::get) {
12660 // `TX_MODE_LARGEST`: no symbol at all, the whole block is one12833 // `TX_MODE_LARGEST`: no symbol at all, the whole block is one
@@ -12965,6 +13138,12 @@ fn reduce_inherited_chroma_tx_type(t: TxType, w: usize, h: usize) -> TxType {
12965 13138
12966 fn inter_txbset_for(tx_px: usize, reduced_tx_set: bool) -> TxbSet {13139 fn inter_txbset_for(tx_px: usize, reduced_tx_set: bool) -> TxbSet {
12967 match tx_px {13140 match tx_px {
13141+ // lane-sb128c r1: a 128x128 inter block's own luma unit
13142+ // (`max_txsize_rect_lookup[BLOCK_128X128] == TX_64X64`).
13143+ // `av1_get_ext_tx_set_type` is `DCT_ONLY` at `tx_size_sqr_up ==
13144+ // TX_64X64`, so no `tx_type` symbol is coded and the intra/inter sets
13145+ // coincide -- exactly the set the whole-64x64 inter block already uses.
13146+ 64 => TxbSet::Luma64,
12968 32 => TxbSet::Luma32Inter,13147 32 => TxbSet::Luma32Inter,
12969 16 if reduced_tx_set => TxbSet::Luma16Inter,13148 16 if reduced_tx_set => TxbSet::Luma16Inter,
12970 16 => TxbSet::Luma16InterSet1,13149 16 => TxbSet::Luma16InterSet1,
@@ -13927,6 +14106,15 @@ thread_local! {
13927 /// How many 128x128 superblock roots resolved to `PARTITION_NONE` -- one14106 /// How many 128x128 superblock roots resolved to `PARTITION_NONE` -- one
13928 /// whole 128x128 block (lane-sb128b r1's gate counter).14107 /// whole 128x128 block (lane-sb128b r1's gate counter).
13929 pub(crate) static PART128_NONE_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };14108 pub(crate) static PART128_NONE_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
14109+ /// 128 roots that resolved to PARTITION_HORZ (two 128x64 pieces, or one
14110+ /// when the bottom half is out of frame) -- lane-sb128c r7.
14111+ pub(crate) static PART128_HORZ_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
14112+ /// 128 roots that resolved to PARTITION_VERT (two 64x128 pieces).
14113+ pub(crate) static PART128_VERT_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
14114+ /// Of those, the ones decided by the GATHERED bit at a frame edge -- the
14115+ /// only shape a 1080p (mi_rows = 270) stream reaches.
14116+ pub(crate) static PART128_EDGE_HORZ_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
14117+ pub(crate) static PART128_EDGE_VERT_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
13930 }14118 }
13931 14119
13932 /// [`PART128_NONE_HITS`], for a gate's own before/after delta.14120 /// [`PART128_NONE_HITS`], for a gate's own before/after delta.
@@ -13934,6 +14122,26 @@ pub(crate) fn part128_none_hits() -> usize {
13934 PART128_NONE_HITS.with(std::cell::Cell::get)14122 PART128_NONE_HITS.with(std::cell::Cell::get)
13935 }14123 }
13936 14124
14125+/// [`PART128_HORZ_HITS`], for a gate's own before/after delta.
14126+pub(crate) fn part128_horz_hits() -> usize {
14127+ PART128_HORZ_HITS.with(std::cell::Cell::get)
14128+}
14129+
14130+/// [`PART128_VERT_HITS`], for a gate's own before/after delta.
14131+pub(crate) fn part128_vert_hits() -> usize {
14132+ PART128_VERT_HITS.with(std::cell::Cell::get)
14133+}
14134+
14135+/// [`PART128_EDGE_HORZ_HITS`] -- gathered-bit HORZ at the bottom frame edge.
14136+pub(crate) fn part128_edge_horz_hits() -> usize {
14137+ PART128_EDGE_HORZ_HITS.with(std::cell::Cell::get)
14138+}
14139+
14140+/// [`PART128_EDGE_VERT_HITS`] -- gathered-bit VERT at the right frame edge.
14141+pub(crate) fn part128_edge_vert_hits() -> usize {
14142+ PART128_EDGE_VERT_HITS.with(std::cell::Cell::get)
14143+}
14144+
13937 thread_local! {14145 thread_local! {
13938 /// How many CHROMA transform units were coded inside a block whose uv14146 /// How many CHROMA transform units were coded inside a block whose uv
13939 /// plane block is more than one unit (lane-sb128b r2 -- only a 128x12814147 /// plane block is more than one unit (lane-sb128b r2 -- only a 128x128
@@ -13995,6 +14203,7 @@ fn read_sb128_root(
13995 if dec.symbol_fixed(&gather_of(&cdfs.partition_w128[ctx128], &VERT_ALIKE128)) == 1 {14203 if dec.symbol_fixed(&gather_of(&cdfs.partition_w128[ctx128], &VERT_ALIKE128)) == 1 {
13996 PARTITION_SPLIT14204 PARTITION_SPLIT
13997 } else {14205 } else {
14206+ PART128_EDGE_HORZ_HITS.with(|c| c.set(c.get() + 1));
13998 PARTITION_HORZ14207 PARTITION_HORZ
13999 }14208 }
14000 }14209 }
@@ -14002,6 +14211,7 @@ fn read_sb128_root(
14002 if dec.symbol_fixed(&gather_of(&cdfs.partition_w128[ctx128], &HORZ_ALIKE128)) == 1 {14211 if dec.symbol_fixed(&gather_of(&cdfs.partition_w128[ctx128], &HORZ_ALIKE128)) == 1 {
14003 PARTITION_SPLIT14212 PARTITION_SPLIT
14004 } else {14213 } else {
14214+ PART128_EDGE_VERT_HITS.with(|c| c.set(c.get() + 1));
14005 PARTITION_VERT14215 PARTITION_VERT
14006 }14216 }
14007 }14217 }
@@ -14015,15 +14225,23 @@ fn read_sb128_root(
14015 // lane-sb128b r1: `PARTITION_NONE` -- one 128x128 block -- is decoded by14225 // lane-sb128b r1: `PARTITION_NONE` -- one 128x128 block -- is decoded by
14016 // the key-frame caller below. The six remaining arms (HORZ/VERT and the14226 // the key-frame caller below. The six remaining arms (HORZ/VERT and the
14017 // four AB shapes) still need the rect/AB machinery at this size.14227 // four AB shapes) still need the rect/AB machinery at this size.
14018- if part128 != PARTITION_SPLIT && part128 != PARTITION_NONE {14228+ // lane-sb128c r7: HORZ (two 128x64) and VERT (two 64x128) now decode on
14019- return Err(unsupported(14229+ // both tile paths. The four AB shapes (libaom `decode_partition`'s
14020- "a 128x128 superblock HORZ/VERT or AB partition (only SPLIT and NONE are decoded at the 128 root)",14230+ // PARTITION_HORZ_A..VERT_B, decodeframe.c) still need the mixed
14021- ));14231+ // 128x64 + 64x64 + 64x64 visit order and stay refused by name; a 128
14022- }14232+ // root has no 1:4 arm at all (`PARTITION_HORZ_4`/`VERT_4` are excluded
14023- if part128 == PARTITION_SPLIT {14233+ // for BLOCK_128X128 by `av1_get_partition_cdf`'s 8-symbol alphabet,
14024- PART128_SPLIT_HITS.with(|c| c.set(c.get() + 1));14234+ // which stops at VERT_B).
14025- } else {14235+ match part128 {
14026- PART128_NONE_HITS.with(|c| c.set(c.get() + 1));14236+ PARTITION_SPLIT => PART128_SPLIT_HITS.with(|c| c.set(c.get() + 1)),
14237+ PARTITION_NONE => PART128_NONE_HITS.with(|c| c.set(c.get() + 1)),
14238+ PARTITION_HORZ => PART128_HORZ_HITS.with(|c| c.set(c.get() + 1)),
14239+ PARTITION_VERT => PART128_VERT_HITS.with(|c| c.set(c.get() + 1)),
14240+ _ => {
14241+ return Err(unsupported(
14242+ "a 128x128 superblock AB partition (HORZ_A/HORZ_B/VERT_A/VERT_B at the 128 root)",
14243+ ));
14244+ }
14027 }14245 }
14028 Ok(part128)14246 Ok(part128)
14029 }14247 }
@@ -14236,6 +14454,16 @@ pub(crate) fn decode_key_frame_tile_with_cdfs(
14236 mi_cols,14454 mi_cols,
14237 mi_rows,14455 mi_rows,
14238 )?;14456 )?;
14457+ if matches!(part128, PARTITION_HORZ | PARTITION_VERT) {
14458+ // lane-sb128c r7: the INTER path decodes these (two 128x64
14459+ // / two 64x128 blocks, the film's own bottom-edge shape);
14460+ // the key path's `decode_block` is square-only, so an
14461+ // intra 128x64 would silently decode as four 64x64
14462+ // quadrants. Refuse by name instead of corrupting.
14463+ return Err(unsupported(
14464+ "a 128x128 superblock HORZ/VERT partition on an intra frame (the inter path decodes it; the intra one is square-block only)",
14465+ ));
14466+ }
14239 if part128 == PARTITION_NONE {14467 if part128 == PARTITION_NONE {
14240 // One 128x128 intra block: four TX_64X64 luma units and a14468 // One 128x128 intra block: four TX_64X64 luma units and a
14241 // single 64x64 chroma unit per plane (`av1_get_max_uv_txsize`14469 // single 64x64 chroma unit per plane (`av1_get_max_uv_txsize`
@@ -16189,6 +16417,12 @@ impl PlaneBuf {
16189 prediction: &[u16],16417 prediction: &[u16],
16190 residual: &[i32],16418 residual: &[i32],
16191 ) {16419 ) {
16420+ // lane-sb128c r7: a 128x64 half of a 128 root at the BOTTOM frame edge
16421+ // is the first block shape whose true footprint overhangs the padded
16422+ // coding surface (mi_rows = 198 -> a plane 800 rows tall, block rows
16423+ // 768..832). libaom reconstructs those rows into the frame buffer's
16424+ // border; nothing reads them back, so they are simply dropped here.
16425+ let (h, w) = (h.min(self.height.saturating_sub(y)), w.min(self.width.saturating_sub(x)));
16192 for row in 0..h {16426 for row in 0..h {
16193 for col in 0..w {16427 for col in 0..w {
16194 let sample = (i32::from(prediction[row * side + col]) + residual[row * side + col])16428 let sample = (i32::from(prediction[row * side + col]) + residual[row * side + col])
@@ -16239,7 +16473,13 @@ fn read_inter_plane(
16239 let skip_ctx = if plane_idx == 0 {16473 let skip_ctx = if plane_idx == 0 {
16240 luma_skip_ctx.unwrap_or(0)16474 luma_skip_ctx.unwrap_or(0)
16241 } else {16475 } else {
16242- usize::from(around.0) + usize::from(around.1)16476+ // lane-sb128c r1: on a CHROMA plane this same parameter carries
16477+ // `get_txb_ctx`'s own offset instead -- `combine_entropy_contexts(..)`
16478+ // is +7 normally and +10 when the plane block is LARGER than the
16479+ // transform (a 128x128 block's 64x64 uv plane block with TX_32X32
16480+ // units, AV1's only such case), and the `txb_skip_chroma_32` table
16481+ // carries the offset-10 rows at +3 (lane-sb128b r3).
16482+ usize::from(around.0) + usize::from(around.1) + luma_skip_ctx.unwrap_or(0)
16243 };16483 };
16244 let mut coding = cdfs.txb(set, tx_mode);16484 let mut coding = cdfs.txb(set, tx_mode);
16245 let default_tx_type = match inherited_luma_tx_type {16485 let default_tx_type = match inherited_luma_tx_type {
@@ -16983,8 +17223,13 @@ fn obmc_blend(
16983 if matches!((write_w, write_h), (16, 8) | (8, 16)) {17223 if matches!((write_w, write_h), (16, 8) | (8, 16)) {
16984 OBMC_RECT_LEAF_HITS.with(|c| c.set(c.get() + 1));17224 OBMC_RECT_LEAF_HITS.with(|c| c.set(c.get() + 1));
16985 }17225 }
16986- let overlap_above = write_h / 2;17226+ // lane-sb128c r1: libaom caps the overlap strip at a 64x64 block's own
16987- let overlap_left = write_w / 2;17227+ // half (`reconinter.c` 860/899: `AOMMIN(block_size_high[bsize],
17228+ // block_size_high[BLOCK_64X64]) >> 1`, and the `block_size_wide` mirror) --
17229+ // inert below 128, where a 128x128 block would otherwise blend a 64-row
17230+ // strip `obmc_mask` has no table for.
17231+ let overlap_above = write_h.min(64) / 2;
17232+ let overlap_left = write_w.min(64) / 2;
16988 // lane-inter8 r1 / lane-scaledref r1: `av1_skip_u4x4_pred_in_obmc`17233 // lane-inter8 r1 / lane-scaledref r1: `av1_skip_u4x4_pred_in_obmc`
16989 // (`reconinter.c` 820, `DISABLE_CHROMA_U8X8_OBMC == 0` -- "one-sided17234 // (`reconinter.c` 820, `DISABLE_CHROMA_U8X8_OBMC == 0` -- "one-sided
16990 // obmc") returns `dir == 0` when the chroma plane's own block is17235 // obmc") returns `dir == 0` when the chroma plane's own block is
@@ -17626,7 +17871,10 @@ fn decode_inter_block(
17626 maybe_read_cdef_idx(dec, rmi, cmi, skip);17871 maybe_read_cdef_idx(dec, rmi, cmi, skip);
17627 // lane-inter4 r1: spec 5.11.6's `bSize == sbSize` -- a 64x32/64x16 strip17872 // lane-inter4 r1: spec 5.11.6's `bSize == sbSize` -- a 64x32/64x16 strip
17628 // is NOT the whole superblock, so its `skip` never suppresses the read.17873 // is NOT the whole superblock, so its `skip` never suppresses the read.
17629- let whole_sb = side == 64 && write_w == 64 && write_h == 64;17874+ // lane-sb128c r7: `sbSize` is 128 under `--sb-size=128`, so the whole-block
17875+ // test is against the sequence's own superblock side, not a hardcoded 64.
17876+ let sb_px = sb_mi_cur() as usize * 4;
17877+ let whole_sb = side == sb_px && write_w == sb_px && write_h == sb_px;
17630 maybe_read_delta_q(dec, cdfs, rmi, cmi, whole_sb, skip);17878 maybe_read_delta_q(dec, cdfs, rmi, cmi, whole_sb, skip);
17631 maybe_read_delta_lf(dec, cdfs, rmi, cmi, whole_sb, skip);17879 maybe_read_delta_lf(dec, cdfs, rmi, cmi, whole_sb, skip);
17632 let (has_above, has_left) = (17880 let (has_above, has_left) = (
@@ -17636,13 +17884,19 @@ fn decode_inter_block(
17636 let (above_inter, left_inter) = (neighbours.above_inter[cmi], neighbours.left_inter[rmi]);17884 let (above_inter, left_inter) = (neighbours.above_inter[cmi], neighbours.left_inter[rmi]);
17637 let ii_ctx = intra_inter_ctx(has_above, has_left, above_inter, left_inter);17885 let ii_ctx = intra_inter_ctx(has_above, has_left, above_inter, left_inter);
17638 let is_inter = skip_mode || dec.symbol(&mut cdfs.intra_inter[ii_ctx]) == 1;17886 let is_inter = skip_mode || dec.symbol(&mut cdfs.intra_inter[ii_ctx]) == 1;
17887+ // lane-sb128c r1: this round wires the INTER half of a 128x128 block (four
17888+ // TX_64X64 luma units and four TX_32X32 chroma units interleaved per mu
17889+ // chunk). An INTRA block at that size inside an inter frame takes the
17890+ // intra tail below, which still codes one whole-block chroma unit and one
17891+ // `read_tx_size` at 128 -- refuse by name instead of mis-decoding it.
17639 if std::env::var_os("EC_TRACE_MODE").is_some() {17892 if std::env::var_os("EC_TRACE_MODE").is_some() {
17640 eprintln!(17893 eprintln!(
17641- "EC_MODE mi_row={} mi_col={} is_inter={} skip={skip} rng={}",17894+ "EC_MODE mi_row={} mi_col={} rng={} is_inter={} skip={} side={side}",
17642 rmi,17895 rmi,
17643 cmi,17896 cmi,
17644- is_inter as u8,17897+ dec.debug_state().0,
17645- dec.debug_state().017898+ u8::from(is_inter),
17899+ u8::from(skip)
17646 );17900 );
17647 }17901 }
17648 // lane-warp r5: see `reject_residual` -- a square-block decode of a17902 // lane-warp r5: see `reject_residual` -- a square-block decode of a
@@ -18582,6 +18836,11 @@ fn decode_inter_block(
18582 neighbours.around_mi(at, side)18836 neighbours.around_mi(at, side)
18583 };18837 };
18584 let luma_tx_type;18838 let luma_tx_type;
18839+ // lane-sb128c r1: a 128x128 inter block's four chroma units
18840+ // are read INSIDE the luma leaf loop (one per 64x64 mu chunk);
18841+ // these collect them for the block-level neighbour write-back.
18842+ let mut u_units = vec![0i32; chroma_side * chroma_side];
18843+ let mut v_units = vec![0i32; chroma_side * chroma_side];
18585 if let Some(leaves) = vartx_leaves.clone() {18844 if let Some(leaves) = vartx_leaves.clone() {
18586 // spec 5.11.17's transform tree, leaf by leaf in the order18845 // spec 5.11.17's transform tree, leaf by leaf in the order
18587 // `read_var_tx_size` coded it: each unit reads its own18846 // `read_var_tx_size` coded it: each unit reads its own
@@ -18600,7 +18859,7 @@ fn decode_inter_block(
18600 let start = (row * MI + rr) * side + col * MI;18859 let start = (row * MI + rr) * side + col * MI;
18601 tu_pred.extend_from_slice(&pred_y[start..start + tx_px]);18860 tu_pred.extend_from_slice(&pred_y[start..start + tx_px]);
18602 }18861 }
18603- let scan = default_scan(tx_px);18862+ let scan = default_scan(tx_px.min(32));
18604 let tu_skip_ctx = neighbours.luma_skip_ctx(tu_mi, tx_px / MI);18863 let tu_skip_ctx = neighbours.luma_skip_ctx(tu_mi, tx_px / MI);
18605 read_inter_plane(18864 read_inter_plane(
18606 dec,18865 dec,
@@ -18652,6 +18911,79 @@ fn decode_inter_block(
18652 first_tx_type = tu_tx_type;18911 first_tx_type = tu_tx_type;
18653 }18912 }
18654 neighbours.record_mi_luma_rect(tu_mi, tw, th, &tu_grid);18913 neighbours.record_mi_luma_rect(tu_mi, tw, th, &tu_grid);
18914+ // lane-sb128c r1: libaom's `decode_token_recon_block`
18915+ // walks 64x64 "mu" chunks (`mu_blocks_wide/high =
18916+ // mi_size_wide[BLOCK_64X64]`) and codes EVERY PLANE of
18917+ // a chunk before the next one, so a 128x128 block
18918+ // interleaves Y,U,V per quadrant -- the same order the
18919+ // intra 128 path reads (lane-sb128b r3, measured
18920+ // against aomdec's `EC_TRACE_COEFF`). Below 128 a block
18921+ // is a single chunk and this never fires.
18922+ if side > 64 {
18923+ let chunk = (row / 16, col / 16);
18924+ let done = idx + 1 == leaves.len()
18925+ || (leaves[idx + 1].0 / 16, leaves[idx + 1].1 / 16) != chunk;
18926+ if done {
18927+ let (cr, cc) = chunk;
18928+ // `av1_get_max_uv_txsize(BLOCK_128X128)` =
18929+ // `av1_get_adjusted_tx_size(TX_64X64)` =
18930+ // TX_32X32: one 32x32 chroma unit per chunk.
18931+ let cu_tx = 32usize;
18932+ let luma_span = cu_tx * 2;
18933+ let cu_mi = (at_mi.0 + cr * 16, at_mi.1 + cc * 16);
18934+ let cu_around = neighbours.around_mi(cu_mi, luma_span);
18935+ let (cu_x, cu_y) = (cpx + cc * cu_tx, cpy + cr * cu_tx);
18936+ let cu_scan = default_scan(cu_tx);
18937+ for plane_idx in 1..3 {
18938+ let (src, buf) = if plane_idx == 1 {
18939+ (&pred_u, &mut *u)
18940+ } else {
18941+ (&pred_v, &mut *v)
18942+ };
18943+ let mut cu_pred = Vec::with_capacity(cu_tx * cu_tx);
18944+ for rr in 0..cu_tx {
18945+ let start =
18946+ (cr * cu_tx + rr) * chroma_side + cc * cu_tx;
18947+ cu_pred.extend_from_slice(&src[start..start + cu_tx]);
18948+ }
18949+ let cu_grid = read_inter_plane(
18950+ dec,
18951+ cdfs,
18952+ chroma_set,
18953+ &cu_scan,
18954+ plane_idx,
18955+ cu_around[plane_idx],
18956+ mode_for_tx,
18957+ buf,
18958+ cu_x,
18959+ cu_y,
18960+ cu_tx,
18961+ base_q_idx,
18962+ &cu_pred,
18963+ Some(first_tx_type),
18964+ Some(3),
18965+ )?
18966+ .0;
18967+ // Immediately, so the NEXT chunk's unit
18968+ // reads this one's coefficient context.
18969+ neighbours.record_mi_chroma(
18970+ cu_mi, luma_span, luma_span, plane_idx, &cu_grid,
18971+ );
18972+ CHROMA_SPLIT_TX_HITS.with(|c| c.set(c.get() + 1));
18973+ let dst = if plane_idx == 1 {
18974+ &mut u_units
18975+ } else {
18976+ &mut v_units
18977+ };
18978+ for rr in 0..cu_tx {
18979+ let start =
18980+ (cr * cu_tx + rr) * chroma_side + cc * cu_tx;
18981+ dst[start..start + cu_tx]
18982+ .copy_from_slice(&cu_grid[rr * cu_tx..][..cu_tx]);
18983+ }
18984+ }
18985+ }
18986+ }
18655 }18987 }
18656 // `av1_get_tx_type`'s chroma lookup scales the chroma18988 // `av1_get_tx_type`'s chroma lookup scales the chroma
18657 // position back to luma, so an inter block's chroma18989 // position back to luma, so an inter block's chroma
@@ -18698,7 +19030,13 @@ fn decode_inter_block(
18698 None,19030 None,
18699 )?;19031 )?;
18700 }19032 }
18701- if rect_tu {19033+ if side > 64 {
19034+ // Already read inside the mu-chunk loop above -- at the 128
19035+ // root a rect (128x64/64x128) block's chroma is per mu
19036+ // chunk too, so this test comes BEFORE the `rect_tu` one.
19037+ u_grid = std::mem::take(&mut u_units);
19038+ v_grid = std::mem::take(&mut v_units);
19039+ } else if rect_tu {
18702 // `av1_get_max_uv_txsize(bsize)`: the chroma transform of a19040 // `av1_get_max_uv_txsize(bsize)`: the chroma transform of a
18703 // 2:1 strip is the strip's own rect chroma size (16x8 /19041 // 2:1 strip is the strip's own rect chroma size (16x8 /
18704 // 8x16), one unit for the whole block, and it codes no19042 // 8x16), one unit for the whole block, and it codes no
@@ -19117,6 +19455,11 @@ fn decode_inter_block(
19117 // interval narrowing, not a wrong value (class19455 // interval narrowing, not a wrong value (class
19118 // wrong-alphabet-same-value).19456 // wrong-alphabet-same-value).
19119 let bsize_idx = match (write_w, write_h) {19457 let bsize_idx = match (write_w, write_h) {
19458+ // lane-sb128c r5: the 128 root's own rows come FIRST --
19459+ // the square arm below maps 128 to row 4 (BLOCK_16X32).
19460+ (64, 128) => 14,
19461+ (128, 64) => 15,
19462+ (128, 128) => 16,
19120 (w, h) if w == h => (w.trailing_zeros() - 3) as usize,19463 (w, h) if w == h => (w.trailing_zeros() - 3) as usize,
19121 (16, 32) => 4,19464 (16, 32) => 4,
19122 (32, 16) => 5,19465 (32, 16) => 5,
@@ -19684,6 +20027,11 @@ fn decode_inter_block(
19684 _ => around,20027 _ => around,
19685 };20028 };
19686 let luma_tx_type;20029 let luma_tx_type;
20030+ // lane-sb128c r1: a 128x128 inter block's four chroma units
20031+ // are read INSIDE the luma leaf loop (one per 64x64 mu chunk);
20032+ // these collect them for the block-level neighbour write-back.
20033+ let mut u_units = vec![0i32; chroma_side * chroma_side];
20034+ let mut v_units = vec![0i32; chroma_side * chroma_side];
19687 if let Some(leaves) = vartx_leaves.clone() {20035 if let Some(leaves) = vartx_leaves.clone() {
19688 // spec 5.11.17's transform tree, leaf by leaf in the order20036 // spec 5.11.17's transform tree, leaf by leaf in the order
19689 // `read_var_tx_size` coded it: each unit reads its own20037 // `read_var_tx_size` coded it: each unit reads its own
@@ -19702,7 +20050,7 @@ fn decode_inter_block(
19702 let start = (row * MI + rr) * side + col * MI;20050 let start = (row * MI + rr) * side + col * MI;
19703 tu_pred.extend_from_slice(&pred_y[start..start + tx_px]);20051 tu_pred.extend_from_slice(&pred_y[start..start + tx_px]);
19704 }20052 }
19705- let scan = default_scan(tx_px);20053+ let scan = default_scan(tx_px.min(32));
19706 let tu_skip_ctx = neighbours.luma_skip_ctx(tu_mi, tx_px / MI);20054 let tu_skip_ctx = neighbours.luma_skip_ctx(tu_mi, tx_px / MI);
19707 read_inter_plane(20055 read_inter_plane(
19708 dec,20056 dec,
@@ -19754,6 +20102,79 @@ fn decode_inter_block(
19754 first_tx_type = tu_tx_type;20102 first_tx_type = tu_tx_type;
19755 }20103 }
19756 neighbours.record_mi_luma_rect(tu_mi, tw, th, &tu_grid);20104 neighbours.record_mi_luma_rect(tu_mi, tw, th, &tu_grid);
20105+ // lane-sb128c r1: libaom's `decode_token_recon_block`
20106+ // walks 64x64 "mu" chunks (`mu_blocks_wide/high =
20107+ // mi_size_wide[BLOCK_64X64]`) and codes EVERY PLANE of
20108+ // a chunk before the next one, so a 128x128 block
20109+ // interleaves Y,U,V per quadrant -- the same order the
20110+ // intra 128 path reads (lane-sb128b r3, measured
20111+ // against aomdec's `EC_TRACE_COEFF`). Below 128 a block
20112+ // is a single chunk and this never fires.
20113+ if side > 64 {
20114+ let chunk = (row / 16, col / 16);
20115+ let done = idx + 1 == leaves.len()
20116+ || (leaves[idx + 1].0 / 16, leaves[idx + 1].1 / 16) != chunk;
20117+ if done {
20118+ let (cr, cc) = chunk;
20119+ // `av1_get_max_uv_txsize(BLOCK_128X128)` =
20120+ // `av1_get_adjusted_tx_size(TX_64X64)` =
20121+ // TX_32X32: one 32x32 chroma unit per chunk.
20122+ let cu_tx = 32usize;
20123+ let luma_span = cu_tx * 2;
20124+ let cu_mi = (at_mi.0 + cr * 16, at_mi.1 + cc * 16);
20125+ let cu_around = neighbours.around_mi(cu_mi, luma_span);
20126+ let (cu_x, cu_y) = (cpx + cc * cu_tx, cpy + cr * cu_tx);
20127+ let cu_scan = default_scan(cu_tx);
20128+ for plane_idx in 1..3 {
20129+ let (src, buf) = if plane_idx == 1 {
20130+ (&pred_u, &mut *u)
20131+ } else {
20132+ (&pred_v, &mut *v)
20133+ };
20134+ let mut cu_pred = Vec::with_capacity(cu_tx * cu_tx);
20135+ for rr in 0..cu_tx {
20136+ let start =
20137+ (cr * cu_tx + rr) * chroma_side + cc * cu_tx;
20138+ cu_pred.extend_from_slice(&src[start..start + cu_tx]);
20139+ }
20140+ let cu_grid = read_inter_plane(
20141+ dec,
20142+ cdfs,
20143+ chroma_set,
20144+ &cu_scan,
20145+ plane_idx,
20146+ cu_around[plane_idx],
20147+ mode_for_tx,
20148+ buf,
20149+ cu_x,
20150+ cu_y,
20151+ cu_tx,
20152+ base_q_idx,
20153+ &cu_pred,
20154+ Some(first_tx_type),
20155+ Some(3),
20156+ )?
20157+ .0;
20158+ // Immediately, so the NEXT chunk's unit
20159+ // reads this one's coefficient context.
20160+ neighbours.record_mi_chroma(
20161+ cu_mi, luma_span, luma_span, plane_idx, &cu_grid,
20162+ );
20163+ CHROMA_SPLIT_TX_HITS.with(|c| c.set(c.get() + 1));
20164+ let dst = if plane_idx == 1 {
20165+ &mut u_units
20166+ } else {
20167+ &mut v_units
20168+ };
20169+ for rr in 0..cu_tx {
20170+ let start =
20171+ (cr * cu_tx + rr) * chroma_side + cc * cu_tx;
20172+ dst[start..start + cu_tx]
20173+ .copy_from_slice(&cu_grid[rr * cu_tx..][..cu_tx]);
20174+ }
20175+ }
20176+ }
20177+ }
19757 }20178 }
19758 // `av1_get_tx_type`'s chroma lookup scales the chroma20179 // `av1_get_tx_type`'s chroma lookup scales the chroma
19759 // position back to luma, so an inter block's chroma20180 // position back to luma, so an inter block's chroma
@@ -19809,6 +20230,12 @@ fn decode_inter_block(
19809 // neither symbol nor context exists.20230 // neither symbol nor context exists.
19810 u_grid = vec![0i32; chroma_side * chroma_side];20231 u_grid = vec![0i32; chroma_side * chroma_side];
19811 v_grid = vec![0i32; chroma_side * chroma_side];20232 v_grid = vec![0i32; chroma_side * chroma_side];
20233+ } else if side > 64 {
20234+ // Already read inside the mu-chunk loop above -- at the 128
20235+ // root a rect (128x64/64x128) block's chroma is per mu
20236+ // chunk too, so this test comes BEFORE the `rect_tu` one.
20237+ u_grid = std::mem::take(&mut u_units);
20238+ v_grid = std::mem::take(&mut v_units);
19812 } else if rect_tu {20239 } else if rect_tu {
19813 // `av1_get_max_uv_txsize(bsize)`: the chroma transform of a20240 // `av1_get_max_uv_txsize(bsize)`: the chroma transform of a
19814 // 2:1 strip is the strip's own rect chroma size (16x8 /20241 // 2:1 strip is the strip's own rect chroma size (16x8 /
@@ -20150,9 +20577,16 @@ fn decode_inter_block(
20150 .1;20577 .1;
20151 let reach = Reach::of(side, px, py, y.width, y.height);20578 let reach = Reach::of(side, px, py, y.width, y.height);
20152 let split_luma = vartx_leaves.is_some();20579 let split_luma = vartx_leaves.is_some();
20580+ // lane-sb128c r3: a 128x128 INTRA block inside an inter frame codes
20581+ // its chroma per 64x64 mu chunk, exactly as the inter half above --
20582+ // `decode_token_recon_block` walks `mu_blocks_wide/high` and codes
20583+ // every plane of a chunk before the next chunk's luma. These collect
20584+ // the four TX_32X32 units per plane for the block-level write-back.
20585+ let mut u_units = vec![0i32; chroma_side * chroma_side];
20586+ let mut v_units = vec![0i32; chroma_side * chroma_side];
20153 if let Some(leaves) = vartx_leaves.clone() {20587 if let Some(leaves) = vartx_leaves.clone() {
20154 let reduced = REDUCED_TX_SET_INTER.with(std::cell::Cell::get);20588 let reduced = REDUCED_TX_SET_INTER.with(std::cell::Cell::get);
20155- for &(row, col, tx_px, _) in &leaves {20589+ for (idx, &(row, col, tx_px, _)) in leaves.iter().enumerate() {
20156 let tu_mi = (at_mi.0 + row, at_mi.1 + col);20590 let tu_mi = (at_mi.0 + row, at_mi.1 + col);
20157 let (tu_px, tu_py) = (px + col * MI, py + row * MI);20591 let (tu_px, tu_py) = (px + col * MI, py + row * MI);
20158 // A transform unit inside a block is not a block at that20592 // A transform unit inside a block is not a block at that
@@ -20183,7 +20617,11 @@ fn decode_inter_block(
20183 dec,20617 dec,
20184 cdfs,20618 cdfs,
20185 txbset_for(tx_px, reduced),20619 txbset_for(tx_px, reduced),
20186- &default_scan(tx_px),20620+ // lane-sb128c r5: a TX_64X64 unit codes only its
20621+ // top-left 32x32 of frequencies (spec 5.11.40), so
20622+ // the scan and `tx_side` are the CODED corner while
20623+ // `side` stays the transform's true 64.
20624+ &default_scan(tx_px.min(32)),
20187 0,20625 0,
20188 neighbours.around_mi(tu_mi, tx_px)[0],20626 neighbours.around_mi(tu_mi, tx_px)[0],
20189 mode,20627 mode,
@@ -20194,7 +20632,7 @@ fn decode_inter_block(
20194 tu_px,20632 tu_px,
20195 tu_py,20633 tu_py,
20196 tx_px,20634 tx_px,
20197- tx_px,20635+ tx_px.min(32),
20198 base_q_idx,20636 base_q_idx,
20199 None,20637 None,
20200 filter_intra,20638 filter_intra,
@@ -20203,9 +20641,96 @@ fn decode_inter_block(
20203 )?20641 )?
20204 };20642 };
20205 neighbours.record_mi_luma(tu_mi, tx_px, &tu_grid);20643 neighbours.record_mi_luma(tu_mi, tx_px, &tu_grid);
20644+ if side > 64 {
20645+ let chunk = (row / 16, col / 16);
20646+ let done = idx + 1 == leaves.len()
20647+ || (leaves[idx + 1].0 / 16, leaves[idx + 1].1 / 16) != chunk;
20648+ if !done {
20649+ continue;
20650+ }
20651+ let (cr, cc) = chunk;
20652+ // `av1_get_max_uv_txsize(BLOCK_128X128)` =
20653+ // `av1_get_adjusted_tx_size(TX_64X64)` = TX_32X32.
20654+ let cu_tx = 32usize;
20655+ let luma_span = cu_tx * 2;
20656+ let cu_mi = (at_mi.0 + cr * 16, at_mi.1 + cc * 16);
20657+ let cu_around = neighbours.around_mi(cu_mi, luma_span);
20658+ let (cu_x, cu_y) = (cpx + cc * cu_tx, cpy + cr * cu_tx);
20659+ let cu_reach = crate::decode::tu_reach(
20660+ side, side,
20661+ cc * luma_span, cr * luma_span, luma_span,
20662+ reach, px, py, y.width, y.height,
20663+ );
20664+ let cu_scan = default_scan(cu_tx);
20665+ for plane_idx in 1..3 {
20666+ let buf: &mut PlaneBuf = if plane_idx == 1 { &mut *u } else { &mut *v };
20667+ let cu_grid = if skip {
20668+ buf.reconstruct(
20669+ cu_x,
20670+ cu_y,
20671+ cu_tx,
20672+ uv_predict_mode,
20673+ angle_delta_uv,
20674+ cu_reach,
20675+ &vec![0i32; cu_tx * cu_tx],
20676+ None,
20677+ None,
20678+ smooth_neighbor_uv,
20679+ );
20680+ vec![0i32; cu_tx * cu_tx]
20681+ } else {
20682+ read_plane(
20683+ dec,
20684+ cdfs,
20685+ chroma_set,
20686+ &cu_scan,
20687+ plane_idx,
20688+ cu_around[plane_idx],
20689+ mode,
20690+ uv_predict_mode,
20691+ angle_delta_uv,
20692+ cu_reach,
20693+ buf,
20694+ cu_x,
20695+ cu_y,
20696+ cu_tx,
20697+ cu_tx,
20698+ base_q_idx,
20699+ // CfL is refused above 32x32
20700+ // (`is_cfl_allowed`), so never here.
20701+ None,
20702+ None,
20703+ // The uv plane block (64x64) is larger than
20704+ // the unit (32x32): `get_txb_ctx`'s offset-10
20705+ // rows, +3 on the `txb_skip_chroma_32` table
20706+ // (lane-sb128b r3).
20707+ Some(3),
20708+ smooth_neighbor_uv,
20709+ )?
20710+ };
20711+ // Immediately, so the NEXT chunk's unit reads this
20712+ // one's coefficient context.
20713+ neighbours.record_mi_chroma(
20714+ cu_mi, luma_span, luma_span, plane_idx, &cu_grid,
20715+ );
20716+ CHROMA_SPLIT_TX_HITS.with(|c| c.set(c.get() + 1));
20717+ let dst = if plane_idx == 1 { &mut u_units } else { &mut v_units };
20718+ for rr in 0..cu_tx {
20719+ let start = (cr * cu_tx + rr) * chroma_side + cc * cu_tx;
20720+ dst[start..start + cu_tx]
20721+ .copy_from_slice(&cu_grid[rr * cu_tx..][..cu_tx]);
20722+ }
20723+ }
20724+ }
20206 }20725 }
20207 }20726 }
20208- if skip {20727+ if side > 64 {
20728+ // Chroma is already coded and reconstructed per mu chunk above.
20729+ luma_grid = vec![0i32; side * side];
20730+ u_grid = std::mem::take(&mut u_units);
20731+ v_grid = std::mem::take(&mut v_units);
20732+ INTRA_128_IN_INTER_HITS.with(|c| c.set(c.get() + 1));
20733+ } else if skip {
20209 if !split_luma {20734 if !split_luma {
20210 y.reconstruct(20735 y.reconstruct(
20211 px,20736 px,
@@ -20428,12 +20953,24 @@ fn decode_inter_block(
20428 // units, not the block -- for LUMA only (lane-golomb r6): the chroma20953 // units, not the block -- for LUMA only (lane-golomb r6): the chroma
20429 // grids keep the block's own `av1_get_max_uv_txsize`, which is what20954 // grids keep the block's own `av1_get_max_uv_txsize`, which is what
20430 // libaom's `get_transform_size` reads for `plane != AOM_PLANE_Y`.20955 // libaom's `get_transform_size` reads for `plane != AOM_PLANE_Y`.
20431- if let Some(leaves) = &vartx_leaves {20956+ // lane-sb128c r4: libaom `set_one_param_for_line_luma` suppresses every
20957+ // edge that is a TU edge but not a PU edge when
20958+ // `curr_skipped = mbmi->skip_txfm && is_inter_block(mbmi)`, so a SKIP
20959+ // inter block's internal transform edges are never filtered even though
20960+ // `get_transform_size` still reports TX_64X64 for it. The only block that
20961+ // reaches here skipped is the 128 root (`read_block_tx_size` hands back
20962+ // four TX_64X64 leaves for `side > 64` regardless of `skip`); leaving its
20963+ // block-level 128 publication in place is exactly that suppression.
20964+ // lane-sb128c r6: narrowed to the 128 root. Below it `read_block_tx_size`
20965+ // hands a skipped inter block a single leaf equal to the block, so the
20966+ // per-leaf write is the block-level one and this branch is a no-op either
20967+ // way; only the 128 root gets four TX_64X64 leaves regardless of `skip`.
20968+ let skip_inter_128 = skip && is_inter && write_w.max(write_h) > 64;
20969+ if skip_inter_128 {
20970+ neighbours.suppress_internal_lf_edges((rmi, cmi), write_w / MI, write_h / MI);
20971+ }
20972+ if let Some(leaves) = (!skip_inter_128).then_some(()).and(vartx_leaves.as_ref()) {
20432 for &(row, col, tw, th) in leaves {20973 for &(row, col, tw, th) in leaves {
20433- // lane-r14's RECT leaf dims through lane-golomb r6's luma-only
20434- // writer: fill_lf_grid_rect would recompute CHROMA tx dims from
20435- // the leaf span, but libaom's `get_transform_size` splits only for
20436- // AOM_PLANE_Y (merge J, ledger constraint).
20437 neighbours.fill_lf_grid_leaf_luma(20974 neighbours.fill_lf_grid_leaf_luma(
20438 (at_mi.0 + row, at_mi.1 + col),20975 (at_mi.0 + row, at_mi.1 + col),
20439 tw / MI,20976 tw / MI,
@@ -23476,13 +24013,25 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
23476 // loop does; the 64-level body below is unchanged, `read_cdef`'s24013 // loop does; the 64-level body below is unchanged, `read_cdef`'s
23477 // per-64x64-quadrant reset (`CDEF_TRANSMITTED`) already matches libaom's24014 // per-64x64-quadrant reset (`CDEF_TRANSMITTED`) already matches libaom's
23478 // `cdef_idx[(mi_row & 16) >> 4 * 2 + (mi_col & 16) >> 4]` slot per quadrant.24015 // `cdef_idx[(mi_row & 16) >> 4 * 2 + (mi_col & 16) >> 4]` slot per quadrant.
24016+ // lane-sb128c r1: set when the 128 root resolved to `PARTITION_NONE` -- its
24017+ // one 128x128 inter block covers all four 64x64 quadrants, so the remaining
24018+ // three items of this superblock carry no syntax at all (same skip the
24019+ // key-frame tile loop runs).
24020+ let mut sb128_none = false;
23479 for (sb_r, sb_c, row_start, sb_start) in sb_visit_order(sb_r0, sb_r1, sb_c0, sb_c1, sb128) {24021 for (sb_r, sb_c, row_start, sb_start) in sb_visit_order(sb_r0, sb_r1, sb_c0, sb_c1, sb128) {
23480 if row_start {24022 if row_start {
23481 neighbours.start_row();24023 neighbours.start_row();
23482 }24024 }
24025+ if sb_start {
24026+ sb128_none = false;
24027+ }
24028+ if sb128_none {
24029+ continue;
24030+ }
23483 {24031 {
24032+ let mut sb128_rect = None;
23484 if sb128 && sb_start {24033 if sb128 && sb_start {
23485- if read_sb128_root(24034+ let part128 = read_sb128_root(
23486 &mut dec,24035 &mut dec,
23487 &mut cdfs,24036 &mut cdfs,
23488 &neighbours,24037 &neighbours,
@@ -23493,14 +24042,24 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
23493 sb_c,24042 sb_c,
23494 mi_cols,24043 mi_cols,
23495 mi_rows,24044 mi_rows,
23496- )? != PARTITION_SPLIT24045+ )?;
23497- {24046+ if matches!(part128, PARTITION_HORZ | PARTITION_VERT) {
23498- // lane-sb128b r1 decodes a `PARTITION_NONE` 128 root on24047+ // Two 128x64 (HORZ) or two 64x128 (VERT) inter blocks; the
23499- // KEY frames only; an inter 128x128 leaf needs whole-block24048+ // whole 128x128 root is consumed here, so the remaining
23500- // MC, OBMC and compound at a size this path has never run.24049+ // three 64-quadrant visits of this superblock carry no
23501- return Err(unsupported(24050+ // syntax (same skip the NONE arm runs).
23502- "a 128x128 superblock PARTITION_NONE root on an inter frame (only the key-frame path codes a whole 128x128 block)",24051+ sb128_none = true;
23503- ));24052+ sb128_rect = Some(part128);
24053+ CDEF_TRANSMITTED.with(|c| c.set(false));
24054+ }
24055+ if part128 == PARTITION_NONE {
24056+ // One 128x128 inter block. Its luma transform is
24057+ // `max_txsize_rect_lookup[BLOCK_128X128]` = TX_64X64 (four
24058+ // units, read as var-tx leaves), its uv plane block is
24059+ // 64x64 with TX_32X32 units (`av1_get_max_uv_txsize`), and
24060+ // `size_group_lookup[BLOCK_128X128]` is 3, same as 64x64.
24061+ sb128_none = true;
24062+ CDEF_TRANSMITTED.with(|c| c.set(false));
23504 }24063 }
23505 }24064 }
23506 if !sb128 {24065 if !sb128 {
@@ -23567,7 +24126,12 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
23567 skip_mode_frame,24126 skip_mode_frame,
23568 switchable_motion_mode,24127 switchable_motion_mode,
23569 allow_warped_motion,24128 allow_warped_motion,
23570- true,24129+ // lane-sb128c r3: `reject_residual` is about a
24130+ // RECTANGULAR strip decoded with square dimensions --
24131+ // the 128x128 NONE root is square, and a hardcoded
24132+ // `true` refused every one of them at its first
24133+ // non-skip block.
24134+ $ww != $side || $wh != $side,
23571 $ww,24135 $ww,
23572 $wh,24136 $wh,
23573 allow_screen_content_tools,24137 allow_screen_content_tools,
@@ -23652,6 +24216,96 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
23652 }24216 }
23653 }};24217 }};
23654 }24218 }
24219+ if let Some(part128) = sb128_rect {
24220+ // lane-sb128c r7: libaom `decode_partition` (decodeframe.c:1554)
24221+ // codes PARTITION_HORZ at the 128 root as `subsize =
24222+ // BLOCK_128X64` at (mi_row, mi_col) and a second one at
24223+ // (mi_row + hbs, mi_col) only `if (mi_row + hbs < mi_rows)`;
24224+ // PARTITION_VERT mirrors it on the column. `hbs` here is
24225+ // `mi_size_high[BLOCK_128X128] / 2` = 16 mi.
24226+ let horz = part128 == PARTITION_HORZ;
24227+ let at128 = ((sb_r & !1) as usize * 4, (sb_c & !1) as usize * 4);
24228+ let base_mi = sub16_to_mi(at128);
24229+ let (bw, bh) = if horz { (128usize, 64usize) } else { (64, 128) };
24230+ for i in 0..2 {
24231+ let at_mi = if horz {
24232+ (base_mi.0 + i * 16, base_mi.1)
24233+ } else {
24234+ (base_mi.0, base_mi.1 + i * 16)
24235+ };
24236+ if i > 0 && (at_mi.0 >= mi_rows as usize || at_mi.1 >= mi_cols as usize) {
24237+ break;
24238+ }
24239+ inter_piece!(
24240+ at_mi, SB * 2,
24241+ TxbSet::Luma64, TxbSet::Luma64, TxbSet::Chroma32, TX32, TX32,
24242+ &scan32, &scan32, 3, bw, bh
24243+ );
24244+ if horz {
24245+ INTER_SB128_HORZ_HITS.with(|c| c.set(c.get() + 1));
24246+ } else {
24247+ INTER_SB128_VERT_HITS.with(|c| c.set(c.get() + 1));
24248+ }
24249+ }
24250+ // One `cdef_idx` per BLOCK, copied to every 64x64 CDEF unit it
24251+ // covers -- both halves of the root read their own, and the
24252+ // first one's read lands in the top-left unit while the
24253+ // second's lands in the bottom-left (HORZ) / top-right (VERT).
24254+ let (q_r, q_c) = ((sb_r & !1) as usize, (sb_c & !1) as usize);
24255+ CDEF_IDX_GRID.with(|g| {
24256+ let mut g = g.borrow_mut();
24257+ let cols = CDEF_SB_COLS.with(|c| c.get());
24258+ if cols == 0 {
24259+ return;
24260+ }
24261+ for (src, dst) in if horz {
24262+ [((0, 0), (0, 1)), ((1, 0), (1, 1))]
24263+ } else {
24264+ [((0, 0), (1, 0)), ((0, 1), (1, 1))]
24265+ } {
24266+ let (si, di) = (
24267+ (q_r + src.0) * cols + q_c + src.1,
24268+ (q_r + dst.0) * cols + q_c + dst.1,
24269+ );
24270+ if q_c + src.1 < cols && q_c + dst.1 < cols && si < g.len() && di < g.len()
24271+ {
24272+ g[di] = g[si];
24273+ }
24274+ }
24275+ });
24276+ continue;
24277+ }
24278+ if sb128_none {
24279+ INTER_SB128_NONE_HITS.with(|c| c.set(c.get() + 1));
24280+ let at128 = ((sb_r & !1) as usize * 4, (sb_c & !1) as usize * 4);
24281+ // lane-sb128c r3: `at128` is in SUB16 units like `sb_at`;
24282+ // `decode_inter_block` takes MI. Unconverted it was (0,0) for
24283+ // the first 128 root and a quarter-position for every other
24284+ // one -- the whole-frame gate never got past superblock 1.
24285+ inter_piece!(
24286+ sub16_to_mi(at128), SB * 2,
24287+ TxbSet::Luma64, TxbSet::Luma64, TxbSet::Chroma32, TX32, TX32,
24288+ &scan32, &scan32, 3, SB * 2, SB * 2
24289+ );
24290+ // libaom writes one `cdef_strength` into the block's own
24291+ // `MB_MODE_INFO`, which all four 64x64 CDEF units point at
24292+ // (mirrors the key-frame 128 NONE block).
24293+ let (q_r, q_c) = ((sb_r & !1) as usize, (sb_c & !1) as usize);
24294+ CDEF_IDX_GRID.with(|g| {
24295+ let mut g = g.borrow_mut();
24296+ let cols = CDEF_SB_COLS.with(|c| c.get());
24297+ if cols > 0 && q_r * cols + q_c < g.len() {
24298+ let idx = g[q_r * cols + q_c];
24299+ for (dr, dc) in [(0, 1), (1, 0), (1, 1)] {
24300+ let i = (q_r + dr) * cols + q_c + dc;
24301+ if q_c + dc < cols && i < g.len() {
24302+ g[i] = idx;
24303+ }
24304+ }
24305+ }
24306+ });
24307+ continue;
24308+ }
23655 let sb_ctx = neighbours.partition_ctx(sb_at, SB);24309 let sb_ctx = neighbours.partition_ctx(sb_at, SB);
23656 let (has_cols, has_rows) = (24310 let (has_cols, has_rows) = (
23657 sb_c * SB_MI + SB_MI / 2 < mi_cols,24311 sb_c * SB_MI + SB_MI / 2 < mi_cols,
crates/ec-av1/src/mvstack.rsmodified+32 -2
@@ -631,6 +631,26 @@ fn scan_col(
631 found631 found
632 }632 }
633 633
634+/// The half of libaom's `has_top_right` (mvref_common.c:264) that
635+/// `setup_ref_mv_list` (mvref_common.c:497/546) gates the top-right mv probe on
636+/// and that this crate can state exactly: `if (bs > mi_size_wide[BLOCK_64X64])
637+/// return 0`. A 128x128 / 128x64 / 64x128 block has NO top-right candidate even
638+/// though the cell diagonally above-right of it sits in decoded memory -- an
639+/// ungated grid probe invented `(441,441) w=644` at `mi(32,0)` and desynced the
640+/// drl symbols of the 128 inter gate (lane-sb128c r5).
641+///
642+/// corner-cut: the position-mask half of `has_top_right` is deliberately NOT
643+/// applied here. It needs libaom's three shape refinements
644+/// (`is_last_vertical_rect`, `is_first_horizontal_rect`, the `PARTITION_VERT_A`
645+/// bottom-left square) which [`has_top_right`] does not port; applying the mask
646+/// without them cost the 64-level AB, free-partition and 1:4 gates frame 16
647+/// (measured lane-sb128c r6). Ceiling: a sub-128 block may still probe a
648+/// top-right libaom would not, exactly as main does today; upgrade path = port
649+/// the three refinements into [`has_top_right`] and gate on it whole.
650+fn top_right_scan_allowed(bw4: usize, bh4: usize) -> bool {
651+ bw4.max(bh4) <= 16
652+}
653+
634 /// libaom `has_top_right` (mvref_common.c:264): whether the unit diagonally654 /// libaom `has_top_right` (mvref_common.c:264): whether the unit diagonally
635 /// above-right of this block has been decoded *by the superblock's own655 /// above-right of this block has been decoded *by the superblock's own
636 /// recursion order*. The mask is `sb_size`-relative, so at a 128x128656 /// recursion order*. The mask is `sb_size`-relative, so at a 128x128
@@ -875,7 +895,12 @@ pub fn find_mv_stack_with_sign_bias(
875 &mut newmv_count,895 &mut newmv_count,
876 &mut processed_cols,896 &mut processed_cols,
877 );897 );
878- let found_top_right = scan_top_right(898+ // libaom `setup_ref_mv_list` gates this probe on `has_top_right`
899+ // (mvref_common.c:497/546): the diagonally-above-right unit of a 128x128
900+ // block sits in decoded memory but is NOT available (bs > 16), so an
901+ // ungated grid probe invents a candidate and desyncs the drl symbols.
902+ let found_top_right = top_right_scan_allowed(bw4, bh4)
903+ && scan_top_right(
879 grid,904 grid,
880 mi_row,905 mi_row,
881 mi_col,906 mi_col,
@@ -1668,7 +1693,12 @@ pub fn find_mv_stack_compound(
1668 &mut newmv_count,1693 &mut newmv_count,
1669 &mut processed_cols,1694 &mut processed_cols,
1670 );1695 );
1671- let found_top_right = scan_top_right_compound(1696+ // libaom `setup_ref_mv_list` gates this probe on `has_top_right`
1697+ // (mvref_common.c:497/546): the diagonally-above-right unit of a 128x128
1698+ // block sits in decoded memory but is NOT available (bs > 16), so an
1699+ // ungated grid probe invents a candidate and desyncs the drl symbols.
1700+ let found_top_right = top_right_scan_allowed(bw4, bh4)
1701+ && scan_top_right_compound(
1672 grid,1702 grid,
1673 mi_row,1703 mi_row,
1674 mi_col,1704 mi_col,
crates/ec-av1/src/refusal_inventory.rsmodified+3 -2
@@ -45,8 +45,9 @@ const REFUSALS: &[&str] = &[
45 "a tx_type symbol outside its CDF's own set: {t}",45 "a tx_type symbol outside its CDF's own set: {t}",
46 "an INTER 32x32 partition type this decoder does not code (value={part32})",46 "an INTER 32x32 partition type this decoder does not code (value={part32})",
47 "a superblock-level partition value outside PARTITION_NONE..PARTITION_VERT_4",47 "a superblock-level partition value outside PARTITION_NONE..PARTITION_VERT_4",
48- "a 128x128 superblock HORZ/VERT or AB partition (only SPLIT and NONE are decoded at the 128 root)",48+ "a 128x128 superblock AB partition (HORZ_A/HORZ_B/VERT_A/VERT_B at the 128 root)",
49- "a 128x128 superblock PARTITION_NONE root on an inter frame (only the key-frame path codes a whole 128x128 block)",49+ "an inter var-tx tree with a leaf transform larger than 64x64",
50+ "a 128x128 superblock HORZ/VERT partition on an intra frame (the inter path decodes it; the intra one is square-block only)",
50 "intrabc under a 128x128 superblock (libaom's av1_is_dv_valid derives the block-vector delay from sb_size, which this decoder hardcodes to 64)",51 "intrabc under a 128x128 superblock (libaom's av1_is_dv_valid derives the block-vector delay from sb_size, which this decoder hardcodes to 64)",
51 "a palette block with a real transform on a superblock-level HORZ/VERT strip (corner-cropped luma coefficients not ported for palette)",52 "a palette block with a real transform on a superblock-level HORZ/VERT strip (corner-cropped luma coefficients not ported for palette)",
52 "a block that actually uses a palette (UV) -- reconstruction is out of scope",53 "a block that actually uses a palette (UV) -- reconstruction is out of scope",
crates/ec-av1/src/stream.rsmodified+349 -0
@@ -105,6 +105,17 @@ pub fn rect_wii_hits() -> [usize; 6] {
105 crate::decode::rect_wii_hits()105 crate::decode::rect_wii_hits()
106 }106 }
107 107
108+/// lane-sb128c r7: the 128 root's rect arms -- (gathered edge HORZ, gathered
109+/// edge VERT, inter 128x64 blocks, inter 64x128 blocks).
110+pub fn sb128_rect_counters() -> (usize, usize, usize, usize) {
111+ (
112+ crate::decode::part128_edge_horz_hits(),
113+ crate::decode::part128_edge_vert_hits(),
114+ crate::decode::inter_sb128_horz_hits(),
115+ crate::decode::inter_sb128_vert_hits(),
116+ )
117+}
118+
108 pub fn rect4_32_counters() -> (usize, usize, usize) {119 pub fn rect4_32_counters() -> (usize, usize, usize) {
109 (120 (
110 crate::decode::rect4_32_horz_hits(),121 crate::decode::rect4_32_horz_hits(),
@@ -21521,6 +21532,173 @@ mod tests {
21521 );21532 );
21522 }21533 }
21523 21534
21535+ /// lane-sb128c r7 GATE: the 128 root's GATHERED bottom/right-edge arm --
21536+ /// the only 128-partition shape the user's 1080p AV1 film reaches
21537+ /// (`mi_rows = 270`, so every bottom 128 row has `has_rows128 == false`,
21538+ /// one gathered bit, and the film codes `PARTITION_HORZ`: a 128x64 block
21539+ /// whose bottom half is outside the frame and never decoded). Frame sizes
21540+ /// here are chosen so the LAST superblock row (or column, for the VERT
21541+ /// twin at 192x256) is partial, which is what forces the gathered symbol.
21542+ /// Both the key frame and the inter frames of each stream carry the arm;
21543+ /// `part128_edge_*_hits` and `inter_sb128_*_hits` HARD-assert it fired,
21544+ /// and `decode_all_frames_vs_oracle` compares EVERY decode-order frame
21545+ /// (hidden alt-refs included) against the instrumented aomdec.
21546+ #[test]
21547+ fn a_real_aomenc_sb128_gathered_edge_horz_partition_decodes_pixel_exact() {
21548+ const NAME: &str =
21549+ "a_real_aomenc_sb128_gathered_edge_horz_partition_decodes_pixel_exact";
21550+ let _gate_lock = lock_gate_counters();
21551+ if !have_ffmpeg() {
21552+ eprintln!("SKIP {NAME}: no ffmpeg");
21553+ return;
21554+ }
21555+ if !have_aomenc() {
21556+ eprintln!("SKIP {NAME}: no aomenc at {}", aomenc_path().display());
21557+ return;
21558+ }
21559+ // (seed, cq, width, height, 10-bit, vertical twin). Every size has a
21560+ // PARTIAL last superblock row (or column, for the VERT twin): 320 px
21561+ // = 80 mi rows, two full 128 rows and a 64-px remainder; 256 px = 64
21562+ // mi = two full rows and none, so the VERT arm uses 192 px = 48 mi on
21563+ // the column axis. A smooth `gradients` source makes the KEY frame
21564+ // take the arm too, which is still refused by name (square-block
21565+ // intra), so this gate's source is `mandelbrot`: its key frames split
21566+ // and its inter frames keep the 128x64/64x128 edge block.
21567+ let arms: Vec<(u32, &str, usize, usize, bool, bool)> = vec![
21568+ (42, "--cq-level=55", 384, 320, false, false),
21569+ (43, "--cq-level=55", 384, 320, true, false),
21570+ (44, "--cq-level=32", 192, 256, false, true),
21571+ (45, "--cq-level=45", 192, 256, true, true),
21572+ ];
21573+ let (mut matched, mut named_refusals) = (0u32, 0u32);
21574+ let (mut edge_arms, mut inter_arms) = (0u32, 0u32);
21575+ for (seed, cq, width, height, ten_bit, vert) in arms {
21576+ let pix = if ten_bit { "yuv420p10le" } else { "yuv420p" };
21577+ let y4m = Command::new("ffmpeg")
21578+ .args([
21579+ "-v", "error", "-f", "lavfi", "-i",
21580+ &format!(
21581+ "mandelbrot=size={width}x{height}:rate=25:start_x=-0.6:start_y=-0.4"
21582+ ),
21583+ "-pix_fmt", pix, "-strict", "-1", "-t", "0.2",
21584+ "-f", "yuv4mpegpipe", "-",
21585+ ])
21586+ .stdin(Stdio::null())
21587+ .stdout(Stdio::piped())
21588+ .stderr(Stdio::piped())
21589+ .output()
21590+ .expect("ffmpeg failed to run");
21591+ assert!(
21592+ y4m.status.success(),
21593+ "{NAME}: ffmpeg fixture: {}",
21594+ String::from_utf8_lossy(&y4m.stderr)
21595+ );
21596+ let mut args: Vec<&str> = vec![
21597+ "--codec=av1", "--passes=1", "--end-usage=q", cq,
21598+ "--cpu-used=0", "--threads=1", "--row-mt=0",
21599+ "--sb-size=128", "--min-partition-size=64",
21600+ "--enable-rect-partitions=1", "--enable-ab-partitions=0",
21601+ "--enable-1to4-partitions=0", "--enable-palette=0",
21602+ "--enable-intrabc=0", "--enable-tx-size-search=0",
21603+ "--deltaq-mode=0", "--limit=5",
21604+ ];
21605+ if ten_bit {
21606+ args.extend_from_slice(&["--input-bit-depth=10", "--bit-depth=10"]);
21607+ }
21608+ args.extend_from_slice(&["--obu", "-o", "-", "-"]);
21609+ let mut child = Command::new(aomenc_path())
21610+ .args(&args)
21611+ .stdin(Stdio::piped())
21612+ .stdout(Stdio::piped())
21613+ .stderr(Stdio::piped())
21614+ .spawn()
21615+ .expect("aomenc failed to start");
21616+ child
21617+ .stdin
21618+ .take()
21619+ .expect("aomenc stdin")
21620+ .write_all(&y4m.stdout)
21621+ .expect("writing y4m to aomenc");
21622+ let out = child.wait_with_output().expect("aomenc failed to run");
21623+ assert!(
21624+ out.status.success(),
21625+ "{NAME}: aomenc refused the fixture: {}",
21626+ String::from_utf8_lossy(&out.stderr)
21627+ );
21628+ let stream = out.stdout;
21629+ let (before_edge, before_inter) = if vert {
21630+ (
21631+ crate::decode::part128_edge_vert_hits(),
21632+ crate::decode::inter_sb128_vert_hits(),
21633+ )
21634+ } else {
21635+ (
21636+ crate::decode::part128_edge_horz_hits(),
21637+ crate::decode::inter_sb128_horz_hits(),
21638+ )
21639+ };
21640+ // A refusal is still a legal outcome for an arm whose stream hits
21641+ // some OTHER lane's gap, but never for all of them (asserted
21642+ // below), and never as a silent skip.
21643+ if let Err(e) = decode_stream(&stream) {
21644+ let msg = e.to_string();
21645+ assert!(
21646+ msg.contains("unsupported"),
21647+ "{NAME} failed outright, not a named refusal \
21648+ (seed {seed} {width}x{height}): {msg}"
21649+ );
21650+ named_refusals += 1;
21651+ eprintln!("{NAME}: seed {seed} {width}x{height} refusal: {msg}");
21652+ continue;
21653+ }
21654+ let (frames, hidden) = decode_all_frames_vs_oracle(
21655+ &stream,
21656+ &format!("sb128c-edge-{seed}-{width}x{height}"),
21657+ );
21658+ assert!(frames > 0, "{NAME}: no frames decoded at {width}x{height}");
21659+ let (edge, inter) = if vert {
21660+ (
21661+ crate::decode::part128_edge_vert_hits() - before_edge,
21662+ crate::decode::inter_sb128_vert_hits() - before_inter,
21663+ )
21664+ } else {
21665+ (
21666+ crate::decode::part128_edge_horz_hits() - before_edge,
21667+ crate::decode::inter_sb128_horz_hits() - before_inter,
21668+ )
21669+ };
21670+ eprintln!(
21671+ "{NAME}: seed {seed} cq {cq} {width}x{height} {}bit {}: \
21672+ {frames} frames pixel-exact ({hidden} hidden), \
21673+ edge_hits +{edge} inter_128rect_blocks +{inter}",
21674+ if ten_bit { 10 } else { 8 },
21675+ if vert { "VERT" } else { "HORZ" },
21676+ );
21677+ if edge > 0 {
21678+ edge_arms += 1;
21679+ }
21680+ if inter > 0 {
21681+ inter_arms += 1;
21682+ }
21683+ matched += 1;
21684+ }
21685+ assert!(
21686+ matched > 0,
21687+ "{NAME}: every attempt refused ({named_refusals}); the gate never \
21688+ decoded a stream"
21689+ );
21690+ assert!(
21691+ edge_arms > 0,
21692+ "{NAME}: {matched} stream(s) decoded pixel-exact but NOT ONE 128 root \
21693+ took the gathered frame-edge HORZ/VERT arm this gate exists for"
21694+ );
21695+ assert!(
21696+ inter_arms > 0,
21697+ "{NAME}: the gathered arm fired only on key frames -- no INTER \
21698+ 128x64/64x128 block was decoded, which is the film's own shape"
21699+ );
21700+ }
21701+
21524 #[test]21702 #[test]
21525 #[ignore = "lane-sb128 r2 diagnostic: is the frame-6 mismatch sb128-specific?"]21703 #[ignore = "lane-sb128 r2 diagnostic: is the frame-6 mismatch sb128-specific?"]
21526 fn sb128_r2_control_sb64() {21704 fn sb128_r2_control_sb64() {
@@ -21730,6 +21908,177 @@ mod tests {
21730 }21908 }
21731 }21909 }
21732 21910
21911+ /// lane-sb128c r1: an INTER frame whose 128x128 superblock root really
21912+ /// resolves `PARTITION_NONE` -- one whole 128x128 inter block, the shape
21913+ /// ReelC's first inter frame stops this decoder on. r1 wired it: four
21914+ /// TX_64X64 luma units (`max_txsize_rect_lookup[BLOCK_128X128]`), four
21915+ /// TX_32X32 chroma units (`av1_get_max_uv_txsize`), interleaved Y,U,V per
21916+ /// 64x64 "mu" chunk (libaom `decode_token_recon_block`) with the chroma
21917+ /// `txb_skip_ctx` offset-10 rows, and OBMC's overlap capped at a 64x64
21918+ /// block's half (`reconinter.c` 860/899).
21919+ ///
21920+ /// `--max-partition-size=128` is what lets the root be NONE at all (the
21921+ /// sibling gate above pins 64, so its roots always SPLIT). Every arm hard
21922+ /// asserts its own `inter_sb128_none_hits` delta, so a recipe that stops
21923+ /// choosing the shape fails instead of passing vacuously; every decode
21924+ /// order frame is compared by [`decode_all_frames_vs_oracle`], which
21925+ /// panics on a refusal or any differing byte. Arms: 8-bit and 10-bit (his
21926+ /// films are 10-bit) with `tx-size-search=0` (TX_MODE_LARGEST, the block's
21927+ /// four TX_64X64 units come straight from `max_txsize_rect_lookup`) and an
21928+ /// 8-bit `tx-size-search=1` arm (the var-tx tree at 128).
21929+ // lane-sb128c r3: green. `--min-partition-size=32` let the RD search reach
21930+ // 16x16-level AB / SB-level AB shapes that other lanes still refuse (two of
21931+ // the three arms stopped there, measured); at 64 every arm decodes and the
21932+ // 128 root still resolves NONE.
21933+ #[test]
21934+ fn a_real_aomenc_inter_128x128_none_root_decodes_pixel_exact() {
21935+ const NAME: &str = "a_real_aomenc_inter_128x128_none_root_decodes_pixel_exact";
21936+ let _gate_lock = lock_gate_counters();
21937+ if !have_ffmpeg() || !have_aomenc() {
21938+ eprintln!("SKIP {NAME}: no ffmpeg/aomenc/aomdec");
21939+ return;
21940+ }
21941+ let (width, height) = (256usize, 256usize);
21942+ let mut intra128_total = 0usize;
21943+ for (ten_bit, tx_search, seed) in [(false, false, 61u32), (true, false, 61), (false, true, 62)] {
21944+ let pix = if ten_bit { "yuv420p10le" } else { "yuv420p" };
21945+ let y4m = Command::new("ffmpeg")
21946+ .args([
21947+ "-v",
21948+ "error",
21949+ "-f",
21950+ "lavfi",
21951+ "-i",
21952+ &format!(
21953+ "{},noise=all_seed={seed}:alls=6:allf=t",
21954+ gradients_source(seed, width, height, "duration=0.32:rate=25")
21955+ ),
21956+ "-pix_fmt",
21957+ pix,
21958+ "-strict",
21959+ "-1",
21960+ "-t",
21961+ "0.32",
21962+ "-f",
21963+ "yuv4mpegpipe",
21964+ "-",
21965+ ])
21966+ .stdin(Stdio::null())
21967+ .stdout(Stdio::piped())
21968+ .stderr(Stdio::piped())
21969+ .output()
21970+ .expect("ffmpeg failed to run");
21971+ assert!(
21972+ y4m.status.success(),
21973+ "{NAME}: ffmpeg fixture: {}",
21974+ String::from_utf8_lossy(&y4m.stderr)
21975+ );
21976+ let mut args: Vec<&str> = vec![
21977+ "--codec=av1",
21978+ "--passes=1",
21979+ "--end-usage=q",
21980+ "--cq-level=62",
21981+ "--cpu-used=0",
21982+ "--threads=1",
21983+ "--row-mt=0",
21984+ "--sb-size=128",
21985+ "--max-partition-size=128",
21986+ "--min-partition-size=64",
21987+ "--enable-rect-partitions=0",
21988+ "--enable-ab-partitions=0",
21989+ "--enable-1to4-partitions=0",
21990+ "--enable-palette=0",
21991+ "--enable-intrabc=0",
21992+ "--deltaq-mode=0",
21993+ "--limit=8",
21994+ ];
21995+ // Spelled ONCE per invocation (a repeated `--enable-*` keeps its
21996+ // LAST occurrence, measured 2026-09-02).
21997+ args.push(if tx_search {
21998+ "--enable-tx-size-search=1"
21999+ } else {
22000+ "--enable-tx-size-search=0"
22001+ });
22002+ if ten_bit {
22003+ args.extend_from_slice(&["--input-bit-depth=10", "--bit-depth=10"]);
22004+ }
22005+ args.extend_from_slice(&["--obu", "-o", "-", "-"]);
22006+ let mut child = Command::new(aomenc_path())
22007+ .args(&args)
22008+ .stdin(Stdio::piped())
22009+ .stdout(Stdio::piped())
22010+ .stderr(Stdio::piped())
22011+ .spawn()
22012+ .expect("aomenc failed to start");
22013+ child
22014+ .stdin
22015+ .take()
22016+ .expect("aomenc stdin")
22017+ .write_all(&y4m.stdout)
22018+ .expect("writing y4m to aomenc");
22019+ let out = child.wait_with_output().expect("aomenc failed to run");
22020+ assert!(
22021+ out.status.success(),
22022+ "{NAME}: aomenc refused the fixture: {}",
22023+ String::from_utf8_lossy(&out.stderr)
22024+ );
22025+ let stream = out.stdout;
22026+ let header = {
22027+ let mut parser = ec_av1_syntax::Av1Parser::new();
22028+ let mut pos = 0usize;
22029+ while let Ok(obu) = parser.parse_obu(&stream[pos..]) {
22030+ pos += obu.total_size;
22031+ if pos >= stream.len() {
22032+ break;
22033+ }
22034+ }
22035+ parser
22036+ .sequence_header()
22037+ .map(|q| (q.use_128x128_superblock, q.color_config.bit_depth))
22038+ };
22039+ assert_eq!(
22040+ header,
22041+ Some((true, if ten_bit { 10 } else { 8 })),
22042+ "{NAME}: the encoder did not write a 128x128-superblock sequence header at \
22043+ the requested bit depth -- the flag never arrived"
22044+ );
22045+ let before = (
22046+ crate::decode::inter_sb128_none_hits(),
22047+ crate::decode::chroma_split_tx_hits(),
22048+ crate::decode::intra_128_in_inter_hits(),
22049+ );
22050+ let (frames, hidden) = decode_all_frames_vs_oracle(
22051+ &stream,
22052+ &format!("sb128c-inter-none-{}-{}", if ten_bit { 10 } else { 8 }, tx_search),
22053+ );
22054+ let (none128, chroma_units, intra128) = (
22055+ crate::decode::inter_sb128_none_hits() - before.0,
22056+ crate::decode::chroma_split_tx_hits() - before.1,
22057+ crate::decode::intra_128_in_inter_hits() - before.2,
22058+ );
22059+ intra128_total += intra128;
22060+ assert!(
22061+ frames >= 6,
22062+ "{NAME} ({pix} tx_search={tx_search}): only {frames} decode-order frames"
22063+ );
22064+ assert!(
22065+ none128 >= 1,
22066+ "{NAME} ({pix} tx_search={tx_search}): no 128x128 PARTITION_NONE root on an \
22067+ inter frame -- the recipe stopped exercising the shape this gate names"
22068+ );
22069+ eprintln!(
22070+ "{NAME} ({pix} tx_search={tx_search}): {frames} decode-order frames pixel-exact \
22071+ ({hidden} hidden), inter_sb128_none_hits={none128} chroma_units={chroma_units} \
22072+ intra_128_in_inter={intra128}"
22073+ );
22074+ }
22075+ assert!(
22076+ intra128_total >= 1,
22077+ "{NAME}: no INTRA-coded 128x128 block inside an inter frame across the three arms -- \
22078+ the refusal this round lifted is no longer exercised"
22079+ );
22080+ }
22081+
21733 /// lane-sbpart r2: a real `aomenc` stream whose superblock-level22082 /// lane-sbpart r2: a real `aomenc` stream whose superblock-level
21734 /// partition decision is genuinely HORZ/VERT (not NONE/SPLIT) must22083 /// partition decision is genuinely HORZ/VERT (not NONE/SPLIT) must
21735 /// decode pixel-exact through [`crate::decode::decode_block_rect64`] --22084 /// decode pixel-exact through [`crate::decode::decode_block_rect64`] --
lanes/sb128c-r1.handoff.mdadded+33 -0
@@ -0,0 +1,33 @@
1+# lane-sb128c r1 -> r2 handoff
2+
3+Tip `31d4d68` on `lane-sb128c` (worktree `/home/user/Documents/Code/Rust/edith_codecs-sb128c`,
4+`CARGO_TARGET_DIR=$HOME/.cache/cargo-target-sb128c`). Full detail: `lanes/sb128c-r1.report.md`.
5+
6+ONE open defect: the 128x128 inter PARTITION_NONE block desyncs.
7+
8+Repro (both files already exist, regenerate with the recipe in the report):
9+- stream `$HOME/.cache/sb128c-work/g8.obu` (256x256, 8 frames, `--sb-size=128 --cpu-used=0
10+ --max-partition-size=128 --min-partition-size=32 --cq-level=62 --enable-rect-partitions=0
11+ --enable-ab-partitions=0 --enable-1to4-partitions=0 --enable-palette=0 --enable-intrabc=0
12+ --enable-tx-size-search=0 --deltaq-mode=0 --limit=8`, gradients seed 61 + noise alls=6)
13+- `decode_probe g8.obu` -> refuses `a split intra strip whose transform unit is 32x64`, which the
14+ encoder cannot have coded (rect partitions off) => our desync.
15+- `EC_AV1_TRACE=1 decode_probe g8.obu | grep partition_w128` -> 4 x `value=0` (NONE), 10 x `value=3`.
16+- `k1.obu` (same recipe, `--limit=1`) decodes OK, so the key frame's 128 path is fine; the defect is on
17+ an inter frame.
18+
19+Method: instrumented aomdec `EC_TRACE_COEFF` vs our `EC_TRACE_COEFF`, compare msac RANGE element by
20+element (never `tell()`), starting at the FIRST inter-frame 128 NONE block.
21+
22+Suspect order (all untested):
23+1. `read_cdef` for a NONE 128 block on the INTER path (`CDEF_TRANSMITTED` reset + quadrant index).
24+ The key path resets it and replicates `CDEF_IDX_GRID`; the inter path now does the same, unverified.
25+2. `maybe_read_delta_q` / delta_lf granularity at a 128 root on an inter frame.
26+3. mvstack with bw4 = bh4 = 32 (`has_top_right` at 128, tpl sample positions, `check_sb_border`
27+ hardcodes 64 which the ledger says is correct at both sb sizes).
28+4. This round's own mu-chunk chroma interleave inside `decode_inter_block`: the `Some(3)` chroma
29+ `txb_skip` offset row, the per-unit `record_mi_chroma`, and the chunk-completion test
30+ (`(leaves[idx+1].0/16, leaves[idx+1].1/16) != chunk`).
31+
32+Un-`#[ignore]` `a_real_aomenc_inter_128x128_none_root_decodes_pixel_exact` (stream.rs) when green, and
33+re-run the siblings `128x128` + `refusal_inventory` + `gate_coverage` before claiming root cause.
lanes/sb128c-r1.report.mdadded+116 -0
@@ -0,0 +1,116 @@
1+# lane-sb128c r1 — the 128x128 INTER block is wired (ReelC advances one refusal), its gate is RED
2+
3+Branch `lane-sb128c` (worktree `edith_codecs-sb128c`), base `e8e64a6` (= lane-sb128b r3, contains main `18bf7dc`).
4+VERDICT: **RED** — the code lands and ReelC moves past its old stop, but no pixel-exact gate proves it yet.
5+
6+## MEASURED first (never assumed)
7+
8+`ffmpeg -t 2 -i ReelC... -c:v copy -an -f obu` -> `$HOME/.cache/sb128c-work/reelc2s.obu` (1428 bytes; the
9+film's first 2 s are near-black, that size is real), `decode_probe`:
10+
11+- BEFORE (base e8e64a6): `REFUSED: unsupported: AV1 tile (a 128x128 superblock PARTITION_NONE root on an
12+ inter frame (only the key-frame path codes a whole 128x128 block))`, after the key frame decoded.
13+ `SEQ: use_128x128_superblock=true bit_depth=10 max_frame=1920x792`, 72 frame headers, 1 tile.
14+- AFTER this round: `REFUSED: ... (a 128x128 superblock HORZ/VERT or AB partition (only SPLIT and NONE are
15+ decoded at the 128 root))` — the next 128-level refusal in line.
16+- Mid-film (`-ss 600 -t 2`, `reelc60.obu`, 1.58 MB): stops on another lane's gap,
17+ `an intra-coded 1:4 (or other non-2:1) rect strip on the inter block path`.
18+
19+EVIDENCE: `$HOME/.cache/sb128c-work/{reelc2s.obu,reelc60.obu}` | `decode_probe` under `systemd-run --scope -p MemoryMax=6G`, before and after the change | **stop string moved from "PARTITION_NONE root on an inter frame" to "HORZ/VERT or AB partition"**
20+
21+## Every remaining 128 refusal (grep of decode.rs + refusal_inventory.rs), after this round
22+
23+1. `a 128x128 superblock HORZ/VERT or AB partition (only SPLIT and NONE are decoded at the 128 root)` — `decode.rs` `read_sb128_root`. **ReelC's new stop.**
24+2. `intrabc under a 128x128 superblock (...)` — key-frame path, `allow_intrabc` only.
25+3. `an INTRA-coded 128x128 block inside an inter frame (...)` — NEW this round, deliberately narrow.
26+(The old `a 128x128 superblock PARTITION_NONE root on an inter frame` is gone from both files.)
27+
28+## What changed
29+
30+- `decode.rs` `read_sb128_root` call site in the inter tile loop (~20826): `PARTITION_NONE` now sets
31+ `sb128_none` and decodes one 128x128 block through the existing `inter_piece!` macro
32+ (`TxbSet::Luma64/Luma64/Chroma32`, `TX32`, `scan32`, size group 3 — `size_group_lookup[BLOCK_128X128] == 3`),
33+ then replicates the block's `cdef_idx` across its four 64x64 units and skips the superblock's other three
34+ quadrant items (same skip the key-frame loop runs).
35+- `decode.rs` `inter_txbset_for`: `64 => TxbSet::Luma64` — `av1_get_ext_tx_set_type` is `DCT_ONLY` at
36+ `tx_size_sqr_up == TX_64X64`, so no `tx_type` symbol is coded and the intra/inter sets coincide.
37+- `decode.rs` `read_block_tx_size`: with `tx_mode == TX_MODE_LARGEST` a 128x128 inter block is still FOUR
38+ TX_64X64 units (`max_txsize_rect_lookup[BLOCK_128X128]`), returned as leaves; the var-tx leaf refusal
39+ moves from `> 32` to `> 64`.
40+- `decode.rs` `decode_inter_block` (both identical coefficient regions, compound and single-ref): the leaf
41+ loop's scan is `default_scan(tx_px.min(32))` (a 64-point transform codes only its 32x32 corner), and at
42+ `side > 64` each 64x64 mu chunk's U and V units are read INSIDE the leaf loop right after that chunk's
43+ luma leaves (libaom `decode_token_recon_block` codes every plane of a chunk before the next chunk —
44+ sb128b r3 measured this against aomdec), recorded per unit, and collected for the block-level write-back.
45+- `decode.rs` `read_inter_plane`: on a chroma plane the `luma_skip_ctx` parameter now carries
46+ `get_txb_ctx`'s offset (+3 selects `txb_skip_chroma_32`'s offset-10 rows, the uv-plane-block-larger-than-
47+ the-transform case). All existing chroma callers pass `None` — inert.
48+- `decode.rs` OBMC: `overlap_above/left` capped at `min(write_h|write_w, 64) / 2`, libaom
49+ `reconinter.c:860` / `:899` (`AOMMIN(block_size_high[bsize], block_size_high[BLOCK_64X64]) >> 1`).
50+ Without it a 128 block asked `obmc_mask(64)`, which panicked `unreachable!` — the first thing ReelC hit.
51+- `stream.rs`: new gate `a_real_aomenc_inter_128x128_none_root_decodes_pixel_exact` (currently `#[ignore]`d,
52+ see below). `refusal_inventory.rs`: one line replaced.
53+
54+## CHARTER PREMISE CORRECTED (cited)
55+
56+The charter states `max_neighbor_obmc[...] = {0,1,2,3,4,8}` so "128 blocks get 8 neighbours". The oracle
57+source says otherwise: `$HOME/.cache/aom-oracle/src/av1/common/blockd.h:1466`
58+`static const int max_neighbor_obmc[6] = { 0, 1, 2, 3, 4, 4 };`. Our existing `max_nb` (`_ => 4`) is already
59+right at 128; **no change was made**. What DID need changing is the overlap cap above.
60+
61+## The gate, and why it is RED
62+
63+`a_real_aomenc_inter_128x128_none_root_decodes_pixel_exact` — real aomenc `--sb-size=128 --cpu-used=0
64+--max-partition-size=128 --min-partition-size=32 --cq-level=62 --limit=8`, 256x256 (both dims > 128, so
65+NONE/HORZ/VERT at 128 are real choices), 3 arms (8-bit tx-size-search=0, 10-bit tx-size-search=0, 8-bit
66+tx-size-search=1), sequence-header assert on `use_128x128_superblock` + bit depth, hard
67+`inter_sb128_none_hits >= 1` per arm, every decode-order frame through `decode_all_frames_vs_oracle`
68+(panics on refusal or any differing byte, so out-of-scope mismatches are structurally 0), flags spelled once.
69+
70+It FAILS on arm 1: `sb128c-inter-none-8-false: this decoder refused the stream: unsupported: AV1 tile
71+(a split intra strip whose transform unit is 32x64 ...)`.
72+
73+Triage done this round:
74+- The recipe genuinely fires the shape: `EC_AV1_TRACE=1 decode_probe g8.obu` shows
75+ `partition_w128 value=0` (PARTITION_NONE) **4 times** and `value=3` (SPLIT) 10 times.
76+- The KEY frame alone (`--limit=1`, `k1.obu`) decodes: `OK: 1 frames decoded, 256x256`.
77+- The stream is encoded with `--enable-rect-partitions=0`, so a 64x128/32x64 intra strip cannot be in it:
78+ the 32x64 refusal is OUR desync talking (class `refusal-from-own-desync`) somewhere at or after the first
79+ inter 128 NONE block.
80+- An INTRA block at 128 inside an inter frame was ruled out as the cause by adding a named refusal for it
81+ (it is not what the stream stops on).
82+
83+EVIDENCE: `$HOME/.cache/sb128c-work/{g8.obu,k1.obu}` | aomenc recipe above at `--limit=8` and `--limit=1`, `EC_AV1_TRACE=1 decode_probe` | **4 `partition_w128 value=0` roots; key-frame-only stream OK; 8-frame stream refuses at a 32x64 strip the encoder never coded**
84+
85+## Suite
86+
87+`$HOME/.cache/sb128c-suite-r1.log` (unit `sb128c-suite-r1-1788325119.service`, tip `31d4d68`):
88+**test result: FAILED. 370 passed; 1 failed; 33 ignored; 1034.05s**. The one red was
89+`a_real_aomenc_stream_with_film_grain_decodes_pixel_exact`, and it is NOT a decode defect: it panicked on
90+`Os { code: 2, NotFound }` reading `fixtures/golden6-mismatch.obu` -- **this worktree was created without the
91+`fixtures` symlink every sibling has** (`fixtures -> /home/user/Documents/Code/Rust/edith_codecs/fixtures`,
92+gitignored). Symlink created, test re-run: `test result: ok. 1 passed; 0 failed`. So the suite is 371/0 in
93+substance; the new 128 inter gate stays `#[ignore]`d.
94+
95+EVIDENCE: `$HOME/.cache/sb128c-suite-r1.log` | full lib suite as a systemd unit, then
96+`cargo test -p ec-av1 --lib -- a_real_aomenc_stream_with_film_grain_decodes_pixel_exact` after creating the
97+symlink | **370+1 passed, 0 failed; the red was a missing fixtures symlink in this worktree**
98+
99+FOREIGN EDIT: `crates/ec-av1/src/decode.rs` gained an `EC_AV1_TRACE`-only `rng=` field on the
100+`partition_w64` trace at 08:15:19, after this lane's last commit (08:11:18) and by no edit of mine -- another
101+agent wrote into this worktree. Kept (inert unless `EC_AV1_TRACE` is set, and useful for r2's ladder) and
102+committed separately as `chore(av1)`.
103+of the commit message / see the log; the new gate is `#[ignore]`d so the suite measures the untouched paths.
104+
105+## Residue
106+
107+- fix-now(r2): the 128 inter NONE desync. Next step is the range ladder (instrumented aomdec
108+ `EC_TRACE_COEFF` vs ours) on `g8.obu`'s FIRST inter frame, first 128 NONE block — compare msac RANGE
109+ element by element, never `tell()`. Prime suspects in order: (1) `read_cdef`'s per-quadrant index/
110+ `CDEF_TRANSMITTED` for a NONE 128 block on the inter path; (2) `maybe_read_delta_q`/delta_lf granularity
111+ at a 128 root; (3) the mvstack at bw4=bh4=32 (`has_top_right` at 128, tpl sample positions);
112+ (4) my mu-chunk chroma interleave (offset `Some(3)` row choice / per-unit `record_mi_chroma`).
113+- deferred: 128-level HORZ/VERT/AB on both the key and inter paths (ReelC's new stop) — unblocked by the
114+ NONE block being exact first.
115+- deferred: `--enable-tx-size-search=1` arm at 128 and a `--tile-columns=1` arm — same blocker.
116+- accepted: `an INTRA-coded 128x128 block inside an inter frame` stays refused by name.
lanes/sb128c-r2.handoff.mdadded+39 -0
@@ -0,0 +1,39 @@
1+# lane-sb128c r2 -> r3 handoff
2+
3+Tip `lane-sb128c` (worktree `edith_codecs-sb128c`, `CARGO_TARGET_DIR=$HOME/.cache/cargo-target-sb128c`).
4+Full detail: `lanes/sb128c-r2.report.md`.
5+
6+CLOSED in r2: the 128 inter NONE desync = `decode_inter_block`'s intra tail read the 14-symbol
7+`uv_mode_cfl` CDF for a 64x64 intra block in an inter frame; libaom uses `is_cfl_allowed(xd)`
8+(`<=32x32`, blockd.h). Fixed at `decode.rs:18713`.
9+
10+ONE open defect, fully characterised, blocking the r1 gate:
11+`an INTRA-coded 128x128 block inside an inter frame` (`decode.rs:16396`).
12+- Repro: `decode_probe $HOME/.cache/sb128c-work/g8.obu` (recipe in `lanes/sb128c-r1.report.md`).
13+- It is REAL, not our desync: aomdec `EC_TRACE=1 EC_TRACE_COEFF=1` shows
14+ `EC_PART_VAL mi_row=32 mi_col=32 bsize=15 value=0` with no `EC_MODE`, then per 64x64 mu chunk
15+ `EC_COEFF plane=0 tx_size=4` (TX_64X64), `plane=1 tx_size=3 ctx=10`, `plane=2 tx_size=3 ctx=10`
16+ (`$HOME/.cache/sb128c-work/aomdec.all:18304`).
17+- Work: the intra tail (`decode.rs:18684+`) already reads 4 TX_64X64 luma leaves via
18+ `read_block_tx_size`, but codes ONE whole-block chroma unit afterwards. Move chroma INTO the leaf
19+ loop per 64x64 mu chunk, exactly as the inter branch does at `decode.rs:17304-17520`
20+ (chunk = `(row/16, col/16)`, chroma unit TX_32X32, `txb_skip` offset-10 rows, per-unit
21+ `record_mi_chroma`). Then drop the `side > 64 && !is_inter` refusal and un-`#[ignore]`
22+ `a_real_aomenc_inter_128x128_none_root_decodes_pixel_exact` (stream.rs).
23+- Sibling gates to re-run before claiming root cause: `128x128`, `refusal_inventory`,
24+ `gate_coverage`, plus the sb128b key-frame 128 gates.
25+
26+Recipe search (seeds 62..67, same recipe) found no stream with the inter 128 NONE but without the
27+intra 128; all six stop on other lanes' gaps. Do not re-run it.
28+
29+## r2 close-out state
30+- Tip commits: `edbdd7b` (fix) + the two docs commits. Working tree clean.
31+- Gate `a_real_aomenc_inter_128x128_none_root_decodes_pixel_exact`: STILL `#[ignore]`d (reason text
32+ updated to the real blocker). No arm was made green this round.
33+- Suite: unit `sb128c-suite-r2-1788326632.service`, log `$HOME/.cache/sb128c-suite-r2.log` —
34+ STILL RUNNING at r2 close (91 `ok`, 0 FAILED so far, no `test result:` line yet). r3 must read the
35+ final line before any green claim.
36+- TASK B: film_grain 8-bit red was NOT lane-caused (passes alone on base `e8e64a6` and on the tip).
37+- TASK C (128-level HORZ/VERT + AB): NOT STARTED.
38+- Exact next step: mu-chunk chroma in the intra tail (`decode.rs:18684+`, copy of `17304-17520`),
39+ then drop the `side > 64 && !is_inter` refusal at `decode.rs:16396` and un-ignore the gate.
lanes/sb128c-r2.report.mdadded+76 -0
@@ -0,0 +1,76 @@
1+# lane-sb128c r2 — the 128 inter NONE desync is a `uv_mode` ALPHABET bug (root cause, cited); gate still RED on a NEW, real blocker
2+
3+Branch `lane-sb128c`, tip `edbdd7b` (base r1 `72a93d8`). VERDICT: **RED on the gate, GREEN on the defect**:
4+the desync r1 chartered is found and fixed at root cause, and the gate now stops on a genuinely
5+different, unimplemented shape (proved against aomdec, not a self-desync).
6+
7+## TASK A — root cause
8+
9+`crates/ec-av1/src/decode.rs:18713` (`decode_inter_block`'s intra tail) read
10+`cdfs.uv_mode_cfl[mode]` **unconditionally**. libaom `read_intra_block_mode_info` calls
11+`read_intra_mode_uv(ec_ctx, r, is_cfl_allowed(xd), bsize)` and `is_cfl_allowed`
12+(`~/.cache/aom-oracle/src/av1/common/blockd.h`) is
13+`block_size_wide[bsize] <= 32 && block_size_high[bsize] <= 32`. So any intra block 64 px or wider
14+inside an INTER frame must read the 13-symbol `uv_mode_no_cfl` alphabet. Reading the 14-symbol CFL
15+one yields the same VALUE from a different interval — class `wrong-alphabet-same-value`. Fix:
16+`let cfl_allowed = write_w.max(write_h) <= 32;` then the two-branch read (the split every other
17+`uv_mode` reader in the file already makes: `decode.rs:5521`, `6203`, `8500`).
18+
19+Method (charter's ladder, RANGE never `tell()`):
20+1. `EC_TRACE_MODE=1 EC_TRACE=1 aomdec g8.obu` vs ours; `EC_MODE` ranges agree block for block until
21+ the 64x64 block at mi (0,32) of an inter frame.
22+2. Added the pre-read range to our `partition_w64` trace: entry rng **61470 == aomdec 61470**; the
23+ NEXT partition (mi (0,48)) is **ours 35887 vs aomdec 54271** → the divergence is inside that block.
24+3. `EC_AV1_TELL` bit ladder: the block spans tell 170→192 in ours, 154→173 in aomdec (same 16-bit
25+ constant offset at entry) → **we over-read ~4 bits**; `is_inter=0 skip=0 side=64` on both sides,
26+ so it is the intra tail, and the only symbol whose alphabet depends on the 64-px size is `uv_mode`.
27+4. After the fix the ladder tracks through this block and every later one, up to a real new stop.
28+
29+EVIDENCE: `$HOME/.cache/sb128c-work/{aomdec.all,ours.trace}` | `EC_TRACE/EC_TRACE_MODE/EC_TRACE_COEFF` aomdec vs `EC_AV1_TRACE/EC_TRACE_MODE/EC_AV1_TELL` decode_probe on `g8.obu`, both under `systemd-run --scope -p MemoryMax=6G` | **partition rng at mi (0,48): 35887 → 54271 (== aomdec) after the fix; refusal moves from "a split intra strip whose transform unit is 32x64" to a shape aomdec confirms exists**
30+
31+## TASK A — the gate is still `#[ignore]`d, and why (this is NOT a self-desync)
32+
33+`g8.obu` now decodes past every inter 128x128 PARTITION_NONE block (aomdec confirms four of them,
34+e.g. `EC_PART_VAL mi_row=0 mi_col=32 bsize=15 value=0` + `EC_MODE ... rng=63756`, which our trace
35+matches exactly: `EC_MODE mi_row=0 mi_col=8 rng=63756 is_inter=1 skip=1 side=128`). It then stops on
36+`an INTRA-coded 128x128 block inside an inter frame` — and aomdec's own trace shows that block is
37+real: `EC_PART_VAL mi_row=32 mi_col=32 bsize=15 value=0` with **no** `EC_MODE` line (aomdec only
38+instruments the inter mode reader), followed by `EC_COEFF plane=0 tx_size=4` / `plane=1 tx_size=3
39+ctx=10` per 64x64 mu chunk. Exactly ONE such block exists in the whole 8-frame stream, in the same
40+frame as the inter 128 NONE blocks, so no `--limit` truncation dodges it.
41+
42+Recipe search for a stream carrying the inter 128 NONE without the intra one: seeds 62..67 on the
43+same recipe all refuse on OTHER lanes' gaps (sub-8 inter leaf ×3, 16-level inter AB/1:4, non-skip
44+rect strip) or on the same intra-128 (seed 63). Report line, not a claim of impossibility.
45+
46+EVIDENCE: `$HOME/.cache/sb128c-work/{s62..s67}.obu` + `seeds.sh` | 6 aomenc encodes (flags spelled once) + `decode_probe` each | **0/6 decode whole; refusal strings listed above**
47+
48+## TASK B — film_grain 8-bit gate: pre-existing flake, not lane-caused
49+
50+- base `e8e64a6` in a detached worktree, own `CARGO_TARGET_DIR=$HOME/.cache/cargo-target-sb128c-base`:
51+ `a_real_aomenc_stream_with_film_grain_decodes_pixel_exact` → `1 passed; 0 failed`
52+ (`$HOME/.cache/sb128c-base-fg.log`).
53+- this tree, same test alone → `1 passed; 0 failed`.
54+So r1's suite red was environmental (10 lanes sharing the box), not a lane regression. It is re-run
55+in the r2 full suite below.
56+
57+## TASK C — not started (turn budget)
58+
59+## ReelC re-probe
60+
61+`reelc2s.obu` (2 s, 10-bit, `use_128x128_superblock=true`): stop string moved
62+`a 128x128 superblock HORZ/VERT or AB partition` (r1) → **`a split transform on a 1:4 inter strip
63+with a 64-px axis`** (another lane's gap). `EC_AV1_FINAL_DUMP` frame count: 1.
64+
65+## Suite
66+
67+`$HOME/.cache/sb128c-suite-r2.log` — see the tail of this file / the handoff for the final N/0.
68+
69+## Residue
70+
71+- fix-now(r3): decode an INTRA-coded 128x128 block inside an inter frame — the intra tail of
72+ `decode_inter_block` needs the same 64x64 mu-chunk interleave the inter branch already has
73+ (`decode.rs:17304-17520`): per chunk one TX_64X64 luma unit then that chunk's TX_32X32 U and V
74+ units (aomdec shows chroma `txb_skip` ctx 10). Unblocks the r1 gate.
75+- deferred: 128-level HORZ/VERT and AB partitions (ReelC's r1 stop) — unblocked by the above.
76+- accepted: the 8-bit `--enable-tx-size-search=1` arm and a `--tile-columns=1` arm ride the same gate.
lanes/sb128c-r3.handoff.mdadded+95 -0
@@ -0,0 +1,95 @@
1+# lane-sb128c r3 -> r4 handoff
2+
3+Tip `lane-sb128c` (worktree `edith_codecs-sb128c`,
4+`CARGO_TARGET_DIR=$HOME/.cache/cargo-target-sb128c`). Full detail:
5+`lanes/sb128c-r3.report.md`.
6+
7+## (0) r2 suite result line
8+
9+NONE EXISTS. `sb128c-suite-r2-1788326632.service` ran 50 min, logged 232 `ok` and
10+0 `FAILED`, never printed a `test result:` line, and was still `active` when r3
11+stopped it to free the target dir. It also ran without the top-level `fixtures`
12+symlink (missing in this worktree until r3 created it) -- that is r2's `film_grain`
13+8-bit red, not a decode defect.
14+
15+## (1) uv_mode / is_cfl_allowed class sweep -- DONE
16+
17+`is_cfl_allowed` = `block_size_wide[bsize] <= 32 && block_size_high[bsize] <= 32`
18+on the LUMA bsize (libaom `blockd.h`, called from `read_intra_mode_uv` at every
19+`read_intra_block_mode_info` / `read_intra_frame_mode_info` site, `decodemv.c`).
20+
21+| site (pre-r3 line) | reader | before | after |
22+|---|---|---|---|
23+| 5521 `read_intra_mode_rect` | key-frame + rect strips | caller's `cfl` param; 4 of 5 call sites pass a hardcoded `true` | `cfl && bw <= 32 && bh <= 32`, decided IN THE READER |
24+| 8500 `read_intra_mode` | `decode_block` square path | caller's `cfl` param | `cfl && side <= 32`, decided IN THE READER |
25+| 6203 `decode_block_rect64` | SB-level 64x32/32x64 | `bw.max(bh) <= 32` (already right) | unchanged |
26+| 10360 `decode_leaf8` | 4x4 sub-8 leaf | always CFL (right) | unchanged |
27+| 20387 `decode_inter_block` 8x8 leaf | 8x8 inter-frame leaf | always CFL (right) | unchanged |
28+| 18722 `decode_inter_block` intra tail | intra-in-inter | `write_w.max(write_h) <= 32` (r2's fix) | unchanged |
29+
30+Only the two READERS decide now, so a future 64/128 caller cannot get it wrong.
31+
32+## (2) intra 128x128 inside an inter frame
33+
34+- IMPLEMENTED. Mu-chunk chroma in the intra tail (TX_32X32 per 64x64 chunk,
35+ offset-10 `txb_skip` rows via `Some(3)`, per-unit `record_mi_chroma`, `tu_reach`).
36+- Refusal string DELETED from `decode.rs` + `refusal_inventory.rs`.
37+- New counter `decode::intra_128_in_inter_hits()`.
38+- Three more defects fixed on the way (all previously unreachable):
39+ 1. `read_block_tx_size` TX_MODE_LARGEST early return was `is_inter && side > 64`;
40+ an intra 128 block also resolves to four TX_64X64 units. Now `side > 64`.
41+ 2. `tx_size_context_txfm(n, at_mi, side)` -> `side.min(64)`
42+ (`get_tx_size_context` compares against `tx_size_wide[max_txsize_rect_lookup]`).
43+ 3. inter tile 128 `PARTITION_NONE` root: `at128` passed in SUB16 units to a
44+ MI-taking callee (every root but the first entered at 1/4 position), and
45+ `inter_piece!` hardcoded `reject_residual = true` so the SQUARE 128 root
46+ refused with the rect-strip string. Now `sub16_to_mi(at128)` and
47+ `$ww != $side || $wh != $side`.
48+- GATE `a_real_aomenc_inter_128x128_none_root_decodes_pixel_exact`:
49+ `#[ignore]` REMOVED, recipe `--min-partition-size=32` -> `64`, hard assert
50+ `intra128_total >= 1`. **NOT GREEN -- it is RED and committed RED.**
51+ `sb128c-inter-none-8-false: decode-order frame 4 of 9 differs at byte 2367
52+ (ours 125 vs 126), 372 bytes differ`.
53+
54+### The residue (exact, this is r4's whole job)
55+
56+Ours vs `aomdec --rawvideo`, seed 61 8-bit, `$HOME/.cache/sb128c-work/g-61-8-0.obu`:
57+```
58+display frame 2 Y: 98 px rows 9..250 cols 58..66 <-- earliest
59+display frame 2 U: 151 px rows 0..126 cols 1..61
60+display frame 2 V: 123 px rows 0..126 cols 0..35
61+display frame 4 Y: 16932 px (whole frame -- propagation, not a new defect)
62+```
63+A 9-px band centred on **x = 64** spanning nearly the full frame height = the
64+14-tap deblock footprint of the 128 root's INTERNAL TX_64X64 edge. Entropy stays
65+in sync for all 9 frames (no refusal, no desync) => loop filter / lf-grid, not a
66+symbol defect.
67+
68+EXACT NEXT STEP: `EC_AV1_PREFILT_DUMP` on display frame 2 of that stream. If
69+pre-filter is exact, the defect is `fill_lf_grid_rect` for the 128 root in
70+`decode_inter_block` (the block-level call publishes `write_w = 128` as the tx
71+dimension before the per-leaf loop overwrites 64, and the chroma side reads
72+`tx/2` while a 128 block's chroma is really four TX_32X32 -- see the
73+"Chroma still reads tx_h_grid / 2" corner-cut comment right above that loop).
74+Memory class: `tx-grid-published-block-side`.
75+
76+## (3) 128-level HORZ/VERT + AB -- NOT STARTED
77+
78+deferred: 128-level HORZ/VERT (128x64 / 64x128) + AB on key and inter paths --
79+r3's budget went to (1)/(2) and the four defects (2) uncovered -- unblocked by
80+nothing, it is r4/r5 work. This is now the FRONTIER for his 10-bit AV1 film.
81+
82+## (4) Merge / ReelC / suite
83+
84+- `git merge --no-commit main` (85887c7) -- clean auto-merge, no conflicts,
85+ `cdf.rs` untouched by both sides, `cargo check -p ec-av1` clean on the merged
86+ tree. Committed as `merge: main (85887c7) into lane-sb128c`.
87+- ReelC re-probe (`reelc2s.obu` and `$HOME/.cache/reelc-head.obu`, both
88+ `use_128x128_superblock=true bit_depth=10 max_frame=1920x792`):
89+ STOP STRING `a 128x128 superblock HORZ/VERT or AB partition (only SPLIT and NONE
90+ are decoded at the 128 root)`; `EC_AV1_FINAL_DUMP` count **1** frame each.
91+ Unchanged by this round -- exactly task (3).
92+- Full suite: unit `sb128c-suite-r3-1788327685.service`, log
93+ `$HOME/.cache/sb128c-suite-r3.log` -- STILL RUNNING at r3 close (181 `ok`,
94+ 0 `FAILED` so far, no `test result:` line). r4 must read the final line.
95+ One KNOWN RED is expected: the gate above.
lanes/sb128c-r3.report.mdadded+125 -0
@@ -0,0 +1,125 @@
1+# lane-sb128c r3 report
2+
3+Tip `lane-sb128c` @ `9c36e62` (worktree `edith_codecs-sb128c`,
4+`CARGO_TARGET_DIR=$HOME/.cache/cargo-target-sb128c`).
5+
6+## VERDICT: RED
7+
8+The refusal this round targeted is gone and all three gate arms now decode every
9+frame with no refusal, but the gate is RED on a **reconstruction/loop-filter**
10+residue (98 luma px on one frame), not on an entropy desync.
11+
12+## (0) r2 suite unit
13+
14+`sb128c-suite-r2-1788326632.service` never produced a `test result:` line. It ran
15+50 min (232 `ok`, 0 `FAILED` in the log) and was still `active`; r3 stopped it to
16+free the target dir for its own suite. **No r2 suite total exists.**
17+It also ran WITHOUT the top-level `fixtures` symlink, which this worktree was
18+missing (created this round) -- that is the r2 `film_grain` 8-bit red, per the
19+COMMON note added mid-batch.
20+
21+## (1) CLASS SWEEP -- every uv_mode symbol site
22+
23+`is_cfl_allowed(xd)` = `block_size_wide[bsize] <= 32 && block_size_high[bsize] <= 32`
24+on the **luma** bsize (libaom `blockd.h`, called from `read_intra_mode_uv` at every
25+`read_intra_block_mode_info` / `read_intra_frame_mode_info` site in `decodemv.c`).
26+Six sites read a `uv_mode` symbol in `decode.rs`:
27+
28+| site (before) | reader | alphabet chosen before | after |
29+|---|---|---|---|
30+| `read_intra_mode_rect` (was 5521) | key/rect strips | caller's `cfl` param (4 call sites pass `true` unconditionally) | `cfl && bw <= 32 && bh <= 32`, decided **in the reader** |
31+| `read_intra_mode` (was 8500) | `decode_block` square path | caller's `cfl` param | `cfl && side <= 32`, decided **in the reader** |
32+| `decode_block_rect64` (was 6203) | SB-level 64x32/32x64 strips | `bw.max(bh) <= 32` (already correct) | unchanged |
33+| `decode_leaf8` sub-8 (was 10360) | 4x4 leaves | always CFL (correct, 4x4 <= 32) | unchanged |
34+| `decode_inter_block` 8x8 leaf (was 20387) | 8x8 inter-frame leaf | always CFL (correct) | unchanged |
35+| `decode_inter_block` intra tail (18722) | intra-in-inter | `write_w.max(write_h) <= 32` (r2's fix) | unchanged |
36+
37+Root-cause shape: the decision moved from six call sites to the two readers every
38+caller routes through, so a future 64/128-sized caller cannot get it wrong.
39+(Class `wrong-alphabet-same-value`: a 14- vs 13-symbol CDF gives the same VALUE and
40+a different range.)
41+
42+## (2) The INTRA-coded 128x128 block inside an inter frame
43+
44+Four distinct defects, all in `crates/ec-av1/src/decode.rs`:
45+
46+1. **Intra tail codes one whole-block chroma unit.** Now codes chroma per 64x64 mu
47+ chunk inside the luma leaf loop -- `cu_tx = 32` (`av1_get_max_uv_txsize(BLOCK_128X128)`
48+ = `av1_get_adjusted_tx_size(TX_64X64)` = TX_32X32), `txb_skip` offset-10 rows
49+ (`Some(3)` on `txb_skip_chroma_32`), per-unit `record_mi_chroma` immediately so the
50+ next chunk reads this one's context, `tu_reach` per unit. Mirrors the inter half
51+ (`decode_inter_block`'s var-tx branch) exactly. Refusal string deleted from
52+ `refusal_inventory.rs`.
53+2. **`read_block_tx_size` TX_MODE_LARGEST early return was `is_inter && side > 64`.**
54+ An INTRA 128x128 block also resolves to `max_txsize_rect_lookup[BLOCK_128X128]`
55+ = TX_64X64 = four units; it got one 128-wide unit that coded nothing. Now `side > 64`.
56+3. **`tx_size_context_txfm(n, at_mi, side)`.** `get_tx_size_context` compares the
57+ neighbour txfm contexts against `tx_size_wide[max_txsize_rect_lookup[bsize]]`,
58+ which is 64 for BLOCK_128X128 -- now `side.min(64)`.
59+4. **Two defects in the inter tile's 128 PARTITION_NONE root** (r1 code, never
60+ exercised past superblock 0):
61+ - `at128` is in SUB16 units like `sb_at`; `decode_inter_block` takes MI. Every 128
62+ root except the first entered at a quarter of its true position
63+ (`TELL ... mi_col=8` where the trace said `partition_w128` at mi col 32).
64+ Now `sub16_to_mi(at128)`.
65+ - the `inter_piece!` macro hardcoded `reject_residual = true`, so the SQUARE 128
66+ root refused at its first non-skip block with the rect-strip refusal string
67+ (class `refusal-from-own-desync` inverted: a refusal naming a shape the encoder
68+ never wrote, produced by our own wiring). Now `$ww != $side || $wh != $side`.
69+
70+### Gate
71+
72+`a_real_aomenc_inter_128x128_none_root_decodes_pixel_exact` -- `#[ignore]` REMOVED,
73+recipe `--min-partition-size=32` -> `64` (measured: at 32, the 10-bit arm stops on
74+"an inter SB-level AB partition" and the tx-search arm on "an inter 16x16-level AB or
75+1:4 partition", both other lanes' gaps; 10 seeds x 2 arms, 0/20 clean. At 64, 3/3
76+arms clean). New hard assert `intra128_total >= 1` on the new
77+`decode::intra_128_in_inter_hits()` counter.
78+
79+RESULT: **FAILED** --
80+`sb128c-inter-none-8-false: decode-order frame 4 of 9 (8 shown, 1 hidden) differs
81+from the oracle at byte 2367 (ours 125 vs 126), 372 bytes differ`.
82+
83+Plane/bbox map of the residue (display order, ours vs `aomdec --rawvideo`, same
84+recipe, seed 61 8-bit):
85+
86+```
87+frame 2 Y: 98 px rows 9..250 cols 58..66 <-- earliest, and the tell
88+frame 2 U: 151 px rows 0..126 cols 1..61
89+frame 2 V: 123 px rows 0..126 cols 0..35
90+frame 4 Y: 16932 px (whole frame; error propagates through prediction)
91+```
92+
93+Frame 2 luma is a 9-px-wide band centred on **x = 64**, spanning nearly the whole
94+frame height -- the 14-tap deblock footprint of the 128 root's INTERNAL TX_64X64
95+edge. The entropy stream stays in sync for all 9 frames (no refusal, no desync),
96+so this is the loop filter / lf grid for the 128 block, not a symbol defect.
97+Next step for r4: `EC_AV1_PREFILT_DUMP` on frame 2 -- if pre-filter is exact, it is
98+`fill_lf_grid_rect`'s tx/skip publication for the 128 root (the block-level call
99+writes `write_w = 128` as the tx dimension before the per-leaf loop overwrites 64,
100+and the chroma side reads `tx/2`, but a 128 block's chroma really is four TX_32X32).
101+
102+## (3) 128-level HORZ/VERT + AB -- NOT STARTED
103+
104+deferred: 128-level HORZ/VERT/AB on key and inter paths -- r3's budget went to (1)
105+and (2) and the four defects (2) uncovered -- unblocked by nothing; it is the next
106+lane round. This is now the FRONTIER for his 10-bit AV1 film: both `reelc2s.obu` and
107+`$HOME/.cache/reelc-head.obu` stop at
108+`a 128x128 superblock HORZ/VERT or AB partition (only SPLIT and NONE are decoded at
109+the 128 root)` (was the same string before this round; 1 `EC_AV1_FINAL_DUMP` frame
110+each).
111+
112+## EVIDENCE
113+
114+```
115+EVIDENCE: $HOME/.cache/sb128c-work/{arm-8-0,arm-10-0,arm-8-1}.obu | decode_probe on the r2 tip recipe (--min-partition-size=32) | 3/3 REFUSED before, then 1/3 (the two others on other lanes' AB refusals)
116+EVIDENCE: $HOME/.cache/sb128c-work/g-61-{8,10}-0.obu, g-62-8-1.obu | decode_probe, --min-partition-size=64 | 3/3 decode all 9 frames, 0 REFUSED
117+EVIDENCE: $HOME/.cache/sb128c-work/{o,m}.yuv | aomdec --rawvideo vs EC_PROBE_OUT on g-61-8-0.obu, per-plane bbox diff | earliest defect display frame 2, luma 98 px in cols 58..66 (x=64 edge), rows 9..250
118+EVIDENCE: cargo test -p ec-av1 --lib -- a_real_aomenc_inter_128x128_none_root_decodes_pixel_exact | single gate run | FAILED, decode-order frame 4 of 9, 372 bytes differ
119+EVIDENCE: $HOME/.cache/reelc-head.obu, $HOME/.cache/sb128c-work/reelc2s.obu | decode_probe with EC_AV1_FINAL_DUMP | both stop at "a 128x128 superblock HORZ/VERT or AB partition", 1 dumped frame each
120+```
121+
122+## Suite
123+
124+`$HOME/.cache/sb128c-suite-r3.log` (unit `sb128c-suite-r3-1788327685.service`) --
125+totals appended below by whoever reads it; the gate above is a KNOWN RED.
lanes/sb128c-r4.handoff.mdadded+129 -0
@@ -0,0 +1,129 @@
1+# lane-sb128c r4 -> r5 handoff
2+
3+Tip `lane-sb128c` (worktree `edith_codecs-sb128c`,
4+`CARGO_TARGET_DIR=$HOME/.cache/cargo-target-sb128c`). Detail: `lanes/sb128c-r4.report.md`
5+(written before the uv-cap correction below -- this file supersedes its fix description).
6+
7+## (0) r3 suite result line
8+
9+`sb128c-suite-r3-1788327685.service`, `$HOME/.cache/sb128c-suite-r3.log`:
10+`test result: FAILED. 371 passed; 1 failed; 32 ignored; 0 measured; 0 filtered out; finished in 797.36s`
11+The single failure was r3's own known-RED gate.
12+
13+## (1) The x=64 deblock band -- ROOT CAUSE, FIXED
14+
15+Stage bisection (aomdec rungs, decode order) on `$HOME/.cache/sb128c-work/g-61-8-0.obu`:
16+decode-order frames 0..4 pre-filter EXACT, frame 4 post-deblock WRONG (98 luma px
17+in a 9-px band at x=64, 274 chroma) => loop filter, not a symbol. Decisive:
18+aomdec's own post-deblock dump changes ZERO pixels in luma cols 50..78 of that
19+frame; ours changed 98 (peak 26 at col 63). libaom filters that edge not at all.
20+
21+libaom `av1/common/av1_loopfilter.c`, `set_one_param_for_line_luma` (~line 690)
22+and `set_one_param_for_line_chroma`:
23+```c
24+const int32_t pu_edge = mi_prev != mbmi;
25+if (!pu_edge) curr_skipped = mbmi->skip_txfm && is_inter_block(mbmi);
26+if ((pu_edge || !curr_skipped) && level) { params->filter_length = ...; }
27+```
28+`get_transform_size` still reports TX_64X64 (luma) / TX_32X32 (chroma) for a
29+SKIP 128x128 INTER block, so the TU edge at x=64 / y=64 exists -- it is
30+suppressed because it is not a PU edge and the block is skipped. Every 128
31+block in the gate stream is `is_inter=1 skip=1`.
32+
33+GRID WRITE (`crates/ec-av1/src/decode.rs`), final shape:
34+- the per-leaf `fill_lf_grid_rect` loop in `decode_inter_block` is gated on
35+ `!(skip && is_inter)`, so the block-level publication (`write_w = 128`) stays
36+ and no internal LUMA edge exists. The 128 root is the only block reaching
37+ that loop skipped (`read_block_tx_size` returns four TX_64X64 leaves for
38+ `side > 64` regardless of `skip`; every `side <= 64` skip inter block gets `None`).
39+- new `Neighbours::suppress_internal_lf_edges(at_mi, w_mi, h_mi)` writes the
40+ UNCAPPED chroma extent (64 for a 128 block) into `uv_tx_grid`/`uv_tx_h_grid`,
41+ called ONLY from the `skip && is_inter` branch of `decode_inter_block`.
42+- `dump_stage` now indexes its file per decode-order picture
43+ (`EC_AV1_POSTDEBLOCK_DUMP` overwrote `.f0` every frame, so only the last
44+ picture was comparable against aomdec's indexed rung). This is the instrument
45+ that found the defect.
46+
47+## (1b) THE UV-CAP TRAP (cost one suite run; do not repeat)
48+
49+My first fix instead removed the `.min(32)` TX_32X32 cap inside
50+`fill_lf_grid_rect` outright, reasoning it was inert for every block up to 64
51+wide. It is inert only for the INTER path. libaom's `curr_skipped` term
52+contains `is_inter_block(mbmi)`, so an INTRA 128x128 block's internal chroma TU
53+edges (every 32 chroma px, `av1_get_max_uv_txsize(BLOCK_128X128) == TX_32X32`)
54+ARE filtered. Removing the cap broke the sibling gate
55+`a_real_aomenc_key_frame_with_a_128x128_none_partition_decodes_pixel_exact`
56+(caught mid-suite at 293/404). The cap is restored; suppression is now explicit
57+and inter-only. Both gates re-run together after the correction:
58+`key_frame_with_a_128x128_none_partition ... ok`, inter gate now fails one
59+frame LATER (see below). Class: `fix-trades-sibling-gate`.
60+
61+## (1c) cdef_idx per 64x64 quadrant -- the r4 charter's suspicion is WRONG
62+
63+`read_cdef` (`av1/decoder/decodemv.c`) reads at most ONE literal per CALL and is
64+called once per BLOCK. A `PARTITION_NONE` 128 root is one block, so exactly ONE
65+`cdef_idx` symbol is read (`index = cdef_unit_col_in_sb + 2*cdef_unit_row_in_sb`
66+= 0 at the SB origin) and stored in the block's own `MB_MODE_INFO`, which all
67+four 64x64 CDEF units point at. r1's "replicated over 4 quadrants" is CORRECT;
68+no change was made. Four symbols are read only when the root SPLITs into four
69+non-skip 64s -- and for a 128-level HORZ/VERT root there are TWO blocks, hence
70+up to TWO literals: re-derive the index from that function, do not assume.
71+
72+## GATE STATES
73+
74+- `a_real_aomenc_key_frame_with_a_128x128_none_partition_decodes_pixel_exact` -- **GREEN**
75+- `a_real_aomenc_inter_128x128_none_root_decodes_pixel_exact` -- **RED**, advanced
76+ from `decode-order frame 4 of 9` (deblock) to `decode-order frame 5 of 9`
77+ (reconstruction): `differs at byte 32264 (ours 140 vs 141), 24858 bytes differ`.
78+- Full suite r4: NOT COMPLETED -- I stopped `sb128c-suite-r4-1788328542.service`
79+ at 293/404 to apply the uv-cap correction. It had exactly two failures, both
80+ named above; the key-frame one is now fixed. r5 must run a fresh full suite.
81+
82+## EXACT NEXT STEP (r5's first job)
83+
84+Decode-order frame 5 of `$HOME/.cache/sb128c-work/g-61-8-0.obu` is wrong ALREADY
85+AT PRE-FILTER, and every reference it uses is now exact at every stage
86+(pre-filter, post-deblock and `EC_AV1_FINAL_DUMP` incl. the hidden frame, frames
87+0..4 all zero-diff). So this is a genuine reconstruction defect, not propagation.
88+
89+```
90+frame 5 pre-filter Y: 19609 px, rows 128..255, cols 0..255, maxd 33, first bad (128,0)
91+frame 5 pre-filter C: 5207 px
92+per-64x64 quadrant Y: [0,0,0,0] [0,0,0,0] [3707,844,3137,3889] [183,177,3844,3828]
93+```
94+The whole BOTTOM superblock row (both 128x128 SBs); rows 0..127 exact. Our mode
95+trace lists that row as two `side=128 is_inter=1 skip=1` blocks -- pure motion
96+compensation. Entropy stays in sync for all 9 frames (no refusal, no desync).
97+The quadrant diff is content-dependent (flat quadrants mostly match, detailed
98+ones do not) = a slightly wrong PREDICTOR, not a wrong write geometry. Frame 4's
99+own `(32,0)` 128 skip block is exact, so 128-wide MC itself works.
100+Suspects in order: the block's mv (mv-stack / GLOBALMV resolution), `ref_frame`,
101+`switchable_interp`, `motion_mode`/OBMC at 128x128.
102+
103+Reproduce:
104+```
105+cd $HOME/.cache/sb128c-work && rm -f pf-o.f* pf-m.f*
106+systemd-run --user --scope -q -p MemoryMax=6G env EC_AV1_PREFILT_DUMP=$PWD/pf-o \
107+ ~/.cache/aom-oracle/build/aomdec --rawvideo -o /dev/null g-61-8-0.obu
108+systemd-run --user --scope -q -p MemoryMax=6G env EC_NOMEMGUARD=1 EC_AV1_PREFILT_DUMP=$PWD/pf-m \
109+ $HOME/.cache/cargo-target-sb128c/debug/examples/decode_probe g-61-8-0.obu
110+# 256x256 yuv420p8, pf-o.fN vs pf-m.fN
111+```
112+Oracle rungs: `EC_AV1_PREFILT_DUMP`, `EC_AV1_POSTDEBLOCK_DUMP`,
113+`EC_AV1_FINAL_DUMP` (all indexed, decode order, hidden frames included),
114+`EC_TRACE_MODE` (`EC_MODE_MV`/`EC_MODE_VAL` carry mode/ref0/ref1/mv0/stack/rng --
115+only 62 lines on this stream and NONE in the failing bottom SB row, so a skip
116+block's mv needs `EC_PRED`/`EC_PREDOUT` or a new rung).
117+NOTE (ledger constraint): our `EC_AV1_POSTDEBLOCK_DUMP` site runs AFTER
118+`apply_cdef` on the inter path -- pair it with `EC_AV1_DEBUG_SKIP_CDEF=1` or a
119+CDEF defect reads as a deblock defect.
120+
121+## (3) 128-level HORZ/VERT + AB -- NOT STARTED
122+
123+deferred: 128x64 / 64x128 and AB at the 128 root, key and inter paths -- r4's
124+budget went to the stage bisection and the uv-cap correction; unblocked by
125+nothing. Both ReelC extracts (`$HOME/.cache/sb128c-work/reelc2s.obu` and
126+`$HOME/.cache/reelc-head.obu`, 1428 B, `use_128x128_superblock=true bit_depth=10`)
127+still stop at `a 128x128 superblock HORZ/VERT or AB partition (only SPLIT and
128+NONE are decoded at the 128 root)`, `EC_AV1_FINAL_DUMP` count 1 -- and that one
129+frame is BYTE-IDENTICAL to ffmpeg's `yuv420p10le` decode (4561920 B, `cmp` clean).
lanes/sb128c-r4.report.mdadded+132 -0
@@ -0,0 +1,132 @@
1+# lane-sb128c r4 report
2+
3+Tip `lane-sb128c` @ `6226c27` (worktree `edith_codecs-sb128c`,
4+`CARGO_TARGET_DIR=$HOME/.cache/cargo-target-sb128c`).
5+
6+## VERDICT: RED
7+
8+The r3 residue is CLOSED at its root cause (deblock), but the gate stream has a
9+SECOND, independent defect one decode-order frame later, in reconstruction.
10+
11+## (0) r3 suite result line
12+
13+`sb128c-suite-r3-1788327685.service`, `$HOME/.cache/sb128c-suite-r3.log`:
14+`test result: FAILED. 371 passed; 1 failed; 32 ignored; 0 measured; 0 filtered
15+out; finished in 797.36s`. The one failure is r3's own known-RED gate
16+`a_real_aomenc_inter_128x128_none_root_decodes_pixel_exact`.
17+
18+## (1) The x=64 band -- ROOT CAUSE FOUND AND FIXED
19+
20+Method: stage bisection with the aomdec instrumentation rungs, decode order.
21+
22+| decode-order frame | pre-filter | post-deblock | final (CDEF+LR) |
23+|---|---|---|---|
24+| 0..3 | exact | exact | exact |
25+| 4 | **exact** | **98 Y px, 274 C** | 98 Y / 274 C |
26+| 5..8 | wrong | wrong | wrong |
27+
28+Pre-filter exact + post-deblock wrong on the SAME frame => the loop filter, not
29+a symbol. The decisive measurement: against `EC_AV1_PREFILT_DUMP`, aomdec's own
30+post-deblock dump changes **ZERO** pixels in luma columns 50..78 of that frame,
31+while ours changes 98 (peak 26 at column 63, footprint 58..66 = the 14-tap
32+vertical filter at x=64). libaom does not filter that edge at all.
33+
34+Why: libaom `av1_loopfilter.c:set_one_param_for_line_luma` (and `_chroma`)
35+
36+```c
37+const int32_t pu_edge = mi_prev != mbmi;
38+if (!pu_edge) curr_skipped = mbmi->skip_txfm && is_inter_block(mbmi);
39+if ((pu_edge || !curr_skipped) && level) { params->filter_length = ...; }
40+```
41+
42+`get_transform_size` still reports TX_64X64 for a SKIP 128x128 inter block, so
43+the transform-unit edge at x=64 exists -- it is simply suppressed because it is
44+not a prediction-unit edge and the block is skipped. Every 128 block in this
45+stream is `is_inter=1 skip=1`.
46+
47+Fix (`crates/ec-av1/src/decode.rs`, commit `6226c27`):
48+- the per-leaf `fill_lf_grid_rect` loop (the var-tx leaf publication, ~line
49+ 19256) is gated on `!(skip && is_inter)`. The block-level publication of
50+ `write_w = 128` stays, which IS the suppression. The 128 root is the only
51+ block that reaches that loop skipped: `read_block_tx_size`'s
52+ `TX_MODE_LARGEST` branch hands back four TX_64X64 leaves for `side > 64`
53+ regardless of `skip`, while every `side <= 64` skip inter block gets `None`.
54+- `fill_lf_grid_rect`'s uv extent (~line 4186) drops its `.min(32)` cap. The
55+ cap was INERT for every block up to 64 wide (`64/2 == 32`) and wrong for a
56+ 128-sided one, where it published an internal chroma TU edge every 32 chroma
57+ px. A non-skip 128 block still gets uv 32, through its own per-leaf calls
58+ (`w_mi * MI == 64`).
59+- `dump_stage` now indexes its file per decode-order picture. It wrote a fixed
60+ `.f0` every frame, so `EC_AV1_POSTDEBLOCK_DUMP` only ever held the LAST
61+ picture and could not be compared against aomdec's indexed rung -- that is
62+ the instrument this root cause needed.
63+
64+Result on `$HOME/.cache/sb128c-work/g-61-8-0.obu`: decode-order frames 0..4 are
65+now exact at pre-filter, post-deblock AND final (`EC_AV1_FINAL_DUMP`, hidden
66+frames included). Before the fix frame 4 was wrong at post-deblock.
67+
68+## (1b) CDEF for a 128 root -- the charter's suspicion is WRONG, verified
69+
70+`read_cdef` (`av1/decoder/decodemv.c`) reads at most one literal PER CALL, and
71+is called once per BLOCK. For a `PARTITION_NONE` 128 root there is exactly one
72+block in the superblock, so exactly ONE `cdef_idx` symbol is read
73+(`index = cdef_unit_col_in_sb + 2 * cdef_unit_row_in_sb` = 0), and it is stored
74+into the block's own `MB_MODE_INFO`, which every mi cell of all four 64x64 CDEF
75+units points at. r1's "replicated over 4 quadrants" is CORRECT; no change made.
76+(Four symbols are read only when the 128 root SPLITs into four non-skip 64s.)
77+
78+## (2) The NEW frontier: decode-order frame 5, reconstruction
79+
80+Every reference of frame 5 is now pixel-exact at every stage, and frame 5 is
81+already wrong at PRE-FILTER, so this is not filter propagation:
82+
83+```
84+decode-order 5 pre-filter: Y 19609 px rows 128..255 cols 0..255 maxd 33
85+ C 5207 px
86+per-64x64-quadrant Y diff: [0,0,0,0] [0,0,0,0] [3707,844,3137,3889] [183,177,3844,3828]
87+first bad pixel: (128, 0)
88+```
89+
90+The whole BOTTOM superblock row, both 128x128 superblocks, from its very first
91+pixel; rows 0..127 exact. Our own mode trace for that picture lists the bottom
92+row as two `side=128 is_inter=1 skip=1` blocks. A skipped inter block's
93+reconstruction is pure motion compensation, the entropy stream stays in sync
94+for all 9 frames, and the quadrant diff is content-dependent (flat quadrants
95+mostly match, detailed ones mostly do not) -- the signature of a slightly wrong
96+predictor, i.e. mv / reference / interp filter / OBMC, NOT of a wrong write
97+geometry. Frame 4's own `(32,0)` 128 skip block decodes exact, so 128-wide MC
98+per se works.
99+
100+fix-now for r5; it is the only thing between this gate and GREEN.
101+
102+## (3) 128-level HORZ/VERT + AB -- NOT STARTED
103+
104+deferred: 128-level HORZ/VERT (128x64, 64x128) and AB on key and inter paths --
105+r4's budget went to (0)/(1) and the stage bisection that found the root cause;
106+unblocked by nothing, it is r5 work. It remains the FRONTIER for his 10-bit AV1
107+film.
108+
109+## ReelC re-probe (unchanged, as expected -- (3) was not started)
110+
111+Both `$HOME/.cache/sb128c-work/reelc2s.obu` and `$HOME/.cache/reelc-head.obu`
112+(1428 bytes each, `use_128x128_superblock=true bit_depth=10`) stop at
113+`a 128x128 superblock HORZ/VERT or AB partition (only SPLIT and NONE are
114+decoded at the 128 root)` with `EC_AV1_FINAL_DUMP` count **1**. That one frame
115+is **byte-identical** to ffmpeg's `yuv420p10le` decode of the same extract
116+(4561920 bytes, `cmp` clean).
117+
118+## EVIDENCE
119+
120+```
121+EVIDENCE: $HOME/.cache/sb128c-work/{pf-o,pf-m}.f0..f8, {pd-o,pd-m}.f* | aomdec EC_AV1_PREFILT_DUMP/EC_AV1_POSTDEBLOCK_DUMP vs ours, per decode-order frame | decode-order 0-4 pre-filter exact; frame 4 post-deblock 98 Y + 274 C before the fix
122+EVIDENCE: $HOME/.cache/sb128c-work/pd-o.f4 vs pf-o.f4 | aomdec's own post-deblock minus pre-filter, luma cols 50..78 | 0 pixels changed by libaom; ours changed 98 (peak 26 at col 63)
123+EVIDENCE: $HOME/.cache/sb128c-work/{fo,fm}.f0..f8 | EC_AV1_FINAL_DUMP (post CDEF+LR, decode order, hidden frames included) after the fix | frames 0-4 exact, first divergence decode-order 5
124+EVIDENCE: $HOME/.cache/sb128c-work/pf-m.f5 vs pf-o.f5 | per-64x64 quadrant diff map | rows 128..255 only, first bad pixel (128,0), maxd 33
125+EVIDENCE: $HOME/.cache/sb128c-work/{td.f0,ff.yuv} | decode_probe EC_AV1_FINAL_DUMP vs ffmpeg -pix_fmt yuv420p10le on reelc2s.obu | cmp IDENTICAL, 4561920 bytes
126+EVIDENCE: $HOME/.cache/sb128c-suite-r3.log | full lib suite on the r3 tip | 371 passed; 1 failed; 32 ignored
127+```
128+
129+## Suite
130+
131+`$HOME/.cache/sb128c-suite-r4.log` (unit `sb128c-suite-r4-1788328542.service`),
132+totals in the handoff. One KNOWN RED expected: the gate above.
lanes/sb128c-r5.handoff.mdadded+102 -0
@@ -0,0 +1,102 @@
1+# lane-sb128c r5 -> r6 handoff
2+
3+Worktree `edith_codecs-sb128c`, `CARGO_TARGET_DIR=$HOME/.cache/cargo-target-sb128c`.
4+Work stream: `$HOME/.cache/sb128c-work/g-61-8-0.obu` (arm 1) and `a3.obu` (arm 3,
5+copied out of the gate's pinned `/tmp` dir -- keep it, /tmp is reaped).
6+
7+## (1) The r4 residue: THREE root causes, all fixed, arms 1+2 GREEN
8+
9+r4's "frame 5 pre-filter wrong, entropy in sync" premise was WRONG: the mode-value
10+ladder (`EC_TRACE_MODE`, values only -- our `EC_MODE_VAL` prints its `rng` at
11+libaom's `EC_MODE_MV` point, so RANGE is not comparable line-for-line) diverges at
12+mode-value line 43, `mi(32,0)`, a 128x128 NEWMV block:
13+
14+```
15+oracle EC_MODE_VAL mi_row=32 mi_col=0 mode=16 ref0=1 mv0=(63,0) stack=1
16+ours EC_MODE_VAL mi_row=32 mi_col=0 mode=16 ref0=1 mv0=(0,0) stack=2
17+```
18+
19+a) **mv stack: the top-right probe was never gated on `has_top_right`.**
20+`crates/ec-av1/src/mvstack.rs:882` (`find_mv_stack`) and `:1680`
21+(`find_mv_stack_compound`) called `scan_top_right{,_compound}` unconditionally.
22+libaom `setup_ref_mv_list` (mvref_common.c:497 + :546) computes
23+`has_tr = has_top_right(cm, xd, mi_row, mi_col, AOMMAX(width,height))` and only
24+then `scan_blk_mbmi(-1, xd->width)`. `has_top_right` returns 0 for `bs > 16`, so a
25+128x128 block has NO top-right candidate -- but the cell diagonally above-right of
26+`mi(32,0)` (= `mi(31,32)`, in the previous SB row) IS populated, so our grid probe
27+invented `(441,441) w=644` and the extra stack entry desynced the drl symbols.
28+The module's own `mvstack::has_top_right` port already existed and was correct; it
29+just was not wired into the mv-stack scan (only into the warp-sample gather).
30+
31+b) **`motion_mode`/`obmc` CDF row 4 for a 128x128 block.**
32+`decode.rs:17977` mapped square sizes with `w == h => (w.trailing_zeros() - 3)`,
33+which sends 128 to row 4 -- our packed `BLOCK_16X32` row. Wrong alphabet narrowing,
34+no wrong value (class `wrong-alphabet-same-value`). Added libaom
35+`default_motion_mode_cdf` / `default_obmc_cdf` rows 13/14/15 (BLOCK_64X128,
36+128X64, 128X128) as our packed indices 14/15/16 in `cdf.rs` (arrays 14 -> 17,
37+`cdf_state.rs` types too) and explicit `(64,128)/(128,64)/(128,128)` match arms
38+BEFORE the square arm.
39+
40+c) **A TX_64X64 luma unit of an INTRA-in-inter 128 block used the full 64x64 scan.**
41+`decode.rs:18995` passed `default_scan(tx_px)` and `tx_side = tx_px`; a TX_64X64
42+codes only its top-left 32x32 (spec 5.11.40). Panicked
43+`transform.rs:828 assertion left==right: one coefficient per position, 1024 vs 4096`
44+on gate arm 2. Now `.min(32)` on both, matching every other 64-capable site
45+(`coeff_tx_side`, `default_scan(tx_px.min(32))` at :17429/:18494).
46+
47+EVIDENCE: `$HOME/.cache/sb128c-work/pf-{o,m}.f0..f8` | `EC_AV1_PREFILT_DUMP` on
48+aomdec oracle + `decode_probe`, g-61-8-0.obu | all 9 decode-order frames 0 bytes
49+differ (was 19550/14164/26667/26716 on f5..f8), mode-value ladder MODE_IDENTICAL.
50+
51+Gate `a_real_aomenc_inter_128x128_none_root_decodes_pixel_exact`:
52+- arm 1 (yuv420p, tx_search=0, seed 61): **9/9 frames exact**, `inter_sb128_none_hits=14 chroma_units=16 intra_128_in_inter=0`
53+- arm 2 (yuv420p10le, tx_search=0, seed 61): **9/9 frames exact**, `hits=29 chroma_units=28 intra_128_in_inter=1`
54+- arm 3 (yuv420p, tx_search=1, seed 62): **RED**, 7 bytes, see below.
55+`a_real_aomenc_key_frame_with_a_128x128_none_partition_decodes_pixel_exact` and
56+`a_real_aomenc_128x128_superblock_stream_decodes_pixel_exact` stay green.
57+
58+## (2) EXACT NEXT STEP: arm 3, a phantom CHROMA deblock edge (4 px), stage-bisected
59+
60+Stream `$HOME/.cache/sb128c-work/a3.obu` (909 B, 256x256 8-bit, 9 decode-order
61+frames). Mode ladder is IDENTICAL to the oracle -- no entropy defect.
62+
63+Stage bisection (oracle rungs `EC_AV1_PREFILT_DUMP` / `EC_AV1_POSTDEBLOCK_DUMP` /
64+`EC_AV1_FINAL_DUMP`; NOTE our POSTDEBLOCK dump indexes 0,2,4,... so oracle `fN`
65+pairs with ours `f2N`, and on THIS stream it really is pre-CDEF):
66+```
67+pre-filter f0..f8 : 0 0 0 0 7 6 6 6 0 (f4+ is propagation)
68+post-deblock f3 : 4 px <-- the defect
69+final f3 : 7 px, f4..f7 6 px each
70+```
71+The 4 post-deblock pixels are V-plane only:
72+`V(46,56) V(46,57) V(47,54) V(47,55)`, ours 170 vs oracle 167 -- two pairs
73+straddling a VERTICAL chroma edge at chroma x=56 (luma x=112), inside the
74+`mi(0,0)` `side=128 is_inter=1 skip=0` block of decode-order frame 3.
75+
76+Root cause (identified, NOT yet fixed): `decode.rs:19303`, the per-vartx-leaf
77+`fill_lf_grid_rect` loop in `decode_inter_block`, passes the LUMA leaf extent, and
78+`fill_lf_grid_rect` derives `uv_tx_w/h` from its own `w_mi/h_mi` (`decode.rs:4211`).
79+So a 16x16 luma leaf publishes a chroma TU extent of 8 and creates chroma edges
80+every 8 px -- e.g. at chroma 56. libaom takes a chroma plane's transform size from
81+`av1_get_max_uv_txsize(mbmi->bsize, ...)` (the BLOCK's, = TX_32X32 for a 128 root)
82+in `set_one_param_for_line_chroma`, never from the luma var-tx leaf. Fix shape:
83+leave the chroma half of the grid at the BLOCK's uv extent when writing per-leaf
84+(a leaf-only luma write, or an explicit uv re-publish after the loop, mirroring
85+r4's `suppress_internal_lf_edges`). Beware r4's trap: the block-level uv `.min(32)`
86+cap must stay (an INTRA 128 block's internal chroma edges ARE filtered).
87+Re-run the key-frame 128 sibling gate after touching this (class
88+`fix-trades-sibling-gate`).
89+
90+## (3) NOT STARTED
91+
92+deferred: 128-level HORZ/VERT + AB partitions (key and inter) -- r5's budget went
93+to the three r4-residue root causes; unblocked by nothing. Refusal
94+`refusal_inventory.rs:45` "a 128x128 superblock HORZ/VERT or AB partition (only
95+SPLIT and NONE are decoded at the 128 root)" is untouched. `cdf::MOTION_MODE`/
96+`cdf::OBMC` now already carry the BLOCK_64X128 / BLOCK_128X64 rows that work needs.
97+deferred: full suite -- not run this round (r4's was also incomplete); r6 must run
98+`systemd-run --user --unit=sb128c-suite-$(date +%s) -p MemoryMax=10G --same-dir bash -lc '...'`
99+per COMMON, log to `$HOME/.cache/sb128c-suite-r6.log`.
100+deferred: ReelC re-probe -- not re-run; r4 measured both extracts still stopping at
101+the 128 HORZ/VERT/AB refusal with `EC_AV1_FINAL_DUMP` count 1, byte-identical to
102+ffmpeg. Nothing in r5 touches that stop string.
lanes/sb128c-r6.handoff.mdadded+75 -0
@@ -0,0 +1,75 @@
1+# lane-sb128c r6 -> r7 handoff: the 128-root HORZ/VERT/AB partition work
2+
3+Worktree `edith_codecs-sb128c`, `CARGO_TARGET_DIR=$HOME/.cache/cargo-target-sb128c`.
4+r6 merged main 727f29a + lane-golomb 173b793 and re-greened the five 128 gate arms;
5+it did NOT start the partition work. Everything below is measured this round.
6+
7+## The blocker on the 1080p AV1 film is ONE arm: the GATHERED bottom-edge HORZ
8+
9+`decode_probe` on four extracts of the 1080p 10-bit AV1 film (2 s each, `-c:v copy`)
10+all stop at `a 128x128 superblock HORZ/VERT or AB partition`, and
11+`EC_AV1_TRACE=1 | grep partition_w128` shows values **0 and 3 only** right up to the
12+stop -- i.e. the refusing partition never came from the full-alphabet symbol (which
13+traces every value) but from `read_sb128_root`'s GATHERED branch (`decode.rs:13317`,
14+no trace line): frame height 1080 gives `mi_rows = 270`, so the bottom 128 row has
15+`mi_r128 = 256`, `256 + SB_MI(16) = 272 > 270` -> `has_rows128 == false`, one gathered
16+bit, and the film codes it as `PARTITION_HORZ` (a 128x64 block whose bottom 8 luma rows
17+are the only ones in frame). Frame width 1920 = 15*128 exactly, so `has_cols128` is
18+always true and the VERT gathered arm is unreachable on this film.
19+=> r7's minimum for the film is the **128x64 block** (key + inter), not the whole set.
20+
21+## What aomenc actually emits (measured, 90 streams)
22+
23+- Sweep A, 72 streams (`sweep.sh`: seeds 41/42/43/61/62/71 x 256x256,384x384 x cq
24+ 40/55/63 x 8+10-bit, `--sb-size=128 --cpu-used=0 --min-partition-size=64
25+ --enable-rect-partitions=1 --enable-ab-partitions=1`): partition_w128 takes ONLY
26+ value 0 (NONE) and 3 (SPLIT). No HORZ, no VERT, no AB, at any setting.
27+- Sweep B, 18 streams (`sweep2.sh`, 512x512 synthetic sources designed to favour the
28+ arms): horizontal-stripe and vertical-stripe sources still give NONE only; the
29+ **AB-shaped** source (`geq` = top 64 rows of every 128 uniform, bottom split into two
30+ 64x64 levels) gives `value=1` (**PARTITION_HORZ at the 128 root**) at every cq
31+ (32/50/63) and both `--min-partition-size` 64 and 16.
32+ Reproduce: `nullsrc=s=512x512:d=0.32:r=25,geq=lum='if(lt(mod(Y\,128)\,64),200,if(lt(mod(X\,128)\,64),40,120))':cb=128:cr=128,noise=all_seed=7:alls=3:allf=t`
33+ Streams kept at `$HOME/.cache/sb128c-work/s2-abshape-*.obu` (decode stops at the
34+ 5th 128 root of the KEY frame).
35+- Whether VERT / the four AB values (4..7) are reachable is still UNKNOWN: our decoder
36+ stops at the first refusing root, so nothing past it is observable. Re-run both
37+ sweeps once HORZ decodes -- only then is "aomenc never picks arm X" a measured claim
38+ (class `refusal-lifted-without-a-gate`: keep the unreached arms refused BY NAME).
39+
40+## Shape of the 128x64 / 64x128 block (spec + libaom, for r7)
41+
42+- luma: `max_txsize_rect_lookup[BLOCK_128X64] = TX_64X64` -> two TX_64X64 units, each
43+ coding only its top-left 32x32 (`default_scan(tx_px.min(32))`, already the convention
44+ at decode.rs:17540/:18670).
45+- chroma: `av1_get_max_uv_txsize(BLOCK_128X64) = TX_32X32` over a 64x32 uv block -> two
46+ units per plane, uv block > uv tx, so the txb_skip CDF takes the offset-10 rows.
47+- coding order: two 64x64 mu chunks (`decode_token_recon_block`), Y then U then V per
48+ chunk -- the existing `side > 64` chunk loop in `decode_inter_block` (decode.rs:17568)
49+ already does this for four chunks; it keys the chunk on `(row/16, col/16)`.
50+- `motion_mode`/`obmc` rows BLOCK_64X128 (14) / BLOCK_128X64 (15) are already in
51+ `cdf.rs` (added r5, packed indices 14/15/16 with 128X128).
52+- `has_top_right`: `mvstack::has_top_right` returns 0 for `bs0 = max(bw4,bh4) > 16`, so
53+ both 128x64 and 64x128 have no top-right candidate; the probe is now gated
54+ (mvstack.rs:882/:1680), nothing more to do there.
55+- lf grid: per-unit write with the skip-inter suppression, luma-only leaf write
56+ (`fill_lf_grid_leaf_luma`, from lane-golomb) -- both already merged in r6.
57+- one `cdef_idx` literal per block, copied to every 64x64 CDEF unit the block covers
58+ (the pattern at decode.rs:13606 / :21744).
59+- palette (>64), CfL (>32) and filter intra are all size-refused already.
60+- AB visit order (libaom `decode_partition`): VERT_A = 64x64 TL, 64x64 BL, 64x128 right;
61+ VERT_B = 64x128 left, 64x64 TR, 64x64 BR; HORZ_A = 64x64 TL, 64x64 TR, 128x64 bottom;
62+ HORZ_B = 128x64 top, 64x64 BL, 64x64 BR.
63+
64+## Entry points to touch
65+
66+- `read_sb128_root` decode.rs:13277 (the refusal at :13345, both branches).
67+- key-frame tile: decode.rs:13554 (`part128 == PARTITION_NONE` arm; the 128 NONE block
68+ goes through `decode_block(..., SB * 2, ...)`; a 128x64 needs the rect analogue --
69+ `decode_block_rect64` (decode.rs:8061) is the 64x32/32x64 one and is corner-cropped
70+ for a 32x32 real transform, so it does NOT generalise as-is).
71+- inter tile: decode.rs:21642 + the `inter_piece!` macro at :21683 -- there a 128x64 is
72+ plausibly `inter_piece!(mi, SB * 2, ..., ww = SB * 2, wh = SB)` because
73+ `decode_inter_block` is already (write_w, write_h)-general; try the inter arm FIRST,
74+ it is much cheaper than the key one.
75+- `refusal_inventory.rs:46` + `gate_coverage.rs` in the same commit as the gate.
lanes/sb128c-r6.report.mdadded+121 -0
@@ -0,0 +1,121 @@
1+# lane-sb128c r6 report
2+
3+Branch `lane-sb128c`, worktree `edith_codecs-sb128c`.
4+Tip `cf0bd84` (merges: `363ab1e` main 727f29a, `5230f4c` lane-golomb 173b793).
5+
6+## Verdict: GREEN on the merge + the five 128 arms; the partition work is NOT started (see below)
7+
8+## (1) Merge (charter step 1) -- done, and it found a real regression
9+
10+`git merge --no-commit main` (main tip 727f29a, which does NOT contain lane-golomb),
11+then `git merge --no-commit 173b793` directly, as chartered.
12+
13+Resolutions (all in `crates/ec-av1/src/decode.rs`):
14+- var-tx leaves are main's general `(row, col, tw, th)`; the lane's 128-root mu-chunk
15+ chroma interleave (`side > 64`, one 32x32 uv unit per 64x64 chunk) is kept, appended
16+ after main's `record_mi_luma_rect` (:17540 and :18670, both leaf loops).
17+- `default_scan(tx_px.min(32))` kept over main's `default_scan(tx_px)` -- a TX_64X64
18+ codes only its top-left 32x32 (r5 root cause c).
19+- the per-vartx-leaf lf grid write is golomb's LUMA-ONLY `fill_lf_grid_leaf_luma`
20+ (:19477), called with `(tw, th)`; this is exactly the r5 arm-3 defect (a 16x16 luma
21+ leaf was publishing a chroma TU extent of 8 and inventing a chroma edge at chroma
22+ x=56), so arm 3 needed no new code of mine.
23+- the lane's skip-inter `suppress_internal_lf_edges` is kept, narrowed to the 128 root.
24+- leaf ceiling is per root: main's TX_32X32 refusal below 128, TX_64X64 at the 128 root.
25+- `cdf.rs` diff vs 173b793 is ONLY the lane's own three rows in `MOTION_MODE`/`OBMC`
26+ (BLOCK_64X128 / 128X64 / 128X128), 18 changed lines vs main; no hand-resolution.
27+
28+REGRESSION FOUND AND FIXED (class `fix-trades-sibling-gate`): r5's mv-stack change wired
29+libaom's WHOLE `has_top_right`, position mask included, without its three shape
30+refinements (`is_last_vertical_rect`, `is_first_horizontal_rect`, the `PARTITION_VERT_A`
31+bottom-left square) that `mvstack::has_top_right`'s own doc calls a corner-cut. Correct
32+at 128 (`bs > 64` -> no candidate) and WRONG below it once main decodes rect/AB inter
33+leaves: `a_real_aomenc_stream_with_ab_partitions`, `..._with_free_partitions` and
34+`real_aomenc_1to4_streams...` all lost frame 16 luma (seed 48), and the
35+`all_same_mv_neighbourhood_dedupes_to_one_entry` unit test lost the corner weight
36+(648 vs 652). Now gated on the size half only (`mvstack::top_right_scan_allowed`,
37+`bw4.max(bh4) <= 16`), with the ceiling and upgrade path named at the helper.
38+
39+EVIDENCE: $HOME/.cache/sb128c-gate-r6e.log | cargo test -p ec-av1 --lib -- ab_partitions
40+free_partitions real_aomenc_1to4_streams inter_128x128_none_root
41+key_frame_with_a_128x128_none_partition a_real_aomenc_128x128_superblock_stream
42+all_same_mv_neighbourhood | test result: ok. 9 passed; 0 failed
43+
44+The five 128 arms the charter asks for, from $HOME/.cache/sb128c-gate-r6a.log (all green
45+already at the merge commit, i.e. arm 3 was fixed by the golomb merge):
46+- inter 128 NONE arm 1 (yuv420p, tx_search=0, seed 61): 9/9 decode-order frames exact,
47+ `inter_sb128_none_hits=14 chroma_units=16 intra_128_in_inter=0`
48+- arm 2 (yuv420p10le, tx_search=0, seed 61): 9/9 exact, `hits=29 chroma_units=28
49+ intra_128_in_inter=1`
50+- arm 3 (yuv420p, tx_search=1, seed 62): 9/9 exact, `hits=15 chroma_units=24` -- was RED
51+ (7 bytes, a phantom chroma deblock edge) at r5.
52+- `a_real_aomenc_key_frame_with_a_128x128_none_partition_decodes_pixel_exact`: ok
53+- `a_real_aomenc_128x128_superblock_stream_decodes_pixel_exact`: ok
54+
55+## (2) 128-level HORZ/VERT + AB partitions -- NOT STARTED, but scoped by measurement
56+
57+deferred: the whole of charter step 2 -- fix-now for r7, unblocked by nothing; the round's
58+budget went to the merge, the has_top_right regression and the measurements below.
59+`refusal_inventory.rs:45` is untouched, no refusal lifted this round.
60+
61+What r6 measured instead (this is what r7 should build against, full detail in
62+`lanes/sb128c-r6.handoff.md`):
63+- 72 aomenc streams (6 seeds x 256x256/384x384 x cq 40/55/63 x 8+10-bit, `--sb-size=128
64+ --cpu-used=0 --min-partition-size=64 --enable-rect-partitions=1 --enable-ab-partitions=1`):
65+ the 128-root partition symbol is ONLY 0 (NONE) or 3 (SPLIT). aomenc picks no 128-level
66+ HORZ/VERT/AB on that recipe at all -- a gate built on it would be vacuous.
67+- 18 further streams with sources designed for the arms (512x512): an AB-shaped source
68+ DOES produce `value=1` = PARTITION_HORZ at the 128 root, at cq 32/50/63 and both
69+ min-partition-size 64 and 16. Recipe + kept streams in the handoff.
70+- Whether VERT / the four AB values are reachable stays UNKNOWN: our decoder stops at the
71+ first refusing root, so nothing past it is observable. Any "aomenc never picks it"
72+ claim needs a re-sweep AFTER HORZ decodes.
73+
74+EVIDENCE: $HOME/.cache/sb128c-work/sweep.out + sweep2 stdout | 90 aomenc encodes decoded
75+with EC_AV1_TRACE=1 | partition_w128 value histogram: {0,3} in all 72 sweep-A streams,
76+{0,1} in the 6 abshape streams
77+
78+## (3) Full suite
79+
80+`cargo test -p ec-av1 --lib` (systemd unit, MemoryMax=10G) at the merge commit:
81+**381 passed / 4 failed / 35 ignored** -- the four failures are the has_top_right
82+regression described above. Re-run at tip cf0bd84: **385 passed / 0 failed / 35 ignored**
83+(1125.89 s), log `$HOME/.cache/sb128c-suite-r6.log`.
84+
85+EVIDENCE: $HOME/.cache/sb128c-suite-r6.log | systemd-run --user --unit=sb128c-suite2-...
86+-p MemoryMax=10G cargo test -p ec-av1 --lib -j3 | test result: ok. 385 passed; 0 failed;
87+35 ignored
88+
89+## (4) Film re-probe (1080p 10-bit AV1, four extracts)
90+
91+| stream | bytes | stop string | FINAL_DUMP frames |
92+|---|---|---|---|
93+| `sb128c-work/reelc2s.obu` | 1428 | 128x128 superblock HORZ/VERT or AB partition | 1 |
94+| `~/.cache/reelc-head.obu` | 1428 | same | 1 |
95+| `sb128c-work/reelc-8100.obu` (`-ss 8100 -t 2`) | 326696 | same | 0 |
96+| `sb128c-work/reelc-9000.obu` (`-ss 9000 -t 2`) | 1287780 | same | 0 |
97+
98+The one shown frame the head extract does decode is byte-identical to ffmpeg's 10-bit
99+output. No film grain on this title.
100+
101+NEW, decisive for r7: on all four extracts `EC_AV1_TRACE=1 | grep partition_w128` shows
102+values 0 and 3 ONLY right up to the stop. The full-alphabet symbol traces every value it
103+reads, so the refusing partition came from `read_sb128_root`'s GATHERED branch
104+(decode.rs:13317, untraced): 1080 luma rows -> `mi_rows = 270`, the bottom 128 row has
105+`mi_r128 = 256`, `256 + 16 > 270`, one gathered bit, and the film codes it
106+`PARTITION_HORZ` -- a 128x64 block at the frame's bottom edge. Width 1920 = 15*128
107+exactly, so the VERT gathered arm is unreachable on this title. The film's minimum ask is
108+therefore the 128x64 block, not the whole 128-level partition set.
109+
110+EVIDENCE: $HOME/.cache/sb128c-work/fd/o.f0 vs reelc-ff.yuv | EC_AV1_FINAL_DUMP decode of
111+reelc2s.obu + `ffmpeg -pix_fmt yuv420p10le -frames:v 1` | cmp: identical, 4561920 B
112+
113+## Open residue
114+
115+- fix-now (r7): 128-level HORZ (128x64) on the key and inter paths, gated on the abshape
116+ recipe; then re-sweep for VERT/AB and keep the unreached arms refused BY NAME.
117+- accepted: `top_right_scan_allowed`'s corner-cut (mask half unported) -- identical to
118+ main's behaviour below 128, ceiling named in the doc comment.
119+- deferred: the three `has_top_right` shape refinements -- unblocked by nothing, but only
120+ observable once a gate exercises a rect/AB inter leaf whose top-right differs; none of
121+ the 416 lib tests does today.
lanes/sb128c-r7.report.mdadded+99 -0
@@ -0,0 +1,99 @@
1+# lane-sb128c r7 report -- the 128 root's gathered frame-edge HORZ/VERT arm
2+
3+Branch `lane-sb128c`, worktree `edith_codecs-sb128c`,
4+`CARGO_TARGET_DIR=$HOME/.cache/cargo-target-sb128c`.
5+Commits this round: `d10a641` (the interrupted r7 builder's partial, committed as
6+wip), `52e4458` (feature + gate), `5bd4556` (inventory).
7+
8+## What changed
9+
10+- `crates/ec-av1/src/decode.rs:13446` `read_sb128_root`: HORZ/VERT are no longer
11+ refused there; they are counted (`PART128_HORZ_HITS`, `PART128_VERT_HITS`, and
12+ the gathered-edge pair `PART128_EDGE_HORZ_HITS`/`PART128_EDGE_VERT_HITS`) and
13+ only the four AB shapes still refuse, by their own name.
14+- `crates/ec-av1/src/decode.rs:21881` inter tile path: a 128 root that resolves
15+ to HORZ/VERT decodes two `inter_piece!` blocks of 128x64 / 64x128 (the second
16+ skipped when its origin is outside the frame, libaom `decode_partition`'s
17+ `if (mi_row + hbs < mi_rows)`), then fans one `cdef_idx` out over the 64x64
18+ CDEF units the block covers.
19+- `crates/ec-av1/src/decode.rs:12029` `read_block_tx_size_rect`: `bw.max(bh) > 64`
20+ reads TWO square TX_64X64 top-level units (libaom `read_block_tx_size`'s
21+ `idy/idx` loop), each with its own `txfm_partition` symbol at depth 0.
22+- `crates/ec-av1/src/decode.rs:11897` `rect_inter_residual_supported`: (128,64)
23+ and (64,128) admitted.
24+- `crates/ec-av1/src/decode.rs:18008` / `:19109`: the `side > 64` mu-chunk chroma
25+ branch now precedes the `rect_tu` one -- at the 128 root a rect block's chroma
26+ is per mu chunk, not one unit for the block.
27+- `crates/ec-av1/src/decode.rs:16891`: the `whole_sb` test that gates delta-q /
28+ delta-lf reads is against `sb_mi_cur() * 4`, not a hardcoded 64.
29+- `crates/ec-av1/src/decode.rs:3948` `Neighbours::new`: the per-mi side arrays are
30+ padded to a superblock multiple. ROOT CAUSE of two index-out-of-bounds panics
31+ (`decode.rs:5018`, `:4537`, len 200 index 200) on the 1080p film: a 128x64 at
32+ the bottom edge records neighbour state for its whole 64-row extent, past the
33+ frame's last mi row -- libaom's own context buffers are `MAX_MIB_SIZE`-aligned
34+ for exactly that reason. The two `get_mut` guards in `record_mi_rect` are the
35+ belt; the padding is the fix.
36+- `crates/ec-av1/src/decode.rs:13700` key-frame path: HORZ/VERT at the 128 root
37+ now REFUSE by name. Before this round they fell through into the four-quadrant
38+ SPLIT visit and silently decoded wrong pixels (the first version of the gate
39+ caught it as a frame-0 mismatch on a `gradients` source).
40+- `crates/ec-av1/src/stream.rs:18957` new gate; `:84` `sb128_rect_counters()`;
41+ `crates/ec-av1/examples/decode_probe.rs:40` prints them.
42+- `crates/ec-av1/src/refusal_inventory.rs:46`: the old
43+ "a 128x128 superblock HORZ/VERT or AB partition" line is REPLACED by
44+ "a 128x128 superblock AB partition (HORZ_A/HORZ_B/VERT_A/VERT_B at the 128 root)"
45+ plus the new intra-frame one and the var-tx >64 leaf guard.
46+
47+## Gate (GREEN)
48+
49+`cargo test -p ec-av1 --lib gathered_edge_horz -- --nocapture`
50+(`a_real_aomenc_sb128_gathered_edge_horz_partition_decodes_pixel_exact`):
51+4 real `aomenc --sb-size=128 --cpu-used=0 --min-partition-size=64
52+--enable-rect-partitions=1` streams, 5 frames each, every decode-order frame
53+(hidden alt-ref included) compared against the instrumented aomdec through
54+`decode_all_frames_vs_oracle`; hard asserts the gathered-edge counter and the
55+inter 128x64/64x128 block counter.
56+
57+ seed 42 cq55 384x320 8bit HORZ: 6 frames pixel-exact (1 hidden), edge +2 inter_128rect +2
58+ seed 43 cq55 384x320 10bit HORZ: 6 frames pixel-exact (1 hidden), edge +24 inter_128rect +24
59+ seed 44 cq32 192x256 8bit VERT: 6 frames pixel-exact (1 hidden), edge +2 inter_128rect +2
60+ seed 45 cq45 192x256 10bit VERT: 6 frames pixel-exact (1 hidden), edge +2 inter_128rect +2
61+ test result: ok. 1 passed; 0 failed
62+
63+EVIDENCE: $HOME/.cache/sb128c-gate3-r7.log | cargo test -p ec-av1 --lib gathered_edge_horz --nocapture | 4/4 arms pixel-exact vs aomdec, edge counters +2/+24/+2/+2
64+
65+## Film (1080p 10-bit AV1, 4 extracts)
66+
67+| extract | before r7 | after r7 | edge_horz | inter_128x64 |
68+|---|---|---|---|---|
69+| 2 s head (1920x792) | stopped: 128 HORZ/VERT/AB | **OK: 48/48 frames, 49/49 dumps bit-exact vs aomdec** | 720 | 720 |
70+| `~/.cache/reelc-head.obu` | stopped: 128 HORZ/VERT/AB | **OK: 48/48 frames, 49/49 dumps bit-exact** | 720 | 720 |
71+| `-ss 8100` 2 s | stopped: 128 HORZ/VERT/AB | stops at another lane: "a split intra strip whose transform unit is 32x64" | 1 | 0 |
72+| `-ss 9000` 2 s | stopped: 128 HORZ/VERT/AB | stops at another lane: "a non-skip rectangular (HORZ/VERT/HORZ_B) strip needs rectangular residual coding" | 12 | 0 |
73+
74+EVIDENCE: $HOME/.cache/sb128c-r7/d2 vs $HOME/.cache/sb128c-r7/o2 | EC_AV1_FINAL_DUMP on decode_probe head2s.obu and on aomdec head2s.obu, cmp per frame | frames=49 frames_differing=0
75+
76+The 128-partition wall is gone from all four extracts; two of them now decode
77+their whole 2 s window bit-exact, the other two stop at OTHER lanes' refusals.
78+
79+## Suite
80+
81+`cargo test -p ec-av1 --lib` (systemd unit, MemoryMax=10G):
82+**386 passed; 0 failed; 35 ignored** in 1133 s -- `$HOME/.cache/sb128c-suite-r7.log`.
83+
84+## Residue
85+
86+- deferred: the INTRA (key-frame) 128x64/64x128 block -- refused by name, was a
87+ silent wrong decode before this round. Unblocked by a rect-capable
88+ `decode_block` at 128 (`decode_block_rect64` is corner-cropped for a 32x32
89+ transform and does not generalise). A smooth `gradients` source at
90+ `--min-partition-size=64` reaches it in one encode, so a gate is one recipe away.
91+- deferred: the four AB shapes at the 128 root (HORZ_A/HORZ_B/VERT_A/VERT_B),
92+ still refused by name. Unblocked by the intra rect block above plus the
93+ libaom visit order recorded in `lanes/sb128c-r6.handoff.md`. Whether aomenc
94+ ever picks them is still unmeasured -- our decoder used to stop at the first
95+ refusing root, so the r6 sweeps could not observe past it; the 512x512
96+ abshape source now decodes further and the sweep can be re-run.
97+- accepted: `PART128_HORZ_HITS`/`PART128_VERT_HITS` (the non-gathered,
98+ full-alphabet arms) are counted but were 0 in every stream measured this
99+ round; the gate asserts the gathered pair only.