Prove the rect transform table/scan refusals over the measured shape domain
Browse files at this commit517f8b4ffa2930986e476adaa6b1b56817be7fffParent: 48ada7f- test
- prove the rect transform table/scan refusals over the measured shape domain
2 changed files +89 -0
crates/ec-av1/src/decode.rsmodified+74 -0
| @@ -14800,6 +14800,80 @@ fn rect_scan(w: usize, h: usize) -> Result<&'static [u16]> { | |||
| 14800 | }) | 14800 | }) |
| 14801 | } | 14801 | } |
| 14802 | 14802 | ||
| 14803 | +/// lane-t900 r20, refusal D -- the three "a rectangular inter luma/chroma | ||
| 14804 | +/// transform unit whose shape has no coefficient table set here" / "a | ||
| 14805 | +/// rectangular transform unit whose shape has no coefficient scan table here" | ||
| 14806 | +/// arms, enumerated against the MEASURED domain of the inter block path | ||
| 14807 | +/// ([`INTER_BLOCK_SHAPES`], filled from three real streams by the gate | ||
| 14808 | +/// `a_block_shape_census_over_three_real_streams_leaves_the_rect_residual_refusal_unreachable`). | ||
| 14809 | +/// | ||
| 14810 | +/// What each helper is actually handed: | ||
| 14811 | +/// | ||
| 14812 | +/// * [`rect_inter_luma_set`] -- the block's own footprint (call sites at the | ||
| 14813 | +/// whole-block residual), and a var-tx LEAF shape. `sub_tx_size_map` is | ||
| 14814 | +/// square for every rect transform except TX_16X4/TX_4X16, whose leaves are | ||
| 14815 | +/// TX_8X4/TX_4X8, so the leaf domain adds exactly 8x4 and 4x8. | ||
| 14816 | +/// * [`rect_inter_chroma_set`] -- `(write_w / 2, write_h / 2)` for a 4:2:0 | ||
| 14817 | +/// block, except a 16x4/4x16 strip, whose chroma is the PAIR's 8x4 / 4x8. | ||
| 14818 | +/// * [`rect_scan`] -- the `min(w, 32) x min(h, 32)` coded corner of a rect | ||
| 14819 | +/// unit, and only when that corner is not 32x32 (a square corner goes | ||
| 14820 | +/// through the square reader with `rect_shape = Some((w, h))`). | ||
| 14821 | +/// | ||
| 14822 | +/// The 128-px halves take neither: `max_txsize_rect_lookup[BLOCK_128X64]` is | ||
| 14823 | +/// TX_64X64, so they tile into SQUARE 64x64 luma units through the mu-chunk | ||
| 14824 | +/// loop, which is why they are skipped below. | ||
| 14825 | +#[test] | ||
| 14826 | +fn every_rect_transform_shape_the_census_lists_has_a_coefficient_table_and_scan() { | ||
| 14827 | + let corner_scan = |w: usize, h: usize| { | ||
| 14828 | + let (cw, ch) = (w.min(32), h.min(32)); | ||
| 14829 | + if (cw, ch) == (32, 32) { | ||
| 14830 | + return; // the square coefficient reader, not `rect_scan` | ||
| 14831 | + } | ||
| 14832 | + assert!( | ||
| 14833 | + rect_scan(cw, ch).is_ok(), | ||
| 14834 | + "a {w}x{h} rect transform codes its {cw}x{ch} corner, which has no scan table" | ||
| 14835 | + ); | ||
| 14836 | + }; | ||
| 14837 | + let mut checked = 0; | ||
| 14838 | + for &(side, w, h) in &INTER_BLOCK_SHAPES { | ||
| 14839 | + if (w, h) == (side, side) || w.max(h) > 64 { | ||
| 14840 | + continue; | ||
| 14841 | + } | ||
| 14842 | + assert!( | ||
| 14843 | + rect_inter_luma_set(w, h).is_ok(), | ||
| 14844 | + "the inter path decodes {w}x{h} blocks but has no luma coefficient table set for one" | ||
| 14845 | + ); | ||
| 14846 | + corner_scan(w, h); | ||
| 14847 | + // 4:2:0 chroma: the pair's 8x4 / 4x8 for a 1:4 strip, the halved | ||
| 14848 | + // footprint for every other shape. | ||
| 14849 | + let (cw, ch) = match (w, h) { | ||
| 14850 | + (16, 4) => (8, 4), | ||
| 14851 | + (4, 16) => (4, 8), | ||
| 14852 | + _ => (w / 2, h / 2), | ||
| 14853 | + }; | ||
| 14854 | + assert!( | ||
| 14855 | + rect_inter_chroma_set(cw, ch).is_ok(), | ||
| 14856 | + "a {w}x{h} block's {cw}x{ch} chroma unit has no coefficient table set" | ||
| 14857 | + ); | ||
| 14858 | + corner_scan(cw, ch); | ||
| 14859 | + checked += 1; | ||
| 14860 | + } | ||
| 14861 | + assert_eq!( | ||
| 14862 | + checked, 12, | ||
| 14863 | + "the block-shape census changed: {checked} rect shapes reach the rect transform \ | ||
| 14864 | + tables, not the 12 this claim was measured over" | ||
| 14865 | + ); | ||
| 14866 | + // `sub_tx_size_map[TX_16X4] == TX_8X4` -- the only RECTANGULAR var-tx leaf | ||
| 14867 | + // shapes, which reach `rect_inter_luma_set` as `(tw, th)`. | ||
| 14868 | + for (w, h) in [(8usize, 4usize), (4, 8)] { | ||
| 14869 | + assert!( | ||
| 14870 | + rect_inter_luma_set(w, h).is_ok(), | ||
| 14871 | + "the {w}x{h} split leaf of a 16x4/4x16 strip has no luma coefficient table set" | ||
| 14872 | + ); | ||
| 14873 | + corner_scan(w, h); | ||
| 14874 | + } | ||
| 14875 | +} | ||
| 14876 | + | ||
| 14803 | /// [`read_block_tx_size`] for a rectangular inter block (lane-inter4 r2): | 14877 | /// [`read_block_tx_size`] for a rectangular inter block (lane-inter4 r2): |
| 14804 | /// spec 5.11.17 / libaom `read_tx_size_vartx` starting from the block's own | 14878 | /// spec 5.11.17 / libaom `read_tx_size_vartx` starting from the block's own |
| 14805 | /// `max_txsize_rect_lookup` entry, which for a 2:1 strip IS rectangular. The | 14879 | /// `max_txsize_rect_lookup` entry, which for a 2:1 strip IS rectangular. The |
crates/ec-av1/src/refusal_inventory.rsmodified+15 -0
| @@ -151,6 +151,21 @@ const PROVEN: &[(&str, &str)] = &[ | |||
| 151 | "an intra 16x4/4x16 strip inside an inter 16x16-level 1:4 partition (its 4:2:0 chroma pair is coded once for two strips; only the inter path implements that pairing)", | 151 | "an intra 16x4/4x16 strip inside an inter 16x16-level 1:4 partition (its 4:2:0 chroma pair is coded once for two strips; only the inter path implements that pairing)", |
| 152 | "a_sub8_footprint_census_over_real_streams_leaves_the_intra_16x4_pairing_refusal_unreachable", | 152 | "a_sub8_footprint_census_over_real_streams_leaves_the_intra_16x4_pairing_refusal_unreachable", |
| 153 | ), | 153 | ), |
| 154 | + // lane-t900 r20, census: the rect transform tables and scans, enumerated | ||
| 155 | + // over the shapes the measured block-shape domain hands each helper (block | ||
| 156 | + // footprint, 4:2:0 chroma unit, rect var-tx leaf, clamped coded corner). | ||
| 157 | + ( | ||
| 158 | + "a rectangular inter luma transform unit whose shape has no coefficient table set here", | ||
| 159 | + "every_rect_transform_shape_the_census_lists_has_a_coefficient_table_and_scan", | ||
| 160 | + ), | ||
| 161 | + ( | ||
| 162 | + "a rectangular inter chroma transform unit whose shape has no coefficient table set here", | ||
| 163 | + "every_rect_transform_shape_the_census_lists_has_a_coefficient_table_and_scan", | ||
| 164 | + ), | ||
| 165 | + ( | ||
| 166 | + "a rectangular transform unit whose shape has no coefficient scan table here", | ||
| 167 | + "every_rect_transform_shape_the_census_lists_has_a_coefficient_table_and_scan", | ||
| 168 | + ), | ||
| 154 | ]; | 169 | ]; |
| 155 | 170 | ||
| 156 | /// Gates whose `Err` arm turns a decode failure into a printed SKIP rather than | 171 | /// Gates whose `Err` arm turns a decode failure into a printed SKIP rather than |