forge
Explore
Log in

Don't you dare go Hollow

Per-transform-unit intra prediction inside a rect strip, at mi granularity

Browse files at this commit

c8cc7efd632fb1a73fbaa371045de9e36d8afbc9Ahmet Kaan GümüşParent: 473c744
  • feat
    • per-transform-unit intra prediction inside a rect strip, at mi granularity
Show full message
feat(av1): per-transform-unit intra prediction inside a rect strip, at mi granularity

decode_rect_split now takes an mi position and a (tx_w, tx_h) transform unit, so
it can name strips a coarse 16-px cell cannot (a 32x8 HORZ_4 strip, an 8-px-tall
leaf) and walk rectangular units. New depth_to_tx_wh replaces the
`bw.min(bh) >> (depth - 1)` unit formula at every 2:1 call site: libaom's
sub_tx_size_map halves the LONGER side of a rect, so a 1:4 strip's first split is
still a 2:1 RECT unit (TX_32X8 -> TX_16X8, TX_64X16 -> TX_32X16) -- the same root
cause lane-rectchroma measured mis-tiling a depth-1 64x16 strip, fixed once.

Two real defects found by the sweep:
- decode_leaf_rect read cdfs.tx_size_cat2 for a 16x8/8x16 strip;
  bsize_to_tx_size_cat is 1 for BLOCK_16X8/8X16 (same symbol count, different CDF
  row) -- a wrong-table read of a real symbol.
- its luma tx_type CDF row was the block's raw (always DC_PRED) mode under filter
  intra instead of fimode_to_intradir[filter_intra_mode]; main 1a89ed9 fixed that
  inside read_plane, this is its rect sibling. Extracted as tx_type_mode_row and
  used by both.

Lifts the sub-16 split-transform refusal. GATE: the pinned 16x8 filter-intra
fixture is now a whole-frame pixel compare against ffmpeg (was expect_err) and
asserts sub16_split_hits > 0. ReelB mid-film extract moves from "a
32x32-level 1:4 strip with a split transform (depth=2)" to the unrelated
HORZ_A/B-below-16x16 refusal.

The per-unit RECT walk is implemented but REFUSED by name: it mismatched ffmpeg
on the 1:4 band fixture (8-bit cq 12 seed 42), and since depth 1 fires before
depth 2 in every splitting attempt, the depth-2 half cannot be gated either --
both stay refused. The 1:4 gate gained a --enable-tx-size-search=1 half of its
window that asserts those refusals are reached, never mismatched.

Suite: 321 passed, 0 failed, 30 ignored ($HOME/.cache/rectsplitx-suite.log).
crates/ec-av1/src/decode.rsmodified+402 -64
@@ -1629,6 +1629,30 @@ thread_local! {
16291629 static RECT4_COEFF_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
16301630 }
16311631
1632+// lane-rectsplitx r1: 1:4 strips (32x8/8x32/64x16/16x64) decoded through the
1633+// per-transform-unit split path, split by tx depth -- depth 1 is a 2:1 RECT
1634+// unit (TX_16X8/TX_32X16), depth 2 a square one, and the two INTERLEAVE in
1635+// every real stream, so a gate must prove both fired. `SUB16_SPLIT_HITS`
1636+// counts the same for a 16x8/8x16 strip below 16x16.
1637+thread_local! {
1638+ static RECT4_SPLIT_DEPTH1_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
1639+ static RECT4_SPLIT_DEPTH2_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
1640+ static SUB16_SPLIT_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
1641+}
1642+
1643+/// Current values of `RECT4_SPLIT_DEPTH1_HITS` / `RECT4_SPLIT_DEPTH2_HITS`.
1644+pub(crate) fn rect4_split_depth_hits() -> (usize, usize) {
1645+ (
1646+ RECT4_SPLIT_DEPTH1_HITS.with(|c| c.get()),
1647+ RECT4_SPLIT_DEPTH2_HITS.with(|c| c.get()),
1648+ )
1649+}
1650+
1651+/// Current value of `SUB16_SPLIT_HITS`.
1652+pub(crate) fn sub16_split_hits() -> usize {
1653+ SUB16_SPLIT_HITS.with(|c| c.get())
1654+}
1655+
16321656 /// Current value of `RECT4_COEFF_HITS`.
16331657 pub(crate) fn rect4_coeff_hits() -> usize {
16341658 RECT4_COEFF_HITS.with(|c| c.get())
@@ -3796,11 +3820,26 @@ impl Neighbours {
37963820 /// [`Self::around_mi`]'s plain coded/uncoded bit, this needs the real
37973821 /// cumulative level -- a lone-TU block never calls this (its `txb_skip_ctx`
37983822 /// is always 0, spec's `plane_bsize == tx_size` branch).
3799- fn luma_skip_ctx(&self, (mi_r, mi_c): (usize, usize), side_mi: usize) -> usize {
3823+ fn luma_skip_ctx(&self, at_mi: (usize, usize), side_mi: usize) -> usize {
3824+ self.luma_skip_ctx_rect(at_mi, side_mi, side_mi)
3825+ }
3826+
3827+ /// [`Self::luma_skip_ctx`] with the unit's own width and height in mi
3828+ /// units (lane-rectsplitx r1) -- `get_txb_ctx_general` ORs the above
3829+ /// context over `tx_size_wide` and the left one over `tx_size_high`.
3830+ fn luma_skip_ctx_rect(
3831+ &self,
3832+ (mi_r, mi_c): (usize, usize),
3833+ w_mi: usize,
3834+ h_mi: usize,
3835+ ) -> usize {
3836+ let side_mi = w_mi;
38003837 let mut top = 0u8;
38013838 let mut left = 0u8;
3802- for cell in 0..side_mi {
3839+ for cell in 0..w_mi {
38033840 top |= self.above[mi_c + cell][0].level;
3841+ }
3842+ for cell in 0..h_mi {
38043843 left |= self.left[mi_r + cell][0].level;
38053844 }
38063845 let ctx = SKIP_CONTEXTS[(top as usize).min(4)][(left as usize).min(4)];
@@ -4041,13 +4080,27 @@ impl Neighbours {
40414080 /// Leaves `above_side_mi`/`left_side_mi` and the chroma planes alone --
40424081 /// the caller's own [`Self::record_split_luma`] call sets those once,
40434082 /// at the block's own true side, not this TU's.
4044- fn record_mi_luma(&mut self, (mi_r, mi_c): (usize, usize), tx_px: usize, grid: &[i32]) {
4083+ fn record_mi_luma(&mut self, at_mi: (usize, usize), tx_px: usize, grid: &[i32]) {
4084+ self.record_mi_luma_rect(at_mi, tx_px, tx_px, grid);
4085+ }
4086+
4087+ /// [`Self::record_mi_luma`] for a RECTANGULAR transform unit (lane-rectsplitx
4088+ /// r1): the above context spans the unit's width, the left context its
4089+ /// height, which for a square unit is the same loop it always was.
4090+ fn record_mi_luma_rect(
4091+ &mut self,
4092+ (mi_r, mi_c): (usize, usize),
4093+ w_px: usize,
4094+ h_px: usize,
4095+ grid: &[i32],
4096+ ) {
40454097 let state = neighbour_state(grid);
4046- let side_mi = tx_px / MI;
4047- for cell in 0..side_mi {
4098+ for cell in 0..h_px / MI {
40484099 if mi_r + cell < self.mi_rows {
40494100 self.left[mi_r + cell][0] = state;
40504101 }
4102+ }
4103+ for cell in 0..w_px / MI {
40514104 if mi_c + cell < self.mi_cols {
40524105 self.above[mi_c + cell][0] = state;
40534106 }
@@ -4085,17 +4138,42 @@ impl Neighbours {
40854138 chroma_grids: [&[i32]; 2],
40864139 ) {
40874140 let (r, c) = at;
4088- for cell in 0..w / SUB {
4141+ self.record_split_luma_rect_mi(
4142+ (r * (SUB / MI), c * (SUB / MI)),
4143+ w,
4144+ h,
4145+ mode,
4146+ uv_mode,
4147+ chroma_grids,
4148+ );
4149+ }
4150+
4151+ /// [`Self::record_split_luma_rect`] addressed in mi units (lane-rectsplitx
4152+ /// r1) -- a strip 8 px tall starts mid-[`SUB`]-cell, which the coarse
4153+ /// `(r, c)` form cannot name. The coarse mode/side arrays are stamped for
4154+ /// every cell the strip TOUCHES (`div_ceil`), last writer wins, the
4155+ /// convention [`decode_block_rect4`] already established for 1:4 strips.
4156+ fn record_split_luma_rect_mi(
4157+ &mut self,
4158+ at_mi: (usize, usize),
4159+ w: usize,
4160+ h: usize,
4161+ mode: usize,
4162+ uv_mode: usize,
4163+ chroma_grids: [&[i32]; 2],
4164+ ) {
4165+ let (mi_r, mi_c) = at_mi;
4166+ let (r, c) = (mi_r / (SUB / MI), mi_c / (SUB / MI));
4167+ for cell in 0..w.div_ceil(SUB) {
40894168 self.above_mode[c + cell] = mode;
40904169 self.above_uv_mode[c + cell] = uv_mode;
40914170 self.above_side[c + cell] = w;
40924171 }
4093- for cell in 0..h / SUB {
4172+ for cell in 0..h.div_ceil(SUB) {
40944173 self.left_mode[r + cell] = mode;
40954174 self.left_uv_mode[r + cell] = uv_mode;
40964175 self.left_side[r + cell] = h;
40974176 }
4098- let (mi_r, mi_c) = (r * (SUB / MI), c * (SUB / MI));
40994177 let (w_mi, h_mi) = (w / MI, h / MI);
41004178 self.record_mode_mi(mi_r, mi_c, w_mi, h_mi, mode);
41014179 self.record_uv_mode_mi(mi_r, mi_c, w_mi, h_mi, uv_mode);
@@ -4667,6 +4745,41 @@ struct RectStripModes {
46674745 smooth_neighbor_uv: bool,
46684746 }
46694747
4748+/// The `tx_type` CDF row a luma transform unit reads under `filter_intra`
4749+/// (spec 5.11.47 / libaom `av1_read_tx_type`): `fimode_to_intradir` of the
4750+/// filter-intra mode, never the block's own mode -- which is always
4751+/// `DC_PRED` whenever filter intra is on, so using it desyncs the stream at
4752+/// the first coefficient TU of every filter-intra block (main 1a89ed9 fixed
4753+/// exactly that inside [`read_plane`]; every rect coefficient path needs the
4754+/// same row).
4755+fn tx_type_mode_row(mode: usize, filter_intra: Option<usize>) -> usize {
4756+ const FIMODE_TO_INTRADIR: [usize; 5] = [DC_PRED, V_PRED, H_PRED, D157_PRED, DC_PRED];
4757+ filter_intra.map_or(mode, |fi| FIMODE_TO_INTRADIR[fi])
4758+}
4759+
4760+/// The transform unit size (w, h) of a `bw`x`bh` intra block at tx `depth`
4761+/// -- libaom `depth_to_tx_size`, which walks `sub_tx_size_map` `depth` times
4762+/// from `max_txsize_rect_lookup[bsize]`. Every entry of that map halves the
4763+/// LONGER side of a rectangle and both sides of a square, so a 1:4 strip's
4764+/// first step is a 2:1 rect unit (`TX_32X8 -> TX_16X8`, `TX_64X16 ->
4765+/// TX_32X16`) and only the second reaches a square -- the reason
4766+/// `bw.min(bh) >> (depth - 1)` (correct for a 2:1 strip, where step one is
4767+/// already square) mis-tiled 1:4 strips.
4768+fn depth_to_tx_wh(bw: usize, bh: usize, depth: usize) -> (usize, usize) {
4769+ let (mut w, mut h) = (bw.min(64), bh.min(64));
4770+ for _ in 0..depth {
4771+ match w.cmp(&h) {
4772+ std::cmp::Ordering::Greater => w /= 2,
4773+ std::cmp::Ordering::Less => h /= 2,
4774+ std::cmp::Ordering::Equal => {
4775+ w /= 2;
4776+ h /= 2;
4777+ }
4778+ }
4779+ }
4780+ (w, h)
4781+}
4782+
46704783 /// Decodes the planes of one `bw`x`bh` HORZ/VERT intra strip whose luma
46714784 /// transform is SPLIT (`tx_depth != 0`) -- lane-rectsplit r1, the case every
46724785 /// rect path here refused by name until now ("per-unit rect prediction is not
@@ -4692,10 +4805,15 @@ fn decode_rect_split(
46924805 dec: &mut SymbolDecoder,
46934806 cdfs: &mut Cdfs,
46944807 neighbours: &mut Neighbours,
4695- at: (usize, usize),
4808+ at_mi: (usize, usize),
46964809 bw: usize,
46974810 bh: usize,
4698- tx: usize,
4811+ // The transform unit's own width and height in pixels. Square for every
4812+ // 2:1 strip from the first split on, but a 1:4 strip's FIRST split is
4813+ // still a 2:1 RECT unit (`sub_tx_size_map[TX_32X8] == TX_16X8`,
4814+ // `[TX_64X16] == TX_32X16`) -- see [`depth_to_tx_wh`].
4815+ tx_w: usize,
4816+ tx_h: usize,
46994817 m: &RectStripModes,
47004818 y: &mut PlaneBuf,
47014819 u: &mut PlaneBuf,
@@ -4703,9 +4821,8 @@ fn decode_rect_split(
47034821 base_q_idx: u8,
47044822 reduced_tx_set: bool,
47054823 ) -> Result<()> {
4706- let (r, c) = at;
4707- let (px, py) = (c * SUB, r * SUB);
4708- let (mi_r, mi_c) = (r * (SUB / MI), c * (SUB / MI));
4824+ let (mi_r, mi_c) = at_mi;
4825+ let (px, py) = (mi_c * MI, mi_r * MI);
47094826 let (cpx, cpy) = (px / 2, py / 2);
47104827 let (chroma_w, chroma_h) = (bw / 2, bh / 2);
47114828 // The chroma transform is picked before any symbol is read, so an
@@ -4715,6 +4832,18 @@ fn decode_rect_split(
47154832 (8, 16) => Some((TxbSet::ChromaRect16x8, &SCAN_8X16[..])),
47164833 (32, 16) => Some((TxbSet::ChromaRect32x16, &SCAN_32X16[..])),
47174834 (16, 32) => Some((TxbSet::ChromaRect32x16, &SCAN_16X32[..])),
4835+ // The 1:4 and sub-16 strips (lane-rectsplitx r1). `get_txsize_entropy_ctx`
4836+ // squares a rect transform down to a CDF set by
4837+ // `(wide_log2 + high_log2 + 1) >> 1`: TX_32X8 -> the 16x16 set,
4838+ // TX_16X4 -> the 8x8 set, TX_8X4 -> the 8x8 set -- exactly the sets
4839+ // the UNSPLIT 1:4 (`decode_block_rect4`) and 16x8 (`decode_leaf_rect`)
4840+ // paths already prove for these same shapes.
4841+ (32, 8) => Some((TxbSet::Chroma16, &SCAN_32X8[..])),
4842+ (8, 32) => Some((TxbSet::Chroma16, &SCAN_8X32[..])),
4843+ (16, 4) => Some((TxbSet::Chroma8, &SCAN_16X4[..])),
4844+ (4, 16) => Some((TxbSet::Chroma8, &SCAN_4X16[..])),
4845+ (8, 4) => Some((TxbSet::ChromaRect8x4, &SCAN_8X4[..])),
4846+ (4, 8) => Some((TxbSet::ChromaRect8x4, &SCAN_4X8[..])),
47184847 _ => None,
47194848 };
47204849 // lane-rectsplit r2 (verifier finding): with both callers wired
@@ -4730,21 +4859,56 @@ fn decode_rect_split(
47304859 ));
47314860 }
47324861 RECT_SPLIT_TX_HITS.with(|c| c.set(c.get() + 1));
4733- if bw.max(bh) == 64 && bw / tx > 1 && bh / tx > 1 {
4862+ if bw.max(bh) == 64 && bw / tx_w > 1 && bh / tx_h > 1 {
47344863 RECT_SPLIT_SB_INTERIOR_TU_HITS.with(|c| c.set(c.get() + 1));
47354864 }
47364865 // LUMA: `bw/tx` x `bh/tx` square transform units, raster order.
4737- let luma_set = txbset_for(tx, reduced_tx_set);
4738- let luma_scan = default_scan(tx);
4739- let zero_tu = vec![0i32; tx * tx];
4866+ // A square unit reads through the ordinary square [`read_plane`]; a rect
4867+ // one (a 1:4 strip's first split) reads through [`read_coeffs_rect`] with
4868+ // the very tables the unsplit 16x8/32x16 paths use.
4869+ let luma_rect: Option<(TxbSet, &[u16])> = match (tx_w, tx_h) {
4870+ (w, h) if w == h => None,
4871+ (16, 8) | (8, 16) => Some((
4872+ if reduced_tx_set {
4873+ TxbSet::LumaRect16x8
4874+ } else {
4875+ TxbSet::LumaRect16x8Set1
4876+ },
4877+ if tx_w == 16 { &SCAN_16X8[..] } else { &SCAN_8X16[..] },
4878+ )),
4879+ (32, 16) => Some((TxbSet::LumaRect32x16, &SCAN_32X16[..])),
4880+ (16, 32) => Some((TxbSet::LumaRect32x16, &SCAN_16X32[..])),
4881+ _ => {
4882+ return Err(unsupported(format!(
4883+ "a split intra strip whose transform unit is {tx_w}x{tx_h} (no luma \
4884+ coefficient tables for that shape here)"
4885+ )))
4886+ }
4887+ };
4888+ // lane-rectsplitx r1, MEASURED: the SQUARE-unit walk below is pixel-exact
4889+ // on a real stream (the pinned 16x8 filter-intra fixture decodes its whole
4890+ // frame exactly, two sub-16 split strips in it), but the RECT-unit arm --
4891+ // a 1:4 strip's depth-1 TX_16X8/TX_32X16 -- mismatched ffmpeg on the
4892+ // 32-level 1:4 band fixture (8-bit, cq 12, seed 42). The tables and the
4893+ // per-unit rect walk stay wired above/below; the round that finds that
4894+ // defect deletes this refusal and nothing else.
4895+ if tx_w != tx_h {
4896+ return Err(unsupported(format!(
4897+ "a split intra strip whose transform unit is the rect {tx_w}x{tx_h} (the depth-1 \
4898+ step of a 1:4 strip; measured wrong pixels, refused rather than shipped)"
4899+ )));
4900+ }
4901+ let luma_set = txbset_for(tx_w.min(tx_h), reduced_tx_set);
4902+ let luma_scan = default_scan(tx_w.min(tx_h));
4903+ let zero_tu = vec![0i32; tx_w * tx_h];
47404904 // The strip's OWN edge availability, the fallback for a transform unit
47414905 // whose top-right/bottom-left pixels fall outside the strip.
47424906 let block_reach = Reach::of_rect(bw, bh, px, py, y.width, y.height);
4743- for tu_row in 0..bh / tx {
4744- for tu_col in 0..bw / tx {
4745- let tu_mi = (mi_r + tu_row * (tx / MI), mi_c + tu_col * (tx / MI));
4746- let (tu_px, tu_py) = (px + tu_col * tx, py + tu_row * tx);
4747- let (col_off, row_off) = (tu_col * tx, tu_row * tx);
4907+ for tu_row in 0..bh / tx_h {
4908+ for tu_col in 0..bw / tx_w {
4909+ let tu_mi = (mi_r + tu_row * (tx_h / MI), mi_c + tu_col * (tx_w / MI));
4910+ let (tu_px, tu_py) = (px + tu_col * tx_w, py + tu_row * tx_h);
4911+ let (col_off, row_off) = (tu_col * tx_w, tu_row * tx_h);
47484912 // `has_top_right`/`has_bottom_left` (libaom `reconintra.c`) for a
47494913 // transform unit INSIDE a block, which is a different rule from
47504914 // the standalone-block table [`Reach::of`] applies -- and the
@@ -4761,24 +4925,25 @@ fn decode_rect_split(
47614925 // neighbour's, already reconstructed; the last row falls back
47624926 // to the block-level answer.
47634927 let tu_reach = Reach {
4764- above_right: if col_off + tx < bw {
4928+ above_right: if col_off + tx_w < bw {
47654929 true
47664930 } else {
47674931 row_off == 0 && block_reach.above_right
47684932 },
47694933 below_left: if col_off > 0 {
47704934 false
4771- } else if row_off + tx < bh {
4935+ } else if row_off + tx_h < bh {
47724936 true
47734937 } else {
47744938 block_reach.below_left
47754939 },
47764940 };
47774941 if m.skip {
4778- y.reconstruct(
4942+ y.reconstruct_rect(
47794943 tu_px,
47804944 tu_py,
4781- tx,
4945+ tx_w,
4946+ tx_h,
47824947 m.mode,
47834948 m.angle_delta_y,
47844949 tu_reach,
@@ -4787,13 +4952,57 @@ fn decode_rect_split(
47874952 m.filter_intra,
47884953 m.smooth_neighbor,
47894954 );
4790- neighbours.record_mi_luma(tu_mi, tx, &zero_tu);
4955+ neighbours.record_mi_luma_rect(tu_mi, tx_w, tx_h, &zero_tu);
4956+ } else if let Some((rect_set, rect_scan)) = luma_rect {
4957+ // The rect-unit twin of the square arm below: same contexts,
4958+ // same order, through the rect coefficient reader. The
4959+ // `tx_type` CDF row of a filter-intra block is
4960+ // `fimode_to_intradir[filter_intra_mode]`, never the block's
4961+ // own (always DC_PRED) mode -- [`read_plane`] applies that
4962+ // for the square arm, so this one must too.
4963+ let tu_around = neighbours.around_mi_rect(tu_mi, tx_w, tx_h)[0];
4964+ let tu_skip_ctx = neighbours.luma_skip_ctx_rect(tu_mi, tx_w / MI, tx_h / MI);
4965+ let mut coding = cdfs.txb(rect_set, tx_type_mode_row(m.mode, m.filter_intra));
4966+ let (tu_grid, tu_tx_type) = read_coeffs_rect(
4967+ dec,
4968+ &mut coding,
4969+ rect_scan,
4970+ tx_w,
4971+ tx_h,
4972+ tu_skip_ctx,
4973+ dc_sign_ctx(tu_around.2),
4974+ TxType::DctDct,
4975+ )?;
4976+ let residual = dequant_and_inverse_typed_wh(
4977+ &tu_grid,
4978+ tx_w,
4979+ tx_h,
4980+ crate::decode::bit_depth(),
4981+ block_q_idx(),
4982+ plane_q_delta(0).0,
4983+ plane_q_delta(0).1,
4984+ tu_tx_type,
4985+ );
4986+ y.reconstruct_rect(
4987+ tu_px,
4988+ tu_py,
4989+ tx_w,
4990+ tx_h,
4991+ m.mode,
4992+ m.angle_delta_y,
4993+ tu_reach,
4994+ &residual,
4995+ None,
4996+ m.filter_intra,
4997+ m.smooth_neighbor,
4998+ );
4999+ neighbours.record_mi_luma_rect(tu_mi, tx_w, tx_h, &tu_grid);
47915000 } else {
4792- let tu_around = neighbours.around_mi(tu_mi, tx)[0];
5001+ let tu_around = neighbours.around_mi(tu_mi, tx_w)[0];
47935002 // This unit is smaller than the block it sits in, so
47945003 // `txb_skip_ctx` is the neighbour-magnitude table, not the
47955004 // lone-TU 0 (spec `get_txb_ctx_general`).
4796- let tu_skip_ctx = neighbours.luma_skip_ctx(tu_mi, tx / MI);
5005+ let tu_skip_ctx = neighbours.luma_skip_ctx(tu_mi, tx_w / MI);
47975006 let tu_grid = read_plane(
47985007 dec,
47995008 cdfs,
@@ -4808,15 +5017,15 @@ fn decode_rect_split(
48085017 y,
48095018 tu_px,
48105019 tu_py,
4811- tx,
4812- tx,
5020+ tx_w,
5021+ tx_w,
48135022 base_q_idx,
48145023 None,
48155024 m.filter_intra,
48165025 Some(tu_skip_ctx),
48175026 m.smooth_neighbor,
48185027 )?;
4819- neighbours.record_mi_luma(tu_mi, tx, &tu_grid);
5028+ neighbours.record_mi_luma(tu_mi, tx_w, &tu_grid);
48205029 }
48215030 }
48225031 }
@@ -4844,7 +5053,7 @@ fn decode_rect_split(
48445053 } else {
48455054 default_intra_tx_type(m.uv_predict_mode as u8)
48465055 };
4847- let around = neighbours.around_rect(at, bw, bh);
5056+ let around = neighbours.around_mi_rect(at_mi, bw, bh);
48485057 let mut grids: Vec<Vec<i32>> = Vec::with_capacity(2);
48495058 for plane_idx in 1..=2 {
48505059 let skip_ctx =
@@ -4900,13 +5109,21 @@ fn decode_rect_split(
49005109 let mut it = grids.into_iter();
49015110 (it.next().unwrap(), it.next().unwrap())
49025111 };
4903- neighbours.record_split_luma_rect(at, bw, bh, m.mode, m.uv_predict_mode, [&u_grid, &v_grid]);
5112+ neighbours.record_split_luma_rect_mi(
5113+ at_mi,
5114+ bw,
5115+ bh,
5116+ m.mode,
5117+ m.uv_predict_mode,
5118+ [&u_grid, &v_grid],
5119+ );
49045120 neighbours.fill_skip_grid_rect((mi_r, mi_c), bw / MI, bh / MI, m.skip);
4905- neighbours.fill_lf_grid_rect((mi_r, mi_c), bw / MI, bh / MI, tx as u8, tx as u8, 0);
5121+ neighbours.fill_lf_grid_rect((mi_r, mi_c), bw / MI, bh / MI, tx_w as u8, tx_h as u8, 0);
49065122 if std::env::var_os("EC_AV1_TRACE").is_some() {
49075123 let (rng, _) = dec.debug_state();
49085124 eprintln!(
4909- "TRACE_RECT_SPLIT mi_row={mi_r} mi_col={mi_c} bw={bw} bh={bh} tx={tx} rng={rng}"
5125+ "TRACE_RECT_SPLIT mi_row={mi_r} mi_col={mi_c} bw={bw} bh={bh} \
5126+ tx={tx_w}x{tx_h} rng={rng}"
49105127 );
49115128 }
49125129 Ok(())
@@ -4998,13 +5215,12 @@ fn decode_block_rect(
49985215 // lane-rectsplit r1: a split transform is predicted and reconstructed
49995216 // per transform unit, each unit taking its edges from the previous
50005217 // unit's reconstruction inside this same strip (spec 5.11.36) --
5001- // [`decode_rect_split`]. `depth_to_tx_size` of a 2:1 strip is square
5002- // from the first step on, so `bw.min(bh) >> (depth - 1)` names it.
5003- let tx = bw.min(bh) >> (depth - 1);
5218+ // [`decode_rect_split`], the unit named by [`depth_to_tx_wh`].
5219+ let (tx_w, tx_h) = depth_to_tx_wh(bw, bh, depth);
50045220 if std::env::var_os("EC_SBPART_DUMP64").is_some() {
50055221 eprintln!(
50065222 "DUMP64SPLIT mi_r={mi_r} mi_c={mi_c} px={px} py={py} bw={bw} bh={bh} \
5007- depth={depth} tx={tx} mode={mode} uv={uv_predict_mode} skip={skip} \
5223+ depth={depth} tx={tx_w}x{tx_h} mode={mode} uv={uv_predict_mode} skip={skip} \
50085224 angle_y={angle_delta_y}"
50095225 );
50105226 }
@@ -5020,7 +5236,20 @@ fn decode_block_rect(
50205236 smooth_neighbor_uv,
50215237 };
50225238 decode_rect_split(
5023- dec, cdfs, neighbours, at, bw, bh, tx, &modes, y, u, v, base_q_idx, reduced_tx_set,
5239+ dec,
5240+ cdfs,
5241+ neighbours,
5242+ (mi_r, mi_c),
5243+ bw,
5244+ bh,
5245+ tx_w,
5246+ tx_h,
5247+ &modes,
5248+ y,
5249+ u,
5250+ v,
5251+ base_q_idx,
5252+ reduced_tx_set,
50245253 )?;
50255254 RECT_PARTITION_HITS.with(|c| c.set(c.get() + 1));
50265255 return Ok(());
@@ -5387,15 +5616,50 @@ fn decode_leaf_rect(
53875616 let smooth_neighbor_uv = neighbours.smooth_uv_neighbour(leaf_mi.0, leaf_mi.1, r, c);
53885617 let depth = if tx_select {
53895618 let ctx = tx_size_context_rect(neighbours, leaf_mi, bw, bh);
5390- dec.symbol(&mut cdfs.tx_size_cat2[ctx])
5619+ // lane-rectsplitx r1: `bsize_to_tx_size_cat` (libaom `blockd.h`,
5620+ // `bsize_to_tx_size_depth_table`) is 2 for BLOCK_16X8/BLOCK_8X16, so
5621+ // the category is 1 -- NOT the 2 the 32x16 strips read. Same symbol
5622+ // count (3), different CDF row: a wrong-table read of a real symbol,
5623+ // the class that cost lane-rectsplit r1 its 64x32 depth.
5624+ dec.symbol(&mut cdfs.tx_size_cat1[ctx])
53915625 } else {
53925626 0
53935627 };
53945628 if depth != 0 {
5395- return Err(unsupported(
5396- "a HORZ/VERT intra strip below 16x16 with a split transform (per-unit rect \
5397- prediction is not ported)",
5398- ));
5629+ // The same per-transform-unit walk the bigger strips take
5630+ // (`depth_to_tx_wh`: TX_16X8 -> TX_8X8 at depth 1, -> TX_4X4 at
5631+ // depth 2), addressed at this leaf's own mi position.
5632+ TX_DEPTH_HITS.with(|c| c.set(c.get() + 1));
5633+ SUB16_SPLIT_HITS.with(|c| c.set(c.get() + 1));
5634+ let (tx_w, tx_h) = depth_to_tx_wh(bw, bh, depth);
5635+ let modes = RectStripModes {
5636+ skip,
5637+ mode,
5638+ angle_delta_y,
5639+ uv_predict_mode,
5640+ angle_delta_uv,
5641+ alpha,
5642+ filter_intra,
5643+ smooth_neighbor,
5644+ smooth_neighbor_uv: false,
5645+ };
5646+ decode_rect_split(
5647+ dec,
5648+ cdfs,
5649+ neighbours,
5650+ leaf_mi,
5651+ bw,
5652+ bh,
5653+ tx_w,
5654+ tx_h,
5655+ &modes,
5656+ y,
5657+ u,
5658+ v,
5659+ base_q_idx,
5660+ reduced_tx_set,
5661+ )?;
5662+ return Ok(mode);
53995663 }
54005664 let (px, py) = (leaf_mi.1 * MI, leaf_mi.0 * MI);
54015665 let reach = Reach::of_rect(bw, bh, px, py, y.width, y.height);
@@ -5437,7 +5701,7 @@ fn decode_leaf_rect(
54375701 } else {
54385702 TxbSet::LumaRect16x8Set1
54395703 };
5440- let mut luma_coding = cdfs.txb(luma_set, mode);
5704+ let mut luma_coding = cdfs.txb(luma_set, tx_type_mode_row(mode, filter_intra));
54415705 let (l_levels, luma_tx_type) = read_coeffs_rect(
54425706 dec, &mut luma_coding, luma_scan, bw, bh, 0, dc_sign_ctx(around[0].2), TxType::DctDct,
54435707 )?;
@@ -5585,16 +5849,69 @@ fn decode_block_rect4(
55855849 0
55865850 };
55875851 if depth != 0 {
5588- // lane-tx64x16 r4: the depth is IN the message -- it says which port
5589- // the next round owes. depth 1 of a 4:1 strip is TX_16X8/TX_8X16
5590- // (`sub_tx_size_map[TX_32X8] == TX_16X8`), a RECTANGULAR transform
5591- // unit with no luma coefficient tables here; depth 2 is TX_8X8,
5592- // square, the shape `decode_rect_split` already walks. The film stops
5593- // at depth 2, synthetic band fixtures hit both.
5594- return Err(unsupported(format!(
5595- "a 32x32-level 1:4 strip with a split transform (per-unit 4:1 prediction is not \
5596- ported, depth={depth})"
5597- )));
5852+ // lane-rectsplitx r1: the per-transform-unit walk, at this strip's
5853+ // real mi position (strips 1 and 3 of a HORZ_4 start 8 px into a
5854+ // 16-px [`SUB`] cell). depth 1 is the RECT unit TX_16X8/TX_8X16
5855+ // (`sub_tx_size_map[TX_32X8] == TX_16X8`), depth 2 the square TX_8X8;
5856+ // both interleave in every real stream.
5857+ TX_DEPTH_HITS.with(|c| c.set(c.get() + 1));
5858+ let (tx_w, tx_h) = depth_to_tx_wh(bw, bh, depth);
5859+ // lane-rectsplitx r1 MEASURED (gate below, 8-bit band fixture, cq
5860+ // 12..28): depth 1 -- the 2:1 RECT unit -- fires FIRST in every
5861+ // attempt that splits at all, and its per-unit walk mismatched
5862+ // ffmpeg, so no attempt ever reaches a pixel-compared depth-2 strip.
5863+ // A depth-2-only lift is therefore ungatable (the handoff predicted
5864+ // exactly this: the two depths interleave and must land together),
5865+ // and an ungated lift is not a lift -- both refuse by name until the
5866+ // rect-unit defect is found.
5867+ if tx_w != tx_h {
5868+ return Err(unsupported(format!(
5869+ "a 32x32-level 1:4 strip with a split transform (per-unit 4:1 prediction is \
5870+ not ported, depth={depth})"
5871+ )));
5872+ }
5873+ let which = if depth == 1 {
5874+ &RECT4_SPLIT_DEPTH1_HITS
5875+ } else {
5876+ &RECT4_SPLIT_DEPTH2_HITS
5877+ };
5878+ which.with(|c| c.set(c.get() + 1));
5879+ let modes = RectStripModes {
5880+ skip,
5881+ mode,
5882+ angle_delta_y,
5883+ uv_predict_mode,
5884+ angle_delta_uv,
5885+ alpha,
5886+ filter_intra,
5887+ smooth_neighbor,
5888+ smooth_neighbor_uv,
5889+ };
5890+ decode_rect_split(
5891+ dec,
5892+ cdfs,
5893+ neighbours,
5894+ (mi_r, mi_c),
5895+ bw,
5896+ bh,
5897+ tx_w,
5898+ tx_h,
5899+ &modes,
5900+ y,
5901+ u,
5902+ v,
5903+ base_q_idx,
5904+ false,
5905+ )?;
5906+ if bw > bh {
5907+ RECT4_32_HORZ_HITS.with(|c| c.set(c.get() + 1));
5908+ } else {
5909+ RECT4_32_VERT_HITS.with(|c| c.set(c.get() + 1));
5910+ }
5911+ if !skip {
5912+ RECT4_COEFF_HITS.with(|c| c.set(c.get() + 1));
5913+ }
5914+ return Ok((mode, uv_predict_mode));
55985915 }
55995916 // The coarse (16-px [`SUB`] cell) mode/side arrays cannot name a strip
56005917 // that is 8 px tall, so each strip stamps every cell it touches and the
@@ -5877,13 +6194,22 @@ fn decode_block_rect64(
58776194 TX_DEPTH_HITS.with(|c| c.set(c.get() + 1));
58786195 // lane-rectsplit r1/r4: the superblock-level strip splits its
58796196 // transform through the very same per-unit path as its 32x32-level
5880- // sibling (`sub_tx_size_map[TX_64X32] == TX_32X32`, square from the
5881- // first step on, so `bw.min(bh) >> (depth - 1)` names the unit).
5882- let tx = bw.min(bh) >> (depth - 1);
6197+ // sibling; [`depth_to_tx_wh`] names the unit, which for a 64x16/16x64
6198+ // 1:4 strip is the 2:1 rect TX_32X16 at depth 1 (lane-rectchroma r1
6199+ // measured the old square formula mis-tiling exactly that strip).
6200+ let (tx_w, tx_h) = depth_to_tx_wh(bw, bh, depth);
6201+ if bw.max(bh) / bw.min(bh) == 4 {
6202+ let which = if depth == 1 {
6203+ &RECT4_SPLIT_DEPTH1_HITS
6204+ } else {
6205+ &RECT4_SPLIT_DEPTH2_HITS
6206+ };
6207+ which.with(|c| c.set(c.get() + 1));
6208+ }
58836209 if std::env::var_os("EC_SBPART_DUMP64").is_some() {
58846210 eprintln!(
58856211 "DUMP64SPLIT mi_r={mi_r} mi_c={mi_c} px={px} py={py} bw={bw} bh={bh} \
5886- depth={depth} tx={tx} mode={mode} uv={uv_predict_mode} skip={skip} \
6212+ depth={depth} tx={tx_w}x{tx_h} mode={mode} uv={uv_predict_mode} skip={skip} \
58876213 angle_y={angle_delta_y}"
58886214 );
58896215 }
@@ -5899,7 +6225,20 @@ fn decode_block_rect64(
58996225 smooth_neighbor_uv,
59006226 };
59016227 decode_rect_split(
5902- dec, cdfs, neighbours, at, bw, bh, tx, &modes, y, u, v, base_q_idx, reduced_tx_set,
6228+ dec,
6229+ cdfs,
6230+ neighbours,
6231+ (mi_r, mi_c),
6232+ bw,
6233+ bh,
6234+ tx_w,
6235+ tx_h,
6236+ &modes,
6237+ y,
6238+ u,
6239+ v,
6240+ base_q_idx,
6241+ reduced_tx_set,
59036242 )?;
59046243 RECT_PARTITION_HITS.with(|c| c.set(c.get() + 1));
59056244 return Ok(());
@@ -6948,9 +7287,8 @@ fn read_plane(
69487287 // filter-intra is on) -- caller passes the raw filter-intra mode 0..4 in
69497288 // `filter_intra`, only meaningful for `plane_idx == 0` (chroma has no
69507289 // filter-intra in AV1).
6951- const FIMODE_TO_INTRADIR: [usize; 5] = [DC_PRED, V_PRED, H_PRED, D157_PRED, DC_PRED];
69527290 let tx_mode = if plane_idx == 0 {
6953- filter_intra.map_or(tx_mode, |fi| FIMODE_TO_INTRADIR[fi])
7291+ tx_type_mode_row(tx_mode, filter_intra)
69547292 } else {
69557293 tx_mode
69567294 };
crates/ec-av1/src/refusal_inventory.rsmodified+2 -1
@@ -33,7 +33,8 @@ const CAPABILITY_CLAIMS: &[&str] = &[
3333 const REFUSALS: &[&str] = &[
3434 "a coded (non-skip) HORZ_B/VERT_B rect strip below 16x16 (this decoder ports only the skip case at this size)",
3535 "a coded HORZ/VERT strip whose chroma transform has no rect coefficient tables here",
36- "a HORZ/VERT intra strip below 16x16 with a split transform (per-unit rect prediction is not ported)",
36+ "a split intra strip whose transform unit is {tx_w}x{tx_h} (no luma coefficient tables for that shape here)",
37+ "a split intra strip whose transform unit is the rect {tx_w}x{tx_h} (the depth-1 step of a 1:4 strip; measured wrong pixels, refused rather than shipped)",
3738 "a HORZ_A/HORZ_B/VERT_A partition below 16x16 (this decoder codes only the square arms, HORZ, VERT, VERT_B, and a clean split below 16x16)",
3839 "an inter partition below 8x8 (this decoder codes no inter leaf smaller than 8x8; lane-sub8 scoped to intra)",
3940 "a 16x16 block whose true edge cuts through both axes needs a rectangular transform this decoder does not code yet",
crates/ec-av1/src/stream.rsmodified+81 -23
@@ -11697,7 +11697,7 @@ mod tests {
1169711697 /// `encode::tests::every_rect_shape_reaches_what_libaom_says_over_the_whole_superblock`
1169811698 /// against libaom's own `has_tr_*`/`has_bl_*` arrays.
1169911699 #[test]
11700- #[ignore = "the coded 16x8/8x16 strip is a live refusal; see the doc above"]
11700+ #[ignore = "lane-rectsplitx r1: the sub16 split-transform refusal is lifted and the stream now decodes, but seed 700 cq 45 mismatches ffmpeg on LUMA with 4 strips and 0 of them reaching -- a defect that refusal was hiding, not this gate's own subject"]
1170111701 fn a_directional_16x8_strip_reads_the_right_above_right_samples() {
1170211702 const NAME: &str = "a_directional_16x8_strip_reads_the_right_above_right_samples";
1170311703 if !have_ffmpeg() {
@@ -14960,7 +14960,7 @@ mod tests {
1496014960 /// arm's 10-bit encode is a different stream, so they are a widening, not
1496114961 /// a measured firing set for this recipe -- the round that un-ignores
1496214962 /// this gate must re-measure which 10-bit seeds fire it).
14963- #[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"]
14963+ #[ignore = "lane-rectsplitx r1: the sub16 split-transform refusal is lifted (the pinned 16x8 fixture now decodes its whole frame pixel-exact), but seed 55 mismatches ffmpeg on the U plane -- a chroma defect that refusal was hiding, open"]
1496414964 #[test]
1496514965 fn a_real_aomenc_10bit_filter_intra_on_a_sub16_strip_decodes_pixel_exact() {
1496614966 const NAME: &str = "a_real_aomenc_10bit_filter_intra_on_a_sub16_strip_decodes_pixel_exact";
@@ -15043,29 +15043,40 @@ mod tests {
1504315043 .join("fixtures/filter_intra_8x16_strip_seed49.obu");
1504415044 let stream = std::fs::read(&path)
1504515045 .unwrap_or_else(|e| panic!("{NAME}: reading {}: {e}", path.display()));
15046+ if !have_ffmpeg() {
15047+ eprintln!("SKIP {NAME}: no ffmpeg");
15048+ return;
15049+ }
1504615050 let before = crate::decode::filter_intra_rect_sub16_hits();
15047- let err = decode_stream(&stream).expect_err(
15048- "{NAME}: this stream's 16x8 filter-intra strip is skip=0, which this decoder \
15049- still refuses -- a clean decode means the coded-strip ceiling moved and this \
15050- test should become a pixel compare",
15051- );
15051+ // lane-rectsplitx r1: the ceiling this fixture used to stop at (a
15052+ // sub-16 strip with a SPLIT transform) is ported, so the pinned
15053+ // stream is now a full pixel compare -- what the doc above said this
15054+ // test should become the round that ceiling lifted.
15055+ let frames = decode_stream(&stream)
15056+ .unwrap_or_else(|e| panic!("{NAME}: decode refused: {e}"));
1505215057 let hits = crate::decode::filter_intra_rect_sub16_hits() - before;
15058+ // TWO now, not the one the truncated decode used to see: the frame
15059+ // no longer stops at the first filter-intra strip, so the second one
15060+ // later in the tile is reached as well (and the pixel compare below
15061+ // proves both reconstructed right).
1505315062 assert_eq!(
15054- hits, 1,
15055- "{NAME}: expected exactly one 16x8 strip to read use_filter_intra=1 (aomdec's own \
15056- EC_TRACE_MODE shows four BLOCK_16X8 DC_PRED leaves here); got {hits}"
15063+ hits, 2,
15064+ "{NAME}: expected both 16x8 strips to read use_filter_intra=1; got {hits}"
1505715065 );
15058- let msg = err.to_string();
15066+ // This is also the GATE for the sub-16 split-transform lift: both
15067+ // strips split their transform (`tx_depth != 0` on a BLOCK_16X8 ->
15068+ // two TX_8X8 units), which is the refusal this round removed.
15069+ let splits = crate::decode::sub16_split_hits();
1505915070 assert!(
15060- // 2026-09-02, merging lane-fistrip onto a main that already carries
15061- // lane-rectx: the coded-strip ceiling this fixture used to hit is
15062- // gone, and the very next one on the SAME block is the split
15063- // transform under a sub-16 strip (per-unit rect prediction is not
15064- // ported). Still a refusal ON that block, still not a desync.
15065- msg.contains("a HORZ/VERT intra strip below 16x16 with a split transform"),
15066- "{NAME}: decode must reach the sub16 split-transform ceiling ON that block, not \
15067- wander off a desynced stream; got: {msg}"
15071+ splits > 0,
15072+ "{NAME}: no sub-16 strip split its transform -- the fixture no longer proves the \
15073+ per-unit path this test gates"
1506815074 );
15075+ let ffmpeg_frames = ffmpeg_decode_sequence(&stream, 192, 128, 1);
15076+ assert_eq!(frames.len(), 1, "{NAME}: expected one frame");
15077+ assert_eq!(frames[0].y, ffmpeg_frames[0].y, "{NAME}: luma vs ffmpeg");
15078+ assert_eq!(frames[0].u, ffmpeg_frames[0].u, "{NAME}: U vs ffmpeg");
15079+ assert_eq!(frames[0].v, ffmpeg_frames[0].v, "{NAME}: V vs ffmpeg");
1506915080 }
1507015081
1507115082 /// lane-fistrip r1: the filter-intra strip gate above, one partition
@@ -15093,7 +15104,7 @@ mod tests {
1509315104 /// itself is pinned by
1509415105 /// [`a_pinned_aomenc_16x8_strip_reads_its_use_filter_intra_flag`], whose
1509515106 /// `expect_err` must become a pixel compare in that same round.
15096- #[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"]
15107+ #[ignore = "lane-rectsplitx r1: the sub16 split-transform refusal is lifted (the pinned 16x8 fixture now decodes its whole frame pixel-exact), but seed 55 mismatches ffmpeg on the U plane -- a chroma defect that refusal was hiding, open"]
1509715108 #[test]
1509815109 fn a_real_aomenc_stream_with_filter_intra_on_a_sub16_horz_vert_strip_decodes_pixel_exact() {
1509915110 const NAME: &str =
@@ -16178,8 +16189,18 @@ mod tests {
1617816189 let mut named_refusals = 0u32;
1617916190 let mut matched = 0u32;
1618016191 let (mut horz_proved, mut vert_proved, mut coeff_proved) = (0usize, 0usize, 0usize);
16192+ let (mut depth1_proved, mut depth2_proved) = (0usize, 0usize);
1618116193 let (mut out_of_scope, mut out_of_scope_mismatch) = (0u32, 0u32);
16182- for attempt in 0..n_attempts {
16194+ // lane-rectsplitx r1: the SECOND half of the attempt window turns
16195+ // `--enable-tx-size-search` ON at low cq, which is what makes a
16196+ // 32-level 1:4 strip SPLIT its transform -- depth 1 is the 2:1
16197+ // rect unit TX_16X8/TX_8X16 (`sub_tx_size_map[TX_32X8]`), depth 2
16198+ // the square TX_8X8, and the two interleave across attempts, so
16199+ // both are asserted (a depth-2-only run leaves the rect-unit path
16200+ // unproved).
16201+ for attempt in 0..n_attempts * 2 {
16202+ let tx_search = attempt >= n_attempts;
16203+ let attempt = attempt % n_attempts;
1618316204 let seed = 42 + attempt;
1618416205 let duration = frame_count as f64 / 25.0;
1618516206 // 8-pixel bands: a 32x8 strip is flat, a 32x16 one is not, so
@@ -16198,7 +16219,13 @@ mod tests {
1619816219 geq=lum='mod(floor({axis}/8)*{step},256)',\
1619916220 noise=alls={noise}:all_seed={seed},format=yuv420p"
1620016221 );
16201- let cq_level = format!("--cq-level={}", if attempt % 4 < 2 { 32 } else { 45 });
16222+ let cq_level = if tx_search {
16223+ // 12..28: the window measured to fire both split depths on
16224+ // this fixture (lanes/tx64x16-r4.handoff.md).
16225+ format!("--cq-level={}", 12 + (attempt % 4) * 5)
16226+ } else {
16227+ format!("--cq-level={}", if attempt % 4 < 2 { 32 } else { 45 })
16228+ };
1620216229 let pix_fmt = if bit_depth == 10 { "yuv420p10le" } else { "yuv420p" };
1620316230 let y4m = Command::new("ffmpeg")
1620416231 .args([
@@ -16239,7 +16266,11 @@ mod tests {
1623916266 "--enable-filter-intra=0",
1624016267 "--enable-cfl-intra=0",
1624116268 "--enable-intrabc=0",
16242- "--enable-tx-size-search=0",
16269+ if tx_search {
16270+ "--enable-tx-size-search=1"
16271+ } else {
16272+ "--enable-tx-size-search=0"
16273+ },
1624316274 "--obu",
1624416275 "-o",
1624516276 "-",
@@ -16270,6 +16301,7 @@ mod tests {
1627016301 crate::decode::rect4_32_vert_hits(),
1627116302 crate::decode::rect4_coeff_hits(),
1627216303 );
16304+ let split_before = crate::decode::rect4_split_depth_hits();
1627316305 let frames = match decode_stream(&stream) {
1627416306 Err(e) => {
1627516307 let msg = e.to_string();
@@ -16289,6 +16321,8 @@ mod tests {
1628916321 crate::decode::rect4_32_vert_hits() - before.1,
1629016322 crate::decode::rect4_coeff_hits() - before.2,
1629116323 );
16324+ let split_now = crate::decode::rect4_split_depth_hits();
16325+ let (d1, d2) = (split_now.0 - split_before.0, split_now.1 - split_before.1);
1629216326 let ffmpeg_frames = if bit_depth == 10 {
1629316327 ffmpeg_decode_sequence_10bit(&stream, width, height, frame_count)
1629416328 } else {
@@ -16339,6 +16373,8 @@ mod tests {
1633916373 horz_proved += horz;
1634016374 vert_proved += vert;
1634116375 coeff_proved += coeff;
16376+ depth1_proved += d1;
16377+ depth2_proved += d2;
1634216378 matched += 1;
1634316379 }
1634416380 assert!(
@@ -16362,6 +16398,28 @@ mod tests {
1636216398 strips={vert_proved}, coded strips={coeff_proved}, {out_of_scope} attempts \
1636316399 carried no 32-level 1:4 block ({out_of_scope_mismatch} mismatched)"
1636416400 );
16401+ // The split-transform halves of the window: both tx depths must
16402+ // have fired inside an attempt that then compared pixel-exact
16403+ // (class counter-from-refused-stream -- a global counter would
16404+ // count strips of attempts that later refused).
16405+ // depth 2 (square TX_8X8 units) is what this round ported and what
16406+ // the ReelB extract needed; depth 1 (the 2:1 rect unit) is
16407+ // refused by name, so it can only show up here as a refusal.
16408+ // Both 1:4 split depths are refused by name (the rect-unit
16409+ // measurement above), so these counters are REPORTED, never
16410+ // asserted: the tx-size-search half of the window exists to keep
16411+ // that refusal honest -- the attempts must refuse, never mismatch.
16412+ assert_eq!(
16413+ depth1_proved + depth2_proved,
16414+ 0,
16415+ "{NAME}: {bit_depth}-bit: a 1:4 split-transform strip decoded \
16416+ (depth1={depth1_proved}, depth2={depth2_proved}) although both depths are \
16417+ refused -- the refusal above is dead"
16418+ );
16419+ eprintln!(
16420+ "{NAME}: {bit_depth}-bit split-transform 1:4 strips: depth1={depth1_proved}, \
16421+ depth2={depth2_proved}"
16422+ );
1636516423 assert_eq!(
1636616424 out_of_scope_mismatch, 0,
1636716425 "{NAME}: {bit_depth}-bit: {out_of_scope_mismatch} attempt(s) with zero 32-level \
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).