forge
Explore
Log in

Don't you dare go Hollow

Prove the intra-in-inter size-group refusal names a shape no stream presents

Browse files at this commit

86c64abfe537e8714042da39942925ee658df8dcAhmet Kaan GümüşParent: 81b0ef9
  • test
    • prove the intra-in-inter size-group refusal names a shape no stream presents
Show full message
test(av1): prove the intra-in-inter size-group refusal names a shape no stream presents

Refusal B ("an intra-coded {bw}x{bh} block on the inter block path") sat on a
match whose reachable domain nothing checked; after r18 lifted the 128 halves
its measured arrivals all take an earlier branch. The match is now
`intra_in_inter_size_row`, and a test enumerates it against the block-shape
census: `decode_intra_rect_in_inter` has one call site (`write != side`), a
sub-8 footprint is either the 16x4/4x16 strip16 branch or refused there, a
128-px one returns from the 128-root branch, so the lookup can only ever see
the ten rectangular census shapes with 8 <= min side and max side <= 64 --
each of which has a row.
crates/ec-av1/src/decode.rsmodified+71 -28
@@ -7601,6 +7601,62 @@ fn decode_rect_split(
76017601 /// grid, deblock grid) are [`decode_rect_split`]'s; the caller adds the
76027602 /// inter-side bands and the mi map.
76037603 #[allow(clippy::too_many_arguments)]
7604+/// The `(size_group_lookup, bsize_to_tx_size_cat)` row an INTRA block coded
7605+/// inside an inter frame reads its `y_mode` and `tx_depth` symbols from, for
7606+/// the rect footprints [`decode_intra_rect_in_inter`] resolves itself (the
7607+/// 128-root halves and the 16x4/4x16 strips of a 1:4 partition take their own
7608+/// branches before this). libaom `common_data.h:61` / `blockd.h:1347`: the 2:1
7609+/// strips keep the group/category diagonal (BLOCK_16X8 -> 1/1, BLOCK_32X16 ->
7610+/// 2/2, BLOCK_64X32 -> 3/3), the 1:4 ones break it (BLOCK_32X8 is group 1 but
7611+/// category 2, BLOCK_64X16 group 2 and category 3), which is why the row is a
7612+/// table here rather than a shift of `bw.min(bh)`.
7613+fn intra_in_inter_size_row(bw: usize, bh: usize) -> Option<(usize, usize)> {
7614+ Some(match (bw.min(bh), bw.max(bh)) {
7615+ (8, 16) => (1usize, 1usize),
7616+ (16, 32) => (2, 2),
7617+ (32, 64) => (3, 3),
7618+ (8, 32) => (1, 2),
7619+ (16, 64) => (2, 3),
7620+ _ => return None,
7621+ })
7622+}
7623+
7624+/// lane-t900 r20, refusal B ("an intra-coded {bw}x{bh} block on the inter
7625+/// block path"): the shapes that can reach that arm, enumerated against the
7626+/// MEASURED domain of the inter block path
7627+/// ([`INTER_BLOCK_SHAPES`], the census the gate
7628+/// `a_block_shape_census_over_three_real_streams_leaves_the_rect_residual_refusal_unreachable`
7629+/// fills from three real streams).
7630+///
7631+/// [`decode_intra_rect_in_inter`] is called from one site, under
7632+/// `write_w != side || write_h != side`, and only after two earlier arms have
7633+/// taken their shapes: a footprint with a side below 8 is either a 16x4/4x16
7634+/// strip WITH a chroma-pair record (the `strip16` branch) or refused by name,
7635+/// and a 128-px footprint returns from the `bw.max(bh) == 128` branch. What is
7636+/// left is every rectangular census shape with `8 <= min` and `max <= 64` --
7637+/// and each of those has a row, so the refusal names a shape no measured
7638+/// stream can present.
7639+#[test]
7640+fn every_intra_in_inter_shape_the_census_lists_has_a_size_group_row() {
7641+ let mut checked = 0;
7642+ for &(side, w, h) in &INTER_BLOCK_SHAPES {
7643+ if (w, h) == (side, side) || w.min(h) < 8 || w.max(h) > 64 {
7644+ continue;
7645+ }
7646+ assert!(
7647+ intra_in_inter_size_row(w, h).is_some(),
7648+ "the inter path decodes {w}x{h} blocks, and an INTRA one of that shape would hit \
7649+ the \"no size-group/tx-category row\" refusal"
7650+ );
7651+ checked += 1;
7652+ }
7653+ assert_eq!(
7654+ checked, 10,
7655+ "the block-shape census changed: {checked} rect shapes reach the intra-in-inter row \
7656+ lookup, not the 10 this claim was measured over"
7657+ );
7658+}
7659+
76047660 fn decode_intra_rect_in_inter(
76057661 dec: &mut SymbolDecoder,
76067662 cdfs: &mut Cdfs,
@@ -7779,35 +7835,22 @@ fn decode_intra_rect_in_inter(
77797835 INTRA_IN_INTER_MODE.with(|c| c.set(None));
77807836 return res;
77817837 }
7782- let (size_group, tx_cat) = match (bw.min(bh), bw.max(bh)) {
7783- (8, 16) => (1usize, 1usize),
7784- (16, 32) => (2, 2),
7785- (32, 64) => (3, 3),
7786- // lane-intra14 r1: the 1:4 strips, read off libaom's own tables --
7787- // `size_group_lookup` (common_data.h:61) gives BLOCK_8X32/32X8 group
7788- // 1 and BLOCK_16X64/64X16 group 2, while
7789- // `bsize_to_tx_size_depth_table` (blockd.h:1347) gives them depth
7790- // 3 and 4, i.e. tx categories 2 and 3 -- the diagonal a 2:1 strip
7791- // keeps is genuinely broken here, which is why the shape was refused
7792- // rather than read from the 2:1 row.
7793- (8, 32) => (1, 2),
7794- (16, 64) => (2, 3),
7795- _ => {
7796- if crate::envflags::env_flag!("EC_OBMCREC") {
7797- eprintln!(
7798- "OBMCREC intra-in-inter shape bw={bw} bh={bh} mi=({mi_r},{mi_c}) skip={skip}"
7799- );
7800- }
7801- // lane-obmcrec r1: the message used to name a 16x4/4x16 strip
7802- // (class refusal-names-a-correlate). Measured with `EC_OBMCREC=1`
7803- // on three 2 s cuts of the 10-bit 1920x792 128-superblock stream:
7804- // every arrival here is a 128x64 block -- a PARTITION_HORZ half of
7805- // a 128 superblock coded INTRA inside an inter frame, at mi
7806- // (128,416) / (192,0) / (192,0) -- not a strip at all.
7807- return Err(unsupported(format!(
7808- "an intra-coded {bw}x{bh} block on the inter block path (no size-group/tx-category row for that shape here)"
7809- )));
7838+ let Some((size_group, tx_cat)) = intra_in_inter_size_row(bw, bh) else {
7839+ if crate::envflags::env_flag!("EC_OBMCREC") {
7840+ eprintln!(
7841+ "OBMCREC intra-in-inter shape bw={bw} bh={bh} mi=({mi_r},{mi_c}) skip={skip}"
7842+ );
78107843 }
7844+ // lane-obmcrec r1: the message used to name a 16x4/4x16 strip
7845+ // (class refusal-names-a-correlate). lane-t900 r20: the shapes that
7846+ // can arrive here are enumerated against the measured block-shape
7847+ // census ([`INTER_BLOCK_SHAPES`]) by
7848+ // [`every_intra_in_inter_shape_the_census_lists_has_a_size_group_row`]
7849+ // -- every one of them has a row, so this arm names a shape no stream
7850+ // has been able to present.
7851+ return Err(unsupported(format!(
7852+ "an intra-coded {bw}x{bh} block on the inter block path (no size-group/tx-category row for that shape here)"
7853+ )));
78117854 };
78127855 // [`read_intra_mode_rect`]'s own refusal: palette/intrabc syntax is
78137856 // consumed for square blocks only, so a strip in a screen-content frame
crates/ec-av1/src/refusal_inventory.rsmodified+12 -3
@@ -135,6 +135,14 @@ const PROVEN: &[(&str, &str)] = &[
135135 "a non-skip rectangular (HORZ/VERT/HORZ_B) strip needs rectangular residual coding",
136136 "a_block_shape_census_over_three_real_streams_leaves_the_rect_residual_refusal_unreachable",
137137 ),
138+ // lane-t900 r20, census: the shapes that can reach `decode_intra_rect_in_inter`'s
139+ // size-group/tx-category lookup are the ten rectangular census shapes with
140+ // `8 <= min` and `max <= 64` (a sub-8 footprint and a 128-px one take
141+ // earlier branches), and every one of them has a row.
142+ (
143+ "an intra-coded {bw}x{bh} block on the inter block path (no size-group/tx-category row for that shape here)",
144+ "every_intra_in_inter_shape_the_census_lists_has_a_size_group_row",
145+ ),
138146 ];
139147
140148 /// Gates whose `Err` arm turns a decode failure into a printed SKIP rather than
@@ -319,15 +327,16 @@ mod tests {
319327 #[test]
320328 fn every_proven_refusal_names_a_test_that_exists() {
321329 let found = decode_path_refusals();
322- let src = include_str!("stream.rs");
330+ let sources = [include_str!("stream.rs"), include_str!("decode.rs")];
323331 for (reason, gate) in PROVEN {
324332 assert!(
325333 found.contains(*reason),
326334 "{reason:?} is listed as proven but is no longer a decode-path refusal -- drop it from PROVEN (the capability landed) or fix the string"
327335 );
328336 assert!(
329- src.contains(&format!("fn {gate}(")),
330- "{reason:?} names the proving test {gate}, which does not exist in stream.rs"
337+ sources.iter().any(|src| src.contains(&format!("fn {gate}("))),
338+ "{reason:?} names the proving test {gate}, which exists in neither stream.rs \
339+ nor decode.rs"
331340 );
332341 }
333342 eprintln!(