forge
Explore
Log in

Don't you dare go Hollow

merge lane-inter8 ae69b25 into lane-gmaffine

Browse files at this commit

cadfff77383eeaeda6451d2f77b9d00c052b0ac5Ahmet Kaan GümüşParent: 0226216cbf9f54
Conflict resolution (both sides kept, duplicates unified):
- obmc chroma-above skip: lane-inter8's explicit BLOCK_4X4/4X8/8X4 match list
  (correct for 8x32/32x8, where lane-gmaffine's `w>=16 && h>=16` would have
  skipped chroma libaom blends).
- OBMC neighbour filter: read from lane-inter8's now mi-granular
  `Neighbours::above_filter/left_filter`; lane-gmaffine's duplicate
  `MiGrid::filters` per-mi record (plus `grid_or_slot`) deleted as the same
  field recorded twice.
- `decode_inter_block8`: one `global_motion` param (lane-gmaffine's) plus
  lane-inter8's `sign_bias_table`/`tpl_frame`; single `gm_table` build at the
  top; returns `(.., leaf_filter_syms, leaf_refs)`.
- the leaf's temporal-mv `cur_offset_0` keys on the leaf's OWN reference
  (lane-inter8 hardcoded LAST because it refused every other ref).
- per-leaf `record_inter_rect_mi` stamp keeps lane-gmaffine's REAL filter
  symbols instead of the `[3, 3]` intra sentinel; the coarse whole-16x16
  `record_inter` and its last_filter/last_ref bookkeeping are gone.
- the interior 16x16 SPLIT branch is lane-inter8's restructure (part16 read
  once, one shared leaf loop); refusal strings follow it.
crates/ec-av1/src/decode.rsmodified+512 -407
@@ -35,7 +35,7 @@ use crate::msac::SymbolDecoder;
35 use crate::mvstack::{35 use crate::mvstack::{
36 ALTREF_FRAME, ALTREF2_FRAME, BWDREF_FRAME, GOLDEN_FRAME, LAST_FRAME, LAST2_FRAME, LAST3_FRAME,36 ALTREF_FRAME, ALTREF2_FRAME, BWDREF_FRAME, GOLDEN_FRAME, LAST_FRAME, LAST2_FRAME, LAST3_FRAME,
37 MiGrid, MiInfo, NO_SIGN_BIAS, NeighbourRef, SignBiasTable, comp_reference_type_ctx,37 MiGrid, MiInfo, NO_SIGN_BIAS, NeighbourRef, SignBiasTable, comp_reference_type_ctx,
38- find_mv_stack_with_sign_bias, reference_mode_ctx, single_ref_ctx,38+ find_mv_stack_with_sign_bias, reference_mode_ctx,
39 single_ref_p1_ctx, single_ref_p2_ctx, single_ref_p3_ctx, single_ref_p4_ctx, single_ref_p5_ctx,39 single_ref_p1_ctx, single_ref_p2_ctx, single_ref_p3_ctx, single_ref_p4_ctx, single_ref_p5_ctx,
40 single_ref_p6_ctx, uni_comp_ref_p1_ctx,40 single_ref_p6_ctx, uni_comp_ref_p1_ctx,
41 };41 };
@@ -766,6 +766,33 @@ pub(crate) fn rect_partition_hits() -> usize {
766 RECT_PARTITION_HITS.with(|c| c.get())766 RECT_PARTITION_HITS.with(|c| c.get())
767 }767 }
768 768
769+// lane-inter8 r1: how many superblocks an inter tile coded as a single
770+// whole-SB `PARTITION_NONE` 64x64 inter block (the case aomenc picks for
771+// static content, previously a named refusal).
772+thread_local! {
773+ static INTER_SB_NONE_HITS: std::cell::Cell<usize> =
774+ const { std::cell::Cell::new(0) };
775+}
776+
777+/// Current value of [`INTER_SB_NONE_HITS`].
778+pub(crate) fn inter_sb_none_hits() -> usize {
779+ INTER_SB_NONE_HITS.with(|c| c.get())
780+}
781+
782+// lane-inter8 r1: how many INTERIOR (not frame-edge-straddling) 16x16 inter
783+// blocks coded a real `PARTITION_SPLIT` into four 8x8 leaves -- the straddle
784+// path has always run that loop, so only this counter proves the newly-lifted
785+// alphabet value fired.
786+thread_local! {
787+ static INTER_SUB16_SPLIT_HITS: std::cell::Cell<usize> =
788+ const { std::cell::Cell::new(0) };
789+}
790+
791+/// Current value of [`INTER_SUB16_SPLIT_HITS`].
792+pub(crate) fn inter_sub16_split_hits() -> usize {
793+ INTER_SUB16_SPLIT_HITS.with(|c| c.get())
794+}
795+
769 // lane-rectwire r2: how many `PARTITION_HORZ`/`VERT` strips actually decoded796 // lane-rectwire r2: how many `PARTITION_HORZ`/`VERT` strips actually decoded
770 // real (non-skip) coefficients through [`read_coeffs_rect`] -- proves the797 // real (non-skip) coefficients through [`read_coeffs_rect`] -- proves the
771 // rect coefficient reader itself fired, not just the strip-level partition798 // rect coefficient reader itself fired, not just the strip-level partition
@@ -1916,22 +1943,26 @@ impl Neighbours {
1916 left_side: vec![SB; rows],1943 left_side: vec![SB; rows],
1917 above_side_mi: vec![SB; cols * (SUB / MI)],1944 above_side_mi: vec![SB; cols * (SUB / MI)],
1918 left_side_mi: vec![SB; rows * (SUB / MI)],1945 left_side_mi: vec![SB; rows * (SUB / MI)],
1919- above_skip: vec![false; cols],1946+ // lane-inter8 r2: mi(4px)-granular, not [`SUB`]-granular -- an
1920- left_skip: vec![false; rows],1947+ // 8x8 inter leaf's left neighbour is the OTHER leaf row of the
1921- above_skip_mode: vec![false; cols],1948+ // 16x16 block beside it, which a SUB-grid slot cannot name
1922- left_skip_mode: vec![false; rows],1949+ // (class context-read-from-one-cell).
1923- above_inter: vec![false; cols],1950+ above_skip: vec![false; cols * (SUB / MI)],
1924- left_inter: vec![false; rows],1951+ left_skip: vec![false; rows * (SUB / MI)],
1925- above_ref: vec![-1; cols],1952+ above_skip_mode: vec![false; cols * (SUB / MI)],
1926- left_ref: vec![-1; rows],1953+ left_skip_mode: vec![false; rows * (SUB / MI)],
1927- above_ref1: vec![None; cols],1954+ above_inter: vec![false; cols * (SUB / MI)],
1928- left_ref1: vec![None; rows],1955+ left_inter: vec![false; rows * (SUB / MI)],
1929- above_comp_group_idx: vec![0; cols],1956+ above_ref: vec![-1; cols * (SUB / MI)],
1930- left_comp_group_idx: vec![0; rows],1957+ left_ref: vec![-1; rows * (SUB / MI)],
1931- above_compound_idx: vec![0; cols],1958+ above_ref1: vec![None; cols * (SUB / MI)],
1932- left_compound_idx: vec![0; rows],1959+ left_ref1: vec![None; rows * (SUB / MI)],
1933- above_filter: vec![[3u8; 2]; cols],1960+ above_comp_group_idx: vec![0; cols * (SUB / MI)],
1934- left_filter: vec![[3u8; 2]; rows],1961+ left_comp_group_idx: vec![0; rows * (SUB / MI)],
1962+ above_compound_idx: vec![0; cols * (SUB / MI)],
1963+ left_compound_idx: vec![0; rows * (SUB / MI)],
1964+ above_filter: vec![[3u8; 2]; cols * (SUB / MI)],
1965+ left_filter: vec![[3u8; 2]; rows * (SUB / MI)],
1935 mi_cols,1966 mi_cols,
1936 mi_rows,1967 mi_rows,
1937 skip_grid: vec![false; cols * (SUB / MI) * rows * (SUB / MI)],1968 skip_grid: vec![false; cols * (SUB / MI) * rows * (SUB / MI)],
@@ -1974,6 +2005,11 @@ impl Neighbours {
1974 for i in sc0.min(sc1)..sc1 {2005 for i in sc0.min(sc1)..sc1 {
1975 self.above_mode[i] = DC_PRED;2006 self.above_mode[i] = DC_PRED;
1976 self.above_side[i] = SB;2007 self.above_side[i] = SB;
2008+ }
2009+ // lane-inter8 r2: the inter bands are mi-granular, so they reset over
2010+ // the tile's own mi column span directly.
2011+ let mend = col1_mi.min(self.above_skip.len());
2012+ for i in col0_mi.min(mend)..mend {
1977 self.above_skip[i] = false;2013 self.above_skip[i] = false;
1978 self.above_skip_mode[i] = false;2014 self.above_skip_mode[i] = false;
1979 self.above_inter[i] = false;2015 self.above_inter[i] = false;
@@ -2280,8 +2316,37 @@ impl Neighbours {
2280 skip_mode: bool,2316 skip_mode: bool,
2281 ) {2317 ) {
2282 let (r, c) = at;2318 let (r, c) = at;
2319+ self.record_inter_rect_mi(
2320+ (r * (SUB / MI), c * (SUB / MI)),
2321+ w_sub / MI,
2322+ h_sub / MI,
2323+ skip,
2324+ is_inter,
2325+ ref_frame,
2326+ filter,
2327+ skip_mode,
2328+ );
2329+ }
2330+
2331+ /// [`Self::record_inter_rect`] in mi (4px) units -- lane-inter8 r2: an
2332+ /// 8x8 leaf covers 2x2 mi, half a [`SUB`] cell in each direction, so the
2333+ /// side bands are written (and read) per mi. Every [`SUB`]-unit caller
2334+ /// routes through the wrapper above.
2335+ #[allow(clippy::too_many_arguments)]
2336+ fn record_inter_rect_mi(
2337+ &mut self,
2338+ at_mi: (usize, usize),
2339+ w_mi: usize,
2340+ h_mi: usize,
2341+ skip: bool,
2342+ is_inter: bool,
2343+ ref_frame: i8,
2344+ filter: [u8; 2],
2345+ skip_mode: bool,
2346+ ) {
2347+ let (r, c) = at_mi;
2283 let altref = is_inter && ref_frame == crate::mvstack::ALTREF_FRAME;2348 let altref = is_inter && ref_frame == crate::mvstack::ALTREF_FRAME;
2284- for cell in 0..w_sub / SUB {2349+ for cell in 0..w_mi {
2285 self.above_skip[c + cell] = skip;2350 self.above_skip[c + cell] = skip;
2286 self.above_skip_mode[c + cell] = skip_mode;2351 self.above_skip_mode[c + cell] = skip_mode;
2287 self.above_inter[c + cell] = is_inter;2352 self.above_inter[c + cell] = is_inter;
@@ -2299,7 +2364,7 @@ impl Neighbours {
2299 self.above_compound_idx[c + cell] = u8::from(altref);2364 self.above_compound_idx[c + cell] = u8::from(altref);
2300 self.above_filter[c + cell] = filter;2365 self.above_filter[c + cell] = filter;
2301 }2366 }
2302- for cell in 0..h_sub / SUB {2367+ for cell in 0..h_mi {
2303 self.left_skip[r + cell] = skip;2368 self.left_skip[r + cell] = skip;
2304 self.left_skip_mode[r + cell] = skip_mode;2369 self.left_skip_mode[r + cell] = skip_mode;
2305 self.left_inter[r + cell] = is_inter;2370 self.left_inter[r + cell] = is_inter;
@@ -2345,12 +2410,34 @@ impl Neighbours {
2345 compound_idx: u8,2410 compound_idx: u8,
2346 ) {2411 ) {
2347 let (r, c) = at;2412 let (r, c) = at;
2348- for cell in 0..w_sub / SUB {2413+ self.record_compound_ctx_rect_mi(
2414+ (r * (SUB / MI), c * (SUB / MI)),
2415+ w_sub / MI,
2416+ h_sub / MI,
2417+ ref1,
2418+ comp_group_idx,
2419+ compound_idx,
2420+ );
2421+ }
2422+
2423+ /// [`Self::record_compound_ctx_rect`] in mi units (lane-inter8 r2, see
2424+ /// [`Self::record_inter_rect_mi`]).
2425+ fn record_compound_ctx_rect_mi(
2426+ &mut self,
2427+ at_mi: (usize, usize),
2428+ w_mi: usize,
2429+ h_mi: usize,
2430+ ref1: i8,
2431+ comp_group_idx: u8,
2432+ compound_idx: u8,
2433+ ) {
2434+ let (r, c) = at_mi;
2435+ for cell in 0..w_mi {
2349 self.above_ref1[c + cell] = Some(ref1);2436 self.above_ref1[c + cell] = Some(ref1);
2350 self.above_comp_group_idx[c + cell] = comp_group_idx;2437 self.above_comp_group_idx[c + cell] = comp_group_idx;
2351 self.above_compound_idx[c + cell] = compound_idx;2438 self.above_compound_idx[c + cell] = compound_idx;
2352 }2439 }
2353- for cell in 0..h_sub / SUB {2440+ for cell in 0..h_mi {
2354 self.left_ref1[r + cell] = Some(ref1);2441 self.left_ref1[r + cell] = Some(ref1);
2355 self.left_comp_group_idx[r + cell] = comp_group_idx;2442 self.left_comp_group_idx[r + cell] = comp_group_idx;
2356 self.left_compound_idx[r + cell] = compound_idx;2443 self.left_compound_idx[r + cell] = compound_idx;
@@ -7815,6 +7902,23 @@ fn read_inter_plane(
7815 default_tx_type,7902 default_tx_type,
7816 None,7903 None,
7817 )?;7904 )?;
7905+ // lane-inter8 r1: a 64-point transform covers the whole 64x64 area but
7906+ // codes only its top-left 32x32 of frequencies (spec 5.11.40) -- the
7907+ // caller hands the 32-point `scan` there, and the coded corner goes into
7908+ // the top-left of the true `side`-sized grid before dequantization
7909+ // (dqDenom is keyed by the true size, not the corner's), mirroring
7910+ // [`read_plane`]'s own `tx_side != side` branch. Every other transform
7911+ // this decoder codes has `tx_side == side`, so this is inert below 64.
7912+ let tx_side = side.min(32);
7913+ let grid = if tx_side == side {
7914+ grid
7915+ } else {
7916+ let mut full = vec![0i32; side * side];
7917+ for row in 0..tx_side {
7918+ full[row * side..][..tx_side].copy_from_slice(&grid[row * tx_side..][..tx_side]);
7919+ }
7920+ full
7921+ };
7818 let (dc_delta, ac_delta) = plane_q_delta(plane_idx);7922 let (dc_delta, ac_delta) = plane_q_delta(plane_idx);
7819 let residual = dequant_and_inverse_typed(&grid, side, bit_depth(), CURRENT_Q_IDX.with(|c| c.get()), dc_delta, ac_delta, tx_type);7923 let residual = dequant_and_inverse_typed(&grid, side, bit_depth(), CURRENT_Q_IDX.with(|c| c.get()), dc_delta, ac_delta, tx_type);
7820 plane.reconstruct_mc(x, y, side, prediction, &residual);7924 plane.reconstruct_mc(x, y, side, prediction, &residual);
@@ -8169,6 +8273,10 @@ fn obmc_mask(len: usize) -> &'static [u8] {
8169 // round wired interior 16x16 splits down to real 8x8 leaves, where the8273 // round wired interior 16x16 splits down to real 8x8 leaves, where the
8170 // old `unreachable!()` below fired as a hard panic.8274 // old `unreachable!()` below fired as a hard panic.
8171 const M1: [u8; 1] = [64];8275 const M1: [u8; 1] = [64];
8276+ // lane-inter8 r1: `obmc_mask_2` (`reconinter.c` 753) -- reached by the
8277+ // LEFT pass of an 8x8 block's chroma plane (overlap 4 luma columns, 2
8278+ // chroma), which only became live once 8x8 inter leaves stopped being
8279+ // refused.
8172 const M2: [u8; 2] = [45, 64];8280 const M2: [u8; 2] = [45, 64];
8173 const M4: [u8; 4] = [39, 50, 59, 64];8281 const M4: [u8; 4] = [39, 50, 59, 64];
8174 const M8: [u8; 8] = [36, 42, 48, 53, 57, 61, 64, 64];8282 const M8: [u8; 8] = [36, 42, 48, 53, 57, 61, 64, 64];
@@ -8198,16 +8306,6 @@ fn obmc_mask(len: usize) -> &'static [u8] {
8198 /// excluded by [`overlappable_above`]/[`overlappable_left`]'s `is_inter`8306 /// excluded by [`overlappable_above`]/[`overlappable_left`]'s `is_inter`
8199 /// gate) or when `interp_fixed` is `Some` for the whole frame, handled here8307 /// gate) or when `interp_fixed` is `Some` for the whole frame, handled here
8200 /// first.8308 /// first.
8201-/// lane-gmaffine r2: prefer the mi-granular filter record, fall back to the
8202-/// coarse 16px `Neighbours` slot when this block's path never recorded one.
8203-fn grid_or_slot(mi_filter: [u8; 2], slot: [u8; 2]) -> [u8; 2] {
8204- if mi_filter[0] <= 2 && mi_filter[1] <= 2 {
8205- mi_filter
8206- } else {
8207- slot
8208- }
8209-}
8210-
8211 fn neighbour_filter(8309 fn neighbour_filter(
8212 interp_fixed: Option<mc::InterpFilterKind>,8310 interp_fixed: Option<mc::InterpFilterKind>,
8213 sym: [u8; 2],8311 sym: [u8; 2],
@@ -8425,14 +8523,7 @@ fn obmc_blend(
8425 };8523 };
8426 let overlap_above = write_h / 2;8524 let overlap_above = write_h / 2;
8427 let overlap_left = write_w / 2;8525 let overlap_left = write_w / 2;
8428- // lane-gmaffine r2 (libaom `av1_skip_u4x4_pred_in_obmc`, reconinter.c:820,8526+ let skip_chroma_above = matches!((write_w, write_h), (8, 8) | (16, 8) | (8, 16));
8429- // `DISABLE_CHROMA_U8X8_OBMC 0`): when the block's CHROMA plane size is
8430- // BLOCK_4X4/4X8/8X4 -- i.e. a luma dimension below 16 under 4:2:0 -- obmc
8431- // is ONE-SIDED on chroma: the above pass (dir==0) skips U/V entirely, the
8432- // left pass (dir==1) still blends them. Blending chroma on both passes is
8433- // exactly the residual that left the 8x8-leaf obmc gate's V plane off by
8434- // ~2 (r1); luma is unaffected at every size.
8435- let chroma_above = write_w >= 16 && write_h >= 16;
8436 8527
8437 for (off4, span4, nb) in overlappable_above(grid, mi_row, mi_col, bw4, mi_cols, max_nb(bw4))8528 for (off4, span4, nb) in overlappable_above(grid, mi_row, mi_col, bw4, mi_cols, max_nb(bw4))
8438 {8529 {
@@ -8447,22 +8538,23 @@ fn obmc_blend(
8447 // (compound), which is what every earlier round used.8538 // (compound), which is what every earlier round used.
8448 let (h_kind, v_kind) = neighbour_filter(8539 let (h_kind, v_kind) = neighbour_filter(
8449 interp_fixed,8540 interp_fixed,
8450- grid_or_slot(8541+ neighbours.above_filter[mi_col + off4],
8451- grid.filter(mi_row.wrapping_sub(1), mi_col + off4),
8452- neighbours.above_filter[(mi_col + off4) / SUB_MI as usize],
8453- ),
8454 );8542 );
8455 let (ny, nu, nv) = ref_planes(nb.ref_frame, ref_y, ref_u, ref_v, other_refs)?;8543 let (ny, nu, nv) = ref_planes(nb.ref_frame, ref_y, ref_u, ref_v, other_refs)?;
8456 let (bw, bh, ox) = (span4 * 4, overlap_above, off4 * 4);8544 let (bw, bh, ox) = (span4 * 4, overlap_above, off4 * 4);
8457 let tmp_y = obmc_neighbour_pred(ny, px + ox, py, nb.mv, bw, bh, true, h_kind, v_kind);8545 let tmp_y = obmc_neighbour_pred(ny, px + ox, py, nb.mv, bw, bh, true, h_kind, v_kind);
8458 obmc_blend_v(pred_y, side, ox, 0, bw, bh, &tmp_y);8546 obmc_blend_v(pred_y, side, ox, 0, bw, bh, &tmp_y);
8459- if chroma_above {8547+ // lane-inter8 r1: `av1_skip_u4x4_pred_in_obmc` (`reconinter.c` 820,
8548+ // `DISABLE_CHROMA_U8X8_OBMC == 0` -- "one-sided obmc"): when the
8549+ // chroma plane's own block size is BLOCK_4X4/8X4/4X8 (a 8x8, 16x8 or
8550+ // 8x16 luma block at 4:2:0), the ABOVE pass skips chroma entirely
8551+ // while the LEFT pass still blends it. Blending chroma here as well
8552+ // would both mis-predict every 8x8 leaf and ask for an overlap of 2.
8553+ if !skip_chroma_above {
8460 let (cbw, cbh, cox) = (bw / 2, overlap_above / 2, ox / 2);8554 let (cbw, cbh, cox) = (bw / 2, overlap_above / 2, ox / 2);
8461- let tmp_u =8555+ let tmp_u = obmc_neighbour_pred(nu, cpx + cox, cpy, nb.mv, cbw, cbh, false, h_kind, v_kind);
8462- obmc_neighbour_pred(nu, cpx + cox, cpy, nb.mv, cbw, cbh, false, h_kind, v_kind);
8463 obmc_blend_v(pred_u, chroma_side, cox, 0, cbw, cbh, &tmp_u);8556 obmc_blend_v(pred_u, chroma_side, cox, 0, cbw, cbh, &tmp_u);
8464- let tmp_v =8557+ let tmp_v = obmc_neighbour_pred(nv, cpx + cox, cpy, nb.mv, cbw, cbh, false, h_kind, v_kind);
8465- obmc_neighbour_pred(nv, cpx + cox, cpy, nb.mv, cbw, cbh, false, h_kind, v_kind);
8466 obmc_blend_v(pred_v, chroma_side, cox, 0, cbw, cbh, &tmp_v);8558 obmc_blend_v(pred_v, chroma_side, cox, 0, cbw, cbh, &tmp_v);
8467 }8559 }
8468 }8560 }
@@ -8470,10 +8562,7 @@ fn obmc_blend(
8470 for (off4, span4, nb) in overlappable_left(grid, mi_row, mi_col, bh4, mi_rows, max_nb(bh4)) {8562 for (off4, span4, nb) in overlappable_left(grid, mi_row, mi_col, bh4, mi_rows, max_nb(bh4)) {
8471 let (h_kind, v_kind) = neighbour_filter(8563 let (h_kind, v_kind) = neighbour_filter(
8472 interp_fixed,8564 interp_fixed,
8473- grid_or_slot(8565+ neighbours.left_filter[mi_row + off4],
8474- grid.filter(mi_row + off4, mi_col.wrapping_sub(1)),
8475- neighbours.left_filter[(mi_row + off4) / SUB_MI as usize],
8476- ),
8477 );8566 );
8478 let (ny, nu, nv) = ref_planes(nb.ref_frame, ref_y, ref_u, ref_v, other_refs)?;8567 let (ny, nu, nv) = ref_planes(nb.ref_frame, ref_y, ref_u, ref_v, other_refs)?;
8479 let (bw, bh, oy) = (overlap_left, span4 * 4, off4 * 4);8568 let (bw, bh, oy) = (overlap_left, span4 * 4, off4 * 4);
@@ -8514,10 +8603,17 @@ fn is_uni_comp_ref(ref0: i8, ref1: i8) -> bool {
8514 /// `get_comp_group_idx_context` (libaom `pred_common.h`): sums the8603 /// `get_comp_group_idx_context` (libaom `pred_common.h`): sums the
8515 /// above/left neighbour contributions [`Neighbours::record_inter`]/8604 /// above/left neighbour contributions [`Neighbours::record_inter`]/
8516 /// [`Neighbours::record_compound_ctx`] already precomputed, clamped to 5.8605 /// [`Neighbours::record_compound_ctx`] already precomputed, clamped to 5.
8517-fn get_comp_group_idx_context(neighbours: &Neighbours, at: (usize, usize), side: usize) -> usize {8606+/// lane-inter8 r2: `at_mi` is the block's own top-left in 4x4 mi units --
8607+/// an 8x8 leaf used to pass its enclosing 16x16's corner here, so all four
8608+/// leaves read the same neighbour cell (class context-read-from-one-cell).
8609+fn get_comp_group_idx_context(
8610+ neighbours: &Neighbours,
8611+ at_mi: (usize, usize),
8612+ side: usize,
8613+) -> usize {
8518 let _ = side;8614 let _ = side;
8519- let (r, c) = at;8615+ let (rmi, cmi) = at_mi;
8520- (neighbours.above_comp_group_idx[c] as usize + neighbours.left_comp_group_idx[r] as usize)8616+ (neighbours.above_comp_group_idx[cmi] as usize + neighbours.left_comp_group_idx[rmi] as usize)
8521 .min(5)8617 .min(5)
8522 }8618 }
8523 8619
@@ -8529,7 +8625,7 @@ fn get_comp_group_idx_context(neighbours: &Neighbours, at: (usize, usize), side:
8529 #[allow(clippy::too_many_arguments)]8625 #[allow(clippy::too_many_arguments)]
8530 fn get_comp_index_context(8626 fn get_comp_index_context(
8531 neighbours: &Neighbours,8627 neighbours: &Neighbours,
8532- at: (usize, usize),8628+ at_mi: (usize, usize),
8533 side: usize,8629 side: usize,
8534 order_hint_bits: u32,8630 order_hint_bits: u32,
8535 cur_order_hint: u32,8631 cur_order_hint: u32,
@@ -8537,7 +8633,7 @@ fn get_comp_index_context(
8537 ref1_order_hint: u32,8633 ref1_order_hint: u32,
8538 ) -> usize {8634 ) -> usize {
8539 let _ = side;8635 let _ = side;
8540- let (r, c) = at;8636+ let (rmi, cmi) = at_mi;
8541 let fwd =8637 let fwd =
8542 crate::motion_field::get_relative_dist(order_hint_bits, ref1_order_hint, cur_order_hint)8638 crate::motion_field::get_relative_dist(order_hint_bits, ref1_order_hint, cur_order_hint)
8543 .abs();8639 .abs();
@@ -8545,8 +8641,8 @@ fn get_comp_index_context(
8545 crate::motion_field::get_relative_dist(order_hint_bits, cur_order_hint, ref0_order_hint)8641 crate::motion_field::get_relative_dist(order_hint_bits, cur_order_hint, ref0_order_hint)
8546 .abs();8642 .abs();
8547 let offset = usize::from(fwd == bck);8643 let offset = usize::from(fwd == bck);
8548- neighbours.above_compound_idx[c] as usize8644+ neighbours.above_compound_idx[cmi] as usize
8549- + neighbours.left_compound_idx[r] as usize8645+ + neighbours.left_compound_idx[rmi] as usize
8550 + 3 * offset8646 + 3 * offset
8551 }8647 }
8552 8648
@@ -8920,6 +9016,11 @@ fn decode_inter_block(
8920 frame_width: usize,9016 frame_width: usize,
8921 ) -> Result<()> {9017 ) -> Result<()> {
8922 let (r, c) = at;9018 let (r, c) = at;
9019+ // lane-inter8 r2: the inter side bands are mi-granular; this block's own
9020+ // above/left neighbour is the mi cell at its top-left corner (libaom
9021+ // `above_mbmi` = mi(mi_row - 1, mi_col)), so a SUB-aligned block reads
9022+ // exactly what it read before.
9023+ let (rmi, cmi) = (r * (SUB / MI), c * (SUB / MI));
8923 let (px, py) = (c * SUB, r * SUB);9024 let (px, py) = (c * SUB, r * SUB);
8924 let (cpx, cpy) = (px / 2, py / 2);9025 let (cpx, cpy) = (px / 2, py / 2);
8925 let chroma_side = side / 2;9026 let chroma_side = side / 2;
@@ -8932,7 +9033,7 @@ fn decode_inter_block(
8932 );9033 );
8933 }9034 }
8934 let skip_mode_ctx =9035 let skip_mode_ctx =
8935- usize::from(neighbours.above_skip_mode[c]) + usize::from(neighbours.left_skip_mode[r]);9036+ usize::from(neighbours.above_skip_mode[cmi]) + usize::from(neighbours.left_skip_mode[rmi]);
8936 // lane-comppin r3: skip_mode desync isolation -- dump ctx + the pre-read9037 // lane-comppin r3: skip_mode desync isolation -- dump ctx + the pre-read
8937 // MSAC tell so it can be diffed against an equivalent hook in libaom's9038 // MSAC tell so it can be diffed against an equivalent hook in libaom's
8938 // own `read_skip_mode`/`av1_get_skip_mode_context`.9039 // own `read_skip_mode`/`av1_get_skip_mode_context`.
@@ -8953,7 +9054,7 @@ fn decode_inter_block(
8953 SKIP_MODE_HITS.with(|c| c.set(c.get() + 1));9054 SKIP_MODE_HITS.with(|c| c.set(c.get() + 1));
8954 }9055 }
8955 9056
8956- let skip_ctx = usize::from(neighbours.above_skip[c]) + usize::from(neighbours.left_skip[r]);9057+ let skip_ctx = usize::from(neighbours.above_skip[cmi]) + usize::from(neighbours.left_skip[rmi]);
8957 let skip = skip_mode || dec.symbol(&mut cdfs.skip[skip_ctx]) == 1;9058 let skip = skip_mode || dec.symbol(&mut cdfs.skip[skip_ctx]) == 1;
8958 maybe_read_cdef_idx(dec, r * SUB_MI as usize, c * SUB_MI as usize, skip);9059 maybe_read_cdef_idx(dec, r * SUB_MI as usize, c * SUB_MI as usize, skip);
8959 maybe_read_delta_q(dec, cdfs, r * SUB_MI as usize, c * SUB_MI as usize, side == 64, skip);9060 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(
8971 r > neighbours.tile_row0_mi / (SUB / MI),9072 r > neighbours.tile_row0_mi / (SUB / MI),
8972 c > neighbours.tile_col0_mi / (SUB / MI),9073 c > neighbours.tile_col0_mi / (SUB / MI),
8973 );9074 );
8974- let (above_inter, left_inter) = (neighbours.above_inter[c], neighbours.left_inter[r]);9075+ let (above_inter, left_inter) = (neighbours.above_inter[cmi], neighbours.left_inter[rmi]);
8975 let ii_ctx = intra_inter_ctx(has_above, has_left, above_inter, left_inter);9076 let ii_ctx = intra_inter_ctx(has_above, has_left, above_inter, left_inter);
8976 let is_inter = skip_mode || dec.symbol(&mut cdfs.intra_inter[ii_ctx]) == 1;9077 let is_inter = skip_mode || dec.symbol(&mut cdfs.intra_inter[ii_ctx]) == 1;
9078+ if std::env::var_os("EC_TRACE_MODE").is_some() {
9079+ eprintln!(
9080+ "EC_MODE mi_row={} mi_col={} rng={}",
9081+ r * SUB_MI as usize,
9082+ c * SUB_MI as usize,
9083+ dec.debug_state().0
9084+ );
9085+ }
8977 if std::env::var_os("EC_AV1_TELL").is_some() {9086 if std::env::var_os("EC_AV1_TELL").is_some() {
8978 eprintln!(9087 eprintln!(
8979 "TELL mi_row={} mi_col={} label=post_is_inter skip_mode={skip_mode} skip={skip} is_inter={is_inter} tell={} range={}",9088 "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(
8996 let above_nbr = has_above.then(|| NeighbourRef {9105 let above_nbr = has_above.then(|| NeighbourRef {
8997 is_inter: above_inter,9106 is_inter: above_inter,
8998 ref0: if above_inter {9107 ref0: if above_inter {
8999- neighbours.above_ref[c]9108+ neighbours.above_ref[cmi]
9000 } else {9109 } else {
9001 09110 0
9002 },9111 },
9003- ref1: neighbours.above_ref1[c],9112+ ref1: neighbours.above_ref1[cmi],
9004- uni: neighbours.above_ref1[c]9113+ uni: neighbours.above_ref1[cmi]
9005- .is_some_and(|r1| is_uni_comp_ref(neighbours.above_ref[c], r1)),9114+ .is_some_and(|r1| is_uni_comp_ref(neighbours.above_ref[cmi], r1)),
9006 });9115 });
9007 let left_nbr = has_left.then(|| NeighbourRef {9116 let left_nbr = has_left.then(|| NeighbourRef {
9008 is_inter: left_inter,9117 is_inter: left_inter,
9009 ref0: if left_inter {9118 ref0: if left_inter {
9010- neighbours.left_ref[r]9119+ neighbours.left_ref[rmi]
9011 } else {9120 } else {
9012 09121 0
9013 },9122 },
9014- ref1: neighbours.left_ref1[r],9123+ ref1: neighbours.left_ref1[rmi],
9015- uni: neighbours.left_ref1[r]9124+ uni: neighbours.left_ref1[rmi]
9016- .is_some_and(|r1| is_uni_comp_ref(neighbours.left_ref[r], r1)),9125+ .is_some_and(|r1| is_uni_comp_ref(neighbours.left_ref[rmi], r1)),
9017 });9126 });
9018 if std::env::var_os("EC_AV1_COMPIDX_DUMP").is_some() {9127 if std::env::var_os("EC_AV1_COMPIDX_DUMP").is_some() {
9019 eprintln!(9128 eprintln!(
@@ -9032,8 +9141,8 @@ fn decode_inter_block(
9032 cdfs,9141 cdfs,
9033 above_nbr,9142 above_nbr,
9034 left_nbr,9143 left_nbr,
9035- neighbours.above_ref[c],9144+ neighbours.above_ref[cmi],
9036- neighbours.left_ref[r],9145+ neighbours.left_ref[rmi],
9037 )9146 )
9038 };9147 };
9039 let (mi_row, mi_col) = (r * SUB_MI as usize, c * SUB_MI as usize);9148 let (mi_row, mi_col) = (r * SUB_MI as usize, c * SUB_MI as usize);
@@ -9110,17 +9219,17 @@ fn decode_inter_block(
9110 // real filter match down to the "no neighbour" sentinel9219 // real filter match down to the "no neighbour" sentinel
9111 // whenever the shared reference sits in the neighbour's SECOND9220 // whenever the shared reference sits in the neighbour's SECOND
9112 // slot (lane-av1idx r2).9221 // slot (lane-av1idx r2).
9113- let above_filter_ctx = if neighbours.above_ref[c] == ref09222+ let above_filter_ctx = if neighbours.above_ref[cmi] == ref0
9114- || neighbours.above_ref1[c] == Some(ref0)9223+ || neighbours.above_ref1[cmi] == Some(ref0)
9115 {9224 {
9116- neighbours.above_filter[c]9225+ neighbours.above_filter[cmi]
9117 } else {9226 } else {
9118 [3, 3]9227 [3, 3]
9119 };9228 };
9120- let left_filter_ctx = if neighbours.left_ref[r] == ref09229+ let left_filter_ctx = if neighbours.left_ref[rmi] == ref0
9121- || neighbours.left_ref1[r] == Some(ref0)9230+ || neighbours.left_ref1[rmi] == Some(ref0)
9122 {9231 {
9123- neighbours.left_filter[r]9232+ neighbours.left_filter[rmi]
9124 } else {9233 } else {
9125 [3, 3]9234 [3, 3]
9126 };9235 };
@@ -9170,7 +9279,7 @@ fn decode_inter_block(
9170 // there), so the gate reduces to the sequence header bit; kept9279 // there), so the gate reduces to the sequence header bit; kept
9171 // as an explicit call so a future smaller block size is not9280 // as an explicit call so a future smaller block size is not
9172 // silently wrong (libaom `reconinter.h::is_any_masked_compound_used`).9281 // silently wrong (libaom `reconinter.h::is_any_masked_compound_used`).
9173- let group_ctx = get_comp_group_idx_context(neighbours, at, side);9282+ let group_ctx = get_comp_group_idx_context(neighbours, (rmi, cmi), side);
9174 let comp_group_idx = if !skip_mode9283 let comp_group_idx = if !skip_mode
9175 && enable_masked_compound9284 && enable_masked_compound
9176 && is_any_masked_compound_used_here(side)9285 && is_any_masked_compound_used_here(side)
@@ -9198,7 +9307,17 @@ fn decode_inter_block(
9198 8 => 3,9307 8 => 3,
9199 16 => 6,9308 16 => 6,
9200 32 => 9,9309 32 => 9,
9201- _ => unreachable!("decode_inter_block leaf side is 8/16/32"),9310+ // lane-inter8 r1: `av1_is_wedge_used` is false at 64x64
9311+ // (`av1_wedge_params_lookup[BLOCK_64X64].wedge_types ==
9312+ // 0`), so a real encoder writes NO `compound_type` symbol
9313+ // there -- COMPOUND_DIFFWTD is inferred. Reading one
9314+ // would desync, so refuse by name rather than guess the
9315+ // inferred-DIFFWTD blend this round.
9316+ _ => {
9317+ return Err(unsupported(
9318+ "a masked compound 64x64 inter block (compound_type is inferred, not coded, at this size)",
9319+ ))
9320+ }
9202 };9321 };
9203 let compound_type = dec.symbol(&mut cdfs.compound_type[wedge_bsize]);9322 let compound_type = dec.symbol(&mut cdfs.compound_type[wedge_bsize]);
9204 if compound_type == 0 {9323 if compound_type == 0 {
@@ -9424,7 +9543,7 @@ fn decode_inter_block(
9424 {9543 {
9425 let idx_ctx = get_comp_index_context(9544 let idx_ctx = get_comp_index_context(
9426 neighbours,9545 neighbours,
9427- at,9546+ (rmi, cmi),
9428 side,9547 side,
9429 order_hint_bits,9548 order_hint_bits,
9430 order_hint,9549 order_hint,
@@ -9713,10 +9832,10 @@ fn decode_inter_block(
9713 read_single_ref(9832 read_single_ref(
9714 dec,9833 dec,
9715 cdfs,9834 cdfs,
9716- neighbours.above_ref[c],9835+ neighbours.above_ref[cmi],
9717- neighbours.above_ref1[c],9836+ neighbours.above_ref1[cmi],
9718- neighbours.left_ref[r],9837+ neighbours.left_ref[rmi],
9719- neighbours.left_ref1[r],9838+ neighbours.left_ref1[rmi],
9720 );9839 );
9721 ref_frame_for_lf = ref_frame;9840 ref_frame_for_lf = ref_frame;
9722 if std::env::var_os("EC_AV1_TELL").is_some() {9841 if std::env::var_os("EC_AV1_TELL").is_some() {
@@ -10093,17 +10212,17 @@ fn decode_inter_block(
10093 // lane-av1idx r2: also match on the neighbour's SECOND reference10212 // lane-av1idx r2: also match on the neighbour's SECOND reference
10094 // (`above_ref1`/`left_ref1`, real for a compound neighbour) --10213 // (`above_ref1`/`left_ref1`, real for a compound neighbour) --
10095 // see the 16x16 leaf's own comment above for the spec citation.10214 // see the 16x16 leaf's own comment above for the spec citation.
10096- let above_filter_ctx = if neighbours.above_ref[c] == ref_frame10215+ let above_filter_ctx = if neighbours.above_ref[cmi] == ref_frame
10097- || neighbours.above_ref1[c] == Some(ref_frame)10216+ || neighbours.above_ref1[cmi] == Some(ref_frame)
10098 {10217 {
10099- neighbours.above_filter[c]10218+ neighbours.above_filter[cmi]
10100 } else {10219 } else {
10101 [3, 3]10220 [3, 3]
10102 };10221 };
10103- let left_filter_ctx = if neighbours.left_ref[r] == ref_frame10222+ let left_filter_ctx = if neighbours.left_ref[rmi] == ref_frame
10104- || neighbours.left_ref1[r] == Some(ref_frame)10223+ || neighbours.left_ref1[rmi] == Some(ref_frame)
10105 {10224 {
10106- neighbours.left_filter[r]10225+ neighbours.left_filter[rmi]
10107 } else {10226 } else {
10108 [3, 3]10227 [3, 3]
10109 };10228 };
@@ -10136,9 +10255,6 @@ fn decode_inter_block(
10136 // a square `bw4`x`bw4` guess.10255 // a square `bw4`x`bw4` guess.
10137 for dr in 0..bh4 {10256 for dr in 0..bh4 {
10138 for dc in 0..bw4 {10257 for dc in 0..bw4 {
10139- // lane-gmaffine r2: mi-granular filter record for OBMC
10140- // neighbour prediction (see `MiGrid::filters`).
10141- grid.set_filter(mi_row + dr, mi_col + dc, block_filter);
10142 grid.set(10258 grid.set(
10143 mi_row + dr,10259 mi_row + dr,
10144 mi_col + dc,10260 mi_col + dc,
@@ -10724,7 +10840,6 @@ fn decode_inter_block8(
10724 base_q_idx: u8,10840 base_q_idx: u8,
10725 scan8: &[u16],10841 scan8: &[u16],
10726 scan4: &[u16],10842 scan4: &[u16],
10727- prev_leaf: Option<((usize, usize), bool, bool)>,
10728 allow_high_precision_mv: bool,10843 allow_high_precision_mv: bool,
10729 force_integer_mv: bool,10844 force_integer_mv: bool,
10730 // lane-gmaffine r1: this frame header's own `global_motion` table (spec10845 // lane-gmaffine r1: this frame header's own `global_motion` table (spec
@@ -10754,7 +10869,7 @@ fn decode_inter_block8(
10754 // lane-av1comp round 14: see [`decode_inter_block`]'s own doc -- this10869 // lane-av1comp round 14: see [`decode_inter_block`]'s own doc -- this
10755 // leaf has no per-leaf `above_skip_mode`/`left_skip_mode` array either,10870 // leaf has no per-leaf `above_skip_mode`/`left_skip_mode` array either,
10756 // so its `skip_mode` context reuses the same [`SUB`]-grid10871 // so its `skip_mode` context reuses the same [`SUB`]-grid
10757- // `above_skip_mode[c]`/`left_skip_mode[r]` the enclosing 16x16 slot10872+ // `above_skip_mode[cmi]`/`left_skip_mode[rmi]` the enclosing 16x16 slot
10758 // tracks (mirroring `above_skip`/`left_skip`'s own leaf approximation10873 // tracks (mirroring `above_skip`/`left_skip`'s own leaf approximation
10759 // just above).10874 // just above).
10760 skip_mode_present: bool,10875 skip_mode_present: bool,
@@ -10782,18 +10897,43 @@ fn decode_inter_block8(
10782 // `BLOCK_8X8` (this leaf's fixed size) is always `av1_allow_palette`-10897 // `BLOCK_8X8` (this leaf's fixed size) is always `av1_allow_palette`-
10783 // eligible (`bsize >= BLOCK_8X8`).10898 // eligible (`bsize >= BLOCK_8X8`).
10784 allow_screen_content_tools: bool,10899 allow_screen_content_tools: bool,
10785-) -> Result<(bool, bool, bool, Option<(i8, i8, u8, u8)>, [u8; 2], i8)> {10900+ // lane-inter8 r1: the leaf's mv stacks used to be built without the
10901+ // frame's sign-bias table (`NO_SIGN_BIAS`), while [`decode_inter_block`]
10902+ // one level up passed it -- it changes the candidate list and with it
10903+ // `new_mv_ctx`/`ref_mv_ctx`, `drl_ctx` and the number of symbols read.
10904+ // Measured: an 8x8 compound NEAR_NEWMV leaf desynced against aomdec's
10905+ // EC_MODE ladder at exactly this block (mi 4,14 of the mandelbrot
10906+ // 8x8-split gate).
10907+ sign_bias_table: &SignBiasTable,
10908+ // lane-inter8 r2: the frame's temporal mv field (spec 7.10.2.8), which
10909+ // [`decode_inter_block`] one level up has always passed and this leaf
10910+ // passed `None` for -- a `use_ref_frame_mvs` frame's stack then holds
10911+ // fewer candidates here than in the reference decoder, which changes the
10912+ // mode contexts AND the number of `drl_mode` bits read (class parsed
10913+ // then discarded).
10914+ tpl_frame: Option<&TplFrameArgs>,
10915+) -> Result<(bool, bool, bool, Option<(i8, i8, u8, u8)>, [u8; 2], (i8, Option<i8>))> {
10786 const LAST_FRAME: i8 = 1;10916 const LAST_FRAME: i8 = 1;
10787- // lane-gmaffine r2: the leaf's OWN switchable-filter symbols and reference,10917+ // lane-gmaffine r2: the leaf's OWN switchable-filter symbols, handed back
10788- // handed back so the caller records them in `Neighbours` instead of the10918+ // so the caller stamps them into `Neighbours` instead of the `[3, 3]`
10789- // `[3, 3]` / hardcoded-LAST_FRAME placeholders r1 left there. `[3, 3]` is10919+ // placeholder. `[3, 3]` is the "intra neighbour, no filter" sentinel: an
10790- // the "intra neighbour, no filter" sentinel: an OBMC blend that picks such10920+ // OBMC blend that picks such a neighbour up feeds it to
10791- // a neighbour up feeds it to `neighbour_filter`, which PANICS on it10921+ // `neighbour_filter`, which PANICS on it (`from_switchable_symbol`) --
10792- // (`from_switchable_symbol`) -- that was the warp gate's crash, not an10922+ // that was the warp gate's crash, not an entropy desync. Stays `[3, 3]`
10793- // entropy desync. Stays `[3, 3]`/-1 on the intra and compound paths, which10923+ // on the intra and compound paths.
10794- // is what the caller already recorded for them.
10795 let mut leaf_filter_syms = [3u8; 2];10924 let mut leaf_filter_syms = [3u8; 2];
10796- let mut leaf_ref: i8 = -1;10925+ // lane-gmaffine r1: this leaf's GLOBALMV vector AND the mv stack's
10926+ // missing-candidate fallback both come from the frame's global motion
10927+ // evaluated at THIS block's centre (gm r6's root cause).
10928+ let gm_table = build_gm_mv_table(
10929+ global_motion,
10930+ leaf_mi.0,
10931+ leaf_mi.1,
10932+ 2,
10933+ 2,
10934+ allow_high_precision_mv,
10935+ force_integer_mv,
10936+ );
10797 /// `Y_MODE`'s size group (`common_data.h`'s `size_group_lookup[BLOCK_8X8]`).10937 /// `Y_MODE`'s size group (`common_data.h`'s `size_group_lookup[BLOCK_8X8]`).
10798 const SIZE_GROUP_8: usize = 1;10938 const SIZE_GROUP_8: usize = 1;
10799 10939
@@ -10803,21 +10943,26 @@ fn decode_inter_block8(
10803 const CHROMA_SIDE: usize = 4;10943 const CHROMA_SIDE: usize = 4;
10804 10944
10805 let (r, c) = outer_at;10945 let (r, c) = outer_at;
10806- let mut above_skip = neighbours.above_skip[c];10946+ let _ = (r, c);
10807- let mut left_skip = neighbours.left_skip[r];10947+ // lane-inter8 r2: this leaf's OWN mi cell, not the enclosing 16x16's --
10808- let mut above_inter = neighbours.above_inter[c];10948+ // leaf (mi_r, mi_c + 2)'s left neighbour is leaf (mi_r, mi_c), and the
10809- let mut left_inter = neighbours.left_inter[r];10949+ // left column of a 16x16's second leaf ROW is the previous 16x16 block's
10810- if let Some(((pr, pc), pskip, pinter)) = prev_leaf {10950+ // bottom leaf, neither of which a SUB-grid slot can name.
10811- if pc == leaf_mi.1 && leaf_mi.0 == pr + 2 {10951+ let (rmi, cmi) = leaf_mi;
10812- above_skip = pskip;10952+ // lane-inter8 r2: no sibling-leaf override any more -- each leaf stamps
10813- above_inter = pinter;10953+ // its own 2x2-mi span into the bands right after it decodes (the caller's
10814- } else if pr == leaf_mi.0 && leaf_mi.1 == pc + 2 {10954+ // `record_inter_rect_mi`), so a plain mi read already names the correct
10815- left_skip = pskip;10955+ // neighbour, including one belonging to the previous 16x16 block.
10816- left_inter = pinter;10956+ let above_skip = neighbours.above_skip[cmi];
10817- }10957+ let left_skip = neighbours.left_skip[rmi];
10818- }10958+ let above_inter = neighbours.above_inter[cmi];
10959+ let left_inter = neighbours.left_inter[rmi];
10960+ let above_ref0 = neighbours.above_ref[cmi];
10961+ let above_ref1 = neighbours.above_ref1[cmi];
10962+ let left_ref0 = neighbours.left_ref[rmi];
10963+ let left_ref1 = neighbours.left_ref1[rmi];
10819 let skip_mode_ctx =10964 let skip_mode_ctx =
10820- usize::from(neighbours.above_skip_mode[c]) + usize::from(neighbours.left_skip_mode[r]);10965+ usize::from(neighbours.above_skip_mode[cmi]) + usize::from(neighbours.left_skip_mode[rmi]);
10821 let skip_mode = skip_mode_present && dec.symbol(&mut cdfs.skip_mode[skip_mode_ctx]) == 1;10966 let skip_mode = skip_mode_present && dec.symbol(&mut cdfs.skip_mode[skip_mode_ctx]) == 1;
10822 if skip_mode {10967 if skip_mode {
10823 SKIP_MODE_HITS.with(|c| c.set(c.get() + 1));10968 SKIP_MODE_HITS.with(|c| c.set(c.get() + 1));
@@ -10836,23 +10981,46 @@ fn decode_inter_block8(
10836 );10981 );
10837 let ii_ctx = intra_inter_ctx(has_above, has_left, above_inter, left_inter);10982 let ii_ctx = intra_inter_ctx(has_above, has_left, above_inter, left_inter);
10838 let is_inter = skip_mode || dec.symbol(&mut cdfs.intra_inter[ii_ctx]) == 1;10983 let is_inter = skip_mode || dec.symbol(&mut cdfs.intra_inter[ii_ctx]) == 1;
10984+ // lane-inter8 r1: mirrors the oracle's `EC_MODE` (instrument rung 4,
10985+ // `read_inter_block_mode_info`) so an 8x8 leaf's mode-info range ladder
10986+ // diffs line for line against a real aomdec.
10987+ if std::env::var_os("EC_TRACE_MODE").is_some() {
10988+ eprintln!(
10989+ "EC_MODE mi_row={} mi_col={} rng={}",
10990+ leaf_mi.0,
10991+ leaf_mi.1,
10992+ dec.debug_state().0
10993+ );
10994+ }
10839 10995
10840 let mode_for_tx;10996 let mode_for_tx;
10841 let (luma_grid, u_grid, v_grid);10997 let (luma_grid, u_grid, v_grid);
10842 let mut compound_ctx8: Option<(i8, i8, u8, u8)> = None;10998 let mut compound_ctx8: Option<(i8, i8, u8, u8)> = None;
10999+ // lane-inter8 r1: this leaf's own resolved references, handed back so the
11000+ // NEXT leaf of the same 16x16 can use them as its real above/left
11001+ // neighbour (`Neighbours`' arrays only move once per 16x16 block).
11002+ // `(0, None)` is intra.
11003+ let mut leaf_refs: (i8, Option<i8>) = (0, None);
10843 if is_inter {11004 if is_inter {
10844 if reference_select || skip_mode {11005 if reference_select || skip_mode {
11006+ // lane-inter8 r1: the REAL neighbour references, not a
11007+ // `LAST_FRAME`-or-intra stand-in. `av1_get_reference_mode_context`
11008+ // and `read_compound_ref_frames`' own contexts both ask whether a
11009+ // neighbour is COMPOUND, so pretending every inter neighbour is
11010+ // single-ref LAST picked the wrong `comp_mode` CDF row -- measured
11011+ // as an 8x8 leaf reading single-ref where aomdec read compound
11012+ // NEAR_NEWMV (mi 4,14).
10845 let above_nbr = has_above.then(|| NeighbourRef {11013 let above_nbr = has_above.then(|| NeighbourRef {
10846 is_inter: above_inter,11014 is_inter: above_inter,
10847- ref0: if above_inter { LAST_FRAME } else { 0 },11015+ ref0: if above_inter { above_ref0 } else { 0 },
10848- ref1: None,11016+ ref1: above_ref1,
10849- uni: false,11017+ uni: above_ref1.is_some_and(|r1| is_uni_comp_ref(above_ref0, r1)),
10850 });11018 });
10851 let left_nbr = has_left.then(|| NeighbourRef {11019 let left_nbr = has_left.then(|| NeighbourRef {
10852 is_inter: left_inter,11020 is_inter: left_inter,
10853- ref0: if left_inter { LAST_FRAME } else { 0 },11021+ ref0: if left_inter { left_ref0 } else { 0 },
10854- ref1: None,11022+ ref1: left_ref1,
10855- uni: false,11023+ uni: left_ref1.is_some_and(|r1| is_uni_comp_ref(left_ref0, r1)),
10856 });11024 });
10857 if skip_mode || read_comp_mode(dec, cdfs, above_nbr, left_nbr) {11025 if skip_mode || read_comp_mode(dec, cdfs, above_nbr, left_nbr) {
10858 let (ref0, ref1) = if skip_mode {11026 let (ref0, ref1) = if skip_mode {
@@ -10875,7 +11043,24 @@ fn decode_inter_block8(
10875 },11043 },
10876 )11044 )
10877 };11045 };
11046+ leaf_refs = (ref0, Some(ref1));
10878 let (mi_row, mi_col) = leaf_mi;11047 let (mi_row, mi_col) = leaf_mi;
11048+ // spec 7.10.2.8, mirroring [`decode_inter_block`]'s own
11049+ // `comp_tpl` build (`use_ref_frame_mvs` frames only).
11050+ let comp_tpl = tpl_frame.map(|t| crate::mvstack::CompoundTplArgs {
11051+ field: t.field,
11052+ cur_offset_0: crate::motion_field::get_relative_dist(
11053+ t.order_hint_bits,
11054+ t.order_hint,
11055+ t.ref_order_hints[(ref0 - LAST_FRAME) as usize],
11056+ ),
11057+ cur_offset_1: crate::motion_field::get_relative_dist(
11058+ t.order_hint_bits,
11059+ t.order_hint,
11060+ t.ref_order_hints[(ref1 - LAST_FRAME) as usize],
11061+ ),
11062+ allow_high_precision_mv,
11063+ });
10879 // lane-av1comp: this leaf path has neither a real sign-bias11064 // lane-av1comp: this leaf path has neither a real sign-bias
10880 // table nor `tpl_frame` (see this function's own doc on the11065 // table nor `tpl_frame` (see this function's own doc on the
10881 // coarse `LAST_FRAME`-or-intra neighbour approximation11066 // coarse `LAST_FRAME`-or-intra neighbour approximation
@@ -10891,9 +11076,9 @@ fn decode_inter_block8(
10891 (ref0, ref1),11076 (ref0, ref1),
10892 mi_cols as usize,11077 mi_cols as usize,
10893 mi_rows as usize,11078 mi_rows as usize,
10894- &NO_SIGN_BIAS,11079+ sign_bias_table,
10895- &crate::mvstack::NO_GM_MV,11080+ &gm_table,
10896- None,11081+ comp_tpl,
10897 );11082 );
10898 let compound_mode = if skip_mode {11083 let compound_mode = if skip_mode {
10899 0 // NEAREST_NEARESTMV, forced -- no mode symbol read11084 0 // NEAREST_NEARESTMV, forced -- no mode symbol read
@@ -10905,6 +11090,18 @@ fn decode_inter_block8(
10905 comp_stack.ref_mv_ctx,11090 comp_stack.ref_mv_ctx,
10906 )11091 )
10907 };11092 };
11093+ if std::env::var_os("EC_TRACE_MODE").is_some() {
11094+ eprintln!(
11095+ "EC_LEAFMODE mi_row={} mi_col={} cmode={} stack={} newmv_ctx={} refmv_ctx={} rng={}",
11096+ leaf_mi.0,
11097+ leaf_mi.1,
11098+ compound_mode + 17,
11099+ comp_stack.entries.len(),
11100+ comp_stack.new_mv_ctx,
11101+ comp_stack.ref_mv_ctx,
11102+ dec.debug_state().0
11103+ );
11104+ }
10908 let (mv0, mv1) = assign_compound_mv(11105 let (mv0, mv1) = assign_compound_mv(
10909 dec,11106 dec,
10910 cdfs,11107 cdfs,
@@ -10912,16 +11109,19 @@ fn decode_inter_block8(
10912 compound_mode,11109 compound_mode,
10913 allow_high_precision_mv,11110 allow_high_precision_mv,
10914 force_integer_mv,11111 force_integer_mv,
10915- // leaf8 stays gm-inert (sanctioned partial landing, see11112+ // lane-inter8 r1: the real per-ref gm mvs, same as
10916- // this fn's own GLOBALMV refusal below).11113+ // [`decode_inter_block`]'s own compound arm.
10917- ((0, 0), (0, 0)),11114+ (
11115+ gm_table[(ref0 - LAST_FRAME) as usize],
11116+ gm_table[(ref1 - LAST_FRAME) as usize],
11117+ ),
10918 );11118 );
10919 11119
10920 // spec 5.11.25: same gating [`decode_inter_block`]'s own11120 // spec 5.11.25: same gating [`decode_inter_block`]'s own
10921 // compound arm uses, keyed off `outer_at`'s [`SUB`]-grid11121 // compound arm uses, keyed off `outer_at`'s [`SUB`]-grid
10922 // slot -- the only granularity `Neighbours`' comp_group_idx/11122 // slot -- the only granularity `Neighbours`' comp_group_idx/
10923 // compound_idx arrays track.11123 // compound_idx arrays track.
10924- let group_ctx = get_comp_group_idx_context(neighbours, outer_at, SIDE);11124+ let group_ctx = get_comp_group_idx_context(neighbours, leaf_mi, SIDE);
10925 let comp_group_idx = if !skip_mode11125 let comp_group_idx = if !skip_mode
10926 && enable_masked_compound11126 && enable_masked_compound
10927 && is_any_masked_compound_used_here(SIDE)11127 && is_any_masked_compound_used_here(SIDE)
@@ -10975,7 +11175,7 @@ fn decode_inter_block8(
10975 {11175 {
10976 let idx_ctx = get_comp_index_context(11176 let idx_ctx = get_comp_index_context(
10977 neighbours,11177 neighbours,
10978- outer_at,11178+ leaf_mi,
10979 SIDE,11179 SIDE,
10980 order_hint_bits,11180 order_hint_bits,
10981 order_hint,11181 order_hint,
@@ -11245,7 +11445,30 @@ fn decode_inter_block8(
11245 )?11445 )?
11246 .0;11446 .0;
11247 }11447 }
11248- return Ok((skip, is_inter, skip_mode, compound_ctx8, leaf_filter_syms, leaf_ref));11448+ // lane-inter8 r2: the COMPOUND leaf used to return here
11449+ // WITHOUT the end-of-function `record_mi`/`fill_lf_grid` the
11450+ // single-ref path falls through to -- so a compound 8x8 leaf
11451+ // left `above_side_mi`/`left_side_mi` (the next block's
11452+ // partition context), the per-plane coefficient level state
11453+ // and the loop-filter grid describing whatever block was
11454+ // there before. Every leaf of the gate's stream is compound,
11455+ // so the 16x16 below a split block read partition ctx 0
11456+ // instead of 1 and mis-read PARTITION_SPLIT as NONE.
11457+ neighbours.record_mi(leaf_mi, 8, &[luma_grid, u_grid, v_grid]);
11458+ neighbours.fill_lf_grid(
11459+ leaf_mi,
11460+ 2,
11461+ 8,
11462+ if is_inter { leaf_refs.0.max(LAST_FRAME) } else { 0 },
11463+ );
11464+ return Ok((
11465+ skip,
11466+ is_inter,
11467+ skip_mode,
11468+ compound_ctx8,
11469+ leaf_filter_syms,
11470+ leaf_refs,
11471+ ));
11249 }11472 }
11250 }11473 }
11251 // lane-gmaffine r1: the leaf reads the FULL `single_ref` tree11474 // lane-gmaffine r1: the leaf reads the FULL `single_ref` tree
@@ -11262,23 +11485,21 @@ fn decode_inter_block8(
11262 neighbours.left_ref[r],11485 neighbours.left_ref[r],
11263 neighbours.left_ref1[r],11486 neighbours.left_ref1[r],
11264 );11487 );
11488+ leaf_refs = (ref_frame, None);
11265 let (sref_y, sref_u, sref_v) = ref_planes(ref_frame, ref_y, ref_u, ref_v, other_refs)?;11489 let (sref_y, sref_u, sref_v) = ref_planes(ref_frame, ref_y, ref_u, ref_v, other_refs)?;
11266 11490
11267 let (mi_row, mi_col) = leaf_mi;11491 let (mi_row, mi_col) = leaf_mi;
11268- // lane-gmaffine r1: this leaf's GLOBALMV vector AND the mv stack's11492+ // lane-inter8 r2: the frame's temporal mv candidates, keyed on THIS
11269- // missing-candidate fallback both come from the frame's global11493+ // leaf's own reference (lane-gmaffine r1 taught it non-LAST refs).
11270- // motion evaluated at THIS block's centre (gm r6's root cause) --11494+ let tpl = tpl_frame.map(|t| crate::mvstack::TplArgs {
11271- // the 8x8 leaf used to build its stack with the zero fallback, which11495+ field: t.field,
11272- // is right only while every model is IDENTITY.11496+ cur_offset_0: crate::motion_field::get_relative_dist(
11273- let gm_table = build_gm_mv_table(11497+ t.order_hint_bits,
11274- global_motion,11498+ t.order_hint,
11275- mi_row,11499+ t.ref_order_hints[(ref_frame - LAST_FRAME) as usize],
11276- mi_col,11500+ ),
11277- 2,
11278- 2,
11279 allow_high_precision_mv,11501 allow_high_precision_mv,
11280- force_integer_mv,11502+ });
11281- );
11282 let stack = crate::mvstack::find_mv_stack_with_sign_bias(11503 let stack = crate::mvstack::find_mv_stack_with_sign_bias(
11283 grid,11504 grid,
11284 mi_row,11505 mi_row,
@@ -11288,9 +11509,9 @@ fn decode_inter_block8(
11288 ref_frame,11509 ref_frame,
11289 mi_cols as usize,11510 mi_cols as usize,
11290 mi_rows as usize,11511 mi_rows as usize,
11291- &crate::mvstack::NO_SIGN_BIAS,11512+ sign_bias_table,
11292 &gm_table,11513 &gm_table,
11293- None,11514+ tpl,
11294 );11515 );
11295 11516
11296 let not_new = dec.symbol(&mut cdfs.new_mv[stack.new_mv_ctx]) == 1;11517 let not_new = dec.symbol(&mut cdfs.new_mv[stack.new_mv_ctx]) == 1;
@@ -11507,16 +11728,6 @@ fn decode_inter_block8(
11507 false,11728 false,
11508 );11729 );
11509 leaf_filter_syms = resolved_filter;11730 leaf_filter_syms = resolved_filter;
11510- leaf_ref = ref_frame;
11511- // lane-gmaffine r2: mi-granular filter record -- a sibling 8x8 leaf
11512- // OBMC-blends this one before the enclosing 16x16's coarse
11513- // `Neighbours` slot is ever written.
11514- for dr in 0..2 {
11515- for dc in 0..2 {
11516- grid.set_filter(leaf_mi.0 + dr, leaf_mi.1 + dc, resolved_filter);
11517- }
11518- }
11519-
11520 // lane-gmaffine r1: `allow_warp`'s `global_warp_allowed` branch11731 // lane-gmaffine r1: `allow_warp`'s `global_warp_allowed` branch
11521 // (`reconinter.c:33-55`), gated INDEPENDENTLY of `motion_mode` --11732 // (`reconinter.c:33-55`), gated INDEPENDENTLY of `motion_mode` --
11522 // see [`decode_inter_block`]'s own copy. A local WARPED_CAUSAL model11733 // see [`decode_inter_block`]'s own copy. A local WARPED_CAUSAL model
@@ -11910,13 +12121,16 @@ fn decode_inter_block8(
11910 leaf_mi,12121 leaf_mi,
11911 2,12122 2,
11912 8,12123 8,
11913- if is_inter {12124+ if is_inter { leaf_refs.0.max(LAST_FRAME) } else { 0 },
11914- if leaf_ref > 0 { leaf_ref } else { LAST_FRAME }
11915- } else {
11916- 0
11917- },
11918 );12125 );
11919- Ok((skip, is_inter, skip_mode, compound_ctx8, leaf_filter_syms, leaf_ref))12126+ Ok((
12127+ skip,
12128+ is_inter,
12129+ skip_mode,
12130+ compound_ctx8,
12131+ leaf_filter_syms,
12132+ leaf_refs,
12133+ ))
11920 }12134 }
11921 12135
11922 /// Decodes the payload [`crate::tile::sb_coeff_inter_frame_tile`] writes,12136 /// Decodes the payload [`crate::tile::sb_coeff_inter_frame_tile`] writes,
@@ -12361,10 +12575,72 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
12361 }12575 }
12362 (false, false) => PARTITION_SPLIT,12576 (false, false) => PARTITION_SPLIT,
12363 };12577 };
12578+ if part64 == PARTITION_NONE {
12579+ // lane-inter8 r1: the whole superblock as one 64x64 inter
12580+ // block. `SB`-sized syntax throughout (size_group 3, same as
12581+ // 32x32 -- `size_group_lookup[BLOCK_64X64] == 3`), luma
12582+ // coefficients through `TxbSet::Luma64` with the 32-point
12583+ // scan (TX_64X64 codes only its top-left corner, spec
12584+ // 5.11.40 -- `read_inter_plane` widens the corner back to
12585+ // 64x64 before the inverse transform), chroma as a plain
12586+ // 32x32 `TxbSet::Chroma32`. TX_64X64 carries no `tx_type`
12587+ // symbol at all, so the intra/inter luma sets coincide.
12588+ INTER_SB_NONE_HITS.with(|c| c.set(c.get() + 1));
12589+ decode_inter_block(
12590+ &mut dec,
12591+ &mut cdfs,
12592+ &mut neighbours,
12593+ &mut grid,
12594+ sb_at,
12595+ SB,
12596+ mi_cols,
12597+ mi_rows,
12598+ &mut y,
12599+ &mut u,
12600+ &mut v,
12601+ &ref_y,
12602+ &ref_u,
12603+ &ref_v,
12604+ &ref_slots,
12605+ &sign_bias_table,
12606+ &global_motion,
12607+ base_q_idx,
12608+ TxbSet::Luma64,
12609+ TxbSet::Luma64,
12610+ TxbSet::Chroma32,
12611+ TX32,
12612+ TX32,
12613+ &scan32,
12614+ &scan32,
12615+ 3,
12616+ allow_high_precision_mv,
12617+ force_integer_mv,
12618+ interp_fixed,
12619+ enable_dual_filter,
12620+ tpl_frame.as_ref(),
12621+ reference_select,
12622+ enable_masked_compound,
12623+ enable_interintra_compound,
12624+ enable_jnt_comp,
12625+ order_hint_bits,
12626+ order_hint,
12627+ ref_order_hints,
12628+ skip_mode_present,
12629+ skip_mode_frame,
12630+ switchable_motion_mode,
12631+ allow_warped_motion,
12632+ false,
12633+ SB,
12634+ SB,
12635+ allow_screen_content_tools,
12636+ frame_width as usize,
12637+ )?;
12638+ continue;
12639+ }
12364 if part64 != PARTITION_SPLIT {12640 if part64 != PARTITION_SPLIT {
12365 return Err(unsupported(12641 return Err(unsupported(
12366- "an inter SB-level partition type other than SPLIT (this decoder's \12642+ "an inter SB-level partition type other than NONE or SPLIT (this decoder's \
12367- inter tile path only recurses a superblock as SPLIT)",12643+ inter tile path recurses a superblock only as SPLIT)",
12368 ));12644 ));
12369 }12645 }
12370 12646
@@ -12479,175 +12755,39 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
12479 ));12755 ));
12480 }12756 }
12481 let at16 = (sr, sc);12757 let at16 = (sr, sc);
12482- if has_cols16 && has_rows16 {
12483 let ctx16 = neighbours.partition_ctx(at16, SUB);12758 let ctx16 = neighbours.partition_ctx(at16, SUB);
12484- let part16 = dec.symbol(&mut cdfs.partition_w16[ctx16]);12759+ // lane-inter8 r1: a straddling 16x16 cannot name a
12485- if part16 == PARTITION_SPLIT {12760+ // value (spec forces SPLIT, one gathered bit); an
12486- // lane-gmaffine r1: an INTERIOR 16x1612761+ // interior one reads the real alphabet, and
12487- // PARTITION_SPLIT -- four 8x8 leaves,12762+ // `PARTITION_SPLIT` now recurses into four 8x8
12488- // the same `partition_w8`-per-leaf loop12763+ // inter leaves through the very same loop the
12489- // the true-edge-straddling branch below12764+ // straddling case has always used.
12490- // already ran (that branch only ever12765+ let part16 = if has_cols16 && has_rows16 {
12491- // reached it for frame-edge blocks, so12766+ let p = dec.symbol(&mut cdfs.partition_w16[ctx16]);
12492- // `decode_inter_block8` was unreachable12767+ if std::env::var_os("EC_AV1_TRACE").is_some() {
12493- // for every whole-superblock stream and12768+ let (rng, _) = dec.debug_state();
12494- // its own GLOBALMV/WARPED_CAUSAL gates12769+ eprintln!(
12495- // could not fire at all).12770+ "TRACE partition_w16 mi=({},{}) ctx={ctx16} value={p} rng={rng}",
12496- let (mi_row0, mi_col0) = (sr as u32 * SUB_MI, sc as u32 * SUB_MI);12771+ sr as u32 * SUB_MI,
12497- let leaf_positions: Vec<(u32, u32)> = (0..4)12772+ sc as u32 * SUB_MI
12498- .map(|i| (mi_row0 + (i / 2) * 2, mi_col0 + (i % 2) * 2))12773+ );
12499- .filter(|&(mr, mc)| mr < mi_rows && mc < mi_cols)
12500- .collect();
12501- // lane-superres r9: decode_inter_block8's own
12502- // MC (below) is not threaded for a scaled
12503- // reference (unlike decode_inter_block's 19
12504- // sites) -- refuse the whole 8x8-leaf split
12505- // up front when ANY live reference this leaf
12506- // could pick has a different width than this
12507- // frame, rather than thread frame_width
12508- // through its own single-ref/compound MC
12509- // calls to reach the same block this round.
12510- if ref_y.width != frame_width as usize
12511- || ref_slots.iter().flatten().any(|(py, _, _)| {
12512- py.width != frame_width as usize
12513- })
12514- {
12515- return Err(unsupported(
12516- "an 8x8 partition leaf under a scaled reference (superres, unimplemented)",
12517- ));
12518 }12774 }
12519- let mut prev_leaf: Option<((usize, usize), bool, bool)> = None;12775+ p
12520- let mut last_compound_ctx: Option<(i8, i8, u8, u8)> = None;12776+ } else {
12521- let mut last_skip_mode = false;12777+ if has_cols16 {
12522- let mut last_filter = [3u8; 2];12778+ dec.symbol_fixed(&gather(
12523- let mut last_ref: i8 = -1;12779+ &cdfs.partition_w16[ctx16],
12524- for (mr, mc) in leaf_positions {12780+ VERT_ALIKE,
12525- let leaf_mi = (mr as usize, mc as usize);
12526- let leaf_ctx = neighbours.partition_ctx_mi(leaf_mi, 8);
12527- let part8 = dec.symbol(&mut cdfs.partition_w8[leaf_ctx]);
12528- if part8 != PARTITION_NONE {
12529- return Err(unsupported(
12530- "a partition below 8x8 (this decoder codes no leaf smaller than 8x8)",
12531 ));12781 ));
12532- }
12533- let (
12534- skip,
12535- is_inter,
12536- skip_mode_leaf,
12537- compound_ctx8,
12538- leaf_filter,
12539- leaf_ref,
12540- ) = decode_inter_block8(
12541- &mut dec,
12542- &mut cdfs,
12543- &mut neighbours,
12544- &mut grid,
12545- mi_cols,
12546- mi_rows,
12547- at16,
12548- leaf_mi,
12549- &mut y,
12550- &mut u,
12551- &mut v,
12552- &ref_y,
12553- &ref_u,
12554- &ref_v,
12555- &ref_slots,
12556- base_q_idx,
12557- &scan8,
12558- &scan4,
12559- prev_leaf,
12560- allow_high_precision_mv,
12561- force_integer_mv,
12562- &global_motion,
12563- enable_dual_filter,
12564- reference_select,
12565- enable_masked_compound,
12566- enable_interintra_compound,
12567- enable_jnt_comp,
12568- order_hint_bits,
12569- order_hint,
12570- ref_order_hints,
12571- skip_mode_present,
12572- skip_mode_frame,
12573- reduced_tx_set,
12574- interp_fixed,
12575- switchable_motion_mode,
12576- allow_warped_motion,
12577- allow_screen_content_tools,
12578- )?;
12579- prev_leaf = Some((leaf_mi, skip, is_inter));
12580- last_skip_mode = skip_mode_leaf;
12581- // lane-gmaffine r2: keep the last INTER
12582- // leaf's own filter/ref for the coarse
12583- // 16px-wide `Neighbours` slot (see below).
12584- // Intra leaves must not overwrite it: the
12585- // slot is shared by all four, and an OBMC
12586- // neighbour is chosen at mi granularity, so
12587- // an intra LAST leaf would hand `[3, 3]` to
12588- // `neighbour_filter` for an inter sibling.
12589- if leaf_ref > 0 {
12590- last_filter = leaf_filter;
12591- last_ref = leaf_ref;
12592- }
12593- if compound_ctx8.is_some() {
12594- last_compound_ctx = compound_ctx8;
12595- }
12596- }
12597- if let Some((_, skip, is_inter)) = prev_leaf {
12598- // lane-gmaffine r2: record the LAST leaf's
12599- // real switchable-filter symbols and its
12600- // real reference. r1 recorded `[3, 3]` (the
12601- // "intra neighbour" sentinel) and a
12602- // hardcoded LAST_FRAME here; `[3, 3]` made
12603- // `obmc_blend`'s `neighbour_filter` PANIC
12604- // the moment a later block OBMC-blended one
12605- // of these leaves, and the fake ref
12606- // corrupted the next block's
12607- // switchable_interp / ref contexts.
12608- // corner-cut: `Neighbours` is 16px-granular,
12609- // so all four leaves collapse into one slot
12610- // (the last one wins). Ceiling: siblings
12611- // that choose DIFFERENT filters or refs give
12612- // the next block one leaf's context instead
12613- // of the bordering one's. Upgrade: mi-
12614- // granular above_filter/above_ref arrays.
12615- neighbours.record_inter(
12616- at16,
12617- SUB,
12618- skip,
12619- is_inter,
12620- if !is_inter {
12621- -1
12622- } else if last_ref > 0 {
12623- last_ref
12624 } else {12782 } else {
12625- LAST_FRAME12783+ dec.symbol_fixed(&gather(
12626- },12784+ &cdfs.partition_w16[ctx16],
12627- last_filter,12785+ HORZ_ALIKE,
12628- last_skip_mode,
12629- );
12630- if let Some((ref0, ref1, group_idx, idx)) = last_compound_ctx {
12631- neighbours.record_inter(
12632- at16,
12633- SUB,
12634- skip,
12635- is_inter,
12636- ref0,
12637- [3, 3],
12638- last_skip_mode,
12639- );
12640- neighbours
12641- .record_compound_ctx(at16, SUB, ref1, group_idx, idx);
12642- }
12643- }
12644- continue;
12645- }
12646- if part16 != PARTITION_NONE {
12647- return Err(unsupported(
12648- "an inter partition below 16x16 other than a clean split into four 8x8 leaves",
12649 ));12786 ));
12650 }12787 }
12788+ PARTITION_SPLIT
12789+ };
12790+ if part16 == PARTITION_NONE {
12651 decode_inter_block(12791 decode_inter_block(
12652 &mut dec,12792 &mut dec,
12653 &mut cdfs,12793 &mut cdfs,
@@ -12701,18 +12841,13 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
12701 allow_screen_content_tools,12841 allow_screen_content_tools,
12702 frame_width as usize,12842 frame_width as usize,
12703 )?;12843 )?;
12704- } else {12844+ } else if part16 != PARTITION_SPLIT {
12705- let ctx16 = neighbours.partition_ctx(at16, SUB);12845+ return Err(unsupported(
12706- if has_cols16 {12846+ "an inter partition below 16x16 other than SPLIT (16x8/8x16 rect inter leaves are not coded yet)",
12707- dec.symbol_fixed(&gather(
12708- &cdfs.partition_w16[ctx16],
12709- VERT_ALIKE,
12710 ));12847 ));
12711 } else {12848 } else {
12712- dec.symbol_fixed(&gather(12849+ if has_cols16 && has_rows16 {
12713- &cdfs.partition_w16[ctx16],12850+ INTER_SUB16_SPLIT_HITS.with(|c| c.set(c.get() + 1));
12714- HORZ_ALIKE,
12715- ));
12716 }12851 }
12717 let (mi_row0, mi_col0) = (sr as u32 * SUB_MI, sc as u32 * SUB_MI);12852 let (mi_row0, mi_col0) = (sr as u32 * SUB_MI, sc as u32 * SUB_MI);
12718 let leaf_positions: Vec<(u32, u32)> = (0..4)12853 let leaf_positions: Vec<(u32, u32)> = (0..4)
@@ -12737,11 +12872,7 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
12737 "an 8x8 partition leaf under a scaled reference (superres, unimplemented)",12872 "an 8x8 partition leaf under a scaled reference (superres, unimplemented)",
12738 ));12873 ));
12739 }12874 }
12740- let mut prev_leaf: Option<((usize, usize), bool, bool)> = None;12875+ let mut prev_leaves: Vec<((usize, usize), bool, bool, i8, Option<i8>)> = Vec::new();
12741- let mut last_compound_ctx: Option<(i8, i8, u8, u8)> = None;
12742- let mut last_skip_mode = false;
12743- let mut last_filter = [3u8; 2];
12744- let mut last_ref: i8 = -1;
12745 for (mr, mc) in leaf_positions {12876 for (mr, mc) in leaf_positions {
12746 let leaf_mi = (mr as usize, mc as usize);12877 let leaf_mi = (mr as usize, mc as usize);
12747 let leaf_ctx = neighbours.partition_ctx_mi(leaf_mi, 8);12878 let leaf_ctx = neighbours.partition_ctx_mi(leaf_mi, 8);
@@ -12757,7 +12888,7 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
12757 skip_mode_leaf,12888 skip_mode_leaf,
12758 compound_ctx8,12889 compound_ctx8,
12759 leaf_filter,12890 leaf_filter,
12760- leaf_ref,12891+ leaf_refs,
12761 ) = decode_inter_block8(12892 ) = decode_inter_block8(
12762 &mut dec,12893 &mut dec,
12763 &mut cdfs,12894 &mut cdfs,
@@ -12777,7 +12908,6 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
12777 base_q_idx,12908 base_q_idx,
12778 &scan8,12909 &scan8,
12779 &scan4,12910 &scan4,
12780- prev_leaf,
12781 allow_high_precision_mv,12911 allow_high_precision_mv,
12782 force_integer_mv,12912 force_integer_mv,
12783 &global_motion,12913 &global_motion,
@@ -12796,72 +12926,47 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
12796 switchable_motion_mode,12926 switchable_motion_mode,
12797 allow_warped_motion,12927 allow_warped_motion,
12798 allow_screen_content_tools,12928 allow_screen_content_tools,
12929+ &sign_bias_table,
12930+ tpl_frame.as_ref(),
12799 )?;12931 )?;
12800- prev_leaf = Some((leaf_mi, skip, is_inter));12932+ prev_leaves.push((leaf_mi, skip, is_inter, leaf_refs.0, leaf_refs.1));
12801- last_skip_mode = skip_mode_leaf;12933+ // lane-inter8 r2: stamp THIS leaf's own
12802- // lane-gmaffine r2: keep the last INTER12934+ // 2x2-mi span before the next leaf reads
12803- // leaf's own filter/ref for the coarse12935+ // it as a neighbour -- the whole-16x16
12804- // 16px-wide `Neighbours` slot (see below).12936+ // stamp below only ever described the
12805- // Intra leaves must not overwrite it: the12937+ // last leaf, so three quarters of the
12806- // slot is shared by all four, and an OBMC12938+ // block carried the wrong skip/ref/inter
12807- // neighbour is chosen at mi granularity, so12939+ // state into the next block's contexts
12808- // an intra LAST leaf would hand `[3, 3]` to12940+ // (class context-read-from-one-cell).
12809- // `neighbour_filter` for an inter sibling.12941+ // lane-gmaffine r3: with the mi-granular
12810- if leaf_ref > 0 {12942+ // band, the leaf's OWN switchable-filter
12811- last_filter = leaf_filter;12943+ // symbols go in here -- the `[3, 3]`
12812- last_ref = leaf_ref;12944+ // ("intra, no filter") sentinel this used
12813- }12945+ // to stamp made `obmc_blend`'s
12814- if compound_ctx8.is_some() {12946+ // `neighbour_filter` PANIC as soon as a
12815- last_compound_ctx = compound_ctx8;12947+ // sibling leaf blended one of these.
12816- }12948+ neighbours.record_inter_rect_mi(
12817- }12949+ leaf_mi,
12818- if let Some((_, skip, is_inter)) = prev_leaf {12950+ 2,
12819- // lane-gmaffine r2: record the LAST leaf's12951+ 2,
12820- // real switchable-filter symbols and its
12821- // real reference. r1 recorded `[3, 3]` (the
12822- // "intra neighbour" sentinel) and a
12823- // hardcoded LAST_FRAME here; `[3, 3]` made
12824- // `obmc_blend`'s `neighbour_filter` PANIC
12825- // the moment a later block OBMC-blended one
12826- // of these leaves, and the fake ref
12827- // corrupted the next block's
12828- // switchable_interp / ref contexts.
12829- // corner-cut: `Neighbours` is 16px-granular,
12830- // so all four leaves collapse into one slot
12831- // (the last one wins). Ceiling: siblings
12832- // that choose DIFFERENT filters or refs give
12833- // the next block one leaf's context instead
12834- // of the bordering one's. Upgrade: mi-
12835- // granular above_filter/above_ref arrays.
12836- neighbours.record_inter(
12837- at16,
12838- SUB,
12839 skip,12952 skip,
12840 is_inter,12953 is_inter,
12841- if !is_inter {12954+ leaf_refs.0,
12842- -112955+ leaf_filter,
12843- } else if last_ref > 0 {12956+ skip_mode_leaf,
12844- last_ref
12845- } else {
12846- LAST_FRAME
12847- },
12848- last_filter,
12849- last_skip_mode,
12850 );12957 );
12851- if let Some((ref0, ref1, group_idx, idx)) = last_compound_ctx {12958+ if let Some(ref1) = leaf_refs.1
12852- neighbours.record_inter(12959+ && let Some((_, _, group_idx, idx)) = compound_ctx8
12853- at16,12960+ {
12854- SUB,12961+ neighbours.record_compound_ctx_rect_mi(
12855- skip,12962+ leaf_mi, 2, 2, ref1, group_idx, idx,
12856- is_inter,
12857- ref0,
12858- [3, 3],
12859- last_skip_mode,
12860 );12963 );
12861- neighbours
12862- .record_compound_ctx(at16, SUB, ref1, group_idx, idx);
12863 }12964 }
12864 }12965 }
12966+ // lane-inter8 r2: the four per-leaf
12967+ // `record_inter_rect_mi` stamps above replace
12968+ // the single whole-16x16 one that used to run
12969+ // here with the LAST leaf's state.
12865 }12970 }
12866 }12971 }
12867 }12972 }
crates/ec-av1/src/mvstack.rsmodified+0 -29
@@ -177,15 +177,6 @@ pub struct MiGrid {
177 cols: usize,177 cols: usize,
178 rows: usize,178 rows: usize,
179 cells: Vec<Option<MiInfo>>,179 cells: Vec<Option<MiInfo>>,
180- /// lane-gmaffine r2: each mi unit's own switchable-filter symbols
181- /// (`[dir0, dir1]`, `3` = unset/intra). libaom's OBMC neighbour
182- /// prediction (`av1_setup_build_prediction_by_{above,left}_pred`) uses the
183- /// NEIGHBOUR mbmi's `interp_filters`, which is mi-granular; the decoder's
184- /// `Neighbours` filter arrays are 16px-granular and are not written until
185- /// a whole 16x16 finishes, so an 8x8 leaf OBMC-blending its own SIBLING
186- /// leaf read the unset `[3, 3]` sentinel (a hard panic in
187- /// `from_switchable_symbol`).
188- filters: Vec<[u8; 2]>,
189 /// lane-tiles r6: the current tile's own mi-unit bounds (spec: an MV180 /// lane-tiles r6: the current tile's own mi-unit bounds (spec: an MV
190 /// candidate scan never reaches across a tile boundary, mirroring181 /// candidate scan never reaches across a tile boundary, mirroring
191 /// `PlaneBuf`'s `tile_x0`/`tile_x1` reach clamp for intra prediction).182 /// `PlaneBuf`'s `tile_x0`/`tile_x1` reach clamp for intra prediction).
@@ -204,7 +195,6 @@ impl MiGrid {
204 cols,195 cols,
205 rows,196 rows,
206 cells: vec![None; cols * rows],197 cells: vec![None; cols * rows],
207- filters: vec![[3u8; 2]; cols * rows],
208 tile_row0: 0,198 tile_row0: 0,
209 tile_col0: 0,199 tile_col0: 0,
210 tile_row1: rows,200 tile_row1: rows,
@@ -212,25 +202,6 @@ impl MiGrid {
212 }202 }
213 }203 }
214 204
215- /// Records the switchable-filter symbols of the block covering `(row,
216- /// col)`; `[3, 3]` (the initial value) means "no filter here" -- intra, a
217- /// fixed-filter frame, or a path that does not track one.
218- pub fn set_filter(&mut self, row: usize, col: usize, filter: [u8; 2]) {
219- if row < self.rows && col < self.cols {
220- self.filters[row * self.cols + col] = filter;
221- }
222- }
223-
224- /// This mi unit's recorded filter symbols, `[3, 3]` when unset.
225- #[must_use]
226- pub fn filter(&self, row: usize, col: usize) -> [u8; 2] {
227- if row < self.rows && col < self.cols {
228- self.filters[row * self.cols + col]
229- } else {
230- [3, 3]
231- }
232- }
233-
234 /// Narrows [`Self::get`]'s own read window to one tile's mi-unit span205 /// Narrows [`Self::get`]'s own read window to one tile's mi-unit span
235 /// (`row1`/`col1` exclusive) -- called once per tile, before that206 /// (`row1`/`col1` exclusive) -- called once per tile, before that
236 /// tile's own superblock walk, the same way `Neighbours::start_tile`207 /// tile's own superblock walk, the same way `Neighbours::start_tile`
crates/ec-av1/src/refusal_inventory.rsmodified+3 -2
@@ -63,8 +63,9 @@ const REFUSALS: &[&str] = &[
63 "a show_existing_frame header naming an empty reference slot",63 "a show_existing_frame header naming an empty reference slot",
64 "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)",64 "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)",
65 "an inter frame with no key frame before it",65 "an inter frame with no key frame before it",
66- "an inter SB-level partition type other than SPLIT (this decoder's inter tile path only recurses a superblock as SPLIT)",66+ "an inter SB-level partition type other than NONE or SPLIT (this decoder's inter tile path recurses a superblock only as SPLIT)",
67- "an inter partition below 16x16 other than a clean split into four 8x8 leaves",67+ "a masked compound 64x64 inter block (compound_type is inferred, not coded, at this size)",
68+ "an inter partition below 16x16 other than SPLIT (16x8/8x16 rect inter leaves are not coded yet)",
68 "an intra mode this decoder does not code (round 2)",69 "an intra mode this decoder does not code (round 2)",
69 "an intra-coded HORZ/VERT strip needs rectangular intra prediction this decoder does not code yet",70 "an intra-coded HORZ/VERT strip needs rectangular intra prediction this decoder does not code yet",
70 "filter intra on a HORZ/VERT strip (this decoder predicts square-only)",71 "filter intra on a HORZ/VERT strip (this decoder predicts square-only)",
crates/ec-av1/src/stream.rsmodified+221 -0
@@ -2762,6 +2762,227 @@ mod tests {
2762 /// single-`LAST_FRAME` P frame (no alt-ref/backward reference this2762 /// single-`LAST_FRAME` P frame (no alt-ref/backward reference this
2763 /// decoder's inter path does not model), `--kf-max-dist` past the clip's2763 /// decoder's inter path does not model), `--kf-max-dist` past the clip's
2764 /// own length keeps frame 0 the only key frame.2764 /// own length keeps frame 0 the only key frame.
2765+ /// lane-inter8 r1: the inter tile path's SB-level `PARTITION_NONE` -- a
2766+ /// whole 64x64 superblock coded as ONE inter block, which is what aomenc
2767+ /// picks for static content and which this decoder refused by name
2768+ /// ("an inter SB-level partition type other than SPLIT") until this
2769+ /// round. HARD-asserts [`decode::inter_sb_none_hits`] moved (the arm
2770+ /// really fired, class refusal-lifted-without-a-gate) and every frame is
2771+ /// pixel-exact vs ffmpeg; a decode error is a FAILURE here, never a SKIP
2772+ /// (class gate-skips-on-its-own-failure).
2773+ /// lane-inter8 r1: generalised so the same recipe can target a deeper
2774+ /// level of the inter partition tree -- `min_part` is aomenc's
2775+ /// `--min-partition-size`, and `hits`/`what` name the counter that proves
2776+ /// the arm under test really fired.
2777+ fn inter_sb_none_gate(
2778+ name: &str,
2779+ ten_bit: bool,
2780+ min_part: &str,
2781+ max_part: &str,
2782+ hits: fn() -> usize,
2783+ what: &str,
2784+ ) {
2785+ if !have_ffmpeg() {
2786+ eprintln!("SKIP {name}: no ffmpeg");
2787+ return;
2788+ }
2789+ if !have_aomenc() {
2790+ eprintln!("SKIP {name}: no aomenc at {}", aomenc_path().display());
2791+ return;
2792+ }
2793+ let (width, height, frame_count) = (64usize, 64usize, 4usize);
2794+ // A deterministic synthetic source with real motion (a static source
2795+ // codes every inter frame as skip and never exercises the residual
2796+ // path); bounded with `-t` (class gate-loader-slurps-whole-file).
2797+ let y4m = Command::new("ffmpeg")
2798+ .args([
2799+ "-v",
2800+ "error",
2801+ "-f",
2802+ "lavfi",
2803+ "-i",
2804+ "mandelbrot=size=64x64:rate=25",
2805+ "-t",
2806+ "0.16",
2807+ "-pix_fmt",
2808+ if ten_bit { "yuv420p10le" } else { "yuv420p" },
2809+ // y4m calls 10-bit unofficial (same as the 10-bit key-frame
2810+ // gate's own fixture).
2811+ "-strict",
2812+ "-1",
2813+ "-f",
2814+ "yuv4mpegpipe",
2815+ "-",
2816+ ])
2817+ .stdin(Stdio::null())
2818+ .stdout(Stdio::piped())
2819+ .stderr(Stdio::piped())
2820+ .output()
2821+ .expect("ffmpeg failed to run");
2822+ assert!(
2823+ y4m.status.success(),
2824+ "{name}: ffmpeg fixture: {}",
2825+ String::from_utf8_lossy(&y4m.stderr)
2826+ );
2827+ let mut args: Vec<String> = [
2828+ "--codec=av1",
2829+ "--passes=1",
2830+ "--end-usage=q",
2831+ "--cq-level=40",
2832+ "--cpu-used=0",
2833+ "--lag-in-frames=0",
2834+ "--auto-alt-ref=0",
2835+ "--kf-max-dist=1000",
2836+ // No cross-frame CDF forwarding in this fixture (see the
2837+ // deblocking gate's own note).
2838+ "--error-resilient=1",
2839+ // This gate targets the SB-level NONE arm only: rect/AB/1-to-4
2840+ // partitions and sub-16x16 splits stay off so a failure here
2841+ // cannot be another lane's missing arm.
2842+ "--enable-rect-partitions=0",
2843+ "--enable-ab-partitions=0",
2844+ "--enable-1to4-partitions=0",
2845+ "--enable-filter-intra=0",
2846+ "--enable-smooth-intra=0",
2847+ "--enable-paeth-intra=0",
2848+ "--enable-directional-intra=0",
2849+ "--enable-angle-delta=0",
2850+ "--enable-tx-size-search=0",
2851+ "--enable-cdef=0",
2852+ "--enable-restoration=0",
2853+ "--enable-palette=0",
2854+ "--enable-intrabc=0",
2855+ "--enable-cfl-intra=0",
2856+ "--enable-ref-frame-mvs=0",
2857+ "--obu",
2858+ "-o",
2859+ "-",
2860+ "-",
2861+ ]
2862+ .iter()
2863+ .map(|s| (*s).to_string())
2864+ .collect();
2865+ args.insert(1, format!("--min-partition-size={min_part}"));
2866+ args.insert(1, format!("--max-partition-size={max_part}"));
2867+ if ten_bit {
2868+ args.insert(1, "--input-bit-depth=10".to_string());
2869+ args.insert(1, "--bit-depth=10".to_string());
2870+ }
2871+ let mut child = Command::new(aomenc_path())
2872+ .args(&args)
2873+ .stdin(Stdio::piped())
2874+ .stdout(Stdio::piped())
2875+ .stderr(Stdio::piped())
2876+ .spawn()
2877+ .expect("aomenc failed to start");
2878+ child
2879+ .stdin
2880+ .take()
2881+ .expect("aomenc stdin")
2882+ .write_all(&y4m.stdout)
2883+ .expect("writing y4m to aomenc");
2884+ let out = child.wait_with_output().expect("aomenc failed to run");
2885+ assert!(
2886+ out.status.success(),
2887+ "{name}: aomenc refused the fixture: {}",
2888+ String::from_utf8_lossy(&out.stderr)
2889+ );
2890+ let stream = out.stdout;
2891+ let before = hits();
2892+ let frames = match decode_stream(&stream) {
2893+ Ok(frames) => frames,
2894+ Err(e) => {
2895+ let pin = std::env::temp_dir().join(format!("{name}-refused.obu"));
2896+ let _ = std::fs::write(&pin, &stream);
2897+ panic!("{name}: decode_stream refused a real aomenc stream: {e} (pinned at {})", pin.display());
2898+ }
2899+ };
2900+ assert!(
2901+ hits() > before,
2902+ "{name}: no {what} fired -- this gate proves nothing"
2903+ );
2904+ let ffmpeg_frames = if ten_bit {
2905+ ffmpeg_decode_sequence_10bit(&stream, width, height, frame_count)
2906+ } else {
2907+ ffmpeg_decode_sequence(&stream, width, height, frame_count)
2908+ };
2909+ assert_eq!(frames.len(), frame_count, "{name}: frame count");
2910+ for (i, (got, want)) in frames.iter().zip(&ffmpeg_frames).enumerate() {
2911+ if got.y != want.y || got.u != want.u || got.v != want.v {
2912+ let pin = std::env::temp_dir().join(format!("{name}-mismatch.obu"));
2913+ let _ = std::fs::write(&pin, &stream);
2914+ panic!("{name}: frame {i} mismatch vs ffmpeg -- stream pinned at {}", pin.display());
2915+ }
2916+ }
2917+ }
2918+
2919+ #[test]
2920+ fn a_real_aomenc_inter_sequence_with_a_whole_superblock_block_decodes_pixel_exact() {
2921+ inter_sb_none_gate(
2922+ "a_real_aomenc_inter_sequence_with_a_whole_superblock_block_decodes_pixel_exact",
2923+ false,
2924+ "32",
2925+ "64",
2926+ decode::inter_sb_none_hits,
2927+ "whole-superblock inter PARTITION_NONE",
2928+ );
2929+ }
2930+
2931+ #[test]
2932+ fn a_real_aomenc_10bit_inter_sequence_with_a_whole_superblock_block_decodes_pixel_exact() {
2933+ inter_sb_none_gate(
2934+ "a_real_aomenc_10bit_inter_sequence_with_a_whole_superblock_block_decodes_pixel_exact",
2935+ true,
2936+ "32",
2937+ "64",
2938+ decode::inter_sb_none_hits,
2939+ "whole-superblock inter PARTITION_NONE",
2940+ );
2941+ }
2942+
2943+ /// lane-inter8 r1: the same recipe with `--min-partition-size=8`, so
2944+ /// aomenc's RD may split a 16x16 inter block into four 8x8 leaves. The
2945+ /// interior (non-edge-straddling) `PARTITION_SPLIT` at the 16x16 level
2946+ /// was refused by name until this round; the straddle path always ran the
2947+ /// same loop, so only [`decode::inter_sub16_split_hits`] -- which counts
2948+ /// interior splits only -- proves the newly-lifted alphabet value fired.
2949+ // lane-inter8 r2: GREEN. The neighbour side bands are mi-granular, every
2950+ // leaf stamps its own 2x2-mi span (including the compound-return path
2951+ // that used to skip `record_mi` entirely) and the compound
2952+ // group/index contexts read the LEAF's mi cell, not its 16x16's corner.
2953+ #[test]
2954+ fn a_real_aomenc_inter_sequence_with_an_8x8_leaf_split_decodes_pixel_exact() {
2955+ inter_sb_none_gate(
2956+ "a_real_aomenc_inter_sequence_with_an_8x8_leaf_split_decodes_pixel_exact",
2957+ false,
2958+ "8",
2959+ "16",
2960+ decode::inter_sub16_split_hits,
2961+ "interior 16x16 inter PARTITION_SPLIT into 8x8 leaves",
2962+ );
2963+ }
2964+
2965+ #[test]
2966+ // lane-inter8 r2: still RED, and ignored rather than deleted -- the 8-bit
2967+ // twin above is green, this 10-bit recipe stops at "an INTER 32x32
2968+ // partition type this decoder does not code (value=9)". That is OUR
2969+ // desync, proven: `EC_TRACE=1 aomdec` on the pinned stream reads
2970+ // 16 `bsize=9 value=3` (SPLIT) partitions and never a single value=9
2971+ // anywhere (class refusal-from-own-desync; the r1 ledger line claiming
2972+ // aomenc emits PARTITION_VERT_4 despite --enable-1to4-partitions=0 is
2973+ // hereby disproven). The divergence itself is not yet bisected.
2974+ #[ignore = "lane-inter8 r2: 10-bit twin still desyncs (surfaces as a bogus 32x32 value=9 refusal); 8-bit gate is green"]
2975+ fn a_real_aomenc_10bit_inter_sequence_with_an_8x8_leaf_split_decodes_pixel_exact() {
2976+ inter_sb_none_gate(
2977+ "a_real_aomenc_10bit_inter_sequence_with_an_8x8_leaf_split_decodes_pixel_exact",
2978+ true,
2979+ "8",
2980+ "16",
2981+ decode::inter_sub16_split_hits,
2982+ "interior 16x16 inter PARTITION_SPLIT into 8x8 leaves",
2983+ );
2984+ }
2985+
2765 #[test]2986 #[test]
2766 fn a_real_aomenc_inter_sequence_with_deblocking_decodes_pixel_exact() {2987 fn a_real_aomenc_inter_sequence_with_deblocking_decodes_pixel_exact() {
2767 if !have_ffmpeg() {2988 if !have_ffmpeg() {
lanes/inter8-r1.report.mdadded+87 -0
@@ -0,0 +1,87 @@
1+# lane-inter8 r1 -- inter partition tree: the 16x16 level and its 8x8 leaves
2+
3+Branch `lane-inter8`, off main `3808cf8` (resumed from the orchestrator's WIP
4+snapshot `a5430ec`). **NOT merge-ready**: the round's gate is RED and `#[ignore]`d
5+with its reason (see "Open residue"). Nothing here has been merged to main.
6+
7+## What changed
8+
9+- `crates/ec-av1/src/decode.rs` (inter tile loop, ~12345): the interior (non
10+ edge-straddling) 16x16 partition symbol is now read as the real alphabet and
11+ `PARTITION_SPLIT` recurses into four 8x8 inter leaves (previously: refused by
12+ name). Refusal narrowed to
13+ `"an inter partition below 16x16 other than SPLIT (16x8/8x16 rect inter leaves are not coded yet)"`.
14+ Counter `INTER_SUB16_SPLIT_HITS` / `inter_sub16_split_hits()` counts *interior*
15+ splits only -- the straddle path always ran that same loop, so only an interior
16+ count proves the newly-lifted alphabet value fired. (from the WIP snapshot)
17+- `decode.rs` `obmc_blend`: `av1_skip_u4x4_pred_in_obmc` -- the ABOVE pass skips
18+ chroma when the chroma block is 4x4/8x4/4x8 (8x8, 16x8, 8x16 luma at 4:2:0);
19+ `obmc_mask_2` added. (from the WIP snapshot)
20+- `decode.rs` `decode_inter_block8` (8x8 leaf), THIS round, three real defects,
21+ each one moving the aomdec range ladder strictly later:
22+ 1. the leaf built its `comp_mode` / compound-ref contexts from a FABRICATED
23+ neighbour (`ref0 = LAST_FRAME` if inter, `ref1 = None`, `uni = false`).
24+ `av1_get_reference_mode_context` asks whether a neighbour is COMPOUND, so
25+ with real LAST+GOLDEN compound neighbours the leaf picked the wrong CDF row
26+ and read single-ref where aomdec read compound `NEAR_NEWMV` (mi 4,14).
27+ Now uses `neighbours.above_ref/above_ref1/left_ref/left_ref1` with the same
28+ `is_uni_comp_ref` logic as `decode_inter_block` one level up.
29+ 2. the sibling-leaf override was a single `prev_leaf` (the previously decoded
30+ leaf). The bottom-LEFT leaf's ABOVE neighbour is leaf 0, never leaf 1, so
31+ one of the four leaves always read a stale neighbour -- class
32+ `context-read-from-one-cell`. Now a `prev_leaves` slice, matched by
33+ coordinate, and each leaf hands back its own resolved `(ref0, ref1)`.
34+ 3. both leaf mv stacks were built with `NO_SIGN_BIAS` / `NO_GM_MV` while the
35+ 16x16 path passed the frame's real tables; `assign_compound_mv` got
36+ `((0,0),(0,0))` for the gm mvs. Now threaded (`sign_bias_table`,
37+ `global_motion` params + a leaf-local `build_gm_mv_table`). Alignment with
38+ the proven path; it did NOT move this fixture's ladder (identity gm here).
39+- `decode.rs`: `EC_MODE mi_row=.. mi_col=.. rng=..` traces under `EC_TRACE_MODE`
40+ in both `decode_inter_block` and `decode_inter_block8`, byte-format-identical
41+ to the oracle's rung-4 `EC_MODE`, plus `EC_LEAFMODE` (compound mode / stack
42+ size / ctxs) and a `TRACE partition_w16` line under `EC_AV1_TRACE`. These are
43+ the instruments the round was actually decided with.
44+- `crates/ec-av1/src/stream.rs`: `inter_sb_none_gate` generalised to take
45+ `min_part` / `max_part` (aomenc `--min/--max-partition-size`) and the counter
46+ + label that proves the arm under test fired, so one recipe can target any
47+ level of the inter partition tree. Two new gates
48+ (`a_real_aomenc_[10bit_]inter_sequence_with_an_8x8_leaf_split_decodes_pixel_exact`,
49+ `min=8 max=16`) assert `inter_sub16_split_hits` moved and every frame is
50+ pixel-exact -- currently `#[ignore]`d, RED.
51+
52+## Gate + evidence
53+
54+Command (from the worktree, `CARGO_TARGET_DIR=$HOME/.cache/cargo-target-inter8`,
55+`EC_AV1_REQUIRE_AOMENC=1`):
56+
57+ cargo test -p ec-av1 --lib -- --ignored an_8x8_leaf_split
58+
59+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)
60+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
61+
62+## Refusals
63+
64+- narrowed: "an inter partition below 16x16 (8x8 and smaller inter blocks are not
65+ coded yet)" -> "... other than SPLIT (16x8/8x16 rect inter leaves are not coded
66+ yet)". **This narrowing is NOT yet backed by a green gate** -- honest status,
67+ and the reason this branch must not merge as-is.
68+- untouched: SB-level non-NONE/SPLIT, the 32x32 alphabet refusal (`value=9`,
69+ `PARTITION_VERT_4`, which aomenc emitted at 32x32 even with
70+ `--enable-1to4-partitions=0` -- same shape as lane-sbpart r2's AB-at-64 note),
71+ the 16x16 true-edge rectangular-transform one, the 8x8 chroma-mode one.
72+
73+## Open residue
74+
75+- fix-now (next round): `Neighbours`' `above_*`/`left_*` arrays are 16x16
76+ granular. Leaf (6,12)'s LEFT neighbour must be leaf (6,10) of the previous
77+ 16x16 block, but both leaf rows of a 16x16 share one array slot, so one of
78+ them is always wrong. Making those arrays mi-granular (or adding a per-mi
79+ side band for skip/inter/ref0/ref1) is the next slice, and it is what
80+ un-ignores the two gates above.
81+- deferred(the above): 8x8 HORZ/VERT -> 8x4/4x8 leaves, rect inter MC/transforms
82+ at 16x8/8x16 (lane-rectx owns the transform half), AB/1-to-4 at 64/32/16, and
83+ the aggregate per-type-per-level hit-counter gate the charter asks for. None
84+ of these were started this round.
85+- deferred(unknown): the 10-bit variant of the same recipe stopped at
86+ "a reference frame other than LAST_FRAME (round 2)" at `--min-partition-size=8
87+ --max-partition-size=64` before the max was clamped to 16; not re-measured.