forge
Explore
Log in

Don't you dare go Hollow

Merge branch 'lane-rectsplitx': per-transform-unit rect intra prediction under split transforms at every strip size (ReelB mid-film / ReelC head blockers); depth_to_tx_wh; three neighbour-map fixes; 16x8 tx_depth reads cat1; sub-16 filter-intra gates live

Browse files at this commit

4bf9109c820546fac540d9334966727e6c6bbf0aAhmet Kaan GümüşParent: 7a9d28d928732c
Merge resolution (main's fixes kept where they overlap):
- decode_rect_split chroma map: superset of rectchroma's and rectsplitx's rows
  (32x8/8x32/16x4/4x16/8x4/4x8), one comment.
- Reach::of_tu WIDENED to (tx_w, tx_h); square callers pass (tx, tx). The lane's
  inline per-unit Reach collapses onto it, and main's palette window inside the
  unit loop is kept (windowed by tx_w/tx_h).
- One fimode->intradir helper: main's fi_tx_row; the lane's identical
  tx_type_mode_row is dropped and its call site rebound.
- depth_to_tx_wh wins at every depth site, including decode_block_rect64's,
  replacing `bw.min(bh) >> (depth - 1)`; the "splits only once" refusal is gone.
- refusal_inventory: the lane's list minus its stale AB-below-16x16 entry (main
  lifted that refusal in lane-ab16).

Two merged gates asserted on counters that the lifted refusals fed, and both went
vacuous/false in the cross-product (class counter-from-refused-stream):
- chroma_is_a_4to1_or_sub8_rect counted attempts REFUSED at the depth-1 1:4
  strip; it now counts depth-1 1:4 strips that DECODED and compared pixel-exact.
- ab_partitions_below_16x16 required a vert-AB TX4 unit "reached" on
  tx-size-search attempts that used to stop at the strip refusal. Those attempts
  now decode to the end and compare pixel-exact, carrying zero such units -- the
  old nonzero count came from a still-desynced decode. The assert is now that
  every tx-size-search attempt compares exact; the lookup values stay pinned by
  of_tu_keeps_the_ordinary_answer_and_uses_the_block_row_under_vert_ab.

Suite on the merged tree: 347 passed / 3 failed / 29 ignored, the 3 being exactly
those two gates plus refusal_inventory; after the resolutions above all 3 pass
(15/15 in the targeted rerun).
crates/ec-av1/src/decode.rsmodified+443 -103
@@ -714,7 +714,7 @@ fn tu_reach(
714714 width: usize,
715715 height: usize,
716716 ) -> Reach {
717- let fixed = Reach::of_tu(bw, bh, col_off, row_off, tx, block);
717+ let fixed = Reach::of_tu(bw, bh, col_off, row_off, tx, tx, block);
718718 let standalone = Reach::of(tx, px + col_off, py + row_off, width, height);
719719 if fixed != standalone {
720720 SPLIT_TU_REACH_FIX_HITS.with(|c| c.set(c.get() + 1));
@@ -1845,6 +1845,30 @@ thread_local! {
18451845 static RECT4_COEFF_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
18461846 }
18471847
1848+// lane-rectsplitx r1: 1:4 strips (32x8/8x32/64x16/16x64) decoded through the
1849+// per-transform-unit split path, split by tx depth -- depth 1 is a 2:1 RECT
1850+// unit (TX_16X8/TX_32X16), depth 2 a square one, and the two INTERLEAVE in
1851+// every real stream, so a gate must prove both fired. `SUB16_SPLIT_HITS`
1852+// counts the same for a 16x8/8x16 strip below 16x16.
1853+thread_local! {
1854+ static RECT4_SPLIT_DEPTH1_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
1855+ static RECT4_SPLIT_DEPTH2_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
1856+ static SUB16_SPLIT_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
1857+}
1858+
1859+/// Current values of `RECT4_SPLIT_DEPTH1_HITS` / `RECT4_SPLIT_DEPTH2_HITS`.
1860+pub(crate) fn rect4_split_depth_hits() -> (usize, usize) {
1861+ (
1862+ RECT4_SPLIT_DEPTH1_HITS.with(|c| c.get()),
1863+ RECT4_SPLIT_DEPTH2_HITS.with(|c| c.get()),
1864+ )
1865+}
1866+
1867+/// Current value of `SUB16_SPLIT_HITS`.
1868+pub(crate) fn sub16_split_hits() -> usize {
1869+ SUB16_SPLIT_HITS.with(|c| c.get())
1870+}
1871+
18481872 /// Current value of `RECT4_COEFF_HITS`.
18491873 pub(crate) fn rect4_coeff_hits() -> usize {
18501874 RECT4_COEFF_HITS.with(|c| c.get())
@@ -4062,11 +4086,26 @@ impl Neighbours {
40624086 /// [`Self::around_mi`]'s plain coded/uncoded bit, this needs the real
40634087 /// cumulative level -- a lone-TU block never calls this (its `txb_skip_ctx`
40644088 /// is always 0, spec's `plane_bsize == tx_size` branch).
4065- fn luma_skip_ctx(&self, (mi_r, mi_c): (usize, usize), side_mi: usize) -> usize {
4089+ fn luma_skip_ctx(&self, at_mi: (usize, usize), side_mi: usize) -> usize {
4090+ self.luma_skip_ctx_rect(at_mi, side_mi, side_mi)
4091+ }
4092+
4093+ /// [`Self::luma_skip_ctx`] with the unit's own width and height in mi
4094+ /// units (lane-rectsplitx r1) -- `get_txb_ctx_general` ORs the above
4095+ /// context over `tx_size_wide` and the left one over `tx_size_high`.
4096+ fn luma_skip_ctx_rect(
4097+ &self,
4098+ (mi_r, mi_c): (usize, usize),
4099+ w_mi: usize,
4100+ h_mi: usize,
4101+ ) -> usize {
4102+ let side_mi = w_mi;
40664103 let mut top = 0u8;
40674104 let mut left = 0u8;
4068- for cell in 0..side_mi {
4105+ for cell in 0..w_mi {
40694106 top |= self.above[mi_c + cell][0].level;
4107+ }
4108+ for cell in 0..h_mi {
40704109 left |= self.left[mi_r + cell][0].level;
40714110 }
40724111 let ctx = SKIP_CONTEXTS[(top as usize).min(4)][(left as usize).min(4)];
@@ -4218,6 +4257,33 @@ impl Neighbours {
42184257 /// strip path ([`decode_leaf_rect`] took this override in r4; a 32x16 strip
42194258 /// whose left neighbour was a 16x8 leaf still read the stale row and picked
42204259 /// a different CDF for the same mode value).
4260+ /// lane-rectsplitx r2: availability-correct above/left luma modes for a
4261+ /// block whose top-left mi is `(mi_r, mi_c)`. libaom reads `above_mbmi`
4262+ /// only when `up_available` and `left_mbmi` only when `left_available`;
4263+ /// the coarse [`SUB`] bands cannot express that, and with 8-px strips they
4264+ /// actively lie -- four 32x8 strips of one `HORZ_4` share ONE 16x16
4265+ /// `left_mode` cell, so the second strip at tile column 0 read the FIRST
4266+ /// strip's mode as its "left neighbour" (measured on the band fixture at
4267+ /// mi(10,0): mode 2 where libaom has DC, a different `kf_y_mode` row).
4268+ fn modes_above_left_mi(
4269+ &self,
4270+ mi_r: usize,
4271+ mi_c: usize,
4272+ fallback: (usize, usize),
4273+ ) -> (usize, usize) {
4274+ let above = if mi_r > self.tile_row0_mi {
4275+ self.mode_above_mi(mi_r, mi_c).unwrap_or(fallback.0)
4276+ } else {
4277+ DC_PRED
4278+ };
4279+ let left = if mi_c > self.tile_col0_mi {
4280+ self.mode_left_mi(mi_r, mi_c).unwrap_or(fallback.1)
4281+ } else {
4282+ DC_PRED
4283+ };
4284+ (above, left)
4285+ }
4286+
42214287 fn modes_above_left(&self, r: usize, c: usize) -> (usize, usize) {
42224288 let (mi_r, mi_c) = (r * (SUB / MI), c * (SUB / MI));
42234289 let above = self.mode_above_mi(mi_r, mi_c).unwrap_or(self.above_mode[c]);
@@ -4323,13 +4389,27 @@ impl Neighbours {
43234389 /// Leaves `above_side_mi`/`left_side_mi` and the chroma planes alone --
43244390 /// the caller's own [`Self::record_split_luma`] call sets those once,
43254391 /// at the block's own true side, not this TU's.
4326- fn record_mi_luma(&mut self, (mi_r, mi_c): (usize, usize), tx_px: usize, grid: &[i32]) {
4392+ fn record_mi_luma(&mut self, at_mi: (usize, usize), tx_px: usize, grid: &[i32]) {
4393+ self.record_mi_luma_rect(at_mi, tx_px, tx_px, grid);
4394+ }
4395+
4396+ /// [`Self::record_mi_luma`] for a RECTANGULAR transform unit (lane-rectsplitx
4397+ /// r1): the above context spans the unit's width, the left context its
4398+ /// height, which for a square unit is the same loop it always was.
4399+ fn record_mi_luma_rect(
4400+ &mut self,
4401+ (mi_r, mi_c): (usize, usize),
4402+ w_px: usize,
4403+ h_px: usize,
4404+ grid: &[i32],
4405+ ) {
43274406 let state = neighbour_state(grid);
4328- let side_mi = tx_px / MI;
4329- for cell in 0..side_mi {
4407+ for cell in 0..h_px / MI {
43304408 if mi_r + cell < self.mi_rows {
43314409 self.left[mi_r + cell][0] = state;
43324410 }
4411+ }
4412+ for cell in 0..w_px / MI {
43334413 if mi_c + cell < self.mi_cols {
43344414 self.above[mi_c + cell][0] = state;
43354415 }
@@ -4367,17 +4447,42 @@ impl Neighbours {
43674447 chroma_grids: [&[i32]; 2],
43684448 ) {
43694449 let (r, c) = at;
4370- for cell in 0..w / SUB {
4450+ self.record_split_luma_rect_mi(
4451+ (r * (SUB / MI), c * (SUB / MI)),
4452+ w,
4453+ h,
4454+ mode,
4455+ uv_mode,
4456+ chroma_grids,
4457+ );
4458+ }
4459+
4460+ /// [`Self::record_split_luma_rect`] addressed in mi units (lane-rectsplitx
4461+ /// r1) -- a strip 8 px tall starts mid-[`SUB`]-cell, which the coarse
4462+ /// `(r, c)` form cannot name. The coarse mode/side arrays are stamped for
4463+ /// every cell the strip TOUCHES (`div_ceil`), last writer wins, the
4464+ /// convention [`decode_block_rect4`] already established for 1:4 strips.
4465+ fn record_split_luma_rect_mi(
4466+ &mut self,
4467+ at_mi: (usize, usize),
4468+ w: usize,
4469+ h: usize,
4470+ mode: usize,
4471+ uv_mode: usize,
4472+ chroma_grids: [&[i32]; 2],
4473+ ) {
4474+ let (mi_r, mi_c) = at_mi;
4475+ let (r, c) = (mi_r / (SUB / MI), mi_c / (SUB / MI));
4476+ for cell in 0..w.div_ceil(SUB) {
43714477 self.above_mode[c + cell] = mode;
43724478 self.above_uv_mode[c + cell] = uv_mode;
43734479 self.above_side[c + cell] = w;
43744480 }
4375- for cell in 0..h / SUB {
4481+ for cell in 0..h.div_ceil(SUB) {
43764482 self.left_mode[r + cell] = mode;
43774483 self.left_uv_mode[r + cell] = uv_mode;
43784484 self.left_side[r + cell] = h;
43794485 }
4380- let (mi_r, mi_c) = (r * (SUB / MI), c * (SUB / MI));
43814486 let (w_mi, h_mi) = (w / MI, h / MI);
43824487 self.record_mode_mi(mi_r, mi_c, w_mi, h_mi, mode);
43834488 self.record_uv_mode_mi(mi_r, mi_c, w_mi, h_mi, uv_mode);
@@ -5052,6 +5157,29 @@ struct RectStripModes {
50525157 palette_uv: Option<(Vec<u16>, Vec<u16>)>,
50535158 }
50545159
5160+/// The transform unit size (w, h) of a `bw`x`bh` intra block at tx `depth`
5161+/// -- libaom `depth_to_tx_size`, which walks `sub_tx_size_map` `depth` times
5162+/// from `max_txsize_rect_lookup[bsize]`. Every entry of that map halves the
5163+/// LONGER side of a rectangle and both sides of a square, so a 1:4 strip's
5164+/// first step is a 2:1 rect unit (`TX_32X8 -> TX_16X8`, `TX_64X16 ->
5165+/// TX_32X16`) and only the second reaches a square -- the reason
5166+/// `bw.min(bh) >> (depth - 1)` (correct for a 2:1 strip, where step one is
5167+/// already square) mis-tiled 1:4 strips.
5168+fn depth_to_tx_wh(bw: usize, bh: usize, depth: usize) -> (usize, usize) {
5169+ let (mut w, mut h) = (bw.min(64), bh.min(64));
5170+ for _ in 0..depth {
5171+ match w.cmp(&h) {
5172+ std::cmp::Ordering::Greater => w /= 2,
5173+ std::cmp::Ordering::Less => h /= 2,
5174+ std::cmp::Ordering::Equal => {
5175+ w /= 2;
5176+ h /= 2;
5177+ }
5178+ }
5179+ }
5180+ (w, h)
5181+}
5182+
50555183 /// Decodes the planes of one `bw`x`bh` HORZ/VERT intra strip whose luma
50565184 /// transform is SPLIT (`tx_depth != 0`) -- lane-rectsplit r1, the case every
50575185 /// rect path here refused by name until now ("per-unit rect prediction is not
@@ -5077,10 +5205,15 @@ fn decode_rect_split(
50775205 dec: &mut SymbolDecoder,
50785206 cdfs: &mut Cdfs,
50795207 neighbours: &mut Neighbours,
5080- at: (usize, usize),
5208+ at_mi: (usize, usize),
50815209 bw: usize,
50825210 bh: usize,
5083- tx: usize,
5211+ // The transform unit's own width and height in pixels. Square for every
5212+ // 2:1 strip from the first split on, but a 1:4 strip's FIRST split is
5213+ // still a 2:1 RECT unit (`sub_tx_size_map[TX_32X8] == TX_16X8`,
5214+ // `[TX_64X16] == TX_32X16`) -- see [`depth_to_tx_wh`].
5215+ tx_w: usize,
5216+ tx_h: usize,
50845217 m: &RectStripModes,
50855218 y: &mut PlaneBuf,
50865219 u: &mut PlaneBuf,
@@ -5088,9 +5221,8 @@ fn decode_rect_split(
50885221 base_q_idx: u8,
50895222 reduced_tx_set: bool,
50905223 ) -> Result<()> {
5091- let (r, c) = at;
5092- let (px, py) = (c * SUB, r * SUB);
5093- let (mi_r, mi_c) = (r * (SUB / MI), c * (SUB / MI));
5224+ let (mi_r, mi_c) = at_mi;
5225+ let (px, py) = (mi_c * MI, mi_r * MI);
50945226 let (cpx, cpy) = (px / 2, py / 2);
50955227 let (chroma_w, chroma_h) = (bw / 2, bh / 2);
50965228 // The chroma transform is picked before any symbol is read, so an
@@ -5100,16 +5232,17 @@ fn decode_rect_split(
51005232 (8, 16) => Some((TxbSet::ChromaRect16x8, &SCAN_8X16[..])),
51015233 (32, 16) => Some((TxbSet::ChromaRect32x16, &SCAN_32X16[..])),
51025234 (16, 32) => Some((TxbSet::ChromaRect32x16, &SCAN_16X32[..])),
5103- // lane-rectchroma r1: the 1:4 superblock strips (64x16/16x64,
5104- // `decode_block_rect64`'s `strip64!` arm) and the 8x16 left rect of a
5105- // 16x16 `VERT_B` reach here once their tx depth is non-zero -- the
5106- // shapes their chroma half takes. `get_txsize_entropy_ctx(TX_32X8)`
5107- // is `(0 + 4 + 1) >> 1 == 2`, the 16x16 CDF set (eob alphabet 256),
5108- // exactly as the unsplit 1:4 path already picks it; `TX_8X4` reduces
5109- // to `(0 + 1 + 1) >> 1 == 1`, the 8x8 set `ChromaRect8x4` carries
5110- // (eob 32), as `decode_leaf_rect`'s own chroma half already does.
5235+ // The 1:4 and sub-16 strips (lane-rectchroma r1 added the 32x8/8x32
5236+ // rows, lane-rectsplitx r1 the 16x4/4x16 ones). `get_txsize_entropy_ctx`
5237+ // squares a rect transform down to a CDF set by
5238+ // `(wide_log2 + high_log2 + 1) >> 1`: TX_32X8 -> the 16x16 set,
5239+ // TX_16X4 -> the 8x8 set, TX_8X4 -> the 8x8 set -- exactly the sets
5240+ // the UNSPLIT 1:4 (`decode_block_rect4`) and 16x8 (`decode_leaf_rect`)
5241+ // paths already prove for these same shapes.
51115242 (32, 8) => Some((TxbSet::Chroma16, &SCAN_32X8[..])),
51125243 (8, 32) => Some((TxbSet::Chroma16, &SCAN_8X32[..])),
5244+ (16, 4) => Some((TxbSet::Chroma8, &SCAN_16X4[..])),
5245+ (4, 16) => Some((TxbSet::Chroma8, &SCAN_4X16[..])),
51135246 (8, 4) => Some((TxbSet::ChromaRect8x4, &SCAN_8X4[..])),
51145247 (4, 8) => Some((TxbSet::ChromaRect8x4, &SCAN_4X8[..])),
51155248 _ => None,
@@ -5132,7 +5265,7 @@ fn decode_rect_split(
51325265 // Diagnostic for the next caller that lands here (class
51335266 // refusal-names-a-correlate: the message names the tool, not the
51345267 // shape); the refusal below keeps its inventory-pinned wording.
5135- eprintln!("EC_RECTCHROMA_GAP luma={bw}x{bh} tx={tx} chroma={chroma_w}x{chroma_h}");
5268+ eprintln!("EC_RECTCHROMA_GAP luma={bw}x{bh} tx={tx_w}x{tx_h} chroma={chroma_w}x{chroma_h}");
51365269 }
51375270 }
51385271 // lane-rectsplit r2 (verifier finding): with both callers wired
@@ -5148,21 +5281,50 @@ fn decode_rect_split(
51485281 ));
51495282 }
51505283 RECT_SPLIT_TX_HITS.with(|c| c.set(c.get() + 1));
5151- if bw.max(bh) == 64 && bw / tx > 1 && bh / tx > 1 {
5284+ if bw.max(bh) == 64 && bw / tx_w > 1 && bh / tx_h > 1 {
51525285 RECT_SPLIT_SB_INTERIOR_TU_HITS.with(|c| c.set(c.get() + 1));
51535286 }
51545287 // LUMA: `bw/tx` x `bh/tx` square transform units, raster order.
5155- let luma_set = txbset_for(tx, reduced_tx_set);
5156- let luma_scan = default_scan(tx);
5157- let zero_tu = vec![0i32; tx * tx];
5288+ // A square unit reads through the ordinary square [`read_plane`]; a rect
5289+ // one (a 1:4 strip's first split) reads through [`read_coeffs_rect`] with
5290+ // the very tables the unsplit 16x8/32x16 paths use.
5291+ let luma_rect: Option<(TxbSet, &[u16])> = match (tx_w, tx_h) {
5292+ (w, h) if w == h => None,
5293+ (16, 8) | (8, 16) => Some((
5294+ if reduced_tx_set {
5295+ TxbSet::LumaRect16x8
5296+ } else {
5297+ TxbSet::LumaRect16x8Set1
5298+ },
5299+ if tx_w == 16 { &SCAN_16X8[..] } else { &SCAN_8X16[..] },
5300+ )),
5301+ (32, 16) => Some((TxbSet::LumaRect32x16, &SCAN_32X16[..])),
5302+ (16, 32) => Some((TxbSet::LumaRect32x16, &SCAN_16X32[..])),
5303+ _ => {
5304+ return Err(unsupported(format!(
5305+ "a split intra strip whose transform unit is {tx_w}x{tx_h} (no luma \
5306+ coefficient tables for that shape here)"
5307+ )))
5308+ }
5309+ };
5310+ // lane-rectsplitx r1, MEASURED: the SQUARE-unit walk below is pixel-exact
5311+ // on a real stream (the pinned 16x8 filter-intra fixture decodes its whole
5312+ // frame exactly, two sub-16 split strips in it), but the RECT-unit arm --
5313+ // a 1:4 strip's depth-1 TX_16X8/TX_32X16 -- mismatched ffmpeg on the
5314+ // 32-level 1:4 band fixture (8-bit, cq 12, seed 42). The tables and the
5315+ // per-unit rect walk stay wired above/below; the round that finds that
5316+ // defect deletes this refusal and nothing else.
5317+ let luma_set = txbset_for(tx_w.min(tx_h), reduced_tx_set);
5318+ let luma_scan = default_scan(tx_w.min(tx_h));
5319+ let zero_tu = vec![0i32; tx_w * tx_h];
51585320 // The strip's OWN edge availability, the fallback for a transform unit
51595321 // whose top-right/bottom-left pixels fall outside the strip.
51605322 let block_reach = Reach::of_rect(bw, bh, px, py, y.width, y.height);
5161- for tu_row in 0..bh / tx {
5162- for tu_col in 0..bw / tx {
5163- let tu_mi = (mi_r + tu_row * (tx / MI), mi_c + tu_col * (tx / MI));
5164- let (tu_px, tu_py) = (px + tu_col * tx, py + tu_row * tx);
5165- let (col_off, row_off) = (tu_col * tx, tu_row * tx);
5323+ for tu_row in 0..bh / tx_h {
5324+ for tu_col in 0..bw / tx_w {
5325+ let tu_mi = (mi_r + tu_row * (tx_h / MI), mi_c + tu_col * (tx_w / MI));
5326+ let (tu_px, tu_py) = (px + tu_col * tx_w, py + tu_row * tx_h);
5327+ let (col_off, row_off) = (tu_col * tx_w, tu_row * tx_h);
51665328 // `has_top_right`/`has_bottom_left` (libaom `reconintra.c`) for a
51675329 // transform unit INSIDE a block, which is a different rule from
51685330 // the standalone-block table [`Reach::of`] applies -- and the
@@ -5178,22 +5340,23 @@ fn decode_rect_split(
51785340 // (`row_off + tx_high < plane_bh`) they are the left
51795341 // neighbour's, already reconstructed; the last row falls back
51805342 // to the block-level answer.
5181- let tu_reach = Reach::of_tu(bw, bh, col_off, row_off, tx, block_reach);
5343+ let tu_reach = Reach::of_tu(bw, bh, col_off, row_off, tx_w, tx_h, block_reach);
51825344 // The unit's own window on the block's palette prediction.
51835345 if let Some(buf) = &m.palette_y {
5184- let tu_buf: Vec<u16> = (0..tx)
5346+ let tu_buf: Vec<u16> = (0..tx_h)
51855347 .flat_map(|i| {
51865348 let base = (row_off + i) * bw + col_off;
5187- buf[base..base + tx].iter().copied()
5349+ buf[base..base + tx_w].iter().copied()
51885350 })
51895351 .collect();
51905352 set_palette_pred(tu_buf);
51915353 }
51925354 if m.skip {
5193- y.reconstruct(
5355+ y.reconstruct_rect(
51945356 tu_px,
51955357 tu_py,
5196- tx,
5358+ tx_w,
5359+ tx_h,
51975360 m.mode,
51985361 m.angle_delta_y,
51995362 tu_reach,
@@ -5202,13 +5365,57 @@ fn decode_rect_split(
52025365 m.filter_intra,
52035366 m.smooth_neighbor,
52045367 );
5205- neighbours.record_mi_luma(tu_mi, tx, &zero_tu);
5368+ neighbours.record_mi_luma_rect(tu_mi, tx_w, tx_h, &zero_tu);
5369+ } else if let Some((rect_set, rect_scan)) = luma_rect {
5370+ // The rect-unit twin of the square arm below: same contexts,
5371+ // same order, through the rect coefficient reader. The
5372+ // `tx_type` CDF row of a filter-intra block is
5373+ // `fimode_to_intradir[filter_intra_mode]`, never the block's
5374+ // own (always DC_PRED) mode -- [`read_plane`] applies that
5375+ // for the square arm, so this one must too.
5376+ let tu_around = neighbours.around_mi_rect(tu_mi, tx_w, tx_h)[0];
5377+ let tu_skip_ctx = neighbours.luma_skip_ctx_rect(tu_mi, tx_w / MI, tx_h / MI);
5378+ let mut coding = cdfs.txb(rect_set, fi_tx_row(m.mode, m.filter_intra));
5379+ let (tu_grid, tu_tx_type) = read_coeffs_rect(
5380+ dec,
5381+ &mut coding,
5382+ rect_scan,
5383+ tx_w,
5384+ tx_h,
5385+ tu_skip_ctx,
5386+ dc_sign_ctx(tu_around.2),
5387+ TxType::DctDct,
5388+ )?;
5389+ let residual = dequant_and_inverse_typed_wh(
5390+ &tu_grid,
5391+ tx_w,
5392+ tx_h,
5393+ crate::decode::bit_depth(),
5394+ block_q_idx(),
5395+ plane_q_delta(0).0,
5396+ plane_q_delta(0).1,
5397+ tu_tx_type,
5398+ );
5399+ y.reconstruct_rect(
5400+ tu_px,
5401+ tu_py,
5402+ tx_w,
5403+ tx_h,
5404+ m.mode,
5405+ m.angle_delta_y,
5406+ tu_reach,
5407+ &residual,
5408+ None,
5409+ m.filter_intra,
5410+ m.smooth_neighbor,
5411+ );
5412+ neighbours.record_mi_luma_rect(tu_mi, tx_w, tx_h, &tu_grid);
52065413 } else {
5207- let tu_around = neighbours.around_mi(tu_mi, tx)[0];
5414+ let tu_around = neighbours.around_mi(tu_mi, tx_w)[0];
52085415 // This unit is smaller than the block it sits in, so
52095416 // `txb_skip_ctx` is the neighbour-magnitude table, not the
52105417 // lone-TU 0 (spec `get_txb_ctx_general`).
5211- let tu_skip_ctx = neighbours.luma_skip_ctx(tu_mi, tx / MI);
5418+ let tu_skip_ctx = neighbours.luma_skip_ctx(tu_mi, tx_w / MI);
52125419 let tu_grid = read_plane(
52135420 dec,
52145421 cdfs,
@@ -5223,15 +5430,15 @@ fn decode_rect_split(
52235430 y,
52245431 tu_px,
52255432 tu_py,
5226- tx,
5227- tx,
5433+ tx_w,
5434+ tx_w,
52285435 base_q_idx,
52295436 None,
52305437 m.filter_intra,
52315438 Some(tu_skip_ctx),
52325439 m.smooth_neighbor,
52335440 )?;
5234- neighbours.record_mi_luma(tu_mi, tx, &tu_grid);
5441+ neighbours.record_mi_luma(tu_mi, tx_w, &tu_grid);
52355442 }
52365443 }
52375444 }
@@ -5265,7 +5472,7 @@ fn decode_rect_split(
52655472 } else {
52665473 default_intra_tx_type(m.uv_predict_mode as u8)
52675474 };
5268- let around = neighbours.around_rect(at, bw, bh);
5475+ let around = neighbours.around_mi_rect(at_mi, bw, bh);
52695476 let mut grids: Vec<Vec<i32>> = Vec::with_capacity(2);
52705477 for plane_idx in 1..=2 {
52715478 let skip_ctx =
@@ -5325,13 +5532,21 @@ fn decode_rect_split(
53255532 let mut it = grids.into_iter();
53265533 (it.next().unwrap(), it.next().unwrap())
53275534 };
5328- neighbours.record_split_luma_rect(at, bw, bh, m.mode, m.uv_predict_mode, [&u_grid, &v_grid]);
5535+ neighbours.record_split_luma_rect_mi(
5536+ at_mi,
5537+ bw,
5538+ bh,
5539+ m.mode,
5540+ m.uv_predict_mode,
5541+ [&u_grid, &v_grid],
5542+ );
53295543 neighbours.fill_skip_grid_rect((mi_r, mi_c), bw / MI, bh / MI, m.skip);
5330- neighbours.fill_lf_grid_rect((mi_r, mi_c), bw / MI, bh / MI, tx as u8, tx as u8, 0);
5544+ neighbours.fill_lf_grid_rect((mi_r, mi_c), bw / MI, bh / MI, tx_w as u8, tx_h as u8, 0);
53315545 if std::env::var_os("EC_AV1_TRACE").is_some() {
53325546 let (rng, _) = dec.debug_state();
53335547 eprintln!(
5334- "TRACE_RECT_SPLIT mi_row={mi_r} mi_col={mi_c} bw={bw} bh={bh} tx={tx} rng={rng}"
5548+ "TRACE_RECT_SPLIT mi_row={mi_r} mi_col={mi_c} bw={bw} bh={bh} \
5549+ tx={tx_w}x{tx_h} rng={rng}"
53355550 );
53365551 }
53375552 Ok(())
@@ -5427,13 +5642,12 @@ fn decode_block_rect(
54275642 // lane-rectsplit r1: a split transform is predicted and reconstructed
54285643 // per transform unit, each unit taking its edges from the previous
54295644 // unit's reconstruction inside this same strip (spec 5.11.36) --
5430- // [`decode_rect_split`]. `depth_to_tx_size` of a 2:1 strip is square
5431- // from the first step on, so `bw.min(bh) >> (depth - 1)` names it.
5432- let tx = bw.min(bh) >> (depth - 1);
5645+ // [`decode_rect_split`], the unit named by [`depth_to_tx_wh`].
5646+ let (tx_w, tx_h) = depth_to_tx_wh(bw, bh, depth);
54335647 if std::env::var_os("EC_SBPART_DUMP64").is_some() {
54345648 eprintln!(
54355649 "DUMP64SPLIT mi_r={mi_r} mi_c={mi_c} px={px} py={py} bw={bw} bh={bh} \
5436- depth={depth} tx={tx} mode={mode} uv={uv_predict_mode} skip={skip} \
5650+ depth={depth} tx={tx_w}x{tx_h} mode={mode} uv={uv_predict_mode} skip={skip} \
54375651 angle_y={angle_delta_y}"
54385652 );
54395653 }
@@ -5461,7 +5675,20 @@ fn decode_block_rect(
54615675 PALETTE_SPLIT_TX_HITS.with(|c| c.set(c.get() + 1));
54625676 }
54635677 decode_rect_split(
5464- dec, cdfs, neighbours, at, bw, bh, tx, &modes, y, u, v, base_q_idx, reduced_tx_set,
5678+ dec,
5679+ cdfs,
5680+ neighbours,
5681+ (mi_r, mi_c),
5682+ bw,
5683+ bh,
5684+ tx_w,
5685+ tx_h,
5686+ &modes,
5687+ y,
5688+ u,
5689+ v,
5690+ base_q_idx,
5691+ reduced_tx_set,
54655692 )?;
54665693 // This early return skips this fn's own tail, so the palette
54675694 // neighbour state has to be stamped HERE too: without it a split-tx
@@ -5811,12 +6038,12 @@ fn decode_leaf_rect(
58116038 // cannot hold the modes a split (or a pair of strips) leaves behind, so
58126039 // when the map holds the block at exactly this strip's above/left mi it
58136040 // is the neighbour libaom's `above_mi`/`left_mi` reads.
5814- if let Some(m) = neighbours.mode_above_mi(leaf_mi.0, leaf_mi.1) {
5815- above_mode = m;
5816- }
5817- if let Some(m) = neighbours.mode_left_mi(leaf_mi.0, leaf_mi.1) {
5818- left_mode = m;
5819- }
6041+ // lane-rectsplitx r2 (same class as the 1:4 fix): mi-exact AND
6042+ // availability-correct -- four 16x8 strips share one coarse 16x16
6043+ // `left_mode` cell too, so the fallback must not stand in for an absent
6044+ // tile-edge neighbour.
6045+ let (above_mode, left_mode) =
6046+ neighbours.modes_above_left_mi(leaf_mi.0, leaf_mi.1, (above_mode, left_mode));
58206047 let smooth_neighbor =
58216048 is_smooth_mode(above_mode) || is_smooth_mode(left_mode);
58226049 if smooth_neighbor {
@@ -5874,15 +6101,57 @@ fn decode_leaf_rect(
58746101 let smooth_neighbor_uv = neighbours.smooth_uv_neighbour(leaf_mi.0, leaf_mi.1, r, c);
58756102 let depth = if tx_select {
58766103 let ctx = tx_size_context_rect(neighbours, leaf_mi, bw, bh);
5877- dec.symbol(&mut cdfs.tx_size_cat2[ctx])
6104+ // lane-rectsplitx r1: `bsize_to_tx_size_cat` (libaom `blockd.h`,
6105+ // `bsize_to_tx_size_depth_table`) is 2 for BLOCK_16X8/BLOCK_8X16, so
6106+ // the category is 1 -- NOT the 2 the 32x16 strips read. Same symbol
6107+ // count (3), different CDF row: a wrong-table read of a real symbol,
6108+ // the class that cost lane-rectsplit r1 its 64x32 depth.
6109+ dec.symbol(&mut cdfs.tx_size_cat1[ctx])
58786110 } else {
58796111 0
58806112 };
58816113 if depth != 0 {
5882- return Err(unsupported(
5883- "a HORZ/VERT intra strip below 16x16 with a split transform (per-unit rect \
5884- prediction is not ported)",
5885- ));
6114+ // The same per-transform-unit walk the bigger strips take
6115+ // (`depth_to_tx_wh`: TX_16X8 -> TX_8X8 at depth 1, -> TX_4X4 at
6116+ // depth 2), addressed at this leaf's own mi position.
6117+ TX_DEPTH_HITS.with(|c| c.set(c.get() + 1));
6118+ SUB16_SPLIT_HITS.with(|c| c.set(c.get() + 1));
6119+ let (tx_w, tx_h) = depth_to_tx_wh(bw, bh, depth);
6120+ let modes = RectStripModes {
6121+ skip,
6122+ mode,
6123+ angle_delta_y,
6124+ uv_predict_mode,
6125+ angle_delta_uv,
6126+ alpha,
6127+ filter_intra,
6128+ smooth_neighbor,
6129+ // lane-rectsplitx r3: the split arm hard-coded `false` here while
6130+ // the unsplit arm below passes the real neighbour answer -- chroma
6131+ // of a tx-split 16x8/8x16 leaf lost its intra-edge filter type.
6132+ smooth_neighbor_uv,
6133+ // Both callers refuse a palette on this shape above (pixel
6134+ // reconstruction is unported here), so the split units carry none.
6135+ palette_y: None,
6136+ palette_uv: None,
6137+ };
6138+ decode_rect_split(
6139+ dec,
6140+ cdfs,
6141+ neighbours,
6142+ leaf_mi,
6143+ bw,
6144+ bh,
6145+ tx_w,
6146+ tx_h,
6147+ &modes,
6148+ y,
6149+ u,
6150+ v,
6151+ base_q_idx,
6152+ reduced_tx_set,
6153+ )?;
6154+ return Ok(mode);
58866155 }
58876156 let (px, py) = (leaf_mi.1 * MI, leaf_mi.0 * MI);
58886157 let reach = Reach::of_rect(bw, bh, px, py, y.width, y.height);
@@ -6042,6 +6311,12 @@ fn decode_block_rect4(
60426311 left_mode = pmode;
60436312 }
60446313 }
6314+ // lane-rectsplitx r2, ROOT CAUSE of the 1:4 mismatch: mi-exact +
6315+ // availability-correct neighbour modes (see
6316+ // [`Neighbours::modes_above_left_mi`]). The coarse 16x16 bands alias every
6317+ // 8-px strip of a `HORZ_4`/`VERT_4` onto one cell.
6318+ let (above_mode, left_mode) =
6319+ neighbours.modes_above_left_mi(mi_r, mi_c, (above_mode, left_mode));
60456320 let (
60466321 skip,
60476322 mode,
@@ -6082,8 +6357,13 @@ fn decode_block_rect4(
60826357 if smooth_neighbor {
60836358 SMOOTH_LUMA_HITS.with(|c| c.set(c.get() + 1));
60846359 }
6085- let smooth_neighbor_uv =
6086- neighbours.smooth_uv_neighbour(r * (SUB / MI), c * (SUB / MI), r, c);
6360+ // lane-rectsplitx r2: this strip's REAL mi, not the [`SUB`] cell's
6361+ // top-left -- a 1:4 strip starts 8 px into a 16-px cell, so
6362+ // `r * (SUB / MI)` names a different mi column and the chroma
6363+ // edge-filter strength was read from the wrong neighbour (measured:
6364+ // seed 43, the last 8x32 strip at luma (152,32), chroma-only mismatch
6365+ // with luma bit-exact).
6366+ let smooth_neighbor_uv = neighbours.smooth_uv_neighbour(mi_r, mi_c, r, c);
60876367 if filter_intra.is_some() {
60886368 FILTER_INTRA_RECT_HITS.with(|c| c.set(c.get() + 1));
60896369 if bw > bh {
@@ -6104,16 +6384,64 @@ fn decode_block_rect4(
61046384 0
61056385 };
61066386 if depth != 0 {
6107- // lane-tx64x16 r4: the depth is IN the message -- it says which port
6108- // the next round owes. depth 1 of a 4:1 strip is TX_16X8/TX_8X16
6109- // (`sub_tx_size_map[TX_32X8] == TX_16X8`), a RECTANGULAR transform
6110- // unit with no luma coefficient tables here; depth 2 is TX_8X8,
6111- // square, the shape `decode_rect_split` already walks. The film stops
6112- // at depth 2, synthetic band fixtures hit both.
6113- return Err(unsupported(format!(
6114- "a 32x32-level 1:4 strip with a split transform (per-unit 4:1 prediction is not \
6115- ported, depth={depth})"
6116- )));
6387+ // lane-rectsplitx r1: the per-transform-unit walk, at this strip's
6388+ // real mi position (strips 1 and 3 of a HORZ_4 start 8 px into a
6389+ // 16-px [`SUB`] cell). depth 1 is the RECT unit TX_16X8/TX_8X16
6390+ // (`sub_tx_size_map[TX_32X8] == TX_16X8`), depth 2 the square TX_8X8;
6391+ // both interleave in every real stream.
6392+ TX_DEPTH_HITS.with(|c| c.set(c.get() + 1));
6393+ let (tx_w, tx_h) = depth_to_tx_wh(bw, bh, depth);
6394+ // lane-rectsplitx r2: both depths ship together, as the r1 handoff
6395+ // predicted -- depth 1 fires FIRST in every attempt that splits at
6396+ // all, so a depth-2-only lift could never be gated. The r1 mismatch
6397+ // was never the rect unit: it was the neighbour MODE the strip reads
6398+ // (see `modes_above_left_mi`).
6399+ let which = if depth == 1 {
6400+ &RECT4_SPLIT_DEPTH1_HITS
6401+ } else {
6402+ &RECT4_SPLIT_DEPTH2_HITS
6403+ };
6404+ which.with(|c| c.set(c.get() + 1));
6405+ let modes = RectStripModes {
6406+ skip,
6407+ mode,
6408+ angle_delta_y,
6409+ uv_predict_mode,
6410+ angle_delta_uv,
6411+ alpha,
6412+ filter_intra,
6413+ smooth_neighbor,
6414+ smooth_neighbor_uv,
6415+ // Both callers refuse a palette on this shape above (pixel
6416+ // reconstruction is unported here), so the split units carry none.
6417+ palette_y: None,
6418+ palette_uv: None,
6419+ };
6420+ decode_rect_split(
6421+ dec,
6422+ cdfs,
6423+ neighbours,
6424+ (mi_r, mi_c),
6425+ bw,
6426+ bh,
6427+ tx_w,
6428+ tx_h,
6429+ &modes,
6430+ y,
6431+ u,
6432+ v,
6433+ base_q_idx,
6434+ false,
6435+ )?;
6436+ if bw > bh {
6437+ RECT4_32_HORZ_HITS.with(|c| c.set(c.get() + 1));
6438+ } else {
6439+ RECT4_32_VERT_HITS.with(|c| c.set(c.get() + 1));
6440+ }
6441+ if !skip {
6442+ RECT4_COEFF_HITS.with(|c| c.set(c.get() + 1));
6443+ }
6444+ return Ok((mode, uv_predict_mode));
61176445 }
61186446 // The coarse (16-px [`SUB`] cell) mode/side arrays cannot name a strip
61196447 // that is 8 px tall, so each strip stamps every cell it touches and the
@@ -6130,6 +6458,14 @@ fn decode_block_rect4(
61306458 neighbours.left_uv_mode[r + cell] = uv_predict_mode;
61316459 neighbours.left_side[r + cell] = bh;
61326460 }
6461+ // ...and the mi-EXACT maps the coarse cells alias away, exactly as
6462+ // [`decode_leaf_rect`] does (the split arm above records these through
6463+ // `record_mi_luma_rect`). Without this an unsplit 32x8 strip left
6464+ // `sub8_mode_row` holding the previous block, and the next 32x32's
6465+ // strips read a stale `kf_y_mode` row (measured: mi(4,8) on the band
6466+ // fixture).
6467+ neighbours.record_mode_mi(mi_r, mi_c, mi_w, mi_h, mode);
6468+ neighbours.record_uv_mode_mi(mi_r, mi_c, mi_w, mi_h, uv_predict_mode);
61336469 let (px, py) = (mi_c * MI, mi_r * MI);
61346470 let (cpx, cpy) = (px / 2, py / 2);
61356471 let (chroma_w, chroma_h) = (bw / 2, bh / 2);
@@ -6412,31 +6748,22 @@ fn decode_block_rect64(
64126748 TX_DEPTH_HITS.with(|c| c.set(c.get() + 1));
64136749 // lane-rectsplit r1/r4: the superblock-level strip splits its
64146750 // transform through the very same per-unit path as its 32x32-level
6415- // sibling (`sub_tx_size_map[TX_64X32] == TX_32X32`, square from the
6416- // first step on, so `bw.min(bh) >> (depth - 1)` names the unit).
6417- // lane-rectchroma r1: `sub_tx_size_map[TX_64X16] == TX_32X16`, NOT a
6418- // square -- a 4:1 strip's first transform split is still a 2:1 RECT
6419- // unit, and only the SECOND step reaches a square (TX_16X16). The
6420- // 2:1 formula below (square from the first step on) named 16x16 units
6421- // for a depth-1 64x16 strip, which decoded 2 chroma-32x8 strips of
6422- // the band fixture with the wrong luma tiling. depth 1 on a 4:1 strip
6423- // is refused by name; depth >= 2 is square, one step later.
6424- let is_1to4 = bw.max(bh) / bw.min(bh) == 4;
6425- if is_1to4 && depth == 1 && !skip {
6426- return Err(unsupported(
6427- "a coded 1:4 HORZ_4/VERT_4 strip whose transform splits only once (the unit is \
6428- still a 2:1 rect, not a square)",
6429- ));
6751+ // sibling; [`depth_to_tx_wh`] names the unit, which for a 64x16/16x64
6752+ // 1:4 strip is the 2:1 rect TX_32X16 at depth 1 (lane-rectchroma r1
6753+ // measured the old square formula mis-tiling exactly that strip).
6754+ let (tx_w, tx_h) = depth_to_tx_wh(bw, bh, depth);
6755+ if bw.max(bh) / bw.min(bh) == 4 {
6756+ let which = if depth == 1 {
6757+ &RECT4_SPLIT_DEPTH1_HITS
6758+ } else {
6759+ &RECT4_SPLIT_DEPTH2_HITS
6760+ };
6761+ which.with(|c| c.set(c.get() + 1));
64306762 }
6431- let tx = if is_1to4 {
6432- bw.min(bh) >> (depth - 2)
6433- } else {
6434- bw.min(bh) >> (depth - 1)
6435- };
64366763 if std::env::var_os("EC_SBPART_DUMP64").is_some() {
64376764 eprintln!(
64386765 "DUMP64SPLIT mi_r={mi_r} mi_c={mi_c} px={px} py={py} bw={bw} bh={bh} \
6439- depth={depth} tx={tx} mode={mode} uv={uv_predict_mode} skip={skip} \
6766+ depth={depth} tx={tx_w}x{tx_h} mode={mode} uv={uv_predict_mode} skip={skip} \
64406767 angle_y={angle_delta_y}"
64416768 );
64426769 }
@@ -6464,7 +6791,20 @@ fn decode_block_rect64(
64646791 PALETTE_SPLIT_TX_HITS.with(|c| c.set(c.get() + 1));
64656792 }
64666793 decode_rect_split(
6467- dec, cdfs, neighbours, at, bw, bh, tx, &modes, y, u, v, base_q_idx, reduced_tx_set,
6794+ dec,
6795+ cdfs,
6796+ neighbours,
6797+ (mi_r, mi_c),
6798+ bw,
6799+ bh,
6800+ tx_w,
6801+ tx_h,
6802+ &modes,
6803+ y,
6804+ u,
6805+ v,
6806+ base_q_idx,
6807+ reduced_tx_set,
64686808 )?;
64696809 // Same early-return palette stamp as [`decode_block_rect`]'s split arm
64706810 // (lane-palette2 r10): this return skips the fn's own tail, so a
@@ -8181,12 +8521,12 @@ fn decode_leaf8(
81818521 // `prev_leaf`: one 16x16 slot cannot hold the two different modes its
81828522 // two 8x8 (or four 4x4) columns leave behind, so a leaf whose above/left
81838523 // neighbour sits in a split cell read the wrong `kf_y_mode` row.
8184- if let Some(m) = neighbours.mode_above_mi(leaf_mi.0, leaf_mi.1) {
8185- above_mode = m;
8186- }
8187- if let Some(m) = neighbours.mode_left_mi(leaf_mi.0, leaf_mi.1) {
8188- left_mode = m;
8189- }
8524+ // lane-rectsplitx r2 swept this arm into
8525+ // [`Neighbours::modes_above_left_mi`]: the mi-exact map ALSO has to answer
8526+ // "no neighbour" at a tile edge, where the coarse cell holds the block
8527+ // above/left of it inside the same 16x16.
8528+ let (above_mode, left_mode) =
8529+ neighbours.modes_above_left_mi(leaf_mi.0, leaf_mi.1, (above_mode, left_mode));
81908530 let smooth_neighbor = is_smooth_mode(above_mode) || is_smooth_mode(left_mode);
81918531 // Chroma's edge-filter type reads the CHROMA neighbour's `uv_mode`
81928532 // (`get_intra_edge_filter_type`, reconintra.c:974), never the luma mode
crates/ec-av1/src/encode.rsmodified+10 -6
@@ -1234,18 +1234,22 @@ impl Reach {
12341234 bh: usize,
12351235 col_off: usize,
12361236 row_off: usize,
1237- tx: usize,
1237+ // The unit's own width and height in pixels; equal for a square
1238+ // transform, different for the rect unit a 1:4 strip's first split
1239+ // produces (lane-rectsplitx r1).
1240+ tx_w: usize,
1241+ tx_h: usize,
12381242 block: Self,
12391243 ) -> Self {
12401244 Self {
1241- above_right: if col_off + tx < bw {
1245+ above_right: if col_off + tx_w < bw {
12421246 true
12431247 } else {
12441248 row_off == 0 && block.above_right
12451249 },
12461250 below_left: if col_off > 0 {
12471251 false
1248- } else if row_off + tx < bh {
1252+ } else if row_off + tx_h < bh {
12491253 true
12501254 } else {
12511255 block.below_left
@@ -3865,14 +3869,14 @@ mod tests {
38653869 // `has_tr_vert_*` tables have no 4x4 row at all, lane-ab16 r2).
38663870 let plain = Reach::of(8, 0, 8, SUPERBLOCK, SUPERBLOCK);
38673871 assert_eq!(
3868- Reach::of_tu(8, 8, 4, 0, 4, plain).above_right,
3872+ Reach::of_tu(8, 8, 4, 0, 4, 4, plain).above_right,
38693873 plain.above_right,
38703874 "ordinary table: the top-right TX4 unit takes the block's row"
38713875 );
38723876 let guard = Reach::vert_ab_partition();
38733877 let vert = Reach::of(8, 0, 8, SUPERBLOCK, SUPERBLOCK);
38743878 assert_eq!(
3875- Reach::of_tu(8, 8, 4, 0, 4, vert).above_right,
3879+ Reach::of_tu(8, 8, 4, 0, 4, 4, vert).above_right,
38763880 vert.above_right,
38773881 "vert AB: the unit follows the vert row the block just picked"
38783882 );
@@ -4016,7 +4020,7 @@ mod tests {
40164020 for row_off in (0..bh).step_by(tx) {
40174021 for col_off in (0..bw).step_by(tx) {
40184022 for &blk in &[Reach { above_right: false, below_left: false }, Reach { above_right: true, below_left: true }] {
4019- let got = Reach::of_tu(bw, bh, col_off, row_off, tx, blk);
4023+ let got = Reach::of_tu(bw, bh, col_off, row_off, tx, tx, blk);
40204024 assert_eq!(
40214025 got.above_right,
40224026 libaom_tr(bw, bh, col_off, row_off, tx, blk.above_right),
crates/ec-av1/src/refusal_inventory.rsmodified+1 -3
@@ -32,15 +32,13 @@ const CAPABILITY_CLAIMS: &[&str] = &[
3232 #[cfg(test)]
3333 const REFUSALS: &[&str] = &[
3434 "a coded HORZ/VERT strip whose chroma transform has no rect coefficient tables here",
35- "a coded 1:4 HORZ_4/VERT_4 strip whose transform splits only once (the unit is still a 2:1 rect, not a square)",
36- "a HORZ/VERT intra strip below 16x16 with a split transform (per-unit rect prediction is not ported)",
35+ "a split intra strip whose transform unit is {tx_w}x{tx_h} (no luma coefficient tables for that shape here)",
3736 "an inter partition below 8x8 (this decoder codes no inter leaf smaller than 8x8; lane-sub8 scoped to intra)",
3837 "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)",
3938 "a 1:4 rect strip that actually uses a palette (reconstruction is not ported at this shape)",
4039 "a 16x16 block whose true edge cuts through both axes needs a rectangular transform this decoder does not code yet",
4140 "a 16x16 inter block whose true edge cuts through both axes needs a rectangular transform this decoder does not code yet",
4241 "a 32x32 partition type this decoder does not code (value={part32})",
43- "a 32x32-level 1:4 strip with a split transform (per-unit 4:1 prediction is not ported, depth={depth})",
4442 "a Golomb tail longer than this decoder reads",
4543 "a tx_type symbol outside its CDF's own set: {t}",
4644 "an INTER 32x32 partition type this decoder does not code (value={part32})",
crates/ec-av1/src/stream.rsmodified+120 -58
@@ -9282,22 +9282,26 @@ mod tests {
92829282 attempts.iter().filter(|a| !a.tx_size_search).count(),
92839283 "{NAME}: every fixed-transform attempt must decode and compare"
92849284 );
9285- // The tx-size-search attempts cannot be compared pixel by pixel yet:
9286- // every 16x16 AB partition contains a strip, and with a free
9287- // transform size aomenc splits at least one of them in every stream
9288- // of a 40-cell {source, cq} sweep (r2 report), so they all stop at
9289- // lane-rectx's "strip with a split transform" refusal (or the 1:4 /
9290- // sub-8x8 ones) before the frame is done. What they DO prove is that
9291- // the TX4 sub-grid of an 8x8 square inside a VERT_A/VERT_B is reached
9292- // on a real stream and answers -- it used to panic there, and a panic
9293- // cannot be tolerated by the `unsupported` arm above. The values it
9294- // answers are pinned separately against libaom in
9295- // `of_tu_keeps_the_ordinary_answer_and_uses_the_block_row_under_vert_ab`.
9296- let _ = tx4_compared;
9297- assert!(
9298- tx4_reached > 0,
9299- "{NAME}: no --enable-tx-size-search=1 attempt reached a TX4 unit inside a \
9300- vertical AB partition -- the r2 panic path is unproven"
9285+ // Until the lane-rectsplitx merge every tx-size-search attempt stopped
9286+ // at "a HORZ/VERT intra strip below 16x16 with a split transform", so
9287+ // this gate could only claim that the TX4 sub-grid of an 8x8 square
9288+ // inside a VERT_A/VERT_B was REACHED (`tx4_reached`, counted even on a
9289+ // refused attempt). With per-TU rect prediction those same attempts now
9290+ // decode to the end and compare pixel-exact, and they carry no vert-AB
9291+ // TX4 unit at all -- the pre-merge nonzero count came from decodes that
9292+ // were still desynced when they hit the refusal (class
9293+ // counter-from-refused-stream). The full pixel compare is the stronger
9294+ // claim and replaces it; the lookup's VALUES stay pinned against libaom
9295+ // in `of_tu_keeps_the_ordinary_answer_and_uses_the_block_row_under_vert_ab`.
9296+ eprintln!("{NAME}: vert-AB TX4 units reached across tx-size-search attempts: {tx4_reached}");
9297+ let _ = tx4_reached;
9298+ assert_eq!(
9299+ tx4_compared,
9300+ attempts.iter().filter(|a| a.tx_size_search).count(),
9301+ "{NAME}: every --enable-tx-size-search=1 attempt must now decode to the end and \
9302+ compare pixel-exact (the split-transform strip refusal these used to stop at is \
9303+ lifted); the vert-AB TX4 lookup values stay pinned by \
9304+ `of_tu_keeps_the_ordinary_answer_and_uses_the_block_row_under_vert_ab`"
93019305 );
93029306 for (i, arm) in ["HORZ_A", "HORZ_B", "VERT_A", "VERT_B"].iter().enumerate() {
93039307 assert!(arms[i] > 0, "{NAME}: PARTITION_{arm} at 16x16 never fired across {compared} \
@@ -12927,7 +12931,7 @@ mod tests {
1292712931 /// `encode::tests::every_rect_shape_reaches_what_libaom_says_over_the_whole_superblock`
1292812932 /// against libaom's own `has_tr_*`/`has_bl_*` arrays.
1292912933 #[test]
12930- #[ignore = "the coded 16x8/8x16 strip is a live refusal; see the doc above"]
12934+ #[ignore = "lane-rectsplitx r2 (re-measured after the neighbour-mode fix): every seed 700..739 attempt now stops at another lane's refusal 'a HORZ_A/HORZ_B/VERT_A partition below 16x16', so the gate reaches no strip at all -- blocked on AB partitions below 16x16, not on this lane"]
1293112935 fn a_directional_16x8_strip_reads_the_right_above_right_samples() {
1293212936 const NAME: &str = "a_directional_16x8_strip_reads_the_right_above_right_samples";
1293312937 if !have_ffmpeg() {
@@ -16180,17 +16184,15 @@ mod tests {
1618016184 }
1618116185
1618216186 /// lane-fistrip r1, the 10-bit arm of the strip gate (his films are
16183- /// yuv420p10le). Same ceiling as its 8-bit twin -- kept `#[ignore]`d
16184- /// with the measurement rather than weakened: MEASURED over seeds
16187+ /// yuv420p10le). Same ceiling as its 8-bit twin, lifted in lane-rectsplitx
16188+ /// r3 (the split arm's `smooth_neighbor_uv`); before that, MEASURED over seeds
1618516189 /// 42..61 the 8x16/16x8 strips aomenc writes filter intra on are
1618616190 /// `skip=0`, which `decode_leaf_rect` refuses, so
1618716191 /// `filter_intra_rect_sub16_hits` never reaches a pixel compare.
1618816192 /// lane-fistrip r2 adds seeds 49 and 213 to the window: those are the two
1618916193 /// seeds measured to fire the feature on the 8-BIT twin's recipe (this
1619016194 /// arm's 10-bit encode is a different stream, so they are a widening, not
16191- /// a measured firing set for this recipe -- the round that un-ignores
16192- /// this gate must re-measure which 10-bit seeds fire it).
16193- #[ignore = "2026-09-02, re-measured on the merged tree: the coded-strip refusal is lifted, but every firing 10-bit seed now stops at the sub16 SPLIT-TRANSFORM refusal (49, 55) or palette-in-screen-content (45, 46); 16 attempts decode pixel-exact with 0 hits, so the gate would prove nothing"]
16195+ /// a measured firing set for this recipe). Green since r3.
1619416196 #[test]
1619516197 fn a_real_aomenc_10bit_filter_intra_on_a_sub16_strip_decodes_pixel_exact() {
1619616198 const NAME: &str = "a_real_aomenc_10bit_filter_intra_on_a_sub16_strip_decodes_pixel_exact";
@@ -16273,29 +16275,40 @@ mod tests {
1627316275 .join("fixtures/filter_intra_8x16_strip_seed49.obu");
1627416276 let stream = std::fs::read(&path)
1627516277 .unwrap_or_else(|e| panic!("{NAME}: reading {}: {e}", path.display()));
16278+ if !have_ffmpeg() {
16279+ eprintln!("SKIP {NAME}: no ffmpeg");
16280+ return;
16281+ }
1627616282 let before = crate::decode::filter_intra_rect_sub16_hits();
16277- let err = decode_stream(&stream).expect_err(
16278- "{NAME}: this stream's 16x8 filter-intra strip is skip=0, which this decoder \
16279- still refuses -- a clean decode means the coded-strip ceiling moved and this \
16280- test should become a pixel compare",
16281- );
16283+ // lane-rectsplitx r1: the ceiling this fixture used to stop at (a
16284+ // sub-16 strip with a SPLIT transform) is ported, so the pinned
16285+ // stream is now a full pixel compare -- what the doc above said this
16286+ // test should become the round that ceiling lifted.
16287+ let frames = decode_stream(&stream)
16288+ .unwrap_or_else(|e| panic!("{NAME}: decode refused: {e}"));
1628216289 let hits = crate::decode::filter_intra_rect_sub16_hits() - before;
16290+ // TWO now, not the one the truncated decode used to see: the frame
16291+ // no longer stops at the first filter-intra strip, so the second one
16292+ // later in the tile is reached as well (and the pixel compare below
16293+ // proves both reconstructed right).
1628316294 assert_eq!(
16284- hits, 1,
16285- "{NAME}: expected exactly one 16x8 strip to read use_filter_intra=1 (aomdec's own \
16286- EC_TRACE_MODE shows four BLOCK_16X8 DC_PRED leaves here); got {hits}"
16295+ hits, 2,
16296+ "{NAME}: expected both 16x8 strips to read use_filter_intra=1; got {hits}"
1628716297 );
16288- let msg = err.to_string();
16298+ // This is also the GATE for the sub-16 split-transform lift: both
16299+ // strips split their transform (`tx_depth != 0` on a BLOCK_16X8 ->
16300+ // two TX_8X8 units), which is the refusal this round removed.
16301+ let splits = crate::decode::sub16_split_hits();
1628916302 assert!(
16290- // 2026-09-02, merging lane-fistrip onto a main that already carries
16291- // lane-rectx: the coded-strip ceiling this fixture used to hit is
16292- // gone, and the very next one on the SAME block is the split
16293- // transform under a sub-16 strip (per-unit rect prediction is not
16294- // ported). Still a refusal ON that block, still not a desync.
16295- msg.contains("a HORZ/VERT intra strip below 16x16 with a split transform"),
16296- "{NAME}: decode must reach the sub16 split-transform ceiling ON that block, not \
16297- wander off a desynced stream; got: {msg}"
16303+ splits > 0,
16304+ "{NAME}: no sub-16 strip split its transform -- the fixture no longer proves the \
16305+ per-unit path this test gates"
1629816306 );
16307+ let ffmpeg_frames = ffmpeg_decode_sequence(&stream, 192, 128, 1);
16308+ assert_eq!(frames.len(), 1, "{NAME}: expected one frame");
16309+ assert_eq!(frames[0].y, ffmpeg_frames[0].y, "{NAME}: luma vs ffmpeg");
16310+ assert_eq!(frames[0].u, ffmpeg_frames[0].u, "{NAME}: U vs ffmpeg");
16311+ assert_eq!(frames[0].v, ffmpeg_frames[0].v, "{NAME}: V vs ffmpeg");
1629916312 }
1630016313
1630116314 /// lane-fistrip r1: the filter-intra strip gate above, one partition
@@ -16311,19 +16324,20 @@ mod tests {
1631116324 /// `filter_intra_rect_hits`: a 32x16 strip firing filter intra would
1631216325 /// satisfy that one and prove nothing about the new shapes.
1631316326 /// MEASURED (lane-fistrip r1, seeds 42..=241; r2 re-ran 50..=241), which
16314- /// is why it is `#[ignore]`d rather than green: over those 200 seeds at
16327+ /// is why the window carries the two firing seeds: over those 200 seeds at
1631516328 /// cq 25 aomenc put filter intra on an 8x16/16x8 strip exactly TWICE --
1631616329 /// **seed 49 and seed 213** -- and both times that strip was `skip=0`, so
1631716330 /// the attempt refused at the coded-rect-strip-below-16x16 ceiling before
1631816331 /// any pixel compare (r1: 177 pixel-exact matches, 23 refusals, compared
1631916332 /// sub16 delta 0, all-attempt delta 2; r2 seeds 50..=241: 172 matches, 20
1632016333 /// refusals, the one all-attempt hit at seed 213). BOTH firing seeds are
16321- /// appended to this gate's seed window below, so the un-ignore compares
16322- /// two real hits. Un-ignore this the round that ceiling lifts; the symbol
16323- /// itself is pinned by
16324- /// [`a_pinned_aomenc_16x8_strip_reads_its_use_filter_intra_flag`], whose
16325- /// `expect_err` must become a pixel compare in that same round.
16326- #[ignore = "2026-09-02, re-measured on the merged tree: 35 of 41 attempts decode pixel-exact with ZERO mismatches, but both firing seeds (49, 213) stop at the sub16 split-transform / HORZ_A-B refusals, so no filter-intra 8x16/16x8 strip is compared yet"]
16334+ /// appended to this gate's seed window below, so it compares two real
16335+ /// hits. UN-IGNORED lane-rectsplitx r3: the ceiling lifted with the split
16336+ /// refusal, and the residual chroma defect was the split arm of
16337+ /// [`crate::decode::decode_leaf_rect`] passing `smooth_neighbor_uv: false`
16338+ /// where the unsplit arm passes the neighbour's real answer. The symbol
16339+ /// itself stays pinned by
16340+ /// [`a_pinned_aomenc_16x8_strip_reads_its_use_filter_intra_flag`].
1632716341 #[test]
1632816342 fn a_real_aomenc_stream_with_filter_intra_on_a_sub16_horz_vert_strip_decodes_pixel_exact() {
1632916343 const NAME: &str =
@@ -17408,8 +17422,18 @@ mod tests {
1740817422 let mut named_refusals = 0u32;
1740917423 let mut matched = 0u32;
1741017424 let (mut horz_proved, mut vert_proved, mut coeff_proved) = (0usize, 0usize, 0usize);
17425+ let (mut depth1_proved, mut depth2_proved) = (0usize, 0usize);
1741117426 let (mut out_of_scope, mut out_of_scope_mismatch) = (0u32, 0u32);
17412- for attempt in 0..n_attempts {
17427+ // lane-rectsplitx r1: the SECOND half of the attempt window turns
17428+ // `--enable-tx-size-search` ON at low cq, which is what makes a
17429+ // 32-level 1:4 strip SPLIT its transform -- depth 1 is the 2:1
17430+ // rect unit TX_16X8/TX_8X16 (`sub_tx_size_map[TX_32X8]`), depth 2
17431+ // the square TX_8X8, and the two interleave across attempts, so
17432+ // both are asserted (a depth-2-only run leaves the rect-unit path
17433+ // unproved).
17434+ for attempt in 0..n_attempts * 2 {
17435+ let tx_search = attempt >= n_attempts;
17436+ let attempt = attempt % n_attempts;
1741317437 let seed = 42 + attempt;
1741417438 let duration = frame_count as f64 / 25.0;
1741517439 // 8-pixel bands: a 32x8 strip is flat, a 32x16 one is not, so
@@ -17428,7 +17452,13 @@ mod tests {
1742817452 geq=lum='mod(floor({axis}/8)*{step},256)',\
1742917453 noise=alls={noise}:all_seed={seed},format=yuv420p"
1743017454 );
17431- let cq_level = format!("--cq-level={}", if attempt % 4 < 2 { 32 } else { 45 });
17455+ let cq_level = if tx_search {
17456+ // 12..28: the window measured to fire both split depths on
17457+ // this fixture (lanes/tx64x16-r4.handoff.md).
17458+ format!("--cq-level={}", 12 + (attempt % 4) * 5)
17459+ } else {
17460+ format!("--cq-level={}", if attempt % 4 < 2 { 32 } else { 45 })
17461+ };
1743217462 let pix_fmt = if bit_depth == 10 { "yuv420p10le" } else { "yuv420p" };
1743317463 let y4m = Command::new("ffmpeg")
1743417464 .args([
@@ -17469,7 +17499,11 @@ mod tests {
1746917499 "--enable-filter-intra=0",
1747017500 "--enable-cfl-intra=0",
1747117501 "--enable-intrabc=0",
17472- "--enable-tx-size-search=0",
17502+ if tx_search {
17503+ "--enable-tx-size-search=1"
17504+ } else {
17505+ "--enable-tx-size-search=0"
17506+ },
1747317507 "--obu",
1747417508 "-o",
1747517509 "-",
@@ -17500,6 +17534,7 @@ mod tests {
1750017534 crate::decode::rect4_32_vert_hits(),
1750117535 crate::decode::rect4_coeff_hits(),
1750217536 );
17537+ let split_before = crate::decode::rect4_split_depth_hits();
1750317538 let frames = match decode_stream(&stream) {
1750417539 Err(e) => {
1750517540 let msg = e.to_string();
@@ -17519,6 +17554,8 @@ mod tests {
1751917554 crate::decode::rect4_32_vert_hits() - before.1,
1752017555 crate::decode::rect4_coeff_hits() - before.2,
1752117556 );
17557+ let split_now = crate::decode::rect4_split_depth_hits();
17558+ let (d1, d2) = (split_now.0 - split_before.0, split_now.1 - split_before.1);
1752217559 let ffmpeg_frames = if bit_depth == 10 {
1752317560 ffmpeg_decode_sequence_10bit(&stream, width, height, frame_count)
1752417561 } else {
@@ -17569,6 +17606,8 @@ mod tests {
1756917606 horz_proved += horz;
1757017607 vert_proved += vert;
1757117608 coeff_proved += coeff;
17609+ depth1_proved += d1;
17610+ depth2_proved += d2;
1757217611 matched += 1;
1757317612 }
1757417613 assert!(
@@ -17592,6 +17631,25 @@ mod tests {
1759217631 strips={vert_proved}, coded strips={coeff_proved}, {out_of_scope} attempts \
1759317632 carried no 32-level 1:4 block ({out_of_scope_mismatch} mismatched)"
1759417633 );
17634+ // The split-transform halves of the window: both tx depths must
17635+ // have fired inside an attempt that then compared pixel-exact
17636+ // (class counter-from-refused-stream -- a global counter would
17637+ // count strips of attempts that later refused).
17638+ // lane-rectsplitx r2: BOTH depths are now decoded, so both are
17639+ // HARD-asserted -- depth 1 is the 2:1 rect unit
17640+ // (`sub_tx_size_map[TX_32X8] == TX_16X8`), depth 2 the square
17641+ // TX_8X8, and they interleave across the window; a run that only
17642+ // reached one of them proves half the walk.
17643+ assert!(
17644+ depth1_proved > 0 && depth2_proved > 0,
17645+ "{NAME}: {bit_depth}-bit: a 1:4 split-transform depth never fired inside a \
17646+ pixel-exact attempt (depth1={depth1_proved}, depth2={depth2_proved}) -- the \
17647+ tx-size-search half of the window proved nothing"
17648+ );
17649+ eprintln!(
17650+ "{NAME}: {bit_depth}-bit split-transform 1:4 strips: depth1={depth1_proved}, \
17651+ depth2={depth2_proved}"
17652+ );
1759517653 assert_eq!(
1759617654 out_of_scope_mismatch, 0,
1759717655 "{NAME}: {bit_depth}-bit: {out_of_scope_mismatch} attempt(s) with zero 32-level \
@@ -18305,9 +18363,14 @@ mod tests {
1830518363 // 10-bit half has to carry the shape on its own.
1830618364 let mut rect4_strips_10bit = 0usize;
1830718365 let (mut out_of_scope, mut out_of_scope_mismatch) = (0u32, 0u32);
18308- // Attempts that stopped at the new named refusal for a 1:4 strip
18309- // whose transform splits once (see the assert at the end).
18310- let mut depth1_refusals = 0u32;
18366+ // 1:4 strips whose transform splits ONCE (the unit is still a 2:1
18367+ // rect) that decoded and compared pixel-exact. Until the rectsplitx
18368+ // merge this shape was refused by name and the gate counted the
18369+ // REFUSALS; counting the decoded hits instead keeps the same
18370+ // territory claim now that the capability landed (class
18371+ // counter-from-refused-stream: only attempts that compared exact
18372+ // count).
18373+ let mut depth1_decoded = 0usize;
1831118374 for (bit_depth, cq) in [(8u32, 45u32), (8, 32), (8, 60), (10, 45), (10, 32), (10, 60)] {
1831218375 for attempt in 0..n_attempts {
1831318376 let seed = 42 + attempt;
@@ -18317,6 +18380,7 @@ mod tests {
1831718380 let stream = rectchroma_stream(bit_depth, cq, attempt, width, height);
1831818381 let before = crate::decode::rect_split_chroma_shape_hits();
1831918382 let split_before = crate::decode::rect_split_tx_hits();
18383+ let depth1_before = crate::decode::rect4_split_depth_hits().0;
1832018384 let rect4_before = (
1832118385 crate::decode::sb_rect4_horz_hits(),
1832218386 crate::decode::sb_rect4_vert_hits(),
@@ -18330,9 +18394,6 @@ mod tests {
1833018394 {seed}): {msg}"
1833118395 );
1833218396 refusals += 1;
18333- if msg.contains("splits only once") {
18334- depth1_refusals += 1;
18335- }
1833618397 all_rect4 += (crate::decode::sb_rect4_horz_hits() - rect4_before.0)
1833718398 + (crate::decode::sb_rect4_vert_hits() - rect4_before.1);
1833818399 let r4 = (crate::decode::sb_rect4_horz_hits() - rect4_before.0)
@@ -18402,6 +18463,7 @@ mod tests {
1840218463 proved[k] += after[k] - before[k];
1840318464 }
1840418465 split_strips += crate::decode::rect_split_tx_hits() - split_before;
18466+ depth1_decoded += crate::decode::rect4_split_depth_hits().0 - depth1_before;
1840518467 let rect4 = (crate::decode::sb_rect4_horz_hits() - rect4_before.0)
1840618468 + (crate::decode::sb_rect4_vert_hits() - rect4_before.1);
1840718469 rect4_strips += rect4;
@@ -18454,11 +18516,11 @@ mod tests {
1845418516 // tables this round wired are in place for it). This assert is what
1845518517 // keeps that from silently regressing to a wrong-pixel decode.
1845618518 assert!(
18457- depth1_refusals > 0,
18458- "{NAME}: no attempt reached a depth-1 1:4 split strip -- the recipe no longer \
18519+ depth1_decoded > 0,
18520+ "{NAME}: no attempt decoded a depth-1 1:4 split strip -- the recipe no longer \
1845918521 covers the shape this round fixed"
1846018522 );
18461- eprintln!("{NAME}: {depth1_refusals} attempts refused the depth-1 1:4 split strip by name");
18523+ eprintln!("{NAME}: {depth1_decoded} depth-1 1:4 split strips decoded pixel-exact");
1846218524 }
1846318525
1846418526 /// The chroma-rect gate's fixture + aomenc recipe for one attempt, shared
lanes/rectsplitx-r1.report.mdadded+105 -0
@@ -0,0 +1,105 @@
1+# lane-rectsplitx r1 report
2+
3+Branch `lane-rectsplitx` off main `8262b99`.
4+
5+## What changed
6+
7+- `crates/ec-av1/src/decode.rs`
8+ - `decode_rect_split` is now **mi-granular** (`at_mi`) and takes the transform
9+ unit as `(tx_w, tx_h)` instead of one square `tx`: it can name a strip that
10+ starts 8 px into a 16-px `SUB` cell, and it walks rectangular units.
11+ Chroma map gained `(32,8)/(8,32)` (`Chroma16`), `(16,4)/(4,16)` (`Chroma8`)
12+ and `(8,4)/(4,8)` (`ChromaRect8x4`).
13+ - new `depth_to_tx_wh(bw, bh, depth)` -- libaom `depth_to_tx_size`: every
14+ `sub_tx_size_map` entry halves the LONGER side of a rect and both sides of
15+ a square, so a 1:4 strip's first split is still a 2:1 RECT unit
16+ (`TX_32X8 -> TX_16X8`, `TX_64X16 -> TX_32X16`). Replaces the
17+ `bw.min(bh) >> (depth - 1)` formula at BOTH 2:1 call sites; it is the same
18+ root cause lane-rectchroma measured mis-tiling a depth-1 64x16 strip, fixed
19+ once for every caller instead of per shape.
20+ - new `tx_type_mode_row(mode, filter_intra)` -- the `fimode_to_intradir` row
21+ rule main `1a89ed9` fixed inside `read_plane`, now also applied to
22+ `decode_leaf_rect`'s rect luma coefficient read (same defect class, sibling
23+ site found by sweeping every `cdfs.txb(<luma set>, mode)` call: the other
24+ luma rect sets are `tx_size_sqr_up >= TX_32X32`, i.e. DCT-only, no symbol).
25+ - **`decode_leaf_rect` read the wrong tx_size CDF category**: BLOCK_16X8 /
26+ BLOCK_8X16 are `bsize_to_tx_size_cat == 1` (libaom
27+ `bsize_to_tx_size_depth_table`), not the 2 the 32x16 strips use. Same
28+ symbol count, different CDF row -- a wrong-table read of a real symbol.
29+ - `decode_leaf_rect`'s split refusal is **lifted**: a 16x8/8x16 strip with
30+ `tx_depth != 0` decodes per transform unit (TX_8X8 at depth 1, TX_4X4 at
31+ depth 2).
32+ - `Neighbours`: `record_mi_luma_rect`, `luma_skip_ctx_rect`,
33+ `record_split_luma_rect_mi` (coarse mode/side cells stamped with
34+ `div_ceil`, so an 8-px-tall strip stamps the cell it touches).
35+- `crates/ec-av1/src/stream.rs`
36+ - `a_pinned_aomenc_16x8_strip_reads_its_use_filter_intra_flag` is now a PIXEL
37+ COMPARE (was `expect_err`) and additionally asserts `sub16_split_hits > 0`:
38+ it is the gate for the sub-16 split lift.
39+ - the 32x32-level 1:4 gate gained a `--enable-tx-size-search=1` half of its
40+ attempt window (cq 12..28), which keeps the 1:4 split refusals honest.
41+- `crates/ec-av1/src/refusal_inventory.rs` updated (one refusal removed, two
42+ added).
43+
44+## Refusals
45+
46+Lifted: "a HORZ/VERT intra strip below 16x16 with a split transform (per-unit
47+rect prediction is not ported)".
48+
49+Added (both MEASURED, not speculative):
50+- "a split intra strip whose transform unit is the rect {tx_w}x{tx_h} ..." --
51+ the per-unit RECT walk (depth 1 of a 1:4 strip) is implemented but mismatched
52+ ffmpeg on the band fixture (8-bit, cq 12, seed 42), so it refuses instead of
53+ shipping wrong pixels.
54+- "a split intra strip whose transform unit is {tx_w}x{tx_h} (no luma
55+ coefficient tables ...)" -- shape guard for the next caller.
56+
57+Kept: "a 32x32-level 1:4 strip with a split transform (... depth={depth})".
58+Reason: depth 1 fires FIRST in every splitting attempt of the fixture, so no
59+attempt ever reaches a pixel-compared depth-2 strip -- a depth-2-only lift is
60+ungatable, and an ungated lift is not a lift (the tx64x16 r4 handoff predicted
61+exactly this interleaving).
62+
63+## Gates
64+
65+- `a_pinned_aomenc_16x8_strip_reads_its_use_filter_intra_flag` -- **ok**.
66+ EVIDENCE: crates/ec-av1/fixtures/filter_intra_8x16_strip_seed49.obu | cargo
67+ test -p ec-av1 --lib -- a_pinned_aomenc_16x8_strip | whole frame Y+U+V equal
68+ to ffmpeg, filter_intra_rect_sub16 hits 2 (was 1 under the truncated decode),
69+ sub16_split_hits > 0.
70+- `a_real_aomenc_stream_with_a_32x32_level_1to4_partition_decodes_pixel_exact`
71+ -- ok, now over 16 attempts per bit depth (8 with tx-size-search on).
72+ 8-bit: 7 pixel-exact of 8 compared, 9 named refusals, horz_4=64, vert_4=72,
73+ coded=136, 0 out-of-scope mismatches.
74+
75+## Open residue (fix-now for the next round, all MEASURED)
76+
77+1. `deferred(rect-unit defect)` -- the depth-1 RECT transform unit (TX_16X8 /
78+ TX_32X16) mismatches ffmpeg; code is wired and refused by one `if tx_w !=
79+ tx_h` in `decode_rect_split`. Deleting that one line + the 1:4 caller's twin
80+ is the whole re-lift. Reproduce: the 1:4 gate with the tx-search half and
81+ the refusal removed, 8-bit cq 12 seed 42.
82+2. `deferred(chroma defect behind the lifted refusal)` --
83+ `a_real_aomenc_stream_with_filter_intra_on_a_sub16_horz_vert_strip_decodes_pixel_exact`
84+ now decodes seed 55 instead of refusing and mismatches on the **U plane**
85+ only; `#[ignore]`d with that measurement.
86+3. `deferred(same)` -- `a_directional_16x8_strip_reads_the_right_above_right_samples`
87+ decodes now and mismatches LUMA at seed 700 cq 45 with 0 reaching strips;
88+ `#[ignore]`d with that measurement. Class refusal-hides-a-defect: both are
89+ defects the split refusal was covering, not regressions of this round.
90+
91+## Films
92+
93+`decode_probe` (release), before -> after:
94+- reelb5.obu: "a 32x32-level 1:4 strip with a split transform (depth=2)" ->
95+ **"a HORZ_A/HORZ_B/VERT_A partition below 16x16"** (another lane's refusal).
96+ The 1:4 depth refusal is still in place, so what moved this film is the
97+ sub-16 split lift plus the `tx_size_cat1` fix -- the extract's 1:4 strips are
98+ reached and decoded (rect4_32: horz=4 coded=4) and the stream now runs on to
99+ a partition shape nobody has ported.
100+ EVIDENCE: reelb5.obu | cargo run --release --example decode_probe -- reelb5.obu |
101+ refusal string changed, rect4_32 horz=4 vert=0 coded=4
102+- hg-head.obu: "filter intra on a HORZ/VERT strip (this decoder predicts
103+ square-only)" (unchanged, another lane).
104+- reelc-head.obu: "an intra block in an inter frame whose tx_depth splits its
105+ luma transform (round 1)" (unchanged, another lane).
lanes/rectsplitx-r2.report.mdadded+102 -0
@@ -0,0 +1,102 @@
1+# lane-rectsplitx r2 report
2+
3+Branch `lane-rectsplitx`, rebased onto main `ce05d5f` (clean), commit `ec0b3b5`.
4+
5+## Root cause (the r1 premise was wrong)
6+
7+r1 refused the depth-1 RECT transform unit (`TX_16X8`/`TX_32X16`) as "measured
8+wrong pixels". It is not the transform unit. Range ladder, band fixture 8-bit
9+cq 12 seed 42 (`EC_TRACE_MODE_STEP=1` ours vs instrumented aomdec):
10+
11+```
12+ours: EC_ISTEP mi_row=4 mi_col=8 name=mode val=11 rng=52576
13+ref : EC_ISTEP mi_row=4 mi_col=8 name=mode val=12 rng=34624
14+ (entry rng identical, 38331, on the preceding dq line)
15+```
16+
17+Same entry range, different value => a different `kf_y_mode` CDF row => the
18+neighbour MODE, not the transform. Three defects, all in the neighbour bands:
19+
20+1. `decode.rs` `decode_block_rect4` unsplit arm never wrote the mi-exact
21+ mode/uv maps (`record_mode_mi`/`record_uv_mode_mi`); only the split arm did
22+ (via `record_mi_luma_rect`). So `mode_left_mi` returned `None` and the
23+ coarse 16x16 cell answered -- holding the LAST of the four 32x8 strips.
24+2. New `Neighbours::modes_above_left_mi` (decode.rs, above `modes_above_left`):
25+ mi-exact AND availability-correct. Four 32x8 strips at tile column 0 share
26+ one `left_mode` cell, so strip 2 read strip 1's mode as its "left" where
27+ libaom has no left neighbour at all (measured at mi(10,0): ours left=2,
28+ libaom DC). Class swept into `decode_leaf_rect` and `decode_leaf8`.
29+3. `decode_block_rect4` asked `smooth_uv_neighbour(r*(SUB/MI), c*(SUB/MI), ..)`
30+ -- the SUB cell's top-left mi, not the strip's real mi (a 1:4 strip starts
31+ 8 px into a 16-px cell). Chroma-only defect: seed 43 VERT_4 had luma
32+ bit-exact with U/V wrong.
33+
34+## Evidence
35+
36+EVIDENCE: scratchpad/s42.obu (sha256 7d578ff5deb0c6ec1ac7142ac0b73dcbdf702417da7868448bada17b4cb07e18) | aomenc band fixture 192x128 8-bit cq12 seed42 --enable-tx-size-search=1, EC_AV1_PREFILT_DUMP ours vs aomdec | 22986 luma + 5293 U diffs -> 0 (byte-identical 36864-byte dumps), rect4_32 horz=92 coded=92
37+EVIDENCE: scratchpad/s43_17.obu | same recipe, axis X (VERT_4), seed43 cq17 | luma 0 diffs / U 39 / V 150 -> byte-identical after the `smooth_uv_neighbour` mi fix, rect4_32 vert=88 coded=88
38+
39+## Gate
40+
41+`a_real_aomenc_stream_with_a_32x32_level_1to4_partition_decodes_pixel_exact`
42+now HARD-asserts `depth1_proved > 0 && depth2_proved > 0` (was
43+`depth1+depth2 == 0`, the refusal-honest form), and both `tx_w != tx_h`
44+refusals are deleted from `decode.rs` + `refusal_inventory.rs`.
45+
46+**This gate is RED as committed.** 8-bit seed 46 (cq 12, tx-size-search on)
47+mismatches CHROMA ONLY: luma bit-exact, U 32 samples and V 173 samples off by
48++-1..2, bounding box U x16..23 y8..15 / V x16..35 y8..24, first wrong sample
49+chroma (16,8) = the 16x4 chroma of the 32x8 strip at luma (32,16). The same
50+seed at cq 32 (tx-size-search OFF) is byte-exact, so it is specific to a
51+strip whose luma transform is SPLIT. Reproducer:
52+
53+```
54+ffmpeg -v error -f lavfi -i "color=c=gray:s=192x128:d=0.04:r=25,format=gray,\
55+geq=lum='mod(floor(Y/8)*91,256)',noise=alls=6:all_seed=46,format=yuv420p" \
56+ -t 0.04 -pix_fmt yuv420p -strict -1 -f yuv4mpegpipe - > src46.y4m
57+aomenc --codec=av1 --passes=1 --end-usage=q --cq-level=12 --cpu-used=0 \
58+ --threads=1 --row-mt=0 --sb-size=64 --bit-depth=8 --input-bit-depth=8 \
59+ --enable-rect-partitions=1 --enable-ab-partitions=0 --enable-1to4-partitions=1 \
60+ --min-partition-size=8 --max-partition-size=32 --enable-restoration=0 \
61+ --enable-palette=0 --deltaq-mode=0 --enable-filter-intra=0 --enable-cfl-intra=0 \
62+ --enable-intrabc=0 --enable-tx-size-search=1 --obu -o s46.obu src46.y4m
63+EC_AV1_PREFILT_DUMP=o cargo run -p ec-av1 --example decode_probe -- s46.obu
64+EC_AV1_PREFILT_DUMP=r aomdec --rawvideo -o /dev/null s46.obu # o.f0 vs r.f0
65+```
66+
67+Entropy is exact through the whole frame (all luma bit-exact), so the residue
68+is chroma RECONSTRUCTION inside `decode_rect_split`'s chroma arm
69+(decode.rs ~5060-5130) -- prediction inputs or the 16x4 inverse, not a symbol.
70+
71+FALLBACK TO GREEN (one edit, if the batch needs a merge before that is found):
72+re-insert `if tx_w != tx_h { return Err(unsupported(..)) }` in
73+`decode_rect_split` (before `let luma_set =`) and in `decode_block_rect4`
74+(before `let which = if depth == 1`), re-add the two strings to
75+`refusal_inventory::REFUSALS`, and flip the gate's depth assert back to
76+`assert_eq!(depth1_proved + depth2_proved, 0, ..)`. The three neighbour-map
77+fixes stay and remain gated by the unsplit half of the same gate.
78+
79+## r1's two ignored gates -- re-measured, both still ignored
80+
81+- `a_real_aomenc_10bit_filter_intra_on_a_sub16_strip_decodes_pixel_exact`
82+ (and its 8-bit twin): still CHROMA-only. 10-bit seed 49 frame 0 plane V,
83+ first diff row 4 col 60, ours 510 vs ffmpeg 509,
84+ `filter_intra_rect_sub16_hits=2`. Ignore text updated with that measurement.
85+ deferred: sub-16 filter-intra chroma prediction -- unblocked by the same
86+ chroma-reconstruction hunt as the seed-46 residue.
87+- `a_directional_16x8_strip_reads_the_right_above_right_samples`: NOT this
88+ lane's defect any more -- every seed 700..739 attempt now stops at another
89+ lane's refusal "a HORZ_A/HORZ_B/VERT_A partition below 16x16", so the gate
90+ reaches no strip at all. deferred: blocked on AB partitions below 16x16.
91+
92+## Films
93+
94+Not re-measured this round (turn cap). r1 measured reelb5.obu moving to
95+"a HORZ_A/HORZ_B/VERT_A partition below 16x16"; the ledger records that no
96+`reelc-head.obu` exists on the box.
97+
98+## Suite
99+
100+`systemd-run --user --unit=rectsplitx-suite-1788313999` ->
101+`$HOME/.cache/rectsplitx-suite-r2.log`. Expected: 1 failure, the 1:4 gate
102+above (the only gate whose assertion this round strengthened).
lanes/rectsplitx-r3.report.mdadded+78 -0
@@ -0,0 +1,78 @@
1+# lane-rectsplitx r3 report
2+
3+Branch `lane-rectsplitx`, commit `58149c8` on top of r2 `eec6a40` (base main
4+`ce05d5f`; main has since moved to `11633d7` -- **not rebased this round**, see
5+"Open").
6+
7+## Root cause (one line of code)
8+
9+`crates/ec-av1/src/decode.rs:5665` -- `decode_leaf_rect`'s SPLIT arm built
10+`RectStripModes { .., smooth_neighbor_uv: false }`, hard-coded, while the
11+unsplit arm two dozen lines below passes the real
12+`neighbours.smooth_uv_neighbour(leaf_mi.0, leaf_mi.1, r, c)` computed at
13+`decode.rs:5637`. So every tx-split 16x8/8x16 leaf predicted its chroma with
14+the intra-edge FILTER TYPE off: luma bit-exact, chroma off by +-1..2 across
15+the block, with the error leaking into the blocks below/right.
16+
17+Class: a split/unsplit pair where the split arm drops a field the unsplit arm
18+passes (sibling of `cdf-row-held-constant` -- a value pinned to a constant
19+where the reference varies it). Sweep: all four `RectStripModes` literals
20+(`decode.rs:5248`, `5656`, `5905`, `6250`) now pass the computed value; that
21+was the only constant one.
22+
23+The charter's suspects (chroma TU geometry, CfL, TX_16X4 dequant/inverse) were
24+all wrong: the failing block is not a 32x8 1:4 strip. `EC_AV1_TRACE` puts a
25+`TRACE_RECT_SPLIT mi_row=4 mi_col=8 bw=16 bh=8 tx=8x8` (and its twin at
26+mi_row=6) exactly over the wrong region -- a 16x16 block split PARTITION_HORZ
27+into two 16x8 strips, each with `tx_depth=1`, chroma 8x4.
28+
29+## Evidence
30+
31+EVIDENCE: scratchpad/r3/s46.obu (sha256 31de47355a098b460975ca0156e0b10cebaacc3c1614d2a8791ece3440c8ba45, generated TWICE identical) | aomenc 192x128 8-bit cq12 seed46 `--enable-tx-size-search=1 --enable-1to4-partitions=1`, `EC_AV1_PREFILT_DUMP` ours vs instrumented aomdec | before: Y 0 diffs, U 32 diffs (all inside chroma cell x16..23 y8..15), V 173; after: `cmp o.f0 r.f0` BYTE-IDENTICAL (36864 bytes)
32+EVIDENCE: scratchpad/r3/trace.txt | `EC_AV1_TRACE=1 decode_probe s46.obu`, grep mi_row=4..7 mi_col=8..11 | `TRACE_RECT_SPLIT mi_row=4 mi_col=8 bw=16 bh=8 tx=8x8` == luma (32,16), the exact 8x8 chroma cell that was wrong
33+
34+## Gates
35+
36+`cargo test -p ec-av1 --lib -- <3 names>` (EC_AV1_REQUIRE_AOMENC=1):
37+`test result: ok. 3 passed; 0 failed` in 21.4s --
38+
39+- `a_real_aomenc_stream_with_a_32x32_level_1to4_partition_decodes_pixel_exact`
40+ (RED as committed in r2, the round's target) -- GREEN, still hard-asserting
41+ `depth1_proved > 0 && depth2_proved > 0`.
42+- `a_real_aomenc_stream_with_filter_intra_on_a_sub16_horz_vert_strip_decodes_pixel_exact`
43+ -- **un-ignored**, GREEN (ignored since lane-fistrip r1).
44+- `a_real_aomenc_10bit_filter_intra_on_a_sub16_strip_decodes_pixel_exact`
45+ -- **un-ignored**, GREEN (his films are 10-bit; this is the 10-bit arm).
46+
47+Both `#[ignore]` attributes and the stale prose in their doc comments are gone
48+in the same commit. No refusal string changed this round (r2 already deleted
49+the two `tx_w != tx_h` ones); `refusal_inventory` and `gate_coverage` stay
50+green in the suite below.
51+
52+## Suite
53+
54+`systemd-run --user --unit=rectsplitx-suite-r3-1788314510 -p MemoryMax=10G` ->
55+`$HOME/.cache/rectsplitx-suite-r3.log`: `test result: ok. 335 passed; 0 failed; 29 ignored; 0 measured; 0 filtered out; finished in 398.99s` (r2 was 1 failed / 31 ignored).
56+
57+## Films (this worktree, not rebased -- other lanes' refusals dominate)
58+
59+- `hg-head.obu`: `filter intra on a HORZ/VERT strip (this decoder predicts square-only)` (unchanged)
60+- `reelc-head.obu`: `an intra block in an inter frame whose tx_depth splits its luma transform (round 1)` (unchanged)
61+- `reelb5.obu`: `a HORZ_A/HORZ_B/VERT_A partition below 16x16` (unchanged; lifted on main by lane-ab16)
62+
63+## Open
64+
65+- deferred: rebase onto main `11633d7` -- this lane is 3 merges behind
66+ (`ce05d5f..11633d7`, palette2/ab16/tiles all touch `decode.rs` hot spots incl.
67+ `Reach::of_tu` arity and a duplicate `FIMODE_TO_INTRADIR` helper per the
68+ ledger). Unblocked by: whoever merges this lane resolving those conflicts;
69+ the fix itself is one field in a struct literal and applies unchanged.
70+- deferred: `reelc-head.obu`'s refusal, "an intra block in an inter frame whose
71+ tx_depth splits its luma transform (round 1)", is this lane's family (the
72+ same split walk, in an inter frame). Unblocked by: an inter-frame gate with
73+ tx-size-search on.
74+- accepted: the coarse-cell `smooth_uv_neighbour(r * (SUB / MI), c * (SUB / MI), ..)`
75+ call form still stands at `decode.rs:5206`, `6197`, `7487`, `15310`. Those
76+ callers are 16px-aligned strips (32x16/64x32) where the SUB cell's mi IS the
77+ strip's mi, so they are correct today -- but a future sub-cell caller would
78+ repeat r2's defect.