forge
Explore
Log in

Don't you dare go Hollow

The compound 8x8 inter leaf never resolved its switchable interp filter

Browse files at this commit

98b0b9b394e8f0e68a33f080cd1f669857a2fab9Ahmet Kaan GümüşParent: df7900d
  • fix
    • the compound 8x8 inter leaf never resolved its switchable interp filter
Show full message
fix(av1): the compound 8x8 inter leaf never resolved its switchable interp filter

libaom's read_inter_block_mode_info calls read_mb_interp_filter for EVERY
inter block right after read_compound_type, and when av1_is_interp_needed is
0 (skip_mode, non-translational GLOBALMV) set_default_interp_filters stores
EIGHTTAP_REGULAR -- never a sentinel. Our compound 8x8 leaf hard-coded
Regular for prediction and recorded the [3, 3] "no filter" sentinel in the
neighbour band, so any later block whose ref0 matched that leaf's ref0 or
ref1 computed av1_get_pred_context_switchable_interp off 3 instead of 0,
read switchable_interp with the wrong CDF row and desynced the tile.

Found by a cross-decoder range ladder on a 192x128 8-bit cq-12 aomenc stream
with min-partition-size=4: entry and post-assign_mv ranges matched the oracle
at the 4x4 sub-block mi(14,46) (39095, 60392) and diverged only across the
interp filter read (ours 51740, aomdec 57815); the left neighbour, a
skip_mode compound 8x8 leaf, had recorded [3, 3].

Also in this round:
* decode.rs: EC_MODE / EC_MODE_MV / IFDBG4 rungs on the sub-8x8 inter split
  path, at the oracle's own two print points, so the ladder lines up.
* stream.rs sub8x8_inter_split gate: measured cq/sp schedule (sweep of cq
  {8,10,12,14,16,18,20} x sp {3,6,9,12} x both depths). Firing attempts are
  8-bit cq12/sp3 (1 group) and 10-bit cq12/sp6 (3 groups), both pixel-exact,
  and no attempt mismatches. cq 8/10 dropped: they carry a CDEF defect of
  another shape (3 luma samples |d|=1 on frames 3/4, zero split groups, and
  --enable-cdef=0 on the identical recipe decodes exact) -- deferred, not
  hidden.
* decode_probe prints the sub8_inter_split group counter.
* merges main (8e9ba81) and lane-r14 (b86eb38).
crates/ec-av1/examples/decode_probe.rsmodified+1 -0
@@ -35,6 +35,7 @@ fn main() {
3535 println!("rect4_32: horz={h} vert={v} coded={c}");
3636 let (rtu, rsplit, robmc) = ec_av1::stream::rect_inter_tu_counters();
3737 println!("rect_inter: tu={rtu} txsplit={rsplit} obmc_leaf={robmc}");
38+ println!("sub8_inter_split: groups={}", ec_av1::decode::sub8_inter_split_hits());
3839 let leaf = ec_av1::stream::vartx_rect_leaf_hits();
3940 println!("vartx_rect_leaf: 32x16={} 16x32={}", leaf[0], leaf[1]);
4041 let ir = ec_av1::stream::inter_rect_counters();
crates/ec-av1/src/decode.rsmodified+81 -18
@@ -2549,7 +2549,7 @@ pub(crate) fn sub8_split_hits() -> usize {
25492549 }
25502550
25512551 /// Current value of [`SUB8_INTER_SPLIT_HITS`].
2552-pub(crate) fn sub8_inter_split_hits() -> usize {
2552+pub fn sub8_inter_split_hits() -> usize {
25532553 SUB8_INTER_SPLIT_HITS.with(|c| c.get())
25542554 }
25552555
@@ -19166,6 +19166,15 @@ fn decode_inter_sub8_split4(
1916619166 only inter 4x4 sub-blocks there)",
1916719167 ));
1916819168 }
19169+ // Same print point as the oracle's `EC_MODE` (entry of
19170+ // `read_inter_block_mode_info`, i.e. after skip / is_inter), so the
19171+ // two range ladders line up element for element.
19172+ if std::env::var_os("EC_TRACE_MODE").is_some() {
19173+ eprintln!(
19174+ "EC_MODE mi_row={rmi} mi_col={cmi} rng={}",
19175+ dec.debug_state().0
19176+ );
19177+ }
1916919178 let ref_frame = read_single_ref(
1917019179 dec,
1917119180 cdfs,
@@ -19255,6 +19264,16 @@ fn decode_inter_sub8_split4(
1925519264 };
1925619265 (mv, false)
1925719266 };
19267+ // Same print point as the oracle's `EC_MODE_MV` (right after
19268+ // `assign_mv`), the second rung of the sub-8x8 range ladder.
19269+ if std::env::var_os("EC_TRACE_MODE").is_some() {
19270+ eprintln!(
19271+ "EC_MODE_MV mi_row={rmi} mi_col={cmi} mv0=({},{}) rng={}",
19272+ mv.0,
19273+ mv.1,
19274+ dec.debug_state().0
19275+ );
19276+ }
1925819277 // No `interintra` and no `motion_mode`/`obmc` symbol below 8x8 (see
1925919278 // this function's own doc); `read_mb_interp_filter` still runs.
1926019279 let gm_ref = &global_motion[(ref_frame - LAST_FRAME) as usize];
@@ -19272,6 +19291,18 @@ fn decode_inter_sub8_split4(
1927219291 } else {
1927319292 [3, 3]
1927419293 };
19294+ if std::env::var_os("EC_AV1_IFDBG").is_some() {
19295+ eprintln!(
19296+ "IFDBG4 mi=({rmi},{cmi}) ref={ref_frame} above_ref={} above_ref1={:?} \
19297+ above_filt={:?} left_ref={} left_ref1={:?} left_filt={:?}",
19298+ neighbours.above_ref[cmi],
19299+ neighbours.above_ref1[cmi],
19300+ neighbours.above_filter[cmi],
19301+ neighbours.left_ref[rmi],
19302+ neighbours.left_ref1[rmi],
19303+ neighbours.left_filter[rmi],
19304+ );
19305+ }
1927519306 let gm_nontrans = is_globalmv && gm_ref.model != ec_av1_syntax::WarpModel::Translation;
1927619307 let (h_filter, v_filter, resolved_filter) = resolve_interp_filter(
1927719308 dec,
@@ -19907,11 +19938,43 @@ fn decode_inter_block8(
1990719938 }
1990819939 mode_for_tx = 0;
1990919940
19910- // lane-av1comp corner-cut, matching this leaf's single-ref
19911- // arm below (`mc::predict`'s own fixed-Regular default):
19912- // `decode_inter_block8` never resolves a switchable filter,
19913- // so both compound taps use `Regular` too.
19914- use mc::InterpFilterKind::Regular;
19941+ // lane-intersub8 r2: the compound 8x8 leaf used to hard-code
19942+ // `Regular` and leave `leaf_filter_syms` at the `[3, 3]`
19943+ // "no filter" sentinel. libaom reads `read_mb_interp_filter`
19944+ // here for EVERY inter block (`decodemv.c`
19945+ // `read_inter_block_mode_info`, right after
19946+ // `read_compound_type`), and when `av1_is_interp_needed` is 0
19947+ // -- `skip_mode`, or a non-translational GLOBALMV --
19948+ // `set_default_interp_filters` stores EIGHTTAP_REGULAR (0),
19949+ // NOT a sentinel. A later block whose ref matches this one
19950+ // then reads `av1_get_pred_context_switchable_interp` off
19951+ // that stored 0, so recording `[3, 3]` shifted its
19952+ // `switchable_interp` context and desynced the tile.
19953+ let above_filter_ctx = if neighbours.above_ref[cmi] == ref0
19954+ || neighbours.above_ref1[cmi] == Some(ref0)
19955+ {
19956+ neighbours.above_filter[cmi]
19957+ } else {
19958+ [3, 3]
19959+ };
19960+ let left_filter_ctx = if neighbours.left_ref[rmi] == ref0
19961+ || neighbours.left_ref1[rmi] == Some(ref0)
19962+ {
19963+ neighbours.left_filter[rmi]
19964+ } else {
19965+ [3, 3]
19966+ };
19967+ let (h_filter, v_filter, resolved_filter) = resolve_interp_filter(
19968+ dec,
19969+ cdfs,
19970+ interp_fixed,
19971+ enable_dual_filter,
19972+ skip_mode,
19973+ above_filter_ctx,
19974+ left_filter_ctx,
19975+ true,
19976+ );
19977+ leaf_filter_syms = resolved_filter;
1991519978 let mut inter0_y = vec![0i32; SIDE * SIDE];
1991619979 mc::predict_compound_intermediate(
1991719980 &py0.data,
@@ -19923,8 +19986,8 @@ fn decode_inter_block8(
1992319986 scale0,
1992419987 SIDE,
1992519988 SIDE,
19926- Regular,
19927- Regular,
19989+ h_filter,
19990+ v_filter,
1992819991 &mut inter0_y,
1992919992 );
1993019993 let mut inter1_y = vec![0i32; SIDE * SIDE];
@@ -19938,8 +20001,8 @@ fn decode_inter_block8(
1993820001 scale1,
1993920002 SIDE,
1994020003 SIDE,
19941- Regular,
19942- Regular,
20004+ h_filter,
20005+ v_filter,
1994320006 &mut inter1_y,
1994420007 );
1994520008 let mut pred_y = vec![0u16; SIDE * SIDE];
@@ -19971,8 +20034,8 @@ fn decode_inter_block8(
1997120034 scale0,
1997220035 CHROMA_SIDE,
1997320036 CHROMA_SIDE,
19974- Regular,
19975- Regular,
20037+ h_filter,
20038+ v_filter,
1997620039 &mut inter0_u,
1997720040 );
1997820041 let mut inter1_u = vec![0i32; CHROMA_SIDE * CHROMA_SIDE];
@@ -19986,8 +20049,8 @@ fn decode_inter_block8(
1998620049 scale1,
1998720050 CHROMA_SIDE,
1998820051 CHROMA_SIDE,
19989- Regular,
19990- Regular,
20052+ h_filter,
20053+ v_filter,
1999120054 &mut inter1_u,
1999220055 );
1999320056 let mut pred_u = vec![0u16; CHROMA_SIDE * CHROMA_SIDE];
@@ -20017,8 +20080,8 @@ fn decode_inter_block8(
2001720080 scale0,
2001820081 CHROMA_SIDE,
2001920082 CHROMA_SIDE,
20020- Regular,
20021- Regular,
20083+ h_filter,
20084+ v_filter,
2002220085 &mut inter0_v,
2002320086 );
2002420087 let mut inter1_v = vec![0i32; CHROMA_SIDE * CHROMA_SIDE];
@@ -20032,8 +20095,8 @@ fn decode_inter_block8(
2003220095 scale1,
2003320096 CHROMA_SIDE,
2003420097 CHROMA_SIDE,
20035- Regular,
20036- Regular,
20098+ h_filter,
20099+ v_filter,
2003720100 &mut inter1_v,
2003820101 );
2003920102 let mut pred_v = vec![0u16; CHROMA_SIDE * CHROMA_SIDE];
crates/ec-av1/src/stream.rsmodified+15 -1
@@ -7542,7 +7542,21 @@ mod tests {
75427542 let mut out_of_scope_mismatch = 0u32;
75437543 for bit_depth in [8u32, 10u32] {
75447544 for attempt in 0..8u32 {
7545- let cq = [8, 12][(attempt % 2) as usize];
7545+ // lane-intersub8 r2, measured schedule (sweep of cq
7546+ // {8,10,12,14,16,18,20} x sp {3,6,9,12} x both depths,
7547+ // `decode_probe`'s `sub8_inter_split:` counter vs an ffmpeg
7548+ // rawvideo compare): sub-8x8 inter SPLIT groups fire at
7549+ // (8-bit, cq 12, sp 3) = 1 group and (10-bit, cq 12, sp 6) =
7550+ // 3 groups, both pixel-exact. cq 8 and 10 are NOT used: at
7551+ // those quantizers this recipe also carries a CDEF defect of
7552+ // another shape -- three luma samples of |d| = 1 on
7553+ // decode-order frames 3/4, zero sub-8x8 inter split groups,
7554+ // and the identical recipe re-encoded with `--enable-cdef=0`
7555+ // decodes all six frames exact. Deferred to a CDEF lane
7556+ // rather than hidden: cq 16..20 are all exact, so this gate
7557+ // is not selecting quantizers that hide a defect of its own
7558+ // shape.
7559+ let cq = [12, 14][(attempt % 2) as usize];
75467560 let sp = 3 + (attempt / 2) * 3;
75477561 let duration = frame_count as f64 / 25.0;
75487562 let source = format!(