forge
Explore
Log in

Don't you dare go Hollow

Merge main 18bf7dc (lane-sb128 5ea5ec8) into lane-sb128b

Browse files at this commit

f00f0e160dc82075c2e5c1ae5bf0a8fa3049ecfaAhmet Kaan GümüşParent: 69826a6c6f22ad
Conflicts all in stream.rs and all resolved to MAIN's side, per the batch
coordinator: main's `a_real_aomenc_128x128_superblock_stream_decodes_pixel_exact`
(one 128 seam gate, `--min-partition-size=16`, part128 symbol assert) replaces
this lane's own conversion of the same gate, and lane-oddh's seam refusal stays
deleted. cdf.rs merged clean -- the NZ_MAP and FILTER_INTRA regions are
byte-identical to main's, this lane's only cdf.rs delta is the four
TXB_SKIP_CHROMA_32_BIG tables.

11 changed files +1519 -100

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+7 -1
@@ -488,7 +488,7 @@ pub const CFL_SIGN: [u16; 9] = [1418, 2123, 13340, 18405, 26972, 28343, 32294, 3
488 /// `av1_filter_intra_allowed_bsize`'s "both sides <= 32" bound, so libaom488 /// `av1_filter_intra_allowed_bsize`'s "both sides <= 32" bound, so libaom
489 /// reads `use_filter_intra` there too and the missing rows dropped the489 /// reads `use_filter_intra` there too and the missing rows dropped the
490 /// symbol on every DC_PRED 1:4 strip.490 /// symbol on every DC_PRED 1:4 strip.
491-pub const FILTER_INTRA: [[u16; 3]; 12] = [491+pub const FILTER_INTRA: [[u16; 3]; 14] = [
492 [4621, 32768, 0],492 [4621, 32768, 0],
493 [7866, 32768, 0],493 [7866, 32768, 0],
494 [12408, 32768, 0],494 [12408, 32768, 0],
@@ -501,6 +501,12 @@ pub const FILTER_INTRA: [[u16; 3]; 12] = [
501 [5893, 32768, 0],501 [5893, 32768, 0],
502 [18101, 32768, 0],502 [18101, 32768, 0],
503 [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],
504 ];510 ];
505 /// `default_filter_intra_mode_cdf` (entropymode.c): which of the five511 /// `default_filter_intra_mode_cdf` (entropymode.c): which of the five
506 /// `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+41 -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 for235 /// The tables one transform block is coded with, borrowed from the state for
@@ -574,7 +590,7 @@ pub(crate) struct Cdfs {
574 /// `[1]`=8x8, `[2]`=16x16, `[3]`=32x32, `[4]`=32x16, `[5]`=16x32,590 /// `[1]`=8x8, `[2]`=16x16, `[3]`=32x32, `[4]`=32x16, `[5]`=16x32,
575 /// `[6]`=16x8, `[7]`=8x16, `[8]`=4x8, `[9]`=8x4, `[10]`=32x8, `[11]`=8x32) --591 /// `[6]`=16x8, `[7]`=8x16, `[8]`=4x8, `[9]`=8x4, `[10]`=32x8, `[11]`=8x32) --
576 /// see [`cdf::FILTER_INTRA`].592 /// see [`cdf::FILTER_INTRA`].
577- pub filter_intra: [[u16; 3]; 12],593+ pub filter_intra: [[u16; 3]; 14],
578 /// Which `FILTER_INTRA_MODES` entry a `use_filter_intra` block picks.594 /// Which `FILTER_INTRA_MODES` entry a `use_filter_intra` block picks.
579 pub filter_intra_mode: [u16; 6],595 pub filter_intra_mode: [u16; 6],
580 /// `TxMode::Select`'s `tx_depth` flag at an 8x8 block, by `tx_size_context`596 /// `TxMode::Select`'s `tx_depth` flag at an 8x8 block, by `tx_size_context`
@@ -1824,6 +1840,30 @@ impl Cdfs {
1824 tx_type: Some(self.intra_tx_type_8_set1[mode].as_mut_slice()),1840 tx_type: Some(self.intra_tx_type_8_set1[mode].as_mut_slice()),
1825 eob_pt_class1: Some(&mut self.eob_pt_128_luma_class1),1841 eob_pt_class1: Some(&mut self.eob_pt_128_luma_class1),
1826 },1842 },
1843+ TxbSet::LumaRect16x4 => TxbTables {
1844+ side: 8,
1845+ txb_skip: &mut self.txb_skip_luma_8,
1846+ eob_pt: &mut self.eob_pt_64_luma,
1847+ eob_extra: &mut self.eob_extra_luma_8,
1848+ base: &mut self.base_luma_8,
1849+ base_eob: &mut self.base_eob_luma_8,
1850+ br: &mut self.br_luma_8,
1851+ dc_sign: &mut self.dc_sign_luma,
1852+ tx_type: Some(self.intra_tx_type_4[mode].as_mut_slice()),
1853+ eob_pt_class1: Some(&mut self.eob_pt_64_luma_class1),
1854+ },
1855+ TxbSet::LumaRect16x4Set1 => TxbTables {
1856+ side: 8,
1857+ txb_skip: &mut self.txb_skip_luma_8,
1858+ eob_pt: &mut self.eob_pt_64_luma,
1859+ eob_extra: &mut self.eob_extra_luma_8,
1860+ base: &mut self.base_luma_8,
1861+ base_eob: &mut self.base_eob_luma_8,
1862+ br: &mut self.br_luma_8,
1863+ dc_sign: &mut self.dc_sign_luma,
1864+ tx_type: Some(self.intra_tx_type_4_set1[mode].as_mut_slice()),
1865+ eob_pt_class1: Some(&mut self.eob_pt_64_luma_class1),
1866+ },
1827 TxbSet::LumaRect16x8Inter => TxbTables {1867 TxbSet::LumaRect16x8Inter => TxbTables {
1828 side: 16,1868 side: 16,
1829 txb_skip: &mut self.txb_skip_luma_16,1869 txb_skip: &mut self.txb_skip_luma_16,
crates/ec-av1/src/decode.rsmodified+661 -30
@@ -88,6 +88,14 @@ pub(crate) fn sb_mi_cur() -> u32 {
88 thread_local! {88 thread_local! {
89 static PART128_SYMBOLS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };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) };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())
91 }99 }
92 100
93 /// Current value of [`PART128_SYMBOLS`].101 /// Current value of [`PART128_SYMBOLS`].
@@ -985,6 +993,10 @@ thread_local! {
985 // their rect max transform into square sub-transforms.993 // their rect max transform into square sub-transforms.
986 static RECT_INTER_TU_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };994 static RECT_INTER_TU_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
987 static RECT_INTER_TXSPLIT_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };995 static RECT_INTER_TXSPLIT_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
996+ // lane-r14 r2: luma transform units of an inter strip with a 64-px axis
997+ // (64x32/32x64/64x16/16x64), whose coefficients are coded as the
998+ // truncated low-32 corner.
999+ static RECT64_INTER_TU_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
988 // lane-inter4 r3: 16x16-level PARTITION_HORZ / PARTITION_VERT on an inter1000 // lane-inter4 r3: 16x16-level PARTITION_HORZ / PARTITION_VERT on an inter
989 // frame -- 16x8 and 8x16 inter leaves.1001 // frame -- 16x8 and 8x16 inter leaves.
990 static INTER_LEAF16_HORZ_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };1002 static INTER_LEAF16_HORZ_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
@@ -1032,6 +1044,11 @@ pub(crate) fn rect_inter_txsplit_hits() -> usize {
1032 RECT_INTER_TXSPLIT_HITS.with(|c| c.get())1044 RECT_INTER_TXSPLIT_HITS.with(|c| c.get())
1033 }1045 }
1034 1046
1047+/// Current value of [`RECT64_INTER_TU_HITS`] (lane-r14 r2).
1048+pub(crate) fn rect64_inter_tu_hits() -> usize {
1049+ RECT64_INTER_TU_HITS.with(|c| c.get())
1050+}
1051+
1035 /// Sets the current thread's [`TX_SELECT_INTER`]/[`REDUCED_TX_SET_INTER`]/1052 /// Sets the current thread's [`TX_SELECT_INTER`]/[`REDUCED_TX_SET_INTER`]/
1036 /// [`ENABLE_FILTER_INTRA_INTER`].1053 /// [`ENABLE_FILTER_INTRA_INTER`].
1037 pub(crate) fn set_inter_tx_mode(1054 pub(crate) fn set_inter_tx_mode(
@@ -2171,6 +2188,30 @@ pub(crate) fn rect4_coeff_hits() -> usize {
2171 RECT4_COEFF_HITS.with(|c| c.get())2188 RECT4_COEFF_HITS.with(|c| c.get())
2172 }2189 }
2173 2190
2191+// lane-r14: the 16x16-level 1:4 pair -- four 16x4 (`PARTITION_HORZ_4`) or
2192+// 4x16 (`PARTITION_VERT_4`) strips, `CHROMA` counting the odd strips that
2193+// close a 4:2:0 chroma pair and `COEFF` the strips with a coded residual.
2194+thread_local! {
2195+ static RECT4_16_HORZ_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
2196+ static RECT4_16_VERT_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
2197+ static RECT4_16_CHROMA_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
2198+ static RECT4_16_COEFF_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
2199+ static RECT4_16_SPLIT_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
2200+}
2201+
2202+/// Current values of the 16x16-level 1:4 counters: `(16x4 strips, 4x16
2203+/// strips, chroma-reference strips, strips with a coded residual, strips
2204+/// whose luma transform is split)`.
2205+pub fn rect4_16_counters() -> (usize, usize, usize, usize, usize) {
2206+ (
2207+ RECT4_16_HORZ_HITS.with(|c| c.get()),
2208+ RECT4_16_VERT_HITS.with(|c| c.get()),
2209+ RECT4_16_CHROMA_HITS.with(|c| c.get()),
2210+ RECT4_16_COEFF_HITS.with(|c| c.get()),
2211+ RECT4_16_SPLIT_HITS.with(|c| c.get()),
2212+ )
2213+}
2214+
2174 /// Current value of `RECT4_32_HORZ_HITS` (32x8 strips decoded).2215 /// Current value of `RECT4_32_HORZ_HITS` (32x8 strips decoded).
2175 pub(crate) fn rect4_32_horz_hits() -> usize {2216 pub(crate) fn rect4_32_horz_hits() -> usize {
2176 RECT4_32_HORZ_HITS.with(|c| c.get())2217 RECT4_32_HORZ_HITS.with(|c| c.get())
@@ -5037,6 +5078,10 @@ fn filter_intra_size_class_rect(bw: usize, bh: usize) -> Option<usize> {
5037 // tile (class symbol-consumption-gap).5078 // tile (class symbol-consumption-gap).
5038 (32, 8) => Some(10),5079 (32, 8) => Some(10),
5039 (8, 32) => Some(11),5080 (8, 32) => Some(11),
5081+ // lane-r14: the 16x16-level 1:4 pair (`decode_rect4_16`'s 16x4/4x16
5082+ // strips), rows 17/16 of `default_filter_intra_cdfs`.
5083+ (16, 4) => Some(12),
5084+ (4, 16) => Some(13),
5040 _ if bw == bh => filter_intra_size_class(bw),5085 _ if bw == bh => filter_intra_size_class(bw),
5041 _ => None,5086 _ => None,
5042 }5087 }
@@ -5062,7 +5107,13 @@ fn palette_bsize_ctx(side: usize) -> Option<usize> {
5062 /// `trailing_zeros` is `log2` exactly. `None` past `av1_allow_palette`'s own5107 /// `trailing_zeros` is `log2` exactly. `None` past `av1_allow_palette`'s own
5063 /// bound (`block_size_wide/high <= 64`, `sb_type >= BLOCK_8X8`).5108 /// bound (`block_size_wide/high <= 64`, `sb_type >= BLOCK_8X8`).
5064 fn palette_bsize_ctx_wh(bw: usize, bh: usize) -> Option<usize> {5109 fn palette_bsize_ctx_wh(bw: usize, bh: usize) -> Option<usize> {
5065- if !(8..=64).contains(&bw) || !(8..=64).contains(&bh) {5110+ // lane-r14: `av1_allow_palette`'s bound is `sb_type >= BLOCK_8X8` by the
5111+ // BLOCK_SIZES_ALL enum INDEX, which the 1:4 shapes BLOCK_4X16 (16) and
5112+ // BLOCK_16X4 (17) clear -- a 64-pixel block, so `av1_get_palette_bsize_ctx`
5113+ // (`num_pels_log2 - num_pels_log2[BLOCK_8X8]`) is 0 for them, exactly as
5114+ // for an 8x8. Reading the dimension bound as "both sides >= 8" dropped
5115+ // `palette_y_mode` on every 16x4/4x16 strip of a screen-content frame.
5116+ if bw > 64 || bh > 64 || bw * bh < 64 {
5066 return None;5117 return None;
5067 }5118 }
5068 Some(((bw * bh) as u32).trailing_zeros() as usize - 6)5119 Some(((bw * bh) as u32).trailing_zeros() as usize - 6)
@@ -5384,6 +5435,12 @@ fn read_intra_mode_rect(
5384 above_mode: usize,5435 above_mode: usize,
5385 left_mode: usize,5436 left_mode: usize,
5386 cfl: bool,5437 cfl: bool,
5438+ // lane-r14: `is_chroma_reference` -- false only for a strip one mi tall
5439+ // (or wide) that is NOT the odd one of its 4:2:0 pair, where libaom reads
5440+ // no `uv_mode`/`cfl_alpha`/`angle_delta_uv`/`palette_uv` at all (the pair's
5441+ // chroma is coded once, on the closing strip). Every other caller is a
5442+ // block big enough to own its chroma and passes `true`.
5443+ has_chroma: bool,
5387 bw: usize,5444 bw: usize,
5388 bh: usize,5445 bh: usize,
5389 enable_filter_intra: bool,5446 enable_filter_intra: bool,
@@ -5447,21 +5504,23 @@ fn read_intra_mode_rect(
5447 05504 0
5448 };5505 };
5449 istep!("angle_y", angle_delta_y);5506 istep!("angle_y", angle_delta_y);
5450- let uv_mode = if cfl {5507+ let uv_mode = if !has_chroma {
5508+ DC_PRED
5509+ } else if cfl {
5451 dec.symbol(&mut cdfs.uv_mode_cfl[mode])5510 dec.symbol(&mut cdfs.uv_mode_cfl[mode])
5452 } else {5511 } else {
5453 dec.symbol(&mut cdfs.uv_mode_no_cfl[mode])5512 dec.symbol(&mut cdfs.uv_mode_no_cfl[mode])
5454 };5513 };
5455 istep!("uv_mode", uv_mode as i32);5514 istep!("uv_mode", uv_mode as i32);
5456- let alpha = if cfl && uv_mode == UV_CFL_PRED {5515+ let alpha = if has_chroma && cfl && uv_mode == UV_CFL_PRED {
5457 Some(read_cfl_alphas(dec, cdfs))5516 Some(read_cfl_alphas(dec, cdfs))
5458 } else {5517 } else {
5459 None5518 None
5460 };5519 };
5461- if (9..=12).contains(&uv_mode) {5520+ if has_chroma && (9..=12).contains(&uv_mode) {
5462 SMOOTH_UV_HITS.with(|c| c.set(c.get() + 1));5521 SMOOTH_UV_HITS.with(|c| c.set(c.get() + 1));
5463 }5522 }
5464- let angle_delta_uv = if (V_PRED..=D67_PRED).contains(&uv_mode) {5523+ let angle_delta_uv = if has_chroma && (V_PRED..=D67_PRED).contains(&uv_mode) {
5465 DIRECTIONAL_UV_HITS.with(|c| c.set(c.get() + 1));5524 DIRECTIONAL_UV_HITS.with(|c| c.set(c.get() + 1));
5466 read_angle_delta(dec, &mut cdfs.angle_delta[uv_mode - V_PRED])5525 read_angle_delta(dec, &mut cdfs.angle_delta[uv_mode - V_PRED])
5467 } else {5526 } else {
@@ -5501,7 +5560,11 @@ fn read_intra_mode_rect(
5501 palette_y_pending = Some((n, colors));5560 palette_y_pending = Some((n, colors));
5502 }5561 }
5503 let palette_uv_mode_ctx = usize::from(use_palette_y);5562 let palette_uv_mode_ctx = usize::from(use_palette_y);
5504- if uv_mode == DC_PRED && dec.symbol(&mut cdfs.palette_uv_mode[palette_uv_mode_ctx]) != 0 {5563+ // `read_palette_mode_info`'s own `xd->is_chroma_ref` guard.
5564+ if has_chroma
5565+ && uv_mode == DC_PRED
5566+ && dec.symbol(&mut cdfs.palette_uv_mode[palette_uv_mode_ctx]) != 0
5567+ {
5505 let n = 2 + dec.symbol(&mut cdfs.palette_uv_size[bsize_ctx]);5568 let n = 2 + dec.symbol(&mut cdfs.palette_uv_size[bsize_ctx]);
5506 let (u_colors, v_colors) = read_palette_colors_uv(dec, n, palette_uv_cache);5569 let (u_colors, v_colors) = read_palette_colors_uv(dec, n, palette_uv_cache);
5507 palette_uv_pending = Some((n, u_colors, v_colors));5570 palette_uv_pending = Some((n, u_colors, v_colors));
@@ -6284,6 +6347,7 @@ fn decode_block_rect(
6284 nb_above_mode,6347 nb_above_mode,
6285 nb_left_mode,6348 nb_left_mode,
6286 true,6349 true,
6350+ true,
6287 bw,6351 bw,
6288 bh,6352 bh,
6289 enable_filter_intra,6353 enable_filter_intra,
@@ -6758,6 +6822,7 @@ fn decode_leaf_rect(
6758 above_mode,6822 above_mode,
6759 left_mode,6823 left_mode,
6760 true,6824 true,
6825+ true,
6761 bw,6826 bw,
6762 bh,6827 bh,
6763 enable_filter_intra,6828 enable_filter_intra,
@@ -7037,6 +7102,7 @@ fn decode_block_rect4(
7037 above_mode,7102 above_mode,
7038 left_mode,7103 left_mode,
7039 true,7104 true,
7105+ true,
7040 bw,7106 bw,
7041 bh,7107 bh,
7042 enable_filter_intra,7108 enable_filter_intra,
@@ -7338,6 +7404,434 @@ fn decode_block_rect4(
7338 Ok((mode, uv_predict_mode))7404 Ok((mode, uv_predict_mode))
7339 }7405 }
7340 7406
7407+/// Decodes the four 16x4 / 4x16 strips of a 16x16-level `PARTITION_HORZ_4` /
7408+/// `PARTITION_VERT_4` (lane-r14) -- [`decode_block_rect4`]'s pair one level
7409+/// down, and the first shape here whose luma block is a single mi row (or
7410+/// column).
7411+///
7412+/// What is new at this size is CHROMA. `is_chroma_reference`
7413+/// (`av1_common_int.h`) is false for a 4:2:0 block one mi tall (wide) on an
7414+/// EVEN mi row (column), so strips 0 and 2 read no `uv_mode`/`cfl_alpha`/
7415+/// `angle_delta_uv` at all and code no chroma residual; strips 1 and 3 close
7416+/// the pair and carry the chroma of the whole 16x8 (8x16) luma pair --
7417+/// `setup_pred_plane`'s own `if (subsampling_y && (mi_row & 1) &&
7418+/// mi_size_high[bsize] == 1) mi_row -= 1` offset, i.e. an 8x4 (4x8) chroma
7419+/// transform at the PAIR's origin, with CfL averaging over the pair's luma.
7420+///
7421+/// Tables: LUMA `TX_16X4`/`TX_4X16` averages to the 8x8 entropy context
7422+/// ((0 + 2 + 1) >> 1 = 1) with 64 coded positions, so its CDF set is
7423+/// [`TxbSet::LumaRect16x4`] (`Luma8`'s tables, the `TX_4X4` `tx_type` row);
7424+/// scans are [`SCAN_16X4`]/[`SCAN_4X16`]. CHROMA `TX_8X4`/`TX_4X8` is
7425+/// [`TxbSet::ChromaRect8x4`] with [`SCAN_8X4`]/[`SCAN_4X8`]. Angle deltas ARE
7426+/// coded (`av1_use_angle_delta` compares the BLOCK_SIZES_ALL enum index, and
7427+/// BLOCK_16X4 is 17), and so is `use_filter_intra` (both sides <= 32) off this
7428+/// shape's own CDF row.
7429+///
7430+/// A split transform (`tx_depth != 0`, `sub_tx_size_map[TX_16X4] == TX_8X4`)
7431+/// refuses by name rather than guess-decode.
7432+#[allow(clippy::too_many_arguments)]
7433+fn decode_rect4_16(
7434+ dec: &mut SymbolDecoder,
7435+ cdfs: &mut Cdfs,
7436+ neighbours: &mut Neighbours,
7437+ at16: (usize, usize),
7438+ horz: bool,
7439+ y: &mut PlaneBuf,
7440+ u: &mut PlaneBuf,
7441+ v: &mut PlaneBuf,
7442+ enable_filter_intra: bool,
7443+ allow_screen_content_tools: bool,
7444+ base_q_idx: u8,
7445+ tx_select: bool,
7446+ reduced_tx_set: bool,
7447+) -> Result<()> {
7448+ let (r, c) = at16;
7449+ let (mi_row0, mi_col0) = (r * (SUB / MI), c * (SUB / MI));
7450+ let (bw, bh) = if horz { (16, 4) } else { (4, 16) };
7451+ let (mi_w, mi_h) = (bw / MI, bh / MI);
7452+ let scan: &[u16] = if horz { &SCAN_16X4 } else { &SCAN_4X16 };
7453+ let chroma_scan: &[u16] = if horz { &SCAN_8X4 } else { &SCAN_4X8 };
7454+ let mut prev: Option<((usize, usize), usize)> = None;
7455+ let mut last_mode = DC_PRED;
7456+ let mut last_uv_mode = DC_PRED;
7457+ for i in 0..4usize {
7458+ let lmi = if horz {
7459+ (mi_row0 + i, mi_col0)
7460+ } else {
7461+ (mi_row0, mi_col0 + i)
7462+ };
7463+ let has_chroma = i % 2 == 1;
7464+ // `decode_block_rect4`'s own neighbour rule: the coarse 16-px cell
7465+ // aliases all four strips onto one entry, so the mi-exact map wins and
7466+ // the previous strip stands in on the split axis.
7467+ let mut above_mode = neighbours.above_mode[c];
7468+ let mut left_mode = neighbours.left_mode[r];
7469+ if let Some(((pr, pc), pmode)) = prev {
7470+ if pc == lmi.1 && lmi.0 == pr + mi_h {
7471+ above_mode = pmode;
7472+ } else if pr == lmi.0 && lmi.1 == pc + mi_w {
7473+ left_mode = pmode;
7474+ }
7475+ }
7476+ let (above_mode, left_mode) =
7477+ neighbours.modes_above_left_mi(lmi.0, lmi.1, (above_mode, left_mode));
7478+ let (
7479+ skip,
7480+ mode,
7481+ angle_delta_y,
7482+ uv_mode,
7483+ angle_delta_uv,
7484+ alpha,
7485+ filter_intra,
7486+ palette_y,
7487+ palette_uv,
7488+ ) = read_intra_mode_rect(
7489+ dec,
7490+ cdfs,
7491+ above_mode,
7492+ left_mode,
7493+ true,
7494+ has_chroma,
7495+ bw,
7496+ bh,
7497+ enable_filter_intra,
7498+ neighbours.skip_txfm_ctx(lmi.0, lmi.1),
7499+ allow_screen_content_tools,
7500+ None,
7501+ &[],
7502+ lmi.0,
7503+ lmi.1,
7504+ )?;
7505+ if palette_y.is_some() || palette_uv.is_some() {
7506+ return Err(unsupported(
7507+ "a 1:4 rect strip that actually uses a palette (reconstruction is not ported at this shape)",
7508+ ));
7509+ }
7510+ let smooth_neighbor = is_smooth_mode(above_mode) || is_smooth_mode(left_mode);
7511+ if smooth_neighbor {
7512+ SMOOTH_LUMA_HITS.with(|h| h.set(h.get() + 1));
7513+ }
7514+ if filter_intra.is_some() {
7515+ FILTER_INTRA_RECT_HITS.with(|h| h.set(h.get() + 1));
7516+ }
7517+ // `bsize_to_tx_size_cat(BLOCK_16X4)`: `max_txsize_rect_lookup` is
7518+ // TX_16X4 and `sub_tx_size_map` reaches TX_4X4 in two steps, so the
7519+ // depth symbol is the 3-symbol `tx_size_cat1` -- not the 2-symbol
7520+ // `cat0` a 4x8 leaf reads nor the `cat2` a 32x8 strip does.
7521+ let depth = if tx_select {
7522+ let ctx = tx_size_context_rect(neighbours, lmi, bw, bh);
7523+ dec.symbol(&mut cdfs.tx_size_cat1[ctx])
7524+ } else {
7525+ 0
7526+ };
7527+ if depth != 0 {
7528+ TX_DEPTH_HITS.with(|h| h.set(h.get() + 1));
7529+ RECT4_16_SPLIT_HITS.with(|h| h.set(h.get() + 1));
7530+ }
7531+ let (tx_w, tx_h) = depth_to_tx_wh(bw, bh, depth);
7532+ let (px, py) = (lmi.1 * MI, lmi.0 * MI);
7533+ let reach = Reach::of_rect(bw, bh, px, py, y.width, y.height);
7534+ neighbours.record_mode_mi(lmi.0, lmi.1, mi_w, mi_h, mode);
7535+ if depth != 0 {
7536+ // [`decode_rect_split`]'s per-unit walk, inlined because the
7537+ // CHROMA of this shape belongs to the strip's 4:2:0 pair, not to
7538+ // the strip (that function codes one chroma transform per block).
7539+ // depth 1 is the 2:1 rect unit TX_8X4/TX_4X8
7540+ // (`sub_tx_size_map[TX_16X4]`), depth 2 the square TX_4X4; each
7541+ // unit predicts off the units before it in raster order.
7542+ let rect_unit = tx_w != tx_h;
7543+ let zero_tu = vec![0i32; tx_w * tx_h];
7544+ for tu_row in 0..bh / tx_h {
7545+ for tu_col in 0..bw / tx_w {
7546+ let tu_mi = (lmi.0 + tu_row * (tx_h / MI), lmi.1 + tu_col * (tx_w / MI));
7547+ let (tu_px, tu_py) = (px + tu_col * tx_w, py + tu_row * tx_h);
7548+ let tu_reach = Reach::of_tu(
7549+ bw,
7550+ bh,
7551+ tu_col * tx_w,
7552+ tu_row * tx_h,
7553+ tx_w,
7554+ tx_h,
7555+ reach,
7556+ );
7557+ if skip {
7558+ y.reconstruct_rect(
7559+ tu_px, tu_py, tx_w, tx_h, mode, angle_delta_y, tu_reach, &zero_tu,
7560+ None, filter_intra, smooth_neighbor,
7561+ );
7562+ neighbours.record_mi_luma_rect(tu_mi, tx_w, tx_h, &zero_tu);
7563+ } else if rect_unit {
7564+ // `get_txsize_entropy_ctx(TX_8X4)` is the 8x8 class with
7565+ // 32 coded positions and the `TX_4X4` `tx_type` row:
7566+ // exactly [`TxbSet::LumaRect4x8`].
7567+ let tu_around = neighbours.around_mi_rect(tu_mi, tx_w, tx_h)[0];
7568+ let tu_skip_ctx =
7569+ neighbours.luma_skip_ctx_rect(tu_mi, tx_w / MI, tx_h / MI);
7570+ let set = if reduced_tx_set {
7571+ TxbSet::LumaRect4x8
7572+ } else {
7573+ TxbSet::LumaRect4x8Set1
7574+ };
7575+ let tu_scan: &[u16] = if tx_w > tx_h { &SCAN_8X4 } else { &SCAN_4X8 };
7576+ let mut coding = cdfs.txb(set, fi_tx_row(mode, filter_intra));
7577+ let (tu_grid, tu_tx_type) = read_coeffs_rect(
7578+ dec,
7579+ &mut coding,
7580+ tu_scan,
7581+ tx_w,
7582+ tx_h,
7583+ tu_skip_ctx,
7584+ dc_sign_ctx(tu_around.2),
7585+ TxType::DctDct,
7586+ )?;
7587+ let residual = dequant_and_inverse_typed_wh(
7588+ &tu_grid,
7589+ tx_w,
7590+ tx_h,
7591+ crate::decode::bit_depth(),
7592+ block_q_idx(),
7593+ plane_q_delta(0).0,
7594+ plane_q_delta(0).1,
7595+ tu_tx_type,
7596+ );
7597+ y.reconstruct_rect(
7598+ tu_px, tu_py, tx_w, tx_h, mode, angle_delta_y, tu_reach, &residual,
7599+ None, filter_intra, smooth_neighbor,
7600+ );
7601+ if tu_grid.iter().any(|&l| l != 0) {
7602+ RECT4_16_COEFF_HITS.with(|h| h.set(h.get() + 1));
7603+ }
7604+ neighbours.record_mi_luma_rect(tu_mi, tx_w, tx_h, &tu_grid);
7605+ } else {
7606+ let tu_around = neighbours.around_mi(tu_mi, tx_w)[0];
7607+ let tu_skip_ctx = neighbours.luma_skip_ctx(tu_mi, tx_w / MI);
7608+ let tu_grid = read_plane(
7609+ dec,
7610+ cdfs,
7611+ txbset_for(tx_w, reduced_tx_set),
7612+ &default_scan(tx_w),
7613+ 0,
7614+ tu_around,
7615+ mode,
7616+ mode,
7617+ angle_delta_y,
7618+ tu_reach,
7619+ y,
7620+ tu_px,
7621+ tu_py,
7622+ tx_w,
7623+ tx_w,
7624+ base_q_idx,
7625+ None,
7626+ filter_intra,
7627+ Some(tu_skip_ctx),
7628+ smooth_neighbor,
7629+ )?;
7630+ if tu_grid.iter().any(|&l| l != 0) {
7631+ RECT4_16_COEFF_HITS.with(|h| h.set(h.get() + 1));
7632+ }
7633+ neighbours.record_mi_luma(tu_mi, tx_w, &tu_grid);
7634+ }
7635+ }
7636+ }
7637+ } else {
7638+ let levels = if skip {
7639+ let zeros = vec![0i32; bw * bh];
7640+ y.reconstruct_rect(
7641+ px, py, bw, bh, mode, angle_delta_y, reach, &zeros, None, filter_intra,
7642+ smooth_neighbor,
7643+ );
7644+ zeros
7645+ } else {
7646+ // The strip's luma TU *is* the strip (`plane_bsize ==
7647+ // txsize_to_bsize[tx_size]`), so `get_txb_ctx` fixes
7648+ // `txb_skip_ctx` at 0.
7649+ let around = neighbours.around_mi_rect(lmi, bw, bh)[0];
7650+ let set = if reduced_tx_set {
7651+ TxbSet::LumaRect16x4
7652+ } else {
7653+ TxbSet::LumaRect16x4Set1
7654+ };
7655+ let mut coding = cdfs.txb(set, fi_tx_row(mode, filter_intra));
7656+ let (levels, tx_type) = read_coeffs_rect(
7657+ dec,
7658+ &mut coding,
7659+ scan,
7660+ bw,
7661+ bh,
7662+ 0,
7663+ dc_sign_ctx(around.2),
7664+ TxType::DctDct,
7665+ )?;
7666+ let residual = dequant_and_inverse_typed_wh(
7667+ &levels,
7668+ bw,
7669+ bh,
7670+ crate::decode::bit_depth(),
7671+ block_q_idx(),
7672+ plane_q_delta(0).0,
7673+ plane_q_delta(0).1,
7674+ tx_type,
7675+ );
7676+ y.reconstruct_rect(
7677+ px, py, bw, bh, mode, angle_delta_y, reach, &residual, None, filter_intra,
7678+ smooth_neighbor,
7679+ );
7680+ RECT4_16_COEFF_HITS.with(|h| h.set(h.get() + 1));
7681+ levels
7682+ };
7683+ neighbours.record_mi_luma_rect(lmi, bw, bh, &levels);
7684+ }
7685+ neighbours.fill_skip_grid_rect(lmi, mi_w, mi_h, skip);
7686+ neighbours.fill_lf_grid_rect(lmi, mi_w, mi_h, tx_w as u8, tx_h as u8, 0);
7687+ // `update_partition_context` writes `partition_context_lookup[
7688+ // BLOCK_16X4]` over the whole 16x16: full width above, a 4-px side on
7689+ // the left (mirrored under VERT_4).
7690+ for cell in 0..mi_w {
7691+ if let Some(slot) = neighbours.above_side_mi.get_mut(lmi.1 + cell) {
7692+ *slot = bw;
7693+ }
7694+ }
7695+ for cell in 0..mi_h {
7696+ if let Some(slot) = neighbours.left_side_mi.get_mut(lmi.0 + cell) {
7697+ *slot = bh;
7698+ }
7699+ }
7700+ if has_chroma {
7701+ RECT4_16_CHROMA_HITS.with(|h| h.set(h.get() + 1));
7702+ let pair_mi = if horz {
7703+ (lmi.0 - 1, lmi.1)
7704+ } else {
7705+ (lmi.0, lmi.1 - 1)
7706+ };
7707+ let (pw, ph) = if horz { (16, 8) } else { (8, 16) };
7708+ let (ppx, ppy) = (pair_mi.1 * MI, pair_mi.0 * MI);
7709+ let (cpx, cpy) = (ppx / 2, ppy / 2);
7710+ let (cw, ch) = (pw / 2, ph / 2);
7711+ let uv_predict_mode = if uv_mode == UV_CFL_PRED { DC_PRED } else { uv_mode };
7712+ let pair_reach = Reach::of_rect(pw, ph, ppx, ppy, y.width, y.height);
7713+ let smooth_neighbor_uv = neighbours.smooth_uv_neighbour(lmi.0, lmi.1, r, c);
7714+ let (u_levels, v_levels) = if skip {
7715+ let zeros = vec![0i32; cw * ch];
7716+ for (buf, _plane) in [(&mut *u, 1usize), (&mut *v, 2)] {
7717+ buf.reconstruct_rect(
7718+ cpx,
7719+ cpy,
7720+ cw,
7721+ ch,
7722+ uv_predict_mode,
7723+ angle_delta_uv,
7724+ pair_reach,
7725+ &zeros,
7726+ None,
7727+ None,
7728+ smooth_neighbor_uv,
7729+ );
7730+ }
7731+ (zeros.clone(), zeros)
7732+ } else {
7733+ let around = neighbours.around_mi_rect(pair_mi, pw, ph);
7734+ let mut planes = Vec::with_capacity(2);
7735+ for plane in 1..3 {
7736+ let default_tx = default_intra_tx_type(uv_predict_mode as u8);
7737+ let skip_ctx = usize::from(around[plane].0) + usize::from(around[plane].1);
7738+ let mut coding = cdfs.txb(TxbSet::ChromaRect8x4, uv_predict_mode);
7739+ let (levels, tx_type) = read_coeffs_rect(
7740+ dec,
7741+ &mut coding,
7742+ chroma_scan,
7743+ cw,
7744+ ch,
7745+ skip_ctx,
7746+ dc_sign_ctx(around[plane].2),
7747+ default_tx,
7748+ )?;
7749+ planes.push((levels, tx_type));
7750+ }
7751+ let (v_levels, v_tx_type) = planes.pop().expect("plane 2");
7752+ let (u_levels, u_tx_type) = planes.pop().expect("plane 1");
7753+ // CfL averages the luma of the WHOLE pair, the region this one
7754+ // chroma transform covers.
7755+ let ac = alpha.map(|_| cfl_ac_q3_rect(y, ppx, ppy, pw, ph));
7756+ for (plane, buf, levels, tx_type) in [
7757+ (1usize, &mut *u, &u_levels, u_tx_type),
7758+ (2, &mut *v, &v_levels, v_tx_type),
7759+ ] {
7760+ let residual = dequant_and_inverse_typed_wh(
7761+ levels,
7762+ cw,
7763+ ch,
7764+ crate::decode::bit_depth(),
7765+ block_q_idx(),
7766+ plane_q_delta(plane).0,
7767+ plane_q_delta(plane).1,
7768+ tx_type,
7769+ );
7770+ buf.reconstruct_rect(
7771+ cpx,
7772+ cpy,
7773+ cw,
7774+ ch,
7775+ uv_predict_mode,
7776+ angle_delta_uv,
7777+ pair_reach,
7778+ &residual,
7779+ alpha
7780+ .zip(ac.as_deref())
7781+ .map(|((au, av), ac)| (if plane == 1 { au } else { av }, ac)),
7782+ None,
7783+ smooth_neighbor_uv,
7784+ );
7785+ }
7786+ (u_levels, v_levels)
7787+ };
7788+ neighbours.record_uv_mode_mi(pair_mi.0, pair_mi.1, pw / MI, ph / MI, uv_predict_mode);
7789+ // The chroma planes' coefficient context, over the PAIR's mi span
7790+ // (`decode_leaf_rect8`'s own rule: a subsampled plane's bound is
7791+ // the luma one rounded up to its 4x4 unit).
7792+ let u_state = neighbour_state(&u_levels);
7793+ let v_state = neighbour_state(&v_levels);
7794+ let round_up_even = |n: usize| n.div_ceil(2) * 2;
7795+ let bound_h = round_up_even(neighbours.mi_rows);
7796+ let bound_w = round_up_even(neighbours.mi_cols);
7797+ for cell in 0..(ph / MI) {
7798+ if pair_mi.0 + cell < bound_h
7799+ && let Some(slot) = neighbours.left.get_mut(pair_mi.0 + cell)
7800+ {
7801+ slot[1] = u_state;
7802+ slot[2] = v_state;
7803+ }
7804+ }
7805+ for cell in 0..(pw / MI) {
7806+ if pair_mi.1 + cell < bound_w
7807+ && let Some(slot) = neighbours.above.get_mut(pair_mi.1 + cell)
7808+ {
7809+ slot[1] = u_state;
7810+ slot[2] = v_state;
7811+ }
7812+ }
7813+ last_uv_mode = uv_predict_mode;
7814+ }
7815+ if horz {
7816+ RECT4_16_HORZ_HITS.with(|h| h.set(h.get() + 1));
7817+ } else {
7818+ RECT4_16_VERT_HITS.with(|h| h.set(h.get() + 1));
7819+ }
7820+ last_mode = mode;
7821+ prev = Some((lmi, mode));
7822+ }
7823+ // The coarse 16-px cell holds one entry for the whole 16x16: the last
7824+ // strip is what a block below (right) sees through it, the mi-exact maps
7825+ // above answering everything finer.
7826+ neighbours.above_mode[c] = last_mode;
7827+ neighbours.left_mode[r] = last_mode;
7828+ neighbours.above_uv_mode[c] = last_uv_mode;
7829+ neighbours.left_uv_mode[r] = last_uv_mode;
7830+ neighbours.above_side[c] = bw;
7831+ neighbours.left_side[r] = bh;
7832+ Ok(())
7833+}
7834+
7341 /// Decodes one true `bw`x`bh` superblock-level `PARTITION_HORZ`/7835 /// Decodes one true `bw`x`bh` superblock-level `PARTITION_HORZ`/
7342 /// `PARTITION_VERT` strip (lane-sbpart r2, `bw, bh` one of `(64, 32)` /7836 /// `PARTITION_VERT` strip (lane-sbpart r2, `bw, bh` one of `(64, 32)` /
7343 /// `(32, 64)` -- [`decode_block_rect`]'s own sibling one level up). Unlike7837 /// `(32, 64)` -- [`decode_block_rect`]'s own sibling one level up). Unlike
@@ -7391,6 +7885,7 @@ fn decode_block_rect64(
7391 // the real 13-symbol `uv_mode_no_cfl` one and desynced the tile7885 // the real 13-symbol `uv_mode_no_cfl` one and desynced the tile
7392 // from this block's very first symbol (lane-sbpart r3 bisect).7886 // from this block's very first symbol (lane-sbpart r3 bisect).
7393 false,7887 false,
7888+ true,
7394 bw,7889 bw,
7395 bh,7890 bh,
7396 enable_filter_intra,7891 enable_filter_intra,
@@ -11053,7 +11548,19 @@ fn read_block_tx_size(
11053 /// `DTT9_IDTX_1DDCT` row at `tx_size_sqr == TX_8X8`, only reachable through a11548 /// `DTT9_IDTX_1DDCT` row at `tx_size_sqr == TX_8X8`, only reachable through a
11054 /// rect transform), neither of which exists yet -- both stay refused by name.11549 /// rect transform), neither of which exists yet -- both stay refused by name.
11055 fn rect_inter_residual_supported(w: usize, h: usize) -> bool {11550 fn rect_inter_residual_supported(w: usize, h: usize) -> bool {
11056- matches!((w, h), (32, 16) | (16, 32) | (16, 8) | (8, 16))11551+ matches!(
11552+ (w, h),
11553+ // 2:1 strips whose transform is coded in full (lane-inter4).
11554+ (32, 16) | (16, 32) | (16, 8) | (8, 16)
11555+ // lane-r14 r2: strips with a 64-px axis. `av1_get_max_eob` codes
11556+ // only the low 32 coefficients of a 64-length axis, so these read
11557+ // exactly the truncated corner the INTRA superblock-strip path
11558+ // already reads (`read_intra_mode_rect`), through
11559+ // `av1_get_adjusted_tx_size`'s CDF set. Their `tx_size_sqr_up` is
11560+ // `TX_64X64`, so `av1_get_ext_tx_set_type` is `DCT_ONLY` and no
11561+ // `tx_type` symbol is coded at all.
11562+ | (64, 32) | (32, 64) | (64, 16) | (16, 64)
11563+ )
11057 }11564 }
11058 11565
11059 /// The luma coefficient/`tx_type` table set of a whole-block rectangular11566 /// The luma coefficient/`tx_type` table set of a whole-block rectangular
@@ -11074,6 +11581,13 @@ fn rect_inter_luma_set(w: usize, h: usize) -> TxbSet {
11074 TxbSet::LumaRect16x8InterSet111581 TxbSet::LumaRect16x8InterSet1
11075 }11582 }
11076 }11583 }
11584+ // lane-r14 r2: `av1_get_adjusted_tx_size` maps TX_64X32/TX_32X64 to
11585+ // TX_32X32 and TX_64X16/TX_16X64 to TX_32X16/TX_16X32, and
11586+ // `get_txsize_entropy_ctx`/`txsize_log2_minus4` agree with the
11587+ // adjusted size, so the existing sets are bit-exact. Neither carries a
11588+ // `tx_type` table (DCT_ONLY above), so the intra/inter split is moot.
11589+ (64, 32) | (32, 64) => TxbSet::Luma64,
11590+ (64, 16) | (16, 64) => TxbSet::LumaRect32x16,
11077 _ => unreachable!("rect_inter_residual_supported gates every shape that reaches here"),11591 _ => unreachable!("rect_inter_residual_supported gates every shape that reaches here"),
11078 }11592 }
11079 }11593 }
@@ -11086,6 +11600,13 @@ fn rect_inter_chroma_set(w: usize, h: usize) -> TxbSet {
11086 match (w, h) {11600 match (w, h) {
11087 (16, 8) | (8, 16) => TxbSet::ChromaRect16x8,11601 (16, 8) | (8, 16) => TxbSet::ChromaRect16x8,
11088 (8, 4) | (4, 8) => TxbSet::ChromaRect8x4,11602 (8, 4) | (4, 8) => TxbSet::ChromaRect8x4,
11603+ // lane-r14 r2: chroma of a 64-axis strip -- 32x16/16x32 under a
11604+ // 64x32/32x64 one, 32x8/8x32 under a 64x16/16x64 one. Neither chroma
11605+ // unit has a 64-px axis, so both are coded in full; `Chroma16` is the
11606+ // exact set for TX_32X8/TX_8X32 (`get_txsize_entropy_ctx` = TX_16X16,
11607+ // `txsize_log2_minus4` = 4), same as the intra strip path uses.
11608+ (32, 16) | (16, 32) => TxbSet::ChromaRect32x16,
11609+ (32, 8) | (8, 32) => TxbSet::Chroma16,
11089 _ => unreachable!("rect_inter_residual_supported gates every shape that reaches here"),11610 _ => unreachable!("rect_inter_residual_supported gates every shape that reaches here"),
11090 }11611 }
11091 }11612 }
@@ -11131,6 +11652,8 @@ fn rect_scan(w: usize, h: usize) -> &'static [u16] {
11131 (8, 16) => &SCAN_8X16,11652 (8, 16) => &SCAN_8X16,
11132 (8, 4) => &SCAN_8X4,11653 (8, 4) => &SCAN_8X4,
11133 (4, 8) => &SCAN_4X8,11654 (4, 8) => &SCAN_4X8,
11655+ (32, 8) => &SCAN_32X8,
11656+ (8, 32) => &SCAN_8X32,
11134 _ => unreachable!("rect_inter_residual_supported gates every shape that reaches here"),11657 _ => unreachable!("rect_inter_residual_supported gates every shape that reaches here"),
11135 }11658 }
11136 }11659 }
@@ -11197,6 +11720,16 @@ fn read_block_tx_size_rect(
11197 }11720 }
11198 TXFM_SPLIT_HITS.with(|c| c.set(c.get() + 1));11721 TXFM_SPLIT_HITS.with(|c| c.set(c.get() + 1));
11199 RECT_INTER_TXSPLIT_HITS.with(|c| c.set(c.get() + 1));11722 RECT_INTER_TXSPLIT_HITS.with(|c| c.set(c.get() + 1));
11723+ // lane-r14 r2: `sub_tx_size_map` is square for every shape this decoder
11724+ // splits (TX_32X16 -> TX_16X16, TX_64X32 -> TX_32X32) EXCEPT the 1:4
11725+ // strips with a 64-px axis, where it stays rectangular
11726+ // (TX_64X16 -> TX_32X16, TX_16X64 -> TX_16X32) and the square recursion
11727+ // below would code the wrong tree.
11728+ if tx_w.max(tx_h) == 64 && tx_w.min(tx_h) == 16 {
11729+ return Err(unsupported(
11730+ "a split transform on a 1:4 inter strip with a 64-px axis",
11731+ ));
11732+ }
11200 let sub = tx_w.min(tx_h);11733 let sub = tx_w.min(tx_h);
11201 let max_w_mi = (bw / MI).min(mi_cols.saturating_sub(at_mi.1));11734 let max_w_mi = (bw / MI).min(mi_cols.saturating_sub(at_mi.1));
11202 let max_h_mi = (bh / MI).min(mi_rows.saturating_sub(at_mi.0));11735 let max_h_mi = (bh / MI).min(mi_rows.saturating_sub(at_mi.0));
@@ -11260,16 +11793,50 @@ fn read_inter_plane_rect(
11260 Some(t) if w.max(h) < 32 => t,11793 Some(t) if w.max(h) < 32 => t,
11261 _ => TxType::DctDct,11794 _ => TxType::DctDct,
11262 };11795 };
11263- let (grid, tx_type) = read_coeffs_rect(11796+ // lane-r14 r2: a 64-length axis codes only its low 32 coefficients
11264- dec,11797+ // (`av1_get_max_eob`), so the coded unit is the `min(w,32) x min(h,32)`
11265- &mut coding,11798+ // corner, zero-extended into the true `w x h` grid before the inverse
11266- rect_scan(w, h),11799+ // transform -- exactly what the intra superblock-strip path does. A
11267- w,11800+ // corner that comes out square (32x32, under a 64x32/32x64 strip) reads
11268- h,11801+ // through the SQUARE coefficient reader with `rect_shape = Some((w, h))`,
11269- skip_ctx,11802+ // because `av1_nz_map_ctx_offset` is indexed by the real, un-adjusted
11270- dc_sign_ctx(around.2),11803+ // rectangular shape (lane-sbpart r8).
11271- default_tx_type,11804+ let (cw, ch) = (w.min(32), h.min(32));
11272- )?;11805+ if plane_idx == 0 && w.max(h) == 64 {
11806+ RECT64_INTER_TU_HITS.with(|c| c.set(c.get() + 1));
11807+ }
11808+ let (corner, tx_type) = if (cw, ch) == (32, 32) {
11809+ let scan32 = default_scan(TX32);
11810+ read_coeffs(
11811+ dec,
11812+ &mut coding,
11813+ &scan32,
11814+ skip_ctx,
11815+ dc_sign_ctx(around.2),
11816+ default_tx_type,
11817+ Some((w, h)),
11818+ )?
11819+ } else {
11820+ read_coeffs_rect(
11821+ dec,
11822+ &mut coding,
11823+ rect_scan(cw, ch),
11824+ cw,
11825+ ch,
11826+ skip_ctx,
11827+ dc_sign_ctx(around.2),
11828+ default_tx_type,
11829+ )?
11830+ };
11831+ let grid = if (cw, ch) == (w, h) {
11832+ corner
11833+ } else {
11834+ let mut full = vec![0i32; w * h];
11835+ for row in 0..ch {
11836+ full[row * w..][..cw].copy_from_slice(&corner[row * cw..][..cw]);
11837+ }
11838+ full
11839+ };
11273 let (dc_delta, ac_delta) = plane_q_delta(plane_idx);11840 let (dc_delta, ac_delta) = plane_q_delta(plane_idx);
11274 let residual = dequant_and_inverse_typed_wh(11841 let residual = dequant_and_inverse_typed_wh(
11275 &grid,11842 &grid,
@@ -12351,16 +12918,33 @@ fn read_sb128_root(
12351 }12918 }
12352 p12919 p
12353 } else {12920 } else {
12921+ // lane-sb128 r4: the gathered half-out-of-frame reads DECIDE the
12922+ // partition, they are not a forced split -- exactly the discarded-bit
12923+ // defect the 64 root carries a comment about at `partition_w64`'s
12924+ // gathered arm. Value 1 is SPLIT; 0 is HORZ (rows out of frame) or
12925+ // VERT (cols out of frame), which the refusal below then names
12926+ // instead of silently reconstructing a split.
12927+ PART128_GATHERED_SYMBOLS.with(|c| c.set(c.get() + 1));
12354 match (has_cols128, has_rows128) {12928 match (has_cols128, has_rows128) {
12355 (true, false) => {12929 (true, false) => {
12356- dec.symbol_fixed(&gather_of(&cdfs.partition_w128[ctx128], &VERT_ALIKE128));12930+ if dec.symbol_fixed(&gather_of(&cdfs.partition_w128[ctx128], &VERT_ALIKE128)) == 1 {
12931+ PARTITION_SPLIT
12932+ } else {
12933+ PARTITION_HORZ
12934+ }
12357 }12935 }
12358 (false, true) => {12936 (false, true) => {
12359- dec.symbol_fixed(&gather_of(&cdfs.partition_w128[ctx128], &HORZ_ALIKE128));12937+ if dec.symbol_fixed(&gather_of(&cdfs.partition_w128[ctx128], &HORZ_ALIKE128)) == 1 {
12938+ PARTITION_SPLIT
12939+ } else {
12940+ PARTITION_VERT
12941+ }
12942+ }
12943+ _ => {
12944+ PART128_GATHERED_SYMBOLS.with(|c| c.set(c.get() - 1));
12945+ PARTITION_SPLIT
12360 }12946 }
12361- _ => {}
12362 }12947 }
12363- PARTITION_SPLIT
12364 };12948 };
12365 // lane-sb128b r1: `PARTITION_NONE` -- one 128x128 block -- is decoded by12949 // lane-sb128b r1: `PARTITION_NONE` -- one 128x128 block -- is decoded by
12366 // the key-frame caller below. The six remaining arms (HORZ/VERT and the12950 // the key-frame caller below. The six remaining arms (HORZ/VERT and the
@@ -13072,11 +13656,34 @@ pub(crate) fn decode_key_frame_tile_with_cdfs(
13072 neighbours.left_mode[sr] = mode_right;13656 neighbours.left_mode[sr] = mode_right;
13073 continue;13657 continue;
13074 }13658 }
13075- if part16 != PARTITION_SPLIT {13659+ if part16 == PARTITION_HORZ_4
13076- return Err(unsupported(13660+ || part16 == PARTITION_VERT_4
13077- "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)",13661+ {
13078- ));13662+ decode_rect4_16(
13663+ &mut dec,
13664+ &mut cdfs,
13665+ &mut neighbours,
13666+ at16,
13667+ part16 == PARTITION_HORZ_4,
13668+ &mut y,
13669+ &mut u,
13670+ &mut v,
13671+ enable_filter_intra,
13672+ allow_screen_content_tools,
13673+ base_q_idx,
13674+ tx_select,
13675+ reduced_tx_set,
13676+ )?;
13677+ continue;
13079 }13678 }
13679+ // lane-r14 r2 (verifier note): every
13680+ // one of the 10 symbols this CDF can
13681+ // produce is handled above, so SPLIT
13682+ // is the only value that reaches
13683+ // here -- the refusal that used to
13684+ // stand here was unreachable and is
13685+ // gone from `refusal_inventory`.
13686+ debug_assert_eq!(part16, PARTITION_SPLIT);
13080 // A real (non-straddle) SPLIT of a13687 // A real (non-straddle) SPLIT of a
13081 // whole 16x16 into four 8x8 leaves --13688 // whole 16x16 into four 8x8 leaves --
13082 // the same recursion the straddle13689 // the same recursion the straddle
@@ -15895,6 +16502,22 @@ fn decode_inter_block(
15895 force_integer_mv,16502 force_integer_mv,
15896 (gm_table[(ref0 - LAST_FRAME) as usize], gm_table[(ref1 - LAST_FRAME) as usize]),16503 (gm_table[(ref0 - LAST_FRAME) as usize], gm_table[(ref1 - LAST_FRAME) as usize]),
15897 );16504 );
16505+ if std::env::var_os("EC_TRACE_MODE").is_some() {
16506+ eprintln!(
16507+ "EC_MODE_VAL mi_row={mi_row} mi_col={mi_col} mode={} ref0={ref0} ref1={ref1} mv0=({},{}) stack={} rng={}",
16508+ compound_mode + 17,
16509+ mv0.0,
16510+ mv0.1,
16511+ comp_stack.entries.len(),
16512+ dec.debug_state().0
16513+ );
16514+ for (i, e) in comp_stack.entries.iter().enumerate() {
16515+ eprintln!(
16516+ "EC_STACK mi_row={mi_row} mi_col={mi_col} i={i} this=({},{}) comp=({},{}) w={}",
16517+ e.mv0.0, e.mv0.1, e.mv1.0, e.mv1.1, e.weight
16518+ );
16519+ }
16520+ }
15898 let is_globalmv = compound_mode == 6; // GLOBAL_GLOBALMV16521 let is_globalmv = compound_mode == 6; // GLOBAL_GLOBALMV
15899 // spec `is_nontrans_global_motion`: ALL active refs' models must16522 // spec `is_nontrans_global_motion`: ALL active refs' models must
15900 // be non-TRANSLATION (IDENTITY counts) for the compound block's16523 // be non-TRANSLATION (IDENTITY counts) for the compound block's
@@ -21974,8 +22597,6 @@ mod tests {
21974 // string that blocks the shape otherwise. Either way the row is22597 // string that blocks the shape otherwise. Either way the row is
21975 // pinned HERE, so the round that lifts one of those refusals cannot22598 // pinned HERE, so the round that lifts one of those refusals cannot
21976 // land a wrong CDF row for the shape it unlocks.22599 // land a wrong CDF row for the shape it unlocks.
21977- const PART16: &str = "a HORZ_A/HORZ_B/VERT_A partition below 16x16 (this decoder codes \
21978- only the square arms, HORZ, VERT, VERT_B, and a clean split below 16x16)";
21979 let libaom: &[(usize, usize, u16, Option<&str>)] = &[22600 let libaom: &[(usize, usize, u16, Option<&str>)] = &[
21980 (4, 4, 4621, None),22601 (4, 4, 4621, None),
21981 (4, 8, 6743, None),22602 (4, 8, 6743, None),
@@ -21990,8 +22611,10 @@ mod tests {
21990 // The 1:4 strips: a 16x16-level PARTITION_HORZ_4/VERT_4 gives22611 // The 1:4 strips: a 16x16-level PARTITION_HORZ_4/VERT_4 gives
21991 // 4x16/16x4 (still refused by name before any leaf is coded),22612 // 4x16/16x4 (still refused by name before any leaf is coded),
21992 // a 32x32-level one 8x32/32x8.22613 // a 32x32-level one 8x32/32x8.
21993- (4, 16, 12770, Some(PART16)),22614+ // lane-r14: the 16-level pair is coded now (`decode_rect4_16`),
21994- (16, 4, 10368, Some(PART16)),22615+ // owning classes 13/12.
22616+ (4, 16, 12770, None),
22617+ (16, 4, 10368, None),
21995 // lane-fi32x8 r1: the 32-level pair is coded (four 32x8/8x3222618 // lane-fi32x8 r1: the 32-level pair is coded (four 32x8/8x32
21996 // strips per `PARTITION_HORZ_4`/`VERT_4`) and now owns classes22619 // strips per `PARTITION_HORZ_4`/`VERT_4`) and now owns classes
21997 // 10/11; only the 16-level pair is still refused before any leaf.22620 // 10/11; only the 16-level pair is still refused before any leaf.
@@ -22466,8 +23089,16 @@ mod tests {
22466 // non-skip, so the named refusal is the rectangular-inter-residual23089 // non-skip, so the named refusal is the rectangular-inter-residual
22467 // one. Either string proves what the pin was written for: a non-SPLIT23090 // one. Either string proves what the pin was written for: a non-SPLIT
22468 // superblock never silently decodes as SPLIT.23091 // superblock never silently decodes as SPLIT.
23092+ // lane-r14 r2: the rectangular-residual refusal is gone (a 64x32 strip
23093+ // now codes its truncated low-32 coefficient corner), so this
23094+ // hand-written fixture walks further still and stops on the limit of
23095+ // the FIXTURE rather than of the decoder: it names no reference
23096+ // pictures. All three strings prove the one thing this pin exists for
23097+ // -- a non-SPLIT superblock never silently decodes as SPLIT.
22469 assert!(23098 assert!(
22470- msg.contains("SPLIT") || msg.contains("rectangular residual coding"),23099+ msg.contains("SPLIT")
23100+ || msg.contains("rectangular residual coding")
23101+ || msg.contains("no picture at this frame's own ref_frame_idx slot"),
22471 "expected the named inter-SB-partition refusal, got: {msg}"23102 "expected the named inter-SB-partition refusal, got: {msg}"
22472 );23103 );
22473 }23104 }
crates/ec-av1/src/mvstack.rsmodified+41 -0
@@ -1660,6 +1660,47 @@ pub fn find_mv_stack_compound(
1660 }1660 }
1661 blk_row += step_h;1661 blk_row += step_h;
1662 }1662 }
1663+ // lane-sb128 r3: libaom's three `tpl_sample_pos` EXTENSION samples
1664+ // (mvref_common.c:591), which the single-ref twin already ports and
1665+ // this compound path dropped. `check_sb_border`'s mask is libaom's
1666+ // hardcoded `mi_size_wide[BLOCK_64X64]` (16), NOT the sequence's
1667+ // superblock size. Missing them cost one weight-2 vote on a
1668+ // candidate, which reordered the stack and gave a NEW_NEWMV block a
1669+ // different predictor -- 957 wrong pixels on one 32x32 block of one
1670+ // frame with the entropy stream in sync.
1671+ let allow_extension = (2..16).contains(&bh4) && (2..16).contains(&bw4);
1672+ if allow_extension {
1673+ let (voffset, hoffset) = (bh4.max(2) as isize, bw4.max(2) as isize);
1674+ let sb_mask = 16isize;
1675+ for (row_off, col_off) in [
1676+ (voffset, -2isize),
1677+ (voffset, hoffset),
1678+ (voffset - 2, hoffset),
1679+ ] {
1680+ let row = (mi_row as isize & (sb_mask - 1)) + row_off;
1681+ let col = (mi_col as isize & (sb_mask - 1)) + col_off;
1682+ if row < 0 || row >= sb_mask || col < 0 || col >= sb_mask {
1683+ continue;
1684+ }
1685+ let cand0 = crate::motion_field::add_tpl_ref_mv(
1686+ field, mi_row, mi_col, row_off, col_off, cur_offset_0,
1687+ allow_high_precision_mv,
1688+ );
1689+ let cand1 = crate::motion_field::add_tpl_ref_mv(
1690+ field, mi_row, mi_col, row_off, col_off, cur_offset_1,
1691+ allow_high_precision_mv,
1692+ );
1693+ if cand0.is_some() || cand1.is_some() {
1694+ any_hit = true;
1695+ add_compound_candidate(
1696+ &mut candidates,
1697+ cand0.map_or((0, 0), |c| c.mv),
1698+ cand1.map_or((0, 0), |c| c.mv),
1699+ 2,
1700+ );
1701+ }
1702+ }
1703+ }
1663 if any_hit {1704 if any_hit {
1664 TMV_HITS.fetch_add(1, std::sync::atomic::Ordering::Relaxed);1705 TMV_HITS.fetch_add(1, std::sync::atomic::Ordering::Relaxed);
1665 }1706 }
crates/ec-av1/src/refusal_inventory.rsmodified+4 -2
@@ -34,7 +34,6 @@ const REFUSALS: &[&str] = &[
34 "a coded HORZ/VERT strip whose chroma transform has no rect coefficient tables here",34 "a coded HORZ/VERT strip whose chroma transform has no rect coefficient tables here",
35 "a split intra strip whose transform unit is {tx_w}x{tx_h} (no luma coefficient tables for that shape here)",35 "a split intra strip whose transform unit is {tx_w}x{tx_h} (no luma coefficient tables for that shape here)",
36 "an inter partition below 8x8 (this decoder codes no inter leaf smaller than 8x8; lane-sub8 scoped to intra)",36 "an inter partition below 8x8 (this decoder codes no inter leaf smaller than 8x8; lane-sub8 scoped to intra)",
37- "a 1:4 partition below 16x16 (PARTITION_HORZ_4/VERT_4, four 16x4/4x16 strips -- this decoder codes NONE, HORZ, VERT, the four AB arms and a clean split at 16x16)",
38 "a 1:4 rect strip that actually uses a palette (reconstruction is not ported at this shape)",37 "a 1:4 rect strip that actually uses a palette (reconstruction is not ported at this shape)",
39 "a 16x16 block whose true edge cuts through both axes needs a rectangular transform this decoder does not code yet",38 "a 16x16 block whose true edge cuts through both axes needs a rectangular transform this decoder does not code yet",
40 "a 16x16 inter block whose true edge cuts through both axes needs a rectangular transform this decoder does not code yet",39 "a 16x16 inter block whose true edge cuts through both axes needs a rectangular transform this decoder does not code yet",
@@ -46,7 +45,6 @@ const REFUSALS: &[&str] = &[
46 "a 128x128 superblock HORZ/VERT or AB partition (only SPLIT and NONE are decoded at the 128 root)",45 "a 128x128 superblock HORZ/VERT or AB partition (only SPLIT and NONE are decoded at the 128 root)",
47 "a 128x128 superblock PARTITION_NONE root on an inter frame (only the key-frame path codes a whole 128x128 block)",46 "a 128x128 superblock PARTITION_NONE root on an inter frame (only the key-frame path codes a whole 128x128 block)",
48 "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)",47 "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)",
49- "an inter frame under a 128x128 superblock (this decoder's inter tile path recurses a 64x64 superblock root only)",
50 "a palette block on a HORZ/VERT intra strip below 16x16 (reconstruction not ported)",48 "a palette block on a HORZ/VERT intra strip below 16x16 (reconstruction not ported)",
51 "a palette block with a real transform on a superblock-level HORZ/VERT strip (corner-cropped luma coefficients not ported for palette)",49 "a palette block with a real transform on a superblock-level HORZ/VERT strip (corner-cropped luma coefficients not ported for palette)",
52 "a block that actually uses a palette (UV) -- reconstruction is out of scope",50 "a block that actually uses a palette (UV) -- reconstruction is out of scope",
@@ -84,6 +82,10 @@ const REFUSALS: &[&str] = &[
84 "warp prediction with a scaled reference (superres, unimplemented)",82 "warp prediction with a scaled reference (superres, unimplemented)",
85 "an 8x8 partition leaf under a scaled reference (superres, unimplemented)",83 "an 8x8 partition leaf under a scaled reference (superres, unimplemented)",
86 "a motion_mode symbol for a block shape with no CDF row here",84 "a motion_mode symbol for a block shape with no CDF row here",
85+ // lane-r14 r2: the whole-transform case of every 64-axis inter strip is
86+ // coded; only the SPLIT of a 1:4 strip with a 64-px axis is left, whose
87+ // `sub_tx_size_map` entry is rectangular (TX_64X16 -> TX_32X16).
88+ "a split transform on a 1:4 inter strip with a 64-px axis",
87 ];89 ];
88 90
89 /// Gates whose `Err` arm turns a decode failure into a printed SKIP rather than91 /// Gates whose `Err` arm turns a decode failure into a printed SKIP rather than
crates/ec-av1/src/stream.rsmodified+307 -66
@@ -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(),
@@ -516,19 +522,6 @@ pub fn decode_stream(data: &[u8]) -> Result<Vec<Picture>> {
516 .is_some_and(|seq| seq.use_128x128_superblock);522 .is_some_and(|seq| seq.use_128x128_superblock);
517 let sb128_active = use_sb128 && (header.mi_cols > 16 || header.mi_rows > 16);523 let sb128_active = use_sb128 && (header.mi_cols > 16 || header.mi_rows > 16);
518 crate::decode::set_sb128(sb128_active);524 crate::decode::set_sb128(sb128_active);
519- // lane-sb128 r2 RESIDUAL: the inter tile loop now reads the 128 root
520- // and walks libaom's quadrant order, and 8 of the 9 decode-order
521- // frames of the r2 gate stream are pixel-exact -- but frame 6 still
522- // differs (996 luma bytes, entropy in sync), and the SAME content at
523- // `--sb-size=64` is exact (`sb128_r2_control_sb64`), so the residual is
524- // sb128-specific. The refusal stays until that frame is exact: silent
525- // wrong pixels on his films are worse than a named stop.
526- if sb128_active && header.frame_type != FrameType::Key {
527- return Err(Error::unsupported(
528- "AV1 decode_stream",
529- "an inter frame under a 128x128 superblock (this decoder's inter tile path recurses a 64x64 superblock root only)",
530- ));
531- }
532 // 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`,
533 // which every dequant/inverse-transform clamp reads -- set per frame,526 // which every dequant/inverse-transform clamp reads -- set per frame,
534 // not once per process, for the same cross-sequence-on-one-thread527 // not once per process, for the same cross-sequence-on-one-thread
@@ -550,27 +543,6 @@ pub fn decode_stream(data: &[u8]) -> Result<Vec<Picture>> {
550 "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)",
551 ));544 ));
552 }545 }
553- // lane-oddh r2: `use_128x128_superblock` reaches every level of the
554- // decode -- the partition tree starts at BLOCK_128X128, `SB_MI` is 32
555- // mi units, and the CDEF/LR/deblock grids are per-128 -- and this
556- // decoder is written for 64x64 superblocks throughout (`SB_MI = 16`,
557- // no BLOCK_128X128 partition read at all). Until r1 that was SILENT:
558- // a 64x72 aomenc key frame at `--cpu-used=0` (libaom picks 128x128
559- // whenever speed is 0, `av1_select_sb_size`) desynced at the very
560- // first symbol -- aomdec reads a gathered 2-symbol
561- // BLOCK_128X128 partition (has_cols false at mi_cols=16,
562- // has_rows true at mi_rows=18) where we read a 10-symbol
563- // BLOCK_64X64 one from the same byte, giving PARTITION_VERT_4 (9)
564- // against SPLIT (3). Refuse by name rather than decode wrong pixels.
565- //
566- // Scoped, not blanket (measured: a blanket refusal red-lined 29
567- // previously pixel-exact gates): on a frame of at most 64x64 a
568- // 128x128 superblock decodes IDENTICALLY to a 64x64 one -- mi (0,0)
569- // has neither `has_rows` nor `has_cols`, so BLOCK_128X128 is a forced
570- // SPLIT that reads no symbol, and only one of its four 64x64 children
571- // is inside the frame. Every sibling inter gate at 64x64 and
572- // `--cpu-used=0` is exactly that case. The divergence starts the
573- // moment a superblock has a second child in frame.
574 crate::decode::set_bit_depth(bit_depth);546 crate::decode::set_bit_depth(bit_depth);
575 // lane-av1comp: `comp_group_idx`/`compound_idx`'s own gating bits.547 // lane-av1comp: `comp_group_idx`/`compound_idx`'s own gating bits.
576 let enable_masked_compound = parser548 let enable_masked_compound = parser
@@ -1112,20 +1084,16 @@ mod tests {
1112 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");
1113 }1085 }
1114 1086
1115- /// lane-oddh r2 GATE: a REAL aomenc stream that uses 128x128 superblocks1087+ /// lane-sb128 r4 GATE (was lane-oddh r2's refusal gate): the SAME real
1116- /// is refused by name, not silently mis-decoded. This is the root cause of1088+ /// aomenc 64x72 `--cpu-used=0 --sb-size=128` stream that once desynced at
1117- /// 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
1118- /// returns BLOCK_128X128 whenever speed is 0, so a tiny frame encoded at1090+ /// = 18 > 16, so the BLOCK_128X128 root reads a real gathered partition
1119- /// `--cpu-used=0` carries 128x128 superblocks, and this 64x64-only1091+ /// symbol (2 symbols: has_cols false, has_rows true) -- exactly the case
1120- /// decoder read a 10-symbol BLOCK_64X64 partition (value 9, VERT_4) where1092+ /// r1 mis-read as a 10-symbol BLOCK_64X64 partition.
1121- /// aomdec read a gathered 2-symbol BLOCK_128X128 one (value 3, SPLIT) from
1122- /// the same byte -- the uncompressed header parse was byte-identical
1123- /// (49 bits, tile data at file offset 20; hand-verified against spec
1124- /// 5.9.2 field by field).
1125 ///1093 ///
1126 /// The `use_128x128_superblock` assert is the "knob reached the tool"1094 /// The `use_128x128_superblock` assert is the "knob reached the tool"
1127- /// half: without it, an aomenc that ignored `--sb-size=128` would leave1095+ /// half: without it an aomenc that ignored `--sb-size=128` would leave
1128- /// the gate asserting a refusal that never fires.1096+ /// the gate proving nothing about 128 superblocks.
1129 #[test]1097 #[test]
1130 fn a_real_aomenc_128x128_superblock_stream_decodes_pixel_exact() {1098 fn a_real_aomenc_128x128_superblock_stream_decodes_pixel_exact() {
1131 if !have_ffmpeg() || !have_aomenc() {1099 if !have_ffmpeg() || !have_aomenc() {
@@ -1148,11 +1116,8 @@ mod tests {
1148 let mut child = Command::new(aomenc_path())1116 let mut child = Command::new(aomenc_path())
1149 .args([1117 .args([
1150 "--codec=av1", "--passes=1", "--end-usage=q", "--cq-level=32",1118 "--codec=av1", "--passes=1", "--end-usage=q", "--cq-level=32",
1151- "--cpu-used=0", "--sb-size=128", "--kf-max-dist=0", "--limit=1",1119+ "--cpu-used=0", "--sb-size=128", "--min-partition-size=16",
1152- // Unrelated to the 128 root: a 64x72 frame at cpu-used=0 also1120+ "--kf-max-dist=0", "--limit=1",
1153- // picks PARTITION_HORZ_4 below 16x16, which this decoder
1154- // refuses by name (lane-sb128b r2).
1155- "--enable-1to4-partitions=0", "--min-partition-size=16",
1156 "--threads=1", "--row-mt=0", "--obu", "-o", "-", "-",1121 "--threads=1", "--row-mt=0", "--obu", "-o", "-", "-",
1157 ])1122 ])
1158 .stdin(Stdio::piped())1123 .stdin(Stdio::piped())
@@ -1182,19 +1147,27 @@ mod tests {
1182 }1147 }
1183 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");
1184 1149
1185- // lane-sb128b: the blanket refusal this gate was written against is1150+ let _guard = lock_gate_counters();
1186- // gone -- the 128 root now decodes (SPLIT and NONE). The gate keeps1151+ let before = crate::decode::part128_symbols()
1187- // its stream and its `--sb-size=128` knob assert and asserts pixels.1152+ + crate::decode::part128_gathered_symbols();
1188- let decoded = decode_stream(&stream).expect("decode the 64x72 sb128 stream");1153+ let (frames, hidden) =
1189- let reference = ffmpeg_decode_sequence(&stream, width, height, decoded.len());1154+ decode_all_frames_vs_oracle(&stream, "sb128-oddh-64x72");
1190- for (i, (ours, theirs)) in decoded.iter().zip(&reference).enumerate() {1155+ assert!(frames > 0, "no frames decoded for {width}x{height}");
1191- let nd = |a: &[u16], b: &[u16]| a.iter().zip(b).filter(|(x, y)| x != y).count();1156+ // The 128 root actually READ a partition symbol here: at mi_rows=18
1192- assert_eq!(1157+ // `has_rows` is true, so BLOCK_128X128 is not a forced split.
1193- (nd(&ours.y, &theirs.y), nd(&ours.u, &theirs.u), nd(&ours.v, &theirs.v)),1158+ let part128 = crate::decode::part128_symbols()
1194- (0, 0, 0),1159+ + crate::decode::part128_gathered_symbols()
1195- "{width}x{height} sb128 cpu-used=0: frame {i} differs from ffmpeg"1160+ - before;
1196- );1161+ assert!(
1197- }1162+ part128 > 0,
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+ );
1198 }1171 }
1199 1172
1200 /// `decode_stream` on a lone key frame's stream matches both the tile1173 /// `decode_stream` on a lone key frame's stream matches both the tile
@@ -6586,10 +6559,21 @@ mod tests {
6586 // 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)
6587 // strip needs rectangular residual coding". The 10-bit twin below is6560 // strip needs rectangular residual coding". The 10-bit twin below is
6588 // `#[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.
6589 for bit_depth in [8u32] {6572 for bit_depth in [8u32] {
6590 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) =
6591 (0u32, 0u32, 0u32, 0u32);6574 (0u32, 0u32, 0u32, 0u32);
6592 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;
6593 for attempt in 0..16u32 {6577 for attempt in 0..16u32 {
6594 // Two orientations (the transposed pair a one-sided gate could6578 // Two orientations (the transposed pair a one-sided gate could
6595 // never separate) x four quantisers x two motion steps: which6579 // never separate) x four quantisers x two motion steps: which
@@ -6662,6 +6646,7 @@ mod tests {
6662 );6646 );
6663 let stream = out.stdout;6647 let stream = out.stdout;
6664 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();
6665 let frames = match decode_stream(&stream) {6650 let frames = match decode_stream(&stream) {
6666 Err(e) => {6651 Err(e) => {
6667 let msg = e.to_string();6652 let msg = e.to_string();
@@ -6678,6 +6663,7 @@ mod tests {
6678 };6663 };
6679 let after = crate::stream::inter_rect_counters();6664 let after = crate::stream::inter_rect_counters();
6680 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;
6681 let ffmpeg_frames = if bit_depth == 10 {6667 let ffmpeg_frames = if bit_depth == 10 {
6682 ffmpeg_decode_sequence_10bit(&stream, width, height, frame_count)6668 ffmpeg_decode_sequence_10bit(&stream, width, height, frame_count)
6683 } else {6669 } else {
@@ -6706,11 +6692,13 @@ mod tests {
6706 }6692 }
6707 horz_proved += horz;6693 horz_proved += horz;
6708 vert_proved += vert;6694 vert_proved += vert;
6695+ rect64_tus += rect64;
6709 matched += 1;6696 matched += 1;
6710 }6697 }
6711 eprintln!(6698 eprintln!(
6712 "{NAME} ({bit_depth}-bit): {named_refusals} named refusals, {matched} pixel-exact \6699 "{NAME} ({bit_depth}-bit): {named_refusals} named refusals, {matched} pixel-exact \
6713 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}, \
6714 {out_of_scope} attempts carried none ({oos_mismatch} of them mismatched)"6702 {out_of_scope} attempts carried none ({oos_mismatch} of them mismatched)"
6715 );6703 );
6716 assert_eq!(6704 assert_eq!(
@@ -6718,6 +6706,15 @@ mod tests {
6718 "{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 \
6719 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"
6720 );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+ );
6721 assert!(6718 assert!(
6722 horz_proved + vert_proved > 0,6719 horz_proved + vert_proved > 0,
6723 "{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 \
@@ -18216,8 +18213,6 @@ mod tests {
18216 /// superblock), and temporal MV candidates (the inter-only path). Both bit18213 /// superblock), and temporal MV candidates (the inter-only path). Both bit
18217 /// depths -- his films are `yuv420p10le`. Only a missing tool SKIPs.18214 /// depths -- his films are `yuv420p10le`. Only a missing tool SKIPs.
18218 #[test]18215 #[test]
18219- #[ignore = "lane-sb128 r2: reproducer for the residual frame-6 mismatch; the \
18220- product path still refuses inter frames at sb128 (see decode_stream)"]
18221 fn a_real_aomenc_inter_sequence_with_128x128_superblocks_decodes_pixel_exact() {18216 fn a_real_aomenc_inter_sequence_with_128x128_superblocks_decodes_pixel_exact() {
18222 const NAME: &str =18217 const NAME: &str =
18223 "a_real_aomenc_inter_sequence_with_128x128_superblocks_decodes_pixel_exact";18218 "a_real_aomenc_inter_sequence_with_128x128_superblocks_decodes_pixel_exact";
@@ -20622,6 +20617,252 @@ mod tests {
20622 /// then compared pixel-exact are counted (class20617 /// then compared pixel-exact are counted (class
20623 /// gate-skips-on-its-own-failure); the 10-bit arm is what retires20618 /// gate-skips-on-its-own-failure); the 10-bit arm is what retires
20624 /// `enable-1to4-partitions` from `NEVER_EXERCISED_10BIT`.20619 /// `enable-1to4-partitions` from `NEVER_EXERCISED_10BIT`.
20620+ /// lane-r14: the 16x16-level 1:4 pair -- four 16x4 (`PARTITION_HORZ_4`) or
20621+ /// 4x16 (`PARTITION_VERT_4`) strips, the shape the wall
20622+ /// "a 1:4 partition below 16x16" refused. Fixture: 4-PIXEL bands (the
20623+ /// 8-pixel ones of the 32-level gate above, one size down -- a 16x4 strip
20624+ /// is flat where a 16x8 one is not), transposed per attempt so a
20625+ /// transposed scan or nz-map table cannot pass (class
20626+ /// scan-weights-cross-axis), plus an explicit-seed noise layer that keeps
20627+ /// aomenc out of screen-content mode. `--enable-filter-intra=1` and
20628+ /// is ON: this shape reads `use_filter_intra` off its own CDF rows
20629+ /// (classes 12/13). The `--enable-tx-size-search=1` half of the window
20630+ /// splits the strip's transform (depth 1 = TX_8X4/TX_4X8, depth 2 =
20631+ /// TX_4X4).
20632+ ///
20633+ /// Counters: 16x4 strips, 4x16 strips, chroma-reference strips (the odd
20634+ /// strip of each 4:2:0 pair, the only one that codes chroma) and strips
20635+ /// with a coded residual must all be nonzero over the compared attempts,
20636+ /// and only attempts that DECODED and were compared pixel-exact count
20637+ /// (class gate-skips-on-its-own-failure).
20638+ #[test]
20639+ fn a_real_aomenc_stream_with_a_16_level_1to4_partition_decodes_pixel_exact() {
20640+ const NAME: &str =
20641+ "a_real_aomenc_stream_with_a_16_level_1to4_partition_decodes_pixel_exact";
20642+ let _gate_lock = lock_gate_counters();
20643+ if !have_ffmpeg() {
20644+ eprintln!("SKIP {NAME}: no ffmpeg");
20645+ return;
20646+ }
20647+ if !have_aomenc() {
20648+ eprintln!("SKIP {NAME}: no aomenc at {}", aomenc_path().display());
20649+ return;
20650+ }
20651+ let (width, height, frame_count) = (192usize, 128usize, 1usize);
20652+ let n_attempts: u32 = std::env::var("EC_R14_GATE_ATTEMPTS")
20653+ .ok()
20654+ .and_then(|s| s.parse().ok())
20655+ .unwrap_or(8);
20656+ for bit_depth in [8u32, 10u32] {
20657+ let mut named_refusals = 0u32;
20658+ let mut matched = 0u32;
20659+ let (mut horz_proved, mut vert_proved) = (0usize, 0usize);
20660+ let (mut chroma_proved, mut coeff_proved) = (0usize, 0usize);
20661+ let mut split_proved = 0usize;
20662+ let (mut out_of_scope, mut out_of_scope_mismatch) = (0u32, 0u32);
20663+ // The second half of the window turns `--enable-tx-size-search` on:
20664+ // that is what makes a 16x4 strip SPLIT its transform (depth 1 =
20665+ // TX_8X4, depth 2 = TX_4X4), the arm the first half never reaches.
20666+ for attempt in 0..n_attempts * 2 {
20667+ let tx_search = attempt >= n_attempts;
20668+ let attempt = attempt % n_attempts;
20669+ let seed = 42 + attempt;
20670+ let duration = frame_count as f64 / 25.0;
20671+ let axis = if attempt % 2 == 0 { "Y" } else { "X" };
20672+ let step = 67 + (attempt / 2) * 12;
20673+ let noise = 6 + (attempt % 4) * 3;
20674+ let source = format!(
20675+ "color=c=gray:s={width}x{height}:d={duration}:r=25,format=gray,\
20676+ geq=lum='mod(floor({axis}/4)*{step},256)',\
20677+ noise=alls={noise}:all_seed={seed},format=yuv420p"
20678+ );
20679+ let cq_level = format!("--cq-level={}", 24 + (attempt % 4) * 8);
20680+ let pix_fmt = if bit_depth == 10 { "yuv420p10le" } else { "yuv420p" };
20681+ let y4m = Command::new("ffmpeg")
20682+ .args([
20683+ "-v", "error", "-f", "lavfi", "-i", &source, "-t", &duration.to_string(),
20684+ "-pix_fmt", pix_fmt, "-strict", "-1", "-f", "yuv4mpegpipe", "-",
20685+ ])
20686+ .stdin(Stdio::null())
20687+ .stdout(Stdio::piped())
20688+ .stderr(Stdio::piped())
20689+ .output()
20690+ .expect("ffmpeg failed to run");
20691+ assert!(
20692+ y4m.status.success(),
20693+ "{NAME}: ffmpeg refused the {bit_depth}-bit fixture: {}",
20694+ String::from_utf8_lossy(&y4m.stderr)
20695+ );
20696+ let depth_arg = format!("--bit-depth={bit_depth}");
20697+ let input_depth_arg = format!("--input-bit-depth={bit_depth}");
20698+ let args: Vec<&str> = vec![
20699+ "--codec=av1",
20700+ "--passes=1",
20701+ "--end-usage=q",
20702+ &cq_level,
20703+ "--cpu-used=0",
20704+ "--threads=1",
20705+ "--row-mt=0",
20706+ "--sb-size=64",
20707+ &depth_arg,
20708+ &input_depth_arg,
20709+ "--enable-rect-partitions=1",
20710+ "--enable-ab-partitions=0",
20711+ "--enable-1to4-partitions=1",
20712+ "--min-partition-size=4",
20713+ "--max-partition-size=16",
20714+ "--enable-restoration=0",
20715+ "--enable-palette=0",
20716+ "--deltaq-mode=0",
20717+ "--enable-filter-intra=1",
20718+ // lane-r14: CfL stays OFF here. This shape's CfL averages
20719+ // the luma of the whole PAIR and is written, but no gate
20720+ // asserts a CfL hit counter (there is none), and passing
20721+ // `=1` would retire `enable-cfl-intra` from
20722+ // `gate_coverage::NEVER_EXERCISED_*` on a flag alone --
20723+ // exactly the false coverage that list exists to prevent.
20724+ "--enable-cfl-intra=0",
20725+ "--enable-intrabc=0",
20726+ if tx_search {
20727+ "--enable-tx-size-search=1"
20728+ } else {
20729+ "--enable-tx-size-search=0"
20730+ },
20731+ "--obu",
20732+ "-o",
20733+ "-",
20734+ "-",
20735+ ];
20736+ let mut child = Command::new(aomenc_path())
20737+ .args(&args)
20738+ .stdin(Stdio::piped())
20739+ .stdout(Stdio::piped())
20740+ .stderr(Stdio::piped())
20741+ .spawn()
20742+ .expect("aomenc failed to start");
20743+ child
20744+ .stdin
20745+ .take()
20746+ .expect("aomenc stdin")
20747+ .write_all(&y4m.stdout)
20748+ .expect("writing y4m to aomenc");
20749+ let out = child.wait_with_output().expect("aomenc failed to run");
20750+ assert!(
20751+ out.status.success(),
20752+ "aomenc refused the fixture: {}",
20753+ String::from_utf8_lossy(&out.stderr)
20754+ );
20755+ let stream = out.stdout;
20756+ let before = crate::decode::rect4_16_counters();
20757+ let frames = match decode_stream(&stream) {
20758+ Err(e) => {
20759+ let msg = e.to_string();
20760+ assert!(
20761+ msg.contains("unsupported"),
20762+ "{NAME} failed outright, not a named refusal ({bit_depth}-bit, seed \
20763+ {seed}): {msg}"
20764+ );
20765+ named_refusals += 1;
20766+ eprintln!("{bit_depth}-bit seed {seed} refusal: {msg}");
20767+ continue;
20768+ }
20769+ Ok(frames) => frames,
20770+ };
20771+ let now = crate::decode::rect4_16_counters();
20772+ let (horz, vert, chroma, coeff, split) = (
20773+ now.0 - before.0,
20774+ now.1 - before.1,
20775+ now.2 - before.2,
20776+ now.3 - before.3,
20777+ now.4 - before.4,
20778+ );
20779+ let ffmpeg_frames = if bit_depth == 10 {
20780+ ffmpeg_decode_sequence_10bit(&stream, width, height, frame_count)
20781+ } else {
20782+ ffmpeg_decode_sequence(&stream, width, height, frame_count)
20783+ };
20784+ assert_eq!(frames.len(), frame_count);
20785+ let mismatched = frames
20786+ .iter()
20787+ .zip(&ffmpeg_frames)
20788+ .any(|(got, want)| got.y != want.y || got.u != want.u || got.v != want.v);
20789+ if horz + vert == 0 {
20790+ out_of_scope += 1;
20791+ if mismatched {
20792+ out_of_scope_mismatch += 1;
20793+ eprintln!(
20794+ "{NAME}: {bit_depth}-bit seed {seed} MISMATCHES with zero 16-level \
20795+ 1:4 strips -- a pre-existing defect of another shape"
20796+ );
20797+ }
20798+ continue;
20799+ }
20800+ if mismatched && let Ok(path) = std::env::var("EC_AV1_GATE_DUMP") {
20801+ std::fs::write(&path, &stream).expect("writing pinned stream");
20802+ eprintln!(
20803+ "EC_AV1_GATE_DUMP: wrote mismatching stream ({bit_depth}-bit, seed \
20804+ {seed}) to {path}"
20805+ );
20806+ }
20807+ for (i, (got, want)) in frames.iter().zip(&ffmpeg_frames).enumerate() {
20808+ assert_eq!(
20809+ got.y, want.y,
20810+ "{NAME} frame {i} luma vs ffmpeg ({bit_depth}-bit, seed {seed})"
20811+ );
20812+ assert_eq!(
20813+ got.u, want.u,
20814+ "{NAME} frame {i} U vs ffmpeg ({bit_depth}-bit, seed {seed})"
20815+ );
20816+ assert_eq!(
20817+ got.v, want.v,
20818+ "{NAME} frame {i} V vs ffmpeg ({bit_depth}-bit, seed {seed})"
20819+ );
20820+ }
20821+ horz_proved += horz;
20822+ vert_proved += vert;
20823+ chroma_proved += chroma;
20824+ coeff_proved += coeff;
20825+ split_proved += split;
20826+ matched += 1;
20827+ }
20828+ assert!(
20829+ matched > 0,
20830+ "{NAME}: every {bit_depth}-bit attempt refused or fell out of scope ({named_refusals} \
20831+ refusals, {out_of_scope} out of scope); the gate proved nothing"
20832+ );
20833+ assert_eq!(
20834+ out_of_scope_mismatch, 0,
20835+ "{NAME}: {out_of_scope_mismatch} {bit_depth}-bit attempt(s) mismatch with no \
20836+ 16-level 1:4 strip at all"
20837+ );
20838+ assert!(
20839+ horz_proved > 0 && vert_proved > 0,
20840+ "{NAME}: {bit_depth}-bit compared attempts decoded {horz_proved} 16x4 and \
20841+ {vert_proved} 4x16 strips -- both orientations must fire or a transposed table \
20842+ passes"
20843+ );
20844+ assert!(
20845+ chroma_proved > 0,
20846+ "{NAME}: {bit_depth}-bit compared attempts closed {chroma_proved} chroma pairs"
20847+ );
20848+ assert!(
20849+ coeff_proved > 0,
20850+ "{NAME}: {bit_depth}-bit compared attempts coded no residual on any strip"
20851+ );
20852+ assert!(
20853+ split_proved > 0,
20854+ "{NAME}: {bit_depth}-bit compared attempts never split a strip's transform -- \
20855+ the `--enable-tx-size-search=1` half of the window proved nothing"
20856+ );
20857+ eprintln!(
20858+ "{NAME}: {bit_depth}-bit {matched} compared attempts, {horz_proved} 16x4 / \
20859+ {vert_proved} 4x16 strips, {chroma_proved} chroma pairs, {coeff_proved} coded \
20860+ units, {split_proved} split-transform strips, {named_refusals} refusals, \
20861+ {out_of_scope} out of scope"
20862+ );
20863+ }
20864+ }
20865+
20625 #[test]20866 #[test]
20626 // lane-tx64x16 r4: the fixture r3 could not find. `gradients` never wins20867 // lane-tx64x16 r4: the fixture r3 could not find. `gradients` never wins
20627 // a 32-level 1:4 shape; 8-pixel BANDS do -- each 32x8 strip is flat, so20868 // a 32-level 1:4 shape; 8-pixel BANDS do -- each 32x8 strip is flat, so
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-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.