forge
Explore
Log in

Don't you dare go Hollow

A GLOBALMV block with a 4-px side must still read its interp filter

Browse files at this commit

defe73ab89e261c05485605a743be091e8ceaed3Ahmet Kaan GümüşParent: 42ede61
  • fix
    • a GLOBALMV block with a 4-px side must still read its interp filter
Show full message
fix(av1): a GLOBALMV block with a 4-px side must still read its interp filter

libaom `is_nontrans_global_motion` (mvref_common.h) returns 0 at
`AOMMIN(mi_size_wide[bsize], mi_size_high[bsize]) < 2` BEFORE it looks at any
global-motion model, so no block with a 4-px side is ever "non-translational
global" and `av1_is_interp_needed` never suppresses its interp-filter symbol.
Our two sub-8x8 readers (quad-4x4 and the 4x8/8x4 rect pair) and the compound
arm of decode_inter_block computed `gm_nontrans` from the model alone and
skipped that symbol -- a one-symbol entropy desync at the block, before any
coefficient. The single-ref arm of decode_inter_block already carried the
guard; the 8x8-leaf reader cannot hit it (min side 2).

Counter `gm_nontrans_small_side_hits()` counts only the blocks where the guard
flips our answer (printed by decode_probe).

Measured on the 10-bit 3840x1608 head cut (170 decode frames), coefficient
ladder vs aomdec (tags all_zero/eob/after_bases + rng): decode frame 99 was
DIFF at element 11933 (we read txfm_split where aomdec read interp: our
rng 60039 vs 46640 at block mi(40,637), the second 4x8 of a vertical sub-8x8
group, GLOBALMV ref0=5); it is now element-exact over all 69065 elements.
Counter fires 109 times on that cut.
crates/ec-av1/examples/decode_probe.rsmodified+1 -0
@@ -44,6 +44,7 @@ fn main() {
44 println!("rect_inter: tu={rtu} txsplit={rsplit} obmc_leaf={robmc}");44 println!("rect_inter: tu={rtu} txsplit={rsplit} obmc_leaf={robmc}");
45 println!("sub8_inter_split: groups={}", ec_av1::decode::sub8_inter_split_hits());45 println!("sub8_inter_split: groups={}", ec_av1::decode::sub8_inter_split_hits());
46 println!("interintra_rect: {}", ec_av1::decode::interintra_rect_hits());46 println!("interintra_rect: {}", ec_av1::decode::interintra_rect_hits());
47+ println!("gm_nontrans_small_side: {}", ec_av1::decode::gm_nontrans_small_side_hits());
47 let (h84, h48) = ec_av1::decode::sub8_inter_rect_hits();48 let (h84, h48) = ec_av1::decode::sub8_inter_rect_hits();
48 println!("sub8_inter_rect: horz8x4={h84} vert4x8={h48}");49 println!("sub8_inter_rect: horz8x4={h84} vert4x8={h48}");
49 let si = ec_av1::stream::sub8_intra_rect_hits();50 let si = ec_av1::stream::sub8_intra_rect_hits();
crates/ec-av1/src/decode.rsmodified+40 -3
@@ -2134,6 +2134,22 @@ pub(crate) fn affine_gm_hits() -> usize {
2134 AFFINE_GM_HITS.with(|c| c.get())2134 AFFINE_GM_HITS.with(|c| c.get())
2135 }2135 }
2136 2136
2137+// lane-t900 r9: libaom `is_nontrans_global_motion` (mvref_common.h) returns 0
2138+// for `AOMMIN(mi_size_wide[bsize], mi_size_high[bsize]) < 2`, i.e. any block
2139+// with a 4-px side is NEVER "non-translational global" and therefore ALWAYS
2140+// reads its interp-filter symbol. Counts the blocks where that guard flips
2141+// our answer -- a GLOBALMV/GLOBAL_GLOBALMV block with a non-TRANSLATION model
2142+// and a 4-px side, which we used to suppress the interp read on (a pre-mode
2143+// entropy desync one symbol wide).
2144+thread_local! {
2145+ static GM_NONTRANS_SMALL_SIDE_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
2146+}
2147+
2148+/// Current value of [`GM_NONTRANS_SMALL_SIDE_HITS`].
2149+pub fn gm_nontrans_small_side_hits() -> usize {
2150+ GM_NONTRANS_SMALL_SIDE_HITS.with(std::cell::Cell::get)
2151+}
2152+
2137 // lane-gmaffine r1: 8x8-leaf-only counters -- how many `BLOCK_8X8` leaves2153 // lane-gmaffine r1: 8x8-leaf-only counters -- how many `BLOCK_8X8` leaves
2138 // coded `GLOBALMV` (`GLOBALMV_HITS_8`) and how many built a real2154 // coded `GLOBALMV` (`GLOBALMV_HITS_8`) and how many built a real
2139 // `WARPED_CAUSAL` local-warp prediction there (`WARP_HITS_8`, incremented2155 // `WARPED_CAUSAL` local-warp prediction there (`WARP_HITS_8`, incremented
@@ -20276,9 +20292,16 @@ fn decode_inter_block(
20276 // spec `is_nontrans_global_motion`: ALL active refs' models must20292 // spec `is_nontrans_global_motion`: ALL active refs' models must
20277 // be non-TRANSLATION (IDENTITY counts) for the compound block's20293 // be non-TRANSLATION (IDENTITY counts) for the compound block's
20278 // interp-filter read to be suppressed.20294 // interp-filter read to be suppressed.
20279- let gm_nontrans = is_globalmv20295+ let gm_nontrans_models = is_globalmv
20280 && global_motion[(ref0 - LAST_FRAME) as usize].model != ec_av1_syntax::WarpModel::Translation20296 && global_motion[(ref0 - LAST_FRAME) as usize].model != ec_av1_syntax::WarpModel::Translation
20281 && global_motion[(ref1 - LAST_FRAME) as usize].model != ec_av1_syntax::WarpModel::Translation;20297 && global_motion[(ref1 - LAST_FRAME) as usize].model != ec_av1_syntax::WarpModel::Translation;
20298+ // lane-t900 r9: `is_nontrans_global_motion` bails at
20299+ // `AOMMIN(mi_size_wide, mi_size_high) < 2` before it looks at any
20300+ // model, so a 4-px-sided block still reads its interp filter.
20301+ let gm_nontrans = gm_nontrans_models && bw4.min(bh4) >= 2;
20302+ if gm_nontrans_models && !gm_nontrans {
20303+ GM_NONTRANS_SMALL_SIDE_HITS.with(|c| c.set(c.get() + 1));
20304+ }
20282 let (py0, pu0, pv0) = ref_planes(ref0, ref_y, ref_u, ref_v, other_refs)?;20305 let (py0, pu0, pv0) = ref_planes(ref0, ref_y, ref_u, ref_v, other_refs)?;
20283 let (py1, pu1, pv1) = ref_planes(ref1, ref_y, ref_u, ref_v, other_refs)?;20306 let (py1, pu1, pv1) = ref_planes(ref1, ref_y, ref_u, ref_v, other_refs)?;
20284 // lane-cwarp r1: `is_global_mv_block` (blockd.h:421-429) is20307 // lane-cwarp r1: `is_global_mv_block` (blockd.h:421-429) is
@@ -23645,7 +23668,14 @@ fn decode_inter_sub8_split4(
23645 neighbours.left_filter[rmi],23668 neighbours.left_filter[rmi],
23646 );23669 );
23647 }23670 }
23648- let gm_nontrans = is_globalmv && gm_ref.model != ec_av1_syntax::WarpModel::Translation;23671+ // lane-t900 r9: this reader's sub-blocks have a 4-px side, and libaom
23672+ // `is_nontrans_global_motion` returns 0 for
23673+ // `AOMMIN(mi_size_wide, mi_size_high) < 2` BEFORE testing any model --
23674+ // so a GLOBALMV sub-block here always reads its interp filter.
23675+ if is_globalmv && gm_ref.model != ec_av1_syntax::WarpModel::Translation {
23676+ GM_NONTRANS_SMALL_SIDE_HITS.with(|c| c.set(c.get() + 1));
23677+ }
23678+ let gm_nontrans = false;
23649 let (h_filter, v_filter, resolved_filter) = resolve_interp_filter(23679 let (h_filter, v_filter, resolved_filter) = resolve_interp_filter(
23650 dec,23680 dec,
23651 cdfs,23681 cdfs,
@@ -24571,7 +24601,14 @@ fn decode_inter_sub8_rect2(
24571 } else {24601 } else {
24572 [3, 3]24602 [3, 3]
24573 };24603 };
24574- let gm_nontrans = is_globalmv && gm_ref.model != ec_av1_syntax::WarpModel::Translation;24604+ // lane-t900 r9: this reader's sub-blocks have a 4-px side, and libaom
24605+ // `is_nontrans_global_motion` returns 0 for
24606+ // `AOMMIN(mi_size_wide, mi_size_high) < 2` BEFORE testing any model --
24607+ // so a GLOBALMV sub-block here always reads its interp filter.
24608+ if is_globalmv && gm_ref.model != ec_av1_syntax::WarpModel::Translation {
24609+ GM_NONTRANS_SMALL_SIDE_HITS.with(|c| c.set(c.get() + 1));
24610+ }
24611+ let gm_nontrans = false;
24575 let (h_filter, v_filter, resolved_filter) = resolve_interp_filter(24612 let (h_filter, v_filter, resolved_filter) = resolve_interp_filter(
24576 dec,24613 dec,
24577 cdfs,24614 cdfs,