forge
Explore
Log in

Don't you dare go Hollow

Decode a 128x128 PARTITION_NONE root on the INTER path (gate still red)

Browse files at this commit

bc895cb0962ca874d263731e05261eb66fac5552Ahmet Kaan GümüşParent: d685b04
  • feat
    • decode a 128x128 PARTITION_NONE root on the INTER path (gate still red)
Show full message
feat(av1): decode a 128x128 PARTITION_NONE root on the INTER path (gate still red)

The inter tile loop now codes one whole 128x128 inter block instead of refusing
it: four TX_64X64 luma units (max_txsize_rect_lookup[BLOCK_128X128]) whether the
tx mode is SELECT or LARGEST, four TX_32X32 chroma units (av1_get_max_uv_txsize)
read INSIDE the luma leaf loop one per 64x64 mu chunk (libaom
decode_token_recon_block codes every plane of a chunk before the next), the
chroma txb_skip offset-10 rows, cdef_idx replicated over the block's four
quadrants, and OBMC's overlap capped at min(block, 64)/2 (reconinter.c:860/899)
-- without that cap obmc_mask(64) panicked, which is the first thing ReelC hit.

ReelC's 2 s head now stops at "a 128x128 superblock HORZ/VERT or AB partition"
instead of "a 128x128 superblock PARTITION_NONE root on an inter frame".

The new gate a_real_aomenc_inter_128x128_none_root_decodes_pixel_exact is
#[ignore]d and RED: the recipe fires four partition_w128 value=0 roots and the
key frame decodes alone, but the 8-frame stream refuses at a 32x64 intra strip
--enable-rect-partitions=0 forbids, i.e. our own desync. lanes/sb128c-r1.report.md
has the triage and r2's ladder.
crates/ec-av1/src/decode.rsmodified+267 -13
@@ -1901,6 +1901,17 @@ pub(crate) fn rect_partition_hits() -> usize {
19011901 // lane-inter8 r1: how many superblocks an inter tile coded as a single
19021902 // whole-SB `PARTITION_NONE` 64x64 inter block (the case aomenc picks for
19031903 // static content, previously a named refusal).
1904+thread_local! {
1905+ /// lane-sb128c r1: how many 128x128 `PARTITION_NONE` roots this INTER tile
1906+ /// path decoded as one whole block (its gate's own witness).
1907+ pub(crate) static INTER_SB128_NONE_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
1908+}
1909+
1910+/// Current value of [`INTER_SB128_NONE_HITS`], for a gate's before/after delta.
1911+pub fn inter_sb128_none_hits() -> usize {
1912+ INTER_SB128_NONE_HITS.with(std::cell::Cell::get)
1913+}
1914+
19041915 thread_local! {
19051916 static INTER_SB_NONE_HITS: std::cell::Cell<usize> =
19061917 const { std::cell::Cell::new(0) };
@@ -11460,6 +11471,19 @@ fn read_block_tx_size(
1146011471 skip: bool,
1146111472 ) -> Result<(usize, Option<Vec<(usize, usize, usize)>>)> {
1146211473 if !TX_SELECT_INTER.with(std::cell::Cell::get) {
11474+ // lane-sb128c r1: `max_txsize_rect_lookup[BLOCK_128X128]` is TX_64X64,
11475+ // so a 128x128 inter block is FOUR luma units even with `tx_mode ==
11476+ // TX_MODE_LARGEST` -- the same leaf shape the var-tx tree hands back.
11477+ if is_inter && side > 64 {
11478+ let step = 64 / MI;
11479+ let mut leaves = Vec::new();
11480+ for row in (0..side / MI).step_by(step) {
11481+ for col in (0..side / MI).step_by(step) {
11482+ leaves.push((row, col, 64));
11483+ }
11484+ }
11485+ return Ok((64, Some(leaves)));
11486+ }
1146311487 return Ok((side, None));
1146411488 }
1146511489 let side_mi = side / MI;
@@ -11487,7 +11511,7 @@ fn read_block_tx_size(
1148711511 }
1148811512 }
1148911513 let single = leaves.len() == 1 && leaves[0].2 == side;
11490- if !single && leaves.iter().any(|leaf| leaf.2 > 32) {
11514+ if !single && leaves.iter().any(|leaf| leaf.2 > 64) {
1149111515 // Only a block wider than a superblock's own 64x64 max transform
1149211516 // reaches here; this crate has no 64-point *inter* coefficient
1149311517 // table set ([`inter_txbset_for`] stops at 32).
@@ -11960,6 +11984,12 @@ fn read_inter_luma8(
1196011984 /// coefficient tables from -- the inter counterpart of [`txbset_for`].
1196111985 fn inter_txbset_for(tx_px: usize, reduced_tx_set: bool) -> TxbSet {
1196211986 match tx_px {
11987+ // lane-sb128c r1: a 128x128 inter block's own luma unit
11988+ // (`max_txsize_rect_lookup[BLOCK_128X128] == TX_64X64`).
11989+ // `av1_get_ext_tx_set_type` is `DCT_ONLY` at `tx_size_sqr_up ==
11990+ // TX_64X64`, so no `tx_type` symbol is coded and the intra/inter sets
11991+ // coincide -- exactly the set the whole-64x64 inter block already uses.
11992+ 64 => TxbSet::Luma64,
1196311993 32 => TxbSet::Luma32Inter,
1196411994 16 if reduced_tx_set => TxbSet::Luma16Inter,
1196511995 16 => TxbSet::Luma16InterSet1,
@@ -15109,7 +15139,13 @@ fn read_inter_plane(
1510915139 let skip_ctx = if plane_idx == 0 {
1511015140 luma_skip_ctx.unwrap_or(0)
1511115141 } else {
15112- usize::from(around.0) + usize::from(around.1)
15142+ // lane-sb128c r1: on a CHROMA plane this same parameter carries
15143+ // `get_txb_ctx`'s own offset instead -- `combine_entropy_contexts(..)`
15144+ // is +7 normally and +10 when the plane block is LARGER than the
15145+ // transform (a 128x128 block's 64x64 uv plane block with TX_32X32
15146+ // units, AV1's only such case), and the `txb_skip_chroma_32` table
15147+ // carries the offset-10 rows at +3 (lane-sb128b r3).
15148+ usize::from(around.0) + usize::from(around.1) + luma_skip_ctx.unwrap_or(0)
1511315149 };
1511415150 let mut coding = cdfs.txb(set, tx_mode);
1511515151 let default_tx_type = match inherited_luma_tx_type {
@@ -15777,8 +15813,13 @@ fn obmc_blend(
1577715813 if matches!((write_w, write_h), (16, 8) | (8, 16)) {
1577815814 OBMC_RECT_LEAF_HITS.with(|c| c.set(c.get() + 1));
1577915815 }
15780- let overlap_above = write_h / 2;
15781- let overlap_left = write_w / 2;
15816+ // lane-sb128c r1: libaom caps the overlap strip at a 64x64 block's own
15817+ // half (`reconinter.c` 860/899: `AOMMIN(block_size_high[bsize],
15818+ // block_size_high[BLOCK_64X64]) >> 1`, and the `block_size_wide` mirror) --
15819+ // inert below 128, where a 128x128 block would otherwise blend a 64-row
15820+ // strip `obmc_mask` has no table for.
15821+ let overlap_above = write_h.min(64) / 2;
15822+ let overlap_left = write_w.min(64) / 2;
1578215823 // lane-inter8 r1 / lane-scaledref r1: `av1_skip_u4x4_pred_in_obmc`
1578315824 // (`reconinter.c` 820, `DISABLE_CHROMA_U8X8_OBMC == 0` -- "one-sided
1578415825 // obmc") returns `dir == 0` when the chroma plane's own block is
@@ -16346,6 +16387,16 @@ fn decode_inter_block(
1634616387 let (above_inter, left_inter) = (neighbours.above_inter[cmi], neighbours.left_inter[rmi]);
1634716388 let ii_ctx = intra_inter_ctx(has_above, has_left, above_inter, left_inter);
1634816389 let is_inter = skip_mode || dec.symbol(&mut cdfs.intra_inter[ii_ctx]) == 1;
16390+ // lane-sb128c r1: this round wires the INTER half of a 128x128 block (four
16391+ // TX_64X64 luma units and four TX_32X32 chroma units interleaved per mu
16392+ // chunk). An INTRA block at that size inside an inter frame takes the
16393+ // intra tail below, which still codes one whole-block chroma unit and one
16394+ // `read_tx_size` at 128 -- refuse by name instead of mis-decoding it.
16395+ if side > 64 && !is_inter {
16396+ return Err(unsupported(
16397+ "an INTRA-coded 128x128 block inside an inter frame (only the inter half of a 128x128 root is decoded here)",
16398+ ));
16399+ }
1634916400 if std::env::var_os("EC_TRACE_MODE").is_some() {
1635016401 eprintln!(
1635116402 "EC_MODE mi_row={} mi_col={} rng={}",
@@ -17246,6 +17297,11 @@ fn decode_inter_block(
1724617297 neighbours.around_mi(at, side)
1724717298 };
1724817299 let luma_tx_type;
17300+ // lane-sb128c r1: a 128x128 inter block's four chroma units
17301+ // are read INSIDE the luma leaf loop (one per 64x64 mu chunk);
17302+ // these collect them for the block-level neighbour write-back.
17303+ let mut u_units = vec![0i32; chroma_side * chroma_side];
17304+ let mut v_units = vec![0i32; chroma_side * chroma_side];
1724917305 if let Some(leaves) = vartx_leaves.clone() {
1725017306 // spec 5.11.17's transform tree, leaf by leaf in the order
1725117307 // `read_var_tx_size` coded it: each unit reads its own
@@ -17262,7 +17318,7 @@ fn decode_inter_block(
1726217318 let start = (row * MI + rr) * side + col * MI;
1726317319 tu_pred.extend_from_slice(&pred_y[start..start + tx_px]);
1726417320 }
17265- let scan = default_scan(tx_px);
17321+ let scan = default_scan(tx_px.min(32));
1726617322 let tu_skip_ctx = neighbours.luma_skip_ctx(tu_mi, tx_px / MI);
1726717323 let (tu_grid, tu_tx_type) = read_inter_plane(
1726817324 dec,
@@ -17285,6 +17341,79 @@ fn decode_inter_block(
1728517341 first_tx_type = tu_tx_type;
1728617342 }
1728717343 neighbours.record_mi_luma(tu_mi, tx_px, &tu_grid);
17344+ // lane-sb128c r1: libaom's `decode_token_recon_block`
17345+ // walks 64x64 "mu" chunks (`mu_blocks_wide/high =
17346+ // mi_size_wide[BLOCK_64X64]`) and codes EVERY PLANE of
17347+ // a chunk before the next one, so a 128x128 block
17348+ // interleaves Y,U,V per quadrant -- the same order the
17349+ // intra 128 path reads (lane-sb128b r3, measured
17350+ // against aomdec's `EC_TRACE_COEFF`). Below 128 a block
17351+ // is a single chunk and this never fires.
17352+ if side > 64 {
17353+ let chunk = (row / 16, col / 16);
17354+ let done = idx + 1 == leaves.len()
17355+ || (leaves[idx + 1].0 / 16, leaves[idx + 1].1 / 16) != chunk;
17356+ if done {
17357+ let (cr, cc) = chunk;
17358+ // `av1_get_max_uv_txsize(BLOCK_128X128)` =
17359+ // `av1_get_adjusted_tx_size(TX_64X64)` =
17360+ // TX_32X32: one 32x32 chroma unit per chunk.
17361+ let cu_tx = 32usize;
17362+ let luma_span = cu_tx * 2;
17363+ let cu_mi = (at_mi.0 + cr * 16, at_mi.1 + cc * 16);
17364+ let cu_around = neighbours.around_mi(cu_mi, luma_span);
17365+ let (cu_x, cu_y) = (cpx + cc * cu_tx, cpy + cr * cu_tx);
17366+ let cu_scan = default_scan(cu_tx);
17367+ for plane_idx in 1..3 {
17368+ let (src, buf) = if plane_idx == 1 {
17369+ (&pred_u, &mut *u)
17370+ } else {
17371+ (&pred_v, &mut *v)
17372+ };
17373+ let mut cu_pred = Vec::with_capacity(cu_tx * cu_tx);
17374+ for rr in 0..cu_tx {
17375+ let start =
17376+ (cr * cu_tx + rr) * chroma_side + cc * cu_tx;
17377+ cu_pred.extend_from_slice(&src[start..start + cu_tx]);
17378+ }
17379+ let cu_grid = read_inter_plane(
17380+ dec,
17381+ cdfs,
17382+ chroma_set,
17383+ &cu_scan,
17384+ plane_idx,
17385+ cu_around[plane_idx],
17386+ mode_for_tx,
17387+ buf,
17388+ cu_x,
17389+ cu_y,
17390+ cu_tx,
17391+ base_q_idx,
17392+ &cu_pred,
17393+ Some(first_tx_type),
17394+ Some(3),
17395+ )?
17396+ .0;
17397+ // Immediately, so the NEXT chunk's unit
17398+ // reads this one's coefficient context.
17399+ neighbours.record_mi_chroma(
17400+ cu_mi, luma_span, luma_span, plane_idx, &cu_grid,
17401+ );
17402+ CHROMA_SPLIT_TX_HITS.with(|c| c.set(c.get() + 1));
17403+ let dst = if plane_idx == 1 {
17404+ &mut u_units
17405+ } else {
17406+ &mut v_units
17407+ };
17408+ for rr in 0..cu_tx {
17409+ let start =
17410+ (cr * cu_tx + rr) * chroma_side + cc * cu_tx;
17411+ dst[start..start + cu_tx]
17412+ .copy_from_slice(&cu_grid[rr * cu_tx..][..cu_tx]);
17413+ }
17414+ }
17415+ }
17416+ }
1728817417 }
1728917418 // `av1_get_tx_type`'s chroma lookup scales the chroma
1729017419 // position back to luma, so an inter block's chroma
@@ -17378,6 +17507,10 @@ fn decode_inter_block(
1737817507 uh,
1737917508 chroma_side,
1738017509 );
17510+ } else if side > 64 {
17511+ // Already read inside the mu-chunk loop above.
17512+ u_grid = std::mem::take(&mut u_units);
17513+ v_grid = std::mem::take(&mut v_units);
1738117514 } else {
1738217515 u_grid = read_inter_plane(
1738317516 dec,
@@ -18224,6 +18357,11 @@ fn decode_inter_block(
1822418357 neighbours.around_mi(at, side)
1822518358 };
1822618359 let luma_tx_type;
18360+ // lane-sb128c r1: a 128x128 inter block's four chroma units
18361+ // are read INSIDE the luma leaf loop (one per 64x64 mu chunk);
18362+ // these collect them for the block-level neighbour write-back.
18363+ let mut u_units = vec![0i32; chroma_side * chroma_side];
18364+ let mut v_units = vec![0i32; chroma_side * chroma_side];
1822718365 if let Some(leaves) = vartx_leaves.clone() {
1822818366 // spec 5.11.17's transform tree, leaf by leaf in the order
1822918367 // `read_var_tx_size` coded it: each unit reads its own
@@ -18240,7 +18378,7 @@ fn decode_inter_block(
1824018378 let start = (row * MI + rr) * side + col * MI;
1824118379 tu_pred.extend_from_slice(&pred_y[start..start + tx_px]);
1824218380 }
18243- let scan = default_scan(tx_px);
18381+ let scan = default_scan(tx_px.min(32));
1824418382 let tu_skip_ctx = neighbours.luma_skip_ctx(tu_mi, tx_px / MI);
1824518383 let (tu_grid, tu_tx_type) = read_inter_plane(
1824618384 dec,
@@ -18263,6 +18401,79 @@ fn decode_inter_block(
1826318401 first_tx_type = tu_tx_type;
1826418402 }
1826518403 neighbours.record_mi_luma(tu_mi, tx_px, &tu_grid);
18404+ // lane-sb128c r1: libaom's `decode_token_recon_block`
18405+ // walks 64x64 "mu" chunks (`mu_blocks_wide/high =
18406+ // mi_size_wide[BLOCK_64X64]`) and codes EVERY PLANE of
18407+ // a chunk before the next one, so a 128x128 block
18408+ // interleaves Y,U,V per quadrant -- the same order the
18409+ // intra 128 path reads (lane-sb128b r3, measured
18410+ // against aomdec's `EC_TRACE_COEFF`). Below 128 a block
18411+ // is a single chunk and this never fires.
18412+ if side > 64 {
18413+ let chunk = (row / 16, col / 16);
18414+ let done = idx + 1 == leaves.len()
18415+ || (leaves[idx + 1].0 / 16, leaves[idx + 1].1 / 16) != chunk;
18416+ if done {
18417+ let (cr, cc) = chunk;
18418+ // `av1_get_max_uv_txsize(BLOCK_128X128)` =
18419+ // `av1_get_adjusted_tx_size(TX_64X64)` =
18420+ // TX_32X32: one 32x32 chroma unit per chunk.
18421+ let cu_tx = 32usize;
18422+ let luma_span = cu_tx * 2;
18423+ let cu_mi = (at_mi.0 + cr * 16, at_mi.1 + cc * 16);
18424+ let cu_around = neighbours.around_mi(cu_mi, luma_span);
18425+ let (cu_x, cu_y) = (cpx + cc * cu_tx, cpy + cr * cu_tx);
18426+ let cu_scan = default_scan(cu_tx);
18427+ for plane_idx in 1..3 {
18428+ let (src, buf) = if plane_idx == 1 {
18429+ (&pred_u, &mut *u)
18430+ } else {
18431+ (&pred_v, &mut *v)
18432+ };
18433+ let mut cu_pred = Vec::with_capacity(cu_tx * cu_tx);
18434+ for rr in 0..cu_tx {
18435+ let start =
18436+ (cr * cu_tx + rr) * chroma_side + cc * cu_tx;
18437+ cu_pred.extend_from_slice(&src[start..start + cu_tx]);
18438+ }
18439+ let cu_grid = read_inter_plane(
18440+ dec,
18441+ cdfs,
18442+ chroma_set,
18443+ &cu_scan,
18444+ plane_idx,
18445+ cu_around[plane_idx],
18446+ mode_for_tx,
18447+ buf,
18448+ cu_x,
18449+ cu_y,
18450+ cu_tx,
18451+ base_q_idx,
18452+ &cu_pred,
18453+ Some(first_tx_type),
18454+ Some(3),
18455+ )?
18456+ .0;
18457+ // Immediately, so the NEXT chunk's unit
18458+ // reads this one's coefficient context.
18459+ neighbours.record_mi_chroma(
18460+ cu_mi, luma_span, luma_span, plane_idx, &cu_grid,
18461+ );
18462+ CHROMA_SPLIT_TX_HITS.with(|c| c.set(c.get() + 1));
18463+ let dst = if plane_idx == 1 {
18464+ &mut u_units
18465+ } else {
18466+ &mut v_units
18467+ };
18468+ for rr in 0..cu_tx {
18469+ let start =
18470+ (cr * cu_tx + rr) * chroma_side + cc * cu_tx;
18471+ dst[start..start + cu_tx]
18472+ .copy_from_slice(&cu_grid[rr * cu_tx..][..cu_tx]);
18473+ }
18474+ }
18475+ }
18476+ }
1826618477 }
1826718478 // `av1_get_tx_type`'s chroma lookup scales the chroma
1826818479 // position back to luma, so an inter block's chroma
@@ -18356,6 +18567,10 @@ fn decode_inter_block(
1835618567 uh,
1835718568 chroma_side,
1835818569 );
18570+ } else if side > 64 {
18571+ // Already read inside the mu-chunk loop above.
18572+ u_grid = std::mem::take(&mut u_units);
18573+ v_grid = std::mem::take(&mut v_units);
1835918574 } else {
1836018575 u_grid = read_inter_plane(
1836118576 dec,
@@ -20816,10 +21031,21 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
2081621031 // loop does; the 64-level body below is unchanged, `read_cdef`'s
2081721032 // per-64x64-quadrant reset (`CDEF_TRANSMITTED`) already matches libaom's
2081821033 // `cdef_idx[(mi_row & 16) >> 4 * 2 + (mi_col & 16) >> 4]` slot per quadrant.
21034+ // lane-sb128c r1: set when the 128 root resolved to `PARTITION_NONE` -- its
21035+ // one 128x128 inter block covers all four 64x64 quadrants, so the remaining
21036+ // three items of this superblock carry no syntax at all (same skip the
21037+ // key-frame tile loop runs).
21038+ let mut sb128_none = false;
2081921039 for (sb_r, sb_c, row_start, sb_start) in sb_visit_order(sb_r0, sb_r1, sb_c0, sb_c1, sb128) {
2082021040 if row_start {
2082121041 neighbours.start_row();
2082221042 }
21043+ if sb_start {
21044+ sb128_none = false;
21045+ }
21046+ if sb128_none {
21047+ continue;
21048+ }
2082321049 {
2082421050 if sb128 && sb_start {
2082521051 if read_sb128_root(
@@ -20833,14 +21059,15 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
2083321059 sb_c,
2083421060 mi_cols,
2083521061 mi_rows,
20836- )? != PARTITION_SPLIT
21062+ )? == PARTITION_NONE
2083721063 {
20838- // lane-sb128b r1 decodes a `PARTITION_NONE` 128 root on
20839- // KEY frames only; an inter 128x128 leaf needs whole-block
20840- // MC, OBMC and compound at a size this path has never run.
20841- return Err(unsupported(
20842- "a 128x128 superblock PARTITION_NONE root on an inter frame (only the key-frame path codes a whole 128x128 block)",
20843- ));
21064+ // One 128x128 inter block. Its luma transform is
21065+ // `max_txsize_rect_lookup[BLOCK_128X128]` = TX_64X64 (four
21066+ // units, read as var-tx leaves), its uv plane block is
21067+ // 64x64 with TX_32X32 units (`av1_get_max_uv_txsize`), and
21068+ // `size_group_lookup[BLOCK_128X128]` is 3, same as 64x64.
21069+ sb128_none = true;
21070+ CDEF_TRANSMITTED.with(|c| c.set(false));
2084421071 }
2084521072 }
2084621073 if !sb128 {
@@ -20915,6 +21142,33 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
2091521142 )?
2091621143 };
2091721144 }
21145+ if sb128_none {
21146+ INTER_SB128_NONE_HITS.with(|c| c.set(c.get() + 1));
21147+ let at128 = ((sb_r & !1) as usize * 4, (sb_c & !1) as usize * 4);
21148+ inter_piece!(
21149+ at128, SB * 2,
21150+ TxbSet::Luma64, TxbSet::Luma64, TxbSet::Chroma32, TX32, TX32,
21151+ &scan32, &scan32, 3, SB * 2, SB * 2
21152+ );
21153+ // libaom writes one `cdef_strength` into the block's own
21154+ // `MB_MODE_INFO`, which all four 64x64 CDEF units point at
21155+ // (mirrors the key-frame 128 NONE block).
21156+ let (q_r, q_c) = ((sb_r & !1) as usize, (sb_c & !1) as usize);
21157+ CDEF_IDX_GRID.with(|g| {
21158+ let mut g = g.borrow_mut();
21159+ let cols = CDEF_SB_COLS.with(|c| c.get());
21160+ if cols > 0 && q_r * cols + q_c < g.len() {
21161+ let idx = g[q_r * cols + q_c];
21162+ for (dr, dc) in [(0, 1), (1, 0), (1, 1)] {
21163+ let i = (q_r + dr) * cols + q_c + dc;
21164+ if q_c + dc < cols && i < g.len() {
21165+ g[i] = idx;
21166+ }
21167+ }
21168+ }
21169+ });
21170+ continue;
21171+ }
2091821172 let sb_ctx = neighbours.partition_ctx(sb_at, SB);
2091921173 let (has_cols, has_rows) = (
2092021174 sb_c * SB_MI + SB_MI / 2 < mi_cols,
crates/ec-av1/src/refusal_inventory.rsmodified+1 -1
@@ -43,7 +43,7 @@ const REFUSALS: &[&str] = &[
4343 "an INTER 32x32 partition type this decoder does not code (value={part32})",
4444 "a superblock-level partition value outside PARTITION_NONE..PARTITION_VERT_4",
4545 "a 128x128 superblock HORZ/VERT or AB partition (only SPLIT and NONE are decoded at the 128 root)",
46- "a 128x128 superblock PARTITION_NONE root on an inter frame (only the key-frame path codes a whole 128x128 block)",
46+ "an INTRA-coded 128x128 block inside an inter frame (only the inter half of a 128x128 root is decoded here)",
4747 "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)",
4848 "a palette block on a HORZ/VERT intra strip below 16x16 (reconstruction not ported)",
4949 "a palette block with a real transform on a superblock-level HORZ/VERT strip (corner-cropped luma coefficients not ported for palette)",
crates/ec-av1/src/stream.rsmodified+164 -0
@@ -18366,6 +18366,170 @@ mod tests {
1836618366 }
1836718367 }
1836818368
18369+ /// lane-sb128c r1: an INTER frame whose 128x128 superblock root really
18370+ /// resolves `PARTITION_NONE` -- one whole 128x128 inter block, the shape
18371+ /// ReelC's first inter frame stops this decoder on. r1 wired it: four
18372+ /// TX_64X64 luma units (`max_txsize_rect_lookup[BLOCK_128X128]`), four
18373+ /// TX_32X32 chroma units (`av1_get_max_uv_txsize`), interleaved Y,U,V per
18374+ /// 64x64 "mu" chunk (libaom `decode_token_recon_block`) with the chroma
18375+ /// `txb_skip_ctx` offset-10 rows, and OBMC's overlap capped at a 64x64
18376+ /// block's half (`reconinter.c` 860/899).
18377+ ///
18378+ /// `--max-partition-size=128` is what lets the root be NONE at all (the
18379+ /// sibling gate above pins 64, so its roots always SPLIT). Every arm hard
18380+ /// asserts its own `inter_sb128_none_hits` delta, so a recipe that stops
18381+ /// choosing the shape fails instead of passing vacuously; every decode
18382+ /// order frame is compared by [`decode_all_frames_vs_oracle`], which
18383+ /// panics on a refusal or any differing byte. Arms: 8-bit and 10-bit (his
18384+ /// films are 10-bit) with `tx-size-search=0` (TX_MODE_LARGEST, the block's
18385+ /// four TX_64X64 units come straight from `max_txsize_rect_lookup`) and an
18386+ /// 8-bit `tx-size-search=1` arm (the var-tx tree at 128).
18387+ #[test]
18388+ // lane-sb128c r1 leaves this gate RED: the recipe really fires the shape
18389+ // (`partition_w128 value=0` four times, traced), the key frame alone
18390+ // decodes, but the 8-frame stream stops on "a split intra strip whose
18391+ // transform unit is 32x64" -- an intra rect strip aomenc cannot have coded
18392+ // with `--enable-rect-partitions=0`, so our own 128 inter block desyncs
18393+ // first (class refusal-from-own-desync). r2 owns the range ladder.
18394+ #[ignore = "lane-sb128c r1: the 128 inter NONE block still desyncs; see lanes/sb128c-r1.report.md"]
18395+ fn a_real_aomenc_inter_128x128_none_root_decodes_pixel_exact() {
18396+ const NAME: &str = "a_real_aomenc_inter_128x128_none_root_decodes_pixel_exact";
18397+ let _gate_lock = lock_gate_counters();
18398+ if !have_ffmpeg() || !have_aomenc() {
18399+ eprintln!("SKIP {NAME}: no ffmpeg/aomenc/aomdec");
18400+ return;
18401+ }
18402+ let (width, height) = (256usize, 256usize);
18403+ for (ten_bit, tx_search, seed) in [(false, false, 61u32), (true, false, 61), (false, true, 62)] {
18404+ let pix = if ten_bit { "yuv420p10le" } else { "yuv420p" };
18405+ let y4m = Command::new("ffmpeg")
18406+ .args([
18407+ "-v",
18408+ "error",
18409+ "-f",
18410+ "lavfi",
18411+ "-i",
18412+ &format!(
18413+ "{},noise=all_seed={seed}:alls=6:allf=t",
18414+ gradients_source(seed, width, height, "duration=0.32:rate=25")
18415+ ),
18416+ "-pix_fmt",
18417+ pix,
18418+ "-strict",
18419+ "-1",
18420+ "-t",
18421+ "0.32",
18422+ "-f",
18423+ "yuv4mpegpipe",
18424+ "-",
18425+ ])
18426+ .stdin(Stdio::null())
18427+ .stdout(Stdio::piped())
18428+ .stderr(Stdio::piped())
18429+ .output()
18430+ .expect("ffmpeg failed to run");
18431+ assert!(
18432+ y4m.status.success(),
18433+ "{NAME}: ffmpeg fixture: {}",
18434+ String::from_utf8_lossy(&y4m.stderr)
18435+ );
18436+ let mut args: Vec<&str> = vec![
18437+ "--codec=av1",
18438+ "--passes=1",
18439+ "--end-usage=q",
18440+ "--cq-level=62",
18441+ "--cpu-used=0",
18442+ "--threads=1",
18443+ "--row-mt=0",
18444+ "--sb-size=128",
18445+ "--max-partition-size=128",
18446+ "--min-partition-size=32",
18447+ "--enable-rect-partitions=0",
18448+ "--enable-ab-partitions=0",
18449+ "--enable-1to4-partitions=0",
18450+ "--enable-palette=0",
18451+ "--enable-intrabc=0",
18452+ "--deltaq-mode=0",
18453+ "--limit=8",
18454+ ];
18455+ // Spelled ONCE per invocation (a repeated `--enable-*` keeps its
18456+ // LAST occurrence, measured 2026-09-02).
18457+ args.push(if tx_search {
18458+ "--enable-tx-size-search=1"
18459+ } else {
18460+ "--enable-tx-size-search=0"
18461+ });
18462+ if ten_bit {
18463+ args.extend_from_slice(&["--input-bit-depth=10", "--bit-depth=10"]);
18464+ }
18465+ args.extend_from_slice(&["--obu", "-o", "-", "-"]);
18466+ let mut child = Command::new(aomenc_path())
18467+ .args(&args)
18468+ .stdin(Stdio::piped())
18469+ .stdout(Stdio::piped())
18470+ .stderr(Stdio::piped())
18471+ .spawn()
18472+ .expect("aomenc failed to start");
18473+ child
18474+ .stdin
18475+ .take()
18476+ .expect("aomenc stdin")
18477+ .write_all(&y4m.stdout)
18478+ .expect("writing y4m to aomenc");
18479+ let out = child.wait_with_output().expect("aomenc failed to run");
18480+ assert!(
18481+ out.status.success(),
18482+ "{NAME}: aomenc refused the fixture: {}",
18483+ String::from_utf8_lossy(&out.stderr)
18484+ );
18485+ let stream = out.stdout;
18486+ let header = {
18487+ let mut parser = ec_av1_syntax::Av1Parser::new();
18488+ let mut pos = 0usize;
18489+ while let Ok(obu) = parser.parse_obu(&stream[pos..]) {
18490+ pos += obu.total_size;
18491+ if pos >= stream.len() {
18492+ break;
18493+ }
18494+ }
18495+ parser
18496+ .sequence_header()
18497+ .map(|q| (q.use_128x128_superblock, q.color_config.bit_depth))
18498+ };
18499+ assert_eq!(
18500+ header,
18501+ Some((true, if ten_bit { 10 } else { 8 })),
18502+ "{NAME}: the encoder did not write a 128x128-superblock sequence header at \
18503+ the requested bit depth -- the flag never arrived"
18504+ );
18505+ let before = (
18506+ crate::decode::inter_sb128_none_hits(),
18507+ crate::decode::chroma_split_tx_hits(),
18508+ );
18509+ let (frames, hidden) = decode_all_frames_vs_oracle(
18510+ &stream,
18511+ &format!("sb128c-inter-none-{}-{}", if ten_bit { 10 } else { 8 }, tx_search),
18512+ );
18513+ let (none128, chroma_units) = (
18514+ crate::decode::inter_sb128_none_hits() - before.0,
18515+ crate::decode::chroma_split_tx_hits() - before.1,
18516+ );
18517+ assert!(
18518+ frames >= 6,
18519+ "{NAME} ({pix} tx_search={tx_search}): only {frames} decode-order frames"
18520+ );
18521+ assert!(
18522+ none128 >= 1,
18523+ "{NAME} ({pix} tx_search={tx_search}): no 128x128 PARTITION_NONE root on an \
18524+ inter frame -- the recipe stopped exercising the shape this gate names"
18525+ );
18526+ eprintln!(
18527+ "{NAME} ({pix} tx_search={tx_search}): {frames} decode-order frames pixel-exact \
18528+ ({hidden} hidden), inter_sb128_none_hits={none128} chroma_units={chroma_units}"
18529+ );
18530+ }
18531+ }
18532+
1836918533 /// lane-sbpart r2: a real `aomenc` stream whose superblock-level
1837018534 /// partition decision is genuinely HORZ/VERT (not NONE/SPLIT) must
1837118535 /// decode pixel-exact through [`crate::decode::decode_block_rect64`] --
lanes/sb128c-r1.report.mdadded+101 -0
@@ -0,0 +1,101 @@
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`) — result in the handoff line
88+of the commit message / see the log; the new gate is `#[ignore]`d so the suite measures the untouched paths.
89+
90+## Residue
91+
92+- fix-now(r2): the 128 inter NONE desync. Next step is the range ladder (instrumented aomdec
93+ `EC_TRACE_COEFF` vs ours) on `g8.obu`'s FIRST inter frame, first 128 NONE block — compare msac RANGE
94+ element by element, never `tell()`. Prime suspects in order: (1) `read_cdef`'s per-quadrant index/
95+ `CDEF_TRANSMITTED` for a NONE 128 block on the inter path; (2) `maybe_read_delta_q`/delta_lf granularity
96+ at a 128 root; (3) the mvstack at bw4=bh4=32 (`has_top_right` at 128, tpl sample positions);
97+ (4) my mu-chunk chroma interleave (offset `Some(3)` row choice / per-unit `record_mi_chroma`).
98+- deferred: 128-level HORZ/VERT/AB on both the key and inter paths (ReelC's new stop) — unblocked by the
99+ NONE block being exact first.
100+- deferred: `--enable-tx-size-search=1` arm at 128 and a `--tile-columns=1` arm — same blocker.
101+- accepted: `an INTRA-coded 128x128 block inside an inter frame` stays refused by name.