merge: main 18bf7dc into lane-intra14 -- inter rect residual (lane-r14) + 128 superblocks (lane-sb128)
Browse files at this commit14 changed files +2552 -176
- crates/ec-av1/examples/decode_probe.rs +12 -0
- crates/ec-av1/src/cdf.rs +18 -1
- crates/ec-av1/src/cdf_state.rs +45 -1
- crates/ec-av1/src/decode.rs +944 -91
- crates/ec-av1/src/encode.rs +32 -15
- crates/ec-av1/src/mvstack.rs +96 -18
- crates/ec-av1/src/refusal_inventory.rs +6 -2
- crates/ec-av1/src/stream.rs +742 -48
- lanes/r14-r1.report.md +119 -0
- lanes/r14-r2.report.md +97 -0
- lanes/sb128-r1.report.md +88 -0
- lanes/sb128-r2.report.md +123 -0
- lanes/sb128-r3.handoff.md +94 -0
- lanes/sb128-r4.report.md +136 -0
crates/ec-av1/examples/decode_probe.rsmodified+12 -0
| @@ -71,6 +71,18 @@ fn main() { | |||
| 71 | } | 71 | } |
| 72 | } | 72 | } |
| 73 | println!("TILING: {frames_seen} frame headers parsed"); | 73 | println!("TILING: {frames_seen} frame headers parsed"); |
| 74 | + // lane-sb128 r4: the superblock size decides the whole partition tree, so | ||
| 75 | + // report it next to the tiling -- it is the first thing a film blocker | ||
| 76 | + // triage needs. | ||
| 77 | + if let Some(seq) = parser.sequence_header() { | ||
| 78 | + println!( | ||
| 79 | + "SEQ: use_128x128_superblock={} bit_depth={} max_frame={}x{}", | ||
| 80 | + seq.use_128x128_superblock, | ||
| 81 | + seq.color_config.bit_depth, | ||
| 82 | + seq.max_frame_width, | ||
| 83 | + seq.max_frame_height | ||
| 84 | + ); | ||
| 85 | + } | ||
| 74 | for (cols, rows, uniform, ctx_id) in &seen { | 86 | for (cols, rows, uniform, ctx_id) in &seen { |
| 75 | println!( | 87 | println!( |
| 76 | "TILING: cols={cols} rows={rows} uniform_spacing={uniform} context_update_tile_id={ctx_id}" | 88 | "TILING: cols={cols} rows={rows} uniform_spacing={uniform} context_update_tile_id={ctx_id}" |
crates/ec-av1/src/cdf.rsmodified+18 -1
| @@ -8,6 +8,17 @@ | |||
| 8 | 8 | ||
| 9 | /// `Default_Partition_W64_Cdf` (spec 9.4): the ten partition types of a | 9 | /// `Default_Partition_W64_Cdf` (spec 9.4): the ten partition types of a |
| 10 | /// 64x64 block, indexed by the context the blocks above and left give. | 10 | /// 64x64 block, indexed by the context the blocks above and left give. |
| 11 | +/// `default_partition_cdf`'s last four contexts (entropymode.c:154, the | ||
| 12 | +/// `AOM_CDF8` rows): the `BLOCK_128X128` root's alphabet is | ||
| 13 | +/// `EXT_PARTITION_TYPES - 2 = 8` -- `PARTITION_HORZ_4`/`_VERT_4` do not exist | ||
| 14 | +/// at 128 (spec `partition_cdf_length`). | ||
| 15 | +pub const PARTITION_W128: [[u16; 9]; 4] = [ | ||
| 16 | + [27899, 28219, 28529, 32484, 32539, 32619, 32639, 32768, 0], | ||
| 17 | + [6607, 6990, 8268, 32060, 32219, 32338, 32371, 32768, 0], | ||
| 18 | + [5429, 6676, 7122, 32027, 32227, 32531, 32582, 32768, 0], | ||
| 19 | + [711, 966, 1172, 32448, 32538, 32617, 32664, 32768, 0], | ||
| 20 | +]; | ||
| 21 | + | ||
| 11 | pub const PARTITION_W64: [[u16; 11]; 4] = [ | 22 | pub const PARTITION_W64: [[u16; 11]; 4] = [ |
| 12 | [ | 23 | [ |
| 13 | 20137, 21547, 23078, 29566, 29837, 30261, 30524, 30892, 31724, 32768, 0, | 24 | 20137, 21547, 23078, 29566, 29837, 30261, 30524, 30892, 31724, 32768, 0, |
| @@ -477,7 +488,7 @@ pub const CFL_SIGN: [u16; 9] = [1418, 2123, 13340, 18405, 26972, 28343, 32294, 3 | |||
| 477 | /// `av1_filter_intra_allowed_bsize`'s "both sides <= 32" bound, so libaom | 488 | /// `av1_filter_intra_allowed_bsize`'s "both sides <= 32" bound, so libaom |
| 478 | /// reads `use_filter_intra` there too and the missing rows dropped the | 489 | /// reads `use_filter_intra` there too and the missing rows dropped the |
| 479 | /// symbol on every DC_PRED 1:4 strip. | 490 | /// symbol on every DC_PRED 1:4 strip. |
| 480 | -pub const FILTER_INTRA: [[u16; 3]; 12] = [ | 491 | +pub const FILTER_INTRA: [[u16; 3]; 14] = [ |
| 481 | [4621, 32768, 0], | 492 | [4621, 32768, 0], |
| 482 | [7866, 32768, 0], | 493 | [7866, 32768, 0], |
| 483 | [12408, 32768, 0], | 494 | [12408, 32768, 0], |
| @@ -490,6 +501,12 @@ pub const FILTER_INTRA: [[u16; 3]; 12] = [ | |||
| 490 | [5893, 32768, 0], | 501 | [5893, 32768, 0], |
| 491 | [18101, 32768, 0], | 502 | [18101, 32768, 0], |
| 492 | [20229, 32768, 0], | 503 | [20229, 32768, 0], |
| 504 | + // lane-r14: the 16x16-level 1:4 pair (`default_filter_intra_cdfs` index | ||
| 505 | + // 17/16 -- BLOCK_16X4/BLOCK_4X16, generated by | ||
| 506 | + // `scripts/extract-filter-intra-cdfs.py`), classes 12/13. Both sides <= 32, | ||
| 507 | + // so libaom writes `use_filter_intra` on every DC_PRED strip of this shape. | ||
| 508 | + [10368, 32768, 0], | ||
| 509 | + [12770, 32768, 0], | ||
| 493 | ]; | 510 | ]; |
| 494 | /// `default_filter_intra_mode_cdf` (entropymode.c): which of the five | 511 | /// `default_filter_intra_mode_cdf` (entropymode.c): which of the five |
| 495 | /// `FILTER_INTRA_MODES` a `use_filter_intra` block picks. | 512 | /// `FILTER_INTRA_MODES` a `use_filter_intra` block picks. |
crates/ec-av1/src/cdf_state.rsmodified+45 -1
| @@ -214,6 +214,22 @@ pub(crate) enum TxbSet { | |||
| 214 | /// `tx_size_sqr == TX_4X4`, intra returns `EXT_TX_SET_DTT4_IDTX_1DDCT`, | 214 | /// `tx_size_sqr == TX_4X4`, intra returns `EXT_TX_SET_DTT4_IDTX_1DDCT`, |
| 215 | /// the same seven-symbol set (and same `TX_4X4` row) `Luma4Set1` reads. | 215 | /// the same seven-symbol set (and same `TX_4X4` row) `Luma4Set1` reads. |
| 216 | LumaRect4x8Set1, | 216 | LumaRect4x8Set1, |
| 217 | + /// The luma 16x4/4x16 transform of a 16x16-level `PARTITION_HORZ_4`/ | ||
| 218 | + /// `PARTITION_VERT_4` strip (lane-r14). `get_txsize_entropy_ctx` | ||
| 219 | + /// ((`txsize_sqr_map` + `txsize_sqr_up_map` + 1) >> 1) resolves `TX_16X4` | ||
| 220 | + /// to `TX_8X8`, and the transform has 64 coded positions, so EVERY table | ||
| 221 | + /// here is [`Luma8`](TxbSet::Luma8)'s (`eob_pt_64` included) except | ||
| 222 | + /// `tx_type`: `read_tx_type` indexes `intra_ext_tx_cdf[eset] | ||
| 223 | + /// [txsize_sqr_map[TX_16X4]]` = the `TX_4X4` row, and | ||
| 224 | + /// `av1_get_ext_tx_set_type` at `tx_size_sqr_up == TX_16X16` with | ||
| 225 | + /// `tx_size_sqr == TX_4X4` returns `EXT_TX_SET_DTT4_IDTX` under | ||
| 226 | + /// `reduced_tx_set` -- the same pair [`LumaRect4x8`](TxbSet::LumaRect4x8) | ||
| 227 | + /// reads, which differs from this variant only in its 32-position `eob_pt`. | ||
| 228 | + LumaRect16x4, | ||
| 229 | + /// [`LumaRect16x4`](TxbSet::LumaRect16x4)'s `reduced_tx_set: false` | ||
| 230 | + /// counterpart: `EXT_TX_SET_DTT4_IDTX_1DDCT`, the seven-symbol `TX_4X4` | ||
| 231 | + /// row [`LumaRect4x8Set1`](TxbSet::LumaRect4x8Set1) reads. | ||
| 232 | + LumaRect16x4Set1, | ||
| 217 | } | 233 | } |
| 218 | 234 | ||
| 219 | /// The tables one transform block is coded with, borrowed from the state for | 235 | /// The tables one transform block is coded with, borrowed from the state for |
| @@ -251,6 +267,8 @@ pub(crate) struct TxbTables<'a> { | |||
| 251 | #[derive(Clone)] | 267 | #[derive(Clone)] |
| 252 | pub(crate) struct Cdfs { | 268 | pub(crate) struct Cdfs { |
| 253 | /// The partition symbol of a 64x64 superblock. | 269 | /// The partition symbol of a 64x64 superblock. |
| 270 | + /// `partition_cdf`'s `BLOCK_128X128` rows (8 symbols). | ||
| 271 | + pub partition_w128: [[u16; 9]; 4], | ||
| 254 | pub partition_w64: [[u16; 11]; 4], | 272 | pub partition_w64: [[u16; 11]; 4], |
| 255 | /// The partition symbol of a 32x32 block. | 273 | /// The partition symbol of a 32x32 block. |
| 256 | pub partition_w32: [[u16; 11]; 4], | 274 | pub partition_w32: [[u16; 11]; 4], |
| @@ -569,7 +587,7 @@ pub(crate) struct Cdfs { | |||
| 569 | /// `[1]`=8x8, `[2]`=16x16, `[3]`=32x32, `[4]`=32x16, `[5]`=16x32, | 587 | /// `[1]`=8x8, `[2]`=16x16, `[3]`=32x32, `[4]`=32x16, `[5]`=16x32, |
| 570 | /// `[6]`=16x8, `[7]`=8x16, `[8]`=4x8, `[9]`=8x4, `[10]`=32x8, `[11]`=8x32) -- | 588 | /// `[6]`=16x8, `[7]`=8x16, `[8]`=4x8, `[9]`=8x4, `[10]`=32x8, `[11]`=8x32) -- |
| 571 | /// see [`cdf::FILTER_INTRA`]. | 589 | /// see [`cdf::FILTER_INTRA`]. |
| 572 | - pub filter_intra: [[u16; 3]; 12], | 590 | + pub filter_intra: [[u16; 3]; 14], |
| 573 | /// Which `FILTER_INTRA_MODES` entry a `use_filter_intra` block picks. | 591 | /// Which `FILTER_INTRA_MODES` entry a `use_filter_intra` block picks. |
| 574 | pub filter_intra_mode: [u16; 6], | 592 | pub filter_intra_mode: [u16; 6], |
| 575 | /// `TxMode::Select`'s `tx_depth` flag at an 8x8 block, by `tx_size_context` | 593 | /// `TxMode::Select`'s `tx_depth` flag at an 8x8 block, by `tx_size_context` |
| @@ -721,6 +739,7 @@ impl Cdfs { | |||
| 721 | /// into a reference slot for cross-frame forwarding; never on a table | 739 | /// into a reference slot for cross-frame forwarding; never on a table |
| 722 | /// still being read within the same tile. | 740 | /// still being read within the same tile. |
| 723 | pub(crate) fn reset_counts(&mut self) { | 741 | pub(crate) fn reset_counts(&mut self) { |
| 742 | + reset2(&mut self.partition_w128); | ||
| 724 | reset2(&mut self.partition_w64); | 743 | reset2(&mut self.partition_w64); |
| 725 | reset2(&mut self.partition_w32); | 744 | reset2(&mut self.partition_w32); |
| 726 | reset2(&mut self.txfm_partition); | 745 | reset2(&mut self.txfm_partition); |
| @@ -886,6 +905,7 @@ impl Cdfs { | |||
| 886 | /// quantizer, so they are the same for every `q_ctx`. | 905 | /// quantizer, so they are the same for every `q_ctx`. |
| 887 | pub fn new(q_ctx: usize) -> Cdfs { | 906 | pub fn new(q_ctx: usize) -> Cdfs { |
| 888 | Cdfs { | 907 | Cdfs { |
| 908 | + partition_w128: cdf::PARTITION_W128, | ||
| 889 | partition_w64: cdf::PARTITION_W64, | 909 | partition_w64: cdf::PARTITION_W64, |
| 890 | partition_w32: cdf::PARTITION_W32, | 910 | partition_w32: cdf::PARTITION_W32, |
| 891 | skip: cdf::SKIP, | 911 | skip: cdf::SKIP, |
| @@ -1807,6 +1827,30 @@ impl Cdfs { | |||
| 1807 | tx_type: Some(self.intra_tx_type_8_set1[mode].as_mut_slice()), | 1827 | tx_type: Some(self.intra_tx_type_8_set1[mode].as_mut_slice()), |
| 1808 | eob_pt_class1: Some(&mut self.eob_pt_128_luma_class1), | 1828 | eob_pt_class1: Some(&mut self.eob_pt_128_luma_class1), |
| 1809 | }, | 1829 | }, |
| 1830 | + TxbSet::LumaRect16x4 => TxbTables { | ||
| 1831 | + side: 8, | ||
| 1832 | + txb_skip: &mut self.txb_skip_luma_8, | ||
| 1833 | + eob_pt: &mut self.eob_pt_64_luma, | ||
| 1834 | + eob_extra: &mut self.eob_extra_luma_8, | ||
| 1835 | + base: &mut self.base_luma_8, | ||
| 1836 | + base_eob: &mut self.base_eob_luma_8, | ||
| 1837 | + br: &mut self.br_luma_8, | ||
| 1838 | + dc_sign: &mut self.dc_sign_luma, | ||
| 1839 | + tx_type: Some(self.intra_tx_type_4[mode].as_mut_slice()), | ||
| 1840 | + eob_pt_class1: Some(&mut self.eob_pt_64_luma_class1), | ||
| 1841 | + }, | ||
| 1842 | + TxbSet::LumaRect16x4Set1 => TxbTables { | ||
| 1843 | + side: 8, | ||
| 1844 | + txb_skip: &mut self.txb_skip_luma_8, | ||
| 1845 | + eob_pt: &mut self.eob_pt_64_luma, | ||
| 1846 | + eob_extra: &mut self.eob_extra_luma_8, | ||
| 1847 | + base: &mut self.base_luma_8, | ||
| 1848 | + base_eob: &mut self.base_eob_luma_8, | ||
| 1849 | + br: &mut self.br_luma_8, | ||
| 1850 | + dc_sign: &mut self.dc_sign_luma, | ||
| 1851 | + tx_type: Some(self.intra_tx_type_4_set1[mode].as_mut_slice()), | ||
| 1852 | + eob_pt_class1: Some(&mut self.eob_pt_64_luma_class1), | ||
| 1853 | + }, | ||
| 1810 | TxbSet::LumaRect16x8Inter => TxbTables { | 1854 | TxbSet::LumaRect16x8Inter => TxbTables { |
| 1811 | side: 16, | 1855 | side: 16, |
| 1812 | txb_skip: &mut self.txb_skip_luma_16, | 1856 | txb_skip: &mut self.txb_skip_luma_16, |
crates/ec-av1/src/decode.rsmodified+944 -91
| @@ -56,6 +56,71 @@ const PARTITION_VERT_4: usize = 9; | |||
| 56 | const SB_MI: u32 = 16; | 56 | const SB_MI: u32 = 16; |
| 57 | const BLOCK_MI: u32 = 8; | 57 | const BLOCK_MI: u32 = 8; |
| 58 | 58 | ||
| 59 | +// lane-sb128 r1: this sequence's `use_128x128_superblock` (spec 5.5.1). | ||
| 60 | +// Every superblock-granular rule below (`delta_q`/`delta_lf`'s "is this the | ||
| 61 | +// superblock's own top-left mi?", the loop-restoration read's unit span, the | ||
| 62 | +// partition tree's own root level) keys off it; `SB_MI` stays the 64x64 | ||
| 63 | +// *quadrant* size a 128 superblock is decoded in, which is also what the CDEF | ||
| 64 | +// grid is indexed by (libaom `read_cdef` reads one `cdef_idx` per 64x64 | ||
| 65 | +// inside a 128 superblock). | ||
| 66 | +thread_local! { | ||
| 67 | + static SB128: std::cell::Cell<bool> = const { std::cell::Cell::new(false) }; | ||
| 68 | +} | ||
| 69 | + | ||
| 70 | +/// Sets [`SB128`] for this thread (called once per frame from `stream.rs`). | ||
| 71 | +pub(crate) fn set_sb128(v: bool) { | ||
| 72 | + SB128.with(|c| c.set(v)); | ||
| 73 | + crate::encode::set_reach_superblock_px(if v { 128 } else { 64 }); | ||
| 74 | +} | ||
| 75 | + | ||
| 76 | +fn sb128() -> bool { | ||
| 77 | + SB128.with(|c| c.get()) | ||
| 78 | +} | ||
| 79 | + | ||
| 80 | +/// This sequence's superblock size in mi units (16 = 64x64, 32 = 128x128). | ||
| 81 | +pub(crate) fn sb_mi_cur() -> u32 { | ||
| 82 | + if sb128() { SB_MI * 2 } else { SB_MI } | ||
| 83 | +} | ||
| 84 | + | ||
| 85 | +/// How many real 128-level partition symbols this decoder has read, and how | ||
| 86 | +/// many superblocks resolved to `PARTITION_SPLIT` (coded or forced) -- the | ||
| 87 | +/// gate's proof a `--sb-size=128` stream exercised the 128 partition root. | ||
| 88 | +thread_local! { | ||
| 89 | + static PART128_SYMBOLS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | ||
| 90 | + static PART128_SPLIT_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | ||
| 91 | + static PART128_GATHERED_SYMBOLS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | ||
| 92 | +} | ||
| 93 | + | ||
| 94 | +/// Current value of `PART128_GATHERED_SYMBOLS`: 128 roots that read the | ||
| 95 | +/// half-out-of-frame gathered split_or_horz/split_or_vert symbol (spec | ||
| 96 | +/// 5.11.4), which this decoder used to read and throw away. | ||
| 97 | +pub(crate) fn part128_gathered_symbols() -> usize { | ||
| 98 | + PART128_GATHERED_SYMBOLS.with(|c| c.get()) | ||
| 99 | +} | ||
| 100 | + | ||
| 101 | +/// Current value of [`PART128_SYMBOLS`]. | ||
| 102 | +pub(crate) fn part128_symbols() -> usize { | ||
| 103 | + PART128_SYMBOLS.with(|c| c.get()) | ||
| 104 | +} | ||
| 105 | + | ||
| 106 | +/// Current value of [`PART128_SPLIT_HITS`]. | ||
| 107 | +pub(crate) fn part128_split_hits() -> usize { | ||
| 108 | + PART128_SPLIT_HITS.with(|c| c.get()) | ||
| 109 | +} | ||
| 110 | + | ||
| 111 | +/// [`gather`] over an alphabet of any length -- the 128-level partition CDF | ||
| 112 | +/// has 8 symbols (no `PARTITION_HORZ_4`/`_VERT_4` at `BLOCK_128X128`, spec | ||
| 113 | +/// `partition_cdf_length`), so its forced-split gather sums 5 elements where | ||
| 114 | +/// the 64/32 levels sum 6. | ||
| 115 | +fn gather_of(cdf: &[u16], elements: &[usize]) -> [u16; 3] { | ||
| 116 | + let split: u16 = elements.iter().map(|&e| element_prob(cdf, e)).sum(); | ||
| 117 | + [32768 - split, 32768, 0] | ||
| 118 | +} | ||
| 119 | + | ||
| 120 | +/// [`VERT_ALIKE`]/[`HORZ_ALIKE`] without the 1:4 arms, for the 128 root. | ||
| 121 | +const VERT_ALIKE128: [usize; 5] = [2, PARTITION_SPLIT, 4, 6, 7]; | ||
| 122 | +const HORZ_ALIKE128: [usize; 5] = [1, PARTITION_SPLIT, 4, 5, 6]; | ||
| 123 | + | ||
| 59 | // How many `use_filter_intra` symbols this decoder has read as `1`, across | 124 | // How many `use_filter_intra` symbols this decoder has read as `1`, across |
| 60 | // every call on the current thread -- the cheap counter [`filter_intra_hits`] gate | 125 | // every call on the current thread -- the cheap counter [`filter_intra_hits`] gate |
| 61 | // tests read (before/after, not the absolute value) to prove a stream | 126 | // tests read (before/after, not the absolute value) to prove a stream |
| @@ -241,10 +306,14 @@ fn maybe_read_delta_q(dec: &mut SymbolDecoder, cdfs: &mut Cdfs, mi_r: usize, mi_ | |||
| 241 | if !DELTA_Q_PRESENT.with(|c| c.get()) { | 306 | if !DELTA_Q_PRESENT.with(|c| c.get()) { |
| 242 | return; | 307 | return; |
| 243 | } | 308 | } |
| 244 | - if mi_r % SB_MI as usize != 0 || mi_c % SB_MI as usize != 0 { | 309 | + let sb_mi = sb_mi_cur() as usize; |
| 310 | + if mi_r % sb_mi != 0 || mi_c % sb_mi != 0 { | ||
| 245 | return; | 311 | return; |
| 246 | } | 312 | } |
| 247 | - if is_whole_sb && skip { | 313 | + // `is_whole_sb` is the caller's "this leaf IS the superblock" flag, which |
| 314 | + // it computes against the 64x64 root; under a 128 superblock no leaf this | ||
| 315 | + // decoder codes can be the whole superblock (the root is always SPLIT). | ||
| 316 | + if is_whole_sb && !sb128() && skip { | ||
| 248 | return; | 317 | return; |
| 249 | } | 318 | } |
| 250 | let mut abs = dec.symbol(&mut cdfs.delta_q) as i32; | 319 | let mut abs = dec.symbol(&mut cdfs.delta_q) as i32; |
| @@ -296,10 +365,14 @@ fn maybe_read_delta_lf(dec: &mut SymbolDecoder, cdfs: &mut Cdfs, mi_r: usize, mi | |||
| 296 | if !DELTA_LF_PRESENT.with(|c| c.get()) { | 365 | if !DELTA_LF_PRESENT.with(|c| c.get()) { |
| 297 | return; | 366 | return; |
| 298 | } | 367 | } |
| 299 | - if mi_r % SB_MI as usize != 0 || mi_c % SB_MI as usize != 0 { | 368 | + let sb_mi = sb_mi_cur() as usize; |
| 369 | + if mi_r % sb_mi != 0 || mi_c % sb_mi != 0 { | ||
| 300 | return; | 370 | return; |
| 301 | } | 371 | } |
| 302 | - if is_whole_sb && skip { | 372 | + // `is_whole_sb` is the caller's "this leaf IS the superblock" flag, which |
| 373 | + // it computes against the 64x64 root; under a 128 superblock no leaf this | ||
| 374 | + // decoder codes can be the whole superblock (the root is always SPLIT). | ||
| 375 | + if is_whole_sb && !sb128() && skip { | ||
| 303 | return; | 376 | return; |
| 304 | } | 377 | } |
| 305 | let multi = DELTA_LF_MULTI.with(|c| c.get()); | 378 | let multi = DELTA_LF_MULTI.with(|c| c.get()); |
| @@ -916,6 +989,10 @@ thread_local! { | |||
| 916 | // their rect max transform into square sub-transforms. | 989 | // their rect max transform into square sub-transforms. |
| 917 | static RECT_INTER_TU_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | 990 | static RECT_INTER_TU_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; |
| 918 | static RECT_INTER_TXSPLIT_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | 991 | static RECT_INTER_TXSPLIT_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; |
| 992 | + // lane-r14 r2: luma transform units of an inter strip with a 64-px axis | ||
| 993 | + // (64x32/32x64/64x16/16x64), whose coefficients are coded as the | ||
| 994 | + // truncated low-32 corner. | ||
| 995 | + static RECT64_INTER_TU_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | ||
| 919 | // lane-inter4 r3: 16x16-level PARTITION_HORZ / PARTITION_VERT on an inter | 996 | // lane-inter4 r3: 16x16-level PARTITION_HORZ / PARTITION_VERT on an inter |
| 920 | // frame -- 16x8 and 8x16 inter leaves. | 997 | // frame -- 16x8 and 8x16 inter leaves. |
| 921 | static INTER_LEAF16_HORZ_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | 998 | static INTER_LEAF16_HORZ_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; |
| @@ -963,6 +1040,11 @@ pub(crate) fn rect_inter_txsplit_hits() -> usize { | |||
| 963 | RECT_INTER_TXSPLIT_HITS.with(|c| c.get()) | 1040 | RECT_INTER_TXSPLIT_HITS.with(|c| c.get()) |
| 964 | } | 1041 | } |
| 965 | 1042 | ||
| 1043 | +/// Current value of [`RECT64_INTER_TU_HITS`] (lane-r14 r2). | ||
| 1044 | +pub(crate) fn rect64_inter_tu_hits() -> usize { | ||
| 1045 | + RECT64_INTER_TU_HITS.with(|c| c.get()) | ||
| 1046 | +} | ||
| 1047 | + | ||
| 966 | /// Sets the current thread's [`TX_SELECT_INTER`]/[`REDUCED_TX_SET_INTER`]/ | 1048 | /// Sets the current thread's [`TX_SELECT_INTER`]/[`REDUCED_TX_SET_INTER`]/ |
| 967 | /// [`ENABLE_FILTER_INTRA_INTER`]. | 1049 | /// [`ENABLE_FILTER_INTRA_INTER`]. |
| 968 | pub(crate) fn set_inter_tx_mode( | 1050 | pub(crate) fn set_inter_tx_mode( |
| @@ -2129,6 +2211,30 @@ pub(crate) fn rect4_coeff_hits() -> usize { | |||
| 2129 | RECT4_COEFF_HITS.with(|c| c.get()) | 2211 | RECT4_COEFF_HITS.with(|c| c.get()) |
| 2130 | } | 2212 | } |
| 2131 | 2213 | ||
| 2214 | +// lane-r14: the 16x16-level 1:4 pair -- four 16x4 (`PARTITION_HORZ_4`) or | ||
| 2215 | +// 4x16 (`PARTITION_VERT_4`) strips, `CHROMA` counting the odd strips that | ||
| 2216 | +// close a 4:2:0 chroma pair and `COEFF` the strips with a coded residual. | ||
| 2217 | +thread_local! { | ||
| 2218 | + static RECT4_16_HORZ_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | ||
| 2219 | + static RECT4_16_VERT_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | ||
| 2220 | + static RECT4_16_CHROMA_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | ||
| 2221 | + static RECT4_16_COEFF_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | ||
| 2222 | + static RECT4_16_SPLIT_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | ||
| 2223 | +} | ||
| 2224 | + | ||
| 2225 | +/// Current values of the 16x16-level 1:4 counters: `(16x4 strips, 4x16 | ||
| 2226 | +/// strips, chroma-reference strips, strips with a coded residual, strips | ||
| 2227 | +/// whose luma transform is split)`. | ||
| 2228 | +pub fn rect4_16_counters() -> (usize, usize, usize, usize, usize) { | ||
| 2229 | + ( | ||
| 2230 | + RECT4_16_HORZ_HITS.with(|c| c.get()), | ||
| 2231 | + RECT4_16_VERT_HITS.with(|c| c.get()), | ||
| 2232 | + RECT4_16_CHROMA_HITS.with(|c| c.get()), | ||
| 2233 | + RECT4_16_COEFF_HITS.with(|c| c.get()), | ||
| 2234 | + RECT4_16_SPLIT_HITS.with(|c| c.get()), | ||
| 2235 | + ) | ||
| 2236 | +} | ||
| 2237 | + | ||
| 2132 | /// Current value of `RECT4_32_HORZ_HITS` (32x8 strips decoded). | 2238 | /// Current value of `RECT4_32_HORZ_HITS` (32x8 strips decoded). |
| 2133 | pub(crate) fn rect4_32_horz_hits() -> usize { | 2239 | pub(crate) fn rect4_32_horz_hits() -> usize { |
| 2134 | RECT4_32_HORZ_HITS.with(|c| c.get()) | 2240 | RECT4_32_HORZ_HITS.with(|c| c.get()) |
| @@ -2502,6 +2608,18 @@ fn note_chroma_class1(plane_idx: usize, tx_type: TxType) { | |||
| 2502 | const SUB_MI: u32 = 4; | 2608 | const SUB_MI: u32 = 4; |
| 2503 | const MI: usize = 4; | 2609 | const MI: usize = 4; |
| 2504 | const SB: usize = 64; | 2610 | const SB: usize = 64; |
| 2611 | +/// The `above_side`/`left_side` value a cell with no decoded neighbour holds | ||
| 2612 | +/// (tile start, superblock-row start). | ||
| 2613 | +/// | ||
| 2614 | +/// [`Neighbours::partition_ctx_mi`] reads it as libaom's | ||
| 2615 | +/// `av1_get_partition_plane_context` reads its own zero-initialised | ||
| 2616 | +/// `above_partition_context` byte: bit `bsl` clear, i.e. "the neighbour is at | ||
| 2617 | +/// least as wide as this block". lane-sb128 r1: the old sentinel was `SB` | ||
| 2618 | +/// (64), which reads identically at every level up to 64x64 but sets the bit | ||
| 2619 | +/// at the `BLOCK_128X128` root (64 * 2 <= 128) -- the 128-level partition | ||
| 2620 | +/// symbol was read off CDF row 3 where libaom uses row 0 (aomdec | ||
| 2621 | +/// `EC_PART mi_row=0 mi_col=0 bsize=15 ctx=16`, i.e. `bsl*4 + 0`). | ||
| 2622 | +const NO_NEIGHBOUR_SIDE: usize = 128; | ||
| 2505 | const BLOCK: usize = 32; | 2623 | const BLOCK: usize = 32; |
| 2506 | const SUB: usize = 16; | 2624 | const SUB: usize = 16; |
| 2507 | const TX32: usize = 32; | 2625 | const TX32: usize = 32; |
| @@ -3729,10 +3847,10 @@ impl Neighbours { | |||
| 3729 | left_mode: vec![DC_PRED; rows], | 3847 | left_mode: vec![DC_PRED; rows], |
| 3730 | above_uv_mode: vec![DC_PRED; cols], | 3848 | above_uv_mode: vec![DC_PRED; cols], |
| 3731 | left_uv_mode: vec![DC_PRED; rows], | 3849 | left_uv_mode: vec![DC_PRED; rows], |
| 3732 | - above_side: vec![SB; cols], | 3850 | + above_side: vec![NO_NEIGHBOUR_SIDE; cols], |
| 3733 | - left_side: vec![SB; rows], | 3851 | + left_side: vec![NO_NEIGHBOUR_SIDE; rows], |
| 3734 | - above_side_mi: vec![SB; cols * (SUB / MI)], | 3852 | + above_side_mi: vec![NO_NEIGHBOUR_SIDE; cols * (SUB / MI)], |
| 3735 | - left_side_mi: vec![SB; rows * (SUB / MI)], | 3853 | + left_side_mi: vec![NO_NEIGHBOUR_SIDE; rows * (SUB / MI)], |
| 3736 | sub8_mode_col: vec![(usize::MAX, 0); cols * (SUB / MI)], | 3854 | sub8_mode_col: vec![(usize::MAX, 0); cols * (SUB / MI)], |
| 3737 | sub8_mode_row: vec![(usize::MAX, 0); rows * (SUB / MI)], | 3855 | sub8_mode_row: vec![(usize::MAX, 0); rows * (SUB / MI)], |
| 3738 | uv_mode_col: vec![(usize::MAX, 0); cols * (SUB / MI)], | 3856 | uv_mode_col: vec![(usize::MAX, 0); cols * (SUB / MI)], |
| @@ -3797,7 +3915,7 @@ impl Neighbours { | |||
| 3797 | let end = col1_mi.min(self.above.len()); | 3915 | let end = col1_mi.min(self.above.len()); |
| 3798 | for i in col0_mi.min(end)..end { | 3916 | for i in col0_mi.min(end)..end { |
| 3799 | self.above[i] = Default::default(); | 3917 | self.above[i] = Default::default(); |
| 3800 | - self.above_side_mi[i] = SB; | 3918 | + self.above_side_mi[i] = NO_NEIGHBOUR_SIDE; |
| 3801 | } | 3919 | } |
| 3802 | let (sc0, sc1) = ( | 3920 | let (sc0, sc1) = ( |
| 3803 | col0_mi / (SUB / MI), | 3921 | col0_mi / (SUB / MI), |
| @@ -3805,7 +3923,7 @@ impl Neighbours { | |||
| 3805 | ); | 3923 | ); |
| 3806 | for i in sc0.min(sc1)..sc1 { | 3924 | for i in sc0.min(sc1)..sc1 { |
| 3807 | self.above_mode[i] = DC_PRED; | 3925 | self.above_mode[i] = DC_PRED; |
| 3808 | - self.above_side[i] = SB; | 3926 | + self.above_side[i] = NO_NEIGHBOUR_SIDE; |
| 3809 | } | 3927 | } |
| 3810 | // lane-inter8 r2: the inter bands are mi-granular, so they reset over | 3928 | // lane-inter8 r2: the inter bands are mi-granular, so they reset over |
| 3811 | // the tile's own mi column span directly. | 3929 | // the tile's own mi column span directly. |
| @@ -4144,8 +4262,8 @@ impl Neighbours { | |||
| 4144 | self.left.iter_mut().for_each(|l| *l = Default::default()); | 4262 | self.left.iter_mut().for_each(|l| *l = Default::default()); |
| 4145 | self.left_mode.iter_mut().for_each(|m| *m = DC_PRED); | 4263 | self.left_mode.iter_mut().for_each(|m| *m = DC_PRED); |
| 4146 | self.left_uv_mode.iter_mut().for_each(|m| *m = DC_PRED); | 4264 | self.left_uv_mode.iter_mut().for_each(|m| *m = DC_PRED); |
| 4147 | - self.left_side.iter_mut().for_each(|s| *s = SB); | 4265 | + self.left_side.iter_mut().for_each(|s| *s = NO_NEIGHBOUR_SIDE); |
| 4148 | - self.left_side_mi.iter_mut().for_each(|s| *s = SB); | 4266 | + self.left_side_mi.iter_mut().for_each(|s| *s = NO_NEIGHBOUR_SIDE); |
| 4149 | self.left_skip.iter_mut().for_each(|s| *s = false); | 4267 | self.left_skip.iter_mut().for_each(|s| *s = false); |
| 4150 | self.left_skip_mode.iter_mut().for_each(|s| *s = false); | 4268 | self.left_skip_mode.iter_mut().for_each(|s| *s = false); |
| 4151 | self.left_inter.iter_mut().for_each(|i| *i = false); | 4269 | self.left_inter.iter_mut().for_each(|i| *i = false); |
| @@ -4957,6 +5075,10 @@ fn filter_intra_size_class_rect(bw: usize, bh: usize) -> Option<usize> { | |||
| 4957 | // tile (class symbol-consumption-gap). | 5075 | // tile (class symbol-consumption-gap). |
| 4958 | (32, 8) => Some(10), | 5076 | (32, 8) => Some(10), |
| 4959 | (8, 32) => Some(11), | 5077 | (8, 32) => Some(11), |
| 5078 | + // lane-r14: the 16x16-level 1:4 pair (`decode_rect4_16`'s 16x4/4x16 | ||
| 5079 | + // strips), rows 17/16 of `default_filter_intra_cdfs`. | ||
| 5080 | + (16, 4) => Some(12), | ||
| 5081 | + (4, 16) => Some(13), | ||
| 4960 | _ if bw == bh => filter_intra_size_class(bw), | 5082 | _ if bw == bh => filter_intra_size_class(bw), |
| 4961 | _ => None, | 5083 | _ => None, |
| 4962 | } | 5084 | } |
| @@ -4982,7 +5104,13 @@ fn palette_bsize_ctx(side: usize) -> Option<usize> { | |||
| 4982 | /// `trailing_zeros` is `log2` exactly. `None` past `av1_allow_palette`'s own | 5104 | /// `trailing_zeros` is `log2` exactly. `None` past `av1_allow_palette`'s own |
| 4983 | /// bound (`block_size_wide/high <= 64`, `sb_type >= BLOCK_8X8`). | 5105 | /// bound (`block_size_wide/high <= 64`, `sb_type >= BLOCK_8X8`). |
| 4984 | fn palette_bsize_ctx_wh(bw: usize, bh: usize) -> Option<usize> { | 5106 | fn palette_bsize_ctx_wh(bw: usize, bh: usize) -> Option<usize> { |
| 4985 | - if !(8..=64).contains(&bw) || !(8..=64).contains(&bh) { | 5107 | + // lane-r14: `av1_allow_palette`'s bound is `sb_type >= BLOCK_8X8` by the |
| 5108 | + // BLOCK_SIZES_ALL enum INDEX, which the 1:4 shapes BLOCK_4X16 (16) and | ||
| 5109 | + // BLOCK_16X4 (17) clear -- a 64-pixel block, so `av1_get_palette_bsize_ctx` | ||
| 5110 | + // (`num_pels_log2 - num_pels_log2[BLOCK_8X8]`) is 0 for them, exactly as | ||
| 5111 | + // for an 8x8. Reading the dimension bound as "both sides >= 8" dropped | ||
| 5112 | + // `palette_y_mode` on every 16x4/4x16 strip of a screen-content frame. | ||
| 5113 | + if bw > 64 || bh > 64 || bw * bh < 64 { | ||
| 4986 | return None; | 5114 | return None; |
| 4987 | } | 5115 | } |
| 4988 | Some(((bw * bh) as u32).trailing_zeros() as usize - 6) | 5116 | Some(((bw * bh) as u32).trailing_zeros() as usize - 6) |
| @@ -5304,6 +5432,12 @@ fn read_intra_mode_rect( | |||
| 5304 | above_mode: usize, | 5432 | above_mode: usize, |
| 5305 | left_mode: usize, | 5433 | left_mode: usize, |
| 5306 | cfl: bool, | 5434 | cfl: bool, |
| 5435 | + // lane-r14: `is_chroma_reference` -- false only for a strip one mi tall | ||
| 5436 | + // (or wide) that is NOT the odd one of its 4:2:0 pair, where libaom reads | ||
| 5437 | + // no `uv_mode`/`cfl_alpha`/`angle_delta_uv`/`palette_uv` at all (the pair's | ||
| 5438 | + // chroma is coded once, on the closing strip). Every other caller is a | ||
| 5439 | + // block big enough to own its chroma and passes `true`. | ||
| 5440 | + has_chroma: bool, | ||
| 5307 | bw: usize, | 5441 | bw: usize, |
| 5308 | bh: usize, | 5442 | bh: usize, |
| 5309 | enable_filter_intra: bool, | 5443 | enable_filter_intra: bool, |
| @@ -5383,21 +5517,23 @@ fn read_intra_mode_rect( | |||
| 5383 | 0 | 5517 | 0 |
| 5384 | }; | 5518 | }; |
| 5385 | istep!("angle_y", angle_delta_y); | 5519 | istep!("angle_y", angle_delta_y); |
| 5386 | - let uv_mode = if cfl { | 5520 | + let uv_mode = if !has_chroma { |
| 5521 | + DC_PRED | ||
| 5522 | + } else if cfl { | ||
| 5387 | dec.symbol(&mut cdfs.uv_mode_cfl[mode]) | 5523 | dec.symbol(&mut cdfs.uv_mode_cfl[mode]) |
| 5388 | } else { | 5524 | } else { |
| 5389 | dec.symbol(&mut cdfs.uv_mode_no_cfl[mode]) | 5525 | dec.symbol(&mut cdfs.uv_mode_no_cfl[mode]) |
| 5390 | }; | 5526 | }; |
| 5391 | istep!("uv_mode", uv_mode as i32); | 5527 | istep!("uv_mode", uv_mode as i32); |
| 5392 | - let alpha = if cfl && uv_mode == UV_CFL_PRED { | 5528 | + let alpha = if has_chroma && cfl && uv_mode == UV_CFL_PRED { |
| 5393 | Some(read_cfl_alphas(dec, cdfs)) | 5529 | Some(read_cfl_alphas(dec, cdfs)) |
| 5394 | } else { | 5530 | } else { |
| 5395 | None | 5531 | None |
| 5396 | }; | 5532 | }; |
| 5397 | - if (9..=12).contains(&uv_mode) { | 5533 | + if has_chroma && (9..=12).contains(&uv_mode) { |
| 5398 | SMOOTH_UV_HITS.with(|c| c.set(c.get() + 1)); | 5534 | SMOOTH_UV_HITS.with(|c| c.set(c.get() + 1)); |
| 5399 | } | 5535 | } |
| 5400 | - let angle_delta_uv = if (V_PRED..=D67_PRED).contains(&uv_mode) { | 5536 | + let angle_delta_uv = if has_chroma && (V_PRED..=D67_PRED).contains(&uv_mode) { |
| 5401 | DIRECTIONAL_UV_HITS.with(|c| c.set(c.get() + 1)); | 5537 | DIRECTIONAL_UV_HITS.with(|c| c.set(c.get() + 1)); |
| 5402 | read_angle_delta(dec, &mut cdfs.angle_delta[uv_mode - V_PRED]) | 5538 | read_angle_delta(dec, &mut cdfs.angle_delta[uv_mode - V_PRED]) |
| 5403 | } else { | 5539 | } else { |
| @@ -5437,7 +5573,11 @@ fn read_intra_mode_rect( | |||
| 5437 | palette_y_pending = Some((n, colors)); | 5573 | palette_y_pending = Some((n, colors)); |
| 5438 | } | 5574 | } |
| 5439 | let palette_uv_mode_ctx = usize::from(use_palette_y); | 5575 | let palette_uv_mode_ctx = usize::from(use_palette_y); |
| 5440 | - if uv_mode == DC_PRED && dec.symbol(&mut cdfs.palette_uv_mode[palette_uv_mode_ctx]) != 0 { | 5576 | + // `read_palette_mode_info`'s own `xd->is_chroma_ref` guard. |
| 5577 | + if has_chroma | ||
| 5578 | + && uv_mode == DC_PRED | ||
| 5579 | + && dec.symbol(&mut cdfs.palette_uv_mode[palette_uv_mode_ctx]) != 0 | ||
| 5580 | + { | ||
| 5441 | let n = 2 + dec.symbol(&mut cdfs.palette_uv_size[bsize_ctx]); | 5581 | let n = 2 + dec.symbol(&mut cdfs.palette_uv_size[bsize_ctx]); |
| 5442 | let (u_colors, v_colors) = read_palette_colors_uv(dec, n, palette_uv_cache); | 5582 | let (u_colors, v_colors) = read_palette_colors_uv(dec, n, palette_uv_cache); |
| 5443 | palette_uv_pending = Some((n, u_colors, v_colors)); | 5583 | palette_uv_pending = Some((n, u_colors, v_colors)); |
| @@ -6293,6 +6433,7 @@ fn decode_block_rect( | |||
| 6293 | nb_above_mode, | 6433 | nb_above_mode, |
| 6294 | nb_left_mode, | 6434 | nb_left_mode, |
| 6295 | true, | 6435 | true, |
| 6436 | + true, | ||
| 6296 | bw, | 6437 | bw, |
| 6297 | bh, | 6438 | bh, |
| 6298 | enable_filter_intra, | 6439 | enable_filter_intra, |
| @@ -6767,6 +6908,7 @@ fn decode_leaf_rect( | |||
| 6767 | above_mode, | 6908 | above_mode, |
| 6768 | left_mode, | 6909 | left_mode, |
| 6769 | true, | 6910 | true, |
| 6911 | + true, | ||
| 6770 | bw, | 6912 | bw, |
| 6771 | bh, | 6913 | bh, |
| 6772 | enable_filter_intra, | 6914 | enable_filter_intra, |
| @@ -7046,6 +7188,7 @@ fn decode_block_rect4( | |||
| 7046 | above_mode, | 7188 | above_mode, |
| 7047 | left_mode, | 7189 | left_mode, |
| 7048 | true, | 7190 | true, |
| 7191 | + true, | ||
| 7049 | bw, | 7192 | bw, |
| 7050 | bh, | 7193 | bh, |
| 7051 | enable_filter_intra, | 7194 | enable_filter_intra, |
| @@ -7347,6 +7490,434 @@ fn decode_block_rect4( | |||
| 7347 | Ok((mode, uv_predict_mode)) | 7490 | Ok((mode, uv_predict_mode)) |
| 7348 | } | 7491 | } |
| 7349 | 7492 | ||
| 7493 | +/// Decodes the four 16x4 / 4x16 strips of a 16x16-level `PARTITION_HORZ_4` / | ||
| 7494 | +/// `PARTITION_VERT_4` (lane-r14) -- [`decode_block_rect4`]'s pair one level | ||
| 7495 | +/// down, and the first shape here whose luma block is a single mi row (or | ||
| 7496 | +/// column). | ||
| 7497 | +/// | ||
| 7498 | +/// What is new at this size is CHROMA. `is_chroma_reference` | ||
| 7499 | +/// (`av1_common_int.h`) is false for a 4:2:0 block one mi tall (wide) on an | ||
| 7500 | +/// EVEN mi row (column), so strips 0 and 2 read no `uv_mode`/`cfl_alpha`/ | ||
| 7501 | +/// `angle_delta_uv` at all and code no chroma residual; strips 1 and 3 close | ||
| 7502 | +/// the pair and carry the chroma of the whole 16x8 (8x16) luma pair -- | ||
| 7503 | +/// `setup_pred_plane`'s own `if (subsampling_y && (mi_row & 1) && | ||
| 7504 | +/// mi_size_high[bsize] == 1) mi_row -= 1` offset, i.e. an 8x4 (4x8) chroma | ||
| 7505 | +/// transform at the PAIR's origin, with CfL averaging over the pair's luma. | ||
| 7506 | +/// | ||
| 7507 | +/// Tables: LUMA `TX_16X4`/`TX_4X16` averages to the 8x8 entropy context | ||
| 7508 | +/// ((0 + 2 + 1) >> 1 = 1) with 64 coded positions, so its CDF set is | ||
| 7509 | +/// [`TxbSet::LumaRect16x4`] (`Luma8`'s tables, the `TX_4X4` `tx_type` row); | ||
| 7510 | +/// scans are [`SCAN_16X4`]/[`SCAN_4X16`]. CHROMA `TX_8X4`/`TX_4X8` is | ||
| 7511 | +/// [`TxbSet::ChromaRect8x4`] with [`SCAN_8X4`]/[`SCAN_4X8`]. Angle deltas ARE | ||
| 7512 | +/// coded (`av1_use_angle_delta` compares the BLOCK_SIZES_ALL enum index, and | ||
| 7513 | +/// BLOCK_16X4 is 17), and so is `use_filter_intra` (both sides <= 32) off this | ||
| 7514 | +/// shape's own CDF row. | ||
| 7515 | +/// | ||
| 7516 | +/// A split transform (`tx_depth != 0`, `sub_tx_size_map[TX_16X4] == TX_8X4`) | ||
| 7517 | +/// refuses by name rather than guess-decode. | ||
| 7518 | +#[allow(clippy::too_many_arguments)] | ||
| 7519 | +fn decode_rect4_16( | ||
| 7520 | + dec: &mut SymbolDecoder, | ||
| 7521 | + cdfs: &mut Cdfs, | ||
| 7522 | + neighbours: &mut Neighbours, | ||
| 7523 | + at16: (usize, usize), | ||
| 7524 | + horz: bool, | ||
| 7525 | + y: &mut PlaneBuf, | ||
| 7526 | + u: &mut PlaneBuf, | ||
| 7527 | + v: &mut PlaneBuf, | ||
| 7528 | + enable_filter_intra: bool, | ||
| 7529 | + allow_screen_content_tools: bool, | ||
| 7530 | + base_q_idx: u8, | ||
| 7531 | + tx_select: bool, | ||
| 7532 | + reduced_tx_set: bool, | ||
| 7533 | +) -> Result<()> { | ||
| 7534 | + let (r, c) = at16; | ||
| 7535 | + let (mi_row0, mi_col0) = (r * (SUB / MI), c * (SUB / MI)); | ||
| 7536 | + let (bw, bh) = if horz { (16, 4) } else { (4, 16) }; | ||
| 7537 | + let (mi_w, mi_h) = (bw / MI, bh / MI); | ||
| 7538 | + let scan: &[u16] = if horz { &SCAN_16X4 } else { &SCAN_4X16 }; | ||
| 7539 | + let chroma_scan: &[u16] = if horz { &SCAN_8X4 } else { &SCAN_4X8 }; | ||
| 7540 | + let mut prev: Option<((usize, usize), usize)> = None; | ||
| 7541 | + let mut last_mode = DC_PRED; | ||
| 7542 | + let mut last_uv_mode = DC_PRED; | ||
| 7543 | + for i in 0..4usize { | ||
| 7544 | + let lmi = if horz { | ||
| 7545 | + (mi_row0 + i, mi_col0) | ||
| 7546 | + } else { | ||
| 7547 | + (mi_row0, mi_col0 + i) | ||
| 7548 | + }; | ||
| 7549 | + let has_chroma = i % 2 == 1; | ||
| 7550 | + // `decode_block_rect4`'s own neighbour rule: the coarse 16-px cell | ||
| 7551 | + // aliases all four strips onto one entry, so the mi-exact map wins and | ||
| 7552 | + // the previous strip stands in on the split axis. | ||
| 7553 | + let mut above_mode = neighbours.above_mode[c]; | ||
| 7554 | + let mut left_mode = neighbours.left_mode[r]; | ||
| 7555 | + if let Some(((pr, pc), pmode)) = prev { | ||
| 7556 | + if pc == lmi.1 && lmi.0 == pr + mi_h { | ||
| 7557 | + above_mode = pmode; | ||
| 7558 | + } else if pr == lmi.0 && lmi.1 == pc + mi_w { | ||
| 7559 | + left_mode = pmode; | ||
| 7560 | + } | ||
| 7561 | + } | ||
| 7562 | + let (above_mode, left_mode) = | ||
| 7563 | + neighbours.modes_above_left_mi(lmi.0, lmi.1, (above_mode, left_mode)); | ||
| 7564 | + let ( | ||
| 7565 | + skip, | ||
| 7566 | + mode, | ||
| 7567 | + angle_delta_y, | ||
| 7568 | + uv_mode, | ||
| 7569 | + angle_delta_uv, | ||
| 7570 | + alpha, | ||
| 7571 | + filter_intra, | ||
| 7572 | + palette_y, | ||
| 7573 | + palette_uv, | ||
| 7574 | + ) = read_intra_mode_rect( | ||
| 7575 | + dec, | ||
| 7576 | + cdfs, | ||
| 7577 | + above_mode, | ||
| 7578 | + left_mode, | ||
| 7579 | + true, | ||
| 7580 | + has_chroma, | ||
| 7581 | + bw, | ||
| 7582 | + bh, | ||
| 7583 | + enable_filter_intra, | ||
| 7584 | + neighbours.skip_txfm_ctx(lmi.0, lmi.1), | ||
| 7585 | + allow_screen_content_tools, | ||
| 7586 | + None, | ||
| 7587 | + &[], | ||
| 7588 | + lmi.0, | ||
| 7589 | + lmi.1, | ||
| 7590 | + )?; | ||
| 7591 | + if palette_y.is_some() || palette_uv.is_some() { | ||
| 7592 | + return Err(unsupported( | ||
| 7593 | + "a 1:4 rect strip that actually uses a palette (reconstruction is not ported at this shape)", | ||
| 7594 | + )); | ||
| 7595 | + } | ||
| 7596 | + let smooth_neighbor = is_smooth_mode(above_mode) || is_smooth_mode(left_mode); | ||
| 7597 | + if smooth_neighbor { | ||
| 7598 | + SMOOTH_LUMA_HITS.with(|h| h.set(h.get() + 1)); | ||
| 7599 | + } | ||
| 7600 | + if filter_intra.is_some() { | ||
| 7601 | + FILTER_INTRA_RECT_HITS.with(|h| h.set(h.get() + 1)); | ||
| 7602 | + } | ||
| 7603 | + // `bsize_to_tx_size_cat(BLOCK_16X4)`: `max_txsize_rect_lookup` is | ||
| 7604 | + // TX_16X4 and `sub_tx_size_map` reaches TX_4X4 in two steps, so the | ||
| 7605 | + // depth symbol is the 3-symbol `tx_size_cat1` -- not the 2-symbol | ||
| 7606 | + // `cat0` a 4x8 leaf reads nor the `cat2` a 32x8 strip does. | ||
| 7607 | + let depth = if tx_select { | ||
| 7608 | + let ctx = tx_size_context_rect(neighbours, lmi, bw, bh); | ||
| 7609 | + dec.symbol(&mut cdfs.tx_size_cat1[ctx]) | ||
| 7610 | + } else { | ||
| 7611 | + 0 | ||
| 7612 | + }; | ||
| 7613 | + if depth != 0 { | ||
| 7614 | + TX_DEPTH_HITS.with(|h| h.set(h.get() + 1)); | ||
| 7615 | + RECT4_16_SPLIT_HITS.with(|h| h.set(h.get() + 1)); | ||
| 7616 | + } | ||
| 7617 | + let (tx_w, tx_h) = depth_to_tx_wh(bw, bh, depth); | ||
| 7618 | + let (px, py) = (lmi.1 * MI, lmi.0 * MI); | ||
| 7619 | + let reach = Reach::of_rect(bw, bh, px, py, y.width, y.height); | ||
| 7620 | + neighbours.record_mode_mi(lmi.0, lmi.1, mi_w, mi_h, mode); | ||
| 7621 | + if depth != 0 { | ||
| 7622 | + // [`decode_rect_split`]'s per-unit walk, inlined because the | ||
| 7623 | + // CHROMA of this shape belongs to the strip's 4:2:0 pair, not to | ||
| 7624 | + // the strip (that function codes one chroma transform per block). | ||
| 7625 | + // depth 1 is the 2:1 rect unit TX_8X4/TX_4X8 | ||
| 7626 | + // (`sub_tx_size_map[TX_16X4]`), depth 2 the square TX_4X4; each | ||
| 7627 | + // unit predicts off the units before it in raster order. | ||
| 7628 | + let rect_unit = tx_w != tx_h; | ||
| 7629 | + let zero_tu = vec![0i32; tx_w * tx_h]; | ||
| 7630 | + for tu_row in 0..bh / tx_h { | ||
| 7631 | + for tu_col in 0..bw / tx_w { | ||
| 7632 | + let tu_mi = (lmi.0 + tu_row * (tx_h / MI), lmi.1 + tu_col * (tx_w / MI)); | ||
| 7633 | + let (tu_px, tu_py) = (px + tu_col * tx_w, py + tu_row * tx_h); | ||
| 7634 | + let tu_reach = Reach::of_tu( | ||
| 7635 | + bw, | ||
| 7636 | + bh, | ||
| 7637 | + tu_col * tx_w, | ||
| 7638 | + tu_row * tx_h, | ||
| 7639 | + tx_w, | ||
| 7640 | + tx_h, | ||
| 7641 | + reach, | ||
| 7642 | + ); | ||
| 7643 | + if skip { | ||
| 7644 | + y.reconstruct_rect( | ||
| 7645 | + tu_px, tu_py, tx_w, tx_h, mode, angle_delta_y, tu_reach, &zero_tu, | ||
| 7646 | + None, filter_intra, smooth_neighbor, | ||
| 7647 | + ); | ||
| 7648 | + neighbours.record_mi_luma_rect(tu_mi, tx_w, tx_h, &zero_tu); | ||
| 7649 | + } else if rect_unit { | ||
| 7650 | + // `get_txsize_entropy_ctx(TX_8X4)` is the 8x8 class with | ||
| 7651 | + // 32 coded positions and the `TX_4X4` `tx_type` row: | ||
| 7652 | + // exactly [`TxbSet::LumaRect4x8`]. | ||
| 7653 | + let tu_around = neighbours.around_mi_rect(tu_mi, tx_w, tx_h)[0]; | ||
| 7654 | + let tu_skip_ctx = | ||
| 7655 | + neighbours.luma_skip_ctx_rect(tu_mi, tx_w / MI, tx_h / MI); | ||
| 7656 | + let set = if reduced_tx_set { | ||
| 7657 | + TxbSet::LumaRect4x8 | ||
| 7658 | + } else { | ||
| 7659 | + TxbSet::LumaRect4x8Set1 | ||
| 7660 | + }; | ||
| 7661 | + let tu_scan: &[u16] = if tx_w > tx_h { &SCAN_8X4 } else { &SCAN_4X8 }; | ||
| 7662 | + let mut coding = cdfs.txb(set, fi_tx_row(mode, filter_intra)); | ||
| 7663 | + let (tu_grid, tu_tx_type) = read_coeffs_rect( | ||
| 7664 | + dec, | ||
| 7665 | + &mut coding, | ||
| 7666 | + tu_scan, | ||
| 7667 | + tx_w, | ||
| 7668 | + tx_h, | ||
| 7669 | + tu_skip_ctx, | ||
| 7670 | + dc_sign_ctx(tu_around.2), | ||
| 7671 | + TxType::DctDct, | ||
| 7672 | + )?; | ||
| 7673 | + let residual = dequant_and_inverse_typed_wh( | ||
| 7674 | + &tu_grid, | ||
| 7675 | + tx_w, | ||
| 7676 | + tx_h, | ||
| 7677 | + crate::decode::bit_depth(), | ||
| 7678 | + block_q_idx(), | ||
| 7679 | + plane_q_delta(0).0, | ||
| 7680 | + plane_q_delta(0).1, | ||
| 7681 | + tu_tx_type, | ||
| 7682 | + ); | ||
| 7683 | + y.reconstruct_rect( | ||
| 7684 | + tu_px, tu_py, tx_w, tx_h, mode, angle_delta_y, tu_reach, &residual, | ||
| 7685 | + None, filter_intra, smooth_neighbor, | ||
| 7686 | + ); | ||
| 7687 | + if tu_grid.iter().any(|&l| l != 0) { | ||
| 7688 | + RECT4_16_COEFF_HITS.with(|h| h.set(h.get() + 1)); | ||
| 7689 | + } | ||
| 7690 | + neighbours.record_mi_luma_rect(tu_mi, tx_w, tx_h, &tu_grid); | ||
| 7691 | + } else { | ||
| 7692 | + let tu_around = neighbours.around_mi(tu_mi, tx_w)[0]; | ||
| 7693 | + let tu_skip_ctx = neighbours.luma_skip_ctx(tu_mi, tx_w / MI); | ||
| 7694 | + let tu_grid = read_plane( | ||
| 7695 | + dec, | ||
| 7696 | + cdfs, | ||
| 7697 | + txbset_for(tx_w, reduced_tx_set), | ||
| 7698 | + &default_scan(tx_w), | ||
| 7699 | + 0, | ||
| 7700 | + tu_around, | ||
| 7701 | + mode, | ||
| 7702 | + mode, | ||
| 7703 | + angle_delta_y, | ||
| 7704 | + tu_reach, | ||
| 7705 | + y, | ||
| 7706 | + tu_px, | ||
| 7707 | + tu_py, | ||
| 7708 | + tx_w, | ||
| 7709 | + tx_w, | ||
| 7710 | + base_q_idx, | ||
| 7711 | + None, | ||
| 7712 | + filter_intra, | ||
| 7713 | + Some(tu_skip_ctx), | ||
| 7714 | + smooth_neighbor, | ||
| 7715 | + )?; | ||
| 7716 | + if tu_grid.iter().any(|&l| l != 0) { | ||
| 7717 | + RECT4_16_COEFF_HITS.with(|h| h.set(h.get() + 1)); | ||
| 7718 | + } | ||
| 7719 | + neighbours.record_mi_luma(tu_mi, tx_w, &tu_grid); | ||
| 7720 | + } | ||
| 7721 | + } | ||
| 7722 | + } | ||
| 7723 | + } else { | ||
| 7724 | + let levels = if skip { | ||
| 7725 | + let zeros = vec![0i32; bw * bh]; | ||
| 7726 | + y.reconstruct_rect( | ||
| 7727 | + px, py, bw, bh, mode, angle_delta_y, reach, &zeros, None, filter_intra, | ||
| 7728 | + smooth_neighbor, | ||
| 7729 | + ); | ||
| 7730 | + zeros | ||
| 7731 | + } else { | ||
| 7732 | + // The strip's luma TU *is* the strip (`plane_bsize == | ||
| 7733 | + // txsize_to_bsize[tx_size]`), so `get_txb_ctx` fixes | ||
| 7734 | + // `txb_skip_ctx` at 0. | ||
| 7735 | + let around = neighbours.around_mi_rect(lmi, bw, bh)[0]; | ||
| 7736 | + let set = if reduced_tx_set { | ||
| 7737 | + TxbSet::LumaRect16x4 | ||
| 7738 | + } else { | ||
| 7739 | + TxbSet::LumaRect16x4Set1 | ||
| 7740 | + }; | ||
| 7741 | + let mut coding = cdfs.txb(set, fi_tx_row(mode, filter_intra)); | ||
| 7742 | + let (levels, tx_type) = read_coeffs_rect( | ||
| 7743 | + dec, | ||
| 7744 | + &mut coding, | ||
| 7745 | + scan, | ||
| 7746 | + bw, | ||
| 7747 | + bh, | ||
| 7748 | + 0, | ||
| 7749 | + dc_sign_ctx(around.2), | ||
| 7750 | + TxType::DctDct, | ||
| 7751 | + )?; | ||
| 7752 | + let residual = dequant_and_inverse_typed_wh( | ||
| 7753 | + &levels, | ||
| 7754 | + bw, | ||
| 7755 | + bh, | ||
| 7756 | + crate::decode::bit_depth(), | ||
| 7757 | + block_q_idx(), | ||
| 7758 | + plane_q_delta(0).0, | ||
| 7759 | + plane_q_delta(0).1, | ||
| 7760 | + tx_type, | ||
| 7761 | + ); | ||
| 7762 | + y.reconstruct_rect( | ||
| 7763 | + px, py, bw, bh, mode, angle_delta_y, reach, &residual, None, filter_intra, | ||
| 7764 | + smooth_neighbor, | ||
| 7765 | + ); | ||
| 7766 | + RECT4_16_COEFF_HITS.with(|h| h.set(h.get() + 1)); | ||
| 7767 | + levels | ||
| 7768 | + }; | ||
| 7769 | + neighbours.record_mi_luma_rect(lmi, bw, bh, &levels); | ||
| 7770 | + } | ||
| 7771 | + neighbours.fill_skip_grid_rect(lmi, mi_w, mi_h, skip); | ||
| 7772 | + neighbours.fill_lf_grid_rect(lmi, mi_w, mi_h, tx_w as u8, tx_h as u8, 0); | ||
| 7773 | + // `update_partition_context` writes `partition_context_lookup[ | ||
| 7774 | + // BLOCK_16X4]` over the whole 16x16: full width above, a 4-px side on | ||
| 7775 | + // the left (mirrored under VERT_4). | ||
| 7776 | + for cell in 0..mi_w { | ||
| 7777 | + if let Some(slot) = neighbours.above_side_mi.get_mut(lmi.1 + cell) { | ||
| 7778 | + *slot = bw; | ||
| 7779 | + } | ||
| 7780 | + } | ||
| 7781 | + for cell in 0..mi_h { | ||
| 7782 | + if let Some(slot) = neighbours.left_side_mi.get_mut(lmi.0 + cell) { | ||
| 7783 | + *slot = bh; | ||
| 7784 | + } | ||
| 7785 | + } | ||
| 7786 | + if has_chroma { | ||
| 7787 | + RECT4_16_CHROMA_HITS.with(|h| h.set(h.get() + 1)); | ||
| 7788 | + let pair_mi = if horz { | ||
| 7789 | + (lmi.0 - 1, lmi.1) | ||
| 7790 | + } else { | ||
| 7791 | + (lmi.0, lmi.1 - 1) | ||
| 7792 | + }; | ||
| 7793 | + let (pw, ph) = if horz { (16, 8) } else { (8, 16) }; | ||
| 7794 | + let (ppx, ppy) = (pair_mi.1 * MI, pair_mi.0 * MI); | ||
| 7795 | + let (cpx, cpy) = (ppx / 2, ppy / 2); | ||
| 7796 | + let (cw, ch) = (pw / 2, ph / 2); | ||
| 7797 | + let uv_predict_mode = if uv_mode == UV_CFL_PRED { DC_PRED } else { uv_mode }; | ||
| 7798 | + let pair_reach = Reach::of_rect(pw, ph, ppx, ppy, y.width, y.height); | ||
| 7799 | + let smooth_neighbor_uv = neighbours.smooth_uv_neighbour(lmi.0, lmi.1, r, c); | ||
| 7800 | + let (u_levels, v_levels) = if skip { | ||
| 7801 | + let zeros = vec![0i32; cw * ch]; | ||
| 7802 | + for (buf, _plane) in [(&mut *u, 1usize), (&mut *v, 2)] { | ||
| 7803 | + buf.reconstruct_rect( | ||
| 7804 | + cpx, | ||
| 7805 | + cpy, | ||
| 7806 | + cw, | ||
| 7807 | + ch, | ||
| 7808 | + uv_predict_mode, | ||
| 7809 | + angle_delta_uv, | ||
| 7810 | + pair_reach, | ||
| 7811 | + &zeros, | ||
| 7812 | + None, | ||
| 7813 | + None, | ||
| 7814 | + smooth_neighbor_uv, | ||
| 7815 | + ); | ||
| 7816 | + } | ||
| 7817 | + (zeros.clone(), zeros) | ||
| 7818 | + } else { | ||
| 7819 | + let around = neighbours.around_mi_rect(pair_mi, pw, ph); | ||
| 7820 | + let mut planes = Vec::with_capacity(2); | ||
| 7821 | + for plane in 1..3 { | ||
| 7822 | + let default_tx = default_intra_tx_type(uv_predict_mode as u8); | ||
| 7823 | + let skip_ctx = usize::from(around[plane].0) + usize::from(around[plane].1); | ||
| 7824 | + let mut coding = cdfs.txb(TxbSet::ChromaRect8x4, uv_predict_mode); | ||
| 7825 | + let (levels, tx_type) = read_coeffs_rect( | ||
| 7826 | + dec, | ||
| 7827 | + &mut coding, | ||
| 7828 | + chroma_scan, | ||
| 7829 | + cw, | ||
| 7830 | + ch, | ||
| 7831 | + skip_ctx, | ||
| 7832 | + dc_sign_ctx(around[plane].2), | ||
| 7833 | + default_tx, | ||
| 7834 | + )?; | ||
| 7835 | + planes.push((levels, tx_type)); | ||
| 7836 | + } | ||
| 7837 | + let (v_levels, v_tx_type) = planes.pop().expect("plane 2"); | ||
| 7838 | + let (u_levels, u_tx_type) = planes.pop().expect("plane 1"); | ||
| 7839 | + // CfL averages the luma of the WHOLE pair, the region this one | ||
| 7840 | + // chroma transform covers. | ||
| 7841 | + let ac = alpha.map(|_| cfl_ac_q3_rect(y, ppx, ppy, pw, ph)); | ||
| 7842 | + for (plane, buf, levels, tx_type) in [ | ||
| 7843 | + (1usize, &mut *u, &u_levels, u_tx_type), | ||
| 7844 | + (2, &mut *v, &v_levels, v_tx_type), | ||
| 7845 | + ] { | ||
| 7846 | + let residual = dequant_and_inverse_typed_wh( | ||
| 7847 | + levels, | ||
| 7848 | + cw, | ||
| 7849 | + ch, | ||
| 7850 | + crate::decode::bit_depth(), | ||
| 7851 | + block_q_idx(), | ||
| 7852 | + plane_q_delta(plane).0, | ||
| 7853 | + plane_q_delta(plane).1, | ||
| 7854 | + tx_type, | ||
| 7855 | + ); | ||
| 7856 | + buf.reconstruct_rect( | ||
| 7857 | + cpx, | ||
| 7858 | + cpy, | ||
| 7859 | + cw, | ||
| 7860 | + ch, | ||
| 7861 | + uv_predict_mode, | ||
| 7862 | + angle_delta_uv, | ||
| 7863 | + pair_reach, | ||
| 7864 | + &residual, | ||
| 7865 | + alpha | ||
| 7866 | + .zip(ac.as_deref()) | ||
| 7867 | + .map(|((au, av), ac)| (if plane == 1 { au } else { av }, ac)), | ||
| 7868 | + None, | ||
| 7869 | + smooth_neighbor_uv, | ||
| 7870 | + ); | ||
| 7871 | + } | ||
| 7872 | + (u_levels, v_levels) | ||
| 7873 | + }; | ||
| 7874 | + neighbours.record_uv_mode_mi(pair_mi.0, pair_mi.1, pw / MI, ph / MI, uv_predict_mode); | ||
| 7875 | + // The chroma planes' coefficient context, over the PAIR's mi span | ||
| 7876 | + // (`decode_leaf_rect8`'s own rule: a subsampled plane's bound is | ||
| 7877 | + // the luma one rounded up to its 4x4 unit). | ||
| 7878 | + let u_state = neighbour_state(&u_levels); | ||
| 7879 | + let v_state = neighbour_state(&v_levels); | ||
| 7880 | + let round_up_even = |n: usize| n.div_ceil(2) * 2; | ||
| 7881 | + let bound_h = round_up_even(neighbours.mi_rows); | ||
| 7882 | + let bound_w = round_up_even(neighbours.mi_cols); | ||
| 7883 | + for cell in 0..(ph / MI) { | ||
| 7884 | + if pair_mi.0 + cell < bound_h | ||
| 7885 | + && let Some(slot) = neighbours.left.get_mut(pair_mi.0 + cell) | ||
| 7886 | + { | ||
| 7887 | + slot[1] = u_state; | ||
| 7888 | + slot[2] = v_state; | ||
| 7889 | + } | ||
| 7890 | + } | ||
| 7891 | + for cell in 0..(pw / MI) { | ||
| 7892 | + if pair_mi.1 + cell < bound_w | ||
| 7893 | + && let Some(slot) = neighbours.above.get_mut(pair_mi.1 + cell) | ||
| 7894 | + { | ||
| 7895 | + slot[1] = u_state; | ||
| 7896 | + slot[2] = v_state; | ||
| 7897 | + } | ||
| 7898 | + } | ||
| 7899 | + last_uv_mode = uv_predict_mode; | ||
| 7900 | + } | ||
| 7901 | + if horz { | ||
| 7902 | + RECT4_16_HORZ_HITS.with(|h| h.set(h.get() + 1)); | ||
| 7903 | + } else { | ||
| 7904 | + RECT4_16_VERT_HITS.with(|h| h.set(h.get() + 1)); | ||
| 7905 | + } | ||
| 7906 | + last_mode = mode; | ||
| 7907 | + prev = Some((lmi, mode)); | ||
| 7908 | + } | ||
| 7909 | + // The coarse 16-px cell holds one entry for the whole 16x16: the last | ||
| 7910 | + // strip is what a block below (right) sees through it, the mi-exact maps | ||
| 7911 | + // above answering everything finer. | ||
| 7912 | + neighbours.above_mode[c] = last_mode; | ||
| 7913 | + neighbours.left_mode[r] = last_mode; | ||
| 7914 | + neighbours.above_uv_mode[c] = last_uv_mode; | ||
| 7915 | + neighbours.left_uv_mode[r] = last_uv_mode; | ||
| 7916 | + neighbours.above_side[c] = bw; | ||
| 7917 | + neighbours.left_side[r] = bh; | ||
| 7918 | + Ok(()) | ||
| 7919 | +} | ||
| 7920 | + | ||
| 7350 | /// Decodes one true `bw`x`bh` superblock-level `PARTITION_HORZ`/ | 7921 | /// Decodes one true `bw`x`bh` superblock-level `PARTITION_HORZ`/ |
| 7351 | /// `PARTITION_VERT` strip (lane-sbpart r2, `bw, bh` one of `(64, 32)` / | 7922 | /// `PARTITION_VERT` strip (lane-sbpart r2, `bw, bh` one of `(64, 32)` / |
| 7352 | /// `(32, 64)` -- [`decode_block_rect`]'s own sibling one level up). Unlike | 7923 | /// `(32, 64)` -- [`decode_block_rect`]'s own sibling one level up). Unlike |
| @@ -7400,6 +7971,7 @@ fn decode_block_rect64( | |||
| 7400 | // the real 13-symbol `uv_mode_no_cfl` one and desynced the tile | 7971 | // the real 13-symbol `uv_mode_no_cfl` one and desynced the tile |
| 7401 | // from this block's very first symbol (lane-sbpart r3 bisect). | 7972 | // from this block's very first symbol (lane-sbpart r3 bisect). |
| 7402 | false, | 7973 | false, |
| 7974 | + true, | ||
| 7403 | bw, | 7975 | bw, |
| 7404 | bh, | 7976 | bh, |
| 7405 | enable_filter_intra, | 7977 | enable_filter_intra, |
| @@ -10970,7 +11542,19 @@ fn read_block_tx_size( | |||
| 10970 | /// `DTT9_IDTX_1DDCT` row at `tx_size_sqr == TX_8X8`, only reachable through a | 11542 | /// `DTT9_IDTX_1DDCT` row at `tx_size_sqr == TX_8X8`, only reachable through a |
| 10971 | /// rect transform), neither of which exists yet -- both stay refused by name. | 11543 | /// rect transform), neither of which exists yet -- both stay refused by name. |
| 10972 | fn rect_inter_residual_supported(w: usize, h: usize) -> bool { | 11544 | fn rect_inter_residual_supported(w: usize, h: usize) -> bool { |
| 10973 | - matches!((w, h), (32, 16) | (16, 32) | (16, 8) | (8, 16)) | 11545 | + matches!( |
| 11546 | + (w, h), | ||
| 11547 | + // 2:1 strips whose transform is coded in full (lane-inter4). | ||
| 11548 | + (32, 16) | (16, 32) | (16, 8) | (8, 16) | ||
| 11549 | + // lane-r14 r2: strips with a 64-px axis. `av1_get_max_eob` codes | ||
| 11550 | + // only the low 32 coefficients of a 64-length axis, so these read | ||
| 11551 | + // exactly the truncated corner the INTRA superblock-strip path | ||
| 11552 | + // already reads (`read_intra_mode_rect`), through | ||
| 11553 | + // `av1_get_adjusted_tx_size`'s CDF set. Their `tx_size_sqr_up` is | ||
| 11554 | + // `TX_64X64`, so `av1_get_ext_tx_set_type` is `DCT_ONLY` and no | ||
| 11555 | + // `tx_type` symbol is coded at all. | ||
| 11556 | + | (64, 32) | (32, 64) | (64, 16) | (16, 64) | ||
| 11557 | + ) | ||
| 10974 | } | 11558 | } |
| 10975 | 11559 | ||
| 10976 | /// The luma coefficient/`tx_type` table set of a whole-block rectangular | 11560 | /// The luma coefficient/`tx_type` table set of a whole-block rectangular |
| @@ -10991,6 +11575,13 @@ fn rect_inter_luma_set(w: usize, h: usize) -> TxbSet { | |||
| 10991 | TxbSet::LumaRect16x8InterSet1 | 11575 | TxbSet::LumaRect16x8InterSet1 |
| 10992 | } | 11576 | } |
| 10993 | } | 11577 | } |
| 11578 | + // lane-r14 r2: `av1_get_adjusted_tx_size` maps TX_64X32/TX_32X64 to | ||
| 11579 | + // TX_32X32 and TX_64X16/TX_16X64 to TX_32X16/TX_16X32, and | ||
| 11580 | + // `get_txsize_entropy_ctx`/`txsize_log2_minus4` agree with the | ||
| 11581 | + // adjusted size, so the existing sets are bit-exact. Neither carries a | ||
| 11582 | + // `tx_type` table (DCT_ONLY above), so the intra/inter split is moot. | ||
| 11583 | + (64, 32) | (32, 64) => TxbSet::Luma64, | ||
| 11584 | + (64, 16) | (16, 64) => TxbSet::LumaRect32x16, | ||
| 10994 | _ => unreachable!("rect_inter_residual_supported gates every shape that reaches here"), | 11585 | _ => unreachable!("rect_inter_residual_supported gates every shape that reaches here"), |
| 10995 | } | 11586 | } |
| 10996 | } | 11587 | } |
| @@ -11003,6 +11594,13 @@ fn rect_inter_chroma_set(w: usize, h: usize) -> TxbSet { | |||
| 11003 | match (w, h) { | 11594 | match (w, h) { |
| 11004 | (16, 8) | (8, 16) => TxbSet::ChromaRect16x8, | 11595 | (16, 8) | (8, 16) => TxbSet::ChromaRect16x8, |
| 11005 | (8, 4) | (4, 8) => TxbSet::ChromaRect8x4, | 11596 | (8, 4) | (4, 8) => TxbSet::ChromaRect8x4, |
| 11597 | + // lane-r14 r2: chroma of a 64-axis strip -- 32x16/16x32 under a | ||
| 11598 | + // 64x32/32x64 one, 32x8/8x32 under a 64x16/16x64 one. Neither chroma | ||
| 11599 | + // unit has a 64-px axis, so both are coded in full; `Chroma16` is the | ||
| 11600 | + // exact set for TX_32X8/TX_8X32 (`get_txsize_entropy_ctx` = TX_16X16, | ||
| 11601 | + // `txsize_log2_minus4` = 4), same as the intra strip path uses. | ||
| 11602 | + (32, 16) | (16, 32) => TxbSet::ChromaRect32x16, | ||
| 11603 | + (32, 8) | (8, 32) => TxbSet::Chroma16, | ||
| 11006 | _ => unreachable!("rect_inter_residual_supported gates every shape that reaches here"), | 11604 | _ => unreachable!("rect_inter_residual_supported gates every shape that reaches here"), |
| 11007 | } | 11605 | } |
| 11008 | } | 11606 | } |
| @@ -11048,6 +11646,8 @@ fn rect_scan(w: usize, h: usize) -> &'static [u16] { | |||
| 11048 | (8, 16) => &SCAN_8X16, | 11646 | (8, 16) => &SCAN_8X16, |
| 11049 | (8, 4) => &SCAN_8X4, | 11647 | (8, 4) => &SCAN_8X4, |
| 11050 | (4, 8) => &SCAN_4X8, | 11648 | (4, 8) => &SCAN_4X8, |
| 11649 | + (32, 8) => &SCAN_32X8, | ||
| 11650 | + (8, 32) => &SCAN_8X32, | ||
| 11051 | _ => unreachable!("rect_inter_residual_supported gates every shape that reaches here"), | 11651 | _ => unreachable!("rect_inter_residual_supported gates every shape that reaches here"), |
| 11052 | } | 11652 | } |
| 11053 | } | 11653 | } |
| @@ -11114,6 +11714,16 @@ fn read_block_tx_size_rect( | |||
| 11114 | } | 11714 | } |
| 11115 | TXFM_SPLIT_HITS.with(|c| c.set(c.get() + 1)); | 11715 | TXFM_SPLIT_HITS.with(|c| c.set(c.get() + 1)); |
| 11116 | RECT_INTER_TXSPLIT_HITS.with(|c| c.set(c.get() + 1)); | 11716 | RECT_INTER_TXSPLIT_HITS.with(|c| c.set(c.get() + 1)); |
| 11717 | + // lane-r14 r2: `sub_tx_size_map` is square for every shape this decoder | ||
| 11718 | + // splits (TX_32X16 -> TX_16X16, TX_64X32 -> TX_32X32) EXCEPT the 1:4 | ||
| 11719 | + // strips with a 64-px axis, where it stays rectangular | ||
| 11720 | + // (TX_64X16 -> TX_32X16, TX_16X64 -> TX_16X32) and the square recursion | ||
| 11721 | + // below would code the wrong tree. | ||
| 11722 | + if tx_w.max(tx_h) == 64 && tx_w.min(tx_h) == 16 { | ||
| 11723 | + return Err(unsupported( | ||
| 11724 | + "a split transform on a 1:4 inter strip with a 64-px axis", | ||
| 11725 | + )); | ||
| 11726 | + } | ||
| 11117 | let sub = tx_w.min(tx_h); | 11727 | let sub = tx_w.min(tx_h); |
| 11118 | let max_w_mi = (bw / MI).min(mi_cols.saturating_sub(at_mi.1)); | 11728 | let max_w_mi = (bw / MI).min(mi_cols.saturating_sub(at_mi.1)); |
| 11119 | let max_h_mi = (bh / MI).min(mi_rows.saturating_sub(at_mi.0)); | 11729 | let max_h_mi = (bh / MI).min(mi_rows.saturating_sub(at_mi.0)); |
| @@ -11177,16 +11787,50 @@ fn read_inter_plane_rect( | |||
| 11177 | Some(t) if w.max(h) < 32 => t, | 11787 | Some(t) if w.max(h) < 32 => t, |
| 11178 | _ => TxType::DctDct, | 11788 | _ => TxType::DctDct, |
| 11179 | }; | 11789 | }; |
| 11180 | - let (grid, tx_type) = read_coeffs_rect( | 11790 | + // lane-r14 r2: a 64-length axis codes only its low 32 coefficients |
| 11181 | - dec, | 11791 | + // (`av1_get_max_eob`), so the coded unit is the `min(w,32) x min(h,32)` |
| 11182 | - &mut coding, | 11792 | + // corner, zero-extended into the true `w x h` grid before the inverse |
| 11183 | - rect_scan(w, h), | 11793 | + // transform -- exactly what the intra superblock-strip path does. A |
| 11184 | - w, | 11794 | + // corner that comes out square (32x32, under a 64x32/32x64 strip) reads |
| 11185 | - h, | 11795 | + // through the SQUARE coefficient reader with `rect_shape = Some((w, h))`, |
| 11186 | - skip_ctx, | 11796 | + // because `av1_nz_map_ctx_offset` is indexed by the real, un-adjusted |
| 11187 | - dc_sign_ctx(around.2), | 11797 | + // rectangular shape (lane-sbpart r8). |
| 11188 | - default_tx_type, | 11798 | + let (cw, ch) = (w.min(32), h.min(32)); |
| 11189 | - )?; | 11799 | + if plane_idx == 0 && w.max(h) == 64 { |
| 11800 | + RECT64_INTER_TU_HITS.with(|c| c.set(c.get() + 1)); | ||
| 11801 | + } | ||
| 11802 | + let (corner, tx_type) = if (cw, ch) == (32, 32) { | ||
| 11803 | + let scan32 = default_scan(TX32); | ||
| 11804 | + read_coeffs( | ||
| 11805 | + dec, | ||
| 11806 | + &mut coding, | ||
| 11807 | + &scan32, | ||
| 11808 | + skip_ctx, | ||
| 11809 | + dc_sign_ctx(around.2), | ||
| 11810 | + default_tx_type, | ||
| 11811 | + Some((w, h)), | ||
| 11812 | + )? | ||
| 11813 | + } else { | ||
| 11814 | + read_coeffs_rect( | ||
| 11815 | + dec, | ||
| 11816 | + &mut coding, | ||
| 11817 | + rect_scan(cw, ch), | ||
| 11818 | + cw, | ||
| 11819 | + ch, | ||
| 11820 | + skip_ctx, | ||
| 11821 | + dc_sign_ctx(around.2), | ||
| 11822 | + default_tx_type, | ||
| 11823 | + )? | ||
| 11824 | + }; | ||
| 11825 | + let grid = if (cw, ch) == (w, h) { | ||
| 11826 | + corner | ||
| 11827 | + } else { | ||
| 11828 | + let mut full = vec![0i32; w * h]; | ||
| 11829 | + for row in 0..ch { | ||
| 11830 | + full[row * w..][..cw].copy_from_slice(&corner[row * cw..][..cw]); | ||
| 11831 | + } | ||
| 11832 | + full | ||
| 11833 | + }; | ||
| 11190 | let (dc_delta, ac_delta) = plane_q_delta(plane_idx); | 11834 | let (dc_delta, ac_delta) = plane_q_delta(plane_idx); |
| 11191 | let residual = dequant_and_inverse_typed_wh( | 11835 | let residual = dequant_and_inverse_typed_wh( |
| 11192 | &grid, | 11836 | &grid, |
| @@ -12157,6 +12801,131 @@ pub(crate) fn take_last_frame_wide_margin() -> Option<Picture> { | |||
| 12157 | /// PRIMARY_REF_NONE`). Returns the tile's own end-of-tile adapted table | 12801 | /// PRIMARY_REF_NONE`). Returns the tile's own end-of-tile adapted table |
| 12158 | /// alongside the picture, for the caller to save into whichever reference | 12802 | /// alongside the picture, for the caller to save into whichever reference |
| 12159 | /// slots this frame's `refresh_frame_flags` names. | 12803 | /// slots this frame's `refresh_frame_flags` names. |
| 12804 | +/// The order the 64x64 superblock quadrants of a tile are decoded in. | ||
| 12805 | +/// | ||
| 12806 | +/// At `sb_size == 64` this is plain raster order over the tile's own | ||
| 12807 | +/// superblock grid. At `sb_size == 128` libaom's `decode_partition` recurses | ||
| 12808 | +/// each 128x128 superblock in raster order and visits its four 64x64 | ||
| 12809 | +/// quadrants (TL, TR, BL, BR) before moving to the next superblock, so the | ||
| 12810 | +/// 64-level bodies must run in that nested order. `row_start` marks the first | ||
| 12811 | +/// item of each *superblock* row (where the left neighbour context resets), | ||
| 12812 | +/// `sb_start` the first item of each superblock (where the 128 root's own | ||
| 12813 | +/// loop-restoration units and partition symbol are read). | ||
| 12814 | +fn sb_visit_order(r0: u32, r1: u32, c0: u32, c1: u32, sb128: bool) -> Vec<(u32, u32, bool, bool)> { | ||
| 12815 | + let mut out = Vec::new(); | ||
| 12816 | + if !sb128 { | ||
| 12817 | + for r in r0..r1 { | ||
| 12818 | + for c in c0..c1 { | ||
| 12819 | + out.push((r, c, c == c0, true)); | ||
| 12820 | + } | ||
| 12821 | + } | ||
| 12822 | + return out; | ||
| 12823 | + } | ||
| 12824 | + let mut r = r0; | ||
| 12825 | + while r < r1 { | ||
| 12826 | + let mut first_in_row = true; | ||
| 12827 | + let mut c = c0; | ||
| 12828 | + while c < c1 { | ||
| 12829 | + let mut first_in_sb = true; | ||
| 12830 | + for qr in 0..2 { | ||
| 12831 | + for qc in 0..2 { | ||
| 12832 | + let (rr, cc) = (r + qr, c + qc); | ||
| 12833 | + if rr >= r1 || cc >= c1 { | ||
| 12834 | + continue; | ||
| 12835 | + } | ||
| 12836 | + out.push((rr, cc, first_in_row, first_in_sb)); | ||
| 12837 | + first_in_row = false; | ||
| 12838 | + first_in_sb = false; | ||
| 12839 | + } | ||
| 12840 | + } | ||
| 12841 | + c += 2; | ||
| 12842 | + } | ||
| 12843 | + r += 2; | ||
| 12844 | + } | ||
| 12845 | + out | ||
| 12846 | +} | ||
| 12847 | + | ||
| 12848 | +/// lane-sb128 r2: the 128x128 superblock root, shared by the key-frame and | ||
| 12849 | +/// the inter tile loop. Its loop-restoration units are read once for the whole | ||
| 12850 | +/// 128x128 (spec 5.11.57 is called with the superblock's own size), then one | ||
| 12851 | +/// partition symbol off the `BLOCK_128X128` CDF (8 symbols, no HORZ_4/VERT_4) | ||
| 12852 | +/// decides the root -- only SPLIT recurses into the four 64x64 quadrants this | ||
| 12853 | +/// decoder codes, the other seven arms refuse by name. | ||
| 12854 | +#[allow(clippy::too_many_arguments)] | ||
| 12855 | +fn read_sb128_root( | ||
| 12856 | + dec: &mut SymbolDecoder, | ||
| 12857 | + cdfs: &mut Cdfs, | ||
| 12858 | + neighbours: &Neighbours, | ||
| 12859 | + lr: &LoopRestorationParams, | ||
| 12860 | + lr_grid: &mut crate::restoration::RestorationGrid, | ||
| 12861 | + lr_reference: &mut [( | ||
| 12862 | + crate::restoration::WienerInfo, | ||
| 12863 | + crate::restoration::SgrprojInfo, | ||
| 12864 | + ); 3], | ||
| 12865 | + sb_r: u32, | ||
| 12866 | + sb_c: u32, | ||
| 12867 | + mi_cols: u32, | ||
| 12868 | + mi_rows: u32, | ||
| 12869 | +) -> Result<()> { | ||
| 12870 | + let (mi_r128, mi_c128) = ((sb_r & !1) * SB_MI, (sb_c & !1) * SB_MI); | ||
| 12871 | + crate::restoration::read_lr( | ||
| 12872 | + dec, | ||
| 12873 | + cdfs, | ||
| 12874 | + lr, | ||
| 12875 | + lr_grid, | ||
| 12876 | + lr_reference, | ||
| 12877 | + mi_r128, | ||
| 12878 | + mi_c128, | ||
| 12879 | + SB_MI * 2, | ||
| 12880 | + ); | ||
| 12881 | + let at128 = ((mi_r128 / SUB_MI) as usize, (mi_c128 / SUB_MI) as usize); | ||
| 12882 | + let ctx128 = neighbours.partition_ctx(at128, 128); | ||
| 12883 | + let (has_cols128, has_rows128) = (mi_c128 + SB_MI < mi_cols, mi_r128 + SB_MI < mi_rows); | ||
| 12884 | + let part128 = if has_cols128 && has_rows128 { | ||
| 12885 | + PART128_SYMBOLS.with(|c| c.set(c.get() + 1)); | ||
| 12886 | + let p = dec.symbol(&mut cdfs.partition_w128[ctx128]); | ||
| 12887 | + if std::env::var_os("EC_AV1_TRACE").is_some() { | ||
| 12888 | + eprintln!("TRACE partition_w128 ctx={ctx128} value={p}"); | ||
| 12889 | + } | ||
| 12890 | + p | ||
| 12891 | + } else { | ||
| 12892 | + // lane-sb128 r4: the gathered half-out-of-frame reads DECIDE the | ||
| 12893 | + // partition, they are not a forced split -- exactly the discarded-bit | ||
| 12894 | + // defect the 64 root carries a comment about at `partition_w64`'s | ||
| 12895 | + // gathered arm. Value 1 is SPLIT; 0 is HORZ (rows out of frame) or | ||
| 12896 | + // VERT (cols out of frame), which the refusal below then names | ||
| 12897 | + // instead of silently reconstructing a split. | ||
| 12898 | + PART128_GATHERED_SYMBOLS.with(|c| c.set(c.get() + 1)); | ||
| 12899 | + match (has_cols128, has_rows128) { | ||
| 12900 | + (true, false) => { | ||
| 12901 | + if dec.symbol_fixed(&gather_of(&cdfs.partition_w128[ctx128], &VERT_ALIKE128)) == 1 { | ||
| 12902 | + PARTITION_SPLIT | ||
| 12903 | + } else { | ||
| 12904 | + PARTITION_HORZ | ||
| 12905 | + } | ||
| 12906 | + } | ||
| 12907 | + (false, true) => { | ||
| 12908 | + if dec.symbol_fixed(&gather_of(&cdfs.partition_w128[ctx128], &HORZ_ALIKE128)) == 1 { | ||
| 12909 | + PARTITION_SPLIT | ||
| 12910 | + } else { | ||
| 12911 | + PARTITION_VERT | ||
| 12912 | + } | ||
| 12913 | + } | ||
| 12914 | + _ => { | ||
| 12915 | + PART128_GATHERED_SYMBOLS.with(|c| c.set(c.get() - 1)); | ||
| 12916 | + PARTITION_SPLIT | ||
| 12917 | + } | ||
| 12918 | + } | ||
| 12919 | + }; | ||
| 12920 | + if part128 != PARTITION_SPLIT { | ||
| 12921 | + return Err(unsupported( | ||
| 12922 | + "a 128x128 superblock partition other than SPLIT (NONE/HORZ/VERT and the four AB arms at the 128 root are not decoded)", | ||
| 12923 | + )); | ||
| 12924 | + } | ||
| 12925 | + PART128_SPLIT_HITS.with(|c| c.set(c.get() + 1)); | ||
| 12926 | + Ok(()) | ||
| 12927 | +} | ||
| 12928 | + | ||
| 12160 | pub(crate) fn decode_key_frame_tile_with_cdfs( | 12929 | pub(crate) fn decode_key_frame_tile_with_cdfs( |
| 12161 | tiles: &[&[u8]], | 12930 | tiles: &[&[u8]], |
| 12162 | tile_info: &TileInfo, | 12931 | tile_info: &TileInfo, |
| @@ -12189,6 +12958,12 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | |||
| 12189 | return Err(unsupported("a frame with no mode-info grid")); | 12958 | return Err(unsupported("a frame with no mode-info grid")); |
| 12190 | } | 12959 | } |
| 12191 | ENABLE_EDGE_FILTER.with(|f| f.set(enable_edge_filter)); | 12960 | ENABLE_EDGE_FILTER.with(|f| f.set(enable_edge_filter)); |
| 12961 | + let sb128 = sb128(); | ||
| 12962 | + if sb128 && allow_intrabc { | ||
| 12963 | + return Err(unsupported( | ||
| 12964 | + "intrabc under a 128x128 superblock (libaom's av1_is_dv_valid derives the block-vector delay from sb_size, which this decoder hardcodes to 64)", | ||
| 12965 | + )); | ||
| 12966 | + } | ||
| 12192 | let (sb_cols, sb_rows) = (mi_cols.div_ceil(SB_MI), mi_rows.div_ceil(SB_MI)); | 12967 | let (sb_cols, sb_rows) = (mi_cols.div_ceil(SB_MI), mi_rows.div_ceil(SB_MI)); |
| 12193 | INTRABC_MI_GRID.with(|g| { | 12968 | INTRABC_MI_GRID.with(|g| { |
| 12194 | *g.borrow_mut() = allow_intrabc.then(|| { | 12969 | *g.borrow_mut() = allow_intrabc.then(|| { |
| @@ -12326,19 +13101,42 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | |||
| 12326 | ); | 13101 | ); |
| 12327 | TILE_HITS.with(|c| c.set(c.get() + 1)); | 13102 | TILE_HITS.with(|c| c.set(c.get() + 1)); |
| 12328 | 13103 | ||
| 12329 | - for sb_r in sb_r0..sb_r1 { | 13104 | + for (sb_r, sb_c, row_start, sb_start) in sb_visit_order(sb_r0, sb_r1, sb_c0, sb_c1, sb128) { |
| 12330 | - neighbours.start_row(); | 13105 | + if row_start { |
| 12331 | - for sb_c in sb_c0..sb_c1 { | 13106 | + neighbours.start_row(); |
| 12332 | - crate::restoration::read_lr( | 13107 | + } |
| 12333 | - &mut dec, | 13108 | + { |
| 12334 | - &mut cdfs, | 13109 | + // lane-sb128 r1: the 128 root. Its loop-restoration units are read |
| 12335 | - lr, | 13110 | + // once for the whole 128x128 (spec 5.11.57 is called with the |
| 12336 | - &mut lr_grid, | 13111 | + // superblock's own size), then one partition symbol off the |
| 12337 | - &mut lr_reference, | 13112 | + // `BLOCK_128X128` CDF (8 symbols) decides the root -- only SPLIT |
| 12338 | - sb_r * SB_MI, | 13113 | + // recurses into the four 64x64 quadrants this decoder codes. |
| 12339 | - sb_c * SB_MI, | 13114 | + if sb128 && sb_start { |
| 12340 | - SB_MI, | 13115 | + read_sb128_root( |
| 12341 | - ); | 13116 | + &mut dec, |
| 13117 | + &mut cdfs, | ||
| 13118 | + &neighbours, | ||
| 13119 | + lr, | ||
| 13120 | + &mut lr_grid, | ||
| 13121 | + &mut lr_reference, | ||
| 13122 | + sb_r, | ||
| 13123 | + sb_c, | ||
| 13124 | + mi_cols, | ||
| 13125 | + mi_rows, | ||
| 13126 | + )?; | ||
| 13127 | + } | ||
| 13128 | + if !sb128 { | ||
| 13129 | + crate::restoration::read_lr( | ||
| 13130 | + &mut dec, | ||
| 13131 | + &mut cdfs, | ||
| 13132 | + lr, | ||
| 13133 | + &mut lr_grid, | ||
| 13134 | + &mut lr_reference, | ||
| 13135 | + sb_r * SB_MI, | ||
| 13136 | + sb_c * SB_MI, | ||
| 13137 | + SB_MI, | ||
| 13138 | + ); | ||
| 13139 | + } | ||
| 12342 | CDEF_TRANSMITTED.with(|c| c.set(false)); | 13140 | CDEF_TRANSMITTED.with(|c| c.set(false)); |
| 12343 | let at = (sb_r as usize * 4, sb_c as usize * 4); | 13141 | let at = (sb_r as usize * 4, sb_c as usize * 4); |
| 12344 | let ctx = neighbours.partition_ctx(at, SB); | 13142 | let ctx = neighbours.partition_ctx(at, SB); |
| @@ -12756,11 +13554,34 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | |||
| 12756 | neighbours.left_mode[sr] = mode_right; | 13554 | neighbours.left_mode[sr] = mode_right; |
| 12757 | continue; | 13555 | continue; |
| 12758 | } | 13556 | } |
| 12759 | - if part16 != PARTITION_SPLIT { | 13557 | + if part16 == PARTITION_HORZ_4 |
| 12760 | - return Err(unsupported( | 13558 | + || part16 == PARTITION_VERT_4 |
| 12761 | - "a 1:4 partition below 16x16 (PARTITION_HORZ_4/VERT_4, four 16x4/4x16 strips -- this decoder codes NONE, HORZ, VERT, the four AB arms and a clean split at 16x16)", | 13559 | + { |
| 12762 | - )); | 13560 | + decode_rect4_16( |
| 13561 | + &mut dec, | ||
| 13562 | + &mut cdfs, | ||
| 13563 | + &mut neighbours, | ||
| 13564 | + at16, | ||
| 13565 | + part16 == PARTITION_HORZ_4, | ||
| 13566 | + &mut y, | ||
| 13567 | + &mut u, | ||
| 13568 | + &mut v, | ||
| 13569 | + enable_filter_intra, | ||
| 13570 | + allow_screen_content_tools, | ||
| 13571 | + base_q_idx, | ||
| 13572 | + tx_select, | ||
| 13573 | + reduced_tx_set, | ||
| 13574 | + )?; | ||
| 13575 | + continue; | ||
| 12763 | } | 13576 | } |
| 13577 | + // lane-r14 r2 (verifier note): every | ||
| 13578 | + // one of the 10 symbols this CDF can | ||
| 13579 | + // produce is handled above, so SPLIT | ||
| 13580 | + // is the only value that reaches | ||
| 13581 | + // here -- the refusal that used to | ||
| 13582 | + // stand here was unreachable and is | ||
| 13583 | + // gone from `refusal_inventory`. | ||
| 13584 | + debug_assert_eq!(part16, PARTITION_SPLIT); | ||
| 12764 | // A real (non-straddle) SPLIT of a | 13585 | // A real (non-straddle) SPLIT of a |
| 12765 | // whole 16x16 into four 8x8 leaves -- | 13586 | // whole 16x16 into four 8x8 leaves -- |
| 12766 | // the same recursion the straddle | 13587 | // the same recursion the straddle |
| @@ -14378,34 +15199,16 @@ fn overlappable_left( | |||
| 14378 | out | 15199 | out |
| 14379 | } | 15200 | } |
| 14380 | 15201 | ||
| 14381 | -/// `has_top_right` (`av1/common/mvref_common.c`), reduced to the | 15202 | +/// The warp-sample gather's own `has_top_right` probe (libaom `av1_findSamples` |
| 14382 | -/// square-block, fixed-64px-superblock case this decoder ever reaches: no | 15203 | +/// calls the same `mvref_common.c` function the MV stack does). lane-sb128 r2: |
| 14383 | -/// rectangular partition (`VERT`/`HORZ`/`_4`/`VERT_A`) ever produces an | 15204 | +/// this used to hardcode `SB_MI` (a 64x64 superblock) -- at `sb_size == 128` |
| 14384 | -/// inter leaf here (`xd->width == xd->height` always), so libaom's own | 15205 | +/// libaom's mask loop runs one level further and strips the top-right sample |
| 14385 | -/// rect-partition branches (`xd->width < xd->height`, `xd->width > | 15206 | +/// off blocks whose neighbour IS decoded, so a warped 128-superblock frame |
| 14386 | -/// xd->height`, `PARTITION_VERT_A`) never fire and are dropped. `bs` is the | 15207 | +/// picked up wrong warp parameters (frame 6 of the 128 inter gate). Delegates |
| 14387 | -/// block's own side in 4x4 (`mi`) units. | 15208 | +/// to the single sb-aware port in [`crate::mvstack::has_top_right`]; `bs` is |
| 15209 | +/// the block's own side in 4x4 (`mi`) units (square inter leaves only here). | ||
| 14388 | fn has_top_right(mi_row: usize, mi_col: usize, bs: usize) -> bool { | 15210 | fn has_top_right(mi_row: usize, mi_col: usize, bs: usize) -> bool { |
| 14389 | - let sb_mi_size = SB_MI as usize; | 15211 | + crate::mvstack::has_top_right(mi_row, mi_col, bs, bs) |
| 14390 | - let mask_row = mi_row & (sb_mi_size - 1); | ||
| 14391 | - let mask_col = mi_col & (sb_mi_size - 1); | ||
| 14392 | - if bs > sb_mi_size { | ||
| 14393 | - return false; | ||
| 14394 | - } | ||
| 14395 | - let mut has_tr = !((mask_row & bs != 0) && (mask_col & bs != 0)); | ||
| 14396 | - let mut b = bs; | ||
| 14397 | - while b < sb_mi_size { | ||
| 14398 | - if mask_col & b != 0 { | ||
| 14399 | - if (mask_col & (2 * b) != 0) && (mask_row & (2 * b) != 0) { | ||
| 14400 | - has_tr = false; | ||
| 14401 | - break; | ||
| 14402 | - } | ||
| 14403 | - } else { | ||
| 14404 | - break; | ||
| 14405 | - } | ||
| 14406 | - b <<= 1; | ||
| 14407 | - } | ||
| 14408 | - has_tr | ||
| 14409 | } | 15212 | } |
| 14410 | 15213 | ||
| 14411 | /// `av1_findSamples` (`mvref_common.c`), full port: the up to | 15214 | /// `av1_findSamples` (`mvref_common.c`), full port: the up to |
| @@ -15597,6 +16400,22 @@ fn decode_inter_block( | |||
| 15597 | force_integer_mv, | 16400 | force_integer_mv, |
| 15598 | (gm_table[(ref0 - LAST_FRAME) as usize], gm_table[(ref1 - LAST_FRAME) as usize]), | 16401 | (gm_table[(ref0 - LAST_FRAME) as usize], gm_table[(ref1 - LAST_FRAME) as usize]), |
| 15599 | ); | 16402 | ); |
| 16403 | + if std::env::var_os("EC_TRACE_MODE").is_some() { | ||
| 16404 | + eprintln!( | ||
| 16405 | + "EC_MODE_VAL mi_row={mi_row} mi_col={mi_col} mode={} ref0={ref0} ref1={ref1} mv0=({},{}) stack={} rng={}", | ||
| 16406 | + compound_mode + 17, | ||
| 16407 | + mv0.0, | ||
| 16408 | + mv0.1, | ||
| 16409 | + comp_stack.entries.len(), | ||
| 16410 | + dec.debug_state().0 | ||
| 16411 | + ); | ||
| 16412 | + for (i, e) in comp_stack.entries.iter().enumerate() { | ||
| 16413 | + eprintln!( | ||
| 16414 | + "EC_STACK mi_row={mi_row} mi_col={mi_col} i={i} this=({},{}) comp=({},{}) w={}", | ||
| 16415 | + e.mv0.0, e.mv0.1, e.mv1.0, e.mv1.1, e.weight | ||
| 16416 | + ); | ||
| 16417 | + } | ||
| 16418 | + } | ||
| 15600 | let is_globalmv = compound_mode == 6; // GLOBAL_GLOBALMV | 16419 | let is_globalmv = compound_mode == 6; // GLOBAL_GLOBALMV |
| 15601 | // spec `is_nontrans_global_motion`: ALL active refs' models must | 16420 | // spec `is_nontrans_global_motion`: ALL active refs' models must |
| 15602 | // be non-TRANSLATION (IDENTITY counts) for the compound block's | 16421 | // be non-TRANSLATION (IDENTITY counts) for the compound block's |
| @@ -19666,6 +20485,7 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | |||
| 19666 | )); | 20485 | )); |
| 19667 | } | 20486 | } |
| 19668 | let (cols, rows) = block_grid(mi_cols, mi_rows); | 20487 | let (cols, rows) = block_grid(mi_cols, mi_rows); |
| 20488 | + let sb128 = sb128(); | ||
| 19669 | let (sb_cols, sb_rows) = (cols.div_ceil(2), rows.div_ceil(2)); | 20489 | let (sb_cols, sb_rows) = (cols.div_ceil(2), rows.div_ceil(2)); |
| 19670 | CDEF_BITS.with(|c| c.set(cdef.bits)); | 20490 | CDEF_BITS.with(|c| c.set(cdef.bits)); |
| 19671 | CDEF_SB_COLS.with(|c| c.set(sb_cols as usize)); | 20491 | CDEF_SB_COLS.with(|c| c.set(sb_cols as usize)); |
| @@ -19887,19 +20707,44 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | |||
| 19887 | ); | 20707 | ); |
| 19888 | TILE_HITS.with(|c| c.set(c.get() + 1)); | 20708 | TILE_HITS.with(|c| c.set(c.get() + 1)); |
| 19889 | 20709 | ||
| 19890 | - for sb_r in sb_r0..sb_r1 { | 20710 | + // lane-sb128 r2: at `sb_size == 128` the tile walks each 128x128 |
| 19891 | - neighbours.start_row(); | 20711 | + // superblock's four 64x64 quadrants in libaom `decode_partition` order |
| 19892 | - for sb_c in sb_c0..sb_c1 { | 20712 | + // (TL, TR, BL, BR) and reads the 128 root's own loop-restoration units and |
| 19893 | - crate::restoration::read_lr( | 20713 | + // partition symbol once per superblock -- exactly what the key-frame tile |
| 19894 | - &mut dec, | 20714 | + // loop does; the 64-level body below is unchanged, `read_cdef`'s |
| 19895 | - &mut cdfs, | 20715 | + // per-64x64-quadrant reset (`CDEF_TRANSMITTED`) already matches libaom's |
| 19896 | - lr, | 20716 | + // `cdef_idx[(mi_row & 16) >> 4 * 2 + (mi_col & 16) >> 4]` slot per quadrant. |
| 19897 | - &mut lr_grid, | 20717 | + for (sb_r, sb_c, row_start, sb_start) in sb_visit_order(sb_r0, sb_r1, sb_c0, sb_c1, sb128) { |
| 19898 | - &mut lr_reference, | 20718 | + if row_start { |
| 19899 | - sb_r * SB_MI, | 20719 | + neighbours.start_row(); |
| 19900 | - sb_c * SB_MI, | 20720 | + } |
| 19901 | - SB_MI, | 20721 | + { |
| 19902 | - ); | 20722 | + if sb128 && sb_start { |
| 20723 | + read_sb128_root( | ||
| 20724 | + &mut dec, | ||
| 20725 | + &mut cdfs, | ||
| 20726 | + &neighbours, | ||
| 20727 | + lr, | ||
| 20728 | + &mut lr_grid, | ||
| 20729 | + &mut lr_reference, | ||
| 20730 | + sb_r, | ||
| 20731 | + sb_c, | ||
| 20732 | + mi_cols, | ||
| 20733 | + mi_rows, | ||
| 20734 | + )?; | ||
| 20735 | + } | ||
| 20736 | + if !sb128 { | ||
| 20737 | + crate::restoration::read_lr( | ||
| 20738 | + &mut dec, | ||
| 20739 | + &mut cdfs, | ||
| 20740 | + lr, | ||
| 20741 | + &mut lr_grid, | ||
| 20742 | + &mut lr_reference, | ||
| 20743 | + sb_r * SB_MI, | ||
| 20744 | + sb_c * SB_MI, | ||
| 20745 | + SB_MI, | ||
| 20746 | + ); | ||
| 20747 | + } | ||
| 19903 | CDEF_TRANSMITTED.with(|c| c.set(false)); | 20748 | CDEF_TRANSMITTED.with(|c| c.set(false)); |
| 19904 | let sb_at = (sb_r as usize * 4, sb_c as usize * 4); | 20749 | let sb_at = (sb_r as usize * 4, sb_c as usize * 4); |
| 19905 | // lane-inter4 r1: every rect inter piece below is the same | 20750 | // lane-inter4 r1: every rect inter piece below is the same |
| @@ -21642,8 +22487,6 @@ mod tests { | |||
| 21642 | // string that blocks the shape otherwise. Either way the row is | 22487 | // string that blocks the shape otherwise. Either way the row is |
| 21643 | // pinned HERE, so the round that lifts one of those refusals cannot | 22488 | // pinned HERE, so the round that lifts one of those refusals cannot |
| 21644 | // land a wrong CDF row for the shape it unlocks. | 22489 | // land a wrong CDF row for the shape it unlocks. |
| 21645 | - const PART16: &str = "a HORZ_A/HORZ_B/VERT_A partition below 16x16 (this decoder codes \ | ||
| 21646 | - only the square arms, HORZ, VERT, VERT_B, and a clean split below 16x16)"; | ||
| 21647 | let libaom: &[(usize, usize, u16, Option<&str>)] = &[ | 22490 | let libaom: &[(usize, usize, u16, Option<&str>)] = &[ |
| 21648 | (4, 4, 4621, None), | 22491 | (4, 4, 4621, None), |
| 21649 | (4, 8, 6743, None), | 22492 | (4, 8, 6743, None), |
| @@ -21658,8 +22501,10 @@ mod tests { | |||
| 21658 | // The 1:4 strips: a 16x16-level PARTITION_HORZ_4/VERT_4 gives | 22501 | // The 1:4 strips: a 16x16-level PARTITION_HORZ_4/VERT_4 gives |
| 21659 | // 4x16/16x4 (still refused by name before any leaf is coded), | 22502 | // 4x16/16x4 (still refused by name before any leaf is coded), |
| 21660 | // a 32x32-level one 8x32/32x8. | 22503 | // a 32x32-level one 8x32/32x8. |
| 21661 | - (4, 16, 12770, Some(PART16)), | 22504 | + // lane-r14: the 16-level pair is coded now (`decode_rect4_16`), |
| 21662 | - (16, 4, 10368, Some(PART16)), | 22505 | + // owning classes 13/12. |
| 22506 | + (4, 16, 12770, None), | ||
| 22507 | + (16, 4, 10368, None), | ||
| 21663 | // lane-fi32x8 r1: the 32-level pair is coded (four 32x8/8x32 | 22508 | // lane-fi32x8 r1: the 32-level pair is coded (four 32x8/8x32 |
| 21664 | // strips per `PARTITION_HORZ_4`/`VERT_4`) and now owns classes | 22509 | // strips per `PARTITION_HORZ_4`/`VERT_4`) and now owns classes |
| 21665 | // 10/11; only the 16-level pair is still refused before any leaf. | 22510 | // 10/11; only the 16-level pair is still refused before any leaf. |
| @@ -22134,8 +22979,16 @@ mod tests { | |||
| 22134 | // non-skip, so the named refusal is the rectangular-inter-residual | 22979 | // non-skip, so the named refusal is the rectangular-inter-residual |
| 22135 | // one. Either string proves what the pin was written for: a non-SPLIT | 22980 | // one. Either string proves what the pin was written for: a non-SPLIT |
| 22136 | // superblock never silently decodes as SPLIT. | 22981 | // superblock never silently decodes as SPLIT. |
| 22982 | + // lane-r14 r2: the rectangular-residual refusal is gone (a 64x32 strip | ||
| 22983 | + // now codes its truncated low-32 coefficient corner), so this | ||
| 22984 | + // hand-written fixture walks further still and stops on the limit of | ||
| 22985 | + // the FIXTURE rather than of the decoder: it names no reference | ||
| 22986 | + // pictures. All three strings prove the one thing this pin exists for | ||
| 22987 | + // -- a non-SPLIT superblock never silently decodes as SPLIT. | ||
| 22137 | assert!( | 22988 | assert!( |
| 22138 | - msg.contains("SPLIT") || msg.contains("rectangular residual coding"), | 22989 | + msg.contains("SPLIT") |
| 22990 | + || msg.contains("rectangular residual coding") | ||
| 22991 | + || msg.contains("no picture at this frame's own ref_frame_idx slot"), | ||
| 22139 | "expected the named inter-SB-partition refusal, got: {msg}" | 22992 | "expected the named inter-SB-partition refusal, got: {msg}" |
| 22140 | ); | 22993 | ); |
| 22141 | } | 22994 | } |
crates/ec-av1/src/encode.rsmodified+32 -15
| @@ -47,6 +47,26 @@ const SUB: usize = 16; | |||
| 47 | /// The side of a superblock, which is what the partition tree starts from. | 47 | /// The side of a superblock, which is what the partition tree starts from. |
| 48 | pub(crate) const SUPERBLOCK: usize = 64; | 48 | pub(crate) const SUPERBLOCK: usize = 64; |
| 49 | 49 | ||
| 50 | +// lane-sb128 r1: the superblock size in samples the intra-reach rules | ||
| 51 | +// (`has_top_right`/`has_bottom_left`) are answered against. libaom masks the | ||
| 52 | +// block's mi position with `mi_size_wide[cm->seq_params->sb_size] - 1` and | ||
| 53 | +// tests the "top row"/"rightmost column" of THAT superblock, so a 128x128 | ||
| 54 | +// superblock changes every answer inside it (the tables themselves are | ||
| 55 | +// already laid out 128-relative -- see `Reach::table_stride`). [`SUPERBLOCK`] | ||
| 56 | +// stays the encoder's own fixed 64. | ||
| 57 | +thread_local! { | ||
| 58 | + static REACH_SB_PX: std::cell::Cell<usize> = const { std::cell::Cell::new(SUPERBLOCK) }; | ||
| 59 | +} | ||
| 60 | + | ||
| 61 | +/// Sets the superblock size [`Reach`] answers against (64 or 128). | ||
| 62 | +pub(crate) fn set_reach_superblock_px(px: usize) { | ||
| 63 | + REACH_SB_PX.with(|c| c.set(px)); | ||
| 64 | +} | ||
| 65 | + | ||
| 66 | +fn reach_sb_px() -> usize { | ||
| 67 | + REACH_SB_PX.with(|c| c.get()) | ||
| 68 | +} | ||
| 69 | + | ||
| 50 | /// How heavily the mode search weighs rate against squared error, in units of | 70 | /// How heavily the mode search weighs rate against squared error, in units of |
| 51 | /// the quantizer's reconstruction step squared per bit. | 71 | /// the quantizer's reconstruction step squared per bit. |
| 52 | /// | 72 | /// |
| @@ -1300,19 +1320,19 @@ impl Reach { | |||
| 1300 | /// the transform covering the whole block, luma): everything before the | 1320 | /// the transform covering the whole block, luma): everything before the |
| 1301 | /// table lookup is that function's own early-exit ladder. | 1321 | /// table lookup is that function's own early-exit ladder. |
| 1302 | fn top_right_rect(bw: usize, bh: usize, x: usize, y: usize) -> bool { | 1322 | fn top_right_rect(bw: usize, bh: usize, x: usize, y: usize) -> bool { |
| 1303 | - const SB_MI: usize = SUPERBLOCK / 4; | 1323 | + let sb_mi: usize = reach_sb_px() / 4; |
| 1304 | let (mi_row, mi_col) = (y / 4, x / 4); | 1324 | let (mi_row, mi_col) = (y / 4, x / 4); |
| 1305 | let bw_log2 = (bw / 4).trailing_zeros() as usize; | 1325 | let bw_log2 = (bw / 4).trailing_zeros() as usize; |
| 1306 | let bh_log2 = (bh / 4).trailing_zeros() as usize; | 1326 | let bh_log2 = (bh / 4).trailing_zeros() as usize; |
| 1307 | - let blk_row = (mi_row & (SB_MI - 1)) >> bh_log2; | 1327 | + let blk_row = (mi_row & (sb_mi - 1)) >> bh_log2; |
| 1308 | - let blk_col = (mi_col & (SB_MI - 1)) >> bw_log2; | 1328 | + let blk_col = (mi_col & (sb_mi - 1)) >> bw_log2; |
| 1309 | // Top row of the superblock: the top-right pixels are in the (already | 1329 | // Top row of the superblock: the top-right pixels are in the (already |
| 1310 | // decoded) superblock above. | 1330 | // decoded) superblock above. |
| 1311 | if blk_row == 0 { | 1331 | if blk_row == 0 { |
| 1312 | return true; | 1332 | return true; |
| 1313 | } | 1333 | } |
| 1314 | // Rightmost column: they fall in the superblock to the right. | 1334 | // Rightmost column: they fall in the superblock to the right. |
| 1315 | - if ((blk_col + 1) << bw_log2) >= SB_MI { | 1335 | + if ((blk_col + 1) << bw_log2) >= sb_mi { |
| 1316 | return false; | 1336 | return false; |
| 1317 | } | 1337 | } |
| 1318 | let table = rect_reach_tables(bw, bh).0; | 1338 | let table = rect_reach_tables(bw, bh).0; |
| @@ -1333,20 +1353,20 @@ impl Reach { | |||
| 1333 | 1353 | ||
| 1334 | /// libaom `has_bottom_left`, same granularity as [`Self::top_right_rect`]. | 1354 | /// libaom `has_bottom_left`, same granularity as [`Self::top_right_rect`]. |
| 1335 | fn bottom_left_rect(bw: usize, bh: usize, x: usize, y: usize) -> bool { | 1355 | fn bottom_left_rect(bw: usize, bh: usize, x: usize, y: usize) -> bool { |
| 1336 | - const SB_MI: usize = SUPERBLOCK / 4; | 1356 | + let sb_mi: usize = reach_sb_px() / 4; |
| 1337 | let (mi_row, mi_col) = (y / 4, x / 4); | 1357 | let (mi_row, mi_col) = (y / 4, x / 4); |
| 1338 | let bw_log2 = (bw / 4).trailing_zeros() as usize; | 1358 | let bw_log2 = (bw / 4).trailing_zeros() as usize; |
| 1339 | let bh_log2 = (bh / 4).trailing_zeros() as usize; | 1359 | let bh_log2 = (bh / 4).trailing_zeros() as usize; |
| 1340 | - let blk_row = (mi_row & (SB_MI - 1)) >> bh_log2; | 1360 | + let blk_row = (mi_row & (sb_mi - 1)) >> bh_log2; |
| 1341 | - let blk_col = (mi_col & (SB_MI - 1)) >> bw_log2; | 1361 | + let blk_col = (mi_col & (sb_mi - 1)) >> bw_log2; |
| 1342 | // Leftmost column of the superblock: the bottom-left pixels are in | 1362 | // Leftmost column of the superblock: the bottom-left pixels are in |
| 1343 | // the left superblock iff they stay inside its height. | 1363 | // the left superblock iff they stay inside its height. |
| 1344 | if blk_col == 0 { | 1364 | if blk_col == 0 { |
| 1345 | - return (blk_row << bh_log2) + (bh / 4) < SB_MI; | 1365 | + return (blk_row << bh_log2) + (bh / 4) < sb_mi; |
| 1346 | } | 1366 | } |
| 1347 | // Bottom row (and not the leftmost column): they fall in the | 1367 | // Bottom row (and not the leftmost column): they fall in the |
| 1348 | // superblock below, which is not decoded yet. | 1368 | // superblock below, which is not decoded yet. |
| 1349 | - if ((blk_row + 1) << bh_log2) >= SB_MI { | 1369 | + if ((blk_row + 1) << bh_log2) >= sb_mi { |
| 1350 | return false; | 1370 | return false; |
| 1351 | } | 1371 | } |
| 1352 | let table = rect_reach_tables(bw, bh).1; | 1372 | let table = rect_reach_tables(bw, bh).1; |
| @@ -1420,7 +1440,7 @@ impl Reach { | |||
| 1420 | fn bottom_left(side: usize, x: usize, y: usize) -> bool { | 1440 | fn bottom_left(side: usize, x: usize, y: usize) -> bool { |
| 1421 | let (row, col, per_side) = Self::position(side, x, y); | 1441 | let (row, col, per_side) = Self::position(side, x, y); |
| 1422 | if col == 0 { | 1442 | if col == 0 { |
| 1423 | - return row * side + side < SUPERBLOCK; | 1443 | + return row * side + side < reach_sb_px(); |
| 1424 | } | 1444 | } |
| 1425 | if row + 1 == per_side { | 1445 | if row + 1 == per_side { |
| 1426 | return false; | 1446 | return false; |
| @@ -1451,11 +1471,8 @@ impl Reach { | |||
| 1451 | /// Where a block sits inside its superblock, in blocks of its own size, | 1471 | /// Where a block sits inside its superblock, in blocks of its own size, |
| 1452 | /// and how many of them a superblock is across. | 1472 | /// and how many of them a superblock is across. |
| 1453 | fn position(side: usize, x: usize, y: usize) -> (usize, usize, usize) { | 1473 | fn position(side: usize, x: usize, y: usize) -> (usize, usize, usize) { |
| 1454 | - ( | 1474 | + let sb = reach_sb_px(); |
| 1455 | - (y % SUPERBLOCK) / side, | 1475 | + ((y % sb) / side, (x % sb) / side, sb / side) |
| 1456 | - (x % SUPERBLOCK) / side, | ||
| 1457 | - SUPERBLOCK / side, | ||
| 1458 | - ) | ||
| 1459 | } | 1476 | } |
| 1460 | 1477 | ||
| 1461 | /// The row stride `HAS_TOP_RIGHT`/`HAS_BOTTOM_LEFT` index by: libaom pins | 1478 | /// The row stride `HAS_TOP_RIGHT`/`HAS_BOTTOM_LEFT` index by: libaom pins |
crates/ec-av1/src/mvstack.rsmodified+96 -18
| @@ -585,6 +585,43 @@ fn scan_col( | |||
| 585 | found | 585 | found |
| 586 | } | 586 | } |
| 587 | 587 | ||
| 588 | +/// libaom `has_top_right` (mvref_common.c:264): whether the unit diagonally | ||
| 589 | +/// above-right of this block has been decoded *by the superblock's own | ||
| 590 | +/// recursion order*. The mask is `sb_size`-relative, so at a 128x128 | ||
| 591 | +/// superblock the `while` loop runs one level further than at 64x64 and | ||
| 592 | +/// strips the top-right neighbour off blocks that DO sit in already-decoded | ||
| 593 | +/// memory -- an availability rule a plain "is the grid cell populated" probe | ||
| 594 | +/// (what this module did before lane-sb128 r2) cannot see. It cost frame 6 of | ||
| 595 | +/// the 128 inter gate 380 wrong luma bytes with the entropy stream in sync. | ||
| 596 | +/// | ||
| 597 | +/// corner-cut: libaom's three shape refinements (`is_last_vertical_rect`, | ||
| 598 | +/// `is_first_horizontal_rect`, the `PARTITION_VERT_A` bottom-left square) are | ||
| 599 | +/// not ported -- the ceiling is rectangular and AB-partitioned INTER leaves, | ||
| 600 | +/// which this decoder refuses by name today; port them with the rect inter | ||
| 601 | +/// leaf. | ||
| 602 | +pub(crate) fn has_top_right(mi_row: usize, mi_col: usize, bw4: usize, bh4: usize) -> bool { | ||
| 603 | + let sb_mi_size = crate::decode::sb_mi_cur() as usize; | ||
| 604 | + let bs0 = bw4.max(bh4); | ||
| 605 | + if bs0 > 16 { | ||
| 606 | + return false; | ||
| 607 | + } | ||
| 608 | + let (mask_row, mask_col) = (mi_row & (sb_mi_size - 1), mi_col & (sb_mi_size - 1)); | ||
| 609 | + let mut has_tr = !(mask_row & bs0 != 0 && mask_col & bs0 != 0); | ||
| 610 | + let mut bs = bs0; | ||
| 611 | + while bs < sb_mi_size { | ||
| 612 | + if mask_col & bs != 0 { | ||
| 613 | + if mask_col & (2 * bs) != 0 && mask_row & (2 * bs) != 0 { | ||
| 614 | + has_tr = false; | ||
| 615 | + break; | ||
| 616 | + } | ||
| 617 | + } else { | ||
| 618 | + break; | ||
| 619 | + } | ||
| 620 | + bs <<= 1; | ||
| 621 | + } | ||
| 622 | + has_tr | ||
| 623 | +} | ||
| 624 | + | ||
| 588 | /// The single top-right probe this reduction keeps of spec 7.10.2.4's extra | 625 | /// The single top-right probe this reduction keeps of spec 7.10.2.4's extra |
| 589 | /// scan positions, at the unit diagonally above-right of the block. Its | 626 | /// scan positions, at the unit diagonally above-right of the block. Its |
| 590 | /// vote is folded into the row scan's candidates (it sits on the same row | 627 | /// vote is folded into the row scan's candidates (it sits on the same row |
| @@ -780,15 +817,15 @@ pub fn find_mv_stack_with_sign_bias( | |||
| 780 | &mut processed_cols, | 817 | &mut processed_cols, |
| 781 | ); | 818 | ); |
| 782 | let found_top_right = scan_top_right( | 819 | let found_top_right = scan_top_right( |
| 783 | - grid, | 820 | + grid, |
| 784 | - mi_row, | 821 | + mi_row, |
| 785 | - mi_col, | 822 | + mi_col, |
| 786 | - bw4, | 823 | + bw4, |
| 787 | - ref_frame, | 824 | + ref_frame, |
| 788 | - gm, | 825 | + gm, |
| 789 | - &mut candidates, | 826 | + &mut candidates, |
| 790 | - &mut newmv_count, | 827 | + &mut newmv_count, |
| 791 | - ); | 828 | + ); |
| 792 | 829 | ||
| 793 | // libaom's `row_match_count`/`col_match_count` (mvref_common.c) fold the | 830 | // libaom's `row_match_count`/`col_match_count` (mvref_common.c) fold the |
| 794 | // top-right probe into the row side, so "found above" for context | 831 | // top-right probe into the row side, so "found above" for context |
| @@ -1539,15 +1576,15 @@ pub fn find_mv_stack_compound( | |||
| 1539 | &mut processed_cols, | 1576 | &mut processed_cols, |
| 1540 | ); | 1577 | ); |
| 1541 | let found_top_right = scan_top_right_compound( | 1578 | let found_top_right = scan_top_right_compound( |
| 1542 | - grid, | 1579 | + grid, |
| 1543 | - mi_row, | 1580 | + mi_row, |
| 1544 | - mi_col, | 1581 | + mi_col, |
| 1545 | - bw4, | 1582 | + bw4, |
| 1546 | - ref_frame, | 1583 | + ref_frame, |
| 1547 | - gm, | 1584 | + gm, |
| 1548 | - &mut candidates, | 1585 | + &mut candidates, |
| 1549 | - &mut newmv_count, | 1586 | + &mut newmv_count, |
| 1550 | - ); | 1587 | + ); |
| 1551 | 1588 | ||
| 1552 | let row_matched = found_above || found_top_right; | 1589 | let row_matched = found_above || found_top_right; |
| 1553 | let nearest_match = usize::from(row_matched) + usize::from(found_left); | 1590 | let nearest_match = usize::from(row_matched) + usize::from(found_left); |
| @@ -1623,6 +1660,47 @@ pub fn find_mv_stack_compound( | |||
| 1623 | } | 1660 | } |
| 1624 | blk_row += step_h; | 1661 | blk_row += step_h; |
| 1625 | } | 1662 | } |
| 1663 | + // lane-sb128 r3: libaom's three `tpl_sample_pos` EXTENSION samples | ||
| 1664 | + // (mvref_common.c:591), which the single-ref twin already ports and | ||
| 1665 | + // this compound path dropped. `check_sb_border`'s mask is libaom's | ||
| 1666 | + // hardcoded `mi_size_wide[BLOCK_64X64]` (16), NOT the sequence's | ||
| 1667 | + // superblock size. Missing them cost one weight-2 vote on a | ||
| 1668 | + // candidate, which reordered the stack and gave a NEW_NEWMV block a | ||
| 1669 | + // different predictor -- 957 wrong pixels on one 32x32 block of one | ||
| 1670 | + // frame with the entropy stream in sync. | ||
| 1671 | + let allow_extension = (2..16).contains(&bh4) && (2..16).contains(&bw4); | ||
| 1672 | + if allow_extension { | ||
| 1673 | + let (voffset, hoffset) = (bh4.max(2) as isize, bw4.max(2) as isize); | ||
| 1674 | + let sb_mask = 16isize; | ||
| 1675 | + for (row_off, col_off) in [ | ||
| 1676 | + (voffset, -2isize), | ||
| 1677 | + (voffset, hoffset), | ||
| 1678 | + (voffset - 2, hoffset), | ||
| 1679 | + ] { | ||
| 1680 | + let row = (mi_row as isize & (sb_mask - 1)) + row_off; | ||
| 1681 | + let col = (mi_col as isize & (sb_mask - 1)) + col_off; | ||
| 1682 | + if row < 0 || row >= sb_mask || col < 0 || col >= sb_mask { | ||
| 1683 | + continue; | ||
| 1684 | + } | ||
| 1685 | + let cand0 = crate::motion_field::add_tpl_ref_mv( | ||
| 1686 | + field, mi_row, mi_col, row_off, col_off, cur_offset_0, | ||
| 1687 | + allow_high_precision_mv, | ||
| 1688 | + ); | ||
| 1689 | + let cand1 = crate::motion_field::add_tpl_ref_mv( | ||
| 1690 | + field, mi_row, mi_col, row_off, col_off, cur_offset_1, | ||
| 1691 | + allow_high_precision_mv, | ||
| 1692 | + ); | ||
| 1693 | + if cand0.is_some() || cand1.is_some() { | ||
| 1694 | + any_hit = true; | ||
| 1695 | + add_compound_candidate( | ||
| 1696 | + &mut candidates, | ||
| 1697 | + cand0.map_or((0, 0), |c| c.mv), | ||
| 1698 | + cand1.map_or((0, 0), |c| c.mv), | ||
| 1699 | + 2, | ||
| 1700 | + ); | ||
| 1701 | + } | ||
| 1702 | + } | ||
| 1703 | + } | ||
| 1626 | if any_hit { | 1704 | if any_hit { |
| 1627 | TMV_HITS.fetch_add(1, std::sync::atomic::Ordering::Relaxed); | 1705 | TMV_HITS.fetch_add(1, std::sync::atomic::Ordering::Relaxed); |
| 1628 | } | 1706 | } |
crates/ec-av1/src/refusal_inventory.rsmodified+6 -2
| @@ -34,7 +34,6 @@ 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 1:4 partition below 16x16 (PARTITION_HORZ_4/VERT_4, four 16x4/4x16 strips -- this decoder codes NONE, HORZ, VERT, the four AB arms and a clean split at 16x16)", | ||
| 38 | "a 1:4 rect strip that actually uses a palette (reconstruction is not ported at this shape)", | 37 | "a 1:4 rect strip that actually uses a palette (reconstruction is not ported at this shape)", |
| 39 | "a 16x16 block whose true edge cuts through both axes needs a rectangular transform this decoder does not code yet", | 38 | "a 16x16 block whose true edge cuts through both axes needs a rectangular transform this decoder does not code yet", |
| 40 | "a 16x16 inter 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", |
| @@ -43,6 +42,8 @@ const REFUSALS: &[&str] = &[ | |||
| 43 | "a tx_type symbol outside its CDF's own set: {t}", | 42 | "a tx_type symbol outside its CDF's own set: {t}", |
| 44 | "an INTER 32x32 partition type this decoder does not code (value={part32})", | 43 | "an INTER 32x32 partition type this decoder does not code (value={part32})", |
| 45 | "a superblock-level partition value outside PARTITION_NONE..PARTITION_VERT_4", | 44 | "a superblock-level partition value outside PARTITION_NONE..PARTITION_VERT_4", |
| 45 | + "a 128x128 superblock partition other than SPLIT (NONE/HORZ/VERT and the four AB arms at the 128 root are not decoded)", | ||
| 46 | + "intrabc under a 128x128 superblock (libaom's av1_is_dv_valid derives the block-vector delay from sb_size, which this decoder hardcodes to 64)", | ||
| 46 | "a palette block on a HORZ/VERT intra strip below 16x16 (reconstruction not ported)", | 47 | "a palette block on a HORZ/VERT intra strip below 16x16 (reconstruction not ported)", |
| 47 | "a palette block with a real transform on a superblock-level HORZ/VERT strip (corner-cropped luma coefficients not ported for palette)", | 48 | "a palette block with a real transform on a superblock-level HORZ/VERT strip (corner-cropped luma coefficients not ported for palette)", |
| 48 | "a block that actually uses a palette (UV) -- reconstruction is out of scope", | 49 | "a block that actually uses a palette (UV) -- reconstruction is out of scope", |
| @@ -50,7 +51,6 @@ const REFUSALS: &[&str] = &[ | |||
| 50 | "a sub-8x8 leaf that uses intrabc (this reader has no block-vector path; the 8x8-and-up reader reconstructs one)", | 51 | "a sub-8x8 leaf that uses intrabc (this reader has no block-vector path; the 8x8-and-up reader reconstructs one)", |
| 51 | "an intrabc block under TxMode::Select (its transform size is coded by the inter var-tx partition tree, which this decoder never reads)", | 52 | "an intrabc block under TxMode::Select (its transform size is coded by the inter var-tx partition tree, which this decoder never reads)", |
| 52 | "a bit depth of 12 (this decoder is gated at 8 and 10 only: warp/MC/wiener rounding shifts change at 12-bit and no 12-bit gate exists)", | 53 | "a bit depth of 12 (this decoder is gated at 8 and 10 only: warp/MC/wiener rounding shifts change at 12-bit and no 12-bit gate exists)", |
| 53 | - "a sequence using 128x128 superblocks on a frame larger than 64x64 (this decoder's whole partition/CDEF/LR grid is 64x64-superblock only; aomenc picks 128x128 at --cpu-used=0)", | ||
| 54 | "a frame OBU with no tile group", | 54 | "a frame OBU with no tile group", |
| 55 | "a frame naming primary_ref_frame at a reference slot with no saved CDF state", | 55 | "a frame naming primary_ref_frame at a reference slot with no saved CDF state", |
| 56 | "a frame with no mode-info grid", | 56 | "a frame with no mode-info grid", |
| @@ -81,6 +81,10 @@ const REFUSALS: &[&str] = &[ | |||
| 81 | "warp prediction with a scaled reference (superres, unimplemented)", | 81 | "warp prediction with a scaled reference (superres, unimplemented)", |
| 82 | "an 8x8 partition leaf under a scaled reference (superres, unimplemented)", | 82 | "an 8x8 partition leaf under a scaled reference (superres, unimplemented)", |
| 83 | "a motion_mode symbol for a block shape with no CDF row here", | 83 | "a motion_mode symbol for a block shape with no CDF row here", |
| 84 | + // lane-r14 r2: the whole-transform case of every 64-axis inter strip is | ||
| 85 | + // coded; only the SPLIT of a 1:4 strip with a 64-px axis is left, whose | ||
| 86 | + // `sub_tx_size_map` entry is rectangular (TX_64X16 -> TX_32X16). | ||
| 87 | + "a split transform on a 1:4 inter strip with a 64-px axis", | ||
| 84 | ]; | 88 | ]; |
| 85 | 89 | ||
| 86 | /// Gates whose `Err` arm turns a decode failure into a printed SKIP rather than | 90 | /// Gates whose `Err` arm turns a decode failure into a printed SKIP rather than |
crates/ec-av1/src/stream.rsmodified+742 -48
| @@ -80,6 +80,12 @@ pub fn intra_rect4_in_inter_counters() -> (usize, usize, usize, usize) { | |||
| 80 | ) | 80 | ) |
| 81 | } | 81 | } |
| 82 | 82 | ||
| 83 | +/// lane-r14 r2: luma transform units of an inter strip with a 64-px axis, | ||
| 84 | +/// coded as the truncated low-32 coefficient corner. | ||
| 85 | +pub fn rect64_inter_tu_hits() -> usize { | ||
| 86 | + crate::decode::rect64_inter_tu_hits() | ||
| 87 | +} | ||
| 88 | + | ||
| 83 | pub fn rect4_32_counters() -> (usize, usize, usize) { | 89 | pub fn rect4_32_counters() -> (usize, usize, usize) { |
| 84 | ( | 90 | ( |
| 85 | crate::decode::rect4_32_horz_hits(), | 91 | crate::decode::rect4_32_horz_hits(), |
| @@ -516,6 +522,18 @@ pub fn decode_stream(data: &[u8]) -> Result<Vec<Picture>> { | |||
| 516 | // inter frames are decoded on a thread that previously decoded a | 522 | // inter frames are decoded on a thread that previously decoded a |
| 517 | // different sequence would inherit that sequence's bit. | 523 | // different sequence would inherit that sequence's bit. |
| 518 | crate::decode::set_enable_edge_filter(enable_edge_filter); | 524 | crate::decode::set_enable_edge_filter(enable_edge_filter); |
| 525 | + // lane-sb128 r1/r2: `use_128x128_superblock` (spec 5.5.1). Both the | ||
| 526 | + // key-frame and the inter tile path read the 128 partition root and | ||
| 527 | + // recurse SPLIT into the four 64x64 quadrants (r2 ported the root and | ||
| 528 | + // libaom's quadrant visit order into the inter loop too). A frame at | ||
| 529 | + // most 64x64 decodes identically either way (its 128 root reads no | ||
| 530 | + // symbol -- neither half is in frame, so SPLIT is inferred), so the | ||
| 531 | + // flag is only armed for frames bigger than one 64x64 superblock. | ||
| 532 | + let use_sb128 = parser | ||
| 533 | + .sequence_header() | ||
| 534 | + .is_some_and(|seq| seq.use_128x128_superblock); | ||
| 535 | + let sb128_active = use_sb128 && (header.mi_cols > 16 || header.mi_rows > 16); | ||
| 536 | + crate::decode::set_sb128(sb128_active); | ||
| 519 | // lane-hbd r5: `BIT_DEPTH` (decode.rs) drives `crate::decode::sample_max`, | 537 | // lane-hbd r5: `BIT_DEPTH` (decode.rs) drives `crate::decode::sample_max`, |
| 520 | // which every dequant/inverse-transform clamp reads -- set per frame, | 538 | // which every dequant/inverse-transform clamp reads -- set per frame, |
| 521 | // not once per process, for the same cross-sequence-on-one-thread | 539 | // not once per process, for the same cross-sequence-on-one-thread |
| @@ -537,37 +555,6 @@ pub fn decode_stream(data: &[u8]) -> Result<Vec<Picture>> { | |||
| 537 | "a bit depth of 12 (this decoder is gated at 8 and 10 only: warp/MC/wiener rounding shifts change at 12-bit and no 12-bit gate exists)", | 555 | "a bit depth of 12 (this decoder is gated at 8 and 10 only: warp/MC/wiener rounding shifts change at 12-bit and no 12-bit gate exists)", |
| 538 | )); | 556 | )); |
| 539 | } | 557 | } |
| 540 | - // lane-oddh r2: `use_128x128_superblock` reaches every level of the | ||
| 541 | - // decode -- the partition tree starts at BLOCK_128X128, `SB_MI` is 32 | ||
| 542 | - // mi units, and the CDEF/LR/deblock grids are per-128 -- and this | ||
| 543 | - // decoder is written for 64x64 superblocks throughout (`SB_MI = 16`, | ||
| 544 | - // no BLOCK_128X128 partition read at all). Until r1 that was SILENT: | ||
| 545 | - // a 64x72 aomenc key frame at `--cpu-used=0` (libaom picks 128x128 | ||
| 546 | - // whenever speed is 0, `av1_select_sb_size`) desynced at the very | ||
| 547 | - // first symbol -- aomdec reads a gathered 2-symbol | ||
| 548 | - // BLOCK_128X128 partition (has_cols false at mi_cols=16, | ||
| 549 | - // has_rows true at mi_rows=18) where we read a 10-symbol | ||
| 550 | - // BLOCK_64X64 one from the same byte, giving PARTITION_VERT_4 (9) | ||
| 551 | - // against SPLIT (3). Refuse by name rather than decode wrong pixels. | ||
| 552 | - // | ||
| 553 | - // Scoped, not blanket (measured: a blanket refusal red-lined 29 | ||
| 554 | - // previously pixel-exact gates): on a frame of at most 64x64 a | ||
| 555 | - // 128x128 superblock decodes IDENTICALLY to a 64x64 one -- mi (0,0) | ||
| 556 | - // has neither `has_rows` nor `has_cols`, so BLOCK_128X128 is a forced | ||
| 557 | - // SPLIT that reads no symbol, and only one of its four 64x64 children | ||
| 558 | - // is inside the frame. Every sibling inter gate at 64x64 and | ||
| 559 | - // `--cpu-used=0` is exactly that case. The divergence starts the | ||
| 560 | - // moment a superblock has a second child in frame. | ||
| 561 | - if parser | ||
| 562 | - .sequence_header() | ||
| 563 | - .is_some_and(|seq| seq.use_128x128_superblock) | ||
| 564 | - && (header.mi_cols > 16 || header.mi_rows > 16) | ||
| 565 | - { | ||
| 566 | - return Err(Error::unsupported( | ||
| 567 | - "AV1 decode_stream", | ||
| 568 | - "a sequence using 128x128 superblocks on a frame larger than 64x64 (this decoder's whole partition/CDEF/LR grid is 64x64-superblock only; aomenc picks 128x128 at --cpu-used=0)", | ||
| 569 | - )); | ||
| 570 | - } | ||
| 571 | crate::decode::set_bit_depth(bit_depth); | 558 | crate::decode::set_bit_depth(bit_depth); |
| 572 | // lane-av1comp: `comp_group_idx`/`compound_idx`'s own gating bits. | 559 | // lane-av1comp: `comp_group_idx`/`compound_idx`'s own gating bits. |
| 573 | let enable_masked_compound = parser | 560 | let enable_masked_compound = parser |
| @@ -1109,22 +1096,18 @@ mod tests { | |||
| 1109 | eprintln!("{NAME}: {compared} attempts pixel-exact, edge_rect_strip_hits={strip_hits}, {refused} refusals"); | 1096 | eprintln!("{NAME}: {compared} attempts pixel-exact, edge_rect_strip_hits={strip_hits}, {refused} refusals"); |
| 1110 | } | 1097 | } |
| 1111 | 1098 | ||
| 1112 | - /// lane-oddh r2 GATE: a REAL aomenc stream that uses 128x128 superblocks | 1099 | + /// lane-sb128 r4 GATE (was lane-oddh r2's refusal gate): the SAME real |
| 1113 | - /// is refused by name, not silently mis-decoded. This is the root cause of | 1100 | + /// aomenc 64x72 `--cpu-used=0 --sb-size=128` stream that once desynced at |
| 1114 | - /// r1's pinned 64x72 first-symbol desync: libaom's `av1_select_sb_size` | 1101 | + /// the very first symbol now decodes PIXEL-EXACT against aomdec. mi_rows |
| 1115 | - /// returns BLOCK_128X128 whenever speed is 0, so a tiny frame encoded at | 1102 | + /// = 18 > 16, so the BLOCK_128X128 root reads a real gathered partition |
| 1116 | - /// `--cpu-used=0` carries 128x128 superblocks, and this 64x64-only | 1103 | + /// symbol (2 symbols: has_cols false, has_rows true) -- exactly the case |
| 1117 | - /// decoder read a 10-symbol BLOCK_64X64 partition (value 9, VERT_4) where | 1104 | + /// r1 mis-read as a 10-symbol BLOCK_64X64 partition. |
| 1118 | - /// aomdec read a gathered 2-symbol BLOCK_128X128 one (value 3, SPLIT) from | ||
| 1119 | - /// the same byte -- the uncompressed header parse was byte-identical | ||
| 1120 | - /// (49 bits, tile data at file offset 20; hand-verified against spec | ||
| 1121 | - /// 5.9.2 field by field). | ||
| 1122 | /// | 1105 | /// |
| 1123 | /// The `use_128x128_superblock` assert is the "knob reached the tool" | 1106 | /// The `use_128x128_superblock` assert is the "knob reached the tool" |
| 1124 | - /// half: without it, an aomenc that ignored `--sb-size=128` would leave | 1107 | + /// half: without it an aomenc that ignored `--sb-size=128` would leave |
| 1125 | - /// the gate asserting a refusal that never fires. | 1108 | + /// the gate proving nothing about 128 superblocks. |
| 1126 | #[test] | 1109 | #[test] |
| 1127 | - fn a_real_aomenc_128x128_superblock_stream_is_refused_by_name() { | 1110 | + fn a_real_aomenc_128x128_superblock_stream_decodes_pixel_exact() { |
| 1128 | if !have_ffmpeg() || !have_aomenc() { | 1111 | if !have_ffmpeg() || !have_aomenc() { |
| 1129 | eprintln!("SKIP: no ffmpeg/aomenc"); | 1112 | eprintln!("SKIP: no ffmpeg/aomenc"); |
| 1130 | return; | 1113 | return; |
| @@ -1145,7 +1128,8 @@ mod tests { | |||
| 1145 | let mut child = Command::new(aomenc_path()) | 1128 | let mut child = Command::new(aomenc_path()) |
| 1146 | .args([ | 1129 | .args([ |
| 1147 | "--codec=av1", "--passes=1", "--end-usage=q", "--cq-level=32", | 1130 | "--codec=av1", "--passes=1", "--end-usage=q", "--cq-level=32", |
| 1148 | - "--cpu-used=0", "--sb-size=128", "--kf-max-dist=0", "--limit=1", | 1131 | + "--cpu-used=0", "--sb-size=128", "--min-partition-size=16", |
| 1132 | + "--kf-max-dist=0", "--limit=1", | ||
| 1149 | "--threads=1", "--row-mt=0", "--obu", "-o", "-", "-", | 1133 | "--threads=1", "--row-mt=0", "--obu", "-o", "-", "-", |
| 1150 | ]) | 1134 | ]) |
| 1151 | .stdin(Stdio::piped()) | 1135 | .stdin(Stdio::piped()) |
| @@ -1175,10 +1159,26 @@ mod tests { | |||
| 1175 | } | 1159 | } |
| 1176 | assert!(sb128, "aomenc ignored --sb-size=128: this stream is 64x64-superblock"); | 1160 | assert!(sb128, "aomenc ignored --sb-size=128: this stream is 64x64-superblock"); |
| 1177 | 1161 | ||
| 1178 | - let err = decode_stream(&stream).unwrap_err().to_string(); | 1162 | + let _guard = lock_gate_counters(); |
| 1163 | + let before = crate::decode::part128_symbols() | ||
| 1164 | + + crate::decode::part128_gathered_symbols(); | ||
| 1165 | + let (frames, hidden) = | ||
| 1166 | + decode_all_frames_vs_oracle(&stream, "sb128-oddh-64x72"); | ||
| 1167 | + assert!(frames > 0, "no frames decoded for {width}x{height}"); | ||
| 1168 | + // The 128 root actually READ a partition symbol here: at mi_rows=18 | ||
| 1169 | + // `has_rows` is true, so BLOCK_128X128 is not a forced split. | ||
| 1170 | + let part128 = crate::decode::part128_symbols() | ||
| 1171 | + + crate::decode::part128_gathered_symbols() | ||
| 1172 | + - before; | ||
| 1179 | assert!( | 1173 | assert!( |
| 1180 | - err.contains("a sequence using 128x128 superblocks"), | 1174 | + part128 > 0, |
| 1181 | - "expected the 128x128-superblock refusal for {width}x{height}, got: {err}" | 1175 | + "{width}x{height} decoded without reading a single BLOCK_128X128 \ |
| 1176 | + partition symbol -- the gate proves nothing about the 128 root" | ||
| 1177 | + ); | ||
| 1178 | + eprintln!( | ||
| 1179 | + "a_real_aomenc_128x128_superblock_stream_decodes_pixel_exact: \ | ||
| 1180 | + {frames} frames pixel-exact ({hidden} hidden) at {width}x{height}, \ | ||
| 1181 | + part128_symbols={part128}" | ||
| 1182 | ); | 1182 | ); |
| 1183 | } | 1183 | } |
| 1184 | 1184 | ||
| @@ -2761,6 +2761,7 @@ mod tests { | |||
| 2761 | "--error-resilient=1", | 2761 | "--error-resilient=1", |
| 2762 | "--aq-mode=0", | 2762 | "--aq-mode=0", |
| 2763 | "--deltaq-mode=0", | 2763 | "--deltaq-mode=0", |
| 2764 | + "--enable-cdef=0", | ||
| 2764 | "--enable-rect-partitions=0", | 2765 | "--enable-rect-partitions=0", |
| 2765 | "--enable-ab-partitions=0", | 2766 | "--enable-ab-partitions=0", |
| 2766 | "--enable-1to4-partitions=0", | 2767 | "--enable-1to4-partitions=0", |
| @@ -6858,10 +6859,21 @@ mod tests { | |||
| 6858 | // NON-skip, so it stops at "a non-skip rectangular (HORZ/VERT/HORZ_B) | 6859 | // NON-skip, so it stops at "a non-skip rectangular (HORZ/VERT/HORZ_B) |
| 6859 | // strip needs rectangular residual coding". The 10-bit twin below is | 6860 | // strip needs rectangular residual coding". The 10-bit twin below is |
| 6860 | // `#[ignore]`d with that exact reason rather than deleted or weakened. | 6861 | // `#[ignore]`d with that exact reason rather than deleted or weakened. |
| 6862 | + // lane-r14 r2 re-measured the 8-bit-only note above: the residual | ||
| 6863 | + // refusal it names is GONE (this round codes a 64-px transform axis as | ||
| 6864 | + // its truncated low-32 corner), and a 10-bit sweep of this exact | ||
| 6865 | + // recipe now reaches the arm -- 2 pixel-exact attempts, 2 64x32 and 2 | ||
| 6866 | + // 32x64 strips, 2 of them carrying a coded 64-axis residual. It stays | ||
| 6867 | + // 8-bit here for a DIFFERENT, newly exposed reason: 10-bit attempt 14 | ||
| 6868 | + // (cq 61, horizontal split, motion step 12) mismatches ffmpeg while | ||
| 6869 | + // decoding ZERO superblock-level rect strips and zero 64-axis | ||
| 6870 | + // residual units, i.e. a defect of some other shape that this gate | ||
| 6871 | + // must not absorb. See lanes/r14-r2.report.md. | ||
| 6861 | for bit_depth in [8u32] { | 6872 | for bit_depth in [8u32] { |
| 6862 | let (mut named_refusals, mut matched, mut out_of_scope, mut oos_mismatch) = | 6873 | let (mut named_refusals, mut matched, mut out_of_scope, mut oos_mismatch) = |
| 6863 | (0u32, 0u32, 0u32, 0u32); | 6874 | (0u32, 0u32, 0u32, 0u32); |
| 6864 | let (mut horz_proved, mut vert_proved) = (0usize, 0usize); | 6875 | let (mut horz_proved, mut vert_proved) = (0usize, 0usize); |
| 6876 | + let mut rect64_tus = 0usize; | ||
| 6865 | for attempt in 0..16u32 { | 6877 | for attempt in 0..16u32 { |
| 6866 | // Two orientations (the transposed pair a one-sided gate could | 6878 | // Two orientations (the transposed pair a one-sided gate could |
| 6867 | // never separate) x four quantisers x two motion steps: which | 6879 | // never separate) x four quantisers x two motion steps: which |
| @@ -6934,6 +6946,7 @@ mod tests { | |||
| 6934 | ); | 6946 | ); |
| 6935 | let stream = out.stdout; | 6947 | let stream = out.stdout; |
| 6936 | let before = crate::stream::inter_rect_counters(); | 6948 | let before = crate::stream::inter_rect_counters(); |
| 6949 | + let rect64_before = crate::stream::rect64_inter_tu_hits(); | ||
| 6937 | let frames = match decode_stream(&stream) { | 6950 | let frames = match decode_stream(&stream) { |
| 6938 | Err(e) => { | 6951 | Err(e) => { |
| 6939 | let msg = e.to_string(); | 6952 | let msg = e.to_string(); |
| @@ -6950,6 +6963,7 @@ mod tests { | |||
| 6950 | }; | 6963 | }; |
| 6951 | let after = crate::stream::inter_rect_counters(); | 6964 | let after = crate::stream::inter_rect_counters(); |
| 6952 | let (horz, vert) = (after.2 - before.2, after.3 - before.3); | 6965 | let (horz, vert) = (after.2 - before.2, after.3 - before.3); |
| 6966 | + let rect64 = crate::stream::rect64_inter_tu_hits() - rect64_before; | ||
| 6953 | let ffmpeg_frames = if bit_depth == 10 { | 6967 | let ffmpeg_frames = if bit_depth == 10 { |
| 6954 | ffmpeg_decode_sequence_10bit(&stream, width, height, frame_count) | 6968 | ffmpeg_decode_sequence_10bit(&stream, width, height, frame_count) |
| 6955 | } else { | 6969 | } else { |
| @@ -6978,11 +6992,13 @@ mod tests { | |||
| 6978 | } | 6992 | } |
| 6979 | horz_proved += horz; | 6993 | horz_proved += horz; |
| 6980 | vert_proved += vert; | 6994 | vert_proved += vert; |
| 6995 | + rect64_tus += rect64; | ||
| 6981 | matched += 1; | 6996 | matched += 1; |
| 6982 | } | 6997 | } |
| 6983 | eprintln!( | 6998 | eprintln!( |
| 6984 | "{NAME} ({bit_depth}-bit): {named_refusals} named refusals, {matched} pixel-exact \ | 6999 | "{NAME} ({bit_depth}-bit): {named_refusals} named refusals, {matched} pixel-exact \ |
| 6985 | attempts carrying the arm, 64x32 strips={horz_proved}, 32x64 strips={vert_proved}, \ | 7000 | attempts carrying the arm, 64x32 strips={horz_proved}, 32x64 strips={vert_proved}, \ |
| 7001 | + 64-axis residual TUs={rect64_tus}, \ | ||
| 6986 | {out_of_scope} attempts carried none ({oos_mismatch} of them mismatched)" | 7002 | {out_of_scope} attempts carried none ({oos_mismatch} of them mismatched)" |
| 6987 | ); | 7003 | ); |
| 6988 | assert_eq!( | 7004 | assert_eq!( |
| @@ -6990,6 +7006,15 @@ mod tests { | |||
| 6990 | "{NAME}: {oos_mismatch} attempt(s) with no superblock-level inter rect strip \ | 7006 | "{NAME}: {oos_mismatch} attempt(s) with no superblock-level inter rect strip \ |
| 6991 | decoded but mismatched ffmpeg -- a defect of another shape, not a pass" | 7007 | decoded but mismatched ffmpeg -- a defect of another shape, not a pass" |
| 6992 | ); | 7008 | ); |
| 7009 | + // lane-r14 r2: the residual half of the arm -- a strip that is not | ||
| 7010 | + // `skip` and codes a real 64-axis transform unit. Without this the | ||
| 7011 | + // gate proves only the partition symbol. | ||
| 7012 | + assert!( | ||
| 7013 | + rect64_tus > 0, | ||
| 7014 | + "{NAME} ({bit_depth}-bit): no superblock-level rect strip carried a coded \ | ||
| 7015 | + 64-axis residual transform unit inside a pixel-exact attempt \ | ||
| 7016 | + (horz={horz_proved}, vert={vert_proved}) -- the residual arm proved nothing" | ||
| 7017 | + ); | ||
| 6993 | assert!( | 7018 | assert!( |
| 6994 | horz_proved + vert_proved > 0, | 7019 | horz_proved + vert_proved > 0, |
| 6995 | "{NAME} ({bit_depth}-bit): the superblock-level inter rect arm never fired \ | 7020 | "{NAME} ({bit_depth}-bit): the superblock-level inter rect arm never fired \ |
| @@ -13915,6 +13940,7 @@ mod tests { | |||
| 13915 | "--cpu-used=4", | 13940 | "--cpu-used=4", |
| 13916 | "--aq-mode=0", | 13941 | "--aq-mode=0", |
| 13917 | "--deltaq-mode=0", | 13942 | "--deltaq-mode=0", |
| 13943 | + "--enable-cdef=0", | ||
| 13918 | "--kf-max-dist=1000", | 13944 | "--kf-max-dist=1000", |
| 13919 | "--threads=1", | 13945 | "--threads=1", |
| 13920 | "--row-mt=0", | 13946 | "--row-mt=0", |
| @@ -17343,6 +17369,7 @@ mod tests { | |||
| 17343 | "--cpu-used=4", | 17369 | "--cpu-used=4", |
| 17344 | &aq, | 17370 | &aq, |
| 17345 | "--deltaq-mode=0", | 17371 | "--deltaq-mode=0", |
| 17372 | + "--enable-cdef=0", | ||
| 17346 | "--kf-max-dist=1000", | 17373 | "--kf-max-dist=1000", |
| 17347 | "--threads=1", | 17374 | "--threads=1", |
| 17348 | "--row-mt=0", | 17375 | "--row-mt=0", |
| @@ -18072,6 +18099,417 @@ mod tests { | |||
| 18072 | ); | 18099 | ); |
| 18073 | } | 18100 | } |
| 18074 | 18101 | ||
| 18102 | + /// lane-sb128 r1 gate: a real `aomenc --sb-size=128` stream (the size his | ||
| 18103 | + /// ReelC encode uses -- `EC_TRACE=1 aomdec reelc-head.obu` prints | ||
| 18104 | + /// `EC_PART mi_row=0 mi_col=0 bsize=15` = `BLOCK_128X128`) must decode | ||
| 18105 | + /// pixel-exact. `--max-partition-size=64` keeps the RD search from ever | ||
| 18106 | + /// choosing a 128-level NONE/HORZ/VERT/AB arm, so every 128 root here is | ||
| 18107 | + /// genuinely `PARTITION_SPLIT` -- the one arm | ||
| 18108 | + /// `decode_key_frame_tile_with_cdfs` codes; the other seven refuse by | ||
| 18109 | + /// name (`PART128_NON_SPLIT_REFUSAL`) and stay refused after this round. | ||
| 18110 | + /// | ||
| 18111 | + /// What the 128 root actually changes, and what this gate therefore | ||
| 18112 | + /// proves: the 8-symbol `partition_w128` CDF and its forced-split gather | ||
| 18113 | + /// at the frame edge, the quadrant VISIT ORDER (TL, TR, BL, BR inside one | ||
| 18114 | + /// superblock, not raster over 64x64 superblocks), one loop-restoration | ||
| 18115 | + /// read per 128x128 instead of per 64x64, `delta_q`/`delta_lf` once per | ||
| 18116 | + /// 128x128, and the per-64x64 `cdef_idx` read inside the 128 superblock. | ||
| 18117 | + /// 256x192 gives a 2x2 grid of 128 superblocks whose bottom row is a | ||
| 18118 | + /// partial superblock (the gathered forced-split read); 384x384 gives a | ||
| 18119 | + /// 3x3 grid of whole ones. 8-bit sweep plus one 10-bit stream (his films | ||
| 18120 | + /// are `yuv420p10le`). Only a missing tool SKIPs. | ||
| 18121 | + #[test] | ||
| 18122 | + fn a_real_aomenc_stream_with_128x128_superblocks_decodes_pixel_exact() { | ||
| 18123 | + const NAME: &str = "a_real_aomenc_stream_with_128x128_superblocks_decodes_pixel_exact"; | ||
| 18124 | + let _gate_lock = lock_gate_counters(); | ||
| 18125 | + if !have_ffmpeg() { | ||
| 18126 | + eprintln!("SKIP {NAME}: no ffmpeg"); | ||
| 18127 | + return; | ||
| 18128 | + } | ||
| 18129 | + if !have_aomenc() { | ||
| 18130 | + eprintln!("SKIP {NAME}: no aomenc at {}", aomenc_path().display()); | ||
| 18131 | + return; | ||
| 18132 | + } | ||
| 18133 | + let base: Vec<&str> = vec![ | ||
| 18134 | + "--codec=av1", | ||
| 18135 | + "--passes=1", | ||
| 18136 | + "--end-usage=q", | ||
| 18137 | + "--cq-level=40", | ||
| 18138 | + "--cpu-used=0", | ||
| 18139 | + "--threads=1", | ||
| 18140 | + "--row-mt=0", | ||
| 18141 | + "--sb-size=128", | ||
| 18142 | + "--max-partition-size=64", | ||
| 18143 | + "--enable-rect-partitions=1", | ||
| 18144 | + "--enable-ab-partitions=0", | ||
| 18145 | + "--enable-1to4-partitions=0", | ||
| 18146 | + // aomenc emits PARTITION_HORZ_4/VERT_4 below 16x16 even with the | ||
| 18147 | + // flag off (ledger, lane-modectx r1), so bound the search instead. | ||
| 18148 | + "--min-partition-size=16", | ||
| 18149 | + "--enable-restoration=1", | ||
| 18150 | + "--enable-palette=0", | ||
| 18151 | + "--deltaq-mode=0", | ||
| 18152 | + "--enable-intrabc=0", | ||
| 18153 | + "--enable-tx-size-search=0", | ||
| 18154 | + "--limit=1", | ||
| 18155 | + ]; | ||
| 18156 | + let encode = |y4m: &[u8], extra: &[&str]| -> Vec<u8> { | ||
| 18157 | + let mut args = base.clone(); | ||
| 18158 | + args.extend_from_slice(extra); | ||
| 18159 | + args.extend_from_slice(&["--obu", "-o", "-", "-"]); | ||
| 18160 | + let mut child = Command::new(aomenc_path()) | ||
| 18161 | + .args(&args) | ||
| 18162 | + .stdin(Stdio::piped()) | ||
| 18163 | + .stdout(Stdio::piped()) | ||
| 18164 | + .stderr(Stdio::piped()) | ||
| 18165 | + .spawn() | ||
| 18166 | + .expect("aomenc failed to start"); | ||
| 18167 | + child | ||
| 18168 | + .stdin | ||
| 18169 | + .take() | ||
| 18170 | + .expect("aomenc stdin") | ||
| 18171 | + .write_all(y4m) | ||
| 18172 | + .expect("writing y4m to aomenc"); | ||
| 18173 | + let out = child.wait_with_output().expect("aomenc failed to run"); | ||
| 18174 | + assert!( | ||
| 18175 | + out.status.success(), | ||
| 18176 | + "aomenc refused the fixture: {}", | ||
| 18177 | + String::from_utf8_lossy(&out.stderr) | ||
| 18178 | + ); | ||
| 18179 | + out.stdout | ||
| 18180 | + }; | ||
| 18181 | + let render = |seed: u32, width: usize, height: usize, ten_bit: bool| -> Vec<u8> { | ||
| 18182 | + let pix = if ten_bit { "yuv420p10le" } else { "yuv420p" }; | ||
| 18183 | + let out = Command::new("ffmpeg") | ||
| 18184 | + .args([ | ||
| 18185 | + "-v", | ||
| 18186 | + "error", | ||
| 18187 | + "-f", | ||
| 18188 | + "lavfi", | ||
| 18189 | + "-i", | ||
| 18190 | + &gradients_source(seed, width, height, "duration=0.04:rate=25"), | ||
| 18191 | + "-pix_fmt", | ||
| 18192 | + pix, | ||
| 18193 | + "-strict", | ||
| 18194 | + "-1", | ||
| 18195 | + "-t", | ||
| 18196 | + "0.04", | ||
| 18197 | + "-f", | ||
| 18198 | + "yuv4mpegpipe", | ||
| 18199 | + "-", | ||
| 18200 | + ]) | ||
| 18201 | + .stdin(Stdio::null()) | ||
| 18202 | + .stdout(Stdio::piped()) | ||
| 18203 | + .stderr(Stdio::piped()) | ||
| 18204 | + .output() | ||
| 18205 | + .expect("ffmpeg failed to run"); | ||
| 18206 | + assert!( | ||
| 18207 | + out.status.success(), | ||
| 18208 | + "ffmpeg fixture: {}", | ||
| 18209 | + String::from_utf8_lossy(&out.stderr) | ||
| 18210 | + ); | ||
| 18211 | + out.stdout | ||
| 18212 | + }; | ||
| 18213 | + let mut matched = 0u32; | ||
| 18214 | + let mut named_refusals = 0u32; | ||
| 18215 | + // (seed, width, height, 10-bit): 256x192 = 2x2 superblocks with a | ||
| 18216 | + // partial bottom row; 384x384 = 3x3 whole ones. | ||
| 18217 | + let arms: Vec<(u32, usize, usize, bool)> = vec![ | ||
| 18218 | + (42, 256, 192, false), | ||
| 18219 | + (43, 256, 192, false), | ||
| 18220 | + (44, 256, 192, false), | ||
| 18221 | + (45, 384, 384, false), | ||
| 18222 | + (46, 256, 192, true), | ||
| 18223 | + (47, 384, 384, true), | ||
| 18224 | + ]; | ||
| 18225 | + for (seed, width, height, ten_bit) in arms { | ||
| 18226 | + let y4m = render(seed, width, height, ten_bit); | ||
| 18227 | + let extra: Vec<&str> = if ten_bit { | ||
| 18228 | + vec!["--input-bit-depth=10", "--bit-depth=10"] | ||
| 18229 | + } else { | ||
| 18230 | + vec![] | ||
| 18231 | + }; | ||
| 18232 | + let stream = encode(&y4m, &extra); | ||
| 18233 | + let parsed = { | ||
| 18234 | + let mut parser = ec_av1_syntax::Av1Parser::new(); | ||
| 18235 | + let mut pos = 0usize; | ||
| 18236 | + while let Ok(obu) = parser.parse_obu(&stream[pos..]) { | ||
| 18237 | + pos += obu.total_size; | ||
| 18238 | + if pos >= stream.len() { | ||
| 18239 | + break; | ||
| 18240 | + } | ||
| 18241 | + } | ||
| 18242 | + parser | ||
| 18243 | + .sequence_header() | ||
| 18244 | + .map(|q| (q.use_128x128_superblock, q.color_config.bit_depth)) | ||
| 18245 | + }; | ||
| 18246 | + assert_eq!( | ||
| 18247 | + parsed, | ||
| 18248 | + Some((true, if ten_bit { 10 } else { 8 })), | ||
| 18249 | + "{NAME} (seed {seed}): the encoder did not write a 128x128-superblock \ | ||
| 18250 | + sequence header at the requested bit depth -- the flag never arrived" | ||
| 18251 | + ); | ||
| 18252 | + let frames = match decode_stream(&stream) { | ||
| 18253 | + Err(e) => { | ||
| 18254 | + let msg = e.to_string(); | ||
| 18255 | + assert!( | ||
| 18256 | + msg.contains("unsupported"), | ||
| 18257 | + "{NAME} failed outright, not a named refusal (seed {seed}): {msg}" | ||
| 18258 | + ); | ||
| 18259 | + named_refusals += 1; | ||
| 18260 | + eprintln!("seed {seed} refusal: {msg}"); | ||
| 18261 | + continue; | ||
| 18262 | + } | ||
| 18263 | + Ok(frames) => frames, | ||
| 18264 | + }; | ||
| 18265 | + let want = if ten_bit { | ||
| 18266 | + ffmpeg_decode_sequence_10bit(&stream, width, height, 1) | ||
| 18267 | + } else { | ||
| 18268 | + ffmpeg_decode_sequence(&stream, width, height, 1) | ||
| 18269 | + }; | ||
| 18270 | + assert_eq!(frames.len(), 1); | ||
| 18271 | + for (i, (got, want)) in frames.iter().zip(&want).enumerate() { | ||
| 18272 | + assert_eq!(got.y, want.y, "{NAME} frame {i} luma vs ffmpeg (seed {seed})"); | ||
| 18273 | + assert_eq!(got.u, want.u, "{NAME} frame {i} U vs ffmpeg (seed {seed})"); | ||
| 18274 | + assert_eq!(got.v, want.v, "{NAME} frame {i} V vs ffmpeg (seed {seed})"); | ||
| 18275 | + } | ||
| 18276 | + matched += 1; | ||
| 18277 | + } | ||
| 18278 | + assert!( | ||
| 18279 | + matched > 0, | ||
| 18280 | + "{NAME}: every attempt refused; the gate never decoded a stream" | ||
| 18281 | + ); | ||
| 18282 | + // 256x192 codes 3 whole + 1 partial superblock, 384x384 codes 9 whole | ||
| 18283 | + // ones, so a run that decoded anything at all must have read real 128 | ||
| 18284 | + // partition symbols and split every one of them. | ||
| 18285 | + assert!( | ||
| 18286 | + crate::decode::part128_symbols() >= 3 * matched as usize, | ||
| 18287 | + "{NAME}: only {} 128-level partition symbols over {matched} decoded streams -- \ | ||
| 18288 | + the 128 root never fired", | ||
| 18289 | + crate::decode::part128_symbols() | ||
| 18290 | + ); | ||
| 18291 | + assert!( | ||
| 18292 | + crate::decode::part128_split_hits() >= 4 * matched as usize, | ||
| 18293 | + "{NAME}: only {} 128 superblocks split", | ||
| 18294 | + crate::decode::part128_split_hits() | ||
| 18295 | + ); | ||
| 18296 | + eprintln!( | ||
| 18297 | + "{NAME}: {matched} pixel-exact, {named_refusals} named refusals, \ | ||
| 18298 | + part128_symbols={} part128_split_hits={}", | ||
| 18299 | + crate::decode::part128_symbols(), | ||
| 18300 | + crate::decode::part128_split_hits() | ||
| 18301 | + ); | ||
| 18302 | + } | ||
| 18303 | + | ||
| 18304 | + #[test] | ||
| 18305 | + #[ignore = "lane-sb128 r2 diagnostic: is the frame-6 mismatch sb128-specific?"] | ||
| 18306 | + fn sb128_r2_control_sb64() { | ||
| 18307 | + let (width, height) = (256usize, 192usize); | ||
| 18308 | + let y4m = Command::new("ffmpeg") | ||
| 18309 | + .args([ | ||
| 18310 | + "-v", "error", "-f", "lavfi", "-i", | ||
| 18311 | + &format!( | ||
| 18312 | + "{},noise=all_seed=53:alls=12:allf=t", | ||
| 18313 | + gradients_source(53, width, height, "duration=0.32:rate=25") | ||
| 18314 | + ), | ||
| 18315 | + "-pix_fmt", "yuv420p", "-t", "0.32", "-f", "yuv4mpegpipe", "-", | ||
| 18316 | + ]) | ||
| 18317 | + .stdin(Stdio::null()) | ||
| 18318 | + .stdout(Stdio::piped()) | ||
| 18319 | + .output() | ||
| 18320 | + .expect("ffmpeg"); | ||
| 18321 | + let mut child = Command::new(aomenc_path()) | ||
| 18322 | + .args([ | ||
| 18323 | + "--codec=av1", "--passes=1", "--end-usage=q", "--cq-level=40", | ||
| 18324 | + "--cpu-used=2", "--threads=1", "--row-mt=0", "--sb-size=64", | ||
| 18325 | + "--max-partition-size=64", "--min-partition-size=32", | ||
| 18326 | + "--enable-rect-partitions=0", "--enable-ab-partitions=0", | ||
| 18327 | + "--enable-1to4-partitions=0", "--enable-palette=0", | ||
| 18328 | + "--enable-intrabc=0", "--enable-tx-size-search=0", | ||
| 18329 | + "--deltaq-mode=0", "--limit=8", "--obu", "-o", "-", "-", | ||
| 18330 | + ]) | ||
| 18331 | + .stdin(Stdio::piped()) | ||
| 18332 | + .stdout(Stdio::piped()) | ||
| 18333 | + .stderr(Stdio::piped()) | ||
| 18334 | + .spawn() | ||
| 18335 | + .expect("aomenc"); | ||
| 18336 | + child.stdin.take().unwrap().write_all(&y4m.stdout).unwrap(); | ||
| 18337 | + let out = child.wait_with_output().expect("aomenc run"); | ||
| 18338 | + assert!(out.status.success()); | ||
| 18339 | + let (frames, hidden) = decode_all_frames_vs_oracle(&out.stdout, "sb128-control-64"); | ||
| 18340 | + eprintln!("control sb64: {frames} frames exact ({hidden} hidden)"); | ||
| 18341 | + } | ||
| 18342 | + | ||
| 18343 | + /// lane-sb128 r2: an INTER SEQUENCE under a 128x128 superblock -- the | ||
| 18344 | + /// half ReelC is made of. r1 refused it by name (the inter tile loop | ||
| 18345 | + /// recursed a 64x64 root only); r2 ported `sb_visit_order` and the 128 | ||
| 18346 | + /// root (per-superblock `read_lr`, the 8-symbol `partition_w128` read with | ||
| 18347 | + /// its edge gather, `delta_q`/`delta_lf` at 128 granularity) into that | ||
| 18348 | + /// loop, so this gate replaces the refusal test. | ||
| 18349 | + /// | ||
| 18350 | + /// Every frame in DECODE order, hidden alt-refs included | ||
| 18351 | + /// ([`decode_all_frames_vs_oracle`], class gate-blind-to-hidden-frames): | ||
| 18352 | + /// `--lag-in-frames` is left at aomenc's default so the encoder really | ||
| 18353 | + /// emits them. Per-ATTEMPT counter deltas are hard asserts (class | ||
| 18354 | + /// counter-from-refused-stream: the helper panics on any refusal, so every | ||
| 18355 | + /// counted attempt is a compared one): 128 partition roots read on this | ||
| 18356 | + /// stream, `cdef_idx` reads (one per 64x64 quadrant inside the 128 | ||
| 18357 | + /// superblock), and temporal MV candidates (the inter-only path). Both bit | ||
| 18358 | + /// depths -- his films are `yuv420p10le`. Only a missing tool SKIPs. | ||
| 18359 | + #[test] | ||
| 18360 | + fn a_real_aomenc_inter_sequence_with_128x128_superblocks_decodes_pixel_exact() { | ||
| 18361 | + const NAME: &str = | ||
| 18362 | + "a_real_aomenc_inter_sequence_with_128x128_superblocks_decodes_pixel_exact"; | ||
| 18363 | + let _gate_lock = lock_gate_counters(); | ||
| 18364 | + if !have_ffmpeg() || !have_aomenc() { | ||
| 18365 | + eprintln!("SKIP {NAME}: no ffmpeg/aomenc/aomdec"); | ||
| 18366 | + return; | ||
| 18367 | + } | ||
| 18368 | + let (width, height) = (256usize, 192usize); | ||
| 18369 | + for ten_bit in [false, true] { | ||
| 18370 | + let pix = if ten_bit { "yuv420p10le" } else { "yuv420p" }; | ||
| 18371 | + let y4m = Command::new("ffmpeg") | ||
| 18372 | + .args([ | ||
| 18373 | + "-v", | ||
| 18374 | + "error", | ||
| 18375 | + "-f", | ||
| 18376 | + "lavfi", | ||
| 18377 | + "-i", | ||
| 18378 | + &format!( | ||
| 18379 | + // Noise on top of the gradient is what makes aomenc | ||
| 18380 | + // signal a nonzero `cdef_bits` (a clean gradient codes | ||
| 18381 | + // with CDEF off, and the cdef_idx counter stays 0). | ||
| 18382 | + "{},noise=all_seed=53:alls=12:allf=t", | ||
| 18383 | + gradients_source(53, width, height, "duration=0.32:rate=25") | ||
| 18384 | + ), | ||
| 18385 | + "-pix_fmt", | ||
| 18386 | + pix, | ||
| 18387 | + "-strict", | ||
| 18388 | + "-1", | ||
| 18389 | + "-t", | ||
| 18390 | + "0.32", | ||
| 18391 | + "-f", | ||
| 18392 | + "yuv4mpegpipe", | ||
| 18393 | + "-", | ||
| 18394 | + ]) | ||
| 18395 | + .stdin(Stdio::null()) | ||
| 18396 | + .stdout(Stdio::piped()) | ||
| 18397 | + .stderr(Stdio::piped()) | ||
| 18398 | + .output() | ||
| 18399 | + .expect("ffmpeg failed to run"); | ||
| 18400 | + assert!( | ||
| 18401 | + y4m.status.success(), | ||
| 18402 | + "{NAME}: ffmpeg fixture: {}", | ||
| 18403 | + String::from_utf8_lossy(&y4m.stderr) | ||
| 18404 | + ); | ||
| 18405 | + let mut args: Vec<&str> = vec![ | ||
| 18406 | + "--codec=av1", | ||
| 18407 | + "--passes=1", | ||
| 18408 | + "--end-usage=q", | ||
| 18409 | + "--cq-level=40", | ||
| 18410 | + "--cpu-used=2", | ||
| 18411 | + "--threads=1", | ||
| 18412 | + "--row-mt=0", | ||
| 18413 | + "--sb-size=128", | ||
| 18414 | + "--max-partition-size=64", | ||
| 18415 | + // aomenc emits PARTITION_HORZ_4/VERT_4 below 16x16 even with | ||
| 18416 | + // the flag off (ledger, lane-modectx r1), so bound the search. | ||
| 18417 | + "--min-partition-size=32", | ||
| 18418 | + // The inter path still refuses rectangular strips ("a non-skip | ||
| 18419 | + // rectangular (HORZ/VERT/HORZ_B) strip needs rectangular | ||
| 18420 | + // residual coding") -- another lane's gap, off here so this | ||
| 18421 | + // gate measures the 128 root and nothing else. | ||
| 18422 | + "--enable-rect-partitions=0", | ||
| 18423 | + "--enable-ab-partitions=0", | ||
| 18424 | + "--enable-1to4-partitions=0", | ||
| 18425 | + "--enable-palette=0", | ||
| 18426 | + "--enable-intrabc=0", | ||
| 18427 | + "--enable-tx-size-search=0", | ||
| 18428 | + "--deltaq-mode=0", | ||
| 18429 | + "--limit=8", | ||
| 18430 | + ]; | ||
| 18431 | + if ten_bit { | ||
| 18432 | + args.extend_from_slice(&["--input-bit-depth=10", "--bit-depth=10"]); | ||
| 18433 | + } | ||
| 18434 | + args.extend_from_slice(&["--obu", "-o", "-", "-"]); | ||
| 18435 | + let mut child = Command::new(aomenc_path()) | ||
| 18436 | + .args(&args) | ||
| 18437 | + .stdin(Stdio::piped()) | ||
| 18438 | + .stdout(Stdio::piped()) | ||
| 18439 | + .stderr(Stdio::piped()) | ||
| 18440 | + .spawn() | ||
| 18441 | + .expect("aomenc failed to start"); | ||
| 18442 | + child | ||
| 18443 | + .stdin | ||
| 18444 | + .take() | ||
| 18445 | + .expect("aomenc stdin") | ||
| 18446 | + .write_all(&y4m.stdout) | ||
| 18447 | + .expect("writing y4m to aomenc"); | ||
| 18448 | + let out = child.wait_with_output().expect("aomenc failed to run"); | ||
| 18449 | + assert!( | ||
| 18450 | + out.status.success(), | ||
| 18451 | + "{NAME}: aomenc refused the fixture: {}", | ||
| 18452 | + String::from_utf8_lossy(&out.stderr) | ||
| 18453 | + ); | ||
| 18454 | + let stream = out.stdout; | ||
| 18455 | + let header = { | ||
| 18456 | + let mut parser = ec_av1_syntax::Av1Parser::new(); | ||
| 18457 | + let mut pos = 0usize; | ||
| 18458 | + while let Ok(obu) = parser.parse_obu(&stream[pos..]) { | ||
| 18459 | + pos += obu.total_size; | ||
| 18460 | + if pos >= stream.len() { | ||
| 18461 | + break; | ||
| 18462 | + } | ||
| 18463 | + } | ||
| 18464 | + parser | ||
| 18465 | + .sequence_header() | ||
| 18466 | + .map(|q| (q.use_128x128_superblock, q.color_config.bit_depth)) | ||
| 18467 | + }; | ||
| 18468 | + assert_eq!( | ||
| 18469 | + header, | ||
| 18470 | + Some((true, if ten_bit { 10 } else { 8 })), | ||
| 18471 | + "{NAME}: the encoder did not write a 128x128-superblock sequence header at \ | ||
| 18472 | + the requested bit depth -- the flag never arrived" | ||
| 18473 | + ); | ||
| 18474 | + let before = ( | ||
| 18475 | + crate::decode::part128_symbols(), | ||
| 18476 | + crate::decode::cdef_idx_hits(), | ||
| 18477 | + crate::decode::tmv_hits(), | ||
| 18478 | + ); | ||
| 18479 | + let (frames, hidden) = decode_all_frames_vs_oracle( | ||
| 18480 | + &stream, | ||
| 18481 | + &format!("sb128-inter-{}", if ten_bit { 10 } else { 8 }), | ||
| 18482 | + ); | ||
| 18483 | + let (part128, cdef_idx, tmv) = ( | ||
| 18484 | + crate::decode::part128_symbols() - before.0, | ||
| 18485 | + crate::decode::cdef_idx_hits() - before.1, | ||
| 18486 | + crate::decode::tmv_hits() - before.2, | ||
| 18487 | + ); | ||
| 18488 | + assert!( | ||
| 18489 | + frames >= 6, | ||
| 18490 | + "{NAME} ({pix}): only {frames} frames in decode order, the recipe asks for 8" | ||
| 18491 | + ); | ||
| 18492 | + assert!( | ||
| 18493 | + part128 >= 3, | ||
| 18494 | + "{NAME} ({pix}): only {part128} 128-level partition symbols on this stream -- \ | ||
| 18495 | + the 128 root never fired on the inter frames" | ||
| 18496 | + ); | ||
| 18497 | + assert!( | ||
| 18498 | + cdef_idx >= 1, | ||
| 18499 | + "{NAME} ({pix}): no cdef_idx read -- the per-64x64-quadrant cdef read inside \ | ||
| 18500 | + the 128 superblock never fired" | ||
| 18501 | + ); | ||
| 18502 | + assert!( | ||
| 18503 | + tmv >= 1, | ||
| 18504 | + "{NAME} ({pix}): no temporal MV candidate -- the inter path never ran" | ||
| 18505 | + ); | ||
| 18506 | + eprintln!( | ||
| 18507 | + "{NAME} ({pix}): {frames} decode-order frames pixel-exact ({hidden} hidden), \ | ||
| 18508 | + part128_symbols={part128} cdef_idx_hits={cdef_idx} tmv_hits={tmv}" | ||
| 18509 | + ); | ||
| 18510 | + } | ||
| 18511 | + } | ||
| 18512 | + | ||
| 18075 | /// lane-sbpart r2: a real `aomenc` stream whose superblock-level | 18513 | /// lane-sbpart r2: a real `aomenc` stream whose superblock-level |
| 18076 | /// partition decision is genuinely HORZ/VERT (not NONE/SPLIT) must | 18514 | /// partition decision is genuinely HORZ/VERT (not NONE/SPLIT) must |
| 18077 | /// decode pixel-exact through [`crate::decode::decode_block_rect64`] -- | 18515 | /// decode pixel-exact through [`crate::decode::decode_block_rect64`] -- |
| @@ -18149,6 +18587,7 @@ mod tests { | |||
| 18149 | "--enable-restoration=0", | 18587 | "--enable-restoration=0", |
| 18150 | "--enable-palette=0", | 18588 | "--enable-palette=0", |
| 18151 | "--deltaq-mode=0", | 18589 | "--deltaq-mode=0", |
| 18590 | + "--enable-cdef=0", | ||
| 18152 | "--enable-filter-intra=0", | 18591 | "--enable-filter-intra=0", |
| 18153 | "--enable-cfl-intra=0", | 18592 | "--enable-cfl-intra=0", |
| 18154 | "--enable-intrabc=0", | 18593 | "--enable-intrabc=0", |
| @@ -18515,6 +18954,7 @@ mod tests { | |||
| 18515 | "--enable-restoration=0", | 18954 | "--enable-restoration=0", |
| 18516 | "--enable-palette=0", | 18955 | "--enable-palette=0", |
| 18517 | "--deltaq-mode=0", | 18956 | "--deltaq-mode=0", |
| 18957 | + "--enable-cdef=0", | ||
| 18518 | "--enable-filter-intra=0", | 18958 | "--enable-filter-intra=0", |
| 18519 | "--enable-cfl-intra=0", | 18959 | "--enable-cfl-intra=0", |
| 18520 | "--enable-intrabc=0", | 18960 | "--enable-intrabc=0", |
| @@ -18721,6 +19161,7 @@ mod tests { | |||
| 18721 | "--enable-restoration=0", | 19161 | "--enable-restoration=0", |
| 18722 | "--enable-palette=0", | 19162 | "--enable-palette=0", |
| 18723 | "--deltaq-mode=0", | 19163 | "--deltaq-mode=0", |
| 19164 | + "--enable-cdef=0", | ||
| 18724 | "--enable-filter-intra=0", | 19165 | "--enable-filter-intra=0", |
| 18725 | "--enable-cfl-intra=0", | 19166 | "--enable-cfl-intra=0", |
| 18726 | "--enable-intrabc=0", | 19167 | "--enable-intrabc=0", |
| @@ -18975,6 +19416,7 @@ mod tests { | |||
| 18975 | "--enable-restoration=0", | 19416 | "--enable-restoration=0", |
| 18976 | "--enable-palette=0", | 19417 | "--enable-palette=0", |
| 18977 | "--deltaq-mode=0", | 19418 | "--deltaq-mode=0", |
| 19419 | + "--enable-cdef=0", | ||
| 18978 | // The point of this gate. | 19420 | // The point of this gate. |
| 18979 | "--enable-filter-intra=1", | 19421 | "--enable-filter-intra=1", |
| 18980 | // NOTE (lane-rectsplit r2, verifier finding): every intra | 19422 | // NOTE (lane-rectsplit r2, verifier finding): every intra |
| @@ -19146,6 +19588,7 @@ mod tests { | |||
| 19146 | "--enable-restoration=0", | 19588 | "--enable-restoration=0", |
| 19147 | "--enable-palette=0", | 19589 | "--enable-palette=0", |
| 19148 | "--deltaq-mode=0", | 19590 | "--deltaq-mode=0", |
| 19591 | + "--enable-cdef=0", | ||
| 19149 | "--enable-filter-intra=1", | 19592 | "--enable-filter-intra=1", |
| 19150 | "--enable-cfl-intra=0", | 19593 | "--enable-cfl-intra=0", |
| 19151 | "--enable-intrabc=0", | 19594 | "--enable-intrabc=0", |
| @@ -19341,6 +19784,7 @@ mod tests { | |||
| 19341 | "--enable-restoration=0", | 19784 | "--enable-restoration=0", |
| 19342 | "--enable-palette=0", | 19785 | "--enable-palette=0", |
| 19343 | "--deltaq-mode=0", | 19786 | "--deltaq-mode=0", |
| 19787 | + "--enable-cdef=0", | ||
| 19344 | "--enable-filter-intra=1", | 19788 | "--enable-filter-intra=1", |
| 19345 | "--enable-cfl-intra=0", | 19789 | "--enable-cfl-intra=0", |
| 19346 | "--enable-intrabc=0", | 19790 | "--enable-intrabc=0", |
| @@ -19539,6 +19983,7 @@ mod tests { | |||
| 19539 | "--enable-restoration=0", | 19983 | "--enable-restoration=0", |
| 19540 | "--enable-palette=0", | 19984 | "--enable-palette=0", |
| 19541 | "--deltaq-mode=0", | 19985 | "--deltaq-mode=0", |
| 19986 | + "--enable-cdef=0", | ||
| 19542 | "--enable-filter-intra=0", | 19987 | "--enable-filter-intra=0", |
| 19543 | "--enable-cfl-intra=0", | 19988 | "--enable-cfl-intra=0", |
| 19544 | "--enable-intrabc=0", | 19989 | "--enable-intrabc=0", |
| @@ -19715,6 +20160,7 @@ mod tests { | |||
| 19715 | "--enable-restoration=0", | 20160 | "--enable-restoration=0", |
| 19716 | "--enable-palette=0", | 20161 | "--enable-palette=0", |
| 19717 | "--deltaq-mode=0", | 20162 | "--deltaq-mode=0", |
| 20163 | + "--enable-cdef=0", | ||
| 19718 | "--enable-filter-intra=0", | 20164 | "--enable-filter-intra=0", |
| 19719 | "--enable-cfl-intra=0", | 20165 | "--enable-cfl-intra=0", |
| 19720 | "--enable-intrabc=0", | 20166 | "--enable-intrabc=0", |
| @@ -20178,6 +20624,7 @@ mod tests { | |||
| 20178 | "--enable-restoration=0", | 20624 | "--enable-restoration=0", |
| 20179 | "--enable-palette=0", | 20625 | "--enable-palette=0", |
| 20180 | "--deltaq-mode=0", | 20626 | "--deltaq-mode=0", |
| 20627 | + "--enable-cdef=0", | ||
| 20181 | "--enable-filter-intra=0", | 20628 | "--enable-filter-intra=0", |
| 20182 | "--enable-cfl-intra=0", | 20629 | "--enable-cfl-intra=0", |
| 20183 | "--enable-intrabc=0", | 20630 | "--enable-intrabc=0", |
| @@ -20314,6 +20761,252 @@ mod tests { | |||
| 20314 | /// then compared pixel-exact are counted (class | 20761 | /// then compared pixel-exact are counted (class |
| 20315 | /// gate-skips-on-its-own-failure); the 10-bit arm is what retires | 20762 | /// gate-skips-on-its-own-failure); the 10-bit arm is what retires |
| 20316 | /// `enable-1to4-partitions` from `NEVER_EXERCISED_10BIT`. | 20763 | /// `enable-1to4-partitions` from `NEVER_EXERCISED_10BIT`. |
| 20764 | + /// lane-r14: the 16x16-level 1:4 pair -- four 16x4 (`PARTITION_HORZ_4`) or | ||
| 20765 | + /// 4x16 (`PARTITION_VERT_4`) strips, the shape the wall | ||
| 20766 | + /// "a 1:4 partition below 16x16" refused. Fixture: 4-PIXEL bands (the | ||
| 20767 | + /// 8-pixel ones of the 32-level gate above, one size down -- a 16x4 strip | ||
| 20768 | + /// is flat where a 16x8 one is not), transposed per attempt so a | ||
| 20769 | + /// transposed scan or nz-map table cannot pass (class | ||
| 20770 | + /// scan-weights-cross-axis), plus an explicit-seed noise layer that keeps | ||
| 20771 | + /// aomenc out of screen-content mode. `--enable-filter-intra=1` and | ||
| 20772 | + /// is ON: this shape reads `use_filter_intra` off its own CDF rows | ||
| 20773 | + /// (classes 12/13). The `--enable-tx-size-search=1` half of the window | ||
| 20774 | + /// splits the strip's transform (depth 1 = TX_8X4/TX_4X8, depth 2 = | ||
| 20775 | + /// TX_4X4). | ||
| 20776 | + /// | ||
| 20777 | + /// Counters: 16x4 strips, 4x16 strips, chroma-reference strips (the odd | ||
| 20778 | + /// strip of each 4:2:0 pair, the only one that codes chroma) and strips | ||
| 20779 | + /// with a coded residual must all be nonzero over the compared attempts, | ||
| 20780 | + /// and only attempts that DECODED and were compared pixel-exact count | ||
| 20781 | + /// (class gate-skips-on-its-own-failure). | ||
| 20782 | + #[test] | ||
| 20783 | + fn a_real_aomenc_stream_with_a_16_level_1to4_partition_decodes_pixel_exact() { | ||
| 20784 | + const NAME: &str = | ||
| 20785 | + "a_real_aomenc_stream_with_a_16_level_1to4_partition_decodes_pixel_exact"; | ||
| 20786 | + let _gate_lock = lock_gate_counters(); | ||
| 20787 | + if !have_ffmpeg() { | ||
| 20788 | + eprintln!("SKIP {NAME}: no ffmpeg"); | ||
| 20789 | + return; | ||
| 20790 | + } | ||
| 20791 | + if !have_aomenc() { | ||
| 20792 | + eprintln!("SKIP {NAME}: no aomenc at {}", aomenc_path().display()); | ||
| 20793 | + return; | ||
| 20794 | + } | ||
| 20795 | + let (width, height, frame_count) = (192usize, 128usize, 1usize); | ||
| 20796 | + let n_attempts: u32 = std::env::var("EC_R14_GATE_ATTEMPTS") | ||
| 20797 | + .ok() | ||
| 20798 | + .and_then(|s| s.parse().ok()) | ||
| 20799 | + .unwrap_or(8); | ||
| 20800 | + for bit_depth in [8u32, 10u32] { | ||
| 20801 | + let mut named_refusals = 0u32; | ||
| 20802 | + let mut matched = 0u32; | ||
| 20803 | + let (mut horz_proved, mut vert_proved) = (0usize, 0usize); | ||
| 20804 | + let (mut chroma_proved, mut coeff_proved) = (0usize, 0usize); | ||
| 20805 | + let mut split_proved = 0usize; | ||
| 20806 | + let (mut out_of_scope, mut out_of_scope_mismatch) = (0u32, 0u32); | ||
| 20807 | + // The second half of the window turns `--enable-tx-size-search` on: | ||
| 20808 | + // that is what makes a 16x4 strip SPLIT its transform (depth 1 = | ||
| 20809 | + // TX_8X4, depth 2 = TX_4X4), the arm the first half never reaches. | ||
| 20810 | + for attempt in 0..n_attempts * 2 { | ||
| 20811 | + let tx_search = attempt >= n_attempts; | ||
| 20812 | + let attempt = attempt % n_attempts; | ||
| 20813 | + let seed = 42 + attempt; | ||
| 20814 | + let duration = frame_count as f64 / 25.0; | ||
| 20815 | + let axis = if attempt % 2 == 0 { "Y" } else { "X" }; | ||
| 20816 | + let step = 67 + (attempt / 2) * 12; | ||
| 20817 | + let noise = 6 + (attempt % 4) * 3; | ||
| 20818 | + let source = format!( | ||
| 20819 | + "color=c=gray:s={width}x{height}:d={duration}:r=25,format=gray,\ | ||
| 20820 | + geq=lum='mod(floor({axis}/4)*{step},256)',\ | ||
| 20821 | + noise=alls={noise}:all_seed={seed},format=yuv420p" | ||
| 20822 | + ); | ||
| 20823 | + let cq_level = format!("--cq-level={}", 24 + (attempt % 4) * 8); | ||
| 20824 | + let pix_fmt = if bit_depth == 10 { "yuv420p10le" } else { "yuv420p" }; | ||
| 20825 | + let y4m = Command::new("ffmpeg") | ||
| 20826 | + .args([ | ||
| 20827 | + "-v", "error", "-f", "lavfi", "-i", &source, "-t", &duration.to_string(), | ||
| 20828 | + "-pix_fmt", pix_fmt, "-strict", "-1", "-f", "yuv4mpegpipe", "-", | ||
| 20829 | + ]) | ||
| 20830 | + .stdin(Stdio::null()) | ||
| 20831 | + .stdout(Stdio::piped()) | ||
| 20832 | + .stderr(Stdio::piped()) | ||
| 20833 | + .output() | ||
| 20834 | + .expect("ffmpeg failed to run"); | ||
| 20835 | + assert!( | ||
| 20836 | + y4m.status.success(), | ||
| 20837 | + "{NAME}: ffmpeg refused the {bit_depth}-bit fixture: {}", | ||
| 20838 | + String::from_utf8_lossy(&y4m.stderr) | ||
| 20839 | + ); | ||
| 20840 | + let depth_arg = format!("--bit-depth={bit_depth}"); | ||
| 20841 | + let input_depth_arg = format!("--input-bit-depth={bit_depth}"); | ||
| 20842 | + let args: Vec<&str> = vec![ | ||
| 20843 | + "--codec=av1", | ||
| 20844 | + "--passes=1", | ||
| 20845 | + "--end-usage=q", | ||
| 20846 | + &cq_level, | ||
| 20847 | + "--cpu-used=0", | ||
| 20848 | + "--threads=1", | ||
| 20849 | + "--row-mt=0", | ||
| 20850 | + "--sb-size=64", | ||
| 20851 | + &depth_arg, | ||
| 20852 | + &input_depth_arg, | ||
| 20853 | + "--enable-rect-partitions=1", | ||
| 20854 | + "--enable-ab-partitions=0", | ||
| 20855 | + "--enable-1to4-partitions=1", | ||
| 20856 | + "--min-partition-size=4", | ||
| 20857 | + "--max-partition-size=16", | ||
| 20858 | + "--enable-restoration=0", | ||
| 20859 | + "--enable-palette=0", | ||
| 20860 | + "--deltaq-mode=0", | ||
| 20861 | + "--enable-filter-intra=1", | ||
| 20862 | + // lane-r14: CfL stays OFF here. This shape's CfL averages | ||
| 20863 | + // the luma of the whole PAIR and is written, but no gate | ||
| 20864 | + // asserts a CfL hit counter (there is none), and passing | ||
| 20865 | + // `=1` would retire `enable-cfl-intra` from | ||
| 20866 | + // `gate_coverage::NEVER_EXERCISED_*` on a flag alone -- | ||
| 20867 | + // exactly the false coverage that list exists to prevent. | ||
| 20868 | + "--enable-cfl-intra=0", | ||
| 20869 | + "--enable-intrabc=0", | ||
| 20870 | + if tx_search { | ||
| 20871 | + "--enable-tx-size-search=1" | ||
| 20872 | + } else { | ||
| 20873 | + "--enable-tx-size-search=0" | ||
| 20874 | + }, | ||
| 20875 | + "--obu", | ||
| 20876 | + "-o", | ||
| 20877 | + "-", | ||
| 20878 | + "-", | ||
| 20879 | + ]; | ||
| 20880 | + let mut child = Command::new(aomenc_path()) | ||
| 20881 | + .args(&args) | ||
| 20882 | + .stdin(Stdio::piped()) | ||
| 20883 | + .stdout(Stdio::piped()) | ||
| 20884 | + .stderr(Stdio::piped()) | ||
| 20885 | + .spawn() | ||
| 20886 | + .expect("aomenc failed to start"); | ||
| 20887 | + child | ||
| 20888 | + .stdin | ||
| 20889 | + .take() | ||
| 20890 | + .expect("aomenc stdin") | ||
| 20891 | + .write_all(&y4m.stdout) | ||
| 20892 | + .expect("writing y4m to aomenc"); | ||
| 20893 | + let out = child.wait_with_output().expect("aomenc failed to run"); | ||
| 20894 | + assert!( | ||
| 20895 | + out.status.success(), | ||
| 20896 | + "aomenc refused the fixture: {}", | ||
| 20897 | + String::from_utf8_lossy(&out.stderr) | ||
| 20898 | + ); | ||
| 20899 | + let stream = out.stdout; | ||
| 20900 | + let before = crate::decode::rect4_16_counters(); | ||
| 20901 | + let frames = match decode_stream(&stream) { | ||
| 20902 | + Err(e) => { | ||
| 20903 | + let msg = e.to_string(); | ||
| 20904 | + assert!( | ||
| 20905 | + msg.contains("unsupported"), | ||
| 20906 | + "{NAME} failed outright, not a named refusal ({bit_depth}-bit, seed \ | ||
| 20907 | + {seed}): {msg}" | ||
| 20908 | + ); | ||
| 20909 | + named_refusals += 1; | ||
| 20910 | + eprintln!("{bit_depth}-bit seed {seed} refusal: {msg}"); | ||
| 20911 | + continue; | ||
| 20912 | + } | ||
| 20913 | + Ok(frames) => frames, | ||
| 20914 | + }; | ||
| 20915 | + let now = crate::decode::rect4_16_counters(); | ||
| 20916 | + let (horz, vert, chroma, coeff, split) = ( | ||
| 20917 | + now.0 - before.0, | ||
| 20918 | + now.1 - before.1, | ||
| 20919 | + now.2 - before.2, | ||
| 20920 | + now.3 - before.3, | ||
| 20921 | + now.4 - before.4, | ||
| 20922 | + ); | ||
| 20923 | + let ffmpeg_frames = if bit_depth == 10 { | ||
| 20924 | + ffmpeg_decode_sequence_10bit(&stream, width, height, frame_count) | ||
| 20925 | + } else { | ||
| 20926 | + ffmpeg_decode_sequence(&stream, width, height, frame_count) | ||
| 20927 | + }; | ||
| 20928 | + assert_eq!(frames.len(), frame_count); | ||
| 20929 | + let mismatched = frames | ||
| 20930 | + .iter() | ||
| 20931 | + .zip(&ffmpeg_frames) | ||
| 20932 | + .any(|(got, want)| got.y != want.y || got.u != want.u || got.v != want.v); | ||
| 20933 | + if horz + vert == 0 { | ||
| 20934 | + out_of_scope += 1; | ||
| 20935 | + if mismatched { | ||
| 20936 | + out_of_scope_mismatch += 1; | ||
| 20937 | + eprintln!( | ||
| 20938 | + "{NAME}: {bit_depth}-bit seed {seed} MISMATCHES with zero 16-level \ | ||
| 20939 | + 1:4 strips -- a pre-existing defect of another shape" | ||
| 20940 | + ); | ||
| 20941 | + } | ||
| 20942 | + continue; | ||
| 20943 | + } | ||
| 20944 | + if mismatched && let Ok(path) = std::env::var("EC_AV1_GATE_DUMP") { | ||
| 20945 | + std::fs::write(&path, &stream).expect("writing pinned stream"); | ||
| 20946 | + eprintln!( | ||
| 20947 | + "EC_AV1_GATE_DUMP: wrote mismatching stream ({bit_depth}-bit, seed \ | ||
| 20948 | + {seed}) to {path}" | ||
| 20949 | + ); | ||
| 20950 | + } | ||
| 20951 | + for (i, (got, want)) in frames.iter().zip(&ffmpeg_frames).enumerate() { | ||
| 20952 | + assert_eq!( | ||
| 20953 | + got.y, want.y, | ||
| 20954 | + "{NAME} frame {i} luma vs ffmpeg ({bit_depth}-bit, seed {seed})" | ||
| 20955 | + ); | ||
| 20956 | + assert_eq!( | ||
| 20957 | + got.u, want.u, | ||
| 20958 | + "{NAME} frame {i} U vs ffmpeg ({bit_depth}-bit, seed {seed})" | ||
| 20959 | + ); | ||
| 20960 | + assert_eq!( | ||
| 20961 | + got.v, want.v, | ||
| 20962 | + "{NAME} frame {i} V vs ffmpeg ({bit_depth}-bit, seed {seed})" | ||
| 20963 | + ); | ||
| 20964 | + } | ||
| 20965 | + horz_proved += horz; | ||
| 20966 | + vert_proved += vert; | ||
| 20967 | + chroma_proved += chroma; | ||
| 20968 | + coeff_proved += coeff; | ||
| 20969 | + split_proved += split; | ||
| 20970 | + matched += 1; | ||
| 20971 | + } | ||
| 20972 | + assert!( | ||
| 20973 | + matched > 0, | ||
| 20974 | + "{NAME}: every {bit_depth}-bit attempt refused or fell out of scope ({named_refusals} \ | ||
| 20975 | + refusals, {out_of_scope} out of scope); the gate proved nothing" | ||
| 20976 | + ); | ||
| 20977 | + assert_eq!( | ||
| 20978 | + out_of_scope_mismatch, 0, | ||
| 20979 | + "{NAME}: {out_of_scope_mismatch} {bit_depth}-bit attempt(s) mismatch with no \ | ||
| 20980 | + 16-level 1:4 strip at all" | ||
| 20981 | + ); | ||
| 20982 | + assert!( | ||
| 20983 | + horz_proved > 0 && vert_proved > 0, | ||
| 20984 | + "{NAME}: {bit_depth}-bit compared attempts decoded {horz_proved} 16x4 and \ | ||
| 20985 | + {vert_proved} 4x16 strips -- both orientations must fire or a transposed table \ | ||
| 20986 | + passes" | ||
| 20987 | + ); | ||
| 20988 | + assert!( | ||
| 20989 | + chroma_proved > 0, | ||
| 20990 | + "{NAME}: {bit_depth}-bit compared attempts closed {chroma_proved} chroma pairs" | ||
| 20991 | + ); | ||
| 20992 | + assert!( | ||
| 20993 | + coeff_proved > 0, | ||
| 20994 | + "{NAME}: {bit_depth}-bit compared attempts coded no residual on any strip" | ||
| 20995 | + ); | ||
| 20996 | + assert!( | ||
| 20997 | + split_proved > 0, | ||
| 20998 | + "{NAME}: {bit_depth}-bit compared attempts never split a strip's transform -- \ | ||
| 20999 | + the `--enable-tx-size-search=1` half of the window proved nothing" | ||
| 21000 | + ); | ||
| 21001 | + eprintln!( | ||
| 21002 | + "{NAME}: {bit_depth}-bit {matched} compared attempts, {horz_proved} 16x4 / \ | ||
| 21003 | + {vert_proved} 4x16 strips, {chroma_proved} chroma pairs, {coeff_proved} coded \ | ||
| 21004 | + units, {split_proved} split-transform strips, {named_refusals} refusals, \ | ||
| 21005 | + {out_of_scope} out of scope" | ||
| 21006 | + ); | ||
| 21007 | + } | ||
| 21008 | + } | ||
| 21009 | + | ||
| 20317 | #[test] | 21010 | #[test] |
| 20318 | // lane-tx64x16 r4: the fixture r3 could not find. `gradients` never wins | 21011 | // lane-tx64x16 r4: the fixture r3 could not find. `gradients` never wins |
| 20319 | // a 32-level 1:4 shape; 8-pixel BANDS do -- each 32x8 strip is flat, so | 21012 | // a 32-level 1:4 shape; 8-pixel BANDS do -- each 32x8 strip is flat, so |
| @@ -21526,6 +22219,7 @@ mod tests { | |||
| 21526 | "--enable-restoration=0", | 22219 | "--enable-restoration=0", |
| 21527 | "--enable-palette=0", | 22220 | "--enable-palette=0", |
| 21528 | "--deltaq-mode=0", | 22221 | "--deltaq-mode=0", |
| 22222 | + "--enable-cdef=0", | ||
| 21529 | "--enable-filter-intra=0", | 22223 | "--enable-filter-intra=0", |
| 21530 | "--enable-cfl-intra=0", | 22224 | "--enable-cfl-intra=0", |
| 21531 | "--enable-intrabc=0", | 22225 | "--enable-intrabc=0", |
lanes/r14-r1.report.mdadded+119 -0
| @@ -0,0 +1,119 @@ | |||
| 1 | +# lane-r14 r1 -- the 16x16-level 1:4 partition (four 16x4 / 4x16 strips) | ||
| 2 | + | ||
| 3 | +Branch `lane-r14` off main `0df090a`; commits `9bde843` (partition + paired | ||
| 4 | +chroma) and `ccd58a2` (split transform). | ||
| 5 | + | ||
| 6 | +## Film first | ||
| 7 | + | ||
| 8 | +`ffmpeg -ss 300 -t 0.4 -i <the 4K 10-bit AV1 mkv> -c:v copy -f obu kf300.obu`, | ||
| 9 | +then `decode_probe`: | ||
| 10 | + | ||
| 11 | +* BEFORE: `REFUSED: a 1:4 partition below 16x16 (PARTITION_HORZ_4/VERT_4, four | ||
| 12 | + 16x4/4x16 strips ...)`. | ||
| 13 | +* AFTER 9bde843: `REFUSED: a 16x4/4x16 strip whose transform is split` -- every | ||
| 14 | + 16-level 1:4 strip in that key frame reads `tx_depth != 0`, so the partition | ||
| 15 | + alone was not enough. | ||
| 16 | +* AFTER ccd58a2: `REFUSED: a non-skip rectangular (HORZ/VERT/HORZ_B) strip needs | ||
| 17 | + rectangular residual coding` -- ANOTHER lane's wall; the 1:4 one is gone, with | ||
| 18 | + rect4_32 counters horz=104 vert=172 coded=238 (these are the 32-level 1:4 counters decode_probe prints, NOT rect4_16; the true rect4_16 numbers on kf300 are 96, 148, 122, 311, 63) strips decoded at the 32 level alone before it stops. | ||
| 19 | + | ||
| 20 | +EVIDENCE: /tmp/claude-1000/-home-user-Documents-Code-Rust-edith-codecs/b6d8a07f-96a4-4bbb-b378-af9ae25cf7c9/scratchpad/r14/kf300.obu | decode_probe before/after each commit | refusal string moved 1:4-partition -> 1:4-split-transform -> rect-residual (another lane) | ||
| 21 | + | ||
| 22 | +## What changed | ||
| 23 | + | ||
| 24 | +* `crates/ec-av1/src/decode.rs` -- `decode_rect4_16` (new): the four strips of a | ||
| 25 | + 16-level `PARTITION_HORZ_4`/`VERT_4`, wired at the key-frame 16-level | ||
| 26 | + partition site (the old refusal is now | ||
| 27 | + "a 16x16-level partition value outside PARTITION_NONE..PARTITION_VERT_4", | ||
| 28 | + the SB-level wording one size down). | ||
| 29 | + - CHROMA is what is new at this size: `is_chroma_reference` is false for a | ||
| 30 | + 4:2:0 block one mi tall (wide) on an EVEN mi row (column), so strips 0 and 2 | ||
| 31 | + read no `uv_mode`/`cfl_alpha`/`angle_delta_uv` and code no chroma; strips 1 | ||
| 32 | + and 3 close the pair and carry the 8x4 (4x8) chroma of the whole 16x8 (8x16) | ||
| 33 | + luma pair at the PAIR's origin (`setup_pred_plane`'s `mi_row -= 1`), CfL | ||
| 34 | + averaging the pair's luma. | ||
| 35 | + - `read_intra_mode_rect` grew a `has_chroma` (`is_chroma_reference`) parameter; | ||
| 36 | + the four existing call sites pass `true`. | ||
| 37 | + - Split transform: `decode_rect_split`'s per-unit walk inlined (its chroma is | ||
| 38 | + the block's, ours is the pair's). depth 1 = TX_8X4/TX_4X8 rect units | ||
| 39 | + (`TxbSet::LumaRect4x8`), depth 2 = square TX_4X4 via `read_plane`. | ||
| 40 | + - `filter_intra_size_class_rect`: classes 12/13 for 16x4/4x16. | ||
| 41 | + - `palette_bsize_ctx_wh`: DEFECT SWEPT -- `av1_allow_palette`'s | ||
| 42 | + `sb_type >= BLOCK_8X8` is an ENUM INDEX test that BLOCK_4X16 (16) and | ||
| 43 | + BLOCK_16X4 (17) clear, so a 64-pixel 1:4 strip DOES read `palette_y_mode` | ||
| 44 | + (ctx 0) in a screen-content frame; the old "both sides >= 8" bound dropped | ||
| 45 | + that symbol. Now `bw <= 64 && bh <= 64 && bw * bh >= 64`, which reproduces | ||
| 46 | + the enum-index rule for every shape. | ||
| 47 | +* `crates/ec-av1/src/cdf.rs` -- `FILTER_INTRA` rows 12/13 (10368/12770), the | ||
| 48 | + values `filter_intra_classes_carry_their_own_libaom_default_row` already | ||
| 49 | + pinned for BLOCK_16X4/BLOCK_4X16; that test now lists both as owning a class. | ||
| 50 | +* `crates/ec-av1/src/cdf_state.rs` -- `TxbSet::LumaRect16x4{,Set1}`: `Luma8`'s | ||
| 51 | + coefficient tables (`get_txsize_entropy_ctx(TX_16X4)` = the 8x8 class, 64 | ||
| 52 | + positions) with the `TX_4X4` `tx_type` row. | ||
| 53 | +* `crates/ec-av1/src/refusal_inventory.rs` -- the 1:4-below-16x16 refusal is | ||
| 54 | + gone; the 16-level partition-value guard replaces it. | ||
| 55 | +* `crates/ec-av1/src/stream.rs` -- the gate. | ||
| 56 | + | ||
| 57 | +## Gate | ||
| 58 | + | ||
| 59 | +`a_real_aomenc_stream_with_a_16_level_1to4_partition_decodes_pixel_exact` | ||
| 60 | +(4-pixel bands, transposed per attempt, explicit-seed noise, 192x128, | ||
| 61 | +`--enable-1to4-partitions=1 --enable-rect-partitions=1 --enable-ab-partitions=0 | ||
| 62 | +--min-partition-size=4 --max-partition-size=16 --enable-filter-intra=1 | ||
| 63 | +--cpu-used=0`, second half of the window `--enable-tx-size-search=1`), 8 seeds x | ||
| 64 | +2 tx-search arms x 2 bit depths. | ||
| 65 | + | ||
| 66 | +``` | ||
| 67 | +systemd-run --user --scope -q -p MemoryMax=8G env CARGO_TARGET_DIR=$HOME/.cache/cargo-target-r14 \ | ||
| 68 | + EC_NOMEMGUARD=1 EC_AV1_REQUIRE_AOMENC=1 nice -n 10 cargo test -p ec-av1 --lib -j3 \ | ||
| 69 | + a_real_aomenc_stream_with_a_16_level_1to4 -- --nocapture | ||
| 70 | +``` | ||
| 71 | + | ||
| 72 | +Result (both green): | ||
| 73 | + | ||
| 74 | +* 8-bit: 15 compared attempts, 192 16x4 / 288 4x16 strips, 240 chroma pairs, | ||
| 75 | + 486 coded units, 102 split-transform strips, 0 refusals, 1 out of scope. | ||
| 76 | +* 10-bit: 16 compared attempts, 148 16x4 / 280 4x16 strips, 214 chroma pairs, | ||
| 77 | + 433 coded units, 82 split-transform strips, 0 refusals, 0 out of scope. | ||
| 78 | + | ||
| 79 | +Every decoded frame is pixel-compared against ffmpeg (`assert_eq` on all three | ||
| 80 | +planes); a decode error is asserted to be a NAMED refusal, never a SKIP. | ||
| 81 | + | ||
| 82 | +EVIDENCE: cargo test output above | 31 real aomenc streams encoded, decoded and compared | 340 16x4 + 568 4x16 strips, 454 chroma pairs, 184 split-transform strips, 0 mismatches | ||
| 83 | + | ||
| 84 | +Encoder-side proof the shape is really in the stream (independent of our | ||
| 85 | +counters): instrumented `aomdec EC_TRACE=1` on the same recipe prints | ||
| 86 | +`EC_PART bsize=6 value=8` (HORZ_4 at BLOCK_16X16) 6x and `value=9` (VERT_4) | ||
| 87 | +10x on the two axes of the fixture. | ||
| 88 | + | ||
| 89 | +## Refusals | ||
| 90 | + | ||
| 91 | +* LIFTED: "a 1:4 partition below 16x16 (PARTITION_HORZ_4/VERT_4, four 16x4/4x16 | ||
| 92 | + strips ...)". | ||
| 93 | +* STILL REFUSED at this shape: "a 1:4 rect strip that actually uses a palette" | ||
| 94 | + (shared with the 32-level pair; reconstruction unported). | ||
| 95 | +* NEW (replacing the lifted one, same site): "a 16x16-level partition value | ||
| 96 | + outside PARTITION_NONE..PARTITION_VERT_4". | ||
| 97 | + | ||
| 98 | +## Residue | ||
| 99 | + | ||
| 100 | +* deferred: the INTER twin of this partition (the inter 16-level site still | ||
| 101 | + refuses 1:4 by its own name) -- unblocked by an inter fixture that reaches a | ||
| 102 | + 16-level 1:4, out of this lane's intra scope. | ||
| 103 | +* deferred: CfL over the pair is written but no gate proves it fired -- | ||
| 104 | + `--enable-cfl-intra` stays `=0` on this recipe because there is no CfL hit | ||
| 105 | + counter, and enabling the flag alone would falsely retire the tool from | ||
| 106 | + `gate_coverage::NEVER_EXERCISED_*`. Unblocked by a CfL counter + a fixture | ||
| 107 | + whose chroma actually correlates with luma. | ||
| 108 | +* accepted: no `--tile-columns` arm in this gate -- the lane added no per-mi | ||
| 109 | + neighbour map, it reuses the existing tile-edge-guarded ones. | ||
| 110 | + | ||
| 111 | +## Suite | ||
| 112 | + | ||
| 113 | +`systemd-run --user --unit=r14-suite3 -p MemoryMax=10G --same-dir bash -lc | ||
| 114 | +'EC_NOMEMGUARD=1 EC_AV1_REQUIRE_AOMENC=1 CARGO_TARGET_DIR=$HOME/.cache/cargo-target-r14 | ||
| 115 | +nice -n 10 cargo test -p ec-av1 --lib -j3'` -> `test result: ok. 356 passed; 0 | ||
| 116 | +failed; 29 ignored` (346 s), log `$HOME/.cache/r14-suite-clean.log`. Siblings | ||
| 117 | +re-run inside it: the 32-level and superblock-level 1:4 gates, every rect-strip | ||
| 118 | +and split-transform gate, `filter_intra_classes_carry_their_own_libaom_default_row`, | ||
| 119 | +`refusal_inventory`, `gate_coverage`, `every_rect_shape`, `base_ctx_rect_offsets`. | ||
lanes/r14-r2.report.mdadded+97 -0
| @@ -0,0 +1,97 @@ | |||
| 1 | +# lane-r14 round 2 — 64-axis rectangular INTER residual coding | ||
| 2 | + | ||
| 3 | +## Per-segment table (ReelB 2160p HDR10, `-c:v copy -an -f obu`, 2 s each) | ||
| 4 | + | ||
| 5 | +| segment | refusal BEFORE this round (at merged main) | refusal AFTER this round | counters | | ||
| 6 | +|---|---|---|---| | ||
| 7 | +| `-ss 300 -t 2` (`seg300.obu`, 206 frame headers) | an intra-coded HORZ/VERT strip needs rectangular intra prediction this decoder does not code yet | *unchanged* (same string, same site `decode.rs:17325`) | rect_inter tu=28 txsplit=18 | | ||
| 8 | +| `-ss 3000 -t 2` (`seg3000.obu`, 288 frame headers) | a non-skip rectangular (HORZ/VERT/HORZ_B) strip needs rectangular residual coding — shape **32x64** at mi(0,32) | a split transform on a 1:4 inter strip with a 64-px axis | 22 SB-level 32x64 strips decoded, tu=21, txsplit=4 | | ||
| 9 | +| `-ss 4500 -t 2` (`seg4500.obu`, 213 frame headers) | a non-skip rectangular (HORZ/VERT/HORZ_B) strip needs rectangular residual coding — shape **16x64** at mi(0,0) | a split transform on a 1:4 inter strip with a 64-px axis | txsplit=1 | | ||
| 10 | + | ||
| 11 | +`kf300.obu` (the r1 blocker): the `git merge main` of this round already advanced it past | ||
| 12 | +"a non-skip rectangular ... needs rectangular residual coding" to the intra-rect-strip refusal — | ||
| 13 | +lane-inter4's merge lifted it, the charter's premise was stale. It is **not** one key frame: | ||
| 14 | +`decode_probe` parses 206 frame headers in it. (`ffmpeg -i kf300.obu -bsf:v trace_headers` | ||
| 15 | +prints nothing at all for a bare `.obu` — no container, so the bitstream filter is never | ||
| 16 | +attached; the header count from our own parser is the measurement used instead.) | ||
| 17 | + | ||
| 18 | +## What changed | ||
| 19 | + | ||
| 20 | +- `crates/ec-av1/src/decode.rs:10891 rect_inter_residual_supported` — accepts `(64,32) (32,64) (64,16) (16,64)`. | ||
| 21 | +- `crates/ec-av1/src/decode.rs:10903 rect_inter_luma_set` — `TxbSet::Luma64` for 64x32/32x64, | ||
| 22 | + `TxbSet::LumaRect32x16` for 64x16/16x64 (`av1_get_adjusted_tx_size`; both sets carry | ||
| 23 | + `tx_type: None`, correct because `tx_size_sqr_up == TX_64X64` makes the ext-tx set DCT_ONLY, | ||
| 24 | + so no `tx_type` symbol is coded and the intra/inter table split is moot). | ||
| 25 | +- `crates/ec-av1/src/decode.rs:10921 rect_inter_chroma_set` — 32x16/16x32 → `ChromaRect32x16`, | ||
| 26 | + 32x8/8x32 → `Chroma16` (same sets the INTRA superblock-strip path already uses). | ||
| 27 | +- `crates/ec-av1/src/decode.rs rect_scan` — `SCAN_32X8` / `SCAN_8X32` arms. | ||
| 28 | +- `crates/ec-av1/src/decode.rs read_inter_plane_rect` — the load-bearing change: a 64-length axis | ||
| 29 | + codes only its low 32 coefficients, so the unit read is the `min(w,32) x min(h,32)` corner, | ||
| 30 | + zero-extended into the true `w x h` grid before `dequant_and_inverse_typed_wh`. A square 32x32 | ||
| 31 | + corner goes through the SQUARE reader with `rect_shape = Some((w, h))`, because | ||
| 32 | + `av1_nz_map_ctx_offset` is indexed by the real un-adjusted shape (class from lane-sbpart r8). | ||
| 33 | +- `crates/ec-av1/src/decode.rs read_block_tx_size_rect` — NEW named refusal | ||
| 34 | + `"a split transform on a 1:4 inter strip with a 64-px axis"`: `sub_tx_size_map` is square for | ||
| 35 | + every shape this decoder splits (TX_32X16→TX_16X16, TX_64X32→TX_32X32) except TX_64X16→TX_32X16 | ||
| 36 | + and TX_16X64→TX_16X32, where the existing square recursion would code the wrong tree. | ||
| 37 | +- `crates/ec-av1/src/decode.rs` + `stream.rs:60` — `rect64_inter_tu_hits()` counter (luma 64-axis TUs). | ||
| 38 | +- `crates/ec-av1/src/refusal_inventory.rs` — the new refusal registered. | ||
| 39 | +- `crates/ec-av1/src/stream.rs` gate | ||
| 40 | + `a_real_aomenc_inter_sequence_with_a_superblock_level_rect_partition_decodes_pixel_exact` | ||
| 41 | + now hard-asserts `rect64_tus > 0` (the residual half of the arm; before, the gate proved only | ||
| 42 | + the partition symbol because every strip it accepted was `skip`). | ||
| 43 | + | ||
| 44 | +Merge commit `399278b` resolved the single conflict (`cdf_state.rs` TxbSet match) by keeping BOTH | ||
| 45 | +sides' arms (lane's 16x4 intra 1:4, main's 16x8 inter rect). | ||
| 46 | + | ||
| 47 | +## Gates | ||
| 48 | + | ||
| 49 | +`EC_AV1_REQUIRE_AOMENC=1 cargo test -p ec-av1 --lib -- --test-threads=1 superblock_level_rect_partition` | ||
| 50 | + | ||
| 51 | +EVIDENCE: gate stderr | real aomenc 192x128x6, `--enable-rect-partitions=1 --min-partition-size=32 --max-partition-size=64 --sb-size=64`, 16 attempts, every decoded frame compared Y+U+V vs ffmpeg | 8-bit: 2 named refusals, 4 pixel-exact attempts carrying the arm, 64x32 strips=4, 32x64 strips=4, **64-axis residual TUs=2**, 10 out of scope (0 mismatched) — test result: ok | ||
| 52 | + | ||
| 53 | +EVIDENCE: same gate run with `for bit_depth in [8u32, 10u32]` | identical recipe at `--bit-depth=10` | 10-bit: 2 pixel-exact attempts carrying the arm, 64x32=2, 32x64=2, **64-axis residual TUs=2** — the capability is pixel-exact at 10 bits too | ||
| 54 | + | ||
| 55 | +EVIDENCE: `cargo run --example decode_probe -- seg3000.obu` before/after, `EC_AV1_RECT_DUMP=1` | 2 s of the real film at 50:00 | `EC_RECT_REFUSE ... w=32 h=64` → no `EC_RECT_REFUSE` line at all; 22 SB-level 32x64 strips now decode | ||
| 56 | + | ||
| 57 | +Merge-verification gates (on `399278b`): `16_level_1to4 superblock_level_ 32x32_level_1to4 | ||
| 58 | +inter_sequence refusal_inventory gate_coverage` → 38 passed, 0 failed, 4 ignored. | ||
| 59 | + | ||
| 60 | +Full suite: `$HOME/.cache/r14-suite-r2.log`, run on the tip after the second `git merge main` | ||
| 61 | +(main `b51719f`) — totals appended below. | ||
| 62 | + | ||
| 63 | +## Verifier notes folded in (round 2) | ||
| 64 | + | ||
| 65 | +1. `lanes/r14-r1.report.md:18` corrected: the "104 / 172" pair is `decode_probe`'s **rect4_32** | ||
| 66 | + counter line, not rect4_16; the true rect4_16 numbers on `kf300.obu` are 96, 148, 122, 311, 63. | ||
| 67 | +2. `"a 16x16-level partition value outside PARTITION_NONE..PARTITION_VERT_4"` was unreachable | ||
| 68 | + (all 10 symbols of that CDF are handled above the check) — removed from `decode.rs` (now a | ||
| 69 | + `debug_assert_eq!(part16, PARTITION_SPLIT)`) and from `refusal_inventory.rs`. | ||
| 70 | +3. The rectangular-residual wall lives in `decode_inter_block`, reached only from | ||
| 71 | + `decode_inter_frame_tile`, so it fires on an **inter** frame: the key frame of `kf300.obu` | ||
| 72 | + decodes through. **Not measured this round**: the decode-order index of the stopping frame and | ||
| 73 | + a 16-bit byte-equality compare of every frame before it. `decode_probe` reports only the | ||
| 74 | + refusal, and adding the per-frame `cmp` ladder did not fit this round's budget — | ||
| 75 | + deferred(a `decode_probe` mode that dumps every decoded frame before the refusal and diffs it | ||
| 76 | + against `ffmpeg -pix_fmt yuv420p10le`). | ||
| 77 | + | ||
| 78 | +## Residue | ||
| 79 | + | ||
| 80 | +- **deferred**(needs a rect-aware var-tx recursion + rect leaf reconstruction, ~2 call sites): | ||
| 81 | + `a split transform on a 1:4 inter strip with a 64-px axis`. This is the film's next blocker in | ||
| 82 | + BOTH mid-film segments. `sub_tx_size_map[TX_64X16] = TX_32X16` is rectangular, so the leaf | ||
| 83 | + tuple `(row, col, tx_px)` and the two square leaf loops (`decode.rs` ~16174 and ~17150) have to | ||
| 84 | + carry `(row, col, tw, th)`. Out of this round's ≤150-line scope. | ||
| 85 | +- **deferred**(unrelated shape, needs its own bisect): enabling the 10-bit arm of the SB rect gate | ||
| 86 | + exposes a pre-existing mismatch at attempt 14 (cq 61, horizontal split, motion step 12) that | ||
| 87 | + decodes **zero** rect strips and zero 64-axis residual units — provably not this round's code | ||
| 88 | + path. The gate stays `[8u32]` with that measured reason written at the loop instead of the | ||
| 89 | + stale "non-skip residual is refused" one. | ||
| 90 | +- **accepted**: `seg300` still stops at the intra-rect-strip refusal (lane-intrarect's wall, | ||
| 91 | + named and inventoried). | ||
| 92 | + | ||
| 93 | +## Suite | ||
| 94 | + | ||
| 95 | +`systemd-run --user --unit=r14-suite-r2 ... cargo test -p ec-av1 --lib -j3` on tip `c604580` | ||
| 96 | +(after `git merge main` @ `b51719f`) -> **365 passed; 0 failed; 31 ignored**, 623.58s, | ||
| 97 | +log `$HOME/.cache/r14-suite-r2.log`. | ||
lanes/sb128-r1.report.mdadded+88 -0
| @@ -0,0 +1,88 @@ | |||
| 1 | +# lane-sb128 r1 — 128x128 superblocks, key frames | ||
| 2 | + | ||
| 3 | +Branch `lane-sb128` off main `a59645c`, worktree `edith_codecs-sb128`. | ||
| 4 | + | ||
| 5 | +## Film first (the ReelC blocker) | ||
| 6 | + | ||
| 7 | +`reelc5.obu` (1.1 MB, 1920x792 yuv420p10le, `use_128x128_superblock=1`) now decodes the 128 | ||
| 8 | +superblock root and stops at a NAMED, unrelated refusal instead of desyncing: | ||
| 9 | + | ||
| 10 | +EVIDENCE: /tmp/claude-1000/.../cdc46329-.../scratchpad/reelc5.obu | `decode_probe reelc5.obu` | ||
| 11 | +after this round | `REFUSED: unsupported: AV1 tile (a HORZ/VERT intra strip below 16x16 with a | ||
| 12 | +split transform (per-unit rect prediction is not ported))` — a sub-16 intra-strip gap owned by | ||
| 13 | +another lane, reached deep inside the tile (78 frame headers parsed, single tile). | ||
| 14 | + | ||
| 15 | +Not measured: the exact pre-change refusal string on this same file (no baseline binary was | ||
| 16 | +built before the patch landed). deferred: film pixel compare — the stream still refuses, so | ||
| 17 | +there is no frame to `cmp` — unblocked by the sub-16 split-transform strip lane. | ||
| 18 | + | ||
| 19 | +## What changed | ||
| 20 | + | ||
| 21 | +- `crates/ec-av1/src/decode.rs` | ||
| 22 | + - `SB128` thread-local + `set_sb128` (also sets `Reach`'s superblock size), `sb_mi_cur()`. | ||
| 23 | + - `sb_visit_order()`: at sb128 the tile walks each 128x128 superblock's four 64x64 | ||
| 24 | + quadrants (TL, TR, BL, BR) before the next superblock — libaom `decode_partition`'s | ||
| 25 | + recursion order, not raster over 64x64 superblocks. | ||
| 26 | + - key-frame tile loop: per 128 superblock, one `read_lr` over the whole 128x128 and one | ||
| 27 | + `partition_w128` symbol (8-symbol alphabet, no HORZ_4/VERT_4 at BLOCK_128X128; forced-split | ||
| 28 | + gather `gather_of` + `VERT_ALIKE128`/`HORZ_ALIKE128` at the frame edge). SPLIT recurses | ||
| 29 | + into the existing 64 path; the other seven arms refuse by name. | ||
| 30 | + - `maybe_read_delta_q` / `maybe_read_delta_lf` key off `sb_mi_cur()` (once per 128x128, not | ||
| 31 | + four times), and `is_whole_sb` is ignored at sb128 (no leaf can be a whole 128 superblock). | ||
| 32 | + - `NO_NEIGHBOUR_SIDE = 128` replaces `SB` as the partition-context sentinel — ROOT CAUSE 1. | ||
| 33 | + - intrabc under sb128 refuses by name (`av1_is_dv_valid`'s delay is sb_size-derived). | ||
| 34 | +- `crates/ec-av1/src/encode.rs`: `Reach`'s `has_top_right`/`has_bottom_left` masked the block | ||
| 35 | + position with a hardcoded 64 superblock; now `reach_sb_px()` (64 or 128) — ROOT CAUSE 2. | ||
| 36 | + The tables themselves were already 128-relative (`table_stride`), only the masks were wrong. | ||
| 37 | +- `crates/ec-av1/src/cdf.rs` / `cdf_state.rs`: `PARTITION_W128` (entropymode.c:154's four | ||
| 38 | + `AOM_CDF8` rows), stored, reset per frame like `partition_w64`. | ||
| 39 | +- `crates/ec-av1/src/stream.rs`: `set_sb128` per frame, scoped inter refusal, two gates. | ||
| 40 | +- `crates/ec-av1/src/refusal_inventory.rs`: the three new refusals listed. | ||
| 41 | + | ||
| 42 | +Two defects found and fixed, both invisible at 64: | ||
| 43 | +1. the no-neighbour partition-context sentinel (64) set the ctx bit at the 128 root — our ctx | ||
| 44 | + was 3 where aomdec printed `ctx=16` (= `bsl*4 + 0`, row 0). Identical at every level <= 64, | ||
| 45 | + so no existing gate could see it. | ||
| 46 | +2. `has_top_right`/`has_bottom_left` answered against a 64 superblock — a bounded 1391-luma-pixel | ||
| 47 | + band (x 124..255, y 44..67) with the entropy stream still in sync. | ||
| 48 | + | ||
| 49 | +## Gates | ||
| 50 | + | ||
| 51 | +`a_real_aomenc_stream_with_128x128_superblocks_decodes_pixel_exact` — real | ||
| 52 | +`aomenc --sb-size=128 --max-partition-size=64`, 6 arms (256x192 seeds 42/43/44 8-bit, | ||
| 53 | +384x384 8-bit, 256x192 10-bit, 384x384 10-bit), sequence header asserted | ||
| 54 | +`use_128x128_superblock == true` at the arm's bit depth, every frame Y/U/V vs ffmpeg, hard | ||
| 55 | +asserts on `part128_symbols`/`part128_split_hits`. No SKIP except a missing tool. | ||
| 56 | + | ||
| 57 | +EVIDENCE: `cargo test -p ec-av1 --lib 128x128 -- --nocapture` | 6 aomenc encodes decoded and | ||
| 58 | +compared plane-by-plane | `6 pixel-exact, 0 named refusals, part128_symbols=26 | ||
| 59 | +part128_split_hits=34`; `a_real_aomenc_128x128_inter_stream_refuses_by_name ... ok`. | ||
| 60 | + | ||
| 61 | +EVIDENCE: scratchpad/sb128/{ref128.yuv,our128.yuv} | seed 44 encoded at `--sb-size=128` and | ||
| 62 | +`--sb-size=64`, both decoded through `decode_probe` and `cmp`ed against | ||
| 63 | +`ffmpeg -f rawvideo -pix_fmt yuv420p` | before the two fixes: sb64 EXACT / sb128 DIFF at byte 1 | ||
| 64 | +(ctx defect) then at byte 11518 (reach defect); after: `seed44 sb128 EXACT`. | ||
| 65 | + | ||
| 66 | +## Refused by name (still), each with its string | ||
| 67 | + | ||
| 68 | +- `a 128x128 superblock partition other than SPLIT (NONE/HORZ/VERT and the four AB arms at the | ||
| 69 | + 128 root are not decoded)` — the six 128-level non-SPLIT arms + a 128x128 leaf. The gate pins | ||
| 70 | + `--max-partition-size=64` so the encoder never chooses them. deferred: 128-level NONE/HORZ/VERT | ||
| 71 | + (a 128x128 block is 2x2 TX_64X64 luma + 2x2 TX_32X32 chroma; `decode_block` codes ONE luma TU | ||
| 72 | + per block outside the `tx_select` multi-TU branch and one chroma TU always) — unblocked by a | ||
| 73 | + multi-TU chroma path in `decode_block`. | ||
| 74 | +- `an inter frame under a 128x128 superblock (this decoder's inter tile path recurses a 64x64 | ||
| 75 | + superblock root only)` — scoped to frames > 64x64 (a <=64x64 frame's 128 root reads no symbol). | ||
| 76 | + deferred: inter at 128 — the second `for sb_r/sb_c` loop in `decode.rs` (~line 17800) plus OBMC | ||
| 77 | + and mvstack neighbour caps — unblocked by porting `sb_visit_order` + the 128 prologue there. | ||
| 78 | +- `intrabc under a 128x128 superblock (...)` — accepted for this round. | ||
| 79 | + | ||
| 80 | +## Suite | ||
| 81 | + | ||
| 82 | +`cargo test -p ec-av1 --lib` (systemd unit, log `$HOME/.cache/sb128-suite.log`): see the tail | ||
| 83 | +appended below by the run. | ||
| 84 | + | ||
| 85 | +``` | ||
| 86 | +test result: ok. 350 passed; 0 failed; 31 ignored; 0 measured; 0 filtered out; finished in 313.69s | ||
| 87 | +``` | ||
| 88 | +(31 ignored = the pre-existing ignore list, unchanged by this lane.) | ||
lanes/sb128-r2.report.mdadded+123 -0
| @@ -0,0 +1,123 @@ | |||
| 1 | +# lane-sb128 r2 — the 128 root on INTER frames | ||
| 2 | + | ||
| 3 | +Branch `lane-sb128` (merged `main` 0df090a first, clean), worktree `edith_codecs-sb128`, | ||
| 4 | +commit `8b4a36f`. | ||
| 5 | + | ||
| 6 | +## Film first | ||
| 7 | + | ||
| 8 | +Both probes ran with the inter refusal LIFTED locally (the code as committed refuses again — | ||
| 9 | +see Residual), i.e. these are what the new inter-128 path reaches: | ||
| 10 | + | ||
| 11 | +EVIDENCE: `/tmp/.../b6d8a07f.../scratchpad/reelc-head.obu` | release `decode_probe` (6G scope) | ||
| 12 | +| `REFUSED: unsupported: AV1 tile (a 128x128 superblock partition other than SPLIT | ||
| 13 | +(NONE/HORZ/VERT and the four AB arms at the 128 root are not decoded))` after 17 frame headers | ||
| 14 | +— i.e. ReelC's own head reaches a TASK-B arm, not the inter gap. | ||
| 15 | + | ||
| 16 | +EVIDENCE: `/tmp/.../cdc46329.../scratchpad/reelc5.obu` | release `decode_probe` (6G scope) | | ||
| 17 | +`REFUSED: unsupported: AV1 tile (a 1:4 partition below 16x16 (PARTITION_HORZ_4/VERT_4, four | ||
| 18 | +16x4/4x16 strips ...))` after 78 frame headers, `rect4_32: horz=8 vert=28 coded=32` — r1's stop | ||
| 19 | +on this file ("a HORZ/VERT intra strip below 16x16 with a split transform") was lifted by the | ||
| 20 | +merge from main; the film now stops on a sub-16 1:4 partition, another lane's cluster. | ||
| 21 | + | ||
| 22 | +With the committed tree the product path stops earlier, at the restored inter refusal. | ||
| 23 | + | ||
| 24 | +## What changed | ||
| 25 | + | ||
| 26 | +- `crates/ec-av1/src/decode.rs` | ||
| 27 | + - `read_sb128_root()` (~11250): the 128 root extracted out of the key-frame loop — one | ||
| 28 | + `read_lr` over the whole 128x128, one `partition_w128` symbol (8 symbols, `gather_of` + | ||
| 29 | + `VERT_ALIKE128`/`HORZ_ALIKE128` at the frame edge), refusal by name for the seven | ||
| 30 | + non-SPLIT arms. Both tile loops call it, so they cannot drift apart. | ||
| 31 | + - `decode_inter_frame_tile_with_cdfs` (~18380, ~18570): `let sb128 = sb128();` and the | ||
| 32 | + superblock loop replaced by `sb_visit_order(...)` + the 128 prologue. `delta_q`/`delta_lf` | ||
| 33 | + already key off `sb_mi_cur()`; `CDEF_TRANSMITTED` is reset per 64x64 quadrant, which is | ||
| 34 | + exactly libaom `read_cdef`'s per-quadrant `cdef_transmitted[index]`, index | ||
| 35 | + `(mi_col&16)>>4 + 2*((mi_row&16)>>4)`. | ||
| 36 | + - warp-sample `has_top_right` (13470) hardcoded `SB_MI` (a 64x64 superblock); now delegates | ||
| 37 | + to the single sb-aware port. | ||
| 38 | +- `crates/ec-av1/src/mvstack.rs`: `has_top_right()` ported from libaom `mvref_common.c:264` | ||
| 39 | + (`sb_mi_size = mi_size_wide[seq.sb_size]`, so the mask loop runs one level further at 128); | ||
| 40 | + both `scan_top_right` and `scan_top_right_compound` are now gated on it instead of a bare | ||
| 41 | + "is the grid cell populated" probe. corner-cut in the doc: the three rect/`VERT_A` shape | ||
| 42 | + refinements are not ported (ceiling = rect/AB INTER leaves, refused by name today). | ||
| 43 | +- `crates/ec-av1/src/stream.rs`: the r1 refusal test replaced by the r2 gate (below), plus the | ||
| 44 | + `sb128_r2_control_sb64` control; the inter refusal restored with the residual named. | ||
| 45 | + | ||
| 46 | +MEASURED, against the charter's premise: libaom `check_sb_border` (mvref_common.c:318) uses | ||
| 47 | +`mi_size_wide[BLOCK_64X64]`, **hardcoded**, NOT `seq_params.sb_size` — the charter said to port | ||
| 48 | +it as sb-derived. `mvstack.rs`'s `sb_mask = 16` is therefore already correct at 128 and was | ||
| 49 | +left alone. `has_top_right` (line 266) is the one that is sb-derived. | ||
| 50 | + | ||
| 51 | +## Gate | ||
| 52 | + | ||
| 53 | +`a_real_aomenc_inter_sequence_with_128x128_superblocks_decodes_pixel_exact` — real aomenc | ||
| 54 | +`--sb-size=128 --max-partition-size=64 --min-partition-size=32 --limit=8`, default | ||
| 55 | +lag/alt-ref (1 hidden frame), gradients+`noise=all_seed=53:alls=12` (a clean gradient codes | ||
| 56 | +with `cdef_bits=0` and the cdef counter stays 0), 8-bit and 10-bit, compared in DECODE order | ||
| 57 | +frame by frame against the instrumented aomdec (`decode_all_frames_vs_oracle`, hidden frames | ||
| 58 | +included), per-attempt counter deltas hard-asserted (`part128_symbols>=3`, `cdef_idx_hits>=1`, | ||
| 59 | +`tmv_hits>=1`). It is `#[ignore]`d: it is a reproducer, not a passing gate. | ||
| 60 | + | ||
| 61 | +EVIDENCE: `cargo test -p ec-av1 --lib -- --nocapture inter_sequence_with_128x128` | | ||
| 62 | +8-frame aomenc encode decoded in decode order vs aomdec | frames 0-5 and 7-8 byte-exact, | ||
| 63 | +`decode-order frame 6 of 9 (8 shown, 1 hidden) differs at byte 24070 (ours 43 vs 42), 996 | ||
| 64 | +bytes differ` — entropy stream in sync (a desync would corrupt the tail, not 996 bytes). | ||
| 65 | + | ||
| 66 | +EVIDENCE: `cargo test -p ec-av1 --lib -- --ignored --nocapture sb128_r2_control_sb64` | the | ||
| 67 | +SAME source/recipe encoded at `--sb-size=64` | `control sb64: 9 frames exact (1 hidden)` — | ||
| 68 | +the residual is sb128-specific, not a pre-existing inter defect the new recipe uncovered. | ||
| 69 | + | ||
| 70 | +Ablations run on the way (each a full gate run): `--enable-cdef=0` still mismatches (380 bytes, | ||
| 71 | +byte 40960) so it is not the cdef read; the `has_top_right` port and the warp-sample fix each | ||
| 72 | +changed nothing on this stream (both are libaom-faithful and stay). | ||
| 73 | + | ||
| 74 | +## Refusals | ||
| 75 | + | ||
| 76 | +- `an inter frame under a 128x128 superblock (...)` — **NOT lifted**, restored in `stream.rs` | ||
| 77 | + with the residual named in the comment; still listed in `refusal_inventory.rs`. | ||
| 78 | + fix-now(next round): identify the frame-6 block (the stream is pinned by the gate's panic | ||
| 79 | + message under `/tmp/ec-av1-sb128-inter-8-<pid>/in.obu`; re-pin it, then range-ladder ours vs | ||
| 80 | + aomdec on frame 6 — the entropy stream matches, so start at the PREDICTION side: OBMC | ||
| 81 | + neighbour walk and mvstack candidates for the quadrant at mi_row 16..31 of an SB row). | ||
| 82 | +- `a 128x128 superblock partition other than SPLIT (...)` — TASK B, deferred: 128-level | ||
| 83 | + NONE/HORZ/VERT/AB — needs a multi-TU chroma loop in `decode_block` (a 128x128 block is | ||
| 84 | + 2x2 TX_64X64 luma + 2x2 TX_32X32 chroma) — unblocked by that loop; ReelC's head stops here. | ||
| 85 | +- `intrabc under a 128x128 superblock (...)` — accepted, unchanged. | ||
| 86 | + | ||
| 87 | +## Suite | ||
| 88 | + | ||
| 89 | +`cargo test -p ec-av1 --lib` under a user systemd unit, log `$HOME/.cache/sb128-suite-r2.log`: | ||
| 90 | +tail appended below. | ||
| 91 | + | ||
| 92 | +``` | ||
| 93 | +test result: FAILED. 348 passed; 8 failed; 31 ignored; finished in 522.44s | ||
| 94 | +``` | ||
| 95 | +- `mvstack::tests::all_same_mv_neighbourhood_dedupes_to_one_entry` — CAUSED BY THIS ROUND and | ||
| 96 | + FIXED: gating `scan_top_right` on the new `has_top_right` red-lined it (the unported rect/ | ||
| 97 | + `VERT_A` refinements). The MV stack keeps its grid probe; only the warp-sample gather uses | ||
| 98 | + the port. Re-run after the fix: `ok`. | ||
| 99 | +- The other 7 (`*_32_level_ab_partition_*`, `*_rect_and_ab_partitions_*`, | ||
| 100 | + `*_superblock_level_1to4_partition_*`, `*_split_transform_horz_vert_strip_*`, | ||
| 101 | + `*_chroma_is_a_4to1_or_sub8_rect_*`, `*_filter_intra_on_a_horz_vert_strip_*`) STILL FAIL after | ||
| 102 | + that fix, and they fail on a FIRING COUNTER, not on pixels: e.g. "16 attempt(s) decoded | ||
| 103 | + pixel-exact but HORZ_A_32 never fired". Every one of them is a rect/AB gate owned by the | ||
| 104 | + lanes main merged today (rectsplitx/rect1d/fiinter/modectx); this lane's only non-sb128 code | ||
| 105 | + change is the warp-sample `has_top_right` delegate, which is bit-identical at `sb_size == 64` | ||
| 106 | + (`sb_mi_cur() == 16`), and all 7 streams are 64-superblock streams whose decode is exact. | ||
| 107 | + NOT PROVEN either way inside this round's budget. | ||
| 108 | + deferred: attribute the 7 — build `main` 0df090a in a detached worktree with its own | ||
| 109 | + CARGO_TARGET_DIR and run the same 7 by name; if red there, they are a merge residue, not | ||
| 110 | + this lane's — unblocked by one clean-tree suite run. | ||
| 111 | + | ||
| 112 | +## Coordinator items from the r1 verifier | ||
| 113 | + | ||
| 114 | +- (1) content-free r1 gate arms (mandelbrot + `--deltaq-mode=2` / `--enable-restoration=1`): | ||
| 115 | + deferred — not started; the r2 gate already carries the noise/cdef fix for its own arms — | ||
| 116 | + unblocked by a round that owns the r1 gate recipe. | ||
| 117 | +- (2) `Reach::table(64)` falling back to the 16x16 rows: deferred — inert today, and TASK B | ||
| 118 | + (the 128-level NONE/HORZ/VERT/AB arms that would hit it) is not started this round. | ||
| 119 | +- (3) lane-oddh's `"a sequence using 128x128 superblocks on a frame larger than 64x64"` | ||
| 120 | + refusal + its gate: NOT PRESENT in `main` 0df090a at merge time (`grep` finds neither the | ||
| 121 | + string nor an asserting gate), so nothing to delete. | ||
| 122 | +- TASK B (128-level NONE/HORZ/VERT/AB roots): deferred, not started — needs the chroma multi-TU | ||
| 123 | + loop in `decode_block` first — unblocked by that loop. | ||
lanes/sb128-r3.handoff.mdadded+94 -0
| @@ -0,0 +1,94 @@ | |||
| 1 | +# lane-sb128 r3 handoff (turn cap) | ||
| 2 | + | ||
| 3 | +Branch `lane-sb128`, worktree `edith_codecs-sb128`. Two commits this round: | ||
| 4 | +`dbf15a4` (TASK 1 fix), `d6cca7d` (TASK 2 fix + refusal lift, WIP: suite not run). | ||
| 5 | + | ||
| 6 | +## TASK 1 -- the 7 rect/AB firing-counter reds: ATTRIBUTED AND FIXED (`dbf15a4`) | ||
| 7 | + | ||
| 8 | +Attribution table (same 7 gate names, run by name, own `CARGO_TARGET_DIR`): | ||
| 9 | + | ||
| 10 | +| tree | result | log | | ||
| 11 | +| --- | --- | --- | | ||
| 12 | +| main `0df090a` (detached worktree) | 7 passed | `$HOME/.cache/sb128-verify7.log` | | ||
| 13 | +| lane r1 `5e5f113` | 7 passed | `$HOME/.cache/sb128-verify-r1.log` | | ||
| 14 | +| lane merge `63890cb` | 7 passed | `$HOME/.cache/sb128-verify-merge.log` | | ||
| 15 | +| lane r2 `807c110` | 7 FAILED | `$HOME/.cache/sb128-lane7.log` | | ||
| 16 | +| lane r3 `dbf15a4` | 7 passed | `$HOME/.cache/sb128-lane7b.log` | | ||
| 17 | + | ||
| 18 | +LANE-CAUSED, and not a merge residue: r2 blanket-rewrote every | ||
| 19 | +`"--min-partition-size=16"` in `stream.rs`'s aomenc recipes to `=32` while writing | ||
| 20 | +its own 128 gate -- 13 lines across 13 gates, 7 of which assert a firing counter. | ||
| 21 | +With min-partition 32 aomenc never emits a 16-level partition, so those streams | ||
| 22 | +still decoded PIXEL-EXACT while `HORZ_A_32` / `rect_partition_hits` / the 1:4 and | ||
| 23 | +strip counters read 0 and the "never fired" guard red-lined them. Fix = revert | ||
| 24 | +exactly those 13 lines (diff-matched old-vs-new, not a sed); no counter bump site | ||
| 25 | +was lost in the merge, that hypothesis is DISPROVED. | ||
| 26 | + | ||
| 27 | +EVIDENCE: `$HOME/.cache/sb128-lane7b.log` | `cargo test -p ec-av1 --lib -- <7 names>` | ||
| 28 | +on `dbf15a4` | `test result: ok. 7 passed; 0 failed`. | ||
| 29 | + | ||
| 30 | +## TASK 2 -- inter frames at 128, frame 6: ROOT-CAUSED AND FIXED (`d6cca7d`) | ||
| 31 | + | ||
| 32 | +Stream re-pinned (sha256 twice, identical): | ||
| 33 | +`.../scratchpad/sb128-inter8.obu` = `3e991db7aa7f6d6f70b91b41417b7741d0468343ee4e19e1adf7db066e3c8981` | ||
| 34 | + | ||
| 35 | +Ladder actually walked: | ||
| 36 | +1. `EC_AV1_PREFILT_DUMP` both sides -> decode-order frame 6 differs PRE-FILTER, | ||
| 37 | + 957 bytes, all inside luma y=96..127 x=0..31, i.e. ONE 32x32 block at mi(24,0). | ||
| 38 | + So it is reconstruction, not deblock/CDEF/LR. | ||
| 39 | +2. `EC_OBMC=1` on aomdec: 0 lines on this stream -- OBMC EXONERATED. | ||
| 40 | +3. Ablation `set_reach_superblock_px(64)` (r1's sb-aware intra `Reach`): frame 6 | ||
| 41 | + still 957 bytes wrong -- Reach EXONERATED. | ||
| 42 | +4. Mode info EQUAL: located the oracle's line by matching `mi_row/mi_col` AND the | ||
| 43 | + pre-mode `rng` (entropy in sync, so ranges match block for block): | ||
| 44 | + both sides `mode=24 (NEW_NEWMV) ref0=3 ref1=5 stack=3`. Ours resolved | ||
| 45 | + `mv0=(847,-105)`, oracle `mv0=(792,-245)`. | ||
| 46 | +5. The MV STACK ORDER differed, from ONE missing weight-2 vote: | ||
| 47 | + oracle `(569,-380) w=6 / (624,-240) w=6 / (802,-381) w=4` | ||
| 48 | + ours `(624,-240) w=6 / (802,-381) w=4 / (569,-380) w=4`. | ||
| 49 | + Spatial scans found NOTHING for this block (mi_col=0, no left; row scan empty), | ||
| 50 | + so every candidate is TEMPORAL. | ||
| 51 | + | ||
| 52 | +ROOT CAUSE: `mvstack.rs::find_mv_stack_compound` never ported libaom's three | ||
| 53 | +`tpl_sample_pos` EXTENSION samples (`mvref_common.c:591`, gated by `allow_extension` | ||
| 54 | ++ `check_sb_border`). The SINGLE-ref twin `find_mv_stack` has them (mvstack.rs ~900); | ||
| 55 | +the compound twin stopped after the main `blk_row/blk_col` loop. Class: | ||
| 56 | +`neighbour-votes-all-its-fields` / asymmetric port -- a compound twin missing a | ||
| 57 | +whole scan phase of its single-ref sibling. NOT sb128-specific: `check_sb_border` | ||
| 58 | +masks with libaom's hardcoded `mi_size_wide[BLOCK_64X64]` (16), never `seq.sb_size`. | ||
| 59 | +sb128 only made aomenc pick the compound NEW_NEWMV block that exposed it. | ||
| 60 | + | ||
| 61 | +Fix (`d6cca7d`): the extension loop added to the compound path, both sides | ||
| 62 | +projected through `motion_field::add_tpl_ref_mv`, `add_compound_candidate(..., 2)`. | ||
| 63 | + | ||
| 64 | +EVIDENCE: `.../scratchpad/pf/{aom,ours}.f0..f8` | `decode_probe` + instrumented | ||
| 65 | +`aomdec`, both under `EC_AV1_PREFILT_DUMP`, on the pinned obu | | ||
| 66 | +all 9 decode-order frames 0 differing bytes (was: frame 6, 957 bytes). | ||
| 67 | + | ||
| 68 | +Also in `d6cca7d`: inter-at-128 refusal DELETED from `stream.rs` and from | ||
| 69 | +`refusal_inventory.rs`; the reproducer gate `a_real_aomenc_inter_sequence_with_ | ||
| 70 | +128x128_superblocks_decodes_pixel_exact` UN-`#[ignore]`d; debug scaffolding removed | ||
| 71 | +(`EC_ABL_REACH64`, `EC_TRACE_MV`); an `EC_MODE_VAL`/`EC_STACK` trace kept on the | ||
| 72 | +compound path under `EC_TRACE_MODE`, byte-format-identical to the oracle's rung-4. | ||
| 73 | + | ||
| 74 | +## NOT DONE -- exact next steps for r4 | ||
| 75 | + | ||
| 76 | +1. RUN THE UN-IGNORED GATE (both bit depths; only the 8-bit arm was proven, via | ||
| 77 | + `decode_probe` on the pinned obu, not through the gate): | ||
| 78 | + `cargo test -p ec-av1 --lib -- --nocapture inter_sequence_with_128x128` | ||
| 79 | +2. Siblings, then the full suite -> `$HOME/.cache/sb128-suite-r3.log`, expect 0 | ||
| 80 | + failed: `128x128` gates, `inter_sequence*`, `obmc`, `temporal_mv_candidates`, | ||
| 81 | + `superblock_level_*`, the 7 rect/AB names above, `refusal_inventory`, | ||
| 82 | + `gate_coverage`. The compound-tpl fix touches EVERY compound inter block in the | ||
| 83 | + crate, so treat any red as this fix, not as flake. | ||
| 84 | +3. SWEEP THE CLASS: diff `find_mv_stack` against `find_mv_stack_compound` phase by | ||
| 85 | + phase (only the extension loop was checked); the same "compound twin dropped a | ||
| 86 | + phase" shape may sit in the outer row/col scans or the extra-search fill. | ||
| 87 | +4. Verifier note still owed: cdef/LR/delta_q arms with noise (`cdef_bits>0`) on the | ||
| 88 | + 128 gate, and the r1 gate's content-free arms. | ||
| 89 | +5. Film: `reelc-head.obu` through `decode_probe` -- expect the 128-root | ||
| 90 | + NONE/HORZ/VERT/AB refusal (sibling lane `lane-sb128b` owns it), NOT the inter one. | ||
| 91 | + | ||
| 92 | +HANDOFF: d6cca7d -- TASK 1 fixed and proven by attribution table; TASK 2 root-caused | ||
| 93 | +(compound MV stack was missing libaom's three tpl extension samples) and fixed with | ||
| 94 | +all 9 frames prefilt-exact, refusal lifted and gate un-ignored, but NO suite run yet. | ||
lanes/sb128-r4.report.mdadded+136 -0
| @@ -0,0 +1,136 @@ | |||
| 1 | +# lane-sb128 r4 report | ||
| 2 | + | ||
| 3 | +Branch `lane-sb128`. Two commits this round: | ||
| 4 | +`a599740` (merge of main `b51719f` + merge-seam repair), `e3d32d1` (128-root | ||
| 5 | +gathered-partition fix). | ||
| 6 | + | ||
| 7 | +## 1. Merge of main `b51719f` (`a599740`) | ||
| 8 | + | ||
| 9 | +`git merge --no-commit main` auto-merged clean (0 conflicted paths, diffstat | ||
| 10 | +21 files / +4375 / -293: palette2, sub8, rectsplitx, inter4, refstamp, oddh, | ||
| 11 | +band63, angleinter content). No lane-vs-main deletion was restored. | ||
| 12 | + | ||
| 13 | +Table check the charter asks for (`git show main:crates/ec-av1/src/cdf.rs` vs | ||
| 14 | +the merged file): the WHOLE cdf.rs delta is 12 lines and they are this lane's | ||
| 15 | +added `PARTITION_W128` constant. `NZ_MAP_CTX_OFFSET_32` / `_32X64` / `_64X32` | ||
| 16 | +and `FILTER_INTRA` / `FILTER_INTRA_MODE` are byte-identical to main (only | ||
| 17 | +their line numbers shift by 11). | ||
| 18 | + | ||
| 19 | +MERGE SEAM REPAIRED (predicted by the ledger constraint on `866cbb1`): main | ||
| 20 | +carries lane-oddh's refusal *"a sequence using 128x128 superblocks on a frame | ||
| 21 | +larger than 64x64"* at `stream.rs` `decode_stream`, which refuses exactly the | ||
| 22 | +capability this lane implements, plus its gate at | ||
| 23 | +`a_real_aomenc_128x128_superblock_stream_is_refused_by_name`. Both deleted, | ||
| 24 | +plus the `refusal_inventory.rs` entry. The gate was NOT dropped: it is now | ||
| 25 | +`a_real_aomenc_128x128_superblock_stream_decodes_pixel_exact`, same 64x72 | ||
| 26 | +`--cpu-used=0 --sb-size=128` aomenc stream, decoded through | ||
| 27 | +`decode_all_frames_vs_oracle` (pixel-exact vs aomdec, refusal or mismatch is a | ||
| 28 | +hard panic, never a SKIP). | ||
| 29 | + | ||
| 30 | +## 2. Root-cause fix: the 128 root threw its own partition symbol away (`e3d32d1`) | ||
| 31 | + | ||
| 32 | +`decode.rs::read_sb128_root`, half-out-of-frame arm: it read the gathered | ||
| 33 | +2-symbol `split_or_horz`/`split_or_vert` and returned `PARTITION_SPLIT` | ||
| 34 | +unconditionally. Spec 5.11.4 makes that symbol the DECISION (1 = SPLIT, | ||
| 35 | +0 = HORZ when only cols are out / VERT when only rows are out). The 64 root | ||
| 36 | +`partition_w64` already carries the fixed form -- its own comment records the | ||
| 37 | +3840x1608 10-bit head this same defect desynced -- so this is that class | ||
| 38 | +(`parsed then discarded`) unported to 128. | ||
| 39 | + | ||
| 40 | +Consequence before the fix: a 128 root that really codes HORZ/VERT at the | ||
| 41 | +frame edge was silently reconstructed as a split instead of reaching the | ||
| 42 | +refusal that names it. Found because the converted oddh gate decoded | ||
| 43 | +pixel-exact while reading zero 128 partition symbols. | ||
| 44 | + | ||
| 45 | +New witness counter `part128_gathered_symbols()` (`decode.rs:89`), asserted | ||
| 46 | +`> 0` by the oddh gate. Its recipe also gains `--min-partition-size=16`: | ||
| 47 | +without it aomenc emits `PARTITION_HORZ_4` below 16x16 (another lane's gap) | ||
| 48 | +and the gate measured that refusal instead of the 128 root. | ||
| 49 | + | ||
| 50 | +`decode_probe` now prints `SEQ: use_128x128_superblock=... bit_depth=... | ||
| 51 | +max_frame=WxH` next to its tiling line. | ||
| 52 | + | ||
| 53 | +## 3. The 128 gates | ||
| 54 | + | ||
| 55 | +Command (all under `systemd-run --user --unit=... -p MemoryMax=10G`, | ||
| 56 | +`EC_AV1_REQUIRE_AOMENC=1`, `CARGO_TARGET_DIR=$HOME/.cache/cargo-target-sb128`): | ||
| 57 | +`cargo test -p ec-av1 --lib -j3 -- --nocapture --test-threads=2 128x128` | ||
| 58 | + | ||
| 59 | +``` | ||
| 60 | +a_real_aomenc_inter_sequence_with_128x128_superblocks_decodes_pixel_exact (yuv420p): 9 decode-order frames pixel-exact (1 hidden), part128_symbols=18 cdef_idx_hits=12 tmv_hits=103 | ||
| 61 | +a_real_aomenc_inter_sequence_with_128x128_superblocks_decodes_pixel_exact (yuv420p10le): 9 decode-order frames pixel-exact (1 hidden), part128_symbols=18 cdef_idx_hits=12 tmv_hits=100 | ||
| 62 | +a_real_aomenc_128x128_superblock_stream_decodes_pixel_exact: 1 frames pixel-exact (0 hidden) at 64x72, part128_symbols=1 | ||
| 63 | +a_real_aomenc_stream_with_128x128_superblocks_decodes_pixel_exact: 6 pixel-exact, 0 named refusals, part128_symbols=26 part128_split_hits=34 | ||
| 64 | +test result: ok. 3 passed; 0 failed; 0 ignored; 0 measured; 395 filtered out; finished in 4.59s | ||
| 65 | +``` | ||
| 66 | + | ||
| 67 | +The un-ignored inter gate meets every clause the charter names: real aomenc | ||
| 68 | +stream with a knob-arrival assert on the sequence header | ||
| 69 | +(`use_128x128_superblock == true` AND the requested bit depth), per-arm | ||
| 70 | +counter deltas taken around the decode (`part128`/`cdef_idx`/`tmv`, each | ||
| 71 | +hard-asserted), every decode-order frame compared inside | ||
| 72 | +`decode_all_frames_vs_oracle` (which panics on a decoder refusal and on any | ||
| 73 | +differing byte -- there is no out-of-scope-mismatch tolerance path in it at | ||
| 74 | +all, so that count is structurally 0), 8- and 10-bit arms, and a SKIP only | ||
| 75 | +when ffmpeg/aomenc are absent, which `EC_AV1_REQUIRE_AOMENC=1` turns into a | ||
| 76 | +hard failure. | ||
| 77 | + | ||
| 78 | +EVIDENCE: `$HOME/.cache/sb128-r4-g128c.log` | `cargo test -p ec-av1 --lib -- --nocapture 128x128` on `e3d32d1` | `test result: ok. 3 passed; 0 failed`. | ||
| 79 | + | ||
| 80 | +## 4. Full lib suite | ||
| 81 | + | ||
| 82 | +``` | ||
| 83 | +test result: ok. 366 passed; 0 failed; 32 ignored; 0 measured; 0 filtered out; finished in 636.94s | ||
| 84 | +``` | ||
| 85 | + | ||
| 86 | +`gate_coverage` (10 tests), `refusal_inventory` and | ||
| 87 | +`decode::tests::base_ctx_rect_offsets_match_the_transcribed_tables_over_the_whole_domain` | ||
| 88 | +all `ok`. | ||
| 89 | + | ||
| 90 | +EVIDENCE: `$HOME/.cache/sb128-suite-r4.log` | `systemd-run --user --unit=sb128-r4-suite -p MemoryMax=10G ... EC_AV1_REQUIRE_AOMENC=1 cargo test -p ec-av1 --lib -j3` on `e3d32d1` | `366 passed; 0 failed; 32 ignored`. | ||
| 91 | + | ||
| 92 | +## 5. ReelC probe | ||
| 93 | + | ||
| 94 | +Stream: `ffmpeg -c:v copy -f obu` extract of | ||
| 95 | +`reelc.mkv`, 1175978 bytes, | ||
| 96 | +sha256 `bf31d1ba8600a9c26ae12c11cb44435490d48f5316a77cc307d6e5dbb4efac8c`, | ||
| 97 | +78 frame headers, 1 tile. | ||
| 98 | + | ||
| 99 | +``` | ||
| 100 | +TILING: 78 frame headers parsed | ||
| 101 | +SEQ: use_128x128_superblock=true bit_depth=10 max_frame=1920x792 | ||
| 102 | +REFUSED: unsupported: AV1 tile (a 1:4 partition below 16x16 (PARTITION_HORZ_4/VERT_4, four 16x4/4x16 strips -- this decoder codes NONE, HORZ, VERT, the four AB arms and a clean split at 16x16)) | ||
| 103 | +``` | ||
| 104 | + | ||
| 105 | +| what | value | | ||
| 106 | +| --- | --- | | ||
| 107 | +| decode-order frame it stops on | 0 (the first key frame) | | ||
| 108 | +| frames compared vs ffmpeg yuv420p10le | 0 -- `decode_stream` returns `Err`, so no plane is produced to compare | | ||
| 109 | +| refusal string reached | `a 1:4 partition below 16x16 (PARTITION_HORZ_4/VERT_4, four 16x4/4x16 strips -- this decoder codes NONE, HORZ, VERT, the four AB arms and a clean split at 16x16)` | | ||
| 110 | +| block | 16x16 at neighbour index `at16 = (21, 119)` = mi_row 84, mi_col 476, pixel (y=336, x=1904) -- the frame's last 16-pixel column (1904+16 = 1920) | | ||
| 111 | +| partition value read | 9 = `PARTITION_VERT_4` | | ||
| 112 | + | ||
| 113 | +Measured by a temporary `eprintln!` at the refusal site (`decode.rs:12462`), | ||
| 114 | +reverted in the same session; the permanent artefact is the `SEQ:` line. | ||
| 115 | + | ||
| 116 | +REELC DOES NOT STOP ON 128 NONE/HORZ/VERT, and it does not stop on the inter | ||
| 117 | +one either: `use_128x128_superblock=true` at 1920x792 is precisely what main | ||
| 118 | +`b51719f` refuses outright, and this lane carries ReelC through the 128 root, | ||
| 119 | +through 128-level SPLIT and the whole 64/32 tree, down to a 16x16 block that | ||
| 120 | +codes `PARTITION_VERT_4`. That gap belongs to the 1:4-below-16x16 lane, not to | ||
| 121 | +lane-sb128b's 128 NONE luma + chroma 2x2 TX_32X32 work -- nothing was | ||
| 122 | +duplicated. | ||
| 123 | + | ||
| 124 | +The first ~30 decode-order frames could not be compared: the decode aborts on | ||
| 125 | +frame 0. That comparison is `deferred(the 1:4-below-16x16 refusal being | ||
| 126 | +lifted)`. | ||
| 127 | + | ||
| 128 | +## Residue | ||
| 129 | + | ||
| 130 | +- `deferred(another round)`: the handoff's TASK 3 class sweep -- diffing | ||
| 131 | + `find_mv_stack` against `find_mv_stack_compound` phase by phase beyond the | ||
| 132 | + tpl extension loop r3 already ported. Not started this round. | ||
| 133 | +- `deferred(the 1:4-below-16x16 lane)`: ReelC's first ~30-frame pixel compare. | ||
| 134 | +- `accepted`: 128-root NONE/HORZ/VERT/AB still refuse by name; with `e3d32d1` | ||
| 135 | + that refusal is now actually reachable at a half-out-of-frame superblock | ||
| 136 | + instead of being silently mis-decoded. lane-sb128b owns lifting it. | ||