diff --git a/crates/ec-av1/src/decode.rs b/crates/ec-av1/src/decode.rs index b54d9bd0..eac88c71 100644 --- a/crates/ec-av1/src/decode.rs +++ b/crates/ec-av1/src/decode.rs @@ -714,7 +714,7 @@ fn tu_reach( width: usize, height: usize, ) -> Reach { - let fixed = Reach::of_tu(bw, bh, col_off, row_off, tx, block); + let fixed = Reach::of_tu(bw, bh, col_off, row_off, tx, tx, block); let standalone = Reach::of(tx, px + col_off, py + row_off, width, height); if fixed != standalone { SPLIT_TU_REACH_FIX_HITS.with(|c| c.set(c.get() + 1)); @@ -1845,6 +1845,30 @@ thread_local! { static RECT4_COEFF_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; } +// lane-rectsplitx r1: 1:4 strips (32x8/8x32/64x16/16x64) decoded through the +// per-transform-unit split path, split by tx depth -- depth 1 is a 2:1 RECT +// unit (TX_16X8/TX_32X16), depth 2 a square one, and the two INTERLEAVE in +// every real stream, so a gate must prove both fired. `SUB16_SPLIT_HITS` +// counts the same for a 16x8/8x16 strip below 16x16. +thread_local! { + static RECT4_SPLIT_DEPTH1_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; + static RECT4_SPLIT_DEPTH2_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; + static SUB16_SPLIT_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; +} + +/// Current values of `RECT4_SPLIT_DEPTH1_HITS` / `RECT4_SPLIT_DEPTH2_HITS`. +pub(crate) fn rect4_split_depth_hits() -> (usize, usize) { + ( + RECT4_SPLIT_DEPTH1_HITS.with(|c| c.get()), + RECT4_SPLIT_DEPTH2_HITS.with(|c| c.get()), + ) +} + +/// Current value of `SUB16_SPLIT_HITS`. +pub(crate) fn sub16_split_hits() -> usize { + SUB16_SPLIT_HITS.with(|c| c.get()) +} + /// Current value of `RECT4_COEFF_HITS`. pub(crate) fn rect4_coeff_hits() -> usize { RECT4_COEFF_HITS.with(|c| c.get()) @@ -4062,11 +4086,26 @@ impl Neighbours { /// [`Self::around_mi`]'s plain coded/uncoded bit, this needs the real /// cumulative level -- a lone-TU block never calls this (its `txb_skip_ctx` /// is always 0, spec's `plane_bsize == tx_size` branch). - fn luma_skip_ctx(&self, (mi_r, mi_c): (usize, usize), side_mi: usize) -> usize { + fn luma_skip_ctx(&self, at_mi: (usize, usize), side_mi: usize) -> usize { + self.luma_skip_ctx_rect(at_mi, side_mi, side_mi) + } + + /// [`Self::luma_skip_ctx`] with the unit's own width and height in mi + /// units (lane-rectsplitx r1) -- `get_txb_ctx_general` ORs the above + /// context over `tx_size_wide` and the left one over `tx_size_high`. + fn luma_skip_ctx_rect( + &self, + (mi_r, mi_c): (usize, usize), + w_mi: usize, + h_mi: usize, + ) -> usize { + let side_mi = w_mi; let mut top = 0u8; let mut left = 0u8; - for cell in 0..side_mi { + for cell in 0..w_mi { top |= self.above[mi_c + cell][0].level; + } + for cell in 0..h_mi { left |= self.left[mi_r + cell][0].level; } let ctx = SKIP_CONTEXTS[(top as usize).min(4)][(left as usize).min(4)]; @@ -4218,6 +4257,33 @@ impl Neighbours { /// strip path ([`decode_leaf_rect`] took this override in r4; a 32x16 strip /// whose left neighbour was a 16x8 leaf still read the stale row and picked /// a different CDF for the same mode value). + /// lane-rectsplitx r2: availability-correct above/left luma modes for a + /// block whose top-left mi is `(mi_r, mi_c)`. libaom reads `above_mbmi` + /// only when `up_available` and `left_mbmi` only when `left_available`; + /// the coarse [`SUB`] bands cannot express that, and with 8-px strips they + /// actively lie -- four 32x8 strips of one `HORZ_4` share ONE 16x16 + /// `left_mode` cell, so the second strip at tile column 0 read the FIRST + /// strip's mode as its "left neighbour" (measured on the band fixture at + /// mi(10,0): mode 2 where libaom has DC, a different `kf_y_mode` row). + fn modes_above_left_mi( + &self, + mi_r: usize, + mi_c: usize, + fallback: (usize, usize), + ) -> (usize, usize) { + let above = if mi_r > self.tile_row0_mi { + self.mode_above_mi(mi_r, mi_c).unwrap_or(fallback.0) + } else { + DC_PRED + }; + let left = if mi_c > self.tile_col0_mi { + self.mode_left_mi(mi_r, mi_c).unwrap_or(fallback.1) + } else { + DC_PRED + }; + (above, left) + } + fn modes_above_left(&self, r: usize, c: usize) -> (usize, usize) { let (mi_r, mi_c) = (r * (SUB / MI), c * (SUB / MI)); let above = self.mode_above_mi(mi_r, mi_c).unwrap_or(self.above_mode[c]); @@ -4323,13 +4389,27 @@ impl Neighbours { /// Leaves `above_side_mi`/`left_side_mi` and the chroma planes alone -- /// the caller's own [`Self::record_split_luma`] call sets those once, /// at the block's own true side, not this TU's. - fn record_mi_luma(&mut self, (mi_r, mi_c): (usize, usize), tx_px: usize, grid: &[i32]) { + fn record_mi_luma(&mut self, at_mi: (usize, usize), tx_px: usize, grid: &[i32]) { + self.record_mi_luma_rect(at_mi, tx_px, tx_px, grid); + } + + /// [`Self::record_mi_luma`] for a RECTANGULAR transform unit (lane-rectsplitx + /// r1): the above context spans the unit's width, the left context its + /// height, which for a square unit is the same loop it always was. + fn record_mi_luma_rect( + &mut self, + (mi_r, mi_c): (usize, usize), + w_px: usize, + h_px: usize, + grid: &[i32], + ) { let state = neighbour_state(grid); - let side_mi = tx_px / MI; - for cell in 0..side_mi { + for cell in 0..h_px / MI { if mi_r + cell < self.mi_rows { self.left[mi_r + cell][0] = state; } + } + for cell in 0..w_px / MI { if mi_c + cell < self.mi_cols { self.above[mi_c + cell][0] = state; } @@ -4367,17 +4447,42 @@ impl Neighbours { chroma_grids: [&[i32]; 2], ) { let (r, c) = at; - for cell in 0..w / SUB { + self.record_split_luma_rect_mi( + (r * (SUB / MI), c * (SUB / MI)), + w, + h, + mode, + uv_mode, + chroma_grids, + ); + } + + /// [`Self::record_split_luma_rect`] addressed in mi units (lane-rectsplitx + /// r1) -- a strip 8 px tall starts mid-[`SUB`]-cell, which the coarse + /// `(r, c)` form cannot name. The coarse mode/side arrays are stamped for + /// every cell the strip TOUCHES (`div_ceil`), last writer wins, the + /// convention [`decode_block_rect4`] already established for 1:4 strips. + fn record_split_luma_rect_mi( + &mut self, + at_mi: (usize, usize), + w: usize, + h: usize, + mode: usize, + uv_mode: usize, + chroma_grids: [&[i32]; 2], + ) { + let (mi_r, mi_c) = at_mi; + let (r, c) = (mi_r / (SUB / MI), mi_c / (SUB / MI)); + for cell in 0..w.div_ceil(SUB) { self.above_mode[c + cell] = mode; self.above_uv_mode[c + cell] = uv_mode; self.above_side[c + cell] = w; } - for cell in 0..h / SUB { + for cell in 0..h.div_ceil(SUB) { self.left_mode[r + cell] = mode; self.left_uv_mode[r + cell] = uv_mode; self.left_side[r + cell] = h; } - let (mi_r, mi_c) = (r * (SUB / MI), c * (SUB / MI)); let (w_mi, h_mi) = (w / MI, h / MI); self.record_mode_mi(mi_r, mi_c, w_mi, h_mi, mode); self.record_uv_mode_mi(mi_r, mi_c, w_mi, h_mi, uv_mode); @@ -5052,6 +5157,29 @@ struct RectStripModes { palette_uv: Option<(Vec, Vec)>, } +/// The transform unit size (w, h) of a `bw`x`bh` intra block at tx `depth` +/// -- libaom `depth_to_tx_size`, which walks `sub_tx_size_map` `depth` times +/// from `max_txsize_rect_lookup[bsize]`. Every entry of that map halves the +/// LONGER side of a rectangle and both sides of a square, so a 1:4 strip's +/// first step is a 2:1 rect unit (`TX_32X8 -> TX_16X8`, `TX_64X16 -> +/// TX_32X16`) and only the second reaches a square -- the reason +/// `bw.min(bh) >> (depth - 1)` (correct for a 2:1 strip, where step one is +/// already square) mis-tiled 1:4 strips. +fn depth_to_tx_wh(bw: usize, bh: usize, depth: usize) -> (usize, usize) { + let (mut w, mut h) = (bw.min(64), bh.min(64)); + for _ in 0..depth { + match w.cmp(&h) { + std::cmp::Ordering::Greater => w /= 2, + std::cmp::Ordering::Less => h /= 2, + std::cmp::Ordering::Equal => { + w /= 2; + h /= 2; + } + } + } + (w, h) +} + /// Decodes the planes of one `bw`x`bh` HORZ/VERT intra strip whose luma /// transform is SPLIT (`tx_depth != 0`) -- lane-rectsplit r1, the case every /// rect path here refused by name until now ("per-unit rect prediction is not @@ -5077,10 +5205,15 @@ fn decode_rect_split( dec: &mut SymbolDecoder, cdfs: &mut Cdfs, neighbours: &mut Neighbours, - at: (usize, usize), + at_mi: (usize, usize), bw: usize, bh: usize, - tx: usize, + // The transform unit's own width and height in pixels. Square for every + // 2:1 strip from the first split on, but a 1:4 strip's FIRST split is + // still a 2:1 RECT unit (`sub_tx_size_map[TX_32X8] == TX_16X8`, + // `[TX_64X16] == TX_32X16`) -- see [`depth_to_tx_wh`]. + tx_w: usize, + tx_h: usize, m: &RectStripModes, y: &mut PlaneBuf, u: &mut PlaneBuf, @@ -5088,9 +5221,8 @@ fn decode_rect_split( base_q_idx: u8, reduced_tx_set: bool, ) -> Result<()> { - let (r, c) = at; - let (px, py) = (c * SUB, r * SUB); - let (mi_r, mi_c) = (r * (SUB / MI), c * (SUB / MI)); + let (mi_r, mi_c) = at_mi; + let (px, py) = (mi_c * MI, mi_r * MI); let (cpx, cpy) = (px / 2, py / 2); let (chroma_w, chroma_h) = (bw / 2, bh / 2); // The chroma transform is picked before any symbol is read, so an @@ -5100,16 +5232,17 @@ fn decode_rect_split( (8, 16) => Some((TxbSet::ChromaRect16x8, &SCAN_8X16[..])), (32, 16) => Some((TxbSet::ChromaRect32x16, &SCAN_32X16[..])), (16, 32) => Some((TxbSet::ChromaRect32x16, &SCAN_16X32[..])), - // lane-rectchroma r1: the 1:4 superblock strips (64x16/16x64, - // `decode_block_rect64`'s `strip64!` arm) and the 8x16 left rect of a - // 16x16 `VERT_B` reach here once their tx depth is non-zero -- the - // shapes their chroma half takes. `get_txsize_entropy_ctx(TX_32X8)` - // is `(0 + 4 + 1) >> 1 == 2`, the 16x16 CDF set (eob alphabet 256), - // exactly as the unsplit 1:4 path already picks it; `TX_8X4` reduces - // to `(0 + 1 + 1) >> 1 == 1`, the 8x8 set `ChromaRect8x4` carries - // (eob 32), as `decode_leaf_rect`'s own chroma half already does. + // The 1:4 and sub-16 strips (lane-rectchroma r1 added the 32x8/8x32 + // rows, lane-rectsplitx r1 the 16x4/4x16 ones). `get_txsize_entropy_ctx` + // squares a rect transform down to a CDF set by + // `(wide_log2 + high_log2 + 1) >> 1`: TX_32X8 -> the 16x16 set, + // TX_16X4 -> the 8x8 set, TX_8X4 -> the 8x8 set -- exactly the sets + // the UNSPLIT 1:4 (`decode_block_rect4`) and 16x8 (`decode_leaf_rect`) + // paths already prove for these same shapes. (32, 8) => Some((TxbSet::Chroma16, &SCAN_32X8[..])), (8, 32) => Some((TxbSet::Chroma16, &SCAN_8X32[..])), + (16, 4) => Some((TxbSet::Chroma8, &SCAN_16X4[..])), + (4, 16) => Some((TxbSet::Chroma8, &SCAN_4X16[..])), (8, 4) => Some((TxbSet::ChromaRect8x4, &SCAN_8X4[..])), (4, 8) => Some((TxbSet::ChromaRect8x4, &SCAN_4X8[..])), _ => None, @@ -5132,7 +5265,7 @@ fn decode_rect_split( // Diagnostic for the next caller that lands here (class // refusal-names-a-correlate: the message names the tool, not the // shape); the refusal below keeps its inventory-pinned wording. - eprintln!("EC_RECTCHROMA_GAP luma={bw}x{bh} tx={tx} chroma={chroma_w}x{chroma_h}"); + eprintln!("EC_RECTCHROMA_GAP luma={bw}x{bh} tx={tx_w}x{tx_h} chroma={chroma_w}x{chroma_h}"); } } // lane-rectsplit r2 (verifier finding): with both callers wired @@ -5148,21 +5281,50 @@ fn decode_rect_split( )); } RECT_SPLIT_TX_HITS.with(|c| c.set(c.get() + 1)); - if bw.max(bh) == 64 && bw / tx > 1 && bh / tx > 1 { + if bw.max(bh) == 64 && bw / tx_w > 1 && bh / tx_h > 1 { RECT_SPLIT_SB_INTERIOR_TU_HITS.with(|c| c.set(c.get() + 1)); } // LUMA: `bw/tx` x `bh/tx` square transform units, raster order. - let luma_set = txbset_for(tx, reduced_tx_set); - let luma_scan = default_scan(tx); - let zero_tu = vec![0i32; tx * tx]; + // A square unit reads through the ordinary square [`read_plane`]; a rect + // one (a 1:4 strip's first split) reads through [`read_coeffs_rect`] with + // the very tables the unsplit 16x8/32x16 paths use. + let luma_rect: Option<(TxbSet, &[u16])> = match (tx_w, tx_h) { + (w, h) if w == h => None, + (16, 8) | (8, 16) => Some(( + if reduced_tx_set { + TxbSet::LumaRect16x8 + } else { + TxbSet::LumaRect16x8Set1 + }, + if tx_w == 16 { &SCAN_16X8[..] } else { &SCAN_8X16[..] }, + )), + (32, 16) => Some((TxbSet::LumaRect32x16, &SCAN_32X16[..])), + (16, 32) => Some((TxbSet::LumaRect32x16, &SCAN_16X32[..])), + _ => { + return Err(unsupported(format!( + "a split intra strip whose transform unit is {tx_w}x{tx_h} (no luma \ + coefficient tables for that shape here)" + ))) + } + }; + // lane-rectsplitx r1, MEASURED: the SQUARE-unit walk below is pixel-exact + // on a real stream (the pinned 16x8 filter-intra fixture decodes its whole + // frame exactly, two sub-16 split strips in it), but the RECT-unit arm -- + // a 1:4 strip's depth-1 TX_16X8/TX_32X16 -- mismatched ffmpeg on the + // 32-level 1:4 band fixture (8-bit, cq 12, seed 42). The tables and the + // per-unit rect walk stay wired above/below; the round that finds that + // defect deletes this refusal and nothing else. + let luma_set = txbset_for(tx_w.min(tx_h), reduced_tx_set); + let luma_scan = default_scan(tx_w.min(tx_h)); + let zero_tu = vec![0i32; tx_w * tx_h]; // The strip's OWN edge availability, the fallback for a transform unit // whose top-right/bottom-left pixels fall outside the strip. let block_reach = Reach::of_rect(bw, bh, px, py, y.width, y.height); - for tu_row in 0..bh / tx { - for tu_col in 0..bw / tx { - let tu_mi = (mi_r + tu_row * (tx / MI), mi_c + tu_col * (tx / MI)); - let (tu_px, tu_py) = (px + tu_col * tx, py + tu_row * tx); - let (col_off, row_off) = (tu_col * tx, tu_row * tx); + for tu_row in 0..bh / tx_h { + for tu_col in 0..bw / tx_w { + let tu_mi = (mi_r + tu_row * (tx_h / MI), mi_c + tu_col * (tx_w / MI)); + let (tu_px, tu_py) = (px + tu_col * tx_w, py + tu_row * tx_h); + let (col_off, row_off) = (tu_col * tx_w, tu_row * tx_h); // `has_top_right`/`has_bottom_left` (libaom `reconintra.c`) for a // transform unit INSIDE a block, which is a different rule from // the standalone-block table [`Reach::of`] applies -- and the @@ -5178,22 +5340,23 @@ fn decode_rect_split( // (`row_off + tx_high < plane_bh`) they are the left // neighbour's, already reconstructed; the last row falls back // to the block-level answer. - let tu_reach = Reach::of_tu(bw, bh, col_off, row_off, tx, block_reach); + let tu_reach = Reach::of_tu(bw, bh, col_off, row_off, tx_w, tx_h, block_reach); // The unit's own window on the block's palette prediction. if let Some(buf) = &m.palette_y { - let tu_buf: Vec = (0..tx) + let tu_buf: Vec = (0..tx_h) .flat_map(|i| { let base = (row_off + i) * bw + col_off; - buf[base..base + tx].iter().copied() + buf[base..base + tx_w].iter().copied() }) .collect(); set_palette_pred(tu_buf); } if m.skip { - y.reconstruct( + y.reconstruct_rect( tu_px, tu_py, - tx, + tx_w, + tx_h, m.mode, m.angle_delta_y, tu_reach, @@ -5202,13 +5365,57 @@ fn decode_rect_split( m.filter_intra, m.smooth_neighbor, ); - neighbours.record_mi_luma(tu_mi, tx, &zero_tu); + neighbours.record_mi_luma_rect(tu_mi, tx_w, tx_h, &zero_tu); + } else if let Some((rect_set, rect_scan)) = luma_rect { + // The rect-unit twin of the square arm below: same contexts, + // same order, through the rect coefficient reader. The + // `tx_type` CDF row of a filter-intra block is + // `fimode_to_intradir[filter_intra_mode]`, never the block's + // own (always DC_PRED) mode -- [`read_plane`] applies that + // for the square arm, so this one must too. + let tu_around = neighbours.around_mi_rect(tu_mi, tx_w, tx_h)[0]; + let tu_skip_ctx = neighbours.luma_skip_ctx_rect(tu_mi, tx_w / MI, tx_h / MI); + let mut coding = cdfs.txb(rect_set, fi_tx_row(m.mode, m.filter_intra)); + let (tu_grid, tu_tx_type) = read_coeffs_rect( + dec, + &mut coding, + rect_scan, + tx_w, + tx_h, + tu_skip_ctx, + dc_sign_ctx(tu_around.2), + TxType::DctDct, + )?; + let residual = dequant_and_inverse_typed_wh( + &tu_grid, + tx_w, + tx_h, + crate::decode::bit_depth(), + block_q_idx(), + plane_q_delta(0).0, + plane_q_delta(0).1, + tu_tx_type, + ); + y.reconstruct_rect( + tu_px, + tu_py, + tx_w, + tx_h, + m.mode, + m.angle_delta_y, + tu_reach, + &residual, + None, + m.filter_intra, + m.smooth_neighbor, + ); + neighbours.record_mi_luma_rect(tu_mi, tx_w, tx_h, &tu_grid); } else { - let tu_around = neighbours.around_mi(tu_mi, tx)[0]; + let tu_around = neighbours.around_mi(tu_mi, tx_w)[0]; // This unit is smaller than the block it sits in, so // `txb_skip_ctx` is the neighbour-magnitude table, not the // lone-TU 0 (spec `get_txb_ctx_general`). - let tu_skip_ctx = neighbours.luma_skip_ctx(tu_mi, tx / MI); + let tu_skip_ctx = neighbours.luma_skip_ctx(tu_mi, tx_w / MI); let tu_grid = read_plane( dec, cdfs, @@ -5223,15 +5430,15 @@ fn decode_rect_split( y, tu_px, tu_py, - tx, - tx, + tx_w, + tx_w, base_q_idx, None, m.filter_intra, Some(tu_skip_ctx), m.smooth_neighbor, )?; - neighbours.record_mi_luma(tu_mi, tx, &tu_grid); + neighbours.record_mi_luma(tu_mi, tx_w, &tu_grid); } } } @@ -5265,7 +5472,7 @@ fn decode_rect_split( } else { default_intra_tx_type(m.uv_predict_mode as u8) }; - let around = neighbours.around_rect(at, bw, bh); + let around = neighbours.around_mi_rect(at_mi, bw, bh); let mut grids: Vec> = Vec::with_capacity(2); for plane_idx in 1..=2 { let skip_ctx = @@ -5325,13 +5532,21 @@ fn decode_rect_split( let mut it = grids.into_iter(); (it.next().unwrap(), it.next().unwrap()) }; - neighbours.record_split_luma_rect(at, bw, bh, m.mode, m.uv_predict_mode, [&u_grid, &v_grid]); + neighbours.record_split_luma_rect_mi( + at_mi, + bw, + bh, + m.mode, + m.uv_predict_mode, + [&u_grid, &v_grid], + ); neighbours.fill_skip_grid_rect((mi_r, mi_c), bw / MI, bh / MI, m.skip); - neighbours.fill_lf_grid_rect((mi_r, mi_c), bw / MI, bh / MI, tx as u8, tx as u8, 0); + neighbours.fill_lf_grid_rect((mi_r, mi_c), bw / MI, bh / MI, tx_w as u8, tx_h as u8, 0); if std::env::var_os("EC_AV1_TRACE").is_some() { let (rng, _) = dec.debug_state(); eprintln!( - "TRACE_RECT_SPLIT mi_row={mi_r} mi_col={mi_c} bw={bw} bh={bh} tx={tx} rng={rng}" + "TRACE_RECT_SPLIT mi_row={mi_r} mi_col={mi_c} bw={bw} bh={bh} \ + tx={tx_w}x{tx_h} rng={rng}" ); } Ok(()) @@ -5427,13 +5642,12 @@ fn decode_block_rect( // lane-rectsplit r1: a split transform is predicted and reconstructed // per transform unit, each unit taking its edges from the previous // unit's reconstruction inside this same strip (spec 5.11.36) -- - // [`decode_rect_split`]. `depth_to_tx_size` of a 2:1 strip is square - // from the first step on, so `bw.min(bh) >> (depth - 1)` names it. - let tx = bw.min(bh) >> (depth - 1); + // [`decode_rect_split`], the unit named by [`depth_to_tx_wh`]. + let (tx_w, tx_h) = depth_to_tx_wh(bw, bh, depth); if std::env::var_os("EC_SBPART_DUMP64").is_some() { eprintln!( "DUMP64SPLIT mi_r={mi_r} mi_c={mi_c} px={px} py={py} bw={bw} bh={bh} \ - depth={depth} tx={tx} mode={mode} uv={uv_predict_mode} skip={skip} \ + depth={depth} tx={tx_w}x{tx_h} mode={mode} uv={uv_predict_mode} skip={skip} \ angle_y={angle_delta_y}" ); } @@ -5461,7 +5675,20 @@ fn decode_block_rect( PALETTE_SPLIT_TX_HITS.with(|c| c.set(c.get() + 1)); } decode_rect_split( - dec, cdfs, neighbours, at, bw, bh, tx, &modes, y, u, v, base_q_idx, reduced_tx_set, + dec, + cdfs, + neighbours, + (mi_r, mi_c), + bw, + bh, + tx_w, + tx_h, + &modes, + y, + u, + v, + base_q_idx, + reduced_tx_set, )?; // This early return skips this fn's own tail, so the palette // neighbour state has to be stamped HERE too: without it a split-tx @@ -5811,12 +6038,12 @@ fn decode_leaf_rect( // cannot hold the modes a split (or a pair of strips) leaves behind, so // when the map holds the block at exactly this strip's above/left mi it // is the neighbour libaom's `above_mi`/`left_mi` reads. - if let Some(m) = neighbours.mode_above_mi(leaf_mi.0, leaf_mi.1) { - above_mode = m; - } - if let Some(m) = neighbours.mode_left_mi(leaf_mi.0, leaf_mi.1) { - left_mode = m; - } + // lane-rectsplitx r2 (same class as the 1:4 fix): mi-exact AND + // availability-correct -- four 16x8 strips share one coarse 16x16 + // `left_mode` cell too, so the fallback must not stand in for an absent + // tile-edge neighbour. + let (above_mode, left_mode) = + neighbours.modes_above_left_mi(leaf_mi.0, leaf_mi.1, (above_mode, left_mode)); let smooth_neighbor = is_smooth_mode(above_mode) || is_smooth_mode(left_mode); if smooth_neighbor { @@ -5874,15 +6101,57 @@ fn decode_leaf_rect( let smooth_neighbor_uv = neighbours.smooth_uv_neighbour(leaf_mi.0, leaf_mi.1, r, c); let depth = if tx_select { let ctx = tx_size_context_rect(neighbours, leaf_mi, bw, bh); - dec.symbol(&mut cdfs.tx_size_cat2[ctx]) + // lane-rectsplitx r1: `bsize_to_tx_size_cat` (libaom `blockd.h`, + // `bsize_to_tx_size_depth_table`) is 2 for BLOCK_16X8/BLOCK_8X16, so + // the category is 1 -- NOT the 2 the 32x16 strips read. Same symbol + // count (3), different CDF row: a wrong-table read of a real symbol, + // the class that cost lane-rectsplit r1 its 64x32 depth. + dec.symbol(&mut cdfs.tx_size_cat1[ctx]) } else { 0 }; if depth != 0 { - return Err(unsupported( - "a HORZ/VERT intra strip below 16x16 with a split transform (per-unit rect \ - prediction is not ported)", - )); + // The same per-transform-unit walk the bigger strips take + // (`depth_to_tx_wh`: TX_16X8 -> TX_8X8 at depth 1, -> TX_4X4 at + // depth 2), addressed at this leaf's own mi position. + TX_DEPTH_HITS.with(|c| c.set(c.get() + 1)); + SUB16_SPLIT_HITS.with(|c| c.set(c.get() + 1)); + let (tx_w, tx_h) = depth_to_tx_wh(bw, bh, depth); + let modes = RectStripModes { + skip, + mode, + angle_delta_y, + uv_predict_mode, + angle_delta_uv, + alpha, + filter_intra, + smooth_neighbor, + // lane-rectsplitx r3: the split arm hard-coded `false` here while + // the unsplit arm below passes the real neighbour answer -- chroma + // of a tx-split 16x8/8x16 leaf lost its intra-edge filter type. + smooth_neighbor_uv, + // Both callers refuse a palette on this shape above (pixel + // reconstruction is unported here), so the split units carry none. + palette_y: None, + palette_uv: None, + }; + decode_rect_split( + dec, + cdfs, + neighbours, + leaf_mi, + bw, + bh, + tx_w, + tx_h, + &modes, + y, + u, + v, + base_q_idx, + reduced_tx_set, + )?; + return Ok(mode); } let (px, py) = (leaf_mi.1 * MI, leaf_mi.0 * MI); let reach = Reach::of_rect(bw, bh, px, py, y.width, y.height); @@ -6042,6 +6311,12 @@ fn decode_block_rect4( left_mode = pmode; } } + // lane-rectsplitx r2, ROOT CAUSE of the 1:4 mismatch: mi-exact + + // availability-correct neighbour modes (see + // [`Neighbours::modes_above_left_mi`]). The coarse 16x16 bands alias every + // 8-px strip of a `HORZ_4`/`VERT_4` onto one cell. + let (above_mode, left_mode) = + neighbours.modes_above_left_mi(mi_r, mi_c, (above_mode, left_mode)); let ( skip, mode, @@ -6082,8 +6357,13 @@ fn decode_block_rect4( if smooth_neighbor { SMOOTH_LUMA_HITS.with(|c| c.set(c.get() + 1)); } - let smooth_neighbor_uv = - neighbours.smooth_uv_neighbour(r * (SUB / MI), c * (SUB / MI), r, c); + // lane-rectsplitx r2: this strip's REAL mi, not the [`SUB`] cell's + // top-left -- a 1:4 strip starts 8 px into a 16-px cell, so + // `r * (SUB / MI)` names a different mi column and the chroma + // edge-filter strength was read from the wrong neighbour (measured: + // seed 43, the last 8x32 strip at luma (152,32), chroma-only mismatch + // with luma bit-exact). + let smooth_neighbor_uv = neighbours.smooth_uv_neighbour(mi_r, mi_c, r, c); if filter_intra.is_some() { FILTER_INTRA_RECT_HITS.with(|c| c.set(c.get() + 1)); if bw > bh { @@ -6104,16 +6384,64 @@ fn decode_block_rect4( 0 }; if depth != 0 { - // lane-tx64x16 r4: the depth is IN the message -- it says which port - // the next round owes. depth 1 of a 4:1 strip is TX_16X8/TX_8X16 - // (`sub_tx_size_map[TX_32X8] == TX_16X8`), a RECTANGULAR transform - // unit with no luma coefficient tables here; depth 2 is TX_8X8, - // square, the shape `decode_rect_split` already walks. The film stops - // at depth 2, synthetic band fixtures hit both. - return Err(unsupported(format!( - "a 32x32-level 1:4 strip with a split transform (per-unit 4:1 prediction is not \ - ported, depth={depth})" - ))); + // lane-rectsplitx r1: the per-transform-unit walk, at this strip's + // real mi position (strips 1 and 3 of a HORZ_4 start 8 px into a + // 16-px [`SUB`] cell). depth 1 is the RECT unit TX_16X8/TX_8X16 + // (`sub_tx_size_map[TX_32X8] == TX_16X8`), depth 2 the square TX_8X8; + // both interleave in every real stream. + TX_DEPTH_HITS.with(|c| c.set(c.get() + 1)); + let (tx_w, tx_h) = depth_to_tx_wh(bw, bh, depth); + // lane-rectsplitx r2: both depths ship together, as the r1 handoff + // predicted -- depth 1 fires FIRST in every attempt that splits at + // all, so a depth-2-only lift could never be gated. The r1 mismatch + // was never the rect unit: it was the neighbour MODE the strip reads + // (see `modes_above_left_mi`). + let which = if depth == 1 { + &RECT4_SPLIT_DEPTH1_HITS + } else { + &RECT4_SPLIT_DEPTH2_HITS + }; + which.with(|c| c.set(c.get() + 1)); + let modes = RectStripModes { + skip, + mode, + angle_delta_y, + uv_predict_mode, + angle_delta_uv, + alpha, + filter_intra, + smooth_neighbor, + smooth_neighbor_uv, + // Both callers refuse a palette on this shape above (pixel + // reconstruction is unported here), so the split units carry none. + palette_y: None, + palette_uv: None, + }; + decode_rect_split( + dec, + cdfs, + neighbours, + (mi_r, mi_c), + bw, + bh, + tx_w, + tx_h, + &modes, + y, + u, + v, + base_q_idx, + false, + )?; + if bw > bh { + RECT4_32_HORZ_HITS.with(|c| c.set(c.get() + 1)); + } else { + RECT4_32_VERT_HITS.with(|c| c.set(c.get() + 1)); + } + if !skip { + RECT4_COEFF_HITS.with(|c| c.set(c.get() + 1)); + } + return Ok((mode, uv_predict_mode)); } // The coarse (16-px [`SUB`] cell) mode/side arrays cannot name a strip // that is 8 px tall, so each strip stamps every cell it touches and the @@ -6130,6 +6458,14 @@ fn decode_block_rect4( neighbours.left_uv_mode[r + cell] = uv_predict_mode; neighbours.left_side[r + cell] = bh; } + // ...and the mi-EXACT maps the coarse cells alias away, exactly as + // [`decode_leaf_rect`] does (the split arm above records these through + // `record_mi_luma_rect`). Without this an unsplit 32x8 strip left + // `sub8_mode_row` holding the previous block, and the next 32x32's + // strips read a stale `kf_y_mode` row (measured: mi(4,8) on the band + // fixture). + neighbours.record_mode_mi(mi_r, mi_c, mi_w, mi_h, mode); + neighbours.record_uv_mode_mi(mi_r, mi_c, mi_w, mi_h, uv_predict_mode); let (px, py) = (mi_c * MI, mi_r * MI); let (cpx, cpy) = (px / 2, py / 2); let (chroma_w, chroma_h) = (bw / 2, bh / 2); @@ -6412,31 +6748,22 @@ fn decode_block_rect64( TX_DEPTH_HITS.with(|c| c.set(c.get() + 1)); // lane-rectsplit r1/r4: the superblock-level strip splits its // transform through the very same per-unit path as its 32x32-level - // sibling (`sub_tx_size_map[TX_64X32] == TX_32X32`, square from the - // first step on, so `bw.min(bh) >> (depth - 1)` names the unit). - // lane-rectchroma r1: `sub_tx_size_map[TX_64X16] == TX_32X16`, NOT a - // square -- a 4:1 strip's first transform split is still a 2:1 RECT - // unit, and only the SECOND step reaches a square (TX_16X16). The - // 2:1 formula below (square from the first step on) named 16x16 units - // for a depth-1 64x16 strip, which decoded 2 chroma-32x8 strips of - // the band fixture with the wrong luma tiling. depth 1 on a 4:1 strip - // is refused by name; depth >= 2 is square, one step later. - let is_1to4 = bw.max(bh) / bw.min(bh) == 4; - if is_1to4 && depth == 1 && !skip { - return Err(unsupported( - "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)", - )); + // sibling; [`depth_to_tx_wh`] names the unit, which for a 64x16/16x64 + // 1:4 strip is the 2:1 rect TX_32X16 at depth 1 (lane-rectchroma r1 + // measured the old square formula mis-tiling exactly that strip). + let (tx_w, tx_h) = depth_to_tx_wh(bw, bh, depth); + if bw.max(bh) / bw.min(bh) == 4 { + let which = if depth == 1 { + &RECT4_SPLIT_DEPTH1_HITS + } else { + &RECT4_SPLIT_DEPTH2_HITS + }; + which.with(|c| c.set(c.get() + 1)); } - let tx = if is_1to4 { - bw.min(bh) >> (depth - 2) - } else { - bw.min(bh) >> (depth - 1) - }; if std::env::var_os("EC_SBPART_DUMP64").is_some() { eprintln!( "DUMP64SPLIT mi_r={mi_r} mi_c={mi_c} px={px} py={py} bw={bw} bh={bh} \ - depth={depth} tx={tx} mode={mode} uv={uv_predict_mode} skip={skip} \ + depth={depth} tx={tx_w}x{tx_h} mode={mode} uv={uv_predict_mode} skip={skip} \ angle_y={angle_delta_y}" ); } @@ -6464,7 +6791,20 @@ fn decode_block_rect64( PALETTE_SPLIT_TX_HITS.with(|c| c.set(c.get() + 1)); } decode_rect_split( - dec, cdfs, neighbours, at, bw, bh, tx, &modes, y, u, v, base_q_idx, reduced_tx_set, + dec, + cdfs, + neighbours, + (mi_r, mi_c), + bw, + bh, + tx_w, + tx_h, + &modes, + y, + u, + v, + base_q_idx, + reduced_tx_set, )?; // Same early-return palette stamp as [`decode_block_rect`]'s split arm // (lane-palette2 r10): this return skips the fn's own tail, so a @@ -8181,12 +8521,12 @@ fn decode_leaf8( // `prev_leaf`: one 16x16 slot cannot hold the two different modes its // two 8x8 (or four 4x4) columns leave behind, so a leaf whose above/left // neighbour sits in a split cell read the wrong `kf_y_mode` row. - if let Some(m) = neighbours.mode_above_mi(leaf_mi.0, leaf_mi.1) { - above_mode = m; - } - if let Some(m) = neighbours.mode_left_mi(leaf_mi.0, leaf_mi.1) { - left_mode = m; - } + // lane-rectsplitx r2 swept this arm into + // [`Neighbours::modes_above_left_mi`]: the mi-exact map ALSO has to answer + // "no neighbour" at a tile edge, where the coarse cell holds the block + // above/left of it inside the same 16x16. + let (above_mode, left_mode) = + neighbours.modes_above_left_mi(leaf_mi.0, leaf_mi.1, (above_mode, left_mode)); let smooth_neighbor = is_smooth_mode(above_mode) || is_smooth_mode(left_mode); // Chroma's edge-filter type reads the CHROMA neighbour's `uv_mode` // (`get_intra_edge_filter_type`, reconintra.c:974), never the luma mode diff --git a/crates/ec-av1/src/encode.rs b/crates/ec-av1/src/encode.rs index 1ba18ed6..12121c4e 100644 --- a/crates/ec-av1/src/encode.rs +++ b/crates/ec-av1/src/encode.rs @@ -1234,18 +1234,22 @@ impl Reach { bh: usize, col_off: usize, row_off: usize, - tx: usize, + // The unit's own width and height in pixels; equal for a square + // transform, different for the rect unit a 1:4 strip's first split + // produces (lane-rectsplitx r1). + tx_w: usize, + tx_h: usize, block: Self, ) -> Self { Self { - above_right: if col_off + tx < bw { + above_right: if col_off + tx_w < bw { true } else { row_off == 0 && block.above_right }, below_left: if col_off > 0 { false - } else if row_off + tx < bh { + } else if row_off + tx_h < bh { true } else { block.below_left @@ -3865,14 +3869,14 @@ mod tests { // `has_tr_vert_*` tables have no 4x4 row at all, lane-ab16 r2). let plain = Reach::of(8, 0, 8, SUPERBLOCK, SUPERBLOCK); assert_eq!( - Reach::of_tu(8, 8, 4, 0, 4, plain).above_right, + Reach::of_tu(8, 8, 4, 0, 4, 4, plain).above_right, plain.above_right, "ordinary table: the top-right TX4 unit takes the block's row" ); let guard = Reach::vert_ab_partition(); let vert = Reach::of(8, 0, 8, SUPERBLOCK, SUPERBLOCK); assert_eq!( - Reach::of_tu(8, 8, 4, 0, 4, vert).above_right, + Reach::of_tu(8, 8, 4, 0, 4, 4, vert).above_right, vert.above_right, "vert AB: the unit follows the vert row the block just picked" ); @@ -4016,7 +4020,7 @@ mod tests { for row_off in (0..bh).step_by(tx) { for col_off in (0..bw).step_by(tx) { for &blk in &[Reach { above_right: false, below_left: false }, Reach { above_right: true, below_left: true }] { - let got = Reach::of_tu(bw, bh, col_off, row_off, tx, blk); + let got = Reach::of_tu(bw, bh, col_off, row_off, tx, tx, blk); assert_eq!( got.above_right, libaom_tr(bw, bh, col_off, row_off, tx, blk.above_right), diff --git a/crates/ec-av1/src/refusal_inventory.rs b/crates/ec-av1/src/refusal_inventory.rs index 5247d19a..9b59feb2 100644 --- a/crates/ec-av1/src/refusal_inventory.rs +++ b/crates/ec-av1/src/refusal_inventory.rs @@ -32,15 +32,13 @@ const CAPABILITY_CLAIMS: &[&str] = &[ #[cfg(test)] const REFUSALS: &[&str] = &[ "a coded HORZ/VERT strip whose chroma transform has no rect coefficient tables here", - "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)", - "a HORZ/VERT intra strip below 16x16 with a split transform (per-unit rect prediction is not ported)", + "a split intra strip whose transform unit is {tx_w}x{tx_h} (no luma coefficient tables for that shape here)", "an inter partition below 8x8 (this decoder codes no inter leaf smaller than 8x8; lane-sub8 scoped to intra)", "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)", "a 1:4 rect strip that actually uses a palette (reconstruction is not ported at this shape)", "a 16x16 block whose true edge cuts through both axes needs a rectangular transform this decoder does not code yet", "a 16x16 inter block whose true edge cuts through both axes needs a rectangular transform this decoder does not code yet", "a 32x32 partition type this decoder does not code (value={part32})", - "a 32x32-level 1:4 strip with a split transform (per-unit 4:1 prediction is not ported, depth={depth})", "a Golomb tail longer than this decoder reads", "a tx_type symbol outside its CDF's own set: {t}", "an INTER 32x32 partition type this decoder does not code (value={part32})", diff --git a/crates/ec-av1/src/stream.rs b/crates/ec-av1/src/stream.rs index cdbe5fbc..502f462d 100644 --- a/crates/ec-av1/src/stream.rs +++ b/crates/ec-av1/src/stream.rs @@ -9282,22 +9282,26 @@ mod tests { attempts.iter().filter(|a| !a.tx_size_search).count(), "{NAME}: every fixed-transform attempt must decode and compare" ); - // The tx-size-search attempts cannot be compared pixel by pixel yet: - // every 16x16 AB partition contains a strip, and with a free - // transform size aomenc splits at least one of them in every stream - // of a 40-cell {source, cq} sweep (r2 report), so they all stop at - // lane-rectx's "strip with a split transform" refusal (or the 1:4 / - // sub-8x8 ones) before the frame is done. What they DO prove is that - // the TX4 sub-grid of an 8x8 square inside a VERT_A/VERT_B is reached - // on a real stream and answers -- it used to panic there, and a panic - // cannot be tolerated by the `unsupported` arm above. The values it - // answers are pinned separately against libaom in - // `of_tu_keeps_the_ordinary_answer_and_uses_the_block_row_under_vert_ab`. - let _ = tx4_compared; - assert!( - tx4_reached > 0, - "{NAME}: no --enable-tx-size-search=1 attempt reached a TX4 unit inside a \ - vertical AB partition -- the r2 panic path is unproven" + // Until the lane-rectsplitx merge every tx-size-search attempt stopped + // at "a HORZ/VERT intra strip below 16x16 with a split transform", so + // this gate could only claim that the TX4 sub-grid of an 8x8 square + // inside a VERT_A/VERT_B was REACHED (`tx4_reached`, counted even on a + // refused attempt). With per-TU rect prediction those same attempts now + // decode to the end and compare pixel-exact, and they carry no vert-AB + // TX4 unit at all -- the pre-merge nonzero count came from decodes that + // were still desynced when they hit the refusal (class + // counter-from-refused-stream). The full pixel compare is the stronger + // claim and replaces it; the lookup's VALUES stay pinned against libaom + // in `of_tu_keeps_the_ordinary_answer_and_uses_the_block_row_under_vert_ab`. + eprintln!("{NAME}: vert-AB TX4 units reached across tx-size-search attempts: {tx4_reached}"); + let _ = tx4_reached; + assert_eq!( + tx4_compared, + attempts.iter().filter(|a| a.tx_size_search).count(), + "{NAME}: every --enable-tx-size-search=1 attempt must now decode to the end and \ + compare pixel-exact (the split-transform strip refusal these used to stop at is \ + lifted); the vert-AB TX4 lookup values stay pinned by \ + `of_tu_keeps_the_ordinary_answer_and_uses_the_block_row_under_vert_ab`" ); for (i, arm) in ["HORZ_A", "HORZ_B", "VERT_A", "VERT_B"].iter().enumerate() { assert!(arms[i] > 0, "{NAME}: PARTITION_{arm} at 16x16 never fired across {compared} \ @@ -12927,7 +12931,7 @@ mod tests { /// `encode::tests::every_rect_shape_reaches_what_libaom_says_over_the_whole_superblock` /// against libaom's own `has_tr_*`/`has_bl_*` arrays. #[test] - #[ignore = "the coded 16x8/8x16 strip is a live refusal; see the doc above"] + #[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"] fn a_directional_16x8_strip_reads_the_right_above_right_samples() { const NAME: &str = "a_directional_16x8_strip_reads_the_right_above_right_samples"; if !have_ffmpeg() { @@ -16180,17 +16184,15 @@ mod tests { } /// lane-fistrip r1, the 10-bit arm of the strip gate (his films are - /// yuv420p10le). Same ceiling as its 8-bit twin -- kept `#[ignore]`d - /// with the measurement rather than weakened: MEASURED over seeds + /// yuv420p10le). Same ceiling as its 8-bit twin, lifted in lane-rectsplitx + /// r3 (the split arm's `smooth_neighbor_uv`); before that, MEASURED over seeds /// 42..61 the 8x16/16x8 strips aomenc writes filter intra on are /// `skip=0`, which `decode_leaf_rect` refuses, so /// `filter_intra_rect_sub16_hits` never reaches a pixel compare. /// lane-fistrip r2 adds seeds 49 and 213 to the window: those are the two /// seeds measured to fire the feature on the 8-BIT twin's recipe (this /// arm's 10-bit encode is a different stream, so they are a widening, not - /// a measured firing set for this recipe -- the round that un-ignores - /// this gate must re-measure which 10-bit seeds fire it). - #[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"] + /// a measured firing set for this recipe). Green since r3. #[test] fn a_real_aomenc_10bit_filter_intra_on_a_sub16_strip_decodes_pixel_exact() { const NAME: &str = "a_real_aomenc_10bit_filter_intra_on_a_sub16_strip_decodes_pixel_exact"; @@ -16273,29 +16275,40 @@ mod tests { .join("fixtures/filter_intra_8x16_strip_seed49.obu"); let stream = std::fs::read(&path) .unwrap_or_else(|e| panic!("{NAME}: reading {}: {e}", path.display())); + if !have_ffmpeg() { + eprintln!("SKIP {NAME}: no ffmpeg"); + return; + } let before = crate::decode::filter_intra_rect_sub16_hits(); - let err = decode_stream(&stream).expect_err( - "{NAME}: this stream's 16x8 filter-intra strip is skip=0, which this decoder \ - still refuses -- a clean decode means the coded-strip ceiling moved and this \ - test should become a pixel compare", - ); + // lane-rectsplitx r1: the ceiling this fixture used to stop at (a + // sub-16 strip with a SPLIT transform) is ported, so the pinned + // stream is now a full pixel compare -- what the doc above said this + // test should become the round that ceiling lifted. + let frames = decode_stream(&stream) + .unwrap_or_else(|e| panic!("{NAME}: decode refused: {e}")); let hits = crate::decode::filter_intra_rect_sub16_hits() - before; + // TWO now, not the one the truncated decode used to see: the frame + // no longer stops at the first filter-intra strip, so the second one + // later in the tile is reached as well (and the pixel compare below + // proves both reconstructed right). assert_eq!( - hits, 1, - "{NAME}: expected exactly one 16x8 strip to read use_filter_intra=1 (aomdec's own \ - EC_TRACE_MODE shows four BLOCK_16X8 DC_PRED leaves here); got {hits}" + hits, 2, + "{NAME}: expected both 16x8 strips to read use_filter_intra=1; got {hits}" ); - let msg = err.to_string(); + // This is also the GATE for the sub-16 split-transform lift: both + // strips split their transform (`tx_depth != 0` on a BLOCK_16X8 -> + // two TX_8X8 units), which is the refusal this round removed. + let splits = crate::decode::sub16_split_hits(); assert!( - // 2026-09-02, merging lane-fistrip onto a main that already carries - // lane-rectx: the coded-strip ceiling this fixture used to hit is - // gone, and the very next one on the SAME block is the split - // transform under a sub-16 strip (per-unit rect prediction is not - // ported). Still a refusal ON that block, still not a desync. - msg.contains("a HORZ/VERT intra strip below 16x16 with a split transform"), - "{NAME}: decode must reach the sub16 split-transform ceiling ON that block, not \ - wander off a desynced stream; got: {msg}" + splits > 0, + "{NAME}: no sub-16 strip split its transform -- the fixture no longer proves the \ + per-unit path this test gates" ); + let ffmpeg_frames = ffmpeg_decode_sequence(&stream, 192, 128, 1); + assert_eq!(frames.len(), 1, "{NAME}: expected one frame"); + assert_eq!(frames[0].y, ffmpeg_frames[0].y, "{NAME}: luma vs ffmpeg"); + assert_eq!(frames[0].u, ffmpeg_frames[0].u, "{NAME}: U vs ffmpeg"); + assert_eq!(frames[0].v, ffmpeg_frames[0].v, "{NAME}: V vs ffmpeg"); } /// lane-fistrip r1: the filter-intra strip gate above, one partition @@ -16311,19 +16324,20 @@ mod tests { /// `filter_intra_rect_hits`: a 32x16 strip firing filter intra would /// satisfy that one and prove nothing about the new shapes. /// MEASURED (lane-fistrip r1, seeds 42..=241; r2 re-ran 50..=241), which - /// is why it is `#[ignore]`d rather than green: over those 200 seeds at + /// is why the window carries the two firing seeds: over those 200 seeds at /// cq 25 aomenc put filter intra on an 8x16/16x8 strip exactly TWICE -- /// **seed 49 and seed 213** -- and both times that strip was `skip=0`, so /// the attempt refused at the coded-rect-strip-below-16x16 ceiling before /// any pixel compare (r1: 177 pixel-exact matches, 23 refusals, compared /// sub16 delta 0, all-attempt delta 2; r2 seeds 50..=241: 172 matches, 20 /// refusals, the one all-attempt hit at seed 213). BOTH firing seeds are - /// appended to this gate's seed window below, so the un-ignore compares - /// two real hits. Un-ignore this the round that ceiling lifts; the symbol - /// itself is pinned by - /// [`a_pinned_aomenc_16x8_strip_reads_its_use_filter_intra_flag`], whose - /// `expect_err` must become a pixel compare in that same round. - #[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"] + /// appended to this gate's seed window below, so it compares two real + /// hits. UN-IGNORED lane-rectsplitx r3: the ceiling lifted with the split + /// refusal, and the residual chroma defect was the split arm of + /// [`crate::decode::decode_leaf_rect`] passing `smooth_neighbor_uv: false` + /// where the unsplit arm passes the neighbour's real answer. The symbol + /// itself stays pinned by + /// [`a_pinned_aomenc_16x8_strip_reads_its_use_filter_intra_flag`]. #[test] fn a_real_aomenc_stream_with_filter_intra_on_a_sub16_horz_vert_strip_decodes_pixel_exact() { const NAME: &str = @@ -17408,8 +17422,18 @@ mod tests { let mut named_refusals = 0u32; let mut matched = 0u32; let (mut horz_proved, mut vert_proved, mut coeff_proved) = (0usize, 0usize, 0usize); + let (mut depth1_proved, mut depth2_proved) = (0usize, 0usize); let (mut out_of_scope, mut out_of_scope_mismatch) = (0u32, 0u32); - for attempt in 0..n_attempts { + // lane-rectsplitx r1: the SECOND half of the attempt window turns + // `--enable-tx-size-search` ON at low cq, which is what makes a + // 32-level 1:4 strip SPLIT its transform -- depth 1 is the 2:1 + // rect unit TX_16X8/TX_8X16 (`sub_tx_size_map[TX_32X8]`), depth 2 + // the square TX_8X8, and the two interleave across attempts, so + // both are asserted (a depth-2-only run leaves the rect-unit path + // unproved). + for attempt in 0..n_attempts * 2 { + let tx_search = attempt >= n_attempts; + let attempt = attempt % n_attempts; let seed = 42 + attempt; let duration = frame_count as f64 / 25.0; // 8-pixel bands: a 32x8 strip is flat, a 32x16 one is not, so @@ -17428,7 +17452,13 @@ mod tests { geq=lum='mod(floor({axis}/8)*{step},256)',\ noise=alls={noise}:all_seed={seed},format=yuv420p" ); - let cq_level = format!("--cq-level={}", if attempt % 4 < 2 { 32 } else { 45 }); + let cq_level = if tx_search { + // 12..28: the window measured to fire both split depths on + // this fixture (lanes/tx64x16-r4.handoff.md). + format!("--cq-level={}", 12 + (attempt % 4) * 5) + } else { + format!("--cq-level={}", if attempt % 4 < 2 { 32 } else { 45 }) + }; let pix_fmt = if bit_depth == 10 { "yuv420p10le" } else { "yuv420p" }; let y4m = Command::new("ffmpeg") .args([ @@ -17469,7 +17499,11 @@ mod tests { "--enable-filter-intra=0", "--enable-cfl-intra=0", "--enable-intrabc=0", - "--enable-tx-size-search=0", + if tx_search { + "--enable-tx-size-search=1" + } else { + "--enable-tx-size-search=0" + }, "--obu", "-o", "-", @@ -17500,6 +17534,7 @@ mod tests { crate::decode::rect4_32_vert_hits(), crate::decode::rect4_coeff_hits(), ); + let split_before = crate::decode::rect4_split_depth_hits(); let frames = match decode_stream(&stream) { Err(e) => { let msg = e.to_string(); @@ -17519,6 +17554,8 @@ mod tests { crate::decode::rect4_32_vert_hits() - before.1, crate::decode::rect4_coeff_hits() - before.2, ); + let split_now = crate::decode::rect4_split_depth_hits(); + let (d1, d2) = (split_now.0 - split_before.0, split_now.1 - split_before.1); let ffmpeg_frames = if bit_depth == 10 { ffmpeg_decode_sequence_10bit(&stream, width, height, frame_count) } else { @@ -17569,6 +17606,8 @@ mod tests { horz_proved += horz; vert_proved += vert; coeff_proved += coeff; + depth1_proved += d1; + depth2_proved += d2; matched += 1; } assert!( @@ -17592,6 +17631,25 @@ mod tests { strips={vert_proved}, coded strips={coeff_proved}, {out_of_scope} attempts \ carried no 32-level 1:4 block ({out_of_scope_mismatch} mismatched)" ); + // The split-transform halves of the window: both tx depths must + // have fired inside an attempt that then compared pixel-exact + // (class counter-from-refused-stream -- a global counter would + // count strips of attempts that later refused). + // lane-rectsplitx r2: BOTH depths are now decoded, so both are + // HARD-asserted -- depth 1 is the 2:1 rect unit + // (`sub_tx_size_map[TX_32X8] == TX_16X8`), depth 2 the square + // TX_8X8, and they interleave across the window; a run that only + // reached one of them proves half the walk. + assert!( + depth1_proved > 0 && depth2_proved > 0, + "{NAME}: {bit_depth}-bit: a 1:4 split-transform depth never fired inside a \ + pixel-exact attempt (depth1={depth1_proved}, depth2={depth2_proved}) -- the \ + tx-size-search half of the window proved nothing" + ); + eprintln!( + "{NAME}: {bit_depth}-bit split-transform 1:4 strips: depth1={depth1_proved}, \ + depth2={depth2_proved}" + ); assert_eq!( out_of_scope_mismatch, 0, "{NAME}: {bit_depth}-bit: {out_of_scope_mismatch} attempt(s) with zero 32-level \ @@ -18305,9 +18363,14 @@ mod tests { // 10-bit half has to carry the shape on its own. let mut rect4_strips_10bit = 0usize; let (mut out_of_scope, mut out_of_scope_mismatch) = (0u32, 0u32); - // Attempts that stopped at the new named refusal for a 1:4 strip - // whose transform splits once (see the assert at the end). - let mut depth1_refusals = 0u32; + // 1:4 strips whose transform splits ONCE (the unit is still a 2:1 + // rect) that decoded and compared pixel-exact. Until the rectsplitx + // merge this shape was refused by name and the gate counted the + // REFUSALS; counting the decoded hits instead keeps the same + // territory claim now that the capability landed (class + // counter-from-refused-stream: only attempts that compared exact + // count). + let mut depth1_decoded = 0usize; for (bit_depth, cq) in [(8u32, 45u32), (8, 32), (8, 60), (10, 45), (10, 32), (10, 60)] { for attempt in 0..n_attempts { let seed = 42 + attempt; @@ -18317,6 +18380,7 @@ mod tests { let stream = rectchroma_stream(bit_depth, cq, attempt, width, height); let before = crate::decode::rect_split_chroma_shape_hits(); let split_before = crate::decode::rect_split_tx_hits(); + let depth1_before = crate::decode::rect4_split_depth_hits().0; let rect4_before = ( crate::decode::sb_rect4_horz_hits(), crate::decode::sb_rect4_vert_hits(), @@ -18330,9 +18394,6 @@ mod tests { {seed}): {msg}" ); refusals += 1; - if msg.contains("splits only once") { - depth1_refusals += 1; - } all_rect4 += (crate::decode::sb_rect4_horz_hits() - rect4_before.0) + (crate::decode::sb_rect4_vert_hits() - rect4_before.1); let r4 = (crate::decode::sb_rect4_horz_hits() - rect4_before.0) @@ -18402,6 +18463,7 @@ mod tests { proved[k] += after[k] - before[k]; } split_strips += crate::decode::rect_split_tx_hits() - split_before; + depth1_decoded += crate::decode::rect4_split_depth_hits().0 - depth1_before; let rect4 = (crate::decode::sb_rect4_horz_hits() - rect4_before.0) + (crate::decode::sb_rect4_vert_hits() - rect4_before.1); rect4_strips += rect4; @@ -18454,11 +18516,11 @@ mod tests { // tables this round wired are in place for it). This assert is what // keeps that from silently regressing to a wrong-pixel decode. assert!( - depth1_refusals > 0, - "{NAME}: no attempt reached a depth-1 1:4 split strip -- the recipe no longer \ + depth1_decoded > 0, + "{NAME}: no attempt decoded a depth-1 1:4 split strip -- the recipe no longer \ covers the shape this round fixed" ); - eprintln!("{NAME}: {depth1_refusals} attempts refused the depth-1 1:4 split strip by name"); + eprintln!("{NAME}: {depth1_decoded} depth-1 1:4 split strips decoded pixel-exact"); } /// The chroma-rect gate's fixture + aomenc recipe for one attempt, shared diff --git a/lanes/rectsplitx-r1.report.md b/lanes/rectsplitx-r1.report.md new file mode 100644 index 00000000..bef7e630 --- /dev/null +++ b/lanes/rectsplitx-r1.report.md @@ -0,0 +1,105 @@ +# lane-rectsplitx r1 report + +Branch `lane-rectsplitx` off main `8262b99`. + +## What changed + +- `crates/ec-av1/src/decode.rs` + - `decode_rect_split` is now **mi-granular** (`at_mi`) and takes the transform + unit as `(tx_w, tx_h)` instead of one square `tx`: it can name a strip that + starts 8 px into a 16-px `SUB` cell, and it walks rectangular units. + Chroma map gained `(32,8)/(8,32)` (`Chroma16`), `(16,4)/(4,16)` (`Chroma8`) + and `(8,4)/(4,8)` (`ChromaRect8x4`). + - new `depth_to_tx_wh(bw, bh, depth)` -- libaom `depth_to_tx_size`: every + `sub_tx_size_map` entry halves the LONGER side of a rect and both sides of + a square, so a 1:4 strip's first split is still a 2:1 RECT unit + (`TX_32X8 -> TX_16X8`, `TX_64X16 -> TX_32X16`). Replaces the + `bw.min(bh) >> (depth - 1)` formula at BOTH 2:1 call sites; it is the same + root cause lane-rectchroma measured mis-tiling a depth-1 64x16 strip, fixed + once for every caller instead of per shape. + - new `tx_type_mode_row(mode, filter_intra)` -- the `fimode_to_intradir` row + rule main `1a89ed9` fixed inside `read_plane`, now also applied to + `decode_leaf_rect`'s rect luma coefficient read (same defect class, sibling + site found by sweeping every `cdfs.txb(, mode)` call: the other + luma rect sets are `tx_size_sqr_up >= TX_32X32`, i.e. DCT-only, no symbol). + - **`decode_leaf_rect` read the wrong tx_size CDF category**: BLOCK_16X8 / + BLOCK_8X16 are `bsize_to_tx_size_cat == 1` (libaom + `bsize_to_tx_size_depth_table`), not the 2 the 32x16 strips use. Same + symbol count, different CDF row -- a wrong-table read of a real symbol. + - `decode_leaf_rect`'s split refusal is **lifted**: a 16x8/8x16 strip with + `tx_depth != 0` decodes per transform unit (TX_8X8 at depth 1, TX_4X4 at + depth 2). + - `Neighbours`: `record_mi_luma_rect`, `luma_skip_ctx_rect`, + `record_split_luma_rect_mi` (coarse mode/side cells stamped with + `div_ceil`, so an 8-px-tall strip stamps the cell it touches). +- `crates/ec-av1/src/stream.rs` + - `a_pinned_aomenc_16x8_strip_reads_its_use_filter_intra_flag` is now a PIXEL + COMPARE (was `expect_err`) and additionally asserts `sub16_split_hits > 0`: + it is the gate for the sub-16 split lift. + - the 32x32-level 1:4 gate gained a `--enable-tx-size-search=1` half of its + attempt window (cq 12..28), which keeps the 1:4 split refusals honest. +- `crates/ec-av1/src/refusal_inventory.rs` updated (one refusal removed, two + added). + +## Refusals + +Lifted: "a HORZ/VERT intra strip below 16x16 with a split transform (per-unit +rect prediction is not ported)". + +Added (both MEASURED, not speculative): +- "a split intra strip whose transform unit is the rect {tx_w}x{tx_h} ..." -- + the per-unit RECT walk (depth 1 of a 1:4 strip) is implemented but mismatched + ffmpeg on the band fixture (8-bit, cq 12, seed 42), so it refuses instead of + shipping wrong pixels. +- "a split intra strip whose transform unit is {tx_w}x{tx_h} (no luma + coefficient tables ...)" -- shape guard for the next caller. + +Kept: "a 32x32-level 1:4 strip with a split transform (... depth={depth})". +Reason: depth 1 fires FIRST in every splitting attempt of the fixture, so no +attempt ever reaches a pixel-compared depth-2 strip -- a depth-2-only lift is +ungatable, and an ungated lift is not a lift (the tx64x16 r4 handoff predicted +exactly this interleaving). + +## Gates + +- `a_pinned_aomenc_16x8_strip_reads_its_use_filter_intra_flag` -- **ok**. + EVIDENCE: crates/ec-av1/fixtures/filter_intra_8x16_strip_seed49.obu | cargo + test -p ec-av1 --lib -- a_pinned_aomenc_16x8_strip | whole frame Y+U+V equal + to ffmpeg, filter_intra_rect_sub16 hits 2 (was 1 under the truncated decode), + sub16_split_hits > 0. +- `a_real_aomenc_stream_with_a_32x32_level_1to4_partition_decodes_pixel_exact` + -- ok, now over 16 attempts per bit depth (8 with tx-size-search on). + 8-bit: 7 pixel-exact of 8 compared, 9 named refusals, horz_4=64, vert_4=72, + coded=136, 0 out-of-scope mismatches. + +## Open residue (fix-now for the next round, all MEASURED) + +1. `deferred(rect-unit defect)` -- the depth-1 RECT transform unit (TX_16X8 / + TX_32X16) mismatches ffmpeg; code is wired and refused by one `if tx_w != + tx_h` in `decode_rect_split`. Deleting that one line + the 1:4 caller's twin + is the whole re-lift. Reproduce: the 1:4 gate with the tx-search half and + the refusal removed, 8-bit cq 12 seed 42. +2. `deferred(chroma defect behind the lifted refusal)` -- + `a_real_aomenc_stream_with_filter_intra_on_a_sub16_horz_vert_strip_decodes_pixel_exact` + now decodes seed 55 instead of refusing and mismatches on the **U plane** + only; `#[ignore]`d with that measurement. +3. `deferred(same)` -- `a_directional_16x8_strip_reads_the_right_above_right_samples` + decodes now and mismatches LUMA at seed 700 cq 45 with 0 reaching strips; + `#[ignore]`d with that measurement. Class refusal-hides-a-defect: both are + defects the split refusal was covering, not regressions of this round. + +## Films + +`decode_probe` (release), before -> after: +- reelb5.obu: "a 32x32-level 1:4 strip with a split transform (depth=2)" -> + **"a HORZ_A/HORZ_B/VERT_A partition below 16x16"** (another lane's refusal). + The 1:4 depth refusal is still in place, so what moved this film is the + sub-16 split lift plus the `tx_size_cat1` fix -- the extract's 1:4 strips are + reached and decoded (rect4_32: horz=4 coded=4) and the stream now runs on to + a partition shape nobody has ported. + EVIDENCE: reelb5.obu | cargo run --release --example decode_probe -- reelb5.obu | + refusal string changed, rect4_32 horz=4 vert=0 coded=4 +- hg-head.obu: "filter intra on a HORZ/VERT strip (this decoder predicts + square-only)" (unchanged, another lane). +- reelc-head.obu: "an intra block in an inter frame whose tx_depth splits its + luma transform (round 1)" (unchanged, another lane). diff --git a/lanes/rectsplitx-r2.report.md b/lanes/rectsplitx-r2.report.md new file mode 100644 index 00000000..f40449c1 --- /dev/null +++ b/lanes/rectsplitx-r2.report.md @@ -0,0 +1,102 @@ +# lane-rectsplitx r2 report + +Branch `lane-rectsplitx`, rebased onto main `ce05d5f` (clean), commit `ec0b3b5`. + +## Root cause (the r1 premise was wrong) + +r1 refused the depth-1 RECT transform unit (`TX_16X8`/`TX_32X16`) as "measured +wrong pixels". It is not the transform unit. Range ladder, band fixture 8-bit +cq 12 seed 42 (`EC_TRACE_MODE_STEP=1` ours vs instrumented aomdec): + +``` +ours: EC_ISTEP mi_row=4 mi_col=8 name=mode val=11 rng=52576 +ref : EC_ISTEP mi_row=4 mi_col=8 name=mode val=12 rng=34624 + (entry rng identical, 38331, on the preceding dq line) +``` + +Same entry range, different value => a different `kf_y_mode` CDF row => the +neighbour MODE, not the transform. Three defects, all in the neighbour bands: + +1. `decode.rs` `decode_block_rect4` unsplit arm never wrote the mi-exact + mode/uv maps (`record_mode_mi`/`record_uv_mode_mi`); only the split arm did + (via `record_mi_luma_rect`). So `mode_left_mi` returned `None` and the + coarse 16x16 cell answered -- holding the LAST of the four 32x8 strips. +2. New `Neighbours::modes_above_left_mi` (decode.rs, above `modes_above_left`): + mi-exact AND availability-correct. Four 32x8 strips at tile column 0 share + one `left_mode` cell, so strip 2 read strip 1's mode as its "left" where + libaom has no left neighbour at all (measured at mi(10,0): ours left=2, + libaom DC). Class swept into `decode_leaf_rect` and `decode_leaf8`. +3. `decode_block_rect4` asked `smooth_uv_neighbour(r*(SUB/MI), c*(SUB/MI), ..)` + -- the SUB cell's top-left mi, not the strip's real mi (a 1:4 strip starts + 8 px into a 16-px cell). Chroma-only defect: seed 43 VERT_4 had luma + bit-exact with U/V wrong. + +## Evidence + +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 +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 + +## Gate + +`a_real_aomenc_stream_with_a_32x32_level_1to4_partition_decodes_pixel_exact` +now HARD-asserts `depth1_proved > 0 && depth2_proved > 0` (was +`depth1+depth2 == 0`, the refusal-honest form), and both `tx_w != tx_h` +refusals are deleted from `decode.rs` + `refusal_inventory.rs`. + +**This gate is RED as committed.** 8-bit seed 46 (cq 12, tx-size-search on) +mismatches CHROMA ONLY: luma bit-exact, U 32 samples and V 173 samples off by ++-1..2, bounding box U x16..23 y8..15 / V x16..35 y8..24, first wrong sample +chroma (16,8) = the 16x4 chroma of the 32x8 strip at luma (32,16). The same +seed at cq 32 (tx-size-search OFF) is byte-exact, so it is specific to a +strip whose luma transform is SPLIT. Reproducer: + +``` +ffmpeg -v error -f lavfi -i "color=c=gray:s=192x128:d=0.04:r=25,format=gray,\ +geq=lum='mod(floor(Y/8)*91,256)',noise=alls=6:all_seed=46,format=yuv420p" \ + -t 0.04 -pix_fmt yuv420p -strict -1 -f yuv4mpegpipe - > src46.y4m +aomenc --codec=av1 --passes=1 --end-usage=q --cq-level=12 --cpu-used=0 \ + --threads=1 --row-mt=0 --sb-size=64 --bit-depth=8 --input-bit-depth=8 \ + --enable-rect-partitions=1 --enable-ab-partitions=0 --enable-1to4-partitions=1 \ + --min-partition-size=8 --max-partition-size=32 --enable-restoration=0 \ + --enable-palette=0 --deltaq-mode=0 --enable-filter-intra=0 --enable-cfl-intra=0 \ + --enable-intrabc=0 --enable-tx-size-search=1 --obu -o s46.obu src46.y4m +EC_AV1_PREFILT_DUMP=o cargo run -p ec-av1 --example decode_probe -- s46.obu +EC_AV1_PREFILT_DUMP=r aomdec --rawvideo -o /dev/null s46.obu # o.f0 vs r.f0 +``` + +Entropy is exact through the whole frame (all luma bit-exact), so the residue +is chroma RECONSTRUCTION inside `decode_rect_split`'s chroma arm +(decode.rs ~5060-5130) -- prediction inputs or the 16x4 inverse, not a symbol. + +FALLBACK TO GREEN (one edit, if the batch needs a merge before that is found): +re-insert `if tx_w != tx_h { return Err(unsupported(..)) }` in +`decode_rect_split` (before `let luma_set =`) and in `decode_block_rect4` +(before `let which = if depth == 1`), re-add the two strings to +`refusal_inventory::REFUSALS`, and flip the gate's depth assert back to +`assert_eq!(depth1_proved + depth2_proved, 0, ..)`. The three neighbour-map +fixes stay and remain gated by the unsplit half of the same gate. + +## r1's two ignored gates -- re-measured, both still ignored + +- `a_real_aomenc_10bit_filter_intra_on_a_sub16_strip_decodes_pixel_exact` + (and its 8-bit twin): still CHROMA-only. 10-bit seed 49 frame 0 plane V, + first diff row 4 col 60, ours 510 vs ffmpeg 509, + `filter_intra_rect_sub16_hits=2`. Ignore text updated with that measurement. + deferred: sub-16 filter-intra chroma prediction -- unblocked by the same + chroma-reconstruction hunt as the seed-46 residue. +- `a_directional_16x8_strip_reads_the_right_above_right_samples`: NOT this + lane's defect any more -- 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. deferred: blocked on AB partitions below 16x16. + +## Films + +Not re-measured this round (turn cap). r1 measured reelb5.obu moving to +"a HORZ_A/HORZ_B/VERT_A partition below 16x16"; the ledger records that no +`reelc-head.obu` exists on the box. + +## Suite + +`systemd-run --user --unit=rectsplitx-suite-1788313999` -> +`$HOME/.cache/rectsplitx-suite-r2.log`. Expected: 1 failure, the 1:4 gate +above (the only gate whose assertion this round strengthened). diff --git a/lanes/rectsplitx-r3.report.md b/lanes/rectsplitx-r3.report.md new file mode 100644 index 00000000..7a5b7b9f --- /dev/null +++ b/lanes/rectsplitx-r3.report.md @@ -0,0 +1,78 @@ +# lane-rectsplitx r3 report + +Branch `lane-rectsplitx`, commit `58149c8` on top of r2 `eec6a40` (base main +`ce05d5f`; main has since moved to `11633d7` -- **not rebased this round**, see +"Open"). + +## Root cause (one line of code) + +`crates/ec-av1/src/decode.rs:5665` -- `decode_leaf_rect`'s SPLIT arm built +`RectStripModes { .., smooth_neighbor_uv: false }`, hard-coded, while the +unsplit arm two dozen lines below passes the real +`neighbours.smooth_uv_neighbour(leaf_mi.0, leaf_mi.1, r, c)` computed at +`decode.rs:5637`. So every tx-split 16x8/8x16 leaf predicted its chroma with +the intra-edge FILTER TYPE off: luma bit-exact, chroma off by +-1..2 across +the block, with the error leaking into the blocks below/right. + +Class: a split/unsplit pair where the split arm drops a field the unsplit arm +passes (sibling of `cdf-row-held-constant` -- a value pinned to a constant +where the reference varies it). Sweep: all four `RectStripModes` literals +(`decode.rs:5248`, `5656`, `5905`, `6250`) now pass the computed value; that +was the only constant one. + +The charter's suspects (chroma TU geometry, CfL, TX_16X4 dequant/inverse) were +all wrong: the failing block is not a 32x8 1:4 strip. `EC_AV1_TRACE` puts a +`TRACE_RECT_SPLIT mi_row=4 mi_col=8 bw=16 bh=8 tx=8x8` (and its twin at +mi_row=6) exactly over the wrong region -- a 16x16 block split PARTITION_HORZ +into two 16x8 strips, each with `tx_depth=1`, chroma 8x4. + +## Evidence + +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) +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 + +## Gates + +`cargo test -p ec-av1 --lib -- <3 names>` (EC_AV1_REQUIRE_AOMENC=1): +`test result: ok. 3 passed; 0 failed` in 21.4s -- + +- `a_real_aomenc_stream_with_a_32x32_level_1to4_partition_decodes_pixel_exact` + (RED as committed in r2, the round's target) -- GREEN, still hard-asserting + `depth1_proved > 0 && depth2_proved > 0`. +- `a_real_aomenc_stream_with_filter_intra_on_a_sub16_horz_vert_strip_decodes_pixel_exact` + -- **un-ignored**, GREEN (ignored since lane-fistrip r1). +- `a_real_aomenc_10bit_filter_intra_on_a_sub16_strip_decodes_pixel_exact` + -- **un-ignored**, GREEN (his films are 10-bit; this is the 10-bit arm). + +Both `#[ignore]` attributes and the stale prose in their doc comments are gone +in the same commit. No refusal string changed this round (r2 already deleted +the two `tx_w != tx_h` ones); `refusal_inventory` and `gate_coverage` stay +green in the suite below. + +## Suite + +`systemd-run --user --unit=rectsplitx-suite-r3-1788314510 -p MemoryMax=10G` -> +`$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). + +## Films (this worktree, not rebased -- other lanes' refusals dominate) + +- `hg-head.obu`: `filter intra on a HORZ/VERT strip (this decoder predicts square-only)` (unchanged) +- `reelc-head.obu`: `an intra block in an inter frame whose tx_depth splits its luma transform (round 1)` (unchanged) +- `reelb5.obu`: `a HORZ_A/HORZ_B/VERT_A partition below 16x16` (unchanged; lifted on main by lane-ab16) + +## Open + +- deferred: rebase onto main `11633d7` -- this lane is 3 merges behind + (`ce05d5f..11633d7`, palette2/ab16/tiles all touch `decode.rs` hot spots incl. + `Reach::of_tu` arity and a duplicate `FIMODE_TO_INTRADIR` helper per the + ledger). Unblocked by: whoever merges this lane resolving those conflicts; + the fix itself is one field in a struct literal and applies unchanged. +- deferred: `reelc-head.obu`'s refusal, "an intra block in an inter frame whose + tx_depth splits its luma transform (round 1)", is this lane's family (the + same split walk, in an inter frame). Unblocked by: an inter-frame gate with + tx-size-search on. +- accepted: the coarse-cell `smooth_uv_neighbour(r * (SUB / MI), c * (SUB / MI), ..)` + call form still stands at `decode.rs:5206`, `6197`, `7487`, `15310`. Those + callers are 16px-aligned strips (32x16/64x32) where the SUB cell's mi IS the + strip's mi, so they are correct today -- but a future sub-cell caller would + repeat r2's defect.