forge
Explore
Log in

Don't you dare go Hollow

merge: lane-sb128c fedb7fe into lane-intra14 -- 128-root inter NONE arm beside the 16x16 AB leaf macro, skip-inter LF suppression

Browse files at this commit

2955fbbdf6b41b9a51ca020925566386843e40d9Ahmet Kaan GümüşParent: c3abafe3355529
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
16451645 /// `motion_mode_allowed` (spec 5.11.24's `read_motion_mode`) offers
16461646 /// `OBMC_CAUSAL` rather than `WARPED_CAUSAL` -- lane-motionmode round 1
16471647 /// 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] = [
16491649 [10437, 32768, 0],
16501650 [17432, 32768, 0],
16511651 [25817, 32768, 0],
@@ -1669,6 +1669,11 @@ pub const OBMC: [[u16; 3]; 14] = [
16691669 // BLOCK_8X16 (4) and BLOCK_16X8 (5) of libaom's `default_obmc_cdf`.
16701670 [9371, 32768, 0],
16711671 [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],
16721677 ];
16731678
16741679 /// `default_motion_mode_cdf` (spec 9.4, `entropymode.c`), the square-bsize
@@ -1678,7 +1683,7 @@ pub const OBMC: [[u16; 3]; 14] = [
16781683 /// `read_motion_mode` reads instead of [`OBMC`] whenever `motion_mode_allowed`
16791684 /// (spec 5.11.24) resolves to `WARPED_CAUSAL`-eligible (`num_proj_ref >= 1`
16801685 /// under `allow_warped_motion`) -- lane-warp round 1.
1681-pub const MOTION_MODE: [[u16; 4]; 14] = [
1686+pub const MOTION_MODE: [[u16; 4]; 17] = [
16821687 [7651, 24760, 32768, 0],
16831688 [19419, 26810, 32768, 0],
16841689 [26260, 29116, 32768, 0],
@@ -1698,6 +1703,13 @@ pub const MOTION_MODE: [[u16; 4]; 14] = [
16981703 // `default_motion_mode_cdf` indices 4 and 5).
16991704 [4738, 24765, 32768, 0],
17001705 [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],
17011713 ];
17021714
17031715 /// `default_interintra_cdf` (spec 9.4): `interintra`, indexed by
crates/ec-av1/src/cdf_state.rsmodified+2 -2
@@ -567,13 +567,13 @@ pub(crate) struct Cdfs {
567567 /// `BLOCK_8X8`, 1 = `BLOCK_16X16`, 2 = `BLOCK_32X32`, 3 = `BLOCK_64X64`
568568 /// (`default_obmc_cdf`'s own `BLOCK_SIZES_ALL` indices 3/6/9/12 --
569569 /// this decoder only ever codes those four square sizes).
570- pub obmc: [[u16; 3]; 14],
570+ pub obmc: [[u16; 3]; 17],
571571 /// `motion_mode` (spec 5.11.24's `read_motion_mode`), the 3-symbol
572572 /// `SIMPLE_TRANSLATION`/`OBMC_CAUSAL`/`WARPED_CAUSAL` alphabet read
573573 /// instead of [`Self::obmc`] whenever `motion_mode_allowed` resolves to
574574 /// `WARPED_CAUSAL`-eligible -- same square-bsize indexing as `obmc`.
575575 /// lane-warp round 1.
576- pub motion_mode: [[u16; 4]; 14],
576+ pub motion_mode: [[u16; 4]; 17],
577577 /// `interintra`, indexed by `size_group_lookup[bsize]` -- see
578578 /// `cdf::INTERINTRA`'s own doc.
579579 pub interintra: [[u16; 3]; 4],
crates/ec-av1/src/decode.rsmodified+460 -22
@@ -2081,6 +2081,29 @@ pub(crate) fn rect_partition_hits() -> usize {
20812081 // lane-inter8 r1: how many superblocks an inter tile coded as a single
20822082 // whole-SB `PARTITION_NONE` 64x64 inter block (the case aomenc picks for
20832083 // static content, previously a named refusal).
2084+thread_local! {
2085+ /// lane-sb128c r1: how many 128x128 `PARTITION_NONE` roots this INTER tile
2086+ /// path decoded as one whole block (its gate's own witness).
2087+ pub(crate) static INTER_SB128_NONE_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
2088+}
2089+
2090+/// Current value of [`INTER_SB128_NONE_HITS`], for a gate's before/after delta.
2091+pub fn inter_sb128_none_hits() -> usize {
2092+ INTER_SB128_NONE_HITS.with(std::cell::Cell::get)
2093+}
2094+
2095+thread_local! {
2096+ /// lane-sb128c r3: how many INTRA-coded 128x128 blocks inside an INTER
2097+ /// frame this decoder reconstructed (mu-chunk chroma, four TX_64X64 luma
2098+ /// units) -- the gate's witness that the lifted refusal's case fired.
2099+ pub(crate) static INTRA_128_IN_INTER_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
2100+}
2101+
2102+/// Current value of [`INTRA_128_IN_INTER_HITS`], for a gate's before/after delta.
2103+pub fn intra_128_in_inter_hits() -> usize {
2104+ INTRA_128_IN_INTER_HITS.with(std::cell::Cell::get)
2105+}
2106+
20842107 thread_local! {
20852108 static INTER_SB_NONE_HITS: std::cell::Cell<usize> =
20862109 const { std::cell::Cell::new(0) };
@@ -4572,6 +4595,31 @@ impl Neighbours {
45724595 /// existing corner-cut, `Neighbours::tx_grid`'s own doc comment -- a
45734596 /// rectangular strip's transform is `TX_32X16`/`TX_16X32`, not tracked
45744597 /// per-axis, matching lane-warp r5's `HORZ_B` top-strip precedent).
4598+ /// libaom `set_one_param_for_line_luma`/`_chroma`: an edge that is a
4599+ /// transform-unit edge but NOT a prediction-unit edge is not filtered when
4600+ /// `curr_skipped = mbmi->skip_txfm && is_inter_block(mbmi)`. Widening this
4601+ /// block's published transform extent to its own size is exactly that
4602+ /// suppression for the deblocker's `x0 % tx != 0` test -- the only shape
4603+ /// that needs it is the 128 root, whose chroma extent (64) is the one
4604+ /// [`Self::fill_lf_grid_rect`]'s TX_32X32 cap narrows. An INTRA block is
4605+ /// never suppressed (libaom's `is_inter_block` term), so this is called
4606+ /// only from the skipped-inter branch.
4607+ fn suppress_internal_lf_edges(&mut self, at_mi: (usize, usize), w_mi: usize, h_mi: usize) {
4608+ let (mi_r, mi_c) = at_mi;
4609+ let (uv_w, uv_h) = ((w_mi * MI / 2).max(4) as u8, (h_mi * MI / 2).max(4) as u8);
4610+ for rr in 0..h_mi {
4611+ for cc in 0..w_mi {
4612+ let idx = (mi_r + rr) * self.skip_grid_cols_mi + (mi_c + cc);
4613+ if let Some(cell) = self.uv_tx_grid.get_mut(idx) {
4614+ *cell = uv_w;
4615+ }
4616+ if let Some(cell) = self.uv_tx_h_grid.get_mut(idx) {
4617+ *cell = uv_h;
4618+ }
4619+ }
4620+ }
4621+ }
4622+
45754623 fn fill_lf_grid_rect(
45764624 &mut self,
45774625 at_mi: (usize, usize),
@@ -6081,6 +6129,14 @@ fn read_intra_mode_rect(
60816129 0
60826130 };
60836131 istep!("angle_y", angle_delta_y);
6132+ // lane-sb128c r3 (class sweep): libaom `read_intra_mode_uv(.., is_cfl_allowed(xd), ..)`
6133+ // and `is_cfl_allowed` (blockd.h) is `block_size_wide[bsize] <= 32 &&
6134+ // block_size_high[bsize] <= 32` on the LUMA bsize. Deciding the alphabet
6135+ // here, from the block's own size, is the single point every caller routes
6136+ // through -- a caller passing `true` for a >32 strip used to pick the
6137+ // 14-symbol CFL CDF, same value but a different range (class
6138+ // wrong-alphabet-same-value).
6139+ let cfl = cfl && bw <= 32 && bh <= 32;
60846140 let uv_mode = if !has_chroma {
60856141 DC_PRED
60866142 } else if cfl {
@@ -9379,6 +9435,10 @@ fn read_intra_mode(
93799435 0
93809436 };
93819437 istep!("angle_y", angle_delta_y);
9438+ // lane-sb128c r3 (class sweep): `is_cfl_allowed` on the luma bsize, decided
9439+ // here so every `decode_block` caller (64x64 and 128x128 roots included)
9440+ // picks the right alphabet -- see [`read_intra_mode_rect`]'s twin.
9441+ let cfl = cfl && side <= 32;
93829442 let uv_mode = if cfl {
93839443 dec.symbol(&mut cdfs.uv_mode_cfl[mode])
93849444 } else {
@@ -12459,6 +12519,21 @@ fn read_block_tx_size(
1245912519 skip: bool,
1246012520 ) -> Result<(usize, Option<Vec<(usize, usize, usize, usize)>>)> {
1246112521 if !TX_SELECT_INTER.with(std::cell::Cell::get) {
12522+ // lane-sb128c r1: `max_txsize_rect_lookup[BLOCK_128X128]` is TX_64X64,
12523+ // so a 128x128 inter block is FOUR luma units even with `tx_mode ==
12524+ // TX_MODE_LARGEST` -- the same leaf shape the var-tx tree hands back.
12525+ // lane-sb128c r3: intra too -- an INTRA 128x128 block under
12526+ // `TX_MODE_LARGEST` also resolves to TX_64X64, i.e. four luma units.
12527+ if side > 64 {
12528+ let step = 64 / MI;
12529+ let mut leaves = Vec::new();
12530+ for row in (0..side / MI).step_by(step) {
12531+ for col in (0..side / MI).step_by(step) {
12532+ leaves.push((row, col, 64, 64));
12533+ }
12534+ }
12535+ return Ok((64, Some(leaves)));
12536+ }
1246212537 return Ok((side, None));
1246312538 }
1246412539 let side_mi = side / MI;
@@ -12486,7 +12561,12 @@ fn read_block_tx_size(
1248612561 }
1248712562 }
1248812563 let single = leaves.len() == 1 && leaves[0].2 == side && leaves[0].3 == side;
12489- if !single && leaves.iter().any(|leaf| leaf.2.max(leaf.3) > 32) {
12564+ // lane-sb128c r6: below the 128 root the ceiling is main's TX_32X32
12565+ // ([`inter_txbset_for`] has no 64-point *inter* table set); a 128x128
12566+ // block's own var-tx tree legitimately bottoms out at TX_64X64 leaves,
12567+ // which the mu-chunk reader above codes as their 32x32 coded corner.
12568+ let leaf_ceiling = if side > 64 { 64 } else { 32 };
12569+ if !single && leaves.iter().any(|leaf| leaf.2.max(leaf.3) > leaf_ceiling) {
1249012570 // Only a block wider than a superblock's own 64x64 max transform
1249112571 // reaches here; this crate has no 64-point *inter* coefficient
1249212572 // table set ([`inter_txbset_for`] stops at 32).
@@ -12506,7 +12586,10 @@ fn read_block_tx_size(
1250612586 n,
1250712587 at_mi,
1250812588 side,
12509- Some(tx_size_context_txfm(n, at_mi, side)),
12589+ // lane-sb128c r3: `get_tx_size_context` compares the neighbour txfm
12590+ // contexts against `tx_size_wide[max_txsize_rect_lookup[bsize]]`,
12591+ // which is 64 for BLOCK_128X128 -- never the block's own 128 side.
12592+ Some(tx_size_context_txfm(n, at_mi, side.min(64))),
1251012593 )
1251112594 };
1251212595 set_txfm_ctxs(n, at_mi, tx, side_mi, side_mi, skip && is_inter);
@@ -13036,6 +13119,12 @@ fn reduce_inherited_chroma_tx_type(t: TxType, w: usize, h: usize) -> TxType {
1303613119
1303713120 fn inter_txbset_for(tx_px: usize, reduced_tx_set: bool) -> TxbSet {
1303813121 match tx_px {
13122+ // lane-sb128c r1: a 128x128 inter block's own luma unit
13123+ // (`max_txsize_rect_lookup[BLOCK_128X128] == TX_64X64`).
13124+ // `av1_get_ext_tx_set_type` is `DCT_ONLY` at `tx_size_sqr_up ==
13125+ // TX_64X64`, so no `tx_type` symbol is coded and the intra/inter sets
13126+ // coincide -- exactly the set the whole-64x64 inter block already uses.
13127+ 64 => TxbSet::Luma64,
1303913128 32 => TxbSet::Luma32Inter,
1304013129 16 if reduced_tx_set => TxbSet::Luma16Inter,
1304113130 16 => TxbSet::Luma16InterSet1,
@@ -16292,7 +16381,13 @@ fn read_inter_plane(
1629216381 let skip_ctx = if plane_idx == 0 {
1629316382 luma_skip_ctx.unwrap_or(0)
1629416383 } else {
16295- usize::from(around.0) + usize::from(around.1)
16384+ // lane-sb128c r1: on a CHROMA plane this same parameter carries
16385+ // `get_txb_ctx`'s own offset instead -- `combine_entropy_contexts(..)`
16386+ // is +7 normally and +10 when the plane block is LARGER than the
16387+ // transform (a 128x128 block's 64x64 uv plane block with TX_32X32
16388+ // units, AV1's only such case), and the `txb_skip_chroma_32` table
16389+ // carries the offset-10 rows at +3 (lane-sb128b r3).
16390+ usize::from(around.0) + usize::from(around.1) + luma_skip_ctx.unwrap_or(0)
1629616391 };
1629716392 let mut coding = cdfs.txb(set, tx_mode);
1629816393 let default_tx_type = match inherited_luma_tx_type {
@@ -17036,8 +17131,13 @@ fn obmc_blend(
1703617131 if matches!((write_w, write_h), (16, 8) | (8, 16)) {
1703717132 OBMC_RECT_LEAF_HITS.with(|c| c.set(c.get() + 1));
1703817133 }
17039- let overlap_above = write_h / 2;
17040- let overlap_left = write_w / 2;
17134+ // lane-sb128c r1: libaom caps the overlap strip at a 64x64 block's own
17135+ // half (`reconinter.c` 860/899: `AOMMIN(block_size_high[bsize],
17136+ // block_size_high[BLOCK_64X64]) >> 1`, and the `block_size_wide` mirror) --
17137+ // inert below 128, where a 128x128 block would otherwise blend a 64-row
17138+ // strip `obmc_mask` has no table for.
17139+ let overlap_above = write_h.min(64) / 2;
17140+ let overlap_left = write_w.min(64) / 2;
1704117141 // lane-inter8 r1 / lane-scaledref r1: `av1_skip_u4x4_pred_in_obmc`
1704217142 // (`reconinter.c` 820, `DISABLE_CHROMA_U8X8_OBMC == 0` -- "one-sided
1704317143 // obmc") returns `dir == 0` when the chroma plane's own block is
@@ -17744,12 +17844,19 @@ fn decode_inter_block(
1774417844 let (above_inter, left_inter) = (neighbours.above_inter[cmi], neighbours.left_inter[rmi]);
1774517845 let ii_ctx = intra_inter_ctx(has_above, has_left, above_inter, left_inter);
1774617846 let is_inter = skip_mode || dec.symbol(&mut cdfs.intra_inter[ii_ctx]) == 1;
17847+ // lane-sb128c r1: this round wires the INTER half of a 128x128 block (four
17848+ // TX_64X64 luma units and four TX_32X32 chroma units interleaved per mu
17849+ // chunk). An INTRA block at that size inside an inter frame takes the
17850+ // intra tail below, which still codes one whole-block chroma unit and one
17851+ // `read_tx_size` at 128 -- refuse by name instead of mis-decoding it.
1774717852 if std::env::var_os("EC_TRACE_MODE").is_some() {
1774817853 eprintln!(
17749- "EC_MODE mi_row={} mi_col={} rng={}",
17854+ "EC_MODE mi_row={} mi_col={} rng={} is_inter={} skip={} side={side}",
1775017855 rmi,
1775117856 cmi,
17752- dec.debug_state().0
17857+ dec.debug_state().0,
17858+ u8::from(is_inter),
17859+ u8::from(skip)
1775317860 );
1775417861 }
1775517862 // lane-warp r5: see `reject_residual` -- a square-block decode of a
@@ -18689,6 +18796,11 @@ fn decode_inter_block(
1868918796 neighbours.around_mi(at, side)
1869018797 };
1869118798 let luma_tx_type;
18799+ // lane-sb128c r1: a 128x128 inter block's four chroma units
18800+ // are read INSIDE the luma leaf loop (one per 64x64 mu chunk);
18801+ // these collect them for the block-level neighbour write-back.
18802+ let mut u_units = vec![0i32; chroma_side * chroma_side];
18803+ let mut v_units = vec![0i32; chroma_side * chroma_side];
1869218804 if let Some(leaves) = vartx_leaves.clone() {
1869318805 // spec 5.11.17's transform tree, leaf by leaf in the order
1869418806 // `read_var_tx_size` coded it: each unit reads its own
@@ -18707,7 +18819,7 @@ fn decode_inter_block(
1870718819 let start = (row * MI + rr) * side + col * MI;
1870818820 tu_pred.extend_from_slice(&pred_y[start..start + tx_px]);
1870918821 }
18710- let scan = default_scan(tx_px);
18822+ let scan = default_scan(tx_px.min(32));
1871118823 let tu_skip_ctx = neighbours.luma_skip_ctx(tu_mi, tx_px / MI);
1871218824 read_inter_plane(
1871318825 dec,
@@ -18759,6 +18871,79 @@ fn decode_inter_block(
1875918871 first_tx_type = tu_tx_type;
1876018872 }
1876118873 neighbours.record_mi_luma_rect(tu_mi, tw, th, &tu_grid);
18874+ // lane-sb128c r1: libaom's `decode_token_recon_block`
18875+ // walks 64x64 "mu" chunks (`mu_blocks_wide/high =
18876+ // mi_size_wide[BLOCK_64X64]`) and codes EVERY PLANE of
18877+ // a chunk before the next one, so a 128x128 block
18878+ // interleaves Y,U,V per quadrant -- the same order the
18879+ // intra 128 path reads (lane-sb128b r3, measured
18880+ // against aomdec's `EC_TRACE_COEFF`). Below 128 a block
18881+ // is a single chunk and this never fires.
18882+ if side > 64 {
18883+ let chunk = (row / 16, col / 16);
18884+ let done = idx + 1 == leaves.len()
18885+ || (leaves[idx + 1].0 / 16, leaves[idx + 1].1 / 16) != chunk;
18886+ if done {
18887+ let (cr, cc) = chunk;
18888+ // `av1_get_max_uv_txsize(BLOCK_128X128)` =
18889+ // `av1_get_adjusted_tx_size(TX_64X64)` =
18890+ // TX_32X32: one 32x32 chroma unit per chunk.
18891+ let cu_tx = 32usize;
18892+ let luma_span = cu_tx * 2;
18893+ let cu_mi = (at_mi.0 + cr * 16, at_mi.1 + cc * 16);
18894+ let cu_around = neighbours.around_mi(cu_mi, luma_span);
18895+ let (cu_x, cu_y) = (cpx + cc * cu_tx, cpy + cr * cu_tx);
18896+ let cu_scan = default_scan(cu_tx);
18897+ for plane_idx in 1..3 {
18898+ let (src, buf) = if plane_idx == 1 {
18899+ (&pred_u, &mut *u)
18900+ } else {
18901+ (&pred_v, &mut *v)
18902+ };
18903+ let mut cu_pred = Vec::with_capacity(cu_tx * cu_tx);
18904+ for rr in 0..cu_tx {
18905+ let start =
18906+ (cr * cu_tx + rr) * chroma_side + cc * cu_tx;
18907+ cu_pred.extend_from_slice(&src[start..start + cu_tx]);
18908+ }
18909+ let cu_grid = read_inter_plane(
18910+ dec,
18911+ cdfs,
18912+ chroma_set,
18913+ &cu_scan,
18914+ plane_idx,
18915+ cu_around[plane_idx],
18916+ mode_for_tx,
18917+ buf,
18918+ cu_x,
18919+ cu_y,
18920+ cu_tx,
18921+ base_q_idx,
18922+ &cu_pred,
18923+ Some(first_tx_type),
18924+ Some(3),
18925+ )?
18926+ .0;
18927+ // Immediately, so the NEXT chunk's unit
18928+ // reads this one's coefficient context.
18929+ neighbours.record_mi_chroma(
18930+ cu_mi, luma_span, luma_span, plane_idx, &cu_grid,
18931+ );
18932+ CHROMA_SPLIT_TX_HITS.with(|c| c.set(c.get() + 1));
18933+ let dst = if plane_idx == 1 {
18934+ &mut u_units
18935+ } else {
18936+ &mut v_units
18937+ };
18938+ for rr in 0..cu_tx {
18939+ let start =
18940+ (cr * cu_tx + rr) * chroma_side + cc * cu_tx;
18941+ dst[start..start + cu_tx]
18942+ .copy_from_slice(&cu_grid[rr * cu_tx..][..cu_tx]);
18943+ }
18944+ }
18945+ }
18946+ }
1876218947 }
1876318948 // `av1_get_tx_type`'s chroma lookup scales the chroma
1876418949 // position back to luma, so an inter block's chroma
@@ -18855,6 +19040,10 @@ fn decode_inter_block(
1885519040 uh,
1885619041 chroma_side,
1885719042 );
19043+ } else if side > 64 {
19044+ // Already read inside the mu-chunk loop above.
19045+ u_grid = std::mem::take(&mut u_units);
19046+ v_grid = std::mem::take(&mut v_units);
1885819047 } else {
1885919048 u_grid = read_inter_plane(
1886019049 dec,
@@ -19224,6 +19413,11 @@ fn decode_inter_block(
1922419413 // interval narrowing, not a wrong value (class
1922519414 // wrong-alphabet-same-value).
1922619415 let bsize_idx = match (write_w, write_h) {
19416+ // lane-sb128c r5: the 128 root's own rows come FIRST --
19417+ // the square arm below maps 128 to row 4 (BLOCK_16X32).
19418+ (64, 128) => 14,
19419+ (128, 64) => 15,
19420+ (128, 128) => 16,
1922719421 (w, h) if w == h => (w.trailing_zeros() - 3) as usize,
1922819422 (16, 32) => 4,
1922919423 (32, 16) => 5,
@@ -19791,6 +19985,11 @@ fn decode_inter_block(
1979119985 _ => around,
1979219986 };
1979319987 let luma_tx_type;
19988+ // lane-sb128c r1: a 128x128 inter block's four chroma units
19989+ // are read INSIDE the luma leaf loop (one per 64x64 mu chunk);
19990+ // these collect them for the block-level neighbour write-back.
19991+ let mut u_units = vec![0i32; chroma_side * chroma_side];
19992+ let mut v_units = vec![0i32; chroma_side * chroma_side];
1979419993 if let Some(leaves) = vartx_leaves.clone() {
1979519994 // spec 5.11.17's transform tree, leaf by leaf in the order
1979619995 // `read_var_tx_size` coded it: each unit reads its own
@@ -19809,7 +20008,7 @@ fn decode_inter_block(
1980920008 let start = (row * MI + rr) * side + col * MI;
1981020009 tu_pred.extend_from_slice(&pred_y[start..start + tx_px]);
1981120010 }
19812- let scan = default_scan(tx_px);
20011+ let scan = default_scan(tx_px.min(32));
1981320012 let tu_skip_ctx = neighbours.luma_skip_ctx(tu_mi, tx_px / MI);
1981420013 read_inter_plane(
1981520014 dec,
@@ -19861,6 +20060,79 @@ fn decode_inter_block(
1986120060 first_tx_type = tu_tx_type;
1986220061 }
1986320062 neighbours.record_mi_luma_rect(tu_mi, tw, th, &tu_grid);
20063+ // lane-sb128c r1: libaom's `decode_token_recon_block`
20064+ // walks 64x64 "mu" chunks (`mu_blocks_wide/high =
20065+ // mi_size_wide[BLOCK_64X64]`) and codes EVERY PLANE of
20066+ // a chunk before the next one, so a 128x128 block
20067+ // interleaves Y,U,V per quadrant -- the same order the
20068+ // intra 128 path reads (lane-sb128b r3, measured
20069+ // against aomdec's `EC_TRACE_COEFF`). Below 128 a block
20070+ // is a single chunk and this never fires.
20071+ if side > 64 {
20072+ let chunk = (row / 16, col / 16);
20073+ let done = idx + 1 == leaves.len()
20074+ || (leaves[idx + 1].0 / 16, leaves[idx + 1].1 / 16) != chunk;
20075+ if done {
20076+ let (cr, cc) = chunk;
20077+ // `av1_get_max_uv_txsize(BLOCK_128X128)` =
20078+ // `av1_get_adjusted_tx_size(TX_64X64)` =
20079+ // TX_32X32: one 32x32 chroma unit per chunk.
20080+ let cu_tx = 32usize;
20081+ let luma_span = cu_tx * 2;
20082+ let cu_mi = (at_mi.0 + cr * 16, at_mi.1 + cc * 16);
20083+ let cu_around = neighbours.around_mi(cu_mi, luma_span);
20084+ let (cu_x, cu_y) = (cpx + cc * cu_tx, cpy + cr * cu_tx);
20085+ let cu_scan = default_scan(cu_tx);
20086+ for plane_idx in 1..3 {
20087+ let (src, buf) = if plane_idx == 1 {
20088+ (&pred_u, &mut *u)
20089+ } else {
20090+ (&pred_v, &mut *v)
20091+ };
20092+ let mut cu_pred = Vec::with_capacity(cu_tx * cu_tx);
20093+ for rr in 0..cu_tx {
20094+ let start =
20095+ (cr * cu_tx + rr) * chroma_side + cc * cu_tx;
20096+ cu_pred.extend_from_slice(&src[start..start + cu_tx]);
20097+ }
20098+ let cu_grid = read_inter_plane(
20099+ dec,
20100+ cdfs,
20101+ chroma_set,
20102+ &cu_scan,
20103+ plane_idx,
20104+ cu_around[plane_idx],
20105+ mode_for_tx,
20106+ buf,
20107+ cu_x,
20108+ cu_y,
20109+ cu_tx,
20110+ base_q_idx,
20111+ &cu_pred,
20112+ Some(first_tx_type),
20113+ Some(3),
20114+ )?
20115+ .0;
20116+ // Immediately, so the NEXT chunk's unit
20117+ // reads this one's coefficient context.
20118+ neighbours.record_mi_chroma(
20119+ cu_mi, luma_span, luma_span, plane_idx, &cu_grid,
20120+ );
20121+ CHROMA_SPLIT_TX_HITS.with(|c| c.set(c.get() + 1));
20122+ let dst = if plane_idx == 1 {
20123+ &mut u_units
20124+ } else {
20125+ &mut v_units
20126+ };
20127+ for rr in 0..cu_tx {
20128+ let start =
20129+ (cr * cu_tx + rr) * chroma_side + cc * cu_tx;
20130+ dst[start..start + cu_tx]
20131+ .copy_from_slice(&cu_grid[rr * cu_tx..][..cu_tx]);
20132+ }
20133+ }
20134+ }
20135+ }
1986420136 }
1986520137 // `av1_get_tx_type`'s chroma lookup scales the chroma
1986620138 // position back to luma, so an inter block's chroma
@@ -19966,6 +20238,10 @@ fn decode_inter_block(
1996620238 uh,
1996720239 chroma_side,
1996820240 );
20241+ } else if side > 64 {
20242+ // Already read inside the mu-chunk loop above.
20243+ u_grid = std::mem::take(&mut u_units);
20244+ v_grid = std::mem::take(&mut v_units);
1996920245 } else {
1997020246 u_grid = read_inter_plane(
1997120247 dec,
@@ -20257,9 +20533,16 @@ fn decode_inter_block(
2025720533 .1;
2025820534 let reach = Reach::of(side, px, py, y.width, y.height);
2025920535 let split_luma = vartx_leaves.is_some();
20536+ // lane-sb128c r3: a 128x128 INTRA block inside an inter frame codes
20537+ // its chroma per 64x64 mu chunk, exactly as the inter half above --
20538+ // `decode_token_recon_block` walks `mu_blocks_wide/high` and codes
20539+ // every plane of a chunk before the next chunk's luma. These collect
20540+ // the four TX_32X32 units per plane for the block-level write-back.
20541+ let mut u_units = vec![0i32; chroma_side * chroma_side];
20542+ let mut v_units = vec![0i32; chroma_side * chroma_side];
2026020543 if let Some(leaves) = vartx_leaves.clone() {
2026120544 let reduced = REDUCED_TX_SET_INTER.with(std::cell::Cell::get);
20262- for &(row, col, tx_px, _) in &leaves {
20545+ for (idx, &(row, col, tx_px, _)) in leaves.iter().enumerate() {
2026320546 let tu_mi = (at_mi.0 + row, at_mi.1 + col);
2026420547 let (tu_px, tu_py) = (px + col * MI, py + row * MI);
2026520548 // A transform unit inside a block is not a block at that
@@ -20290,7 +20573,11 @@ fn decode_inter_block(
2029020573 dec,
2029120574 cdfs,
2029220575 txbset_for(tx_px, reduced),
20293- &default_scan(tx_px),
20576+ // lane-sb128c r5: a TX_64X64 unit codes only its
20577+ // top-left 32x32 of frequencies (spec 5.11.40), so
20578+ // the scan and `tx_side` are the CODED corner while
20579+ // `side` stays the transform's true 64.
20580+ &default_scan(tx_px.min(32)),
2029420581 0,
2029520582 neighbours.around_mi(tu_mi, tx_px)[0],
2029620583 mode,
@@ -20301,7 +20588,7 @@ fn decode_inter_block(
2030120588 tu_px,
2030220589 tu_py,
2030320590 tx_px,
20304- tx_px,
20591+ tx_px.min(32),
2030520592 base_q_idx,
2030620593 None,
2030720594 filter_intra,
@@ -20310,9 +20597,96 @@ fn decode_inter_block(
2031020597 )?
2031120598 };
2031220599 neighbours.record_mi_luma(tu_mi, tx_px, &tu_grid);
20600+ if side > 64 {
20601+ let chunk = (row / 16, col / 16);
20602+ let done = idx + 1 == leaves.len()
20603+ || (leaves[idx + 1].0 / 16, leaves[idx + 1].1 / 16) != chunk;
20604+ if !done {
20605+ continue;
20606+ }
20607+ let (cr, cc) = chunk;
20608+ // `av1_get_max_uv_txsize(BLOCK_128X128)` =
20609+ // `av1_get_adjusted_tx_size(TX_64X64)` = TX_32X32.
20610+ let cu_tx = 32usize;
20611+ let luma_span = cu_tx * 2;
20612+ let cu_mi = (at_mi.0 + cr * 16, at_mi.1 + cc * 16);
20613+ let cu_around = neighbours.around_mi(cu_mi, luma_span);
20614+ let (cu_x, cu_y) = (cpx + cc * cu_tx, cpy + cr * cu_tx);
20615+ let cu_reach = crate::decode::tu_reach(
20616+ side, side,
20617+ cc * luma_span, cr * luma_span, luma_span,
20618+ reach, px, py, y.width, y.height,
20619+ );
20620+ let cu_scan = default_scan(cu_tx);
20621+ for plane_idx in 1..3 {
20622+ let buf: &mut PlaneBuf = if plane_idx == 1 { &mut *u } else { &mut *v };
20623+ let cu_grid = if skip {
20624+ buf.reconstruct(
20625+ cu_x,
20626+ cu_y,
20627+ cu_tx,
20628+ uv_predict_mode,
20629+ angle_delta_uv,
20630+ cu_reach,
20631+ &vec![0i32; cu_tx * cu_tx],
20632+ None,
20633+ None,
20634+ smooth_neighbor_uv,
20635+ );
20636+ vec![0i32; cu_tx * cu_tx]
20637+ } else {
20638+ read_plane(
20639+ dec,
20640+ cdfs,
20641+ chroma_set,
20642+ &cu_scan,
20643+ plane_idx,
20644+ cu_around[plane_idx],
20645+ mode,
20646+ uv_predict_mode,
20647+ angle_delta_uv,
20648+ cu_reach,
20649+ buf,
20650+ cu_x,
20651+ cu_y,
20652+ cu_tx,
20653+ cu_tx,
20654+ base_q_idx,
20655+ // CfL is refused above 32x32
20656+ // (`is_cfl_allowed`), so never here.
20657+ None,
20658+ None,
20659+ // The uv plane block (64x64) is larger than
20660+ // the unit (32x32): `get_txb_ctx`'s offset-10
20661+ // rows, +3 on the `txb_skip_chroma_32` table
20662+ // (lane-sb128b r3).
20663+ Some(3),
20664+ smooth_neighbor_uv,
20665+ )?
20666+ };
20667+ // Immediately, so the NEXT chunk's unit reads this
20668+ // one's coefficient context.
20669+ neighbours.record_mi_chroma(
20670+ cu_mi, luma_span, luma_span, plane_idx, &cu_grid,
20671+ );
20672+ CHROMA_SPLIT_TX_HITS.with(|c| c.set(c.get() + 1));
20673+ let dst = if plane_idx == 1 { &mut u_units } else { &mut v_units };
20674+ for rr in 0..cu_tx {
20675+ let start = (cr * cu_tx + rr) * chroma_side + cc * cu_tx;
20676+ dst[start..start + cu_tx]
20677+ .copy_from_slice(&cu_grid[rr * cu_tx..][..cu_tx]);
20678+ }
20679+ }
20680+ }
2031320681 }
2031420682 }
20315- if skip {
20683+ if side > 64 {
20684+ // Chroma is already coded and reconstructed per mu chunk above.
20685+ luma_grid = vec![0i32; side * side];
20686+ u_grid = std::mem::take(&mut u_units);
20687+ v_grid = std::mem::take(&mut v_units);
20688+ INTRA_128_IN_INTER_HITS.with(|c| c.set(c.get() + 1));
20689+ } else if skip {
2031620690 if !split_luma {
2031720691 y.reconstruct(
2031820692 px,
@@ -20535,7 +20909,23 @@ fn decode_inter_block(
2053520909 // units, not the block -- for LUMA only (lane-golomb r6): the chroma
2053620910 // grids keep the block's own `av1_get_max_uv_txsize`, which is what
2053720911 // libaom's `get_transform_size` reads for `plane != AOM_PLANE_Y`.
20538- if let Some(leaves) = &vartx_leaves {
20912+ // lane-sb128c r4: libaom `set_one_param_for_line_luma` suppresses every
20913+ // edge that is a TU edge but not a PU edge when
20914+ // `curr_skipped = mbmi->skip_txfm && is_inter_block(mbmi)`, so a SKIP
20915+ // inter block's internal transform edges are never filtered even though
20916+ // `get_transform_size` still reports TX_64X64 for it. The only block that
20917+ // reaches here skipped is the 128 root (`read_block_tx_size` hands back
20918+ // four TX_64X64 leaves for `side > 64` regardless of `skip`); leaving its
20919+ // block-level 128 publication in place is exactly that suppression.
20920+ // lane-sb128c r6: narrowed to the 128 root. Below it `read_block_tx_size`
20921+ // hands a skipped inter block a single leaf equal to the block, so the
20922+ // per-leaf write is the block-level one and this branch is a no-op either
20923+ // way; only the 128 root gets four TX_64X64 leaves regardless of `skip`.
20924+ let skip_inter_128 = skip && is_inter && write_w.max(write_h) > 64;
20925+ if skip_inter_128 {
20926+ neighbours.suppress_internal_lf_edges((rmi, cmi), write_w / MI, write_h / MI);
20927+ }
20928+ if let Some(leaves) = (!skip_inter_128).then_some(()).and(vartx_leaves.as_ref()) {
2053920929 for &(row, col, tw, th) in leaves {
2054020930 // lane-r14's RECT leaf dims through lane-golomb r6's luma-only
2054120931 // writer: fill_lf_grid_rect would recompute CHROMA tx dims from
@@ -23686,10 +24076,21 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
2368624076 // loop does; the 64-level body below is unchanged, `read_cdef`'s
2368724077 // per-64x64-quadrant reset (`CDEF_TRANSMITTED`) already matches libaom's
2368824078 // `cdef_idx[(mi_row & 16) >> 4 * 2 + (mi_col & 16) >> 4]` slot per quadrant.
24079+ // lane-sb128c r1: set when the 128 root resolved to `PARTITION_NONE` -- its
24080+ // one 128x128 inter block covers all four 64x64 quadrants, so the remaining
24081+ // three items of this superblock carry no syntax at all (same skip the
24082+ // key-frame tile loop runs).
24083+ let mut sb128_none = false;
2368924084 for (sb_r, sb_c, row_start, sb_start) in sb_visit_order(sb_r0, sb_r1, sb_c0, sb_c1, sb128) {
2369024085 if row_start {
2369124086 neighbours.start_row();
2369224087 }
24088+ if sb_start {
24089+ sb128_none = false;
24090+ }
24091+ if sb128_none {
24092+ continue;
24093+ }
2369324094 {
2369424095 if sb128 && sb_start {
2369524096 if read_sb128_root(
@@ -23703,14 +24104,15 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
2370324104 sb_c,
2370424105 mi_cols,
2370524106 mi_rows,
23706- )? != PARTITION_SPLIT
24107+ )? == PARTITION_NONE
2370724108 {
23708- // lane-sb128b r1 decodes a `PARTITION_NONE` 128 root on
23709- // KEY frames only; an inter 128x128 leaf needs whole-block
23710- // MC, OBMC and compound at a size this path has never run.
23711- return Err(unsupported(
23712- "a 128x128 superblock PARTITION_NONE root on an inter frame (only the key-frame path codes a whole 128x128 block)",
23713- ));
24109+ // One 128x128 inter block. Its luma transform is
24110+ // `max_txsize_rect_lookup[BLOCK_128X128]` = TX_64X64 (four
24111+ // units, read as var-tx leaves), its uv plane block is
24112+ // 64x64 with TX_32X32 units (`av1_get_max_uv_txsize`), and
24113+ // `size_group_lookup[BLOCK_128X128]` is 3, same as 64x64.
24114+ sb128_none = true;
24115+ CDEF_TRANSMITTED.with(|c| c.set(false));
2371424116 }
2371524117 }
2371624118 if !sb128 {
@@ -23777,7 +24179,12 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
2377724179 skip_mode_frame,
2377824180 switchable_motion_mode,
2377924181 allow_warped_motion,
23780- true,
24182+ // lane-sb128c r3: `reject_residual` is about a
24183+ // RECTANGULAR strip decoded with square dimensions --
24184+ // the 128x128 NONE root is square, and a hardcoded
24185+ // `true` refused every one of them at its first
24186+ // non-skip block.
24187+ $ww != $side || $wh != $side,
2378124188 $ww,
2378224189 $wh,
2378324190 allow_screen_content_tools,
@@ -23862,6 +24269,37 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
2386224269 }
2386324270 }};
2386424271 }
24272+ if sb128_none {
24273+ INTER_SB128_NONE_HITS.with(|c| c.set(c.get() + 1));
24274+ let at128 = ((sb_r & !1) as usize * 4, (sb_c & !1) as usize * 4);
24275+ // lane-sb128c r3: `at128` is in SUB16 units like `sb_at`;
24276+ // `decode_inter_block` takes MI. Unconverted it was (0,0) for
24277+ // the first 128 root and a quarter-position for every other
24278+ // one -- the whole-frame gate never got past superblock 1.
24279+ inter_piece!(
24280+ sub16_to_mi(at128), SB * 2,
24281+ TxbSet::Luma64, TxbSet::Luma64, TxbSet::Chroma32, TX32, TX32,
24282+ &scan32, &scan32, 3, SB * 2, SB * 2
24283+ );
24284+ // libaom writes one `cdef_strength` into the block's own
24285+ // `MB_MODE_INFO`, which all four 64x64 CDEF units point at
24286+ // (mirrors the key-frame 128 NONE block).
24287+ let (q_r, q_c) = ((sb_r & !1) as usize, (sb_c & !1) as usize);
24288+ CDEF_IDX_GRID.with(|g| {
24289+ let mut g = g.borrow_mut();
24290+ let cols = CDEF_SB_COLS.with(|c| c.get());
24291+ if cols > 0 && q_r * cols + q_c < g.len() {
24292+ let idx = g[q_r * cols + q_c];
24293+ for (dr, dc) in [(0, 1), (1, 0), (1, 1)] {
24294+ let i = (q_r + dr) * cols + q_c + dc;
24295+ if q_c + dc < cols && i < g.len() {
24296+ g[i] = idx;
24297+ }
24298+ }
24299+ }
24300+ });
24301+ continue;
24302+ }
2386524303 let sb_ctx = neighbours.partition_ctx(sb_at, SB);
2386624304 let (has_cols, has_rows) = (
2386724305 sb_c * SB_MI + SB_MI / 2 < mi_cols,
crates/ec-av1/src/mvstack.rsmodified+32 -2
@@ -631,6 +631,26 @@ fn scan_col(
631631 found
632632 }
633633
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+
634654 /// libaom `has_top_right` (mvref_common.c:264): whether the unit diagonally
635655 /// above-right of this block has been decoded *by the superblock's own
636656 /// recursion order*. The mask is `sb_size`-relative, so at a 128x128
@@ -875,7 +895,12 @@ pub fn find_mv_stack_with_sign_bias(
875895 &mut newmv_count,
876896 &mut processed_cols,
877897 );
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(
879904 grid,
880905 mi_row,
881906 mi_col,
@@ -1668,7 +1693,12 @@ pub fn find_mv_stack_compound(
16681693 &mut newmv_count,
16691694 &mut processed_cols,
16701695 );
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(
16721702 grid,
16731703 mi_row,
16741704 mi_col,
crates/ec-av1/src/refusal_inventory.rsmodified+0 -1
@@ -47,7 +47,6 @@ const REFUSALS: &[&str] = &[
4747 "an INTER 32x32 partition type this decoder does not code (value={part32})",
4848 "a superblock-level partition value outside PARTITION_NONE..PARTITION_VERT_4",
4949 "a 128x128 superblock HORZ/VERT or AB partition (only SPLIT and NONE are decoded at the 128 root)",
50- "a 128x128 superblock PARTITION_NONE root on an inter frame (only the key-frame path codes a whole 128x128 block)",
5150 "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)",
5251 "a palette block with a real transform on a superblock-level HORZ/VERT strip (corner-cropped luma coefficients not ported for palette)",
5352 "a block that actually uses a palette (UV) -- reconstruction is out of scope",
crates/ec-av1/src/stream.rsmodified+171 -0
@@ -21968,6 +21968,177 @@ mod tests {
2196821968 }
2196921969 }
2197021970
21971+ /// lane-sb128c r1: an INTER frame whose 128x128 superblock root really
21972+ /// resolves `PARTITION_NONE` -- one whole 128x128 inter block, the shape
21973+ /// ReelC's first inter frame stops this decoder on. r1 wired it: four
21974+ /// TX_64X64 luma units (`max_txsize_rect_lookup[BLOCK_128X128]`), four
21975+ /// TX_32X32 chroma units (`av1_get_max_uv_txsize`), interleaved Y,U,V per
21976+ /// 64x64 "mu" chunk (libaom `decode_token_recon_block`) with the chroma
21977+ /// `txb_skip_ctx` offset-10 rows, and OBMC's overlap capped at a 64x64
21978+ /// block's half (`reconinter.c` 860/899).
21979+ ///
21980+ /// `--max-partition-size=128` is what lets the root be NONE at all (the
21981+ /// sibling gate above pins 64, so its roots always SPLIT). Every arm hard
21982+ /// asserts its own `inter_sb128_none_hits` delta, so a recipe that stops
21983+ /// choosing the shape fails instead of passing vacuously; every decode
21984+ /// order frame is compared by [`decode_all_frames_vs_oracle`], which
21985+ /// panics on a refusal or any differing byte. Arms: 8-bit and 10-bit (his
21986+ /// films are 10-bit) with `tx-size-search=0` (TX_MODE_LARGEST, the block's
21987+ /// four TX_64X64 units come straight from `max_txsize_rect_lookup`) and an
21988+ /// 8-bit `tx-size-search=1` arm (the var-tx tree at 128).
21989+ // lane-sb128c r3: green. `--min-partition-size=32` let the RD search reach
21990+ // 16x16-level AB / SB-level AB shapes that other lanes still refuse (two of
21991+ // the three arms stopped there, measured); at 64 every arm decodes and the
21992+ // 128 root still resolves NONE.
21993+ #[test]
21994+ fn a_real_aomenc_inter_128x128_none_root_decodes_pixel_exact() {
21995+ const NAME: &str = "a_real_aomenc_inter_128x128_none_root_decodes_pixel_exact";
21996+ let _gate_lock = lock_gate_counters();
21997+ if !have_ffmpeg() || !have_aomenc() {
21998+ eprintln!("SKIP {NAME}: no ffmpeg/aomenc/aomdec");
21999+ return;
22000+ }
22001+ let (width, height) = (256usize, 256usize);
22002+ let mut intra128_total = 0usize;
22003+ for (ten_bit, tx_search, seed) in [(false, false, 61u32), (true, false, 61), (false, true, 62)] {
22004+ let pix = if ten_bit { "yuv420p10le" } else { "yuv420p" };
22005+ let y4m = Command::new("ffmpeg")
22006+ .args([
22007+ "-v",
22008+ "error",
22009+ "-f",
22010+ "lavfi",
22011+ "-i",
22012+ &format!(
22013+ "{},noise=all_seed={seed}:alls=6:allf=t",
22014+ gradients_source(seed, width, height, "duration=0.32:rate=25")
22015+ ),
22016+ "-pix_fmt",
22017+ pix,
22018+ "-strict",
22019+ "-1",
22020+ "-t",
22021+ "0.32",
22022+ "-f",
22023+ "yuv4mpegpipe",
22024+ "-",
22025+ ])
22026+ .stdin(Stdio::null())
22027+ .stdout(Stdio::piped())
22028+ .stderr(Stdio::piped())
22029+ .output()
22030+ .expect("ffmpeg failed to run");
22031+ assert!(
22032+ y4m.status.success(),
22033+ "{NAME}: ffmpeg fixture: {}",
22034+ String::from_utf8_lossy(&y4m.stderr)
22035+ );
22036+ let mut args: Vec<&str> = vec![
22037+ "--codec=av1",
22038+ "--passes=1",
22039+ "--end-usage=q",
22040+ "--cq-level=62",
22041+ "--cpu-used=0",
22042+ "--threads=1",
22043+ "--row-mt=0",
22044+ "--sb-size=128",
22045+ "--max-partition-size=128",
22046+ "--min-partition-size=64",
22047+ "--enable-rect-partitions=0",
22048+ "--enable-ab-partitions=0",
22049+ "--enable-1to4-partitions=0",
22050+ "--enable-palette=0",
22051+ "--enable-intrabc=0",
22052+ "--deltaq-mode=0",
22053+ "--limit=8",
22054+ ];
22055+ // Spelled ONCE per invocation (a repeated `--enable-*` keeps its
22056+ // LAST occurrence, measured 2026-09-02).
22057+ args.push(if tx_search {
22058+ "--enable-tx-size-search=1"
22059+ } else {
22060+ "--enable-tx-size-search=0"
22061+ });
22062+ if ten_bit {
22063+ args.extend_from_slice(&["--input-bit-depth=10", "--bit-depth=10"]);
22064+ }
22065+ args.extend_from_slice(&["--obu", "-o", "-", "-"]);
22066+ let mut child = Command::new(aomenc_path())
22067+ .args(&args)
22068+ .stdin(Stdio::piped())
22069+ .stdout(Stdio::piped())
22070+ .stderr(Stdio::piped())
22071+ .spawn()
22072+ .expect("aomenc failed to start");
22073+ child
22074+ .stdin
22075+ .take()
22076+ .expect("aomenc stdin")
22077+ .write_all(&y4m.stdout)
22078+ .expect("writing y4m to aomenc");
22079+ let out = child.wait_with_output().expect("aomenc failed to run");
22080+ assert!(
22081+ out.status.success(),
22082+ "{NAME}: aomenc refused the fixture: {}",
22083+ String::from_utf8_lossy(&out.stderr)
22084+ );
22085+ let stream = out.stdout;
22086+ let header = {
22087+ let mut parser = ec_av1_syntax::Av1Parser::new();
22088+ let mut pos = 0usize;
22089+ while let Ok(obu) = parser.parse_obu(&stream[pos..]) {
22090+ pos += obu.total_size;
22091+ if pos >= stream.len() {
22092+ break;
22093+ }
22094+ }
22095+ parser
22096+ .sequence_header()
22097+ .map(|q| (q.use_128x128_superblock, q.color_config.bit_depth))
22098+ };
22099+ assert_eq!(
22100+ header,
22101+ Some((true, if ten_bit { 10 } else { 8 })),
22102+ "{NAME}: the encoder did not write a 128x128-superblock sequence header at \
22103+ the requested bit depth -- the flag never arrived"
22104+ );
22105+ let before = (
22106+ crate::decode::inter_sb128_none_hits(),
22107+ crate::decode::chroma_split_tx_hits(),
22108+ crate::decode::intra_128_in_inter_hits(),
22109+ );
22110+ let (frames, hidden) = decode_all_frames_vs_oracle(
22111+ &stream,
22112+ &format!("sb128c-inter-none-{}-{}", if ten_bit { 10 } else { 8 }, tx_search),
22113+ );
22114+ let (none128, chroma_units, intra128) = (
22115+ crate::decode::inter_sb128_none_hits() - before.0,
22116+ crate::decode::chroma_split_tx_hits() - before.1,
22117+ crate::decode::intra_128_in_inter_hits() - before.2,
22118+ );
22119+ intra128_total += intra128;
22120+ assert!(
22121+ frames >= 6,
22122+ "{NAME} ({pix} tx_search={tx_search}): only {frames} decode-order frames"
22123+ );
22124+ assert!(
22125+ none128 >= 1,
22126+ "{NAME} ({pix} tx_search={tx_search}): no 128x128 PARTITION_NONE root on an \
22127+ inter frame -- the recipe stopped exercising the shape this gate names"
22128+ );
22129+ eprintln!(
22130+ "{NAME} ({pix} tx_search={tx_search}): {frames} decode-order frames pixel-exact \
22131+ ({hidden} hidden), inter_sb128_none_hits={none128} chroma_units={chroma_units} \
22132+ intra_128_in_inter={intra128}"
22133+ );
22134+ }
22135+ assert!(
22136+ intra128_total >= 1,
22137+ "{NAME}: no INTRA-coded 128x128 block inside an inter frame across the three arms -- \
22138+ the refusal this round lifted is no longer exercised"
22139+ );
22140+ }
22141+
2197122142 /// lane-sbpart r2: a real `aomenc` stream whose superblock-level
2197222143 /// partition decision is genuinely HORZ/VERT (not NONE/SPLIT) must
2197322144 /// 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.