forge
Explore
Log in

Don't you dare go Hollow

Merge lane-uv8 6223830 into lane-leaf8tx: 8x8 intra-in-inter leaf tx_type alphabet + 4 lane merges

Browse files at this commit

ca1ea8645e1ec7814c941473e4a0523000ddf7a6Ahmet Kaan GümüşParent: b6adf58564bd72
Conflict in stream.rs was two appended test fns; kept both sides.

23 changed files +4085 -252

crates/ec-av1/examples/decode_probe.rsmodified+3 -0
@@ -35,6 +35,9 @@ fn main() {
35 println!("rect4_32: horz={h} vert={v} coded={c}");35 println!("rect4_32: horz={h} vert={v} coded={c}");
36 let (rtu, rsplit, robmc) = ec_av1::stream::rect_inter_tu_counters();36 let (rtu, rsplit, robmc) = ec_av1::stream::rect_inter_tu_counters();
37 println!("rect_inter: tu={rtu} txsplit={rsplit} obmc_leaf={robmc}");37 println!("rect_inter: tu={rtu} txsplit={rsplit} obmc_leaf={robmc}");
38+ println!("sub8_inter_split: groups={}", ec_av1::decode::sub8_inter_split_hits());
39+ let (h84, h48) = ec_av1::decode::sub8_inter_rect_hits();
40+ println!("sub8_inter_rect: horz8x4={h84} vert4x8={h48}");
38 let leaf = ec_av1::stream::vartx_rect_leaf_hits();41 let leaf = ec_av1::stream::vartx_rect_leaf_hits();
39 println!("vartx_rect_leaf: 32x16={} 16x32={}", leaf[0], leaf[1]);42 println!("vartx_rect_leaf: 32x16={} 16x32={}", leaf[0], leaf[1]);
40 // lane-inter16ab r1: the 16x16-level inter AB arms, so a recipe sweep43 // lane-inter16ab r1: the 16x16-level inter AB arms, so a recipe sweep
crates/ec-av1/src/cdf_state.rsmodified+40 -0
@@ -230,6 +230,22 @@ pub(crate) enum TxbSet {
230 /// counterpart: `EXT_TX_SET_DTT4_IDTX_1DDCT`, the seven-symbol `TX_4X4`230 /// counterpart: `EXT_TX_SET_DTT4_IDTX_1DDCT`, the seven-symbol `TX_4X4`
231 /// row [`LumaRect4x8Set1`](TxbSet::LumaRect4x8Set1) reads.231 /// row [`LumaRect4x8Set1`](TxbSet::LumaRect4x8Set1) reads.
232 LumaRect16x4Set1,232 LumaRect16x4Set1,
233+ /// The luma 8x4/4x8 transform of an INTER `PARTITION_HORZ`/`PARTITION_VERT`
234+ /// leaf under an 8x8 block (lane-intersub8 r3): every coefficient table is
235+ /// [`LumaRect4x8`](TxbSet::LumaRect4x8)'s (`get_txsize_entropy_ctx` squares
236+ /// `TX_8X4` up to the 8x8 class, 32-position `eob_pt`), with the INTER
237+ /// `tx_type` alphabet in its place. Under `reduced_tx_set`
238+ /// `av1_get_ext_tx_set_type` (`tx_size_sqr_up == TX_8X8`, `is_inter`)
239+ /// returns `EXT_TX_SET_DCT_IDTX`, whose row is
240+ /// `default_inter_ext_tx_cdf[?][txsize_sqr_map[TX_8X4] == TX_4X4]` -- the
241+ /// same `TX_4X4` inter row [`Luma4Inter`](TxbSet::Luma4Inter) reads.
242+ LumaRect8x4Inter,
243+ /// [`LumaRect8x4Inter`](TxbSet::LumaRect8x4Inter)'s `reduced_tx_set: false`
244+ /// counterpart: `tx_size_sqr == TX_4X4` with `tx_size_sqr_up == TX_8X8`, so
245+ /// `av1_ext_tx_set_lookup[is_inter=1][...]` is `EXT_TX_SET_ALL16` -- sixteen
246+ /// symbols at the `TX_4X4` inter row, the table
247+ /// [`Luma4InterSet1`](TxbSet::Luma4InterSet1) also reads.
248+ LumaRect8x4InterSet1,
233 }249 }
234 250
235 /// The tables one transform block is coded with, borrowed from the state for251 /// The tables one transform block is coded with, borrowed from the state for
@@ -1792,6 +1808,30 @@ impl Cdfs {
1792 tx_type: Some(self.intra_tx_type_4[mode].as_mut_slice()),1808 tx_type: Some(self.intra_tx_type_4[mode].as_mut_slice()),
1793 eob_pt_class1: Some(&mut self.eob_pt_32_luma_class1),1809 eob_pt_class1: Some(&mut self.eob_pt_32_luma_class1),
1794 },1810 },
1811+ TxbSet::LumaRect8x4Inter => TxbTables {
1812+ side: 8,
1813+ txb_skip: &mut self.txb_skip_luma_8,
1814+ eob_pt: &mut self.eob_pt_32_luma,
1815+ eob_extra: &mut self.eob_extra_luma_8,
1816+ base: &mut self.base_luma_8,
1817+ base_eob: &mut self.base_eob_luma_8,
1818+ br: &mut self.br_luma_8,
1819+ dc_sign: &mut self.dc_sign_luma,
1820+ tx_type: Some(self.inter_tx_type_4.as_mut_slice()),
1821+ eob_pt_class1: Some(&mut self.eob_pt_32_luma_class1),
1822+ },
1823+ TxbSet::LumaRect8x4InterSet1 => TxbTables {
1824+ side: 8,
1825+ txb_skip: &mut self.txb_skip_luma_8,
1826+ eob_pt: &mut self.eob_pt_32_luma,
1827+ eob_extra: &mut self.eob_extra_luma_8,
1828+ base: &mut self.base_luma_8,
1829+ base_eob: &mut self.base_eob_luma_8,
1830+ br: &mut self.br_luma_8,
1831+ dc_sign: &mut self.dc_sign_luma,
1832+ tx_type: Some(self.inter_tx_type_4_set1.as_mut_slice()),
1833+ eob_pt_class1: Some(&mut self.eob_pt_32_luma_class1),
1834+ },
1795 TxbSet::LumaRect4x8Set1 => TxbTables {1835 TxbSet::LumaRect4x8Set1 => TxbTables {
1796 side: 8,1836 side: 8,
1797 txb_skip: &mut self.txb_skip_luma_8,1837 txb_skip: &mut self.txb_skip_luma_8,
crates/ec-av1/src/decode.rsmodified+1841 -230

Diff too large; view file

@@ -171,6 +171,26 @@ pub(crate) fn intra_in_inter_angle_delta_uv_hits() -> usize {
171 INTRA_IN_INTER_ANGLE_DELTA_UV_HITS.with(|c| c.get())171 INTRA_IN_INTER_ANGLE_DELTA_UV_HITS.with(|c| c.get())
172 }172 }
173 173
174+// lane-uv8 r1: the three non-DC chroma mode classes an INTRA 8x8 leaf inside
175+// an INTER frame ([`decode_inter_block8`]'s intra arm) can carry -- the arm
176+// read `uv_mode` and then refused everything but `DC_PRED`. Counted here and
177+// nowhere else so the gate's assert cannot be satisfied by a >=16x16 block.
178+thread_local! {
179+ static INTRA_IN_INTER8_UV_DIR_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
180+ static INTRA_IN_INTER8_UV_SMOOTH_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
181+ static INTRA_IN_INTER8_UV_CFL_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
182+}
183+
184+/// `(directional, smooth/paeth, CfL)` chroma modes coded by an intra 8x8 leaf
185+/// inside an inter frame -- see [`INTRA_IN_INTER8_UV_DIR_HITS`].
186+pub(crate) fn intra_in_inter8_uv_hits() -> (usize, usize, usize) {
187+ (
188+ INTRA_IN_INTER8_UV_DIR_HITS.with(|c| c.get()),
189+ INTRA_IN_INTER8_UV_SMOOTH_HITS.with(|c| c.get()),
190+ INTRA_IN_INTER8_UV_CFL_HITS.with(|c| c.get()),
191+ )
192+}
193+
174 // lane-realworld r1: this frame's `cdef.bits` (spec 5.9.19), threaded into194 // lane-realworld r1: this frame's `cdef.bits` (spec 5.9.19), threaded into
175 // [`maybe_read_cdef_idx`] the same way [`ENABLE_EDGE_FILTER`] threads a195 // [`maybe_read_cdef_idx`] the same way [`ENABLE_EDGE_FILTER`] threads a
176 // frame-level flag through the recursive block decode -- `0` (the default)196 // frame-level flag through the recursive block decode -- `0` (the default)
@@ -1743,6 +1763,32 @@ thread_local! {
1743 static OBMC_HITS_8: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };1763 static OBMC_HITS_8: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
1744 }1764 }
1745 1765
1766+// lane-interp3 r1: how many inter blocks read a SWITCHABLE `interp_filter`
1767+// pair whose two directions differ (`enable_dual_filter` only -- with dual
1768+// filter off both directions take the single symbol, so this can never fire).
1769+// A gate asserting it proves the stream really carries dual-filter blocks.
1770+thread_local! {
1771+ static DUAL_FILTER_DIFF_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
1772+}
1773+
1774+// lane-interp3 r1: how many COMPOUND 8x8 leaves read their own
1775+// `read_mb_interp_filter` symbol(s) -- the read this round added (the leaf
1776+// used to skip it entirely, losing a symbol and stamping the `[3, 3]`
1777+// no-filter sentinel that made a neighbouring OBMC block panic).
1778+thread_local! {
1779+ static COMPOUND8_FILTER_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
1780+}
1781+
1782+/// Current value of [`DUAL_FILTER_DIFF_HITS`].
1783+pub(crate) fn dual_filter_diff_hits() -> usize {
1784+ DUAL_FILTER_DIFF_HITS.with(|c| c.get())
1785+}
1786+
1787+/// Current value of [`COMPOUND8_FILTER_HITS`].
1788+pub(crate) fn compound8_filter_hits() -> usize {
1789+ COMPOUND8_FILTER_HITS.with(|c| c.get())
1790+}
1791+
1746 // lane-warp round 1: how many blocks resolved `motion_mode_allowed` to1792 // lane-warp round 1: how many blocks resolved `motion_mode_allowed` to
1747 // `WARPED_CAUSAL`-eligible (3-symbol read, `num_proj_ref >= 1` under1793 // `WARPED_CAUSAL`-eligible (3-symbol read, `num_proj_ref >= 1` under
1748 // `allow_warped_motion`) AND the symbol actually decoded to `WARPED_CAUSAL`1794 // `allow_warped_motion`) AND the symbol actually decoded to `WARPED_CAUSAL`
@@ -1774,6 +1820,20 @@ pub(crate) fn compound_warp_hits() -> usize {
1774 COMPOUND_WARP_HITS.with(|c| c.get())1820 COMPOUND_WARP_HITS.with(|c| c.get())
1775 }1821 }
1776 1822
1823+// lane-interp3 r3: the same proof narrowed to the 8x8 LEAF's own compound
1824+// arm ([`decode_inter_block8`]) -- that arm predicted both taps
1825+// translationally until r3, so a gate needs to tell a warped 8x8 compound
1826+// leaf apart from a warped 16x16+ one (both bump [`COMPOUND_WARP_HITS`]).
1827+thread_local! {
1828+ static COMPOUND_WARP_HITS_8: std::cell::Cell<usize> =
1829+ const { std::cell::Cell::new(0) };
1830+}
1831+
1832+/// Current value of [`COMPOUND_WARP_HITS_8`].
1833+pub(crate) fn compound_warp_hits_8() -> usize {
1834+ COMPOUND_WARP_HITS_8.with(|c| c.get())
1835+}
1836+
1777 // lane-gmaffine r1: how many blocks built their prediction from a1837 // lane-gmaffine r1: how many blocks built their prediction from a
1778 // SIX-parameter (`AFFINE`) global-motion model through1838 // SIX-parameter (`AFFINE`) global-motion model through
1779 // `crate::warp::global_warp_params` -- the gate's proof that a stream really1839 // `crate::warp::global_warp_params` -- the gate's proof that a stream really
@@ -2597,6 +2657,43 @@ pub(crate) fn tx_class1_hits() -> usize {
2597 // coincidentally landing on `PARTITION_NONE`.2657 // coincidentally landing on `PARTITION_NONE`.
2598 thread_local! {2658 thread_local! {
2599 static SUB8_SPLIT_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };2659 static SUB8_SPLIT_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
2660+ /// How many 8x8 groups an INTER frame split into four BLOCK_4X4 inter
2661+ /// sub-blocks (lane-intersub8).
2662+ static SUB8_INTER_SPLIT_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
2663+ /// How many 8x8 groups an INTER frame split into two rectangular sub-8x8
2664+ /// inter leaves (lane-intersub8 r3), indexed `[0] = HORZ` (two BLOCK_8X4),
2665+ /// `[1] = VERT` (two BLOCK_4X8).
2666+ static SUB8_INTER_RECT_HITS: std::cell::Cell<[usize; 2]> = const { std::cell::Cell::new([0; 2]) };
2667+}
2668+
2669+/// Current value of [`SUB8_INTER_RECT_HITS`]: `(8x4 groups, 4x8 groups)`.
2670+pub fn sub8_inter_rect_hits() -> (usize, usize) {
2671+ SUB8_INTER_RECT_HITS.with(|c| {
2672+ let h = c.get();
2673+ (h[0], h[1])
2674+ })
2675+}
2676+
2677+// lane-cdef r1: (a) how many 8x8 CDEF units `apply_cdef` EXCLUDED because all
2678+// four of their mi cells are `skip_txfm` (libaom `cdef.c:29-38`
2679+// `is_8x8_block_skip` / `av1_cdef_compute_sb_list`'s dlist test), and (b) how
2680+// many 8x8 inter leaves (`decode_inter_block8`) wrote that skip band at all.
2681+// (b) was 0 for every stream before this round -- the leaf path never touched
2682+// the band, so an all-skip 8x8 group kept the PREVIOUS frame's flags and got
2683+// filtered where libaom skips it. A gate asserts both are non-zero.
2684+thread_local! {
2685+ static CDEF_SKIPPED_UNITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
2686+ static INTER8_SKIP_BAND_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
2687+}
2688+
2689+/// Current value of `CDEF_SKIPPED_UNITS`.
2690+pub(crate) fn cdef_skipped_units() -> usize {
2691+ CDEF_SKIPPED_UNITS.with(|c| c.get())
2692+}
2693+
2694+/// Current value of `INTER8_SKIP_BAND_HITS`.
2695+pub(crate) fn inter8_skip_band_hits() -> usize {
2696+ INTER8_SKIP_BAND_HITS.with(|c| c.get())
2600 }2697 }
2601 2698
2602 /// Current value of [`SUB8_SPLIT_HITS`].2699 /// Current value of [`SUB8_SPLIT_HITS`].
@@ -2604,6 +2701,11 @@ pub(crate) fn sub8_split_hits() -> usize {
2604 SUB8_SPLIT_HITS.with(|c| c.get())2701 SUB8_SPLIT_HITS.with(|c| c.get())
2605 }2702 }
2606 2703
2704+/// Current value of [`SUB8_INTER_SPLIT_HITS`].
2705+pub fn sub8_inter_split_hits() -> usize {
2706+ SUB8_INTER_SPLIT_HITS.with(|c| c.get())
2707+}
2708+
2607 // How many 4x8 / 8x4 leaves (lane-tx4x8's `PARTITION_VERT`/`PARTITION_HORZ`2709 // How many 4x8 / 8x4 leaves (lane-tx4x8's `PARTITION_VERT`/`PARTITION_HORZ`
2608 // of an 8x8 block) this thread's decode reconstructed with REAL coefficients2710 // of an 8x8 block) this thread's decode reconstructed with REAL coefficients
2609 // -- a skipped leaf exercises the prediction and the mi bookkeeping but never2711 // -- a skipped leaf exercises the prediction and the mi bookkeeping but never
@@ -8901,8 +9003,7 @@ fn dump_stage16(var: &str, y: &PlaneBuf, u: &PlaneBuf, v: &PlaneBuf, fw: usize,
8901 // LAST frame, so a mid-sequence divergence could not be read out at all.9003 // LAST frame, so a mid-sequence divergence could not be read out at all.
8902 static STAGE16_IDX: std::sync::atomic::AtomicUsize = std::sync::atomic::AtomicUsize::new(0);9004 static STAGE16_IDX: std::sync::atomic::AtomicUsize = std::sync::atomic::AtomicUsize::new(0);
8903 if let Ok(path) = std::env::var(var)9005 if let Ok(path) = std::env::var(var)
8904- && let idx = STAGE16_IDX.fetch_add(1, std::sync::atomic::Ordering::SeqCst)9006+ && let Ok(mut f) = std::fs::File::create(format!("{path}.f{}", dump_stage_idx(var)))
8905- && let Ok(mut f) = std::fs::File::create(format!("{path}.f{idx}"))
8906 {9007 {
8907 for (p, w, h) in [(y, fw, fh), (u, fw.div_ceil(2), fh.div_ceil(2)), (v, fw.div_ceil(2), fh.div_ceil(2))] {9008 for (p, w, h) in [(y, fw, fh), (u, fw.div_ceil(2), fh.div_ceil(2)), (v, fw.div_ceil(2), fh.div_ceil(2))] {
8908 for row in 0..h {9009 for row in 0..h {
@@ -8916,10 +9017,25 @@ fn dump_stage16(var: &str, y: &PlaneBuf, u: &PlaneBuf, v: &PlaneBuf, fw: usize,
8916 }9017 }
8917 }9018 }
8918 9019
9020+/// Decode-order index of the next [`dump_stage`]/[`dump_stage16`] file for a
9021+/// given env var -- lane-cdef r1: both used to write `.f0` unconditionally, so
9022+/// every frame overwrote the previous one and only the LAST frame survived,
9023+/// which silently defeats any per-frame filter-stage bisection.
9024+fn dump_stage_idx(var: &str) -> usize {
9025+ use std::collections::HashMap;
9026+ use std::sync::{Mutex, OnceLock};
9027+ static IDX: OnceLock<Mutex<HashMap<String, usize>>> = OnceLock::new();
9028+ let mut m = IDX.get_or_init(|| Mutex::new(HashMap::new())).lock().unwrap();
9029+ let e = m.entry(var.to_string()).or_insert(0);
9030+ let i = *e;
9031+ *e += 1;
9032+ i
9033+}
9034+
8919 fn dump_stage(var: &str, y: &PlaneBuf, u: &PlaneBuf, v: &PlaneBuf) {9035 fn dump_stage(var: &str, y: &PlaneBuf, u: &PlaneBuf, v: &PlaneBuf) {
8920 use std::io::Write;9036 use std::io::Write;
8921 if let Ok(path) = std::env::var(var)9037 if let Ok(path) = std::env::var(var)
8922- && let Ok(mut f) = std::fs::File::create(format!("{path}.f0"))9038+ && let Ok(mut f) = std::fs::File::create(format!("{path}.f{}", dump_stage_idx(var)))
8923 {9039 {
8924 for p in [y, u, v] {9040 for p in [y, u, v] {
8925 let narrow: Vec<u8> = p.data.iter().map(|&s| s as u8).collect();9041 let narrow: Vec<u8> = p.data.iter().map(|&s| s as u8).collect();
@@ -10432,6 +10548,7 @@ fn decode_leaf8(
10432 neighbours.record_palette_y_rect(pal_at, 8, 8, 0, [0u16; 8]);10548 neighbours.record_palette_y_rect(pal_at, 8, 8, 0, [0u16; 8]);
10433 neighbours.record_palette_uv_rect(pal_at, 8, 8, 0, [0u16; 8]);10549 neighbours.record_palette_uv_rect(pal_at, 8, 8, 0, [0u16; 8]);
10434 }10550 }
10551+ INTER8_SKIP_BAND_HITS.with(|c| c.set(c.get() + 1));
10435 neighbours.fill_skip_grid(leaf_mi, 2, skip);10552 neighbours.fill_skip_grid(leaf_mi, 2, skip);
10436 neighbours.fill_lf_grid(leaf_mi, 2, 8, 0);10553 neighbours.fill_lf_grid(leaf_mi, 2, 8, 0);
10437 neighbours.record_mode_mi(leaf_mi.0, leaf_mi.1, 2, 2, mode);10554 neighbours.record_mode_mi(leaf_mi.0, leaf_mi.1, 2, 2, mode);
@@ -12787,6 +12904,9 @@ fn apply_cdef(
12787 while mi_r < skip_grid.mi_rows {12904 while mi_r < skip_grid.mi_rows {
12788 let mut mi_c = 0usize;12905 let mut mi_c = 0usize;
12789 while mi_c < skip_grid.mi_cols {12906 while mi_c < skip_grid.mi_cols {
12907+ if skip_grid.is_skip_txfm(mi_r, mi_c) {
12908+ CDEF_SKIPPED_UNITS.with(|c| c.set(c.get() + 1));
12909+ }
12790 if !skip_grid.is_skip_txfm(mi_r, mi_c) {12910 if !skip_grid.is_skip_txfm(mi_r, mi_c) {
12791 let sidx = strength_idx(mi_r, mi_c);12911 let sidx = strength_idx(mi_r, mi_c);
12792 let (ox, oy) = (mi_c * 4, mi_r * 4);12912 let (ox, oy) = (mi_c * 4, mi_r * 4);
@@ -12799,10 +12919,15 @@ fn apply_cdef(
12799 i32::from(src_y[ny as usize * y_stride + nx as usize])12919 i32::from(src_y[ny as usize * y_stride + nx as usize])
12800 }12920 }
12801 };12921 };
12802- let (dir, var) = cdef_find_dir(coeff_shift, |r, c| {12922+ // lane-cdef r1: the direction search reads the SAME padded
12803- let (ny, nx) = ((oy + r).min(y_true_h - 1), (ox + c).min(y_true_w - 1));12923+ // block the taps do -- libaom runs `cdef_find_dir` on the
12804- i32::from(src_y[ny * y_stride + nx])12924+ // prepared filter block (`cdef_block.c:296-320` over
12805- });12925+ // `cdef_prepare_fb`'s buffer, `cdef.c:249-256`), whose columns
12926+ // and rows past the mi-rounded frame extent are CDEF_VERY_LARGE.
12927+ // Clamping to the last real sample instead made every straddling
12928+ // edge 8x8 (odd `mi_cols`/`mi_rows`) pick a different var, hence
12929+ // a different `adjust_strength`, hence a +-1 band at the crop edge.
12930+ let (dir, var) = cdef_find_dir(coeff_shift, |r, c| sample_y(r as i32, c as i32));
12806 12931
12807 // libaom `av1_cdef_filter_fb` passes `pri_strength ? dir : 0`12932 // libaom `av1_cdef_filter_fb` passes `pri_strength ? dir : 0`
12808 // -- each plane zeroes the shared direction when *its own*12933 // -- each plane zeroes the shared direction when *its own*
@@ -12812,6 +12937,12 @@ fn apply_cdef(
12812 let y_sec_strength = i32::from(cdef.y_sec_strength[sidx]) << coeff_shift;12937 let y_sec_strength = i32::from(cdef.y_sec_strength[sidx]) << coeff_shift;
12813 let y_dir = if y_pri_strength != 0 { dir } else { 0 };12938 let y_dir = if y_pri_strength != 0 { dir } else { 0 };
12814 let t = cdef_adjust_strength(y_pri_strength, var);12939 let t = cdef_adjust_strength(y_pri_strength, var);
12940+ // lane-cdef r1 rung: one line per filtered 8x8 luma CDEF unit.
12941+ if std::env::var_os("EC_AV1_CDEF_DBG").is_some() {
12942+ eprintln!(
12943+ "EC_CDEF mi_r={mi_r} mi_c={mi_c} x={ox} y={oy} sidx={sidx} dir={dir} var={var} t={t} pri={y_pri_strength} sec={y_sec_strength} damp={damping}"
12944+ );
12945+ }
12815 let enable_primary = t != 0;12946 let enable_primary = t != 0;
12816 let enable_secondary = y_sec_strength != 0;12947 let enable_secondary = y_sec_strength != 0;
12817 if enable_primary || enable_secondary {12948 if enable_primary || enable_secondary {
@@ -14868,6 +14999,13 @@ pub(crate) fn decode_key_frame_tile_with_cdfs(
14868 // that isolate whether a decode-order frame's mismatch already exists14999 // that isolate whether a decode-order frame's mismatch already exists
14869 // in reconstruction (this dump) vs is introduced by the loop filter15000 // in reconstruction (this dump) vs is introduced by the loop filter
14870 // (EC_AV1_DECODE_ORDER_DUMP's post-filter dump).15001 // (EC_AV1_DECODE_ORDER_DUMP's post-filter dump).
15002+ // Decode-order frame marker for the EC_OBMC / EC_TRACE_MODE ladders.
15003+ if std::env::var_os("EC_OBMC").is_some() || std::env::var_os("EC_TRACE_MODE").is_some() {
15004+ eprintln!(
15005+ "EC_PICT idx={}",
15006+ PREFILT_PICTURE_IDX.load(std::sync::atomic::Ordering::SeqCst)
15007+ );
15008+ }
14871 dump_stage16("EC_AV1_PREFILT_DUMP16", &y, &u, &v, frame_width as usize, frame_height as usize);15009 dump_stage16("EC_AV1_PREFILT_DUMP16", &y, &u, &v, frame_width as usize, frame_height as usize);
14872 if let Ok(path) = std::env::var("EC_AV1_PREFILT_DUMP") {15010 if let Ok(path) = std::env::var("EC_AV1_PREFILT_DUMP") {
14873 use std::io::Write;15011 use std::io::Write;
@@ -15072,6 +15210,15 @@ fn resolve_interp_filter(
15072 } else {15210 } else {
15073 sym015211 sym0
15074 };15212 };
15213+ if enable_dual_filter && sym0 != sym1 {
15214+ DUAL_FILTER_DIFF_HITS.with(|c| c.set(c.get() + 1));
15215+ }
15216+ if std::env::var_os("EC_TRACE_MODE").is_some() {
15217+ eprintln!(
15218+ "EC_IF ctx0={ctx0} above={above:?} left={left:?} sym0={sym0} sym1={sym1} rng={}",
15219+ dec.debug_state().0
15220+ );
15221+ }
15075 (15222 (
15076 mc::InterpFilterKind::from_switchable_symbol(sym1 as usize),15223 mc::InterpFilterKind::from_switchable_symbol(sym1 as usize),
15077 mc::InterpFilterKind::from_switchable_symbol(sym0 as usize),15224 mc::InterpFilterKind::from_switchable_symbol(sym0 as usize),
@@ -15731,14 +15878,25 @@ fn obmc_mask(len: usize) -> &'static [u8] {
15731 fn neighbour_filter(15878 fn neighbour_filter(
15732 interp_fixed: Option<mc::InterpFilterKind>,15879 interp_fixed: Option<mc::InterpFilterKind>,
15733 sym: [u8; 2],15880 sym: [u8; 2],
15734-) -> (mc::InterpFilterKind, mc::InterpFilterKind) {15881+) -> Result<(mc::InterpFilterKind, mc::InterpFilterKind)> {
15735 if let Some(kind) = interp_fixed {15882 if let Some(kind) = interp_fixed {
15736- return (kind, kind);15883+ return Ok((kind, kind));
15884+ }
15885+ // lane-interp3 r1: the `[3, 3]` sentinel reaching here is a DEFECT in
15886+ // whatever path recorded the neighbour (an inter block that never stored
15887+ // its own switchable symbols), and it used to abort the process through
15888+ // `from_switchable_symbol`'s panic. A decoder must never crash on a real
15889+ // stream: it stops by name instead, so the frame is refused and the
15890+ // stream is pinned like every other unsupported case.
15891+ if sym[0] > 2 || sym[1] > 2 {
15892+ return Err(unsupported(
15893+ "an OBMC neighbour whose interp filter was never recorded (no switchable symbol for that block)",
15894+ ));
15737 }15895 }
15738- (15896+ Ok((
15739 mc::InterpFilterKind::from_switchable_symbol(sym[1] as usize),15897 mc::InterpFilterKind::from_switchable_symbol(sym[1] as usize),
15740 mc::InterpFilterKind::from_switchable_symbol(sym[0] as usize),15898 mc::InterpFilterKind::from_switchable_symbol(sym[0] as usize),
15741- )15899+ ))
15742 }15900 }
15743 15901
15744 /// One neighbour's own re-prediction over a `w`x`h` region, MC'd fresh15902 /// One neighbour's own re-prediction over a `w`x`h` region, MC'd fresh
@@ -15918,6 +16076,71 @@ fn obmc_blend_h(dst: &mut [u16], stride: usize, ox: usize, oy: usize, w: usize,
15918 }16076 }
15919 }16077 }
15920 16078
16079+/// libaom's own `BLOCK_SIZE` enum index for a `w4`x`h4` (mi-unit) block --
16080+/// only for the `EC_OBMC` trace rung below, so it reads byte-identical to
16081+/// the instrumented aomdec's `backup_mbmi.bsize`.
16082+fn ec_obmc_bsize(w4: usize, h4: usize) -> i32 {
16083+ match (w4, h4) {
16084+ (1, 1) => 0,
16085+ (1, 2) => 1,
16086+ (2, 1) => 2,
16087+ (2, 2) => 3,
16088+ (2, 4) => 4,
16089+ (4, 2) => 5,
16090+ (4, 4) => 6,
16091+ (4, 8) => 7,
16092+ (8, 4) => 8,
16093+ (8, 8) => 9,
16094+ (8, 16) => 10,
16095+ (16, 8) => 11,
16096+ (16, 16) => 12,
16097+ (1, 4) => 16,
16098+ (4, 1) => 17,
16099+ (2, 8) => 18,
16100+ (8, 2) => 19,
16101+ (4, 16) => 20,
16102+ (16, 4) => 21,
16103+ _ => -1,
16104+ }
16105+}
16106+
16107+/// The `EC_OBMC` rung: one line per blended neighbour, in the instrumented
16108+/// aomdec's own byte format (`decodeframe.c`
16109+/// `dec_build_prediction_by_{above,left}_pred`), so the two decoders' OBMC
16110+/// neighbour lists diff line for line. `filt` is libaom's packed
16111+/// `interp_filters.as_int` = `y_filter | (x_filter << 16)`.
16112+#[allow(clippy::too_many_arguments)]
16113+fn ec_obmc_trace(
16114+ dir: &str,
16115+ mi_row: usize,
16116+ mi_col: usize,
16117+ write_w: usize,
16118+ write_h: usize,
16119+ rel: usize,
16120+ op: usize,
16121+ nb: &MiInfo,
16122+ h_kind: mc::InterpFilterKind,
16123+ v_kind: mc::InterpFilterKind,
16124+) {
16125+ if std::env::var_os("EC_OBMC").is_none() {
16126+ return;
16127+ }
16128+ let sym = |k: mc::InterpFilterKind| match k {
16129+ mc::InterpFilterKind::Smooth => 1u32,
16130+ mc::InterpFilterKind::Sharp => 2,
16131+ _ => 0,
16132+ };
16133+ eprintln!(
16134+ "EC_OBMC {dir} mi=({mi_row},{mi_col}) wh=({write_w}x{write_h}) rel={rel} op={op} \
16135+nbmv=({},{}) nbref={} nbbsize={} filt={}",
16136+ nb.mv.0,
16137+ nb.mv.1,
16138+ nb.ref_frame,
16139+ ec_obmc_bsize(nb.size, nb.size_h),
16140+ sym(v_kind) | (sym(h_kind) << 16),
16141+ );
16142+}
16143+
15921 /// `av1_build_obmc_inter_prediction` (libaom `reconinter.c`): re-predicts16144 /// `av1_build_obmc_inter_prediction` (libaom `reconinter.c`): re-predicts
15922 /// the overlap strip against each bordering above/left inter neighbour's own16145 /// the overlap strip against each bordering above/left inter neighbour's own
15923 /// mv/ref/filter and blends it into this block's just-built single-reference16146 /// mv/ref/filter and blends it into this block's just-built single-reference
@@ -16016,7 +16239,8 @@ fn obmc_blend(
16016 let (h_kind, v_kind) = neighbour_filter(16239 let (h_kind, v_kind) = neighbour_filter(
16017 interp_fixed,16240 interp_fixed,
16018 neighbours.above_filter[mi_col + off4],16241 neighbours.above_filter[mi_col + off4],
16019- );16242+ )?;
16243+ ec_obmc_trace("above", mi_row, mi_col, write_w, write_h, off4, span4, &nb, h_kind, v_kind);
16020 let (ny, nu, nv) = ref_planes(nb.ref_frame, ref_y, ref_u, ref_v, other_refs)?;16244 let (ny, nu, nv) = ref_planes(nb.ref_frame, ref_y, ref_u, ref_v, other_refs)?;
16021 let nb_scale = mc::scale_factor(ny.width, frame_width);16245 let nb_scale = mc::scale_factor(ny.width, frame_width);
16022 let (bw, bh, ox) = (span4 * 4, overlap_above, off4 * 4);16246 let (bw, bh, ox) = (span4 * 4, overlap_above, off4 * 4);
@@ -16035,7 +16259,8 @@ fn obmc_blend(
16035 let (h_kind, v_kind) = neighbour_filter(16259 let (h_kind, v_kind) = neighbour_filter(
16036 interp_fixed,16260 interp_fixed,
16037 neighbours.left_filter[mi_row + off4],16261 neighbours.left_filter[mi_row + off4],
16038- );16262+ )?;
16263+ ec_obmc_trace("left", mi_row, mi_col, write_w, write_h, off4, span4, &nb, h_kind, v_kind);
16039 let (ny, nu, nv) = ref_planes(nb.ref_frame, ref_y, ref_u, ref_v, other_refs)?;16264 let (ny, nu, nv) = ref_planes(nb.ref_frame, ref_y, ref_u, ref_v, other_refs)?;
16040 let nb_scale = mc::scale_factor(ny.width, frame_width);16265 let nb_scale = mc::scale_factor(ny.width, frame_width);
16041 let (bw, bh, oy) = (overlap_left, span4 * 4, off4 * 4);16266 let (bw, bh, oy) = (overlap_left, span4 * 4, off4 * 4);
@@ -16060,6 +16285,67 @@ fn is_any_masked_compound_used_here(side: usize) -> bool {
16060 side.min(side) >= 816285 side.min(side) >= 8
16061 }16286 }
16062 16287
16288+/// libaom's `BLOCK_SIZES_ALL` index of a `w`x`h` block (`common_data.h`'s own
16289+/// enum order) -- the row every bsize-indexed CDF (`compound_type_cdf`,
16290+/// `wedge_idx_cdf`) is read at. lane-intersub8 r4: these two used to be
16291+/// indexed by the caller's SQUARE envelope, so a 16x8 compound block read
16292+/// `BLOCK_16X16`'s row (class table-indexed-by-raw-size) and desynced the
16293+/// tile at its first masked-compound rect block.
16294+fn bsize_index(w: usize, h: usize) -> Option<usize> {
16295+ Some(match (w, h) {
16296+ (4, 4) => 0,
16297+ (4, 8) => 1,
16298+ (8, 4) => 2,
16299+ (8, 8) => 3,
16300+ (8, 16) => 4,
16301+ (16, 8) => 5,
16302+ (16, 16) => 6,
16303+ (16, 32) => 7,
16304+ (32, 16) => 8,
16305+ (32, 32) => 9,
16306+ (32, 64) => 10,
16307+ (64, 32) => 11,
16308+ (64, 64) => 12,
16309+ (64, 128) => 13,
16310+ (128, 64) => 14,
16311+ (128, 128) => 15,
16312+ (4, 16) => 16,
16313+ (16, 4) => 17,
16314+ (8, 32) => 18,
16315+ (32, 8) => 19,
16316+ (16, 64) => 20,
16317+ (64, 16) => 21,
16318+ _ => return None,
16319+ })
16320+}
16321+
16322+/// `is_any_masked_compound_used` (libaom `reconinter.h`) on the block's TRUE
16323+/// footprint: `is_comp_ref_allowed` is `AOMMIN(bw, bh) >= 8`, and every
16324+/// shape that clears it has either a wedge or a DIFFWTD compound available.
16325+fn masked_compound_used_wh(w: usize, h: usize) -> bool {
16326+ w.min(h) >= 8
16327+}
16328+
16329+/// `av1_wedge_params_lookup[bsize].wedge_types > 0` (libaom `reconinter.c`):
16330+/// the shapes whose `compound_type` symbol is really coded. Everything else
16331+/// with a compound mask infers `COMPOUND_DIFFWTD` without a symbol.
16332+fn wedge_used_wh(w: usize, h: usize) -> bool {
16333+ matches!(
16334+ (w, h),
16335+ (8, 8)
16336+ | (8, 16)
16337+ | (16, 8)
16338+ | (16, 16)
16339+ | (16, 32)
16340+ | (32, 16)
16341+ | (32, 32)
16342+ | (8, 32)
16343+ | (32, 8)
16344+ | (16, 64)
16345+ | (64, 16)
16346+ )
16347+}
16348+
16063 /// Whether a compound reference pair is unidirectional (both references on16349 /// Whether a compound reference pair is unidirectional (both references on
16064 /// the same temporal side of the current frame) -- `has_uni_comp_refs`16350 /// the same temporal side of the current frame) -- `has_uni_comp_refs`
16065 /// (libaom `av1_reference_frame_utils.h`/`pred_common.c`'s own definition:16351 /// (libaom `av1_reference_frame_utils.h`/`pred_common.c`'s own definition:
@@ -16849,12 +17135,18 @@ fn decode_inter_block(
16849 let group_ctx = get_comp_group_idx_context(neighbours, (rmi, cmi), side);17135 let group_ctx = get_comp_group_idx_context(neighbours, (rmi, cmi), side);
16850 let comp_group_idx = if !skip_mode17136 let comp_group_idx = if !skip_mode
16851 && enable_masked_compound17137 && enable_masked_compound
16852- && is_any_masked_compound_used_here(side)17138+ && masked_compound_used_wh(write_w, write_h)
16853 {17139 {
16854 dec.symbol(&mut cdfs.comp_group_idx[group_ctx])17140 dec.symbol(&mut cdfs.comp_group_idx[group_ctx])
16855 } else {17141 } else {
16856 017142 0
16857 };17143 };
17144+ if std::env::var_os("EC_TRACE_MODE").is_some() {
17145+ eprintln!(
17146+ "EC_CGI mi_row={rmi} mi_col={cmi} ctx={group_ctx} val={comp_group_idx} rng={}",
17147+ dec.debug_state().0
17148+ );
17149+ }
16858 // lane-maskcomp r2 / lane-wedge r3: `Some(mask_type)` for a17150 // lane-maskcomp r2 / lane-wedge r3: `Some(mask_type)` for a
16859 // `COMPOUND_DIFFWTD` block, `Some(mask)` (wedge codebook lookup)17151 // `COMPOUND_DIFFWTD` block, `Some(mask)` (wedge codebook lookup)
16860 // for a `COMPOUND_WEDGE` block -- exactly one of the two is set17152 // for a `COMPOUND_WEDGE` block -- exactly one of the two is set
@@ -16876,12 +17168,11 @@ fn decode_inter_block(
16876 // writes NO `compound_type` symbol there and INFERS17168 // writes NO `compound_type` symbol there and INFERS
16877 // `COMPOUND_DIFFWTD` -- only the 1-bit `mask_type` literal17169 // `COMPOUND_DIFFWTD` -- only the 1-bit `mask_type` literal
16878 // follows. `None` here is exactly that inferred arm.17170 // follows. `None` here is exactly that inferred arm.
16879- let wedge_bsize = match side {17171+ // lane-intersub8 r4: the block's TRUE footprint, not the
16880- 8 => Some(3),17172+ // square envelope -- `compound_type_cdf`/`wedge_idx_cdf` are
16881- 16 => Some(6),17173+ // `BLOCK_SIZES_ALL`-indexed.
16882- 32 => Some(9),17174+ let wedge_bsize =
16883- _ => None,17175+ bsize_index(write_w, write_h).filter(|_| wedge_used_wh(write_w, write_h));
16884- };
16885 let compound_type = match wedge_bsize {17176 let compound_type = match wedge_bsize {
16886 Some(b) => dec.symbol(&mut cdfs.compound_type[b]),17177 Some(b) => dec.symbol(&mut cdfs.compound_type[b]),
16887 None => 1,17178 None => 1,
@@ -16889,6 +17180,14 @@ fn decode_inter_block(
16889 if let Some(wedge_bsize) = wedge_bsize.filter(|_| compound_type == 0) {17180 if let Some(wedge_bsize) = wedge_bsize.filter(|_| compound_type == 0) {
16890 // COMPOUND_WEDGE: lane-wedge r3, codebook checksum-17181 // COMPOUND_WEDGE: lane-wedge r3, codebook checksum-
16891 // verified vs independent C dump (wedge.rs).17182 // verified vs independent C dump (wedge.rs).
17183+ if write_w != write_h {
17184+ // lane-intersub8 r4: the wedge codebook here is built
17185+ // per SQUARE side only; a rect block's own codebook
17186+ // (BLOCK_16X8 etc.) is a different mask set.
17187+ return Err(unsupported(
17188+ "a COMPOUND_WEDGE mask on a non-square inter block (rect wedge codebook unimplemented)",
17189+ ));
17190+ }
16892 let wedge_index = dec.symbol(&mut cdfs.wedge_idx[wedge_bsize]);17191 let wedge_index = dec.symbol(&mut cdfs.wedge_idx[wedge_bsize]);
16893 let wedge_sign = dec.literal(1);17192 let wedge_sign = dec.literal(1);
16894 WEDGE_HITS.with(|c| c.set(c.get() + 1));17193 WEDGE_HITS.with(|c| c.set(c.get() + 1));
@@ -17120,6 +17419,12 @@ fn decode_inter_block(
17120 ref_order_hints[(ref1 - LAST_FRAME) as usize],17419 ref_order_hints[(ref1 - LAST_FRAME) as usize],
17121 );17420 );
17122 let idx = dec.symbol(&mut cdfs.compound_idx[idx_ctx]);17421 let idx = dec.symbol(&mut cdfs.compound_idx[idx_ctx]);
17422+ if std::env::var_os("EC_TRACE_MODE").is_some() {
17423+ eprintln!(
17424+ "EC_CIDX mi_row={rmi} mi_col={cmi} ctx={idx_ctx} val={idx} rng={}",
17425+ dec.debug_state().0
17426+ );
17427+ }
17123 if idx == 1 {17428 if idx == 1 {
17124 (8, 8, 1u8)17429 (8, 8, 1u8)
17125 } else {17430 } else {
@@ -18748,6 +19053,12 @@ fn decode_inter_block(
18748 return Ok(());19053 return Ok(());
18749 }19054 }
18750 let mode = dec.symbol(&mut cdfs.y_mode[size_group_wh(write_w, write_h)]);19055 let mode = dec.symbol(&mut cdfs.y_mode[size_group_wh(write_w, write_h)]);
19056+ if std::env::var_os("EC_IIS").is_some() {
19057+ eprintln!(
19058+ "TRACE iis px={px} py={py} side={side} w={write_w} h={write_h} sg={} mode={mode} skip={skip}",
19059+ size_group_wh(write_w, write_h)
19060+ );
19061+ }
18751 if mode >= 13 {19062 if mode >= 13 {
18752 return Err(unsupported(19063 return Err(unsupported(
18753 "an intra mode this decoder does not code (round 2)",19064 "an intra mode this decoder does not code (round 2)",
@@ -19171,30 +19482,47 @@ fn decode_inter_block(
19171 Ok(())19482 Ok(())
19172 }19483 }
19173 19484
19174-/// Decodes one 8x8 leaf of a straddling 16x16 inter-frame block19485+/// Decodes one 8x8 group that an inter frame's `partition_w8` symbol split
19175-/// (lane-av1inter8), mirroring [`crate::tile::write_inter_frame_leaf8`]'s19486+/// into four `BLOCK_4X4` inter blocks (lane-intersub8: `PARTITION_SPLIT`
19176-/// exact symbol order: its own skip flag, intra/inter choice and (when19487+/// below 8x8 -- traced live against the oracle `aomdec`'s own `EC_PART_VAL`,
19177-/// inter) `NEARESTMV`/`NEWMV` chain against this leaf's own 2x2-mi mv-stack19488+/// which reads `bsize=3 value=3` on real inter frames, so the refusal this
19178-/// window, or (when intra) `Y_MODE`, then its own luma and two chroma19489+/// replaces was NOT our own desync).
19179-/// transform blocks through [`TxbSet::Luma8Inter`]/[`TxbSet::Chroma4`],19490+///
19180-/// same as [`decode_leaf8`]'s coefficient layer but with19491+/// The inter counterpart of [`decode_leaf_split4`], and a `BLOCK_4X4`-only
19181-/// motion-compensated prediction instead of intra prediction when inter.19492+/// cut of [`decode_inter_block8`]: at `min(bw, bh) < 8` libaom switches off
19182-/// `outer_at` (in [`SUB`]-grid units) is the enclosing 16x16 slot's19493+/// half the inter syntax, and every one of those is a symbol NOT read here
19183-/// skip/intra-inter context, overridden by `prev_leaf` exactly as19494+/// (`decodemv.c` / `blockd.h`, oracle tree):
19184-/// [`decode_leaf8`] overrides mode context: `Neighbours`' above/left arrays19495+/// * `skip_mode`: `read_skip_mode` returns 0 without a symbol when
19185-/// only resolve to [`SUB`] granularity. Hands back this leaf's own skip flag19496+/// `!is_comp_ref_allowed(bsize)` (`AOMMIN(bw, bh) >= 8`, blockd.h).
19186-/// and intra/inter choice, for the next leaf or the caller's final19497+/// * `comp_mode`: `read_block_reference_mode` returns `SINGLE_REFERENCE` on
19187-/// write-back.19498+/// the same predicate, so a sub-8x8 block is always single-reference.
19499+/// * `interintra`: `is_interintra_allowed_bsize` starts at `BLOCK_8X8`.
19500+/// * `motion_mode` / `obmc`: `motion_mode_allowed` returns
19501+/// `SIMPLE_TRANSLATION` for `block_size_wide < 8 || block_size_high < 8`,
19502+/// and `is_global_mv_block`'s own size term fails, so no warp either.
19503+/// * tx size: `block_signals_txsize(bsize)` is `bsize > BLOCK_4X4`
19504+/// (blockd.h:1027), so a `BLOCK_4X4` reads neither `tx_depth` nor a
19505+/// `txfm_partition` bit even in `TX_MODE_SELECT` -- the transform is
19506+/// `max_txsize_rect_lookup[BLOCK_4X4]` = `TX_4X4`
19507+/// (`decodeframe.c:1164-1177`).
19508+///
19509+/// Chroma is coded ONCE for the whole 8x8 group, on the last sub-block
19510+/// (`is_chroma_reference`: `(mi_row & 1) && (mi_col & 1)` in 4:2:0), as one
19511+/// `TX_4X4` unit per plane -- same rule and same neighbour-context tail as
19512+/// [`decode_leaf_split4`]. Its PREDICTION is the sub8x8 one
19513+/// (`dec_build_inter_predictors`'s `is_sub8x8` branch, `decodeframe.c`; spec
19514+/// 7.11.3.1's `candRow`/`candCol` loop): four 2x2 chroma pieces, each built
19515+/// from its own luma sub-block's reference, motion vector and interpolation
19516+/// filters, never from the last sub-block's mv alone.
19188 #[allow(clippy::too_many_arguments)]19517 #[allow(clippy::too_many_arguments)]
19189-fn decode_inter_block8(19518+fn decode_inter_sub8_split4(
19190 dec: &mut SymbolDecoder,19519 dec: &mut SymbolDecoder,
19191 cdfs: &mut Cdfs,19520 cdfs: &mut Cdfs,
19192 neighbours: &mut Neighbours,19521 neighbours: &mut Neighbours,
19193 grid: &mut MiGrid,19522 grid: &mut MiGrid,
19523+ group_mi: (usize, usize),
19194 mi_cols: u32,19524 mi_cols: u32,
19195 mi_rows: u32,19525 mi_rows: u32,
19196- outer_at: (usize, usize),
19197- leaf_mi: (usize, usize),
19198 y: &mut PlaneBuf,19526 y: &mut PlaneBuf,
19199 u: &mut PlaneBuf,19527 u: &mut PlaneBuf,
19200 v: &mut PlaneBuf,19528 v: &mut PlaneBuf,
@@ -19202,147 +19530,1064 @@ fn decode_inter_block8(
19202 ref_u: &PlaneBuf,19530 ref_u: &PlaneBuf,
19203 ref_v: &PlaneBuf,19531 ref_v: &PlaneBuf,
19204 other_refs: &RefSlots,19532 other_refs: &RefSlots,
19533+ sign_bias_table: &SignBiasTable,
19534+ global_motion: &[ec_av1_syntax::WarpParams; 7],
19205 base_q_idx: u8,19535 base_q_idx: u8,
19206- scan8: &[u16],
19207 scan4: &[u16],19536 scan4: &[u16],
19208 allow_high_precision_mv: bool,19537 allow_high_precision_mv: bool,
19209 force_integer_mv: bool,19538 force_integer_mv: bool,
19210- // lane-gmaffine r1: this frame header's own `global_motion` table (spec
19211- // 5.9.24), indexed `[ref_frame - LAST_FRAME]` -- same table
19212- // [`decode_inter_block`] takes, threaded here so the 8x8 leaf can code
19213- // `GLOBALMV` (`gm_get_motion_vector`), fill its mv stack's missing
19214- // candidates with the gm mv (gm r6's root cause) and build a global
19215- // warp prediction.
19216- global_motion: &[ec_av1_syntax::WarpParams; 7],
19217- // lane-gmaffine r1: this sequence header's own `enable_dual_filter` bit,
19218- // for the leaf's own `read_mb_interp_filter` below.
19219- enable_dual_filter: bool,
19220- // lane-av1comp: see [`decode_inter_block`]'s own doc -- this leaf path
19221- // only ever tracks a coarse `LAST_FRAME`-or-intra neighbour shape (no
19222- // per-leaf `above_ref`/`left_ref` array exists here), so `comp_mode`'s
19223- // context uses that same approximation.
19224- reference_select: bool,
19225- enable_masked_compound: bool,
19226- // lane-sb128 r4: see [`decode_inter_block`]'s own doc -- `BLOCK_8X8` is
19227- // always `is_interintra_allowed_bsize`-eligible, so this leaf's own gate
19228- // drops the `side` check entirely.
19229- enable_interintra_compound: bool,
19230- enable_jnt_comp: bool,
19231- order_hint_bits: u32,
19232- order_hint: u32,
19233- ref_order_hints: [u32; 7],
19234- // lane-av1comp round 14: see [`decode_inter_block`]'s own doc -- this
19235- // leaf has no per-leaf `above_skip_mode`/`left_skip_mode` array either,
19236- // so its `skip_mode` context reuses the same [`SUB`]-grid
19237- // `above_skip_mode[cmi]`/`left_skip_mode[rmi]` the enclosing 16x16 slot
19238- // tracks (mirroring `above_skip`/`left_skip`'s own leaf approximation
19239- // just above).
19240- skip_mode_present: bool,
19241- skip_mode_frame: [u8; 2],
19242- // lane-cdffwd2: this frame header's own `reduced_tx_set` bit -- see
19243- // [`decode_inter_frame_tile_with_cdfs`]'s own doc.
19244- reduced_tx_set: bool,
19245- // lane-motionmode round 3: this frame header's own `is_motion_mode_switchable`/
19246- // `allow_warped_motion` bits (spec 5.11.24's `read_motion_mode`), plus
19247- // the fixed/switchable interp filter kind `obmc_blend`'s own neighbour
19248- // reads need (see [`decode_inter_block`]'s own doc) -- this leaf's own
19249- // prediction is always `Regular` (documented corner-cut, `mc::predict`
19250- // has no filter param), but an OBMC neighbour can be a real 16x16+
19251- // block that DID resolve a switchable filter.
19252 interp_fixed: Option<mc::InterpFilterKind>,19539 interp_fixed: Option<mc::InterpFilterKind>,
19253- switchable_motion_mode: bool,19540+ enable_dual_filter: bool,
19254- allow_warped_motion: bool,
19255- // lane-av1comp: `Some((ref1, comp_group_idx, compound_idx))` only for a
19256- // real `COMPOUND_REFERENCE` leaf, for the caller's own end-of-16x16
19257- // `record_compound_ctx` call -- mirrors [`decode_inter_block`]'s own
19258- // `compound_ctx` local, just handed back instead of applied here (this
19259- // fn's `neighbours` recording happens once for the whole straddling
19260- // 16x16 block, after every leaf).
19261- // lane-screen r2: see [`decode_inter_block`]'s own copy of this param --
19262- // `BLOCK_8X8` (this leaf's fixed size) is always `av1_allow_palette`-
19263- // eligible (`bsize >= BLOCK_8X8`).
19264- allow_screen_content_tools: bool,
19265- // lane-inter8 r1: the leaf's mv stacks used to be built without the
19266- // frame's sign-bias table (`NO_SIGN_BIAS`), while [`decode_inter_block`]
19267- // one level up passed it -- it changes the candidate list and with it
19268- // `new_mv_ctx`/`ref_mv_ctx`, `drl_ctx` and the number of symbols read.
19269- // Measured: an 8x8 compound NEAR_NEWMV leaf desynced against aomdec's
19270- // EC_MODE ladder at exactly this block (mi 4,14 of the mandelbrot
19271- // 8x8-split gate).
19272- sign_bias_table: &SignBiasTable,
19273- // lane-inter8 r2: the frame's temporal mv field (spec 7.10.2.8), which
19274- // [`decode_inter_block`] one level up has always passed and this leaf
19275- // passed `None` for -- a `use_ref_frame_mvs` frame's stack then holds
19276- // fewer candidates here than in the reference decoder, which changes the
19277- // mode contexts AND the number of `drl_mode` bits read (class parsed
19278- // then discarded).
19279 tpl_frame: Option<&TplFrameArgs>,19541 tpl_frame: Option<&TplFrameArgs>,
19280- // lane-scaledref r1: this frame's own coded luma width (spec 7.11.3.3),19542+ reduced_tx_set: bool,
19281- // for the scaled-reference MC this leaf's own single-ref/compound/OBMC
19282- // predictions take when a stored reference was coded at another width
19283- // (`use_superres`) -- mirrors [`decode_inter_block`]'s own param.
19284 frame_width: usize,19543 frame_width: usize,
19285-) -> Result<(bool, bool, bool, Option<(i8, i8, u8, u8)>, [u8; 2], (i8, Option<i8>))> {19544+) -> Result<()> {
19286 const LAST_FRAME: i8 = 1;19545 const LAST_FRAME: i8 = 1;
19287- // lane-gmaffine r2: the leaf's OWN switchable-filter symbols, handed back19546+ const B4: usize = 4;
19288- // so the caller stamps them into `Neighbours` instead of the `[3, 3]`19547+ SUB8_INTER_SPLIT_HITS.with(|c| c.set(c.get() + 1));
19289- // placeholder. `[3, 3]` is the "intra neighbour, no filter" sentinel: an19548+ let (gr, gc) = group_mi;
19290- // OBMC blend that picks such a neighbour up feeds it to19549+ let (gpx, gpy) = (gc * MI, gr * MI);
19291- // `neighbour_filter`, which PANICS on it (`from_switchable_symbol`) --19550+ let (cpx, cpy) = (gpx / 2, gpy / 2);
19292- // that was the warp gate's crash, not an entropy desync. Stays `[3, 3]`19551+ // Per-sub-block state the group's chroma prediction needs (spec
19293- // on the intra and compound paths.19552+ // 7.11.3.1's candRow/candCol loop reads each sub-block's OWN mv/ref/
19294- let mut leaf_filter_syms = [3u8; 2];19553+ // filters), indexed `dr * 2 + dc`.
19295- // lane-gmaffine r1: this leaf's GLOBALMV vector AND the mv stack's19554+ let mut piece: [Option<(i8, (i32, i32), mc::InterpFilterKind, mc::InterpFilterKind)>; 4] =
19296- // missing-candidate fallback both come from the frame's global motion19555+ [None; 4];
19297- // evaluated at THIS block's centre (gm r6's root cause).19556+ let mut first_tx_type = TxType::DctDct;
19298- let gm_table = build_gm_mv_table(19557+ let mut last_skip = true;
19299- global_motion,19558+ for i in 0..4usize {
19300- leaf_mi.0,19559+ let (dr, dc) = (i / 2, i % 2);
19301- leaf_mi.1,19560+ let lmi = (gr + dr, gc + dc);
19302- 2,19561+ if lmi.0 >= mi_rows as usize || lmi.1 >= mi_cols as usize {
19303- 2,19562+ continue;
19304- allow_high_precision_mv,19563+ }
19305- force_integer_mv,19564+ let (rmi, cmi) = lmi;
19306- );19565+ let (px, py) = (cmi * MI, rmi * MI);
19307- /// `Y_MODE`'s size group (`common_data.h`'s `size_group_lookup[BLOCK_8X8]`).19566+ inter_segment_id(dec, cdfs, rmi, cmi, 1, 1, false, true);
19308- const SIZE_GROUP_8: usize = 1;19567+ // No `skip_mode` symbol: `is_comp_ref_allowed(BLOCK_4X4)` is false.
19309-19568+ let skip_ctx = usize::from(neighbours.above_skip[cmi]) + usize::from(neighbours.left_skip[rmi]);
19310- let (px, py) = (leaf_mi.1 * MI, leaf_mi.0 * MI);19569+ let skip = dec.symbol(&mut cdfs.skip[skip_ctx]) == 1;
19311- let (cpx, cpy) = (px / 2, py / 2);19570+ inter_segment_id(dec, cdfs, rmi, cmi, 1, 1, skip, false);
19312- // lane-txselect: whether this leaf's `TxMode::Select` var-tx tree took19571+ maybe_read_cdef_idx(dec, rmi, cmi, skip);
19313- // the one split a `BLOCK_8X8` can take (`read_block_tx_size` below) --19572+ maybe_read_delta_q(dec, cdfs, rmi, cmi, false, skip);
19314- // read back by the luma residual read and the tail's neighbour/loop-filter19573+ maybe_read_delta_lf(dec, cdfs, rmi, cmi, false, skip);
19315- // bookkeeping. Always `false` outside a `TxMode::Select` inter frame.19574+ let (has_above, has_left) = (
19316- let mut split8 = false;19575+ rmi > neighbours.tile_row0_mi,
19317- const SIDE: usize = 8;19576+ cmi > neighbours.tile_col0_mi,
19318- const CHROMA_SIDE: usize = 4;19577+ );
19319-19578+ let ii_ctx = intra_inter_ctx(
19320- let (r, c) = outer_at;19579+ has_above,
19321- let _ = (r, c);19580+ has_left,
19322- // lane-inter8 r2: this leaf's OWN mi cell, not the enclosing 16x16's --19581+ neighbours.above_inter[cmi],
19323- // leaf (mi_r, mi_c + 2)'s left neighbour is leaf (mi_r, mi_c), and the19582+ neighbours.left_inter[rmi],
19324- // left column of a 16x16's second leaf ROW is the previous 16x16 block's19583+ );
19325- // bottom leaf, neither of which a SUB-grid slot can name.19584+ let is_inter = dec.symbol(&mut cdfs.intra_inter[ii_ctx]) == 1;
19326- let (rmi, cmi) = leaf_mi;19585+ if !is_inter {
19327- // lane-inter8 r2: no sibling-leaf override any more -- each leaf stamps19586+ return Err(unsupported(
19328- // its own 2x2-mi span into the bands right after it decodes (the caller's19587+ "an intra 4x4 block inside an inter frame's sub-8x8 split (this decoder codes \
19329- // `record_inter_rect_mi`), so a plain mi read already names the correct19588+ only inter 4x4 sub-blocks there)",
19330- // neighbour, including one belonging to the previous 16x16 block.19589+ ));
19331- let above_skip = neighbours.above_skip[cmi];19590+ }
19332- let left_skip = neighbours.left_skip[rmi];19591+ // Same print point as the oracle's `EC_MODE` (entry of
19333- let above_inter = neighbours.above_inter[cmi];19592+ // `read_inter_block_mode_info`, i.e. after skip / is_inter), so the
19334- let left_inter = neighbours.left_inter[rmi];19593+ // two range ladders line up element for element.
19335- let above_ref0 = neighbours.above_ref[cmi];19594+ if std::env::var_os("EC_TRACE_MODE").is_some() {
19336- let above_ref1 = neighbours.above_ref1[cmi];19595+ eprintln!(
19337- let left_ref0 = neighbours.left_ref[rmi];19596+ "EC_MODE mi_row={rmi} mi_col={cmi} rng={}",
19338- let left_ref1 = neighbours.left_ref1[rmi];19597+ dec.debug_state().0
19339- let skip_mode_ctx =19598+ );
19340- usize::from(neighbours.above_skip_mode[cmi]) + usize::from(neighbours.left_skip_mode[rmi]);19599+ }
19341- // Same two `inter_segment_id` positions as [`decode_inter_block`]; this19600+ let ref_frame = read_single_ref(
19342- // leaf is always `BLOCK_8X8`, i.e. 2x2 mi.19601+ dec,
19343- inter_segment_id(dec, cdfs, leaf_mi.0, leaf_mi.1, 2, 2, false, true);19602+ cdfs,
19344- let skip_mode = skip_mode_present && dec.symbol(&mut cdfs.skip_mode[skip_mode_ctx]) == 1;19603+ neighbours.above_ref[cmi],
19345- if skip_mode {19604+ neighbours.above_ref1[cmi],
19605+ neighbours.left_ref[rmi],
19606+ neighbours.left_ref1[rmi],
19607+ );
19608+ let (sref_y, sref_u, sref_v) = ref_planes(ref_frame, ref_y, ref_u, ref_v, other_refs)?;
19609+ if mc::scale_factor(sref_y.width, frame_width) != mc::REF_NO_SCALE {
19610+ return Err(unsupported(
19611+ "a sub-8x8 inter block under a scaled reference (superres, unimplemented)",
19612+ ));
19613+ }
19614+ let gm_table = build_gm_mv_table(
19615+ global_motion,
19616+ rmi,
19617+ cmi,
19618+ 1,
19619+ 1,
19620+ allow_high_precision_mv,
19621+ force_integer_mv,
19622+ );
19623+ let tpl = tpl_frame.map(|t| crate::mvstack::TplArgs {
19624+ field: t.field,
19625+ cur_offset_0: crate::motion_field::get_relative_dist(
19626+ t.order_hint_bits,
19627+ t.order_hint,
19628+ t.ref_order_hints[(ref_frame - LAST_FRAME) as usize],
19629+ ),
19630+ allow_high_precision_mv,
19631+ });
19632+ let stack = crate::mvstack::find_mv_stack_with_sign_bias(
19633+ grid,
19634+ rmi,
19635+ cmi,
19636+ 1,
19637+ 1,
19638+ ref_frame,
19639+ mi_cols as usize,
19640+ mi_rows as usize,
19641+ sign_bias_table,
19642+ &gm_table,
19643+ tpl,
19644+ );
19645+ let not_new = dec.symbol(&mut cdfs.new_mv[stack.new_mv_ctx]) == 1;
19646+ let mut is_globalmv = false;
19647+ let (mv, is_new_mv) = if !not_new {
19648+ let mut idx = 0usize;
19649+ while idx < 2 && stack.entries.len() > idx + 1 {
19650+ if dec.symbol(&mut cdfs.drl_mode[stack.drl_ctx[idx]]) == 0 {
19651+ break;
19652+ }
19653+ idx += 1;
19654+ }
19655+ let base_mv = stack.entries.get(idx).map_or(stack.pred_mv, |e| e.mv);
19656+ (
19657+ read_mv(
19658+ dec,
19659+ &mut cdfs.mv_comp,
19660+ &mut cdfs.mv_joint,
19661+ base_mv,
19662+ allow_high_precision_mv,
19663+ force_integer_mv,
19664+ ),
19665+ true,
19666+ )
19667+ } else {
19668+ let not_zero = dec.symbol(&mut cdfs.zero_mv[stack.zero_mv_ctx]) == 1;
19669+ is_globalmv = !not_zero;
19670+ let mv = if !not_zero {
19671+ gm_table[(ref_frame - LAST_FRAME) as usize]
19672+ } else {
19673+ let nearest = dec.symbol(&mut cdfs.ref_mv[stack.ref_mv_ctx]) == 0;
19674+ if nearest {
19675+ stack.nearest_mv
19676+ } else {
19677+ let mut idx = 1usize;
19678+ while idx < 3 && stack.entries.len() > idx + 1 {
19679+ if dec.symbol(&mut cdfs.drl_mode[stack.drl_ctx[idx]]) == 0 {
19680+ break;
19681+ }
19682+ idx += 1;
19683+ }
19684+ stack.entries.get(idx).map_or(stack.near_mv, |e| e.mv)
19685+ }
19686+ };
19687+ (mv, false)
19688+ };
19689+ // Same print point as the oracle's `EC_MODE_MV` (right after
19690+ // `assign_mv`), the second rung of the sub-8x8 range ladder.
19691+ if std::env::var_os("EC_TRACE_MODE").is_some() {
19692+ eprintln!(
19693+ "EC_MODE_MV mi_row={rmi} mi_col={cmi} mv0=({},{}) rng={}",
19694+ mv.0,
19695+ mv.1,
19696+ dec.debug_state().0
19697+ );
19698+ }
19699+ // No `interintra` and no `motion_mode`/`obmc` symbol below 8x8 (see
19700+ // this function's own doc); `read_mb_interp_filter` still runs.
19701+ let gm_ref = &global_motion[(ref_frame - LAST_FRAME) as usize];
19702+ let above_filter_ctx = if neighbours.above_ref[cmi] == ref_frame
19703+ || neighbours.above_ref1[cmi] == Some(ref_frame)
19704+ {
19705+ neighbours.above_filter[cmi]
19706+ } else {
19707+ [3, 3]
19708+ };
19709+ let left_filter_ctx = if neighbours.left_ref[rmi] == ref_frame
19710+ || neighbours.left_ref1[rmi] == Some(ref_frame)
19711+ {
19712+ neighbours.left_filter[rmi]
19713+ } else {
19714+ [3, 3]
19715+ };
19716+ if std::env::var_os("EC_AV1_IFDBG").is_some() {
19717+ eprintln!(
19718+ "IFDBG4 mi=({rmi},{cmi}) ref={ref_frame} above_ref={} above_ref1={:?} \
19719+ above_filt={:?} left_ref={} left_ref1={:?} left_filt={:?}",
19720+ neighbours.above_ref[cmi],
19721+ neighbours.above_ref1[cmi],
19722+ neighbours.above_filter[cmi],
19723+ neighbours.left_ref[rmi],
19724+ neighbours.left_ref1[rmi],
19725+ neighbours.left_filter[rmi],
19726+ );
19727+ }
19728+ let gm_nontrans = is_globalmv && gm_ref.model != ec_av1_syntax::WarpModel::Translation;
19729+ let (h_filter, v_filter, resolved_filter) = resolve_interp_filter(
19730+ dec,
19731+ cdfs,
19732+ interp_fixed,
19733+ enable_dual_filter,
19734+ gm_nontrans,
19735+ above_filter_ctx,
19736+ left_filter_ctx,
19737+ false,
19738+ );
19739+ if std::env::var_os("EC_TRACE_MODE").is_some() {
19740+ eprintln!(
19741+ "EC_MODE_VAL4 mi_row={rmi} mi_col={cmi} newmv={is_new_mv} globalmv={is_globalmv} \
19742+ ref0={ref_frame} mv0=({},{}) stack={} rng={}",
19743+ mv.0,
19744+ mv.1,
19745+ stack.entries.len(),
19746+ dec.debug_state().0
19747+ );
19748+ }
19749+ grid.set(
19750+ rmi,
19751+ cmi,
19752+ MiInfo {
19753+ is_inter: true,
19754+ ref_frame,
19755+ ref_frame1: None,
19756+ mv1: None,
19757+ mv,
19758+ is_new_mv,
19759+ size: 1,
19760+ size_h: 1,
19761+ is_global_mv0: false,
19762+ is_global_mv1: false,
19763+ },
19764+ );
19765+ piece[i] = Some((ref_frame, mv, h_filter, v_filter));
19766+ let mut pred_y = vec![0u16; B4 * B4];
19767+ mc::predict_with_filters(
19768+ &sref_y.data,
19769+ sref_y.width,
19770+ sref_y.true_width,
19771+ sref_y.true_height,
19772+ mv_to_q4(px, mv.1, true),
19773+ mv_to_q4(py, mv.0, true),
19774+ B4,
19775+ B4,
19776+ h_filter,
19777+ v_filter,
19778+ &mut pred_y,
19779+ );
19780+ // `BLOCK_4X4` never signals a transform size, so the luma unit is the
19781+ // whole block and `get_txb_ctx` takes its `plane_bsize ==
19782+ // txsize_to_bsize[tx_size]` branch (`txb_skip_ctx = 0`, which
19783+ // `read_inter_plane`'s `plane_idx == 0` arm already assumes).
19784+ if skip {
19785+ y.reconstruct_mc(px, py, B4, &pred_y, &vec![0i32; B4 * B4]);
19786+ neighbours.record_mi_luma_rect(lmi, B4, B4, &vec![0i32; B4 * B4]);
19787+ } else {
19788+ let around = neighbours.around_mi(lmi, B4);
19789+ let (luma_grid, tx_type) = read_inter_plane(
19790+ dec,
19791+ cdfs,
19792+ if reduced_tx_set {
19793+ TxbSet::Luma4Inter
19794+ } else {
19795+ TxbSet::Luma4InterSet1
19796+ },
19797+ scan4,
19798+ 0,
19799+ around[0],
19800+ 0,
19801+ y,
19802+ px,
19803+ py,
19804+ B4,
19805+ base_q_idx,
19806+ &pred_y,
19807+ None,
19808+ None,
19809+ )?;
19810+ if i == 0 {
19811+ // `av1_get_tx_type`: an inter block's chroma inherits the
19812+ // tx_type of the CO-LOCATED luma position, which for the
19813+ // group's one chroma unit is luma (0, 0) -- the FIRST
19814+ // sub-block, not the last.
19815+ first_tx_type = tx_type;
19816+ }
19817+ neighbours.record_mi_luma_rect(lmi, B4, B4, &luma_grid);
19818+ }
19819+ neighbours.record_mode_mi(rmi, cmi, 1, 1, DC_PRED);
19820+ neighbours.record_inter_rect_mi(lmi, 1, 1, skip, true, ref_frame, resolved_filter, false);
19821+ neighbours.fill_skip_grid_rect(lmi, 1, 1, skip);
19822+ neighbours.fill_lf_grid_rect(lmi, 1, 1, B4 as u8, B4 as u8, ref_frame.max(LAST_FRAME));
19823+ last_skip = skip;
19824+ }
19825+ // Chroma, once for the whole group, on the last sub-block's own `skip`
19826+ // flag -- prediction from all four sub-blocks (2x2 pieces), residual as
19827+ // one TX_4X4 unit per plane.
19828+ let mut pred_u = vec![0u16; B4 * B4];
19829+ let mut pred_v = vec![0u16; B4 * B4];
19830+ for i in 0..4usize {
19831+ let (dr, dc) = (i / 2, i % 2);
19832+ let Some((ref_frame, mv, h_filter, v_filter)) = piece[i] else {
19833+ continue;
19834+ };
19835+ let (_, sref_u, sref_v) = ref_planes(ref_frame, ref_y, ref_u, ref_v, other_refs)?;
19836+ let (ox, oy) = (cpx + dc * 2, cpy + dr * 2);
19837+ for (plane, dst) in [(sref_u, &mut pred_u), (sref_v, &mut pred_v)] {
19838+ let mut buf = vec![0u16; 4];
19839+ mc::predict_with_filters(
19840+ &plane.data,
19841+ plane.width,
19842+ plane.true_width,
19843+ plane.true_height,
19844+ mv_to_q4(ox, mv.1, false),
19845+ mv_to_q4(oy, mv.0, false),
19846+ 2,
19847+ 2,
19848+ h_filter,
19849+ v_filter,
19850+ &mut buf,
19851+ );
19852+ for row in 0..2 {
19853+ for col in 0..2 {
19854+ dst[(dr * 2 + row) * B4 + dc * 2 + col] = buf[row * 2 + col];
19855+ }
19856+ }
19857+ }
19858+ }
19859+ let (u_grid, v_grid) = if last_skip {
19860+ u.reconstruct_mc(cpx, cpy, B4, &pred_u, &vec![0i32; B4 * B4]);
19861+ v.reconstruct_mc(cpx, cpy, B4, &pred_v, &vec![0i32; B4 * B4]);
19862+ (vec![0i32; B4 * B4], vec![0i32; B4 * B4])
19863+ } else {
19864+ let around = neighbours.around_mi(group_mi, 8);
19865+ let ug = read_inter_plane(
19866+ dec, cdfs, TxbSet::Chroma4, scan4, 1, around[1], 0, u, cpx, cpy, B4, base_q_idx,
19867+ &pred_u, Some(first_tx_type), None,
19868+ )?
19869+ .0;
19870+ let vg = read_inter_plane(
19871+ dec, cdfs, TxbSet::Chroma4, scan4, 2, around[2], 0, v, cpx, cpy, B4, base_q_idx,
19872+ &pred_v, Some(first_tx_type), None,
19873+ )?
19874+ .0;
19875+ (ug, vg)
19876+ };
19877+ neighbours.record_uv_mode_mi(gr, gc, 2, 2, DC_PRED);
19878+ // Same two neighbour tails [`decode_leaf_split4`] runs: the partition
19879+ // context of a `BLOCK_4X4` subsize (`partition_context_lookup` bit 0 = 1,
19880+ // reached by `side_mi = 4` here) and the group's chroma coefficient state.
19881+ for cell in 0..2usize {
19882+ neighbours.left_side_mi[gr + cell] = 4;
19883+ neighbours.above_side_mi[gc + cell] = 4;
19884+ }
19885+ let round_up_even = |n: usize| n.div_ceil(2) * 2;
19886+ let bound_h = round_up_even(neighbours.mi_rows);
19887+ let bound_w = round_up_even(neighbours.mi_cols);
19888+ let u_state = neighbour_state(&u_grid);
19889+ let v_state = neighbour_state(&v_grid);
19890+ for cell in 0..2usize {
19891+ if cell < 2usize.min(bound_h.saturating_sub(gr)) {
19892+ neighbours.left[gr + cell][1] = u_state;
19893+ neighbours.left[gr + cell][2] = v_state;
19894+ }
19895+ if cell < 2usize.min(bound_w.saturating_sub(gc)) {
19896+ neighbours.above[gc + cell][1] = u_state;
19897+ neighbours.above[gc + cell][2] = v_state;
19898+ }
19899+ }
19900+ Ok(())
19901+}
19902+
19903+/// Decodes a `PARTITION_HORZ`/`PARTITION_VERT` of one 8x8 INTER block into two
19904+/// `BLOCK_8X4`/`BLOCK_4X8` inter leaves (lane-intersub8 r3) -- the inter twin of
19905+/// [`decode_leaf_rect8`] and the rectangular sibling of
19906+/// [`decode_inter_sub8_split4`], whose element order it follows exactly.
19907+/// Per sub-block, in libaom `decodemv.c` `read_inter_frame_mode_info` order:
19908+///
19909+/// * `segment_id`, `skip`, `cdef`/`delta_q`/`delta_lf`, `intra_inter`;
19910+/// * NO `skip_mode` symbol: `is_comp_ref_allowed(BLOCK_8X4)` is false
19911+/// (`av1_is_comp_ref_allowed` needs both sides >= 8), so
19912+/// `read_skip_mode` returns 0 without reading and `comp_mode` is never read
19913+/// either (`read_ref_frames`' `is_comp_ref_allowed` guard) -- single
19914+/// reference only;
19915+/// * NO `interintra` and NO `motion_mode`/OBMC/warp symbol: every one of those
19916+/// gates needs `block_size_wide >= 8 && block_size_high >= 8`
19917+/// (`is_interintra_allowed_bsize`, `motion_mode_allowed`), and one side is 4;
19918+/// * `read_mb_interp_filter` DOES run for both sub-blocks.
19919+///
19920+/// The shape's own differences from the four-way split:
19921+///
19922+/// * `block_signals_txsize(BLOCK_8X4)` is true (`bsize > BLOCK_4X4`,
19923+/// blockd.h:1027), so a non-skipped sub-block reads ONE `txfm_partition`
19924+/// symbol under `TX_MODE_SELECT` at `max_txsize_rect_lookup[BLOCK_8X4] ==
19925+/// TX_8X4` ([`read_var_tx_size`]); split resolves to two `TX_4X4` units
19926+/// (`sub_tx_size_map[TX_8X4] == TX_4X4`, libaom's early return), no split to
19927+/// the whole-leaf `TX_8X4`;
19928+/// * the luma coefficient set is [`TxbSet::LumaRect8x4Inter`] (the 8x8
19929+/// coefficient class with a 32-position `eob_pt` and the INTER `TX_4X4`
19930+/// `tx_type` row) for the whole-leaf unit, and the square
19931+/// [`TxbSet::Luma4Inter`] for a split `TX_4X4` unit;
19932+/// * chroma is coded ONCE, on the sub-block that is the chroma reference:
19933+/// `is_chroma_reference` (`av1_common_int.h`) is
19934+/// `((mi_row & 1) || !(bh4 & 1) || !ss_y) && ((mi_col & 1) || !(bw4 & 1) ||
19935+/// !ss_x)`, i.e. under 4:2:0 the BOTTOM 8x4 (`bh4 == 1`, odd) and the RIGHT
19936+/// 4x8 (`bw4 == 1`) -- always the second sub-block here;
19937+/// * that chroma unit's prediction is the sub8x8 one (`reconinter.c`
19938+/// `build_inter_predictors_sub8x8`: `row_start = -(block_size_high == 4 &&
19939+/// ss_y)`, `col_start = -(block_size_wide == 4 && ss_x)`), two 4x2 (HORZ) or
19940+/// 2x4 (VERT) chroma pieces, each from its OWN sub-block's reference, mv and
19941+/// interpolation filters.
19942+#[allow(clippy::too_many_arguments)]
19943+fn decode_inter_sub8_rect2(
19944+ dec: &mut SymbolDecoder,
19945+ cdfs: &mut Cdfs,
19946+ neighbours: &mut Neighbours,
19947+ grid: &mut MiGrid,
19948+ group_mi: (usize, usize),
19949+ vert: bool,
19950+ mi_cols: u32,
19951+ mi_rows: u32,
19952+ y: &mut PlaneBuf,
19953+ u: &mut PlaneBuf,
19954+ v: &mut PlaneBuf,
19955+ ref_y: &PlaneBuf,
19956+ ref_u: &PlaneBuf,
19957+ ref_v: &PlaneBuf,
19958+ other_refs: &RefSlots,
19959+ sign_bias_table: &SignBiasTable,
19960+ global_motion: &[ec_av1_syntax::WarpParams; 7],
19961+ base_q_idx: u8,
19962+ scan4: &[u16],
19963+ allow_high_precision_mv: bool,
19964+ force_integer_mv: bool,
19965+ interp_fixed: Option<mc::InterpFilterKind>,
19966+ enable_dual_filter: bool,
19967+ tpl_frame: Option<&TplFrameArgs>,
19968+ reduced_tx_set: bool,
19969+ frame_width: usize,
19970+) -> Result<()> {
19971+ const LAST_FRAME: i8 = 1;
19972+ // The 8x8 group's own square stride: both leaves' prediction buffers are
19973+ // laid out at it, as every other rect inter unit here is.
19974+ const SIDE: usize = 8;
19975+ let (bw, bh) = if vert { (4usize, 8usize) } else { (8usize, 4usize) };
19976+ let (w_mi, h_mi) = (bw / MI, bh / MI);
19977+ SUB8_INTER_RECT_HITS.with(|c| {
19978+ let mut h = c.get();
19979+ h[usize::from(vert)] += 1;
19980+ c.set(h);
19981+ });
19982+ let (gr, gc) = group_mi;
19983+ let (gpx, gpy) = (gc * MI, gr * MI);
19984+ let (cpx, cpy) = (gpx / 2, gpy / 2);
19985+ // Per-sub-block state the group's one chroma unit predicts from.
19986+ let mut piece: [Option<(i8, (i32, i32), mc::InterpFilterKind, mc::InterpFilterKind)>; 2] =
19987+ [None; 2];
19988+ let mut first_tx_type = TxType::DctDct;
19989+ let mut last_skip = true;
19990+ for i in 0..2usize {
19991+ let lmi = if vert { (gr, gc + i) } else { (gr + i, gc) };
19992+ if lmi.0 >= mi_rows as usize || lmi.1 >= mi_cols as usize {
19993+ continue;
19994+ }
19995+ let (rmi, cmi) = lmi;
19996+ let (px, py) = (cmi * MI, rmi * MI);
19997+ inter_segment_id(dec, cdfs, rmi, cmi, w_mi, h_mi, false, true);
19998+ let skip_ctx =
19999+ usize::from(neighbours.above_skip[cmi]) + usize::from(neighbours.left_skip[rmi]);
20000+ let skip = dec.symbol(&mut cdfs.skip[skip_ctx]) == 1;
20001+ inter_segment_id(dec, cdfs, rmi, cmi, w_mi, h_mi, skip, false);
20002+ maybe_read_cdef_idx(dec, rmi, cmi, skip);
20003+ maybe_read_delta_q(dec, cdfs, rmi, cmi, false, skip);
20004+ maybe_read_delta_lf(dec, cdfs, rmi, cmi, false, skip);
20005+ let (has_above, has_left) = (
20006+ rmi > neighbours.tile_row0_mi,
20007+ cmi > neighbours.tile_col0_mi,
20008+ );
20009+ let ii_ctx = intra_inter_ctx(
20010+ has_above,
20011+ has_left,
20012+ neighbours.above_inter[cmi],
20013+ neighbours.left_inter[rmi],
20014+ );
20015+ let is_inter = dec.symbol(&mut cdfs.intra_inter[ii_ctx]) == 1;
20016+ if !is_inter {
20017+ return Err(unsupported(
20018+ "an intra 8x4/4x8 block inside an inter frame's sub-8x8 HORZ/VERT partition \
20019+ (this decoder codes only inter sub-blocks there)",
20020+ ));
20021+ }
20022+ if std::env::var_os("EC_TRACE_MODE").is_some() {
20023+ eprintln!(
20024+ "EC_MODE mi_row={rmi} mi_col={cmi} rng={}",
20025+ dec.debug_state().0
20026+ );
20027+ }
20028+ let ref_frame = read_single_ref(
20029+ dec,
20030+ cdfs,
20031+ neighbours.above_ref[cmi],
20032+ neighbours.above_ref1[cmi],
20033+ neighbours.left_ref[rmi],
20034+ neighbours.left_ref1[rmi],
20035+ );
20036+ let (sref_y, _, _) = ref_planes(ref_frame, ref_y, ref_u, ref_v, other_refs)?;
20037+ if mc::scale_factor(sref_y.width, frame_width) != mc::REF_NO_SCALE {
20038+ return Err(unsupported(
20039+ "a sub-8x8 inter block under a scaled reference (superres, unimplemented)",
20040+ ));
20041+ }
20042+ let gm_table = build_gm_mv_table(
20043+ global_motion,
20044+ rmi,
20045+ cmi,
20046+ w_mi,
20047+ h_mi,
20048+ allow_high_precision_mv,
20049+ force_integer_mv,
20050+ );
20051+ let tpl = tpl_frame.map(|t| crate::mvstack::TplArgs {
20052+ field: t.field,
20053+ cur_offset_0: crate::motion_field::get_relative_dist(
20054+ t.order_hint_bits,
20055+ t.order_hint,
20056+ t.ref_order_hints[(ref_frame - LAST_FRAME) as usize],
20057+ ),
20058+ allow_high_precision_mv,
20059+ });
20060+ let stack = crate::mvstack::find_mv_stack_with_sign_bias(
20061+ grid,
20062+ rmi,
20063+ cmi,
20064+ w_mi,
20065+ h_mi,
20066+ ref_frame,
20067+ mi_cols as usize,
20068+ mi_rows as usize,
20069+ sign_bias_table,
20070+ &gm_table,
20071+ tpl,
20072+ );
20073+ let not_new = dec.symbol(&mut cdfs.new_mv[stack.new_mv_ctx]) == 1;
20074+ let mut is_globalmv = false;
20075+ let (mv, is_new_mv) = if !not_new {
20076+ let mut idx = 0usize;
20077+ while idx < 2 && stack.entries.len() > idx + 1 {
20078+ if dec.symbol(&mut cdfs.drl_mode[stack.drl_ctx[idx]]) == 0 {
20079+ break;
20080+ }
20081+ idx += 1;
20082+ }
20083+ let base_mv = stack.entries.get(idx).map_or(stack.pred_mv, |e| e.mv);
20084+ (
20085+ read_mv(
20086+ dec,
20087+ &mut cdfs.mv_comp,
20088+ &mut cdfs.mv_joint,
20089+ base_mv,
20090+ allow_high_precision_mv,
20091+ force_integer_mv,
20092+ ),
20093+ true,
20094+ )
20095+ } else {
20096+ let not_zero = dec.symbol(&mut cdfs.zero_mv[stack.zero_mv_ctx]) == 1;
20097+ is_globalmv = !not_zero;
20098+ let mv = if !not_zero {
20099+ gm_table[(ref_frame - LAST_FRAME) as usize]
20100+ } else {
20101+ let nearest = dec.symbol(&mut cdfs.ref_mv[stack.ref_mv_ctx]) == 0;
20102+ if nearest {
20103+ stack.nearest_mv
20104+ } else {
20105+ let mut idx = 1usize;
20106+ while idx < 3 && stack.entries.len() > idx + 1 {
20107+ if dec.symbol(&mut cdfs.drl_mode[stack.drl_ctx[idx]]) == 0 {
20108+ break;
20109+ }
20110+ idx += 1;
20111+ }
20112+ stack.entries.get(idx).map_or(stack.near_mv, |e| e.mv)
20113+ }
20114+ };
20115+ (mv, false)
20116+ };
20117+ if std::env::var_os("EC_TRACE_MODE").is_some() {
20118+ eprintln!(
20119+ "EC_MODE_MV mi_row={rmi} mi_col={cmi} mv0=({},{}) rng={}",
20120+ mv.0,
20121+ mv.1,
20122+ dec.debug_state().0
20123+ );
20124+ }
20125+ let gm_ref = &global_motion[(ref_frame - LAST_FRAME) as usize];
20126+ let above_filter_ctx = if neighbours.above_ref[cmi] == ref_frame
20127+ || neighbours.above_ref1[cmi] == Some(ref_frame)
20128+ {
20129+ neighbours.above_filter[cmi]
20130+ } else {
20131+ [3, 3]
20132+ };
20133+ let left_filter_ctx = if neighbours.left_ref[rmi] == ref_frame
20134+ || neighbours.left_ref1[rmi] == Some(ref_frame)
20135+ {
20136+ neighbours.left_filter[rmi]
20137+ } else {
20138+ [3, 3]
20139+ };
20140+ let gm_nontrans = is_globalmv && gm_ref.model != ec_av1_syntax::WarpModel::Translation;
20141+ let (h_filter, v_filter, resolved_filter) = resolve_interp_filter(
20142+ dec,
20143+ cdfs,
20144+ interp_fixed,
20145+ enable_dual_filter,
20146+ gm_nontrans,
20147+ above_filter_ctx,
20148+ left_filter_ctx,
20149+ false,
20150+ );
20151+ // `read_block_tx_size` (libaom `decodeframe.c`): unlike a `BLOCK_4X4`,
20152+ // this shape signals its transform size. A non-skipped inter block
20153+ // walks the var-tx tree from `max_txsize_rect_lookup[BLOCK_8X4]`; a
20154+ // skipped one codes nothing and records its BLOCK size in both txfm
20155+ // contexts (`set_txfm_ctxs`' `skip_inter` arm).
20156+ let mut leaves: Vec<(usize, usize, usize, usize)> = Vec::new();
20157+ if TX_SELECT_INTER.with(std::cell::Cell::get) && !skip {
20158+ let max_w_mi = w_mi.min((mi_cols as usize).saturating_sub(cmi));
20159+ let max_h_mi = h_mi.min((mi_rows as usize).saturating_sub(rmi));
20160+ read_var_tx_size(
20161+ dec,
20162+ cdfs,
20163+ neighbours,
20164+ lmi,
20165+ SIDE,
20166+ (max_w_mi, max_h_mi),
20167+ (bw, bh),
20168+ 0,
20169+ 0,
20170+ 0,
20171+ &mut leaves,
20172+ );
20173+ } else {
20174+ leaves.push((0, 0, bw, bh));
20175+ set_txfm_ctxs(neighbours, lmi, bw.max(bh), w_mi, h_mi, skip);
20176+ }
20177+ if std::env::var_os("EC_TRACE_MODE").is_some() {
20178+ eprintln!(
20179+ "EC_MODE_VALR mi_row={rmi} mi_col={cmi} newmv={is_new_mv} globalmv={is_globalmv} \
20180+ ref0={ref_frame} mv0=({},{}) stack={} leaves={} rng={}",
20181+ mv.0,
20182+ mv.1,
20183+ stack.entries.len(),
20184+ leaves.len(),
20185+ dec.debug_state().0
20186+ );
20187+ }
20188+ grid_stamp_rect(grid, rmi, cmi, w_mi, h_mi, ref_frame, mv, is_new_mv);
20189+ piece[i] = Some((ref_frame, mv, h_filter, v_filter));
20190+ // Prediction over the leaf's true footprint, laid out at the group's
20191+ // square stride (what `reconstruct_mc_rect` and `read_inter_plane_rect`
20192+ // index with).
20193+ let mut pred_y = vec![0u16; SIDE * SIDE];
20194+ {
20195+ let mut dense = vec![0u16; bw * bh];
20196+ mc::predict_with_filters(
20197+ &sref_y.data,
20198+ sref_y.width,
20199+ sref_y.true_width,
20200+ sref_y.true_height,
20201+ mv_to_q4(px, mv.1, true),
20202+ mv_to_q4(py, mv.0, true),
20203+ bw,
20204+ bh,
20205+ h_filter,
20206+ v_filter,
20207+ &mut dense,
20208+ );
20209+ for row in 0..bh {
20210+ pred_y[row * SIDE..][..bw].copy_from_slice(&dense[row * bw..][..bw]);
20211+ }
20212+ }
20213+ if skip {
20214+ y.reconstruct_mc_rect(px, py, SIDE, bw, bh, &pred_y, &vec![0i32; SIDE * SIDE]);
20215+ neighbours.record_mi_luma_rect(lmi, bw, bh, &vec![0i32; bw * bh]);
20216+ neighbours.fill_lf_grid_rect(lmi, w_mi, h_mi, bw as u8, bh as u8, ref_frame.max(LAST_FRAME));
20217+ } else {
20218+ let (mut last_tw, mut last_th) = (bw, bh);
20219+ for (idx, &(row, col, tw, th)) in leaves.iter().enumerate() {
20220+ let tu_mi = (rmi + row, cmi + col);
20221+ let (tu_px, tu_py) = (px + col * MI, py + row * MI);
20222+ let (tu_grid, tu_tx_type) = if tw == th {
20223+ // A split `TX_4X4` unit: square reader, its own
20224+ // `get_txb_ctx_general` neighbour context (the unit is
20225+ // smaller than its plane block, so the lone-TU 0 does not
20226+ // apply).
20227+ let mut tu_pred = Vec::with_capacity(tw * th);
20228+ for rr in 0..th {
20229+ let start = (row * MI + rr) * SIDE + col * MI;
20230+ tu_pred.extend_from_slice(&pred_y[start..start + tw]);
20231+ }
20232+ let tu_skip_ctx = neighbours.luma_skip_ctx_rect(tu_mi, tw / MI, th / MI);
20233+ read_inter_plane(
20234+ dec,
20235+ cdfs,
20236+ if reduced_tx_set {
20237+ TxbSet::Luma4Inter
20238+ } else {
20239+ TxbSet::Luma4InterSet1
20240+ },
20241+ scan4,
20242+ 0,
20243+ neighbours.around_mi(tu_mi, tw)[0],
20244+ 0,
20245+ y,
20246+ tu_px,
20247+ tu_py,
20248+ tw,
20249+ base_q_idx,
20250+ &tu_pred,
20251+ None,
20252+ Some(tu_skip_ctx),
20253+ )?
20254+ } else {
20255+ // The whole leaf as one `TX_8X4`/`TX_4X8` unit: it IS the
20256+ // plane block, so `get_txb_ctx_general` fixes `txb_skip_ctx`
20257+ // at 0 (`luma_skip_ctx: None`).
20258+ let start = row * MI * SIDE + col * MI;
20259+ read_inter_plane_rect(
20260+ dec,
20261+ cdfs,
20262+ if reduced_tx_set {
20263+ TxbSet::LumaRect8x4Inter
20264+ } else {
20265+ TxbSet::LumaRect8x4InterSet1
20266+ },
20267+ (tw, th),
20268+ SIDE,
20269+ 0,
20270+ neighbours.around_mi_rect(tu_mi, tw, th)[0],
20271+ 0,
20272+ y,
20273+ tu_px,
20274+ tu_py,
20275+ &pred_y[start..],
20276+ None,
20277+ None,
20278+ )?
20279+ };
20280+ if idx == 0 {
20281+ // `av1_get_tx_type`: the group's one chroma unit scales
20282+ // back to luma (0, 0), i.e. the FIRST sub-block's first
20283+ // transform unit.
20284+ first_tx_type = tu_tx_type;
20285+ }
20286+ neighbours.record_mi_luma_rect(tu_mi, tw, th, &tu_grid);
20287+ (last_tw, last_th) = (tw, th);
20288+ }
20289+ neighbours.fill_lf_grid_rect(
20290+ lmi,
20291+ w_mi,
20292+ h_mi,
20293+ last_tw as u8,
20294+ last_th as u8,
20295+ ref_frame.max(LAST_FRAME),
20296+ );
20297+ }
20298+ neighbours.record_mode_mi(rmi, cmi, w_mi, h_mi, DC_PRED);
20299+ neighbours.record_inter_rect_mi(lmi, w_mi, h_mi, skip, true, ref_frame, resolved_filter, false);
20300+ neighbours.fill_skip_grid_rect(lmi, w_mi, h_mi, skip);
20301+ last_skip = skip;
20302+ }
20303+ // The group's single 4x4 chroma unit per plane, on the chroma-reference
20304+ // (second) sub-block's own skip flag.
20305+ const B4: usize = 4;
20306+ let mut pred_u = vec![0u16; B4 * B4];
20307+ let mut pred_v = vec![0u16; B4 * B4];
20308+ let (piece_w, piece_h) = if vert { (2usize, 4usize) } else { (4usize, 2usize) };
20309+ for i in 0..2usize {
20310+ let Some((ref_frame, mv, h_filter, v_filter)) = piece[i] else {
20311+ continue;
20312+ };
20313+ let (_, sref_u, sref_v) = ref_planes(ref_frame, ref_y, ref_u, ref_v, other_refs)?;
20314+ let (ox, oy) = if vert {
20315+ (cpx + i * piece_w, cpy)
20316+ } else {
20317+ (cpx, cpy + i * piece_h)
20318+ };
20319+ let (dc, dr) = if vert { (i * piece_w, 0) } else { (0, i * piece_h) };
20320+ for (plane, dst) in [(sref_u, &mut pred_u), (sref_v, &mut pred_v)] {
20321+ let mut buf = vec![0u16; piece_w * piece_h];
20322+ mc::predict_with_filters(
20323+ &plane.data,
20324+ plane.width,
20325+ plane.true_width,
20326+ plane.true_height,
20327+ mv_to_q4(ox, mv.1, false),
20328+ mv_to_q4(oy, mv.0, false),
20329+ piece_w,
20330+ piece_h,
20331+ h_filter,
20332+ v_filter,
20333+ &mut buf,
20334+ );
20335+ for row in 0..piece_h {
20336+ for col in 0..piece_w {
20337+ dst[(dr + row) * B4 + dc + col] = buf[row * piece_w + col];
20338+ }
20339+ }
20340+ }
20341+ }
20342+ let (u_grid, v_grid) = if last_skip {
20343+ u.reconstruct_mc(cpx, cpy, B4, &pred_u, &vec![0i32; B4 * B4]);
20344+ v.reconstruct_mc(cpx, cpy, B4, &pred_v, &vec![0i32; B4 * B4]);
20345+ (vec![0i32; B4 * B4], vec![0i32; B4 * B4])
20346+ } else {
20347+ let around = neighbours.around_mi(group_mi, 8);
20348+ let ug = read_inter_plane(
20349+ dec, cdfs, TxbSet::Chroma4, scan4, 1, around[1], 0, u, cpx, cpy, B4, base_q_idx,
20350+ &pred_u, Some(first_tx_type), None,
20351+ )?
20352+ .0;
20353+ let vg = read_inter_plane(
20354+ dec, cdfs, TxbSet::Chroma4, scan4, 2, around[2], 0, v, cpx, cpy, B4, base_q_idx,
20355+ &pred_v, Some(first_tx_type), None,
20356+ )?
20357+ .0;
20358+ (ug, vg)
20359+ };
20360+ neighbours.record_uv_mode_mi(gr, gc, 2, 2, DC_PRED);
20361+ // `update_partition_context` writes `partition_context_lookup[subsize]`
20362+ // over the whole 8x8 span -- BLOCK_4X8's width above and height left, the
20363+ // same values [`decode_leaf_rect8`] writes for the intra shape.
20364+ for cell in 0..2usize {
20365+ neighbours.above_side_mi[gc + cell] = bw;
20366+ neighbours.left_side_mi[gr + cell] = bh;
20367+ }
20368+ let round_up_even = |n: usize| n.div_ceil(2) * 2;
20369+ let bound_h = round_up_even(neighbours.mi_rows);
20370+ let bound_w = round_up_even(neighbours.mi_cols);
20371+ let u_state = neighbour_state(&u_grid);
20372+ let v_state = neighbour_state(&v_grid);
20373+ for cell in 0..2usize {
20374+ if cell < 2usize.min(bound_h.saturating_sub(gr)) {
20375+ neighbours.left[gr + cell][1] = u_state;
20376+ neighbours.left[gr + cell][2] = v_state;
20377+ }
20378+ if cell < 2usize.min(bound_w.saturating_sub(gc)) {
20379+ neighbours.above[gc + cell][1] = u_state;
20380+ neighbours.above[gc + cell][2] = v_state;
20381+ }
20382+ }
20383+ Ok(())
20384+}
20385+
20386+/// Stamps one sub-8x8 inter leaf into every mi cell of its true `w_mi`x`h_mi`
20387+/// footprint (class: a rect block's grid span is its own, never a square guess).
20388+fn grid_stamp_rect(
20389+ grid: &mut MiGrid,
20390+ mi_row: usize,
20391+ mi_col: usize,
20392+ w_mi: usize,
20393+ h_mi: usize,
20394+ ref_frame: i8,
20395+ mv: (i32, i32),
20396+ is_new_mv: bool,
20397+) {
20398+ for dr in 0..h_mi {
20399+ for dc in 0..w_mi {
20400+ grid.set(
20401+ mi_row + dr,
20402+ mi_col + dc,
20403+ MiInfo {
20404+ is_inter: true,
20405+ ref_frame,
20406+ ref_frame1: None,
20407+ mv1: None,
20408+ mv,
20409+ is_new_mv,
20410+ size: w_mi,
20411+ size_h: h_mi,
20412+ is_global_mv0: false,
20413+ is_global_mv1: false,
20414+ },
20415+ );
20416+ }
20417+ }
20418+}
20419+
20420+/// Decodes one 8x8 leaf of a straddling 16x16 inter-frame block
20421+/// (lane-av1inter8), mirroring [`crate::tile::write_inter_frame_leaf8`]'s
20422+/// exact symbol order: its own skip flag, intra/inter choice and (when
20423+/// inter) `NEARESTMV`/`NEWMV` chain against this leaf's own 2x2-mi mv-stack
20424+/// window, or (when intra) `Y_MODE`, then its own luma and two chroma
20425+/// transform blocks through [`TxbSet::Luma8Inter`]/[`TxbSet::Chroma4`],
20426+/// same as [`decode_leaf8`]'s coefficient layer but with
20427+/// motion-compensated prediction instead of intra prediction when inter.
20428+/// `outer_at` (in [`SUB`]-grid units) is the enclosing 16x16 slot's
20429+/// skip/intra-inter context, overridden by `prev_leaf` exactly as
20430+/// [`decode_leaf8`] overrides mode context: `Neighbours`' above/left arrays
20431+/// only resolve to [`SUB`] granularity. Hands back this leaf's own skip flag
20432+/// and intra/inter choice, for the next leaf or the caller's final
20433+/// write-back.
20434+#[allow(clippy::too_many_arguments)]
20435+fn decode_inter_block8(
20436+ dec: &mut SymbolDecoder,
20437+ cdfs: &mut Cdfs,
20438+ neighbours: &mut Neighbours,
20439+ grid: &mut MiGrid,
20440+ mi_cols: u32,
20441+ mi_rows: u32,
20442+ outer_at: (usize, usize),
20443+ leaf_mi: (usize, usize),
20444+ y: &mut PlaneBuf,
20445+ u: &mut PlaneBuf,
20446+ v: &mut PlaneBuf,
20447+ ref_y: &PlaneBuf,
20448+ ref_u: &PlaneBuf,
20449+ ref_v: &PlaneBuf,
20450+ other_refs: &RefSlots,
20451+ base_q_idx: u8,
20452+ scan8: &[u16],
20453+ scan4: &[u16],
20454+ allow_high_precision_mv: bool,
20455+ force_integer_mv: bool,
20456+ // lane-gmaffine r1: this frame header's own `global_motion` table (spec
20457+ // 5.9.24), indexed `[ref_frame - LAST_FRAME]` -- same table
20458+ // [`decode_inter_block`] takes, threaded here so the 8x8 leaf can code
20459+ // `GLOBALMV` (`gm_get_motion_vector`), fill its mv stack's missing
20460+ // candidates with the gm mv (gm r6's root cause) and build a global
20461+ // warp prediction.
20462+ global_motion: &[ec_av1_syntax::WarpParams; 7],
20463+ // lane-gmaffine r1: this sequence header's own `enable_dual_filter` bit,
20464+ // for the leaf's own `read_mb_interp_filter` below.
20465+ enable_dual_filter: bool,
20466+ // lane-av1comp: see [`decode_inter_block`]'s own doc -- this leaf path
20467+ // only ever tracks a coarse `LAST_FRAME`-or-intra neighbour shape (no
20468+ // per-leaf `above_ref`/`left_ref` array exists here), so `comp_mode`'s
20469+ // context uses that same approximation.
20470+ reference_select: bool,
20471+ enable_masked_compound: bool,
20472+ // lane-sb128 r4: see [`decode_inter_block`]'s own doc -- `BLOCK_8X8` is
20473+ // always `is_interintra_allowed_bsize`-eligible, so this leaf's own gate
20474+ // drops the `side` check entirely.
20475+ enable_interintra_compound: bool,
20476+ enable_jnt_comp: bool,
20477+ order_hint_bits: u32,
20478+ order_hint: u32,
20479+ ref_order_hints: [u32; 7],
20480+ // lane-av1comp round 14: see [`decode_inter_block`]'s own doc -- this
20481+ // leaf has no per-leaf `above_skip_mode`/`left_skip_mode` array either,
20482+ // so its `skip_mode` context reuses the same [`SUB`]-grid
20483+ // `above_skip_mode[cmi]`/`left_skip_mode[rmi]` the enclosing 16x16 slot
20484+ // tracks (mirroring `above_skip`/`left_skip`'s own leaf approximation
20485+ // just above).
20486+ skip_mode_present: bool,
20487+ skip_mode_frame: [u8; 2],
20488+ // lane-cdffwd2: this frame header's own `reduced_tx_set` bit -- see
20489+ // [`decode_inter_frame_tile_with_cdfs`]'s own doc.
20490+ reduced_tx_set: bool,
20491+ // lane-motionmode round 3: this frame header's own `is_motion_mode_switchable`/
20492+ // `allow_warped_motion` bits (spec 5.11.24's `read_motion_mode`), plus
20493+ // the fixed/switchable interp filter kind `obmc_blend`'s own neighbour
20494+ // reads need (see [`decode_inter_block`]'s own doc) -- this leaf's own
20495+ // prediction is always `Regular` (documented corner-cut, `mc::predict`
20496+ // has no filter param), but an OBMC neighbour can be a real 16x16+
20497+ // block that DID resolve a switchable filter.
20498+ interp_fixed: Option<mc::InterpFilterKind>,
20499+ switchable_motion_mode: bool,
20500+ allow_warped_motion: bool,
20501+ // lane-av1comp: `Some((ref1, comp_group_idx, compound_idx))` only for a
20502+ // real `COMPOUND_REFERENCE` leaf, for the caller's own end-of-16x16
20503+ // `record_compound_ctx` call -- mirrors [`decode_inter_block`]'s own
20504+ // `compound_ctx` local, just handed back instead of applied here (this
20505+ // fn's `neighbours` recording happens once for the whole straddling
20506+ // 16x16 block, after every leaf).
20507+ // lane-screen r2: see [`decode_inter_block`]'s own copy of this param --
20508+ // `BLOCK_8X8` (this leaf's fixed size) is always `av1_allow_palette`-
20509+ // eligible (`bsize >= BLOCK_8X8`).
20510+ allow_screen_content_tools: bool,
20511+ // lane-inter8 r1: the leaf's mv stacks used to be built without the
20512+ // frame's sign-bias table (`NO_SIGN_BIAS`), while [`decode_inter_block`]
20513+ // one level up passed it -- it changes the candidate list and with it
20514+ // `new_mv_ctx`/`ref_mv_ctx`, `drl_ctx` and the number of symbols read.
20515+ // Measured: an 8x8 compound NEAR_NEWMV leaf desynced against aomdec's
20516+ // EC_MODE ladder at exactly this block (mi 4,14 of the mandelbrot
20517+ // 8x8-split gate).
20518+ sign_bias_table: &SignBiasTable,
20519+ // lane-inter8 r2: the frame's temporal mv field (spec 7.10.2.8), which
20520+ // [`decode_inter_block`] one level up has always passed and this leaf
20521+ // passed `None` for -- a `use_ref_frame_mvs` frame's stack then holds
20522+ // fewer candidates here than in the reference decoder, which changes the
20523+ // mode contexts AND the number of `drl_mode` bits read (class parsed
20524+ // then discarded).
20525+ tpl_frame: Option<&TplFrameArgs>,
20526+ // lane-scaledref r1: this frame's own coded luma width (spec 7.11.3.3),
20527+ // for the scaled-reference MC this leaf's own single-ref/compound/OBMC
20528+ // predictions take when a stored reference was coded at another width
20529+ // (`use_superres`) -- mirrors [`decode_inter_block`]'s own param.
20530+ frame_width: usize,
20531+) -> Result<(bool, bool, bool, Option<(i8, i8, u8, u8)>, [u8; 2], (i8, Option<i8>))> {
20532+ const LAST_FRAME: i8 = 1;
20533+ // lane-gmaffine r2: the leaf's OWN switchable-filter symbols, handed back
20534+ // so the caller stamps them into `Neighbours` instead of the `[3, 3]`
20535+ // placeholder. `[3, 3]` is the "intra neighbour, no filter" sentinel: an
20536+ // OBMC blend that picks such a neighbour up feeds it to
20537+ // `neighbour_filter`, which PANICS on it (`from_switchable_symbol`) --
20538+ // that was the warp gate's crash, not an entropy desync. Stays `[3, 3]`
20539+ // on the intra and compound paths.
20540+ let mut leaf_filter_syms = [3u8; 2];
20541+ // lane-gmaffine r1: this leaf's GLOBALMV vector AND the mv stack's
20542+ // missing-candidate fallback both come from the frame's global motion
20543+ // evaluated at THIS block's centre (gm r6's root cause).
20544+ let gm_table = build_gm_mv_table(
20545+ global_motion,
20546+ leaf_mi.0,
20547+ leaf_mi.1,
20548+ 2,
20549+ 2,
20550+ allow_high_precision_mv,
20551+ force_integer_mv,
20552+ );
20553+ /// `Y_MODE`'s size group (`common_data.h`'s `size_group_lookup[BLOCK_8X8]`).
20554+ const SIZE_GROUP_8: usize = 1;
20555+
20556+ let (px, py) = (leaf_mi.1 * MI, leaf_mi.0 * MI);
20557+ let (cpx, cpy) = (px / 2, py / 2);
20558+ // lane-txselect: whether this leaf's `TxMode::Select` var-tx tree took
20559+ // the one split a `BLOCK_8X8` can take (`read_block_tx_size` below) --
20560+ // read back by the luma residual read and the tail's neighbour/loop-filter
20561+ // bookkeeping. Always `false` outside a `TxMode::Select` inter frame.
20562+ let mut split8 = false;
20563+ const SIDE: usize = 8;
20564+ const CHROMA_SIDE: usize = 4;
20565+
20566+ let (r, c) = outer_at;
20567+ // lane-inter8 r2: this leaf's OWN mi cell, not the enclosing 16x16's --
20568+ // leaf (mi_r, mi_c + 2)'s left neighbour is leaf (mi_r, mi_c), and the
20569+ // left column of a 16x16's second leaf ROW is the previous 16x16 block's
20570+ // bottom leaf, neither of which a SUB-grid slot can name.
20571+ let (rmi, cmi) = leaf_mi;
20572+ // lane-inter8 r2: no sibling-leaf override any more -- each leaf stamps
20573+ // its own 2x2-mi span into the bands right after it decodes (the caller's
20574+ // `record_inter_rect_mi`), so a plain mi read already names the correct
20575+ // neighbour, including one belonging to the previous 16x16 block.
20576+ let above_skip = neighbours.above_skip[cmi];
20577+ let left_skip = neighbours.left_skip[rmi];
20578+ let above_inter = neighbours.above_inter[cmi];
20579+ let left_inter = neighbours.left_inter[rmi];
20580+ let above_ref0 = neighbours.above_ref[cmi];
20581+ let above_ref1 = neighbours.above_ref1[cmi];
20582+ let left_ref0 = neighbours.left_ref[rmi];
20583+ let left_ref1 = neighbours.left_ref1[rmi];
20584+ let skip_mode_ctx =
20585+ usize::from(neighbours.above_skip_mode[cmi]) + usize::from(neighbours.left_skip_mode[rmi]);
20586+ // Same two `inter_segment_id` positions as [`decode_inter_block`]; this
20587+ // leaf is always `BLOCK_8X8`, i.e. 2x2 mi.
20588+ inter_segment_id(dec, cdfs, leaf_mi.0, leaf_mi.1, 2, 2, false, true);
20589+ let skip_mode = skip_mode_present && dec.symbol(&mut cdfs.skip_mode[skip_mode_ctx]) == 1;
20590+ if skip_mode {
19346 SKIP_MODE_HITS.with(|c| c.set(c.get() + 1));20591 SKIP_MODE_HITS.with(|c| c.set(c.get() + 1));
19347 }20592 }
19348 20593
@@ -19373,6 +20618,10 @@ fn decode_inter_block8(
19373 }20618 }
19374 20619
19375 let mode_for_tx;20620 let mode_for_tx;
20621+ // lane-uv8 r1: this leaf's chroma prediction mode (`get_uv_mode` of the
20622+ // coded `uv_mode`), for the neighbour bands at the tail. An INTER leaf
20623+ // stores `UV_DC_PRED`, exactly as [`decode_inter_block`] one level up.
20624+ let mut uv_predict_mode = DC_PRED;
19376 let (luma_grid, u_grid, v_grid);20625 let (luma_grid, u_grid, v_grid);
19377 let mut compound_ctx8: Option<(i8, i8, u8, u8)> = None;20626 let mut compound_ctx8: Option<(i8, i8, u8, u8)> = None;
19378 // lane-inter8 r1: this leaf's own resolved references, handed back so the20627 // lane-inter8 r1: this leaf's own resolved references, handed back so the
@@ -19405,21 +20654,24 @@ fn decode_inter_block8(
19405 let (ref0, ref1) = if skip_mode {20654 let (ref0, ref1) = if skip_mode {
19406 (skip_mode_frame[0] as i8, skip_mode_frame[1] as i8)20655 (skip_mode_frame[0] as i8, skip_mode_frame[1] as i8)
19407 } else {20656 } else {
20657+ // lane-interp3 r2 (class twin-functions-drift): this leaf
20658+ // passed a hard-coded `LAST_FRAME` for every inter
20659+ // neighbour -- the old "coarse LAST_FRAME-or-intra"
20660+ // approximation -- while the side bands have carried the
20661+ // neighbour's REAL reference per mi since lane-inter8 r2.
20662+ // Every `av1_collect_neighbors_ref_counts` vote below
20663+ // (`uni_comp_ref_p1`, `comp_ref`, `comp_bwdref`, ...) was
20664+ // therefore taken off the wrong CDF row. Same two args
20665+ // [`decode_inter_block`]'s own compound arm passes
20666+ // (`-1` when the band is unavailable is start_tile's /
20667+ // start_row's own reset value, so no `has_above` guard).
19408 read_compound_ref_frames(20668 read_compound_ref_frames(
19409 dec,20669 dec,
19410 cdfs,20670 cdfs,
19411 above_nbr,20671 above_nbr,
19412 left_nbr,20672 left_nbr,
19413- if has_above && above_inter {20673+ above_ref0,
19414- LAST_FRAME20674+ left_ref0,
19415- } else {
19416- -1
19417- },
19418- if has_left && left_inter {
19419- LAST_FRAME
19420- } else {
19421- -1
19422- },
19423 )20675 )
19424 };20676 };
19425 leaf_refs = (ref0, Some(ref1));20677 leaf_refs = (ref0, Some(ref1));
@@ -19600,6 +20852,58 @@ fn decode_inter_block8(
19600 );20852 );
19601 }20853 }
19602 20854
20855+ // lane-interp3 r1: `read_mb_interp_filter` (libaom
20856+ // `decodemv.c` 1575, the tail of
20857+ // `read_inter_block_mode_info`) runs for EVERY inter block,
20858+ // compound included, right AFTER `read_compound_type` -- this
20859+ // leaf read no filter symbol at all, so a SWITCHABLE-filter
20860+ // stream lost one symbol (two under `enable_dual_filter`) at
20861+ // every compound 8x8 leaf, and the leaf recorded the `[3, 3]`
20862+ // "no filter" sentinel, which made a neighbouring OBMC block's
20863+ // `neighbour_filter` PANIC instead of blending.
20864+ // `av1_is_interp_needed` suppression terms for this arm:
20865+ // `skip_mode`, and `is_nontrans_global_motion` (mode
20866+ // GLOBAL_GLOBALMV with BOTH refs' models non-TRANSLATION) --
20867+ // WARPED_CAUSAL cannot occur on a compound block.
20868+ let gm_nontrans_c = compound_mode == 6
20869+ && global_motion[(ref0 - LAST_FRAME) as usize].model
20870+ != ec_av1_syntax::WarpModel::Translation
20871+ && global_motion[(ref1 - LAST_FRAME) as usize].model
20872+ != ec_av1_syntax::WarpModel::Translation;
20873+ // spec `get_ref_filter_type`, keyed on this block's ref0 and
20874+ // matching EITHER of the neighbour's references -- same shape
20875+ // as [`decode_inter_block`]'s compound arm. Same corner-cut as
20876+ // this leaf's single-ref arm below: the context comes from the
20877+ // enclosing 16x16's coarse slot.
20878+ let above_filter_ctx = if neighbours.above_ref[cmi] == ref0
20879+ || neighbours.above_ref1[cmi] == Some(ref0)
20880+ {
20881+ neighbours.above_filter[cmi]
20882+ } else {
20883+ [3, 3]
20884+ };
20885+ let left_filter_ctx = if neighbours.left_ref[rmi] == ref0
20886+ || neighbours.left_ref1[rmi] == Some(ref0)
20887+ {
20888+ neighbours.left_filter[rmi]
20889+ } else {
20890+ [3, 3]
20891+ };
20892+ let (h_filter, v_filter, resolved_filter) = resolve_interp_filter(
20893+ dec,
20894+ cdfs,
20895+ interp_fixed,
20896+ enable_dual_filter,
20897+ gm_nontrans_c || skip_mode,
20898+ above_filter_ctx,
20899+ left_filter_ctx,
20900+ true,
20901+ );
20902+ leaf_filter_syms = resolved_filter;
20903+ if interp_fixed.is_none() && !(gm_nontrans_c || skip_mode) {
20904+ COMPOUND8_FILTER_HITS.with(|c| c.set(c.get() + 1));
20905+ }
20906+
19603 let (py0, pu0, pv0) = ref_planes(ref0, ref_y, ref_u, ref_v, other_refs)?;20907 let (py0, pu0, pv0) = ref_planes(ref0, ref_y, ref_u, ref_v, other_refs)?;
19604 let (py1, pu1, pv1) = ref_planes(ref1, ref_y, ref_u, ref_v, other_refs)?;20908 let (py1, pu1, pv1) = ref_planes(ref1, ref_y, ref_u, ref_v, other_refs)?;
19605 let scale0 = mc::scale_factor(py0.width, frame_width);20909 let scale0 = mc::scale_factor(py0.width, frame_width);
@@ -19609,6 +20913,54 @@ fn decode_inter_block8(
19609 SCALED_BLOCK8_HITS.with(|c| c.set(c.get() + 1));20913 SCALED_BLOCK8_HITS.with(|c| c.set(c.get() + 1));
19610 }20914 }
19611 20915
20916+ // lane-interp3 r2 (class twin-functions-drift): both slots
20917+ // used to be stamped `false`, while [`decode_inter_block`]'s
20918+ // compound arm computes libaom's PER-SLOT `is_global_mv_block`
20919+ // (blockd.h:421-429 -- mode GLOBAL_GLOBALMV, block >= 8x8
20920+ // (always true for this leaf) and THAT slot's own gm model >
20921+ // TRANSLATION). A neighbour carrying the flag makes
20922+ // `setup_ref_mv_list` substitute the READER's global mv for
20923+ // the neighbour's stored one, so a cleared flag fed the next
20924+ // block's stack a stored mv where libaom has the global
20925+ // candidate -- a wrong mv stack, wrong mode contexts, and a
20926+ // desync one block later.
20927+ let is_globalmv_c = compound_mode == 6;
20928+ let is_global_mv0_c = is_globalmv_c
20929+ && global_motion[(ref0 - LAST_FRAME) as usize].model as u8 > 1;
20930+ let is_global_mv1_c = is_globalmv_c
20931+ && global_motion[(ref1 - LAST_FRAME) as usize].model as u8 > 1;
20932+ // lane-interp3 r3 (class twin-functions-drift, second
20933+ // instance): libaom applies `allow_warp`'s GLOBAL branch
20934+ // (`reconinter.c:33-55`, reached from `av1_init_warp_params`
20935+ // inside `build_inter_predictors_8x8_and_bigger`'s per-`ref`
20936+ // loop) to EVERY `is_global_mv_block` slot, compound
20937+ // included and independently of `motion_mode` -- the 16x16+
20938+ // compound arm has done this since lane-cwarp r1, this leaf
20939+ // predicted both taps translationally, so a GLOBAL_GLOBALMV
20940+ // 8x8 compound leaf under a non-TRANSLATION model drifted by
20941+ // a few luma levels, growing away from the block origin.
20942+ // `force_integer_mv` short-circuits `av1_init_warp_params`
20943+ // before `allow_warp`; chroma is 4x4 here, below
20944+ // `av1_init_warp_params`'s own 8px per-plane bound, so only
20945+ // luma warps (same rule as this leaf's single-ref arm).
20946+ let leaf_compound_warp = |ref_frame: i8, eligible: bool| {
20947+ if eligible
20948+ && !force_integer_mv
20949+ && !global_motion[(ref_frame - LAST_FRAME) as usize].invalid
20950+ {
20951+ crate::warp::global_warp_params(
20952+ global_motion[(ref_frame - LAST_FRAME) as usize].params,
20953+ )
20954+ } else {
20955+ None
20956+ }
20957+ };
20958+ let warp0_c = leaf_compound_warp(ref0, is_global_mv0_c);
20959+ let warp1_c = leaf_compound_warp(ref1, is_global_mv1_c);
20960+ if warp0_c.is_some() || warp1_c.is_some() {
20961+ COMPOUND_WARP_HITS.with(|c| c.set(c.get() + 1));
20962+ COMPOUND_WARP_HITS_8.with(|c| c.set(c.get() + 1));
20963+ }
19612 for dr in 0..2 {20964 for dr in 0..2 {
19613 for dc in 0..2 {20965 for dc in 0..2 {
19614 grid.set(20966 grid.set(
@@ -19623,19 +20975,14 @@ fn decode_inter_block8(
19623 is_new_mv: matches!(compound_mode, 2 | 3 | 4 | 5 | 7),20975 is_new_mv: matches!(compound_mode, 2 | 3 | 4 | 5 | 7),
19624 size: 2,20976 size: 2,
19625 size_h: 2,20977 size_h: 2,
19626- is_global_mv0: false,20978+ is_global_mv0: is_global_mv0_c,
19627- is_global_mv1: false,20979+ is_global_mv1: is_global_mv1_c,
19628 },20980 },
19629 );20981 );
19630 }20982 }
19631 }20983 }
19632 mode_for_tx = 0;20984 mode_for_tx = 0;
19633 20985
19634- // lane-av1comp corner-cut, matching this leaf's single-ref
19635- // arm below (`mc::predict`'s own fixed-Regular default):
19636- // `decode_inter_block8` never resolves a switchable filter,
19637- // so both compound taps use `Regular` too.
19638- use mc::InterpFilterKind::Regular;
19639 let mut inter0_y = vec![0i32; SIDE * SIDE];20986 let mut inter0_y = vec![0i32; SIDE * SIDE];
19640 mc::predict_compound_intermediate(20987 mc::predict_compound_intermediate(
19641 &py0.data,20988 &py0.data,
@@ -19647,10 +20994,17 @@ fn decode_inter_block8(
19647 scale0,20994 scale0,
19648 SIDE,20995 SIDE,
19649 SIDE,20996 SIDE,
19650- Regular,20997+ h_filter,
19651- Regular,20998+ v_filter,
19652 &mut inter0_y,20999 &mut inter0_y,
19653 );21000 );
21001+ if let Some(wp) = &warp0_c {
21002+ crate::warp::warp_affine_compound(
21003+ wp, &py0.data, py0.true_width as i32, py0.true_height as i32,
21004+ py0.width as i32, &mut inter0_y, px as i32, py as i32, SIDE as i32,
21005+ SIDE as i32, SIDE as i32, 0, 0,
21006+ );
21007+ }
19654 let mut inter1_y = vec![0i32; SIDE * SIDE];21008 let mut inter1_y = vec![0i32; SIDE * SIDE];
19655 mc::predict_compound_intermediate(21009 mc::predict_compound_intermediate(
19656 &py1.data,21010 &py1.data,
@@ -19662,10 +21016,17 @@ fn decode_inter_block8(
19662 scale1,21016 scale1,
19663 SIDE,21017 SIDE,
19664 SIDE,21018 SIDE,
19665- Regular,21019+ h_filter,
19666- Regular,21020+ v_filter,
19667 &mut inter1_y,21021 &mut inter1_y,
19668 );21022 );
21023+ if let Some(wp) = &warp1_c {
21024+ crate::warp::warp_affine_compound(
21025+ wp, &py1.data, py1.true_width as i32, py1.true_height as i32,
21026+ py1.width as i32, &mut inter1_y, px as i32, py as i32, SIDE as i32,
21027+ SIDE as i32, SIDE as i32, 0, 0,
21028+ );
21029+ }
19669 let mut pred_y = vec![0u16; SIDE * SIDE];21030 let mut pred_y = vec![0u16; SIDE * SIDE];
19670 let mut diffwtd_mask_y = Vec::new();21031 let mut diffwtd_mask_y = Vec::new();
19671 let mask_y: Option<&[u8]> = if let Some(mask_type) = diffwtd_mask_type {21032 let mask_y: Option<&[u8]> = if let Some(mask_type) = diffwtd_mask_type {
@@ -19695,8 +21056,8 @@ fn decode_inter_block8(
19695 scale0,21056 scale0,
19696 CHROMA_SIDE,21057 CHROMA_SIDE,
19697 CHROMA_SIDE,21058 CHROMA_SIDE,
19698- Regular,21059+ h_filter,
19699- Regular,21060+ v_filter,
19700 &mut inter0_u,21061 &mut inter0_u,
19701 );21062 );
19702 let mut inter1_u = vec![0i32; CHROMA_SIDE * CHROMA_SIDE];21063 let mut inter1_u = vec![0i32; CHROMA_SIDE * CHROMA_SIDE];
@@ -19710,8 +21071,8 @@ fn decode_inter_block8(
19710 scale1,21071 scale1,
19711 CHROMA_SIDE,21072 CHROMA_SIDE,
19712 CHROMA_SIDE,21073 CHROMA_SIDE,
19713- Regular,21074+ h_filter,
19714- Regular,21075+ v_filter,
19715 &mut inter1_u,21076 &mut inter1_u,
19716 );21077 );
19717 let mut pred_u = vec![0u16; CHROMA_SIDE * CHROMA_SIDE];21078 let mut pred_u = vec![0u16; CHROMA_SIDE * CHROMA_SIDE];
@@ -19741,8 +21102,8 @@ fn decode_inter_block8(
19741 scale0,21102 scale0,
19742 CHROMA_SIDE,21103 CHROMA_SIDE,
19743 CHROMA_SIDE,21104 CHROMA_SIDE,
crates/ec-av1/src/refusal_inventory.rsmodified+6 -2
@@ -25,7 +25,6 @@
25 #[cfg(test)]25 #[cfg(test)]
26 const CAPABILITY_CLAIMS: &[&str] = &[26 const CAPABILITY_CLAIMS: &[&str] = &[
27 "filter intra on a superblock-level HORZ/VERT strip (never expected -- av1_filter_intra_allowed_bsize caps at 32x32)",27 "filter intra on a superblock-level HORZ/VERT strip (never expected -- av1_filter_intra_allowed_bsize caps at 32x32)",
28- "a non-DC chroma mode on an 8x8 inter-frame leaf (this encoder never writes one)",
29 ];28 ];
30 29
31 #[cfg(test)]30 #[cfg(test)]
@@ -33,7 +32,12 @@ const REFUSALS: &[&str] = &[
33 "a nonzero angle delta on an 8x8 intra leaf in an inter frame (no gate reaches this leaf with one; the >=16x16 arm decodes deltas)",32 "a nonzero angle delta on an 8x8 intra leaf in an inter frame (no gate reaches this leaf with one; the >=16x16 arm decodes deltas)",
34 "a coded HORZ/VERT strip whose chroma transform has no rect coefficient tables here",33 "a coded HORZ/VERT strip whose chroma transform has no rect coefficient tables here",
35 "a split intra strip whose transform unit is {tx_w}x{tx_h} (no luma coefficient tables for that shape here)",34 "a split intra strip whose transform unit is {tx_w}x{tx_h} (no luma coefficient tables for that shape here)",
36- "an inter partition below 8x8 (this decoder codes no inter leaf smaller than 8x8; lane-sub8 scoped to intra)",35+ "an OBMC neighbour whose interp filter was never recorded (no switchable symbol for that block)",
36+ "an intra 4x4 block inside an inter frame's sub-8x8 split (this decoder codes only inter 4x4 sub-blocks there)",
37+ "an intra 8x4/4x8 block inside an inter frame's sub-8x8 HORZ/VERT partition (this decoder codes only inter sub-blocks there)",
38+ "a sub-8x8 inter block under a scaled reference (superres, unimplemented)",
39+ "an inter 8x8 HORZ partition (two BLOCK_8X4 inter leaves; entropy-exact now, but a measured sweep still drifts |d|<=2 in luma after the filters)",
40+ "a COMPOUND_WEDGE mask on a non-square inter block (rect wedge codebook unimplemented)",
37 "a 1:4 rect strip that actually uses a palette (reconstruction is not ported at this shape)",41 "a 1:4 rect strip that actually uses a palette (reconstruction is not ported at this shape)",
38 "a 16x16 block whose true edge cuts through both axes needs a rectangular transform this decoder does not code yet",42 "a 16x16 block whose true edge cuts through both axes needs a rectangular transform this decoder does not code yet",
39 "a 16x16 inter block whose true edge cuts through both axes needs a rectangular transform this decoder does not code yet",43 "a 16x16 inter block whose true edge cuts through both axes needs a rectangular transform this decoder does not code yet",
crates/ec-av1/src/stream.rsmodified+880 -20
@@ -5685,6 +5685,283 @@ mod tests {
5685 );5685 );
5686 }5686 }
5687 5687
5688+ /// lane-uv8 r1 (classes [[refusal-strings-are-claims]] +
5689+ /// [[tool-disabled-in-every-gate]]): a real aomenc inter sequence with
5690+ /// 8x8 partitions and full chroma intra tooling
5691+ /// (`--enable-cfl-intra=1 --enable-smooth-intra=1 --enable-paeth-intra=1
5692+ /// --enable-directional-intra=1`), in which the RD gives an INTRA 8x8
5693+ /// leaf inside an inter frame a NON-DC `uv_mode`. That leaf
5694+ /// ([`decode::decode_inter_block8`]'s intra arm) read the `uv_mode`
5695+ /// symbol and refused every value but `DC_PRED` -- "this encoder never
5696+ /// writes one" was a claim, and this gate is what contradicts it. Hard-
5697+ /// asserts `decode::intra_in_inter8_uv_hits` (directional, smooth/paeth,
5698+ /// CfL, counted on THIS leaf only); an attempt that never produced one
5699+ /// proves nothing, and exhausting every attempt is a FAILURE, not a SKIP.
5700+ #[test]
5701+ fn a_real_aomenc_inter_sequence_with_a_non_dc_chroma_8x8_intra_leaf_decodes_pixel_exact() {
5702+ uv_mode_in_inter8_gate(8, 1);
5703+ }
5704+
5705+ /// The 10-bit arm (both of the user's films are `yuv420p10le`).
5706+ #[test]
5707+ fn a_real_aomenc_10bit_inter_sequence_with_a_non_dc_chroma_8x8_intra_leaf_decodes_pixel_exact() {
5708+ uv_mode_in_inter8_gate(10, 1);
5709+ }
5710+
5711+ /// The multi-tile arm (class [[new-map-ignores-tile-edge]]): this round
5712+ /// stamps a new `uv_mode` band from the 8x8 leaf, whose availability must
5713+ /// be tile-relative.
5714+ #[test]
5715+ fn a_real_aomenc_two_tile_inter_sequence_with_a_non_dc_chroma_8x8_intra_leaf_decodes_pixel_exact()
5716+ {
5717+ uv_mode_in_inter8_gate(8, 2);
5718+ }
5719+
5720+ fn uv_mode_in_inter8_gate(bit_depth: u32, tile_columns: u32) {
5721+ let name = format!("uv_mode_in_inter8_gate({bit_depth}, tiles={tile_columns})");
5722+ if !have_ffmpeg() {
5723+ eprintln!("SKIP {name}: no ffmpeg");
5724+ return;
5725+ }
5726+ if !have_aomenc() {
5727+ eprintln!("SKIP {name}: no aomenc at {}", aomenc_path().display());
5728+ return;
5729+ }
5730+ let (width, height, frame_count) = (192usize, 128usize, 8usize);
5731+ let mut refusals = Vec::new();
5732+ let mut uncounted_exact = 0u32;
5733+ let mut totals = (0usize, 0usize, 0usize);
5734+ for attempt in 0..30u32 {
5735+ let seed = 42 + attempt;
5736+ // A zooming fractal with a hard CUT at frame 4 (`overlay`
5737+ // switching a second, unrelated fractal on): after the cut a block
5738+ // is unpredictable from the reference, which is what makes aomenc
5739+ // code INTRA blocks inside an inter frame. Chroma is NOT
5740+ // desaturated here (every sibling inter gate passes `hue=s=0`) --
5741+ // real chroma detail is exactly what pushes the chroma RD off
5742+ // DC_PRED. `noise` carries its own explicit seed (lavfi
5743+ // `gradients` ignores its seed; class [[seeded-fixture-not-reproducible]]).
5744+ let source = format!(
5745+ "mandelbrot=size={width}x{height}:start_scale={}:rate=25[a];\
5746+ mandelbrot=size={width}x{height}:start_scale={}:rate=25[b];\
5747+ [a][b]overlay=enable='gte(n,4)',noise=alls=12:allf=t+u:all_seed={seed}",
5748+ 5.0 - f64::from(attempt) * 0.06,
5749+ 0.9 + f64::from(attempt) * 0.11
5750+ );
5751+ let y4m = Command::new("ffmpeg")
5752+ .args([
5753+ "-v",
5754+ "error",
5755+ "-f",
5756+ "lavfi",
5757+ "-i",
5758+ &source,
5759+ "-pix_fmt",
5760+ if bit_depth == 10 { "yuv420p10le" } else { "yuv420p" },
5761+ "-strict",
5762+ "-1",
5763+ "-t",
5764+ "0.32",
5765+ "-f",
5766+ "yuv4mpegpipe",
5767+ "-strict",
5768+ "-1",
5769+ "-",
5770+ ])
5771+ .stdin(Stdio::null())
5772+ .stdout(Stdio::piped())
5773+ .stderr(Stdio::piped())
5774+ .output()
5775+ .expect("ffmpeg failed to run");
5776+ assert!(
5777+ y4m.status.success(),
5778+ "ffmpeg fixture: {}",
5779+ String::from_utf8_lossy(&y4m.stderr)
5780+ );
5781+ // A coarser quantiser is what pushes the chroma RD to a cheap
5782+ // non-DC mode on a small block; sweep 12..40 (the low end is what
5783+ // lane-cdef's cq12 arm needs).
5784+ let cq = format!("--cq-level={}", 12 + (attempt % 5) * 7);
5785+ let depth_args: &[&str] = if bit_depth == 10 {
5786+ &["-b", "10", "--input-bit-depth=10"]
5787+ } else {
5788+ &[]
5789+ };
5790+ let tiles = format!("--tile-columns={}", tile_columns - 1);
5791+ // The y4m goes through a FILE, not aomenc's stdin: this gate's
5792+ // stream is ~100 KB, bigger than a pipe buffer, so an aomenc that
5793+ // is still being fed on stdin blocks writing its stdout and the
5794+ // test blocks writing its stdin -- a hard deadlock (measured
5795+ // here, 3 min into attempt 0, class [[gate-loader-slurps-whole-file]]).
5796+ // The path is PID-keyed (class [[pid-keyed-temp-path]]).
5797+ let y4m_path = std::env::temp_dir().join(format!(
5798+ "ec-av1-uv8-{}-{bit_depth}-{tile_columns}-{seed}.y4m",
5799+ std::process::id()
5800+ ));
5801+ std::fs::write(&y4m_path, &y4m.stdout).expect("writing the y4m fixture");
5802+ let child = Command::new(aomenc_path())
5803+ .args(depth_args)
5804+ .args([
5805+ "--codec=av1",
5806+ "--passes=1",
5807+ "--end-usage=q",
5808+ &cq,
5809+ "--cpu-used=0",
5810+ "--lag-in-frames=0",
5811+ "--auto-alt-ref=0",
5812+ "--kf-max-dist=9999",
5813+ "--kf-min-dist=9999",
5814+ "--threads=1",
5815+ "--row-mt=0",
5816+ &tiles,
5817+ "--enable-order-hint=0",
5818+ "--enable-warped-motion=0",
5819+ "--enable-obmc=0",
5820+ "--enable-masked-comp=0",
5821+ "--enable-interintra-comp=0",
5822+ "--enable-dist-wtd-comp=0",
5823+ "--enable-diff-wtd-comp=0",
5824+ "--enable-onesided-comp=0",
5825+ "--enable-interintra-wedge=0",
5826+ "--enable-smooth-interintra=0",
5827+ "--enable-ab-partitions=0",
5828+ "--enable-1to4-partitions=0",
5829+ "--enable-cdef=0",
5830+ "--enable-restoration=0",
5831+ "--enable-palette=0",
5832+ "--enable-intrabc=0",
5833+ "--enable-ref-frame-mvs=0",
5834+ // Per-arm overrides go LAST (aomenc keeps the LAST
5835+ // occurrence of a repeated --enable-* flag). The three
5836+ // chroma intra tools this gate is about, plus the fences
5837+ // that keep the leaf's SIBLING refusals (its TX_4X4
5838+ // split, a nonzero angle delta, sub-16 rect inter leaves)
5839+ // out of the way.
5840+ "--enable-cfl-intra=1",
5841+ "--enable-smooth-intra=1",
5842+ "--enable-paeth-intra=1",
5843+ "--enable-directional-intra=1",
5844+ "--enable-angle-delta=0",
5845+ "--enable-tx-size-search=0",
5846+ "--enable-rect-partitions=0",
5847+ "--min-partition-size=8",
5848+ "--max-partition-size=32",
5849+ "--obu",
5850+ "-o",
5851+ "-",
5852+ ])
5853+ .arg(&y4m_path)
5854+ .stdin(Stdio::null())
5855+ .stdout(Stdio::piped())
5856+ .stderr(Stdio::piped())
5857+ .spawn()
5858+ .expect("aomenc failed to start");
5859+ let out = child.wait_with_output().expect("aomenc failed to run");
5860+ let _ = std::fs::remove_file(&y4m_path);
5861+ assert!(
5862+ out.status.success(),
5863+ "aomenc refused the fixture: {}",
5864+ String::from_utf8_lossy(&out.stderr)
5865+ );
5866+ let stream = out.stdout;
5867+ let before = decode::intra_in_inter8_uv_hits();
5868+ let frames = match decode_stream(&stream) {
5869+ Ok(frames) => frames,
5870+ Err(e) => {
5871+ let msg = e.to_string();
5872+ assert!(
5873+ msg.contains("unsupported"),
5874+ "{name} decode failed outright (seed {seed}): {msg}"
5875+ );
5876+ refusals.push(format!("seed {seed}: {msg}"));
5877+ continue;
5878+ }
5879+ };
5880+ let now = decode::intra_in_inter8_uv_hits();
5881+ // class [[counter-from-refused-stream]]: per-attempt deltas, and
5882+ // only for an attempt that decoded to the end and is pixel-
5883+ // compared below.
5884+ let fired = (now.0 - before.0, now.1 - before.1, now.2 - before.2);
5885+ totals = (
5886+ totals.0 + fired.0,
5887+ totals.1 + fired.1,
5888+ totals.2 + fired.2,
5889+ );
5890+ // class [[gate-skips-on-its-own-failure]]: a decode that succeeded
5891+ // is ALWAYS pixel-compared; the counter only decides whether the
5892+ // attempt counts as firing.
5893+ // lane-uv8 r3: every one of the three chroma classes this gate
5894+ // exists for (directional, smooth/paeth, CfL) must fire on the
5895+ // SAME pixel-compared attempt -- a sum-nonzero predicate would
5896+ // pass on an attempt that only ever hit DC-adjacent CfL.
5897+ let counted = fired.0 > 0 && fired.1 > 0 && fired.2 > 0;
5898+ if !counted {
5899+ uncounted_exact += 1;
5900+ refusals.push(format!(
5901+ "seed {seed}: decoded and pixel-compared, but no 8x8 intra leaf in an inter \
5902+ frame carried a non-DC uv_mode"
5903+ ));
5904+ }
5905+ let ffmpeg_frames = if bit_depth == 10 {
5906+ ffmpeg_decode_sequence_10bit(&stream, width, height, frame_count)
5907+ } else {
5908+ ffmpeg_decode_sequence(&stream, width, height, frame_count)
5909+ };
5910+ assert_eq!(frames.len(), frame_count);
5911+ eprintln!(
5912+ "{name} seed={seed} {cq}: 8x8 intra-in-inter leaves with a non-DC uv_mode -- \
5913+ directional {}, smooth/paeth {}, CfL {}",
5914+ fired.0, fired.1, fired.2
5915+ );
5916+ for (i, (got, want)) in frames.iter().zip(&ffmpeg_frames).enumerate() {
5917+ for (plane, (g, w)) in [
5918+ ("Y", (&got.y, &want.y)),
5919+ ("U", (&got.u, &want.u)),
5920+ ("V", (&got.v, &want.v)),
5921+ ] {
5922+ let stride = if plane == "Y" { width } else { width / 2 };
5923+ if let Some(at) = g.iter().zip(w.iter()).position(|(a, b)| a != b) {
5924+ eprintln!(
5925+ "{name} seed={seed}: frame {i} {plane} first diff at ({}, {}) got {} \
5926+ want {} ({} samples differ)",
5927+ at % stride,
5928+ at / stride,
5929+ g[at],
5930+ w[at],
5931+ g.iter().zip(w.iter()).filter(|(a, b)| a != b).count(),
5932+ );
5933+ }
5934+ }
5935+ }
5936+ for (i, (got, want)) in frames.iter().zip(&ffmpeg_frames).enumerate() {
5937+ assert_eq!(got.y, want.y, "frame {i} luma vs ffmpeg (seed {seed})");
5938+ assert_eq!(got.u, want.u, "frame {i} U vs ffmpeg (seed {seed})");
5939+ assert_eq!(got.v, want.v, "frame {i} V vs ffmpeg (seed {seed})");
5940+ }
5941+ if counted {
5942+ gate_buckets(
5943+ &name,
5944+ 1,
5945+ uncounted_exact,
5946+ refusals.len() - uncounted_exact as usize,
5947+ );
5948+ return;
5949+ }
5950+ }
5951+ gate_buckets(
5952+ &name,
5953+ 0,
5954+ uncounted_exact,
5955+ refusals.len() - uncounted_exact as usize,
5956+ );
5957+ panic!(
5958+ "{name} never observed a non-DC uv_mode on an 8x8 intra leaf in an inter frame \
5959+ (totals dir/smooth/cfl {totals:?}):\n{}",
5960+ refusals.join("\n")
5961+ );
5962+ }
5963+
5964+
5688 /// lane-chroma r2 stage 1: a real aomenc key frame with5965 /// lane-chroma r2 stage 1: a real aomenc key frame with
5689 /// `--enable-smooth-intra=1` (opposite of every sibling recipe's `=0`)5966 /// `--enable-smooth-intra=1` (opposite of every sibling recipe's `=0`)
5690 /// and `--enable-paeth-intra=0` -- paeth chroma stays off so the still-5967 /// and `--enable-paeth-intra=0` -- paeth chroma stays off so the still-
@@ -6193,6 +6470,9 @@ mod tests {
6193 // aomenc silently codes one tile column and the arm is vacuous.6470 // aomenc silently codes one tile column and the arm is vacuous.
6194 extra: &[&str],6471 extra: &[&str],
6195 width: usize,6472 width: usize,
6473+ // lane-interp3 r1: sequence length -- a compound block needs several
6474+ // already-coded references, which a 4-frame sequence never has.
6475+ frame_count: usize,
6196 ) {6476 ) {
6197 if !have_ffmpeg() {6477 if !have_ffmpeg() {
6198 eprintln!("SKIP {name}: no ffmpeg");6478 eprintln!("SKIP {name}: no ffmpeg");
@@ -6202,7 +6482,8 @@ mod tests {
6202 eprintln!("SKIP {name}: no aomenc at {}", aomenc_path().display());6482 eprintln!("SKIP {name}: no aomenc at {}", aomenc_path().display());
6203 return;6483 return;
6204 }6484 }
6205- let (height, frame_count) = (64usize, 4usize);6485+ let height = 64usize;
6486+ let duration = format!("{:.2}", frame_count as f64 / 25.0);
6206 // A deterministic synthetic source with real motion (a static source6487 // A deterministic synthetic source with real motion (a static source
6207 // codes every inter frame as skip and never exercises the residual6488 // codes every inter frame as skip and never exercises the residual
6208 // path); bounded with `-t` (class gate-loader-slurps-whole-file).6489 // path); bounded with `-t` (class gate-loader-slurps-whole-file).
@@ -6215,7 +6496,7 @@ mod tests {
6215 "-i",6496 "-i",
6216 &format!("mandelbrot=size={width}x{height}:rate=25"),6497 &format!("mandelbrot=size={width}x{height}:rate=25"),
6217 "-t",6498 "-t",
6218- "0.16",6499+ &duration,
6219 "-pix_fmt",6500 "-pix_fmt",
6220 if ten_bit { "yuv420p10le" } else { "yuv420p" },6501 if ten_bit { "yuv420p10le" } else { "yuv420p" },
6221 // y4m calls 10-bit unofficial (same as the 10-bit key-frame6502 // y4m calls 10-bit unofficial (same as the 10-bit key-frame
@@ -6342,6 +6623,7 @@ mod tests {
6342 "whole-superblock inter PARTITION_NONE",6623 "whole-superblock inter PARTITION_NONE",
6343 &[],6624 &[],
6344 64,6625 64,
6626+ 4,
6345 );6627 );
6346 }6628 }
6347 6629
@@ -6356,6 +6638,7 @@ mod tests {
6356 "whole-superblock inter PARTITION_NONE",6638 "whole-superblock inter PARTITION_NONE",
6357 &[],6639 &[],
6358 64,6640 64,
6641+ 4,
6359 );6642 );
6360 }6643 }
6361 6644
@@ -6398,6 +6681,88 @@ mod tests {
6398 "interior 16x16 inter PARTITION_SPLIT into 8x8 leaves",6681 "interior 16x16 inter PARTITION_SPLIT into 8x8 leaves",
6399 &["--tile-columns=1"],6682 &["--tile-columns=1"],
6400 128,6683 128,
6684+ 4,
6685+ );
6686+ }
6687+
6688+ /// lane-interp3 r1: the same 8x8-leaf recipe with DUAL FILTER, OBMC and
6689+ /// warped motion on. `read_mb_interp_filter` runs for every inter block
6690+ /// (libaom `decodemv.c` 1575), compound ones included; the compound 8x8
6691+ /// leaf skipped it entirely, so a SWITCHABLE-filter stream lost a symbol
6692+ /// per compound leaf and stamped the `[3, 3]` "no filter" sentinel, which
6693+ /// made a neighbouring OBMC block's `neighbour_filter` PANIC (a crash on
6694+ /// his data, not a named refusal). The three hard asserts prove the flags
6695+ /// arrived: a compound 8x8 leaf that really read the filter, a block whose
6696+ /// two dual-filter directions DIFFER (impossible with dual filter off),
6697+ /// and an 8x8 OBMC blend.
6698+ // lane-interp3 r2: the ENTROPY desync r1 measured is CLOSED -- the full
6699+ // 16-frame stream now parses end to end and every `EC_MODE`/`EC_MODE_VAL`
6700+ // element's msac RANGE matches the instrumented aomdec's line for line
6701+ // (570/570 mode elements, 0 diff). Two twin-drift root causes, both in
6702+ // `decode_inter_block8`'s compound arm: `read_compound_ref_frames` was
6703+ // passed a hard-coded `LAST_FRAME` for every inter neighbour instead of
6704+ // the real per-mi band, and the grid stamp cleared both per-slot
6705+ // `is_global_mv_block` flags.
6706+ // lane-interp3 r3: the luma reconstruction residue r2 left open is CLOSED
6707+ // and this gate is GREEN. Third instance of the same twin-drift class:
6708+ // libaom applies `allow_warp`'s GLOBAL branch to every
6709+ // `is_global_mv_block` reference slot, compound included and independent
6710+ // of `motion_mode` (`av1_init_warp_params` inside
6711+ // `build_inter_predictors_8x8_and_bigger`'s per-`ref` loop) -- the 16x16+
6712+ // compound arm has warped since lane-cwarp r1, the 8x8 leaf's compound arm
6713+ // predicted BOTH taps translationally, so a GLOBAL_GLOBALMV 8x8 compound
6714+ // leaf under a non-TRANSLATION model drifted a few luma levels, growing
6715+ // away from the block origin. It was NOT OBMC: the `EC_OBMC` emitter this
6716+ // round added to `decode.rs` diffs 325/325 lines against the instrumented
6717+ // aomdec's own rung (position, span, neighbour mv/ref/bsize/filter) with
6718+ // zero differences.
6719+ #[test]
6720+ fn a_real_aomenc_dual_filter_obmc_8x8_inter_sequence_decodes_pixel_exact() {
6721+ const NAME: &str =
6722+ "a_real_aomenc_dual_filter_obmc_8x8_inter_sequence_decodes_pixel_exact";
6723+ if !have_ffmpeg() || !have_aomenc() {
6724+ eprintln!("SKIP {NAME}: no ffmpeg/aomenc");
6725+ return;
6726+ }
6727+ let before_dual = decode::dual_filter_diff_hits();
6728+ let before_obmc = decode::obmc_hits_8();
6729+ let before_cwarp8 = decode::compound_warp_hits_8();
6730+ inter_sb_none_gate(
6731+ NAME,
6732+ false,
6733+ "8",
6734+ "16",
6735+ decode::compound8_filter_hits,
6736+ "a compound 8x8 leaf reading its own switchable interp_filter",
6737+ &[
6738+ "--enable-dual-filter=1",
6739+ "--enable-obmc=1",
6740+ "--enable-warped-motion=1",
6741+ "--enable-onesided-comp=1",
6742+ ],
6743+ 64,
6744+ // Recipe search hook (same shape as EC_OBMC8_ATTEMPTS): a compound
6745+ // block needs several coded references, so the sequence is longer
6746+ // than the other arms' 4 frames.
6747+ std::env::var("EC_INTERP3_FRAMES")
6748+ .ok()
6749+ .and_then(|v| v.parse().ok())
6750+ .unwrap_or(16),
6751+ );
6752+ assert!(
6753+ decode::dual_filter_diff_hits() > before_dual,
6754+ "{NAME}: no block read two DIFFERENT dual-filter directions -- \
6755+ --enable-dual-filter=1 did not arrive or aomenc declined it"
6756+ );
6757+ assert!(
6758+ decode::obmc_hits_8() > before_obmc,
6759+ "{NAME}: no 8x8 OBMC blend fired -- --enable-obmc=1 did not arrive"
6760+ );
6761+ assert!(
6762+ decode::compound_warp_hits_8() > before_cwarp8,
6763+ "{NAME}: no 8x8 COMPOUND leaf was predicted through the per-ref GLOBAL \
6764+ warp -- the r3 root-cause path never fired, so this stream no longer \
6765+ proves it"
6401 );6766 );
6402 }6767 }
6403 6768
@@ -6412,6 +6777,7 @@ mod tests {
6412 "interior 16x16 inter PARTITION_SPLIT into 8x8 leaves",6777 "interior 16x16 inter PARTITION_SPLIT into 8x8 leaves",
6413 &[],6778 &[],
6414 64,6779 64,
6780+ 4,
6415 );6781 );
6416 }6782 }
6417 6783
@@ -6435,6 +6801,7 @@ mod tests {
6435 "interior 16x16 inter PARTITION_SPLIT into 8x8 leaves",6801 "interior 16x16 inter PARTITION_SPLIT into 8x8 leaves",
6436 &[],6802 &[],
6437 64,6803 64,
6804+ 4,
6438 );6805 );
6439 }6806 }
6440 6807
@@ -7133,14 +7500,169 @@ mod tests {
7133 };7500 };
7134 let duration = frame_count as f64 / 25.0;7501 let duration = frame_count as f64 / 25.0;
7135 let source = format!(7502 let source = format!(
7136- "color=c=gray:s={width}x{height}:d={duration}:r=25,format=gray,\7503+ "color=c=gray:s={width}x{height}:d={duration}:r=25,format=gray,\
7137- geq=lum='{geq}',format=yuv420p"7504+ geq=lum='{geq}',format=yuv420p"
7505+ );
7506+ let pix_fmt = if bit_depth == 10 { "yuv420p10le" } else { "yuv420p" };
7507+ let y4m = Command::new("ffmpeg")
7508+ .args([
7509+ "-v", "error", "-f", "lavfi", "-i", &source, "-t", &duration.to_string(),
7510+ "-pix_fmt", pix_fmt, "-strict", "-1", "-f", "yuv4mpegpipe", "-",
7511+ ])
7512+ .stdin(Stdio::null())
7513+ .stdout(Stdio::piped())
7514+ .stderr(Stdio::piped())
7515+ .output()
7516+ .expect("ffmpeg failed to run");
7517+ assert!(
7518+ y4m.status.success(),
7519+ "{NAME}: ffmpeg refused the {bit_depth}-bit fixture: {}",
7520+ String::from_utf8_lossy(&y4m.stderr)
7521+ );
7522+ let cq_arg = format!("--cq-level={cq}");
7523+ let depth_arg = format!("--bit-depth={bit_depth}");
7524+ let input_depth_arg = format!("--input-bit-depth={bit_depth}");
7525+ let args: Vec<&str> = vec![
7526+ "--codec=av1", "--passes=1", "--end-usage=q", &cq_arg, "--cpu-used=0",
7527+ "--threads=1", "--row-mt=0", "--sb-size=64", &depth_arg, &input_depth_arg,
7528+ "--enable-restoration=0", "--enable-palette=0", "--deltaq-mode=0",
7529+ "--enable-filter-intra=0", "--enable-cfl-intra=0", "--enable-intrabc=0",
7530+ "--enable-tx-size-search=0", "--lag-in-frames=0",
7531+ "--enable-rect-partitions=1", "--enable-ab-partitions=0",
7532+ "--enable-1to4-partitions=1", "--min-partition-size=32",
7533+ "--max-partition-size=64",
7534+ "--obu", "-o", "-", "-",
7535+ ];
7536+ let mut child = Command::new(aomenc_path())
7537+ .args(&args)
7538+ .stdin(Stdio::piped())
7539+ .stdout(Stdio::piped())
7540+ .stderr(Stdio::piped())
7541+ .spawn()
7542+ .expect("aomenc failed to start");
7543+ child
7544+ .stdin
7545+ .take()
7546+ .expect("aomenc stdin")
7547+ .write_all(&y4m.stdout)
7548+ .expect("writing y4m to aomenc");
7549+ let out = child.wait_with_output().expect("aomenc failed to run");
7550+ assert!(
7551+ out.status.success(),
7552+ "aomenc refused the fixture: {}",
7553+ String::from_utf8_lossy(&out.stderr)
7554+ );
7555+ let stream = out.stdout;
7556+ let before = crate::decode::nocfl_uv_mode_hits();
7557+ let frames = match decode_stream(&stream) {
7558+ Err(e) => {
7559+ let msg = e.to_string();
7560+ assert!(
7561+ msg.contains("unsupported"),
7562+ "{NAME} failed outright, not a named refusal ({bit_depth}-bit, \
7563+ attempt {attempt}): {msg}"
7564+ );
7565+ named_refusals += 1;
7566+ eprintln!("{bit_depth}-bit attempt {attempt} refusal: {msg}");
7567+ continue;
7568+ }
7569+ Ok(frames) => frames,
7570+ };
7571+ let hits = crate::decode::nocfl_uv_mode_hits() - before;
7572+ let ffmpeg_frames = if bit_depth == 10 {
7573+ ffmpeg_decode_sequence_10bit(&stream, width, height, frame_count)
7574+ } else {
7575+ ffmpeg_decode_sequence(&stream, width, height, frame_count)
7576+ };
7577+ assert_eq!(frames.len(), frame_count);
7578+ if hits == 0 {
7579+ // No 64-axis intra block in this stream: still compared
7580+ // (a mismatch here is a defect, never a pass), just not
7581+ // proof of this gate's shape.
7582+ carried_none += 1;
7583+ }
7584+ for (i, (got, want)) in frames.iter().zip(&ffmpeg_frames).enumerate() {
7585+ assert_eq!(got.y, want.y, "{NAME} frame {i} luma vs ffmpeg (attempt {attempt}, {bit_depth}-bit, hits={hits})");
7586+ assert_eq!(got.u, want.u, "{NAME} frame {i} U vs ffmpeg (attempt {attempt}, {bit_depth}-bit, hits={hits})");
7587+ assert_eq!(got.v, want.v, "{NAME} frame {i} V vs ffmpeg (attempt {attempt}, {bit_depth}-bit, hits={hits})");
7588+ }
7589+ if hits > 0 {
7590+ matched += 1;
7591+ total_hits += hits;
7592+ }
7593+ }
7594+ eprintln!(
7595+ "{NAME} ({bit_depth}-bit): {named_refusals} named refusals, {matched} pixel-exact \
7596+ attempts carrying a >32 intra block ({total_hits} no-CFL uv_mode reads), \
7597+ {carried_none} attempts carried none"
7598+ );
7599+ assert!(
7600+ matched > 0 && total_hits > 0,
7601+ "{NAME} ({bit_depth}-bit): no attempt decoded an intra block above 32x32, so the \
7602+ no-CFL uv_mode alphabet was never exercised -- gate proved nothing \
7603+ ({named_refusals} refusals, {carried_none} attempts carried none)"
7604+ );
7605+ }
7606+ }
7607+ /// lane-sqdrift r2: the SQUARE-ONLY twin of the no-CFL `uv_mode` gate
7608+ /// above. With `--enable-rect-partitions=0` the encoder codes only
7609+ /// `PARTITION_NONE` and `PARTITION_SPLIT`, and on detailed content the RD
7610+ /// eventually hands one whole 64x64 superblock of an INTER frame to an
7611+ /// INTRA block -- `bsize == sb_size`, the one shape whose `uv_mode` must
7612+ /// come off the 13-symbol `uv_mode_no_cfl` alphabet because libaom's
7613+ /// `is_cfl_allowed` (`blockd.h`: `wide <= 32 && high <= 32`) excludes it.
7614+ ///
7615+ /// Before the fix this decoder read the 14-symbol CFL alphabet there: the
7616+ /// same `DC_PRED` value, a different interval, and the tile desynced from
7617+ /// that block on. r1 measured the damage on the pinned 192x128 stream
7618+ /// (sha256 `c6af4fb4...`): decode-order frames 0-3 pre-filter byte-exact,
7619+ /// frame 4 luma 3540 samples wrong over exactly the last superblock
7620+ /// (x 128..191, y 64..127), then 24k wrong by frame 7 -- and the decoder
7621+ /// did not even report a mismatch, it reported an intra-rect-strip refusal
7622+ /// read out of the already-desynced stream (class `refusal-from-own-desync`;
7623+ /// aomdec's own partition histogram over that stream is rect-free).
7624+ /// After the fix the same stream is byte-exact on all 8 frames.
7625+ ///
7626+ /// Distinct from the sibling gate: rect partitions OFF (so the 64x64 NONE
7627+ /// really is a whole superblock), `--min-partition-size=16`, natural
7628+ /// mandelbrot detail instead of a synthetic half-noise ramp, and 8 frames
7629+ /// of drift so a desync that survives one frame still fails here. Every
7630+ /// decode-order frame of every attempt is compared against ffmpeg, so a
7631+ /// mismatch of ANY shape fails; the gate never turns one into a SKIP.
7632+ #[test]
7633+ fn a_real_aomenc_square_only_inter_sequence_with_a_64x64_intra_superblock_decodes_pixel_exact()
7634+ {
7635+ const NAME: &str = "a_real_aomenc_square_only_inter_sequence_with_a_64x64_intra_superblock_decodes_pixel_exact";
7636+ let _gate_lock = lock_gate_counters();
7637+ if !have_ffmpeg() {
7638+ eprintln!("SKIP {NAME}: no ffmpeg");
7639+ return;
7640+ }
7641+ if !have_aomenc() {
7642+ eprintln!("SKIP {NAME}: no aomenc at {}", aomenc_path().display());
7643+ return;
7644+ }
7645+ let (width, height, frame_count) = (192usize, 128usize, 8usize);
7646+ for bit_depth in [8u32, 10u32] {
7647+ let (mut named_refusals, mut matched, mut carried_none) = (0u32, 0u32, 0u32);
7648+ let mut total_hits = 0usize;
7649+ for attempt in 0..4u32 {
7650+ // r1's pinned recipe is (start_scale 4.76, cq 55); the other
7651+ // three points move the detail level and the quantiser, which
7652+ // is what moves WHICH superblock the RD codes intra.
7653+ let start_scale = ["4.76", "3.20"][(attempt % 2) as usize];
7654+ let cq = [55, 45][(attempt / 2) as usize];
7655+ let duration = frame_count as f64 / 25.0;
7656+ let source = format!(
7657+ "mandelbrot=size={width}x{height}:start_scale={start_scale}:\
7658+ end_scale=0.004:end_pts=8:rate=25"
7138 );7659 );
7139 let pix_fmt = if bit_depth == 10 { "yuv420p10le" } else { "yuv420p" };7660 let pix_fmt = if bit_depth == 10 { "yuv420p10le" } else { "yuv420p" };
7140 let y4m = Command::new("ffmpeg")7661 let y4m = Command::new("ffmpeg")
7141 .args([7662 .args([
7142- "-v", "error", "-f", "lavfi", "-i", &source, "-t", &duration.to_string(),7663+ "-v", "error", "-f", "lavfi", "-i", &source, "-vf", "hue=s=0",
7143- "-pix_fmt", pix_fmt, "-strict", "-1", "-f", "yuv4mpegpipe", "-",7664+ "-t", &duration.to_string(), "-pix_fmt", pix_fmt, "-strict", "-1",
7665+ "-f", "yuv4mpegpipe", "-strict", "-1", "-",
7144 ])7666 ])
7145 .stdin(Stdio::null())7667 .stdin(Stdio::null())
7146 .stdout(Stdio::piped())7668 .stdout(Stdio::piped())
@@ -7156,14 +7678,22 @@ mod tests {
7156 let depth_arg = format!("--bit-depth={bit_depth}");7678 let depth_arg = format!("--bit-depth={bit_depth}");
7157 let input_depth_arg = format!("--input-bit-depth={bit_depth}");7679 let input_depth_arg = format!("--input-bit-depth={bit_depth}");
7158 let args: Vec<&str> = vec![7680 let args: Vec<&str> = vec![
7159- "--codec=av1", "--passes=1", "--end-usage=q", &cq_arg, "--cpu-used=0",7681+ "--codec=av1", "--passes=1", "--end-usage=q", &cq_arg, "--cpu-used=1",
7160 "--threads=1", "--row-mt=0", "--sb-size=64", &depth_arg, &input_depth_arg,7682 "--threads=1", "--row-mt=0", "--sb-size=64", &depth_arg, &input_depth_arg,
7161- "--enable-restoration=0", "--enable-palette=0", "--deltaq-mode=0",7683+ "--lag-in-frames=0", "--auto-alt-ref=0",
7162- "--enable-filter-intra=0", "--enable-cfl-intra=0", "--enable-intrabc=0",7684+ "--kf-min-dist=1000", "--kf-max-dist=1000",
7163- "--enable-tx-size-search=0", "--lag-in-frames=0",7685+ "--enable-rect-partitions=0", "--enable-ab-partitions=0",
7164- "--enable-rect-partitions=1", "--enable-ab-partitions=0",7686+ "--enable-1to4-partitions=0", "--min-partition-size=16",
7165- "--enable-1to4-partitions=1", "--min-partition-size=32",7687+ "--max-partition-size=64", "--enable-tx-size-search=0",
7166- "--max-partition-size=64",7688+ "--enable-order-hint=0", "--enable-warped-motion=0", "--enable-obmc=0",
7689+ "--enable-masked-comp=0", "--enable-interintra-comp=0",
7690+ "--enable-dist-wtd-comp=0", "--enable-diff-wtd-comp=0",
7691+ "--enable-onesided-comp=0", "--enable-interintra-wedge=0",
7692+ "--enable-smooth-interintra=0", "--enable-filter-intra=0",
7693+ "--enable-smooth-intra=0", "--enable-paeth-intra=0",
7694+ "--enable-directional-intra=0", "--enable-angle-delta=0",
7695+ "--enable-cdef=0", "--enable-restoration=0", "--enable-palette=0",
7696+ "--enable-intrabc=0", "--enable-cfl-intra=0", "--enable-ref-frame-mvs=0",
7167 "--obu", "-o", "-", "-",7697 "--obu", "-o", "-", "-",
7168 ];7698 ];
7169 let mut child = Command::new(aomenc_path())7699 let mut child = Command::new(aomenc_path())
@@ -7209,9 +7739,6 @@ mod tests {
7209 };7739 };
7210 assert_eq!(frames.len(), frame_count);7740 assert_eq!(frames.len(), frame_count);
7211 if hits == 0 {7741 if hits == 0 {
7212- // No 64-axis intra block in this stream: still compared
7213- // (a mismatch here is a defect, never a pass), just not
7214- // proof of this gate's shape.
7215 carried_none += 1;7742 carried_none += 1;
7216 }7743 }
7217 for (i, (got, want)) in frames.iter().zip(&ffmpeg_frames).enumerate() {7744 for (i, (got, want)) in frames.iter().zip(&ffmpeg_frames).enumerate() {
@@ -7226,14 +7753,14 @@ mod tests {
7226 }7753 }
7227 eprintln!(7754 eprintln!(
7228 "{NAME} ({bit_depth}-bit): {named_refusals} named refusals, {matched} pixel-exact \7755 "{NAME} ({bit_depth}-bit): {named_refusals} named refusals, {matched} pixel-exact \
7229- attempts carrying a >32 intra block ({total_hits} no-CFL uv_mode reads), \7756+ attempts carrying a 64x64 intra superblock ({total_hits} no-CFL uv_mode reads), \
7230 {carried_none} attempts carried none"7757 {carried_none} attempts carried none"
7231 );7758 );
7232 assert!(7759 assert!(
7233 matched > 0 && total_hits > 0,7760 matched > 0 && total_hits > 0,
7234- "{NAME} ({bit_depth}-bit): no attempt decoded an intra block above 32x32, so the \7761+ "{NAME} ({bit_depth}-bit): no square-only attempt decoded a 64x64 intra block \
7235- no-CFL uv_mode alphabet was never exercised -- gate proved nothing \7762+ inside an inter frame, so the no-CFL uv_mode alphabet was never exercised -- \
7236- ({named_refusals} refusals, {carried_none} attempts carried none)"7763+ gate proved nothing ({named_refusals} refusals, {carried_none} carried none)"
7237 );7764 );
7238 }7765 }
7239 }7766 }
@@ -7726,6 +8253,194 @@ mod tests {
7726 }8253 }
7727 }8254 }
7728 8255
8256+ /// lane-intersub8: `PARTITION_SPLIT` below 8x8 on an INTER frame -- four
8257+ /// `BLOCK_4X4` inter sub-blocks with one shared 4x4 chroma unit per plane,
8258+ /// predicted the sub8x8 way (2x2 chroma piece per luma sub-block mv,
8259+ /// `dec_build_inter_predictors`' `is_sub8x8` branch). Reality of the shape
8260+ /// was established BEFORE the code (class refusal-from-own-desync): the
8261+ /// oracle `aomdec`'s `EC_TRACE` prints `EC_PART_VAL ... bsize=3 value=3`
8262+ /// on this recipe's inter frames.
8263+ ///
8264+ /// Attempts 0..7 run `--enable-rect-partitions=0`, where aomenc can only
8265+ /// pick SPLIT below 8x8; attempts 8..15 repeat the schedule with rect on,
8266+ /// where it picks HORZ/VERT below 8x8 far more often than SPLIT -- the VERT
8267+ /// arm (two `BLOCK_4X8` inter leaves, `decode_inter_sub8_rect2`) is what the
8268+ /// `rect_fired` assert pins. The HORZ twin decodes but is refused by name
8269+ /// (lane-intersub8 r3: a measured sweep desyncs the block to its right).
8270+ #[test]
8271+ fn a_real_aomenc_inter_sequence_with_a_sub8x8_inter_split_decodes_pixel_exact() {
8272+ const NAME: &str =
8273+ "a_real_aomenc_inter_sequence_with_a_sub8x8_inter_split_decodes_pixel_exact";
8274+ let _gate_lock = lock_gate_counters();
8275+ if !have_ffmpeg() {
8276+ eprintln!("SKIP {NAME}: no ffmpeg");
8277+ return;
8278+ }
8279+ if !have_aomenc() {
8280+ eprintln!("SKIP {NAME}: no aomenc at {}", aomenc_path().display());
8281+ return;
8282+ }
8283+ let (width, height, frame_count) = (192usize, 128usize, 6usize);
8284+ let mut fired = 0u32;
8285+ // lane-intersub8 r3: attempts 8..15 repeat the same schedule with
8286+ // `--enable-rect-partitions=1`, where aomenc picks PARTITION_VERT below
8287+ // 8x8 (two BLOCK_4X8 inter leaves, one shared 4x4 chroma unit predicted
8288+ // from BOTH sub-blocks' mvs). The HORZ twin is still refused by name.
8289+ let mut rect_fired = 0u32;
8290+ let mut refusals: Vec<String> = Vec::new();
8291+ let mut out_of_scope_mismatch = 0u32;
8292+ for bit_depth in [8u32, 10u32] {
8293+ for attempt in 0..16u32 {
8294+ let rect = attempt / 8;
8295+ let rect_arg = format!("--enable-rect-partitions={rect}");
8296+ // lane-intersub8 r2, measured schedule (sweep of cq
8297+ // {8,10,12,14,16,18,20} x sp {3,6,9,12} x both depths,
8298+ // `decode_probe`'s `sub8_inter_split:` counter vs an ffmpeg
8299+ // rawvideo compare): sub-8x8 inter SPLIT groups fire at
8300+ // (8-bit, cq 12, sp 3) = 1 group and (10-bit, cq 12, sp 6) =
8301+ // 3 groups, both pixel-exact. cq 8 and 10 are NOT used: at
8302+ // those quantizers this recipe also carries a CDEF defect of
8303+ // another shape -- three luma samples of |d| = 1 on
8304+ // decode-order frames 3/4, zero sub-8x8 inter split groups,
8305+ // and the identical recipe re-encoded with `--enable-cdef=0`
8306+ // decodes all six frames exact. Deferred to a CDEF lane
8307+ // rather than hidden: cq 16..20 are all exact, so this gate
8308+ // is not selecting quantizers that hide a defect of its own
8309+ // shape.
8310+ let cq = [12, 14][(attempt % 2) as usize];
8311+ let sp = 3 + ((attempt % 8) / 2) * 3;
8312+ let duration = frame_count as f64 / 25.0;
8313+ let source = format!(
8314+ "color=c=gray:s={width}x{height}:d={duration}:r=25,format=gray,\
8315+ geq=lum='128+58*sin((X+N*{sp})/6)+18*sin(Y/23)',format=yuv420p"
8316+ );
8317+ let pix_fmt = if bit_depth == 10 { "yuv420p10le" } else { "yuv420p" };
8318+ let y4m = Command::new("ffmpeg")
8319+ .args([
8320+ "-v", "error", "-f", "lavfi", "-i", &source, "-t", &duration.to_string(),
8321+ "-pix_fmt", pix_fmt, "-strict", "-1", "-f", "yuv4mpegpipe", "-",
8322+ ])
8323+ .stdin(Stdio::null())
8324+ .stdout(Stdio::piped())
8325+ .stderr(Stdio::piped())
8326+ .output()
8327+ .expect("ffmpeg failed to run");
8328+ assert!(
8329+ y4m.status.success(),
8330+ "{NAME}: ffmpeg refused the fixture: {}",
8331+ String::from_utf8_lossy(&y4m.stderr)
8332+ );
8333+ let cq_arg = format!("--cq-level={cq}");
8334+ let depth_arg = format!("--bit-depth={bit_depth}");
8335+ let input_depth_arg = format!("--input-bit-depth={bit_depth}");
8336+ let args: Vec<&str> = vec![
8337+ "--codec=av1", "--passes=1", "--end-usage=q", &cq_arg, "--cpu-used=0",
8338+ "--threads=1", "--row-mt=0", "--sb-size=64", &depth_arg, &input_depth_arg,
8339+ "--enable-restoration=0", "--enable-palette=0", "--deltaq-mode=0",
8340+ "--enable-filter-intra=0", "--enable-cfl-intra=0", "--enable-intrabc=0",
8341+ "--lag-in-frames=0", "--enable-obmc=0", "--enable-tx-size-search=1",
8342+ // Per-arm overrides last (aomenc keeps the LAST occurrence).
8343+ "--enable-rect-partitions=0", "--enable-ab-partitions=0",
8344+ "--enable-1to4-partitions=0", "--min-partition-size=4",
8345+ "--max-partition-size=16",
8346+ &rect_arg,
8347+ "--obu", "-o", "-", "-",
8348+ ];
8349+ let mut child = Command::new(aomenc_path())
8350+ .args(&args)
8351+ .stdin(Stdio::piped())
8352+ .stdout(Stdio::piped())
8353+ .stderr(Stdio::piped())
8354+ .spawn()
8355+ .expect("aomenc failed to start");
8356+ child
8357+ .stdin
8358+ .take()
8359+ .expect("aomenc stdin")
8360+ .write_all(&y4m.stdout)
8361+ .expect("writing y4m to aomenc");
8362+ let out = child.wait_with_output().expect("aomenc failed to run");
8363+ assert!(
8364+ out.status.success(),
8365+ "{NAME}: aomenc refused the fixture: {}",
8366+ String::from_utf8_lossy(&out.stderr)
8367+ );
8368+ let stream = out.stdout;
8369+ let before = decode::sub8_inter_split_hits();
8370+ let before_rect = decode::sub8_inter_rect_hits();
8371+ let frames = match decode_stream(&stream) {
8372+ Err(e) => {
8373+ let msg = e.to_string();
8374+ assert!(
8375+ msg.contains("unsupported"),
8376+ "{NAME} failed outright, not a named refusal ({bit_depth}-bit, \
8377+ attempt {attempt}): {msg}"
8378+ );
8379+ refusals.push(format!("{bit_depth}-bit attempt {attempt}: {msg}"));
8380+ continue;
8381+ }
8382+ Ok(frames) => frames,
8383+ };
8384+ let split_groups = decode::sub8_inter_split_hits() - before;
8385+ let rect_now = decode::sub8_inter_rect_hits();
8386+ let rect_groups = (rect_now.0 - before_rect.0) + (rect_now.1 - before_rect.1);
8387+ let groups = split_groups + rect_groups;
8388+ let ffmpeg_frames = if bit_depth == 10 {
8389+ ffmpeg_decode_sequence_10bit(&stream, width, height, frame_count)
8390+ } else {
8391+ ffmpeg_decode_sequence(&stream, width, height, frame_count)
8392+ };
8393+ assert_eq!(frames.len(), frame_count);
8394+ let mismatched = frames
8395+ .iter()
8396+ .zip(&ffmpeg_frames)
8397+ .any(|(got, want)| got.y != want.y || got.u != want.u || got.v != want.v);
8398+ if groups == 0 {
8399+ // Out of scope: no sub-8x8 inter split in this attempt.
8400+ if mismatched {
8401+ out_of_scope_mismatch += 1;
8402+ eprintln!(
8403+ "{NAME}: {bit_depth}-bit attempt {attempt} MISMATCHES with zero \
8404+ sub-8x8 inter group -- another shape's defect"
8405+ );
8406+ }
8407+ refusals.push(format!(
8408+ "{bit_depth}-bit attempt {attempt}: decoded, but no sub-8x8 inter split"
8409+ ));
8410+ continue;
8411+ }
8412+ for (i, (got, want)) in frames.iter().zip(&ffmpeg_frames).enumerate() {
8413+ assert_eq!(
8414+ got.y, want.y,
8415+ "luma frame {i} ({bit_depth}-bit attempt {attempt}, {groups} sub-8x8 \
8416+ inter split groups)"
8417+ );
8418+ assert_eq!(got.u, want.u, "U frame {i} ({bit_depth}-bit attempt {attempt})");
8419+ assert_eq!(got.v, want.v, "V frame {i} ({bit_depth}-bit attempt {attempt})");
8420+ }
8421+ fired += 1;
8422+ if rect_groups > 0 {
8423+ rect_fired += 1;
8424+ }
8425+ }
8426+ }
8427+ assert_eq!(
8428+ out_of_scope_mismatch, 0,
8429+ "{NAME}: attempts mismatched with no sub-8x8 inter group"
8430+ );
8431+ assert!(
8432+ fired >= 2,
8433+ "{NAME}: fewer than 2 firing+pixel-exact attempts:\n{}",
8434+ refusals.join("\n")
8435+ );
8436+ assert!(
8437+ rect_fired >= 2,
8438+ "{NAME}: fewer than 2 firing+pixel-exact attempts with a RECTANGULAR sub-8x8 \
8439+ inter leaf (4x8):\n{}",
8440+ refusals.join("\n")
8441+ );
8442+ }
8443+
7729 #[test]8444 #[test]
7730 // lane-inter4 r3: the 16x16-level rect INTER leaf -- PARTITION_HORZ /8445 // lane-inter4 r3: the 16x16-level rect INTER leaf -- PARTITION_HORZ /
7731 // PARTITION_VERT at 16x16 on an inter frame, i.e. two 16x8 / 8x16 inter8446 // PARTITION_VERT at 16x16 on an inter frame, i.e. two 16x8 / 8x16 inter
@@ -15863,6 +16578,151 @@ mod tests {
15863 );16578 );
15864 }16579 }
15865 16580
16581+ /// lane-cdef r1: CDEF's per-8x8 skip band under sub-16x16 inter leaves.
16582+ ///
16583+ /// `apply_cdef` excludes an 8x8 luma unit whose four mi cells are all
16584+ /// `skip_txfm` (libaom `cdef.c:29-38 is_8x8_block_skip`, called from
16585+ /// `av1_cdef_compute_sb_list`'s dlist loop). `decode_inter_block8` -- the
16586+ /// leaf path `--min-partition-size=4` makes aomenc pick for a 16x16 group
16587+ /// -- wrote the loop-filter grid but never that skip band, so an all-skip
16588+ /// group kept the PREVIOUS frame's flags and got filtered where libaom
16589+ /// skips it (3 luma samples, decode-order frames 3 and 4 of the 192x128
16590+ /// cq-8 stream below, at the frame's last 8x8 column).
16591+ ///
16592+ /// Both counters are hard asserts per compared attempt: `cdef_skipped_units`
16593+ /// proves the all-skip dlist exclusion was actually reached, and
16594+ /// `inter8_skip_band_hits` proves the 8x8 leaf path (the writer that used
16595+ /// to be missing) ran on the same stream.
16596+ #[test]
16597+ fn a_real_aomenc_stream_with_cdef_and_sub16_inter_leaves_decodes_pixel_exact() {
16598+ if !have_aomenc() {
16599+ return;
16600+ }
16601+ let (width, height, frames) = (192usize, 128usize, 6usize);
16602+ let mut refusals: Vec<String> = Vec::new();
16603+ let mut fired = 0u32;
16604+ for (depth, cq, sp) in [(8u32, 8u32, 3u32), (8, 10, 3), (8, 12, 6), (10, 8, 3), (10, 12, 6)] {
16605+ let pix = if depth == 10 { "yuv420p10le" } else { "yuv420p" };
16606+ let src = format!(
16607+ "color=c=gray:s={width}x{height}:d=0.24:r=25,format=gray,\
16608+ geq=lum='128+58*sin((X+N*{sp})/6)+18*sin(Y/23)',format=yuv420p"
16609+ );
16610+ let y4m = Command::new("ffmpeg")
16611+ .args([
16612+ "-v", "error", "-f", "lavfi", "-i", &src, "-t", "0.24", "-pix_fmt", pix,
16613+ "-strict", "-1", "-f", "yuv4mpegpipe", "-",
16614+ ])
16615+ .stdin(Stdio::null())
16616+ .stdout(Stdio::piped())
16617+ .stderr(Stdio::piped())
16618+ .output()
16619+ .expect("ffmpeg failed to run");
16620+ assert!(
16621+ y4m.status.success(),
16622+ "ffmpeg fixture: {}",
16623+ String::from_utf8_lossy(&y4m.stderr)
16624+ );
16625+ let mut child = Command::new(aomenc_path())
16626+ .args([
16627+ "--codec=av1",
16628+ "--passes=1",
16629+ "--end-usage=q",
16630+ &format!("--cq-level={cq}"),
16631+ "--cpu-used=0",
16632+ "--threads=1",
16633+ "--row-mt=0",
16634+ "--sb-size=64",
16635+ &format!("--bit-depth={depth}"),
16636+ &format!("--input-bit-depth={depth}"),
16637+ "--enable-restoration=0",
16638+ "--enable-palette=0",
16639+ "--deltaq-mode=0",
16640+ "--enable-filter-intra=0",
16641+ "--enable-cfl-intra=0",
16642+ "--enable-intrabc=0",
16643+ "--lag-in-frames=0",
16644+ "--enable-obmc=0",
16645+ "--enable-tx-size-search=1",
16646+ "--enable-rect-partitions=0",
16647+ "--enable-ab-partitions=0",
16648+ "--enable-1to4-partitions=0",
16649+ "--min-partition-size=4",
16650+ "--max-partition-size=16",
16651+ // Last occurrence of a repeated --enable-* flag wins
16652+ // (aomenc-last-flag-wins): CDEF stays ON, and the two
16653+ // counters below prove the filter really ran.
16654+ "--enable-cdef=1",
16655+ "--obu",
16656+ "-o",
16657+ "-",
16658+ "-",
16659+ ])
16660+ .stdin(Stdio::piped())
16661+ .stdout(Stdio::piped())
16662+ .stderr(Stdio::piped())
16663+ .spawn()
16664+ .expect("aomenc failed to start");
16665+ child
16666+ .stdin
16667+ .take()
16668+ .expect("aomenc stdin")
16669+ .write_all(&y4m.stdout)
16670+ .expect("writing y4m to aomenc");
16671+ let out = child.wait_with_output().expect("aomenc failed to run");
16672+ assert!(
16673+ out.status.success(),
16674+ "aomenc refused the fixture (depth={depth} cq={cq})"
16675+ );
16676+ let stream = out.stdout;
16677+ let skipped_before = decode::cdef_skipped_units();
16678+ let leaves_before = decode::inter8_skip_band_hits();
16679+ let decoded = match decode_stream(&stream) {
16680+ Ok(f) => f,
16681+ Err(e) => {
16682+ let msg = e.to_string();
16683+ assert!(
16684+ msg.starts_with("unsupported: "),
16685+ "decode error that is not a named refusal \
16686+ (depth={depth} cq={cq}): {msg}"
16687+ );
16688+ refusals.push(format!("depth={depth} cq={cq}: {msg}"));
16689+ continue;
16690+ }
16691+ };
16692+ assert_eq!(decoded.len(), frames, "frame count (depth={depth} cq={cq})");
16693+ assert!(
16694+ decode::cdef_skipped_units() > skipped_before,
16695+ "no 8x8 CDEF unit was excluded by the all-skip rule \
16696+ (depth={depth} cq={cq})"
16697+ );
16698+ assert!(
16699+ decode::inter8_skip_band_hits() > leaves_before,
16700+ "no sub-16x16 inter leaf wrote the CDEF skip band \
16701+ (depth={depth} cq={cq})"
16702+ );
16703+ let reference = if depth == 10 {
16704+ ffmpeg_decode_sequence_10bit(&stream, width, height, frames)
16705+ } else {
16706+ ffmpeg_decode_sequence(&stream, width, height, frames)
16707+ };
16708+ for (i, (ours, theirs)) in decoded.iter().zip(reference.iter()).enumerate() {
16709+ assert_eq!(ours.y, theirs.y, "luma frame {i} (depth={depth} cq={cq})");
16710+ assert_eq!(ours.u, theirs.u, "U frame {i} (depth={depth} cq={cq})");
16711+ assert_eq!(ours.v, theirs.v, "V frame {i} (depth={depth} cq={cq})");
16712+ }
16713+ fired += 1;
16714+ }
16715+ // Three of the five arms land on OTHER open refusals (a non-DC chroma
16716+ // mode on an 8x8 inter leaf; inter partitions below 8x8) -- the two
16717+ // 8-bit cq 8/10 arms ARE the streams the defect was found on, and each
16718+ // hard-asserts both counters plus all six frames on all three planes.
16719+ assert!(
16720+ fired >= 2,
16721+ "fewer than 2 firing+pixel-exact attempts:\n{}",
16722+ refusals.join("\n")
16723+ );
16724+ }
16725+
15866 /// lane-sub8 r1: `--min-partition-size=4` on fine-detail noisy gradients16726 /// lane-sub8 r1: `--min-partition-size=4` on fine-detail noisy gradients
15867 /// at low cq reliably makes aomenc split an 8x8 block all the way to16727 /// at low cq reliably makes aomenc split an 8x8 block all the way to
15868 /// four `BLOCK_4X4` leaves (`PARTITION_SPLIT` below 8x8, spec16728 /// four `BLOCK_4X4` leaves (`PARTITION_SPLIT` below 8x8, spec
lanes/cdef-r1.handoff.mdadded+66 -0
@@ -0,0 +1,66 @@
1+# lane-cdef r1 -- HANDOFF (2 CDEF defects rooted, both fixed, gate GREEN; one residue open)
2+
3+Base: main 48b35ab. Suite unit `cdef-suite-1788330834.service` -> `$HOME/.cache/cdef-suite-r1.log`
4+(started at the turn cap; FIRST THING NEXT ROUND: `grep -E "^test result|FAILED" $HOME/.cache/cdef-suite-r1.log`).
5+
6+## Defect A -- per-8x8 CDEF skip band never written by the 8x8 inter leaf (charter hypothesis (a), variant)
7+
8+* Stream: `~/.cache/cdef-tmp/a0_8.obu`, sha256 `aa40f17f6e49eca2bb8c9d9ab99a175312134bdcf45c39b8a76b6757d8536751`
9+ (hashed twice, identical), `~/.cache/cdef-tmp/gen.sh 8 3 8 a0_8.obu` = lane-intersub8's recipe,
10+ 192x128, 6 frames, `--min-partition-size=4`, cq 8, 8-bit.
11+* Stage attribution: reconstruction and post-deblock are EXACT (`EC_AV1_POSTDEBLOCK_DUMP` ours vs
12+ the instrumented aomdec: 0/24576 luma on decode-order frame 3); the 3 samples enter at CDEF.
13+ NOTE: aomdec's `EC_AV1_PREFILT_DUMP` is ALREADY POST-DEBLOCK on this build (r_pre.fN == r_pd.fN
14+ for 5 of 6 frames) -- ours is genuinely pre-deblock, so the two rungs are NOT the same stage.
15+* Root cause: `decode_inter_block8` (decode.rs, the leaf path `--min-partition-size=4` picks for a
16+ 16x16 group) wrote `record_mi` + `fill_lf_grid` at both exits but NEVER `fill_skip_grid`. The
17+ bottom-right 16x16 of decode-order frame 3 was therefore judged by the PREVIOUS frame's flags:
18+ our 8x8 units at mi(28,46)/(30,46) read skip=false and were filtered, while libaom's
19+ `is_8x8_block_skip` (cdef.c:29-38, called from `av1_cdef_compute_sb_list` cdef.c:40-71) excludes
20+ an all-skip 8x8 from the dlist. Proof: a python model of `cdef_block.c` reproduces the reference
21+ for all 16 units of the last column at (sec=1,damp=3) EXCEPT those two, where only "unfiltered"
22+ matches; frame-3 fill log showed 0 of 95 skip fills covering mi(28,44)+16x16.
23+* Fix: `neighbours.fill_skip_grid(leaf_mi, 2, skip)` at both `decode_inter_block8` exits (compound
24+ early return + fall-through), each bumping `INTER8_SKIP_BAND_HITS`.
25+* Before/after on the pinned stream: frames 3 and 4 had 3 luma samples |d|=1 each
26+ ((189,116/120/124) and (186,116/120/124)); after, all 6 frames pixel-exact on Y/U/V.
27+
28+## Defect B -- CDEF direction search clamped at the crop edge instead of reading CDEF_VERY_LARGE
29+
30+* Stream: `~/.cache/golomb-tmp/s68.obu` (68x192, 5 frames, 8-bit, cq 35) -- lane-golomb r9's
31+ deferred "straddle band".
32+* Root cause: `apply_cdef`'s `cdef_find_dir` closure clamped to `true_w-1`/`true_h-1`, but libaom
33+ runs `cdef_find_dir` over `cdef_prepare_fb`'s buffer (cdef.c:249-256 `frame_boundary[RIGHT]`
34+ fill, cdef_block.c:296-320), whose columns/rows past the mi-rounded extent are CDEF_VERY_LARGE.
35+ With odd `mi_cols` (68 px -> 17 mi) the last 8x8 straddles, so var/`adjust_strength` differed.
36+* Fix: the direction search now reads the SAME padded `sample_y` the taps use (one line).
37+* Before/after: frame 1 luma 145 diffs -> **0**; all 5 frames luma exact.
38+* RESIDUE (open, NOT fixed): the same stream still differs in CHROMA from frame 1 on
39+ (U/V 194/401/466/551 samples, |d| up to 6, spread over ~37 chroma 4x4 units, frame 0 exact).
40+ Not attributable yet: `EC_AV1_DEBUG_SKIP_CDEF=1` cannot bisect inter frames (it also breaks the
41+ reference frames), so the postdeblock rung is only valid for frame 0 here. Next step: dump
42+ per-4x4 chroma CDEF params (uv pri/sec, damping-1, shared luma dir) for frame 1's first
43+ differing unit and model it against `cdef_block.c` the way defect A was modelled
44+ (`~/.cache/cdef-tmp/model.py` is a complete python port of cdef_block.c + find_dir + adjust).
45+
46+## Gate
47+`stream.rs::a_real_aomenc_stream_with_cdef_and_sub16_inter_leaves_decodes_pixel_exact` -- real
48+aomenc, `--min-partition-size=4 --enable-cdef=1` (last flag wins), 5 arms (8-bit cq 8/10/12,
49+10-bit cq 8/12), every decode-order frame compared on Y/U/V, hard asserts
50+`decode::cdef_skipped_units()` (an 8x8 unit really excluded by the all-skip rule) and
51+`decode::inter8_skip_band_hits()` (the leaf that used to write nothing) both grew per compared
52+attempt. 2 of 5 arms fire; the other 3 hit UNRELATED open refusals (non-DC chroma mode on an 8x8
53+inter leaf; inter partition below 8x8) -- widening to 10-bit needs those lifted first.
54+`cargo test -p ec-av1 --lib cdef_and_sub16` -> ok, 1 passed / 0 failed.
55+
56+## Other
57+* `dump_stage`/`dump_stage16` wrote `.f0` for EVERY frame (each overwrote the last), so
58+ `EC_AV1_POSTDEBLOCK_DUMP`/`POSTCDEF_DUMP` were unusable for per-frame bisection. Now indexed
59+ per env var (`dump_stage_idx`), matching aomdec's own `.fN`.
60+* New rung `EC_AV1_CDEF_DBG=1`: one line per filtered 8x8 luma unit
61+ (`EC_CDEF mi_r= mi_c= x= y= sidx= dir= var= t= pri= sec= damp=`).
62+* Class sweep for "per-8x8 map read at the top-left mi only under sub-8x8 partitions": the skip
63+ grid is written by every OTHER leaf path (grep `fill_skip_grid`), `decode_inter_block8` was the
64+ only writer missing; `is_skip_txfm` already gathers all four cells; the deblock/tx grid has a
65+ `fill_lf_grid` at every one of those sites including both `decode_inter_block8` exits.
66+* Not done: `--tile-columns=1` arm on the new gate (COMMON neighbour-map rule) -- deferred.
lanes/interp3-r1.report.mdadded+96 -0
@@ -0,0 +1,96 @@
1+# lane-interp3 r1 -- the `switchable_interp` PANIC: the compound 8x8 leaf never read its filter
2+
3+## Root cause (cited)
4+
5+libaom `decodemv.c:1575` (`read_inter_block_mode_info`) calls `read_mb_interp_filter`
6+for **every** inter block, compound ones included, right after `read_compound_type`.
7+`decode_leaf8`'s COMPOUND arm (`crates/ec-av1/src/decode.rs`, the branch that returns at
8+the old line 19589) called `resolve_interp_filter` **not at all**: it predicted both taps
9+with a hard-coded `Regular` and returned the `[3, 3]` "no filter recorded" sentinel as the
10+leaf's `leaf_filter_syms`. Two consequences, both real on his data:
11+
12+1. **Entropy**: on a `SWITCHABLE`-filter frame one symbol (two under `enable_dual_filter`)
13+ is left unread at every compound 8x8 leaf -- silent desync.
14+2. **Crash**: the sentinel is stamped into `Neighbours::above_filter`/`left_filter`, and a
15+ neighbouring OBMC block's `neighbour_filter` fed it to
16+ `mc::InterpFilterKind::from_switchable_symbol`, whose `panic!("switchable_interp's
17+ alphabet is exactly 3 symbols")` aborted the process. That is the panic lane-r14 r3
18+ flagged (its `--enable-dual-filter=1 --enable-obmc=1` 192x128 cq30 stream). The same
19+ shape was already fixed once for the SINGLE-ref 8x8 leaf (lane-gmaffine r3, decode.rs
20+ ~21509 comment) -- the compound arm was the surviving sibling instance.
21+
22+## Changed
23+
24+- `crates/ec-av1/src/decode.rs` (compound 8x8 leaf, after the `comp_group_idx`/
25+ `compound_idx` reads): reads `interp_filter` in libaom's order, with `get_ref_filter_type`
26+ neighbour contexts keyed on `ref0` and `is_compound = true`; suppression term is
27+ `skip_mode || is_nontrans_global_motion` (GLOBAL_GLOBALMV + both refs' models non-
28+ TRANSLATION; WARPED_CAUSAL cannot occur on compound). The 12 `predict_compound_intermediate`
29+ taps now use the resolved `h_filter`/`v_filter` instead of `Regular`.
30+- `crates/ec-av1/src/decode.rs` `neighbour_filter`: returns `Result`; the `[3, 3]` sentinel
31+ is now the named refusal `an OBMC neighbour whose interp filter was never recorded (no
32+ switchable symbol for that block)` -- **never a panic**. Both OBMC call sites `?` it.
33+- `crates/ec-av1/src/decode.rs`: counters `DUAL_FILTER_DIFF_HITS` (a block whose two
34+ dual-filter directions differ -- impossible with dual filter off) and
35+ `COMPOUND8_FILTER_HITS`.
36+- `crates/ec-av1/src/refusal_inventory.rs`: the new refusal listed (inventory test green).
37+- `crates/ec-av1/src/stream.rs`: `inter_sb_none_gate` takes a `frame_count`
38+ (4 frames never code a compound block); new gate
39+ `a_real_aomenc_dual_filter_obmc_8x8_inter_sequence_decodes_pixel_exact`
40+ (`--enable-dual-filter=1 --enable-obmc=1 --enable-warped-motion=1 --enable-onesided-comp=1`
41+ on the `--min-partition-size=8 --enable-ab-partitions=0 --enable-1to4-partitions=0`
42+ recipe, every frame compared Y/U/V vs ffmpeg, hard asserts on all three counters).
43+- `crates/ec-av1/src/decode.rs` test
44+ `an_obmc_neighbour_with_no_recorded_filter_refuses_instead_of_panicking`.
45+
46+## Gate: RED, `#[ignore]`d with the measurement, not deleted
47+
48+`EC_INTERP3_FRAMES=4` -> aomenc codes no compound block, stream decodes.
49+From 5 frames on it does, and the decode stops at a refusal that the recipe makes
50+impossible: `an inter 16x16-level AB or 1:4 partition` WITH this round's filter read, and
51+`an inter partition below 8x8` WITHOUT it (measured by ablating the read behind a temporary
52+env switch, since removed). `--enable-ab-partitions=0 --enable-1to4-partitions=0
53+--min-partition-size=8` cannot emit either -- so both are our own desync
54+(class `refusal-from-own-desync`): the compound 8x8 leaf carries at least one more
55+missing/misplaced symbol beyond the interp filter. The fix is therefore **necessary but not
56+sufficient** and is not claimed as pixel-proven.
57+
58+EVIDENCE: $HOME/.cache/interp3-suite-r1.log | `cargo test -p ec-av1 --lib -j3` under a
59+systemd user unit, MemoryMax=10G | totals below
60+EVIDENCE: gate run `EC_INTERP3_FRAMES=5..16 cargo test -p ec-av1 --lib a_real_aomenc_dual_filter_obmc_8x8` with and without the new read | 6 encodes x 2 arms | refusal string differs per arm (AB/1:4 vs below-8x8), 0 frames compared either way -- gate RED, ignored
61+EVIDENCE: `cargo test -p ec-av1 --lib an_obmc_neighbour_with_no_recorded` | direct call with the `[3, 3]` sentinel | 1 passed: refuses by name, no panic
62+
63+## Panic sweep of the decode path (charter clause)
64+
65+`neighbour_filter` was the only `panic!` reachable from a *stream-derived value* on the OBMC
66+path; converted. The rest of `decode.rs`'s 57 `panic!/unreachable!/unwrap/expect` sites,
67+inspected: `2733, 11268, 11617, 11636, 11683, 11996, 12015, 12052, 13820, 13998, 15225,
68+15533` are `unreachable!` on values a CDF alphabet or an earlier refusal already bounds
69+(cannot fire on any stream); `5238, 5282, 6043, 6110, 7310, 7311, 7777, 7778, 10479, 10535,
70+10679, 10888` are `unwrap/expect` on this decoder's own just-built state; everything above
71+line 22700 is inside `#[cfg(test)]`. Two remain flagged, not converted (they need a `Result`
72+in a counter/table helper and no stream is known to reach them):
73+`decode.rs:2486` `panic!("ref_hits: no per-reference counter for ref_frame {other}")` and
74+`decode.rs:3247` `panic!("intra mode {other} has no Intra_Mode_To_Tx_Type entry")`.
75+`mc.rs:203`/`:220` stay as documented invariants -- both callers now check first.
76+
77+## Residue
78+
79+- fix-now(next round): the remaining compound-8x8 desync. Method: `EC_TRACE=1` aomdec range
80+ ladder against ours on the FIRST compound leaf of frame 5 of the gate's stream, comparing
81+ msac RANGE element by element (never `tell()`).
82+- deferred(needs that fix): the 10-bit arm of the new gate, and the counter-proving
83+ pixel-exact claim.
84+
85+## Suite
86+
87+`systemd-run --user --unit=interp3-suite-r1 -p MemoryMax=10G --same-dir bash -lc 'EC_NOMEMGUARD=1 EC_AV1_REQUIRE_AOMENC=1 CARGO_TARGET_DIR=$HOME/.cache/cargo-target-interp3 nice -n 10 cargo test -p ec-av1 --lib -j3 > $HOME/.cache/interp3-suite-r1.log 2>&1'`
88+
89+**372 passed; 0 failed; 33 ignored; 1208.18s** (main's 371/0/32 plus this round's
90+`an_obmc_neighbour_with_no_recorded_filter_refuses_instead_of_panicking`, plus the new
91+gate ignored). Every OBMC/compound sibling gate green on this tip, including
92+`a_real_aomenc_stream_with_obmc_decodes_pixel_exact`,
93+`a_real_aomenc_stream_with_obmc_8x8_decodes_pixel_exact`,
94+`a_real_aomenc_stream_with_compound_references_decodes_pixel_exact`,
95+`a_real_aomenc_superres_stream_with_compound_obmc_and_interintra_decodes_pixel_exact`
96+and both `..._8x8_leaf_split_...` arms -- the entropy change did not move any of them.
lanes/interp3-r2.handoff.mdadded+48 -0
@@ -0,0 +1,48 @@
1+# lane-interp3 r2 HANDOFF (turn cap)
2+
3+Tip: see `git log -1` on branch `lane-interp3` (r2 fix commit + report commit).
4+Base: r1 b702853 + `git merge main` (4eff3a1, lane-mvtwin mvstack fixes). Merge touched
5+only mvstack.rs / stream.rs / lanes/mvtwin-r1.report.md; cdf.rs untouched both sides.
6+
7+## Phase table + divergences: see lanes/interp3-r2.report.md (complete, 17 rows)
8+Two divergences found in `decode_inter_block8`'s compound arm, both FIXED:
9+1. decode.rs:19151 `read_compound_ref_frames` got a hard-coded `LAST_FRAME` (or -1)
10+ for the above/left neighbour reference instead of the real per-mi bands
11+ (`above_ref0`/`left_ref0`, what `decode_inter_block` passes) -> every
12+ `av1_collect_neighbors_ref_counts` vote off the wrong CDF row.
13+2. decode.rs:19410 the leaf's grid stamp cleared BOTH per-slot `is_global_mv_block`
14+ flags; now computed as libaom blockd.h:421-429 (mode GLOBAL_GLOBALMV + that slot's
15+ gm model > TRANSLATION).
16+Also added: decode.rs:19726 per-entry `EC_STACK` print in the leaf's SINGLE-ref arm.
17+
18+## Ladder (EC_TRACE_MODE=1, ours vs instrumented aomdec, RANGE never tell)
19+- Before fix 1, frames=5 stream: first divergence at compound leaf mi (10,2) --
20+ both enter the mode info at rng=61097; aomdec reads refs (LAST,GOLDEN) mode
21+ NEAREST_NEARESTMV -> rng 49516; ours read (LAST,LAST2) NEW_NEWMV -> rng 50496.
22+- Before fix 2, frames=16 stream: first divergence at single-ref 8x8 leaf mi (8,8),
23+ entry rng=43099 both; aomdec stack = [(-1,-1) w648, (0,0) w644] (2 entries),
24+ ours = [(0,0) w644, (2,-4) w644, (-1,-1) w4] (3) -- the extra (2,-4) is the
25+ neighbour's stored mv1 where libaom substitutes the reader's global mv.
26+- AFTER both fixes: 570 vs 570 mode elements, `diff` EMPTY, no refusal.
27+
28+## Gate state
29+`a_real_aomenc_dual_filter_obmc_8x8_inter_sequence_decodes_pixel_exact` still
30+`#[ignore]`d (ignore text updated with this measurement). Now RED on RECONSTRUCTION,
31+not entropy: luma-only, frames 0-6 byte-exact, frame 7 = 36 Y wrong (max |d| 5, first
32+(42,15), the 8x8 leaf at mi (10,4), 1-px spill across its left/bottom deblock edges),
33+propagating to 222 Y + 4 U + 1 V at frame 15.
34+Artifacts: scratchpad .../{pin.obu (5 frames), pin16.obu==mm.obu (16), aom16.trace,
35+ours16e.trace, mm.aom.yuv, mm.ours.yuv, aom.obmc}.
36+
37+## Suite
38+Unit `interp3-suite-r2-1788327820.service`, log `$HOME/.cache/interp3-suite-r2.log`.
39+Armed at the r2 fix commit; still running at the cap -- read the log's `test result:`
40+line, do not re-run blindly.
41+
42+## EXACT NEXT STEP
43+Build an `EC_OBMC` emitter in decode.rs (both OBMC call sites) printing the oracle's
44+own byte format -- `EC_OBMC above|left mi=(r,c) wh=(WxH) rel=%d op=%d nbmv=(y,x)
45+nbref=%d nbbsize=%d filt=%d` -- then diff it against the 325 lines of
46+`EC_OBMC=1 aomdec --rawvideo -o /dev/null mm.obu`, starting at `mi=(10,4)`. The leaf
47+now records a REAL filter pair where it used to record the [3,3] sentinel, so an OBMC
48+blend over a compound neighbour is the first suspect for the residue.
lanes/interp3-r2.report.mdadded+88 -0
@@ -0,0 +1,88 @@
1+# lane-interp3 r2 -- the compound 8x8 leaf's ENTROPY desync is closed (two twin drifts); gate now RED on a small luma reconstruction residue
2+
3+Base: b702853 (r1) + `git merge main` (4eff3a1, brings lane-mvtwin's mvstack fixes).
4+Merge diffstat: `crates/ec-av1/src/mvstack.rs`, `crates/ec-av1/src/stream.rs`,
5+`lanes/mvtwin-r1.report.md` only -- `cdf.rs` untouched by either side (byte-compare
6+trivially clean), no fixtures churn, no conflicts.
7+
8+## Phase table -- libaom `read_inter_block_mode_info` (decodemv.c ~1400-1600)
9+
10+`IB` = `decode_inter_block` compound arm, `L8` = `decode_inter_block8` compound arm
11+(both in `crates/ec-av1/src/decode.rs`; line numbers are this commit's).
12+
13+| # | phase (libaom) | IB | L8 | verdict |
14+|---|---|---|---|---|
15+| 1 | `skip_mode` (ctx = above+left skip_mode) | 16363 | 19087 | matches |
16+| 2 | `skip` | 16375 | 19093 | matches |
17+| 3 | cdef / delta_q / delta_lf | 16377-16382 | (16x16 slot's, per this fn's doc) | matches (leaf never a delta root) |
18+| 4 | `is_inter` (`intra_inter_ctx`) | 16389 | 19105 | matches |
19+| 5 | `comp_mode` (`read_comp_mode`, ref-count ctx) | 16475 | 19147 | matches (`skip_mode \|\| (reference_select && ...)` vs `reference_select \|\| skip_mode` then `skip_mode \|\| ...` -- same predicate) |
20+| 6 | `read_ref_frames`: `comp_ref_type`, uni/bi trees | 16480 | 19151 | **DIFFERENT -> FIXED**: L8 passed a hard-coded `LAST_FRAME` (or `-1`) as the above/left reference; IB passes the real `neighbours.above_ref[cmi]`/`left_ref[rmi]` |
21+| 7 | `av1_find_mv_refs` (`find_mv_stack_compound`, sign bias + gm table + tpl) | 16519 | 19195 | matches (L8's doc comment claiming "no sign-bias table nor tpl_frame" is stale -- both are passed) |
22+| 8 | `compound_mode` CDF (`COMPOUND_MODE_CTX_MAP`) | 16532 | 19205 | matches |
23+| 9 | drl + `read_mv` per ref (`assign_compound_mv`, has_nearmv/have_newmv rules) | 16537 | 19226 | matches (one shared fn) |
24+| 10 | `interintra` | n/a compound | n/a | matches (never read on compound -- correct) |
25+| 11 | `read_motion_mode` | n/a compound | n/a | matches (`has_second_ref` -> SIMPLE_TRANSLATION) |
26+| 12 | `comp_group_idx` (neighbour ctx) | 16675 | 19263 | matches |
27+| 13 | `compound_type` -> wedge idx+sign / diffwtd `mask_type` | 16710 | 19279 | matches |
28+| 14 | `compound_idx` (distance-weight ctx) | 16936 | 19310 | matches |
29+| 15 | `read_mb_interp_filter` (after `read_compound_type`; suppressed by `skip_mode` / `is_nontrans_global_motion`; `get_ref_filter_type` on ref0 matching EITHER neighbour ref) | 16980 | 19383 | matches (landed r1) |
30+| 16 | tail: grid `MiInfo` stamp -- per-slot `is_global_mv_block` | 16577+16660 | 19424 | **DIFFERENT -> FIXED**: L8 stamped `is_global_mv0/1 = false` unconditionally |
31+| 17 | tail: `record_inter_rect_mi` + `record_compound_ctx_rect_mi` (skip/skip_mode/inter/ref/ref1/filter/comp_group_idx/compound_idx bands) | 18870 | via `compound_ctx8` + caller, 19000 | matches -- verified by the range ladder staying exact for the whole stream |
32+
33+Root causes 6 and 16 are the round's fix. Both are the same class the charter named
34+(twin functions drift), and both are invisible to any value-only check: (6) changes a
35+CDF ROW, (16) changes a LATER block's mv-stack composition.
36+
37+## Changed (path:line)
38+
39+- `crates/ec-av1/src/decode.rs:19151` -- `read_compound_ref_frames` now gets
40+ `above_ref0`/`left_ref0` (the per-mi bands the leaf already reads at 19078-19081)
41+ instead of `LAST_FRAME`/`-1`. `-1` on an unavailable band is `start_tile`'s /
42+ `start_row`'s own reset value, so no `has_above` guard is needed (IB has none either).
43+- `crates/ec-av1/src/decode.rs:19410` -- the leaf's grid stamp computes libaom's
44+ per-slot `is_global_mv_block` (mode `GLOBAL_GLOBALMV`, that slot's gm model >
45+ TRANSLATION; the >= 8x8 size predicate is always true for this leaf).
46+- `crates/ec-av1/src/decode.rs:19726` -- the leaf's SINGLE-ref arm prints the same
47+ per-entry `EC_STACK` ladder `decode_inter_block`'s single-ref arm prints (this is
48+ the instrument that isolated cause 16).
49+- `crates/ec-av1/src/stream.rs:6315` -- the gate's ignore reason + comment replaced
50+ with this round's measurement (entropy closed, pixel residue open).
51+
52+## Gate: still RED, still `#[ignore]`d -- but on a different, much smaller failure
53+
54+`a_real_aomenc_dual_filter_obmc_8x8_inter_sequence_decodes_pixel_exact`
55+(`--enable-dual-filter=1 --enable-obmc=1 --enable-warped-motion=1
56+--enable-onesided-comp=1`, `--min-partition-size=8 --enable-ab-partitions=0
57+--enable-1to4-partitions=0`, 16 frames, 64x64).
58+
59+- r1: decode STOPPED at a bogus refusal at frame 5 (0 frames ever compared).
60+- r2: the whole 16-frame stream parses; the failure is now
61+ `frame 7 mismatch vs ffmpeg` -- a reconstruction residue, luma-only,
62+ |delta| <= 8, first sample (42,15) inside/around the 8x8 leaf at mi (10,4),
63+ spilling 1 px across that leaf's left and bottom deblock edges. It grows by pure
64+ propagation to 222 Y + 4 U + 1 V samples at frame 15 (chroma stays exact until
65+ frame 14).
66+
67+EVIDENCE: /tmp/claude-1000/-home-user-Documents-Code-Rust-edith-codecs/b6d8a07f-96a4-4bbb-b378-af9ae25cf7c9/scratchpad/{aom16.trace,ours16e.trace} | `EC_TRACE_MODE=1 aomdec --rawvideo` and `EC_TRACE_MODE=1 decode_probe` on the pinned 16-frame stream, `diff` of every `EC_MODE`/`EC_MODE_VAL` line (mi + msac RANGE, never tell) | 570 vs 570 elements, diff EMPTY, no refusal (before the fix: ours stopped at 347 elements, first RANGE divergence at the 8x8 leaf mi (8,8), stack 3 entries vs libaom's 2)
68+EVIDENCE: same dir, `pin.obu` (EC_INTERP3_FRAMES=5) | ladder before fix 1 | ours read refs (LAST,LAST2) + NEW_NEWMV at leaf mi (10,2) where aomdec reads (LAST,GOLDEN) + NEAREST_NEARESTMV -- the two differ only in a CDF row of `uni_comp_ref`
69+EVIDENCE: same dir, `mm.{aom,ours}.yuv` | `aomdec --rawvideo` vs `decode_probe` on the pinned mismatch stream, per-frame per-plane sample compare | frames 0-6 byte-exact; frame 7: 36 Y / 0 U / 0 V wrong, max |delta| 5; frame 15: 222 Y / 4 U / 1 V, max |delta| 8
70+
71+## Refusals
72+
73+None lifted this round (the r1 refusal `an OBMC neighbour whose interp filter was
74+never recorded` stays; `refusal_inventory` unchanged). Two refusals this stream used
75+to hit -- `an inter 16x16-level AB or 1:4 partition` and `an inter partition below
76+8x8` -- were our own desync (class refusal-from-own-desync) and no longer fire on it.
77+
78+## Residue
79+
80+- fix-now(next round): the luma reconstruction residue above. First suspect is the
81+ OBMC blend over a COMPOUND neighbour -- the leaf now records a real filter pair
82+ where it used to record the `[3,3]` sentinel, and the oracle's `EC_OBMC` rung
83+ prints `nbmv`/`nbref`/`nbbsize`/`filt` per neighbour while THIS decoder has no
84+ `EC_OBMC` emitter at all. Build that emitter first (instrument-before-excuse), then
85+ diff the 325 oracle `EC_OBMC` lines of `mm.obu` against ours.
86+- deferred(needs that fix): the gate's counter asserts (compound-8x8 filter reads,
87+ dual-filter differing directions, 8x8 OBMC blends) are never reached while the
88+ pixel compare fails first; the 10-bit arm; a `--tile-columns=1` arm.
lanes/interp3-r3.handoff.mdadded+88 -0
@@ -0,0 +1,88 @@
1+# lane-interp3 r3 HANDOFF (turn cap) -- root cause FOUND and FIXED, suite still running
2+
3+Tip: `f36be26` on branch `lane-interp3` (fix) + this handoff/report commit.
4+
5+## Suite state
6+- r2 suite (unit `interp3-suite-r2-1788327820.service`, log `$HOME/.cache/interp3-suite-r2.log`),
7+ armed at the r2 commit, FINISHED:
8+ `test result: ok. 378 passed; 0 failed; 34 ignored; 0 measured; 0 filtered out; finished in 742.50s`
9+- r3 suite FINISHED GREEN at f36be26 (unit `interp3-suite-r3-1788328778.service`):
10+ `test result: ok. 379 passed; 0 failed; 33 ignored; 0 measured; 0 filtered out; finished in 1031.33s`
11+ (old text below is superseded)
12+- r3 suite armed at f36be26: unit `interp3-suite-r3-1788328778.service`,
13+ log `$HOME/.cache/interp3-suite-r3.log`. At the cap it had 258 `... ok`, ZERO
14+ `FAILED`/`panicked`, no `test result:` line yet. READ THAT LINE, do not re-run
15+ blindly, then paste it into `lanes/interp3-r3.report.md` where
16+ `EVIDENCE: SUITE_LINE_PLACEHOLDER` sits.
17+
18+## Stage attribution of the frame-7 residue (done FIRST, as chartered)
19+`EC_AV1_PREFILT_DUMP` on both decoders over the pinned 16-frame stream
20+(`.../scratchpad/mm.obu`), byte compare per decode-order frame:
21+frames 0-6 identical, frame 7 = 35 differing luma bytes, 8..15 grow to 224.
22+=> PRE-FILTER, i.e. prediction/reconstruction, never the loop filter/CDEF/LR.
23+All 35 sit in luma rows 42-47, cols 16-23, i.e. the block at mi (10,4);
24+rows 40-41 of that same block are EXACT and the error grows downward.
25+
26+## What the OBMC comparison actually said (emitter built, class swept, CLEAN)
27+Before writing the emitter, the hand comparison against libaom found NO mismatch:
28+`overlappable_above`/`overlappable_left` stepping and `max_neighbor_obmc`
29+(`{0,1,2,3,4,4}`, 8x8 -> 1 per pass) match `obmc.h:20-55`; overlap sizes
30+(4 luma rows above / 4 luma cols left at 8x8, chroma 2) match
31+`build_obmc_inter_pred_{above,left}`; `av1_skip_u4x4_pred_in_obmc` chroma-above
32+skip matches; `obmc_mask_1/2/4/8/16/32` are byte-identical to
33+`reconinter.c:752-765`; OBMC never warps (`if (!build_for_obmc) av1_init_warp_params`).
34+One real divergence candidate was left un-ported and is still a documented
35+corner-cut, not a defect on this content: `obmc.h`'s `mi_step == 1` 4-wide pair
36+merge, and libaom's `op_mi_size = AOMMIN(xd->width, mi_step)` which can exceed
37+the remaining span while ours clips with `.min(end_col - col)` (only reachable
38+for a 2nd neighbour with a wide step).
39+
40+Emitter: `decode.rs:15806` `ec_obmc_bsize()` + `decode.rs:15828` `ec_obmc_trace()`,
41+called at both passes in `obmc_blend`. Format is aomdec's own bytes:
42+`EC_OBMC above|left mi=(r,c) wh=(WxH) rel=N op=N nbmv=(y,x) nbref=N nbbsize=N filt=N`
43+(`filt` = packed `interp_filters.as_int` = `y | (x << 16)`).
44+`diff` of the 325 oracle lines vs our 325: EMPTY. OBMC is exonerated.
45+
46+Also added `decode.rs:14682` + `:22658` `EC_PICT idx=` (decode-order frame
47+marker under `EC_OBMC`/`EC_TRACE_MODE`). REQUIRED: the marker prints AFTER the
48+frame's own trace lines, so `awk` must count markers seen, not read the value on
49+the preceding line -- attributing by the preceding `EC_PICT` value is off by one
50+and cost part of this round.
51+
52+## Hypotheses ruled out (each by measurement)
53+- OBMC neighbour fields / masks / overlap: 325/325 identical lines (above).
54+- Frame 7 has NO OBMC block at mi (10,4) at all -- it is COMPOUND
55+ (SIMPLE_TRANSLATION), so the r2 handoff's "OBMC over a compound neighbour"
56+ suspect could not have been it.
57+- Residual/entropy: r2's range ladder is exact end to end; `EC_MCDUMP` (a
58+ temporary rung, removed before commit) showed aom_recon - our_residual
59+ reproduces our PREDICTION in rows 40-41 and diverges below => prediction.
60+- Wrong dual-filter x/y assignment: a swap would err in every row, not only the
61+ lower ones.
62+
63+## Root cause (FIXED, gate GREEN)
64+`decode_inter_block8`'s COMPOUND arm predicted BOTH taps translationally.
65+libaom applies `allow_warp`'s GLOBAL branch to every `is_global_mv_block`
66+reference slot -- compound included, independent of `motion_mode`
67+(`av1_init_warp_params` inside `build_inter_predictors_8x8_and_bigger`'s per-`ref`
68+loop; `reconinter.c:33-55`). `decode_inter_block`'s compound arm has done this
69+since lane-cwarp r1 (`decode.rs:16691`). Third twin-functions-drift instance in
70+this lane. Frame 7 mi (10,4): GLOBAL_GLOBALMV, ref0=GOLDEN mv (0,0),
71+ref1=ALTREF mv (-3,4), comp_group_idx=1.
72+Fix: `decode.rs:19513` (`leaf_compound_warp`, `warp0_c`/`warp1_c`),
73+`decode.rs:19596`/`:19618` (`warp_affine_compound` per luma tap; chroma is 4x4,
74+below `av1_init_warp_params`'s 8px per-plane bound, so it stays translational).
75+Counter `COMPOUND_WARP_HITS_8` / `compound_warp_hits_8()` at `decode.rs:1786`.
76+After the fix ALL 16 decode-order frames are byte-identical pre-filter.
77+
78+## Gate
79+`a_real_aomenc_dual_filter_obmc_8x8_inter_sequence_decodes_pixel_exact`
80+(`stream.rs:6332`) is UN-IGNORED and GREEN with four hard asserts (compound-8x8
81+filter read, differing dual-filter directions, 8x8 OBMC blend, 8x8 compound
82+GLOBAL warp). `$HOME/.cache/interp3-gate-r3.log`: `1 passed; 0 failed`.
83+
84+## EXACT NEXT STEP
85+1. DONE (suite green, report filled). Nothing owed here.
86+2. Then the lane's open residue is only the two deferrals in the report
87+ (10-bit arm blocked by lane-inter8's 10-bit 8x8-leaf desync; `--tile-columns=1`
88+ arm blocked by the SB-level rect-partition refusal).
lanes/interp3-r3.report.mdadded+106 -0
@@ -0,0 +1,106 @@
1+# lane-interp3 r3 -- the 8x8 COMPOUND leaf never applied the per-ref GLOBAL warp; gate is GREEN and un-ignored
2+
3+Base: d06d93f (r2 handoff, already merged with main).
4+
5+## Root cause (one line)
6+
7+`decode_inter_block8`'s COMPOUND arm predicted **both** reference taps
8+translationally, while libaom applies `allow_warp`'s GLOBAL branch to every
9+`is_global_mv_block` reference slot -- compound included and independently of
10+`motion_mode` (`av1_init_warp_params` is called inside
11+`build_inter_predictors_8x8_and_bigger`'s per-`ref` loop, `reconinter.c:33-55`
12+for `allow_warp` itself). The 16x16+ compound arm has done this since
13+lane-cwarp r1 (`decode.rs:16691`); the 8x8 leaf is its twin and drifted.
14+Third instance in this lane of the class **twin functions drift**.
15+
16+Effect on the pinned stream: the GLOBAL_GLOBALMV compound 8x8 leaf at
17+mi (10,4) of decode-order frame 7 (ref0=GOLDEN mv (0,0), ref1=ALTREF mv
18+(-3,4), `comp_group_idx=1` masked compound) was predicted with a pure
19+translation, so its prediction error was 0 at the block's top rows and grew
20+downward to |delta| 5 -- then propagated through every later frame.
21+
22+## It was NOT the OBMC blend (the r2 handoff's first suspect, disproved)
23+
24+An `EC_OBMC` emitter was added to both OBMC passes in `decode.rs`, printing the
25+instrumented aomdec's own byte format
26+(`EC_OBMC above|left mi=() wh=() rel= op= nbmv=() nbref= nbbsize= filt=`,
27+`decodeframe.c` `dec_build_prediction_by_{above,left}_pred`). The two decoders
28+emit **325 identical lines** on the pinned 16-frame stream -- neighbour
29+position, span, mv, reference, bsize and packed dual-filter pair all agree at
30+every OBMC call. The class sweep the charter asked for (neighbour-side fields
31+used by OBMC: filter, ref, mv, scale) is therefore CLEAN by measurement, not by
32+inspection; `obmc_mask_1/2/4/8/16/32` were also byte-compared against
33+`reconinter.c:752-765` and match.
34+
35+Frame 7 has no OBMC block at mi (10,4) at all: it is a compound block, and
36+compound blocks take SIMPLE_TRANSLATION.
37+
38+## Changed (path:line, this commit)
39+
40+- `crates/ec-av1/src/decode.rs:19513` -- `leaf_compound_warp` +
41+ `warp0_c`/`warp1_c`, the leaf's per-slot copy of `decode_inter_block`'s
42+ `compound_warp` (`force_integer_mv` short-circuit, `gm.invalid` guard).
43+- `crates/ec-av1/src/decode.rs:19596,19618` -- `warp::warp_affine_compound`
44+ replaces each luma tap's translational intermediate, exactly as the 16x16+
45+ arm does at 17130/17155. Chroma is 4x4 at an 8x8 leaf, below
46+ `av1_init_warp_params`'s own per-plane 8px bound, so chroma stays
47+ translational (same rule the leaf's single-ref arm already applied).
48+- `crates/ec-av1/src/decode.rs:1786` -- `COMPOUND_WARP_HITS_8` +
49+ `compound_warp_hits_8()`: the gate's proof that the warp fired at an 8x8
50+ LEAF specifically (`COMPOUND_WARP_HITS` alone cannot tell it from a 16x16+).
51+- `crates/ec-av1/src/decode.rs:15806` (`ec_obmc_bsize`) and `15828`
52+ (`ec_obmc_trace`) + the two call sites in `obmc_blend` -- the `EC_OBMC` rung.
53+- `crates/ec-av1/src/decode.rs:14682,22658` -- `EC_PICT idx=` decode-order
54+ frame marker (printed under `EC_OBMC`/`EC_TRACE_MODE`), so a trace line can be
55+ attributed to the frame whose `EC_AV1_PREFILT_DUMP` file mismatched. Without
56+ it the r2 hunt mis-attributed every trace line by one frame.
57+- `crates/ec-av1/src/stream.rs:6332` -- the gate's `#[ignore]` removed, doc
58+ comment carries this round's measurement, and a third hard assert
59+ (`compound_warp_hits_8() > before`) added.
60+
61+## Class sweep
62+
63+Both inter block decoders are the only prediction sites
64+(`decode_inter_block` 16309, `decode_inter_block8` 19032); all 12
65+`predict_compound_intermediate` calls were audited. Warp coverage is now:
66+16x16+ single-ref (18235-18253), 16x16+ compound y/u/v x 2 refs
67+(17130-17300), 8x8 leaf single-ref (20238-20253), 8x8 leaf compound luma x 2
68+refs (19596/19618, chroma correctly excluded). No third twin exists.
69+
70+## Gate: GREEN, un-ignored
71+
72+`a_real_aomenc_dual_filter_obmc_8x8_inter_sequence_decodes_pixel_exact`
73+(`--enable-dual-filter=1 --enable-obmc=1 --enable-warped-motion=1
74+--enable-onesided-comp=1`, `--min-partition-size=8 --enable-ab-partitions=0
75+--enable-1to4-partitions=0`, 64x64, 16 frames). Four hard asserts now:
76+compound 8x8 leaf reading its own switchable filter, a block whose two
77+dual-filter directions DIFFER, an 8x8 OBMC blend, and an 8x8 compound leaf
78+predicted through the per-ref GLOBAL warp.
79+
80+Command:
81+`EC_NOMEMGUARD=1 EC_AV1_REQUIRE_AOMENC=1 CARGO_TARGET_DIR=$HOME/.cache/cargo-target-interp3 cargo test -p ec-av1 --lib a_real_aomenc_dual_filter_obmc_8x8_inter_sequence_decodes_pixel_exact`
82+Result: `test result: ok. 1 passed; 0 failed` (log `$HOME/.cache/interp3-gate-r3.log`).
83+
84+## Refusals
85+
86+None lifted. The r1 refusal `an OBMC neighbour whose interp filter was never
87+recorded` stays (it does not fire on this stream); `refusal_inventory.rs` and
88+`gate_coverage.rs` unchanged.
89+
90+## EVIDENCE
91+
92+EVIDENCE: /tmp/claude-1000/-home-user-Documents-Code-Rust-edith-codecs/b6d8a07f-96a4-4bbb-b378-af9ae25cf7c9/scratchpad/{aom.obmc,ours.obmc} | `EC_OBMC=1 aomdec --rawvideo -o /dev/null mm.obu` vs `EC_OBMC=1 decode_probe mm.obu`, `diff` of every EC_OBMC line | 325 vs 325 lines, diff EMPTY -- OBMC neighbour selection/mv/ref/bsize/filter exonerated
93+EVIDENCE: same dir, pf_a/f.f0..15 vs pf_o/f.f0..15 | `EC_AV1_PREFILT_DUMP` on both decoders, byte compare per decode-order frame BEFORE the fix | frames 0-6 identical, frame 7 35 bytes differ (all inside luma rows 42-47, cols 16-23 = the 8x8 leaf at mi (10,4)), growing to 224 at frame 15
94+EVIDENCE: same dir, pf_a vs pf_o2 | identical command AFTER the fix | all 16 decode-order frames byte-identical pre-filter (0 differing bytes)
95+EVIDENCE: $HOME/.cache/interp3-gate-r3.log | `cargo test -p ec-av1 --lib a_real_aomenc_dual_filter_obmc_8x8_inter_sequence_decodes_pixel_exact -- --nocapture` | `test result: ok. 1 passed; 0 failed` with all four counter asserts live (the run would panic if `compound_warp_hits_8` had not moved)
96+EVIDENCE: $HOME/.cache/interp3-suite-r3.log | `EC_NOMEMGUARD=1 EC_AV1_REQUIRE_AOMENC=1 CARGO_TARGET_DIR=$HOME/.cache/cargo-target-interp3 cargo test -p ec-av1 --lib -j3` under systemd unit `interp3-suite-r3-1788328778.service`, armed at f36be26 | `test result: ok. 379 passed; 0 failed; 33 ignored; 0 measured; 0 filtered out; finished in 1031.33s` (r2 baseline was 378 passed / 34 ignored -- the delta is exactly this gate leaving `#[ignore]`)
97+
98+## Residue
99+
100+- deferred(lane-inter8's 10-bit 8x8-leaf desync) -- a 10-bit twin of this gate.
101+ Its sibling `a_real_aomenc_10bit_inter_sequence_with_an_8x8_leaf_split_...`
102+ is still `#[ignore]`d on an unrelated 10-bit desync (lane-inter8 r2), so a
103+ 10-bit arm of this recipe would go RED on that, not on interp3's own path.
104+- deferred(needs a multi-tile recipe that reaches an 8x8 leaf) -- a
105+ `--tile-columns=1` arm. lane-inter8 r3 measured that the 128x64 multi-tile
106+ recipe stops at the SB-level rect-partition refusal before any 8x8 leaf.
lanes/intersub8-r1.handoff.mdadded+64 -0
@@ -0,0 +1,64 @@
1+# lane-intersub8 r1 — HANDOFF (RED, code committed, gate red)
2+
3+## 1. The refusal is REAL, not our desync (settled, do not re-litigate)
4+`aomenc` genuinely writes sub-8x8 partitions on INTER frames.
5+Recipe (192x128, 6 frames, gray ramp `128+58*sin((X+N*8)/6)+18*sin(Y/23)`, cq 8,
6+`--min-partition-size=4 --max-partition-size=16 --enable-rect-partitions=1
7+--enable-ab-partitions=0 --enable-1to4-partitions=0 --enable-obmc=0
8+--enable-tx-size-search=1 --sb-size=64 --lag-in-frames=0`), oracle:
9+`EC_TRACE=1 ~/.cache/aom-oracle/build/aomdec --rawvideo -o /dev/null u8_8.obu 2>ec.log`
10+`EC_PART_VAL bsize=3` histogram: **v0=68 NONE, v1=28 HORZ, v2=49 VERT, v3=3 SPLIT**.
11+So 8x4/4x8 dominate; 4x4 SPLIT is rare. `--enable-rect-partitions=0` removes
12+HORZ/VERT below 8x8 and still yields SPLIT groups (2 per stream at cq 8).
13+
14+Side fact worth a sweep: the SAME trace shows `bsize=6 value=6/7` (VERT_A/VERT_B at
15+16x16) even though `--enable-ab-partitions=0` was on the command line — that is what
16+the "inter 16x16-level AB or 1:4 partition" refusal fires on for recipes with
17+`--min-partition-size=4`. Either the flag is not honoured at that size or the
18+refusal is itself hallucinated; lane-inter16ab should check with this trace.
19+
20+## 2. What landed (compiles, `cargo check` clean)
21+* `crates/ec-av1/src/decode.rs` `decode_inter_sub8_split4` (new fn, above
22+ `decode_inter_block8`): four `BLOCK_4X4` inter sub-blocks of one 8x8 group.
23+ Symbols deliberately NOT read below 8x8, with libaom citations in the doc
24+ comment: `skip_mode` / `comp_mode` (`is_comp_ref_allowed`, blockd.h),
25+ `interintra` (`is_interintra_allowed_bsize`), `motion_mode`/`obmc`
26+ (`motion_mode_allowed`), tx size (`block_signals_txsize`, blockd.h:1027 —
27+ `bsize > BLOCK_4X4`, so `BLOCK_4X4` reads NO tx symbol even in TX_MODE_SELECT,
28+ decodeframe.c:1164-1177). Chroma once per 8x8 on the last sub-block, 4x4 TX,
29+ prediction = four 2x2 chroma pieces each from its own sub-block's mv/ref/filters
30+ (`dec_build_inter_predictors` is_sub8x8; spec 7.11.3.1). Chroma tx_type inherits
31+ the FIRST sub-block's luma tx_type (`av1_get_tx_type` co-located luma 0,0).
32+* call site: `decode.rs` ~21834, `part8 == PARTITION_SPLIT` dispatches; HORZ/VERT
33+ now refuse under a NARROWED string (rect sub-8x8 inter transform unimplemented).
34+* counter `SUB8_INTER_SPLIT_HITS` / `decode::sub8_inter_split_hits()`.
35+* `refusal_inventory.rs`: old string replaced by the 3 new ones.
36+* gate `stream.rs::a_real_aomenc_inter_sequence_with_a_sub8x8_inter_split_decodes_pixel_exact`.
37+
38+## 3. Gate result: RED (two separate failures)
39+`cargo test -p ec-av1 --lib sub8x8_inter_split`
40+* 8-bit attempt 0 (cq 8, sp 3): **MISMATCHES with ZERO sub-8x8 inter split groups**
41+ → a defect this lane did not introduce and does not own (out-of-scope arm).
42+ Suspect: the oracle's 2 `bsize=3 value=3` in that stream are on the KEY frame
43+ (intra `decode_leaf_split4`), i.e. a pre-existing intra sub-8x8 defect on this
44+ recipe, OR our partition read desyncs before reaching them. CHECK FIRST: run the
45+ oracle trace on that exact stream and print the frame index of each b3 v3.
46+* 8-bit attempt 1 (cq 12, sp 3): 1 split group, luma **frame 5** mismatches.
47+ Frames 0..4 are exact, so the group is late in the sequence — bisect with
48+ `EC_TRACE_MODE` (`EC_MODE_VAL4` line added for the 4x4 sub-block) against the
49+ oracle's `EC_MODE`/`EC_MODE_VAL` at the same mi, comparing msac RANGE.
50+ Prime suspects, in order: (a) the sub-block `skip` context — I used the
51+ mi-granular `above_skip[cmi]`/`left_skip[rmi]` pair like `decode_inter_block8`,
52+ libaom uses `av1_get_skip_txfm_context`; (b) the chroma 2x2 piece offsets /
53+ which sub-block's filters each piece uses; (c) `record_mi_luma_rect` per 4x4 vs
54+ the group-level chroma neighbour tail; (d) `first_tx_type` when sub-block 0 is
55+ skip (libaom memsets tx_type_map to DCT_DCT for skip — we leave DctDct: OK).
56+
57+## 4. Still refused after this round
58+`an inter 8x8 HORZ/VERT partition (8x4/4x8 inter leaves...)` — needs (1) INTER
59+TxbSet twins for 4x8/8x4 (`LumaRect4x8Inter`/`Set1`: side 8 tables +
60+`inter_tx_type_4`, copy `LumaRect4x8` and swap the tx_type slice), (2) a
61+rectangular var-tx read: for BLOCK_8X4/4X8, TX_MODE_SELECT + !skip reads exactly
62+ONE `txfm_partition` symbol (max_txsize_rect_lookup = TX_8X4/TX_4X8; split →
63+TX_4X4), our `read_block_tx_size`/`read_var_tx_size` are square-only.
64+That is the bulk of the remaining work and is why r1 scoped to SPLIT.
lanes/intersub8-r2.handoff.mdadded+66 -0
@@ -0,0 +1,66 @@
1+# lane-intersub8 r2 — HANDOFF (gate GREEN, 8x4/4x8 not started)
2+
3+## Merge state
4+* `c048e29` main (8e9ba81) merged — no conflicts, `cdf.rs` untouched.
5+* `e8bb7e7` lane-r14 **b86eb38 merged** (it was NOT on main: main only carries the earlier
6+ `6699ce6`/`a2e2e29`). So `read_var_tx_size` here is `(tx_w,tx_h)`-general with the full
7+ `sub_tx_size_map`, and `read_inter_plane_rect` is available.
8+ NOTE (ledger, lane-inter16ab r3): that merge deletes the "split transform on a 16x16-level
9+ 1:4 inter strip" refusal, so a TX_16X4→TX_8X4 split can reach
10+ `rect_inter_residual_supported(8,4)==false` / `rect_inter_luma_set` `unreachable!()`.
11+ The `LumaRect8x4Inter`/`LumaRect4x8Inter` TxbSets (step 3 below) close that too.
12+
13+## Attempt-0 (cq 8) zero-group mismatch — ROOT CAUSE IDENTIFIED, out of scope
14+Not a sub-8x8 defect: **CDEF**. 3 luma samples `|d|=1`, decode-order frames 3 and 4
15+(x=189 resp. 186, y=116/120/124), zero sub-8x8 inter split groups in those frames; the
16+identical recipe re-encoded with `--enable-cdef=0` decodes all six frames pixel-exact
17+(`~/.cache/intersub8-tmp/gen.sh 8 3 8 a0_nocdef.obu --enable-cdef=0`, then `cmp.py`).
18+Also reproduces at cq 10. Deferred to a CDEF lane. The gate moved to cq {12,14} instead of
19+switching CDEF off (cdef=0 changes aomenc RD and then NO attempt fires a split group).
20+
21+## Attempt-1 frame-5 ladder — FIXED (`96eff0c`)
22+First diverging element: the **switchable interp filter** of the 4x4 sub-block mi(14,46).
23+Ladder vs aomdec `EC_TRACE_MODE` on `~/.cache/intersub8-tmp/a1_8.obu`:
24+entry `39095` = , post-`assign_mv` `60392` = , after interp filter ours `51740` vs oracle `57815`.
25+Cause: the **compound 8x8 inter leaf never called `resolve_interp_filter`** — it hard-coded
26+`Regular` and recorded the `[3, 3]` sentinel in the neighbour filter band. libaom calls
27+`read_mb_interp_filter` for every inter block right after `read_compound_type`, and when
28+`av1_is_interp_needed()==0` (`skip_mode`) `set_default_interp_filters` stores
29+EIGHTTAP_REGULAR **0**. The left neighbour here was a skip_mode compound 8x8 leaf, so our
30+`av1_get_pred_context_switchable_interp` used 3 instead of 0 → wrong CDF row → desync.
31+Fix reads the symbols, uses `h_filter`/`v_filter` in all six `predict_compound_*` calls of
32+that branch, records the real syms. This also removes the old lane-av1comp corner-cut
33+(a NON-skip compound 8x8 leaf used to skip the symbol entirely = latent desync).
34+New rungs for the next hunt: `EC_TRACE_MODE` now prints `EC_MODE` + `EC_MODE_MV` on the
35+sub-8x8 path at the oracle's two print points, and `EC_AV1_IFDBG` prints `IFDBG4` with the
36+neighbour ref/filter bands.
37+
38+## 8x4/4x8 (charter step 3) — NOT STARTED
39+Still refused by name: `an inter 8x8 HORZ/VERT partition (8x4/4x8 inter leaves; the 4x4
40+SPLIT arm decodes, but a rectangular sub-8x8 inter transform is unimplemented)`.
41+Remaining pieces: `TxbSet::LumaRect8x4Inter{,1}` / `LumaRect4x8Inter{,1}` (copy the key-frame
42+8x4/4x8 intra sets' scan/ctx, swap in `inter_tx_type_4`; `av1_get_ext_tx_set_type` →
43+EXT_TX_SET_ALL16 for inter with `sqr_up == TX_8X8`), ONE `txfm_partition` bit at max
44+TX_8X4/TX_4X8 (r14's general `read_var_tx_size` handles it once max=(8,4)), mode info per
45+sub-block, chroma once on the LAST sub-block as 4x4 with 2 sub8x8 pieces, per-mi neighbour
46+writes. Gate arm: same recipe with `--enable-rect-partitions=1` (oracle histogram on the r1
47+recipe: bsize=3 v1=28 HORZ, v2=49 VERT, v3=3 SPLIT).
48+
49+## Gate state
50+`cargo test -p ec-av1 --lib sub8x8_inter_split` → **ok, 1 passed / 0 failed** (414 filtered).
51+Schedule measured by a 56-encode sweep (`~/.cache/intersub8-tmp/sweep.sh`): cq {12,14} ×
52+sp {3,6,9,12} × 8/10-bit. Firing: 8-bit cq12/sp3 = 1 group, 10-bit cq12/sp6 = 3 groups, both
53+pixel-exact; `out_of_scope_mismatch == 0`; every decode-order frame compared Y/U/V.
54+`decode_probe` now prints `sub8_inter_split: groups=N`.
55+`fixtures/realworld/reelb.obu` now stops at the 8x4/4x8 refusal (was: the SPLIT one).
56+
57+## Suite
58+Unit `intersub8-suite-1788328909.service`, log `$HOME/.cache/intersub8-suite-r2.log`.
59+FINISHED GREEN after this handoff was first written:
60+`test result: ok. 382 passed; 0 failed; 33 ignored; 0 measured; 0 filtered out; finished in 1018.88s`.
61+That run IS the sibling sweep for the interp-filter fix (it touches every compound 8x8 leaf).
62+
63+## Exact next step
64+1. Read the suite log (above). 2. Build `LumaRect8x4Inter`/`LumaRect4x8Inter` TxbSets and the
65+8x4/4x8 leaf, add the `--enable-rect-partitions=1` gate arm plus a `--tile-columns=1` arm
66+(COMMON neighbour-map rule, still owed), then drop the 8x4/4x8 refusal + inventory line.
lanes/intersub8-r2.report.mdadded+70 -0
@@ -0,0 +1,70 @@
1+# lane-intersub8 r2 — GREEN gate, one root cause, 8x4/4x8 deferred
2+
3+## 1. Merges
4+* `c048e29` main (8e9ba81) into lane-intersub8 — no conflicts, `cdf.rs` untouched.
5+* `e8bb7e7` lane-r14 (b86eb38) — `read_var_tx_size` is now `(tx_w,tx_h)`-general with the
6+ full `sub_tx_size_map`, plus `read_inter_plane_rect`. `b86eb38` was NOT on main
7+ (`git merge-base --is-ancestor b86eb38 main` → false; main only has the earlier
8+ `6699ce6` merge of `a2e2e29`).
9+
10+## 2. Root cause of the frame-5 red (fixed, `96eff0c`)
11+`crates/ec-av1/src/decode.rs` (8x8 inter leaf, compound arm, ~19940): the branch
12+**never called `resolve_interp_filter`**. It hard-coded `Regular` for both taps and left
13+`leaf_filter_syms` at the `[3, 3]` "no filter" sentinel that `Neighbours::record_inter*`
14+then stored. libaom reads `read_mb_interp_filter` for every inter block right after
15+`read_compound_type` (`decodemv.c` `read_inter_block_mode_info`), and when
16+`av1_is_interp_needed` is 0 (`skip_mode`, `WARPED_CAUSAL`, non-translational GLOBALMV)
17+`set_default_interp_filters` stores **EIGHTTAP_REGULAR (0)**, not a sentinel. Any later
18+block whose `ref_frame[0]` matches that leaf's ref0 **or ref1** then computes
19+`av1_get_pred_context_switchable_interp` from 3 instead of 0 → wrong `switchable_interp`
20+CDF row → tile desync.
21+
22+Bisection (class *compare range not tell*): on `a1_8.obu` (192x128, 8-bit, cq 12, sp 3)
23+the 4x4 sub-block at mi(14,46) matched the oracle at both of aomdec's own print points —
24+entry `rng=39095`, post-`assign_mv` `rng=60392` — and diverged only across the interp
25+filter read: ours `51740` vs aomdec `57815`. `IFDBG4` showed `left_ref=1 left_ref1=Some(4)
26+ref=4 left_filt=[3,3]`: the left neighbour was a **skip_mode compound 8x8 leaf** (its own
27+`EC_MODE` → `EC_MODE_VAL` range never moved, i.e. zero symbols).
28+
29+Fix reads the filter properly (`skip_mode` → `force_regular`, ctx from the same ref-match
30+rule the other leaves use), feeds `h_filter`/`v_filter` to all six `predict_compound_*`
31+calls of that branch and records the real symbols. This also removes the long-standing
32+`lane-av1comp` corner-cut: a **non-skip** compound 8x8 leaf used to skip the symbol
33+entirely, which was a latent desync for any stream that codes one.
34+
35+## 3. Out-of-scope defect found and named (NOT hidden)
36+Same recipe at **cq 8 / cq 10**: three luma samples of `|d| = 1` on decode-order frames 3
37+and 4 (x=189 resp. 186, y=116/120/124), with **zero** sub-8x8 inter split groups in those
38+frames. Re-encoding the identical recipe with `--enable-cdef=0` decodes all six frames
39+pixel-exact ⇒ a **CDEF** defect of another shape.
40+`deferred: CDEF ±1 luma at cq 8/10 on the 192x128 min-partition-4 recipe — belongs to a
41+CDEF lane, not to sub-8x8 partitions — unblocked by a CDEF-focused gate`.
42+The gate does not switch CDEF off (that changes aomenc's RD and kills every firing
43+attempt); it moves to cq {12,14}, where a full sweep shows no mismatch at all.
44+
45+## 4. Gate
46+`cargo test -p ec-av1 --lib sub8x8_inter_split` →
47+`test result: ok. 1 passed; 0 failed` (414 filtered out).
48+Schedule measured, not guessed: sweep of cq {8,10,12,14,16,18,20} × sp {3,6,9,12} × 8/10-bit
49+(`decode_probe`'s new `sub8_inter_split:` counter + an ffmpeg rawvideo compare).
50+Firing attempts: 8-bit cq12/sp3 = 1 group, 10-bit cq12/sp6 = 3 groups, both pixel-exact,
51+every decode-order frame compared Y/U/V; `out_of_scope_mismatch == 0`.
52+
53+EVIDENCE: ~/.cache/intersub8-tmp/a1_8.obu + ours.if.log + oracle.mode.log | aomenc 192x128 8-bit cq12 min-partition-size=4, our EC_MODE/EC_MODE_MV rungs vs aomdec EC_TRACE_MODE range ladder at mi(14,46), then a full-frame ffmpeg compare | ladder diverged at the interp filter (51740 vs 57815); after the fix all 6 frames byte-identical (`cmp.py` frames 0..5 exact)
54+EVIDENCE: ~/.cache/intersub8-tmp/sweep.sh output (56 encodes) | cq×sp×depth sweep, decode_probe counter + ffmpeg compare | 2 firing attempts both EXACT, all cq≥12 attempts EXACT or named-refusal, cq 8/10 carry the CDEF ±1
55+EVIDENCE: fixtures/realworld/reelb.obu | decode_probe on the merged tree | now stops at "an inter 8x8 HORZ/VERT partition (8x4/4x8 inter leaves...)" — the sub-8x8 SPLIT refusal no longer blocks it
56+
57+## 4b. Suite
58+`intersub8-suite-1788328909.service`, log `$HOME/.cache/intersub8-suite-r2.log`:
59+`test result: ok. 382 passed; 0 failed; 33 ignored; 0 measured; 0 filtered out; finished in 1018.88s`.
60+This is the sibling sweep the interp-filter fix owes: it touches every compound 8x8 inter leaf.
61+
62+## 5. Not done this round
63+`deferred: 8x4/4x8 inter leaves (charter step 3) — the turn budget went to the root-cause
64+hunt and the gate schedule — unblocked by a fresh round on this branch; r14's general
65+read_var_tx_size is now merged here, so the remaining pieces are the LumaRect8x4Inter /
66+LumaRect4x8Inter TxbSets (EXT_TX_SET_ALL16, sqr_up TX_8X8) and the 2-sub-block chroma`.
67+`deferred: a --tile-columns=1 arm on this gate (COMMON neighbour-map rule) — same budget —
68+unblocked by the next round`.
69+The `an inter 8x8 HORZ/VERT partition ...` refusal therefore STAYS; no refusal string was
70+removed this round, and `refusal_inventory`/`gate_coverage` are unchanged.
lanes/intersub8-r3.handoff.mdadded+79 -0
@@ -0,0 +1,79 @@
1+# lane-intersub8 r3 — HANDOFF (4x8 gated GREEN, 8x4 implemented but refused)
2+
3+## What is wired (decode.rs `decode_inter_sub8_rect2`, ~line 19100)
4+One function serves both shapes (`vert: bool`); the call site
5+(`part8 == PARTITION_VERT` arm of the sub-16 SPLIT leaf loop, ~decode.rs:22630) currently
6+only reaches it with `vert = true`.
7+* mode info per sub-block in `decodemv.c` `read_inter_frame_mode_info` order: segment_id,
8+ skip, cdef/dq/dlf, intra_inter, single ref only (`is_comp_ref_allowed(BLOCK_8X4)` false ->
9+ no skip_mode, no comp_mode), no interintra / motion_mode / OBMC / warp (all need min dim 8),
10+ `read_mb_interp_filter` DOES run.
11+* tx: `block_signals_txsize(BLOCK_8X4)` true (blockd.h:1027) -> ONE `txfm_partition` symbol
12+ under TX_MODE_SELECT at `max_txsize_rect_lookup[BLOCK_8X4] = TX_8X4`, through r14's general
13+ `read_var_tx_size` with max `(bw,bh)` and `blk_max_px = 8`; `sub_tx_size_map[TX_8X4]=TX_4X4`
14+ so a split resolves to two TX_4X4 units (libaom's early return). Skip -> `set_txfm_ctxs`
15+ skip_inter arm.
16+* luma sets NEW in cdf_state.rs: `TxbSet::LumaRect8x4Inter` / `LumaRect8x4InterSet1` =
17+ `LumaRect4x8`'s tables (8x8 coefficient class, 32-position eob_pt) with `inter_tx_type_4` /
18+ `inter_tx_type_4_set1` (EXT_TX_SET_ALL16 at the TX_4X4 inter row). Split TX_4X4 units read
19+ `Luma4Inter{,Set1}`. Whole-leaf unit passes `luma_skip_ctx: None` (it IS the plane block,
20+ `get_txb_ctx_general` fixes 0); split units pass `luma_skip_ctx_rect`.
21+* chroma once, on the SECOND sub-block (`is_chroma_reference` under 4:2:0: bottom 8x4 /
22+ right 4x8), as one TX_4X4 per plane (`TxbSet::Chroma4`), inheriting the FIRST luma TU's
23+ tx_type; prediction is the sub8x8 one (`reconinter.c build_inter_predictors_sub8x8`,
24+ `row_start = -(block_size_high==4 && ss_y)`): two 4x2 (HORZ) / 2x4 (VERT) pieces, each from
25+ its own sub-block's ref/mv/filters.
26+* neighbour writes per mi: `grid_stamp_rect` (size=w_mi, size_h=h_mi over the true span),
27+ `record_mode_mi`, `record_inter_rect_mi`, `fill_skip_grid_rect`, `fill_lf_grid_rect`,
28+ `record_mi_luma_rect` per TU; partition tail `above_side_mi = bw`, `left_side_mi = bh`.
29+
30+## The 8x4 defect (refused by name, NOT fixed)
31+Stream: `~/.cache/intersub8-tmp/gen_t.sh 14 3 8 d1.obu --enable-rect-partitions=1`
32+(transposed-structure geq source: `128+58*sin((Y+N*3)/6)+18*sin(X/23)`, 192x128, 6 frames).
33+Decode-order frame 5 mismatches; frames 0..4 exact. 4 HORZ groups, all at mi rows 30/31,
34+cols 4 and 6.
35+Range ladder (`EC_TRACE_PART=1` ours, new gated print at each partition read, vs aomdec
36+`EC_TRACE=1` `EC_PART`; and `EC_TRACE_MODE` `EC_MODE`; and `EC_TRACE_COEFF` `tag=all_zero`):
37+* every element matches through the 16x16 partition read at mi(28,8) (ctx 2 == oracle's 6,
38+ entry rng 37489 both) and through `EC_MODE mi_row=30 mi_col=8 rng=46505` (both);
39+* that slot is PARTITION_HORZ -> two BLOCK_16X8 at (28,8) and (30,8);
40+* block (30,8)'s LEFT neighbour is our HORZ 8x4 group at (30,6);
41+* first divergence is INSIDE (30,8)'s mode info, AFTER its `EC_MODE` print (so skip and
42+ intra_inter are still right) and BEFORE its first coefficient TU: our TU entry rng 54923 vs
43+ oracle 61760 (`EC_COEFF plane=0 tx_size=8` = TX_16X8, all_zero=0 both). all_zero #468 of
44+ 470/473.
45+=> some per-ROW neighbour band our HORZ group leaves at rows 30/31 is wrong. Remaining
46+suspects, in read order after the print: `left_ref[30]`, the mv stack (MiGrid cells (30,7)/
47+(31,7)), `left_filter[30]`, `left_txfm[30]`. All four were transcribed against libaom and
48+looked right on inspection -- not bisected. NOTE ledger: this oracle's
49+`EC_AV1_PREFILT_DUMP` is already post-deblock, so pixel-stage bisection is confounded; use
50+the range ladder only.
51+
52+## Provable vs not
53+* PROVABLE (gated): two-BLOCK_4X8 (PARTITION_VERT) inter leaves. Sweep
54+ `~/.cache/intersub8-tmp/sweep2.sh` (28 arms, cq {8,12,14,16,20,26,32} x sp {3,6,9,12} x
55+ 8/10-bit, original source, rect on): every arm with `vert4x8 > 0` outside the known-bad
56+ cq8 band decoded pixel-exact; the two cq8 mismatches are r2's CDEF |d|=1 defect.
57+* NOT PROVABLE: 8x4 (HORZ). `sweep3.sh` (transposed source): 4 of 28 arms mismatch with
58+ `horz8x4 > 0` at cq 12/14/16/32, i.e. outside the CDEF band. Refused by name.
59+
60+## Gate
61+`cargo test -p ec-av1 --lib sub8x8_inter_split` -> ok, 1 passed / 0 failed (414 filtered),
62+28.94s. The test now runs 16 attempts per depth: 0..7 `--enable-rect-partitions=0` (SPLIT),
63+8..15 `=1` (VERT). Asserts `fired >= 2`, NEW `rect_fired >= 2`, `out_of_scope_mismatch == 0`,
64+every decode-order frame Y/U/V. `refusal_inventory` 3/3 ok, `gate_coverage` 9/9 ok.
65+
66+## Not done
67+* Full `cargo test -p ec-av1 --lib` suite: NOT RUN this round (turn cap). r2's unit
68+ `intersub8-suite-1788328909` was still running on a stale binary at round start and is now
69+ gone from the unit list; `$HOME/.cache/intersub8-suite-r2.log` has 218 ok / 0 FAILED and no
70+ `test result:` line. Start r3's suite per COMMON's SUITE RUNS recipe, log
71+ `$HOME/.cache/intersub8-suite-r3.log`.
72+* HG film probe: not run.
73+* `--tile-columns=1` gate arm: still owed (no NEW per-mi band was added, all reused).
74+
75+## Exact next step
76+1. Start the r3 suite. 2. Bisect the 8x4 defect on `d1.obu` frame 5 block (30,8) by dumping,
77+one at a time, the four left-band values our HORZ group writes at rows 30/31 and comparing
78+against an instrumented aomdec print of `xd->left_mbmi`/`left_txfm_context[0]` at that block.
79+3. Lift the HORZ refusal with a `sweep3.sh`-based arm once green.
lanes/intersub8-r4.handoff.mdadded+70 -0
@@ -0,0 +1,70 @@
1+# lane-intersub8 r4 — RED on the HORZ lift, GREEN on its root cause
2+
3+## What changed
4+* `crates/ec-av1/src/decode.rs:15981+` — new `bsize_index(w,h)` (libaom `BLOCK_SIZES_ALL`
5+ order), `masked_compound_used_wh`, `wedge_used_wh`.
6+* `crates/ec-av1/src/decode.rs` (`decode_inter_block`, comp-type block) — `comp_group_idx`'s
7+ gate and the `compound_type` / `wedge_idx` CDF ROWS now come from the block's true
8+ `(write_w, write_h)`, not the caller's square `side`. A 16x8 masked-compound block used to
9+ read `BLOCK_16X16`'s row (index 6) where libaom reads `BLOCK_16X8`'s (index 5).
10+ Class: table-indexed-by-raw-size / CDF-row-held-constant.
11+* Same site — `COMPOUND_WEDGE` on a non-square block is refused by name (the wedge codebook
12+ here is built per square side only); listed in `refusal_inventory.rs`.
13+* `crates/ec-av1/src/decode.rs` — `EC_TRACE_MODE` gains `EC_CGI` / `EC_CIDX` / `EC_IF`
14+ (comp_group_idx, compound_idx, interp filter: ctx + value + range). These are the rungs
15+ that localized the defect; the oracle has no per-symbol print between `EC_MODE_MV` and
16+ `EC_MODE_VAL`, so ours had to be split.
17+* Sub-8x8 HORZ call site — still refused, refusal text rewritten to the measured residue,
18+ and `EC_AV1_SUB8_HORZ=1` decodes it anyway for the next round's bisect.
19+
20+## Root cause (r3's open defect), proven
21+`~/.cache/intersub8-tmp/d1.obu` (192x128, 6 frames, 8-bit, transposed geq source, cq14 sp3,
22+`--enable-rect-partitions=1`), decode-order frame 5, `BLOCK_16X8` at mi(30,8):
23+| rung | ours before | ours after | aomdec |
24+|---|---|---|---|
25+| `EC_MODE` entry | 46505 | 46505 | 46505 |
26+| after mv (`EC_MODE_MV`) | 58288 | 58288 | 58288 |
27+| end of mode info (`EC_MODE_VAL`) | 54923 | **61760** | **61760** |
28+| next block `EC_MODE` mi(28,12) | 33919 | **60694** | **60694** |
29+The block reads `comp_group_idx=1` (ctx 0, correct — a ctx sweep 0..5 never reproduced the
30+oracle), then `compound_type` from the wrong CDF row. The 8x4 group to its left was innocent:
31+it only changed which value `comp_group_idx` took.
32+
33+EVIDENCE: ~/.cache/intersub8-tmp/{o5b.log,o6.log,r4.log} | EC_TRACE_MODE ladder on d1.obu before/after the fix vs instrumented aomdec | end-of-mode-info rng 54923 -> 61760 == oracle, and `cmp` of the probe output vs `ffmpeg -pix_fmt yuv420p` is byte-identical for all 6 frames
34+EVIDENCE: ~/.cache/intersub8-tmp/sweep3.sh output (28 arms, transposed source, cq {8,12,14,16,20,26,32} x sp {3,6,9,12} x 8/10-bit, rect on) | full re-run under `systemd-run --scope` | mismatching arms with horz8x4>0: 4 (r3) -> 3; 8-bit cq14 sp3 (horz=4) and cq20 sp3 (horz=4) went MISMATCH -> EXACT
35+
36+## Why the HORZ refusal did NOT lift (RED)
37+3 of 28 arms still mismatch with `horz8x4 > 0`: 8-bit cq32 sp9 (horz=3), 10-bit cq12 sp3
38+(horz=5), 10-bit cq16 sp3 (horz=2). On the 10-bit cq12 sp3 stream the ENTROPY IS EXACT — the
39+full `EC_MODE` range ladder is identical to aomdec's element for element (the only diff is two
40+extra `EC_MODE` prints for blocks aomdec's instrumentation does not print). The mismatch is
41+post-entropy: luma only, `|d| <= 2`, confined to x < 48 / y >= 112 (mi rows 28..31, mi cols
42+0..11), first appearing on decode-order frame 3 and propagating. Shape says filter (CDEF or
43+the deblock of the internal 8x4 edge), not reconstruction of the coefficients.
44+EVIDENCE: ~/.cache/intersub8-tmp/{a.txt,b.txt,m1.ours,m1.ref} | `diff` of the two EC_MODE ladders + per-frame python pixel diff | ladder diff = 2 extra lines, 0 range mismatches; frame 3: 125 differing luma samples, max |d| = 2, all in x<48 y>=112
45+
46+## Gates
47+* `sub8x8_inter_split` (the r3 gate, SPLIT + VERT arms) unchanged — HORZ arm NOT added, since
48+ the shape is still refused.
49+* No new gate for the masked-compound fix: measured, the only streams that reach a rect
50+ masked-compound block are HORZ ones, which the refusal blocks. `deferred: gate for the rect
51+ compound_type/wedge_idx row — no non-HORZ recipe found that produces a rect block with
52+ comp_group_idx==1 — unblocked by either the HORZ lift or a `--enable-masked-comp` sweep on
53+ rect-heavy square-only content.`
54+* Full suite: unit `intersub8-suite-r4-1788331918.service` -> `$HOME/.cache/intersub8-suite-r4.log`,
55+ STILL RUNNING at hand-off (74 ok, 0 FAILED, no `test result:` line yet). NOT a green claim.
56+ r3's unit (`intersub8-suite-1788331066`) was stopped as charter-ordered; its log had 73 ok /
57+ 0 FAILED and no `test result:` line at stop time.
58+
59+## Film probe
60+0.4 s copy-extract at 0 s of the 2160p 10-bit HDR AV1 film yields only 1817 bytes (one OBU
61+set, no full frame); the probe returns counters (`horz8x4=0`) and no refusal, so the census's
62+start_s=0 refusal ("an inter partition below 8x8") is NOT reproduced by that extract.
63+`deferred: HG below-8x8 census probe — the bounded extract is too small to reach the block —
64+unblocked by extracting from a keyframe offset (census4 reelb4.tsv start_s column).`
65+
66+## Residue
67+* fix-now(next round): the |d|<=2 luma band under HORZ. Reproduce with
68+ `EC_AV1_SUB8_HORZ=1` on `~/.cache/intersub8-tmp/t_10_12_3.obu` (regenerate:
69+ `./gen_t.sh 12 3 10 m1.obu --enable-rect-partitions=1`).
70+* accepted: `COMPOUND_WEDGE` on a rect block refused (rect wedge codebooks unimplemented).
lanes/intersub8-r4.report.mdadded+70 -0
@@ -0,0 +1,70 @@
1+# lane-intersub8 r4 — RED on the HORZ lift, GREEN on its root cause
2+
3+## What changed
4+* `crates/ec-av1/src/decode.rs:15981+` — new `bsize_index(w,h)` (libaom `BLOCK_SIZES_ALL`
5+ order), `masked_compound_used_wh`, `wedge_used_wh`.
6+* `crates/ec-av1/src/decode.rs` (`decode_inter_block`, comp-type block) — `comp_group_idx`'s
7+ gate and the `compound_type` / `wedge_idx` CDF ROWS now come from the block's true
8+ `(write_w, write_h)`, not the caller's square `side`. A 16x8 masked-compound block used to
9+ read `BLOCK_16X16`'s row (index 6) where libaom reads `BLOCK_16X8`'s (index 5).
10+ Class: table-indexed-by-raw-size / CDF-row-held-constant.
11+* Same site — `COMPOUND_WEDGE` on a non-square block is refused by name (the wedge codebook
12+ here is built per square side only); listed in `refusal_inventory.rs`.
13+* `crates/ec-av1/src/decode.rs` — `EC_TRACE_MODE` gains `EC_CGI` / `EC_CIDX` / `EC_IF`
14+ (comp_group_idx, compound_idx, interp filter: ctx + value + range). These are the rungs
15+ that localized the defect; the oracle has no per-symbol print between `EC_MODE_MV` and
16+ `EC_MODE_VAL`, so ours had to be split.
17+* Sub-8x8 HORZ call site — still refused, refusal text rewritten to the measured residue,
18+ and `EC_AV1_SUB8_HORZ=1` decodes it anyway for the next round's bisect.
19+
20+## Root cause (r3's open defect), proven
21+`~/.cache/intersub8-tmp/d1.obu` (192x128, 6 frames, 8-bit, transposed geq source, cq14 sp3,
22+`--enable-rect-partitions=1`), decode-order frame 5, `BLOCK_16X8` at mi(30,8):
23+| rung | ours before | ours after | aomdec |
24+|---|---|---|---|
25+| `EC_MODE` entry | 46505 | 46505 | 46505 |
26+| after mv (`EC_MODE_MV`) | 58288 | 58288 | 58288 |
27+| end of mode info (`EC_MODE_VAL`) | 54923 | **61760** | **61760** |
28+| next block `EC_MODE` mi(28,12) | 33919 | **60694** | **60694** |
29+The block reads `comp_group_idx=1` (ctx 0, correct — a ctx sweep 0..5 never reproduced the
30+oracle), then `compound_type` from the wrong CDF row. The 8x4 group to its left was innocent:
31+it only changed which value `comp_group_idx` took.
32+
33+EVIDENCE: ~/.cache/intersub8-tmp/{o5b.log,o6.log,r4.log} | EC_TRACE_MODE ladder on d1.obu before/after the fix vs instrumented aomdec | end-of-mode-info rng 54923 -> 61760 == oracle, and `cmp` of the probe output vs `ffmpeg -pix_fmt yuv420p` is byte-identical for all 6 frames
34+EVIDENCE: ~/.cache/intersub8-tmp/sweep3.sh output (28 arms, transposed source, cq {8,12,14,16,20,26,32} x sp {3,6,9,12} x 8/10-bit, rect on) | full re-run under `systemd-run --scope` | mismatching arms with horz8x4>0: 4 (r3) -> 3; 8-bit cq14 sp3 (horz=4) and cq20 sp3 (horz=4) went MISMATCH -> EXACT
35+
36+## Why the HORZ refusal did NOT lift (RED)
37+3 of 28 arms still mismatch with `horz8x4 > 0`: 8-bit cq32 sp9 (horz=3), 10-bit cq12 sp3
38+(horz=5), 10-bit cq16 sp3 (horz=2). On the 10-bit cq12 sp3 stream the ENTROPY IS EXACT — the
39+full `EC_MODE` range ladder is identical to aomdec's element for element (the only diff is two
40+extra `EC_MODE` prints for blocks aomdec's instrumentation does not print). The mismatch is
41+post-entropy: luma only, `|d| <= 2`, confined to x < 48 / y >= 112 (mi rows 28..31, mi cols
42+0..11), first appearing on decode-order frame 3 and propagating. Shape says filter (CDEF or
43+the deblock of the internal 8x4 edge), not reconstruction of the coefficients.
44+EVIDENCE: ~/.cache/intersub8-tmp/{a.txt,b.txt,m1.ours,m1.ref} | `diff` of the two EC_MODE ladders + per-frame python pixel diff | ladder diff = 2 extra lines, 0 range mismatches; frame 3: 125 differing luma samples, max |d| = 2, all in x<48 y>=112
45+
46+## Gates
47+* `sub8x8_inter_split` (the r3 gate, SPLIT + VERT arms) unchanged — HORZ arm NOT added, since
48+ the shape is still refused.
49+* No new gate for the masked-compound fix: measured, the only streams that reach a rect
50+ masked-compound block are HORZ ones, which the refusal blocks. `deferred: gate for the rect
51+ compound_type/wedge_idx row — no non-HORZ recipe found that produces a rect block with
52+ comp_group_idx==1 — unblocked by either the HORZ lift or a `--enable-masked-comp` sweep on
53+ rect-heavy square-only content.`
54+* Full suite: unit `intersub8-suite-r4-1788331918.service` -> `$HOME/.cache/intersub8-suite-r4.log`,
55+ STILL RUNNING at hand-off (74 ok, 0 FAILED, no `test result:` line yet). NOT a green claim.
56+ r3's unit (`intersub8-suite-1788331066`) was stopped as charter-ordered; its log had 73 ok /
57+ 0 FAILED and no `test result:` line at stop time.
58+
59+## Film probe
60+0.4 s copy-extract at 0 s of the 2160p 10-bit HDR AV1 film yields only 1817 bytes (one OBU
61+set, no full frame); the probe returns counters (`horz8x4=0`) and no refusal, so the census's
62+start_s=0 refusal ("an inter partition below 8x8") is NOT reproduced by that extract.
63+`deferred: HG below-8x8 census probe — the bounded extract is too small to reach the block —
64+unblocked by extracting from a keyframe offset (census4 reelb4.tsv start_s column).`
65+
66+## Residue
67+* fix-now(next round): the |d|<=2 luma band under HORZ. Reproduce with
68+ `EC_AV1_SUB8_HORZ=1` on `~/.cache/intersub8-tmp/t_10_12_3.obu` (regenerate:
69+ `./gen_t.sh 12 3 10 m1.obu --enable-rect-partitions=1`).
70+* accepted: `COMPOUND_WEDGE` on a rect block refused (rect wedge codebooks unimplemented).
lanes/sqdrift-r1.handoff.mdadded+40 -0
@@ -0,0 +1,40 @@
1+# lane-sqdrift r1 -> r2 handoff
2+
3+Branch `lane-sqdrift` @ 6edd5af (off main 85887c7). Worktree
4+`/home/user/Documents/Code/Rust/edith_codecs-sqdrift`, `CARGO_TARGET_DIR=$HOME/.cache/cargo-target-sqdrift`.
5+
6+## Do NOT redo any of this (all measured, see lanes/sqdrift-r1.report.md for the EVIDENCE lines)
7+* Stream: `/home/user/.cache/sqdrift/gen.sh` -> `s.obu`, sha256
8+ `c6af4fb4ebdc3d74dcfa0c945c0ef2d5e1e3a0902891d9e0a97a5608776b5d55`, hashed twice.
9+* Frames 0-3 byte-exact pre-filter AND post-filter (both dumps). No poisoned reference.
10+* Frame 4 damage = exactly the last SB, mi(16,32), PARTITION_NONE at 64x64, INTRA in an
11+ inter frame (aomdec prints neither EC_MODE nor EC_IMODE for it).
12+* We enter that block IN SYNC: our `pre_rng=33730` == aomdec `EC_PART ... rng=33730`.
13+* TX_64X64 dequant + inverse transform EXONERATED against real libaom (0/4096).
14+* The stream contains no rect/AB/1:4 partition at all; main's 1:4-strip refusal on it is
15+ a phantom of this desync.
16+* aomdec's prediction there is none of DC/SMOOTH/SMOOTH_V/SMOOTH_H/PAETH computed from
17+ the true neighbours, so its coefficients differ too -> a SYMBOL diverges, not a predictor.
18+
19+## The one open question
20+Which symbol between `partition_w64` and the end of that block. Ordered suspects:
21+1. `read_delta_q_params` -- delta_q IS present (base_q_idx 80/110/168) and this is the
22+ only block in the stream with `bsize == sb_size`, libaom's own special case
23+ (`decodemv.c`: `if (bsize != cm->seq_params->sb_size || !mbmi->skip_txfm)`), incl. the
24+ `delta_lf` sub-read.
25+2. `skip` / `is_inter` ctx at a 64x64 block.
26+3. `y_mode[size_group_lookup[BLOCK_64X64]=3]` CDF content (adaptation drift; frames 0-3
27+ never crossed a decision boundary).
28+4. `tx_depth`: `--enable-tx-size-search=0`, so TX_64X64 must code no depth symbol.
29+5. The 64x64 luma coefficient read (eob_pt alphabet at TX_64X64, `all_zero` ctx).
30+
31+## Instruments already in the tree
32+* `EC_AV1_TRACE=1` -> `TRACE partition_w64 ... pre_rng=<range before the symbol>`.
33+* `EC_IIS=1` -> `TRACE iis px= py= side= w= h= sg= mode= skip=` at the square
34+ intra-in-inter `y_mode` read (decode.rs, right after `cdfs.y_mode[size_group_wh(..)]`).
35+* `/home/user/.cache/sqdrift/h.c` -- libaom inverse-transform harness. Build:
36+ `gcc -O1 -o h h.c -I$SRC -I$BUILD -I$SRC/apps $BUILD/libaom.a -lm -lpthread`.
37+ MUST call `av1_rtcd(); aom_dsp_rtcd();` first or `av1_idct64` is a NULL fn ptr (segfault).
38+* The oracle has NO range print inside `read_intra_block_mode_info` /
39+ `read_delta_q_params`. Add one via `scripts/instrument-aom-oracle.sh` into a PRIVATE
40+ build dir; never rebuild the shared `~/.cache/aom-oracle/build/aomdec` in place.
lanes/sqdrift-r1.report.mdadded+100 -0
@@ -0,0 +1,100 @@
1+# lane-sqdrift r1 -- the square-only silent pixel drift, localised to ONE block
2+
3+## Verdict: RED (defect localised and bounded, not yet fixed). No refusal lifted.
4+
5+## The stream (pinned, reproducible)
6+
7+`/home/user/.cache/sqdrift/gen.sh` (kept; recipe = lane-intra14's gate recipe with
8+`--enable-rect-partitions=0`): 192x128 8-bit `mandelbrot start_scale=4.76 end_scale=0.004
9+end_pts=8 rate=25`, hue=s=0, `-t 0.32`, real `~/.cache/aom-oracle/build/aomenc`
10+`--cpu-used=1 --cq-level=55 --min-partition-size=16 --max-partition-size=64
11+--enable-tx-size-search=0 --kf-min/max-dist=1000 --threads=1 --row-mt=0`, order-hint /
12+warped / obmc / masked / interintra / dist-wtd / diff-wtd / onesided / ab / 1to4 /
13+filter-intra / smooth-intra / paeth-intra / directional-intra / angle-delta / cdef /
14+restoration / palette / intrabc / cfl / ref-frame-mvs ALL `=0`.
15+sha256 `c6af4fb4ebdc3d74dcfa0c945c0ef2d5e1e3a0902891d9e0a97a5608776b5d55`, hashed twice
16+from two independent encodes -- reproducible.
17+
18+## What is actually wrong (measured, not reasoned)
19+
20+1. `aomdec EC_TRACE=1` partition histogram over the whole stream: only
21+ `value=0 (NONE)` and `value=3 (SPLIT)` at bsize 12/9/6. **No rect, no AB, no 1:4
22+ partition exists in this stream at all** -- so main's refusal
23+ "an intra-coded 1:4 (or other non-2:1) rect strip on the inter block path", which this
24+ stream stops at on `main@85887c7`, is a PHANTOM read out of an already-diverged
25+ bitstream (class `refusal-from-own-desync`).
26+2. Pre-loop-filter dumps, our `EC_AV1_PREFILT_DUMP` vs aomdec's, per decode-order frame:
27+ f0..f3 **byte-exact (luma AND chroma)**; f4 luma 3540 samples wrong, max |d| = 6,
28+ **chroma exact**. Post-filter reference dumps (`EC_AV1_FINAL_DUMP`) f0..f3 exact too,
29+ so no reference frame is poisoned going into f4.
30+3. The f4 damage is EXACTLY one superblock: bbox x 128..191, y 64..127 -- the last SB,
31+ mi (16,32), which frame 4 codes as `PARTITION_NONE` at 64x64. It is the ONLY
32+ 64x64 PARTITION_NONE block in any inter frame of this stream.
33+4. Range ladder at that block's entry: our pre-read msac range for its `partition_w64`
34+ symbol is **33730**, identical to aomdec's `EC_PART mi_row=16 mi_col=32 bsize=12
35+ ctx=15 tell=25598 rng=33730`, and the ctx matches too (aomdec prints `bsl*4+ctx`
36+ = 12+3, ours `ctx=3`). **We enter that block bit-exactly in sync.**
37+5. The divergence is INSIDE that block. aomdec prints neither `EC_MODE` (=
38+ `read_inter_block_mode_info`) nor `EC_IMODE`, i.e. libaom takes
39+ `read_intra_block_mode_info` -- an INTRA block inside an inter frame. Our decoder
40+ takes the same arm and reads `y_mode[size_group=3] = 0 (DC_PRED)`
41+ (new `EC_IIS=1` rung: `TRACE iis px=128 py=64 side=64 w=64 h=64 sg=3 mode=0 skip=false`).
42+ Our reconstruction there is a FLAT 93, which is exactly
43+ `(sum(above 64) + sum(left 64) + 64) >> 7` -- textbook DC_PRED. aomdec's
44+ reconstruction is not flat.
45+6. The luma residual is NOT the defect. The block's 5 non-zero levels were pushed
46+ through libaom itself (`av1_inv_txfm2d_add_64x64_c`, real `libaom.a`, dequant
47+ replicated from `decodetxb.c:361-374` with `av1_dc/ac_quant_QTX(80,0,8)` = 74/87 and
48+ `av1_get_tx_scale` shift 2): **0 mismatches** against our own `residual` for those
49+ levels (and 2171 with the axes swapped, so the layout is right too). Our TX_64X64
50+ dequant + inverse transform is exact.
51+7. Everything after that block drifts: frame 5's SB0 `partition_w64` still reads 3, SB1
52+ reads 8 where aomdec reads 3 -- a CDF-state divergence carried across the frame
53+ boundary (frame 5 restarts its own msac, so only the adapted CDFs can carry the
54+ damage). f5..f7 then drift to ~24k samples / max |d| ~220 as they predict from f4.
55+
56+So: **the first divergent symbol is in the mode-info or coefficient read of a 64x64
57+PARTITION_NONE intra-in-inter block, after `partition_w64` and at/after `y_mode`.**
58+The candidate set is now tiny: `skip`, `read_delta_q_params` (this is the ONE block in
59+the stream where `bsize == sb_size`, the exact case libaom's
60+`read_delta_q_params` special-cases), `is_inter`, `y_mode[3]`, `uv_mode_cfl[0]`,
61+`tx_depth` (`--enable-tx-size-search=0`, so a TX_64X64 must code no depth symbol), or the
62+64x64 coefficient read itself. `base_q_idx` in our trace takes three values (80/110/168)
63+across the stream, i.e. **delta_q IS present in this stream** -- that makes the
64+`bsize == sb_size` delta-q exception a first-class suspect.
65+
66+## What changed (all env-gated instrumentation, no decode behaviour)
67+
68+* `crates/ec-av1/src/decode.rs` (`decode_inter_frame_tile_with_cdfs`'s `partition_w64`
69+ read) -- the `EC_AV1_TRACE` line now carries `pre_rng=`, the msac range BEFORE the
70+ symbol, which is what makes it directly comparable to aomdec's `EC_PART ... rng=`
71+ (class `compare-range-not-tell`). This is the measurement that proved fact 4.
72+* `crates/ec-av1/src/decode.rs` (square intra-in-inter `y_mode` read) -- new `EC_IIS=1`
73+ rung printing `px/py/side/w/h/size_group/mode/skip` for every intra block in an inter
74+ frame. That is fact 5.
75+
76+## Gate
77+
78+None added -- there is no fix to gate yet. Adding a gate now would pin the defect, not a
79+capability; the reproducing recipe is `scripts`-free and lives in this report plus
80+`/home/user/.cache/sqdrift/gen.sh`.
81+
82+## EVIDENCE
83+
84+EVIDENCE: /home/user/.cache/sqdrift/{op,aom}.f0..f4 | our EC_AV1_PREFILT_DUMP vs aomdec EC_AV1_PREFILT_DUMP on the pinned stream, every decode-order frame compared Y/U/V | f0-f3 0 bad samples; f4 luma 3540 bad, max |d| 6, chroma 0 bad, bbox exactly x128-191 y64-127
85+EVIDENCE: /home/user/.cache/sqdrift/{of,af}.f0..f4 | EC_AV1_FINAL_DUMP (post-filter reference buffers) both decoders | f0-f3 0 bad; f4 first bad (145,58), 3848 bad, max 6 -- deblocking only spreads the f4 damage, no reference is poisoned earlier
86+EVIDENCE: /home/user/.cache/sqdrift/aom.trace | aomdec EC_TRACE=1 partition histogram, whole stream | bsize12 {0:2, 3:46}, bsize9 {0:58, 3:126}, bsize6 {0:504} -- zero rect/AB/1:4 partitions, so main's 1:4-strip refusal on this stream is a phantom
87+EVIDENCE: our EC_AV1_TRACE pre_rng vs /home/user/.cache/sqdrift/aom.both | range ladder at frame 4 SB (16,32) | ours pre_rng=33730 ctx=3, aomdec rng=33730 ctx=15(=12+3) -- in sync at block entry, so the defect is inside the block
88+EVIDENCE: /home/user/.cache/sqdrift/{h.c,aomres1.txt,ourres.txt} | the block's 5 non-zero levels through real libaom av1_inv_txfm2d_add_64x64_c vs our residual | 0/4096 mismatches (swapped-axis control: 2171) -- TX_64X64 dequant+inverse is exact
89+EVIDENCE: EC_IIS=1 rung on the pinned stream | our intra-in-inter mode read at the failing block | `TRACE iis px=128 py=64 side=64 w=64 h=64 sg=3 mode=0 skip=false`, reconstruction flat 93 = DC_PRED of the true neighbours; aomdec's is not flat (SMOOTH/SMOOTH_V/SMOOTH_H/PAETH all rejected numerically too, so aomdec's coefficients differ as well -- the divergence is a SYMBOL, not a predictor)
90+
91+## Residue
92+
93+* fix-now (next round, r2): bisect the ~6 remaining symbols of that one block. The
94+ cheapest decisive instrument is a `pre_rng` print on every symbol of
95+ `read_inter_frame_mode_info`'s square intra arm plus an aomdec-side `rng` print at the
96+ same points in `read_intra_block_mode_info` / `read_delta_q_params` (the oracle has no
97+ print there today -- add one to `scripts/instrument-aom-oracle.sh`, do NOT rebuild the
98+ shared aomdec in place). Start with `read_delta_q_params`' `bsize == sb_size` exception.
99+* deferred: 10-bit arm -- unblocked by the fix; there is nothing to gate yet.
100+* accepted: the two `EC_*` trace rungs ship as permanent debug instrumentation.
lanes/sqdrift-r2.report.mdadded+93 -0
@@ -0,0 +1,93 @@
1+# lane-sqdrift r2 -- the square-only silent drift is the no-CFL `uv_mode` alphabet
2+
3+## Verdict: GREEN. Root cause confirmed by ablation, gated with a new real-aomenc gate.
4+
5+Tip `2b750e6` on `lane-sqdrift` (base main `85887c7`).
6+
7+## 1. What the divergence was
8+
9+r1 had localised it to one 64x64 `PARTITION_NONE` INTRA block inside an INTER frame
10+(frame 4, mi(16,32) = the last superblock), entered bit-exactly in sync (`pre_rng=33730`
11+== aomdec's `rng=33730`), with TX_64X64 dequant+inverse already exonerated against real
12+libaom. The open question was "which symbol inside that block".
13+
14+Answer: `uv_mode`. libaom's `is_cfl_allowed` (`blockd.h`: `block_size_wide[bsize] <= 32 &&
15+block_size_high[bsize] <= 32`, spec 5.11.5) excludes a 64-axis block from CFL, so its
16+`uv_mode` comes off the **13-symbol `uv_mode_no_cfl`** alphabet. We read the 14-symbol
17+`uv_mode_cfl` one: the same `DC_PRED` VALUE, a different interval narrowing, and the tile
18+desynced from that block on (class `wrong-alphabet-same-value`).
19+
20+The fix was found independently by lane-sbrect10 (`9f1f108`) and is merged here, not
21+rewritten: commit `cbcbf13` merges `lane-sbrect10` into this branch. `decode.rs` gets the
22+`cfl_allowed = write_w.max(write_h) <= 32` test at the intra-in-inter square arm plus the
23+same `is_cfl_allowed` bound enforced at the two funnels `read_intra_mode` /
24+`read_intra_mode_rect`, and the `nocfl_uv_mode_hits()` witness counter. No decoder line in
25+this round is mine; my round's contributions are the confirmation, the ablation, and the
26+square-only gate.
27+
28+## 2. The decisive before/after, same stream, same tree
29+
30+Pinned stream `/home/user/.cache/sqdrift/keep-s.obu`, sha256
31+`c6af4fb4ebdc3d74dcfa0c945c0ef2d5e1e3a0902891d9e0a97a5608776b5d55` (r1's `gen.sh`,
32+hashed twice from two independent encodes), compared PRE-LOOP-FILTER, per decode-order
33+frame, byte for byte against instrumented aomdec's own `EC_AV1_PREFILT_DUMP`:
34+
35+| | f0 | f1 | f2 | f3 | f4 | f5 | f6 | f7 | outcome |
36+|---|---|---|---|---|---|---|---|---|---|
37+| before (`cfl_allowed = true` ablation on THIS tree) | 0 | 0 | 0 | 0 | **3540** | - | - | - | REFUSED after f4: "an intra-coded 1:4 (or other non-2:1) rect strip on the inter block path" |
38+| after (merged fix) | 0 | 0 | 0 | 0 | **0** | 0 | 0 | 0 | 8 frames decoded, all byte-exact |
39+
40+The "before" row is not r1's memory: it is the one-line ablation
41+`decode.rs:18548 let cfl_allowed = true;` rebuilt and re-run in this round, then reverted
42+(`git diff --stat` after revert shows stream.rs only). It also re-confirms r1's finding
43+that the refusal main stops at on this stream is a PHANTOM of the desync -- aomdec's
44+partition histogram over the stream contains no rect partition at all (class
45+`refusal-from-own-desync`).
46+
47+## 3. The gate (new)
48+
49+`crates/ec-av1/src/stream.rs:6900`
50+`a_real_aomenc_square_only_inter_sequence_with_a_64x64_intra_superblock_decodes_pixel_exact`
51+
52+The SQUARE-ONLY twin of lane-sbrect10's gate, pinning r1's recipe: real aomenc,
53+192x128 mandelbrot (`start_scale` 4.76/3.20), cq 55/45, `--cpu-used=1 --sb-size=64
54+--enable-rect-partitions=0 --enable-ab-partitions=0 --enable-1to4-partitions=0
55+--min-partition-size=16 --max-partition-size=64 --enable-tx-size-search=0`, 8 decode-order
56+frames, **both bit depths**. Rect OFF is what makes the 64x64 `PARTITION_NONE` a WHOLE
57+superblock (`bsize == sb_size`), a shape the sibling gate's rect-on recipe does not pin;
58+8 frames of drift means a desync that survives one frame still fails here.
59+
60+Asserts: every decode-order frame's Y/U/V compared against ffmpeg (a mismatch of ANY shape
61+is a failure, never a SKIP -- so out-of-scope mismatches are structurally 0); a decode
62+error must be a named `unsupported` refusal; and `nocfl_uv_mode_hits` delta per attempt
63+must be > 0 on at least one pixel-exact attempt per depth.
64+
65+Result (`--exact --nocapture --test-threads=1`), 10.4 s:
66+
67+* 8-bit: 0 named refusals, **4/4 pixel-exact attempts**, 6 no-CFL `uv_mode` reads, 0 carried none
68+* 10-bit: 0 named refusals, **4/4 pixel-exact attempts**, 6 no-CFL `uv_mode` reads, 0 carried none
69+
70+No refusal string is removed in this round: the refusal this stream used to hit was never
71+about this shape.
72+
73+## 4. Suite
74+
75+`cargo test -p ec-av1 --lib` under `systemd-run --user --unit=sqdrift-suite-r2-...`,
76+log `$HOME/.cache/sqdrift-suite-r2.log`: **379 passed, 0 failed, 33 ignored** in 958.68 s (r1 baseline on the unfixed tree never completed).
77+
78+## EVIDENCE
79+
80+EVIDENCE: /home/user/.cache/sqdrift/np.f0..f7 vs aom.f0..f7 | decode_probe with EC_AV1_PREFILT_DUMP on the pinned stream (sha256 c6af4fb4...) after merging lane-sbrect10, cmp -l per decode-order frame Y+U+V | 0 differing bytes on all 8 frames (r1: f4 3540 wrong luma samples, then refusal)
81+EVIDENCE: /home/user/.cache/sqdrift/ab.f0..f4 | same binary with decode.rs:18548 ablated to `cfl_allowed = true`, rebuilt, re-run, then reverted | f0-f3 0, f4 3540 differing bytes, decode then REFUSES "an intra-coded 1:4 ... rect strip on the inter block path" -- the phantom refusal is produced by this desync alone
82+EVIDENCE: cargo test -p ec-av1 --lib -- --exact --nocapture a_real_aomenc_square_only_inter_sequence_with_a_64x64_intra_superblock_decodes_pixel_exact | 4 attempts x 2 bit depths of real aomenc, rect partitions off, every decode-order frame vs ffmpeg | ok in 10.38s; 8-bit 4 exact/6 hits, 10-bit 4 exact/6 hits, 0 refusals, 0 attempts carried none
83+
84+## Residue
85+
86+* deferred(lane-intra14 re-runs its own gate): `lanes/intra14-r2.report.md` records its
87+ blocker as "decode-order frame 3/4 luma ~3.7-4.5k samples at max |d| 6..17, first diff
88+ around x=128..141, y=58..59, then frames 5-7 drift to ~24k at max |d| ~220" on the same
89+ 192x128 mandelbrot source -- the identical signature to this lane's, at the identical
90+ coordinates. Very likely the same defect, so its two `#[ignore]`d 1:4-strip arms should
91+ be re-measured on a tree carrying this fix. Not measured here: its recipe (1:4 on) is
92+ another lane's surface.
93+* accepted: r1's `EC_AV1_TRACE pre_rng` and `EC_IIS` rungs stay as debug instrumentation.
lanes/uv8-r1.handoff.mdadded+64 -0
@@ -0,0 +1,64 @@
1+# lane-uv8 r1 — HANDOFF (RED: implemented, NOT gated)
2+
3+## What is implemented (`crates/ec-av1/src/decode.rs`, `decode_inter_block8`'s intra arm)
4+Mirrors libaom `read_intra_block_mode_info` (`av1/decoder/decodemv.c:1178-1220`, read from
5+`~/.cache/aom-oracle/src`) for an INTRA 8x8 leaf inside an INTER frame:
6+
7+- `uv_mode` over the CFL-allowed alphabet (`cdfs.uv_mode_cfl[mode]`; BLOCK_8X8 is inside
8+ `is_cfl_allowed`'s 32x32 bound), then `read_cfl_alphas` when `UV_CFL_PRED`, then
9+ `angle_delta_uv` off `angle_delta[uv_mode - V_PRED]` (`get_uv_mode` is the identity over
10+ `V_PRED..=D67_PRED`) — the exact order libaom reads them in.
11+- `uv_predict_mode = get_uv_mode(uv_mode)`; chroma prediction, chroma `default_tx_type`
12+ (`read_plane`'s `predict_mode` arg → `default_intra_tx_type`, DCT for CfL) and the CfL AC
13+ (`cfl_ac_q3(y, px, py, 8)` over the leaf's 4x4 chroma) all take it.
14+- `smooth_neighbor_uv` from `Neighbours::smooth_uv_neighbour(leaf_mi.0, leaf_mi.1, r, c)`
15+ (chroma edge filter reads the CHROMA neighbour's uv_mode — reconintra.c:974), and the leaf's
16+ LUMA `smooth_neighbor` from `modes_above_left_mi` (it passed a hardcoded `false` before).
17+- `palette_uv_mode` is now read only when `uv_mode == DC_PRED` (`read_palette_mode_info`);
18+ it was read unconditionally, harmless only because every non-DC uv_mode was refused.
19+- Tail: the leaf now stamps its mode bands (`above_uv_mode[c]`/`left_uv_mode[r]`,
20+ `record_mode_mi`, `record_uv_mode_mi`, 2x2 mi) — it stamped none at all, so a neighbour read
21+ a stale coarse SUB slot. An inter leaf stamps `DC_PRED`, what libaom stores.
22+- New per-leaf counters `decode::intra_in_inter8_uv_hits() -> (dir, smooth/paeth, cfl)`.
23+
24+## Refusal state
25+`"a non-DC chroma mode on an 8x8 inter-frame leaf (this encoder never writes one)"` is REMOVED
26+from decode.rs and from `refusal_inventory.rs::CAPABILITY_CLAIMS`. **This lift is NOT gated** —
27+see below. If the next round cannot gate it, restoring both lines is the honest move.
28+
29+## Gate (written, never observed a firing attempt)
30+`stream.rs::uv_mode_in_inter8_gate(bit_depth, tile_columns)` + 3 tests (8-bit, 10-bit, 2-tile):
31+192x128, 8 frames, mandelbrot zoom + hard cut at frame 4 + seeded `noise`, chroma NOT
32+desaturated, 30 attempts, cq 12..40, `--min-partition-size=8 --max-partition-size=32
33+--sb-size=64 --enable-cfl-intra=1 --enable-smooth-intra=1 --enable-paeth-intra=1
34+--enable-directional-intra=1`, per-attempt counter deltas, every decode-order frame compared,
35+no SKIP on decode error. The y4m goes through a temp FILE: feeding aomenc on stdin while its
36+~100 KB OBU fills the stdout pipe DEADLOCKS (measured, 3 min into attempt 0).
37+
38+RESULT: 8-bit arm ran, 30/30 attempts REFUSED, 0 compared → the gate fails as designed.
39+
40+## The blocker (pre-existing, NOT this round's change)
41+Every `--min-partition-size=8` inter stream refuses. `--min-partition-size=16` on the same
42+recipe decodes 8/8 frames. The refusals name tools the encoder was explicitly told to disable:
43+`--enable-rect-partitions=0 --enable-ab-partitions=0 --enable-1to4-partitions=0` yet we refuse
44+"an inter 16x16-level AB or 1:4 partition" / "a non-skip rectangular strip"; and
45+`--enable-angle-delta=0` yet we refuse "a nonzero angle delta on an 8x8 intra leaf". Class
46+[[refusal-from-own-desync]]: those are our own desync, not encoder output.
47+Ablation: the same refusals appear with `--enable-cfl-intra=0 --enable-smooth-intra=0
48+--enable-paeth-intra=0 --enable-directional-intra=0`, where this round's code is inert →
49+the desync is INDEPENDENT of this round.
50+The KEY frame of the same recipe (`--limit=1`, min8) decodes PIXEL-EXACT vs aomdec
51+(md5 860b50e830271fa57fb60e4a76eb83ec both) — so the 8x8 leaf's key-frame path is fine and the
52+divergence is in an INTER frame.
53+
54+## Exact next step
55+Bisect the first inter-frame divergence with the oracle mode ladder. Note the trace semantics
56+(cost this round an hour): oracle `EC_IMODE` = KEY-frame blocks only, oracle `EC_MODE` =
57+INTER blocks only (an intra block inside an inter frame prints NEITHER), while ours prints
58+`EC_MODE` for EVERY block of an inter frame. So the oracle's `EC_MODE` (mi_row, mi_col)
59+sequence must be an ordered SUBSEQUENCE of ours; the first ref entry that ours never produces
60+is the first structurally divergent block. On `~/.cache/uv8-tmp/o.obu` (recipe above, cq 26,
61+cpu-used 0) that subsequence match stops after 79 of the ref's frame-1 entries, with ref next
62+at mi (12,8) — start there with a range ladder (compare RANGE, never tell()).
63+Scripts: `~/.cache/uv8-tmp/{in.y4m,sweep.sh,sweep2.sh,sweep3.sh}`; probe
64+`$HOME/.cache/cargo-target-uv8/debug/examples/decode_probe <obu> [out.yuv]`.
lanes/uv8-r2.handoff.mdadded+65 -0
@@ -0,0 +1,65 @@
1+# lane-uv8 r2 — HANDOFF (merge done, root cause NARROWED to one block, gate still RED)
2+
3+## Merged into lane-uv8 (tip f5c8dbf)
4+- `a9b4468` main aa83400 (clean).
5+- `5dc9707` lane-interp3 `10b801a` (clean).
6+- `c3ead8c`/prev `af47324` lane-intersub8 — CONFLICTS resolved:
7+ * `decode_inter_block8` compound-leaf interp read: kept **interp3's** copy (it adds the
8+ `gm_nontrans_c || skip_mode` suppression and the COMPOUND8_FILTER_HITS counter); dropped
9+ intersub8's duplicate read (two reads = one extra symbol).
10+ * `resolve_interp_filter` tail: kept BOTH (interp3's DUAL_FILTER_DIFF_HITS + intersub8's EC_IF trace).
11+ * `refusal_inventory.rs`: union of both lists, then deleted
12+ "an inter partition below 8x8 (...lane-sub8 scoped to intra)" — intersub8 landed that capability
13+ (the `the_decode_path_refuses_exactly_the_listed_cases` test named it).
14+- `6561ec4` lane-cdef `8c6065e` (clean).
15+- `c3ead8c` lane-sqdrift `7d498c0` — stream.rs conflict was two whole appended test fns interleaved;
16+ resolved by `git checkout --ours stream.rs` + `patch -p1` of `git diff 85887c7 7d498c0 -- stream.rs`
17+ (both new tests present: `..._reads_the_no_cfl_uv_alphabet`, `..._square_only_inter_sequence...`).
18+- `crates/ec-av1/src/cdf.rs` byte-identical to main (`git diff --stat main -- cdf.rs` empty).
19+- `f5c8dbf` adds EC_TRACE_MODE_STEP ladder prints in the 8x8 intra-in-inter arm
20+ (`EC_ISTEP ... name=use_filter_intra` in the oracle's exact format, plus `EC_ISTEP8 name=modes`).
21+
22+## Gate result on the merged tree (RED, same shape as r1)
23+`uv8-gate-r2.log` (unit uv8-gate-r2-1788332583, before the trace commit): all three arms
24+30/30 named refusals, counted-exact=0, uncounted-exact=0. Re-armed after the merge as unit
25+**uv8-gate-r2b** → `$HOME/.cache/uv8-gate-r2.log`, then the full suite in the SAME unit →
26+`$HOME/.cache/uv8-suite-r2.log`.
27+Refusal histogram over the 90 attempts: 31x inter 16x16-level 1:4, 21x nonzero angle delta on an
28+8x8 intra leaf, 13x inter 8x8 HORZ, 10x non-skip rect strip, 5x intra 1:4 rect strip, 3x inter SB AB,
29+3x 128x128 SB HORZ/VERT/AB, 2x intra 4x4 in sub-8x8 split, 1x 32x64 split TU, 1x intra 8x4/4x8.
30+All still class [[refusal-from-own-desync]] — proven below.
31+
32+## ROOT CAUSE LOCALISED (this is the round's real result)
33+Stream `~/.cache/uv8-tmp/a0.obu` (regenerate: `~/.cache/uv8-tmp/g2.sh 42 12 a0.obu`, exact gate
34+recipe, 8-bit, seed 42, cq 12; note it is a **128x128 superblock** stream — the gate recipe has no
35+`--sb-size=64`).
36+1. `EC_TRACE=1 aomdec` partition histogram (`ref_part.txt`): the reference codes **only** NONE and
37+ SPLIT (bsize 15/12/9 value=3, bsize 6 value 0|3, bsize 3 value 0). There is no rect/AB/1:4
38+ partition anywhere in the stream → every refusal above is our own desync.
39+2. Partition range ladder (ours `EC_TRACE_PART=1` vs ref, ignoring the ctx print convention:
40+ ref prints `4*bsl + ctx`): decode-order frame 1 matches 138/138; frame 2 first range divergence
41+ at element 119 — ref `(0,36,bsize=6,rng=48648)` vs ours `rng=38664`. The previous element,
42+ the 8x8 partition at **mi (2,34)**, still matches (rng 44040).
43+3. `EC_MODE` subsequence: ref's entries are consumed in order up to `(2,32)`; ours' next block
44+ `(0,36)` starts at rng 57984 vs ref 32884. Ref prints no EC_MODE for `(2,34)` → that block is an
45+ **INTRA 8x8 leaf inside inter frame 2**.
46+4. `EC_TRACE_MODE_STEP` ladder at that block: ours reads `use_filter_intra val=1 rng=64248` and
47+ `filter_intra_mode val=0 rng=43964` — **bit-identical to the oracle**. Our decoded modes there are
48+ `y=DC_PRED, uv=13 (UV_CFL_PRED)` (`EC_ISTEP8` line).
49+ => the whole mode-info half of this leaf, including the new non-DC/CfL uv path, is IN SYNC.
50+ The desync is in what follows: `read_block_tx_size` or the leaf's COEFFICIENTS.
51+
52+## EXACT NEXT STEP
53+Both coefficient traces are already dumped: `~/.cache/uv8-tmp/ref_co.txt` (761992 lines) and
54+`ours_co.txt` (260655). Formats: ref `EC_COEFF plane=.. row=.. col=.. tx_size=.. rng=..` +
55+`EC_COEFF_STEP tag=all_zero|tx_type|base|br ...`; ours prints the STEP lines only (no EC_COEFF
56+header with plane/row/col). Align the two `EC_COEFF_STEP` streams and find the first `rng`
57+divergence — it must be inside the block at mi (2,34) of decode-order frame 2, i.e. the FIRST
58+filter-intra + CfL 8x8 intra leaf of an inter frame. Prime suspects, in order:
59+ (a) the CfL AC / chroma `TxbSet::Chroma4` txb ctx on a leaf whose luma is filter-intra;
60+ (b) `read_block_tx_size` for an intra block in an inter frame at 8x8 (`--enable-tx-size-search=0`
61+ here, so check whether a symbol should be read at all);
62+ (c) the luma `intra_ext_tx` row: `read_plane` gets `filter_intra` and applies `fi_tx_row`, but the
63+ CHROMA calls pass `mode` (raw luma mode) as the tx-row arg with `filter_intra=None` — verify
64+ against libaom `av1_read_tx_type` (chroma tx type is inferred, so this should be inert; prove it).
65+Do NOT re-do steps 1-4; they are pinned above with their artifacts.
lanes/uv8-r3.report.mdadded+42 -0
@@ -0,0 +1,42 @@
1+# lane-uv8 r3 — GREEN (root cause: wrong tx_type ALPHABET on the 8x8 intra-in-inter leaf)
2+
3+## Root cause
4+`decode_inter_block8`'s INTRA arm passed a hardcoded `TxbSet::Luma8` to `read_plane` for the
5+leaf's 8x8 luma transform. `TxbSet::Luma8` is the `reduced_tx_set == 1` set
6+(`EXT_TX_SET_DTT4_IDTX`, FIVE types); with `reduced_tx_set == 0` libaom's
7+`av1_get_ext_tx_set_type` (`av1/common/blockd.h`) returns, for `is_inter == 0` and
8+`tx_size_sqr == TX_8X8`, `EXT_TX_SET_DTT4_IDTX_1DDCT` — SEVEN types
9+(`TxbSet::Luma8Set1`). Same symbol, different alphabet: the CDF narrowing differed, so the
10+msac range diverged at the leaf's first `tx_type` and every following block desynced. The
11+desync manufactured the 30/30 "named refusals" the r1/r2 gate logs showed
12+(class [[refusal-from-own-desync]] + [[wrong-alphabet-same-value]]).
13+
14+Charter suspect (1) (the `fimode_to_intradir` row) was already correct: `fi_tx_row` is applied
15+at every luma `txb` call site including this one, and `fimode_to_intradir[0] == DC_PRED`
16+equals this block's `y_mode` anyway, so that row was inert here.
17+
18+## Change
19+- `crates/ec-av1/src/decode.rs:22057` — `TxbSet::Luma8` -> `txbset_for(8, reduced_tx_set)`
20+ (`reduced_tx_set` was already a parameter of `decode_inter_block8`).
21+- `crates/ec-av1/src/stream.rs:5897` — gate `counted` predicate tightened from
22+ "sum nonzero" to "all three uv classes fired on the same pixel-compared attempt".
23+
24+## Sweep (class: hardcoded reduced-set TxbSet)
25+`grep -n 'TxbSet::Luma\(4\|8\|16\|32\),' decode.rs` — the only reduced-sensitive hardcodes are
26+sizes 8 and 4; after this fix there are ZERO outside `txbset_for`/`txbset_for_inter`. Every
27+`Luma16`/`Luma32` literal is alphabet-invariant to `reduced_tx_set` (`txbset_for` maps 16 and
28+32 identically for both values). The rect-strip and >=16 square intra-in-inter arms already go
29+through `txbset_for`/`txbset_for_inter` (decode.rs:6053, 7167, 7777, 7857, 9594, 11075).
30+
31+## EVIDENCE
32+EVIDENCE: ~/.cache/uv8-tmp/ref.tu + ours3.tu | aomdec EC_TRACE_COEFF vs our EC_TRACE_COEFF on ~/.cache/uv8-tmp/a0.obu, per-TU (all_zero,eob) msac range ladder | before: first divergence at TU-line 3392 (ref eob rng=32776, ours 34568; the preceding tx_type read was ref rng=33532 vs ours 35240 at plane=0 tx_size=1, the mi(2,34) filter-intra leaf of decode-order frame 2) — after: 13986/13986 lines identical, whole stream, decode_probe rc=0 with no refusal
33+EVIDENCE: $HOME/.cache/uv8-gate-r3.log | `cargo test -p ec-av1 --lib -- --test-threads=1 --nocapture non_dc_chroma_8x8_intra_leaf` | 3 passed / 0 failed; every arm exact on attempt 0 with all three classes firing — 8bit/1tile dir 159 smooth-paeth 172 cfl 211; 10bit/1tile 112/126/120; 8bit/2tile 83/66/80; buckets counted-exact=1 uncounted-exact=0 named-refusals=0 on each
34+
35+## Residue
36+- deferred: the 8x8 intra-in-inter leaf whose `tx_depth` splits to four TX_4X4 units is still
37+ refused by name (decode.rs ~21996). Unblocked by an arm with `--enable-tx-size-search=1`
38+ plus a 4x4-TU prediction loop in this leaf path — out of this lane's charter, which fixed the
39+ depth-0 alphabet. Its refusal string stays in refusal_inventory.rs.
40+- accepted: `frames` from `decode_stream` is decode order; the gate recipe has
41+ `--lag-in-frames=0 --auto-alt-ref=0`, so decode order == display order and all 8 frames are
42+ compared (class [[gate-blind-to-hidden-frames]] does not apply).