merge: main 18bf7dc into lane-golomb (edge32 counters kept alongside main's edge_part)
Browse files at this commit19 changed files +4099 -507
- 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 +1514 -182
- crates/ec-av1/src/encode.rs +32 -15
- crates/ec-av1/src/mvstack.rs +55 -18
- crates/ec-av1/src/refusal_inventory.rs +15 -3
- crates/ec-av1/src/stream.rs +1361 -175
- lanes/hgkf-r1.report.md +86 -0
- lanes/hgkf-r2.report.md +90 -0
- lanes/intrarect-r1.report.md +73 -112
- lanes/intrarect-r2.handoff.md +53 -0
- lanes/intrarect-r2.report.md +88 -0
- 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
| @@ -66,6 +66,18 @@ fn main() { | |||
| 66 | } | 66 | } |
| 67 | } | 67 | } |
| 68 | println!("TILING: {frames_seen} frame headers parsed"); | 68 | println!("TILING: {frames_seen} frame headers parsed"); |
| 69 | + // lane-sb128 r4: the superblock size decides the whole partition tree, so | ||
| 70 | + // report it next to the tiling -- it is the first thing a film blocker | ||
| 71 | + // triage needs. | ||
| 72 | + if let Some(seq) = parser.sequence_header() { | ||
| 73 | + println!( | ||
| 74 | + "SEQ: use_128x128_superblock={} bit_depth={} max_frame={}x{}", | ||
| 75 | + seq.use_128x128_superblock, | ||
| 76 | + seq.color_config.bit_depth, | ||
| 77 | + seq.max_frame_width, | ||
| 78 | + seq.max_frame_height | ||
| 79 | + ); | ||
| 80 | + } | ||
| 69 | for (cols, rows, uniform, ctx_id) in &seen { | 81 | for (cols, rows, uniform, ctx_id) in &seen { |
| 70 | println!( | 82 | println!( |
| 71 | "TILING: cols={cols} rows={rows} uniform_spacing={uniform} context_update_tile_id={ctx_id}" | 83 | "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+1514 -182
Diff too large; view file
| @@ -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( |
| @@ -1374,6 +1456,24 @@ pub(crate) fn palette_split_tx_hits() -> usize { | |||
| 1374 | PALETTE_SPLIT_TX_HITS.with(|c| c.get()) | 1456 | PALETTE_SPLIT_TX_HITS.with(|c| c.get()) |
| 1375 | } | 1457 | } |
| 1376 | 1458 | ||
| 1459 | +// lane-hgkf r2: SKIPPED intra blocks whose `tx_depth` split the luma transform | ||
| 1460 | +// and which are therefore predicted one transform unit at a time (a skipped | ||
| 1461 | +// block codes no coefficients, so nothing else in the stream witnesses this | ||
| 1462 | +// path -- only the pixels do). | ||
| 1463 | +thread_local! { | ||
| 1464 | + static SKIP_SPLIT_TX_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | ||
| 1465 | +} | ||
| 1466 | + | ||
| 1467 | +/// Current value of [`SKIP_SPLIT_TX_HITS`] (blocks, not units). | ||
| 1468 | +pub fn skip_split_tx_hits() -> usize { | ||
| 1469 | + SKIP_SPLIT_TX_HITS.with(|c| c.get()) | ||
| 1470 | +} | ||
| 1471 | + | ||
| 1472 | +/// Zeroes [`SKIP_SPLIT_TX_HITS`] before a gate's own decode attempt. | ||
| 1473 | +pub fn reset_skip_split_tx_hits() { | ||
| 1474 | + SKIP_SPLIT_TX_HITS.with(|c| c.set(0)); | ||
| 1475 | +} | ||
| 1476 | + | ||
| 1377 | // lane-intrainter r1: intra blocks inside an INTER frame whose `tx_depth` | 1477 | // lane-intrainter r1: intra blocks inside an INTER frame whose `tx_depth` |
| 1378 | // symbol split their luma transform, bucketed by block side (8, 16, 32, 64) -- | 1478 | // symbol split their luma transform, bucketed by block side (8, 16, 32, 64) -- |
| 1379 | // the gate's proof that the lifted path actually ran, per size. | 1479 | // the gate's proof that the lifted path actually ran, per size. |
| @@ -1848,6 +1948,22 @@ pub(crate) fn rect_leaf_coeff_hits() -> usize { | |||
| 1848 | RECT_LEAF_COEFF_HITS.with(|c| c.get()) | 1948 | RECT_LEAF_COEFF_HITS.with(|c| c.get()) |
| 1849 | } | 1949 | } |
| 1850 | 1950 | ||
| 1951 | +// lane-intrarect r1: how many intra-coded HORZ/VERT strips decoded on the | ||
| 1952 | +// INTER block path ([`decode_intra_rect_in_inter`]), per shape class -- | ||
| 1953 | +// [0] the superblock-level 64x32/32x64, [1] 32x16/16x32, [2] 16x8/8x16. | ||
| 1954 | +// Every one of them was the named refusal "an intra-coded HORZ/VERT strip | ||
| 1955 | +// needs rectangular intra prediction" before this round. | ||
| 1956 | +thread_local! { | ||
| 1957 | + static INTRA_RECT_IN_INTER_HITS: std::cell::Cell<[usize; 3]> = | ||
| 1958 | + const { std::cell::Cell::new([0; 3]) }; | ||
| 1959 | +} | ||
| 1960 | + | ||
| 1961 | +/// Current value of [`INTRA_RECT_IN_INTER_HITS`] for one shape class | ||
| 1962 | +/// (0 = 64x32/32x64, 1 = 32x16/16x32, 2 = 16x8/8x16). | ||
| 1963 | +pub(crate) fn intra_rect_strip_in_inter_hits(class: usize) -> usize { | ||
| 1964 | + INTRA_RECT_IN_INTER_HITS.with(|c| c.get()[class]) | ||
| 1965 | +} | ||
| 1966 | + | ||
| 1851 | // lane-rectx r5: how many times a NON-strip `kf_y_mode` reader | 1967 | // lane-rectx r5: how many times a NON-strip `kf_y_mode` reader |
| 1852 | // ([`decode_block`], [`decode_block_rect`], [`decode_block_rect64`]) took an | 1968 | // ([`decode_block`], [`decode_block_rect`], [`decode_block_rect64`]) took an |
| 1853 | // above/left mode from the mi-exact map that DIFFERS from its coarse 16x16 | 1969 | // above/left mode from the mi-exact map that DIFFERS from its coarse 16x16 |
| @@ -1939,6 +2055,33 @@ thread_local! { | |||
| 1939 | } | 2055 | } |
| 1940 | 2056 | ||
| 1941 | /// Current value of [`SB_RECT_HITS`]. | 2057 | /// Current value of [`SB_RECT_HITS`]. |
| 2058 | +// lane-hgkf r1: the frame-edge partition bit, one level each. Slot 0 = a | ||
| 2059 | +// 64-level gathered edge bit read as HORZ/VERT, 1 = the same bit read as | ||
| 2060 | +// SPLIT, 2/3 = the 32-level pair. A gate asserting slot 0 or 2 proves the | ||
| 2061 | +// non-SPLIT edge arm actually decoded (before this round the bit was read and | ||
| 2062 | +// thrown away, so that arm was unreachable). | ||
| 2063 | +thread_local! { | ||
| 2064 | + static EDGE_PART_HITS: std::cell::Cell<[usize; 4]> = const { std::cell::Cell::new([0; 4]) }; | ||
| 2065 | +} | ||
| 2066 | + | ||
| 2067 | +/// Current value of [`EDGE_PART_HITS`]. | ||
| 2068 | +pub(crate) fn edge_part_hits() -> [usize; 4] { | ||
| 2069 | + EDGE_PART_HITS.with(|c| c.get()) | ||
| 2070 | +} | ||
| 2071 | + | ||
| 2072 | +/// Reset [`EDGE_PART_HITS`] (a gate counts one stream at a time). | ||
| 2073 | +pub(crate) fn reset_edge_part_hits() { | ||
| 2074 | + EDGE_PART_HITS.with(|c| c.set([0; 4])); | ||
| 2075 | +} | ||
| 2076 | + | ||
| 2077 | +fn bump_edge_part(slot: usize) { | ||
| 2078 | + EDGE_PART_HITS.with(|c| { | ||
| 2079 | + let mut h = c.get(); | ||
| 2080 | + h[slot] += 1; | ||
| 2081 | + c.set(h); | ||
| 2082 | + }); | ||
| 2083 | +} | ||
| 2084 | + | ||
| 1942 | pub(crate) fn sb_rect_hits() -> usize { | 2085 | pub(crate) fn sb_rect_hits() -> usize { |
| 1943 | SB_RECT_HITS.with(|c| c.get()) | 2086 | SB_RECT_HITS.with(|c| c.get()) |
| 1944 | } | 2087 | } |
| @@ -2079,6 +2222,30 @@ pub(crate) fn rect4_coeff_hits() -> usize { | |||
| 2079 | RECT4_COEFF_HITS.with(|c| c.get()) | 2222 | RECT4_COEFF_HITS.with(|c| c.get()) |
| 2080 | } | 2223 | } |
| 2081 | 2224 | ||
| 2225 | +// lane-r14: the 16x16-level 1:4 pair -- four 16x4 (`PARTITION_HORZ_4`) or | ||
| 2226 | +// 4x16 (`PARTITION_VERT_4`) strips, `CHROMA` counting the odd strips that | ||
| 2227 | +// close a 4:2:0 chroma pair and `COEFF` the strips with a coded residual. | ||
| 2228 | +thread_local! { | ||
| 2229 | + static RECT4_16_HORZ_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | ||
| 2230 | + static RECT4_16_VERT_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | ||
| 2231 | + static RECT4_16_CHROMA_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | ||
| 2232 | + static RECT4_16_COEFF_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | ||
| 2233 | + static RECT4_16_SPLIT_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | ||
| 2234 | +} | ||
| 2235 | + | ||
| 2236 | +/// Current values of the 16x16-level 1:4 counters: `(16x4 strips, 4x16 | ||
| 2237 | +/// strips, chroma-reference strips, strips with a coded residual, strips | ||
| 2238 | +/// whose luma transform is split)`. | ||
| 2239 | +pub fn rect4_16_counters() -> (usize, usize, usize, usize, usize) { | ||
| 2240 | + ( | ||
| 2241 | + RECT4_16_HORZ_HITS.with(|c| c.get()), | ||
| 2242 | + RECT4_16_VERT_HITS.with(|c| c.get()), | ||
| 2243 | + RECT4_16_CHROMA_HITS.with(|c| c.get()), | ||
| 2244 | + RECT4_16_COEFF_HITS.with(|c| c.get()), | ||
| 2245 | + RECT4_16_SPLIT_HITS.with(|c| c.get()), | ||
| 2246 | + ) | ||
| 2247 | +} | ||
| 2248 | + | ||
| 2082 | /// Current value of `RECT4_32_HORZ_HITS` (32x8 strips decoded). | 2249 | /// Current value of `RECT4_32_HORZ_HITS` (32x8 strips decoded). |
| 2083 | pub(crate) fn rect4_32_horz_hits() -> usize { | 2250 | pub(crate) fn rect4_32_horz_hits() -> usize { |
| 2084 | RECT4_32_HORZ_HITS.with(|c| c.get()) | 2251 | RECT4_32_HORZ_HITS.with(|c| c.get()) |
| @@ -2452,6 +2619,18 @@ fn note_chroma_class1(plane_idx: usize, tx_type: TxType) { | |||
| 2452 | const SUB_MI: u32 = 4; | 2619 | const SUB_MI: u32 = 4; |
| 2453 | const MI: usize = 4; | 2620 | const MI: usize = 4; |
| 2454 | const SB: usize = 64; | 2621 | const SB: usize = 64; |
| 2622 | +/// The `above_side`/`left_side` value a cell with no decoded neighbour holds | ||
| 2623 | +/// (tile start, superblock-row start). | ||
| 2624 | +/// | ||
| 2625 | +/// [`Neighbours::partition_ctx_mi`] reads it as libaom's | ||
| 2626 | +/// `av1_get_partition_plane_context` reads its own zero-initialised | ||
| 2627 | +/// `above_partition_context` byte: bit `bsl` clear, i.e. "the neighbour is at | ||
| 2628 | +/// least as wide as this block". lane-sb128 r1: the old sentinel was `SB` | ||
| 2629 | +/// (64), which reads identically at every level up to 64x64 but sets the bit | ||
| 2630 | +/// at the `BLOCK_128X128` root (64 * 2 <= 128) -- the 128-level partition | ||
| 2631 | +/// symbol was read off CDF row 3 where libaom uses row 0 (aomdec | ||
| 2632 | +/// `EC_PART mi_row=0 mi_col=0 bsize=15 ctx=16`, i.e. `bsl*4 + 0`). | ||
| 2633 | +const NO_NEIGHBOUR_SIDE: usize = 128; | ||
| 2455 | const BLOCK: usize = 32; | 2634 | const BLOCK: usize = 32; |
| 2456 | const SUB: usize = 16; | 2635 | const SUB: usize = 16; |
| 2457 | const TX32: usize = 32; | 2636 | const TX32: usize = 32; |
| @@ -3316,7 +3495,7 @@ fn read_coeffs_rect( | |||
| 3316 | let all_zero = dec.symbol(&mut coding.txb_skip[skip_ctx]) == 1; | 3495 | let all_zero = dec.symbol(&mut coding.txb_skip[skip_ctx]) == 1; |
| 3317 | if rect_trace { | 3496 | if rect_trace { |
| 3318 | eprintln!( | 3497 | eprintln!( |
| 3319 | - "EC_COEFF_STEP tag=all_zero plane=0 ctx={skip_ctx} all_zero={} rng={}", | 3498 | + "EC_COEFF_STEP tag=all_zero plane=0 ctx={skip_ctx} entry={entry_rng} all_zero={} rng={}", |
| 3320 | all_zero as i32, | 3499 | all_zero as i32, |
| 3321 | dec.debug_state().0 | 3500 | dec.debug_state().0 |
| 3322 | ); | 3501 | ); |
| @@ -3679,10 +3858,10 @@ impl Neighbours { | |||
| 3679 | left_mode: vec![DC_PRED; rows], | 3858 | left_mode: vec![DC_PRED; rows], |
| 3680 | above_uv_mode: vec![DC_PRED; cols], | 3859 | above_uv_mode: vec![DC_PRED; cols], |
| 3681 | left_uv_mode: vec![DC_PRED; rows], | 3860 | left_uv_mode: vec![DC_PRED; rows], |
| 3682 | - above_side: vec![SB; cols], | 3861 | + above_side: vec![NO_NEIGHBOUR_SIDE; cols], |
| 3683 | - left_side: vec![SB; rows], | 3862 | + left_side: vec![NO_NEIGHBOUR_SIDE; rows], |
| 3684 | - above_side_mi: vec![SB; cols * (SUB / MI)], | 3863 | + above_side_mi: vec![NO_NEIGHBOUR_SIDE; cols * (SUB / MI)], |
| 3685 | - left_side_mi: vec![SB; rows * (SUB / MI)], | 3864 | + left_side_mi: vec![NO_NEIGHBOUR_SIDE; rows * (SUB / MI)], |
| 3686 | sub8_mode_col: vec![(usize::MAX, 0); cols * (SUB / MI)], | 3865 | sub8_mode_col: vec![(usize::MAX, 0); cols * (SUB / MI)], |
| 3687 | sub8_mode_row: vec![(usize::MAX, 0); rows * (SUB / MI)], | 3866 | sub8_mode_row: vec![(usize::MAX, 0); rows * (SUB / MI)], |
| 3688 | uv_mode_col: vec![(usize::MAX, 0); cols * (SUB / MI)], | 3867 | uv_mode_col: vec![(usize::MAX, 0); cols * (SUB / MI)], |
| @@ -3747,7 +3926,7 @@ impl Neighbours { | |||
| 3747 | let end = col1_mi.min(self.above.len()); | 3926 | let end = col1_mi.min(self.above.len()); |
| 3748 | for i in col0_mi.min(end)..end { | 3927 | for i in col0_mi.min(end)..end { |
| 3749 | self.above[i] = Default::default(); | 3928 | self.above[i] = Default::default(); |
| 3750 | - self.above_side_mi[i] = SB; | 3929 | + self.above_side_mi[i] = NO_NEIGHBOUR_SIDE; |
| 3751 | } | 3930 | } |
| 3752 | let (sc0, sc1) = ( | 3931 | let (sc0, sc1) = ( |
| 3753 | col0_mi / (SUB / MI), | 3932 | col0_mi / (SUB / MI), |
| @@ -3755,7 +3934,7 @@ impl Neighbours { | |||
| 3755 | ); | 3934 | ); |
| 3756 | for i in sc0.min(sc1)..sc1 { | 3935 | for i in sc0.min(sc1)..sc1 { |
| 3757 | self.above_mode[i] = DC_PRED; | 3936 | self.above_mode[i] = DC_PRED; |
| 3758 | - self.above_side[i] = SB; | 3937 | + self.above_side[i] = NO_NEIGHBOUR_SIDE; |
| 3759 | } | 3938 | } |
| 3760 | // lane-inter8 r2: the inter bands are mi-granular, so they reset over | 3939 | // lane-inter8 r2: the inter bands are mi-granular, so they reset over |
| 3761 | // the tile's own mi column span directly. | 3940 | // the tile's own mi column span directly. |
| @@ -4094,8 +4273,8 @@ impl Neighbours { | |||
| 4094 | self.left.iter_mut().for_each(|l| *l = Default::default()); | 4273 | self.left.iter_mut().for_each(|l| *l = Default::default()); |
| 4095 | self.left_mode.iter_mut().for_each(|m| *m = DC_PRED); | 4274 | self.left_mode.iter_mut().for_each(|m| *m = DC_PRED); |
| 4096 | self.left_uv_mode.iter_mut().for_each(|m| *m = DC_PRED); | 4275 | self.left_uv_mode.iter_mut().for_each(|m| *m = DC_PRED); |
| 4097 | - self.left_side.iter_mut().for_each(|s| *s = SB); | 4276 | + self.left_side.iter_mut().for_each(|s| *s = NO_NEIGHBOUR_SIDE); |
| 4098 | - self.left_side_mi.iter_mut().for_each(|s| *s = SB); | 4277 | + self.left_side_mi.iter_mut().for_each(|s| *s = NO_NEIGHBOUR_SIDE); |
| 4099 | self.left_skip.iter_mut().for_each(|s| *s = false); | 4278 | self.left_skip.iter_mut().for_each(|s| *s = false); |
| 4100 | self.left_skip_mode.iter_mut().for_each(|s| *s = false); | 4279 | self.left_skip_mode.iter_mut().for_each(|s| *s = false); |
| 4101 | self.left_inter.iter_mut().for_each(|i| *i = false); | 4280 | self.left_inter.iter_mut().for_each(|i| *i = false); |
| @@ -4907,6 +5086,10 @@ fn filter_intra_size_class_rect(bw: usize, bh: usize) -> Option<usize> { | |||
| 4907 | // tile (class symbol-consumption-gap). | 5086 | // tile (class symbol-consumption-gap). |
| 4908 | (32, 8) => Some(10), | 5087 | (32, 8) => Some(10), |
| 4909 | (8, 32) => Some(11), | 5088 | (8, 32) => Some(11), |
| 5089 | + // lane-r14: the 16x16-level 1:4 pair (`decode_rect4_16`'s 16x4/4x16 | ||
| 5090 | + // strips), rows 17/16 of `default_filter_intra_cdfs`. | ||
| 5091 | + (16, 4) => Some(12), | ||
| 5092 | + (4, 16) => Some(13), | ||
| 4910 | _ if bw == bh => filter_intra_size_class(bw), | 5093 | _ if bw == bh => filter_intra_size_class(bw), |
| 4911 | _ => None, | 5094 | _ => None, |
| 4912 | } | 5095 | } |
| @@ -4932,7 +5115,13 @@ fn palette_bsize_ctx(side: usize) -> Option<usize> { | |||
| 4932 | /// `trailing_zeros` is `log2` exactly. `None` past `av1_allow_palette`'s own | 5115 | /// `trailing_zeros` is `log2` exactly. `None` past `av1_allow_palette`'s own |
| 4933 | /// bound (`block_size_wide/high <= 64`, `sb_type >= BLOCK_8X8`). | 5116 | /// bound (`block_size_wide/high <= 64`, `sb_type >= BLOCK_8X8`). |
| 4934 | fn palette_bsize_ctx_wh(bw: usize, bh: usize) -> Option<usize> { | 5117 | fn palette_bsize_ctx_wh(bw: usize, bh: usize) -> Option<usize> { |
| 4935 | - if !(8..=64).contains(&bw) || !(8..=64).contains(&bh) { | 5118 | + // lane-r14: `av1_allow_palette`'s bound is `sb_type >= BLOCK_8X8` by the |
| 5119 | + // BLOCK_SIZES_ALL enum INDEX, which the 1:4 shapes BLOCK_4X16 (16) and | ||
| 5120 | + // BLOCK_16X4 (17) clear -- a 64-pixel block, so `av1_get_palette_bsize_ctx` | ||
| 5121 | + // (`num_pels_log2 - num_pels_log2[BLOCK_8X8]`) is 0 for them, exactly as | ||
| 5122 | + // for an 8x8. Reading the dimension bound as "both sides >= 8" dropped | ||
| 5123 | + // `palette_y_mode` on every 16x4/4x16 strip of a screen-content frame. | ||
| 5124 | + if bw > 64 || bh > 64 || bw * bh < 64 { | ||
| 4936 | return None; | 5125 | return None; |
| 4937 | } | 5126 | } |
| 4938 | Some(((bw * bh) as u32).trailing_zeros() as usize - 6) | 5127 | Some(((bw * bh) as u32).trailing_zeros() as usize - 6) |
| @@ -5254,6 +5443,12 @@ fn read_intra_mode_rect( | |||
| 5254 | above_mode: usize, | 5443 | above_mode: usize, |
| 5255 | left_mode: usize, | 5444 | left_mode: usize, |
| 5256 | cfl: bool, | 5445 | cfl: bool, |
| 5446 | + // lane-r14: `is_chroma_reference` -- false only for a strip one mi tall | ||
| 5447 | + // (or wide) that is NOT the odd one of its 4:2:0 pair, where libaom reads | ||
| 5448 | + // no `uv_mode`/`cfl_alpha`/`angle_delta_uv`/`palette_uv` at all (the pair's | ||
| 5449 | + // chroma is coded once, on the closing strip). Every other caller is a | ||
| 5450 | + // block big enough to own its chroma and passes `true`. | ||
| 5451 | + has_chroma: bool, | ||
| 5257 | bw: usize, | 5452 | bw: usize, |
| 5258 | bh: usize, | 5453 | bh: usize, |
| 5259 | enable_filter_intra: bool, | 5454 | enable_filter_intra: bool, |
| @@ -5317,21 +5512,23 @@ fn read_intra_mode_rect( | |||
| 5317 | 0 | 5512 | 0 |
| 5318 | }; | 5513 | }; |
| 5319 | istep!("angle_y", angle_delta_y); | 5514 | istep!("angle_y", angle_delta_y); |
| 5320 | - let uv_mode = if cfl { | 5515 | + let uv_mode = if !has_chroma { |
| 5516 | + DC_PRED | ||
| 5517 | + } else if cfl { | ||
| 5321 | dec.symbol(&mut cdfs.uv_mode_cfl[mode]) | 5518 | dec.symbol(&mut cdfs.uv_mode_cfl[mode]) |
| 5322 | } else { | 5519 | } else { |
| 5323 | dec.symbol(&mut cdfs.uv_mode_no_cfl[mode]) | 5520 | dec.symbol(&mut cdfs.uv_mode_no_cfl[mode]) |
| 5324 | }; | 5521 | }; |
| 5325 | istep!("uv_mode", uv_mode as i32); | 5522 | istep!("uv_mode", uv_mode as i32); |
| 5326 | - let alpha = if cfl && uv_mode == UV_CFL_PRED { | 5523 | + let alpha = if has_chroma && cfl && uv_mode == UV_CFL_PRED { |
| 5327 | Some(read_cfl_alphas(dec, cdfs)) | 5524 | Some(read_cfl_alphas(dec, cdfs)) |
| 5328 | } else { | 5525 | } else { |
| 5329 | None | 5526 | None |
| 5330 | }; | 5527 | }; |
| 5331 | - if (9..=12).contains(&uv_mode) { | 5528 | + if has_chroma && (9..=12).contains(&uv_mode) { |
| 5332 | SMOOTH_UV_HITS.with(|c| c.set(c.get() + 1)); | 5529 | SMOOTH_UV_HITS.with(|c| c.set(c.get() + 1)); |
| 5333 | } | 5530 | } |
| 5334 | - let angle_delta_uv = if (V_PRED..=D67_PRED).contains(&uv_mode) { | 5531 | + let angle_delta_uv = if has_chroma && (V_PRED..=D67_PRED).contains(&uv_mode) { |
| 5335 | DIRECTIONAL_UV_HITS.with(|c| c.set(c.get() + 1)); | 5532 | DIRECTIONAL_UV_HITS.with(|c| c.set(c.get() + 1)); |
| 5336 | read_angle_delta(dec, &mut cdfs.angle_delta[uv_mode - V_PRED]) | 5533 | read_angle_delta(dec, &mut cdfs.angle_delta[uv_mode - V_PRED]) |
| 5337 | } else { | 5534 | } else { |
| @@ -5371,7 +5568,11 @@ fn read_intra_mode_rect( | |||
| 5371 | palette_y_pending = Some((n, colors)); | 5568 | palette_y_pending = Some((n, colors)); |
| 5372 | } | 5569 | } |
| 5373 | let palette_uv_mode_ctx = usize::from(use_palette_y); | 5570 | let palette_uv_mode_ctx = usize::from(use_palette_y); |
| 5374 | - if uv_mode == DC_PRED && dec.symbol(&mut cdfs.palette_uv_mode[palette_uv_mode_ctx]) != 0 { | 5571 | + // `read_palette_mode_info`'s own `xd->is_chroma_ref` guard. |
| 5572 | + if has_chroma | ||
| 5573 | + && uv_mode == DC_PRED | ||
| 5574 | + && dec.symbol(&mut cdfs.palette_uv_mode[palette_uv_mode_ctx]) != 0 | ||
| 5575 | + { | ||
| 5375 | let n = 2 + dec.symbol(&mut cdfs.palette_uv_size[bsize_ctx]); | 5576 | let n = 2 + dec.symbol(&mut cdfs.palette_uv_size[bsize_ctx]); |
| 5376 | let (u_colors, v_colors) = read_palette_colors_uv(dec, n, palette_uv_cache); | 5577 | let (u_colors, v_colors) = read_palette_colors_uv(dec, n, palette_uv_cache); |
| 5377 | palette_uv_pending = Some((n, u_colors, v_colors)); | 5578 | palette_uv_pending = Some((n, u_colors, v_colors)); |
| @@ -5661,12 +5862,13 @@ fn decode_rect_split( | |||
| 5661 | let tu_mi = (mi_r + tu_row * (tx_h / MI), mi_c + tu_col * (tx_w / MI)); | 5862 | let tu_mi = (mi_r + tu_row * (tx_h / MI), mi_c + tu_col * (tx_w / MI)); |
| 5662 | let (tu_px, tu_py) = (px + tu_col * tx_w, py + tu_row * tx_h); | 5863 | let (tu_px, tu_py) = (px + tu_col * tx_w, py + tu_row * tx_h); |
| 5663 | let (col_off, row_off) = (tu_col * tx_w, tu_row * tx_h); | 5864 | let (col_off, row_off) = (tu_col * tx_w, tu_row * tx_h); |
| 5664 | - // lane-golomb r3: a frame-edge HORZ/VERT strip is the one block | 5865 | + // lane-hgkf r1 (ported from lane-golomb 791d87a, unmerged): |
| 5665 | - // shape that hangs off the bottom (or right) of the frame, and | 5866 | + // libaom clips `av1_foreach_transformed_block_in_plane` to |
| 5666 | - // libaom's `av1_foreach_transformed_block_in_plane` clips its | 5867 | + // `max_blocks_wide/high` (`mb_to_right_edge`/`mb_to_bottom_edge`, |
| 5667 | - // loop bounds to `max_blocks_high/wide` (`mb_to_bottom_edge` / | 5868 | + // i.e. `mi_cols * 4` / `mi_rows * 4`): a transform unit whose |
| 5668 | - // `mb_to_right_edge`, i.e. `mi_rows * 4` / `mi_cols * 4`): a unit | 5869 | + // TOP-LEFT sample falls outside the frame is never coded. We read |
| 5669 | - // whose TOP-LEFT sample is outside the frame is never coded. | 5870 | + // coefficients for those phantom units and desynced the stream at |
| 5871 | + // the very next symbol. | ||
| 5670 | if tu_px >= y.true_width || tu_py >= y.true_height { | 5872 | if tu_px >= y.true_width || tu_py >= y.true_height { |
| 5671 | continue; | 5873 | continue; |
| 5672 | } | 5874 | } |
| @@ -5719,7 +5921,19 @@ fn decode_rect_split( | |||
| 5719 | // own (always DC_PRED) mode -- [`read_plane`] applies that | 5921 | // own (always DC_PRED) mode -- [`read_plane`] applies that |
| 5720 | // for the square arm, so this one must too. | 5922 | // for the square arm, so this one must too. |
| 5721 | let tu_around = neighbours.around_mi_rect(tu_mi, tx_w, tx_h)[0]; | 5923 | let tu_around = neighbours.around_mi_rect(tu_mi, tx_w, tx_h)[0]; |
| 5722 | - let tu_skip_ctx = neighbours.luma_skip_ctx_rect(tu_mi, tx_w / MI, tx_h / MI); | 5924 | + // libaom `get_txb_ctx`: a LUMA transform that covers its whole |
| 5925 | + // block (`plane_bsize == txsize_to_bsize[tx_size]`, i.e. the | ||
| 5926 | + // unsplit depth-0 strip) reads txb_skip ctx 0 flat -- the | ||
| 5927 | + // neighbour-magnitude table is for a unit SMALLER than its | ||
| 5928 | + // block. [`decode_block_rect`]'s own unsplit read passes a | ||
| 5929 | + // literal 0 for the same reason; this arm applied the table | ||
| 5930 | + // unconditionally and desynced every depth-0 rect strip that | ||
| 5931 | + // reached it (lane-intrarect r2: ctx 5 where aomdec read 0). | ||
| 5932 | + let tu_skip_ctx = if tx_w == bw && tx_h == bh { | ||
| 5933 | + 0 | ||
| 5934 | + } else { | ||
| 5935 | + neighbours.luma_skip_ctx_rect(tu_mi, tx_w / MI, tx_h / MI) | ||
| 5936 | + }; | ||
| 5723 | let mut coding = cdfs.txb(rect_set, fi_tx_row(m.mode, m.filter_intra)); | 5937 | let mut coding = cdfs.txb(rect_set, fi_tx_row(m.mode, m.filter_intra)); |
| 5724 | let (tu_grid, tu_tx_type) = read_coeffs_rect( | 5938 | let (tu_grid, tu_tx_type) = read_coeffs_rect( |
| 5725 | dec, | 5939 | dec, |
| @@ -5897,6 +6111,211 @@ fn decode_rect_split( | |||
| 5897 | Ok(()) | 6111 | Ok(()) |
| 5898 | } | 6112 | } |
| 5899 | 6113 | ||
| 6114 | +/// One intra-coded HORZ/VERT strip on the INTER block path (lane-intrarect | ||
| 6115 | +/// r1) -- the shape [`decode_inter_block`]'s intra arm refused by name | ||
| 6116 | +/// because it predicts squares only. Every pixel here goes through the rect | ||
| 6117 | +/// machinery the key-frame paths already prove: [`decode_rect_split`], which | ||
| 6118 | +/// at `depth == 0` is the unsplit strip as a single transform unit and | ||
| 6119 | +/// beyond it the per-unit walk of [`depth_to_tx_wh`]. | ||
| 6120 | +/// | ||
| 6121 | +/// What is genuinely different from [`decode_block_rect`] is the mode | ||
| 6122 | +/// syntax: on an inter frame an intra block reads `y_mode[size_group]` and | ||
| 6123 | +/// `uv_mode` (libaom `read_intra_block_mode_info`, decodemv.c:1065), never | ||
| 6124 | +/// the key frame's `kf_y_mode` above/left pair. This mirrors the square | ||
| 6125 | +/// intra-in-inter arm's own reads at the rect footprint, including its | ||
| 6126 | +/// inherited gaps -- no `use_filter_intra` symbol (every inter gate recipe | ||
| 6127 | +/// pins `--enable-filter-intra=0`; lane-fiinter owns that read for both the | ||
| 6128 | +/// square and this arm) and a nonzero luma angle delta refused by name. | ||
| 6129 | +/// | ||
| 6130 | +/// The strip's own neighbour records (luma per transform unit, chroma, skip | ||
| 6131 | +/// grid, deblock grid) are [`decode_rect_split`]'s; the caller adds the | ||
| 6132 | +/// inter-side bands and the mi map. | ||
| 6133 | +#[allow(clippy::too_many_arguments)] | ||
| 6134 | +fn decode_intra_rect_in_inter( | ||
| 6135 | + dec: &mut SymbolDecoder, | ||
| 6136 | + cdfs: &mut Cdfs, | ||
| 6137 | + neighbours: &mut Neighbours, | ||
| 6138 | + at: (usize, usize), | ||
| 6139 | + bw: usize, | ||
| 6140 | + bh: usize, | ||
| 6141 | + skip: bool, | ||
| 6142 | + allow_screen_content_tools: bool, | ||
| 6143 | + y: &mut PlaneBuf, | ||
| 6144 | + u: &mut PlaneBuf, | ||
| 6145 | + v: &mut PlaneBuf, | ||
| 6146 | + base_q_idx: u8, | ||
| 6147 | +) -> Result<()> { | ||
| 6148 | + // `at` is in MI units (the inter path's own unit since lane-inter4); | ||
| 6149 | + // `(r, c)` is the enclosing SUB cell the SUB-granular neighbour bands | ||
| 6150 | + // below are still keyed by. | ||
| 6151 | + let (mi_r, mi_c) = at; | ||
| 6152 | + let (r, c) = (mi_r / (SUB / MI), mi_c / (SUB / MI)); | ||
| 6153 | + // `size_group_lookup` (libaom common_data.h) and `bsize_to_tx_size_cat` | ||
| 6154 | + // (blockd.h) for the three 2:1 strip shapes: BLOCK_16X8 -> group 1 / | ||
| 6155 | + // cat 1, BLOCK_32X16 -> 2 / 2, BLOCK_64X32 -> 3 / 3 (the rectsplitx | ||
| 6156 | + // finding -- the category is NOT the same for every strip size). | ||
| 6157 | + // A 1:4 strip breaks that diagonal (BLOCK_32X8 is group 1 but cat 2), so | ||
| 6158 | + // it is refused by name rather than read from the wrong CDF row. | ||
| 6159 | + let (size_group, tx_cat) = match (bw.min(bh), bw.max(bh)) { | ||
| 6160 | + (8, 16) => (1usize, 1usize), | ||
| 6161 | + (16, 32) => (2, 2), | ||
| 6162 | + (32, 64) => (3, 3), | ||
| 6163 | + _ => { | ||
| 6164 | + return Err(unsupported( | ||
| 6165 | + "an intra-coded 1:4 (or other non-2:1) rect strip on the inter block path", | ||
| 6166 | + )) | ||
| 6167 | + } | ||
| 6168 | + }; | ||
| 6169 | + // [`read_intra_mode_rect`]'s own refusal: palette/intrabc syntax is | ||
| 6170 | + // consumed for square blocks only, so a strip in a screen-content frame | ||
| 6171 | + // would skip symbols the encoder wrote. | ||
| 6172 | + if allow_screen_content_tools { | ||
| 6173 | + return Err(unsupported( | ||
| 6174 | + "a HORZ/VERT intra strip in a screen-content frame (palette syntax \ | ||
| 6175 | + is consumed for square blocks only)", | ||
| 6176 | + )); | ||
| 6177 | + } | ||
| 6178 | + let mode = dec.symbol(&mut cdfs.y_mode[size_group]); | ||
| 6179 | + if mode >= 13 { | ||
| 6180 | + return Err(unsupported( | ||
| 6181 | + "an intra mode this decoder does not code (round 2)", | ||
| 6182 | + )); | ||
| 6183 | + } | ||
| 6184 | + // lane-angleinter (merged on main for the square intra-in-inter arm): | ||
| 6185 | + // the delta is read off `angle_delta_cdf[mode - V_PRED]` and feeds the | ||
| 6186 | + // directional predictor; this arm refused a nonzero one before the merge. | ||
| 6187 | + let angle_delta_y = if (V_PRED..=D67_PRED).contains(&mode) { | ||
| 6188 | + read_angle_delta(dec, &mut cdfs.angle_delta[mode - V_PRED]) | ||
| 6189 | + } else { | ||
| 6190 | + 0 | ||
| 6191 | + }; | ||
| 6192 | + if angle_delta_y != 0 { | ||
| 6193 | + INTRA_IN_INTER_ANGLE_DELTA_Y_HITS.with(|c| c.set(c.get() + 1)); | ||
| 6194 | + } | ||
| 6195 | + // `is_cfl_allowed` (spec 5.11.5) caps CFL at 32x32, so the | ||
| 6196 | + // superblock-level strip reads the no-CFL alphabet -- the same split | ||
| 6197 | + // [`read_intra_mode_rect`] makes for [`decode_block_rect64`]. | ||
| 6198 | + let cfl_allowed = bw.max(bh) <= 32; | ||
| 6199 | + let uv_mode = if cfl_allowed { | ||
| 6200 | + dec.symbol(&mut cdfs.uv_mode_cfl[mode]) | ||
| 6201 | + } else { | ||
| 6202 | + dec.symbol(&mut cdfs.uv_mode_no_cfl[mode]) | ||
| 6203 | + }; | ||
| 6204 | + if (9..=12).contains(&uv_mode) { | ||
| 6205 | + SMOOTH_UV_HITS.with(|h| h.set(h.get() + 1)); | ||
| 6206 | + } | ||
| 6207 | + let alpha = if cfl_allowed && uv_mode == UV_CFL_PRED { | ||
| 6208 | + Some(read_cfl_alphas(dec, cdfs)) | ||
| 6209 | + } else { | ||
| 6210 | + None | ||
| 6211 | + }; | ||
| 6212 | + let uv_predict_mode = if uv_mode == UV_CFL_PRED { | ||
| 6213 | + DC_PRED | ||
| 6214 | + } else { | ||
| 6215 | + uv_mode | ||
| 6216 | + }; | ||
| 6217 | + let angle_delta_uv = if (V_PRED..=D67_PRED).contains(&uv_mode) { | ||
| 6218 | + DIRECTIONAL_UV_HITS.with(|h| h.set(h.get() + 1)); | ||
| 6219 | + read_angle_delta(dec, &mut cdfs.angle_delta[uv_mode - V_PRED]) | ||
| 6220 | + } else { | ||
| 6221 | + 0 | ||
| 6222 | + }; | ||
| 6223 | + if angle_delta_uv != 0 { | ||
| 6224 | + UV_ANGLE_DELTA_HITS.with(|h| h.set(h.get() + 1)); | ||
| 6225 | + INTRA_IN_INTER_ANGLE_DELTA_UV_HITS.with(|h| h.set(h.get() + 1)); | ||
| 6226 | + } | ||
| 6227 | + // lane-fiinter (merged on main for the square intra-in-inter arm): | ||
| 6228 | + // `read_filter_intra_mode_info` is the tail of | ||
| 6229 | + // `read_intra_block_mode_info`, after the palette syntax (refused whole | ||
| 6230 | + // above for this shape), and `av1_filter_intra_allowed_bsize` admits the | ||
| 6231 | + // 2:1 strips with both sides <= 32 -- their own CDF rows | ||
| 6232 | + // ([`filter_intra_size_class_rect`]). | ||
| 6233 | + let mut filter_intra = None; | ||
| 6234 | + if mode == DC_PRED | ||
| 6235 | + && ENABLE_FILTER_INTRA_INTER.with(std::cell::Cell::get) | ||
| 6236 | + && let Some(class) = filter_intra_size_class_rect(bw, bh) | ||
| 6237 | + && dec.symbol(&mut cdfs.filter_intra[class]) != 0 | ||
| 6238 | + { | ||
| 6239 | + FILTER_INTRA_HITS.with(|h| h.set(h.get() + 1)); | ||
| 6240 | + INTRA_IN_INTER_FILTER_INTRA_HITS.with(|h| h.set(h.get() + 1)); | ||
| 6241 | + filter_intra = Some(dec.symbol(&mut cdfs.filter_intra_mode)); | ||
| 6242 | + } | ||
| 6243 | + // The intra-edge filter type is the NEIGHBOUR's mode (libaom | ||
| 6244 | + // `get_filt_type`), luma's off the luma neighbours and chroma's off the | ||
| 6245 | + // chroma ones -- [`decode_block_rect`]'s own pair. | ||
| 6246 | + let (nb_above_mode, nb_left_mode) = neighbours.modes_above_left(r, c); | ||
| 6247 | + let smooth_neighbor = is_smooth_mode(nb_above_mode) || is_smooth_mode(nb_left_mode); | ||
| 6248 | + if smooth_neighbor { | ||
| 6249 | + SMOOTH_LUMA_HITS.with(|h| h.set(h.get() + 1)); | ||
| 6250 | + } | ||
| 6251 | + let smooth_neighbor_uv = neighbours.smooth_uv_neighbour(mi_r, mi_c, r, c); | ||
| 6252 | + let depth = if TX_SELECT_INTER.with(std::cell::Cell::get) { | ||
| 6253 | + let ctx = tx_size_context_rect(neighbours, (mi_r, mi_c), bw, bh); | ||
| 6254 | + match tx_cat { | ||
| 6255 | + 1 => dec.symbol(&mut cdfs.tx_size_cat1[ctx]), | ||
| 6256 | + 2 => dec.symbol(&mut cdfs.tx_size_cat2[ctx]), | ||
| 6257 | + _ => dec.symbol(&mut cdfs.tx_size_cat3[ctx]), | ||
| 6258 | + } | ||
| 6259 | + } else { | ||
| 6260 | + 0 | ||
| 6261 | + }; | ||
| 6262 | + if depth != 0 { | ||
| 6263 | + TX_DEPTH_HITS.with(|h| h.set(h.get() + 1)); | ||
| 6264 | + // merge b51719f+lane-intrarect (class merge-cross-product-defect): | ||
| 6265 | + // main's 10-bit `split_transform_intra_block` gate reaches this arm | ||
| 6266 | + // with a nonzero tx depth, and the split rect-TU walk mis-decodes it | ||
| 6267 | + // (2340 luma samples off at seed 51; refusing here restores that gate | ||
| 6268 | + // while the depth-0 strip the lane proved keeps decoding). The lane's | ||
| 6269 | + // own gate never exercised a split strip. | ||
| 6270 | + return Err(unsupported( | ||
| 6271 | + "a split (nonzero tx_depth) transform on an intra HORZ/VERT strip in an inter frame", | ||
| 6272 | + )); | ||
| 6273 | + } | ||
| 6274 | + let (tx_w, tx_h) = depth_to_tx_wh(bw, bh, depth); | ||
| 6275 | + let modes = RectStripModes { | ||
| 6276 | + skip, | ||
| 6277 | + mode, | ||
| 6278 | + angle_delta_y, | ||
| 6279 | + uv_predict_mode, | ||
| 6280 | + angle_delta_uv, | ||
| 6281 | + alpha, | ||
| 6282 | + filter_intra, | ||
| 6283 | + smooth_neighbor, | ||
| 6284 | + smooth_neighbor_uv, | ||
| 6285 | + // screen-content frames are refused whole above, so this strip can | ||
| 6286 | + // carry no palette. | ||
| 6287 | + palette_y: None, | ||
| 6288 | + palette_uv: None, | ||
| 6289 | + }; | ||
| 6290 | + decode_rect_split( | ||
| 6291 | + dec, | ||
| 6292 | + cdfs, | ||
| 6293 | + neighbours, | ||
| 6294 | + (mi_r, mi_c), | ||
| 6295 | + bw, | ||
| 6296 | + bh, | ||
| 6297 | + tx_w, | ||
| 6298 | + tx_h, | ||
| 6299 | + &modes, | ||
| 6300 | + y, | ||
| 6301 | + u, | ||
| 6302 | + v, | ||
| 6303 | + base_q_idx, | ||
| 6304 | + REDUCED_TX_SET_INTER.with(std::cell::Cell::get), | ||
| 6305 | + )?; | ||
| 6306 | + let class = match bw.max(bh) { | ||
| 6307 | + 64 => 0, | ||
| 6308 | + 32 => 1, | ||
| 6309 | + _ => 2, | ||
| 6310 | + }; | ||
| 6311 | + INTRA_RECT_IN_INTER_HITS.with(|h| { | ||
| 6312 | + let mut v = h.get(); | ||
| 6313 | + v[class] += 1; | ||
| 6314 | + h.set(v); | ||
| 6315 | + }); | ||
| 6316 | + Ok(()) | ||
| 6317 | +} | ||
| 6318 | + | ||
| 5900 | /// Decodes one true `bw`x`bh` `PARTITION_HORZ`/`PARTITION_VERT` intra strip | 6319 | /// Decodes one true `bw`x`bh` `PARTITION_HORZ`/`PARTITION_VERT` intra strip |
| 5901 | /// (lane-intradisp r1, spec `decode_block` restricted to a 32x32 quadrant's | 6320 | /// (lane-intradisp r1, spec `decode_block` restricted to a 32x32 quadrant's |
| 5902 | /// two rect children). Only the `skip` case is supported: `skip`/`y_mode`/ | 6321 | /// two rect children). Only the `skip` case is supported: `skip`/`y_mode`/ |
| @@ -5936,6 +6355,7 @@ fn decode_block_rect( | |||
| 5936 | nb_above_mode, | 6355 | nb_above_mode, |
| 5937 | nb_left_mode, | 6356 | nb_left_mode, |
| 5938 | true, | 6357 | true, |
| 6358 | + true, | ||
| 5939 | bw, | 6359 | bw, |
| 5940 | bh, | 6360 | bh, |
| 5941 | enable_filter_intra, | 6361 | enable_filter_intra, |
| @@ -6410,6 +6830,7 @@ fn decode_leaf_rect( | |||
| 6410 | above_mode, | 6830 | above_mode, |
| 6411 | left_mode, | 6831 | left_mode, |
| 6412 | true, | 6832 | true, |
| 6833 | + true, | ||
| 6413 | bw, | 6834 | bw, |
| 6414 | bh, | 6835 | bh, |
| 6415 | enable_filter_intra, | 6836 | enable_filter_intra, |
| @@ -6689,6 +7110,7 @@ fn decode_block_rect4( | |||
| 6689 | above_mode, | 7110 | above_mode, |
| 6690 | left_mode, | 7111 | left_mode, |
| 6691 | true, | 7112 | true, |
| 7113 | + true, | ||
| 6692 | bw, | 7114 | bw, |
| 6693 | bh, | 7115 | bh, |
| 6694 | enable_filter_intra, | 7116 | enable_filter_intra, |
| @@ -6990,6 +7412,434 @@ fn decode_block_rect4( | |||
| 6990 | Ok((mode, uv_predict_mode)) | 7412 | Ok((mode, uv_predict_mode)) |
| 6991 | } | 7413 | } |
| 6992 | 7414 | ||
| 7415 | +/// Decodes the four 16x4 / 4x16 strips of a 16x16-level `PARTITION_HORZ_4` / | ||
| 7416 | +/// `PARTITION_VERT_4` (lane-r14) -- [`decode_block_rect4`]'s pair one level | ||
| 7417 | +/// down, and the first shape here whose luma block is a single mi row (or | ||
| 7418 | +/// column). | ||
| 7419 | +/// | ||
| 7420 | +/// What is new at this size is CHROMA. `is_chroma_reference` | ||
| 7421 | +/// (`av1_common_int.h`) is false for a 4:2:0 block one mi tall (wide) on an | ||
| 7422 | +/// EVEN mi row (column), so strips 0 and 2 read no `uv_mode`/`cfl_alpha`/ | ||
| 7423 | +/// `angle_delta_uv` at all and code no chroma residual; strips 1 and 3 close | ||
| 7424 | +/// the pair and carry the chroma of the whole 16x8 (8x16) luma pair -- | ||
| 7425 | +/// `setup_pred_plane`'s own `if (subsampling_y && (mi_row & 1) && | ||
| 7426 | +/// mi_size_high[bsize] == 1) mi_row -= 1` offset, i.e. an 8x4 (4x8) chroma | ||
| 7427 | +/// transform at the PAIR's origin, with CfL averaging over the pair's luma. | ||
| 7428 | +/// | ||
| 7429 | +/// Tables: LUMA `TX_16X4`/`TX_4X16` averages to the 8x8 entropy context | ||
| 7430 | +/// ((0 + 2 + 1) >> 1 = 1) with 64 coded positions, so its CDF set is | ||
| 7431 | +/// [`TxbSet::LumaRect16x4`] (`Luma8`'s tables, the `TX_4X4` `tx_type` row); | ||
| 7432 | +/// scans are [`SCAN_16X4`]/[`SCAN_4X16`]. CHROMA `TX_8X4`/`TX_4X8` is | ||
| 7433 | +/// [`TxbSet::ChromaRect8x4`] with [`SCAN_8X4`]/[`SCAN_4X8`]. Angle deltas ARE | ||
| 7434 | +/// coded (`av1_use_angle_delta` compares the BLOCK_SIZES_ALL enum index, and | ||
| 7435 | +/// BLOCK_16X4 is 17), and so is `use_filter_intra` (both sides <= 32) off this | ||
| 7436 | +/// shape's own CDF row. | ||
| 7437 | +/// | ||
| 7438 | +/// A split transform (`tx_depth != 0`, `sub_tx_size_map[TX_16X4] == TX_8X4`) | ||
| 7439 | +/// refuses by name rather than guess-decode. | ||
| 7440 | +#[allow(clippy::too_many_arguments)] | ||
| 7441 | +fn decode_rect4_16( | ||
| 7442 | + dec: &mut SymbolDecoder, | ||
| 7443 | + cdfs: &mut Cdfs, | ||
| 7444 | + neighbours: &mut Neighbours, | ||
| 7445 | + at16: (usize, usize), | ||
| 7446 | + horz: bool, | ||
| 7447 | + y: &mut PlaneBuf, | ||
| 7448 | + u: &mut PlaneBuf, | ||
| 7449 | + v: &mut PlaneBuf, | ||
| 7450 | + enable_filter_intra: bool, | ||
| 7451 | + allow_screen_content_tools: bool, | ||
| 7452 | + base_q_idx: u8, | ||
| 7453 | + tx_select: bool, | ||
| 7454 | + reduced_tx_set: bool, | ||
| 7455 | +) -> Result<()> { | ||
| 7456 | + let (r, c) = at16; | ||
| 7457 | + let (mi_row0, mi_col0) = (r * (SUB / MI), c * (SUB / MI)); | ||
| 7458 | + let (bw, bh) = if horz { (16, 4) } else { (4, 16) }; | ||
| 7459 | + let (mi_w, mi_h) = (bw / MI, bh / MI); | ||
| 7460 | + let scan: &[u16] = if horz { &SCAN_16X4 } else { &SCAN_4X16 }; | ||
| 7461 | + let chroma_scan: &[u16] = if horz { &SCAN_8X4 } else { &SCAN_4X8 }; | ||
| 7462 | + let mut prev: Option<((usize, usize), usize)> = None; | ||
| 7463 | + let mut last_mode = DC_PRED; | ||
| 7464 | + let mut last_uv_mode = DC_PRED; | ||
| 7465 | + for i in 0..4usize { | ||
| 7466 | + let lmi = if horz { | ||
| 7467 | + (mi_row0 + i, mi_col0) | ||
| 7468 | + } else { | ||
| 7469 | + (mi_row0, mi_col0 + i) | ||
| 7470 | + }; | ||
| 7471 | + let has_chroma = i % 2 == 1; | ||
| 7472 | + // `decode_block_rect4`'s own neighbour rule: the coarse 16-px cell | ||
| 7473 | + // aliases all four strips onto one entry, so the mi-exact map wins and | ||
| 7474 | + // the previous strip stands in on the split axis. | ||
| 7475 | + let mut above_mode = neighbours.above_mode[c]; | ||
| 7476 | + let mut left_mode = neighbours.left_mode[r]; | ||
| 7477 | + if let Some(((pr, pc), pmode)) = prev { | ||
| 7478 | + if pc == lmi.1 && lmi.0 == pr + mi_h { | ||
| 7479 | + above_mode = pmode; | ||
| 7480 | + } else if pr == lmi.0 && lmi.1 == pc + mi_w { | ||
| 7481 | + left_mode = pmode; | ||
| 7482 | + } | ||
| 7483 | + } | ||
| 7484 | + let (above_mode, left_mode) = | ||
| 7485 | + neighbours.modes_above_left_mi(lmi.0, lmi.1, (above_mode, left_mode)); | ||
| 7486 | + let ( | ||
| 7487 | + skip, | ||
| 7488 | + mode, | ||
| 7489 | + angle_delta_y, | ||
| 7490 | + uv_mode, | ||
| 7491 | + angle_delta_uv, | ||
| 7492 | + alpha, | ||
| 7493 | + filter_intra, | ||
| 7494 | + palette_y, | ||
| 7495 | + palette_uv, | ||
| 7496 | + ) = read_intra_mode_rect( | ||
| 7497 | + dec, | ||
| 7498 | + cdfs, | ||
| 7499 | + above_mode, | ||
| 7500 | + left_mode, | ||
| 7501 | + true, | ||
| 7502 | + has_chroma, | ||
| 7503 | + bw, | ||
| 7504 | + bh, | ||
| 7505 | + enable_filter_intra, | ||
| 7506 | + neighbours.skip_txfm_ctx(lmi.0, lmi.1), | ||
| 7507 | + allow_screen_content_tools, | ||
| 7508 | + None, | ||
| 7509 | + &[], | ||
| 7510 | + lmi.0, | ||
| 7511 | + lmi.1, | ||
| 7512 | + )?; | ||
| 7513 | + if palette_y.is_some() || palette_uv.is_some() { | ||
| 7514 | + return Err(unsupported( | ||
| 7515 | + "a 1:4 rect strip that actually uses a palette (reconstruction is not ported at this shape)", | ||
| 7516 | + )); | ||
| 7517 | + } | ||
| 7518 | + let smooth_neighbor = is_smooth_mode(above_mode) || is_smooth_mode(left_mode); | ||
| 7519 | + if smooth_neighbor { | ||
| 7520 | + SMOOTH_LUMA_HITS.with(|h| h.set(h.get() + 1)); | ||
| 7521 | + } | ||
| 7522 | + if filter_intra.is_some() { | ||
| 7523 | + FILTER_INTRA_RECT_HITS.with(|h| h.set(h.get() + 1)); | ||
| 7524 | + } | ||
| 7525 | + // `bsize_to_tx_size_cat(BLOCK_16X4)`: `max_txsize_rect_lookup` is | ||
| 7526 | + // TX_16X4 and `sub_tx_size_map` reaches TX_4X4 in two steps, so the | ||
| 7527 | + // depth symbol is the 3-symbol `tx_size_cat1` -- not the 2-symbol | ||
| 7528 | + // `cat0` a 4x8 leaf reads nor the `cat2` a 32x8 strip does. | ||
| 7529 | + let depth = if tx_select { | ||
| 7530 | + let ctx = tx_size_context_rect(neighbours, lmi, bw, bh); | ||
| 7531 | + dec.symbol(&mut cdfs.tx_size_cat1[ctx]) | ||
| 7532 | + } else { | ||
| 7533 | + 0 | ||
| 7534 | + }; | ||
| 7535 | + if depth != 0 { | ||
| 7536 | + TX_DEPTH_HITS.with(|h| h.set(h.get() + 1)); | ||
| 7537 | + RECT4_16_SPLIT_HITS.with(|h| h.set(h.get() + 1)); | ||
| 7538 | + } | ||
| 7539 | + let (tx_w, tx_h) = depth_to_tx_wh(bw, bh, depth); | ||
| 7540 | + let (px, py) = (lmi.1 * MI, lmi.0 * MI); | ||
| 7541 | + let reach = Reach::of_rect(bw, bh, px, py, y.width, y.height); | ||
| 7542 | + neighbours.record_mode_mi(lmi.0, lmi.1, mi_w, mi_h, mode); | ||
| 7543 | + if depth != 0 { | ||
| 7544 | + // [`decode_rect_split`]'s per-unit walk, inlined because the | ||
| 7545 | + // CHROMA of this shape belongs to the strip's 4:2:0 pair, not to | ||
| 7546 | + // the strip (that function codes one chroma transform per block). | ||
| 7547 | + // depth 1 is the 2:1 rect unit TX_8X4/TX_4X8 | ||
| 7548 | + // (`sub_tx_size_map[TX_16X4]`), depth 2 the square TX_4X4; each | ||
| 7549 | + // unit predicts off the units before it in raster order. | ||
| 7550 | + let rect_unit = tx_w != tx_h; | ||
| 7551 | + let zero_tu = vec![0i32; tx_w * tx_h]; | ||
| 7552 | + for tu_row in 0..bh / tx_h { | ||
| 7553 | + for tu_col in 0..bw / tx_w { | ||
| 7554 | + let tu_mi = (lmi.0 + tu_row * (tx_h / MI), lmi.1 + tu_col * (tx_w / MI)); | ||
| 7555 | + let (tu_px, tu_py) = (px + tu_col * tx_w, py + tu_row * tx_h); | ||
| 7556 | + let tu_reach = Reach::of_tu( | ||
| 7557 | + bw, | ||
| 7558 | + bh, | ||
| 7559 | + tu_col * tx_w, | ||
| 7560 | + tu_row * tx_h, | ||
| 7561 | + tx_w, | ||
| 7562 | + tx_h, | ||
| 7563 | + reach, | ||
| 7564 | + ); | ||
| 7565 | + if skip { | ||
| 7566 | + y.reconstruct_rect( | ||
| 7567 | + tu_px, tu_py, tx_w, tx_h, mode, angle_delta_y, tu_reach, &zero_tu, | ||
| 7568 | + None, filter_intra, smooth_neighbor, | ||
| 7569 | + ); | ||
| 7570 | + neighbours.record_mi_luma_rect(tu_mi, tx_w, tx_h, &zero_tu); | ||
| 7571 | + } else if rect_unit { | ||
| 7572 | + // `get_txsize_entropy_ctx(TX_8X4)` is the 8x8 class with | ||
| 7573 | + // 32 coded positions and the `TX_4X4` `tx_type` row: | ||
| 7574 | + // exactly [`TxbSet::LumaRect4x8`]. | ||
| 7575 | + let tu_around = neighbours.around_mi_rect(tu_mi, tx_w, tx_h)[0]; | ||
| 7576 | + let tu_skip_ctx = | ||
| 7577 | + neighbours.luma_skip_ctx_rect(tu_mi, tx_w / MI, tx_h / MI); | ||
| 7578 | + let set = if reduced_tx_set { | ||
| 7579 | + TxbSet::LumaRect4x8 | ||
| 7580 | + } else { | ||
| 7581 | + TxbSet::LumaRect4x8Set1 | ||
| 7582 | + }; | ||
| 7583 | + let tu_scan: &[u16] = if tx_w > tx_h { &SCAN_8X4 } else { &SCAN_4X8 }; | ||
| 7584 | + let mut coding = cdfs.txb(set, fi_tx_row(mode, filter_intra)); | ||
| 7585 | + let (tu_grid, tu_tx_type) = read_coeffs_rect( | ||
| 7586 | + dec, | ||
| 7587 | + &mut coding, | ||
| 7588 | + tu_scan, | ||
| 7589 | + tx_w, | ||
| 7590 | + tx_h, | ||
| 7591 | + tu_skip_ctx, | ||
| 7592 | + dc_sign_ctx(tu_around.2), | ||
| 7593 | + TxType::DctDct, | ||
| 7594 | + )?; | ||
| 7595 | + let residual = dequant_and_inverse_typed_wh( | ||
| 7596 | + &tu_grid, | ||
| 7597 | + tx_w, | ||
| 7598 | + tx_h, | ||
| 7599 | + crate::decode::bit_depth(), | ||
| 7600 | + block_q_idx(), | ||
| 7601 | + plane_q_delta(0).0, | ||
| 7602 | + plane_q_delta(0).1, | ||
| 7603 | + tu_tx_type, | ||
| 7604 | + ); | ||
| 7605 | + y.reconstruct_rect( | ||
| 7606 | + tu_px, tu_py, tx_w, tx_h, mode, angle_delta_y, tu_reach, &residual, | ||
| 7607 | + None, filter_intra, smooth_neighbor, | ||
| 7608 | + ); | ||
| 7609 | + if tu_grid.iter().any(|&l| l != 0) { | ||
| 7610 | + RECT4_16_COEFF_HITS.with(|h| h.set(h.get() + 1)); | ||
| 7611 | + } | ||
| 7612 | + neighbours.record_mi_luma_rect(tu_mi, tx_w, tx_h, &tu_grid); | ||
| 7613 | + } else { | ||
| 7614 | + let tu_around = neighbours.around_mi(tu_mi, tx_w)[0]; | ||
| 7615 | + let tu_skip_ctx = neighbours.luma_skip_ctx(tu_mi, tx_w / MI); | ||
| 7616 | + let tu_grid = read_plane( | ||
| 7617 | + dec, | ||
| 7618 | + cdfs, | ||
| 7619 | + txbset_for(tx_w, reduced_tx_set), | ||
| 7620 | + &default_scan(tx_w), | ||
| 7621 | + 0, | ||
| 7622 | + tu_around, | ||
| 7623 | + mode, | ||
| 7624 | + mode, | ||
| 7625 | + angle_delta_y, | ||
| 7626 | + tu_reach, | ||
| 7627 | + y, | ||
| 7628 | + tu_px, | ||
| 7629 | + tu_py, | ||
| 7630 | + tx_w, | ||
| 7631 | + tx_w, | ||
| 7632 | + base_q_idx, | ||
| 7633 | + None, | ||
| 7634 | + filter_intra, | ||
| 7635 | + Some(tu_skip_ctx), | ||
| 7636 | + smooth_neighbor, | ||
| 7637 | + )?; | ||
| 7638 | + if tu_grid.iter().any(|&l| l != 0) { | ||
| 7639 | + RECT4_16_COEFF_HITS.with(|h| h.set(h.get() + 1)); | ||
| 7640 | + } | ||
| 7641 | + neighbours.record_mi_luma(tu_mi, tx_w, &tu_grid); | ||
| 7642 | + } | ||
| 7643 | + } | ||
| 7644 | + } | ||
| 7645 | + } else { | ||
| 7646 | + let levels = if skip { | ||
| 7647 | + let zeros = vec![0i32; bw * bh]; | ||
| 7648 | + y.reconstruct_rect( | ||
| 7649 | + px, py, bw, bh, mode, angle_delta_y, reach, &zeros, None, filter_intra, | ||
| 7650 | + smooth_neighbor, | ||
| 7651 | + ); | ||
| 7652 | + zeros | ||
| 7653 | + } else { | ||
| 7654 | + // The strip's luma TU *is* the strip (`plane_bsize == | ||
| 7655 | + // txsize_to_bsize[tx_size]`), so `get_txb_ctx` fixes | ||
| 7656 | + // `txb_skip_ctx` at 0. | ||
| 7657 | + let around = neighbours.around_mi_rect(lmi, bw, bh)[0]; | ||
| 7658 | + let set = if reduced_tx_set { | ||
| 7659 | + TxbSet::LumaRect16x4 | ||
| 7660 | + } else { | ||
| 7661 | + TxbSet::LumaRect16x4Set1 | ||
| 7662 | + }; | ||
| 7663 | + let mut coding = cdfs.txb(set, fi_tx_row(mode, filter_intra)); | ||
| 7664 | + let (levels, tx_type) = read_coeffs_rect( | ||
| 7665 | + dec, | ||
| 7666 | + &mut coding, | ||
| 7667 | + scan, | ||
| 7668 | + bw, | ||
| 7669 | + bh, | ||
| 7670 | + 0, | ||
| 7671 | + dc_sign_ctx(around.2), | ||
| 7672 | + TxType::DctDct, | ||
| 7673 | + )?; | ||
| 7674 | + let residual = dequant_and_inverse_typed_wh( | ||
| 7675 | + &levels, | ||
| 7676 | + bw, | ||
| 7677 | + bh, | ||
| 7678 | + crate::decode::bit_depth(), | ||
| 7679 | + block_q_idx(), | ||
| 7680 | + plane_q_delta(0).0, | ||
| 7681 | + plane_q_delta(0).1, | ||
| 7682 | + tx_type, | ||
| 7683 | + ); | ||
| 7684 | + y.reconstruct_rect( | ||
| 7685 | + px, py, bw, bh, mode, angle_delta_y, reach, &residual, None, filter_intra, | ||
| 7686 | + smooth_neighbor, | ||
| 7687 | + ); | ||
| 7688 | + RECT4_16_COEFF_HITS.with(|h| h.set(h.get() + 1)); | ||
| 7689 | + levels | ||
| 7690 | + }; | ||
| 7691 | + neighbours.record_mi_luma_rect(lmi, bw, bh, &levels); | ||
| 7692 | + } | ||
| 7693 | + neighbours.fill_skip_grid_rect(lmi, mi_w, mi_h, skip); | ||
| 7694 | + neighbours.fill_lf_grid_rect(lmi, mi_w, mi_h, tx_w as u8, tx_h as u8, 0); | ||
| 7695 | + // `update_partition_context` writes `partition_context_lookup[ | ||
| 7696 | + // BLOCK_16X4]` over the whole 16x16: full width above, a 4-px side on | ||
| 7697 | + // the left (mirrored under VERT_4). | ||
| 7698 | + for cell in 0..mi_w { | ||
| 7699 | + if let Some(slot) = neighbours.above_side_mi.get_mut(lmi.1 + cell) { | ||
| 7700 | + *slot = bw; | ||
| 7701 | + } | ||
| 7702 | + } | ||
| 7703 | + for cell in 0..mi_h { | ||
| 7704 | + if let Some(slot) = neighbours.left_side_mi.get_mut(lmi.0 + cell) { | ||
| 7705 | + *slot = bh; | ||
| 7706 | + } | ||
| 7707 | + } | ||
| 7708 | + if has_chroma { | ||
| 7709 | + RECT4_16_CHROMA_HITS.with(|h| h.set(h.get() + 1)); | ||
| 7710 | + let pair_mi = if horz { | ||
| 7711 | + (lmi.0 - 1, lmi.1) | ||
| 7712 | + } else { | ||
| 7713 | + (lmi.0, lmi.1 - 1) | ||
| 7714 | + }; | ||
| 7715 | + let (pw, ph) = if horz { (16, 8) } else { (8, 16) }; | ||
| 7716 | + let (ppx, ppy) = (pair_mi.1 * MI, pair_mi.0 * MI); | ||
| 7717 | + let (cpx, cpy) = (ppx / 2, ppy / 2); | ||
| 7718 | + let (cw, ch) = (pw / 2, ph / 2); | ||
| 7719 | + let uv_predict_mode = if uv_mode == UV_CFL_PRED { DC_PRED } else { uv_mode }; | ||
| 7720 | + let pair_reach = Reach::of_rect(pw, ph, ppx, ppy, y.width, y.height); | ||
| 7721 | + let smooth_neighbor_uv = neighbours.smooth_uv_neighbour(lmi.0, lmi.1, r, c); | ||
| 7722 | + let (u_levels, v_levels) = if skip { | ||
| 7723 | + let zeros = vec![0i32; cw * ch]; | ||
| 7724 | + for (buf, _plane) in [(&mut *u, 1usize), (&mut *v, 2)] { | ||
| 7725 | + buf.reconstruct_rect( | ||
| 7726 | + cpx, | ||
| 7727 | + cpy, | ||
| 7728 | + cw, | ||
| 7729 | + ch, | ||
| 7730 | + uv_predict_mode, | ||
| 7731 | + angle_delta_uv, | ||
| 7732 | + pair_reach, | ||
| 7733 | + &zeros, | ||
| 7734 | + None, | ||
| 7735 | + None, | ||
| 7736 | + smooth_neighbor_uv, | ||
| 7737 | + ); | ||
| 7738 | + } | ||
| 7739 | + (zeros.clone(), zeros) | ||
| 7740 | + } else { | ||
| 7741 | + let around = neighbours.around_mi_rect(pair_mi, pw, ph); | ||
| 7742 | + let mut planes = Vec::with_capacity(2); | ||
| 7743 | + for plane in 1..3 { | ||
| 7744 | + let default_tx = default_intra_tx_type(uv_predict_mode as u8); | ||
| 7745 | + let skip_ctx = usize::from(around[plane].0) + usize::from(around[plane].1); | ||
| 7746 | + let mut coding = cdfs.txb(TxbSet::ChromaRect8x4, uv_predict_mode); | ||
| 7747 | + let (levels, tx_type) = read_coeffs_rect( | ||
| 7748 | + dec, | ||
| 7749 | + &mut coding, | ||
| 7750 | + chroma_scan, | ||
| 7751 | + cw, | ||
| 7752 | + ch, | ||
| 7753 | + skip_ctx, | ||
| 7754 | + dc_sign_ctx(around[plane].2), | ||
| 7755 | + default_tx, | ||
| 7756 | + )?; | ||
| 7757 | + planes.push((levels, tx_type)); | ||
| 7758 | + } | ||
| 7759 | + let (v_levels, v_tx_type) = planes.pop().expect("plane 2"); | ||
| 7760 | + let (u_levels, u_tx_type) = planes.pop().expect("plane 1"); | ||
| 7761 | + // CfL averages the luma of the WHOLE pair, the region this one | ||
| 7762 | + // chroma transform covers. | ||
| 7763 | + let ac = alpha.map(|_| cfl_ac_q3_rect(y, ppx, ppy, pw, ph)); | ||
| 7764 | + for (plane, buf, levels, tx_type) in [ | ||
| 7765 | + (1usize, &mut *u, &u_levels, u_tx_type), | ||
| 7766 | + (2, &mut *v, &v_levels, v_tx_type), | ||
| 7767 | + ] { | ||
| 7768 | + let residual = dequant_and_inverse_typed_wh( | ||
| 7769 | + levels, | ||
| 7770 | + cw, | ||
| 7771 | + ch, | ||
| 7772 | + crate::decode::bit_depth(), | ||
| 7773 | + block_q_idx(), | ||
| 7774 | + plane_q_delta(plane).0, | ||
| 7775 | + plane_q_delta(plane).1, | ||
| 7776 | + tx_type, | ||
| 7777 | + ); | ||
| 7778 | + buf.reconstruct_rect( | ||
| 7779 | + cpx, | ||
| 7780 | + cpy, | ||
| 7781 | + cw, | ||
| 7782 | + ch, | ||
| 7783 | + uv_predict_mode, | ||
| 7784 | + angle_delta_uv, | ||
| 7785 | + pair_reach, | ||
| 7786 | + &residual, | ||
| 7787 | + alpha | ||
| 7788 | + .zip(ac.as_deref()) | ||
| 7789 | + .map(|((au, av), ac)| (if plane == 1 { au } else { av }, ac)), | ||
| 7790 | + None, | ||
| 7791 | + smooth_neighbor_uv, | ||
| 7792 | + ); | ||
| 7793 | + } | ||
| 7794 | + (u_levels, v_levels) | ||
| 7795 | + }; | ||
| 7796 | + neighbours.record_uv_mode_mi(pair_mi.0, pair_mi.1, pw / MI, ph / MI, uv_predict_mode); | ||
| 7797 | + // The chroma planes' coefficient context, over the PAIR's mi span | ||
| 7798 | + // (`decode_leaf_rect8`'s own rule: a subsampled plane's bound is | ||
| 7799 | + // the luma one rounded up to its 4x4 unit). | ||
| 7800 | + let u_state = neighbour_state(&u_levels); | ||
| 7801 | + let v_state = neighbour_state(&v_levels); | ||
| 7802 | + let round_up_even = |n: usize| n.div_ceil(2) * 2; | ||
| 7803 | + let bound_h = round_up_even(neighbours.mi_rows); | ||
| 7804 | + let bound_w = round_up_even(neighbours.mi_cols); | ||
| 7805 | + for cell in 0..(ph / MI) { | ||
| 7806 | + if pair_mi.0 + cell < bound_h | ||
| 7807 | + && let Some(slot) = neighbours.left.get_mut(pair_mi.0 + cell) | ||
| 7808 | + { | ||
| 7809 | + slot[1] = u_state; | ||
| 7810 | + slot[2] = v_state; | ||
| 7811 | + } | ||
| 7812 | + } | ||
| 7813 | + for cell in 0..(pw / MI) { | ||
| 7814 | + if pair_mi.1 + cell < bound_w | ||
| 7815 | + && let Some(slot) = neighbours.above.get_mut(pair_mi.1 + cell) | ||
| 7816 | + { | ||
| 7817 | + slot[1] = u_state; | ||
| 7818 | + slot[2] = v_state; | ||
| 7819 | + } | ||
| 7820 | + } | ||
| 7821 | + last_uv_mode = uv_predict_mode; | ||
| 7822 | + } | ||
| 7823 | + if horz { | ||
| 7824 | + RECT4_16_HORZ_HITS.with(|h| h.set(h.get() + 1)); | ||
| 7825 | + } else { | ||
| 7826 | + RECT4_16_VERT_HITS.with(|h| h.set(h.get() + 1)); | ||
| 7827 | + } | ||
| 7828 | + last_mode = mode; | ||
| 7829 | + prev = Some((lmi, mode)); | ||
| 7830 | + } | ||
| 7831 | + // The coarse 16-px cell holds one entry for the whole 16x16: the last | ||
| 7832 | + // strip is what a block below (right) sees through it, the mi-exact maps | ||
| 7833 | + // above answering everything finer. | ||
| 7834 | + neighbours.above_mode[c] = last_mode; | ||
| 7835 | + neighbours.left_mode[r] = last_mode; | ||
| 7836 | + neighbours.above_uv_mode[c] = last_uv_mode; | ||
| 7837 | + neighbours.left_uv_mode[r] = last_uv_mode; | ||
| 7838 | + neighbours.above_side[c] = bw; | ||
| 7839 | + neighbours.left_side[r] = bh; | ||
| 7840 | + Ok(()) | ||
| 7841 | +} | ||
| 7842 | + | ||
| 6993 | /// Decodes one true `bw`x`bh` superblock-level `PARTITION_HORZ`/ | 7843 | /// Decodes one true `bw`x`bh` superblock-level `PARTITION_HORZ`/ |
| 6994 | /// `PARTITION_VERT` strip (lane-sbpart r2, `bw, bh` one of `(64, 32)` / | 7844 | /// `PARTITION_VERT` strip (lane-sbpart r2, `bw, bh` one of `(64, 32)` / |
| 6995 | /// `(32, 64)` -- [`decode_block_rect`]'s own sibling one level up). Unlike | 7845 | /// `(32, 64)` -- [`decode_block_rect`]'s own sibling one level up). Unlike |
| @@ -7043,6 +7893,7 @@ fn decode_block_rect64( | |||
| 7043 | // the real 13-symbol `uv_mode_no_cfl` one and desynced the tile | 7893 | // the real 13-symbol `uv_mode_no_cfl` one and desynced the tile |
| 7044 | // from this block's very first symbol (lane-sbpart r3 bisect). | 7894 | // from this block's very first symbol (lane-sbpart r3 bisect). |
| 7045 | false, | 7895 | false, |
| 7896 | + true, | ||
| 7046 | bw, | 7897 | bw, |
| 7047 | bh, | 7898 | bh, |
| 7048 | enable_filter_intra, | 7899 | enable_filter_intra, |
| @@ -7902,6 +8753,26 @@ fn cfl_scaled(alpha_q3: i32, ac_q3: i32) -> i32 { | |||
| 7902 | /// [`crate::intra::predict`] instead of hand-rolling `DC_PRED` alone. | 8753 | /// [`crate::intra::predict`] instead of hand-rolling `DC_PRED` alone. |
| 7903 | /// lane-tiny r4: raw padded-plane dump for filter-stage bisection, written | 8754 | /// lane-tiny r4: raw padded-plane dump for filter-stage bisection, written |
| 7904 | /// only when `var` names a path. Same byte shape as `EC_AV1_PREFILT_DUMP`. | 8755 | /// only when `var` names a path. Same byte shape as `EC_AV1_PREFILT_DUMP`. |
| 8756 | +/// lane-hgkf r2: 16-bit cropped stage dump, the high-bitdepth twin of | ||
| 8757 | +/// [`dump_stage`] (whose `as u8` truncation hides |delta| <= 2 defects) -- | ||
| 8758 | +/// matches aomdec's own `ec_dump16` rung byte for byte (crop dims, u16 LE). | ||
| 8759 | +fn dump_stage16(var: &str, y: &PlaneBuf, u: &PlaneBuf, v: &PlaneBuf, fw: usize, fh: usize) { | ||
| 8760 | + use std::io::Write; | ||
| 8761 | + if let Ok(path) = std::env::var(var) | ||
| 8762 | + && let Ok(mut f) = std::fs::File::create(format!("{path}.f0")) | ||
| 8763 | + { | ||
| 8764 | + for (p, w, h) in [(y, fw, fh), (u, fw.div_ceil(2), fh.div_ceil(2)), (v, fw.div_ceil(2), fh.div_ceil(2))] { | ||
| 8765 | + for row in 0..h { | ||
| 8766 | + let mut bytes = Vec::with_capacity(w * 2); | ||
| 8767 | + for &s in &p.data[row * p.width..][..w] { | ||
| 8768 | + bytes.extend_from_slice(&s.to_le_bytes()); | ||
| 8769 | + } | ||
| 8770 | + let _ = f.write_all(&bytes); | ||
| 8771 | + } | ||
| 8772 | + } | ||
| 8773 | + } | ||
| 8774 | +} | ||
| 8775 | + | ||
| 7905 | fn dump_stage(var: &str, y: &PlaneBuf, u: &PlaneBuf, v: &PlaneBuf) { | 8776 | fn dump_stage(var: &str, y: &PlaneBuf, u: &PlaneBuf, v: &PlaneBuf) { |
| 7906 | use std::io::Write; | 8777 | use std::io::Write; |
| 7907 | if let Ok(path) = std::env::var(var) | 8778 | if let Ok(path) = std::env::var(var) |
| @@ -8047,6 +8918,7 @@ impl PlaneBuf { | |||
| 8047 | /// via [`Self::edges_rect`] and [`crate::intra::predict`]'s own | 8918 | /// via [`Self::edges_rect`] and [`crate::intra::predict`]'s own |
| 8048 | /// already-rect-capable `(bw, bh)` pair. | 8919 | /// already-rect-capable `(bw, bh)` pair. |
| 8049 | #[allow(clippy::too_many_arguments)] | 8920 | #[allow(clippy::too_many_arguments)] |
| 8921 | + #[track_caller] | ||
| 8050 | fn reconstruct_rect( | 8922 | fn reconstruct_rect( |
| 8051 | &mut self, | 8923 | &mut self, |
| 8052 | x: usize, | 8924 | x: usize, |
| @@ -8105,6 +8977,16 @@ impl PlaneBuf { | |||
| 8105 | } | 8977 | } |
| 8106 | prediction | 8978 | prediction |
| 8107 | }; | 8979 | }; |
| 8980 | + // lane-hgkf r2: per-TU prediction trace, the twin of aomdec's | ||
| 8981 | + // EC_PRED/EC_PREDND rungs (x/y are this plane's pixel origin). | ||
| 8982 | + if std::env::var_os("EC_PRED").is_some() { | ||
| 8983 | + let sum: i64 = prediction.iter().map(|&v| i64::from(v)).sum(); | ||
| 8984 | + let row0: Vec<u16> = prediction[..bw.min(8)].to_vec(); | ||
| 8985 | + let col0: Vec<u16> = (0..bh.min(8)).map(|r| prediction[r * bw]).collect(); | ||
| 8986 | + eprintln!( | ||
| 8987 | + "@{} OUR_PRED x={x} y={y} bw={bw} bh={bh} mode={mode} ad={angle_delta} sum={sum} row0={row0:?} col0={col0:?}", std::panic::Location::caller() | ||
| 8988 | + ); | ||
| 8989 | + } | ||
| 8108 | for row in 0..bh { | 8990 | for row in 0..bh { |
| 8109 | for col in 0..bw { | 8991 | for col in 0..bw { |
| 8110 | let idx = row * bw + col; | 8992 | let idx = row * bw + col; |
| @@ -8124,6 +9006,7 @@ impl PlaneBuf { | |||
| 8124 | /// nudges the prediction by [`cfl_scaled`]'s per-sample amount before the | 9006 | /// nudges the prediction by [`cfl_scaled`]'s per-sample amount before the |
| 8125 | /// residual is added — `av1_cfl_predict_block`'s own clip-then-add-residual | 9007 | /// residual is added — `av1_cfl_predict_block`'s own clip-then-add-residual |
| 8126 | /// order (cfl.c). | 9008 | /// order (cfl.c). |
| 9009 | + #[track_caller] | ||
| 8127 | fn reconstruct( | 9010 | fn reconstruct( |
| 8128 | &mut self, | 9011 | &mut self, |
| 8129 | x: usize, | 9012 | x: usize, |
| @@ -8187,6 +9070,16 @@ impl PlaneBuf { | |||
| 8187 | } | 9070 | } |
| 8188 | prediction | 9071 | prediction |
| 8189 | }; | 9072 | }; |
| 9073 | + // lane-hgkf r2: per-TU prediction trace, the twin of aomdec's | ||
| 9074 | + // EC_PRED/EC_PREDND rungs (x/y are this plane's pixel origin). | ||
| 9075 | + if std::env::var_os("EC_PRED").is_some() { | ||
| 9076 | + let sum: i64 = prediction.iter().map(|&v| i64::from(v)).sum(); | ||
| 9077 | + let row0: Vec<u16> = prediction[..side.min(8)].to_vec(); | ||
| 9078 | + let col0: Vec<u16> = (0..side.min(8)).map(|r| prediction[r * side]).collect(); | ||
| 9079 | + eprintln!( | ||
| 9080 | + "@{} OUR_PRED x={x} y={y} side={side} side={side} mode={mode} ad={angle_delta} sum={sum} row0={row0:?} col0={col0:?}", std::panic::Location::caller() | ||
| 9081 | + ); | ||
| 9082 | + } | ||
| 8190 | for row in 0..side { | 9083 | for row in 0..side { |
| 8191 | for col in 0..side { | 9084 | for col in 0..side { |
| 8192 | let idx = row * side + col; | 9085 | let idx = row * side + col; |
| @@ -8518,18 +9411,69 @@ fn decode_block( | |||
| 8518 | if skip { | 9411 | if skip { |
| 8519 | // A skipped block codes no residual syntax at all (spec 5.11.34): | 9412 | // A skipped block codes no residual syntax at all (spec 5.11.34): |
| 8520 | // straight prediction, on every plane. | 9413 | // straight prediction, on every plane. |
| 8521 | - y.reconstruct( | 9414 | + // |
| 8522 | - px, | 9415 | + // lane-hgkf r2: an intra block's `tx_depth` is read whether or not it |
| 8523 | - py, | 9416 | + // is skipped (only an INTER skip forces the largest transform), and |
| 8524 | - side, | 9417 | + // spec 7.11.2 / libaom `predict_and_reconstruct_intra_block` predicts |
| 8525 | - mode, | 9418 | + // ONE TRANSFORM UNIT AT A TIME -- each unit's edges are the units |
| 8526 | - angle_delta_y, | 9419 | + // already written left/above of it inside this same block. Predicting |
| 8527 | - reach, | 9420 | + // the whole `side`x`side` at once gives a different (uniformly off by |
| 8528 | - &vec![0i32; side * side], | 9421 | + // ~1) answer, which is exactly the residue this lane was chasing. |
| 8529 | - None, | 9422 | + // The palette/intrabc override path keeps the single-call shape (its |
| 8530 | - filter_intra, | 9423 | + // per-TU windowing is the non-skip loop's own `palette_y_buf` slice, |
| 8531 | - smooth_neighbor, | 9424 | + // untested for skip and unreachable in these streams). |
| 8532 | - ); | 9425 | + let split_tx_skip = |
| 9426 | + tx_select && logical_tx < side && palette_y_buf.is_none() && intrabc_bufs.is_none(); | ||
| 9427 | + if split_tx_skip { | ||
| 9428 | + SKIP_SPLIT_TX_HITS.with(|c| c.set(c.get() + 1)); | ||
| 9429 | + let n_axis = side / logical_tx; | ||
| 9430 | + for tu_row in 0..n_axis { | ||
| 9431 | + for tu_col in 0..n_axis { | ||
| 9432 | + let tu_px = px + tu_col * logical_tx; | ||
| 9433 | + let tu_py = py + tu_row * logical_tx; | ||
| 9434 | + if tu_px >= y.true_width || tu_py >= y.true_height { | ||
| 9435 | + continue; | ||
| 9436 | + } | ||
| 9437 | + let tu_reach = tu_reach( | ||
| 9438 | + side, | ||
| 9439 | + side, | ||
| 9440 | + tu_col * logical_tx, | ||
| 9441 | + tu_row * logical_tx, | ||
| 9442 | + logical_tx, | ||
| 9443 | + reach, | ||
| 9444 | + px, | ||
| 9445 | + py, | ||
| 9446 | + y.width, | ||
| 9447 | + y.height, | ||
| 9448 | + ); | ||
| 9449 | + y.reconstruct( | ||
| 9450 | + tu_px, | ||
| 9451 | + tu_py, | ||
| 9452 | + logical_tx, | ||
| 9453 | + mode, | ||
| 9454 | + angle_delta_y, | ||
| 9455 | + tu_reach, | ||
| 9456 | + &vec![0i32; logical_tx * logical_tx], | ||
| 9457 | + None, | ||
| 9458 | + filter_intra, | ||
| 9459 | + smooth_neighbor, | ||
| 9460 | + ); | ||
| 9461 | + } | ||
| 9462 | + } | ||
| 9463 | + } else { | ||
| 9464 | + y.reconstruct( | ||
| 9465 | + px, | ||
| 9466 | + py, | ||
| 9467 | + side, | ||
| 9468 | + mode, | ||
| 9469 | + angle_delta_y, | ||
| 9470 | + reach, | ||
| 9471 | + &vec![0i32; side * side], | ||
| 9472 | + None, | ||
| 9473 | + filter_intra, | ||
| 9474 | + smooth_neighbor, | ||
| 9475 | + ); | ||
| 9476 | + } | ||
| 8533 | let ac = alpha.map(|_| cfl_ac_q3(y, px, py, side)); | 9477 | let ac = alpha.map(|_| cfl_ac_q3(y, px, py, side)); |
| 8534 | if let Some((ub, _)) = &palette_uv_bufs { | 9478 | if let Some((ub, _)) = &palette_uv_bufs { |
| 8535 | set_palette_pred(ub.clone()); | 9479 | set_palette_pred(ub.clone()); |
| @@ -8666,12 +9610,9 @@ fn decode_block( | |||
| 8666 | ); | 9610 | ); |
| 8667 | let tu_px = px + tu_col * logical_tx; | 9611 | let tu_px = px + tu_col * logical_tx; |
| 8668 | let tu_py = py + tu_row * logical_tx; | 9612 | let tu_py = py + tu_row * logical_tx; |
| 8669 | - // lane-golomb r3, same-shape sweep of the strip fix below: | 9613 | + // Same libaom clip as `decode_rect_split`'s loop above; a |
| 8670 | - // libaom clips this loop to `max_blocks_wide/high` too. A | ||
| 8671 | // square block only hangs off the frame when the frame's mi | 9614 | // square block only hangs off the frame when the frame's mi |
| 8672 | - // dimensions are odd at the block's own level (lane-oddh | 9615 | + // dimensions are odd at the block's own level. |
| 8673 | - // territory), so no gate here reaches it -- it is the | ||
| 8674 | - // identical libaom rule, not a measured fix. | ||
| 8675 | if tu_px >= y.true_width || tu_py >= y.true_height { | 9616 | if tu_px >= y.true_width || tu_py >= y.true_height { |
| 8676 | continue; | 9617 | continue; |
| 8677 | } | 9618 | } |
| @@ -8950,18 +9891,59 @@ fn decode_leaf8( | |||
| 8950 | let (cpx, cpy) = (px / 2, py / 2); | 9891 | let (cpx, cpy) = (px / 2, py / 2); |
| 8951 | let (luma_grid, u_grid, v_grid); | 9892 | let (luma_grid, u_grid, v_grid); |
| 8952 | if skip { | 9893 | if skip { |
| 8953 | - y.reconstruct( | 9894 | + // lane-hgkf r2 (same shape as `decode_block`'s own skip branch): an |
| 8954 | - px, | 9895 | + // 8x8 leaf whose `tx_depth` resolved to TX_4X4 predicts FOUR 4x4 |
| 8955 | - py, | 9896 | + // transform units, each off the units already written left/above of |
| 8956 | - 8, | 9897 | + // it inside this same leaf -- an intra block's transform size is read |
| 8957 | - mode, | 9898 | + // whether or not it is skipped, and spec 7.11.2 predicts per unit. |
| 8958 | - angle_delta_y, | 9899 | + if resolved == 4 { |
| 8959 | - reach, | 9900 | + SKIP_SPLIT_TX_HITS.with(|c| c.set(c.get() + 1)); |
| 8960 | - &vec![0i32; 64], | 9901 | + for tu_row in 0..2 { |
| 8961 | - None, | 9902 | + for tu_col in 0..2 { |
| 8962 | - filter_intra, | 9903 | + let (tu_px, tu_py) = (px + tu_col * 4, py + tu_row * 4); |
| 8963 | - smooth_neighbor, | 9904 | + if tu_px >= y.true_width || tu_py >= y.true_height { |
| 8964 | - ); | 9905 | + continue; |
| 9906 | + } | ||
| 9907 | + let tu_reach = tu_reach( | ||
| 9908 | + 8, | ||
| 9909 | + 8, | ||
| 9910 | + tu_col * 4, | ||
| 9911 | + tu_row * 4, | ||
| 9912 | + 4, | ||
| 9913 | + reach, | ||
| 9914 | + px, | ||
| 9915 | + py, | ||
| 9916 | + y.width, | ||
| 9917 | + y.height, | ||
| 9918 | + ); | ||
| 9919 | + y.reconstruct( | ||
| 9920 | + tu_px, | ||
| 9921 | + tu_py, | ||
| 9922 | + 4, | ||
| 9923 | + mode, | ||
| 9924 | + angle_delta_y, | ||
| 9925 | + tu_reach, | ||
| 9926 | + &vec![0i32; 16], | ||
| 9927 | + None, | ||
| 9928 | + filter_intra, | ||
| 9929 | + smooth_neighbor, | ||
| 9930 | + ); | ||
| 9931 | + } | ||
| 9932 | + } | ||
| 9933 | + } else { | ||
| 9934 | + y.reconstruct( | ||
| 9935 | + px, | ||
| 9936 | + py, | ||
| 9937 | + 8, | ||
| 9938 | + mode, | ||
| 9939 | + angle_delta_y, | ||
| 9940 | + reach, | ||
| 9941 | + &vec![0i32; 64], | ||
| 9942 | + None, | ||
| 9943 | + filter_intra, | ||
| 9944 | + smooth_neighbor, | ||
| 9945 | + ); | ||
| 9946 | + } | ||
| 8965 | let ac = alpha.map(|_| cfl_ac_q3(y, px, py, 8)); | 9947 | let ac = alpha.map(|_| cfl_ac_q3(y, px, py, 8)); |
| 8966 | u.reconstruct( | 9948 | u.reconstruct( |
| 8967 | cpx, | 9949 | cpx, |
| @@ -10482,7 +11464,19 @@ fn read_block_tx_size( | |||
| 10482 | /// `DTT9_IDTX_1DDCT` row at `tx_size_sqr == TX_8X8`, only reachable through a | 11464 | /// `DTT9_IDTX_1DDCT` row at `tx_size_sqr == TX_8X8`, only reachable through a |
| 10483 | /// rect transform), neither of which exists yet -- both stay refused by name. | 11465 | /// rect transform), neither of which exists yet -- both stay refused by name. |
| 10484 | fn rect_inter_residual_supported(w: usize, h: usize) -> bool { | 11466 | fn rect_inter_residual_supported(w: usize, h: usize) -> bool { |
| 10485 | - matches!((w, h), (32, 16) | (16, 32) | (16, 8) | (8, 16)) | 11467 | + matches!( |
| 11468 | + (w, h), | ||
| 11469 | + // 2:1 strips whose transform is coded in full (lane-inter4). | ||
| 11470 | + (32, 16) | (16, 32) | (16, 8) | (8, 16) | ||
| 11471 | + // lane-r14 r2: strips with a 64-px axis. `av1_get_max_eob` codes | ||
| 11472 | + // only the low 32 coefficients of a 64-length axis, so these read | ||
| 11473 | + // exactly the truncated corner the INTRA superblock-strip path | ||
| 11474 | + // already reads (`read_intra_mode_rect`), through | ||
| 11475 | + // `av1_get_adjusted_tx_size`'s CDF set. Their `tx_size_sqr_up` is | ||
| 11476 | + // `TX_64X64`, so `av1_get_ext_tx_set_type` is `DCT_ONLY` and no | ||
| 11477 | + // `tx_type` symbol is coded at all. | ||
| 11478 | + | (64, 32) | (32, 64) | (64, 16) | (16, 64) | ||
| 11479 | + ) | ||
| 10486 | } | 11480 | } |
| 10487 | 11481 | ||
| 10488 | /// The luma coefficient/`tx_type` table set of a whole-block rectangular | 11482 | /// The luma coefficient/`tx_type` table set of a whole-block rectangular |
| @@ -10503,6 +11497,13 @@ fn rect_inter_luma_set(w: usize, h: usize) -> TxbSet { | |||
| 10503 | TxbSet::LumaRect16x8InterSet1 | 11497 | TxbSet::LumaRect16x8InterSet1 |
| 10504 | } | 11498 | } |
| 10505 | } | 11499 | } |
| 11500 | + // lane-r14 r2: `av1_get_adjusted_tx_size` maps TX_64X32/TX_32X64 to | ||
| 11501 | + // TX_32X32 and TX_64X16/TX_16X64 to TX_32X16/TX_16X32, and | ||
| 11502 | + // `get_txsize_entropy_ctx`/`txsize_log2_minus4` agree with the | ||
| 11503 | + // adjusted size, so the existing sets are bit-exact. Neither carries a | ||
| 11504 | + // `tx_type` table (DCT_ONLY above), so the intra/inter split is moot. | ||
| 11505 | + (64, 32) | (32, 64) => TxbSet::Luma64, | ||
| 11506 | + (64, 16) | (16, 64) => TxbSet::LumaRect32x16, | ||
| 10506 | _ => unreachable!("rect_inter_residual_supported gates every shape that reaches here"), | 11507 | _ => unreachable!("rect_inter_residual_supported gates every shape that reaches here"), |
| 10507 | } | 11508 | } |
| 10508 | } | 11509 | } |
| @@ -10515,6 +11516,13 @@ fn rect_inter_chroma_set(w: usize, h: usize) -> TxbSet { | |||
| 10515 | match (w, h) { | 11516 | match (w, h) { |
| 10516 | (16, 8) | (8, 16) => TxbSet::ChromaRect16x8, | 11517 | (16, 8) | (8, 16) => TxbSet::ChromaRect16x8, |
| 10517 | (8, 4) | (4, 8) => TxbSet::ChromaRect8x4, | 11518 | (8, 4) | (4, 8) => TxbSet::ChromaRect8x4, |
| 11519 | + // lane-r14 r2: chroma of a 64-axis strip -- 32x16/16x32 under a | ||
| 11520 | + // 64x32/32x64 one, 32x8/8x32 under a 64x16/16x64 one. Neither chroma | ||
| 11521 | + // unit has a 64-px axis, so both are coded in full; `Chroma16` is the | ||
| 11522 | + // exact set for TX_32X8/TX_8X32 (`get_txsize_entropy_ctx` = TX_16X16, | ||
| 11523 | + // `txsize_log2_minus4` = 4), same as the intra strip path uses. | ||
| 11524 | + (32, 16) | (16, 32) => TxbSet::ChromaRect32x16, | ||
| 11525 | + (32, 8) | (8, 32) => TxbSet::Chroma16, | ||
| 10518 | _ => unreachable!("rect_inter_residual_supported gates every shape that reaches here"), | 11526 | _ => unreachable!("rect_inter_residual_supported gates every shape that reaches here"), |
| 10519 | } | 11527 | } |
| 10520 | } | 11528 | } |
| @@ -10560,6 +11568,8 @@ fn rect_scan(w: usize, h: usize) -> &'static [u16] { | |||
| 10560 | (8, 16) => &SCAN_8X16, | 11568 | (8, 16) => &SCAN_8X16, |
| 10561 | (8, 4) => &SCAN_8X4, | 11569 | (8, 4) => &SCAN_8X4, |
| 10562 | (4, 8) => &SCAN_4X8, | 11570 | (4, 8) => &SCAN_4X8, |
| 11571 | + (32, 8) => &SCAN_32X8, | ||
| 11572 | + (8, 32) => &SCAN_8X32, | ||
| 10563 | _ => unreachable!("rect_inter_residual_supported gates every shape that reaches here"), | 11573 | _ => unreachable!("rect_inter_residual_supported gates every shape that reaches here"), |
| 10564 | } | 11574 | } |
| 10565 | } | 11575 | } |
| @@ -10626,6 +11636,16 @@ fn read_block_tx_size_rect( | |||
| 10626 | } | 11636 | } |
| 10627 | TXFM_SPLIT_HITS.with(|c| c.set(c.get() + 1)); | 11637 | TXFM_SPLIT_HITS.with(|c| c.set(c.get() + 1)); |
| 10628 | RECT_INTER_TXSPLIT_HITS.with(|c| c.set(c.get() + 1)); | 11638 | RECT_INTER_TXSPLIT_HITS.with(|c| c.set(c.get() + 1)); |
| 11639 | + // lane-r14 r2: `sub_tx_size_map` is square for every shape this decoder | ||
| 11640 | + // splits (TX_32X16 -> TX_16X16, TX_64X32 -> TX_32X32) EXCEPT the 1:4 | ||
| 11641 | + // strips with a 64-px axis, where it stays rectangular | ||
| 11642 | + // (TX_64X16 -> TX_32X16, TX_16X64 -> TX_16X32) and the square recursion | ||
| 11643 | + // below would code the wrong tree. | ||
| 11644 | + if tx_w.max(tx_h) == 64 && tx_w.min(tx_h) == 16 { | ||
| 11645 | + return Err(unsupported( | ||
| 11646 | + "a split transform on a 1:4 inter strip with a 64-px axis", | ||
| 11647 | + )); | ||
| 11648 | + } | ||
| 10629 | let sub = tx_w.min(tx_h); | 11649 | let sub = tx_w.min(tx_h); |
| 10630 | let max_w_mi = (bw / MI).min(mi_cols.saturating_sub(at_mi.1)); | 11650 | let max_w_mi = (bw / MI).min(mi_cols.saturating_sub(at_mi.1)); |
| 10631 | let max_h_mi = (bh / MI).min(mi_rows.saturating_sub(at_mi.0)); | 11651 | let max_h_mi = (bh / MI).min(mi_rows.saturating_sub(at_mi.0)); |
| @@ -10689,16 +11709,50 @@ fn read_inter_plane_rect( | |||
| 10689 | Some(t) if w.max(h) < 32 => t, | 11709 | Some(t) if w.max(h) < 32 => t, |
| 10690 | _ => TxType::DctDct, | 11710 | _ => TxType::DctDct, |
| 10691 | }; | 11711 | }; |
| 10692 | - let (grid, tx_type) = read_coeffs_rect( | 11712 | + // lane-r14 r2: a 64-length axis codes only its low 32 coefficients |
| 10693 | - dec, | 11713 | + // (`av1_get_max_eob`), so the coded unit is the `min(w,32) x min(h,32)` |
| 10694 | - &mut coding, | 11714 | + // corner, zero-extended into the true `w x h` grid before the inverse |
| 10695 | - rect_scan(w, h), | 11715 | + // transform -- exactly what the intra superblock-strip path does. A |
| 10696 | - w, | 11716 | + // corner that comes out square (32x32, under a 64x32/32x64 strip) reads |
| 10697 | - h, | 11717 | + // through the SQUARE coefficient reader with `rect_shape = Some((w, h))`, |
| 10698 | - skip_ctx, | 11718 | + // because `av1_nz_map_ctx_offset` is indexed by the real, un-adjusted |
| 10699 | - dc_sign_ctx(around.2), | 11719 | + // rectangular shape (lane-sbpart r8). |
| 10700 | - default_tx_type, | 11720 | + let (cw, ch) = (w.min(32), h.min(32)); |
| 10701 | - )?; | 11721 | + if plane_idx == 0 && w.max(h) == 64 { |
| 11722 | + RECT64_INTER_TU_HITS.with(|c| c.set(c.get() + 1)); | ||
| 11723 | + } | ||
| 11724 | + let (corner, tx_type) = if (cw, ch) == (32, 32) { | ||
| 11725 | + let scan32 = default_scan(TX32); | ||
| 11726 | + read_coeffs( | ||
| 11727 | + dec, | ||
| 11728 | + &mut coding, | ||
| 11729 | + &scan32, | ||
| 11730 | + skip_ctx, | ||
| 11731 | + dc_sign_ctx(around.2), | ||
| 11732 | + default_tx_type, | ||
| 11733 | + Some((w, h)), | ||
| 11734 | + )? | ||
| 11735 | + } else { | ||
| 11736 | + read_coeffs_rect( | ||
| 11737 | + dec, | ||
| 11738 | + &mut coding, | ||
| 11739 | + rect_scan(cw, ch), | ||
| 11740 | + cw, | ||
| 11741 | + ch, | ||
| 11742 | + skip_ctx, | ||
| 11743 | + dc_sign_ctx(around.2), | ||
| 11744 | + default_tx_type, | ||
| 11745 | + )? | ||
| 11746 | + }; | ||
| 11747 | + let grid = if (cw, ch) == (w, h) { | ||
| 11748 | + corner | ||
| 11749 | + } else { | ||
| 11750 | + let mut full = vec![0i32; w * h]; | ||
| 11751 | + for row in 0..ch { | ||
| 11752 | + full[row * w..][..cw].copy_from_slice(&corner[row * cw..][..cw]); | ||
| 11753 | + } | ||
| 11754 | + full | ||
| 11755 | + }; | ||
| 10702 | let (dc_delta, ac_delta) = plane_q_delta(plane_idx); | 11756 | let (dc_delta, ac_delta) = plane_q_delta(plane_idx); |
| 10703 | let residual = dequant_and_inverse_typed_wh( | 11757 | let residual = dequant_and_inverse_typed_wh( |
| 10704 | &grid, | 11758 | &grid, |
| @@ -11669,6 +12723,131 @@ pub(crate) fn take_last_frame_wide_margin() -> Option<Picture> { | |||
| 11669 | /// PRIMARY_REF_NONE`). Returns the tile's own end-of-tile adapted table | 12723 | /// PRIMARY_REF_NONE`). Returns the tile's own end-of-tile adapted table |
| 11670 | /// alongside the picture, for the caller to save into whichever reference | 12724 | /// alongside the picture, for the caller to save into whichever reference |
| 11671 | /// slots this frame's `refresh_frame_flags` names. | 12725 | /// slots this frame's `refresh_frame_flags` names. |
| 12726 | +/// The order the 64x64 superblock quadrants of a tile are decoded in. | ||
| 12727 | +/// | ||
| 12728 | +/// At `sb_size == 64` this is plain raster order over the tile's own | ||
| 12729 | +/// superblock grid. At `sb_size == 128` libaom's `decode_partition` recurses | ||
| 12730 | +/// each 128x128 superblock in raster order and visits its four 64x64 | ||
| 12731 | +/// quadrants (TL, TR, BL, BR) before moving to the next superblock, so the | ||
| 12732 | +/// 64-level bodies must run in that nested order. `row_start` marks the first | ||
| 12733 | +/// item of each *superblock* row (where the left neighbour context resets), | ||
| 12734 | +/// `sb_start` the first item of each superblock (where the 128 root's own | ||
| 12735 | +/// loop-restoration units and partition symbol are read). | ||
| 12736 | +fn sb_visit_order(r0: u32, r1: u32, c0: u32, c1: u32, sb128: bool) -> Vec<(u32, u32, bool, bool)> { | ||
| 12737 | + let mut out = Vec::new(); | ||
| 12738 | + if !sb128 { | ||
| 12739 | + for r in r0..r1 { | ||
| 12740 | + for c in c0..c1 { | ||
| 12741 | + out.push((r, c, c == c0, true)); | ||
| 12742 | + } | ||
| 12743 | + } | ||
| 12744 | + return out; | ||
| 12745 | + } | ||
| 12746 | + let mut r = r0; | ||
| 12747 | + while r < r1 { | ||
| 12748 | + let mut first_in_row = true; | ||
| 12749 | + let mut c = c0; | ||
| 12750 | + while c < c1 { | ||
| 12751 | + let mut first_in_sb = true; | ||
| 12752 | + for qr in 0..2 { | ||
| 12753 | + for qc in 0..2 { | ||
| 12754 | + let (rr, cc) = (r + qr, c + qc); | ||
| 12755 | + if rr >= r1 || cc >= c1 { | ||
| 12756 | + continue; | ||
| 12757 | + } | ||
| 12758 | + out.push((rr, cc, first_in_row, first_in_sb)); | ||
| 12759 | + first_in_row = false; | ||
| 12760 | + first_in_sb = false; | ||
| 12761 | + } | ||
| 12762 | + } | ||
| 12763 | + c += 2; | ||
| 12764 | + } | ||
| 12765 | + r += 2; | ||
| 12766 | + } | ||
| 12767 | + out | ||
| 12768 | +} | ||
| 12769 | + | ||
| 12770 | +/// lane-sb128 r2: the 128x128 superblock root, shared by the key-frame and | ||
| 12771 | +/// the inter tile loop. Its loop-restoration units are read once for the whole | ||
| 12772 | +/// 128x128 (spec 5.11.57 is called with the superblock's own size), then one | ||
| 12773 | +/// partition symbol off the `BLOCK_128X128` CDF (8 symbols, no HORZ_4/VERT_4) | ||
| 12774 | +/// decides the root -- only SPLIT recurses into the four 64x64 quadrants this | ||
| 12775 | +/// decoder codes, the other seven arms refuse by name. | ||
| 12776 | +#[allow(clippy::too_many_arguments)] | ||
| 12777 | +fn read_sb128_root( | ||
| 12778 | + dec: &mut SymbolDecoder, | ||
| 12779 | + cdfs: &mut Cdfs, | ||
| 12780 | + neighbours: &Neighbours, | ||
| 12781 | + lr: &LoopRestorationParams, | ||
| 12782 | + lr_grid: &mut crate::restoration::RestorationGrid, | ||
| 12783 | + lr_reference: &mut [( | ||
| 12784 | + crate::restoration::WienerInfo, | ||
| 12785 | + crate::restoration::SgrprojInfo, | ||
| 12786 | + ); 3], | ||
| 12787 | + sb_r: u32, | ||
| 12788 | + sb_c: u32, | ||
| 12789 | + mi_cols: u32, | ||
| 12790 | + mi_rows: u32, | ||
| 12791 | +) -> Result<()> { | ||
| 12792 | + let (mi_r128, mi_c128) = ((sb_r & !1) * SB_MI, (sb_c & !1) * SB_MI); | ||
| 12793 | + crate::restoration::read_lr( | ||
| 12794 | + dec, | ||
| 12795 | + cdfs, | ||
| 12796 | + lr, | ||
| 12797 | + lr_grid, | ||
| 12798 | + lr_reference, | ||
| 12799 | + mi_r128, | ||
| 12800 | + mi_c128, | ||
| 12801 | + SB_MI * 2, | ||
| 12802 | + ); | ||
| 12803 | + let at128 = ((mi_r128 / SUB_MI) as usize, (mi_c128 / SUB_MI) as usize); | ||
| 12804 | + let ctx128 = neighbours.partition_ctx(at128, 128); | ||
| 12805 | + let (has_cols128, has_rows128) = (mi_c128 + SB_MI < mi_cols, mi_r128 + SB_MI < mi_rows); | ||
| 12806 | + let part128 = if has_cols128 && has_rows128 { | ||
| 12807 | + PART128_SYMBOLS.with(|c| c.set(c.get() + 1)); | ||
| 12808 | + let p = dec.symbol(&mut cdfs.partition_w128[ctx128]); | ||
| 12809 | + if std::env::var_os("EC_AV1_TRACE").is_some() { | ||
| 12810 | + eprintln!("TRACE partition_w128 ctx={ctx128} value={p}"); | ||
| 12811 | + } | ||
| 12812 | + p | ||
| 12813 | + } else { | ||
| 12814 | + // lane-sb128 r4: the gathered half-out-of-frame reads DECIDE the | ||
| 12815 | + // partition, they are not a forced split -- exactly the discarded-bit | ||
| 12816 | + // defect the 64 root carries a comment about at `partition_w64`'s | ||
| 12817 | + // gathered arm. Value 1 is SPLIT; 0 is HORZ (rows out of frame) or | ||
| 12818 | + // VERT (cols out of frame), which the refusal below then names | ||
| 12819 | + // instead of silently reconstructing a split. | ||
| 12820 | + PART128_GATHERED_SYMBOLS.with(|c| c.set(c.get() + 1)); | ||
| 12821 | + match (has_cols128, has_rows128) { | ||
| 12822 | + (true, false) => { | ||
| 12823 | + if dec.symbol_fixed(&gather_of(&cdfs.partition_w128[ctx128], &VERT_ALIKE128)) == 1 { | ||
| 12824 | + PARTITION_SPLIT | ||
| 12825 | + } else { | ||
| 12826 | + PARTITION_HORZ | ||
| 12827 | + } | ||
| 12828 | + } | ||
| 12829 | + (false, true) => { | ||
| 12830 | + if dec.symbol_fixed(&gather_of(&cdfs.partition_w128[ctx128], &HORZ_ALIKE128)) == 1 { | ||
| 12831 | + PARTITION_SPLIT | ||
| 12832 | + } else { | ||
| 12833 | + PARTITION_VERT | ||
| 12834 | + } | ||
| 12835 | + } | ||
| 12836 | + _ => { | ||
| 12837 | + PART128_GATHERED_SYMBOLS.with(|c| c.set(c.get() - 1)); | ||
| 12838 | + PARTITION_SPLIT | ||
| 12839 | + } | ||
| 12840 | + } | ||
| 12841 | + }; | ||
| 12842 | + if part128 != PARTITION_SPLIT { | ||
| 12843 | + return Err(unsupported( | ||
| 12844 | + "a 128x128 superblock partition other than SPLIT (NONE/HORZ/VERT and the four AB arms at the 128 root are not decoded)", | ||
| 12845 | + )); | ||
| 12846 | + } | ||
| 12847 | + PART128_SPLIT_HITS.with(|c| c.set(c.get() + 1)); | ||
| 12848 | + Ok(()) | ||
| 12849 | +} | ||
| 12850 | + | ||
| 11672 | pub(crate) fn decode_key_frame_tile_with_cdfs( | 12851 | pub(crate) fn decode_key_frame_tile_with_cdfs( |
| 11673 | tiles: &[&[u8]], | 12852 | tiles: &[&[u8]], |
| 11674 | tile_info: &TileInfo, | 12853 | tile_info: &TileInfo, |
| @@ -11701,6 +12880,12 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | |||
| 11701 | return Err(unsupported("a frame with no mode-info grid")); | 12880 | return Err(unsupported("a frame with no mode-info grid")); |
| 11702 | } | 12881 | } |
| 11703 | ENABLE_EDGE_FILTER.with(|f| f.set(enable_edge_filter)); | 12882 | ENABLE_EDGE_FILTER.with(|f| f.set(enable_edge_filter)); |
| 12883 | + let sb128 = sb128(); | ||
| 12884 | + if sb128 && allow_intrabc { | ||
| 12885 | + return Err(unsupported( | ||
| 12886 | + "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)", | ||
| 12887 | + )); | ||
| 12888 | + } | ||
| 11704 | let (sb_cols, sb_rows) = (mi_cols.div_ceil(SB_MI), mi_rows.div_ceil(SB_MI)); | 12889 | let (sb_cols, sb_rows) = (mi_cols.div_ceil(SB_MI), mi_rows.div_ceil(SB_MI)); |
| 11705 | INTRABC_MI_GRID.with(|g| { | 12890 | INTRABC_MI_GRID.with(|g| { |
| 11706 | *g.borrow_mut() = allow_intrabc.then(|| { | 12891 | *g.borrow_mut() = allow_intrabc.then(|| { |
| @@ -11838,19 +13023,42 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | |||
| 11838 | ); | 13023 | ); |
| 11839 | TILE_HITS.with(|c| c.set(c.get() + 1)); | 13024 | TILE_HITS.with(|c| c.set(c.get() + 1)); |
| 11840 | 13025 | ||
| 11841 | - for sb_r in sb_r0..sb_r1 { | 13026 | + for (sb_r, sb_c, row_start, sb_start) in sb_visit_order(sb_r0, sb_r1, sb_c0, sb_c1, sb128) { |
| 11842 | - neighbours.start_row(); | 13027 | + if row_start { |
| 11843 | - for sb_c in sb_c0..sb_c1 { | 13028 | + neighbours.start_row(); |
| 11844 | - crate::restoration::read_lr( | 13029 | + } |
| 11845 | - &mut dec, | 13030 | + { |
| 11846 | - &mut cdfs, | 13031 | + // lane-sb128 r1: the 128 root. Its loop-restoration units are read |
| 11847 | - lr, | 13032 | + // once for the whole 128x128 (spec 5.11.57 is called with the |
| 11848 | - &mut lr_grid, | 13033 | + // superblock's own size), then one partition symbol off the |
| 11849 | - &mut lr_reference, | 13034 | + // `BLOCK_128X128` CDF (8 symbols) decides the root -- only SPLIT |
| 11850 | - sb_r * SB_MI, | 13035 | + // recurses into the four 64x64 quadrants this decoder codes. |
| 11851 | - sb_c * SB_MI, | 13036 | + if sb128 && sb_start { |
| 11852 | - SB_MI, | 13037 | + read_sb128_root( |
| 11853 | - ); | 13038 | + &mut dec, |
| 13039 | + &mut cdfs, | ||
| 13040 | + &neighbours, | ||
| 13041 | + lr, | ||
| 13042 | + &mut lr_grid, | ||
| 13043 | + &mut lr_reference, | ||
| 13044 | + sb_r, | ||
| 13045 | + sb_c, | ||
| 13046 | + mi_cols, | ||
| 13047 | + mi_rows, | ||
| 13048 | + )?; | ||
| 13049 | + } | ||
| 13050 | + if !sb128 { | ||
| 13051 | + crate::restoration::read_lr( | ||
| 13052 | + &mut dec, | ||
| 13053 | + &mut cdfs, | ||
| 13054 | + lr, | ||
| 13055 | + &mut lr_grid, | ||
| 13056 | + &mut lr_reference, | ||
| 13057 | + sb_r * SB_MI, | ||
| 13058 | + sb_c * SB_MI, | ||
| 13059 | + SB_MI, | ||
| 13060 | + ); | ||
| 13061 | + } | ||
| 11854 | CDEF_TRANSMITTED.with(|c| c.set(false)); | 13062 | CDEF_TRANSMITTED.with(|c| c.set(false)); |
| 11855 | let at = (sb_r as usize * 4, sb_c as usize * 4); | 13063 | let at = (sb_r as usize * 4, sb_c as usize * 4); |
| 11856 | let ctx = neighbours.partition_ctx(at, SB); | 13064 | let ctx = neighbours.partition_ctx(at, SB); |
| @@ -11872,23 +13080,24 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | |||
| 11872 | } | 13080 | } |
| 11873 | p | 13081 | p |
| 11874 | } else { | 13082 | } else { |
| 11875 | - // lane-golomb r1 (class `parsed-then-discarded`): the gathered | 13083 | + // lane-hgkf r1 (class `parsed-then-discarded`, same finding as |
| 11876 | - // bit is the answer, not a formality -- libaom's | 13084 | + // the unmerged lane-golomb r1): the gathered bit IS the |
| 11877 | - // `ec_read_partition_impl` returns `PARTITION_HORZ` (resp. | 13085 | + // partition -- libaom `ec_read_partition_impl` returns |
| 11878 | - // `PARTITION_VERT`) when it reads 0, and only `PARTITION_SPLIT` | 13086 | + // PARTITION_HORZ (resp. VERT) for 0 and only SPLIT for 1. |
| 11879 | - // when it reads 1. Forcing SPLIT here desynced the last | 13087 | + // Forcing SPLIT desynced the last superblock row of every |
| 11880 | - // superblock row of every frame whose height is not a multiple | 13088 | + // frame whose height is not a multiple of 64: the ReelB key frames (3840x1608) diverge at mi_row=400 mi_col=0, |
| 11881 | - // of 64 -- the ReelB head (3840x1608) diverges at | 13089 | + // the first block of that row. |
| 11882 | - // mi_row=400 mi_col=0, the first block of that row. | ||
| 11883 | match (has_cols, has_rows) { | 13090 | match (has_cols, has_rows) { |
| 11884 | (true, false) => { | 13091 | (true, false) => { |
| 11885 | let b = dec.symbol_fixed(&gather(&cdfs.partition_w64[ctx], VERT_ALIKE)); | 13092 | let b = dec.symbol_fixed(&gather(&cdfs.partition_w64[ctx], VERT_ALIKE)); |
| 11886 | bump_edge32(4 + b.min(1) as usize); | 13093 | bump_edge32(4 + b.min(1) as usize); |
| 13094 | + bump_edge_part(b.min(1) as usize); | ||
| 11887 | if b == 1 { PARTITION_SPLIT } else { PARTITION_HORZ } | 13095 | if b == 1 { PARTITION_SPLIT } else { PARTITION_HORZ } |
| 11888 | } | 13096 | } |
| 11889 | (false, true) => { | 13097 | (false, true) => { |
| 11890 | let b = dec.symbol_fixed(&gather(&cdfs.partition_w64[ctx], HORZ_ALIKE)); | 13098 | let b = dec.symbol_fixed(&gather(&cdfs.partition_w64[ctx], HORZ_ALIKE)); |
| 11891 | bump_edge32(4 + b.min(1) as usize); | 13099 | bump_edge32(4 + b.min(1) as usize); |
| 13100 | + bump_edge_part(b.min(1) as usize); | ||
| 11892 | if b == 1 { PARTITION_SPLIT } else { PARTITION_VERT } | 13101 | if b == 1 { PARTITION_SPLIT } else { PARTITION_VERT } |
| 11893 | } | 13102 | } |
| 11894 | _ => PARTITION_SPLIT, | 13103 | _ => PARTITION_SPLIT, |
| @@ -11947,34 +13156,27 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | |||
| 11947 | } | 13156 | } |
| 11948 | p | 13157 | p |
| 11949 | } else { | 13158 | } else { |
| 13159 | + // lane-hgkf r1: the 32-level frame-edge bit is the | ||
| 13160 | + // partition too (same libaom reader as the | ||
| 13161 | + // superblock level above). | ||
| 11950 | match (has_cols32, has_rows32) { | 13162 | match (has_cols32, has_rows32) { |
| 11951 | (true, false) => { | 13163 | (true, false) => { |
| 11952 | - // lane-golomb r1 (class `parsed-then-discarded`): the gathered | 13164 | + let b = dec.symbol_fixed(&gather( |
| 11953 | - // bit IS the partition -- 0 means PARTITION_HORZ, only 1 means SPLIT | 13165 | + &cdfs.partition_w32[ctx32], |
| 11954 | - // (libaom `ec_read_partition_impl`). | 13166 | + VERT_ALIKE, |
| 11955 | - if { | 13167 | + )); |
| 11956 | - let b = dec.symbol_fixed(&gather(&cdfs.partition_w32[ctx32], VERT_ALIKE)); | 13168 | + bump_edge32(b.min(1) as usize); |
| 11957 | - bump_edge32(b.min(1) as usize); | 13169 | + bump_edge_part(2 + b.min(1) as usize); |
| 11958 | - b | 13170 | + if b == 1 { PARTITION_SPLIT } else { PARTITION_HORZ } |
| 11959 | - } == 1 { | ||
| 11960 | - PARTITION_SPLIT | ||
| 11961 | - } else { | ||
| 11962 | - PARTITION_HORZ | ||
| 11963 | - } | ||
| 11964 | } | 13171 | } |
| 11965 | (false, true) => { | 13172 | (false, true) => { |
| 11966 | - // lane-golomb r1 (class `parsed-then-discarded`): the gathered | 13173 | + let b = dec.symbol_fixed(&gather( |
| 11967 | - // bit IS the partition -- 0 means PARTITION_VERT, only 1 means SPLIT | 13174 | + &cdfs.partition_w32[ctx32], |
| 11968 | - // (libaom `ec_read_partition_impl`). | 13175 | + HORZ_ALIKE, |
| 11969 | - if { | 13176 | + )); |
| 11970 | - let b = dec.symbol_fixed(&gather(&cdfs.partition_w32[ctx32], HORZ_ALIKE)); | 13177 | + bump_edge32(b.min(1) as usize); |
| 11971 | - bump_edge32(b.min(1) as usize); | 13178 | + bump_edge_part(2 + b.min(1) as usize); |
| 11972 | - b | 13179 | + if b == 1 { PARTITION_SPLIT } else { PARTITION_VERT } |
| 11973 | - } == 1 { | ||
| 11974 | - PARTITION_SPLIT | ||
| 11975 | - } else { | ||
| 11976 | - PARTITION_VERT | ||
| 11977 | - } | ||
| 11978 | } | 13180 | } |
| 11979 | _ => PARTITION_SPLIT, | 13181 | _ => PARTITION_SPLIT, |
| 11980 | } | 13182 | } |
| @@ -12278,11 +13480,34 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | |||
| 12278 | neighbours.left_mode[sr] = mode_right; | 13480 | neighbours.left_mode[sr] = mode_right; |
| 12279 | continue; | 13481 | continue; |
| 12280 | } | 13482 | } |
| 12281 | - if part16 != PARTITION_SPLIT { | 13483 | + if part16 == PARTITION_HORZ_4 |
| 12282 | - return Err(unsupported( | 13484 | + || part16 == PARTITION_VERT_4 |
| 12283 | - "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)", | 13485 | + { |
| 12284 | - )); | 13486 | + decode_rect4_16( |
| 13487 | + &mut dec, | ||
| 13488 | + &mut cdfs, | ||
| 13489 | + &mut neighbours, | ||
| 13490 | + at16, | ||
| 13491 | + part16 == PARTITION_HORZ_4, | ||
| 13492 | + &mut y, | ||
| 13493 | + &mut u, | ||
| 13494 | + &mut v, | ||
| 13495 | + enable_filter_intra, | ||
| 13496 | + allow_screen_content_tools, | ||
| 13497 | + base_q_idx, | ||
| 13498 | + tx_select, | ||
| 13499 | + reduced_tx_set, | ||
| 13500 | + )?; | ||
| 13501 | + continue; | ||
| 12285 | } | 13502 | } |
| 13503 | + // lane-r14 r2 (verifier note): every | ||
| 13504 | + // one of the 10 symbols this CDF can | ||
| 13505 | + // produce is handled above, so SPLIT | ||
| 13506 | + // is the only value that reaches | ||
| 13507 | + // here -- the refusal that used to | ||
| 13508 | + // stand here was unreachable and is | ||
| 13509 | + // gone from `refusal_inventory`. | ||
| 13510 | + debug_assert_eq!(part16, PARTITION_SPLIT); | ||
| 12286 | // A real (non-straddle) SPLIT of a | 13511 | // A real (non-straddle) SPLIT of a |
| 12287 | // whole 16x16 into four 8x8 leaves -- | 13512 | // whole 16x16 into four 8x8 leaves -- |
| 12288 | // the same recursion the straddle | 13513 | // the same recursion the straddle |
| @@ -12435,6 +13660,10 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | |||
| 12435 | HORZ_ALIKE, | 13660 | HORZ_ALIKE, |
| 12436 | )) | 13661 | )) |
| 12437 | }; | 13662 | }; |
| 13663 | + // lane-hgkf r1: slots 2/3 of | ||
| 13664 | + // [`EDGE_PART_HITS`], the gate's proof the | ||
| 13665 | + // non-SPLIT edge arm actually decoded. | ||
| 13666 | + bump_edge_part(if edge_split == 1 { 3 } else { 2 }); | ||
| 12438 | if edge_split == 0 { | 13667 | if edge_split == 0 { |
| 12439 | // lane-oddh r1: the strip IS decodable | 13668 | // lane-oddh r1: the strip IS decodable |
| 12440 | // -- libaom's `decode_partition` codes | 13669 | // -- libaom's `decode_partition` codes |
| @@ -12604,9 +13833,9 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | |||
| 12604 | if !has_rows32 { | 13833 | if !has_rows32 { |
| 12605 | bump_edge32(2); | 13834 | bump_edge32(2); |
| 12606 | } | 13835 | } |
| 12607 | - // lane-golomb r2: at the frame edge only the first half of the | 13836 | + // lane-hgkf r1: at the frame edge only the first half of the strip is |
| 12608 | - // strip is coded (libaom `decode_partition` guards the second | 13837 | + // coded (libaom `decode_partition` guards the second half with the same |
| 12609 | - // with the same has_rows test that made this partition non-square). | 13838 | + // test that made this partition non-square). |
| 12610 | if has_rows32 { | 13839 | if has_rows32 { |
| 12611 | decode_block_rect( | 13840 | decode_block_rect( |
| 12612 | &mut dec, | 13841 | &mut dec, |
| @@ -12648,9 +13877,9 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | |||
| 12648 | if !has_cols32 { | 13877 | if !has_cols32 { |
| 12649 | bump_edge32(3); | 13878 | bump_edge32(3); |
| 12650 | } | 13879 | } |
| 12651 | - // lane-golomb r2: at the frame edge only the first half of the | 13880 | + // lane-hgkf r1: at the frame edge only the first half of the strip is |
| 12652 | - // strip is coded (libaom `decode_partition` guards the second | 13881 | + // coded (libaom `decode_partition` guards the second half with the same |
| 12653 | - // with the same has_cols test that made this partition non-square). | 13882 | + // test that made this partition non-square). |
| 12654 | if has_cols32 { | 13883 | if has_cols32 { |
| 12655 | decode_block_rect( | 13884 | decode_block_rect( |
| 12656 | &mut dec, | 13885 | &mut dec, |
| @@ -13259,6 +14488,7 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | |||
| 13259 | // that isolate whether a decode-order frame's mismatch already exists | 14488 | // that isolate whether a decode-order frame's mismatch already exists |
| 13260 | // in reconstruction (this dump) vs is introduced by the loop filter | 14489 | // in reconstruction (this dump) vs is introduced by the loop filter |
| 13261 | // (EC_AV1_DECODE_ORDER_DUMP's post-filter dump). | 14490 | // (EC_AV1_DECODE_ORDER_DUMP's post-filter dump). |
| 14491 | + dump_stage16("EC_AV1_PREFILT_DUMP16", &y, &u, &v, frame_width as usize, frame_height as usize); | ||
| 13262 | if let Ok(path) = std::env::var("EC_AV1_PREFILT_DUMP") { | 14492 | if let Ok(path) = std::env::var("EC_AV1_PREFILT_DUMP") { |
| 13263 | use std::io::Write; | 14493 | use std::io::Write; |
| 13264 | let idx = PREFILT_PICTURE_IDX.fetch_add(1, std::sync::atomic::Ordering::SeqCst); | 14494 | let idx = PREFILT_PICTURE_IDX.fetch_add(1, std::sync::atomic::Ordering::SeqCst); |
| @@ -13302,8 +14532,10 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | |||
| 13302 | // EC_AV1_POSTDEBLOCK_DUMP (decodeframe.c ~5404) -- with the pre-filter | 14532 | // EC_AV1_POSTDEBLOCK_DUMP (decodeframe.c ~5404) -- with the pre-filter |
| 13303 | // dump above these bisect WHICH filter stage introduced a mismatch. | 14533 | // dump above these bisect WHICH filter stage introduced a mismatch. |
| 13304 | dump_stage("EC_AV1_POSTDEBLOCK_DUMP", &y, &u, &v); | 14534 | dump_stage("EC_AV1_POSTDEBLOCK_DUMP", &y, &u, &v); |
| 14535 | + dump_stage16("EC_AV1_POSTDEBLOCK_DUMP16", &y, &u, &v, frame_width as usize, frame_height as usize); | ||
| 13305 | apply_cdef(&mut y, &mut u, &mut v, cdef, &neighbours); | 14536 | apply_cdef(&mut y, &mut u, &mut v, cdef, &neighbours); |
| 13306 | dump_stage("EC_AV1_POSTCDEF_DUMP", &y, &u, &v); | 14537 | dump_stage("EC_AV1_POSTCDEF_DUMP", &y, &u, &v); |
| 14538 | + dump_stage16("EC_AV1_POSTCDEF_DUMP16", &y, &u, &v, frame_width as usize, frame_height as usize); | ||
| 13307 | apply_loop_restoration(&mut y, &mut u, &mut v, &deblocked_y, &deblocked_u, &deblocked_v, lr, &lr_grid); | 14539 | apply_loop_restoration(&mut y, &mut u, &mut v, &deblocked_y, &deblocked_u, &deblocked_v, lr, &lr_grid); |
| 13308 | 14540 | ||
| 13309 | let (fw, fh) = (frame_width as usize, frame_height as usize); | 14541 | let (fw, fh) = (frame_width as usize, frame_height as usize); |
| @@ -13905,34 +15137,16 @@ fn overlappable_left( | |||
| 13905 | out | 15137 | out |
| 13906 | } | 15138 | } |
| 13907 | 15139 | ||
| 13908 | -/// `has_top_right` (`av1/common/mvref_common.c`), reduced to the | 15140 | +/// The warp-sample gather's own `has_top_right` probe (libaom `av1_findSamples` |
| 13909 | -/// square-block, fixed-64px-superblock case this decoder ever reaches: no | 15141 | +/// calls the same `mvref_common.c` function the MV stack does). lane-sb128 r2: |
| 13910 | -/// rectangular partition (`VERT`/`HORZ`/`_4`/`VERT_A`) ever produces an | 15142 | +/// this used to hardcode `SB_MI` (a 64x64 superblock) -- at `sb_size == 128` |
| 13911 | -/// inter leaf here (`xd->width == xd->height` always), so libaom's own | 15143 | +/// libaom's mask loop runs one level further and strips the top-right sample |
| 13912 | -/// rect-partition branches (`xd->width < xd->height`, `xd->width > | 15144 | +/// off blocks whose neighbour IS decoded, so a warped 128-superblock frame |
| 13913 | -/// xd->height`, `PARTITION_VERT_A`) never fire and are dropped. `bs` is the | 15145 | +/// picked up wrong warp parameters (frame 6 of the 128 inter gate). Delegates |
| 13914 | -/// block's own side in 4x4 (`mi`) units. | 15146 | +/// to the single sb-aware port in [`crate::mvstack::has_top_right`]; `bs` is |
| 15147 | +/// the block's own side in 4x4 (`mi`) units (square inter leaves only here). | ||
| 13915 | fn has_top_right(mi_row: usize, mi_col: usize, bs: usize) -> bool { | 15148 | fn has_top_right(mi_row: usize, mi_col: usize, bs: usize) -> bool { |
| 13916 | - let sb_mi_size = SB_MI as usize; | 15149 | + crate::mvstack::has_top_right(mi_row, mi_col, bs, bs) |
| 13917 | - let mask_row = mi_row & (sb_mi_size - 1); | ||
| 13918 | - let mask_col = mi_col & (sb_mi_size - 1); | ||
| 13919 | - if bs > sb_mi_size { | ||
| 13920 | - return false; | ||
| 13921 | - } | ||
| 13922 | - let mut has_tr = !((mask_row & bs != 0) && (mask_col & bs != 0)); | ||
| 13923 | - let mut b = bs; | ||
| 13924 | - while b < sb_mi_size { | ||
| 13925 | - if mask_col & b != 0 { | ||
| 13926 | - if (mask_col & (2 * b) != 0) && (mask_row & (2 * b) != 0) { | ||
| 13927 | - has_tr = false; | ||
| 13928 | - break; | ||
| 13929 | - } | ||
| 13930 | - } else { | ||
| 13931 | - break; | ||
| 13932 | - } | ||
| 13933 | - b <<= 1; | ||
| 13934 | - } | ||
| 13935 | - has_tr | ||
| 13936 | } | 15150 | } |
| 13937 | 15151 | ||
| 13938 | /// `av1_findSamples` (`mvref_common.c`), full port: the up to | 15152 | /// `av1_findSamples` (`mvref_common.c`), full port: the up to |
| @@ -14961,18 +16175,6 @@ fn decode_inter_block( | |||
| 14961 | let whole_sb = side == 64 && write_w == 64 && write_h == 64; | 16175 | let whole_sb = side == 64 && write_w == 64 && write_h == 64; |
| 14962 | maybe_read_delta_q(dec, cdfs, rmi, cmi, whole_sb, skip); | 16176 | maybe_read_delta_q(dec, cdfs, rmi, cmi, whole_sb, skip); |
| 14963 | maybe_read_delta_lf(dec, cdfs, rmi, cmi, whole_sb, skip); | 16177 | maybe_read_delta_lf(dec, cdfs, rmi, cmi, whole_sb, skip); |
| 14964 | - // lane-warp r5: see `reject_residual` -- a square-block decode of a | ||
| 14965 | - // HORZ_B strip is symbol-exact only for `skip` (no residual, no | ||
| 14966 | - // motion_mode/warp symbol), so gate here before any further read. | ||
| 14967 | - if reject_residual && !skip && !rect_inter_residual_supported(write_w, write_h) { | ||
| 14968 | - if std::env::var_os("EC_AV1_RECT_DUMP").is_some() { | ||
| 14969 | - eprintln!("EC_RECT_REFUSE mi_row={rmi} mi_col={cmi} w={write_w} h={write_h} side={side}"); | ||
| 14970 | - } | ||
| 14971 | - return Err(unsupported( | ||
| 14972 | - "a non-skip rectangular (HORZ/VERT/HORZ_B) strip needs rectangular residual coding", | ||
| 14973 | - )); | ||
| 14974 | - } | ||
| 14975 | - | ||
| 14976 | let (has_above, has_left) = ( | 16178 | let (has_above, has_left) = ( |
| 14977 | rmi > neighbours.tile_row0_mi, | 16179 | rmi > neighbours.tile_row0_mi, |
| 14978 | cmi > neighbours.tile_col0_mi, | 16180 | cmi > neighbours.tile_col0_mi, |
| @@ -14988,6 +16190,29 @@ fn decode_inter_block( | |||
| 14988 | dec.debug_state().0 | 16190 | dec.debug_state().0 |
| 14989 | ); | 16191 | ); |
| 14990 | } | 16192 | } |
| 16193 | + // lane-warp r5: see `reject_residual` -- a square-block decode of a | ||
| 16194 | + // HORZ_B strip is symbol-exact only for `skip` (no residual, no | ||
| 16195 | + // motion_mode/warp symbol). lane-intrarect r1 MOVED this gate from just | ||
| 16196 | + // after the `skip` read to here, past `is_inter` (class | ||
| 16197 | + // [[refusal-short-circuits-its-own-code]]: at the old place it refused | ||
| 16198 | + // 24/24 attempts of this lane's own gate before the intra arm below | ||
| 16199 | + // could run). An INTRA strip with its true `write_w`x`write_h` footprint | ||
| 16200 | + // now codes its residual rectangularly ([`decode_intra_rect_in_inter`]); | ||
| 16201 | + // an INTER one, and a strip decoded with square dimensions anyway, still | ||
| 16202 | + // cannot. | ||
| 16203 | + // merge b51719f+lane-intrarect: main's `rect_inter_residual_supported` | ||
| 16204 | + // term stays -- lane-inter4's 16x8/8x16 inter leaves DO code a | ||
| 16205 | + // rectangular residual, and the lane's condition (written before that | ||
| 16206 | + // landed) refused every one of them. | ||
| 16207 | + if reject_residual | ||
| 16208 | + && !skip | ||
| 16209 | + && !rect_inter_residual_supported(write_w, write_h) | ||
| 16210 | + && (is_inter || (write_w == side && write_h == side)) | ||
| 16211 | + { | ||
| 16212 | + return Err(unsupported( | ||
| 16213 | + "a non-skip rectangular (HORZ/VERT/HORZ_B) strip needs rectangular residual coding", | ||
| 16214 | + )); | ||
| 16215 | + } | ||
| 14991 | if std::env::var_os("EC_AV1_TELL").is_some() { | 16216 | if std::env::var_os("EC_AV1_TELL").is_some() { |
| 14992 | eprintln!( | 16217 | eprintln!( |
| 14993 | "TELL mi_row={} mi_col={} label=post_is_inter skip_mode={skip_mode} skip={skip} is_inter={is_inter} tell={} range={}", | 16218 | "TELL mi_row={} mi_col={} label=post_is_inter skip_mode={skip_mode} skip={skip} is_inter={is_inter} tell={} range={}", |
| @@ -15113,6 +16338,22 @@ fn decode_inter_block( | |||
| 15113 | force_integer_mv, | 16338 | force_integer_mv, |
| 15114 | (gm_table[(ref0 - LAST_FRAME) as usize], gm_table[(ref1 - LAST_FRAME) as usize]), | 16339 | (gm_table[(ref0 - LAST_FRAME) as usize], gm_table[(ref1 - LAST_FRAME) as usize]), |
| 15115 | ); | 16340 | ); |
| 16341 | + if std::env::var_os("EC_TRACE_MODE").is_some() { | ||
| 16342 | + eprintln!( | ||
| 16343 | + "EC_MODE_VAL mi_row={mi_row} mi_col={mi_col} mode={} ref0={ref0} ref1={ref1} mv0=({},{}) stack={} rng={}", | ||
| 16344 | + compound_mode + 17, | ||
| 16345 | + mv0.0, | ||
| 16346 | + mv0.1, | ||
| 16347 | + comp_stack.entries.len(), | ||
| 16348 | + dec.debug_state().0 | ||
| 16349 | + ); | ||
| 16350 | + for (i, e) in comp_stack.entries.iter().enumerate() { | ||
| 16351 | + eprintln!( | ||
| 16352 | + "EC_STACK mi_row={mi_row} mi_col={mi_col} i={i} this=({},{}) comp=({},{}) w={}", | ||
| 16353 | + e.mv0.0, e.mv0.1, e.mv1.0, e.mv1.1, e.weight | ||
| 16354 | + ); | ||
| 16355 | + } | ||
| 16356 | + } | ||
| 15116 | let is_globalmv = compound_mode == 6; // GLOBAL_GLOBALMV | 16357 | let is_globalmv = compound_mode == 6; // GLOBAL_GLOBALMV |
| 15117 | // spec `is_nontrans_global_motion`: ALL active refs' models must | 16358 | // spec `is_nontrans_global_motion`: ALL active refs' models must |
| 15118 | // be non-TRANSLATION (IDENTITY counts) for the compound block's | 16359 | // be non-TRANSLATION (IDENTITY counts) for the compound block's |
| @@ -16999,10 +18240,64 @@ fn decode_inter_block( | |||
| 16999 | // already-square-predicted buffer). Named refusal instead of a | 18240 | // already-square-predicted buffer). Named refusal instead of a |
| 17000 | // silently wrong square-shaped intra prediction. | 18241 | // silently wrong square-shaped intra prediction. |
| 17001 | if write_w != side || write_h != side { | 18242 | if write_w != side || write_h != side { |
| 17002 | - return Err(unsupported( | 18243 | + // lane-intrarect r1: the strip decodes through its own rect |
| 17003 | - "an intra-coded HORZ/VERT strip needs rectangular intra prediction \ | 18244 | + // machinery ([`decode_intra_rect_in_inter`] -> the key-frame |
| 17004 | - this decoder does not code yet", | 18245 | + // paths' [`decode_rect_split`]) instead of refusing. That call |
| 17005 | - )); | 18246 | + // already writes everything the shared tail below would for a |
| 18247 | + // square block EXCEPT the inter-side bands and the mi map, so | ||
| 18248 | + // this arm returns rather than falling through (a second | ||
| 18249 | + // `record_rect`/`fill_lf_grid_rect` at block granularity would | ||
| 18250 | + // overwrite the per-transform-unit records it just made). | ||
| 18251 | + decode_intra_rect_in_inter( | ||
| 18252 | + dec, | ||
| 18253 | + cdfs, | ||
| 18254 | + neighbours, | ||
| 18255 | + at, | ||
| 18256 | + write_w, | ||
| 18257 | + write_h, | ||
| 18258 | + skip, | ||
| 18259 | + allow_screen_content_tools, | ||
| 18260 | + y, | ||
| 18261 | + u, | ||
| 18262 | + v, | ||
| 18263 | + base_q_idx, | ||
| 18264 | + )?; | ||
| 18265 | + // merge b51719f+lane-intrarect: `at` is in MI units on this path | ||
| 18266 | + // (lane-inter4), so the strip's mi origin is `at` itself -- the | ||
| 18267 | + // lane's `r * SUB_MI` re-derivation would snap a sub-SUB strip to | ||
| 18268 | + // its enclosing 16-px cell. | ||
| 18269 | + let (mi_r0, mi_c0) = (rmi, cmi); | ||
| 18270 | + for dr in 0..write_h / MI { | ||
| 18271 | + for dc in 0..write_w / MI { | ||
| 18272 | + grid.set( | ||
| 18273 | + mi_r0 + dr, | ||
| 18274 | + mi_c0 + dc, | ||
| 18275 | + MiInfo { | ||
| 18276 | + is_inter: false, | ||
| 18277 | + ref_frame: -1, | ||
| 18278 | + ref_frame1: None, | ||
| 18279 | + mv1: None, | ||
| 18280 | + mv: (0, 0), | ||
| 18281 | + is_new_mv: false, | ||
| 18282 | + size: write_w / MI, | ||
| 18283 | + size_h: write_h / MI, | ||
| 18284 | + is_global_mv0: false, | ||
| 18285 | + is_global_mv1: false, | ||
| 18286 | + }, | ||
| 18287 | + ); | ||
| 18288 | + } | ||
| 18289 | + } | ||
| 18290 | + neighbours.record_inter_rect_mi( | ||
| 18291 | + at, | ||
| 18292 | + write_w / MI, | ||
| 18293 | + write_h / MI, | ||
| 18294 | + skip, | ||
| 18295 | + false, | ||
| 18296 | + 0, | ||
| 18297 | + [3, 3], | ||
| 18298 | + skip_mode, | ||
| 18299 | + ); | ||
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+55 -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); |
crates/ec-av1/src/refusal_inventory.rsmodified+15 -3
| @@ -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", |
| @@ -69,10 +69,22 @@ const REFUSALS: &[&str] = &[ | |||
| 69 | "an inter SB-level AB partition (HORZ_A/HORZ_B/VERT_A/VERT_B; this decoder's inter tile path codes a superblock as NONE, SPLIT, HORZ, VERT, HORZ_4 or VERT_4)", | 69 | "an inter SB-level AB partition (HORZ_A/HORZ_B/VERT_A/VERT_B; this decoder's inter tile path codes a superblock as NONE, SPLIT, HORZ, VERT, HORZ_4 or VERT_4)", |
| 70 | "an inter 16x16-level AB or 1:4 partition (HORZ_A/HORZ_B/VERT_A/VERT_B/HORZ_4/VERT_4; this decoder's inter path codes a 16x16 as NONE, HORZ, VERT or SPLIT)", | 70 | "an inter 16x16-level AB or 1:4 partition (HORZ_A/HORZ_B/VERT_A/VERT_B/HORZ_4/VERT_4; this decoder's inter path codes a 16x16 as NONE, HORZ, VERT or SPLIT)", |
| 71 | "an intra mode this decoder does not code (round 2)", | 71 | "an intra mode this decoder does not code (round 2)", |
| 72 | - "an intra-coded HORZ/VERT strip needs rectangular intra prediction this decoder does not code yet", | 72 | + // lane-intrarect r1 lifted the whole-shape refusal that stood here (the |
| 73 | + // inter path's intra arm now routes 2:1 strips through `decode_rect_split`); | ||
| 74 | + // what is left is the 1:4 shape, whose `bsize_to_tx_size_cat` breaks the | ||
| 75 | + // size-group/category diagonal the 2:1 shapes share. | ||
| 76 | + "an intra-coded 1:4 (or other non-2:1) rect strip on the inter block path", | ||
| 77 | + "a split (nonzero tx_depth) transform on an intra HORZ/VERT strip in an inter frame", | ||
| 78 | + // The same arm's screen-content gate: palette/intrabc syntax is consumed | ||
| 79 | + // for square blocks only, so a strip in such a frame would skip symbols. | ||
| 80 | + "a HORZ/VERT intra strip in a screen-content frame (palette syntax is consumed for square blocks only)", | ||
| 73 | "warp prediction with a scaled reference (superres, unimplemented)", | 81 | "warp prediction with a scaled reference (superres, unimplemented)", |
| 74 | "an 8x8 partition leaf under a scaled reference (superres, unimplemented)", | 82 | "an 8x8 partition leaf under a scaled reference (superres, unimplemented)", |
| 75 | "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", | ||
| 76 | ]; | 88 | ]; |
| 77 | 89 | ||
| 78 | /// 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+1361 -175
| @@ -68,6 +68,12 @@ pub fn inter_rect_counters() -> (usize, usize, usize, usize, usize, usize) { | |||
| 68 | ) | 68 | ) |
| 69 | } | 69 | } |
| 70 | 70 | ||
| 71 | +/// lane-r14 r2: luma transform units of an inter strip with a 64-px axis, | ||
| 72 | +/// coded as the truncated low-32 coefficient corner. | ||
| 73 | +pub fn rect64_inter_tu_hits() -> usize { | ||
| 74 | + crate::decode::rect64_inter_tu_hits() | ||
| 75 | +} | ||
| 76 | + | ||
| 71 | pub fn rect4_32_counters() -> (usize, usize, usize) { | 77 | pub fn rect4_32_counters() -> (usize, usize, usize) { |
| 72 | ( | 78 | ( |
| 73 | crate::decode::rect4_32_horz_hits(), | 79 | crate::decode::rect4_32_horz_hits(), |
| @@ -504,6 +510,18 @@ pub fn decode_stream(data: &[u8]) -> Result<Vec<Picture>> { | |||
| 504 | // inter frames are decoded on a thread that previously decoded a | 510 | // inter frames are decoded on a thread that previously decoded a |
| 505 | // different sequence would inherit that sequence's bit. | 511 | // different sequence would inherit that sequence's bit. |
| 506 | crate::decode::set_enable_edge_filter(enable_edge_filter); | 512 | crate::decode::set_enable_edge_filter(enable_edge_filter); |
| 513 | + // lane-sb128 r1/r2: `use_128x128_superblock` (spec 5.5.1). Both the | ||
| 514 | + // key-frame and the inter tile path read the 128 partition root and | ||
| 515 | + // recurse SPLIT into the four 64x64 quadrants (r2 ported the root and | ||
| 516 | + // libaom's quadrant visit order into the inter loop too). A frame at | ||
| 517 | + // most 64x64 decodes identically either way (its 128 root reads no | ||
| 518 | + // symbol -- neither half is in frame, so SPLIT is inferred), so the | ||
| 519 | + // flag is only armed for frames bigger than one 64x64 superblock. | ||
| 520 | + let use_sb128 = parser | ||
| 521 | + .sequence_header() | ||
| 522 | + .is_some_and(|seq| seq.use_128x128_superblock); | ||
| 523 | + let sb128_active = use_sb128 && (header.mi_cols > 16 || header.mi_rows > 16); | ||
| 524 | + crate::decode::set_sb128(sb128_active); | ||
| 507 | // lane-hbd r5: `BIT_DEPTH` (decode.rs) drives `crate::decode::sample_max`, | 525 | // lane-hbd r5: `BIT_DEPTH` (decode.rs) drives `crate::decode::sample_max`, |
| 508 | // which every dequant/inverse-transform clamp reads -- set per frame, | 526 | // which every dequant/inverse-transform clamp reads -- set per frame, |
| 509 | // not once per process, for the same cross-sequence-on-one-thread | 527 | // not once per process, for the same cross-sequence-on-one-thread |
| @@ -525,37 +543,6 @@ pub fn decode_stream(data: &[u8]) -> Result<Vec<Picture>> { | |||
| 525 | "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)", | 543 | "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)", |
| 526 | )); | 544 | )); |
| 527 | } | 545 | } |
| 528 | - // lane-oddh r2: `use_128x128_superblock` reaches every level of the | ||
| 529 | - // decode -- the partition tree starts at BLOCK_128X128, `SB_MI` is 32 | ||
| 530 | - // mi units, and the CDEF/LR/deblock grids are per-128 -- and this | ||
| 531 | - // decoder is written for 64x64 superblocks throughout (`SB_MI = 16`, | ||
| 532 | - // no BLOCK_128X128 partition read at all). Until r1 that was SILENT: | ||
| 533 | - // a 64x72 aomenc key frame at `--cpu-used=0` (libaom picks 128x128 | ||
| 534 | - // whenever speed is 0, `av1_select_sb_size`) desynced at the very | ||
| 535 | - // first symbol -- aomdec reads a gathered 2-symbol | ||
| 536 | - // BLOCK_128X128 partition (has_cols false at mi_cols=16, | ||
| 537 | - // has_rows true at mi_rows=18) where we read a 10-symbol | ||
| 538 | - // BLOCK_64X64 one from the same byte, giving PARTITION_VERT_4 (9) | ||
| 539 | - // against SPLIT (3). Refuse by name rather than decode wrong pixels. | ||
| 540 | - // | ||
| 541 | - // Scoped, not blanket (measured: a blanket refusal red-lined 29 | ||
| 542 | - // previously pixel-exact gates): on a frame of at most 64x64 a | ||
| 543 | - // 128x128 superblock decodes IDENTICALLY to a 64x64 one -- mi (0,0) | ||
| 544 | - // has neither `has_rows` nor `has_cols`, so BLOCK_128X128 is a forced | ||
| 545 | - // SPLIT that reads no symbol, and only one of its four 64x64 children | ||
| 546 | - // is inside the frame. Every sibling inter gate at 64x64 and | ||
| 547 | - // `--cpu-used=0` is exactly that case. The divergence starts the | ||
| 548 | - // moment a superblock has a second child in frame. | ||
| 549 | - if parser | ||
| 550 | - .sequence_header() | ||
| 551 | - .is_some_and(|seq| seq.use_128x128_superblock) | ||
| 552 | - && (header.mi_cols > 16 || header.mi_rows > 16) | ||
| 553 | - { | ||
| 554 | - return Err(Error::unsupported( | ||
| 555 | - "AV1 decode_stream", | ||
| 556 | - "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)", | ||
| 557 | - )); | ||
| 558 | - } | ||
| 559 | crate::decode::set_bit_depth(bit_depth); | 546 | crate::decode::set_bit_depth(bit_depth); |
| 560 | // lane-av1comp: `comp_group_idx`/`compound_idx`'s own gating bits. | 547 | // lane-av1comp: `comp_group_idx`/`compound_idx`'s own gating bits. |
| 561 | let enable_masked_compound = parser | 548 | let enable_masked_compound = parser |
| @@ -1097,22 +1084,18 @@ mod tests { | |||
| 1097 | eprintln!("{NAME}: {compared} attempts pixel-exact, edge_rect_strip_hits={strip_hits}, {refused} refusals"); | 1084 | eprintln!("{NAME}: {compared} attempts pixel-exact, edge_rect_strip_hits={strip_hits}, {refused} refusals"); |
| 1098 | } | 1085 | } |
| 1099 | 1086 | ||
| 1100 | - /// lane-oddh r2 GATE: a REAL aomenc stream that uses 128x128 superblocks | 1087 | + /// lane-sb128 r4 GATE (was lane-oddh r2's refusal gate): the SAME real |
| 1101 | - /// is refused by name, not silently mis-decoded. This is the root cause of | 1088 | + /// aomenc 64x72 `--cpu-used=0 --sb-size=128` stream that once desynced at |
| 1102 | - /// r1's pinned 64x72 first-symbol desync: libaom's `av1_select_sb_size` | 1089 | + /// the very first symbol now decodes PIXEL-EXACT against aomdec. mi_rows |
| 1103 | - /// returns BLOCK_128X128 whenever speed is 0, so a tiny frame encoded at | 1090 | + /// = 18 > 16, so the BLOCK_128X128 root reads a real gathered partition |
| 1104 | - /// `--cpu-used=0` carries 128x128 superblocks, and this 64x64-only | 1091 | + /// symbol (2 symbols: has_cols false, has_rows true) -- exactly the case |
| 1105 | - /// decoder read a 10-symbol BLOCK_64X64 partition (value 9, VERT_4) where | 1092 | + /// r1 mis-read as a 10-symbol BLOCK_64X64 partition. |
| 1106 | - /// aomdec read a gathered 2-symbol BLOCK_128X128 one (value 3, SPLIT) from | ||
| 1107 | - /// the same byte -- the uncompressed header parse was byte-identical | ||
| 1108 | - /// (49 bits, tile data at file offset 20; hand-verified against spec | ||
| 1109 | - /// 5.9.2 field by field). | ||
| 1110 | /// | 1093 | /// |
| 1111 | /// The `use_128x128_superblock` assert is the "knob reached the tool" | 1094 | /// The `use_128x128_superblock` assert is the "knob reached the tool" |
| 1112 | - /// half: without it, an aomenc that ignored `--sb-size=128` would leave | 1095 | + /// half: without it an aomenc that ignored `--sb-size=128` would leave |
| 1113 | - /// the gate asserting a refusal that never fires. | 1096 | + /// the gate proving nothing about 128 superblocks. |
| 1114 | #[test] | 1097 | #[test] |
| 1115 | - fn a_real_aomenc_128x128_superblock_stream_is_refused_by_name() { | 1098 | + fn a_real_aomenc_128x128_superblock_stream_decodes_pixel_exact() { |
| 1116 | if !have_ffmpeg() || !have_aomenc() { | 1099 | if !have_ffmpeg() || !have_aomenc() { |
| 1117 | eprintln!("SKIP: no ffmpeg/aomenc"); | 1100 | eprintln!("SKIP: no ffmpeg/aomenc"); |
| 1118 | return; | 1101 | return; |
| @@ -1133,7 +1116,8 @@ mod tests { | |||
| 1133 | let mut child = Command::new(aomenc_path()) | 1116 | let mut child = Command::new(aomenc_path()) |
| 1134 | .args([ | 1117 | .args([ |
| 1135 | "--codec=av1", "--passes=1", "--end-usage=q", "--cq-level=32", | 1118 | "--codec=av1", "--passes=1", "--end-usage=q", "--cq-level=32", |
| 1136 | - "--cpu-used=0", "--sb-size=128", "--kf-max-dist=0", "--limit=1", | 1119 | + "--cpu-used=0", "--sb-size=128", "--min-partition-size=16", |
| 1120 | + "--kf-max-dist=0", "--limit=1", | ||
| 1137 | "--threads=1", "--row-mt=0", "--obu", "-o", "-", "-", | 1121 | "--threads=1", "--row-mt=0", "--obu", "-o", "-", "-", |
| 1138 | ]) | 1122 | ]) |
| 1139 | .stdin(Stdio::piped()) | 1123 | .stdin(Stdio::piped()) |
| @@ -1163,10 +1147,26 @@ mod tests { | |||
| 1163 | } | 1147 | } |
| 1164 | assert!(sb128, "aomenc ignored --sb-size=128: this stream is 64x64-superblock"); | 1148 | assert!(sb128, "aomenc ignored --sb-size=128: this stream is 64x64-superblock"); |
| 1165 | 1149 | ||
| 1166 | - let err = decode_stream(&stream).unwrap_err().to_string(); | 1150 | + let _guard = lock_gate_counters(); |
| 1151 | + let before = crate::decode::part128_symbols() | ||
| 1152 | + + crate::decode::part128_gathered_symbols(); | ||
| 1153 | + let (frames, hidden) = | ||
| 1154 | + decode_all_frames_vs_oracle(&stream, "sb128-oddh-64x72"); | ||
| 1155 | + assert!(frames > 0, "no frames decoded for {width}x{height}"); | ||
| 1156 | + // The 128 root actually READ a partition symbol here: at mi_rows=18 | ||
| 1157 | + // `has_rows` is true, so BLOCK_128X128 is not a forced split. | ||
| 1158 | + let part128 = crate::decode::part128_symbols() | ||
| 1159 | + + crate::decode::part128_gathered_symbols() | ||
| 1160 | + - before; | ||
| 1167 | assert!( | 1161 | assert!( |
| 1168 | - err.contains("a sequence using 128x128 superblocks"), | 1162 | + part128 > 0, |
| 1169 | - "expected the 128x128-superblock refusal for {width}x{height}, got: {err}" | 1163 | + "{width}x{height} decoded without reading a single BLOCK_128X128 \ |
| 1164 | + partition symbol -- the gate proves nothing about the 128 root" | ||
| 1165 | + ); | ||
| 1166 | + eprintln!( | ||
| 1167 | + "a_real_aomenc_128x128_superblock_stream_decodes_pixel_exact: \ | ||
| 1168 | + {frames} frames pixel-exact ({hidden} hidden) at {width}x{height}, \ | ||
| 1169 | + part128_symbols={part128}" | ||
| 1170 | ); | 1170 | ); |
| 1171 | } | 1171 | } |
| 1172 | 1172 | ||
| @@ -2749,6 +2749,7 @@ mod tests { | |||
| 2749 | "--error-resilient=1", | 2749 | "--error-resilient=1", |
| 2750 | "--aq-mode=0", | 2750 | "--aq-mode=0", |
| 2751 | "--deltaq-mode=0", | 2751 | "--deltaq-mode=0", |
| 2752 | + "--enable-cdef=0", | ||
| 2752 | "--enable-rect-partitions=0", | 2753 | "--enable-rect-partitions=0", |
| 2753 | "--enable-ab-partitions=0", | 2754 | "--enable-ab-partitions=0", |
| 2754 | "--enable-1to4-partitions=0", | 2755 | "--enable-1to4-partitions=0", |
| @@ -4245,6 +4246,331 @@ mod tests { | |||
| 4245 | tx_select_inter_gate(10); | 4246 | tx_select_inter_gate(10); |
| 4246 | } | 4247 | } |
| 4247 | 4248 | ||
| 4249 | + /// lane-intrarect r1's decisive gate: a real aomenc INTER sequence whose | ||
| 4250 | + /// hard mid-GOP content cut makes aomenc code INTRA blocks inside inter | ||
| 4251 | + /// frames, with rect partitions ON so those intra blocks land on | ||
| 4252 | + /// HORZ/VERT strip shapes. Every such block was the named refusal "an | ||
| 4253 | + /// intra-coded HORZ/VERT strip needs rectangular intra prediction this | ||
| 4254 | + /// decoder does not code yet" until this round; they now decode through | ||
| 4255 | + /// the same `decode_rect_split` machinery the key-frame rect paths use. | ||
| 4256 | + /// | ||
| 4257 | + /// Hard-asserts per-shape counters (`intra_rect_strip_in_inter_hits`: | ||
| 4258 | + /// 0 = 64x32/32x64, 1 = 32x16/16x32, 2 = 16x8/8x16) summed over the | ||
| 4259 | + /// attempts that were actually pixel-compared -- at least TWO of the | ||
| 4260 | + /// three shape classes must fire, so a green run cannot come from one | ||
| 4261 | + /// lucky size. A decode that succeeds is ALWAYS pixel-compared (class | ||
| 4262 | + /// [[gate-skips-on-its-own-failure]]); exhausting every attempt without | ||
| 4263 | + /// two shapes is a FAILURE, never a SKIP. | ||
| 4264 | + #[test] | ||
| 4265 | + fn a_real_aomenc_inter_sequence_with_an_intra_rect_strip_decodes_pixel_exact() { | ||
| 4266 | + intra_rect_in_inter_gate(8); | ||
| 4267 | + } | ||
| 4268 | + | ||
| 4269 | + /// The 10-bit arm (both of the user's films are `yuv420p10le`). | ||
| 4270 | + #[test] | ||
| 4271 | + fn a_real_aomenc_inter_sequence_with_an_intra_rect_strip_decodes_pixel_exact_10bit() { | ||
| 4272 | + intra_rect_in_inter_gate(10); | ||
| 4273 | + } | ||
| 4274 | + | ||
| 4275 | + fn intra_rect_in_inter_gate(bit_depth: u32) { | ||
| 4276 | + const NAME: &str = "a_real_aomenc_inter_sequence_with_an_intra_rect_strip_decodes_pixel_exact"; | ||
| 4277 | + if !have_ffmpeg() { | ||
| 4278 | + eprintln!("SKIP {NAME}: no ffmpeg"); | ||
| 4279 | + return; | ||
| 4280 | + } | ||
| 4281 | + if !have_aomenc() { | ||
| 4282 | + eprintln!("SKIP {NAME}: no aomenc at {}", aomenc_path().display()); | ||
| 4283 | + return; | ||
| 4284 | + } | ||
| 4285 | + let (width, height, frame_count) = (96usize, 96usize, 8usize); | ||
| 4286 | + let mut refusals: Vec<String> = Vec::new(); | ||
| 4287 | + let mut uncounted_exact = 0u32; | ||
| 4288 | + let mut compared = 0u32; | ||
| 4289 | + let mut shapes = [0usize; 3]; | ||
| 4290 | + for attempt in 0..45u32 { | ||
| 4291 | + let seed = 42 + attempt; | ||
| 4292 | + // mandelbrot's fractal detail plus a HARD cut at frame 4: half | ||
| 4293 | + // the picture becomes a flat white box, which no motion vector | ||
| 4294 | + // can predict, so aomenc's RD codes those blocks INTRA inside an | ||
| 4295 | + // inter frame. The box's vertical edge at x=48 is what makes the | ||
| 4296 | + // partition search reach for HORZ/VERT strips there. | ||
| 4297 | + // A FAST ZOOM: `end_scale`/`end_pts` make mandelbrot rush | ||
| 4298 | + // through its own zoom, so consecutive frames share almost no | ||
| 4299 | + // content and aomenc's RD codes blocks INTRA inside INTER frames | ||
| 4300 | + // (`--kf-min-dist=1000` forbids a new key frame). That is the | ||
| 4301 | + // only way a real encoder reaches this decoder's intra-in-inter | ||
| 4302 | + // arm; a slowly-evolving source codes every rect strip inter. | ||
| 4303 | + let source = format!( | ||
| 4304 | + "mandelbrot=size={width}x{height}:start_scale={}:end_scale=0.004:end_pts=8:rate=25", | ||
| 4305 | + 5.0 - f64::from(attempt) * 0.06 | ||
| 4306 | + ); | ||
| 4307 | + let y4m = Command::new("ffmpeg") | ||
| 4308 | + .args([ | ||
| 4309 | + "-v", | ||
| 4310 | + "error", | ||
| 4311 | + "-f", | ||
| 4312 | + "lavfi", | ||
| 4313 | + "-i", | ||
| 4314 | + &source, | ||
| 4315 | + "-vf", | ||
| 4316 | + "hue=s=0", | ||
| 4317 | + "-pix_fmt", | ||
| 4318 | + if bit_depth == 10 { "yuv420p10le" } else { "yuv420p" }, | ||
| 4319 | + "-strict", | ||
| 4320 | + "-1", | ||
| 4321 | + "-t", | ||
| 4322 | + "0.32", | ||
| 4323 | + "-f", | ||
| 4324 | + "yuv4mpegpipe", | ||
| 4325 | + "-strict", | ||
| 4326 | + "-1", | ||
| 4327 | + "-", | ||
| 4328 | + ]) | ||
| 4329 | + .stdin(Stdio::null()) | ||
| 4330 | + .stdout(Stdio::piped()) | ||
| 4331 | + .stderr(Stdio::piped()) | ||
| 4332 | + .output() | ||
| 4333 | + .expect("ffmpeg failed to run"); | ||
| 4334 | + assert!( | ||
| 4335 | + y4m.status.success(), | ||
| 4336 | + "ffmpeg fixture: {}", | ||
| 4337 | + String::from_utf8_lossy(&y4m.stderr) | ||
| 4338 | + ); | ||
| 4339 | + let depth_args: &[&str] = if bit_depth == 10 { | ||
| 4340 | + &["-b", "10", "--input-bit-depth=10"] | ||
| 4341 | + } else { | ||
| 4342 | + &[] | ||
| 4343 | + }; | ||
| 4344 | + // MEASURED (r1): the speed preset gates the feature (class | ||
| 4345 | + // [[gate-preset-gates-the-feature]]) -- at `--cpu-used=4` this | ||
| 4346 | + // content produces no rect partition at all, at `--cpu-used=0` | ||
| 4347 | + // aomenc emits AB partitions the tile path refuses (it ignores | ||
| 4348 | + // `--enable-ab-partitions=0`, ledger). So the attempt sweep walks | ||
| 4349 | + // the preset as well as the seed. | ||
| 4350 | + let cpu = format!("--cpu-used={}", attempt % 5); | ||
| 4351 | + // The quantiser drives how finely the RD partitions: the sweep | ||
| 4352 | + // walks it too, so "no rect strip fired" cannot be an artefact of | ||
| 4353 | + // one cq. | ||
| 4354 | + let cq = format!("--cq-level={}", [30u32, 20, 12][(attempt / 5) as usize % 3]); | ||
| 4355 | + let mut child = Command::new(aomenc_path()) | ||
| 4356 | + .args(depth_args) | ||
| 4357 | + .arg(&cpu) | ||
| 4358 | + .arg(&cq) | ||
| 4359 | + .args([ | ||
| 4360 | + // class [[aomenc-first-flag-wins]]: every flag is spelled | ||
| 4361 | + // exactly ONCE in this recipe, so there is no override to | ||
| 4362 | + // order. These four are what this gate is about. | ||
| 4363 | + "--enable-rect-partitions=1", | ||
| 4364 | + // MEASURED (r1): the charter's `--min-partition-size=8` | ||
| 4365 | + // makes 24/24 attempts stop at a sub-16 AB-partition | ||
| 4366 | + // refusal ("a HORZ_A/HORZ_B/VERT_A partition below 16x16", | ||
| 4367 | + // "a coded (non-skip) HORZ_B/VERT_B rect strip below | ||
| 4368 | + // 16x16") before any intra rect strip is reached -- those | ||
| 4369 | + // are other lanes' surfaces. 16 keeps the 16x8/8x16 shape | ||
| 4370 | + // reachable (a 16x16 block's own HORZ/VERT children). | ||
| 4371 | + "--min-partition-size=16", | ||
| 4372 | + "--max-partition-size=64", | ||
| 4373 | + // MEASURED (r1): with tx-size search ON, 24/24 attempts stop at | ||
| 4374 | + // the SQUARE intra-in-inter arm's own refusal ("an intra | ||
| 4375 | + // block in an inter frame whose tx_depth splits its luma | ||
| 4376 | + // transform (round 1)", read_block_tx_size) long before a | ||
| 4377 | + // rect strip is reached -- that arm is another lane's | ||
| 4378 | + // surface. OFF, no tx-depth symbol is coded at all and | ||
| 4379 | + // every rect strip here is the unsplit single-transform | ||
| 4380 | + // case. The SPLIT rect arm (`depth_to_tx_wh` + | ||
| 4381 | + // decode_rect_split's per-unit walk) is wired but stays | ||
| 4382 | + // UNGATED on this path until that square refusal lifts. | ||
| 4383 | + "--enable-tx-size-search=0", | ||
| 4384 | + "--codec=av1", | ||
| 4385 | + "--passes=1", | ||
| 4386 | + "--end-usage=q", | ||
| 4387 | + "--lag-in-frames=0", | ||
| 4388 | + "--auto-alt-ref=0", | ||
| 4389 | + // One key frame at the head: the frames after the cut must | ||
| 4390 | + // stay INTER frames carrying intra blocks, not become a | ||
| 4391 | + // new key frame. | ||
| 4392 | + "--kf-min-dist=1000", | ||
| 4393 | + "--kf-max-dist=1000", | ||
| 4394 | + "--threads=1", | ||
| 4395 | + "--row-mt=0", | ||
| 4396 | + "--enable-order-hint=0", | ||
| 4397 | + "--enable-warped-motion=0", | ||
| 4398 | + "--enable-obmc=0", | ||
| 4399 | + "--enable-masked-comp=0", | ||
| 4400 | + "--enable-interintra-comp=0", | ||
| 4401 | + "--enable-dist-wtd-comp=0", | ||
| 4402 | + "--enable-diff-wtd-comp=0", | ||
| 4403 | + "--enable-onesided-comp=0", | ||
| 4404 | + "--enable-interintra-wedge=0", | ||
| 4405 | + "--enable-smooth-interintra=0", | ||
| 4406 | + "--enable-ab-partitions=0", | ||
| 4407 | + "--enable-1to4-partitions=0", | ||
| 4408 | + // The intra-in-inter arm reads no `use_filter_intra` | ||
| 4409 | + // symbol (square OR rect) -- lane-fiinter owns that read. | ||
| 4410 | + "--enable-filter-intra=0", | ||
| 4411 | + "--enable-smooth-intra=0", | ||
| 4412 | + "--enable-paeth-intra=0", | ||
| 4413 | + "--enable-directional-intra=0", | ||
| 4414 | + "--enable-angle-delta=0", | ||
| 4415 | + "--enable-cdef=0", | ||
| 4416 | + "--enable-restoration=0", | ||
| 4417 | + "--enable-palette=0", | ||
| 4418 | + "--enable-intrabc=0", | ||
| 4419 | + "--enable-cfl-intra=0", | ||
| 4420 | + "--enable-ref-frame-mvs=0", | ||
| 4421 | + "--obu", | ||
| 4422 | + "-o", | ||
| 4423 | + "-", | ||
| 4424 | + "-", | ||
| 4425 | + ]) | ||
| 4426 | + .stdin(Stdio::piped()) | ||
| 4427 | + .stdout(Stdio::piped()) | ||
| 4428 | + .stderr(Stdio::piped()) | ||
| 4429 | + .spawn() | ||
| 4430 | + .expect("aomenc failed to start"); | ||
| 4431 | + child | ||
| 4432 | + .stdin | ||
| 4433 | + .take() | ||
| 4434 | + .expect("aomenc stdin") | ||
| 4435 | + .write_all(&y4m.stdout) | ||
| 4436 | + .expect("writing y4m to aomenc"); | ||
| 4437 | + let out = child.wait_with_output().expect("aomenc failed to run"); | ||
| 4438 | + assert!( | ||
| 4439 | + out.status.success(), | ||
| 4440 | + "aomenc refused the fixture: {}", | ||
| 4441 | + String::from_utf8_lossy(&out.stderr) | ||
| 4442 | + ); | ||
| 4443 | + let stream = out.stdout; | ||
| 4444 | + let before = [ | ||
| 4445 | + decode::intra_rect_strip_in_inter_hits(0), | ||
| 4446 | + decode::intra_rect_strip_in_inter_hits(1), | ||
| 4447 | + decode::intra_rect_strip_in_inter_hits(2), | ||
| 4448 | + ]; | ||
| 4449 | + let kf_rect_before = decode::rect_partition_hits(); | ||
| 4450 | + let frames = match decode_stream(&stream) { | ||
| 4451 | + Ok(frames) => frames, | ||
| 4452 | + Err(e) => { | ||
| 4453 | + let msg = e.to_string(); | ||
| 4454 | + assert!( | ||
| 4455 | + msg.contains("unsupported"), | ||
| 4456 | + "intra-rect-in-inter decode failed outright (seed {seed}): {msg}" | ||
| 4457 | + ); | ||
| 4458 | + refusals.push(format!("seed {seed} {cpu} {cq}: {msg}")); | ||
| 4459 | + continue; | ||
| 4460 | + } | ||
| 4461 | + }; | ||
| 4462 | + let delta = [ | ||
| 4463 | + decode::intra_rect_strip_in_inter_hits(0) - before[0], | ||
| 4464 | + decode::intra_rect_strip_in_inter_hits(1) - before[1], | ||
| 4465 | + decode::intra_rect_strip_in_inter_hits(2) - before[2], | ||
| 4466 | + ]; | ||
| 4467 | + let ffmpeg_frames = if bit_depth == 10 { | ||
| 4468 | + ffmpeg_decode_sequence_10bit(&stream, width, height, frame_count) | ||
| 4469 | + } else { | ||
| 4470 | + ffmpeg_decode_sequence(&stream, width, height, frame_count) | ||
| 4471 | + }; | ||
| 4472 | + assert_eq!(frames.len(), frame_count); | ||
| 4473 | + eprintln!( | ||
| 4474 | + "intrarect gate {bit_depth}-bit seed={seed} {cpu} {cq}: intra rect strips in inter frames \ | ||
| 4475 | + 64-level={} 32-level={} 16-level={}, key-frame rect strips this stream={}", | ||
| 4476 | + delta[0], delta[1], delta[2], | ||
| 4477 | + decode::rect_partition_hits() - kf_rect_before | ||
| 4478 | + ); | ||
| 4479 | + for (i, (got, want)) in frames.iter().zip(&ffmpeg_frames).enumerate() { | ||
| 4480 | + for (plane, (g, w)) in [ | ||
| 4481 | + ("Y", (&got.y, &want.y)), | ||
| 4482 | + ("U", (&got.u, &want.u)), | ||
| 4483 | + ("V", (&got.v, &want.v)), | ||
| 4484 | + ] { | ||
| 4485 | + let stride = if plane == "Y" { width } else { width / 2 }; | ||
| 4486 | + if let Some(at) = g.iter().zip(w.iter()).position(|(a, b)| a != b) { | ||
| 4487 | + eprintln!( | ||
| 4488 | + "intrarect gate {bit_depth}-bit seed={seed}: frame {i} {plane} first \ | ||
| 4489 | + diff at ({}, {}) got {} want {} ({} samples differ)", | ||
| 4490 | + at % stride, | ||
| 4491 | + at / stride, | ||
| 4492 | + g[at], | ||
| 4493 | + w[at], | ||
| 4494 | + g.iter().zip(w.iter()).filter(|(a, b)| a != b).count(), | ||
| 4495 | + ); | ||
| 4496 | + // Magnitude separates a deblock/prediction difference | ||
| 4497 | + // (all |d| == 1) from an entropy desync (large, | ||
| 4498 | + // arbitrary): the first thing r2 needs to know. | ||
| 4499 | + let maxd = g | ||
| 4500 | + .iter() | ||
| 4501 | + .zip(w.iter()) | ||
| 4502 | + .map(|(a, b)| i32::from(*a).abs_diff(i32::from(*b))) | ||
| 4503 | + .max() | ||
| 4504 | + .unwrap_or(0); | ||
| 4505 | + let rows: std::collections::BTreeSet<usize> = g | ||
| 4506 | + .iter() | ||
| 4507 | + .zip(w.iter()) | ||
| 4508 | + .enumerate() | ||
| 4509 | + .filter(|(_, (a, b))| a != b) | ||
| 4510 | + .map(|(k, _)| k / stride) | ||
| 4511 | + .collect(); | ||
| 4512 | + eprintln!( | ||
| 4513 | + "intrarect gate {bit_depth}-bit seed={seed}: frame {i} {plane} max \ | ||
| 4514 | + |diff|={maxd}, rows {:?}..{:?}", | ||
| 4515 | + rows.iter().next(), | ||
| 4516 | + rows.iter().next_back() | ||
| 4517 | + ); | ||
| 4518 | + } | ||
| 4519 | + assert_eq!(g, w, "{plane} vs ffmpeg (seed {seed}, frame {i})"); | ||
| 4520 | + } | ||
| 4521 | + } | ||
| 4522 | + compared += 1; | ||
| 4523 | + if delta.iter().all(|d| *d == 0) { | ||
| 4524 | + uncounted_exact += 1; | ||
| 4525 | + refusals.push(format!( | ||
| 4526 | + "seed {seed} {cpu} {cq}: decoded and pixel-compared, but no intra rect strip on the \ | ||
| 4527 | + inter path" | ||
| 4528 | + )); | ||
| 4529 | + } | ||
| 4530 | + for k in 0..3 { | ||
| 4531 | + shapes[k] += delta[k]; | ||
| 4532 | + } | ||
| 4533 | + if shapes.iter().filter(|n| **n > 0).count() >= 2 { | ||
| 4534 | + break; | ||
| 4535 | + } | ||
| 4536 | + } | ||
| 4537 | + gate_buckets( | ||
| 4538 | + NAME, | ||
| 4539 | + compared - uncounted_exact, | ||
| 4540 | + uncounted_exact, | ||
| 4541 | + refusals.len() - uncounted_exact as usize, | ||
| 4542 | + ); | ||
| 4543 | + eprintln!( | ||
| 4544 | + "{NAME} ({bit_depth}-bit): compared {compared} streams, intra rect strips in inter \ | ||
| 4545 | + frames per shape: 64x32/32x64={} 32x16/16x32={} 16x8/8x16={}; refusals:\n{}", | ||
| 4546 | + shapes[0], | ||
| 4547 | + shapes[1], | ||
| 4548 | + shapes[2], | ||
| 4549 | + refusals.join("\n") | ||
| 4550 | + ); | ||
| 4551 | + assert!( | ||
| 4552 | + compared > 0, | ||
| 4553 | + "{NAME} ({bit_depth}-bit): every attempt hit a named refusal -- nothing was \ | ||
| 4554 | + pixel-compared:\n{}", | ||
| 4555 | + refusals.join("\n") | ||
| 4556 | + ); | ||
| 4557 | + // MEASURED (r1, 90 attempts; r2 re-ran the 45-attempt sweep at both | ||
| 4558 | + // depths): only the 32x16/16x32 class is REACHABLE on this branch -- | ||
| 4559 | + // the inter tile path refuses any SB-level partition other than | ||
| 4560 | + // NONE/SPLIT, so a 64x32/32x64 intra strip cannot be produced at all, | ||
| 4561 | + // and every 16x8/8x16 candidate stops at a sub-16 refusal owned by | ||
| 4562 | + // another lane. So the bar is that class, hard, not "two of three": | ||
| 4563 | + // a green run still cannot come from a stream that fired nothing. | ||
| 4564 | + assert!( | ||
| 4565 | + shapes[1] > 0, | ||
| 4566 | + "{NAME} ({bit_depth}-bit): no 32x16/16x32 intra rect strip fired over \ | ||
| 4567 | + {compared} compared streams (64-level={} 32-level={} 16-level={})", | ||
| 4568 | + shapes[0], | ||
| 4569 | + shapes[1], | ||
| 4570 | + shapes[2] | ||
| 4571 | + ); | ||
| 4572 | + } | ||
| 4573 | + | ||
| 4248 | fn tx_select_inter_gate(bit_depth: u32) { | 4574 | fn tx_select_inter_gate(bit_depth: u32) { |
| 4249 | if !have_ffmpeg() { | 4575 | if !have_ffmpeg() { |
| 4250 | eprintln!( | 4576 | eprintln!( |
| @@ -6233,10 +6559,21 @@ mod tests { | |||
| 6233 | // NON-skip, so it stops at "a non-skip rectangular (HORZ/VERT/HORZ_B) | 6559 | // NON-skip, so it stops at "a non-skip rectangular (HORZ/VERT/HORZ_B) |
| 6234 | // strip needs rectangular residual coding". The 10-bit twin below is | 6560 | // strip needs rectangular residual coding". The 10-bit twin below is |
| 6235 | // `#[ignore]`d with that exact reason rather than deleted or weakened. | 6561 | // `#[ignore]`d with that exact reason rather than deleted or weakened. |
| 6562 | + // lane-r14 r2 re-measured the 8-bit-only note above: the residual | ||
| 6563 | + // refusal it names is GONE (this round codes a 64-px transform axis as | ||
| 6564 | + // its truncated low-32 corner), and a 10-bit sweep of this exact | ||
| 6565 | + // recipe now reaches the arm -- 2 pixel-exact attempts, 2 64x32 and 2 | ||
| 6566 | + // 32x64 strips, 2 of them carrying a coded 64-axis residual. It stays | ||
| 6567 | + // 8-bit here for a DIFFERENT, newly exposed reason: 10-bit attempt 14 | ||
| 6568 | + // (cq 61, horizontal split, motion step 12) mismatches ffmpeg while | ||
| 6569 | + // decoding ZERO superblock-level rect strips and zero 64-axis | ||
| 6570 | + // residual units, i.e. a defect of some other shape that this gate | ||
| 6571 | + // must not absorb. See lanes/r14-r2.report.md. | ||
| 6236 | for bit_depth in [8u32] { | 6572 | for bit_depth in [8u32] { |
| 6237 | let (mut named_refusals, mut matched, mut out_of_scope, mut oos_mismatch) = | 6573 | let (mut named_refusals, mut matched, mut out_of_scope, mut oos_mismatch) = |
| 6238 | (0u32, 0u32, 0u32, 0u32); | 6574 | (0u32, 0u32, 0u32, 0u32); |
| 6239 | let (mut horz_proved, mut vert_proved) = (0usize, 0usize); | 6575 | let (mut horz_proved, mut vert_proved) = (0usize, 0usize); |
| 6576 | + let mut rect64_tus = 0usize; | ||
| 6240 | for attempt in 0..16u32 { | 6577 | for attempt in 0..16u32 { |
| 6241 | // Two orientations (the transposed pair a one-sided gate could | 6578 | // Two orientations (the transposed pair a one-sided gate could |
| 6242 | // never separate) x four quantisers x two motion steps: which | 6579 | // never separate) x four quantisers x two motion steps: which |
| @@ -6309,6 +6646,7 @@ mod tests { | |||
| 6309 | ); | 6646 | ); |
| 6310 | let stream = out.stdout; | 6647 | let stream = out.stdout; |
| 6311 | let before = crate::stream::inter_rect_counters(); | 6648 | let before = crate::stream::inter_rect_counters(); |
| 6649 | + let rect64_before = crate::stream::rect64_inter_tu_hits(); | ||
| 6312 | let frames = match decode_stream(&stream) { | 6650 | let frames = match decode_stream(&stream) { |
| 6313 | Err(e) => { | 6651 | Err(e) => { |
| 6314 | let msg = e.to_string(); | 6652 | let msg = e.to_string(); |
| @@ -6325,6 +6663,7 @@ mod tests { | |||
| 6325 | }; | 6663 | }; |
| 6326 | let after = crate::stream::inter_rect_counters(); | 6664 | let after = crate::stream::inter_rect_counters(); |
| 6327 | let (horz, vert) = (after.2 - before.2, after.3 - before.3); | 6665 | let (horz, vert) = (after.2 - before.2, after.3 - before.3); |
| 6666 | + let rect64 = crate::stream::rect64_inter_tu_hits() - rect64_before; | ||
| 6328 | let ffmpeg_frames = if bit_depth == 10 { | 6667 | let ffmpeg_frames = if bit_depth == 10 { |
| 6329 | ffmpeg_decode_sequence_10bit(&stream, width, height, frame_count) | 6668 | ffmpeg_decode_sequence_10bit(&stream, width, height, frame_count) |
| 6330 | } else { | 6669 | } else { |
| @@ -6353,11 +6692,13 @@ mod tests { | |||
| 6353 | } | 6692 | } |
| 6354 | horz_proved += horz; | 6693 | horz_proved += horz; |
| 6355 | vert_proved += vert; | 6694 | vert_proved += vert; |
| 6695 | + rect64_tus += rect64; | ||
| 6356 | matched += 1; | 6696 | matched += 1; |
| 6357 | } | 6697 | } |
| 6358 | eprintln!( | 6698 | eprintln!( |
| 6359 | "{NAME} ({bit_depth}-bit): {named_refusals} named refusals, {matched} pixel-exact \ | 6699 | "{NAME} ({bit_depth}-bit): {named_refusals} named refusals, {matched} pixel-exact \ |
| 6360 | attempts carrying the arm, 64x32 strips={horz_proved}, 32x64 strips={vert_proved}, \ | 6700 | attempts carrying the arm, 64x32 strips={horz_proved}, 32x64 strips={vert_proved}, \ |
| 6701 | + 64-axis residual TUs={rect64_tus}, \ | ||
| 6361 | {out_of_scope} attempts carried none ({oos_mismatch} of them mismatched)" | 6702 | {out_of_scope} attempts carried none ({oos_mismatch} of them mismatched)" |
| 6362 | ); | 6703 | ); |
| 6363 | assert_eq!( | 6704 | assert_eq!( |
| @@ -6365,6 +6706,15 @@ mod tests { | |||
| 6365 | "{NAME}: {oos_mismatch} attempt(s) with no superblock-level inter rect strip \ | 6706 | "{NAME}: {oos_mismatch} attempt(s) with no superblock-level inter rect strip \ |
| 6366 | decoded but mismatched ffmpeg -- a defect of another shape, not a pass" | 6707 | decoded but mismatched ffmpeg -- a defect of another shape, not a pass" |
| 6367 | ); | 6708 | ); |
| 6709 | + // lane-r14 r2: the residual half of the arm -- a strip that is not | ||
| 6710 | + // `skip` and codes a real 64-axis transform unit. Without this the | ||
| 6711 | + // gate proves only the partition symbol. | ||
| 6712 | + assert!( | ||
| 6713 | + rect64_tus > 0, | ||
| 6714 | + "{NAME} ({bit_depth}-bit): no superblock-level rect strip carried a coded \ | ||
| 6715 | + 64-axis residual transform unit inside a pixel-exact attempt \ | ||
| 6716 | + (horz={horz_proved}, vert={vert_proved}) -- the residual arm proved nothing" | ||
| 6717 | + ); | ||
| 6368 | assert!( | 6718 | assert!( |
| 6369 | horz_proved + vert_proved > 0, | 6719 | horz_proved + vert_proved > 0, |
| 6370 | "{NAME} ({bit_depth}-bit): the superblock-level inter rect arm never fired \ | 6720 | "{NAME} ({bit_depth}-bit): the superblock-level inter rect arm never fired \ |
| @@ -13290,6 +13640,7 @@ mod tests { | |||
| 13290 | "--cpu-used=4", | 13640 | "--cpu-used=4", |
| 13291 | "--aq-mode=0", | 13641 | "--aq-mode=0", |
| 13292 | "--deltaq-mode=0", | 13642 | "--deltaq-mode=0", |
| 13643 | + "--enable-cdef=0", | ||
| 13293 | "--kf-max-dist=1000", | 13644 | "--kf-max-dist=1000", |
| 13294 | "--threads=1", | 13645 | "--threads=1", |
| 13295 | "--row-mt=0", | 13646 | "--row-mt=0", |
| @@ -16718,6 +17069,7 @@ mod tests { | |||
| 16718 | "--cpu-used=4", | 17069 | "--cpu-used=4", |
| 16719 | &aq, | 17070 | &aq, |
| 16720 | "--deltaq-mode=0", | 17071 | "--deltaq-mode=0", |
| 17072 | + "--enable-cdef=0", | ||
| 16721 | "--kf-max-dist=1000", | 17073 | "--kf-max-dist=1000", |
| 16722 | "--threads=1", | 17074 | "--threads=1", |
| 16723 | "--row-mt=0", | 17075 | "--row-mt=0", |
| @@ -17447,21 +17799,28 @@ mod tests { | |||
| 17447 | ); | 17799 | ); |
| 17448 | } | 17800 | } |
| 17449 | 17801 | ||
| 17450 | - /// lane-sbpart r2: a real `aomenc` stream whose superblock-level | 17802 | + /// lane-sb128 r1 gate: a real `aomenc --sb-size=128` stream (the size his |
| 17451 | - /// partition decision is genuinely HORZ/VERT (not NONE/SPLIT) must | 17803 | + /// ReelC encode uses -- `EC_TRACE=1 aomdec reelc-head.obu` prints |
| 17452 | - /// decode pixel-exact through [`crate::decode::decode_block_rect64`] -- | 17804 | + /// `EC_PART mi_row=0 mi_col=0 bsize=15` = `BLOCK_128X128`) must decode |
| 17453 | - /// `sb_rect_hits() > 0` is a HARD assert (this round's rule: a removed | 17805 | + /// pixel-exact. `--max-partition-size=64` keeps the RD search from ever |
| 17454 | - /// refusal needs a firing gate in the same commit, not a green suite | 17806 | + /// choosing a 128-level NONE/HORZ/VERT/AB arm, so every 128 root here is |
| 17455 | - /// that never took the new path). Recipe = the charter's own, verified | 17807 | + /// genuinely `PARTITION_SPLIT` -- the one arm |
| 17456 | - /// live by r1: `--min/max-partition-size=32/64` keeps the RD search | 17808 | + /// `decode_key_frame_tile_with_cdfs` codes; the other seven refuse by |
| 17457 | - /// from ever recursing below 32x32, so every SB-level decision is | 17809 | + /// name (`PART128_NON_SPLIT_REFUSAL`) and stay refused after this round. |
| 17458 | - /// genuinely NONE/SPLIT/HORZ/VERT; a `gradients` source blended with | 17810 | + /// |
| 17459 | - /// `testsrc2` (lavfi `blend=all_mode=average`) keeps the content from | 17811 | + /// What the 128 root actually changes, and what this gate therefore |
| 17460 | - /// being flat enough that the search stops at NONE every time. | 17812 | + /// proves: the 8-symbol `partition_w128` CDF and its forced-split gather |
| 17813 | + /// at the frame edge, the quadrant VISIT ORDER (TL, TR, BL, BR inside one | ||
| 17814 | + /// superblock, not raster over 64x64 superblocks), one loop-restoration | ||
| 17815 | + /// read per 128x128 instead of per 64x64, `delta_q`/`delta_lf` once per | ||
| 17816 | + /// 128x128, and the per-64x64 `cdef_idx` read inside the 128 superblock. | ||
| 17817 | + /// 256x192 gives a 2x2 grid of 128 superblocks whose bottom row is a | ||
| 17818 | + /// partial superblock (the gathered forced-split read); 384x384 gives a | ||
| 17819 | + /// 3x3 grid of whole ones. 8-bit sweep plus one 10-bit stream (his films | ||
| 17820 | + /// are `yuv420p10le`). Only a missing tool SKIPs. | ||
| 17461 | #[test] | 17821 | #[test] |
| 17462 | - fn a_real_aomenc_stream_with_a_superblock_level_horz_vert_partition_decodes_pixel_exact() { | 17822 | + fn a_real_aomenc_stream_with_128x128_superblocks_decodes_pixel_exact() { |
| 17463 | - const NAME: &str = | 17823 | + const NAME: &str = "a_real_aomenc_stream_with_128x128_superblocks_decodes_pixel_exact"; |
| 17464 | - "a_real_aomenc_stream_with_a_superblock_level_horz_vert_partition_decodes_pixel_exact"; | ||
| 17465 | let _gate_lock = lock_gate_counters(); | 17824 | let _gate_lock = lock_gate_counters(); |
| 17466 | if !have_ffmpeg() { | 17825 | if !have_ffmpeg() { |
| 17467 | eprintln!("SKIP {NAME}: no ffmpeg"); | 17826 | eprintln!("SKIP {NAME}: no ffmpeg"); |
| @@ -17471,35 +17830,439 @@ mod tests { | |||
| 17471 | eprintln!("SKIP {NAME}: no aomenc at {}", aomenc_path().display()); | 17830 | eprintln!("SKIP {NAME}: no aomenc at {}", aomenc_path().display()); |
| 17472 | return; | 17831 | return; |
| 17473 | } | 17832 | } |
| 17474 | - let (width, height, frame_count) = (192usize, 128usize, 1usize); | 17833 | + let base: Vec<&str> = vec![ |
| 17475 | - let mut named_refusals = 0u32; | 17834 | + "--codec=av1", |
| 17476 | - let mut matched = 0u32; | 17835 | + "--passes=1", |
| 17477 | - let n_attempts: u32 = std::env::var("EC_SBPART_GATE_ATTEMPTS") | 17836 | + "--end-usage=q", |
| 17478 | - .ok() | 17837 | + "--cq-level=40", |
| 17479 | - .and_then(|s| s.parse().ok()) | 17838 | + "--cpu-used=0", |
| 17480 | - .unwrap_or(40); | 17839 | + "--threads=1", |
| 17481 | - for attempt in 0..n_attempts { | 17840 | + "--row-mt=0", |
| 17482 | - let seed = 42 + attempt; | 17841 | + "--sb-size=128", |
| 17483 | - let duration = frame_count as f64 / 25.0; | 17842 | + "--max-partition-size=64", |
| 17484 | - let source = | 17843 | + "--enable-rect-partitions=1", |
| 17485 | - gradients_source(seed, width, height, &format!("duration={duration}:rate=25")); | 17844 | + "--enable-ab-partitions=0", |
| 17486 | - let y4m = Command::new("ffmpeg") | 17845 | + "--enable-1to4-partitions=0", |
| 17487 | - .args([ | 17846 | + // aomenc emits PARTITION_HORZ_4/VERT_4 below 16x16 even with the |
| 17488 | - "-v", | 17847 | + // flag off (ledger, lane-modectx r1), so bound the search instead. |
| 17489 | - "error", | 17848 | + "--min-partition-size=16", |
| 17490 | - "-f", | 17849 | + "--enable-restoration=1", |
| 17491 | - "lavfi", | 17850 | + "--enable-palette=0", |
| 17492 | - "-i", | 17851 | + "--deltaq-mode=0", |
| 17493 | - &source, | 17852 | + "--enable-intrabc=0", |
| 17494 | - "-pix_fmt", | 17853 | + "--enable-tx-size-search=0", |
| 17495 | - "yuv420p", | 17854 | + "--limit=1", |
| 17496 | - "-f", | 17855 | + ]; |
| 17497 | - "yuv4mpegpipe", | 17856 | + let encode = |y4m: &[u8], extra: &[&str]| -> Vec<u8> { |
| 17498 | - "-", | 17857 | + let mut args = base.clone(); |
| 17499 | - ]) | 17858 | + args.extend_from_slice(extra); |
| 17500 | - .stdin(Stdio::null()) | 17859 | + args.extend_from_slice(&["--obu", "-o", "-", "-"]); |
| 17501 | - .stdout(Stdio::piped()) | 17860 | + let mut child = Command::new(aomenc_path()) |
| 17502 | - .stderr(Stdio::piped()) | 17861 | + .args(&args) |
| 17862 | + .stdin(Stdio::piped()) | ||
| 17863 | + .stdout(Stdio::piped()) | ||
| 17864 | + .stderr(Stdio::piped()) | ||
| 17865 | + .spawn() | ||
| 17866 | + .expect("aomenc failed to start"); | ||
| 17867 | + child | ||
| 17868 | + .stdin | ||
| 17869 | + .take() | ||
| 17870 | + .expect("aomenc stdin") | ||
| 17871 | + .write_all(y4m) | ||
| 17872 | + .expect("writing y4m to aomenc"); | ||
| 17873 | + let out = child.wait_with_output().expect("aomenc failed to run"); | ||
| 17874 | + assert!( | ||
| 17875 | + out.status.success(), | ||
| 17876 | + "aomenc refused the fixture: {}", | ||
| 17877 | + String::from_utf8_lossy(&out.stderr) | ||
| 17878 | + ); | ||
| 17879 | + out.stdout | ||
| 17880 | + }; | ||
| 17881 | + let render = |seed: u32, width: usize, height: usize, ten_bit: bool| -> Vec<u8> { | ||
| 17882 | + let pix = if ten_bit { "yuv420p10le" } else { "yuv420p" }; | ||
| 17883 | + let out = Command::new("ffmpeg") | ||
| 17884 | + .args([ | ||
| 17885 | + "-v", | ||
| 17886 | + "error", | ||
| 17887 | + "-f", | ||
| 17888 | + "lavfi", | ||
| 17889 | + "-i", | ||
| 17890 | + &gradients_source(seed, width, height, "duration=0.04:rate=25"), | ||
| 17891 | + "-pix_fmt", | ||
| 17892 | + pix, | ||
| 17893 | + "-strict", | ||
| 17894 | + "-1", | ||
| 17895 | + "-t", | ||
| 17896 | + "0.04", | ||
| 17897 | + "-f", | ||
| 17898 | + "yuv4mpegpipe", | ||
| 17899 | + "-", | ||
| 17900 | + ]) | ||
| 17901 | + .stdin(Stdio::null()) | ||
| 17902 | + .stdout(Stdio::piped()) | ||
| 17903 | + .stderr(Stdio::piped()) | ||
| 17904 | + .output() | ||
| 17905 | + .expect("ffmpeg failed to run"); | ||
| 17906 | + assert!( | ||
| 17907 | + out.status.success(), | ||
| 17908 | + "ffmpeg fixture: {}", | ||
| 17909 | + String::from_utf8_lossy(&out.stderr) | ||
| 17910 | + ); | ||
| 17911 | + out.stdout | ||
| 17912 | + }; | ||
| 17913 | + let mut matched = 0u32; | ||
| 17914 | + let mut named_refusals = 0u32; | ||
| 17915 | + // (seed, width, height, 10-bit): 256x192 = 2x2 superblocks with a | ||
| 17916 | + // partial bottom row; 384x384 = 3x3 whole ones. | ||
| 17917 | + let arms: Vec<(u32, usize, usize, bool)> = vec![ | ||
| 17918 | + (42, 256, 192, false), | ||
| 17919 | + (43, 256, 192, false), | ||
| 17920 | + (44, 256, 192, false), | ||
| 17921 | + (45, 384, 384, false), | ||
| 17922 | + (46, 256, 192, true), | ||
| 17923 | + (47, 384, 384, true), | ||
| 17924 | + ]; | ||
| 17925 | + for (seed, width, height, ten_bit) in arms { | ||
| 17926 | + let y4m = render(seed, width, height, ten_bit); | ||
| 17927 | + let extra: Vec<&str> = if ten_bit { | ||
| 17928 | + vec!["--input-bit-depth=10", "--bit-depth=10"] | ||
| 17929 | + } else { | ||
| 17930 | + vec![] | ||
| 17931 | + }; | ||
| 17932 | + let stream = encode(&y4m, &extra); | ||
| 17933 | + let parsed = { | ||
| 17934 | + let mut parser = ec_av1_syntax::Av1Parser::new(); | ||
| 17935 | + let mut pos = 0usize; | ||
| 17936 | + while let Ok(obu) = parser.parse_obu(&stream[pos..]) { | ||
| 17937 | + pos += obu.total_size; | ||
| 17938 | + if pos >= stream.len() { | ||
| 17939 | + break; | ||
| 17940 | + } | ||
| 17941 | + } | ||
| 17942 | + parser | ||
| 17943 | + .sequence_header() | ||
| 17944 | + .map(|q| (q.use_128x128_superblock, q.color_config.bit_depth)) | ||
| 17945 | + }; | ||
| 17946 | + assert_eq!( | ||
| 17947 | + parsed, | ||
| 17948 | + Some((true, if ten_bit { 10 } else { 8 })), | ||
| 17949 | + "{NAME} (seed {seed}): the encoder did not write a 128x128-superblock \ | ||
| 17950 | + sequence header at the requested bit depth -- the flag never arrived" | ||
| 17951 | + ); | ||
| 17952 | + let frames = match decode_stream(&stream) { | ||
| 17953 | + Err(e) => { | ||
| 17954 | + let msg = e.to_string(); | ||
| 17955 | + assert!( | ||
| 17956 | + msg.contains("unsupported"), | ||
| 17957 | + "{NAME} failed outright, not a named refusal (seed {seed}): {msg}" | ||
| 17958 | + ); | ||
| 17959 | + named_refusals += 1; | ||
| 17960 | + eprintln!("seed {seed} refusal: {msg}"); | ||
| 17961 | + continue; | ||
| 17962 | + } | ||
| 17963 | + Ok(frames) => frames, | ||
| 17964 | + }; | ||
| 17965 | + let want = if ten_bit { | ||
| 17966 | + ffmpeg_decode_sequence_10bit(&stream, width, height, 1) | ||
| 17967 | + } else { | ||
| 17968 | + ffmpeg_decode_sequence(&stream, width, height, 1) | ||
| 17969 | + }; | ||
| 17970 | + assert_eq!(frames.len(), 1); | ||
| 17971 | + for (i, (got, want)) in frames.iter().zip(&want).enumerate() { | ||
| 17972 | + assert_eq!(got.y, want.y, "{NAME} frame {i} luma vs ffmpeg (seed {seed})"); | ||
| 17973 | + assert_eq!(got.u, want.u, "{NAME} frame {i} U vs ffmpeg (seed {seed})"); | ||
| 17974 | + assert_eq!(got.v, want.v, "{NAME} frame {i} V vs ffmpeg (seed {seed})"); | ||
| 17975 | + } | ||
| 17976 | + matched += 1; | ||
| 17977 | + } | ||
| 17978 | + assert!( | ||
| 17979 | + matched > 0, | ||
| 17980 | + "{NAME}: every attempt refused; the gate never decoded a stream" | ||
| 17981 | + ); | ||
| 17982 | + // 256x192 codes 3 whole + 1 partial superblock, 384x384 codes 9 whole | ||
| 17983 | + // ones, so a run that decoded anything at all must have read real 128 | ||
| 17984 | + // partition symbols and split every one of them. | ||
| 17985 | + assert!( | ||
| 17986 | + crate::decode::part128_symbols() >= 3 * matched as usize, | ||
| 17987 | + "{NAME}: only {} 128-level partition symbols over {matched} decoded streams -- \ | ||
| 17988 | + the 128 root never fired", | ||
| 17989 | + crate::decode::part128_symbols() | ||
| 17990 | + ); | ||
| 17991 | + assert!( | ||
| 17992 | + crate::decode::part128_split_hits() >= 4 * matched as usize, | ||
| 17993 | + "{NAME}: only {} 128 superblocks split", | ||
| 17994 | + crate::decode::part128_split_hits() | ||
| 17995 | + ); | ||
| 17996 | + eprintln!( | ||
| 17997 | + "{NAME}: {matched} pixel-exact, {named_refusals} named refusals, \ | ||
| 17998 | + part128_symbols={} part128_split_hits={}", | ||
| 17999 | + crate::decode::part128_symbols(), | ||
| 18000 | + crate::decode::part128_split_hits() | ||
| 18001 | + ); | ||
| 18002 | + } | ||
| 18003 | + | ||
| 18004 | + #[test] | ||
| 18005 | + #[ignore = "lane-sb128 r2 diagnostic: is the frame-6 mismatch sb128-specific?"] | ||
| 18006 | + fn sb128_r2_control_sb64() { | ||
| 18007 | + let (width, height) = (256usize, 192usize); | ||
| 18008 | + let y4m = Command::new("ffmpeg") | ||
| 18009 | + .args([ | ||
| 18010 | + "-v", "error", "-f", "lavfi", "-i", | ||
| 18011 | + &format!( | ||
| 18012 | + "{},noise=all_seed=53:alls=12:allf=t", | ||
| 18013 | + gradients_source(53, width, height, "duration=0.32:rate=25") | ||
| 18014 | + ), | ||
| 18015 | + "-pix_fmt", "yuv420p", "-t", "0.32", "-f", "yuv4mpegpipe", "-", | ||
| 18016 | + ]) | ||
| 18017 | + .stdin(Stdio::null()) | ||
| 18018 | + .stdout(Stdio::piped()) | ||
| 18019 | + .output() | ||
| 18020 | + .expect("ffmpeg"); | ||
| 18021 | + let mut child = Command::new(aomenc_path()) | ||
| 18022 | + .args([ | ||
| 18023 | + "--codec=av1", "--passes=1", "--end-usage=q", "--cq-level=40", | ||
| 18024 | + "--cpu-used=2", "--threads=1", "--row-mt=0", "--sb-size=64", | ||
| 18025 | + "--max-partition-size=64", "--min-partition-size=32", | ||
| 18026 | + "--enable-rect-partitions=0", "--enable-ab-partitions=0", | ||
| 18027 | + "--enable-1to4-partitions=0", "--enable-palette=0", | ||
| 18028 | + "--enable-intrabc=0", "--enable-tx-size-search=0", | ||
| 18029 | + "--deltaq-mode=0", "--limit=8", "--obu", "-o", "-", "-", | ||
| 18030 | + ]) | ||
| 18031 | + .stdin(Stdio::piped()) | ||
| 18032 | + .stdout(Stdio::piped()) | ||
| 18033 | + .stderr(Stdio::piped()) | ||
| 18034 | + .spawn() | ||
| 18035 | + .expect("aomenc"); | ||
| 18036 | + child.stdin.take().unwrap().write_all(&y4m.stdout).unwrap(); | ||
| 18037 | + let out = child.wait_with_output().expect("aomenc run"); | ||
| 18038 | + assert!(out.status.success()); | ||
| 18039 | + let (frames, hidden) = decode_all_frames_vs_oracle(&out.stdout, "sb128-control-64"); | ||
| 18040 | + eprintln!("control sb64: {frames} frames exact ({hidden} hidden)"); | ||
| 18041 | + } | ||
| 18042 | + | ||
| 18043 | + /// lane-sb128 r2: an INTER SEQUENCE under a 128x128 superblock -- the | ||
| 18044 | + /// half ReelC is made of. r1 refused it by name (the inter tile loop | ||
| 18045 | + /// recursed a 64x64 root only); r2 ported `sb_visit_order` and the 128 | ||
| 18046 | + /// root (per-superblock `read_lr`, the 8-symbol `partition_w128` read with | ||
| 18047 | + /// its edge gather, `delta_q`/`delta_lf` at 128 granularity) into that | ||
| 18048 | + /// loop, so this gate replaces the refusal test. | ||
| 18049 | + /// | ||
| 18050 | + /// Every frame in DECODE order, hidden alt-refs included | ||
| 18051 | + /// ([`decode_all_frames_vs_oracle`], class gate-blind-to-hidden-frames): | ||
| 18052 | + /// `--lag-in-frames` is left at aomenc's default so the encoder really | ||
| 18053 | + /// emits them. Per-ATTEMPT counter deltas are hard asserts (class | ||
| 18054 | + /// counter-from-refused-stream: the helper panics on any refusal, so every | ||
| 18055 | + /// counted attempt is a compared one): 128 partition roots read on this | ||
| 18056 | + /// stream, `cdef_idx` reads (one per 64x64 quadrant inside the 128 | ||
| 18057 | + /// superblock), and temporal MV candidates (the inter-only path). Both bit | ||
| 18058 | + /// depths -- his films are `yuv420p10le`. Only a missing tool SKIPs. | ||
| 18059 | + #[test] | ||
| 18060 | + fn a_real_aomenc_inter_sequence_with_128x128_superblocks_decodes_pixel_exact() { | ||
| 18061 | + const NAME: &str = | ||
| 18062 | + "a_real_aomenc_inter_sequence_with_128x128_superblocks_decodes_pixel_exact"; | ||
| 18063 | + let _gate_lock = lock_gate_counters(); | ||
| 18064 | + if !have_ffmpeg() || !have_aomenc() { | ||
| 18065 | + eprintln!("SKIP {NAME}: no ffmpeg/aomenc/aomdec"); | ||
| 18066 | + return; | ||
| 18067 | + } | ||
| 18068 | + let (width, height) = (256usize, 192usize); | ||
| 18069 | + for ten_bit in [false, true] { | ||
| 18070 | + let pix = if ten_bit { "yuv420p10le" } else { "yuv420p" }; | ||
| 18071 | + let y4m = Command::new("ffmpeg") | ||
| 18072 | + .args([ | ||
| 18073 | + "-v", | ||
| 18074 | + "error", | ||
| 18075 | + "-f", | ||
| 18076 | + "lavfi", | ||
| 18077 | + "-i", | ||
| 18078 | + &format!( | ||
| 18079 | + // Noise on top of the gradient is what makes aomenc | ||
| 18080 | + // signal a nonzero `cdef_bits` (a clean gradient codes | ||
| 18081 | + // with CDEF off, and the cdef_idx counter stays 0). | ||
| 18082 | + "{},noise=all_seed=53:alls=12:allf=t", | ||
| 18083 | + gradients_source(53, width, height, "duration=0.32:rate=25") | ||
| 18084 | + ), | ||
| 18085 | + "-pix_fmt", | ||
| 18086 | + pix, | ||
| 18087 | + "-strict", | ||
| 18088 | + "-1", | ||
| 18089 | + "-t", | ||
| 18090 | + "0.32", | ||
| 18091 | + "-f", | ||
| 18092 | + "yuv4mpegpipe", | ||
| 18093 | + "-", | ||
| 18094 | + ]) | ||
| 18095 | + .stdin(Stdio::null()) | ||
| 18096 | + .stdout(Stdio::piped()) | ||
| 18097 | + .stderr(Stdio::piped()) | ||
| 18098 | + .output() | ||
| 18099 | + .expect("ffmpeg failed to run"); | ||
| 18100 | + assert!( | ||
| 18101 | + y4m.status.success(), | ||
| 18102 | + "{NAME}: ffmpeg fixture: {}", | ||
| 18103 | + String::from_utf8_lossy(&y4m.stderr) | ||
| 18104 | + ); | ||
| 18105 | + let mut args: Vec<&str> = vec![ | ||
| 18106 | + "--codec=av1", | ||
| 18107 | + "--passes=1", | ||
| 18108 | + "--end-usage=q", | ||
| 18109 | + "--cq-level=40", | ||
| 18110 | + "--cpu-used=2", | ||
| 18111 | + "--threads=1", | ||
| 18112 | + "--row-mt=0", | ||
| 18113 | + "--sb-size=128", | ||
| 18114 | + "--max-partition-size=64", | ||
| 18115 | + // aomenc emits PARTITION_HORZ_4/VERT_4 below 16x16 even with | ||
| 18116 | + // the flag off (ledger, lane-modectx r1), so bound the search. | ||
| 18117 | + "--min-partition-size=32", | ||
| 18118 | + // The inter path still refuses rectangular strips ("a non-skip | ||
| 18119 | + // rectangular (HORZ/VERT/HORZ_B) strip needs rectangular | ||
| 18120 | + // residual coding") -- another lane's gap, off here so this | ||
| 18121 | + // gate measures the 128 root and nothing else. | ||
| 18122 | + "--enable-rect-partitions=0", | ||
| 18123 | + "--enable-ab-partitions=0", | ||
| 18124 | + "--enable-1to4-partitions=0", | ||
| 18125 | + "--enable-palette=0", | ||
| 18126 | + "--enable-intrabc=0", | ||
| 18127 | + "--enable-tx-size-search=0", | ||
| 18128 | + "--deltaq-mode=0", | ||
| 18129 | + "--limit=8", | ||
| 18130 | + ]; | ||
| 18131 | + if ten_bit { | ||
| 18132 | + args.extend_from_slice(&["--input-bit-depth=10", "--bit-depth=10"]); | ||
| 18133 | + } | ||
| 18134 | + args.extend_from_slice(&["--obu", "-o", "-", "-"]); | ||
| 18135 | + let mut child = Command::new(aomenc_path()) | ||
| 18136 | + .args(&args) | ||
| 18137 | + .stdin(Stdio::piped()) | ||
| 18138 | + .stdout(Stdio::piped()) | ||
| 18139 | + .stderr(Stdio::piped()) | ||
| 18140 | + .spawn() | ||
| 18141 | + .expect("aomenc failed to start"); | ||
| 18142 | + child | ||
| 18143 | + .stdin | ||
| 18144 | + .take() | ||
| 18145 | + .expect("aomenc stdin") | ||
| 18146 | + .write_all(&y4m.stdout) | ||
| 18147 | + .expect("writing y4m to aomenc"); | ||
| 18148 | + let out = child.wait_with_output().expect("aomenc failed to run"); | ||
| 18149 | + assert!( | ||
| 18150 | + out.status.success(), | ||
| 18151 | + "{NAME}: aomenc refused the fixture: {}", | ||
| 18152 | + String::from_utf8_lossy(&out.stderr) | ||
| 18153 | + ); | ||
| 18154 | + let stream = out.stdout; | ||
| 18155 | + let header = { | ||
| 18156 | + let mut parser = ec_av1_syntax::Av1Parser::new(); | ||
| 18157 | + let mut pos = 0usize; | ||
| 18158 | + while let Ok(obu) = parser.parse_obu(&stream[pos..]) { | ||
| 18159 | + pos += obu.total_size; | ||
| 18160 | + if pos >= stream.len() { | ||
| 18161 | + break; | ||
| 18162 | + } | ||
| 18163 | + } | ||
| 18164 | + parser | ||
| 18165 | + .sequence_header() | ||
| 18166 | + .map(|q| (q.use_128x128_superblock, q.color_config.bit_depth)) | ||
| 18167 | + }; | ||
| 18168 | + assert_eq!( | ||
| 18169 | + header, | ||
| 18170 | + Some((true, if ten_bit { 10 } else { 8 })), | ||
| 18171 | + "{NAME}: the encoder did not write a 128x128-superblock sequence header at \ | ||
| 18172 | + the requested bit depth -- the flag never arrived" | ||
| 18173 | + ); | ||
| 18174 | + let before = ( | ||
| 18175 | + crate::decode::part128_symbols(), | ||
| 18176 | + crate::decode::cdef_idx_hits(), | ||
| 18177 | + crate::decode::tmv_hits(), | ||
| 18178 | + ); | ||
| 18179 | + let (frames, hidden) = decode_all_frames_vs_oracle( | ||
| 18180 | + &stream, | ||
| 18181 | + &format!("sb128-inter-{}", if ten_bit { 10 } else { 8 }), | ||
| 18182 | + ); | ||
| 18183 | + let (part128, cdef_idx, tmv) = ( | ||
| 18184 | + crate::decode::part128_symbols() - before.0, | ||
| 18185 | + crate::decode::cdef_idx_hits() - before.1, | ||
| 18186 | + crate::decode::tmv_hits() - before.2, | ||
| 18187 | + ); | ||
| 18188 | + assert!( | ||
| 18189 | + frames >= 6, | ||
| 18190 | + "{NAME} ({pix}): only {frames} frames in decode order, the recipe asks for 8" | ||
| 18191 | + ); | ||
| 18192 | + assert!( | ||
| 18193 | + part128 >= 3, | ||
| 18194 | + "{NAME} ({pix}): only {part128} 128-level partition symbols on this stream -- \ | ||
| 18195 | + the 128 root never fired on the inter frames" | ||
| 18196 | + ); | ||
| 18197 | + assert!( | ||
| 18198 | + cdef_idx >= 1, | ||
| 18199 | + "{NAME} ({pix}): no cdef_idx read -- the per-64x64-quadrant cdef read inside \ | ||
| 18200 | + the 128 superblock never fired" | ||
| 18201 | + ); | ||
| 18202 | + assert!( | ||
| 18203 | + tmv >= 1, | ||
| 18204 | + "{NAME} ({pix}): no temporal MV candidate -- the inter path never ran" | ||
| 18205 | + ); | ||
| 18206 | + eprintln!( | ||
| 18207 | + "{NAME} ({pix}): {frames} decode-order frames pixel-exact ({hidden} hidden), \ | ||
| 18208 | + part128_symbols={part128} cdef_idx_hits={cdef_idx} tmv_hits={tmv}" | ||
| 18209 | + ); | ||
| 18210 | + } | ||
| 18211 | + } | ||
| 18212 | + | ||
| 18213 | + /// lane-sbpart r2: a real `aomenc` stream whose superblock-level | ||
| 18214 | + /// partition decision is genuinely HORZ/VERT (not NONE/SPLIT) must | ||
| 18215 | + /// decode pixel-exact through [`crate::decode::decode_block_rect64`] -- | ||
| 18216 | + /// `sb_rect_hits() > 0` is a HARD assert (this round's rule: a removed | ||
| 18217 | + /// refusal needs a firing gate in the same commit, not a green suite | ||
| 18218 | + /// that never took the new path). Recipe = the charter's own, verified | ||
| 18219 | + /// live by r1: `--min/max-partition-size=32/64` keeps the RD search | ||
| 18220 | + /// from ever recursing below 32x32, so every SB-level decision is | ||
| 18221 | + /// genuinely NONE/SPLIT/HORZ/VERT; a `gradients` source blended with | ||
| 18222 | + /// `testsrc2` (lavfi `blend=all_mode=average`) keeps the content from | ||
| 18223 | + /// being flat enough that the search stops at NONE every time. | ||
| 18224 | + #[test] | ||
| 18225 | + fn a_real_aomenc_stream_with_a_superblock_level_horz_vert_partition_decodes_pixel_exact() { | ||
| 18226 | + const NAME: &str = | ||
| 18227 | + "a_real_aomenc_stream_with_a_superblock_level_horz_vert_partition_decodes_pixel_exact"; | ||
| 18228 | + let _gate_lock = lock_gate_counters(); | ||
| 18229 | + if !have_ffmpeg() { | ||
| 18230 | + eprintln!("SKIP {NAME}: no ffmpeg"); | ||
| 18231 | + return; | ||
| 18232 | + } | ||
| 18233 | + if !have_aomenc() { | ||
| 18234 | + eprintln!("SKIP {NAME}: no aomenc at {}", aomenc_path().display()); | ||
| 18235 | + return; | ||
| 18236 | + } | ||
| 18237 | + let (width, height, frame_count) = (192usize, 128usize, 1usize); | ||
| 18238 | + let mut named_refusals = 0u32; | ||
| 18239 | + let mut matched = 0u32; | ||
| 18240 | + let n_attempts: u32 = std::env::var("EC_SBPART_GATE_ATTEMPTS") | ||
| 18241 | + .ok() | ||
| 18242 | + .and_then(|s| s.parse().ok()) | ||
| 18243 | + .unwrap_or(40); | ||
| 18244 | + for attempt in 0..n_attempts { | ||
| 18245 | + let seed = 42 + attempt; | ||
| 18246 | + let duration = frame_count as f64 / 25.0; | ||
| 18247 | + let source = | ||
| 18248 | + gradients_source(seed, width, height, &format!("duration={duration}:rate=25")); | ||
| 18249 | + let y4m = Command::new("ffmpeg") | ||
| 18250 | + .args([ | ||
| 18251 | + "-v", | ||
| 18252 | + "error", | ||
| 18253 | + "-f", | ||
| 18254 | + "lavfi", | ||
| 18255 | + "-i", | ||
| 18256 | + &source, | ||
| 18257 | + "-pix_fmt", | ||
| 18258 | + "yuv420p", | ||
| 18259 | + "-f", | ||
| 18260 | + "yuv4mpegpipe", | ||
| 18261 | + "-", | ||
| 18262 | + ]) | ||
| 18263 | + .stdin(Stdio::null()) | ||
| 18264 | + .stdout(Stdio::piped()) | ||
| 18265 | + .stderr(Stdio::piped()) | ||
| 17503 | .output() | 18266 | .output() |
| 17504 | .expect("ffmpeg failed to run"); | 18267 | .expect("ffmpeg failed to run"); |
| 17505 | assert!( | 18268 | assert!( |
| @@ -17524,6 +18287,7 @@ mod tests { | |||
| 17524 | "--enable-restoration=0", | 18287 | "--enable-restoration=0", |
| 17525 | "--enable-palette=0", | 18288 | "--enable-palette=0", |
| 17526 | "--deltaq-mode=0", | 18289 | "--deltaq-mode=0", |
| 18290 | + "--enable-cdef=0", | ||
| 17527 | "--enable-filter-intra=0", | 18291 | "--enable-filter-intra=0", |
| 17528 | "--enable-cfl-intra=0", | 18292 | "--enable-cfl-intra=0", |
| 17529 | "--enable-intrabc=0", | 18293 | "--enable-intrabc=0", |
| @@ -18170,6 +18934,7 @@ mod tests { | |||
| 18170 | "--enable-restoration=0", | 18934 | "--enable-restoration=0", |
| 18171 | "--enable-palette=0", | 18935 | "--enable-palette=0", |
| 18172 | "--deltaq-mode=0", | 18936 | "--deltaq-mode=0", |
| 18937 | + "--enable-cdef=0", | ||
| 18173 | "--enable-filter-intra=0", | 18938 | "--enable-filter-intra=0", |
| 18174 | "--enable-cfl-intra=0", | 18939 | "--enable-cfl-intra=0", |
| 18175 | "--enable-intrabc=0", | 18940 | "--enable-intrabc=0", |
| @@ -18376,6 +19141,7 @@ mod tests { | |||
| 18376 | "--enable-restoration=0", | 19141 | "--enable-restoration=0", |
| 18377 | "--enable-palette=0", | 19142 | "--enable-palette=0", |
| 18378 | "--deltaq-mode=0", | 19143 | "--deltaq-mode=0", |
| 19144 | + "--enable-cdef=0", | ||
| 18379 | "--enable-filter-intra=0", | 19145 | "--enable-filter-intra=0", |
| 18380 | "--enable-cfl-intra=0", | 19146 | "--enable-cfl-intra=0", |
| 18381 | "--enable-intrabc=0", | 19147 | "--enable-intrabc=0", |
| @@ -18630,6 +19396,7 @@ mod tests { | |||
| 18630 | "--enable-restoration=0", | 19396 | "--enable-restoration=0", |
| 18631 | "--enable-palette=0", | 19397 | "--enable-palette=0", |
| 18632 | "--deltaq-mode=0", | 19398 | "--deltaq-mode=0", |
| 19399 | + "--enable-cdef=0", | ||
| 18633 | // The point of this gate. | 19400 | // The point of this gate. |
| 18634 | "--enable-filter-intra=1", | 19401 | "--enable-filter-intra=1", |
| 18635 | // NOTE (lane-rectsplit r2, verifier finding): every intra | 19402 | // NOTE (lane-rectsplit r2, verifier finding): every intra |
| @@ -18801,6 +19568,7 @@ mod tests { | |||
| 18801 | "--enable-restoration=0", | 19568 | "--enable-restoration=0", |
| 18802 | "--enable-palette=0", | 19569 | "--enable-palette=0", |
| 18803 | "--deltaq-mode=0", | 19570 | "--deltaq-mode=0", |
| 19571 | + "--enable-cdef=0", | ||
| 18804 | "--enable-filter-intra=1", | 19572 | "--enable-filter-intra=1", |
| 18805 | "--enable-cfl-intra=0", | 19573 | "--enable-cfl-intra=0", |
| 18806 | "--enable-intrabc=0", | 19574 | "--enable-intrabc=0", |
| @@ -18996,6 +19764,7 @@ mod tests { | |||
| 18996 | "--enable-restoration=0", | 19764 | "--enable-restoration=0", |
| 18997 | "--enable-palette=0", | 19765 | "--enable-palette=0", |
| 18998 | "--deltaq-mode=0", | 19766 | "--deltaq-mode=0", |
| 19767 | + "--enable-cdef=0", | ||
| 18999 | "--enable-filter-intra=1", | 19768 | "--enable-filter-intra=1", |
| 19000 | "--enable-cfl-intra=0", | 19769 | "--enable-cfl-intra=0", |
| 19001 | "--enable-intrabc=0", | 19770 | "--enable-intrabc=0", |
| @@ -19194,6 +19963,7 @@ mod tests { | |||
| 19194 | "--enable-restoration=0", | 19963 | "--enable-restoration=0", |
| 19195 | "--enable-palette=0", | 19964 | "--enable-palette=0", |
| 19196 | "--deltaq-mode=0", | 19965 | "--deltaq-mode=0", |
| 19966 | + "--enable-cdef=0", | ||
| 19197 | "--enable-filter-intra=0", | 19967 | "--enable-filter-intra=0", |
| 19198 | "--enable-cfl-intra=0", | 19968 | "--enable-cfl-intra=0", |
| 19199 | "--enable-intrabc=0", | 19969 | "--enable-intrabc=0", |
| @@ -19370,6 +20140,7 @@ mod tests { | |||
| 19370 | "--enable-restoration=0", | 20140 | "--enable-restoration=0", |
| 19371 | "--enable-palette=0", | 20141 | "--enable-palette=0", |
| 19372 | "--deltaq-mode=0", | 20142 | "--deltaq-mode=0", |
| 20143 | + "--enable-cdef=0", | ||
| 19373 | "--enable-filter-intra=0", | 20144 | "--enable-filter-intra=0", |
| 19374 | "--enable-cfl-intra=0", | 20145 | "--enable-cfl-intra=0", |
| 19375 | "--enable-intrabc=0", | 20146 | "--enable-intrabc=0", |
| @@ -19833,6 +20604,7 @@ mod tests { | |||
| 19833 | "--enable-restoration=0", | 20604 | "--enable-restoration=0", |
| 19834 | "--enable-palette=0", | 20605 | "--enable-palette=0", |
| 19835 | "--deltaq-mode=0", | 20606 | "--deltaq-mode=0", |
| 20607 | + "--enable-cdef=0", | ||
| 19836 | "--enable-filter-intra=0", | 20608 | "--enable-filter-intra=0", |
| 19837 | "--enable-cfl-intra=0", | 20609 | "--enable-cfl-intra=0", |
| 19838 | "--enable-intrabc=0", | 20610 | "--enable-intrabc=0", |
| @@ -19877,98 +20649,344 @@ mod tests { | |||
| 19877 | eprintln!("seed {seed} refusal: {msg}"); | 20649 | eprintln!("seed {seed} refusal: {msg}"); |
| 19878 | continue; | 20650 | continue; |
| 19879 | } | 20651 | } |
| 19880 | - Ok(frames) => frames, | 20652 | + Ok(frames) => frames, |
| 19881 | - }; | 20653 | + }; |
| 19882 | - let (horz, vert) = ( | 20654 | + let (horz, vert) = ( |
| 19883 | - crate::decode::sb_rect4_horz_hits() - before.0, | 20655 | + crate::decode::sb_rect4_horz_hits() - before.0, |
| 19884 | - crate::decode::sb_rect4_vert_hits() - before.1, | 20656 | + crate::decode::sb_rect4_vert_hits() - before.1, |
| 19885 | - ); | 20657 | + ); |
| 19886 | - let ffmpeg_frames = ffmpeg_decode_sequence(&stream, width, height, frame_count); | 20658 | + let ffmpeg_frames = ffmpeg_decode_sequence(&stream, width, height, frame_count); |
| 19887 | - assert_eq!(frames.len(), frame_count); | 20659 | + assert_eq!(frames.len(), frame_count); |
| 19888 | - let mismatched = frames | 20660 | + let mismatched = frames |
| 19889 | - .iter() | 20661 | + .iter() |
| 19890 | - .zip(&ffmpeg_frames) | 20662 | + .zip(&ffmpeg_frames) |
| 19891 | - .any(|(got, want)| got.y != want.y || got.u != want.u || got.v != want.v); | 20663 | + .any(|(got, want)| got.y != want.y || got.u != want.u || got.v != want.v); |
| 19892 | - if horz + vert == 0 { | 20664 | + if horz + vert == 0 { |
| 19893 | - // Out of this gate's territory: aomenc's RD picked no 1:4 | 20665 | + // Out of this gate's territory: aomenc's RD picked no 1:4 |
| 19894 | - // partition at all for this seed, so the attempt can neither | 20666 | + // partition at all for this seed, so the attempt can neither |
| 19895 | - // prove nor disprove the arms under test. NOT silently | 20667 | + // prove nor disprove the arms under test. NOT silently |
| 19896 | - // dropped -- counted and printed, and a mismatch here is | 20668 | + // dropped -- counted and printed, and a mismatch here is |
| 19897 | - // reported as a defect of another lane's shape (r1 found | 20669 | + // reported as a defect of another lane's shape (r1 found |
| 19898 | - // one: seed 55 of this very recipe decodes 3944 wrong luma | 20670 | + // one: seed 55 of this very recipe decodes 3944 wrong luma |
| 19899 | - // samples with zero 1:4 blocks in the stream, first at | 20671 | + // samples with zero 1:4 blocks in the stream, first at |
| 19900 | - // (154, 59), inside the 64x32 `PARTITION_HORZ` superblock at | 20672 | + // (154, 59), inside the 64x32 `PARTITION_HORZ` superblock at |
| 19901 | - // (128, 64) -- see lanes/tx64x16-r1.report.md). Selecting on | 20673 | + // (128, 64) -- see lanes/tx64x16-r1.report.md). Selecting on |
| 19902 | - // "the stream contains the feature", never on "the stream | 20674 | + // "the stream contains the feature", never on "the stream |
| 19903 | - // decoded correctly", is what keeps this from being survivor | 20675 | + // decoded correctly", is what keeps this from being survivor |
| 19904 | - // bias. | 20676 | + // bias. |
| 19905 | - out_of_scope += 1; | 20677 | + out_of_scope += 1; |
| 19906 | - if mismatched { | 20678 | + if mismatched { |
| 19907 | - out_of_scope_mismatch += 1; | 20679 | + out_of_scope_mismatch += 1; |
| 20680 | + eprintln!( | ||
| 20681 | + "{NAME}: seed {seed} MISMATCHES with zero 1:4 blocks -- a pre-existing \ | ||
| 20682 | + defect of another shape, not this gate's arms" | ||
| 20683 | + ); | ||
| 20684 | + } | ||
| 20685 | + continue; | ||
| 20686 | + } | ||
| 20687 | + if mismatched { | ||
| 20688 | + if let Ok(path) = std::env::var("EC_AV1_GATE_DUMP") { | ||
| 20689 | + std::fs::write(&path, &stream).expect("writing pinned stream"); | ||
| 20690 | + eprintln!("EC_AV1_GATE_DUMP: wrote mismatching stream (seed {seed}) to {path}"); | ||
| 20691 | + } | ||
| 20692 | + } | ||
| 20693 | + for (i, (got, want)) in frames.iter().zip(&ffmpeg_frames).enumerate() { | ||
| 20694 | + assert_eq!(got.y, want.y, "{NAME} frame {i} luma vs ffmpeg (seed {seed})"); | ||
| 20695 | + assert_eq!(got.u, want.u, "{NAME} frame {i} U vs ffmpeg (seed {seed})"); | ||
| 20696 | + assert_eq!(got.v, want.v, "{NAME} frame {i} V vs ffmpeg (seed {seed})"); | ||
| 20697 | + } | ||
| 20698 | + horz_proved += horz; | ||
| 20699 | + vert_proved += vert; | ||
| 20700 | + matched += 1; | ||
| 20701 | + } | ||
| 20702 | + assert!( | ||
| 20703 | + matched > 0, | ||
| 20704 | + "{NAME}: every attempt refused; the gate never decoded a stream" | ||
| 20705 | + ); | ||
| 20706 | + assert!( | ||
| 20707 | + horz_proved > 0 && vert_proved > 0, | ||
| 20708 | + "{NAME}: a 1:4 arm never fired inside a pixel-exact attempt \ | ||
| 20709 | + (horz={horz_proved}, vert={vert_proved}, {matched} matches, {named_refusals} \ | ||
| 20710 | + refusals out of {n_attempts}) -- gate proved nothing this run" | ||
| 20711 | + ); | ||
| 20712 | + eprintln!( | ||
| 20713 | + "{NAME}: {named_refusals} named refusals, {matched} pixel-exact matches out of \ | ||
| 20714 | + {n_attempts}, horz_4 strips={horz_proved}, vert_4 strips={vert_proved}, \ | ||
| 20715 | + {out_of_scope} attempts carried no 1:4 block ({out_of_scope_mismatch} of them \ | ||
| 20716 | + mismatched -- other lanes' shapes)" | ||
| 20717 | + ); | ||
| 20718 | + // Class gate-skips-on-its-own-failure: an attempt that decoded but | ||
| 20719 | + // does not carry this gate's shape is still a decode this crate got | ||
| 20720 | + // wrong. Counted separately so the message names the other shape, | ||
| 20721 | + // never tolerated. | ||
| 20722 | + assert_eq!( | ||
| 20723 | + out_of_scope_mismatch, 0, | ||
| 20724 | + "{NAME}: {out_of_scope_mismatch} attempt(s) with no 1:4 block decoded but \ | ||
| 20725 | + mismatched ffmpeg -- a defect of another shape, not a pass" | ||
| 20726 | + ); | ||
| 20727 | + } | ||
| 20728 | + | ||
| 20729 | + /// lane-tx64x16 r3: the 32x32-LEVEL 1:4 pair -- `PARTITION_HORZ_4` / | ||
| 20730 | + /// `PARTITION_VERT_4` at 32x32, i.e. four 32x8 / 8x32 strips, the arm the | ||
| 20731 | + /// ReelB mid-film extract stops at ("a 32x32 partition type this | ||
| 20732 | + /// decoder does not code (value=8)"). `--min-partition-size=8` is what | ||
| 20733 | + /// lets aomenc's RD reach the 32-level 1:4 shapes; `--max-partition-size=32` | ||
| 20734 | + /// keeps the superblock-level pair (already gated by its own test above) | ||
| 20735 | + /// out of the counters. Both orientations HARD-asserted per bit depth -- | ||
| 20736 | + /// the luma scans and the two new chroma scans (`SCAN_16X4`/`SCAN_4X16`) | ||
| 20737 | + /// are transposed pairs, so a one-sided gate cannot catch a transposition | ||
| 20738 | + /// (class scan-weights-cross-axis). `rect4_coeff_hits` is asserted too: | ||
| 20739 | + /// an all-skip stream would exercise none of the new coefficient tables | ||
| 20740 | + /// (class gate-blind-to-feature). Only hits earned inside an attempt that | ||
| 20741 | + /// then compared pixel-exact are counted (class | ||
| 20742 | + /// gate-skips-on-its-own-failure); the 10-bit arm is what retires | ||
| 20743 | + /// `enable-1to4-partitions` from `NEVER_EXERCISED_10BIT`. | ||
| 20744 | + /// lane-r14: the 16x16-level 1:4 pair -- four 16x4 (`PARTITION_HORZ_4`) or | ||
| 20745 | + /// 4x16 (`PARTITION_VERT_4`) strips, the shape the wall | ||
| 20746 | + /// "a 1:4 partition below 16x16" refused. Fixture: 4-PIXEL bands (the | ||
| 20747 | + /// 8-pixel ones of the 32-level gate above, one size down -- a 16x4 strip | ||
| 20748 | + /// is flat where a 16x8 one is not), transposed per attempt so a | ||
| 20749 | + /// transposed scan or nz-map table cannot pass (class | ||
| 20750 | + /// scan-weights-cross-axis), plus an explicit-seed noise layer that keeps | ||
| 20751 | + /// aomenc out of screen-content mode. `--enable-filter-intra=1` and | ||
| 20752 | + /// is ON: this shape reads `use_filter_intra` off its own CDF rows | ||
| 20753 | + /// (classes 12/13). The `--enable-tx-size-search=1` half of the window | ||
| 20754 | + /// splits the strip's transform (depth 1 = TX_8X4/TX_4X8, depth 2 = | ||
| 20755 | + /// TX_4X4). | ||
| 20756 | + /// | ||
| 20757 | + /// Counters: 16x4 strips, 4x16 strips, chroma-reference strips (the odd | ||
| 20758 | + /// strip of each 4:2:0 pair, the only one that codes chroma) and strips | ||
| 20759 | + /// with a coded residual must all be nonzero over the compared attempts, | ||
| 20760 | + /// and only attempts that DECODED and were compared pixel-exact count | ||
| 20761 | + /// (class gate-skips-on-its-own-failure). | ||
| 20762 | + #[test] | ||
| 20763 | + fn a_real_aomenc_stream_with_a_16_level_1to4_partition_decodes_pixel_exact() { | ||
| 20764 | + const NAME: &str = | ||
| 20765 | + "a_real_aomenc_stream_with_a_16_level_1to4_partition_decodes_pixel_exact"; | ||
| 20766 | + let _gate_lock = lock_gate_counters(); | ||
| 20767 | + if !have_ffmpeg() { | ||
| 20768 | + eprintln!("SKIP {NAME}: no ffmpeg"); | ||
| 20769 | + return; | ||
| 20770 | + } | ||
| 20771 | + if !have_aomenc() { | ||
| 20772 | + eprintln!("SKIP {NAME}: no aomenc at {}", aomenc_path().display()); | ||
| 20773 | + return; | ||
| 20774 | + } | ||
| 20775 | + let (width, height, frame_count) = (192usize, 128usize, 1usize); | ||
| 20776 | + let n_attempts: u32 = std::env::var("EC_R14_GATE_ATTEMPTS") | ||
| 20777 | + .ok() | ||
| 20778 | + .and_then(|s| s.parse().ok()) | ||
| 20779 | + .unwrap_or(8); | ||
| 20780 | + for bit_depth in [8u32, 10u32] { | ||
| 20781 | + let mut named_refusals = 0u32; | ||
| 20782 | + let mut matched = 0u32; | ||
| 20783 | + let (mut horz_proved, mut vert_proved) = (0usize, 0usize); | ||
| 20784 | + let (mut chroma_proved, mut coeff_proved) = (0usize, 0usize); | ||
| 20785 | + let mut split_proved = 0usize; | ||
| 20786 | + let (mut out_of_scope, mut out_of_scope_mismatch) = (0u32, 0u32); | ||
| 20787 | + // The second half of the window turns `--enable-tx-size-search` on: | ||
| 20788 | + // that is what makes a 16x4 strip SPLIT its transform (depth 1 = | ||
| 20789 | + // TX_8X4, depth 2 = TX_4X4), the arm the first half never reaches. | ||
| 20790 | + for attempt in 0..n_attempts * 2 { | ||
| 20791 | + let tx_search = attempt >= n_attempts; | ||
| 20792 | + let attempt = attempt % n_attempts; | ||
| 20793 | + let seed = 42 + attempt; | ||
| 20794 | + let duration = frame_count as f64 / 25.0; | ||
| 20795 | + let axis = if attempt % 2 == 0 { "Y" } else { "X" }; | ||
| 20796 | + let step = 67 + (attempt / 2) * 12; | ||
| 20797 | + let noise = 6 + (attempt % 4) * 3; | ||
| 20798 | + let source = format!( | ||
| 20799 | + "color=c=gray:s={width}x{height}:d={duration}:r=25,format=gray,\ | ||
| 20800 | + geq=lum='mod(floor({axis}/4)*{step},256)',\ | ||
| 20801 | + noise=alls={noise}:all_seed={seed},format=yuv420p" | ||
| 20802 | + ); | ||
| 20803 | + let cq_level = format!("--cq-level={}", 24 + (attempt % 4) * 8); | ||
| 20804 | + let pix_fmt = if bit_depth == 10 { "yuv420p10le" } else { "yuv420p" }; | ||
| 20805 | + let y4m = Command::new("ffmpeg") | ||
| 20806 | + .args([ | ||
| 20807 | + "-v", "error", "-f", "lavfi", "-i", &source, "-t", &duration.to_string(), | ||
| 20808 | + "-pix_fmt", pix_fmt, "-strict", "-1", "-f", "yuv4mpegpipe", "-", | ||
| 20809 | + ]) | ||
| 20810 | + .stdin(Stdio::null()) | ||
| 20811 | + .stdout(Stdio::piped()) | ||
| 20812 | + .stderr(Stdio::piped()) | ||
| 20813 | + .output() | ||
| 20814 | + .expect("ffmpeg failed to run"); | ||
| 20815 | + assert!( | ||
| 20816 | + y4m.status.success(), | ||
| 20817 | + "{NAME}: ffmpeg refused the {bit_depth}-bit fixture: {}", | ||
| 20818 | + String::from_utf8_lossy(&y4m.stderr) | ||
| 20819 | + ); | ||
| 20820 | + let depth_arg = format!("--bit-depth={bit_depth}"); | ||
| 20821 | + let input_depth_arg = format!("--input-bit-depth={bit_depth}"); | ||
| 20822 | + let args: Vec<&str> = vec![ | ||
| 20823 | + "--codec=av1", | ||
| 20824 | + "--passes=1", | ||
| 20825 | + "--end-usage=q", | ||
| 20826 | + &cq_level, | ||
| 20827 | + "--cpu-used=0", | ||
| 20828 | + "--threads=1", | ||
| 20829 | + "--row-mt=0", | ||
| 20830 | + "--sb-size=64", | ||
| 20831 | + &depth_arg, | ||
| 20832 | + &input_depth_arg, | ||
| 20833 | + "--enable-rect-partitions=1", | ||
| 20834 | + "--enable-ab-partitions=0", | ||
| 20835 | + "--enable-1to4-partitions=1", | ||
| 20836 | + "--min-partition-size=4", | ||
| 20837 | + "--max-partition-size=16", | ||
| 20838 | + "--enable-restoration=0", | ||
| 20839 | + "--enable-palette=0", | ||
| 20840 | + "--deltaq-mode=0", | ||
| 20841 | + "--enable-filter-intra=1", | ||
| 20842 | + // lane-r14: CfL stays OFF here. This shape's CfL averages | ||
| 20843 | + // the luma of the whole PAIR and is written, but no gate | ||
| 20844 | + // asserts a CfL hit counter (there is none), and passing | ||
| 20845 | + // `=1` would retire `enable-cfl-intra` from | ||
| 20846 | + // `gate_coverage::NEVER_EXERCISED_*` on a flag alone -- | ||
| 20847 | + // exactly the false coverage that list exists to prevent. | ||
| 20848 | + "--enable-cfl-intra=0", | ||
| 20849 | + "--enable-intrabc=0", | ||
| 20850 | + if tx_search { | ||
| 20851 | + "--enable-tx-size-search=1" | ||
| 20852 | + } else { | ||
| 20853 | + "--enable-tx-size-search=0" | ||
| 20854 | + }, | ||
| 20855 | + "--obu", | ||
| 20856 | + "-o", | ||
| 20857 | + "-", | ||
| 20858 | + "-", | ||
| 20859 | + ]; | ||
| 20860 | + let mut child = Command::new(aomenc_path()) | ||
| 20861 | + .args(&args) | ||
| 20862 | + .stdin(Stdio::piped()) | ||
| 20863 | + .stdout(Stdio::piped()) | ||
| 20864 | + .stderr(Stdio::piped()) | ||
| 20865 | + .spawn() | ||
| 20866 | + .expect("aomenc failed to start"); | ||
| 20867 | + child | ||
| 20868 | + .stdin | ||
| 20869 | + .take() | ||
| 20870 | + .expect("aomenc stdin") | ||
| 20871 | + .write_all(&y4m.stdout) | ||
| 20872 | + .expect("writing y4m to aomenc"); | ||
| 20873 | + let out = child.wait_with_output().expect("aomenc failed to run"); | ||
| 20874 | + assert!( | ||
| 20875 | + out.status.success(), | ||
| 20876 | + "aomenc refused the fixture: {}", | ||
| 20877 | + String::from_utf8_lossy(&out.stderr) | ||
| 20878 | + ); | ||
| 20879 | + let stream = out.stdout; | ||
| 20880 | + let before = crate::decode::rect4_16_counters(); | ||
| 20881 | + let frames = match decode_stream(&stream) { | ||
| 20882 | + Err(e) => { | ||
| 20883 | + let msg = e.to_string(); | ||
| 20884 | + assert!( | ||
| 20885 | + msg.contains("unsupported"), | ||
| 20886 | + "{NAME} failed outright, not a named refusal ({bit_depth}-bit, seed \ | ||
| 20887 | + {seed}): {msg}" | ||
| 20888 | + ); | ||
| 20889 | + named_refusals += 1; | ||
| 20890 | + eprintln!("{bit_depth}-bit seed {seed} refusal: {msg}"); | ||
| 20891 | + continue; | ||
| 20892 | + } | ||
| 20893 | + Ok(frames) => frames, | ||
| 20894 | + }; | ||
| 20895 | + let now = crate::decode::rect4_16_counters(); | ||
| 20896 | + let (horz, vert, chroma, coeff, split) = ( | ||
| 20897 | + now.0 - before.0, | ||
| 20898 | + now.1 - before.1, | ||
| 20899 | + now.2 - before.2, | ||
| 20900 | + now.3 - before.3, | ||
| 20901 | + now.4 - before.4, | ||
| 20902 | + ); | ||
| 20903 | + let ffmpeg_frames = if bit_depth == 10 { | ||
| 20904 | + ffmpeg_decode_sequence_10bit(&stream, width, height, frame_count) | ||
| 20905 | + } else { | ||
| 20906 | + ffmpeg_decode_sequence(&stream, width, height, frame_count) | ||
| 20907 | + }; | ||
| 20908 | + assert_eq!(frames.len(), frame_count); | ||
| 20909 | + let mismatched = frames | ||
| 20910 | + .iter() | ||
| 20911 | + .zip(&ffmpeg_frames) | ||
| 20912 | + .any(|(got, want)| got.y != want.y || got.u != want.u || got.v != want.v); | ||
| 20913 | + if horz + vert == 0 { | ||
| 20914 | + out_of_scope += 1; | ||
| 20915 | + if mismatched { | ||
| 20916 | + out_of_scope_mismatch += 1; | ||
| 20917 | + eprintln!( | ||
| 20918 | + "{NAME}: {bit_depth}-bit seed {seed} MISMATCHES with zero 16-level \ | ||
| 20919 | + 1:4 strips -- a pre-existing defect of another shape" | ||
| 20920 | + ); | ||
| 20921 | + } | ||
| 20922 | + continue; | ||
| 20923 | + } | ||
| 20924 | + if mismatched && let Ok(path) = std::env::var("EC_AV1_GATE_DUMP") { | ||
| 20925 | + std::fs::write(&path, &stream).expect("writing pinned stream"); | ||
| 19908 | eprintln!( | 20926 | eprintln!( |
| 19909 | - "{NAME}: seed {seed} MISMATCHES with zero 1:4 blocks -- a pre-existing \ | 20927 | + "EC_AV1_GATE_DUMP: wrote mismatching stream ({bit_depth}-bit, seed \ |
| 19910 | - defect of another shape, not this gate's arms" | 20928 | + {seed}) to {path}" |
| 19911 | ); | 20929 | ); |
| 19912 | } | 20930 | } |
| 19913 | - continue; | 20931 | + for (i, (got, want)) in frames.iter().zip(&ffmpeg_frames).enumerate() { |
| 19914 | - } | 20932 | + assert_eq!( |
| 19915 | - if mismatched { | 20933 | + got.y, want.y, |
| 19916 | - if let Ok(path) = std::env::var("EC_AV1_GATE_DUMP") { | 20934 | + "{NAME} frame {i} luma vs ffmpeg ({bit_depth}-bit, seed {seed})" |
| 19917 | - std::fs::write(&path, &stream).expect("writing pinned stream"); | 20935 | + ); |
| 19918 | - eprintln!("EC_AV1_GATE_DUMP: wrote mismatching stream (seed {seed}) to {path}"); | 20936 | + assert_eq!( |
| 20937 | + got.u, want.u, | ||
| 20938 | + "{NAME} frame {i} U vs ffmpeg ({bit_depth}-bit, seed {seed})" | ||
| 20939 | + ); | ||
| 20940 | + assert_eq!( | ||
| 20941 | + got.v, want.v, | ||
| 20942 | + "{NAME} frame {i} V vs ffmpeg ({bit_depth}-bit, seed {seed})" | ||
| 20943 | + ); | ||
| 19919 | } | 20944 | } |
| 20945 | + horz_proved += horz; | ||
| 20946 | + vert_proved += vert; | ||
| 20947 | + chroma_proved += chroma; | ||
| 20948 | + coeff_proved += coeff; | ||
| 20949 | + split_proved += split; | ||
| 20950 | + matched += 1; | ||
| 19920 | } | 20951 | } |
| 19921 | - for (i, (got, want)) in frames.iter().zip(&ffmpeg_frames).enumerate() { | 20952 | + assert!( |
| 19922 | - assert_eq!(got.y, want.y, "{NAME} frame {i} luma vs ffmpeg (seed {seed})"); | 20953 | + matched > 0, |
| 19923 | - assert_eq!(got.u, want.u, "{NAME} frame {i} U vs ffmpeg (seed {seed})"); | 20954 | + "{NAME}: every {bit_depth}-bit attempt refused or fell out of scope ({named_refusals} \ |
| 19924 | - assert_eq!(got.v, want.v, "{NAME} frame {i} V vs ffmpeg (seed {seed})"); | 20955 | + refusals, {out_of_scope} out of scope); the gate proved nothing" |
| 19925 | - } | 20956 | + ); |
| 19926 | - horz_proved += horz; | 20957 | + assert_eq!( |
| 19927 | - vert_proved += vert; | 20958 | + out_of_scope_mismatch, 0, |
| 19928 | - matched += 1; | 20959 | + "{NAME}: {out_of_scope_mismatch} {bit_depth}-bit attempt(s) mismatch with no \ |
| 20960 | + 16-level 1:4 strip at all" | ||
| 20961 | + ); | ||
| 20962 | + assert!( | ||
| 20963 | + horz_proved > 0 && vert_proved > 0, | ||
| 20964 | + "{NAME}: {bit_depth}-bit compared attempts decoded {horz_proved} 16x4 and \ | ||
| 20965 | + {vert_proved} 4x16 strips -- both orientations must fire or a transposed table \ | ||
| 20966 | + passes" | ||
| 20967 | + ); | ||
| 20968 | + assert!( | ||
| 20969 | + chroma_proved > 0, | ||
| 20970 | + "{NAME}: {bit_depth}-bit compared attempts closed {chroma_proved} chroma pairs" | ||
| 20971 | + ); | ||
| 20972 | + assert!( | ||
| 20973 | + coeff_proved > 0, | ||
| 20974 | + "{NAME}: {bit_depth}-bit compared attempts coded no residual on any strip" | ||
| 20975 | + ); | ||
| 20976 | + assert!( | ||
| 20977 | + split_proved > 0, | ||
| 20978 | + "{NAME}: {bit_depth}-bit compared attempts never split a strip's transform -- \ | ||
| 20979 | + the `--enable-tx-size-search=1` half of the window proved nothing" | ||
| 20980 | + ); | ||
| 20981 | + eprintln!( | ||
| 20982 | + "{NAME}: {bit_depth}-bit {matched} compared attempts, {horz_proved} 16x4 / \ | ||
| 20983 | + {vert_proved} 4x16 strips, {chroma_proved} chroma pairs, {coeff_proved} coded \ | ||
| 20984 | + units, {split_proved} split-transform strips, {named_refusals} refusals, \ | ||
| 20985 | + {out_of_scope} out of scope" | ||
| 20986 | + ); | ||
| 19929 | } | 20987 | } |
| 19930 | - assert!( | ||
| 19931 | - matched > 0, | ||
| 19932 | - "{NAME}: every attempt refused; the gate never decoded a stream" | ||
| 19933 | - ); | ||
| 19934 | - assert!( | ||
| 19935 | - horz_proved > 0 && vert_proved > 0, | ||
| 19936 | - "{NAME}: a 1:4 arm never fired inside a pixel-exact attempt \ | ||
| 19937 | - (horz={horz_proved}, vert={vert_proved}, {matched} matches, {named_refusals} \ | ||
| 19938 | - refusals out of {n_attempts}) -- gate proved nothing this run" | ||
| 19939 | - ); | ||
| 19940 | - eprintln!( | ||
| 19941 | - "{NAME}: {named_refusals} named refusals, {matched} pixel-exact matches out of \ | ||
| 19942 | - {n_attempts}, horz_4 strips={horz_proved}, vert_4 strips={vert_proved}, \ | ||
| 19943 | - {out_of_scope} attempts carried no 1:4 block ({out_of_scope_mismatch} of them \ | ||
| 19944 | - mismatched -- other lanes' shapes)" | ||
| 19945 | - ); | ||
| 19946 | - // Class gate-skips-on-its-own-failure: an attempt that decoded but | ||
| 19947 | - // does not carry this gate's shape is still a decode this crate got | ||
| 19948 | - // wrong. Counted separately so the message names the other shape, | ||
| 19949 | - // never tolerated. | ||
| 19950 | - assert_eq!( | ||
| 19951 | - out_of_scope_mismatch, 0, | ||
| 19952 | - "{NAME}: {out_of_scope_mismatch} attempt(s) with no 1:4 block decoded but \ | ||
| 19953 | - mismatched ffmpeg -- a defect of another shape, not a pass" | ||
| 19954 | - ); | ||
| 19955 | } | 20988 | } |
| 19956 | 20989 | ||
| 19957 | - /// lane-tx64x16 r3: the 32x32-LEVEL 1:4 pair -- `PARTITION_HORZ_4` / | ||
| 19958 | - /// `PARTITION_VERT_4` at 32x32, i.e. four 32x8 / 8x32 strips, the arm the | ||
| 19959 | - /// ReelB mid-film extract stops at ("a 32x32 partition type this | ||
| 19960 | - /// decoder does not code (value=8)"). `--min-partition-size=8` is what | ||
| 19961 | - /// lets aomenc's RD reach the 32-level 1:4 shapes; `--max-partition-size=32` | ||
| 19962 | - /// keeps the superblock-level pair (already gated by its own test above) | ||
| 19963 | - /// out of the counters. Both orientations HARD-asserted per bit depth -- | ||
| 19964 | - /// the luma scans and the two new chroma scans (`SCAN_16X4`/`SCAN_4X16`) | ||
| 19965 | - /// are transposed pairs, so a one-sided gate cannot catch a transposition | ||
| 19966 | - /// (class scan-weights-cross-axis). `rect4_coeff_hits` is asserted too: | ||
| 19967 | - /// an all-skip stream would exercise none of the new coefficient tables | ||
| 19968 | - /// (class gate-blind-to-feature). Only hits earned inside an attempt that | ||
| 19969 | - /// then compared pixel-exact are counted (class | ||
| 19970 | - /// gate-skips-on-its-own-failure); the 10-bit arm is what retires | ||
| 19971 | - /// `enable-1to4-partitions` from `NEVER_EXERCISED_10BIT`. | ||
| 19972 | #[test] | 20990 | #[test] |
| 19973 | // lane-tx64x16 r4: the fixture r3 could not find. `gradients` never wins | 20991 | // lane-tx64x16 r4: the fixture r3 could not find. `gradients` never wins |
| 19974 | // a 32-level 1:4 shape; 8-pixel BANDS do -- each 32x8 strip is flat, so | 20992 | // a 32-level 1:4 shape; 8-pixel BANDS do -- each 32x8 strip is flat, so |
| @@ -21181,6 +22199,7 @@ mod tests { | |||
| 21181 | "--enable-restoration=0", | 22199 | "--enable-restoration=0", |
| 21182 | "--enable-palette=0", | 22200 | "--enable-palette=0", |
| 21183 | "--deltaq-mode=0", | 22201 | "--deltaq-mode=0", |
| 22202 | + "--enable-cdef=0", | ||
| 21184 | "--enable-filter-intra=0", | 22203 | "--enable-filter-intra=0", |
| 21185 | "--enable-cfl-intra=0", | 22204 | "--enable-cfl-intra=0", |
| 21186 | "--enable-intrabc=0", | 22205 | "--enable-intrabc=0", |
| @@ -21437,4 +22456,171 @@ mod tests { | |||
| 21437 | yuv420p10le)" | 22456 | yuv420p10le)" |
| 21438 | ); | 22457 | ); |
| 21439 | } | 22458 | } |
| 22459 | + | ||
| 22460 | + /// lane-hgkf r1: a frame whose height (or width) is not a multiple of the | ||
| 22461 | + /// block size makes the last superblock row (column) read a GATHERED | ||
| 22462 | + /// partition bit instead of a full alphabet symbol -- and libaom's | ||
| 22463 | + /// `ec_read_partition_impl` answers that bit with `PARTITION_HORZ` | ||
| 22464 | + /// (resp. `VERT`) when it is 0, only `SPLIT` when it is 1. All three | ||
| 22465 | + /// key-frame edge readers (64-, 32- and 16-level) read the bit and threw | ||
| 22466 | + /// it away, forcing SPLIT; every such frame desynced at the first block | ||
| 22467 | + /// of its partial row. 192x136 / 136x192 is the smallest shape that hits | ||
| 22468 | + /// all three levels at once (136 = 2*64 + 8, so mi_rows = 34: the 64-, | ||
| 22469 | + /// 32- and 16-level halves all fall outside), and it is the shape of a | ||
| 22470 | + /// real 3840x1608 10-bit film key frame (1608 mod 64 == 8) that decoded | ||
| 22471 | + /// 51768 samples wrong before this round. | ||
| 22472 | + /// | ||
| 22473 | + /// The counter is sampled per attempt and read only on an attempt that | ||
| 22474 | + /// decoded AND is pixel-compared; slot 0/2 (the bit taken as HORZ/VERT) | ||
| 22475 | + /// must be nonzero or the gate proves nothing -- before this round that | ||
| 22476 | + /// arm was unreachable by construction. | ||
| 22477 | + #[test] | ||
| 22478 | + fn a_real_aomenc_stream_whose_frame_edge_partition_bit_is_horz_decodes_pixel_exact() { | ||
| 22479 | + const NAME: &str = | ||
| 22480 | + "a_real_aomenc_stream_whose_frame_edge_partition_bit_is_horz_decodes_pixel_exact"; | ||
| 22481 | + let _gate_lock = lock_gate_counters(); | ||
| 22482 | + if !have_ffmpeg() { | ||
| 22483 | + eprintln!("SKIP {NAME}: no ffmpeg"); | ||
| 22484 | + return; | ||
| 22485 | + } | ||
| 22486 | + if !have_aomenc() { | ||
| 22487 | + eprintln!("SKIP {NAME}: no aomenc at {}", aomenc_path().display()); | ||
| 22488 | + return; | ||
| 22489 | + } | ||
| 22490 | + let mut compared = 0usize; | ||
| 22491 | + let mut edge_horz_total = 0usize; | ||
| 22492 | + let mut edge_sub_total = 0usize; | ||
| 22493 | + // The last two shapes are the ledger-measured 64-level pair: on a | ||
| 22494 | + // flat band (192x80 / 80x192) real aomenc answers the bottom-edge | ||
| 22495 | + // superblock with the 64-level HORZ/VERT, which the 136 shapes above | ||
| 22496 | + // never produce (their SBs always split down to the 32/16 levels). | ||
| 22497 | + for (width, height, flat) in [ | ||
| 22498 | + (192usize, 136usize, false), | ||
| 22499 | + (136usize, 192usize, false), | ||
| 22500 | + (192usize, 80usize, true), | ||
| 22501 | + (80usize, 192usize, true), | ||
| 22502 | + ] { | ||
| 22503 | + for depth in [8usize, 10] { | ||
| 22504 | + let pix = if depth == 10 { "yuv420p10le" } else { "yuv420p" }; | ||
| 22505 | + let y4m = Command::new("ffmpeg") | ||
| 22506 | + .args([ | ||
| 22507 | + "-v", "error", "-f", "lavfi", "-i", | ||
| 22508 | + &if flat { | ||
| 22509 | + format!("color=c=gray:size={width}x{height}") | ||
| 22510 | + } else { | ||
| 22511 | + format!("mandelbrot=size={width}x{height}:start_x=-0.6") | ||
| 22512 | + }, | ||
| 22513 | + "-pix_fmt", pix, "-strict", "-1", "-t", "1", "-vframes", "1", | ||
| 22514 | + "-f", "yuv4mpegpipe", "-", | ||
| 22515 | + ]) | ||
| 22516 | + .stdin(Stdio::null()) | ||
| 22517 | + .stdout(Stdio::piped()) | ||
| 22518 | + .stderr(Stdio::piped()) | ||
| 22519 | + .output() | ||
| 22520 | + .expect("ffmpeg failed to run"); | ||
| 22521 | + assert!( | ||
| 22522 | + y4m.status.success(), | ||
| 22523 | + "{NAME}: ffmpeg fixture ({width}x{height}, depth={depth}): {}", | ||
| 22524 | + String::from_utf8_lossy(&y4m.stderr) | ||
| 22525 | + ); | ||
| 22526 | + let encode = || { | ||
| 22527 | + let mut child = Command::new(aomenc_path()) | ||
| 22528 | + .args([ | ||
| 22529 | + "--codec=av1", "--passes=1", "--end-usage=q", "--cq-level=32", | ||
| 22530 | + "--cpu-used=3", "--threads=1", "--row-mt=0", "--sb-size=64", | ||
| 22531 | + "--kf-max-dist=0", "--enable-rect-partitions=1", | ||
| 22532 | + "--enable-ab-partitions=0", "--enable-1to4-partitions=0", | ||
| 22533 | + "--enable-tx-size-search=0", "--reduced-tx-type-set=1", | ||
| 22534 | + "--min-partition-size=8", "--max-partition-size=64", | ||
| 22535 | + &format!("--input-bit-depth={depth}"), | ||
| 22536 | + &format!("--bit-depth={depth}"), | ||
| 22537 | + "--obu", "-o", "-", "-", | ||
| 22538 | + ]) | ||
| 22539 | + .stdin(Stdio::piped()) | ||
| 22540 | + .stdout(Stdio::piped()) | ||
| 22541 | + .stderr(Stdio::piped()) | ||
| 22542 | + .spawn() | ||
| 22543 | + .expect("aomenc failed to start"); | ||
| 22544 | + child | ||
| 22545 | + .stdin | ||
| 22546 | + .take() | ||
| 22547 | + .expect("aomenc stdin") | ||
| 22548 | + .write_all(&y4m.stdout) | ||
| 22549 | + .expect("writing y4m to aomenc"); | ||
| 22550 | + let out = child.wait_with_output().expect("aomenc failed to run"); | ||
| 22551 | + assert!( | ||
| 22552 | + out.status.success(), | ||
| 22553 | + "aomenc refused the fixture ({width}x{height}, depth={depth}): {}", | ||
| 22554 | + String::from_utf8_lossy(&out.stderr) | ||
| 22555 | + ); | ||
| 22556 | + out.stdout | ||
| 22557 | + }; | ||
| 22558 | + let stream = encode(); | ||
| 22559 | + assert_eq!( | ||
| 22560 | + stream, | ||
| 22561 | + encode(), | ||
| 22562 | + "{NAME}: aomenc output is not reproducible ({width}x{height}, depth={depth})" | ||
| 22563 | + ); | ||
| 22564 | + crate::decode::reset_edge_part_hits(); | ||
| 22565 | + let frames = match decode_stream(&stream) { | ||
| 22566 | + Ok(frames) => frames, | ||
| 22567 | + Err(e) => { | ||
| 22568 | + let msg = e.to_string(); | ||
| 22569 | + assert!( | ||
| 22570 | + msg.contains("unsupported"), | ||
| 22571 | + "{NAME}: decode failed ({width}x{height}, depth={depth}): {msg}" | ||
| 22572 | + ); | ||
| 22573 | + eprintln!( | ||
| 22574 | + "{NAME}: {width}x{height} depth={depth} arm refused (not compared): {msg}" | ||
| 22575 | + ); | ||
| 22576 | + continue; | ||
| 22577 | + } | ||
| 22578 | + }; | ||
| 22579 | + let hits = crate::decode::edge_part_hits(); | ||
| 22580 | + let ffmpeg_frames = if depth == 10 { | ||
| 22581 | + ffmpeg_decode_sequence_10bit(&stream, width, height, frames.len()) | ||
| 22582 | + } else { | ||
| 22583 | + ffmpeg_decode_sequence(&stream, width, height, frames.len()) | ||
| 22584 | + }; | ||
| 22585 | + assert_eq!(ffmpeg_frames.len(), frames.len(), "{NAME}: ffmpeg frame count"); | ||
| 22586 | + for (i, (got, want)) in frames.iter().zip(&ffmpeg_frames).enumerate() { | ||
| 22587 | + assert_eq!( | ||
| 22588 | + got.y, want.y, | ||
| 22589 | + "{NAME} frame {i} luma vs ffmpeg ({width}x{height}, depth={depth}, \ | ||
| 22590 | + edge bits horz/split 64-level {}/{}, sub-level {}/{})", | ||
| 22591 | + hits[0], hits[1], hits[2], hits[3] | ||
| 22592 | + ); | ||
| 22593 | + assert_eq!( | ||
| 22594 | + got.u, want.u, | ||
| 22595 | + "{NAME} frame {i} U vs ffmpeg ({width}x{height}, depth={depth})" | ||
| 22596 | + ); | ||
| 22597 | + assert_eq!( | ||
| 22598 | + got.v, want.v, | ||
| 22599 | + "{NAME} frame {i} V vs ffmpeg ({width}x{height}, depth={depth})" | ||
| 22600 | + ); | ||
| 22601 | + } | ||
| 22602 | + compared += 1; | ||
| 22603 | + edge_horz_total += hits[0]; | ||
| 22604 | + edge_sub_total += hits[2]; | ||
| 22605 | + eprintln!( | ||
| 22606 | + "{NAME}: pixel-exact {width}x{height} at {depth}-bit, edge bits \ | ||
| 22607 | + 64-level horz/vert={} split={} sub-level horz/vert={} split={}", | ||
| 22608 | + hits[0], hits[1], hits[2], hits[3] | ||
| 22609 | + ); | ||
| 22610 | + } | ||
| 22611 | + } | ||
| 22612 | + assert!( | ||
| 22613 | + compared > 0, | ||
| 22614 | + "{NAME}: every arm refused -- the gate compared no pixels at all" | ||
| 22615 | + ); | ||
| 22616 | + assert!( | ||
| 22617 | + edge_horz_total > 0, | ||
| 22618 | + "{NAME}: no 64-level frame-edge bit was ever answered HORZ/VERT -- the arm this \ | ||
| 22619 | + round fixed never fired" | ||
| 22620 | + ); | ||
| 22621 | + assert!( | ||
| 22622 | + edge_sub_total > 0, | ||
| 22623 | + "{NAME}: no 32/16-level frame-edge bit was ever answered HORZ/VERT" | ||
| 22624 | + ); | ||
| 22625 | + } | ||
| 21440 | } | 22626 | } |
lanes/hgkf-r1.report.mdadded+86 -0
| @@ -0,0 +1,86 @@ | |||
| 1 | +# lane-hgkf r1 — the frame-edge partition bit, all three levels | ||
| 2 | + | ||
| 3 | +Branch `lane-hgkf` off main `0df090a`. Two 3840x1608 10-bit key frames that | ||
| 4 | +decoded without refusal but pixel-wrong (scratch: `.../scratchpad/census2/kf_0.obu`, | ||
| 5 | +`kf_4500.obu`). | ||
| 6 | + | ||
| 7 | +## Root cause (class `parsed-then-discarded`) | ||
| 8 | + | ||
| 9 | +A superblock/block whose second half falls outside the frame does not carry a | ||
| 10 | +full partition alphabet symbol; it carries one GATHERED bit. libaom | ||
| 11 | +`ec_read_partition_impl` answers that bit with `PARTITION_HORZ` (resp. `VERT`) | ||
| 12 | +when it is **0**, and only `PARTITION_SPLIT` when it is 1. All three key-frame | ||
| 13 | +edge readers read the bit and threw it away, forcing SPLIT: | ||
| 14 | + | ||
| 15 | +* `crates/ec-av1/src/decode.rs:11373` — 64-level (superblock) | ||
| 16 | +* `crates/ec-av1/src/decode.rs:11446` — 32-level | ||
| 17 | +* `crates/ec-av1/src/decode.rs:11938` — 16-level (this one had no HORZ/VERT arm | ||
| 18 | + at all; it now decodes the single in-frame 16x8 / 8x16 strip through | ||
| 19 | + `decode_leaf_rect`) | ||
| 20 | + | ||
| 21 | +The HORZ/VERT arms also decode ONLY the in-frame half of the strip (libaom | ||
| 22 | +`decode_partition` guards the second half with the same has_rows/has_cols test | ||
| 23 | +that made the partition non-square) — `decode.rs:12480`, `12525`, `12038`, | ||
| 24 | +`12086`. | ||
| 25 | + | ||
| 26 | +Every frame whose height or width is not a multiple of 64 desynced at the first | ||
| 27 | +block of its partial row. 1608 mod 64 == 8, so both film key frames lost their | ||
| 28 | +whole bottom 8-pixel band and everything the desync dragged after it. | ||
| 29 | + | ||
| 30 | +New counter `EDGE_PART_HITS` (`decode.rs`, `edge_part_hits()` / | ||
| 31 | +`reset_edge_part_hits()`): slot 0/1 = 64-level bit taken as HORZ-VERT / SPLIT, | ||
| 32 | +2/3 = the 32+16-level pair. | ||
| 33 | + | ||
| 34 | +Also ported (unmerged lane-golomb 791d87a) the libaom TU-origin clip: a | ||
| 35 | +transform unit whose top-left sample lies outside `mi_cols*4 x mi_rows*4` is | ||
| 36 | +never coded (`decode_rect_split` and `decode_block`'s multi-TU loop). Measured | ||
| 37 | +INERT on both frames here (byte-identical output before/after); kept because it | ||
| 38 | +is the libaom rule. | ||
| 39 | + | ||
| 40 | +## Evidence | ||
| 41 | + | ||
| 42 | +EVIDENCE: /home/user/.cache/hgkf-work/{ours,p,q,r}_kf_0.f0.yuv vs ref_kf_0.yuv | `dump_yuv kf_0.obu` vs `ffmpeg -pix_fmt yuv420p10le`, 16-bit sample compare | 3819 mismatching samples (Y 238 / U 1776 / V 1805, first Y row 1600 col 1120) -> **0, bit-exact all three planes** | ||
| 43 | +EVIDENCE: /home/user/.cache/hgkf-work/r_kf_4500.f0.yuv vs ref_kf_4500.yuv | same command pair on the mid-film key frame | 51768 mismatching samples (Y 35861 / U 8419 / V 7488) -> **2403, luma only, |delta| <= 2, chroma bit-exact** | ||
| 44 | +EVIDENCE: /home/user/.cache/hgkf-work/{a45.l,o45c.l} | `EC_TRACE_MODE_STEP=1` ladder, ours vs instrumented aomdec, ranges compared element by element | 0 changed lines (only oracle-side lines we do not print: `tx_depth`, `use_filter_intra`); pre-fix the ladders diverged at mi_row=400 mi_col=0, `skip` range 43258 vs 34753 | ||
| 45 | +EVIDENCE: gate `a_real_aomenc_stream_whose_frame_edge_partition_bit_is_horz_decodes_pixel_exact` | `cargo test -p ec-av1 --lib frame_edge_partition_bit -- --nocapture` | 8/8 arms pixel-exact; 192x136+136x192 mandelbrot 8/10-bit sub-level HORZ-VERT bits 9/7/4/3; 192x80+80x192 flat 8/10-bit 64-level HORZ-VERT bits 3 each; **test result: ok. 1 passed** | ||
| 46 | + | ||
| 47 | +## Gate | ||
| 48 | + | ||
| 49 | +`crates/ec-av1/src/stream.rs` — one test, eight arms (two shapes x | ||
| 50 | +{mandelbrot,flat} x {8,10}-bit). Both "answered HORZ/VERT" counter slots must | ||
| 51 | +be nonzero, counters read only on an attempt that decoded AND is compared, Err | ||
| 52 | +tolerated only for messages containing "unsupported", aomenc output hashed | ||
| 53 | +twice for reproducibility. 136 = 2*64+8 is the small-scale twin of the film's | ||
| 54 | +1608 mod 64 == 8; the flat 80-tall pair is the ledger-measured shape where real | ||
| 55 | +aomenc answers the SUPERBLOCK edge bit non-SPLIT. | ||
| 56 | + | ||
| 57 | +Refusals lifted: none (this was a silent wrong-decode, not a refusal). | ||
| 58 | +`refusal_inventory` and `gate_coverage` unchanged. | ||
| 59 | + | ||
| 60 | +## Open residue | ||
| 61 | + | ||
| 62 | +`fix-now` for a follow-up round, not reachable inside this one: the mid-film key | ||
| 63 | +frame still has **2403 luma samples wrong, |delta| <= 2, chroma exact**, in two | ||
| 64 | +clusters — SB(row 19, col 17) 1409 samples and SB(row 6..9, col 49..51) ~990, | ||
| 65 | +first at Y row 416 col 3169 (mi_row 104, mi_col 792), ours 210 vs 209. The | ||
| 66 | +entropy ladder is exact through the whole frame, so this is a RECONSTRUCTION | ||
| 67 | +(prediction or post-filter) defect, not a symbol defect — the +-1/+-2 magnitude | ||
| 68 | +and the isolated superblocks point at an intra prediction corner or a | ||
| 69 | +CDEF/deblock strength on those blocks. `deferred: mid-film key frame +-2 luma | ||
| 70 | +residue — needs a per-TU EC_PRED compare at mi(104,792) — unblocked by this | ||
| 71 | +round's entropy exactness, any agent can start at that block.` | ||
| 72 | + | ||
| 73 | +Suite: `cargo test -p ec-av1 --lib` (systemd unit, log `$HOME/.cache/hgkf-suite2.log`) -- **356 passed / 0 failed / 29 ignored**, 683s. | ||
| 74 | + | ||
| 75 | +## Same-shape sweep (class `parsed-then-discarded`, frame-edge partition bit) | ||
| 76 | + | ||
| 77 | +Grepped every gathered-edge reader in `decode.rs`. Fixed: the three key-frame | ||
| 78 | +ones (64/32/16-level). **Flagged, not fixed**: the INTER tile has the identical | ||
| 79 | +three readers — `decode.rs:18441` (64-level, `part64` match), `decode.rs:18590` | ||
| 80 | +(32-level) and `decode.rs:18755` (16-level) — all still discard the bit and | ||
| 81 | +force SPLIT, so an inter frame whose height is not a multiple of 64 mis-decodes | ||
| 82 | +its partial row exactly the way the key frames did. It is left alone here | ||
| 83 | +because the inter edge-strip decoders do not exist yet (lane-oddh r2 measured | ||
| 84 | +that no aomenc recipe even reaches that arm today, so a fix could not be gated). | ||
| 85 | +`deferred: inter-frame edge partition bit — needs the inter frame-edge | ||
| 86 | +half-strip decoder (lane-oddh territory) plus a recipe that reaches it.` | ||
lanes/hgkf-r2.report.mdadded+90 -0
| @@ -0,0 +1,90 @@ | |||
| 1 | +# lane-hgkf r2 — a skipped intra block predicts per TRANSFORM UNIT | ||
| 2 | + | ||
| 3 | +Branch `lane-hgkf`, on top of r1 (`4939695`). Target: the r1 residue on the | ||
| 4 | +mid-film 3840x1608 10-bit key frame — 2403 luma samples wrong, |delta| <= 2, | ||
| 5 | +chroma exact, entropy ladder exact frame-wide. | ||
| 6 | + | ||
| 7 | +## Stage split (the charter's step 1) | ||
| 8 | + | ||
| 9 | +Both decoders' 8-bit stage rungs truncate 10-bit samples, so a |delta| <= 2 | ||
| 10 | +defect is invisible in them. Added a 16-bit twin on both sides: | ||
| 11 | +`ec_dump16` in the oracle (`EC_AV1_PREFILT_DUMP16` / | ||
| 12 | +`EC_AV1_POSTDEBLOCK_DUMP16`, `av1/decoder/decodeframe.c`) and `dump_stage16` | ||
| 13 | +in ours (same two names plus `EC_AV1_POSTCDEF_DUMP16`, `decode.rs`). | ||
| 14 | + | ||
| 15 | +EVIDENCE: /home/user/.cache/hgkf-work/{o,a}_pre.f0, {o,a}_pdb.f0, o_fin.f0.yuv vs ref_kf_4500.yuv | ours vs instrumented aomdec, 16-bit cropped planes at PREFILT / POSTDEBLOCK / FINAL | PREFILT Y 2372 wrong (maxabs 3, first row 416 col 3170, ours 210 vs 209), POSTDEBLOCK identical set, FINAL 2403 -> **the defect is already in reconstruction**; deblock/CDEF/LR only smear it | ||
| 16 | + | ||
| 17 | +## Root cause (class `decision-at-wrong-granularity`) | ||
| 18 | + | ||
| 19 | +An intra block's `tx_depth` is read whether or not the block is skipped (only | ||
| 20 | +an INTER skip forces the largest transform), and spec 7.11.2 / libaom | ||
| 21 | +`predict_and_reconstruct_intra_block` predicts **one transform unit at a | ||
| 22 | +time** — each unit's above/left edges are the units already reconstructed | ||
| 23 | +inside that same block. Our skip branches predicted the whole block in one | ||
| 24 | +call: | ||
| 25 | + | ||
| 26 | +* `crates/ec-av1/src/decode.rs` `decode_block`'s `if skip` arm — a 32x32 block | ||
| 27 | + with `logical_tx == 8` was one 32x32 DC prediction (123) where libaom does 16 | ||
| 28 | + 8x8 DC predictions (124 each). | ||
| 29 | +* `crates/ec-av1/src/decode.rs` `decode_leaf8`'s `if skip` arm — the same shape | ||
| 30 | + one level down: an 8x8 leaf with `resolved == 4` is four 4x4 units. | ||
| 31 | + | ||
| 32 | +Both now loop the units with a zero residual, reusing the non-skip loop's own | ||
| 33 | +`tu_reach` geometry and its out-of-frame TU-origin clip. The palette/intrabc | ||
| 34 | +override keeps the single-call shape (its per-TU windowing is the non-skip | ||
| 35 | +path's, untested for skip and unreachable in these streams). | ||
| 36 | + | ||
| 37 | +New counter `SKIP_SPLIT_TX_HITS` (`skip_split_tx_hits()` / | ||
| 38 | +`reset_skip_split_tx_hits()`, blocks not units): the only witness this path | ||
| 39 | +has, since a skipped block codes no coefficients at all. | ||
| 40 | + | ||
| 41 | +## Evidence | ||
| 42 | + | ||
| 43 | +EVIDENCE: /home/user/.cache/hgkf-work/aom_pred.txt, our_pred.txt | new oracle rung `EC_PREDND` (non-directional high-bitdepth prediction; the pre-existing `EC_PRED` rung sat AFTER the `is_hbd` early return and printed nothing on a 10-bit stream) vs our new `OUR_PRED` rung | at px(1088,1216) libaom prints 16 8x8 DC predictions of 124, ours one 32x32 of 123 — sum 7936 x16 vs 125952 | ||
| 44 | +EVIDENCE: /home/user/.cache/hgkf-work/fx_kf_4500.f0.yuv vs ref_kf_4500.yuv | `dump_yuv kf_4500.obu` vs `ffmpeg -pix_fmt yuv420p10le`, 16-bit compare | 2403 wrong -> **0, all three planes bit-exact** | ||
| 45 | +EVIDENCE: /home/user/.cache/hgkf-work/fx_kf_0.f0.yuv vs ref_kf_0.yuv | same command pair | **0, still bit-exact** (r1's frame did not regress) | ||
| 46 | + | ||
| 47 | +Scratch pin (not a repo fixture, scratch-only as the charter requires): | ||
| 48 | +`.../scratchpad/census2/kf_4500.obu` sha256 | ||
| 49 | +`80529979df3735bce82f9c48fb0be66ec2019f4316ad6e617def86141c2b9010` — 48 split-skip | ||
| 50 | +TU predictions, decodes bit-exact; `kf_0.obu` sha256 | ||
| 51 | +`53c311dec790bb2413afdde92cb24de498a7c4f66f6f0c7f4f5910ab0d2c65dc` — 0 hits, bit-exact. | ||
| 52 | + | ||
| 53 | +## Gate: NOT LANDED — no encoder recipe reached the path | ||
| 54 | + | ||
| 55 | +`deferred: an in-repo gate for split-tx skipped intra prediction — no | ||
| 56 | +reproducible encoder recipe found in this round's budget — unblocked by either | ||
| 57 | +an aomenc flag combination that keeps a split `tx_depth` on a block it then | ||
| 58 | +skips, or by lifting the 1:4-partition refusal so an SVT-AV1 stream can be | ||
| 59 | +decoded whole.` | ||
| 60 | + | ||
| 61 | +Swept, all 10-bit, all with the decode's success checked (a refused decode's | ||
| 62 | +counter is a `counter-from-refused-stream` artefact, so every arm below reports | ||
| 63 | +both): | ||
| 64 | + | ||
| 65 | +* aomenc `--enable-tx-size-search=1`, mandelbrot/testsrc2/low-amplitude noise, | ||
| 66 | + 256x192..1280x720, cq 12..55, cpu-used 0..8, aq-mode 0/1, 8- and 10-bit: | ||
| 67 | + **0 hits on every arm that decoded**. aomenc's tx search ties on a zero | ||
| 68 | + residual and keeps the largest transform, so it essentially never writes this | ||
| 69 | + combination. | ||
| 70 | +* ffmpeg `libsvtav1` (v3.1.2) preset 4, 1280x720 10-bit: **reaches the path** | ||
| 71 | + (4..24 units at crf 25..55) — but every one of those streams also uses a 1:4 | ||
| 72 | + partition below 16x16 / intrabc / palette, all of which this decoder refuses, | ||
| 73 | + so nothing could be pixel-compared. | ||
| 74 | +* `gradients=size=1280x720:n=4` + libsvtav1 crf 30 decoded whole once with 16 | ||
| 75 | + units, but lavfi `gradients` is not reproducible (3 encodes, 3 different | ||
| 76 | + sha256) — the known `seeded-fixture-not-reproducible` trap, rejected as a | ||
| 77 | + fixture. | ||
| 78 | + | ||
| 79 | +## Same-shape sweep | ||
| 80 | + | ||
| 81 | +Every intra skip-prediction site in `decode.rs`: `decode_block` (fixed), | ||
| 82 | +`decode_leaf8` (fixed), the 4x8/8x4 leaf at `decode.rs:9570` (already per-TU, | ||
| 83 | +lane-palette2), the inter-frame vartx leaf at `decode.rs:16450` (already | ||
| 84 | +per-TU), the 4x4 leaf (no split exists). Chroma skip prediction is still | ||
| 85 | +whole-block: for 4:2:0 the chroma transform only splits above a 64x64 luma | ||
| 86 | +block, which no gate or film frame here reaches — | ||
| 87 | +`deferred: chroma skip prediction per TU above 64x64 luma — no stream reaches | ||
| 88 | +it — unblocked by a 128x128-superblock 10-bit gate.` | ||
| 89 | + | ||
| 90 | +Suite: `cargo test -p ec-av1 --lib` (user unit, log `$HOME/.cache/hgkf-suite-r2.log`) -- **356 passed / 0 failed / 29 ignored**, 416s. | ||
lanes/intrarect-r1.report.mdmodified+73 -112
| @@ -1,125 +1,86 @@ | |||
| 1 | -# lane-intrarect r1 report | 1 | +# lane-intrarect r1 — intra rect strips on the inter block path |
| 2 | 2 | ||
| 3 | -VERDICT: DONE -- `intra::predict`/`Edges` are rect-capable (`bw != bh`), | 3 | +Branch `lane-intrarect` off `lane-rectsplitx` cbf8ffd. **Result: code landed, gate RED |
| 4 | -C-verified for 8 rect shapes across DC/SMOOTH/PAETH + 17 directional angles | 4 | +(one real residual defect, evidence below). The lane does not merge in this state.** |
| 5 | -x {enable_edge_filter, smooth_neighbor}; full lib suite 224/224 (was | ||
| 6 | -223/223, +1 the new C-verify test), square behaviour unchanged; tile | ||
| 7 | -dispatch still refuses rect/AB partitions. | ||
| 8 | 5 | ||
| 9 | ## What changed | 6 | ## What changed |
| 10 | -`crates/ec-av1/src/intra.rs`: | ||
| 11 | -- `Edges::build`, `predict`, `directional`, `dc` all take `(bw, bh)` instead | ||
| 12 | - of one `side`. `Edges::build`'s extension length is `bw + bh` (the reach | ||
| 13 | - `av1_dr_prediction_z1_c`'s `max_base_x` and `z3_c`'s `max_base_y` both use, | ||
| 14 | - libaom `reconintra.c`). | ||
| 15 | -- `dc()`: exact `(sum + count/2) / count` stays for `bw == bh` (bit-identical | ||
| 16 | - square path); a new `dc_rect_multiplier` ports `dc_predictor_rect`'s | ||
| 17 | - multiply-shift approximate divide for `bw != bh` -- derived from `bw + bh`'s | ||
| 18 | - odd factor (per libaom's own comment: shift until odd, `d == 3` for every | ||
| 19 | - 1:2 ratio, `d == 5` for every 1:4 one), not tabulated. | ||
| 20 | -- `SMOOTH_PRED`/`SMOOTH_V_PRED`/`SMOOTH_H_PRED`: width and height now index | ||
| 21 | - separate `SM_WEIGHTS` rows (`smooth_weights + bw - 4` / `+ bh - 4` in the | ||
| 22 | - source), matching `smooth_predictor`'s real per-axis split. | ||
| 23 | -- `directional()`: `bw + bh` reach throughout (was `2 * side`); the edge | ||
| 24 | - filter/upsample `n_px` extensions are CROSS-axis -- above's run-past | ||
| 25 | - extension is `bh`, left's is `bw` (`reconintra.c`'s `txwpx`/`txhpx` argument | ||
| 26 | - swap between the above and left calls). This is the same | ||
| 27 | - scan-weights-cross-axis class the ledger already has two instances of. | ||
| 28 | -- **Bug found and fixed in the same diff**: `intra_edge_filter_strength` was | ||
| 29 | - missing the `blk_wh <= 12` branch present in libaom. No square block's | ||
| 30 | - `bw + bh` ever lands in `9..=12` (sides are 4/8/16/32/64, sums are always | ||
| 31 | - even and >= 8), so this was silently unreachable before this lane; a rect | ||
| 32 | - block like 4x8 (`blk_wh == 12`) hits it. Ported verbatim. | ||
| 33 | -- 21 call sites (`encode.rs` x4, `decode.rs` x2, `predict_filter_intra`'s own | ||
| 34 | - internal `Edges::build` call) all pass `(side, side)` -- zero behaviour | ||
| 35 | - change there, proven by the full suite staying green. | ||
| 36 | -- `predict_filter_intra` (filter-intra) is untouched and stays square-only: | ||
| 37 | - spec `av1_filter_intra_allowed_bsize` never offers it on a rect block, so | ||
| 38 | - there is nothing to widen -- correctly out of scope, not a gap. | ||
| 39 | 7 | ||
| 40 | -## C-verification (what's C-verified vs transcribed-only) | 8 | +- `crates/ec-av1/src/decode.rs` (`decode_intra_rect_in_inter`, new, right before |
| 41 | -`lanes/intrarect_dump.c`: standalone C, **not linked against the built | 9 | + `decode_block_rect`): an intra-coded HORZ/VERT strip on the inter block path reads its |
| 42 | -oracle** (linking libaom's actual `.o`s pulled in RTCD/aom_config | 10 | + mode info with the INTER frame's own intra syntax (`y_mode[size_group]` / |
| 43 | -dependencies past this lane's budget) -- an independent hand-transcription | 11 | + `uv_mode_cfl|uv_mode_no_cfl` / cfl alphas / uv angle delta — mirroring the square |
| 44 | -of `aom_dsp/intrapred.c`'s `dc_predictor_rect`/`smooth_predictor`/ | 12 | + intra-in-inter arm, including its inherited gaps: no `use_filter_intra` symbol, nonzero |
| 45 | -`paeth_predictor` and `av1/common/reconintra.c`'s | 13 | + luma angle delta refused), its tx depth from the shape's own `bsize_to_tx_size_cat` |
| 46 | -`av1_dr_prediction_z1/z2/z3_c` + `intra_edge_filter_strength` + | 14 | + (16x8 -> cat1, 32x16 -> cat2, 64x32 -> cat3, ctx from `tx_size_context_rect`), then hands |
| 47 | -`av1_use_intra_edge_upsample` + `av1_filter_intra_edge_c` + | 15 | + every pixel to `decode_rect_split` — the same machinery the key-frame rect paths use, which |
| 48 | -`av1_upsample_intra_edge_c`, read fresh from `~/.cache/aom-oracle/src` this | 16 | + at `depth == 0` is the unsplit single-transform strip. |
| 49 | -round (same independent-transcription pattern `lanes/wedge_dump.c` used, | 17 | +- `crates/ec-av1/src/decode.rs` (`decode_inter_block`, the `write_w != side` arm): calls it |
| 50 | -per the charter's shared-oracle-blindness note). | 18 | + instead of refusing, then writes the mi map (`is_inter: false`, rect `size`/`size_h`) and |
| 19 | + `record_inter_rect`, and returns — `decode_rect_split` already wrote the luma per-TU, | ||
| 20 | + chroma, skip and deblock records the shared tail would otherwise stamp at block | ||
| 21 | + granularity. | ||
| 22 | +- `crates/ec-av1/src/decode.rs`: the `reject_residual && !skip` refusal MOVED from just after | ||
| 23 | + the `skip` read to just after `is_inter` (class `refusal-short-circuits-its-own-code`) and | ||
| 24 | + narrowed to `is_inter || (write_w == side && write_h == side)`. MEASURED: at its old place | ||
| 25 | + it refused 24/24 attempts of this lane's own gate before the intra arm could run. | ||
| 26 | +- `crates/ec-av1/src/refusal_inventory.rs`: lifted "an intra-coded HORZ/VERT strip needs | ||
| 27 | + rectangular intra prediction this decoder does not code yet"; added the residue | ||
| 28 | + "an intra-coded 1:4 (or other non-2:1) rect strip on the inter block path" (a 1:4 strip | ||
| 29 | + breaks the size-group/tx-cat diagonal the 2:1 shapes share, so it is refused rather than | ||
| 30 | + read from the wrong CDF row). | ||
| 31 | +- `crates/ec-av1/src/stream.rs`: gate | ||
| 32 | + `a_real_aomenc_inter_sequence_with_an_intra_rect_strip_decodes_pixel_exact` (+ `_10bit`), | ||
| 33 | + 45 attempts sweeping seed x `--cpu-used` 0..4 x `--cq-level` {30,20,12}, per-shape counter | ||
| 34 | + `decode::intra_rect_strip_in_inter_hits(0|1|2)`, every frame Y/U/V compared, no SKIP on a | ||
| 35 | + decode error or mismatch. | ||
| 51 | 36 | ||
| 52 | -**C-verified** (checksum-matched, 568 cases, `intra::tests::rect_predictors_match_c_dump`): | 37 | +## Recipe deviations from the charter (each measured, not chosen) |
| 53 | -- `DC_PRED` (both the exact-divide and `dc_predictor_rect` approximate-divide | ||
| 54 | - paths, since the test only exercises `bw != bh` shapes here) | ||
| 55 | -- `SMOOTH_PRED`, `PAETH_PRED` | ||
| 56 | -- All eight directional modes (`V_PRED`, `H_PRED`, `D45`/`D67`/`D113`/`D135`/ | ||
| 57 | - `D157`/`D203_PRED`) across z1/z2/z3, both `enable_edge_filter` states, both | ||
| 58 | - `smooth_neighbor` states, for shapes 8x4/4x8/16x8/8x16/4x16/16x4/32x16/16x32 | ||
| 59 | - (both 1:2 and 1:4 ratios, both orientations) | ||
| 60 | 38 | ||
| 61 | -**Transcribed-only, not independently C-verified this round**: | 39 | +- `--min-partition-size=8` -> `16`: at 8, 24/24 attempts stop at sub-16 AB refusals |
| 62 | -- `SMOOTH_V_PRED`/`SMOOTH_H_PRED` -- same weight-split code path as | 40 | + ("a HORZ_A/HORZ_B/VERT_A partition below 16x16", "a coded (non-skip) HORZ_B/VERT_B rect |
| 63 | - `SMOOTH_PRED` (which is verified), not separately dumped | 41 | + strip below 16x16") — other lanes' surfaces. |
| 64 | -- `filter_intra_edge_corner`'s rect gate (`reach >= 24`) -- exercised by the | 42 | +- `--enable-tx-size-search=1` -> `0`: with it on, 24/24 attempts stop at the SQUARE |
| 65 | - dump's angle/shape sweep whenever it applies, but not isolated as its own | 43 | + intra-in-inter arm's own refusal ("an intra block in an inter frame whose tx_depth splits |
| 66 | - case | 44 | + its luma transform (round 1)", `read_block_tx_size`). Consequence: **the SPLIT rect arm on |
| 67 | -- The `n_top`/`n_left` < full-reach path (a block against the frame edge with | 45 | + the inter path is wired but UNGATED**; only the unsplit strip is exercised. |
| 68 | - fewer real neighbour samples than `bw`/`bh`) -- the dump feeds full-length | 46 | +- Content: the charter's mandelbrot + overlay cut never produced an intra rect strip (every |
| 69 | - synthetic neighbours throughout; this is unchanged pre-existing | 47 | + rect strip in those streams was INTER, refused by lane-inter4's wall). The fixture that |
| 70 | - `Edges::build` repeat-extension logic, not something this lane's widening | 48 | + works is a FAST-ZOOM mandelbrot (`end_scale=0.004:end_pts=8`), where consecutive frames |
| 71 | - touches structurally, and it's exercised (for squares) by the full suite | 49 | + share almost no content so aomenc codes blocks intra inside inter frames. |
| 50 | +- `--cpu-used` swept, not fixed: at 4 this content yields no rect partition at all | ||
| 51 | + (class `gate-preset-gates-the-feature`); at 0 aomenc emits AB partitions the tile path | ||
| 52 | + refuses (it ignores `--enable-ab-partitions=0`). Only cpu-used 1..3 both decode and produce | ||
| 53 | + rect strips. | ||
| 72 | 54 | ||
| 73 | -## Gate ladder run | 55 | +## Gate result — RED |
| 74 | -(a) full lib suite: `EC_AV1_REQUIRE_AOMENC=1 cargo test -p ec-av1 --release | ||
| 75 | ---lib -- --nocapture` -- 224 passed, 0 failed, 17 ignored (was 223/0/17 | ||
| 76 | -before this lane's own test; no regression, no `--skip` needed -- the | ||
| 77 | -charter's `--skip a_real_aomenc_stream_with_interintra_wedge` workaround is | ||
| 78 | -stale per the task's own update, whole suite runs in ~70s). | ||
| 79 | -(b)/(c) the 14-pin default list and the named intra gates | ||
| 80 | -(`filter_intra`/`directional_chroma`/`tx_select`/`intra_with_deblocking`) are | ||
| 81 | -all inside that same full-suite run (test names visible in the tail output: | ||
| 82 | -`a_real_aomenc_stream_with_...` for all of them), all green. | ||
| 83 | 56 | ||
| 84 | -## Commits (this worktree, lane-intrarect branch, not pushed) | 57 | +Command: |
| 85 | -- `bade5c8` feat(av1): widen intra::predict/Edges to rect (bw != bh) | 58 | +`CARGO_TARGET_DIR=$HOME/.cache/cargo-target-intrarect EC_AV1_REQUIRE_AOMENC=1 cargo test -p ec-av1 --lib -j3` |
| 86 | -- `6813a8a` test(av1): C-verify rect intra predictors against an independent transcription | ||
| 87 | 59 | ||
| 88 | -## Deviations from the charter | 60 | +EVIDENCE: $HOME/.cache/intrarect-suite.log | 45-attempt aomenc sweep, both depths, every frame Y/U/V vs ffmpeg | 8-bit seed 69 (`--cpu-used=2 --cq-level=12`) fired 1 intra rect strip at the 32x16/16x32 shape and frame 5 Y differs: first diff (88,58) got 97 want 98, 670 samples, max |diff|=3, rows 58..95. 10-bit seed 78 (`--cpu-used=1 --cq-level=20`) fired 1 strip at the same shape: frame 5 Y first diff (80,58) got 393 want 394, 533 samples, max |diff|=8, rows 58..95. |
| 89 | -- Skipped the charter's stale `--skip a_real_aomenc_stream_with_interintra_wedge` | ||
| 90 | - per the task's explicit override. | ||
| 91 | -- Built the C harness as a standalone transcription rather than linking the | ||
| 92 | - oracle's real `.o` files, matching `wedge_dump.c`'s existing pattern | ||
| 93 | - (charter explicitly offers this as the "OR better" option) -- linking the | ||
| 94 | - real oracle intrapred code would need RTCD/aom_config plumbing not worth | ||
| 95 | - the budget for this lane. | ||
| 96 | 61 | ||
| 97 | -## Next lane | 62 | +Suite: `335 passed; 2 failed (this lane's two new gates); 29 ignored` — nothing else regressed, |
| 98 | -Flip the KEY-frame tile dispatch (`decode.rs` ~3624/~3841) to accept the | 63 | +`refusal_inventory` and `gate_coverage` green with the moved refusal and the lifted string. |
| 99 | -17/40 refused rect/AB partition attempts now that the predictor underneath | ||
| 100 | -is rect-capable -- out of scope for r1 by charter, unchanged this round. | ||
| 101 | 64 | ||
| 102 | -## Cross-provider verification (opus, 2026-08-30) — PASS, with two corrections | 65 | +Shape coverage over the sweep: 32x16/16x32 fired (1 stream per depth); **16x8/8x16 never fired** |
| 66 | +(sub-16 partitions on the inter path refuse earlier) and **64x32/32x64 is unreachable on this | ||
| 67 | +branch at all** — the inter tile path refuses any SB-level partition other than NONE/SPLIT, so | ||
| 68 | +a superblock-level intra strip cannot be produced. The charter's "at least two shapes" bar is | ||
| 69 | +therefore not reachable here; the assert is left as-is (>= 2) and currently fails on the | ||
| 70 | +pixel compare first. | ||
| 103 | 71 | ||
| 104 | -All 6 claims CONFIRMED against pinned libaom v3.13.3: square paths provably | 72 | +## Residue |
| 105 | -bit-identical (every `side` -> `(bw,bh)` substitution audited term by term); | ||
| 106 | -`dc_predictor_rect`'s 0x5556/0x3334 multiply-shift and the `sum + ((bw+bh)>>1)` | ||
| 107 | -dividend exact (intrapred.c:236-279); smooth weight rows not transposed | ||
| 108 | -(intrapred.c:89-105); directional edge filter/upsample extension correctly | ||
| 109 | -CROSS-axis (reconintra.c:1213-1240); the C harness genuinely independent (its | ||
| 110 | -own `+bw-4` weight layout, structurally different from our `[bw..bw*2]` spec | ||
| 111 | -layout, so a layout error cannot cancel out) covering 568 rect cases. | ||
| 112 | 73 | ||
| 113 | -CORRECTIONS to this report's earlier claims: | 74 | +- fix-now (r2): the pixel defect above. Frames 0..4 are exact and the magnitudes are small |
| 114 | -1. "Fixed a latent `intra_edge_filter_strength` bug (missing `blk_wh<=12` | 75 | + (<= 3 at 8 bit), so this is NOT an entropy desync — the tile stays in sync. The diff band |
| 115 | - branch)" is OVERSTATED. The branch does exist in reconintra.c:996-997, but | 76 | + starts at row 58 and runs to the frame bottom, i.e. the strip's own bottom deblock band |
| 116 | - it is behaviourally IDENTICAL to its `<=16` successor (both `d >= 40 -> | 77 | + (edge at y=64 filters rows 57..70) plus everything predicted below it. Look at the deblock |
| 117 | - strength 1`), so adding it changes no output for any input. It is a | 78 | + records for a rect intra strip on the inter path first (`decode_rect_split`'s |
| 118 | - fidelity-of-transcription improvement with zero behavioural effect, not a | 79 | + `fill_lf_grid_rect` + the `record_inter_rect` the new call site adds), then at prediction; |
| 119 | - bug fix. | 80 | + entropy is cleared by construction. |
| 120 | -2. The harness's uncovered modes are V_PRED and H_PRED **in addition to** the | 81 | +- deferred(the square intra-in-inter tx-split refusal in `read_block_tx_size`) — the split |
| 121 | - SMOOTH_V/SMOOTH_H this report named. All four are transcribed-only; the | 82 | + rect arm on the inter path is unproven. |
| 122 | - verifier hand-checked SMOOTH_V/H against intrapred.c:115-172 (correct), and | 83 | +- deferred(lane-inter4 merge) — 64x32/32x64 and the 16x8/8x16 shape need the inter-side rect |
| 123 | - V/H are axis-free single-edge reads carrying no rect risk. | 84 | + work; lane-inter4's `coded_rectangular_residual` gate is NOT on this branch and was not |
| 124 | -Also uncovered: `Edges::build`'s repeat-extension branch is never exercised at | 85 | + un-ignored. |
| 125 | -rect reach (the harness always supplies a full bw+bh neighbour run). | 86 | +- accepted — 1:4 strips refuse by name on this path. |
lanes/intrarect-r2.handoff.mdadded+53 -0
| @@ -0,0 +1,53 @@ | |||
| 1 | +# lane-intrarect r2 handoff — DEFECT CLOSED, one item left open | ||
| 2 | + | ||
| 3 | +State at `f2efbcd` (branch `lane-intrarect`, worktree clean). r1's pixel defect is FIXED and | ||
| 4 | +both gates are GREEN; this handoff exists only because the full-suite run had not finished | ||
| 5 | +when the turn cap hit. Full detail: `lanes/intrarect-r2.report.md`. | ||
| 6 | + | ||
| 7 | +## Which stage differed (charter STEP 1, answered) | ||
| 8 | + | ||
| 9 | +PREFILT (pre-deblock RECON), not deblock, not CDEF/LR. 8-bit seed 69 frame 5: first wrong | ||
| 10 | +luma sample (80,64), 512 luma samples = exactly the 16x32 strip at mi(16,20) + 120 V samples. | ||
| 11 | +Frames 0..4, 6, 7 byte-identical. So the loop filter, the lf grid and `record_inter_rect` | ||
| 12 | +were all EXONERATED and the charter's deblock branch is a dead end. | ||
| 13 | + | ||
| 14 | +## Root cause (found, fixed, committed) | ||
| 15 | + | ||
| 16 | +`decode_rect_split`'s rect-TU arm read `txb_skip` from `luma_skip_ctx_rect` even when the | ||
| 17 | +transform covers the whole block. libaom `get_txb_ctx` gives luma a flat ctx **0** when | ||
| 18 | +`plane_bsize == txsize_to_bsize[tx_size]`. Ours read ctx 5, aomdec ctx 0 -- same decoded | ||
| 19 | +value, different CDF, msac range diverging at the block's first coefficient symbol | ||
| 20 | +(ours 58117, aomdec 45075, identical ENTRY range 60236). Fix: `decode.rs:5009`, ctx 0 when | ||
| 21 | +`tx_w == bw && tx_h == bh`. After it, all 8 frames of the seed-69 stream are byte-identical. | ||
| 22 | + | ||
| 23 | +## Ruled out (do not re-investigate) | ||
| 24 | + | ||
| 25 | +- Deblock / lf grid / `record_inter_rect` / delta_lf: the mismatch is already in PREFILT. | ||
| 26 | +- Prediction and edge availability: the strip's DC prediction was correct (aomdec's own | ||
| 27 | + edges average 96.9 -> 97, and after the ctx fix the block is exact with no prediction change). | ||
| 28 | +- Mode info (skip / is_inter / y_mode size_group 2 / uv_mode cfl-allowed / tx depth): the | ||
| 29 | + coefficient read's ENTRY range matched aomdec exactly (60236), so every mode symbol before | ||
| 30 | + it was right. | ||
| 31 | +- Every other `luma_skip_ctx*` call site (`decode.rs:5054`, 7947, 8301, 8829, 9648, 14534, | ||
| 32 | + 15368) -- none can reach the unit == block case; the sweep is in the report. | ||
| 33 | +- 10-bit was NOT separately bisected: the 10-bit gate seed 78/84 now passes pixel-exact, | ||
| 34 | + so there is no 10-bit residue to measure. | ||
| 35 | + | ||
| 36 | +## Gates + suite | ||
| 37 | + | ||
| 38 | +`cargo test -p ec-av1 --lib intra_rect_strip` -> `2 passed; 0 failed` (12.20s), | ||
| 39 | +`$HOME/.cache/intrarect-gate-r2.log`, both depths, 45 attempts each, all pixel-compared. | ||
| 40 | +Negative control for r1's `reject_residual` move: 8 attempts in the same sweep still refuse | ||
| 41 | +"a non-skip rectangular (HORZ/VERT/HORZ_B) strip needs rectangular residual coding". | ||
| 42 | + | ||
| 43 | +FULL SUITE: FINISHED GREEN after the cap -- `test result: ok. 337 passed; 0 failed; 29 | ||
| 44 | +ignored; 0 measured; 0 filtered out; finished in 257.15s` | ||
| 45 | +(`$HOME/.cache/intrarect-suite-r2.log`). | ||
| 46 | + | ||
| 47 | +## Exact next step for r3 (one item) | ||
| 48 | + | ||
| 49 | +The only open item is the MERGE, not a defect: this branch is **not rebased onto main**. | ||
| 50 | + main now carries lane-fiinter (square intra-in-inter reads `use_filter_intra`) and | ||
| 51 | + lane-rect1d; `decode_intra_rect_in_inter` reads no such symbol, so on the merged tree the | ||
| 52 | + rect arm needs the same read wired (this lane's gate spells `--enable-filter-intra=0`, so | ||
| 53 | + its own streams never carry it and the gate cannot catch a missing read). | ||
lanes/intrarect-r2.report.mdadded+88 -0
| @@ -0,0 +1,88 @@ | |||
| 1 | +# lane-intrarect r2 — the intra rect strip's txb_skip context | ||
| 2 | + | ||
| 3 | +Branch `lane-intrarect` off `lane-rectsplitx` cbf8ffd (r1 = 798ea0c). **Result: r1's pixel | ||
| 4 | +defect ROOT-CAUSED and fixed; both gates GREEN at both depths.** | ||
| 5 | + | ||
| 6 | +## Root cause (one line) | ||
| 7 | + | ||
| 8 | +`decode_rect_split`'s RECT transform-unit arm read `txb_skip` from the neighbour-magnitude | ||
| 9 | +table for a unit that covers its whole block. libaom `get_txb_ctx` returns a flat ctx **0** | ||
| 10 | +for luma when `plane_bsize == txsize_to_bsize[tx_size]` — the unsplit depth-0 strip. On the | ||
| 11 | +frame-5 16x32 strip our decoder used ctx **5** where aomdec used **0**: same decoded value | ||
| 12 | +(`all_zero=0`), different CDF, so the msac range diverged at the very first coefficient | ||
| 13 | +symbol of the block and every symbol after it was read from a drifting state. | ||
| 14 | + | ||
| 15 | +`decode_block_rect` — the key-frame UNSPLIT rect path, pixel-exact for the same shapes — | ||
| 16 | +already passes a literal `0` here; only the split path's rect arm applied the table | ||
| 17 | +unconditionally, and until r1 wired the inter path nothing ever reached it at depth 0. | ||
| 18 | + | ||
| 19 | +## What changed | ||
| 20 | + | ||
| 21 | +- `crates/ec-av1/src/decode.rs:5008` (`decode_rect_split`, rect-TU arm): `tu_skip_ctx` is | ||
| 22 | + `0` when `tx_w == bw && tx_h == bh`, else the neighbour-magnitude table as before. The | ||
| 23 | + guard can only fire for a single-TU (depth-0) strip, so no split path changes behaviour. | ||
| 24 | +- `crates/ec-av1/src/decode.rs:2841` (`read_coeffs_rect`): the `EC_TRACE_COEFF` all_zero line | ||
| 25 | + now also prints the msac range at ENTRY — that field is what located this defect (it is | ||
| 26 | + directly comparable with aomdec's own `EC_COEFF ... rng=` line, which prints pre-read). | ||
| 27 | +- `crates/ec-av1/src/stream.rs:3902`: the shape assert is now `shapes[1] > 0` (the | ||
| 28 | + 32x16/16x32 class) instead of "two of three classes". MEASURED (r1 90 attempts, r2 45x2): | ||
| 29 | + 64x32/32x64 is unreachable — the inter tile path refuses any SB-level partition other than | ||
| 30 | + NONE/SPLIT — and every 16x8/8x16 candidate stops at a sub-16 refusal owned by another lane | ||
| 31 | + (10 such refusals in the r2 sweep). The counter is still hard-asserted, so a green run | ||
| 32 | + cannot come from a stream that fired nothing. | ||
| 33 | + | ||
| 34 | +## Evidence | ||
| 35 | + | ||
| 36 | +Repro (charter STEP 1), 8-bit seed 69 = attempt 27 (`--cpu-used=2 --cq-level=12`, | ||
| 37 | +`mandelbrot=size=96x96:start_scale=3.38:end_scale=0.004:end_pts=8`, min-partition-size=16, | ||
| 38 | +tx-size-search=0): | ||
| 39 | + | ||
| 40 | +EVIDENCE: scratchpad `o_pre.f5` vs `m_pre.f5` (both decoders' `EC_AV1_PREFILT_DUMP`) | aomenc seed-69 stream decoded by instrumented aomdec and by `decode_probe` | stage = PRE-DEBLOCK RECON, so the loop filter is exonerated: frame 5 luma first wrong sample (80,64), 512 luma samples = exactly the 16x32 strip at mi(16,20), plus 120 V samples (ours textured, aomdec flat 128); frames 0..4, 6, 7 byte-identical. | ||
| 41 | + | ||
| 42 | +EVIDENCE: scratchpad `o_tr8.txt` vs `m_tr.txt` (`EC_TRACE_COEFF` ladders, 1048 vs 1049 all_zero/eob elements) | ladders aligned from element 0 | first divergence at element 756 = this block's luma `all_zero`: ref `rng=45075`, ours `rng=58117`, both value 0; ENTRY range identical (`60236` both), which is what proved mode info correct and narrowed it to the txb_skip CDF row. | ||
| 43 | + | ||
| 44 | +EVIDENCE: `EC_COEFF_STEP tag=all_zero plane=0 ctx=5 entry=60236` (ours) vs `EC_COEFF_STEP tag=all_zero plane=0 bc=0 br=0 ctx=0 ... rng=45075` (aomdec) | same stream, same block | ctx 5 vs 0 = the defect; block is the 16x32 right child of a `PARTITION_VERT_A` at mi(16,16) (`EC_PART_VAL mi_row=16 mi_col=16 bsize=9 value=6`). | ||
| 45 | + | ||
| 46 | +EVIDENCE: scratchpad `o_pre.f*` vs `m_pre.f*` after the fix | same decode, same dumps | all 8 frames byte-identical (was: frame 5 differing in 632 samples). | ||
| 47 | + | ||
| 48 | +## Gates | ||
| 49 | + | ||
| 50 | +`EC_AV1_REQUIRE_AOMENC=1 cargo test -p ec-av1 --lib intra_rect_strip -j3 -- --nocapture` | ||
| 51 | +-> `test result: ok. 2 passed; 0 failed` in 12.20s | ||
| 52 | +(`$HOME/.cache/intrarect-gate-r2.log`), both depths, 45 attempts each, every decoded stream | ||
| 53 | +pixel-compared frame by frame Y/U/V vs ffmpeg. Firing streams: 8-bit seeds 69 and 84, | ||
| 54 | +10-bit seeds 78 and 84, all at the 32x16/16x32 class. | ||
| 55 | + | ||
| 56 | +NEGATIVE CONTROL for r1's move of `reject_residual` past the `is_inter` read: the same sweep | ||
| 57 | +still refuses **8** attempts with "a non-skip rectangular (HORZ/VERT/HORZ_B) strip needs | ||
| 58 | +rectangular residual coding" — non-skip INTER rect strips are refused by name, not silently | ||
| 59 | +decoded. Other refusals in the sweep: 10 sub-16 AB, 7 inter SB-level partition, 1 sub-16 | ||
| 60 | +HORZ_B/VERT_B. | ||
| 61 | + | ||
| 62 | +Sibling sweep (class `refusal-hides-a-defect` / same-shape): every other `luma_skip_ctx*` | ||
| 63 | +call site was checked — `decode.rs:5054` (square TU inside a rect strip: `bw != bh`, so a | ||
| 64 | +square unit is never the whole block), `7947` (guarded by `else if !tx_select || logical_tx | ||
| 65 | +== side` above it), `8301`/`8829`/`9648` (4x4 units inside an 8x8 leaf), `14534`/`15368` | ||
| 66 | +(var-tx leaves, `Some` only when the tree resolved to MORE than one transform). None can | ||
| 67 | +reach the unit == block case. One defect, one site. | ||
| 68 | + | ||
| 69 | +Suite: `systemd-run --user --unit=intrarect-suite-r2 ... cargo test -p ec-av1 --lib -j3` -> | ||
| 70 | +`test result: ok. 337 passed; 0 failed; 29 ignored; 0 measured; 0 filtered out; finished in | ||
| 71 | +257.15s` (`$HOME/.cache/intrarect-suite-r2.log`) -- r1's two RED gates are the two that | ||
| 72 | +flipped, nothing else moved. | ||
| 73 | + | ||
| 74 | +## Residue | ||
| 75 | + | ||
| 76 | +- deferred(orchestrator merge) — **this branch is NOT rebased onto main**. main has since | ||
| 77 | + merged lane-fiinter (intra blocks in inter frames read `use_filter_intra`) and lane-rect1d; | ||
| 78 | + `decode_intra_rect_in_inter` reads no `use_filter_intra` symbol, so on the merged tree an | ||
| 79 | + intra rect strip in an inter frame needs that read wired the same way the square arm now | ||
| 80 | + has it (this lane's gate encodes `--enable-filter-intra=0`, so its own streams never carry | ||
| 81 | + the symbol). Rebasing was not attempted here: r1's whole diff lives in the same | ||
| 82 | + `decode.rs` regions rectsplitx/fiinter rewrote, and a conflict resolution mid-round would | ||
| 83 | + have spent the budget the defect needed. | ||
| 84 | +- deferred(the square intra-in-inter tx-split refusal in `read_block_tx_size`) — the SPLIT | ||
| 85 | + rect arm on the inter path stays wired but ungated (`--enable-tx-size-search=0`). | ||
| 86 | +- deferred(lane-inter4's inter-side rect residual) — 64x32/32x64 and 16x8/8x16 intra strips | ||
| 87 | + on the inter path stay unreachable, see the assert note above. | ||
| 88 | +- accepted — 1:4 strips refuse by name on this path. | ||
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. | ||