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() {
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());
38 let leaf = ec_av1::stream::vartx_rect_leaf_hits();39 let leaf = ec_av1::stream::vartx_rect_leaf_hits();
39 println!("vartx_rect_leaf: 32x16={} 16x32={}", leaf[0], leaf[1]);40 println!("vartx_rect_leaf: 32x16={} 16x32={}", leaf[0], leaf[1]);
40 let ir = ec_av1::stream::inter_rect_counters();41 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 {
2549 }2549 }
2550 2550
2551 /// Current value of [`SUB8_INTER_SPLIT_HITS`].2551 /// Current value of [`SUB8_INTER_SPLIT_HITS`].
2552-pub(crate) fn sub8_inter_split_hits() -> usize {2552+pub fn sub8_inter_split_hits() -> usize {
2553 SUB8_INTER_SPLIT_HITS.with(|c| c.get())2553 SUB8_INTER_SPLIT_HITS.with(|c| c.get())
2554 }2554 }
2555 2555
@@ -19166,6 +19166,15 @@ fn decode_inter_sub8_split4(
19166 only inter 4x4 sub-blocks there)",19166 only inter 4x4 sub-blocks there)",
19167 ));19167 ));
19168 }19168 }
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+ }
19169 let ref_frame = read_single_ref(19178 let ref_frame = read_single_ref(
19170 dec,19179 dec,
19171 cdfs,19180 cdfs,
@@ -19255,6 +19264,16 @@ fn decode_inter_sub8_split4(
19255 };19264 };
19256 (mv, false)19265 (mv, false)
19257 };19266 };
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+ }
19258 // No `interintra` and no `motion_mode`/`obmc` symbol below 8x8 (see19277 // No `interintra` and no `motion_mode`/`obmc` symbol below 8x8 (see
19259 // this function's own doc); `read_mb_interp_filter` still runs.19278 // this function's own doc); `read_mb_interp_filter` still runs.
19260 let gm_ref = &global_motion[(ref_frame - LAST_FRAME) as usize];19279 let gm_ref = &global_motion[(ref_frame - LAST_FRAME) as usize];
@@ -19272,6 +19291,18 @@ fn decode_inter_sub8_split4(
19272 } else {19291 } else {
19273 [3, 3]19292 [3, 3]
19274 };19293 };
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+ }
19275 let gm_nontrans = is_globalmv && gm_ref.model != ec_av1_syntax::WarpModel::Translation;19306 let gm_nontrans = is_globalmv && gm_ref.model != ec_av1_syntax::WarpModel::Translation;
19276 let (h_filter, v_filter, resolved_filter) = resolve_interp_filter(19307 let (h_filter, v_filter, resolved_filter) = resolve_interp_filter(
19277 dec,19308 dec,
@@ -19907,11 +19938,43 @@ fn decode_inter_block8(
19907 }19938 }
19908 mode_for_tx = 0;19939 mode_for_tx = 0;
19909 19940
19910- // lane-av1comp corner-cut, matching this leaf's single-ref19941+ // lane-intersub8 r2: the compound 8x8 leaf used to hard-code
19911- // arm below (`mc::predict`'s own fixed-Regular default):19942+ // `Regular` and leave `leaf_filter_syms` at the `[3, 3]`
19912- // `decode_inter_block8` never resolves a switchable filter,19943+ // "no filter" sentinel. libaom reads `read_mb_interp_filter`
19913- // so both compound taps use `Regular` too.19944+ // here for EVERY inter block (`decodemv.c`
19914- use mc::InterpFilterKind::Regular;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;
19915 let mut inter0_y = vec![0i32; SIDE * SIDE];19978 let mut inter0_y = vec![0i32; SIDE * SIDE];
19916 mc::predict_compound_intermediate(19979 mc::predict_compound_intermediate(
19917 &py0.data,19980 &py0.data,
@@ -19923,8 +19986,8 @@ fn decode_inter_block8(
19923 scale0,19986 scale0,
19924 SIDE,19987 SIDE,
19925 SIDE,19988 SIDE,
19926- Regular,19989+ h_filter,
19927- Regular,19990+ v_filter,
19928 &mut inter0_y,19991 &mut inter0_y,
19929 );19992 );
19930 let mut inter1_y = vec![0i32; SIDE * SIDE];19993 let mut inter1_y = vec![0i32; SIDE * SIDE];
@@ -19938,8 +20001,8 @@ fn decode_inter_block8(
19938 scale1,20001 scale1,
19939 SIDE,20002 SIDE,
19940 SIDE,20003 SIDE,
19941- Regular,20004+ h_filter,
19942- Regular,20005+ v_filter,
19943 &mut inter1_y,20006 &mut inter1_y,
19944 );20007 );
19945 let mut pred_y = vec![0u16; SIDE * SIDE];20008 let mut pred_y = vec![0u16; SIDE * SIDE];
@@ -19971,8 +20034,8 @@ fn decode_inter_block8(
19971 scale0,20034 scale0,
19972 CHROMA_SIDE,20035 CHROMA_SIDE,
19973 CHROMA_SIDE,20036 CHROMA_SIDE,
19974- Regular,20037+ h_filter,
19975- Regular,20038+ v_filter,
19976 &mut inter0_u,20039 &mut inter0_u,
19977 );20040 );
19978 let mut inter1_u = vec![0i32; CHROMA_SIDE * CHROMA_SIDE];20041 let mut inter1_u = vec![0i32; CHROMA_SIDE * CHROMA_SIDE];
@@ -19986,8 +20049,8 @@ fn decode_inter_block8(
19986 scale1,20049 scale1,
19987 CHROMA_SIDE,20050 CHROMA_SIDE,
19988 CHROMA_SIDE,20051 CHROMA_SIDE,
19989- Regular,20052+ h_filter,
19990- Regular,20053+ v_filter,
19991 &mut inter1_u,20054 &mut inter1_u,
19992 );20055 );
19993 let mut pred_u = vec![0u16; CHROMA_SIDE * CHROMA_SIDE];20056 let mut pred_u = vec![0u16; CHROMA_SIDE * CHROMA_SIDE];
@@ -20017,8 +20080,8 @@ fn decode_inter_block8(
20017 scale0,20080 scale0,
20018 CHROMA_SIDE,20081 CHROMA_SIDE,
20019 CHROMA_SIDE,20082 CHROMA_SIDE,
20020- Regular,20083+ h_filter,
20021- Regular,20084+ v_filter,
20022 &mut inter0_v,20085 &mut inter0_v,
20023 );20086 );
20024 let mut inter1_v = vec![0i32; CHROMA_SIDE * CHROMA_SIDE];20087 let mut inter1_v = vec![0i32; CHROMA_SIDE * CHROMA_SIDE];
@@ -20032,8 +20095,8 @@ fn decode_inter_block8(
20032 scale1,20095 scale1,
20033 CHROMA_SIDE,20096 CHROMA_SIDE,
20034 CHROMA_SIDE,20097 CHROMA_SIDE,
20035- Regular,20098+ h_filter,
20036- Regular,20099+ v_filter,
20037 &mut inter1_v,20100 &mut inter1_v,
20038 );20101 );
20039 let mut pred_v = vec![0u16; CHROMA_SIDE * CHROMA_SIDE];20102 let mut pred_v = vec![0u16; CHROMA_SIDE * CHROMA_SIDE];
crates/ec-av1/src/stream.rsmodified+15 -1
@@ -7542,7 +7542,21 @@ mod tests {
7542 let mut out_of_scope_mismatch = 0u32;7542 let mut out_of_scope_mismatch = 0u32;
7543 for bit_depth in [8u32, 10u32] {7543 for bit_depth in [8u32, 10u32] {
7544 for attempt in 0..8u32 {7544 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];
7546 let sp = 3 + (attempt / 2) * 3;7560 let sp = 3 + (attempt / 2) * 3;
7547 let duration = frame_count as f64 / 25.0;7561 let duration = frame_count as f64 / 25.0;
7548 let source = format!(7562 let source = format!(