8x4/4x8 INTER var-tx leaves (a split 16x4/4x16 strip) had no table set and panicked
Browse files at this commitc3fc1741d11f584f26667d8c3f0c7e4b00f6168eParent: 4336284- fix
- 8x4/4x8 INTER var-tx leaves (a split 16x4/4x16 strip) had no table set and panicked
- three side-keyed CDF rows on rect blocks
5 changed files +152 -35
- crates/ec-av1/examples/decode_probe.rs +2 -0
- crates/ec-av1/src/cdf_state.rs +41 -0
- crates/ec-av1/src/decode.rs +77 -28
- crates/ec-av1/src/refusal_inventory.rs +3 -0
- crates/ec-av1/src/stream.rs +29 -7
crates/ec-av1/examples/decode_probe.rsmodified+2 -0
| @@ -46,6 +46,8 @@ fn main() { | |||
| 46 | println!("inter16_1to4: horz4={h4} vert4={v4} chroma_pairs={pairs} sub8_pieces={sub8}"); | 46 | println!("inter16_1to4: horz4={h4} vert4={v4} chroma_pairs={pairs} sub8_pieces={sub8}"); |
| 47 | let leaf = ec_av1::stream::vartx_rect_leaf_hits(); | 47 | let leaf = ec_av1::stream::vartx_rect_leaf_hits(); |
| 48 | println!("vartx_rect_leaf: 32x16={} 16x32={}", leaf[0], leaf[1]); | 48 | println!("vartx_rect_leaf: 32x16={} 16x32={}", leaf[0], leaf[1]); |
| 49 | + let leaf4 = ec_av1::stream::vartx_rect_leaf4_hits(); | ||
| 50 | + println!("vartx_rect_leaf4: 8x4={} 4x8={}", leaf4[0], leaf4[1]); | ||
| 49 | let ir = ec_av1::stream::inter_rect_counters(); | 51 | let ir = ec_av1::stream::inter_rect_counters(); |
| 50 | println!( | 52 | println!( |
| 51 | "inter_rect: 32x8={} 8x32={} 64x32={} 32x64={} 64x16={} 16x64={}", | 53 | "inter_rect: 32x8={} 8x32={} 64x32={} 32x64={} 64x16={} 16x64={}", |
crates/ec-av1/src/cdf_state.rsmodified+41 -0
| @@ -243,6 +243,23 @@ pub(crate) enum TxbSet { | |||
| 243 | /// TX_16X16, so `av1_get_ext_tx_set_type` returns `EXT_TX_SET_ALL16` -- | 243 | /// TX_16X16, so `av1_get_ext_tx_set_type` returns `EXT_TX_SET_ALL16` -- |
| 244 | /// sixteen symbols, `inter_tx_type_4_set1`. | 244 | /// sixteen symbols, `inter_tx_type_4_set1`. |
| 245 | LumaRect16x4Inter1, | 245 | LumaRect16x4Inter1, |
| 246 | + /// The luma 8x4/4x8 INTER transform of a `sub_tx_size_map` SPLIT LEAF of | ||
| 247 | + /// a 16x4/4x16 strip (lane-inter16ab r4): `sub_tx_size_map[TX_16X4] == | ||
| 248 | + /// TX_8X4`. Shape = [`LumaRect4x8`](TxbSet::LumaRect4x8)'s -- | ||
| 249 | + /// `get_txsize_entropy_ctx(TX_8X4)` ((`txsize_sqr_map` TX_4X4 + | ||
| 250 | + /// `txsize_sqr_up_map` TX_8X8 + 1) >> 1) resolves to TX_8X8 so every | ||
| 251 | + /// coefficient table is [`Luma8`](TxbSet::Luma8)'s, with the true | ||
| 252 | + /// 32-position `eob_pt` -- but the `tx_type` table is the INTER one at | ||
| 253 | + /// `txsize_sqr_map[TX_8X4]` = TX_4X4. `av1_get_ext_tx_set_type` | ||
| 254 | + /// (`blockd.h:1097`) with `tx_size_sqr_up == TX_8X8` (not > TX_32X32), | ||
| 255 | + /// inter and `use_reduced_set` returns `EXT_TX_SET_DCT_IDTX` -- | ||
| 256 | + /// `inter_tx_type_4`. | ||
| 257 | + LumaRect8x4Inter, | ||
| 258 | + /// [`LumaRect8x4Inter`](TxbSet::LumaRect8x4Inter)'s `reduced_tx_set: | ||
| 259 | + /// false` counterpart: `tx_size_sqr` is TX_4X4, so | ||
| 260 | + /// `av1_get_ext_tx_set_type` returns `EXT_TX_SET_ALL16` -- | ||
| 261 | + /// `inter_tx_type_4_set1`. | ||
| 262 | + LumaRect8x4Inter1, | ||
| 246 | } | 263 | } |
| 247 | 264 | ||
| 248 | /// The tables one transform block is coded with, borrowed from the state for | 265 | /// The tables one transform block is coded with, borrowed from the state for |
| @@ -1901,6 +1918,30 @@ impl Cdfs { | |||
| 1901 | tx_type: Some(self.inter_tx_type_4_set1.as_mut_slice()), | 1918 | tx_type: Some(self.inter_tx_type_4_set1.as_mut_slice()), |
| 1902 | eob_pt_class1: Some(&mut self.eob_pt_64_luma_class1), | 1919 | eob_pt_class1: Some(&mut self.eob_pt_64_luma_class1), |
| 1903 | }, | 1920 | }, |
| 1921 | + TxbSet::LumaRect8x4Inter => TxbTables { | ||
| 1922 | + side: 8, | ||
| 1923 | + txb_skip: &mut self.txb_skip_luma_8, | ||
| 1924 | + eob_pt: &mut self.eob_pt_32_luma, | ||
| 1925 | + eob_extra: &mut self.eob_extra_luma_8, | ||
| 1926 | + base: &mut self.base_luma_8, | ||
| 1927 | + base_eob: &mut self.base_eob_luma_8, | ||
| 1928 | + br: &mut self.br_luma_8, | ||
| 1929 | + dc_sign: &mut self.dc_sign_luma, | ||
| 1930 | + tx_type: Some(self.inter_tx_type_4.as_mut_slice()), | ||
| 1931 | + eob_pt_class1: Some(&mut self.eob_pt_32_luma_class1), | ||
| 1932 | + }, | ||
| 1933 | + TxbSet::LumaRect8x4Inter1 => TxbTables { | ||
| 1934 | + side: 8, | ||
| 1935 | + txb_skip: &mut self.txb_skip_luma_8, | ||
| 1936 | + eob_pt: &mut self.eob_pt_32_luma, | ||
| 1937 | + eob_extra: &mut self.eob_extra_luma_8, | ||
| 1938 | + base: &mut self.base_luma_8, | ||
| 1939 | + base_eob: &mut self.base_eob_luma_8, | ||
| 1940 | + br: &mut self.br_luma_8, | ||
| 1941 | + dc_sign: &mut self.dc_sign_luma, | ||
| 1942 | + tx_type: Some(self.inter_tx_type_4_set1.as_mut_slice()), | ||
| 1943 | + eob_pt_class1: Some(&mut self.eob_pt_32_luma_class1), | ||
| 1944 | + }, | ||
| 1904 | TxbSet::LumaRect16x8Inter => TxbTables { | 1945 | TxbSet::LumaRect16x8Inter => TxbTables { |
| 1905 | side: 16, | 1946 | side: 16, |
| 1906 | txb_skip: &mut self.txb_skip_luma_16, | 1947 | txb_skip: &mut self.txb_skip_luma_16, |
crates/ec-av1/src/decode.rsmodified+77 -28
| @@ -999,6 +999,9 @@ thread_local! { | |||
| 999 | static RECT64_INTER_TU_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | 999 | static RECT64_INTER_TU_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; |
| 1000 | // lane-r14 r3: rectangular var-tx LEAVES, [32x16, 16x32]. | 1000 | // lane-r14 r3: rectangular var-tx LEAVES, [32x16, 16x32]. |
| 1001 | static VARTX_RECT_LEAF_HITS: std::cell::Cell<[usize; 2]> = const { std::cell::Cell::new([0; 2]) }; | 1001 | static VARTX_RECT_LEAF_HITS: std::cell::Cell<[usize; 2]> = const { std::cell::Cell::new([0; 2]) }; |
| 1002 | + // lane-inter16ab r4: rectangular var-tx leaves with a 4-px axis, [8x4, 4x8] | ||
| 1003 | + // -- the `sub_tx_size_map[TX_16X4]` split leaves of a 16x16-level 1:4 strip. | ||
| 1004 | + static VARTX_RECT_LEAF4_HITS: std::cell::Cell<[usize; 2]> = const { std::cell::Cell::new([0; 2]) }; | ||
| 1002 | // lane-inter4 r3: 16x16-level PARTITION_HORZ / PARTITION_VERT on an inter | 1005 | // lane-inter4 r3: 16x16-level PARTITION_HORZ / PARTITION_VERT on an inter |
| 1003 | // frame -- 16x8 and 8x16 inter leaves. | 1006 | // frame -- 16x8 and 8x16 inter leaves. |
| 1004 | static INTER_LEAF16_HORZ_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | 1007 | static INTER_LEAF16_HORZ_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; |
| @@ -1057,9 +1060,16 @@ pub(crate) fn vartx_rect_leaf_hits() -> [usize; 2] { | |||
| 1057 | VARTX_RECT_LEAF_HITS.with(|c| c.get()) | 1060 | VARTX_RECT_LEAF_HITS.with(|c| c.get()) |
| 1058 | } | 1061 | } |
| 1059 | 1062 | ||
| 1063 | +/// Current value of [`VARTX_RECT_LEAF4_HITS`] (lane-inter16ab r4): 8x4/4x8 | ||
| 1064 | +/// split leaves of a 16x4/4x16 strip, `[8x4, 4x8]`. | ||
| 1065 | +pub(crate) fn vartx_rect_leaf4_hits() -> [usize; 2] { | ||
| 1066 | + VARTX_RECT_LEAF4_HITS.with(|c| c.get()) | ||
| 1067 | +} | ||
| 1068 | + | ||
| 1060 | /// Records one rectangular var-tx leaf. | 1069 | /// Records one rectangular var-tx leaf. |
| 1061 | fn vartx_rect_leaf_hit(tw: usize, th: usize) { | 1070 | fn vartx_rect_leaf_hit(tw: usize, th: usize) { |
| 1062 | - VARTX_RECT_LEAF_HITS.with(|c| { | 1071 | + let cell = if tw.min(th) == 4 { &VARTX_RECT_LEAF4_HITS } else { &VARTX_RECT_LEAF_HITS }; |
| 1072 | + cell.with(|c| { | ||
| 1063 | let mut h = c.get(); | 1073 | let mut h = c.get(); |
| 1064 | h[usize::from(th > tw)] += 1; | 1074 | h[usize::from(th > tw)] += 1; |
| 1065 | c.set(h); | 1075 | c.set(h); |
| @@ -11761,6 +11771,11 @@ fn rect_inter_residual_supported(w: usize, h: usize) -> bool { | |||
| 11761 | // `TX_64X64`, so `av1_get_ext_tx_set_type` is `DCT_ONLY` and no | 11771 | // `TX_64X64`, so `av1_get_ext_tx_set_type` is `DCT_ONLY` and no |
| 11762 | // `tx_type` symbol is coded at all. | 11772 | // `tx_type` symbol is coded at all. |
| 11763 | | (64, 32) | (32, 64) | (64, 16) | (16, 64) | 11773 | | (64, 32) | (32, 64) | (64, 16) | (16, 64) |
| 11774 | + // lane-inter16ab r4: `sub_tx_size_map[TX_16X4] == TX_8X4`, so a | ||
| 11775 | + // split-transform 16x4/4x16 strip has RECTANGULAR 8x4/4x8 leaves. | ||
| 11776 | + // Only reachable as a var-tx LEAF -- an 8x4/4x8 inter BLOCK is | ||
| 11777 | + // refused earlier ("an inter partition below 8x8"). | ||
| 11778 | + | (8, 4) | (4, 8) | ||
| 11764 | ) | 11779 | ) |
| 11765 | } | 11780 | } |
| 11766 | 11781 | ||
| @@ -11772,9 +11787,20 @@ fn rect_inter_residual_supported(w: usize, h: usize) -> bool { | |||
| 11772 | /// `tx_size_sqr == TX_8X8`, so it reads `EXT_TX_SET_DCT_IDTX` when reduced | 11787 | /// `tx_size_sqr == TX_8X8`, so it reads `EXT_TX_SET_DCT_IDTX` when reduced |
| 11773 | /// and the 16-symbol `EXT_TX_SET_ALL16` otherwise -- both at the *8x8* CDF | 11788 | /// and the 16-symbol `EXT_TX_SET_ALL16` otherwise -- both at the *8x8* CDF |
| 11774 | /// row (`txsize_sqr_map`), never the 16x16 one. | 11789 | /// row (`txsize_sqr_map`), never the 16x16 one. |
| 11775 | -fn rect_inter_luma_set(w: usize, h: usize) -> TxbSet { | 11790 | +fn rect_inter_luma_set(w: usize, h: usize) -> Result<TxbSet> { |
| 11776 | - match (w, h) { | 11791 | + Ok(match (w, h) { |
| 11777 | (32, 16) | (16, 32) => TxbSet::LumaRect32x16Inter, | 11792 | (32, 16) | (16, 32) => TxbSet::LumaRect32x16Inter, |
| 11793 | + // lane-inter16ab r4: the 8x4/4x8 split leaf of a 16x4/4x16 strip. | ||
| 11794 | + // `av1_get_ext_tx_set_type` (blockd.h:1097) at `tx_size_sqr_up == | ||
| 11795 | + // TX_8X8`, `tx_size_sqr == TX_4X4`, inter: DCT_IDTX when reduced, | ||
| 11796 | + // ALL16 otherwise -- both at the TX_4X4 row. | ||
| 11797 | + (8, 4) | (4, 8) => { | ||
| 11798 | + if REDUCED_TX_SET_INTER.with(std::cell::Cell::get) { | ||
| 11799 | + TxbSet::LumaRect8x4Inter | ||
| 11800 | + } else { | ||
| 11801 | + TxbSet::LumaRect8x4Inter1 | ||
| 11802 | + } | ||
| 11803 | + } | ||
| 11778 | (16, 4) | (4, 16) => { | 11804 | (16, 4) | (4, 16) => { |
| 11779 | if REDUCED_TX_SET_INTER.with(std::cell::Cell::get) { | 11805 | if REDUCED_TX_SET_INTER.with(std::cell::Cell::get) { |
| 11780 | TxbSet::LumaRect16x4Inter | 11806 | TxbSet::LumaRect16x4Inter |
| @@ -11796,16 +11822,20 @@ fn rect_inter_luma_set(w: usize, h: usize) -> TxbSet { | |||
| 11796 | // `tx_type` table (DCT_ONLY above), so the intra/inter split is moot. | 11822 | // `tx_type` table (DCT_ONLY above), so the intra/inter split is moot. |
| 11797 | (64, 32) | (32, 64) => TxbSet::Luma64, | 11823 | (64, 32) | (32, 64) => TxbSet::Luma64, |
| 11798 | (64, 16) | (16, 64) => TxbSet::LumaRect32x16, | 11824 | (64, 16) | (16, 64) => TxbSet::LumaRect32x16, |
| 11799 | - _ => unreachable!("rect_inter_residual_supported gates every shape that reaches here"), | 11825 | + _ => { |
| 11800 | - } | 11826 | + return Err(unsupported( |
| 11827 | + "a rectangular inter luma transform unit whose shape has no coefficient table set here", | ||
| 11828 | + )); | ||
| 11829 | + } | ||
| 11830 | + }) | ||
| 11801 | } | 11831 | } |
| 11802 | 11832 | ||
| 11803 | /// The chroma table set of the same block's single rectangular chroma unit | 11833 | /// The chroma table set of the same block's single rectangular chroma unit |
| 11804 | /// (`av1_get_max_uv_txsize`): 16x8/8x16 under a 32x16/16x32 strip, 8x4/4x8 | 11834 | /// (`av1_get_max_uv_txsize`): 16x8/8x16 under a 32x16/16x32 strip, 8x4/4x8 |
| 11805 | /// under a 16x8/8x16 one. Neither codes a `tx_type` symbol -- both inherit | 11835 | /// under a 16x8/8x16 one. Neither codes a `tx_type` symbol -- both inherit |
| 11806 | /// the luma unit's. | 11836 | /// the luma unit's. |
| 11807 | -fn rect_inter_chroma_set(w: usize, h: usize) -> TxbSet { | 11837 | +fn rect_inter_chroma_set(w: usize, h: usize) -> Result<TxbSet> { |
| 11808 | - match (w, h) { | 11838 | + Ok(match (w, h) { |
| 11809 | (16, 8) | (8, 16) => TxbSet::ChromaRect16x8, | 11839 | (16, 8) | (8, 16) => TxbSet::ChromaRect16x8, |
| 11810 | (8, 4) | (4, 8) => TxbSet::ChromaRect8x4, | 11840 | (8, 4) | (4, 8) => TxbSet::ChromaRect8x4, |
| 11811 | // lane-r14 r2: chroma of a 64-axis strip -- 32x16/16x32 under a | 11841 | // lane-r14 r2: chroma of a 64-axis strip -- 32x16/16x32 under a |
| @@ -11815,8 +11845,12 @@ fn rect_inter_chroma_set(w: usize, h: usize) -> TxbSet { | |||
| 11815 | // `txsize_log2_minus4` = 4), same as the intra strip path uses. | 11845 | // `txsize_log2_minus4` = 4), same as the intra strip path uses. |
| 11816 | (32, 16) | (16, 32) => TxbSet::ChromaRect32x16, | 11846 | (32, 16) | (16, 32) => TxbSet::ChromaRect32x16, |
| 11817 | (32, 8) | (8, 32) => TxbSet::Chroma16, | 11847 | (32, 8) | (8, 32) => TxbSet::Chroma16, |
| 11818 | - _ => unreachable!("rect_inter_residual_supported gates every shape that reaches here"), | 11848 | + _ => { |
| 11819 | - } | 11849 | + return Err(unsupported( |
| 11850 | + "a rectangular inter chroma transform unit whose shape has no coefficient table set here", | ||
| 11851 | + )); | ||
| 11852 | + } | ||
| 11853 | + }) | ||
| 11820 | } | 11854 | } |
| 11821 | 11855 | ||
| 11822 | /// libaom `size_group_lookup[bsize]` for the block shapes this decoder's | 11856 | /// libaom `size_group_lookup[bsize]` for the block shapes this decoder's |
| @@ -11852,8 +11886,8 @@ fn size_group_wh_matches_libaom_size_group_lookup() { | |||
| 11852 | } | 11886 | } |
| 11853 | 11887 | ||
| 11854 | /// The default (2D) coefficient scan of a rectangular transform. | 11888 | /// The default (2D) coefficient scan of a rectangular transform. |
| 11855 | -fn rect_scan(w: usize, h: usize) -> &'static [u16] { | 11889 | +fn rect_scan(w: usize, h: usize) -> Result<&'static [u16]> { |
| 11856 | - match (w, h) { | 11890 | + Ok(match (w, h) { |
| 11857 | (32, 16) => &SCAN_32X16, | 11891 | (32, 16) => &SCAN_32X16, |
| 11858 | (16, 32) => &SCAN_16X32, | 11892 | (16, 32) => &SCAN_16X32, |
| 11859 | (16, 8) => &SCAN_16X8, | 11893 | (16, 8) => &SCAN_16X8, |
| @@ -11864,8 +11898,12 @@ fn rect_scan(w: usize, h: usize) -> &'static [u16] { | |||
| 11864 | (4, 8) => &SCAN_4X8, | 11898 | (4, 8) => &SCAN_4X8, |
| 11865 | (32, 8) => &SCAN_32X8, | 11899 | (32, 8) => &SCAN_32X8, |
| 11866 | (8, 32) => &SCAN_8X32, | 11900 | (8, 32) => &SCAN_8X32, |
| 11867 | - _ => unreachable!("rect_inter_residual_supported gates every shape that reaches here"), | 11901 | + _ => { |
| 11868 | - } | 11902 | + return Err(unsupported( |
| 11903 | + "a rectangular transform unit whose shape has no coefficient scan table here", | ||
| 11904 | + )); | ||
| 11905 | + } | ||
| 11906 | + }) | ||
| 11869 | } | 11907 | } |
| 11870 | 11908 | ||
| 11871 | /// [`read_block_tx_size`] for a rectangular inter block (lane-inter4 r2): | 11909 | /// [`read_block_tx_size`] for a rectangular inter block (lane-inter4 r2): |
| @@ -12027,7 +12065,7 @@ fn read_inter_plane_rect( | |||
| 12027 | read_coeffs_rect( | 12065 | read_coeffs_rect( |
| 12028 | dec, | 12066 | dec, |
| 12029 | &mut coding, | 12067 | &mut coding, |
| 12030 | - rect_scan(cw, ch), | 12068 | + rect_scan(cw, ch)?, |
| 12031 | cw, | 12069 | cw, |
| 12032 | ch, | 12070 | ch, |
| 12033 | skip_ctx, | 12071 | skip_ctx, |
| @@ -16047,8 +16085,13 @@ fn obmc_blend( | |||
| 16047 | /// always `is_interinter_compound_used`, so the function is always `true` | 16085 | /// always `is_interinter_compound_used`, so the function is always `true` |
| 16048 | /// for `side` -- kept as a named call (rather than inlined `true`) so a | 16086 | /// for `side` -- kept as a named call (rather than inlined `true`) so a |
| 16049 | /// future sub-8 block size does not silently misdecode a real stream. | 16087 | /// future sub-8 block size does not silently misdecode a real stream. |
| 16050 | -fn is_any_masked_compound_used_here(side: usize) -> bool { | 16088 | +fn is_any_masked_compound_used_here(bw: usize, bh: usize) -> bool { |
| 16051 | - side.min(side) >= 8 | 16089 | + // lane-inter16ab r4 (class sweep of the r3 CDF-row defect): |
| 16090 | + // `is_comp_ref_allowed(bsize)` is `AOMMIN(block_size_wide, block_size_high) | ||
| 16091 | + // >= 8` on the block's TRUE footprint -- a 16x4/4x16 strip is NOT allowed, | ||
| 16092 | + // so libaom writes no `comp_group_idx` symbol there at all. Keyed off the | ||
| 16093 | + // square `side` we read one the reference never wrote. | ||
| 16094 | + bw.min(bh) >= 8 | ||
| 16052 | } | 16095 | } |
| 16053 | 16096 | ||
| 16054 | /// The `BLOCK_SIZES_ALL` index of a `bw x bh` block (libaom `enum BLOCK_SIZE`, | 16097 | /// The `BLOCK_SIZES_ALL` index of a `bw x bh` block (libaom `enum BLOCK_SIZE`, |
| @@ -16916,7 +16959,7 @@ fn decode_inter_block( | |||
| 16916 | let group_ctx = get_comp_group_idx_context(neighbours, (rmi, cmi), side); | 16959 | let group_ctx = get_comp_group_idx_context(neighbours, (rmi, cmi), side); |
| 16917 | let comp_group_idx = if !skip_mode | 16960 | let comp_group_idx = if !skip_mode |
| 16918 | && enable_masked_compound | 16961 | && enable_masked_compound |
| 16919 | - && is_any_masked_compound_used_here(side) | 16962 | + && is_any_masked_compound_used_here(write_w, write_h) |
| 16920 | { | 16963 | { |
| 16921 | dec.symbol(&mut cdfs.comp_group_idx[group_ctx]) | 16964 | dec.symbol(&mut cdfs.comp_group_idx[group_ctx]) |
| 16922 | } else { | 16965 | } else { |
| @@ -17588,7 +17631,7 @@ fn decode_inter_block( | |||
| 17588 | read_inter_plane_rect( | 17631 | read_inter_plane_rect( |
| 17589 | dec, | 17632 | dec, |
| 17590 | cdfs, | 17633 | cdfs, |
| 17591 | - rect_inter_luma_set(tw, th), | 17634 | + rect_inter_luma_set(tw, th)?, |
| 17592 | (tw, th), | 17635 | (tw, th), |
| 17593 | side, | 17636 | side, |
| 17594 | 0, | 17637 | 0, |
| @@ -17618,7 +17661,7 @@ fn decode_inter_block( | |||
| 17618 | let (grid, tx_type) = read_inter_plane_rect( | 17661 | let (grid, tx_type) = read_inter_plane_rect( |
| 17619 | dec, | 17662 | dec, |
| 17620 | cdfs, | 17663 | cdfs, |
| 17621 | - rect_inter_luma_set(write_w, write_h), | 17664 | + rect_inter_luma_set(write_w, write_h)?, |
| 17622 | (write_w, write_h), | 17665 | (write_w, write_h), |
| 17623 | side, | 17666 | side, |
| 17624 | 0, | 17667 | 0, |
| @@ -17662,7 +17705,7 @@ fn decode_inter_block( | |||
| 17662 | &read_inter_plane_rect( | 17705 | &read_inter_plane_rect( |
| 17663 | dec, | 17706 | dec, |
| 17664 | cdfs, | 17707 | cdfs, |
| 17665 | - rect_inter_chroma_set(write_chroma_w, write_chroma_h), | 17708 | + rect_inter_chroma_set(write_chroma_w, write_chroma_h)?, |
| 17666 | (uw, uh), | 17709 | (uw, uh), |
| 17667 | chroma_side, | 17710 | chroma_side, |
| 17668 | 1, | 17711 | 1, |
| @@ -17684,7 +17727,7 @@ fn decode_inter_block( | |||
| 17684 | &read_inter_plane_rect( | 17727 | &read_inter_plane_rect( |
| 17685 | dec, | 17728 | dec, |
| 17686 | cdfs, | 17729 | cdfs, |
| 17687 | - rect_inter_chroma_set(write_chroma_w, write_chroma_h), | 17730 | + rect_inter_chroma_set(write_chroma_w, write_chroma_h)?, |
| 17688 | (uw, uh), | 17731 | (uw, uh), |
| 17689 | chroma_side, | 17732 | chroma_side, |
| 17690 | 2, | 17733 | 2, |
| @@ -18673,7 +18716,7 @@ fn decode_inter_block( | |||
| 18673 | read_inter_plane_rect( | 18716 | read_inter_plane_rect( |
| 18674 | dec, | 18717 | dec, |
| 18675 | cdfs, | 18718 | cdfs, |
| 18676 | - rect_inter_luma_set(tw, th), | 18719 | + rect_inter_luma_set(tw, th)?, |
| 18677 | (tw, th), | 18720 | (tw, th), |
| 18678 | side, | 18721 | side, |
| 18679 | 0, | 18722 | 0, |
| @@ -18703,7 +18746,7 @@ fn decode_inter_block( | |||
| 18703 | let (grid, tx_type) = read_inter_plane_rect( | 18746 | let (grid, tx_type) = read_inter_plane_rect( |
| 18704 | dec, | 18747 | dec, |
| 18705 | cdfs, | 18748 | cdfs, |
| 18706 | - rect_inter_luma_set(write_w, write_h), | 18749 | + rect_inter_luma_set(write_w, write_h)?, |
| 18707 | (write_w, write_h), | 18750 | (write_w, write_h), |
| 18708 | side, | 18751 | side, |
| 18709 | 0, | 18752 | 0, |
| @@ -18756,7 +18799,7 @@ fn decode_inter_block( | |||
| 18756 | &read_inter_plane_rect( | 18799 | &read_inter_plane_rect( |
| 18757 | dec, | 18800 | dec, |
| 18758 | cdfs, | 18801 | cdfs, |
| 18759 | - rect_inter_chroma_set(write_chroma_w, write_chroma_h), | 18802 | + rect_inter_chroma_set(write_chroma_w, write_chroma_h)?, |
| 18760 | (uw, uh), | 18803 | (uw, uh), |
| 18761 | chroma_side, | 18804 | chroma_side, |
| 18762 | 1, | 18805 | 1, |
| @@ -18778,7 +18821,7 @@ fn decode_inter_block( | |||
| 18778 | &read_inter_plane_rect( | 18821 | &read_inter_plane_rect( |
| 18779 | dec, | 18822 | dec, |
| 18780 | cdfs, | 18823 | cdfs, |
| 18781 | - rect_inter_chroma_set(write_chroma_w, write_chroma_h), | 18824 | + rect_inter_chroma_set(write_chroma_w, write_chroma_h)?, |
| 18782 | (uw, uh), | 18825 | (uw, uh), |
| 18783 | chroma_side, | 18826 | chroma_side, |
| 18784 | 2, | 18827 | 2, |
| @@ -18983,8 +19026,12 @@ fn decode_inter_block( | |||
| 18983 | // -- `palette_mode_ctx`/`palette_uv_mode_ctx` hardcoded 0, provably | 19026 | // -- `palette_mode_ctx`/`palette_uv_mode_ctx` hardcoded 0, provably |
| 18984 | // safe since a nonzero neighbour `palette_size` would already have | 19027 | // safe since a nonzero neighbour `palette_size` would already have |
| 18985 | // refused the decode that produced it. | 19028 | // refused the decode that produced it. |
| 19029 | + // lane-inter16ab r4 (class sweep): `av1_get_palette_bsize_ctx` is keyed | ||
| 19030 | + // by the block's TRUE footprint -- a rect strip's row is not its | ||
| 19031 | + // enclosing square's, and a 16x4 strip (64 pixels) reads no palette | ||
| 19032 | + // symbol at all. | ||
| 18986 | if allow_screen_content_tools | 19033 | if allow_screen_content_tools |
| 18987 | - && let Some(bsize_ctx) = palette_bsize_ctx(side) | 19034 | + && let Some(bsize_ctx) = palette_bsize_ctx_wh(write_w, write_h) |
| 18988 | { | 19035 | { |
| 18989 | if mode == DC_PRED && dec.symbol(&mut cdfs.palette_y_mode[bsize_ctx][0]) != 0 { | 19036 | if mode == DC_PRED && dec.symbol(&mut cdfs.palette_y_mode[bsize_ctx][0]) != 0 { |
| 18990 | return Err(unsupported( | 19037 | return Err(unsupported( |
| @@ -19008,7 +19055,9 @@ fn decode_inter_block( | |||
| 19008 | let mut filter_intra = None; | 19055 | let mut filter_intra = None; |
| 19009 | if mode == DC_PRED | 19056 | if mode == DC_PRED |
| 19010 | && ENABLE_FILTER_INTRA_INTER.with(std::cell::Cell::get) | 19057 | && ENABLE_FILTER_INTRA_INTER.with(std::cell::Cell::get) |
| 19011 | - && let Some(class) = filter_intra_size_class(side) | 19058 | + // lane-inter16ab r4 (class sweep): `cdf::FILTER_INTRA`'s row is the |
| 19059 | + // true `BLOCK_SIZES_ALL` class of this strip, not its square side's. | ||
| 19060 | + && let Some(class) = filter_intra_size_class_rect(write_w, write_h) | ||
| 19012 | && dec.symbol(&mut cdfs.filter_intra[class]) != 0 | 19061 | && dec.symbol(&mut cdfs.filter_intra[class]) != 0 |
| 19013 | { | 19062 | { |
| 19014 | FILTER_INTRA_HITS.with(|c| c.set(c.get() + 1)); | 19063 | FILTER_INTRA_HITS.with(|c| c.set(c.get() + 1)); |
| @@ -19705,7 +19754,7 @@ fn decode_inter_block8( | |||
| 19705 | let group_ctx = get_comp_group_idx_context(neighbours, leaf_mi, SIDE); | 19754 | let group_ctx = get_comp_group_idx_context(neighbours, leaf_mi, SIDE); |
| 19706 | let comp_group_idx = if !skip_mode | 19755 | let comp_group_idx = if !skip_mode |
| 19707 | && enable_masked_compound | 19756 | && enable_masked_compound |
| 19708 | - && is_any_masked_compound_used_here(SIDE) | 19757 | + && is_any_masked_compound_used_here(SIDE, SIDE) |
| 19709 | { | 19758 | { |
| 19710 | dec.symbol(&mut cdfs.comp_group_idx[group_ctx]) | 19759 | dec.symbol(&mut cdfs.comp_group_idx[group_ctx]) |
| 19711 | } else { | 19760 | } else { |
crates/ec-av1/src/refusal_inventory.rsmodified+3 -0
| @@ -34,6 +34,9 @@ const REFUSALS: &[&str] = &[ | |||
| 34 | "a coded HORZ/VERT strip whose chroma transform has no rect coefficient tables here", | 34 | "a coded HORZ/VERT strip whose chroma transform has no rect coefficient tables here", |
| 35 | "a split intra strip whose transform unit is {tx_w}x{tx_h} (no luma coefficient tables for that shape here)", | 35 | "a split intra strip whose transform unit is {tx_w}x{tx_h} (no luma coefficient tables for that shape here)", |
| 36 | "an inter partition below 8x8 (this decoder codes no inter leaf smaller than 8x8; lane-sub8 scoped to intra)", | 36 | "an inter partition below 8x8 (this decoder codes no inter leaf smaller than 8x8; lane-sub8 scoped to intra)", |
| 37 | + "a rectangular inter luma transform unit whose shape has no coefficient table set here", | ||
| 38 | + "a rectangular inter chroma transform unit whose shape has no coefficient table set here", | ||
| 39 | + "a rectangular transform unit whose shape has no coefficient scan table here", | ||
| 37 | "a 1:4 rect strip that actually uses a palette (reconstruction is not ported at this shape)", | 40 | "a 1:4 rect strip that actually uses a palette (reconstruction is not ported at this shape)", |
| 38 | "a 16x16 block whose true edge cuts through both axes needs a rectangular transform this decoder does not code yet", | 41 | "a 16x16 block whose true edge cuts through both axes needs a rectangular transform this decoder does not code yet", |
| 39 | "a 16x16 inter block whose true edge cuts through both axes needs a rectangular transform this decoder does not code yet", | 42 | "a 16x16 inter block whose true edge cuts through both axes needs a rectangular transform this decoder does not code yet", |
crates/ec-av1/src/stream.rsmodified+29 -7
| @@ -81,6 +81,13 @@ pub fn vartx_rect_leaf_hits() -> [usize; 2] { | |||
| 81 | crate::decode::vartx_rect_leaf_hits() | 81 | crate::decode::vartx_rect_leaf_hits() |
| 82 | } | 82 | } |
| 83 | 83 | ||
| 84 | +/// lane-inter16ab r4: RECTANGULAR var-tx leaves with a 4-px axis, `[8x4, 4x8]` | ||
| 85 | +/// -- what `sub_tx_size_map[TX_16X4] == TX_8X4` produces when a 16x16-level | ||
| 86 | +/// 1:4 inter strip splits its transform. | ||
| 87 | +pub fn vartx_rect_leaf4_hits() -> [usize; 2] { | ||
| 88 | + crate::decode::vartx_rect_leaf4_hits() | ||
| 89 | +} | ||
| 90 | + | ||
| 84 | pub fn rect4_32_counters() -> (usize, usize, usize) { | 91 | pub fn rect4_32_counters() -> (usize, usize, usize) { |
| 85 | ( | 92 | ( |
| 86 | crate::decode::rect4_32_horz_hits(), | 93 | crate::decode::rect4_32_horz_hits(), |
| @@ -8025,11 +8032,18 @@ mod tests { | |||
| 8025 | let (width, height, frame_count) = (192usize, 128usize, 6usize); | 8032 | let (width, height, frame_count) = (192usize, 128usize, 6usize); |
| 8026 | // Per arm, over both bit depths: how many pixel-exact attempts fired | 8033 | // Per arm, over both bit depths: how many pixel-exact attempts fired |
| 8027 | // it at least once. | 8034 | // it at least once. |
| 8028 | - let mut arms_total = [0u32; 4]; | 8035 | + let mut arms_total = [0u32; 5]; |
| 8029 | for bit_depth in [8u32, 10u32] { | 8036 | for bit_depth in [8u32, 10u32] { |
| 8030 | let (mut named_refusals, mut matched, mut out_of_scope, mut oos_mismatch) = | 8037 | let (mut named_refusals, mut matched, mut out_of_scope, mut oos_mismatch) = |
| 8031 | (0u32, 0u32, 0u32, 0u32); | 8038 | (0u32, 0u32, 0u32, 0u32); |
| 8032 | - let mut arms_proved = [0u32; 4]; | 8039 | + let mut arms_proved = [0u32; 5]; |
| 8040 | + // lane-inter16ab r4: a 4-recipe widening (fine `sin(X/3)` stripes | ||
| 8041 | + // at cq 8..14, both depths) was measured and REMOVED again -- every | ||
| 8042 | + // extra 1:4 partition it produced is in the KEY frame, and this | ||
| 8043 | + // gate's arms count INTER-frame strips. Frame-aware histogram | ||
| 8044 | + // script + table in lanes/inter16ab-r4.report.md; the only recipe | ||
| 8045 | + // in the whole sweep with an inter-frame `PARTITION_VERT_4` is | ||
| 8046 | + // attempt 1's, which refuses on the rect wedge-interintra mask. | ||
| 8033 | for attempt in 0..32u32 { | 8047 | for attempt in 0..32u32 { |
| 8034 | // Two sources (structure along X vs along Y -- an AB | 8048 | // Two sources (structure along X vs along Y -- an AB |
| 8035 | // partition needs an L/T-shaped feature, so both orientations | 8049 | // partition needs an L/T-shaped feature, so both orientations |
| @@ -8136,6 +8150,7 @@ mod tests { | |||
| 8136 | ); | 8150 | ); |
| 8137 | let stream = out.stdout; | 8151 | let stream = out.stdout; |
| 8138 | let before = decode::inter16_rect4_counters(); | 8152 | let before = decode::inter16_rect4_counters(); |
| 8153 | + let leaf4_before = crate::stream::vartx_rect_leaf4_hits(); | ||
| 8139 | let frames = match decode_stream(&stream) { | 8154 | let frames = match decode_stream(&stream) { |
| 8140 | Err(e) => { | 8155 | Err(e) => { |
| 8141 | let msg = e.to_string(); | 8156 | let msg = e.to_string(); |
| @@ -8151,6 +8166,7 @@ mod tests { | |||
| 8151 | Ok(frames) => frames, | 8166 | Ok(frames) => frames, |
| 8152 | }; | 8167 | }; |
| 8153 | let after = decode::inter16_rect4_counters(); | 8168 | let after = decode::inter16_rect4_counters(); |
| 8169 | + let leaf4_after = crate::stream::vartx_rect_leaf4_hits(); | ||
| 8154 | // [16x4 strips, 4x16 strips, chroma pairs closed, chroma | 8170 | // [16x4 strips, 4x16 strips, chroma pairs closed, chroma |
| 8155 | // pairs built from two strips' motion vectors]. | 8171 | // pairs built from two strips' motion vectors]. |
| 8156 | let fired = [ | 8172 | let fired = [ |
| @@ -8158,6 +8174,11 @@ mod tests { | |||
| 8158 | after.1 - before.1, | 8174 | after.1 - before.1, |
| 8159 | after.2 - before.2, | 8175 | after.2 - before.2, |
| 8160 | after.3 - before.3, | 8176 | after.3 - before.3, |
| 8177 | + // lane-inter16ab r4: the SPLIT-transform arm -- | ||
| 8178 | + // `sub_tx_size_map[TX_16X4] == TX_8X4`, so a 1:4 strip | ||
| 8179 | + // that splits its transform codes 8x4/4x8 RECTANGULAR | ||
| 8180 | + // var-tx leaves (`--enable-tx-size-search=1`). | ||
| 8181 | + (leaf4_after[0] - leaf4_before[0]) + (leaf4_after[1] - leaf4_before[1]), | ||
| 8161 | ]; | 8182 | ]; |
| 8162 | let ffmpeg_frames = if bit_depth == 10 { | 8183 | let ffmpeg_frames = if bit_depth == 10 { |
| 8163 | ffmpeg_decode_sequence_10bit(&stream, width, height, frame_count) | 8184 | ffmpeg_decode_sequence_10bit(&stream, width, height, frame_count) |
| @@ -8204,7 +8225,7 @@ mod tests { | |||
| 8204 | assert_eq!(got.u, want.u, "{NAME} frame {i} U vs ffmpeg (attempt {attempt}, {bit_depth}-bit, arms {fired:?})"); | 8225 | assert_eq!(got.u, want.u, "{NAME} frame {i} U vs ffmpeg (attempt {attempt}, {bit_depth}-bit, arms {fired:?})"); |
| 8205 | assert_eq!(got.v, want.v, "{NAME} frame {i} V vs ffmpeg (attempt {attempt}, {bit_depth}-bit, arms {fired:?})"); | 8226 | assert_eq!(got.v, want.v, "{NAME} frame {i} V vs ffmpeg (attempt {attempt}, {bit_depth}-bit, arms {fired:?})"); |
| 8206 | } | 8227 | } |
| 8207 | - for a in 0..4 { | 8228 | + for a in 0..5 { |
| 8208 | if fired[a] > 0 { | 8229 | if fired[a] > 0 { |
| 8209 | arms_proved[a] += 1; | 8230 | arms_proved[a] += 1; |
| 8210 | arms_total[a] += 1; | 8231 | arms_total[a] += 1; |
| @@ -8215,7 +8236,7 @@ mod tests { | |||
| 8215 | eprintln!( | 8236 | eprintln!( |
| 8216 | "{NAME} ({bit_depth}-bit): {named_refusals} named refusals, {matched} pixel-exact \ | 8237 | "{NAME} ({bit_depth}-bit): {named_refusals} named refusals, {matched} pixel-exact \ |
| 8217 | attempts carrying a 16-level inter 1:4 partition, per-arm attempts \ | 8238 | attempts carrying a 16-level inter 1:4 partition, per-arm attempts \ |
| 8218 | - HORZ_4/VERT_4/chroma-pair/sub8x8-chroma={arms_proved:?}, {out_of_scope} attempts carried \ | 8239 | + HORZ_4/VERT_4/chroma-pair/sub8x8-chroma/split-tx-8x4={arms_proved:?}, {out_of_scope} attempts carried \ |
| 8219 | none ({oos_mismatch} of them mismatched)" | 8240 | none ({oos_mismatch} of them mismatched)" |
| 8220 | ); | 8241 | ); |
| 8221 | assert_eq!( | 8242 | assert_eq!( |
| @@ -8227,9 +8248,10 @@ mod tests { | |||
| 8227 | assert!( | 8248 | assert!( |
| 8228 | arms_total.iter().all(|&n| n > 0), | 8249 | arms_total.iter().all(|&n| n > 0), |
| 8229 | "{NAME}: a 16-level inter 1:4 arm never fired on a pixel-exact attempt \ | 8250 | "{NAME}: a 16-level inter 1:4 arm never fired on a pixel-exact attempt \ |
| 8230 | - (HORZ_4/VERT_4/chroma-pairs/sub8x8-chroma-pairs={arms_total:?}) -- an arm at 0 is \ | 8251 | + (HORZ_4/VERT_4/chroma-pairs/sub8x8-chroma-pairs/split-tx-8x4={arms_total:?}) -- an \ |
| 8231 | - unproven; the last two are the odd-strip `is_chroma_reference` pair and the \ | 8252 | + arm at 0 is unproven; arms 3/4 are the odd-strip `is_chroma_reference` pair and the \ |
| 8232 | - `build_inter_predictors_sub8x8` two-mv chroma build" | 8253 | + `build_inter_predictors_sub8x8` two-mv chroma build, arm 5 the \ |
| 8254 | + `sub_tx_size_map[TX_16X4] == TX_8X4` split-transform leaf" | ||
| 8233 | ); | 8255 | ); |
| 8234 | } | 8256 | } |
| 8235 | 8257 | ||