diff --git a/crates/ec-av1/src/cdf.rs b/crates/ec-av1/src/cdf.rs index e3ecb30e..a21cbdfc 100644 --- a/crates/ec-av1/src/cdf.rs +++ b/crates/ec-av1/src/cdf.rs @@ -3167,6 +3167,16 @@ pub const TXB_SKIP_CHROMA_16_Q3: [[u16; 3]; 3] = /// TXB_SKIP_CHROMA_32, q-context 3: the same table as [`TXB_SKIP_CHROMA_32`], for `base_q_idx` 121..=255. pub const TXB_SKIP_CHROMA_32_Q3: [[u16; 3]; 3] = [[4656, 32768, 0], [16074, 32768, 0], [24704, 32768, 0]]; + +/// `av1_default_txb_skip_cdfs[q][TX_32X32][10..13]` (token_cdfs.h): libaom's +/// chroma `txb_skip_ctx` offset is 10 instead of 7 when the plane block is +/// LARGER than the transform (`get_txb_ctx`), which in AV1 happens only for a +/// 128x128 block's four TX_32X32 chroma units -- the offset-7 rows above are +/// every other case (lane-sb128b r3). +pub const TXB_SKIP_CHROMA_32_BIG_Q0: [[u16; 3]; 3] = [[146, 32768, 0], [5132, 32768, 0], [31657, 32768, 0]]; +pub const TXB_SKIP_CHROMA_32_BIG_Q1: [[u16; 3]; 3] = [[641, 32768, 0], [22265, 32768, 0], [31452, 32768, 0]]; +pub const TXB_SKIP_CHROMA_32_BIG: [[u16; 3]; 3] = [[3082, 32768, 0], [20982, 32768, 0], [29443, 32768, 0]]; +pub const TXB_SKIP_CHROMA_32_BIG_Q3: [[u16; 3]; 3] = [[1806, 32768, 0], [14645, 32768, 0], [25336, 32768, 0]]; /// EOB_EXTRA_LUMA_16, q-context 3: the same table as [`EOB_EXTRA_LUMA_16`], for `base_q_idx` 121..=255. pub const EOB_EXTRA_LUMA_16_Q3: [[u16; 3]; 9] = [ [19941, 32768, 0], diff --git a/crates/ec-av1/src/cdf_state.rs b/crates/ec-av1/src/cdf_state.rs index 7eef9418..89334535 100644 --- a/crates/ec-av1/src/cdf_state.rs +++ b/crates/ec-av1/src/cdf_state.rs @@ -399,7 +399,10 @@ pub(crate) struct Cdfs { /// The all-zero flag of a 16x16 chroma transform. pub txb_skip_chroma_16: [[u16; 3]; 3], /// The all-zero flag of a 32x32 chroma transform. - pub txb_skip_chroma_32: [[u16; 3]; 3], + /// SIX contexts, not three: rows 0..3 are libaom's `txb_skip_ctx` 7..9 + /// (chroma transform == its plane block) and rows 3..6 its 10..12 (plane + /// block larger, i.e. a 128x128 block's four TX_32X32 chroma units). + pub txb_skip_chroma_32: [[u16; 3]; 6], /// The end-of-block group of a luma transform of 1024 positions. pub eob_pt_1024_luma: [u16; 12], /// The same, for chroma. @@ -1253,13 +1256,23 @@ impl Cdfs { cdf::TXB_SKIP_CHROMA_16, cdf::TXB_SKIP_CHROMA_16_Q3, ), - txb_skip_chroma_32: pick( - q_ctx, - cdf::TXB_SKIP_CHROMA_32_Q0, - cdf::TXB_SKIP_CHROMA_32_Q1, - cdf::TXB_SKIP_CHROMA_32, - cdf::TXB_SKIP_CHROMA_32_Q3, - ), + txb_skip_chroma_32: { + let small = pick( + q_ctx, + cdf::TXB_SKIP_CHROMA_32_Q0, + cdf::TXB_SKIP_CHROMA_32_Q1, + cdf::TXB_SKIP_CHROMA_32, + cdf::TXB_SKIP_CHROMA_32_Q3, + ); + let big = pick( + q_ctx, + cdf::TXB_SKIP_CHROMA_32_BIG_Q0, + cdf::TXB_SKIP_CHROMA_32_BIG_Q1, + cdf::TXB_SKIP_CHROMA_32_BIG, + cdf::TXB_SKIP_CHROMA_32_BIG_Q3, + ); + [small[0], small[1], small[2], big[0], big[1], big[2]] + }, eob_pt_1024_luma: pick( q_ctx, cdf::EOB_PT_1024_LUMA_Q0, diff --git a/crates/ec-av1/src/decode.rs b/crates/ec-av1/src/decode.rs index 79696231..8fc6494a 100644 --- a/crates/ec-av1/src/decode.rs +++ b/crates/ec-av1/src/decode.rs @@ -310,10 +310,12 @@ fn maybe_read_delta_q(dec: &mut SymbolDecoder, cdfs: &mut Cdfs, mi_r: usize, mi_ if mi_r % sb_mi != 0 || mi_c % sb_mi != 0 { return; } - // `is_whole_sb` is the caller's "this leaf IS the superblock" flag, which - // it computes against the 64x64 root; under a 128 superblock no leaf this - // decoder codes can be the whole superblock (the root is always SPLIT). - if is_whole_sb && !sb128() && skip { + // `is_whole_sb` is the caller's "this leaf IS the superblock" flag, + // computed against the sequence's own superblock size (lane-sb128b r1: + // it used to be hardcoded against 64 and disabled under `sb128`, which a + // `PARTITION_NONE` 128x128 root -- itself the whole superblock -- makes + // wrong). + if is_whole_sb && skip { return; } let mut abs = dec.symbol(&mut cdfs.delta_q) as i32; @@ -369,10 +371,12 @@ fn maybe_read_delta_lf(dec: &mut SymbolDecoder, cdfs: &mut Cdfs, mi_r: usize, mi if mi_r % sb_mi != 0 || mi_c % sb_mi != 0 { return; } - // `is_whole_sb` is the caller's "this leaf IS the superblock" flag, which - // it computes against the 64x64 root; under a 128 superblock no leaf this - // decoder codes can be the whole superblock (the root is always SPLIT). - if is_whole_sb && !sb128() && skip { + // `is_whole_sb` is the caller's "this leaf IS the superblock" flag, + // computed against the sequence's own superblock size (lane-sb128b r1: + // it used to be hardcoded against 64 and disabled under `sb128`, which a + // `PARTITION_NONE` 128x128 root -- itself the whole superblock -- makes + // wrong). + if is_whole_sb && skip { return; } let multi = DELTA_LF_MULTI.with(|c| c.get()); @@ -4870,6 +4874,32 @@ impl Neighbours { self.record_mi_luma_rect(at_mi, tx_px, tx_px, grid); } + /// [`Self::record_mi_luma`] for ONE CHROMA transform unit of a block whose + /// uv plane block is several units (lane-sb128b r2: a 128x128 block's + /// 64x64 uv plane block is four TX_32X32 units, `av1_get_max_uv_txsize`). + /// `w_px`/`h_px` are the unit's extent in LUMA pixels -- the chroma + /// coefficient-context arrays are indexed by luma mi, the convention + /// [`Self::record_split_luma_rect_mi`] already writes them in, frame-edge + /// clamp included. + fn record_mi_chroma( + &mut self, + (mi_r, mi_c): (usize, usize), + w_px: usize, + h_px: usize, + plane: usize, + grid: &[i32], + ) { + let round_up_even = |n: usize| n.div_ceil(2) * 2; + let (bound_h, bound_w) = (round_up_even(self.mi_rows), round_up_even(self.mi_cols)); + let state = neighbour_state(grid); + for cell in 0..(h_px / MI).min(bound_h.saturating_sub(mi_r)) { + self.left[mi_r + cell][plane] = state; + } + for cell in 0..(w_px / MI).min(bound_w.saturating_sub(mi_c)) { + self.above[mi_c + cell][plane] = state; + } + } + /// [`Self::record_mi_luma`] for a RECTANGULAR transform unit (lane-rectsplitx /// r1): the above context spans the unit's width, the left context its /// height, which for a square unit is the same loop it always was. @@ -8425,8 +8455,12 @@ fn read_intra_mode( // `segment_id`, `cdef`, `delta_q` -- `cdef` lands right here. maybe_read_cdef_idx(dec, mi_r, mi_c, skip); istep!("cdef", 0); - maybe_read_delta_q(dec, cdfs, mi_r, mi_c, side == 64, skip); - maybe_read_delta_lf(dec, cdfs, mi_r, mi_c, side == 64, skip); + // lane-sb128b r1: "this leaf IS the superblock" is `side == sb_size`, not + // a hardcoded 64 -- a `PARTITION_NONE` 128x128 root is the whole + // superblock and skips `delta_q` exactly like a 64 one under a 64 root. + let whole_sb = side == sb_mi_cur() as usize * 4; + maybe_read_delta_q(dec, cdfs, mi_r, mi_c, whole_sb, skip); + maybe_read_delta_lf(dec, cdfs, mi_r, mi_c, whole_sb, skip); istep!("dq", 0); // `read_intrabc_info` (spec 5.11.13, libaom decodemv.c:693, called at // :811 right after `skip_txfm`/`segment_id`/`cdef`/`delta_q` and before @@ -9120,7 +9154,12 @@ fn read_plane( let skip_ctx = if plane_idx == 0 { luma_skip_ctx.unwrap_or(0) } else { - usize::from(around.0) + usize::from(around.1) + // libaom `get_txb_ctx`: a chroma unit's context is + // `combine_entropy_contexts(above, left)` plus 7, or plus 10 when the + // plane block is bigger than the transform. Our chroma tables hold the + // offset-7 rows first, so the caller adds 3 for the bigger-block case + // (only a 128x128 block's TX_32X32 chroma units, lane-sb128b r3). + usize::from(around.0) + usize::from(around.1) + luma_skip_ctx.unwrap_or(0) }; // spec 5.11.47/libaom `av1_read_tx_type`: a filter-intra luma block's // `intra_ext_tx_cdf` row is indexed by `fimode_to_intradir[filter_intra_mode]`, @@ -9305,7 +9344,11 @@ fn decode_block( let resolved = read_tx_size(dec, cdfs, neighbours, (mi_r, mi_c), side, None); (resolved, if resolved == 64 { 32 } else { resolved }) } else { - (side, luma_tx) + // lane-sb128b r1: `max_txsize_rect_lookup[BLOCK_128X128]` is + // TX_64X64, so a 128x128 block is always FOUR luma transform units + // even with `tx_select` off -- the TU loop below, never the + // single-unit path. + (side.min(64), luma_tx) }; if tx_select && logical_tx < side && uv_mode != DC_PRED { SQ_CHROMA_TX_HITS.with(|c| c.set(c.get() + 1)); @@ -9410,10 +9453,17 @@ fn decode_block( // The palette/intrabc override path keeps the single-call shape (its // per-TU windowing is the non-skip loop's own `palette_y_buf` slice, // untested for skip and unreachable in these streams). + // lane-sb128b r2: a 128x128 block's transform is TX_64X64 even with + // `tx_select` off (`max_txsize_rect_lookup[BLOCK_128X128]`), so the + // per-unit prediction is keyed on the transform being smaller than + // the block, not on the tx-depth syntax. The counter keeps lane-hgkf's + // narrower meaning (a READ split tx depth). let split_tx_skip = - tx_select && logical_tx < side && palette_y_buf.is_none() && intrabc_bufs.is_none(); + logical_tx < side && palette_y_buf.is_none() && intrabc_bufs.is_none(); if split_tx_skip { - SKIP_SPLIT_TX_HITS.with(|c| c.set(c.get() + 1)); + if tx_select { + SKIP_SPLIT_TX_HITS.with(|c| c.set(c.get() + 1)); + } let n_axis = side / logical_tx; for tu_row in 0..n_axis { for tu_col in 0..n_axis { @@ -9463,41 +9513,62 @@ fn decode_block( ); } let ac = alpha.map(|_| cfl_ac_q3(y, px, py, side)); - if let Some((ub, _)) = &palette_uv_bufs { - set_palette_pred(ub.clone()); - } - u.reconstruct( - cpx, - cpy, - chroma_side, - uv_predict_mode, - angle_delta_uv, - reach, - &vec![0i32; chroma_side * chroma_side], - alpha.zip(ac.as_deref()).map(|((au, _), ac)| (au, ac)), - None, - smooth_neighbor_uv, - ); - if let Some((_, vb)) = &palette_uv_bufs { - set_palette_pred(vb.clone()); + let cn = (chroma_side / chroma_tx).max(1); + for cu_row in 0..cn { + for cu_col in 0..cn { + let luma_span = chroma_tx * 2; + let cu_r = if cn == 1 { + reach + } else { + tu_reach( + side, side, + cu_col * luma_span, cu_row * luma_span, luma_span, + reach, px, py, y.width, y.height, + ) + }; + let (cu_x, cu_y) = (cpx + cu_col * chroma_tx, cpy + cu_row * chroma_tx); + if let Some((ub, _)) = &palette_uv_bufs { + set_palette_pred(ub.clone()); + } + u.reconstruct( + cu_x, + cu_y, + chroma_tx, + uv_predict_mode, + angle_delta_uv, + cu_r, + &vec![0i32; chroma_tx * chroma_tx], + alpha.zip(ac.as_deref()).map(|((au, _), ac)| (au, ac)), + None, + smooth_neighbor_uv, + ); + if let Some((_, vb)) = &palette_uv_bufs { + set_palette_pred(vb.clone()); + } + v.reconstruct( + cu_x, + cu_y, + chroma_tx, + uv_predict_mode, + angle_delta_uv, + cu_r, + &vec![0i32; chroma_tx * chroma_tx], + alpha.zip(ac.as_deref()).map(|((_, av), ac)| (av, ac)), + None, + smooth_neighbor_uv, + ); + } } - v.reconstruct( - cpx, - cpy, - chroma_side, - uv_predict_mode, - angle_delta_uv, - reach, - &vec![0i32; chroma_side * chroma_side], - alpha.zip(ac.as_deref()).map(|((_, av), ac)| (av, ac)), - None, - smooth_neighbor_uv, - ); let luma_grid = vec![0i32; side * side]; let u_grid = vec![0i32; chroma_side * chroma_side]; let v_grid = vec![0i32; chroma_side * chroma_side]; neighbours.record(at, side, mode, uv_predict_mode, &[luma_grid, u_grid, v_grid]); - } else if !tx_select || logical_tx == side { + } else if logical_tx == side { + // lane-sb128b r1: the test used to be `!tx_select || logical_tx == side`. + // Without `tx_select` `logical_tx` IS `side` at every size <= 64, so + // that arm was redundant -- and wrong at 128, where + // `max_txsize_rect_lookup` caps the block's transform at 64 and the + // block is four units whether or not `tx_select` is on. // A single luma transform unit -- the old path, unchanged (including // the 64x64 corner case, `logical_tx == side == 64` with // `coeff_tx_side == 32`). @@ -9590,8 +9661,27 @@ fn decode_block( // the earlier tiles in this same block already wrote -- the same // per-TU pattern [`decode_leaf8`] already runs for an 8x8 leaf. let n_axis = side / logical_tx; - for tu_row in 0..n_axis { - for tu_col in 0..n_axis { + let cn = (chroma_side / chroma_tx).max(1); + // libaom's transform-block loop is over 64x64 luma "mu" chunks + // (`decode_token_recon_block`: `mu_blocks_wide/high` = + // `mi_size_wide[BLOCK_64X64]`), and it codes EVERY PLANE of a chunk + // before moving to the next one. Below 128 a block is a single chunk, + // so this is byte-for-byte the all-luma-then-all-chroma order that has + // always run; at 128 the four quadrants interleave Y,U,V per quadrant + // and reading all four luma units first desyncs the tile at the second + // one (lane-sb128b r3, measured against aomdec's `EC_TRACE_COEFF`). + let nchunk = (side / 64).max(1); + // `cn > 1` means the uv plane block is larger than the uv transform, + // which moves libaom's chroma `txb_skip_ctx` offset from 7 to 10. + let chroma_ctx_offset = if cn > 1 { Some(3) } else { None }; + let tpc = (n_axis / nchunk).max(1); + let cpc = (cn / nchunk).max(1); + let mut last_grids = [Vec::new(), Vec::new()]; + let mut units: Vec<((usize, usize), usize, Vec, Vec)> = Vec::new(); + for ch_row in 0..nchunk { + for ch_col in 0..nchunk { + for tu_row in ch_row * tpc..(ch_row + 1) * tpc { + for tu_col in ch_col * tpc..(ch_col + 1) * tpc { let tu_mi = ( mi_r + tu_row * (logical_tx / MI), mi_c + tu_col * (logical_tx / MI), @@ -9652,7 +9742,11 @@ fn decode_block( tu_px, tu_py, logical_tx, - logical_tx, + // The unit's own COEFFICIENT grid, half its side at + // TX_64X64 (a 64-point transform codes nothing past 32); + // identical to `logical_tx` at every smaller size + // (lane-sb128b r1). + coeff_tx_side, base_q_idx, None, filter_intra, @@ -9670,59 +9764,81 @@ fn decode_block( neighbours.record_mi_luma(tu_mi, logical_tx, &tu_grid); } } + // CfL is only allowed up to 32x32, i.e. only at `nchunk == 1`, where + // this still runs after every luma unit of the block. let ac = alpha.map(|_| cfl_ac_q3(y, px, py, side)); - let chroma_around = neighbours.around(at, side); - if let Some((ub, _)) = &palette_uv_bufs { - set_palette_pred(ub.clone()); + // The block's uv plane block is `chroma_side` across but its uv + // transform is `chroma_tx` (`av1_get_max_uv_txsize` = + // `av1_get_adjusted_tx_size(max_txsize_rect_lookup[uv_plane_bsize])`): + // identical at every size up to 64x64, but a 128x128 block's 64x64 uv + // plane block adjusts TX_64X64 down to TX_32X32, so each plane is + // FOUR units (lane-sb128b r2) -- one per mu chunk. + for cu_row in ch_row * cpc..(ch_row + 1) * cpc { + for cu_col in ch_col * cpc..(ch_col + 1) * cpc { + // The chroma context arrays are indexed in LUMA mi, so this + // unit's anchor is its own luma quadrant: `chroma_tx` chroma + // pixels span `2 * chroma_tx` luma ones. + let luma_span = chroma_tx * 2; + let cu_mi = ( + mi_r + cu_row * (luma_span / MI), + mi_c + cu_col * (luma_span / MI), + ); + let cu_around = neighbours.around_mi(cu_mi, luma_span); + let cu_reach = if cn == 1 { + reach + } else { + tu_reach( + side, side, + cu_col * luma_span, cu_row * luma_span, luma_span, + reach, px, py, y.width, y.height, + ) + }; + let (cu_x, cu_y) = (cpx + cu_col * chroma_tx, cpy + cu_row * chroma_tx); + if let Some((ub, _)) = &palette_uv_bufs { + set_palette_pred(ub.clone()); + } + let u_grid = read_plane( + dec, cdfs, chroma_set, scans.1, 1, cu_around[1], mode, + uv_predict_mode, angle_delta_uv, cu_reach, u, cu_x, cu_y, + chroma_tx, chroma_tx, base_q_idx, + alpha.zip(ac.as_deref()).map(|((au, _), ac)| (au, ac)), + None, chroma_ctx_offset, smooth_neighbor_uv, + )?; + if let Some((_, vb)) = &palette_uv_bufs { + set_palette_pred(vb.clone()); + } + let v_grid = read_plane( + dec, cdfs, chroma_set, scans.1, 2, cu_around[2], mode, + uv_predict_mode, angle_delta_uv, cu_reach, v, cu_x, cu_y, + chroma_tx, chroma_tx, base_q_idx, + alpha.zip(ac.as_deref()).map(|((_, av), ac)| (av, ac)), + None, chroma_ctx_offset, smooth_neighbor_uv, + )?; + if cn > 1 { + CHROMA_SPLIT_TX_HITS.with(|c| c.set(c.get() + 1)); + // Immediately, so the NEXT unit of this same block reads + // this one's coefficient context (libaom's chroma + // `txb_skip_ctx` for the second quadrant is 11, i.e. base + // 1 from this left neighbour -- measured against aomdec). + // The same writes are replayed after `record_split_luma` + // below, which would otherwise clobber them whole-block. + neighbours.record_mi_chroma(cu_mi, luma_span, luma_span, 1, &u_grid); + neighbours.record_mi_chroma(cu_mi, luma_span, luma_span, 2, &v_grid); + units.push((cu_mi, luma_span, u_grid.clone(), v_grid.clone())); + } + last_grids = [u_grid, v_grid]; + } } - let u_grid = read_plane( - dec, - cdfs, - chroma_set, - scans.1, - 1, - chroma_around[1], - mode, - uv_predict_mode, - angle_delta_uv, - reach, - u, - cpx, - cpy, - chroma_side, - chroma_tx, - base_q_idx, - alpha.zip(ac.as_deref()).map(|((au, _), ac)| (au, ac)), - None, - None, - smooth_neighbor_uv, - )?; - if let Some((_, vb)) = &palette_uv_bufs { - set_palette_pred(vb.clone()); } - let v_grid = read_plane( - dec, - cdfs, - chroma_set, - scans.1, - 2, - chroma_around[2], - mode, - uv_predict_mode, - angle_delta_uv, - reach, - v, - cpx, - cpy, - chroma_side, - chroma_tx, - base_q_idx, - alpha.zip(ac.as_deref()).map(|((_, av), ac)| (av, ac)), - None, - None, - smooth_neighbor_uv, - )?; - neighbours.record_split_luma(at, side, mode, uv_predict_mode, [&u_grid, &v_grid]); + } + // Mode/side bookkeeping plus, at `cn == 1`, the whole-plane chroma + // context write; at `cn > 1` the per-unit writes above are what the + // next block reads, so they run after this (last writer wins). + neighbours.record_split_luma(at, side, mode, uv_predict_mode, [&last_grids[0], &last_grids[1]]); + for (cu_mi, luma_span, u_grid, v_grid) in &units { + neighbours.record_mi_chroma(*cu_mi, *luma_span, *luma_span, 1, u_grid); + neighbours.record_mi_chroma(*cu_mi, *luma_span, *luma_span, 2, v_grid); + } } // Unconditional, `size == 0` for a non-palette block: clears any stale // neighbour palette state the same way [`Neighbours::record`] always @@ -11129,8 +11245,14 @@ fn read_tx_size( // key-frame path's own deblock-grid approximation. ctx_override: Option, ) -> usize { - let ctx = ctx_override.unwrap_or_else(|| tx_size_context(n, at_mi, side)); - let depth = match side { + // `max_txsize_rect_lookup[bsize]` (libaom `read_selected_tx_size` / + // `get_tx_size_context`): a block wider than 64 still tops out at + // TX_64X64, so BLOCK_128X128 reads BLOCK_64X64's own category (its depth + // chain 64->32->16->8->4 is the same four steps) and resolves against 64, + // never against its own 128 side (lane-sb128b r1). + let max_tx = side.min(64); + let ctx = ctx_override.unwrap_or_else(|| tx_size_context(n, at_mi, max_tx)); + let depth = match max_tx { 8 => { dec.symbol(&mut cdfs.tx_size_cat0[ctx]) } @@ -11143,7 +11265,7 @@ fn read_tx_size( 64 => { dec.symbol(&mut cdfs.tx_size_cat3[ctx]) } - _ => unreachable!("decode_block/decode_leaf8 only call this at 8/16/32/64"), + _ => unreachable!("decode_block/decode_leaf8 only call this at 8/16/32/64/128"), }; if std::env::var_os("EC_TRACE_MODE_STEP").is_some() { let (rng, _) = dec.debug_state(); @@ -11155,7 +11277,7 @@ fn read_tx_size( if depth != 0 { TX_DEPTH_HITS.with(|c| c.set(c.get() + 1)); } - side >> depth + max_tx >> depth } /// `txfm_partition_context` (libaom `av1_common_int.h`): an inter block's @@ -12762,6 +12884,29 @@ fn sb_visit_order(r0: u32, r1: u32, c0: u32, c1: u32, sb128: bool) -> Vec<(u32, /// decides the root -- only SPLIT recurses into the four 64x64 quadrants this /// decoder codes, the other seven arms refuse by name. #[allow(clippy::too_many_arguments)] +thread_local! { + /// How many 128x128 superblock roots resolved to `PARTITION_NONE` -- one + /// whole 128x128 block (lane-sb128b r1's gate counter). + pub(crate) static PART128_NONE_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; +} + +/// [`PART128_NONE_HITS`], for a gate's own before/after delta. +pub(crate) fn part128_none_hits() -> usize { + PART128_NONE_HITS.with(std::cell::Cell::get) +} + +thread_local! { + /// How many CHROMA transform units were coded inside a block whose uv + /// plane block is more than one unit (lane-sb128b r2 -- only a 128x128 + /// block, four per plane). + pub(crate) static CHROMA_SPLIT_TX_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; +} + +/// [`CHROMA_SPLIT_TX_HITS`], for a gate's own before/after delta. +pub(crate) fn chroma_split_tx_hits() -> usize { + CHROMA_SPLIT_TX_HITS.with(std::cell::Cell::get) +} + fn read_sb128_root( dec: &mut SymbolDecoder, cdfs: &mut Cdfs, @@ -12776,7 +12921,7 @@ fn read_sb128_root( sb_c: u32, mi_cols: u32, mi_rows: u32, -) -> Result<()> { +) -> Result { let (mi_r128, mi_c128) = ((sb_r & !1) * SB_MI, (sb_c & !1) * SB_MI); crate::restoration::read_lr( dec, @@ -12827,13 +12972,20 @@ fn read_sb128_root( } } }; - if part128 != PARTITION_SPLIT { + // lane-sb128b r1: `PARTITION_NONE` -- one 128x128 block -- is decoded by + // the key-frame caller below. The six remaining arms (HORZ/VERT and the + // four AB shapes) still need the rect/AB machinery at this size. + if part128 != PARTITION_SPLIT && part128 != PARTITION_NONE { return Err(unsupported( - "a 128x128 superblock partition other than SPLIT (NONE/HORZ/VERT and the four AB arms at the 128 root are not decoded)", + "a 128x128 superblock HORZ/VERT or AB partition (only SPLIT and NONE are decoded at the 128 root)", )); } - PART128_SPLIT_HITS.with(|c| c.set(c.get() + 1)); - Ok(()) + if part128 == PARTITION_SPLIT { + PART128_SPLIT_HITS.with(|c| c.set(c.get() + 1)); + } else { + PART128_NONE_HITS.with(|c| c.set(c.get() + 1)); + } + Ok(part128) } pub(crate) fn decode_key_frame_tile_with_cdfs( @@ -13011,10 +13163,20 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( ); TILE_HITS.with(|c| c.set(c.get() + 1)); + // lane-sb128b r1: set when the 128 root resolved to `PARTITION_NONE` -- + // its one block covers all four 64x64 quadrants, so the remaining three + // visits of this superblock code nothing at all. + let mut sb128_none = false; for (sb_r, sb_c, row_start, sb_start) in sb_visit_order(sb_r0, sb_r1, sb_c0, sb_c1, sb128) { if row_start { neighbours.start_row(); } + if sb_start { + sb128_none = false; + } + if sb128_none { + continue; + } { // lane-sb128 r1: the 128 root. Its loop-restoration units are read // once for the whole 128x128 (spec 5.11.57 is called with the @@ -13022,7 +13184,7 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( // `BLOCK_128X128` CDF (8 symbols) decides the root -- only SPLIT // recurses into the four 64x64 quadrants this decoder codes. if sb128 && sb_start { - read_sb128_root( + let part128 = read_sb128_root( &mut dec, &mut cdfs, &neighbours, @@ -13034,6 +13196,62 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( mi_cols, mi_rows, )?; + if part128 == PARTITION_NONE { + // One 128x128 intra block: four TX_64X64 luma units and a + // single 64x64 chroma unit per plane (`av1_get_max_uv_txsize` + // of a 128x128 block is TX_64X64 over its 64x64 uv plane + // block). No CfL, no filter intra, no palette at this size -- + // [`read_intra_mode`]'s own size gates already say so. + sb128_none = true; + CDEF_TRANSMITTED.with(|c| c.set(false)); + let at128 = ((sb_r & !1) as usize * 4, (sb_c & !1) as usize * 4); + decode_block( + &mut dec, + &mut cdfs, + &mut neighbours, + at128, + SB * 2, + TxbSet::Luma64, + TxbSet::Chroma32, + TX32, + TX32, + (&scan32, &scan32), + false, + &mut y, + &mut u, + &mut v, + base_q_idx, + enable_filter_intra, + allow_screen_content_tools, + allow_intrabc, + &scan32, + &scan16, + &scan8, + &scan4, + tx_select, + reduced_tx_set, + )?; + // libaom writes one `cdef_strength` into the block's own + // `MB_MODE_INFO`, which every mi cell of the block -- + // hence all four 64x64 CDEF units -- points at; our grid + // is per-unit, so the read (which only ever lands in the + // top-left unit, `read_cdef`'s index 0) is copied across. + let (q_r, q_c) = ((sb_r & !1) as usize, (sb_c & !1) as usize); + CDEF_IDX_GRID.with(|g| { + let mut g = g.borrow_mut(); + let cols = CDEF_SB_COLS.with(|c| c.get()); + if cols > 0 && q_r * cols + q_c < g.len() { + let idx = g[q_r * cols + q_c]; + for (dr, dc) in [(0, 1), (1, 0), (1, 1)] { + let i = (q_r + dr) * cols + q_c + dc; + if q_c + dc < cols && i < g.len() { + g[i] = idx; + } + } + } + }); + continue; + } } if !sb128 { crate::restoration::read_lr( @@ -20630,7 +20848,7 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( } { if sb128 && sb_start { - read_sb128_root( + if read_sb128_root( &mut dec, &mut cdfs, &neighbours, @@ -20641,7 +20859,15 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( sb_c, mi_cols, mi_rows, - )?; + )? != PARTITION_SPLIT + { + // lane-sb128b r1 decodes a `PARTITION_NONE` 128 root on + // KEY frames only; an inter 128x128 leaf needs whole-block + // MC, OBMC and compound at a size this path has never run. + return Err(unsupported( + "a 128x128 superblock PARTITION_NONE root on an inter frame (only the key-frame path codes a whole 128x128 block)", + )); + } } if !sb128 { crate::restoration::read_lr( diff --git a/crates/ec-av1/src/mvstack.rs b/crates/ec-av1/src/mvstack.rs index 300fa320..cb4e42e9 100644 --- a/crates/ec-av1/src/mvstack.rs +++ b/crates/ec-av1/src/mvstack.rs @@ -92,6 +92,36 @@ pub(crate) fn tmv_hits() -> usize { TMV_HITS.load(std::sync::atomic::Ordering::Relaxed) } +/// lane-mvtwin r1 firing counters, one per divergence this round closed. +/// `COMP_GM_FILL_HITS`: compound extension candidates whose `comp_list` slot +/// came from `gm_mv_candidates[side]` rather than a scanned neighbour, and +/// where that global mv was NOT `(0, 0)` (the only case the old zero fill +/// could not fake). `STACK_FULL_DROPS`: distinct candidates libaom drops at +/// `MAX_REF_MV_STACK_SIZE` on insertion. `TILE_REACH_CLIPS`: row/col reaches +/// shortened by a tile origin past mi 0, which the old frame-edge clamp +/// missed entirely. +static COMP_GM_FILL_HITS: std::sync::atomic::AtomicUsize = + std::sync::atomic::AtomicUsize::new(0); +static STACK_FULL_DROPS: std::sync::atomic::AtomicUsize = + std::sync::atomic::AtomicUsize::new(0); +static TILE_REACH_CLIPS: std::sync::atomic::AtomicUsize = + std::sync::atomic::AtomicUsize::new(0); + +/// [`COMP_GM_FILL_HITS`]. +pub(crate) fn comp_gm_fill_hits() -> usize { + COMP_GM_FILL_HITS.load(std::sync::atomic::Ordering::Relaxed) +} + +/// [`STACK_FULL_DROPS`]. +pub(crate) fn stack_full_drops() -> usize { + STACK_FULL_DROPS.load(std::sync::atomic::Ordering::Relaxed) +} + +/// [`TILE_REACH_CLIPS`]. +pub(crate) fn tile_reach_clips() -> usize { + TILE_REACH_CLIPS.load(std::sync::atomic::Ordering::Relaxed) +} + /// Everything [`find_mv_stack_with_sign_bias`] needs to fold temporal MV /// candidates into a block's stack (spec 7.10.2.8, only reached when the /// frame header's own `use_ref_frame_mvs` is set): the current frame's own @@ -213,6 +243,14 @@ impl MiGrid { self.tile_col1 = col1; } + /// The current tile's top-left mi-unit origin ([`Self::set_tile_bounds`]). + /// libaom's `tile->mi_row_start`/`mi_col_start`, which every availability + /// and reach clamp in `setup_ref_mv_list` is written against + /// (`xd->up_available`, `find_valid_row_offset`, mvref_common.c:512-528). + pub fn tile_origin(&self) -> (usize, usize) { + (self.tile_row0, self.tile_col0) + } + /// Records the unit at `(row, col)`. Out-of-range coordinates are a /// no-op — the caller only ever addresses units inside the grid it built. pub fn set(&mut self, row: usize, col: usize, info: MiInfo) { @@ -313,7 +351,15 @@ const MVREF_ROW_COLS: usize = 3; fn add_candidate(candidates: &mut Vec, mv: (i32, i32), weight: u32) { if let Some(entry) = candidates.iter_mut().find(|e| e.mv == mv) { entry.weight += weight; + } else if candidates.len() >= MAX_STACK_SIZE { + STACK_FULL_DROPS.fetch_add(1, std::sync::atomic::Ordering::Relaxed); } else { + // libaom `add_ref_mv_candidate` (mvref_common.c:100) and + // `add_tpl_ref_mv` (:388) only push when + // `*refmv_count < MAX_REF_MV_STACK_SIZE` -- the 9th distinct MV is + // DROPPED AT INSERTION, never "kept if it outweighs an earlier one". + // Sorting first and truncating afterwards (what this did) keeps a + // different set whenever more than 8 distinct candidates are seen. candidates.push(StackEntry { mv, weight }); } } @@ -773,22 +819,35 @@ pub fn find_mv_stack_with_sign_bias( // nothing here relies on that. let row_adj = bh4 < 2 && mi_row % 2 == 1; let col_adj = bw4 < 2 && mi_col % 2 == 1; - let max_row_offset: isize = if mi_row > 0 { + // r1 (lane-mvtwin): availability and reach are TILE-relative, never + // frame-relative -- libaom's `xd->up_available`/`left_available` are + // `mi_row > tile->mi_row_start` / `mi_col > tile->mi_col_start`, and + // `find_valid_row_offset`/`find_valid_col_offset` (mvref_common.c:512-528) + // clamp the reach to `tile->mi_row_start - mi_row`. Clamping to the FRAME + // edge left `max_row_offset`/`max_col_offset` too long inside every tile + // that does not start at 0, which changes the row/col scan's `inc` weight + // (and so the stack ORDER) even though `MiGrid::get` already returns + // `None` for the cells outside the tile. + let (tile_row0, tile_col0) = grid.tile_origin(); + if tile_row0 > 0 || tile_col0 > 0 { + TILE_REACH_CLIPS.fetch_add(1, std::sync::atomic::Ordering::Relaxed); + } + let max_row_offset: isize = if mi_row > tile_row0 { let reach = if bh4 < 2 { -4 } else { -6 } + isize::from(row_adj); - reach.max(-(mi_row as isize)) + reach.max(tile_row0 as isize - mi_row as isize) } else { 0 }; - let max_col_offset: isize = if mi_col > 0 { + let max_col_offset: isize = if mi_col > tile_col0 { let reach = if bw4 < 2 { -4 } else { -6 } + isize::from(col_adj); - reach.max(-(mi_col as isize)) + reach.max(tile_col0 as isize - mi_col as isize) } else { 0 }; let mut processed_rows = 0usize; let mut processed_cols = 0usize; - let found_above = mi_row > 0 + let found_above = max_row_offset.unsigned_abs() >= 1 && scan_row( grid, mi_row, @@ -802,7 +861,7 @@ pub fn find_mv_stack_with_sign_bias( &mut newmv_count, &mut processed_rows, ); - let found_left = mi_col > 0 + let found_left = max_col_offset.unsigned_abs() >= 1 && scan_col( grid, mi_row, @@ -1227,7 +1286,12 @@ fn add_compound_candidate( ) { if let Some(entry) = candidates.iter_mut().find(|e| e.mv0 == mv0 && e.mv1 == mv1) { entry.weight += weight; + } else if candidates.len() >= MAX_STACK_SIZE { + STACK_FULL_DROPS.fetch_add(1, std::sync::atomic::Ordering::Relaxed); } else { + // Same insertion cap as [`add_candidate`]: libaom's compound branch + // of `add_ref_mv_candidate` (mvref_common.c:128) and `add_tpl_ref_mv` + // (:425) both gate the push on `*refmv_count < MAX_REF_MV_STACK_SIZE`. candidates.push(CompoundStackEntry { mv0, mv1, weight }); } } @@ -1477,9 +1541,18 @@ fn process_compound_ref_mv_candidate( /// libaom's combine step (`setup_ref_mv_list`, `mvref_common.c` ~696-720): /// zips each side's `ref_id` (exact matches) then `ref_diff` (borrowed, /// sign-flipped) entries, position-wise and independently per side, into up -/// to two full `(mv0, mv1)` pair candidates — missing slots default to -/// `(0, 0)`, matching libaom's zero-initialized `combined_mvs`. -fn combine_compound_candidates(lists: &CompoundRefLists) -> [((i32, i32), (i32, i32)); 2] { +/// to two full `(mv0, mv1)` pair candidates. r1 (lane-mvtwin): slots past +/// both lists are filled with THAT SIDE's own global motion vector +/// (`gm_mv_candidates[idx]`, mvref_common.c:718-719), never `(0, 0)` — the +/// exact gap the single-reference twin closed in r6 for its own +/// `mv_ref_list` tail, still open on this side. Invisible while every live +/// reference's global motion is IDENTITY (an unclamped gm mv of exactly +/// `(0,0)`), wrong the moment a compound pair names a ROTZOOM/AFFINE +/// reference and the scans leave the stack short. +fn combine_compound_candidates( + lists: &CompoundRefLists, + gm_mv_candidates: [(i32, i32); 2], +) -> [((i32, i32), (i32, i32)); 2] { let side_slots = |side: usize| -> [(i32, i32); 2] { let merged: Vec<(i32, i32)> = lists.ref_id[side] .iter() @@ -1487,7 +1560,14 @@ fn combine_compound_candidates(lists: &CompoundRefLists) -> [((i32, i32), (i32, .take(2) .copied() .collect(); - std::array::from_fn(|i| merged.get(i).copied().unwrap_or((0, 0))) + std::array::from_fn(|i| { + merged.get(i).copied().unwrap_or_else(|| { + if gm_mv_candidates[side] != (0, 0) { + COMP_GM_FILL_HITS.fetch_add(1, std::sync::atomic::Ordering::Relaxed); + } + gm_mv_candidates[side] + }) + }) }; let side0 = side_slots(0); let side1 = side_slots(1); @@ -1532,22 +1612,35 @@ pub fn find_mv_stack_compound( let row_adj = bh4 < 2 && mi_row % 2 == 1; let col_adj = bw4 < 2 && mi_col % 2 == 1; - let max_row_offset: isize = if mi_row > 0 { + // r1 (lane-mvtwin): availability and reach are TILE-relative, never + // frame-relative -- libaom's `xd->up_available`/`left_available` are + // `mi_row > tile->mi_row_start` / `mi_col > tile->mi_col_start`, and + // `find_valid_row_offset`/`find_valid_col_offset` (mvref_common.c:512-528) + // clamp the reach to `tile->mi_row_start - mi_row`. Clamping to the FRAME + // edge left `max_row_offset`/`max_col_offset` too long inside every tile + // that does not start at 0, which changes the row/col scan's `inc` weight + // (and so the stack ORDER) even though `MiGrid::get` already returns + // `None` for the cells outside the tile. + let (tile_row0, tile_col0) = grid.tile_origin(); + if tile_row0 > 0 || tile_col0 > 0 { + TILE_REACH_CLIPS.fetch_add(1, std::sync::atomic::Ordering::Relaxed); + } + let max_row_offset: isize = if mi_row > tile_row0 { let reach = if bh4 < 2 { -4 } else { -6 } + isize::from(row_adj); - reach.max(-(mi_row as isize)) + reach.max(tile_row0 as isize - mi_row as isize) } else { 0 }; - let max_col_offset: isize = if mi_col > 0 { + let max_col_offset: isize = if mi_col > tile_col0 { let reach = if bw4 < 2 { -4 } else { -6 } + isize::from(col_adj); - reach.max(-(mi_col as isize)) + reach.max(tile_col0 as isize - mi_col as isize) } else { 0 }; let mut processed_rows = 0usize; let mut processed_cols = 0usize; - let found_above = mi_row > 0 + let found_above = max_row_offset.unsigned_abs() >= 1 && scan_row_compound( grid, mi_row, @@ -1561,7 +1654,7 @@ pub fn find_mv_stack_compound( &mut newmv_count, &mut processed_rows, ); - let found_left = mi_col > 0 + let found_left = max_col_offset.unsigned_abs() >= 1 && scan_col_compound( grid, mi_row, @@ -1802,7 +1895,8 @@ pub fn find_mv_stack_compound( // bump) — otherwise append `comp_list[0]` as a brand-new entry. When // the stack is empty, both `comp_list[0]` and `comp_list[1]` are // appended unconditionally, with no dedup check at all. - let comp_list = combine_compound_candidates(&lists); + let comp_list = + combine_compound_candidates(&lists, [gm_mv(gm, ref_frame.0), gm_mv(gm, ref_frame.1)]); if candidates.len() == 1 { let (mv0, mv1) = if comp_list[0] == (candidates[0].mv0, candidates[0].mv1) { comp_list[1] @@ -2824,7 +2918,7 @@ mod tests { // side 1 has only one entry -> comp_idx 1 falls back to ref_diff. lists.ref_diff[1].push((4, 4)); - let combined = combine_compound_candidates(&lists); + let combined = combine_compound_candidates(&lists, [(0, 0), (0, 0)]); assert_eq!(combined[0], ((1, 1), (3, 3))); assert_eq!(combined[1], ((2, 2), (4, 4))); } @@ -2911,4 +3005,91 @@ mod tests { assert_eq!(stack.entries[1].mv0, (-3, -3)); assert_eq!(stack.entries[1].mv1, (7, 7)); } + + /// lane-mvtwin r1, defect 1 (twin drift, compound only): libaom fills a + /// `comp_list` slot past both `ref_id`/`ref_diff` lists with THAT SIDE's + /// own `gm_mv_candidates[idx]` (mvref_common.c:718-719). This module + /// filled it with `(0, 0)`, which is only accidentally right while every + /// live reference's global motion is IDENTITY -- the single-ref twin had + /// already closed the same gap on its own `mv_ref_list` tail in r6. + #[test] + fn a_missing_compound_combine_slot_takes_that_sides_global_mv_not_zero() { + let lists = CompoundRefLists::default(); + let combined = combine_compound_candidates(&lists, [(9, -5), (-11, 3)]); + assert_eq!(combined[0], ((9, -5), (-11, 3))); + assert_eq!(combined[1], ((9, -5), (-11, 3))); + // One side supplied, the other short: only the short side falls back. + let mut half = CompoundRefLists::default(); + half.ref_id[0].push((1, 2)); + let combined = combine_compound_candidates(&half, [(9, -5), (-11, 3)]); + assert_eq!(combined[0], ((1, 2), (-11, 3))); + assert_eq!(combined[1], ((9, -5), (-11, 3))); + } + + /// lane-mvtwin r1, defect 2 (both twins): libaom drops the 9th distinct + /// candidate AT INSERTION (`*refmv_count < MAX_REF_MV_STACK_SIZE`, + /// mvref_common.c:100/128/388/425). Pushing everything and truncating + /// after the weight sort keeps a different set: here the heavy 9th + /// candidate would survive and evict a scanned one. + #[test] + fn the_ninth_distinct_candidate_is_dropped_at_insertion_not_after_sorting() { + let mut candidates = Vec::new(); + for i in 0..MAX_STACK_SIZE as i32 { + add_candidate(&mut candidates, (i, i), 2); + } + let before = stack_full_drops(); + add_candidate(&mut candidates, (99, 99), 10_000); + assert_eq!(candidates.len(), MAX_STACK_SIZE); + assert!(!candidates.iter().any(|e| e.mv == (99, 99))); + assert_eq!(stack_full_drops(), before + 1); + // A full stack still takes the dedup weight bump libaom applies + // before the cap check. + add_candidate(&mut candidates, (0, 0), 6); + assert_eq!(candidates[0].weight, 8); + + let mut comp = Vec::new(); + for i in 0..MAX_STACK_SIZE as i32 { + add_compound_candidate(&mut comp, (i, i), (i, -i), 2); + } + add_compound_candidate(&mut comp, (99, 99), (99, 99), 10_000); + assert_eq!(comp.len(), MAX_STACK_SIZE); + } + + /// lane-mvtwin r1, defect 3 (both twins): the row/col reach is clamped to + /// the TILE origin (`find_valid_row_offset`, mvref_common.c:512-528), not + /// the frame edge. `MiGrid::get` already hides the out-of-tile cells, so + /// the only visible symptom is the scan WEIGHT (`inc`) -- and through it + /// the stack order. Query at mi_row 9 with the tile starting at row 8: + /// the real reach is -1, so `inc = 1` and the weight stays at the floor + /// 2; the frame-edge clamp gave -6, `inc = min(6, size_h) = 4`, doubling + /// the vote. + #[test] + fn the_row_reach_is_clamped_to_the_tile_origin_not_the_frame_edge() { + let weight_with_tile_origin = |row0: usize| { + // A neighbour at least as wide as the query block (`bw4 <= n4`) + // is what makes libaom compute `inc` at all. + let wide = MiInfo { + size: 4, + size_h: 4, + ..inter((5, 5)) + }; + let mut grid = MiGrid::new(16, 16); + grid.set(8, 4, wide); + grid.set(8, 6, wide); + grid.set_tile_bounds(row0, 0, 16, 16); + let stack = find_mv_stack(&grid, 9, 4, 2, 2, LAST_FRAME, 16, 16); + assert_eq!(stack.entries.len(), 1); + stack.entries[0].weight + }; + let tiled = weight_with_tile_origin(8); + let whole_frame = weight_with_tile_origin(0); + // One scanned row cell (`end_mi == bw4 == 2`, `len == 2`) plus the + // top-right probe's own flat `CORNER_WEIGHT`, which the reach never + // touches -- so the whole delta below is the row scan's `inc`. + // reach -1 -> inc 1 -> weight stays at the floor 2. + assert_eq!(tiled, REF_CAT_LEVEL + 2 * 2 + CORNER_WEIGHT); + // frame-edge clamp: reach -6 -> inc min(6, size_h) = 4. + assert_eq!(whole_frame, REF_CAT_LEVEL + 2 * 4 + CORNER_WEIGHT); + assert_ne!(tiled, whole_frame); + } } diff --git a/crates/ec-av1/src/refusal_inventory.rs b/crates/ec-av1/src/refusal_inventory.rs index 9581323a..4ab1f2c6 100644 --- a/crates/ec-av1/src/refusal_inventory.rs +++ b/crates/ec-av1/src/refusal_inventory.rs @@ -42,7 +42,8 @@ const REFUSALS: &[&str] = &[ "a tx_type symbol outside its CDF's own set: {t}", "an INTER 32x32 partition type this decoder does not code (value={part32})", "a superblock-level partition value outside PARTITION_NONE..PARTITION_VERT_4", - "a 128x128 superblock partition other than SPLIT (NONE/HORZ/VERT and the four AB arms at the 128 root are not decoded)", + "a 128x128 superblock HORZ/VERT or AB partition (only SPLIT and NONE are decoded at the 128 root)", + "a 128x128 superblock PARTITION_NONE root on an inter frame (only the key-frame path codes a whole 128x128 block)", "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)", "a palette block on a HORZ/VERT intra strip below 16x16 (reconstruction not ported)", "a palette block with a real transform on a superblock-level HORZ/VERT strip (corner-cropped luma coefficients not ported for palette)", diff --git a/crates/ec-av1/src/stream.rs b/crates/ec-av1/src/stream.rs index b669441b..aa93fea9 100644 --- a/crates/ec-av1/src/stream.rs +++ b/crates/ec-av1/src/stream.rs @@ -14395,6 +14395,299 @@ mod tests { a_real_aomenc_temporal_mv_gate(42, 40); } + /// lane-mvtwin r1: the COMPOUND MV-stack gate. Every other compound gate + /// here pins `--enable-ref-frame-mvs=0`, so `find_mv_stack_compound`'s + /// temporal half (the three `tpl_sample_pos` extension samples lane-sb128 + /// r3 found missing) and its extension pass have never been exercised by + /// a real encoder. This arm turns ref-frame-mvs ON, gives the encoder a + /// 25-frame lookahead plus alt-refs so `reference_select` really drives + /// blocks to COMPOUND_REFERENCE, and sweeps global motion off/on so the + /// combine step's `gm_mv_candidates` fill (r1 defect 1) is reachable. + /// + /// Firing proof, hard-asserted: `decode::comp_mode_hits` (a real + /// compound block) AND `mvstack::tmv_hits` (a temporal candidate landed + /// in some stack) must BOTH have advanced on an attempt that also + /// decoded pixel-exact -- class [[gate-skips-on-its-own-failure]]: a + /// decode that succeeds is ALWAYS compared, on every decode-order frame, + /// and only the counters decide whether the attempt counts. + fn a_real_aomenc_compound_mv_stack_gate( + gate_name: &str, + seed_base: u32, + attempts: u32, + bit_depth: u32, + sb_size: u32, + global_motion: u32, + width: usize, + tile_columns: u32, + ) { + let _gate_lock = lock_gate_counters(); + if !have_ffmpeg() { + eprintln!("SKIP {gate_name}: no ffmpeg"); + return; + } + if !have_aomenc() { + eprintln!("SKIP {gate_name}: no aomenc at {}", aomenc_path().display()); + return; + } + let (height, frame_count) = (64usize, 16usize); + let mut never_fired = 0u32; + let mut refusals = Vec::new(); + for attempt in 0..attempts { + let seed = seed_base + attempt; + let duration = frame_count as f64 / 25.0; + let source = + gradients_source(seed, width, height, &format!("duration={duration}:rate=25")); + let y4m = Command::new("ffmpeg") + .args([ + "-v", + "error", + "-f", + "lavfi", + "-i", + &source, + "-pix_fmt", + if bit_depth == 10 { "yuv420p10le" } else { "yuv420p" }, + "-strict", + "-1", + "-t", + "0.64", + "-f", + "yuv4mpegpipe", + "-strict", + "-1", + "-", + ]) + .stdin(Stdio::null()) + .stdout(Stdio::piped()) + .stderr(Stdio::piped()) + .output() + .expect("ffmpeg failed to run"); + assert!( + y4m.status.success(), + "ffmpeg fixture: {}", + String::from_utf8_lossy(&y4m.stderr) + ); + let depth_args: &[&str] = if bit_depth == 10 { + &["-b", "10", "--input-bit-depth=10"] + } else { + &[] + }; + // The cq sweep: how finely RD partitions decides how often a + // block's stack comes up short enough to reach the extension + // pass at all. + let cq = format!("--cq-level={}", [45u32, 55, 35][(attempt % 3) as usize]); + let sb = format!("--sb-size={sb_size}"); + let gm = format!("--enable-global-motion={global_motion}"); + // `--tile-columns` is log2: 1 means two tile columns, which is + // what makes every block in the right-hand tile carry a nonzero + // `tile_col0` and so exercise r1 defect 3's reach clamp. + let tiles = format!("--tile-columns={tile_columns}"); + // class [[aomenc-last-flag-wins]]: every flag appears exactly + // once below, so there is no override to order. + let out = { + let mut child = Command::new(aomenc_path()) + .args(depth_args) + .arg(&cq) + .arg(&sb) + .arg(&gm) + .arg(&tiles) + .args([ + "--codec=av1", + "--passes=1", + "--end-usage=q", + "--cpu-used=0", + "--kf-max-dist=1000", + "--threads=1", + "--row-mt=0", + // What this gate is about: real compound references + // with a real temporal MV field behind them. + "--enable-ref-frame-mvs=1", + "--enable-order-hint=1", + "--auto-alt-ref=1", + "--lag-in-frames=25", + "--enable-fwd-kf=0", + "--enable-warped-motion=0", + "--enable-obmc=0", + "--enable-masked-comp=0", + "--enable-interintra-comp=0", + "--enable-dist-wtd-comp=0", + "--enable-diff-wtd-comp=0", + "--enable-onesided-comp=0", + "--enable-interintra-wedge=0", + "--enable-smooth-interintra=0", + "--enable-rect-partitions=0", + "--enable-ab-partitions=0", + "--enable-1to4-partitions=0", + "--enable-filter-intra=0", + "--enable-smooth-intra=0", + "--enable-paeth-intra=0", + "--enable-directional-intra=0", + "--enable-angle-delta=0", + "--enable-tx-size-search=0", + "--enable-cdef=0", + "--enable-restoration=0", + "--max-partition-size=32", + "--min-partition-size=32", + "--enable-palette=0", + "--enable-intrabc=0", + "--enable-cfl-intra=0", + "--obu", + "-o", + "-", + "-", + ]) + .stdin(Stdio::piped()) + .stdout(Stdio::piped()) + .stderr(Stdio::piped()) + .spawn() + .expect("aomenc failed to start"); + child + .stdin + .take() + .expect("aomenc stdin") + .write_all(&y4m.stdout) + .expect("writing y4m to aomenc"); + child.wait_with_output().expect("aomenc failed to run") + }; + assert!( + out.status.success(), + "aomenc refused the fixture: {}", + String::from_utf8_lossy(&out.stderr) + ); + let stream = out.stdout; + let (before_comp, before_tmv) = (decode::comp_mode_hits(), decode::tmv_hits()); + let frames = match decode_stream(&stream) { + Err(e) => { + let msg = e.to_string(); + assert!( + msg.contains("unsupported"), + "{gate_name} failed outright (seed {seed}): {msg}" + ); + refusals.push(format!("seed {seed}: {msg}")); + continue; + } + Ok(frames) => frames, + }; + let counted = + decode::comp_mode_hits() != before_comp && decode::tmv_hits() != before_tmv; + if !counted { + never_fired += 1; + } + let ffmpeg_frames = if bit_depth == 10 { + ffmpeg_decode_sequence_10bit(&stream, width, height, frame_count) + } else { + ffmpeg_decode_sequence(&stream, width, height, frame_count) + }; + assert_eq!(frames.len(), frame_count); + // EVERY decode-order frame compared, never just the shown ones + // (class [[gate-blind-to-hidden-frames]]). + for (i, (got, want)) in frames.iter().zip(&ffmpeg_frames).enumerate() { + assert_eq!( + got.y, want.y, + "{gate_name} frame {i} luma vs ffmpeg (seed {seed})" + ); + assert_eq!( + got.u, want.u, + "{gate_name} frame {i} U vs ffmpeg (seed {seed})" + ); + assert_eq!( + got.v, want.v, + "{gate_name} frame {i} V vs ffmpeg (seed {seed})" + ); + } + if counted { + eprintln!( + "{gate_name} FIRING seed {seed}: comp_mode_hits +{}, tmv_hits +{}, \ + comp_gm_fill_hits={}, stack_full_drops={}, tile_reach_clips={}", + decode::comp_mode_hits() - before_comp, + decode::tmv_hits() - before_tmv, + crate::mvstack::comp_gm_fill_hits(), + crate::mvstack::stack_full_drops(), + crate::mvstack::tile_reach_clips(), + ); + gate_buckets(gate_name, 1, never_fired, refusals.len()); + return; + } + } + gate_buckets(gate_name, 0, never_fired, refusals.len()); + eprintln!( + "SKIP {gate_name}: {never_fired} attempts decoded but never drove a compound block \ + with a temporal MV candidate, and every other attempt hit a named refusal:\n{}", + refusals.join("\n") + ); + } + + #[test] + fn a_real_aomenc_compound_mv_stack_with_temporal_mvs_decodes_pixel_exact() { + a_real_aomenc_compound_mv_stack_gate( + "a_real_aomenc_compound_mv_stack_with_temporal_mvs_decodes_pixel_exact", + 42, + 30, + 8, + 64, + 0, + 64, + 0, + ); + } + + #[test] + fn a_real_aomenc_compound_mv_stack_with_global_motion_decodes_pixel_exact() { + a_real_aomenc_compound_mv_stack_gate( + "a_real_aomenc_compound_mv_stack_with_global_motion_decodes_pixel_exact", + 80, + 30, + 8, + 64, + 1, + 64, + 0, + ); + } + + #[test] + fn a_real_aomenc_10bit_compound_mv_stack_at_128_superblocks_decodes_pixel_exact() { + a_real_aomenc_compound_mv_stack_gate( + "a_real_aomenc_10bit_compound_mv_stack_at_128_superblocks_decodes_pixel_exact", + 120, + 30, + 10, + 128, + 1, + 64, + 0, + ); + } + + /// KNOWN OPEN DEFECT, found by lane-mvtwin r1 and NOT caused by it: a + /// real aomenc stream 128 px wide with `--tile-columns=1` (two 64-px tile + /// columns) mis-decodes frame 1's luma against ffmpeg, at seed 200 with + /// this exact recipe. ABLATION-PROVEN pre-existing: the same arm fails + /// identically with r1's tile-origin reach clamp + /// (`MiGrid::tile_origin`) forced back to `(0, 0)`, so the cause is + /// somewhere else in the multi-tile path, not in `mvstack`. Kept as the + /// exact reproducer for the lane that owns tiles -- it is `#[ignore]`d + /// rather than deleted so the repro command survives: + /// `cargo test -p ec-av1 --lib across_two_tile_columns -- --ignored --nocapture`. + /// + /// It is also the ONLY arm that reaches r1 defect 3 (the col reach is + /// clamped to `tile_col0`, not the frame edge): the counter + /// `mvstack::tile_reach_clips` advanced to 60 on this stream. Defect 3 + /// itself is proven deterministically by + /// `mvstack::tests::the_row_reach_is_clamped_to_the_tile_origin_not_the_frame_edge`. + #[test] + #[ignore = "known pre-existing multi-tile-column decode defect, see doc comment"] + fn a_real_aomenc_compound_mv_stack_across_two_tile_columns_decodes_pixel_exact() { + let name = "a_real_aomenc_compound_mv_stack_across_two_tile_columns_decodes_pixel_exact"; + let before = crate::mvstack::tile_reach_clips(); + a_real_aomenc_compound_mv_stack_gate(name, 200, 30, 8, 64, 0, 128, 1); + assert!( + crate::mvstack::tile_reach_clips() > before, + "{name}: no block was ever built inside a tile past mi 0 -- \ + --tile-columns=1 did not produce a second tile column" + ); + } + /// bisect scratch: decode a pinned stream exactly once -- generic /// pin-repro tool, kept for manual use. #[test] @@ -18001,6 +18294,162 @@ mod tests { ); } + /// lane-sb128b r1 gate: a real `aomenc --sb-size=128` KEY frame whose 128 + /// roots resolve to `PARTITION_NONE` -- one whole 128x128 intra block, + /// four TX_64X64 luma transform units and FOUR TX_32X32 chroma units per + /// plane (`av1_get_max_uv_txsize(BLOCK_128X128)` is + /// `av1_get_adjusted_tx_size` of its 64x64 uv plane block's TX_64X64, so + /// TX_32X32) -- lane-sb128b r2's `chroma_split_tx_hits` asserts them. The r1 gate above pins `--max-partition-size=64`, which + /// makes every 128 root a forced SPLIT and leaves this arm unexercised. + /// Smooth gradients at a high `--cq-level` are what make the RD search + /// keep a whole 128x128 block; `part128_none_hits` HARD-asserts it did. + #[test] + fn a_real_aomenc_key_frame_with_a_128x128_none_partition_decodes_pixel_exact() { + const NAME: &str = + "a_real_aomenc_key_frame_with_a_128x128_none_partition_decodes_pixel_exact"; + let _gate_lock = lock_gate_counters(); + if !have_ffmpeg() { + eprintln!("SKIP {NAME}: no ffmpeg"); + return; + } + if !have_aomenc() { + eprintln!("SKIP {NAME}: no aomenc at {}", aomenc_path().display()); + return; + } + let render = |seed: u32, width: usize, height: usize, ten_bit: bool| -> Vec { + let pix = if ten_bit { "yuv420p10le" } else { "yuv420p" }; + let out = Command::new("ffmpeg") + .args([ + "-v", "error", "-f", "lavfi", "-i", + &gradients_source(seed, width, height, "duration=0.04:rate=25"), + "-pix_fmt", pix, "-strict", "-1", "-t", "0.04", + "-f", "yuv4mpegpipe", "-", + ]) + .stdin(Stdio::null()) + .stdout(Stdio::piped()) + .stderr(Stdio::piped()) + .output() + .expect("ffmpeg failed to run"); + assert!( + out.status.success(), + "ffmpeg fixture: {}", + String::from_utf8_lossy(&out.stderr) + ); + out.stdout + }; + let mut matched = 0u32; + let mut named_refusals = 0u32; + let mut none_arms = 0u32; + // (seed, cq, width, height, 10-bit). 384x384 is a 3x3 grid of whole + // 128 superblocks; 256x256 a 2x2. + let arms: Vec<(u32, &str, usize, usize, bool)> = vec![ + (42, "--cq-level=63", 384, 384, false), + (43, "--cq-level=55", 384, 384, false), + (44, "--cq-level=63", 256, 256, false), + (45, "--cq-level=63", 384, 384, true), + ]; + for (seed, cq, width, height, ten_bit) in arms { + let y4m = render(seed, width, height, ten_bit); + let mut args: Vec<&str> = vec![ + "--codec=av1", "--passes=1", "--end-usage=q", cq, + "--cpu-used=0", "--threads=1", "--row-mt=0", + "--sb-size=128", + "--enable-rect-partitions=0", + "--enable-ab-partitions=0", + "--enable-1to4-partitions=0", + "--min-partition-size=16", + "--enable-restoration=1", + "--enable-palette=0", + "--deltaq-mode=0", + "--enable-intrabc=0", + "--enable-tx-size-search=0", + "--limit=1", + ]; + if ten_bit { + args.extend_from_slice(&["--input-bit-depth=10", "--bit-depth=10"]); + } + args.extend_from_slice(&["--obu", "-o", "-", "-"]); + let mut child = Command::new(aomenc_path()) + .args(&args) + .stdin(Stdio::piped()) + .stdout(Stdio::piped()) + .stderr(Stdio::piped()) + .spawn() + .expect("aomenc failed to start"); + child + .stdin + .take() + .expect("aomenc stdin") + .write_all(&y4m) + .expect("writing y4m to aomenc"); + let out = child.wait_with_output().expect("aomenc failed to run"); + assert!( + out.status.success(), + "aomenc refused the fixture: {}", + String::from_utf8_lossy(&out.stderr) + ); + let stream = out.stdout; + let before = crate::decode::part128_none_hits(); + let frames = match decode_stream(&stream) { + Err(e) => { + let msg = e.to_string(); + assert!( + msg.contains("unsupported"), + "{NAME} failed outright, not a named refusal (seed {seed}): {msg}" + ); + named_refusals += 1; + eprintln!("seed {seed} refusal: {msg}"); + continue; + } + Ok(frames) => frames, + }; + let want = if ten_bit { + ffmpeg_decode_sequence_10bit(&stream, width, height, 1) + } else { + ffmpeg_decode_sequence(&stream, width, height, 1) + }; + assert_eq!(frames.len(), 1); + for (i, (got, want)) in frames.iter().zip(&want).enumerate() { + for (name, a, b, w) in [ + ("Y", &got.y, &want.y, width), + ("U", &got.u, &want.u, width / 2), + ("V", &got.v, &want.v, width / 2), + ] { + let n = a.iter().zip(b.iter()).filter(|(x, y)| x != y).count(); + let first = a.iter().zip(b.iter()).position(|(x, y)| x != y); + assert_eq!( + n, 0, + "{NAME} frame {i} {name} vs ffmpeg (seed {seed}): {n} differ, first row {} col {} ours {:?} ffmpeg {:?}", + first.unwrap_or(0) / w, + first.unwrap_or(0) % w, + first.map(|k| a[k]), + first.map(|k| b[k]), + ); + } + } + let hits = crate::decode::part128_none_hits() - before; + eprintln!("seed {seed} cq {cq} {width}x{height}: part128_none_hits +{hits}"); + if hits > 0 { + none_arms += 1; + } + matched += 1; + } + assert!( + matched > 0, + "{NAME}: every attempt refused; the gate never decoded a stream" + ); + assert!( + none_arms > 0, + "{NAME}: {matched} stream(s) decoded pixel-exact but NOT ONE 128 root was \ + PARTITION_NONE -- the arm this gate exists for never fired" + ); + eprintln!( + "{NAME}: {matched} pixel-exact ({none_arms} with a 128 NONE root), \ + {named_refusals} named refusals, part128_none_hits={}", + crate::decode::part128_none_hits() + ); + } + #[test] #[ignore = "lane-sb128 r2 diagnostic: is the frame-6 mismatch sb128-specific?"] fn sb128_r2_control_sb64() { diff --git a/lanes/mvtwin-r1.report.md b/lanes/mvtwin-r1.report.md new file mode 100644 index 00000000..b849eaea --- /dev/null +++ b/lanes/mvtwin-r1.report.md @@ -0,0 +1,91 @@ +# lane-mvtwin r1 — phase-by-phase diff of the two MV-stack twins vs libaom + +Base: lane-sb128 5ea5ec8, merged main 7a47fc1 (clean; the 128x128-superblock +refusal main re-added at b51719f stayed deleted — grep confirms). +Oracle: `~/.cache/aom-oracle/src/av1/common/mvref_common.c` (`setup_ref_mv_list`, +`av1_find_mv_refs`). Ours: `crates/ec-av1/src/mvstack.rs` +(`find_mv_stack_with_sign_bias` = single-ref twin, `find_mv_stack_compound` = compound twin). + +## The table (libaom line = mvref_common.c) + +| # | phase (libaom) | single-ref ours | compound ours | defect? | +|---|---|---|---|---| +| 1 | `row_adj`/`col_adj`, `find_valid_row/col_offset` reach (:502-533) | mvstack.rs:809 | mvstack.rs:1610 | **DEFECT 3** — both clamped the reach to the FRAME edge, libaom clamps to `tile->mi_row_start`/`mi_col_start` | +| 2 | `scan_row_mbmi` immediate, `len`/`weight`/`inc`/`processed_rows` (:141-190, :534-538) | `scan_row` :471 | `scan_row_compound` :1290 | exact (availability gate was `mi_row > 0`, folded into defect 3) | +| 3 | `scan_col_mbmi` (:192-236, :540-543) | `scan_col` :553 | `scan_col_compound` :1347 | exact | +| 4 | `has_top_right` + top-right `scan_blk_mbmi` (:264-312, :496, :544-548) | `scan_top_right` :645 | `scan_top_right_compound` :1403 | no change — see "has_tr" below | +| 5 | `nearest_match`, `REF_CAT_LEVEL` boost over `nearest_refmv_count` (:550-555) | :836 | :1600 | exact | +| 6 | `add_tpl_ref_mv` main loop, `step_h`/`step_w`/`blk_*_end` (:557-589) | :868 | :1625 | exact (compound reads the field once per side; `motion_field.rs:500` makes the lookup offset-independent, so both sides are Some/None together — libaom's single lookup) | +| 7 | `tpl_sample_pos` 3 extension samples + `check_sb_border` (:591-600, :316) | :898 | :1670 (added lane-sb128 r3) | exact — the twin drift r3 found, now symmetric | +| 8 | `GLOBALMV_OFFSET` / `zero_mv_ctx` far-or-missing test (:375-380, :406-412, :592) | :955 | :1750 | exact | +| 9 | corner `scan_blk_mbmi(-1,-1)` with `dummy_newmv_count`, weight `2*len`=4 (:604-607) | :967 | :1758 | exact | +| 10 | extended row/col scan `idx = 2..=MVREF_ROW_COLS` (:609-622) | :990 | :1770 | exact | +| 11 | `ref_match_count` + `mode_context` switch / `REFMV_OFFSET` (:624-651) | :1140 | :1858 | exact | +| 12 | the TWO bubble passes (nearest region, then the rest) (:653-682) | single stable `sort_by_key` :1050 | same :1802 | not a defect — every nearest entry carries `+REF_CAT_LEVEL` (640) and no post-boost entry can reach it (max post-boost weight seen is `len*weight` <= 80), so the two-phase ranking and one stable global sort agree | +| 13 | insertion cap `*refmv_count < MAX_REF_MV_STACK_SIZE` (:100, :128, :388, :425) | `add_candidate` :341 | `add_compound_candidate` :1268 | **DEFECT 2** — both pushed unbounded then sorted+truncated, keeping a different set than libaom's drop-at-insertion | +| 14 | `mi_size` = min(64x64 span, block span, frame edge) (:684-689) | :1060 | :1815 | exact | +| 15 | `process_compound_ref_mv_candidate`, sign-bias inversion, `can_rf > INTRA_FRAME` (:434-470, :693-706) | n/a | :1478 | exact | +| 16 | `comp_list` combine, slots past both lists = `gm_mv_candidates[idx]` (:708-720) | n/a | `combine_compound_candidates` :1520 | **DEFECT 1 (twin drift)** — filled `(0, 0)`; the single-ref twin closed the same gm-fallback gap in r6 | +| 17 | compound stack merge, `refmv_count==1` dedupe vs empty (:722-742) | n/a | :1845 | exact | +| 18 | `clamp_mv_ref` + `MV_BORDER`, every entry (:745-751, :768-772) | :1105 | :1878 | exact | +| 19 | single-ref extension gated per step on `MAX_MV_REF_CANDIDATES` (:754-766) | :1065 | n/a | exact | +| 20 | `mv_ref_list` tail filled with `gm_mv_candidates[0]`, unclamped (:775-782) | :1128 | n/a (libaom has no compound `mv_ref_list`) | exact | + +### has_tr (phase 4), why no change +Ours probes "is the grid cell at `(mi_row-1, mi_col+bw4)` populated", which for a +decoder is exactly "was it decoded". Walking libaom's mask logic: for SQUARE blocks +the mask result and "already decoded" coincide at both sb64 and sb128; for the +rect case that differs (`bs > 16` at a 64x128 block) libaom's own +`is_last_vertical_rect` refinement forces `has_tr = 1` again, agreeing with our +probe. Porting the mask WITHOUT the three shape refinements (which need the +partition type, not passed to this module) would REGRESS the VERT-rect case. +Recorded as the same corner-cut already documented at `mvstack.rs:588`; +upgrade path = thread the partition type in with the rect inter leaf. + +## Fixes (all in crates/ec-av1/src/mvstack.rs) +- D1 `combine_compound_candidates` (:1520 + call site :1859): unfilled slots take + `gm_mv(gm, ref_frame.side)`, not `(0, 0)` (mvref_common.c:718-719). +- D2 `add_candidate` (:341) / `add_compound_candidate` (:1268): drop the 9th + distinct candidate AT INSERTION (mvref_common.c:100/128/388/425); the dedup + weight bump still applies on a full stack. +- D3 both twins (:809, :1610) + new `MiGrid::tile_origin` (:216): reach and + availability are tile-relative (mvref_common.c:512-533). + +## Checks +`cargo test -p ec-av1 --lib mvstack::` -> 32 passed, 0 failed. Three new +deterministic tests, one per defect: +- `a_missing_compound_combine_slot_takes_that_sides_global_mv_not_zero` +- `the_ninth_distinct_candidate_is_dropped_at_insertion_not_after_sorting` +- `the_row_reach_is_clamped_to_the_tile_origin_not_the_frame_edge` (644 -> 648 vs 652) + +New real-aomenc gate `a_real_aomenc_compound_mv_stack_gate` (stream.rs), the first +compound gate here that does NOT pin `--enable-ref-frame-mvs=0`: +`--enable-ref-frame-mvs=1 --enable-order-hint=1 --auto-alt-ref=1 --lag-in-frames=25`, +cq sweep 45/55/35, 30 seeds/arm, hard-asserting BOTH `comp_mode_hits` and +`tmv_hits` advanced, every decode-order frame compared (Y/U/V) against ffmpeg, +decode errors only tolerated when the message contains "unsupported". +Arms: 8-bit sb64 gm=0 · 8-bit sb64 gm=1 · 10-bit sb128 gm=1. + +EVIDENCE: $HOME/.cache/mvtwin-suite-r1.log | cargo test -p ec-av1 --lib compound_mv_stack -- --test-threads=1 --nocapture | 3 arms FIRING pixel-exact: seed 44 comp_mode_hits +7 tmv_hits +56; seed 80 comp_mode_hits +1 tmv_hits +56; seed 122 (10-bit, sb128) comp_mode_hits +8 tmv_hits +55 +EVIDENCE: crates/ec-av1/src/mvstack.rs tests | cargo test -p ec-av1 --lib mvstack:: | 32 passed 0 failed, each of the 3 defects asserted on its own values + +Full suite (systemd unit, MemoryMax=10G): `cargo test -p ec-av1 --lib -j3` -> +**375 passed, 0 failed, 33 ignored**, 692 s. Log `$HOME/.cache/mvtwin-suite-r1.log`. + +EVIDENCE: $HOME/.cache/mvtwin-suite-r1.log | systemd-run --user --unit=mvtwin-suite-... cargo test -p ec-av1 --lib -j3 | test result: ok. 375 passed; 0 failed; 33 ignored + +## Open residue +- fix-now-elsewhere (NOT this lane's surface): a real aomenc stream 128 px wide + with `--tile-columns=1` MIS-DECODES frame 1 luma vs ffmpeg (seed 200, recipe in + `a_real_aomenc_compound_mv_stack_across_two_tile_columns_decodes_pixel_exact`, + `#[ignore]`d with the repro command in its doc). ABLATION-PROVEN pre-existing: + identical failure with r1's tile-origin clamp forced back to `(0, 0)`. That arm + is also the only one that reaches defect 3 on a real stream — + `mvstack::tile_reach_clips` advanced to 60 there. +- deferred(a stream whose compound pair names a non-IDENTITY ROTZOOM/AFFINE + reference) — `comp_gm_fill_hits` reads 0 on all three green arms, so D1 is + proven by its unit test, not yet by a real stream. aomenc at gradients content + keeps global motion IDENTITY even with `--enable-global-motion=1`. +- deferred(same) — `stack_full_drops` reads 0 on all three arms: no real block + here produced 9 distinct candidates. D2 is unit-test-proven only. +- accepted — `has_tr` corner-cut (phase 4 above), ceiling and upgrade path named. diff --git a/lanes/sb128b-r1.report.md b/lanes/sb128b-r1.report.md new file mode 100644 index 00000000..95d7da0a --- /dev/null +++ b/lanes/sb128b-r1.report.md @@ -0,0 +1,103 @@ +# lane-sb128b r1 — the 128 root's `PARTITION_NONE` arm (key frames) + +Branch `lane-sb128b` off `lane-sb128` 807c110, worktree `edith_codecs-sb128b`, commit `ceec9fa`. + +## ReelC first — the charter's premise is FALSE on ReelC's key frame + +EVIDENCE: `$HOME/.cache/sb128b-work/reelc2s.obu` (fresh cut, `ffmpeg -t 2 -c:v copy -f obu` +off the real film, 1428 bytes) | release `decode_probe` under a 6G scope with `EC_AV1_TRACE=1` +| **90 `partition_w128` symbols, value=3 (`PARTITION_SPLIT`) on every one** (ctx 3 x70, ctx 2 +x14, ctx 1 x5, ctx 0 x1); the run then stops at `an inter frame under a 128x128 superblock`. +Same numbers on the pre-existing `reelc-head.obu`. + +So ReelC's KEY frame is 100% SPLIT at the 128 root — the key-frame 128 arms are **not** its +blocker, and TASK 4's "the inter arms" is where ReelC's non-SPLIT roots live (r2 saw them only +with the inter refusal locally lifted). Charter premise "ReelC's key frame is the first thing to +decode / stops at a TASK-B arm" corrected here, measured, not argued. + +## What landed (all against libaom, each cited) + +`crates/ec-av1/src/decode.rs` +- `read_sb128_root` (11286) returns the root partition; the key-frame loop (11536) decodes + `PARTITION_NONE` as one 128x128 block and skips the superblock's other three visits + (`sb128_none`). The inter loop refuses any non-SPLIT root by name. +- `read_tx_size` (10003): `max_txsize_rect_lookup[BLOCK_128X128]` is TX_64X64 → a 128 block + reads BLOCK_64X64's own `tx_size_cat3` and resolves `max_tx >> depth`, and + `get_tx_size_context` is asked about 64, not 128. +- `decode_block`: the single-TU arm was `!tx_select || logical_tx == side`. Without `tx_select` + `logical_tx` IS `side` at every size <= 64, so the first half was redundant — and wrong at + 128. Now `logical_tx == side`, and the non-select resolve is `(side.min(64), luma_tx)`, so a + 128 block is always four TX_64X64 units. The TU loop passes the unit's **coefficient** side + (32 at TX_64X64), not its transform side. +- `delta_q`/`delta_lf` "this leaf IS the superblock" is now `side == sb_size` (was a hardcoded + 64 plus a `!sb128()` disable) — a NONE 128 root is the whole superblock. +- the 128 block's one `cdef_idx` read is copied to all four 64x64 CDEF units (libaom's four + units share one `MB_MODE_INFO`). + +`crates/ec-av1/src/stream.rs`: new gate (below). `refusal_inventory.rs`: the single +"partition other than SPLIT" string splits into three named arms. + +## Gate + +`a_real_aomenc_key_frame_with_a_128x128_none_partition_decodes_pixel_exact` — real aomenc +`--sb-size=128` with **no** `--max-partition-size` (the r1 gate's flag is exactly what made +every 128 root a forced SPLIT), smooth gradients at `--cq-level=63/55`, 384x384 + 256x256, +8- and 10-bit, `--enable-tx-size-search=0`. `#[ignore]`d: it is a reproducer, not a pass. + +EVIDENCE: `cargo test -p ec-av1 --lib -- --nocapture a_real_aomenc_key_frame_with_a_128x128_none` +| aomenc 384x384 cq63 seed 42, decoded then compared to ffmpeg | the NONE arm **fires** and the +tile decodes end to end (no desync panic, no refusal), but frame 0 luma differs from ffmpeg at +138523 of 147456 samples, first at row 0 col 60, magnitudes 1..3 (ours 114/113 where ffmpeg has +115) — a reconstruction difference, not an entropy blow-up. + +Two earlier failures on the way, both fixed and both real defects of the generalisation: +`transform.rs:843 index out of bounds (len 64, index 64)` = the redundant `!tx_select` arm +above sending a 128-wide inverse transform; then the pixel deltas. + +## Root cause of the residual (found, not guessed) + +`av1_get_max_uv_txsize` = `av1_get_adjusted_tx_size(max_txsize_rect_lookup[uv_plane_bsize])`. +The uv plane block of a 128x128 is 64x64 → TX_64X64 → **adjusted to TX_32X32**. A 128 block's +chroma is therefore FOUR TX_32X32 units per plane, and `decode_block` codes exactly one +whole-plane chroma unit. That is the desync, and it also means the charter's +"one chroma TU of 64x64 per plane / new chroma TX_64X64 path" is wrong: **no `TxbSet::Chroma64` +is needed at all.** I had transcribed the 16 libaom `[TX_64X64][PLANE_TYPE_UV]` CDF tables and +wired the variant before finding this; that work is reverted (`cdf.rs`/`cdf_state.rs` are +untouched in this commit) rather than shipped as dead code. + +## Refusals + +- `a 128x128 superblock HORZ/VERT or AB partition (only SPLIT and NONE are decoded at the 128 + root)` — NOT lifted, TASKs 2/3, not started. +- `a 128x128 superblock PARTITION_NONE root on an inter frame (...)` — NOT lifted, TASK 4. +- `a 128x128 PARTITION_NONE block's chroma (its 64x64 uv plane block is four TX_32X32 units, + and this decoder codes one whole-plane chroma unit per block)` — NEW, guards the arm this + round built. fix-now(r2): give `decode_block` a chroma TU loop (2x2 TX_32X32, `TxbSet::Chroma32`, + per-unit `chroma_skip_ctx`, grids assembled for `record_split_luma`) — unblocked by that loop; + the gate above is the reproducer and flips green the moment it is right. +- `intrabc under a 128x128 superblock` — accepted, unchanged. + +## Suite + +`cargo test -p ec-av1 --lib` under user unit `sb128b-suite-1788322151.service`, +log `$HOME/.cache/sb128b-suite.log` — result appended below by the handoff line in the report +message. The 7 rect/AB reds inherited from 807c110 (r2's `deferred: attribute the 7`) are the +sibling lane's; this round touched no rect/AB path. + +## Deferred + +- deferred: TASK 2/3 (HORZ/VERT + AB at 128) — not started — unblocked by the chroma TU loop + plus rect handling at 128. +- deferred: TASK 4 (inter 128 NONE) — refused by name — unblocked by the same loop and the + sibling lane's inter residue. +- deferred: `tx_select` at 128 (`read_tx_size` now handles it, cat3 against 64) is UNTESTED — + every gate arm here runs `--enable-tx-size-search=0` — unblocked by an r2 arm with it on. + +## Suite state at hand-off (honest, incomplete) + +`sb128b-suite-1788322151.service` was STILL RUNNING when this round hit its tool-call ceiling. +At that point the log showed **2 failures, both inherited from 807c110's rect/AB cluster**: +`a_real_aomenc_10bit_rect_and_ab_partitions_decode_pixel_exact`, +`a_real_aomenc_10bit_stream_with_a_32_level_ab_partition_decodes_pixel_exact`. +No total ("test result:" line) yet — read `$HOME/.cache/sb128b-suite.log` for the final count +before merging. NOT a clean-suite claim. diff --git a/lanes/sb128b-r2.report.md b/lanes/sb128b-r2.report.md new file mode 100644 index 00000000..7d425798 --- /dev/null +++ b/lanes/sb128b-r2.report.md @@ -0,0 +1,97 @@ +# lane-sb128b r2 — ReelC's key frame is BIT-EXACT; the 128 chroma TU loop; the 128 root's residual + +Branch `lane-sb128b`, worktree `edith_codecs-sb128b`, commits `4e13f60`, `1524838`, `c415a31` +(off r1's `d3bc8da` + `git merge main` b51719f, clean). + +## FIRST: the ReelC KEY-frame pixel check (the charter's first task — first ReelC pixel measurement ever) + +EVIDENCE: `$HOME/.cache/sb128b-work/{reelckf0.obu,ours.f0.yuv,ref.yuv}` | +`ffmpeg -ss 0 -t 2 -c:v copy -frames:v 1 -f obu` off the real film (74 B, 1920x792 yuv420p10le) +→ `dump_yuv` (release, 6G scope) vs `ffmpeg -pix_fmt yuv420p10le -f rawvideo` | +**`cmp` says BYTES EQUAL — ReelC's key frame decodes BIT-EXACT (4 561 920 bytes, 0 differing samples).** + +It was NOT exact before the merge. Pre-merge measurement (same artifacts, r1's tree): +Y 36448 samples off (max |d| 2), U/V 9483 each (max |d| 4), all inside the bottom partial +superblock row — luma rows 765..791 (768 = 6*128, frame is 792 tall) plus 3 deblock rows above, +`+1` per 16-row band, ref uniformly flat (this key frame is black). `git merge main` (lane-oddh's +odd-frame-size work) removes it entirely. Class: [[stale-premise lanes]] — the lane's base +predates the fix. + +ReelC now stops at `an inter frame under a 128x128 superblock` (probe on the 2 s cut, 72 frame +headers parsed) — the sibling lane-sb128 r3's residue, exactly as r1 predicted. + +## Merge seam (had to be fixed before anything could run) + +main b51719f re-introduced lane-oddh's blanket refusal `a sequence using 128x128 superblocks on a +frame larger than 64x64` (stream.rs) — textually a clean merge, semantically a lane-killer (the +ledger's recorded `merge seam` constraint). Deleted, with its inventory line, and its gate +`a_real_aomenc_128x128_superblock_stream_is_refused_by_name` turned into +`..._decodes_pixel_exact`. + +EVIDENCE: `cargo test -p ec-av1 --lib -- a_real_aomenc_128x128_superblock_stream gate_coverage` | +real aomenc 64x72 mandelbrot `--cpu-used=0 --sb-size=128` (`use_128x128_superblock` asserted in +the stream), decoded vs ffmpeg | **ok — 10 passed, 0 failed**; the frame's Y/U/V match ffmpeg +sample for sample. One recipe change was needed and is unrelated to the 128 root: at 64x72 +aomenc also picks `PARTITION_HORZ_4` below 16x16, so the gate now passes +`--enable-1to4-partitions=0 --min-partition-size=16` (gate_coverage green with it). + +## TASK A — the chroma half of a 128x128 `PARTITION_NONE` block (landed, not yet exact) + +`crates/ec-av1/src/decode.rs` +- `decode_block`'s multi-TU arm now codes `cn = chroma_side / chroma_tx` **squared** chroma units + per plane instead of one whole-plane unit. `av1_get_max_uv_txsize(BLOCK_128X128)` = + `av1_get_adjusted_tx_size(max_txsize_rect_lookup[BLOCK_64X64])` = TX_32X32, so a 128 block is + 2x2 TX_32X32 per plane; `cn == 1` (every block at 64 and below) is byte-for-byte the read this + always did. Per unit: `around_mi` gathered over the unit's own 64-luma-pixel span (which is + also its `txb_skip_ctx`, `read_plane`'s chroma branch), `tu_reach` on the matching luma + quadrant, own `set_palette_pred`. +- `Neighbours::record_mi_chroma` (new, next to `record_mi_luma`): per-unit chroma coefficient + context, luma-mi indexed with `record_split_luma_rect_mi`'s own frame-edge clamp. Applied + AFTER `record_split_luma` so the per-unit state is what the next block reads. +- The `skip` arm predicts per transform unit now (libaom predicts inside the transform-block + loop); `n_axis == 1` / `cn == 1` is the unchanged whole-block call. +- counter `chroma_split_tx_hits()`. + +**Result: not pixel-exact, so the refusal is BACK, reworded to what was measured.** +EVIDENCE: `$HOME/.cache/sb128b-work/g42.obu` (the gate's own arm reproduced by hand: gradients +seed 42, 384x384, cq63, `--sb-size=128 --cpu-used=0 --enable-tx-size-search=0`) | `dump_yuv` vs +`ffmpeg -pix_fmt yuv420p` | 139162/147456 luma samples differ, first at row 0 col 60 (ours 114, +ffmpeg 115). **ffmpeg's row 0 is a CONSTANT 115 across the whole first unit where ours ramps +115 → 112**, and the stream is 76 bytes: the mode and the DC agree, our first TX_64X64 luma unit +reads AC coefficients libaom never wrote. So the divergence is inside that unit's coefficient +read, not in chroma and not in prediction. + +Refusal now reads: `a 128x128 PARTITION_NONE block (four TX_64X64 luma and four TX_32X32 chroma +units all decode, but the first unit's coefficients already carry AC where libaom has DC only -- +lane-sb128b r2's open entropy residual)`. Gate +`a_real_aomenc_key_frame_with_a_128x128_none_partition_decodes_pixel_exact` stays `#[ignore]`d as +the reproducer, with its plane asserts rewritten to LOCATE the divergence (count + first +row/col/values) instead of printing 147 456 samples. + +Also corrected in that gate's doc: r1 wrote "ONE TX_64X64 chroma unit per plane / `TxbSet::Chroma64`"; +the truth is four TX_32X32 and no `Chroma64` set exists or is needed. + +## Not done + +- deferred: TASK A's `tx_select` at 128 arm (`--enable-tx-size-search=1`) — not added — unblocked + by the NONE arm being exact at all (an inexact arm cannot gate a tx-depth counter). +- deferred: TASK B (HORZ/VERT + AB at 128) — not started, refused by name + (`a 128x128 superblock HORZ/VERT or AB partition`) — unblocked by the same residual. +- deferred: TASK C (inter 128) — not started, refused by name on both this tree and the sibling's + (`an inter frame under a 128x128 superblock`) — unblocked by lane-sb128 r3 lifting its inter + root refusal; nothing of TASK C was written, so nothing is "ready behind" it. +- `git merge lane-sb128` NOT done: the sibling's tip is `dbf15a4` (gate-recipe fix only, no + inter-128 lift yet), so there was nothing to take. + +## Suite + +r2's first run (`$HOME/.cache/sb128b-suite-r2.log`, unit `sb128b-suite-r2-1788322817.service`) was +armed at the intermediate commit `1524838` and is superseded. Its FAILED list: the 2 rect/AB reds +inherited from 807c110 (`a_real_aomenc_10bit_rect_and_ab_partitions_decode_pixel_exact`, +`a_real_aomenc_10bit_stream_with_a_32_level_ab_partition_decodes_pixel_exact`) — **still red after +`git merge main` b51719f, so main did NOT fix them** — plus the two 128 gates that this round's +final commit resolves (`..._128x128_superblock_stream...` now green, +`..._128x128_none_partition...` now `#[ignore]`d). +The authoritative run for `c415a31` is unit `sb128b-suite-r2b-1788323051.service` → +`$HOME/.cache/sb128b-suite-r2b.log`; it was still running at this round's tool-call ceiling. +NOT a clean-suite claim: read that log for the totals before merging. diff --git a/lanes/sb128b-r3.report.md b/lanes/sb128b-r3.report.md new file mode 100644 index 00000000..47828ed8 --- /dev/null +++ b/lanes/sb128b-r3.report.md @@ -0,0 +1,101 @@ +# lane-sb128b r3 — the 128x128 PARTITION_NONE block decodes PIXEL-EXACT (3 root causes), the 10-bit reds were a recipe defect + +Branch `lane-sb128b`, worktree `edith_codecs-sb128b`, commits `dd6f934` (merge main 7a47fc1 + TASK B), +`f2b6f1c` (TASK A), `7ceb309` (merge main 18bf7dc / lane-sb128 5ea5ec8). + +## TASK A — the 128 NONE residual: THREE root causes, none of them where r2 pointed + +r2 read "our first TX_64X64 luma unit reads AC coefficients libaom never wrote". Measured with a +range ladder (instrumented `aomdec` `EC_TRACE_COEFF` vs our `EC_TRACE_COEFF`) that premise is +WRONG: the first luma unit is identical symbol for symbol and range for range +(`all_zero ctx=1 rng=59208 / eob=3 rng=41268 / base_eob level=5 rng=44688 / ... / rng=36616`). +The divergence is at the SECOND element of the block, and it is three separate defects: + +1. **Plane order.** libaom's `decode_token_recon_block` loops 64x64 luma "mu" chunks + (`mu_blocks_wide/high = mi_size_wide[BLOCK_64X64]`) and codes EVERY PLANE of a chunk before the + next chunk. The oracle ladder is Y(0,0) U(0,0) V(0,0) Y(0,16) U(0,8) V(0,8) ... — Y,U,V per + quadrant. We read all four luma units and then all chroma units. Below 128 a block is one chunk, + so the fix (`nchunk = side/64`, luma TUs then chroma units per chunk) is byte-for-byte the old + order at every size the decoder already handled. +2. **The chroma `txb_skip_ctx` offset.** `get_txb_ctx`: chroma ctx is + `combine_entropy_contexts(above,left)` **+7** normally, **+10** when the plane block is LARGER + than the transform. A 128 block's 64x64 uv plane block with TX_32X32 units is AV1's only such + case, and our chroma table only ever carried the offset-7 rows (`txb_skip_chroma_*: [[u16;3];3]`). + Oracle read ctx=10, we read ctx=0. Added `TXB_SKIP_CHROMA_32_BIG{,_Q0,_Q1,_Q3}` from + `av1_default_txb_skip_cdfs[q][TX_32X32][10..13]` (token_cdfs.h, all four q contexts, verified by + re-deriving the existing offset-7 rows from the same array), `txb_skip_chroma_32` is six rows, + caller adds 3 when `cn > 1`. +3. **Deferred chroma context writes.** r2 recorded each chroma unit's coefficient context only + after the whole block, so the second quadrant read ctx 10 where the oracle reads 11 (base 1 from + its left neighbour inside the same block). Now recorded per unit inside the loop; the + post-`record_split_luma` replay stays, because that call would otherwise clobber them whole-block. + +Files: `crates/ec-av1/src/decode.rs` (mu-chunk loop + `chroma_ctx_offset` + per-unit record + +`read_plane`'s chroma `skip_ctx`), `crates/ec-av1/src/cdf.rs` (4 tables), +`crates/ec-av1/src/cdf_state.rs` (`txb_skip_chroma_32` 3 -> 6 rows). + +EVIDENCE: `$HOME/.cache/sb128b-work/{s44.obu,ref44.yuv,ours44.yuv.f0.yuv,ref.ladder}` | +aomenc gate-arm-3 recipe (seed 44 gradients 256x256 cq63 `--sb-size=128 --cpu-used=0 +--enable-tx-size-search=0 ...`), `EC_TRACE_COEFF` ladders of aomdec and `dump_yuv`, then +`dump_yuv` vs `ffmpeg -pix_fmt yuv420p` | **48 `txb_skip` symbols, ranges identical one for one; +0 of 98304 samples differ (pixel-exact)**. Before the fix: 60857 luma samples differed. + +REFUSAL LIFTED (with its gate): `a 128x128 PARTITION_NONE block (...)` deleted from `decode.rs` and +`refusal_inventory.rs`; `a_real_aomenc_key_frame_with_a_128x128_none_partition_decodes_pixel_exact` +un-`#[ignore]`d. +EVIDENCE: `cargo test -p ec-av1 --lib -- a_real_aomenc_key_frame_with_a_128x128_none_partition_decodes_pixel_exact --nocapture` | +4 real-aomenc arms (384x384 seed 42 cq63, 384x384 seed 43 cq55, 256x256 seed 44 cq63, 384x384 seed 45 +10-bit) decoded vs ffmpeg | **ok — 4/4 pixel-exact, 0 named refusals, `part128_none_hits=31`** +(9+9+4+9 128-NONE roots). Sibling gates `a_real_aomenc_128x128_superblock_stream_decodes_pixel_exact`, +`refusal_inventory`, `gate_coverage` re-run green in the same invocation (14 passed / 0 failed). + +## TASK B — the 2 inherited 10-bit reds were an ENCODER RECIPE defect + +`git show main:crates/ec-av1/src/stream.rs` vs the lane's: r2 rewrote `--min-partition-size=16` to +`32` at **13** call sites that main has at 16, including both failing gates. 32 removes the 16-level +the rect/AB gates assert. Reverted all 13 (the lane's own two 128 gates keep their deliberate 32). +EVIDENCE: `cargo test -p ec-av1 --lib -- a_real_aomenc_10bit_rect_and_ab_partitions_decode_pixel_exact a_real_aomenc_10bit_stream_with_a_32_level_ab_partition_decodes_pixel_exact refusal_inventory gate_coverage` | +recipe reverted, rebuilt, re-run | **ok — 14 passed, 0 failed**. Class: +[[gate-recipe-confound]] / the ledger's "a gate that decodes pixel-exact with counter 0 is an +encoder-recipe defect". Swept: those 13 are every 16->32 rewrite in the lane. + +## TASK C — merges + +`git merge main` twice: 7a47fc1 (one conflict, `decode.rs`'s skipped-block arm: took main's +lane-hgkf per-TU prediction + `true_width` guard + `SKIP_SPLIT_TX_HITS`, broadened its condition +from `tx_select && logical_tx < side` to `logical_tx < side` because a 128 block's transform is +TX_64X64 with no tx-depth syntax; the counter keeps its narrow `tx_select` meaning), then 18bf7dc +(= lane-sb128 5ea5ec8; three conflicts in `stream.rs`, ALL resolved to main's side per the batch +coordinator, so main's single seam gate `a_real_aomenc_128x128_superblock_stream_decodes_pixel_exact` +survives and lane-oddh's seam refusal stays deleted). `cdf.rs` merged clean; its NZ_MAP and +FILTER_INTRA regions are byte-identical to main's (`git diff main -- crates/ec-av1/src/cdf.rs` shows +only the four new `TXB_SKIP_CHROMA_32_BIG*` tables). + +## Suite + +EVIDENCE: `$HOME/.cache/sb128b-suite-r3.log` (unit `sb128b-suite-r3-1788323779.service`, tip +`7ceb309`) | `EC_NOMEMGUARD=1 EC_AV1_REQUIRE_AOMENC=1 cargo test -p ec-av1 --lib -j3` | +**test result: ok. 371 passed; 0 failed; 32 ignored; 473.61s** — GREEN. + +## ReelC key frame + +EVIDENCE: `$HOME/.cache/sb128b-work/{reelckf0.obu,reelcours.yuv.f0.yuv,ref.yuv}` | r2's recipe +(`ffmpeg -t 2 -c:v copy -f obu` off the film, 1920x792 yuv420p10le), `dump_yuv` under a 6G scope vs +ffmpeg's rawvideo | **`cmp` says BYTES EQUAL — 4 561 920 bytes, 0 differing samples.** + +Film probe on the 2 s cut (`decode_probe reelc2s.obu`) still stops at +`an inter frame under a 128x128 superblock (this decoder's inter tile path recurses a 64x64 +superblock root only)` — main 18bf7dc (lane-sb128 5ea5ec8) did NOT lift this one on this tree. + +## Open residue + +- deferred: `a 128x128 superblock HORZ/VERT or AB partition` — not started; every 128 root in the + four gate arms resolves NONE or SPLIT, so nothing here is measured. Unblocked by an aomenc recipe + that actually emits a 128-level HORZ/VERT (r2's seed-42 "HORZ/VERT at 128" sighting was our own + desync talking — class [[refusal-from-own-desync]]: with the entropy fixed, that same stream + reads nine NONE roots). +- deferred: `a 128x128 superblock PARTITION_NONE root on an inter frame` and + `an inter frame under a 128x128 superblock` (the ReelC blocker) — inter path untouched this round; + unblocked by the inter tile path recursing a 128 root. +- deferred: the `--enable-tx-size-search=1` arm at 128 (a read tx_depth under a 128 NONE root) — + the four arms all pin `=0`; unblocked now that the NONE arm is exact, so it is a one-arm follow-up.