forge
Explore
Log in

Don't you dare go Hollow

Merge lane-inter8 12809b2: interior 16x16 SPLIT into 8x8 inter leaves; mi-granular inter neighbour bands; three leaf-context defects (fabricated compound refs, sibling override, comp ctx corner) + compound-arm tail; 8-bit 8x8-leaf gate green (verifier PASS, 269/0/23); conflict = keep mi index + main's segment_id read

Browse files at this commit

f822a4c283dfca1272e68d311c05007e6fa19c0cAhmet Kaan GümüşParent: 8c9548c581d074
crates/ec-av1/src/decode.rsmodified+509 -154
@@ -1201,6 +1201,33 @@ pub(crate) fn rect_partition_hits() -> usize {
12011201 RECT_PARTITION_HITS.with(|c| c.get())
12021202 }
12031203
1204+// lane-inter8 r1: how many superblocks an inter tile coded as a single
1205+// whole-SB `PARTITION_NONE` 64x64 inter block (the case aomenc picks for
1206+// static content, previously a named refusal).
1207+thread_local! {
1208+ static INTER_SB_NONE_HITS: std::cell::Cell<usize> =
1209+ const { std::cell::Cell::new(0) };
1210+}
1211+
1212+/// Current value of [`INTER_SB_NONE_HITS`].
1213+pub(crate) fn inter_sb_none_hits() -> usize {
1214+ INTER_SB_NONE_HITS.with(|c| c.get())
1215+}
1216+
1217+// lane-inter8 r1: how many INTERIOR (not frame-edge-straddling) 16x16 inter
1218+// blocks coded a real `PARTITION_SPLIT` into four 8x8 leaves -- the straddle
1219+// path has always run that loop, so only this counter proves the newly-lifted
1220+// alphabet value fired.
1221+thread_local! {
1222+ static INTER_SUB16_SPLIT_HITS: std::cell::Cell<usize> =
1223+ const { std::cell::Cell::new(0) };
1224+}
1225+
1226+/// Current value of [`INTER_SUB16_SPLIT_HITS`].
1227+pub(crate) fn inter_sub16_split_hits() -> usize {
1228+ INTER_SUB16_SPLIT_HITS.with(|c| c.get())
1229+}
1230+
12041231 // lane-rectwire r2: how many `PARTITION_HORZ`/`VERT` strips actually decoded
12051232 // real (non-skip) coefficients through [`read_coeffs_rect`] -- proves the
12061233 // rect coefficient reader itself fired, not just the strip-level partition
@@ -2459,22 +2486,26 @@ impl Neighbours {
24592486 left_side: vec![SB; rows],
24602487 above_side_mi: vec![SB; cols * (SUB / MI)],
24612488 left_side_mi: vec![SB; rows * (SUB / MI)],
2462- above_skip: vec![false; cols],
2463- left_skip: vec![false; rows],
2464- above_skip_mode: vec![false; cols],
2465- left_skip_mode: vec![false; rows],
2466- above_inter: vec![false; cols],
2467- left_inter: vec![false; rows],
2468- above_ref: vec![-1; cols],
2469- left_ref: vec![-1; rows],
2470- above_ref1: vec![None; cols],
2471- left_ref1: vec![None; rows],
2472- above_comp_group_idx: vec![0; cols],
2473- left_comp_group_idx: vec![0; rows],
2474- above_compound_idx: vec![0; cols],
2475- left_compound_idx: vec![0; rows],
2476- above_filter: vec![[3u8; 2]; cols],
2477- left_filter: vec![[3u8; 2]; rows],
2489+ // lane-inter8 r2: mi(4px)-granular, not [`SUB`]-granular -- an
2490+ // 8x8 inter leaf's left neighbour is the OTHER leaf row of the
2491+ // 16x16 block beside it, which a SUB-grid slot cannot name
2492+ // (class context-read-from-one-cell).
2493+ above_skip: vec![false; cols * (SUB / MI)],
2494+ left_skip: vec![false; rows * (SUB / MI)],
2495+ above_skip_mode: vec![false; cols * (SUB / MI)],
2496+ left_skip_mode: vec![false; rows * (SUB / MI)],
2497+ above_inter: vec![false; cols * (SUB / MI)],
2498+ left_inter: vec![false; rows * (SUB / MI)],
2499+ above_ref: vec![-1; cols * (SUB / MI)],
2500+ left_ref: vec![-1; rows * (SUB / MI)],
2501+ above_ref1: vec![None; cols * (SUB / MI)],
2502+ left_ref1: vec![None; rows * (SUB / MI)],
2503+ above_comp_group_idx: vec![0; cols * (SUB / MI)],
2504+ left_comp_group_idx: vec![0; rows * (SUB / MI)],
2505+ above_compound_idx: vec![0; cols * (SUB / MI)],
2506+ left_compound_idx: vec![0; rows * (SUB / MI)],
2507+ above_filter: vec![[3u8; 2]; cols * (SUB / MI)],
2508+ left_filter: vec![[3u8; 2]; rows * (SUB / MI)],
24782509 mi_cols,
24792510 mi_rows,
24802511 skip_grid: vec![false; cols * (SUB / MI) * rows * (SUB / MI)],
@@ -2522,6 +2553,11 @@ impl Neighbours {
25222553 for i in sc0.min(sc1)..sc1 {
25232554 self.above_mode[i] = DC_PRED;
25242555 self.above_side[i] = SB;
2556+ }
2557+ // lane-inter8 r2: the inter bands are mi-granular, so they reset over
2558+ // the tile's own mi column span directly.
2559+ let mend = col1_mi.min(self.above_skip.len());
2560+ for i in col0_mi.min(mend)..mend {
25252561 self.above_skip[i] = false;
25262562 self.above_skip_mode[i] = false;
25272563 self.above_inter[i] = false;
@@ -2839,8 +2875,37 @@ impl Neighbours {
28392875 skip_mode: bool,
28402876 ) {
28412877 let (r, c) = at;
2878+ self.record_inter_rect_mi(
2879+ (r * (SUB / MI), c * (SUB / MI)),
2880+ w_sub / MI,
2881+ h_sub / MI,
2882+ skip,
2883+ is_inter,
2884+ ref_frame,
2885+ filter,
2886+ skip_mode,
2887+ );
2888+ }
2889+
2890+ /// [`Self::record_inter_rect`] in mi (4px) units -- lane-inter8 r2: an
2891+ /// 8x8 leaf covers 2x2 mi, half a [`SUB`] cell in each direction, so the
2892+ /// side bands are written (and read) per mi. Every [`SUB`]-unit caller
2893+ /// routes through the wrapper above.
2894+ #[allow(clippy::too_many_arguments)]
2895+ fn record_inter_rect_mi(
2896+ &mut self,
2897+ at_mi: (usize, usize),
2898+ w_mi: usize,
2899+ h_mi: usize,
2900+ skip: bool,
2901+ is_inter: bool,
2902+ ref_frame: i8,
2903+ filter: [u8; 2],
2904+ skip_mode: bool,
2905+ ) {
2906+ let (r, c) = at_mi;
28422907 let altref = is_inter && ref_frame == crate::mvstack::ALTREF_FRAME;
2843- for cell in 0..w_sub / SUB {
2908+ for cell in 0..w_mi {
28442909 self.above_skip[c + cell] = skip;
28452910 self.above_skip_mode[c + cell] = skip_mode;
28462911 self.above_inter[c + cell] = is_inter;
@@ -2858,7 +2923,7 @@ impl Neighbours {
28582923 self.above_compound_idx[c + cell] = u8::from(altref);
28592924 self.above_filter[c + cell] = filter;
28602925 }
2861- for cell in 0..h_sub / SUB {
2926+ for cell in 0..h_mi {
28622927 self.left_skip[r + cell] = skip;
28632928 self.left_skip_mode[r + cell] = skip_mode;
28642929 self.left_inter[r + cell] = is_inter;
@@ -2904,12 +2969,34 @@ impl Neighbours {
29042969 compound_idx: u8,
29052970 ) {
29062971 let (r, c) = at;
2907- for cell in 0..w_sub / SUB {
2972+ self.record_compound_ctx_rect_mi(
2973+ (r * (SUB / MI), c * (SUB / MI)),
2974+ w_sub / MI,
2975+ h_sub / MI,
2976+ ref1,
2977+ comp_group_idx,
2978+ compound_idx,
2979+ );
2980+ }
2981+
2982+ /// [`Self::record_compound_ctx_rect`] in mi units (lane-inter8 r2, see
2983+ /// [`Self::record_inter_rect_mi`]).
2984+ fn record_compound_ctx_rect_mi(
2985+ &mut self,
2986+ at_mi: (usize, usize),
2987+ w_mi: usize,
2988+ h_mi: usize,
2989+ ref1: i8,
2990+ comp_group_idx: u8,
2991+ compound_idx: u8,
2992+ ) {
2993+ let (r, c) = at_mi;
2994+ for cell in 0..w_mi {
29082995 self.above_ref1[c + cell] = Some(ref1);
29092996 self.above_comp_group_idx[c + cell] = comp_group_idx;
29102997 self.above_compound_idx[c + cell] = compound_idx;
29112998 }
2912- for cell in 0..h_sub / SUB {
2999+ for cell in 0..h_mi {
29133000 self.left_ref1[r + cell] = Some(ref1);
29143001 self.left_comp_group_idx[r + cell] = comp_group_idx;
29153002 self.left_compound_idx[r + cell] = compound_idx;
@@ -9301,6 +9388,23 @@ fn read_inter_plane(
93019388 default_tx_type,
93029389 None,
93039390 )?;
9391+ // lane-inter8 r1: a 64-point transform covers the whole 64x64 area but
9392+ // codes only its top-left 32x32 of frequencies (spec 5.11.40) -- the
9393+ // caller hands the 32-point `scan` there, and the coded corner goes into
9394+ // the top-left of the true `side`-sized grid before dequantization
9395+ // (dqDenom is keyed by the true size, not the corner's), mirroring
9396+ // [`read_plane`]'s own `tx_side != side` branch. Every other transform
9397+ // this decoder codes has `tx_side == side`, so this is inert below 64.
9398+ let tx_side = side.min(32);
9399+ let grid = if tx_side == side {
9400+ grid
9401+ } else {
9402+ let mut full = vec![0i32; side * side];
9403+ for row in 0..tx_side {
9404+ full[row * side..][..tx_side].copy_from_slice(&grid[row * tx_side..][..tx_side]);
9405+ }
9406+ full
9407+ };
93049408 let (dc_delta, ac_delta) = plane_q_delta(plane_idx);
93059409 let residual = dequant_and_inverse_typed(&grid, side, bit_depth(), block_q_idx(), dc_delta, ac_delta, tx_type);
93069410 plane.reconstruct_mc(x, y, side, prediction, &residual);
@@ -9649,6 +9753,11 @@ fn num_proj_ref(
96499753 /// decoder's own overlap sizes ever produce (luma 8/16/32, chroma 4/8/16)
96509754 /// are transcribed.
96519755 fn obmc_mask(len: usize) -> &'static [u8] {
9756+ // lane-inter8 r1: `obmc_mask_2` (`reconinter.c` 753) -- reached by the
9757+ // LEFT pass of an 8x8 block's chroma plane (overlap 4 luma columns, 2
9758+ // chroma), which only became live once 8x8 inter leaves stopped being
9759+ // refused.
9760+ const M2: [u8; 2] = [45, 64];
96529761 const M4: [u8; 4] = [39, 50, 59, 64];
96539762 const M8: [u8; 8] = [36, 42, 48, 53, 57, 61, 64, 64];
96549763 const M16: [u8; 16] = [
@@ -9659,6 +9768,7 @@ fn obmc_mask(len: usize) -> &'static [u8] {
96599768 61, 62, 64, 64, 64, 64, 64, 64, 64, 64,
96609769 ];
96619770 match len {
9771+ 2 => &M2,
96629772 4 => &M4,
96639773 8 => &M8,
96649774 16 => &M16,
@@ -9892,6 +10002,7 @@ fn obmc_blend(
989210002 };
989310003 let overlap_above = write_h / 2;
989410004 let overlap_left = write_w / 2;
10005+ let skip_chroma_above = matches!((write_w, write_h), (8, 8) | (16, 8) | (8, 16));
989510006
989610007 for (off4, span4, nb) in overlappable_above(grid, mi_row, mi_col, bw4, mi_cols, max_nb(bw4))
989710008 {
@@ -9901,23 +10012,31 @@ fn obmc_blend(
990110012 // divide back down to that column.
990210013 let (h_kind, v_kind) = neighbour_filter(
990310014 interp_fixed,
9904- neighbours.above_filter[(mi_col + off4) / SUB_MI as usize],
10015+ neighbours.above_filter[mi_col + off4],
990510016 );
990610017 let (ny, nu, nv) = ref_planes(nb.ref_frame, ref_y, ref_u, ref_v, other_refs)?;
990710018 let (bw, bh, ox) = (span4 * 4, overlap_above, off4 * 4);
990810019 let tmp_y = obmc_neighbour_pred(ny, px + ox, py, nb.mv, bw, bh, true, h_kind, v_kind);
990910020 obmc_blend_v(pred_y, side, ox, 0, bw, bh, &tmp_y);
9910- let (cbw, cbh, cox) = (bw / 2, overlap_above / 2, ox / 2);
9911- let tmp_u = obmc_neighbour_pred(nu, cpx + cox, cpy, nb.mv, cbw, cbh, false, h_kind, v_kind);
9912- obmc_blend_v(pred_u, chroma_side, cox, 0, cbw, cbh, &tmp_u);
9913- let tmp_v = obmc_neighbour_pred(nv, cpx + cox, cpy, nb.mv, cbw, cbh, false, h_kind, v_kind);
9914- obmc_blend_v(pred_v, chroma_side, cox, 0, cbw, cbh, &tmp_v);
10021+ // lane-inter8 r1: `av1_skip_u4x4_pred_in_obmc` (`reconinter.c` 820,
10022+ // `DISABLE_CHROMA_U8X8_OBMC == 0` -- "one-sided obmc"): when the
10023+ // chroma plane's own block size is BLOCK_4X4/8X4/4X8 (a 8x8, 16x8 or
10024+ // 8x16 luma block at 4:2:0), the ABOVE pass skips chroma entirely
10025+ // while the LEFT pass still blends it. Blending chroma here as well
10026+ // would both mis-predict every 8x8 leaf and ask for an overlap of 2.
10027+ if !skip_chroma_above {
10028+ let (cbw, cbh, cox) = (bw / 2, overlap_above / 2, ox / 2);
10029+ let tmp_u = obmc_neighbour_pred(nu, cpx + cox, cpy, nb.mv, cbw, cbh, false, h_kind, v_kind);
10030+ obmc_blend_v(pred_u, chroma_side, cox, 0, cbw, cbh, &tmp_u);
10031+ let tmp_v = obmc_neighbour_pred(nv, cpx + cox, cpy, nb.mv, cbw, cbh, false, h_kind, v_kind);
10032+ obmc_blend_v(pred_v, chroma_side, cox, 0, cbw, cbh, &tmp_v);
10033+ }
991510034 }
991610035
991710036 for (off4, span4, nb) in overlappable_left(grid, mi_row, mi_col, bh4, mi_rows, max_nb(bh4)) {
991810037 let (h_kind, v_kind) = neighbour_filter(
991910038 interp_fixed,
9920- neighbours.left_filter[(mi_row + off4) / SUB_MI as usize],
10039+ neighbours.left_filter[mi_row + off4],
992110040 );
992210041 let (ny, nu, nv) = ref_planes(nb.ref_frame, ref_y, ref_u, ref_v, other_refs)?;
992310042 let (bw, bh, oy) = (overlap_left, span4 * 4, off4 * 4);
@@ -9958,10 +10077,17 @@ fn is_uni_comp_ref(ref0: i8, ref1: i8) -> bool {
995810077 /// `get_comp_group_idx_context` (libaom `pred_common.h`): sums the
995910078 /// above/left neighbour contributions [`Neighbours::record_inter`]/
996010079 /// [`Neighbours::record_compound_ctx`] already precomputed, clamped to 5.
9961-fn get_comp_group_idx_context(neighbours: &Neighbours, at: (usize, usize), side: usize) -> usize {
10080+/// lane-inter8 r2: `at_mi` is the block's own top-left in 4x4 mi units --
10081+/// an 8x8 leaf used to pass its enclosing 16x16's corner here, so all four
10082+/// leaves read the same neighbour cell (class context-read-from-one-cell).
10083+fn get_comp_group_idx_context(
10084+ neighbours: &Neighbours,
10085+ at_mi: (usize, usize),
10086+ side: usize,
10087+) -> usize {
996210088 let _ = side;
9963- let (r, c) = at;
9964- (neighbours.above_comp_group_idx[c] as usize + neighbours.left_comp_group_idx[r] as usize)
10089+ let (rmi, cmi) = at_mi;
10090+ (neighbours.above_comp_group_idx[cmi] as usize + neighbours.left_comp_group_idx[rmi] as usize)
996510091 .min(5)
996610092 }
996710093
@@ -9973,7 +10099,7 @@ fn get_comp_group_idx_context(neighbours: &Neighbours, at: (usize, usize), side:
997310099 #[allow(clippy::too_many_arguments)]
997410100 fn get_comp_index_context(
997510101 neighbours: &Neighbours,
9976- at: (usize, usize),
10102+ at_mi: (usize, usize),
997710103 side: usize,
997810104 order_hint_bits: u32,
997910105 cur_order_hint: u32,
@@ -9981,7 +10107,7 @@ fn get_comp_index_context(
998110107 ref1_order_hint: u32,
998210108 ) -> usize {
998310109 let _ = side;
9984- let (r, c) = at;
10110+ let (rmi, cmi) = at_mi;
998510111 let fwd =
998610112 crate::motion_field::get_relative_dist(order_hint_bits, ref1_order_hint, cur_order_hint)
998710113 .abs();
@@ -9989,8 +10115,8 @@ fn get_comp_index_context(
998910115 crate::motion_field::get_relative_dist(order_hint_bits, cur_order_hint, ref0_order_hint)
999010116 .abs();
999110117 let offset = usize::from(fwd == bck);
9992- neighbours.above_compound_idx[c] as usize
9993- + neighbours.left_compound_idx[r] as usize
10118+ neighbours.above_compound_idx[cmi] as usize
10119+ + neighbours.left_compound_idx[rmi] as usize
999410120 + 3 * offset
999510121 }
999610122
@@ -10364,6 +10490,11 @@ fn decode_inter_block(
1036410490 frame_width: usize,
1036510491 ) -> Result<()> {
1036610492 let (r, c) = at;
10493+ // lane-inter8 r2: the inter side bands are mi-granular; this block's own
10494+ // above/left neighbour is the mi cell at its top-left corner (libaom
10495+ // `above_mbmi` = mi(mi_row - 1, mi_col)), so a SUB-aligned block reads
10496+ // exactly what it read before.
10497+ let (rmi, cmi) = (r * (SUB / MI), c * (SUB / MI));
1036710498 let (px, py) = (c * SUB, r * SUB);
1036810499 let (cpx, cpy) = (px / 2, py / 2);
1036910500 let chroma_side = side / 2;
@@ -10376,7 +10507,7 @@ fn decode_inter_block(
1037610507 );
1037710508 }
1037810509 let skip_mode_ctx =
10379- usize::from(neighbours.above_skip_mode[c]) + usize::from(neighbours.left_skip_mode[r]);
10510+ usize::from(neighbours.above_skip_mode[cmi]) + usize::from(neighbours.left_skip_mode[rmi]);
1038010511 // lane-comppin r3: skip_mode desync isolation -- dump ctx + the pre-read
1038110512 // MSAC tell so it can be diffed against an equivalent hook in libaom's
1038210513 // own `read_skip_mode`/`av1_get_skip_mode_context`.
@@ -10402,7 +10533,7 @@ fn decode_inter_block(
1040210533 SKIP_MODE_HITS.with(|c| c.set(c.get() + 1));
1040310534 }
1040410535
10405- let skip_ctx = usize::from(neighbours.above_skip[c]) + usize::from(neighbours.left_skip[r]);
10536+ let skip_ctx = usize::from(neighbours.above_skip[cmi]) + usize::from(neighbours.left_skip[rmi]);
1040610537 let skip = skip_mode || dec.symbol(&mut cdfs.skip[skip_ctx]) == 1;
1040710538 inter_segment_id(dec, cdfs, seg_mi_r, seg_mi_c, seg_w_mi, seg_h_mi, skip, false);
1040810539 maybe_read_cdef_idx(dec, r * SUB_MI as usize, c * SUB_MI as usize, skip);
@@ -10421,9 +10552,17 @@ fn decode_inter_block(
1042110552 r > neighbours.tile_row0_mi / (SUB / MI),
1042210553 c > neighbours.tile_col0_mi / (SUB / MI),
1042310554 );
10424- let (above_inter, left_inter) = (neighbours.above_inter[c], neighbours.left_inter[r]);
10555+ let (above_inter, left_inter) = (neighbours.above_inter[cmi], neighbours.left_inter[rmi]);
1042510556 let ii_ctx = intra_inter_ctx(has_above, has_left, above_inter, left_inter);
1042610557 let is_inter = skip_mode || dec.symbol(&mut cdfs.intra_inter[ii_ctx]) == 1;
10558+ if std::env::var_os("EC_TRACE_MODE").is_some() {
10559+ eprintln!(
10560+ "EC_MODE mi_row={} mi_col={} rng={}",
10561+ r * SUB_MI as usize,
10562+ c * SUB_MI as usize,
10563+ dec.debug_state().0
10564+ );
10565+ }
1042710566 if std::env::var_os("EC_AV1_TELL").is_some() {
1042810567 eprintln!(
1042910568 "TELL mi_row={} mi_col={} label=post_is_inter skip_mode={skip_mode} skip={skip} is_inter={is_inter} tell={} range={}",
@@ -10446,24 +10585,24 @@ fn decode_inter_block(
1044610585 let above_nbr = has_above.then(|| NeighbourRef {
1044710586 is_inter: above_inter,
1044810587 ref0: if above_inter {
10449- neighbours.above_ref[c]
10588+ neighbours.above_ref[cmi]
1045010589 } else {
1045110590 0
1045210591 },
10453- ref1: neighbours.above_ref1[c],
10454- uni: neighbours.above_ref1[c]
10455- .is_some_and(|r1| is_uni_comp_ref(neighbours.above_ref[c], r1)),
10592+ ref1: neighbours.above_ref1[cmi],
10593+ uni: neighbours.above_ref1[cmi]
10594+ .is_some_and(|r1| is_uni_comp_ref(neighbours.above_ref[cmi], r1)),
1045610595 });
1045710596 let left_nbr = has_left.then(|| NeighbourRef {
1045810597 is_inter: left_inter,
1045910598 ref0: if left_inter {
10460- neighbours.left_ref[r]
10599+ neighbours.left_ref[rmi]
1046110600 } else {
1046210601 0
1046310602 },
10464- ref1: neighbours.left_ref1[r],
10465- uni: neighbours.left_ref1[r]
10466- .is_some_and(|r1| is_uni_comp_ref(neighbours.left_ref[r], r1)),
10603+ ref1: neighbours.left_ref1[rmi],
10604+ uni: neighbours.left_ref1[rmi]
10605+ .is_some_and(|r1| is_uni_comp_ref(neighbours.left_ref[rmi], r1)),
1046710606 });
1046810607 if std::env::var_os("EC_AV1_COMPIDX_DUMP").is_some() {
1046910608 eprintln!(
@@ -10482,8 +10621,8 @@ fn decode_inter_block(
1048210621 cdfs,
1048310622 above_nbr,
1048410623 left_nbr,
10485- neighbours.above_ref[c],
10486- neighbours.left_ref[r],
10624+ neighbours.above_ref[cmi],
10625+ neighbours.left_ref[rmi],
1048710626 )
1048810627 };
1048910628 let (mi_row, mi_col) = (r * SUB_MI as usize, c * SUB_MI as usize);
@@ -10599,17 +10738,17 @@ fn decode_inter_block(
1059910738 // real filter match down to the "no neighbour" sentinel
1060010739 // whenever the shared reference sits in the neighbour's SECOND
1060110740 // slot (lane-av1idx r2).
10602- let above_filter_ctx = if neighbours.above_ref[c] == ref0
10603- || neighbours.above_ref1[c] == Some(ref0)
10741+ let above_filter_ctx = if neighbours.above_ref[cmi] == ref0
10742+ || neighbours.above_ref1[cmi] == Some(ref0)
1060410743 {
10605- neighbours.above_filter[c]
10744+ neighbours.above_filter[cmi]
1060610745 } else {
1060710746 [3, 3]
1060810747 };
10609- let left_filter_ctx = if neighbours.left_ref[r] == ref0
10610- || neighbours.left_ref1[r] == Some(ref0)
10748+ let left_filter_ctx = if neighbours.left_ref[rmi] == ref0
10749+ || neighbours.left_ref1[rmi] == Some(ref0)
1061110750 {
10612- neighbours.left_filter[r]
10751+ neighbours.left_filter[rmi]
1061310752 } else {
1061410753 [3, 3]
1061510754 };
@@ -10655,7 +10794,7 @@ fn decode_inter_block(
1065510794 // there), so the gate reduces to the sequence header bit; kept
1065610795 // as an explicit call so a future smaller block size is not
1065710796 // silently wrong (libaom `reconinter.h::is_any_masked_compound_used`).
10658- let group_ctx = get_comp_group_idx_context(neighbours, at, side);
10797+ let group_ctx = get_comp_group_idx_context(neighbours, (rmi, cmi), side);
1065910798 let comp_group_idx = if !skip_mode
1066010799 && enable_masked_compound
1066110800 && is_any_masked_compound_used_here(side)
@@ -10683,7 +10822,17 @@ fn decode_inter_block(
1068310822 8 => 3,
1068410823 16 => 6,
1068510824 32 => 9,
10686- _ => unreachable!("decode_inter_block leaf side is 8/16/32"),
10825+ // lane-inter8 r1: `av1_is_wedge_used` is false at 64x64
10826+ // (`av1_wedge_params_lookup[BLOCK_64X64].wedge_types ==
10827+ // 0`), so a real encoder writes NO `compound_type` symbol
10828+ // there -- COMPOUND_DIFFWTD is inferred. Reading one
10829+ // would desync, so refuse by name rather than guess the
10830+ // inferred-DIFFWTD blend this round.
10831+ _ => {
10832+ return Err(unsupported(
10833+ "a masked compound 64x64 inter block (compound_type is inferred, not coded, at this size)",
10834+ ))
10835+ }
1068710836 };
1068810837 let compound_type = dec.symbol(&mut cdfs.compound_type[wedge_bsize]);
1068910838 if compound_type == 0 {
@@ -10909,7 +11058,7 @@ fn decode_inter_block(
1090911058 {
1091011059 let idx_ctx = get_comp_index_context(
1091111060 neighbours,
10912- at,
11061+ (rmi, cmi),
1091311062 side,
1091411063 order_hint_bits,
1091511064 order_hint,
@@ -11266,10 +11415,10 @@ fn decode_inter_block(
1126611415 read_single_ref(
1126711416 dec,
1126811417 cdfs,
11269- neighbours.above_ref[c],
11270- neighbours.above_ref1[c],
11271- neighbours.left_ref[r],
11272- neighbours.left_ref1[r],
11418+ neighbours.above_ref[cmi],
11419+ neighbours.above_ref1[cmi],
11420+ neighbours.left_ref[rmi],
11421+ neighbours.left_ref1[rmi],
1127311422 );
1127411423 ref_frame_for_lf = ref_frame;
1127511424 if std::env::var_os("EC_AV1_TELL").is_some() {
@@ -11643,17 +11792,17 @@ fn decode_inter_block(
1164311792 // lane-av1idx r2: also match on the neighbour's SECOND reference
1164411793 // (`above_ref1`/`left_ref1`, real for a compound neighbour) --
1164511794 // see the 16x16 leaf's own comment above for the spec citation.
11646- let above_filter_ctx = if neighbours.above_ref[c] == ref_frame
11647- || neighbours.above_ref1[c] == Some(ref_frame)
11795+ let above_filter_ctx = if neighbours.above_ref[cmi] == ref_frame
11796+ || neighbours.above_ref1[cmi] == Some(ref_frame)
1164811797 {
11649- neighbours.above_filter[c]
11798+ neighbours.above_filter[cmi]
1165011799 } else {
1165111800 [3, 3]
1165211801 };
11653- let left_filter_ctx = if neighbours.left_ref[r] == ref_frame
11654- || neighbours.left_ref1[r] == Some(ref_frame)
11802+ let left_filter_ctx = if neighbours.left_ref[rmi] == ref_frame
11803+ || neighbours.left_ref1[rmi] == Some(ref_frame)
1165511804 {
11656- neighbours.left_filter[r]
11805+ neighbours.left_filter[rmi]
1165711806 } else {
1165811807 [3, 3]
1165911808 };
@@ -12271,7 +12420,6 @@ fn decode_inter_block8(
1227112420 base_q_idx: u8,
1227212421 scan8: &[u16],
1227312422 scan4: &[u16],
12274- prev_leaf: Option<((usize, usize), bool, bool)>,
1227512423 allow_high_precision_mv: bool,
1227612424 force_integer_mv: bool,
1227712425 // lane-av1comp: see [`decode_inter_block`]'s own doc -- this leaf path
@@ -12291,7 +12439,7 @@ fn decode_inter_block8(
1229112439 // lane-av1comp round 14: see [`decode_inter_block`]'s own doc -- this
1229212440 // leaf has no per-leaf `above_skip_mode`/`left_skip_mode` array either,
1229312441 // so its `skip_mode` context reuses the same [`SUB`]-grid
12294- // `above_skip_mode[c]`/`left_skip_mode[r]` the enclosing 16x16 slot
12442+ // `above_skip_mode[cmi]`/`left_skip_mode[rmi]` the enclosing 16x16 slot
1229512443 // tracks (mirroring `above_skip`/`left_skip`'s own leaf approximation
1229612444 // just above).
1229712445 skip_mode_present: bool,
@@ -12319,8 +12467,34 @@ fn decode_inter_block8(
1231912467 // `BLOCK_8X8` (this leaf's fixed size) is always `av1_allow_palette`-
1232012468 // eligible (`bsize >= BLOCK_8X8`).
1232112469 allow_screen_content_tools: bool,
12322-) -> Result<(bool, bool, bool, Option<(i8, i8, u8, u8)>)> {
12470+ // lane-inter8 r1: the leaf's mv stacks used to be built with neither the
12471+ // frame's sign-bias table nor its global-motion mv table (`NO_SIGN_BIAS`
12472+ // / `NO_GM_MV`), while [`decode_inter_block`] one level up passed both.
12473+ // A neighbour coded GLOBALMV contributes the gm mv, so dropping the table
12474+ // changes the candidate list -- and with it `new_mv_ctx`/`ref_mv_ctx`,
12475+ // `drl_ctx` and the number of symbols read. Measured: an 8x8 compound
12476+ // NEAR_NEWMV leaf desynced against aomdec's EC_MODE ladder at exactly
12477+ // this block (mi 4,14 of the mandelbrot 8x8-split gate).
12478+ sign_bias_table: &SignBiasTable,
12479+ global_motion: &[ec_av1_syntax::WarpParams; 7],
12480+ // lane-inter8 r2: the frame's temporal mv field (spec 7.10.2.8), which
12481+ // [`decode_inter_block`] one level up has always passed and this leaf
12482+ // passed `None` for -- a `use_ref_frame_mvs` frame's stack then holds
12483+ // fewer candidates here than in the reference decoder, which changes the
12484+ // mode contexts AND the number of `drl_mode` bits read (class parsed
12485+ // then discarded).
12486+ tpl_frame: Option<&TplFrameArgs>,
12487+) -> Result<(bool, bool, bool, Option<(i8, i8, u8, u8)>, (i8, Option<i8>))> {
1232312488 const LAST_FRAME: i8 = 1;
12489+ let gm_table = build_gm_mv_table(
12490+ global_motion,
12491+ leaf_mi.0,
12492+ leaf_mi.1,
12493+ 2,
12494+ 2,
12495+ allow_high_precision_mv,
12496+ force_integer_mv,
12497+ );
1232412498 /// `Y_MODE`'s size group (`common_data.h`'s `size_group_lookup[BLOCK_8X8]`).
1232512499 const SIZE_GROUP_8: usize = 1;
1232612500
@@ -12330,21 +12504,26 @@ fn decode_inter_block8(
1233012504 const CHROMA_SIDE: usize = 4;
1233112505
1233212506 let (r, c) = outer_at;
12333- let mut above_skip = neighbours.above_skip[c];
12334- let mut left_skip = neighbours.left_skip[r];
12335- let mut above_inter = neighbours.above_inter[c];
12336- let mut left_inter = neighbours.left_inter[r];
12337- if let Some(((pr, pc), pskip, pinter)) = prev_leaf {
12338- if pc == leaf_mi.1 && leaf_mi.0 == pr + 2 {
12339- above_skip = pskip;
12340- above_inter = pinter;
12341- } else if pr == leaf_mi.0 && leaf_mi.1 == pc + 2 {
12342- left_skip = pskip;
12343- left_inter = pinter;
12344- }
12345- }
12507+ let _ = (r, c);
12508+ // lane-inter8 r2: this leaf's OWN mi cell, not the enclosing 16x16's --
12509+ // leaf (mi_r, mi_c + 2)'s left neighbour is leaf (mi_r, mi_c), and the
12510+ // left column of a 16x16's second leaf ROW is the previous 16x16 block's
12511+ // bottom leaf, neither of which a SUB-grid slot can name.
12512+ let (rmi, cmi) = leaf_mi;
12513+ // lane-inter8 r2: no sibling-leaf override any more -- each leaf stamps
12514+ // its own 2x2-mi span into the bands right after it decodes (the caller's
12515+ // `record_inter_rect_mi`), so a plain mi read already names the correct
12516+ // neighbour, including one belonging to the previous 16x16 block.
12517+ let above_skip = neighbours.above_skip[cmi];
12518+ let left_skip = neighbours.left_skip[rmi];
12519+ let above_inter = neighbours.above_inter[cmi];
12520+ let left_inter = neighbours.left_inter[rmi];
12521+ let above_ref0 = neighbours.above_ref[cmi];
12522+ let above_ref1 = neighbours.above_ref1[cmi];
12523+ let left_ref0 = neighbours.left_ref[rmi];
12524+ let left_ref1 = neighbours.left_ref1[rmi];
1234612525 let skip_mode_ctx =
12347- usize::from(neighbours.above_skip_mode[c]) + usize::from(neighbours.left_skip_mode[r]);
12526+ usize::from(neighbours.above_skip_mode[cmi]) + usize::from(neighbours.left_skip_mode[rmi]);
1234812527 // Same two `inter_segment_id` positions as [`decode_inter_block`]; this
1234912528 // leaf is always `BLOCK_8X8`, i.e. 2x2 mi.
1235012529 inter_segment_id(dec, cdfs, leaf_mi.0, leaf_mi.1, 2, 2, false, true);
@@ -12367,23 +12546,46 @@ fn decode_inter_block8(
1236712546 );
1236812547 let ii_ctx = intra_inter_ctx(has_above, has_left, above_inter, left_inter);
1236912548 let is_inter = skip_mode || dec.symbol(&mut cdfs.intra_inter[ii_ctx]) == 1;
12549+ // lane-inter8 r1: mirrors the oracle's `EC_MODE` (instrument rung 4,
12550+ // `read_inter_block_mode_info`) so an 8x8 leaf's mode-info range ladder
12551+ // diffs line for line against a real aomdec.
12552+ if std::env::var_os("EC_TRACE_MODE").is_some() {
12553+ eprintln!(
12554+ "EC_MODE mi_row={} mi_col={} rng={}",
12555+ leaf_mi.0,
12556+ leaf_mi.1,
12557+ dec.debug_state().0
12558+ );
12559+ }
1237012560
1237112561 let mode_for_tx;
1237212562 let (luma_grid, u_grid, v_grid);
1237312563 let mut compound_ctx8: Option<(i8, i8, u8, u8)> = None;
12564+ // lane-inter8 r1: this leaf's own resolved references, handed back so the
12565+ // NEXT leaf of the same 16x16 can use them as its real above/left
12566+ // neighbour (`Neighbours`' arrays only move once per 16x16 block).
12567+ // `(0, None)` is intra.
12568+ let mut leaf_refs: (i8, Option<i8>) = (0, None);
1237412569 if is_inter {
1237512570 if reference_select || skip_mode {
12571+ // lane-inter8 r1: the REAL neighbour references, not a
12572+ // `LAST_FRAME`-or-intra stand-in. `av1_get_reference_mode_context`
12573+ // and `read_compound_ref_frames`' own contexts both ask whether a
12574+ // neighbour is COMPOUND, so pretending every inter neighbour is
12575+ // single-ref LAST picked the wrong `comp_mode` CDF row -- measured
12576+ // as an 8x8 leaf reading single-ref where aomdec read compound
12577+ // NEAR_NEWMV (mi 4,14).
1237612578 let above_nbr = has_above.then(|| NeighbourRef {
1237712579 is_inter: above_inter,
12378- ref0: if above_inter { LAST_FRAME } else { 0 },
12379- ref1: None,
12380- uni: false,
12580+ ref0: if above_inter { above_ref0 } else { 0 },
12581+ ref1: above_ref1,
12582+ uni: above_ref1.is_some_and(|r1| is_uni_comp_ref(above_ref0, r1)),
1238112583 });
1238212584 let left_nbr = has_left.then(|| NeighbourRef {
1238312585 is_inter: left_inter,
12384- ref0: if left_inter { LAST_FRAME } else { 0 },
12385- ref1: None,
12386- uni: false,
12586+ ref0: if left_inter { left_ref0 } else { 0 },
12587+ ref1: left_ref1,
12588+ uni: left_ref1.is_some_and(|r1| is_uni_comp_ref(left_ref0, r1)),
1238712589 });
1238812590 if skip_mode || read_comp_mode(dec, cdfs, above_nbr, left_nbr) {
1238912591 let (ref0, ref1) = if skip_mode {
@@ -12406,7 +12608,24 @@ fn decode_inter_block8(
1240612608 },
1240712609 )
1240812610 };
12611+ leaf_refs = (ref0, Some(ref1));
1240912612 let (mi_row, mi_col) = leaf_mi;
12613+ // spec 7.10.2.8, mirroring [`decode_inter_block`]'s own
12614+ // `comp_tpl` build (`use_ref_frame_mvs` frames only).
12615+ let comp_tpl = tpl_frame.map(|t| crate::mvstack::CompoundTplArgs {
12616+ field: t.field,
12617+ cur_offset_0: crate::motion_field::get_relative_dist(
12618+ t.order_hint_bits,
12619+ t.order_hint,
12620+ t.ref_order_hints[(ref0 - LAST_FRAME) as usize],
12621+ ),
12622+ cur_offset_1: crate::motion_field::get_relative_dist(
12623+ t.order_hint_bits,
12624+ t.order_hint,
12625+ t.ref_order_hints[(ref1 - LAST_FRAME) as usize],
12626+ ),
12627+ allow_high_precision_mv,
12628+ });
1241012629 // lane-av1comp: this leaf path has neither a real sign-bias
1241112630 // table nor `tpl_frame` (see this function's own doc on the
1241212631 // coarse `LAST_FRAME`-or-intra neighbour approximation
@@ -12422,9 +12641,9 @@ fn decode_inter_block8(
1242212641 (ref0, ref1),
1242312642 mi_cols as usize,
1242412643 mi_rows as usize,
12425- &NO_SIGN_BIAS,
12426- &crate::mvstack::NO_GM_MV,
12427- None,
12644+ sign_bias_table,
12645+ &gm_table,
12646+ comp_tpl,
1242812647 );
1242912648 let compound_mode = if skip_mode {
1243012649 0 // NEAREST_NEARESTMV, forced -- no mode symbol read
@@ -12436,6 +12655,18 @@ fn decode_inter_block8(
1243612655 comp_stack.ref_mv_ctx,
1243712656 )
1243812657 };
12658+ if std::env::var_os("EC_TRACE_MODE").is_some() {
12659+ eprintln!(
12660+ "EC_LEAFMODE mi_row={} mi_col={} cmode={} stack={} newmv_ctx={} refmv_ctx={} rng={}",
12661+ leaf_mi.0,
12662+ leaf_mi.1,
12663+ compound_mode + 17,
12664+ comp_stack.entries.len(),
12665+ comp_stack.new_mv_ctx,
12666+ comp_stack.ref_mv_ctx,
12667+ dec.debug_state().0
12668+ );
12669+ }
1243912670 let (mv0, mv1) = assign_compound_mv(
1244012671 dec,
1244112672 cdfs,
@@ -12443,16 +12674,35 @@ fn decode_inter_block8(
1244312674 compound_mode,
1244412675 allow_high_precision_mv,
1244512676 force_integer_mv,
12446- // leaf8 stays gm-inert (sanctioned partial landing, see
12447- // this fn's own GLOBALMV refusal below).
12448- ((0, 0), (0, 0)),
12677+ // lane-inter8 r1: the real per-ref gm mvs, same as
12678+ // [`decode_inter_block`]'s own compound arm.
12679+ (
12680+ gm_table[(ref0 - LAST_FRAME) as usize],
12681+ gm_table[(ref1 - LAST_FRAME) as usize],
12682+ ),
1244912683 );
12684+ // lane-inter8 r3: byte-format-identical to the oracle's
12685+ // rung-4 `EC_MODE_VAL`, so the leaf's mode+mv VALUE ladder
12686+ // diffs line for line against a real aomdec.
12687+ if std::env::var_os("EC_TRACE_MODE").is_some() {
12688+ eprintln!(
12689+ "EC_MODE_VAL mi_row={} mi_col={} mode={} ref0={} ref1={} mv0=({},{}) rng={}",
12690+ leaf_mi.0,
12691+ leaf_mi.1,
12692+ compound_mode + 17,
12693+ ref0,
12694+ ref1,
12695+ mv0.0,
12696+ mv0.1,
12697+ dec.debug_state().0
12698+ );
12699+ }
1245012700
1245112701 // spec 5.11.25: same gating [`decode_inter_block`]'s own
1245212702 // compound arm uses, keyed off `outer_at`'s [`SUB`]-grid
1245312703 // slot -- the only granularity `Neighbours`' comp_group_idx/
1245412704 // compound_idx arrays track.
12455- let group_ctx = get_comp_group_idx_context(neighbours, outer_at, SIDE);
12705+ let group_ctx = get_comp_group_idx_context(neighbours, leaf_mi, SIDE);
1245612706 let comp_group_idx = if !skip_mode
1245712707 && enable_masked_compound
1245812708 && is_any_masked_compound_used_here(SIDE)
@@ -12506,7 +12756,7 @@ fn decode_inter_block8(
1250612756 {
1250712757 let idx_ctx = get_comp_index_context(
1250812758 neighbours,
12509- outer_at,
12759+ leaf_mi,
1251012760 SIDE,
1251112761 order_hint_bits,
1251212762 order_hint,
@@ -12776,9 +13026,21 @@ fn decode_inter_block8(
1277613026 )?
1277713027 .0;
1277813028 }
12779- return Ok((skip, is_inter, skip_mode, compound_ctx8));
12780- }
12781- }
13029+ // lane-inter8 r2: the COMPOUND leaf used to return here
13030+ // WITHOUT the end-of-function `record_mi`/`fill_lf_grid` the
13031+ // single-ref path falls through to -- so a compound 8x8 leaf
13032+ // left `above_side_mi`/`left_side_mi` (the next block's
13033+ // partition context), the per-plane coefficient level state
13034+ // and the loop-filter grid describing whatever block was
13035+ // there before. Every leaf of the gate's stream is compound,
13036+ // so the 16x16 below a split block read partition ctx 0
13037+ // instead of 1 and mis-read PARTITION_SPLIT as NONE.
13038+ neighbours.record_mi(leaf_mi, 8, &[luma_grid, u_grid, v_grid]);
13039+ neighbours.fill_lf_grid(leaf_mi, 2, 8, if is_inter { LAST_FRAME } else { 0 });
13040+ return Ok((skip, is_inter, skip_mode, compound_ctx8, leaf_refs));
13041+ }
13042+ }
13043+ leaf_refs = (LAST_FRAME, None);
1278213044 let sr_ctx = single_ref_ctx(above_inter || left_inter);
1278313045 let p1 = dec.symbol(&mut cdfs.single_ref[sr_ctx][0]);
1278413046 let p3 = dec.symbol(&mut cdfs.single_ref[sr_ctx][2]);
@@ -12790,7 +13052,16 @@ fn decode_inter_block8(
1279013052 }
1279113053
1279213054 let (mi_row, mi_col) = leaf_mi;
12793- let stack = find_mv_stack(
13055+ let tpl = tpl_frame.map(|t| crate::mvstack::TplArgs {
13056+ field: t.field,
13057+ cur_offset_0: crate::motion_field::get_relative_dist(
13058+ t.order_hint_bits,
13059+ t.order_hint,
13060+ t.ref_order_hints[(LAST_FRAME - LAST_FRAME) as usize],
13061+ ),
13062+ allow_high_precision_mv,
13063+ });
13064+ let stack = find_mv_stack_with_sign_bias(
1279413065 grid,
1279513066 mi_row,
1279613067 mi_col,
@@ -12799,6 +13070,9 @@ fn decode_inter_block8(
1279913070 LAST_FRAME,
1280013071 mi_cols as usize,
1280113072 mi_rows as usize,
13073+ sign_bias_table,
13074+ &gm_table,
13075+ tpl,
1280213076 );
1280313077
1280413078 let not_new = dec.symbol(&mut cdfs.new_mv[stack.new_mv_ctx]) == 1;
@@ -13275,7 +13549,7 @@ fn decode_inter_block8(
1327513549 }
1327613550 neighbours.record_mi(leaf_mi, 8, &[luma_grid, u_grid, v_grid]);
1327713551 neighbours.fill_lf_grid(leaf_mi, 2, 8, if is_inter { LAST_FRAME } else { 0 });
13278- Ok((skip, is_inter, skip_mode, compound_ctx8))
13552+ Ok((skip, is_inter, skip_mode, compound_ctx8, leaf_refs))
1327913553 }
1328013554
1328113555 /// Decodes the payload [`crate::tile::sb_coeff_inter_frame_tile`] writes,
@@ -13720,10 +13994,72 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
1372013994 }
1372113995 (false, false) => PARTITION_SPLIT,
1372213996 };
13997+ if part64 == PARTITION_NONE {
13998+ // lane-inter8 r1: the whole superblock as one 64x64 inter
13999+ // block. `SB`-sized syntax throughout (size_group 3, same as
14000+ // 32x32 -- `size_group_lookup[BLOCK_64X64] == 3`), luma
14001+ // coefficients through `TxbSet::Luma64` with the 32-point
14002+ // scan (TX_64X64 codes only its top-left corner, spec
14003+ // 5.11.40 -- `read_inter_plane` widens the corner back to
14004+ // 64x64 before the inverse transform), chroma as a plain
14005+ // 32x32 `TxbSet::Chroma32`. TX_64X64 carries no `tx_type`
14006+ // symbol at all, so the intra/inter luma sets coincide.
14007+ INTER_SB_NONE_HITS.with(|c| c.set(c.get() + 1));
14008+ decode_inter_block(
14009+ &mut dec,
14010+ &mut cdfs,
14011+ &mut neighbours,
14012+ &mut grid,
14013+ sb_at,
14014+ SB,
14015+ mi_cols,
14016+ mi_rows,
14017+ &mut y,
14018+ &mut u,
14019+ &mut v,
14020+ &ref_y,
14021+ &ref_u,
14022+ &ref_v,
14023+ &ref_slots,
14024+ &sign_bias_table,
14025+ &global_motion,
14026+ base_q_idx,
14027+ TxbSet::Luma64,
14028+ TxbSet::Luma64,
14029+ TxbSet::Chroma32,
14030+ TX32,
14031+ TX32,
14032+ &scan32,
14033+ &scan32,
14034+ 3,
14035+ allow_high_precision_mv,
14036+ force_integer_mv,
14037+ interp_fixed,
14038+ enable_dual_filter,
14039+ tpl_frame.as_ref(),
14040+ reference_select,
14041+ enable_masked_compound,
14042+ enable_interintra_compound,
14043+ enable_jnt_comp,
14044+ order_hint_bits,
14045+ order_hint,
14046+ ref_order_hints,
14047+ skip_mode_present,
14048+ skip_mode_frame,
14049+ switchable_motion_mode,
14050+ allow_warped_motion,
14051+ false,
14052+ SB,
14053+ SB,
14054+ allow_screen_content_tools,
14055+ frame_width as usize,
14056+ )?;
14057+ continue;
14058+ }
1372314059 if part64 != PARTITION_SPLIT {
1372414060 return Err(unsupported(
13725- "an inter SB-level partition type other than SPLIT (this decoder's \
13726- inter tile path only recurses a superblock as SPLIT)",
14061+ "an inter SB-level partition type other than NONE or SPLIT (this decoder's \
14062+ inter tile path recurses a superblock only as SPLIT)",
1372714063 ));
1372814064 }
1372914065
@@ -13838,14 +14174,39 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
1383814174 ));
1383914175 }
1384014176 let at16 = (sr, sc);
13841- if has_cols16 && has_rows16 {
13842- let ctx16 = neighbours.partition_ctx(at16, SUB);
13843- let part16 = dec.symbol(&mut cdfs.partition_w16[ctx16]);
13844- if part16 != PARTITION_NONE {
13845- return Err(unsupported(
13846- "an inter partition below 16x16 (8x8 and smaller inter blocks are not coded yet)",
14177+ let ctx16 = neighbours.partition_ctx(at16, SUB);
14178+ // lane-inter8 r1: a straddling 16x16 cannot name a
14179+ // value (spec forces SPLIT, one gathered bit); an
14180+ // interior one reads the real alphabet, and
14181+ // `PARTITION_SPLIT` now recurses into four 8x8
14182+ // inter leaves through the very same loop the
14183+ // straddling case has always used.
14184+ let part16 = if has_cols16 && has_rows16 {
14185+ let p = dec.symbol(&mut cdfs.partition_w16[ctx16]);
14186+ if std::env::var_os("EC_AV1_TRACE").is_some() {
14187+ let (rng, _) = dec.debug_state();
14188+ eprintln!(
14189+ "TRACE partition_w16 mi=({},{}) ctx={ctx16} value={p} rng={rng}",
14190+ sr as u32 * SUB_MI,
14191+ sc as u32 * SUB_MI
14192+ );
14193+ }
14194+ p
14195+ } else {
14196+ if has_cols16 {
14197+ dec.symbol_fixed(&gather(
14198+ &cdfs.partition_w16[ctx16],
14199+ VERT_ALIKE,
14200+ ));
14201+ } else {
14202+ dec.symbol_fixed(&gather(
14203+ &cdfs.partition_w16[ctx16],
14204+ HORZ_ALIKE,
1384714205 ));
1384814206 }
14207+ PARTITION_SPLIT
14208+ };
14209+ if part16 == PARTITION_NONE {
1384914210 decode_inter_block(
1385014211 &mut dec,
1385114212 &mut cdfs,
@@ -13899,18 +14260,13 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
1389914260 allow_screen_content_tools,
1390014261 frame_width as usize,
1390114262 )?;
14263+ } else if part16 != PARTITION_SPLIT {
14264+ return Err(unsupported(
14265+ "an inter partition below 16x16 other than SPLIT (16x8/8x16 rect inter leaves are not coded yet)",
14266+ ));
1390214267 } else {
13903- let ctx16 = neighbours.partition_ctx(at16, SUB);
13904- if has_cols16 {
13905- dec.symbol_fixed(&gather(
13906- &cdfs.partition_w16[ctx16],
13907- VERT_ALIKE,
13908- ));
13909- } else {
13910- dec.symbol_fixed(&gather(
13911- &cdfs.partition_w16[ctx16],
13912- HORZ_ALIKE,
13913- ));
14268+ if has_cols16 && has_rows16 {
14269+ INTER_SUB16_SPLIT_HITS.with(|c| c.set(c.get() + 1));
1391414270 }
1391514271 let (mi_row0, mi_col0) = (sr as u32 * SUB_MI, sc as u32 * SUB_MI);
1391614272 let leaf_positions: Vec<(u32, u32)> = (0..4)
@@ -13935,7 +14291,7 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
1393514291 "an 8x8 partition leaf under a scaled reference (superres, unimplemented)",
1393614292 ));
1393714293 }
13938- let mut prev_leaf: Option<((usize, usize), bool, bool)> = None;
14294+ let mut prev_leaves: Vec<((usize, usize), bool, bool, i8, Option<i8>)> = Vec::new();
1393914295 let mut last_compound_ctx: Option<(i8, i8, u8, u8)> = None;
1394014296 let mut last_skip_mode = false;
1394114297 for (mr, mc) in leaf_positions {
@@ -13947,7 +14303,7 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
1394714303 "a partition below 8x8 (this decoder codes no leaf smaller than 8x8)",
1394814304 ));
1394914305 }
13950- let (skip, is_inter, skip_mode_leaf, compound_ctx8) =
14306+ let (skip, is_inter, skip_mode_leaf, compound_ctx8, leaf_refs) =
1395114307 decode_inter_block8(
1395214308 &mut dec,
1395314309 &mut cdfs,
@@ -13967,7 +14323,6 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
1396714323 base_q_idx,
1396814324 &scan8,
1396914325 &scan4,
13970- prev_leaf,
1397114326 allow_high_precision_mv,
1397214327 force_integer_mv,
1397314328 reference_select,
@@ -13984,48 +14339,48 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
1398414339 switchable_motion_mode,
1398514340 allow_warped_motion,
1398614341 allow_screen_content_tools,
14342+ &sign_bias_table,
14343+ &global_motion,
14344+ tpl_frame.as_ref(),
1398714345 )?;
13988- prev_leaf = Some((leaf_mi, skip, is_inter));
14346+ prev_leaves.push((leaf_mi, skip, is_inter, leaf_refs.0, leaf_refs.1));
1398914347 last_skip_mode = skip_mode_leaf;
1399014348 if compound_ctx8.is_some() {
1399114349 last_compound_ctx = compound_ctx8;
1399214350 }
13993- }
13994- if let Some((_, skip, is_inter)) = prev_leaf {
13995- // corner-cut: `decode_inter_block8`'s
13996- // leaves never read a switchable filter
13997- // (round-3 GLOBALMV refusal already
13998- // bounds them away from the Regular-only
13999- // gap this round closes elsewhere); `[3,
14000- // 3]` is "no info", the same value an
14001- // intra neighbour records. Upgrade:
14002- // thread `interp_fixed`/`enable_dual_filter`
14003- // into `decode_inter_block8` once a
14004- // straddling 8x8 SWITCHABLE stream is on
14005- // hand to pin against.
14006- neighbours.record_inter(
14007- at16,
14008- SUB,
14351+ // lane-inter8 r2: stamp THIS leaf's own
14352+ // 2x2-mi span before the next leaf reads
14353+ // it as a neighbour -- the whole-16x16
14354+ // stamp below only ever described the
14355+ // last leaf, so three quarters of the
14356+ // block carried the wrong skip/ref/inter
14357+ // state into the next block's contexts
14358+ // (class context-read-from-one-cell).
14359+ // corner-cut: `[3, 3]` filter, as the
14360+ // 16x16 stamp used -- `decode_inter_block8`
14361+ // reads no switchable filter yet.
14362+ neighbours.record_inter_rect_mi(
14363+ leaf_mi,
14364+ 2,
14365+ 2,
1400914366 skip,
1401014367 is_inter,
14011- if is_inter { LAST_FRAME } else { -1 },
14368+ leaf_refs.0,
1401214369 [3, 3],
14013- last_skip_mode,
14370+ skip_mode_leaf,
1401414371 );
14015- if let Some((ref0, ref1, group_idx, idx)) = last_compound_ctx {
14016- neighbours.record_inter(
14017- at16,
14018- SUB,
14019- skip,
14020- is_inter,
14021- ref0,
14022- [3, 3],
14023- last_skip_mode,
14372+ if let Some(ref1) = leaf_refs.1
14373+ && let Some((_, _, group_idx, idx)) = compound_ctx8
14374+ {
14375+ neighbours.record_compound_ctx_rect_mi(
14376+ leaf_mi, 2, 2, ref1, group_idx, idx,
1402414377 );
14025- neighbours
14026- .record_compound_ctx(at16, SUB, ref1, group_idx, idx);
1402714378 }
1402814379 }
14380+ // lane-inter8 r2: the four per-leaf
14381+ // `record_inter_rect_mi` stamps above replace
14382+ // the single whole-16x16 one that used to run
14383+ // here with the LAST leaf's state.
1402914384 }
1403014385 }
1403114386 }
crates/ec-av1/src/refusal_inventory.rsmodified+3 -2
@@ -67,8 +67,9 @@ const REFUSALS: &[&str] = &[
6767 "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)",
6868 "an inter frame whose global motion for a single-reference frame is AFFINE (unverified this round; ROTZOOM/TRANSLATION/IDENTITY are proven)",
6969 "an inter frame with no key frame before it",
70- "an inter SB-level partition type other than SPLIT (this decoder's inter tile path only recurses a superblock as SPLIT)",
71- "an inter partition below 16x16 (8x8 and smaller inter blocks are not coded yet)",
70+ "an inter SB-level partition type other than NONE or SPLIT (this decoder's inter tile path recurses a superblock only as SPLIT)",
71+ "a masked compound 64x64 inter block (compound_type is inferred, not coded, at this size)",
72+ "an inter partition below 16x16 other than SPLIT (16x8/8x16 rect inter leaves are not coded yet)",
7273 "an intra mode this decoder does not code (round 2)",
7374 "an intra-coded HORZ/VERT strip needs rectangular intra prediction this decoder does not code yet",
7475 "filter intra on a HORZ/VERT strip (this decoder predicts square-only)",
crates/ec-av1/src/stream.rsmodified+269 -0
@@ -3849,6 +3849,275 @@ mod tests {
38493849 /// single-`LAST_FRAME` P frame (no alt-ref/backward reference this
38503850 /// decoder's inter path does not model), `--kf-max-dist` past the clip's
38513851 /// own length keeps frame 0 the only key frame.
3852+ /// lane-inter8 r1: the inter tile path's SB-level `PARTITION_NONE` -- a
3853+ /// whole 64x64 superblock coded as ONE inter block, which is what aomenc
3854+ /// picks for static content and which this decoder refused by name
3855+ /// ("an inter SB-level partition type other than SPLIT") until this
3856+ /// round. HARD-asserts [`decode::inter_sb_none_hits`] moved (the arm
3857+ /// really fired, class refusal-lifted-without-a-gate) and every frame is
3858+ /// pixel-exact vs ffmpeg; a decode error is a FAILURE here, never a SKIP
3859+ /// (class gate-skips-on-its-own-failure).
3860+ /// lane-inter8 r1: generalised so the same recipe can target a deeper
3861+ /// level of the inter partition tree -- `min_part` is aomenc's
3862+ /// `--min-partition-size`, and `hits`/`what` name the counter that proves
3863+ /// the arm under test really fired.
3864+ fn inter_sb_none_gate(
3865+ name: &str,
3866+ ten_bit: bool,
3867+ min_part: &str,
3868+ max_part: &str,
3869+ hits: fn() -> usize,
3870+ what: &str,
3871+ // lane-inter8 r3: extra aomenc flags + the frame width they need.
3872+ // `--tile-columns=1` needs a frame at least two superblocks wide or
3873+ // aomenc silently codes one tile column and the arm is vacuous.
3874+ extra: &[&str],
3875+ width: usize,
3876+ ) {
3877+ if !have_ffmpeg() {
3878+ eprintln!("SKIP {name}: no ffmpeg");
3879+ return;
3880+ }
3881+ if !have_aomenc() {
3882+ eprintln!("SKIP {name}: no aomenc at {}", aomenc_path().display());
3883+ return;
3884+ }
3885+ let (height, frame_count) = (64usize, 4usize);
3886+ // A deterministic synthetic source with real motion (a static source
3887+ // codes every inter frame as skip and never exercises the residual
3888+ // path); bounded with `-t` (class gate-loader-slurps-whole-file).
3889+ let y4m = Command::new("ffmpeg")
3890+ .args([
3891+ "-v",
3892+ "error",
3893+ "-f",
3894+ "lavfi",
3895+ "-i",
3896+ &format!("mandelbrot=size={width}x{height}:rate=25"),
3897+ "-t",
3898+ "0.16",
3899+ "-pix_fmt",
3900+ if ten_bit { "yuv420p10le" } else { "yuv420p" },
3901+ // y4m calls 10-bit unofficial (same as the 10-bit key-frame
3902+ // gate's own fixture).
3903+ "-strict",
3904+ "-1",
3905+ "-f",
3906+ "yuv4mpegpipe",
3907+ "-",
3908+ ])
3909+ .stdin(Stdio::null())
3910+ .stdout(Stdio::piped())
3911+ .stderr(Stdio::piped())
3912+ .output()
3913+ .expect("ffmpeg failed to run");
3914+ assert!(
3915+ y4m.status.success(),
3916+ "{name}: ffmpeg fixture: {}",
3917+ String::from_utf8_lossy(&y4m.stderr)
3918+ );
3919+ let mut args: Vec<String> = [
3920+ "--codec=av1",
3921+ "--passes=1",
3922+ "--end-usage=q",
3923+ "--cq-level=40",
3924+ "--cpu-used=0",
3925+ "--lag-in-frames=0",
3926+ "--auto-alt-ref=0",
3927+ "--kf-max-dist=1000",
3928+ // No cross-frame CDF forwarding in this fixture (see the
3929+ // deblocking gate's own note).
3930+ "--error-resilient=1",
3931+ // This gate targets the SB-level NONE arm only: rect/AB/1-to-4
3932+ // partitions and sub-16x16 splits stay off so a failure here
3933+ // cannot be another lane's missing arm.
3934+ "--enable-rect-partitions=0",
3935+ "--enable-ab-partitions=0",
3936+ "--enable-1to4-partitions=0",
3937+ "--enable-filter-intra=0",
3938+ "--enable-smooth-intra=0",
3939+ "--enable-paeth-intra=0",
3940+ "--enable-directional-intra=0",
3941+ "--enable-angle-delta=0",
3942+ "--enable-tx-size-search=0",
3943+ "--enable-cdef=0",
3944+ "--enable-restoration=0",
3945+ "--enable-palette=0",
3946+ "--enable-intrabc=0",
3947+ "--enable-cfl-intra=0",
3948+ "--enable-ref-frame-mvs=0",
3949+ "--obu",
3950+ "-o",
3951+ "-",
3952+ "-",
3953+ ]
3954+ .iter()
3955+ .map(|s| (*s).to_string())
3956+ .collect();
3957+ for e in extra {
3958+ args.insert(1, (*e).to_string());
3959+ }
3960+ args.insert(1, format!("--min-partition-size={min_part}"));
3961+ args.insert(1, format!("--max-partition-size={max_part}"));
3962+ if ten_bit {
3963+ args.insert(1, "--input-bit-depth=10".to_string());
3964+ args.insert(1, "--bit-depth=10".to_string());
3965+ }
3966+ let mut child = Command::new(aomenc_path())
3967+ .args(&args)
3968+ .stdin(Stdio::piped())
3969+ .stdout(Stdio::piped())
3970+ .stderr(Stdio::piped())
3971+ .spawn()
3972+ .expect("aomenc failed to start");
3973+ child
3974+ .stdin
3975+ .take()
3976+ .expect("aomenc stdin")
3977+ .write_all(&y4m.stdout)
3978+ .expect("writing y4m to aomenc");
3979+ let out = child.wait_with_output().expect("aomenc failed to run");
3980+ assert!(
3981+ out.status.success(),
3982+ "{name}: aomenc refused the fixture: {}",
3983+ String::from_utf8_lossy(&out.stderr)
3984+ );
3985+ let stream = out.stdout;
3986+ let before = hits();
3987+ let frames = match decode_stream(&stream) {
3988+ Ok(frames) => frames,
3989+ Err(e) => {
3990+ let pin = std::env::temp_dir().join(format!("{name}-refused.obu"));
3991+ let _ = std::fs::write(&pin, &stream);
3992+ panic!("{name}: decode_stream refused a real aomenc stream: {e} (pinned at {})", pin.display());
3993+ }
3994+ };
3995+ assert!(
3996+ hits() > before,
3997+ "{name}: no {what} fired -- this gate proves nothing"
3998+ );
3999+ let ffmpeg_frames = if ten_bit {
4000+ ffmpeg_decode_sequence_10bit(&stream, width, height, frame_count)
4001+ } else {
4002+ ffmpeg_decode_sequence(&stream, width, height, frame_count)
4003+ };
4004+ assert_eq!(frames.len(), frame_count, "{name}: frame count");
4005+ for (i, (got, want)) in frames.iter().zip(&ffmpeg_frames).enumerate() {
4006+ if got.y != want.y || got.u != want.u || got.v != want.v {
4007+ let pin = std::env::temp_dir().join(format!("{name}-mismatch.obu"));
4008+ let _ = std::fs::write(&pin, &stream);
4009+ panic!("{name}: frame {i} mismatch vs ffmpeg -- stream pinned at {}", pin.display());
4010+ }
4011+ }
4012+ }
4013+
4014+ #[test]
4015+ fn a_real_aomenc_inter_sequence_with_a_whole_superblock_block_decodes_pixel_exact() {
4016+ inter_sb_none_gate(
4017+ "a_real_aomenc_inter_sequence_with_a_whole_superblock_block_decodes_pixel_exact",
4018+ false,
4019+ "32",
4020+ "64",
4021+ decode::inter_sb_none_hits,
4022+ "whole-superblock inter PARTITION_NONE",
4023+ &[],
4024+ 64,
4025+ );
4026+ }
4027+
4028+ #[test]
4029+ fn a_real_aomenc_10bit_inter_sequence_with_a_whole_superblock_block_decodes_pixel_exact() {
4030+ inter_sb_none_gate(
4031+ "a_real_aomenc_10bit_inter_sequence_with_a_whole_superblock_block_decodes_pixel_exact",
4032+ true,
4033+ "32",
4034+ "64",
4035+ decode::inter_sb_none_hits,
4036+ "whole-superblock inter PARTITION_NONE",
4037+ &[],
4038+ 64,
4039+ );
4040+ }
4041+
4042+ /// lane-inter8 r1: the same recipe with `--min-partition-size=8`, so
4043+ /// aomenc's RD may split a 16x16 inter block into four 8x8 leaves. The
4044+ /// interior (non-edge-straddling) `PARTITION_SPLIT` at the 16x16 level
4045+ /// was refused by name until this round; the straddle path always ran the
4046+ /// same loop, so only [`decode::inter_sub16_split_hits`] -- which counts
4047+ /// interior splits only -- proves the newly-lifted alphabet value fired.
4048+ // lane-inter8 r2: GREEN. The neighbour side bands are mi-granular, every
4049+ // leaf stamps its own 2x2-mi span (including the compound-return path
4050+ // that used to skip `record_mi` entirely) and the compound
4051+ // group/index contexts read the LEAF's mi cell, not its 16x16's corner.
4052+ /// lane-inter8 r3, from lane-sub8's verifier finding: the mi-granular
4053+ /// inter neighbour bands added in r2 must reset per TILE (above) and per
4054+ /// SB row (left) and guard availability tile-relative, so the same recipe
4055+ /// runs again at 128x64 with two tile columns -- a leaf on the second
4056+ /// tile's first column has no left neighbour and must not read the first
4057+ /// tile's band.
4058+ // lane-inter8 r3: RED for a reason OUTSIDE this lane -- at 128x64 (the
4059+ // narrowest frame two tile columns can exist in) aomenc codes an
4060+ // SB-level rect partition on the KEY frame despite
4061+ // --enable-rect-partitions=0, so the stream stops at "a superblock-level
4062+ // partition type other than NONE or SPLIT" (lane-sbpart's arm) before a
4063+ // single 8x8 leaf is reached. The tile-relative audit it was written for
4064+ // was done by inspection instead: every reader of the mi bands guards on
4065+ // `tile_row0_mi`/`tile_col0_mi` (no `> 0` guard exists in decode.rs),
4066+ // `start_tile` resets the above mi bands over the tile's own mi column
4067+ // span and `start_row` resets every left mi band.
4068+ #[ignore = "lane-inter8 r3: blocked by the SB-level rect-partition refusal at 128x64 (lane-sbpart's arm), not by tile context"]
4069+ #[test]
4070+ fn a_real_aomenc_inter_sequence_with_an_8x8_leaf_split_across_tile_columns_decodes_pixel_exact()
4071+ {
4072+ inter_sb_none_gate(
4073+ "a_real_aomenc_inter_sequence_with_an_8x8_leaf_split_across_tile_columns_decodes_pixel_exact",
4074+ false,
4075+ "8",
4076+ "16",
4077+ decode::inter_sub16_split_hits,
4078+ "interior 16x16 inter PARTITION_SPLIT into 8x8 leaves",
4079+ &["--tile-columns=1"],
4080+ 128,
4081+ );
4082+ }
4083+
4084+ #[test]
4085+ fn a_real_aomenc_inter_sequence_with_an_8x8_leaf_split_decodes_pixel_exact() {
4086+ inter_sb_none_gate(
4087+ "a_real_aomenc_inter_sequence_with_an_8x8_leaf_split_decodes_pixel_exact",
4088+ false,
4089+ "8",
4090+ "16",
4091+ decode::inter_sub16_split_hits,
4092+ "interior 16x16 inter PARTITION_SPLIT into 8x8 leaves",
4093+ &[],
4094+ 64,
4095+ );
4096+ }
4097+
4098+ #[test]
4099+ // lane-inter8 r2: still RED, and ignored rather than deleted -- the 8-bit
4100+ // twin above is green, this 10-bit recipe stops at "an INTER 32x32
4101+ // partition type this decoder does not code (value=9)". That is OUR
4102+ // desync, proven: `EC_TRACE=1 aomdec` on the pinned stream reads
4103+ // 16 `bsize=9 value=3` (SPLIT) partitions and never a single value=9
4104+ // anywhere (class refusal-from-own-desync; the r1 ledger line claiming
4105+ // aomenc emits PARTITION_VERT_4 despite --enable-1to4-partitions=0 is
4106+ // hereby disproven). The divergence itself is not yet bisected.
4107+ #[ignore = "lane-inter8 r2: 10-bit twin still desyncs (surfaces as a bogus 32x32 value=9 refusal); 8-bit gate is green"]
4108+ fn a_real_aomenc_10bit_inter_sequence_with_an_8x8_leaf_split_decodes_pixel_exact() {
4109+ inter_sb_none_gate(
4110+ "a_real_aomenc_10bit_inter_sequence_with_an_8x8_leaf_split_decodes_pixel_exact",
4111+ true,
4112+ "8",
4113+ "16",
4114+ decode::inter_sub16_split_hits,
4115+ "interior 16x16 inter PARTITION_SPLIT into 8x8 leaves",
4116+ &[],
4117+ 64,
4118+ );
4119+ }
4120+
38524121 #[test]
38534122 fn a_real_aomenc_inter_sequence_with_deblocking_decodes_pixel_exact() {
38544123 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.
lanes/inter8-r2.report.mdadded+88 -0
@@ -0,0 +1,88 @@
1+# lane-inter8 r2 -- mi-granular inter neighbour bands; the 8-bit 8x8-split gate is GREEN
2+
3+Branch `lane-inter8`, commit `ae69b25` on top of r1's `b2231a9` (off main `3808cf8`,
4+not rebased -- the orchestrator merges).
5+
6+## What changed (`crates/ec-av1/src/decode.rs`, `crates/ec-av1/src/stream.rs`)
7+
8+1. **`Neighbours`' inter side bands are mi(4px)-granular** (`decode.rs` ~1910 `new`,
9+ ~1975 `start_tile`, `record_inter_rect` -> new `record_inter_rect_mi` ~2300,
10+ `record_compound_ctx_rect` -> `record_compound_ctx_rect_mi` ~2389; every reader
11+ now indexes `[cmi]`/`[rmi]`). Fields: `above/left_skip`, `_skip_mode`, `_inter`,
12+ `_ref`, `_ref1`, `_comp_group_idx`, `_compound_idx`, `_filter`. The SUB-unit
13+ wrappers stay, so every 16x16+ caller reads exactly what it read before (a
14+ SUB-aligned block's mi corner is libaom's `above_mbmi = mi(mi_row-1, mi_col)`).
15+ r1's `prev_leaves` sibling-override is deleted: each leaf stamps its own 2x2-mi
16+ span in the caller loop (`decode.rs` ~12664) right after it decodes, so a leaf's
17+ left neighbour can now be the *previous 16x16 block's* bottom leaf.
18+2. **The compound arm of `decode_inter_block8` returned before its own
19+ `record_mi`/`fill_lf_grid`** (`decode.rs` ~11353). The single-ref arm falls
20+ through to them at the end of the function; the compound arm did not. Every leaf
21+ of the gate's stream is compound (LAST+ALTREF), so a split 16x16 left
22+ `above_side_mi` at 16 and the *next* block's coefficient level state and lf grid
23+ describing whatever block was there before. Consequence: the 16x16 at mi(8,12)
24+ computed partition ctx **0** where aomdec had **1** and read `PARTITION_NONE`
25+ where the stream coded `PARTITION_SPLIT`.
26+3. **`get_comp_group_idx_context` / `get_comp_index_context` took the leaf's
27+ ENCLOSING 16x16 corner** (`outer_at`). Both now take mi coordinates
28+ (`decode.rs` ~8558/~8572) and the leaf passes `leaf_mi`; `decode_inter_block`
29+ passes its own `(rmi, cmi)`. This was the last divergence (block mi(8,14)).
30+4. `tpl_frame` threaded into the leaf's two mv stacks (`decode_inter_block8` new
31+ last param + `comp_tpl`/`tpl` builds mirroring `decode_inter_block`). Alignment
32+ only -- **it did not move this stream's ladder** (no `use_ref_frame_mvs` here);
33+ kept because passing `None` while the level above passes the field is a real
34+ parsed-then-discarded gap.
35+
36+All three of 1-3 are class `context-read-from-one-cell`.
37+
38+## Gate
39+
40+ cd <worktree>; export CARGO_TARGET_DIR=$HOME/.cache/cargo-target-inter8 EC_AV1_REQUIRE_AOMENC=1
41+ cargo test -p ec-av1 --lib -- an_8x8_leaf_split
42+
43+`a_real_aomenc_inter_sequence_with_an_8x8_leaf_split_decodes_pixel_exact` **ok**
44+(un-ignored). It hard-asserts `decode::inter_sub16_split_hits` advanced (interior
45+16x16 `PARTITION_SPLIT` fired) and every one of the 4 frames pixel-exact vs ffmpeg;
46+a refusal or a mismatch panics, it never SKIPs.
47+
48+EVIDENCE: /tmp/r2-fix.obu (aomenc mandelbrot 64x64 4 frames cq40 cpu0 --min-partition-size=8 --max-partition-size=16, rect/AB/1to4 off) | ours EC_TRACE_MODE vs instrumented aomdec EC_TRACE_MODE, `EC_MODE` ladders diffed line for line | inter mode-info range ladder 42/57 (r1) -> 48/57 (bands mi-granular) -> 50/57 (compound-arm record) -> **57/57**, and the gate decodes 4/4 frames pixel-exact
49+EVIDENCE: /tmp/orc_r2.txt (aomdec EC_TRACE=1 EC_TRACE_MODE=1 on the same stream) | `EC_PART mi_row=8 mi_col=12 bsize=6 ctx=5 rng=38329` / `EC_PART_VAL ... value=3` vs our `TRACE partition_w16 mi=(8,12) ctx=0 value=0` before fix 2 | partition context 0 vs 1 at the block below a split 16x16 -- the stale `above_side_mi`
50+EVIDENCE: /tmp/orc10.txt (aomdec EC_TRACE=1 on the 10-bit pinned stream) | `grep EC_PART_VAL | uniq -c` | 16 `bsize=9 value=3`, **zero** `value=9` anywhere in the stream
51+
52+## Test totals
53+
54+`EC_AV1_REQUIRE_AOMENC=1 cargo test -p ec-av1 --lib` -> **270 passed, 0 failed,
55+24 ignored** (1100 s). `refusal_inventory` and `gate_coverage` green; neither
56+needed an edit -- r1 already listed the narrowed string, and no gate recipe flag
57+changed.
58+
59+## Refusals
60+
61+- No new narrowing this round. r1's narrowing
62+ `"an inter partition below 16x16 other than SPLIT (16x8/8x16 rect inter leaves are not coded yet)"`
63+ is now **backed by a green gate** (it was not at r1), which is what this round owed.
64+- Disproved, not a refusal change: the r1 ledger dead-end
65+ `"aomenc emits PARTITION_VERT_4 (value=9) at 32x32 even with --enable-1to4-partitions=0"`
66+ is wrong. `EC_TRACE=1 aomdec` on the very stream that produced it reads no
67+ `value=9` at any bsize. Class `refusal-from-own-desync`.
68+
69+## Open residue
70+
71+- fix-now(next round): the **10-bit twin** `a_real_aomenc_10bit_inter_sequence_with_an_8x8_leaf_split_decodes_pixel_exact`
72+ stays `#[ignore]`d with the corrected reason. It refuses with "an INTER 32x32
73+ partition type this decoder does not code (value=9)", which the oracle trace above
74+ proves is our own desync, not the encoder. Not bisected: start by diffing the
75+ `EC_MODE` ladder of `/tmp/a_real_aomenc_10bit_..._-refused.obu` against
76+ `EC_TRACE_MODE=1 aomdec`, exactly as this round did for 8-bit.
77+- deferred(lane-gmaffine merge): the per-leaf stamp records `[3, 3]` ("no info") for
78+ the leaf's interp filter, as r1's whole-16x16 stamp did. lane-gmaffine `65ef3f5`
79+ makes `decode_inter_block8` read and hand back its real filter symbols; at merge,
80+ that value goes into the `record_inter_rect_mi(leaf_mi, 2, 2, ..., [3, 3], ...)`
81+ call at `decode.rs` ~12664. **Merge warning**: lane-gmaffine rewrites large parts
82+ of the same `decode_inter_block8` (GLOBALMV/WARPED_CAUSAL/non-LAST refs/interp
83+ filter); this branch's leaf edits are the neighbour/context plumbing only, but the
84+ two WILL conflict textually in that function.
85+- deferred(unstarted): 8x8 HORZ/VERT -> 8x4/4x8 leaves, rect inter leaves at
86+ 16x8/8x16, AB/1-to-4 at every level, and the per-type-per-level aggregate
87+ hit-counter gate.
88+- accepted: `tpl_frame` in the leaf stacks is unmeasured on this stream (item 4).