diff --git a/crates/ec-av1/src/decode.rs b/crates/ec-av1/src/decode.rs index 2ad2969f..a02d365e 100644 --- a/crates/ec-av1/src/decode.rs +++ b/crates/ec-av1/src/decode.rs @@ -35,7 +35,7 @@ use crate::msac::SymbolDecoder; use crate::mvstack::{ ALTREF_FRAME, ALTREF2_FRAME, BWDREF_FRAME, GOLDEN_FRAME, LAST_FRAME, LAST2_FRAME, LAST3_FRAME, MiGrid, MiInfo, NO_SIGN_BIAS, NeighbourRef, SignBiasTable, comp_reference_type_ctx, - find_mv_stack_with_sign_bias, reference_mode_ctx, single_ref_ctx, + find_mv_stack_with_sign_bias, reference_mode_ctx, single_ref_p1_ctx, single_ref_p2_ctx, single_ref_p3_ctx, single_ref_p4_ctx, single_ref_p5_ctx, single_ref_p6_ctx, uni_comp_ref_p1_ctx, }; @@ -766,6 +766,33 @@ pub(crate) fn rect_partition_hits() -> usize { RECT_PARTITION_HITS.with(|c| c.get()) } +// lane-inter8 r1: how many superblocks an inter tile coded as a single +// whole-SB `PARTITION_NONE` 64x64 inter block (the case aomenc picks for +// static content, previously a named refusal). +thread_local! { + static INTER_SB_NONE_HITS: std::cell::Cell = + const { std::cell::Cell::new(0) }; +} + +/// Current value of [`INTER_SB_NONE_HITS`]. +pub(crate) fn inter_sb_none_hits() -> usize { + INTER_SB_NONE_HITS.with(|c| c.get()) +} + +// lane-inter8 r1: how many INTERIOR (not frame-edge-straddling) 16x16 inter +// blocks coded a real `PARTITION_SPLIT` into four 8x8 leaves -- the straddle +// path has always run that loop, so only this counter proves the newly-lifted +// alphabet value fired. +thread_local! { + static INTER_SUB16_SPLIT_HITS: std::cell::Cell = + const { std::cell::Cell::new(0) }; +} + +/// Current value of [`INTER_SUB16_SPLIT_HITS`]. +pub(crate) fn inter_sub16_split_hits() -> usize { + INTER_SUB16_SPLIT_HITS.with(|c| c.get()) +} + // lane-rectwire r2: how many `PARTITION_HORZ`/`VERT` strips actually decoded // real (non-skip) coefficients through [`read_coeffs_rect`] -- proves the // rect coefficient reader itself fired, not just the strip-level partition @@ -1916,22 +1943,26 @@ impl Neighbours { left_side: vec![SB; rows], above_side_mi: vec![SB; cols * (SUB / MI)], left_side_mi: vec![SB; rows * (SUB / MI)], - above_skip: vec![false; cols], - left_skip: vec![false; rows], - above_skip_mode: vec![false; cols], - left_skip_mode: vec![false; rows], - above_inter: vec![false; cols], - left_inter: vec![false; rows], - above_ref: vec![-1; cols], - left_ref: vec![-1; rows], - above_ref1: vec![None; cols], - left_ref1: vec![None; rows], - above_comp_group_idx: vec![0; cols], - left_comp_group_idx: vec![0; rows], - above_compound_idx: vec![0; cols], - left_compound_idx: vec![0; rows], - above_filter: vec![[3u8; 2]; cols], - left_filter: vec![[3u8; 2]; rows], + // lane-inter8 r2: mi(4px)-granular, not [`SUB`]-granular -- an + // 8x8 inter leaf's left neighbour is the OTHER leaf row of the + // 16x16 block beside it, which a SUB-grid slot cannot name + // (class context-read-from-one-cell). + above_skip: vec![false; cols * (SUB / MI)], + left_skip: vec![false; rows * (SUB / MI)], + above_skip_mode: vec![false; cols * (SUB / MI)], + left_skip_mode: vec![false; rows * (SUB / MI)], + above_inter: vec![false; cols * (SUB / MI)], + left_inter: vec![false; rows * (SUB / MI)], + above_ref: vec![-1; cols * (SUB / MI)], + left_ref: vec![-1; rows * (SUB / MI)], + above_ref1: vec![None; cols * (SUB / MI)], + left_ref1: vec![None; rows * (SUB / MI)], + above_comp_group_idx: vec![0; cols * (SUB / MI)], + left_comp_group_idx: vec![0; rows * (SUB / MI)], + above_compound_idx: vec![0; cols * (SUB / MI)], + left_compound_idx: vec![0; rows * (SUB / MI)], + above_filter: vec![[3u8; 2]; cols * (SUB / MI)], + left_filter: vec![[3u8; 2]; rows * (SUB / MI)], mi_cols, mi_rows, skip_grid: vec![false; cols * (SUB / MI) * rows * (SUB / MI)], @@ -1974,6 +2005,11 @@ impl Neighbours { for i in sc0.min(sc1)..sc1 { self.above_mode[i] = DC_PRED; self.above_side[i] = SB; + } + // lane-inter8 r2: the inter bands are mi-granular, so they reset over + // the tile's own mi column span directly. + let mend = col1_mi.min(self.above_skip.len()); + for i in col0_mi.min(mend)..mend { self.above_skip[i] = false; self.above_skip_mode[i] = false; self.above_inter[i] = false; @@ -2280,8 +2316,37 @@ impl Neighbours { skip_mode: bool, ) { let (r, c) = at; + self.record_inter_rect_mi( + (r * (SUB / MI), c * (SUB / MI)), + w_sub / MI, + h_sub / MI, + skip, + is_inter, + ref_frame, + filter, + skip_mode, + ); + } + + /// [`Self::record_inter_rect`] in mi (4px) units -- lane-inter8 r2: an + /// 8x8 leaf covers 2x2 mi, half a [`SUB`] cell in each direction, so the + /// side bands are written (and read) per mi. Every [`SUB`]-unit caller + /// routes through the wrapper above. + #[allow(clippy::too_many_arguments)] + fn record_inter_rect_mi( + &mut self, + at_mi: (usize, usize), + w_mi: usize, + h_mi: usize, + skip: bool, + is_inter: bool, + ref_frame: i8, + filter: [u8; 2], + skip_mode: bool, + ) { + let (r, c) = at_mi; let altref = is_inter && ref_frame == crate::mvstack::ALTREF_FRAME; - for cell in 0..w_sub / SUB { + for cell in 0..w_mi { self.above_skip[c + cell] = skip; self.above_skip_mode[c + cell] = skip_mode; self.above_inter[c + cell] = is_inter; @@ -2299,7 +2364,7 @@ impl Neighbours { self.above_compound_idx[c + cell] = u8::from(altref); self.above_filter[c + cell] = filter; } - for cell in 0..h_sub / SUB { + for cell in 0..h_mi { self.left_skip[r + cell] = skip; self.left_skip_mode[r + cell] = skip_mode; self.left_inter[r + cell] = is_inter; @@ -2345,12 +2410,34 @@ impl Neighbours { compound_idx: u8, ) { let (r, c) = at; - for cell in 0..w_sub / SUB { + self.record_compound_ctx_rect_mi( + (r * (SUB / MI), c * (SUB / MI)), + w_sub / MI, + h_sub / MI, + ref1, + comp_group_idx, + compound_idx, + ); + } + + /// [`Self::record_compound_ctx_rect`] in mi units (lane-inter8 r2, see + /// [`Self::record_inter_rect_mi`]). + fn record_compound_ctx_rect_mi( + &mut self, + at_mi: (usize, usize), + w_mi: usize, + h_mi: usize, + ref1: i8, + comp_group_idx: u8, + compound_idx: u8, + ) { + let (r, c) = at_mi; + for cell in 0..w_mi { self.above_ref1[c + cell] = Some(ref1); self.above_comp_group_idx[c + cell] = comp_group_idx; self.above_compound_idx[c + cell] = compound_idx; } - for cell in 0..h_sub / SUB { + for cell in 0..h_mi { self.left_ref1[r + cell] = Some(ref1); self.left_comp_group_idx[r + cell] = comp_group_idx; self.left_compound_idx[r + cell] = compound_idx; @@ -7815,6 +7902,23 @@ fn read_inter_plane( default_tx_type, None, )?; + // lane-inter8 r1: a 64-point transform covers the whole 64x64 area but + // codes only its top-left 32x32 of frequencies (spec 5.11.40) -- the + // caller hands the 32-point `scan` there, and the coded corner goes into + // the top-left of the true `side`-sized grid before dequantization + // (dqDenom is keyed by the true size, not the corner's), mirroring + // [`read_plane`]'s own `tx_side != side` branch. Every other transform + // this decoder codes has `tx_side == side`, so this is inert below 64. + let tx_side = side.min(32); + let grid = if tx_side == side { + grid + } else { + let mut full = vec![0i32; side * side]; + for row in 0..tx_side { + full[row * side..][..tx_side].copy_from_slice(&grid[row * tx_side..][..tx_side]); + } + full + }; let (dc_delta, ac_delta) = plane_q_delta(plane_idx); let residual = dequant_and_inverse_typed(&grid, side, bit_depth(), CURRENT_Q_IDX.with(|c| c.get()), dc_delta, ac_delta, tx_type); plane.reconstruct_mc(x, y, side, prediction, &residual); @@ -8169,6 +8273,10 @@ fn obmc_mask(len: usize) -> &'static [u8] { // round wired interior 16x16 splits down to real 8x8 leaves, where the // old `unreachable!()` below fired as a hard panic. const M1: [u8; 1] = [64]; + // lane-inter8 r1: `obmc_mask_2` (`reconinter.c` 753) -- reached by the + // LEFT pass of an 8x8 block's chroma plane (overlap 4 luma columns, 2 + // chroma), which only became live once 8x8 inter leaves stopped being + // refused. const M2: [u8; 2] = [45, 64]; const M4: [u8; 4] = [39, 50, 59, 64]; const M8: [u8; 8] = [36, 42, 48, 53, 57, 61, 64, 64]; @@ -8198,16 +8306,6 @@ fn obmc_mask(len: usize) -> &'static [u8] { /// excluded by [`overlappable_above`]/[`overlappable_left`]'s `is_inter` /// gate) or when `interp_fixed` is `Some` for the whole frame, handled here /// first. -/// lane-gmaffine r2: prefer the mi-granular filter record, fall back to the -/// coarse 16px `Neighbours` slot when this block's path never recorded one. -fn grid_or_slot(mi_filter: [u8; 2], slot: [u8; 2]) -> [u8; 2] { - if mi_filter[0] <= 2 && mi_filter[1] <= 2 { - mi_filter - } else { - slot - } -} - fn neighbour_filter( interp_fixed: Option, sym: [u8; 2], @@ -8425,14 +8523,7 @@ fn obmc_blend( }; let overlap_above = write_h / 2; let overlap_left = write_w / 2; - // lane-gmaffine r2 (libaom `av1_skip_u4x4_pred_in_obmc`, reconinter.c:820, - // `DISABLE_CHROMA_U8X8_OBMC 0`): when the block's CHROMA plane size is - // BLOCK_4X4/4X8/8X4 -- i.e. a luma dimension below 16 under 4:2:0 -- obmc - // is ONE-SIDED on chroma: the above pass (dir==0) skips U/V entirely, the - // left pass (dir==1) still blends them. Blending chroma on both passes is - // exactly the residual that left the 8x8-leaf obmc gate's V plane off by - // ~2 (r1); luma is unaffected at every size. - let chroma_above = write_w >= 16 && write_h >= 16; + let skip_chroma_above = matches!((write_w, write_h), (8, 8) | (16, 8) | (8, 16)); for (off4, span4, nb) in overlappable_above(grid, mi_row, mi_col, bw4, mi_cols, max_nb(bw4)) { @@ -8447,22 +8538,23 @@ fn obmc_blend( // (compound), which is what every earlier round used. let (h_kind, v_kind) = neighbour_filter( interp_fixed, - grid_or_slot( - grid.filter(mi_row.wrapping_sub(1), mi_col + off4), - neighbours.above_filter[(mi_col + off4) / SUB_MI as usize], - ), + neighbours.above_filter[mi_col + off4], ); let (ny, nu, nv) = ref_planes(nb.ref_frame, ref_y, ref_u, ref_v, other_refs)?; let (bw, bh, ox) = (span4 * 4, overlap_above, off4 * 4); let tmp_y = obmc_neighbour_pred(ny, px + ox, py, nb.mv, bw, bh, true, h_kind, v_kind); obmc_blend_v(pred_y, side, ox, 0, bw, bh, &tmp_y); - if chroma_above { + // lane-inter8 r1: `av1_skip_u4x4_pred_in_obmc` (`reconinter.c` 820, + // `DISABLE_CHROMA_U8X8_OBMC == 0` -- "one-sided obmc"): when the + // chroma plane's own block size is BLOCK_4X4/8X4/4X8 (a 8x8, 16x8 or + // 8x16 luma block at 4:2:0), the ABOVE pass skips chroma entirely + // while the LEFT pass still blends it. Blending chroma here as well + // would both mis-predict every 8x8 leaf and ask for an overlap of 2. + if !skip_chroma_above { let (cbw, cbh, cox) = (bw / 2, overlap_above / 2, ox / 2); - let tmp_u = - obmc_neighbour_pred(nu, cpx + cox, cpy, nb.mv, cbw, cbh, false, h_kind, v_kind); + let tmp_u = obmc_neighbour_pred(nu, cpx + cox, cpy, nb.mv, cbw, cbh, false, h_kind, v_kind); obmc_blend_v(pred_u, chroma_side, cox, 0, cbw, cbh, &tmp_u); - let tmp_v = - obmc_neighbour_pred(nv, cpx + cox, cpy, nb.mv, cbw, cbh, false, h_kind, v_kind); + let tmp_v = obmc_neighbour_pred(nv, cpx + cox, cpy, nb.mv, cbw, cbh, false, h_kind, v_kind); obmc_blend_v(pred_v, chroma_side, cox, 0, cbw, cbh, &tmp_v); } } @@ -8470,10 +8562,7 @@ fn obmc_blend( for (off4, span4, nb) in overlappable_left(grid, mi_row, mi_col, bh4, mi_rows, max_nb(bh4)) { let (h_kind, v_kind) = neighbour_filter( interp_fixed, - grid_or_slot( - grid.filter(mi_row + off4, mi_col.wrapping_sub(1)), - neighbours.left_filter[(mi_row + off4) / SUB_MI as usize], - ), + neighbours.left_filter[mi_row + off4], ); let (ny, nu, nv) = ref_planes(nb.ref_frame, ref_y, ref_u, ref_v, other_refs)?; let (bw, bh, oy) = (overlap_left, span4 * 4, off4 * 4); @@ -8514,10 +8603,17 @@ fn is_uni_comp_ref(ref0: i8, ref1: i8) -> bool { /// `get_comp_group_idx_context` (libaom `pred_common.h`): sums the /// above/left neighbour contributions [`Neighbours::record_inter`]/ /// [`Neighbours::record_compound_ctx`] already precomputed, clamped to 5. -fn get_comp_group_idx_context(neighbours: &Neighbours, at: (usize, usize), side: usize) -> usize { +/// lane-inter8 r2: `at_mi` is the block's own top-left in 4x4 mi units -- +/// an 8x8 leaf used to pass its enclosing 16x16's corner here, so all four +/// leaves read the same neighbour cell (class context-read-from-one-cell). +fn get_comp_group_idx_context( + neighbours: &Neighbours, + at_mi: (usize, usize), + side: usize, +) -> usize { let _ = side; - let (r, c) = at; - (neighbours.above_comp_group_idx[c] as usize + neighbours.left_comp_group_idx[r] as usize) + let (rmi, cmi) = at_mi; + (neighbours.above_comp_group_idx[cmi] as usize + neighbours.left_comp_group_idx[rmi] as usize) .min(5) } @@ -8529,7 +8625,7 @@ fn get_comp_group_idx_context(neighbours: &Neighbours, at: (usize, usize), side: #[allow(clippy::too_many_arguments)] fn get_comp_index_context( neighbours: &Neighbours, - at: (usize, usize), + at_mi: (usize, usize), side: usize, order_hint_bits: u32, cur_order_hint: u32, @@ -8537,7 +8633,7 @@ fn get_comp_index_context( ref1_order_hint: u32, ) -> usize { let _ = side; - let (r, c) = at; + let (rmi, cmi) = at_mi; let fwd = crate::motion_field::get_relative_dist(order_hint_bits, ref1_order_hint, cur_order_hint) .abs(); @@ -8545,8 +8641,8 @@ fn get_comp_index_context( crate::motion_field::get_relative_dist(order_hint_bits, cur_order_hint, ref0_order_hint) .abs(); let offset = usize::from(fwd == bck); - neighbours.above_compound_idx[c] as usize - + neighbours.left_compound_idx[r] as usize + neighbours.above_compound_idx[cmi] as usize + + neighbours.left_compound_idx[rmi] as usize + 3 * offset } @@ -8920,6 +9016,11 @@ fn decode_inter_block( frame_width: usize, ) -> Result<()> { let (r, c) = at; + // lane-inter8 r2: the inter side bands are mi-granular; this block's own + // above/left neighbour is the mi cell at its top-left corner (libaom + // `above_mbmi` = mi(mi_row - 1, mi_col)), so a SUB-aligned block reads + // exactly what it read before. + let (rmi, cmi) = (r * (SUB / MI), c * (SUB / MI)); let (px, py) = (c * SUB, r * SUB); let (cpx, cpy) = (px / 2, py / 2); let chroma_side = side / 2; @@ -8932,7 +9033,7 @@ fn decode_inter_block( ); } let skip_mode_ctx = - usize::from(neighbours.above_skip_mode[c]) + usize::from(neighbours.left_skip_mode[r]); + usize::from(neighbours.above_skip_mode[cmi]) + usize::from(neighbours.left_skip_mode[rmi]); // lane-comppin r3: skip_mode desync isolation -- dump ctx + the pre-read // MSAC tell so it can be diffed against an equivalent hook in libaom's // own `read_skip_mode`/`av1_get_skip_mode_context`. @@ -8953,7 +9054,7 @@ fn decode_inter_block( SKIP_MODE_HITS.with(|c| c.set(c.get() + 1)); } - let skip_ctx = usize::from(neighbours.above_skip[c]) + usize::from(neighbours.left_skip[r]); + let skip_ctx = usize::from(neighbours.above_skip[cmi]) + usize::from(neighbours.left_skip[rmi]); let skip = skip_mode || dec.symbol(&mut cdfs.skip[skip_ctx]) == 1; maybe_read_cdef_idx(dec, r * SUB_MI as usize, c * SUB_MI as usize, skip); maybe_read_delta_q(dec, cdfs, r * SUB_MI as usize, c * SUB_MI as usize, side == 64, skip); @@ -8971,9 +9072,17 @@ fn decode_inter_block( r > neighbours.tile_row0_mi / (SUB / MI), c > neighbours.tile_col0_mi / (SUB / MI), ); - let (above_inter, left_inter) = (neighbours.above_inter[c], neighbours.left_inter[r]); + let (above_inter, left_inter) = (neighbours.above_inter[cmi], neighbours.left_inter[rmi]); let ii_ctx = intra_inter_ctx(has_above, has_left, above_inter, left_inter); let is_inter = skip_mode || dec.symbol(&mut cdfs.intra_inter[ii_ctx]) == 1; + if std::env::var_os("EC_TRACE_MODE").is_some() { + eprintln!( + "EC_MODE mi_row={} mi_col={} rng={}", + r * SUB_MI as usize, + c * SUB_MI as usize, + dec.debug_state().0 + ); + } if std::env::var_os("EC_AV1_TELL").is_some() { eprintln!( "TELL mi_row={} mi_col={} label=post_is_inter skip_mode={skip_mode} skip={skip} is_inter={is_inter} tell={} range={}", @@ -8996,24 +9105,24 @@ fn decode_inter_block( let above_nbr = has_above.then(|| NeighbourRef { is_inter: above_inter, ref0: if above_inter { - neighbours.above_ref[c] + neighbours.above_ref[cmi] } else { 0 }, - ref1: neighbours.above_ref1[c], - uni: neighbours.above_ref1[c] - .is_some_and(|r1| is_uni_comp_ref(neighbours.above_ref[c], r1)), + ref1: neighbours.above_ref1[cmi], + uni: neighbours.above_ref1[cmi] + .is_some_and(|r1| is_uni_comp_ref(neighbours.above_ref[cmi], r1)), }); let left_nbr = has_left.then(|| NeighbourRef { is_inter: left_inter, ref0: if left_inter { - neighbours.left_ref[r] + neighbours.left_ref[rmi] } else { 0 }, - ref1: neighbours.left_ref1[r], - uni: neighbours.left_ref1[r] - .is_some_and(|r1| is_uni_comp_ref(neighbours.left_ref[r], r1)), + ref1: neighbours.left_ref1[rmi], + uni: neighbours.left_ref1[rmi] + .is_some_and(|r1| is_uni_comp_ref(neighbours.left_ref[rmi], r1)), }); if std::env::var_os("EC_AV1_COMPIDX_DUMP").is_some() { eprintln!( @@ -9032,8 +9141,8 @@ fn decode_inter_block( cdfs, above_nbr, left_nbr, - neighbours.above_ref[c], - neighbours.left_ref[r], + neighbours.above_ref[cmi], + neighbours.left_ref[rmi], ) }; let (mi_row, mi_col) = (r * SUB_MI as usize, c * SUB_MI as usize); @@ -9110,17 +9219,17 @@ fn decode_inter_block( // real filter match down to the "no neighbour" sentinel // whenever the shared reference sits in the neighbour's SECOND // slot (lane-av1idx r2). - let above_filter_ctx = if neighbours.above_ref[c] == ref0 - || neighbours.above_ref1[c] == Some(ref0) + let above_filter_ctx = if neighbours.above_ref[cmi] == ref0 + || neighbours.above_ref1[cmi] == Some(ref0) { - neighbours.above_filter[c] + neighbours.above_filter[cmi] } else { [3, 3] }; - let left_filter_ctx = if neighbours.left_ref[r] == ref0 - || neighbours.left_ref1[r] == Some(ref0) + let left_filter_ctx = if neighbours.left_ref[rmi] == ref0 + || neighbours.left_ref1[rmi] == Some(ref0) { - neighbours.left_filter[r] + neighbours.left_filter[rmi] } else { [3, 3] }; @@ -9170,7 +9279,7 @@ fn decode_inter_block( // there), so the gate reduces to the sequence header bit; kept // as an explicit call so a future smaller block size is not // silently wrong (libaom `reconinter.h::is_any_masked_compound_used`). - let group_ctx = get_comp_group_idx_context(neighbours, at, side); + let group_ctx = get_comp_group_idx_context(neighbours, (rmi, cmi), side); let comp_group_idx = if !skip_mode && enable_masked_compound && is_any_masked_compound_used_here(side) @@ -9198,7 +9307,17 @@ fn decode_inter_block( 8 => 3, 16 => 6, 32 => 9, - _ => unreachable!("decode_inter_block leaf side is 8/16/32"), + // lane-inter8 r1: `av1_is_wedge_used` is false at 64x64 + // (`av1_wedge_params_lookup[BLOCK_64X64].wedge_types == + // 0`), so a real encoder writes NO `compound_type` symbol + // there -- COMPOUND_DIFFWTD is inferred. Reading one + // would desync, so refuse by name rather than guess the + // inferred-DIFFWTD blend this round. + _ => { + return Err(unsupported( + "a masked compound 64x64 inter block (compound_type is inferred, not coded, at this size)", + )) + } }; let compound_type = dec.symbol(&mut cdfs.compound_type[wedge_bsize]); if compound_type == 0 { @@ -9424,7 +9543,7 @@ fn decode_inter_block( { let idx_ctx = get_comp_index_context( neighbours, - at, + (rmi, cmi), side, order_hint_bits, order_hint, @@ -9713,10 +9832,10 @@ fn decode_inter_block( read_single_ref( dec, cdfs, - neighbours.above_ref[c], - neighbours.above_ref1[c], - neighbours.left_ref[r], - neighbours.left_ref1[r], + neighbours.above_ref[cmi], + neighbours.above_ref1[cmi], + neighbours.left_ref[rmi], + neighbours.left_ref1[rmi], ); ref_frame_for_lf = ref_frame; if std::env::var_os("EC_AV1_TELL").is_some() { @@ -10093,17 +10212,17 @@ fn decode_inter_block( // lane-av1idx r2: also match on the neighbour's SECOND reference // (`above_ref1`/`left_ref1`, real for a compound neighbour) -- // see the 16x16 leaf's own comment above for the spec citation. - let above_filter_ctx = if neighbours.above_ref[c] == ref_frame - || neighbours.above_ref1[c] == Some(ref_frame) + let above_filter_ctx = if neighbours.above_ref[cmi] == ref_frame + || neighbours.above_ref1[cmi] == Some(ref_frame) { - neighbours.above_filter[c] + neighbours.above_filter[cmi] } else { [3, 3] }; - let left_filter_ctx = if neighbours.left_ref[r] == ref_frame - || neighbours.left_ref1[r] == Some(ref_frame) + let left_filter_ctx = if neighbours.left_ref[rmi] == ref_frame + || neighbours.left_ref1[rmi] == Some(ref_frame) { - neighbours.left_filter[r] + neighbours.left_filter[rmi] } else { [3, 3] }; @@ -10136,9 +10255,6 @@ fn decode_inter_block( // a square `bw4`x`bw4` guess. for dr in 0..bh4 { for dc in 0..bw4 { - // lane-gmaffine r2: mi-granular filter record for OBMC - // neighbour prediction (see `MiGrid::filters`). - grid.set_filter(mi_row + dr, mi_col + dc, block_filter); grid.set( mi_row + dr, mi_col + dc, @@ -10724,7 +10840,6 @@ fn decode_inter_block8( base_q_idx: u8, scan8: &[u16], scan4: &[u16], - prev_leaf: Option<((usize, usize), bool, bool)>, allow_high_precision_mv: bool, force_integer_mv: bool, // lane-gmaffine r1: this frame header's own `global_motion` table (spec @@ -10754,7 +10869,7 @@ fn decode_inter_block8( // lane-av1comp round 14: see [`decode_inter_block`]'s own doc -- this // leaf has no per-leaf `above_skip_mode`/`left_skip_mode` array either, // so its `skip_mode` context reuses the same [`SUB`]-grid - // `above_skip_mode[c]`/`left_skip_mode[r]` the enclosing 16x16 slot + // `above_skip_mode[cmi]`/`left_skip_mode[rmi]` the enclosing 16x16 slot // tracks (mirroring `above_skip`/`left_skip`'s own leaf approximation // just above). skip_mode_present: bool, @@ -10782,18 +10897,43 @@ fn decode_inter_block8( // `BLOCK_8X8` (this leaf's fixed size) is always `av1_allow_palette`- // eligible (`bsize >= BLOCK_8X8`). allow_screen_content_tools: bool, -) -> Result<(bool, bool, bool, Option<(i8, i8, u8, u8)>, [u8; 2], i8)> { + // lane-inter8 r1: the leaf's mv stacks used to be built without the + // frame's sign-bias table (`NO_SIGN_BIAS`), while [`decode_inter_block`] + // one level up passed it -- it changes the candidate list and with it + // `new_mv_ctx`/`ref_mv_ctx`, `drl_ctx` and the number of symbols read. + // Measured: an 8x8 compound NEAR_NEWMV leaf desynced against aomdec's + // EC_MODE ladder at exactly this block (mi 4,14 of the mandelbrot + // 8x8-split gate). + sign_bias_table: &SignBiasTable, + // lane-inter8 r2: the frame's temporal mv field (spec 7.10.2.8), which + // [`decode_inter_block`] one level up has always passed and this leaf + // passed `None` for -- a `use_ref_frame_mvs` frame's stack then holds + // fewer candidates here than in the reference decoder, which changes the + // mode contexts AND the number of `drl_mode` bits read (class parsed + // then discarded). + tpl_frame: Option<&TplFrameArgs>, +) -> Result<(bool, bool, bool, Option<(i8, i8, u8, u8)>, [u8; 2], (i8, Option))> { const LAST_FRAME: i8 = 1; - // lane-gmaffine r2: the leaf's OWN switchable-filter symbols and reference, - // handed back so the caller records them in `Neighbours` instead of the - // `[3, 3]` / hardcoded-LAST_FRAME placeholders r1 left there. `[3, 3]` is - // the "intra neighbour, no filter" sentinel: an OBMC blend that picks such - // a neighbour up feeds it to `neighbour_filter`, which PANICS on it - // (`from_switchable_symbol`) -- that was the warp gate's crash, not an - // entropy desync. Stays `[3, 3]`/-1 on the intra and compound paths, which - // is what the caller already recorded for them. + // lane-gmaffine r2: the leaf's OWN switchable-filter symbols, handed back + // so the caller stamps them into `Neighbours` instead of the `[3, 3]` + // placeholder. `[3, 3]` is the "intra neighbour, no filter" sentinel: an + // OBMC blend that picks such a neighbour up feeds it to + // `neighbour_filter`, which PANICS on it (`from_switchable_symbol`) -- + // that was the warp gate's crash, not an entropy desync. Stays `[3, 3]` + // on the intra and compound paths. let mut leaf_filter_syms = [3u8; 2]; - let mut leaf_ref: i8 = -1; + // lane-gmaffine r1: this leaf's GLOBALMV vector AND the mv stack's + // missing-candidate fallback both come from the frame's global motion + // evaluated at THIS block's centre (gm r6's root cause). + let gm_table = build_gm_mv_table( + global_motion, + leaf_mi.0, + leaf_mi.1, + 2, + 2, + allow_high_precision_mv, + force_integer_mv, + ); /// `Y_MODE`'s size group (`common_data.h`'s `size_group_lookup[BLOCK_8X8]`). const SIZE_GROUP_8: usize = 1; @@ -10803,21 +10943,26 @@ fn decode_inter_block8( const CHROMA_SIDE: usize = 4; let (r, c) = outer_at; - let mut above_skip = neighbours.above_skip[c]; - let mut left_skip = neighbours.left_skip[r]; - let mut above_inter = neighbours.above_inter[c]; - let mut left_inter = neighbours.left_inter[r]; - if let Some(((pr, pc), pskip, pinter)) = prev_leaf { - if pc == leaf_mi.1 && leaf_mi.0 == pr + 2 { - above_skip = pskip; - above_inter = pinter; - } else if pr == leaf_mi.0 && leaf_mi.1 == pc + 2 { - left_skip = pskip; - left_inter = pinter; - } - } + let _ = (r, c); + // lane-inter8 r2: this leaf's OWN mi cell, not the enclosing 16x16's -- + // leaf (mi_r, mi_c + 2)'s left neighbour is leaf (mi_r, mi_c), and the + // left column of a 16x16's second leaf ROW is the previous 16x16 block's + // bottom leaf, neither of which a SUB-grid slot can name. + let (rmi, cmi) = leaf_mi; + // lane-inter8 r2: no sibling-leaf override any more -- each leaf stamps + // its own 2x2-mi span into the bands right after it decodes (the caller's + // `record_inter_rect_mi`), so a plain mi read already names the correct + // neighbour, including one belonging to the previous 16x16 block. + let above_skip = neighbours.above_skip[cmi]; + let left_skip = neighbours.left_skip[rmi]; + let above_inter = neighbours.above_inter[cmi]; + let left_inter = neighbours.left_inter[rmi]; + let above_ref0 = neighbours.above_ref[cmi]; + let above_ref1 = neighbours.above_ref1[cmi]; + let left_ref0 = neighbours.left_ref[rmi]; + let left_ref1 = neighbours.left_ref1[rmi]; let skip_mode_ctx = - usize::from(neighbours.above_skip_mode[c]) + usize::from(neighbours.left_skip_mode[r]); + usize::from(neighbours.above_skip_mode[cmi]) + usize::from(neighbours.left_skip_mode[rmi]); let skip_mode = skip_mode_present && dec.symbol(&mut cdfs.skip_mode[skip_mode_ctx]) == 1; if skip_mode { SKIP_MODE_HITS.with(|c| c.set(c.get() + 1)); @@ -10836,23 +10981,46 @@ fn decode_inter_block8( ); let ii_ctx = intra_inter_ctx(has_above, has_left, above_inter, left_inter); let is_inter = skip_mode || dec.symbol(&mut cdfs.intra_inter[ii_ctx]) == 1; + // lane-inter8 r1: mirrors the oracle's `EC_MODE` (instrument rung 4, + // `read_inter_block_mode_info`) so an 8x8 leaf's mode-info range ladder + // diffs line for line against a real aomdec. + if std::env::var_os("EC_TRACE_MODE").is_some() { + eprintln!( + "EC_MODE mi_row={} mi_col={} rng={}", + leaf_mi.0, + leaf_mi.1, + dec.debug_state().0 + ); + } let mode_for_tx; let (luma_grid, u_grid, v_grid); let mut compound_ctx8: Option<(i8, i8, u8, u8)> = None; + // lane-inter8 r1: this leaf's own resolved references, handed back so the + // NEXT leaf of the same 16x16 can use them as its real above/left + // neighbour (`Neighbours`' arrays only move once per 16x16 block). + // `(0, None)` is intra. + let mut leaf_refs: (i8, Option) = (0, None); if is_inter { if reference_select || skip_mode { + // lane-inter8 r1: the REAL neighbour references, not a + // `LAST_FRAME`-or-intra stand-in. `av1_get_reference_mode_context` + // and `read_compound_ref_frames`' own contexts both ask whether a + // neighbour is COMPOUND, so pretending every inter neighbour is + // single-ref LAST picked the wrong `comp_mode` CDF row -- measured + // as an 8x8 leaf reading single-ref where aomdec read compound + // NEAR_NEWMV (mi 4,14). let above_nbr = has_above.then(|| NeighbourRef { is_inter: above_inter, - ref0: if above_inter { LAST_FRAME } else { 0 }, - ref1: None, - uni: false, + ref0: if above_inter { above_ref0 } else { 0 }, + ref1: above_ref1, + uni: above_ref1.is_some_and(|r1| is_uni_comp_ref(above_ref0, r1)), }); let left_nbr = has_left.then(|| NeighbourRef { is_inter: left_inter, - ref0: if left_inter { LAST_FRAME } else { 0 }, - ref1: None, - uni: false, + ref0: if left_inter { left_ref0 } else { 0 }, + ref1: left_ref1, + uni: left_ref1.is_some_and(|r1| is_uni_comp_ref(left_ref0, r1)), }); if skip_mode || read_comp_mode(dec, cdfs, above_nbr, left_nbr) { let (ref0, ref1) = if skip_mode { @@ -10875,7 +11043,24 @@ fn decode_inter_block8( }, ) }; + leaf_refs = (ref0, Some(ref1)); let (mi_row, mi_col) = leaf_mi; + // spec 7.10.2.8, mirroring [`decode_inter_block`]'s own + // `comp_tpl` build (`use_ref_frame_mvs` frames only). + let comp_tpl = tpl_frame.map(|t| crate::mvstack::CompoundTplArgs { + field: t.field, + cur_offset_0: crate::motion_field::get_relative_dist( + t.order_hint_bits, + t.order_hint, + t.ref_order_hints[(ref0 - LAST_FRAME) as usize], + ), + cur_offset_1: crate::motion_field::get_relative_dist( + t.order_hint_bits, + t.order_hint, + t.ref_order_hints[(ref1 - LAST_FRAME) as usize], + ), + allow_high_precision_mv, + }); // lane-av1comp: this leaf path has neither a real sign-bias // table nor `tpl_frame` (see this function's own doc on the // coarse `LAST_FRAME`-or-intra neighbour approximation @@ -10891,9 +11076,9 @@ fn decode_inter_block8( (ref0, ref1), mi_cols as usize, mi_rows as usize, - &NO_SIGN_BIAS, - &crate::mvstack::NO_GM_MV, - None, + sign_bias_table, + &gm_table, + comp_tpl, ); let compound_mode = if skip_mode { 0 // NEAREST_NEARESTMV, forced -- no mode symbol read @@ -10905,6 +11090,18 @@ fn decode_inter_block8( comp_stack.ref_mv_ctx, ) }; + if std::env::var_os("EC_TRACE_MODE").is_some() { + eprintln!( + "EC_LEAFMODE mi_row={} mi_col={} cmode={} stack={} newmv_ctx={} refmv_ctx={} rng={}", + leaf_mi.0, + leaf_mi.1, + compound_mode + 17, + comp_stack.entries.len(), + comp_stack.new_mv_ctx, + comp_stack.ref_mv_ctx, + dec.debug_state().0 + ); + } let (mv0, mv1) = assign_compound_mv( dec, cdfs, @@ -10912,16 +11109,19 @@ fn decode_inter_block8( compound_mode, allow_high_precision_mv, force_integer_mv, - // leaf8 stays gm-inert (sanctioned partial landing, see - // this fn's own GLOBALMV refusal below). - ((0, 0), (0, 0)), + // lane-inter8 r1: the real per-ref gm mvs, same as + // [`decode_inter_block`]'s own compound arm. + ( + gm_table[(ref0 - LAST_FRAME) as usize], + gm_table[(ref1 - LAST_FRAME) as usize], + ), ); // spec 5.11.25: same gating [`decode_inter_block`]'s own // compound arm uses, keyed off `outer_at`'s [`SUB`]-grid // slot -- the only granularity `Neighbours`' comp_group_idx/ // compound_idx arrays track. - let group_ctx = get_comp_group_idx_context(neighbours, outer_at, SIDE); + let group_ctx = get_comp_group_idx_context(neighbours, leaf_mi, SIDE); let comp_group_idx = if !skip_mode && enable_masked_compound && is_any_masked_compound_used_here(SIDE) @@ -10975,7 +11175,7 @@ fn decode_inter_block8( { let idx_ctx = get_comp_index_context( neighbours, - outer_at, + leaf_mi, SIDE, order_hint_bits, order_hint, @@ -11245,7 +11445,30 @@ fn decode_inter_block8( )? .0; } - return Ok((skip, is_inter, skip_mode, compound_ctx8, leaf_filter_syms, leaf_ref)); + // lane-inter8 r2: the COMPOUND leaf used to return here + // WITHOUT the end-of-function `record_mi`/`fill_lf_grid` the + // single-ref path falls through to -- so a compound 8x8 leaf + // left `above_side_mi`/`left_side_mi` (the next block's + // partition context), the per-plane coefficient level state + // and the loop-filter grid describing whatever block was + // there before. Every leaf of the gate's stream is compound, + // so the 16x16 below a split block read partition ctx 0 + // instead of 1 and mis-read PARTITION_SPLIT as NONE. + neighbours.record_mi(leaf_mi, 8, &[luma_grid, u_grid, v_grid]); + neighbours.fill_lf_grid( + leaf_mi, + 2, + 8, + if is_inter { leaf_refs.0.max(LAST_FRAME) } else { 0 }, + ); + return Ok(( + skip, + is_inter, + skip_mode, + compound_ctx8, + leaf_filter_syms, + leaf_refs, + )); } } // lane-gmaffine r1: the leaf reads the FULL `single_ref` tree @@ -11262,23 +11485,21 @@ fn decode_inter_block8( neighbours.left_ref[r], neighbours.left_ref1[r], ); + leaf_refs = (ref_frame, None); let (sref_y, sref_u, sref_v) = ref_planes(ref_frame, ref_y, ref_u, ref_v, other_refs)?; let (mi_row, mi_col) = leaf_mi; - // lane-gmaffine r1: this leaf's GLOBALMV vector AND the mv stack's - // missing-candidate fallback both come from the frame's global - // motion evaluated at THIS block's centre (gm r6's root cause) -- - // the 8x8 leaf used to build its stack with the zero fallback, which - // is right only while every model is IDENTITY. - let gm_table = build_gm_mv_table( - global_motion, - mi_row, - mi_col, - 2, - 2, + // lane-inter8 r2: the frame's temporal mv candidates, keyed on THIS + // leaf's own reference (lane-gmaffine r1 taught it non-LAST refs). + let tpl = tpl_frame.map(|t| crate::mvstack::TplArgs { + field: t.field, + cur_offset_0: crate::motion_field::get_relative_dist( + t.order_hint_bits, + t.order_hint, + t.ref_order_hints[(ref_frame - LAST_FRAME) as usize], + ), allow_high_precision_mv, - force_integer_mv, - ); + }); let stack = crate::mvstack::find_mv_stack_with_sign_bias( grid, mi_row, @@ -11288,9 +11509,9 @@ fn decode_inter_block8( ref_frame, mi_cols as usize, mi_rows as usize, - &crate::mvstack::NO_SIGN_BIAS, + sign_bias_table, &gm_table, - None, + tpl, ); let not_new = dec.symbol(&mut cdfs.new_mv[stack.new_mv_ctx]) == 1; @@ -11507,16 +11728,6 @@ fn decode_inter_block8( false, ); leaf_filter_syms = resolved_filter; - leaf_ref = ref_frame; - // lane-gmaffine r2: mi-granular filter record -- a sibling 8x8 leaf - // OBMC-blends this one before the enclosing 16x16's coarse - // `Neighbours` slot is ever written. - for dr in 0..2 { - for dc in 0..2 { - grid.set_filter(leaf_mi.0 + dr, leaf_mi.1 + dc, resolved_filter); - } - } - // lane-gmaffine r1: `allow_warp`'s `global_warp_allowed` branch // (`reconinter.c:33-55`), gated INDEPENDENTLY of `motion_mode` -- // see [`decode_inter_block`]'s own copy. A local WARPED_CAUSAL model @@ -11910,13 +12121,16 @@ fn decode_inter_block8( leaf_mi, 2, 8, - if is_inter { - if leaf_ref > 0 { leaf_ref } else { LAST_FRAME } - } else { - 0 - }, + if is_inter { leaf_refs.0.max(LAST_FRAME) } else { 0 }, ); - Ok((skip, is_inter, skip_mode, compound_ctx8, leaf_filter_syms, leaf_ref)) + Ok(( + skip, + is_inter, + skip_mode, + compound_ctx8, + leaf_filter_syms, + leaf_refs, + )) } /// Decodes the payload [`crate::tile::sb_coeff_inter_frame_tile`] writes, @@ -12361,10 +12575,72 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( } (false, false) => PARTITION_SPLIT, }; + if part64 == PARTITION_NONE { + // lane-inter8 r1: the whole superblock as one 64x64 inter + // block. `SB`-sized syntax throughout (size_group 3, same as + // 32x32 -- `size_group_lookup[BLOCK_64X64] == 3`), luma + // coefficients through `TxbSet::Luma64` with the 32-point + // scan (TX_64X64 codes only its top-left corner, spec + // 5.11.40 -- `read_inter_plane` widens the corner back to + // 64x64 before the inverse transform), chroma as a plain + // 32x32 `TxbSet::Chroma32`. TX_64X64 carries no `tx_type` + // symbol at all, so the intra/inter luma sets coincide. + INTER_SB_NONE_HITS.with(|c| c.set(c.get() + 1)); + decode_inter_block( + &mut dec, + &mut cdfs, + &mut neighbours, + &mut grid, + sb_at, + SB, + mi_cols, + mi_rows, + &mut y, + &mut u, + &mut v, + &ref_y, + &ref_u, + &ref_v, + &ref_slots, + &sign_bias_table, + &global_motion, + base_q_idx, + TxbSet::Luma64, + TxbSet::Luma64, + TxbSet::Chroma32, + TX32, + TX32, + &scan32, + &scan32, + 3, + allow_high_precision_mv, + force_integer_mv, + interp_fixed, + enable_dual_filter, + tpl_frame.as_ref(), + reference_select, + enable_masked_compound, + enable_interintra_compound, + enable_jnt_comp, + order_hint_bits, + order_hint, + ref_order_hints, + skip_mode_present, + skip_mode_frame, + switchable_motion_mode, + allow_warped_motion, + false, + SB, + SB, + allow_screen_content_tools, + frame_width as usize, + )?; + continue; + } if part64 != PARTITION_SPLIT { return Err(unsupported( - "an inter SB-level partition type other than SPLIT (this decoder's \ - inter tile path only recurses a superblock as SPLIT)", + "an inter SB-level partition type other than NONE or SPLIT (this decoder's \ + inter tile path recurses a superblock only as SPLIT)", )); } @@ -12479,175 +12755,39 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( )); } let at16 = (sr, sc); - if has_cols16 && has_rows16 { - let ctx16 = neighbours.partition_ctx(at16, SUB); - let part16 = dec.symbol(&mut cdfs.partition_w16[ctx16]); - if part16 == PARTITION_SPLIT { - // lane-gmaffine r1: an INTERIOR 16x16 - // PARTITION_SPLIT -- four 8x8 leaves, - // the same `partition_w8`-per-leaf loop - // the true-edge-straddling branch below - // already ran (that branch only ever - // reached it for frame-edge blocks, so - // `decode_inter_block8` was unreachable - // for every whole-superblock stream and - // its own GLOBALMV/WARPED_CAUSAL gates - // could not fire at all). - let (mi_row0, mi_col0) = (sr as u32 * SUB_MI, sc as u32 * SUB_MI); - let leaf_positions: Vec<(u32, u32)> = (0..4) - .map(|i| (mi_row0 + (i / 2) * 2, mi_col0 + (i % 2) * 2)) - .filter(|&(mr, mc)| mr < mi_rows && mc < mi_cols) - .collect(); - // lane-superres r9: decode_inter_block8's own - // MC (below) is not threaded for a scaled - // reference (unlike decode_inter_block's 19 - // sites) -- refuse the whole 8x8-leaf split - // up front when ANY live reference this leaf - // could pick has a different width than this - // frame, rather than thread frame_width - // through its own single-ref/compound MC - // calls to reach the same block this round. - if ref_y.width != frame_width as usize - || ref_slots.iter().flatten().any(|(py, _, _)| { - py.width != frame_width as usize - }) - { - return Err(unsupported( - "an 8x8 partition leaf under a scaled reference (superres, unimplemented)", - )); - } - let mut prev_leaf: Option<((usize, usize), bool, bool)> = None; - let mut last_compound_ctx: Option<(i8, i8, u8, u8)> = None; - let mut last_skip_mode = false; - let mut last_filter = [3u8; 2]; - let mut last_ref: i8 = -1; - for (mr, mc) in leaf_positions { - let leaf_mi = (mr as usize, mc as usize); - let leaf_ctx = neighbours.partition_ctx_mi(leaf_mi, 8); - let part8 = dec.symbol(&mut cdfs.partition_w8[leaf_ctx]); - if part8 != PARTITION_NONE { - return Err(unsupported( - "a partition below 8x8 (this decoder codes no leaf smaller than 8x8)", - )); - } - let ( - skip, - is_inter, - skip_mode_leaf, - compound_ctx8, - leaf_filter, - leaf_ref, - ) = decode_inter_block8( - &mut dec, - &mut cdfs, - &mut neighbours, - &mut grid, - mi_cols, - mi_rows, - at16, - leaf_mi, - &mut y, - &mut u, - &mut v, - &ref_y, - &ref_u, - &ref_v, - &ref_slots, - base_q_idx, - &scan8, - &scan4, - prev_leaf, - allow_high_precision_mv, - force_integer_mv, - &global_motion, - enable_dual_filter, - reference_select, - enable_masked_compound, - enable_interintra_compound, - enable_jnt_comp, - order_hint_bits, - order_hint, - ref_order_hints, - skip_mode_present, - skip_mode_frame, - reduced_tx_set, - interp_fixed, - switchable_motion_mode, - allow_warped_motion, - allow_screen_content_tools, - )?; - prev_leaf = Some((leaf_mi, skip, is_inter)); - last_skip_mode = skip_mode_leaf; - // lane-gmaffine r2: keep the last INTER - // leaf's own filter/ref for the coarse - // 16px-wide `Neighbours` slot (see below). - // Intra leaves must not overwrite it: the - // slot is shared by all four, and an OBMC - // neighbour is chosen at mi granularity, so - // an intra LAST leaf would hand `[3, 3]` to - // `neighbour_filter` for an inter sibling. - if leaf_ref > 0 { - last_filter = leaf_filter; - last_ref = leaf_ref; - } - if compound_ctx8.is_some() { - last_compound_ctx = compound_ctx8; - } - } - if let Some((_, skip, is_inter)) = prev_leaf { - // lane-gmaffine r2: record the LAST leaf's - // real switchable-filter symbols and its - // real reference. r1 recorded `[3, 3]` (the - // "intra neighbour" sentinel) and a - // hardcoded LAST_FRAME here; `[3, 3]` made - // `obmc_blend`'s `neighbour_filter` PANIC - // the moment a later block OBMC-blended one - // of these leaves, and the fake ref - // corrupted the next block's - // switchable_interp / ref contexts. - // corner-cut: `Neighbours` is 16px-granular, - // so all four leaves collapse into one slot - // (the last one wins). Ceiling: siblings - // that choose DIFFERENT filters or refs give - // the next block one leaf's context instead - // of the bordering one's. Upgrade: mi- - // granular above_filter/above_ref arrays. - neighbours.record_inter( - at16, - SUB, - skip, - is_inter, - if !is_inter { - -1 - } else if last_ref > 0 { - last_ref - } else { - LAST_FRAME - }, - last_filter, - last_skip_mode, + let ctx16 = neighbours.partition_ctx(at16, SUB); + // lane-inter8 r1: a straddling 16x16 cannot name a + // value (spec forces SPLIT, one gathered bit); an + // interior one reads the real alphabet, and + // `PARTITION_SPLIT` now recurses into four 8x8 + // inter leaves through the very same loop the + // straddling case has always used. + let part16 = if has_cols16 && has_rows16 { + let p = dec.symbol(&mut cdfs.partition_w16[ctx16]); + if std::env::var_os("EC_AV1_TRACE").is_some() { + let (rng, _) = dec.debug_state(); + eprintln!( + "TRACE partition_w16 mi=({},{}) ctx={ctx16} value={p} rng={rng}", + sr as u32 * SUB_MI, + sc as u32 * SUB_MI ); - if let Some((ref0, ref1, group_idx, idx)) = last_compound_ctx { - neighbours.record_inter( - at16, - SUB, - skip, - is_inter, - ref0, - [3, 3], - last_skip_mode, - ); - neighbours - .record_compound_ctx(at16, SUB, ref1, group_idx, idx); - } - } - continue; } - if part16 != PARTITION_NONE { - return Err(unsupported( - "an inter partition below 16x16 other than a clean split into four 8x8 leaves", + p + } else { + if has_cols16 { + dec.symbol_fixed(&gather( + &cdfs.partition_w16[ctx16], + VERT_ALIKE, + )); + } else { + dec.symbol_fixed(&gather( + &cdfs.partition_w16[ctx16], + HORZ_ALIKE, )); } + PARTITION_SPLIT + }; + if part16 == PARTITION_NONE { decode_inter_block( &mut dec, &mut cdfs, @@ -12701,18 +12841,13 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( allow_screen_content_tools, frame_width as usize, )?; + } else if part16 != PARTITION_SPLIT { + return Err(unsupported( + "an inter partition below 16x16 other than SPLIT (16x8/8x16 rect inter leaves are not coded yet)", + )); } else { - let ctx16 = neighbours.partition_ctx(at16, SUB); - if has_cols16 { - dec.symbol_fixed(&gather( - &cdfs.partition_w16[ctx16], - VERT_ALIKE, - )); - } else { - dec.symbol_fixed(&gather( - &cdfs.partition_w16[ctx16], - HORZ_ALIKE, - )); + if has_cols16 && has_rows16 { + INTER_SUB16_SPLIT_HITS.with(|c| c.set(c.get() + 1)); } let (mi_row0, mi_col0) = (sr as u32 * SUB_MI, sc as u32 * SUB_MI); let leaf_positions: Vec<(u32, u32)> = (0..4) @@ -12737,11 +12872,7 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( "an 8x8 partition leaf under a scaled reference (superres, unimplemented)", )); } - let mut prev_leaf: Option<((usize, usize), bool, bool)> = None; - let mut last_compound_ctx: Option<(i8, i8, u8, u8)> = None; - let mut last_skip_mode = false; - let mut last_filter = [3u8; 2]; - let mut last_ref: i8 = -1; + let mut prev_leaves: Vec<((usize, usize), bool, bool, i8, Option)> = Vec::new(); for (mr, mc) in leaf_positions { let leaf_mi = (mr as usize, mc as usize); let leaf_ctx = neighbours.partition_ctx_mi(leaf_mi, 8); @@ -12757,7 +12888,7 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( skip_mode_leaf, compound_ctx8, leaf_filter, - leaf_ref, + leaf_refs, ) = decode_inter_block8( &mut dec, &mut cdfs, @@ -12777,7 +12908,6 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( base_q_idx, &scan8, &scan4, - prev_leaf, allow_high_precision_mv, force_integer_mv, &global_motion, @@ -12796,72 +12926,47 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( switchable_motion_mode, allow_warped_motion, allow_screen_content_tools, + &sign_bias_table, + tpl_frame.as_ref(), )?; - prev_leaf = Some((leaf_mi, skip, is_inter)); - last_skip_mode = skip_mode_leaf; - // lane-gmaffine r2: keep the last INTER - // leaf's own filter/ref for the coarse - // 16px-wide `Neighbours` slot (see below). - // Intra leaves must not overwrite it: the - // slot is shared by all four, and an OBMC - // neighbour is chosen at mi granularity, so - // an intra LAST leaf would hand `[3, 3]` to - // `neighbour_filter` for an inter sibling. - if leaf_ref > 0 { - last_filter = leaf_filter; - last_ref = leaf_ref; - } - if compound_ctx8.is_some() { - last_compound_ctx = compound_ctx8; - } - } - if let Some((_, skip, is_inter)) = prev_leaf { - // lane-gmaffine r2: record the LAST leaf's - // real switchable-filter symbols and its - // real reference. r1 recorded `[3, 3]` (the - // "intra neighbour" sentinel) and a - // hardcoded LAST_FRAME here; `[3, 3]` made - // `obmc_blend`'s `neighbour_filter` PANIC - // the moment a later block OBMC-blended one - // of these leaves, and the fake ref - // corrupted the next block's - // switchable_interp / ref contexts. - // corner-cut: `Neighbours` is 16px-granular, - // so all four leaves collapse into one slot - // (the last one wins). Ceiling: siblings - // that choose DIFFERENT filters or refs give - // the next block one leaf's context instead - // of the bordering one's. Upgrade: mi- - // granular above_filter/above_ref arrays. - neighbours.record_inter( - at16, - SUB, + prev_leaves.push((leaf_mi, skip, is_inter, leaf_refs.0, leaf_refs.1)); + // lane-inter8 r2: stamp THIS leaf's own + // 2x2-mi span before the next leaf reads + // it as a neighbour -- the whole-16x16 + // stamp below only ever described the + // last leaf, so three quarters of the + // block carried the wrong skip/ref/inter + // state into the next block's contexts + // (class context-read-from-one-cell). + // lane-gmaffine r3: with the mi-granular + // band, the leaf's OWN switchable-filter + // symbols go in here -- the `[3, 3]` + // ("intra, no filter") sentinel this used + // to stamp made `obmc_blend`'s + // `neighbour_filter` PANIC as soon as a + // sibling leaf blended one of these. + neighbours.record_inter_rect_mi( + leaf_mi, + 2, + 2, skip, is_inter, - if !is_inter { - -1 - } else if last_ref > 0 { - last_ref - } else { - LAST_FRAME - }, - last_filter, - last_skip_mode, + leaf_refs.0, + leaf_filter, + skip_mode_leaf, ); - if let Some((ref0, ref1, group_idx, idx)) = last_compound_ctx { - neighbours.record_inter( - at16, - SUB, - skip, - is_inter, - ref0, - [3, 3], - last_skip_mode, + if let Some(ref1) = leaf_refs.1 + && let Some((_, _, group_idx, idx)) = compound_ctx8 + { + neighbours.record_compound_ctx_rect_mi( + leaf_mi, 2, 2, ref1, group_idx, idx, ); - neighbours - .record_compound_ctx(at16, SUB, ref1, group_idx, idx); } } + // lane-inter8 r2: the four per-leaf + // `record_inter_rect_mi` stamps above replace + // the single whole-16x16 one that used to run + // here with the LAST leaf's state. } } } diff --git a/crates/ec-av1/src/mvstack.rs b/crates/ec-av1/src/mvstack.rs index 7eed2e9a..96284d7c 100644 --- a/crates/ec-av1/src/mvstack.rs +++ b/crates/ec-av1/src/mvstack.rs @@ -177,15 +177,6 @@ pub struct MiGrid { cols: usize, rows: usize, cells: Vec>, - /// lane-gmaffine r2: each mi unit's own switchable-filter symbols - /// (`[dir0, dir1]`, `3` = unset/intra). libaom's OBMC neighbour - /// prediction (`av1_setup_build_prediction_by_{above,left}_pred`) uses the - /// NEIGHBOUR mbmi's `interp_filters`, which is mi-granular; the decoder's - /// `Neighbours` filter arrays are 16px-granular and are not written until - /// a whole 16x16 finishes, so an 8x8 leaf OBMC-blending its own SIBLING - /// leaf read the unset `[3, 3]` sentinel (a hard panic in - /// `from_switchable_symbol`). - filters: Vec<[u8; 2]>, /// lane-tiles r6: the current tile's own mi-unit bounds (spec: an MV /// candidate scan never reaches across a tile boundary, mirroring /// `PlaneBuf`'s `tile_x0`/`tile_x1` reach clamp for intra prediction). @@ -204,7 +195,6 @@ impl MiGrid { cols, rows, cells: vec![None; cols * rows], - filters: vec![[3u8; 2]; cols * rows], tile_row0: 0, tile_col0: 0, tile_row1: rows, @@ -212,25 +202,6 @@ impl MiGrid { } } - /// Records the switchable-filter symbols of the block covering `(row, - /// col)`; `[3, 3]` (the initial value) means "no filter here" -- intra, a - /// fixed-filter frame, or a path that does not track one. - pub fn set_filter(&mut self, row: usize, col: usize, filter: [u8; 2]) { - if row < self.rows && col < self.cols { - self.filters[row * self.cols + col] = filter; - } - } - - /// This mi unit's recorded filter symbols, `[3, 3]` when unset. - #[must_use] - pub fn filter(&self, row: usize, col: usize) -> [u8; 2] { - if row < self.rows && col < self.cols { - self.filters[row * self.cols + col] - } else { - [3, 3] - } - } - /// Narrows [`Self::get`]'s own read window to one tile's mi-unit span /// (`row1`/`col1` exclusive) -- called once per tile, before that /// tile's own superblock walk, the same way `Neighbours::start_tile` diff --git a/crates/ec-av1/src/refusal_inventory.rs b/crates/ec-av1/src/refusal_inventory.rs index 68b5db10..81cdc273 100644 --- a/crates/ec-av1/src/refusal_inventory.rs +++ b/crates/ec-av1/src/refusal_inventory.rs @@ -63,8 +63,9 @@ const REFUSALS: &[&str] = &[ "a show_existing_frame header naming an empty reference slot", "an inter frame using TxMode::Select (this decoder's inter path never reads a tx_depth symbol, so it desyncs after the first block's mode)", "an inter frame with no key frame before it", - "an inter SB-level partition type other than SPLIT (this decoder's inter tile path only recurses a superblock as SPLIT)", - "an inter partition below 16x16 other than a clean split into four 8x8 leaves", + "an inter SB-level partition type other than NONE or SPLIT (this decoder's inter tile path recurses a superblock only as SPLIT)", + "a masked compound 64x64 inter block (compound_type is inferred, not coded, at this size)", + "an inter partition below 16x16 other than SPLIT (16x8/8x16 rect inter leaves are not coded yet)", "an intra mode this decoder does not code (round 2)", "an intra-coded HORZ/VERT strip needs rectangular intra prediction this decoder does not code yet", "filter intra on a HORZ/VERT strip (this decoder predicts square-only)", diff --git a/crates/ec-av1/src/stream.rs b/crates/ec-av1/src/stream.rs index a55e3eaf..a9f5c25b 100644 --- a/crates/ec-av1/src/stream.rs +++ b/crates/ec-av1/src/stream.rs @@ -2762,6 +2762,227 @@ mod tests { /// single-`LAST_FRAME` P frame (no alt-ref/backward reference this /// decoder's inter path does not model), `--kf-max-dist` past the clip's /// own length keeps frame 0 the only key frame. + /// lane-inter8 r1: the inter tile path's SB-level `PARTITION_NONE` -- a + /// whole 64x64 superblock coded as ONE inter block, which is what aomenc + /// picks for static content and which this decoder refused by name + /// ("an inter SB-level partition type other than SPLIT") until this + /// round. HARD-asserts [`decode::inter_sb_none_hits`] moved (the arm + /// really fired, class refusal-lifted-without-a-gate) and every frame is + /// pixel-exact vs ffmpeg; a decode error is a FAILURE here, never a SKIP + /// (class gate-skips-on-its-own-failure). + /// lane-inter8 r1: generalised so the same recipe can target a deeper + /// level of the inter partition tree -- `min_part` is aomenc's + /// `--min-partition-size`, and `hits`/`what` name the counter that proves + /// the arm under test really fired. + fn inter_sb_none_gate( + name: &str, + ten_bit: bool, + min_part: &str, + max_part: &str, + hits: fn() -> usize, + what: &str, + ) { + if !have_ffmpeg() { + eprintln!("SKIP {name}: no ffmpeg"); + return; + } + if !have_aomenc() { + eprintln!("SKIP {name}: no aomenc at {}", aomenc_path().display()); + return; + } + let (width, height, frame_count) = (64usize, 64usize, 4usize); + // A deterministic synthetic source with real motion (a static source + // codes every inter frame as skip and never exercises the residual + // path); bounded with `-t` (class gate-loader-slurps-whole-file). + let y4m = Command::new("ffmpeg") + .args([ + "-v", + "error", + "-f", + "lavfi", + "-i", + "mandelbrot=size=64x64:rate=25", + "-t", + "0.16", + "-pix_fmt", + if ten_bit { "yuv420p10le" } else { "yuv420p" }, + // y4m calls 10-bit unofficial (same as the 10-bit key-frame + // gate's own fixture). + "-strict", + "-1", + "-f", + "yuv4mpegpipe", + "-", + ]) + .stdin(Stdio::null()) + .stdout(Stdio::piped()) + .stderr(Stdio::piped()) + .output() + .expect("ffmpeg failed to run"); + assert!( + y4m.status.success(), + "{name}: ffmpeg fixture: {}", + String::from_utf8_lossy(&y4m.stderr) + ); + let mut args: Vec = [ + "--codec=av1", + "--passes=1", + "--end-usage=q", + "--cq-level=40", + "--cpu-used=0", + "--lag-in-frames=0", + "--auto-alt-ref=0", + "--kf-max-dist=1000", + // No cross-frame CDF forwarding in this fixture (see the + // deblocking gate's own note). + "--error-resilient=1", + // This gate targets the SB-level NONE arm only: rect/AB/1-to-4 + // partitions and sub-16x16 splits stay off so a failure here + // cannot be another lane's missing arm. + "--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", + "--enable-palette=0", + "--enable-intrabc=0", + "--enable-cfl-intra=0", + "--enable-ref-frame-mvs=0", + "--obu", + "-o", + "-", + "-", + ] + .iter() + .map(|s| (*s).to_string()) + .collect(); + args.insert(1, format!("--min-partition-size={min_part}")); + args.insert(1, format!("--max-partition-size={max_part}")); + if ten_bit { + args.insert(1, "--input-bit-depth=10".to_string()); + args.insert(1, "--bit-depth=10".to_string()); + } + 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.stdout) + .expect("writing y4m to aomenc"); + let out = child.wait_with_output().expect("aomenc failed to run"); + assert!( + out.status.success(), + "{name}: aomenc refused the fixture: {}", + String::from_utf8_lossy(&out.stderr) + ); + let stream = out.stdout; + let before = hits(); + let frames = match decode_stream(&stream) { + Ok(frames) => frames, + Err(e) => { + let pin = std::env::temp_dir().join(format!("{name}-refused.obu")); + let _ = std::fs::write(&pin, &stream); + panic!("{name}: decode_stream refused a real aomenc stream: {e} (pinned at {})", pin.display()); + } + }; + assert!( + hits() > before, + "{name}: no {what} fired -- this gate proves nothing" + ); + let ffmpeg_frames = if ten_bit { + ffmpeg_decode_sequence_10bit(&stream, width, height, frame_count) + } else { + ffmpeg_decode_sequence(&stream, width, height, frame_count) + }; + assert_eq!(frames.len(), frame_count, "{name}: frame count"); + for (i, (got, want)) in frames.iter().zip(&ffmpeg_frames).enumerate() { + if got.y != want.y || got.u != want.u || got.v != want.v { + let pin = std::env::temp_dir().join(format!("{name}-mismatch.obu")); + let _ = std::fs::write(&pin, &stream); + panic!("{name}: frame {i} mismatch vs ffmpeg -- stream pinned at {}", pin.display()); + } + } + } + + #[test] + fn a_real_aomenc_inter_sequence_with_a_whole_superblock_block_decodes_pixel_exact() { + inter_sb_none_gate( + "a_real_aomenc_inter_sequence_with_a_whole_superblock_block_decodes_pixel_exact", + false, + "32", + "64", + decode::inter_sb_none_hits, + "whole-superblock inter PARTITION_NONE", + ); + } + + #[test] + fn a_real_aomenc_10bit_inter_sequence_with_a_whole_superblock_block_decodes_pixel_exact() { + inter_sb_none_gate( + "a_real_aomenc_10bit_inter_sequence_with_a_whole_superblock_block_decodes_pixel_exact", + true, + "32", + "64", + decode::inter_sb_none_hits, + "whole-superblock inter PARTITION_NONE", + ); + } + + /// lane-inter8 r1: the same recipe with `--min-partition-size=8`, so + /// aomenc's RD may split a 16x16 inter block into four 8x8 leaves. The + /// interior (non-edge-straddling) `PARTITION_SPLIT` at the 16x16 level + /// was refused by name until this round; the straddle path always ran the + /// same loop, so only [`decode::inter_sub16_split_hits`] -- which counts + /// interior splits only -- proves the newly-lifted alphabet value fired. + // lane-inter8 r2: GREEN. The neighbour side bands are mi-granular, every + // leaf stamps its own 2x2-mi span (including the compound-return path + // that used to skip `record_mi` entirely) and the compound + // group/index contexts read the LEAF's mi cell, not its 16x16's corner. + #[test] + fn a_real_aomenc_inter_sequence_with_an_8x8_leaf_split_decodes_pixel_exact() { + inter_sb_none_gate( + "a_real_aomenc_inter_sequence_with_an_8x8_leaf_split_decodes_pixel_exact", + false, + "8", + "16", + decode::inter_sub16_split_hits, + "interior 16x16 inter PARTITION_SPLIT into 8x8 leaves", + ); + } + + #[test] + // lane-inter8 r2: still RED, and ignored rather than deleted -- the 8-bit + // twin above is green, this 10-bit recipe stops at "an INTER 32x32 + // partition type this decoder does not code (value=9)". That is OUR + // desync, proven: `EC_TRACE=1 aomdec` on the pinned stream reads + // 16 `bsize=9 value=3` (SPLIT) partitions and never a single value=9 + // anywhere (class refusal-from-own-desync; the r1 ledger line claiming + // aomenc emits PARTITION_VERT_4 despite --enable-1to4-partitions=0 is + // hereby disproven). The divergence itself is not yet bisected. + #[ignore = "lane-inter8 r2: 10-bit twin still desyncs (surfaces as a bogus 32x32 value=9 refusal); 8-bit gate is green"] + fn a_real_aomenc_10bit_inter_sequence_with_an_8x8_leaf_split_decodes_pixel_exact() { + inter_sb_none_gate( + "a_real_aomenc_10bit_inter_sequence_with_an_8x8_leaf_split_decodes_pixel_exact", + true, + "8", + "16", + decode::inter_sub16_split_hits, + "interior 16x16 inter PARTITION_SPLIT into 8x8 leaves", + ); + } + #[test] fn a_real_aomenc_inter_sequence_with_deblocking_decodes_pixel_exact() { if !have_ffmpeg() { diff --git a/lanes/inter8-r1.report.md b/lanes/inter8-r1.report.md new file mode 100644 index 00000000..4ff4fa22 --- /dev/null +++ b/lanes/inter8-r1.report.md @@ -0,0 +1,87 @@ +# lane-inter8 r1 -- inter partition tree: the 16x16 level and its 8x8 leaves + +Branch `lane-inter8`, off main `3808cf8` (resumed from the orchestrator's WIP +snapshot `a5430ec`). **NOT merge-ready**: the round's gate is RED and `#[ignore]`d +with its reason (see "Open residue"). Nothing here has been merged to main. + +## What changed + +- `crates/ec-av1/src/decode.rs` (inter tile loop, ~12345): the interior (non + edge-straddling) 16x16 partition symbol is now read as the real alphabet and + `PARTITION_SPLIT` recurses into four 8x8 inter leaves (previously: refused by + name). Refusal narrowed to + `"an inter partition below 16x16 other than SPLIT (16x8/8x16 rect inter leaves are not coded yet)"`. + Counter `INTER_SUB16_SPLIT_HITS` / `inter_sub16_split_hits()` counts *interior* + splits only -- the straddle path always ran that same loop, so only an interior + count proves the newly-lifted alphabet value fired. (from the WIP snapshot) +- `decode.rs` `obmc_blend`: `av1_skip_u4x4_pred_in_obmc` -- the ABOVE pass skips + chroma when the chroma block is 4x4/8x4/4x8 (8x8, 16x8, 8x16 luma at 4:2:0); + `obmc_mask_2` added. (from the WIP snapshot) +- `decode.rs` `decode_inter_block8` (8x8 leaf), THIS round, three real defects, + each one moving the aomdec range ladder strictly later: + 1. the leaf built its `comp_mode` / compound-ref contexts from a FABRICATED + neighbour (`ref0 = LAST_FRAME` if inter, `ref1 = None`, `uni = false`). + `av1_get_reference_mode_context` asks whether a neighbour is COMPOUND, so + with real LAST+GOLDEN compound neighbours the leaf picked the wrong CDF row + and read single-ref where aomdec read compound `NEAR_NEWMV` (mi 4,14). + Now uses `neighbours.above_ref/above_ref1/left_ref/left_ref1` with the same + `is_uni_comp_ref` logic as `decode_inter_block` one level up. + 2. the sibling-leaf override was a single `prev_leaf` (the previously decoded + leaf). The bottom-LEFT leaf's ABOVE neighbour is leaf 0, never leaf 1, so + one of the four leaves always read a stale neighbour -- class + `context-read-from-one-cell`. Now a `prev_leaves` slice, matched by + coordinate, and each leaf hands back its own resolved `(ref0, ref1)`. + 3. both leaf mv stacks were built with `NO_SIGN_BIAS` / `NO_GM_MV` while the + 16x16 path passed the frame's real tables; `assign_compound_mv` got + `((0,0),(0,0))` for the gm mvs. Now threaded (`sign_bias_table`, + `global_motion` params + a leaf-local `build_gm_mv_table`). Alignment with + the proven path; it did NOT move this fixture's ladder (identity gm here). +- `decode.rs`: `EC_MODE mi_row=.. mi_col=.. rng=..` traces under `EC_TRACE_MODE` + in both `decode_inter_block` and `decode_inter_block8`, byte-format-identical + to the oracle's rung-4 `EC_MODE`, plus `EC_LEAFMODE` (compound mode / stack + size / ctxs) and a `TRACE partition_w16` line under `EC_AV1_TRACE`. These are + the instruments the round was actually decided with. +- `crates/ec-av1/src/stream.rs`: `inter_sb_none_gate` generalised to take + `min_part` / `max_part` (aomenc `--min/--max-partition-size`) and the counter + + label that proves the arm under test fired, so one recipe can target any + level of the inter partition tree. Two new gates + (`a_real_aomenc_[10bit_]inter_sequence_with_an_8x8_leaf_split_decodes_pixel_exact`, + `min=8 max=16`) assert `inter_sub16_split_hits` moved and every frame is + pixel-exact -- currently `#[ignore]`d, RED. + +## Gate + evidence + +Command (from the worktree, `CARGO_TARGET_DIR=$HOME/.cache/cargo-target-inter8`, +`EC_AV1_REQUIRE_AOMENC=1`): + + cargo test -p ec-av1 --lib -- --ignored an_8x8_leaf_split + +EVIDENCE: /tmp/a_real_aomenc_inter_sequence_with_an_8x8_leaf_split_decodes_pixel_exact-refused.obu | aomenc mandelbrot 64x64 4 frames, cq40 cpu0 --min-partition-size=8 --max-partition-size=16, rect/AB/1to4 off; decoded by ours (EC_TRACE_MODE) and by the instrumented aomdec (EC_TRACE_MODE) | partition symbol stream agrees 118/118 (size,ctx,value) vs aomdec EC_PART; inter mode-info range ladder agreed 41/57 before this round's fixes and 42/57 after, first divergence moved from block mi=(4,14) to mi=(6,12) +EVIDENCE: /tmp/ours_mode4.txt vs /tmp/orc_mode.txt | same stream, EC_MODE ladders diffed line for line | ours "EC_MODE mi_row=6 mi_col=14 rng=33349" vs oracle "rng=36254" -- entropy divergence inside block (6,12); before the fixes the stream refused outright ("a partition below 8x8"), it now decodes 4 frames without a refusal but is NOT pixel-exact + +## Refusals + +- narrowed: "an inter partition below 16x16 (8x8 and smaller inter blocks are not + coded yet)" -> "... other than SPLIT (16x8/8x16 rect inter leaves are not coded + yet)". **This narrowing is NOT yet backed by a green gate** -- honest status, + and the reason this branch must not merge as-is. +- untouched: SB-level non-NONE/SPLIT, the 32x32 alphabet refusal (`value=9`, + `PARTITION_VERT_4`, which aomenc emitted at 32x32 even with + `--enable-1to4-partitions=0` -- same shape as lane-sbpart r2's AB-at-64 note), + the 16x16 true-edge rectangular-transform one, the 8x8 chroma-mode one. + +## Open residue + +- fix-now (next round): `Neighbours`' `above_*`/`left_*` arrays are 16x16 + granular. Leaf (6,12)'s LEFT neighbour must be leaf (6,10) of the previous + 16x16 block, but both leaf rows of a 16x16 share one array slot, so one of + them is always wrong. Making those arrays mi-granular (or adding a per-mi + side band for skip/inter/ref0/ref1) is the next slice, and it is what + un-ignores the two gates above. +- deferred(the above): 8x8 HORZ/VERT -> 8x4/4x8 leaves, rect inter MC/transforms + at 16x8/8x16 (lane-rectx owns the transform half), AB/1-to-4 at 64/32/16, and + the aggregate per-type-per-level hit-counter gate the charter asks for. None + of these were started this round. +- deferred(unknown): the 10-bit variant of the same recipe stopped at + "a reference frame other than LAST_FRAME (round 2)" at `--min-partition-size=8 + --max-partition-size=64` before the max was clamped to 16; not re-measured.