From 6f2548b2a63c004bea2aceb21711beec2587170e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Thu, 24 Sep 2026 16:52:37 +0300 Subject: [PATCH] lane-av1-ibcrect: intrabc on 128-root HORZ/VERT strips decodes pixel-exact; per-unit chroma replay after the end-of-block record Lift the refusal "intra block copy on a HORZ/VERT/1:4 rect intra strip (reconstruction is not ported at this shape)" for its last site, the 128 root: decode_block_128rect now routes use_intrabc blocks to the new decode_intrabc_128rect (BLOCK_128X64 / BLOCK_64X128), porting libaom decode_token_recon_block's inter arm at that shape -- the whole-block prediction, the TX_64X64-rooted var-tx tree per 64x64 mu chunk, chroma at av1_get_max_uv_txsize(BLOCK_128X64) = TX_32X32 one unit per plane per chunk (av1_get_tx_type inheritance of the covering luma leaf's coded tx_type), the lossless TX_4X4-chroma walk, and the skip arm's av1_reset_entropy_context band reset. refusal_inventory.rs drops the string and its pairing; decode_probe.rs prints the new counters (intrabc_128rect, part128 census) and stream.rs exposes intrabc_128rect_hits(). Root cause of the r2 desync (class override-slot-on-one-arm): the mu chunk loop stamped each TX_32X32 chroma unit's own entropy state (av1_set_entropy_contexts), but the end-of-block record_split_luma_rect_mi re-stamped BOTH chroma planes over the whole 128x64 span with ONE neighbour_state composed from the full grids -- level = the SUM of both 64x64 chunks' units, dc = chunk-0's top-left sign. The next block read txb_skip off the smeared state ("chunk-1 U level 1 pollutes block 3's left band"). Fix mirrors the inter-128 path's proven shape: a mu_chroma flag set on the lossless and TX_32X32 arms, then after the record a per-unit replay -- slice each chunk's TX_32X32 (TX_4X4 when lossless) grid out of the composed plane grid and record_mi_chroma it at its own luma-mi origin, in mu-chunk raster order so a later unit still wins the shared seam cells. Witness (the name refusal_inventory cites): an_sb128_rect_strip_with_intrabc_decodes_pixel_exact -- real aomenc --sb-size=128 --tune-content=screen --enable-intrabc=1 over the deterministic geq sinusoid sources (gradients ignores its seed, the flakes were that): - arm 1 HORZ 384x320 cq32: 5 decode-order frames pixel-exact vs the instrumented aomdec, intrabc_128rect_hits +14 (all skip=false 128x64); - arm 2 VERT 512x512 cq45: 5 frames pixel-exact, +1 (unskipped 64x128 at mi(64,96)); - arm 3 10-bit decode-only: 5 frames pixel-exact, +15 -- the encoder engages the shape at 10 bit here, so the per-depth firing assert was NOT needed as a gated gap. Both orientations hard-assert engagement + exactness; every decode-order frame (hidden alt-refs included) compared via decode_all_frames_vs_oracle. Hunt r2 sweep (fixtures ~/.cache/ibcrect-hunt, Agent11-2): all four 128rect-engaging fixtures E1(hits=3)/E2(14)/E5/E8 decode 0 diff bytes vs ffmpeg; the five diffing ones (A1/A2/A3/B1/D1) have intrabc_128rect=0 -- pre-existing rect/leaf8-intrabc and part128-split paths, not this lane's shape; C1/C2/E3/E4/E6/E7/F1/F2 clean. Sibling gates green on the merged tree: intrabc family 13 passed, sb128 family 9 passed, lossless/rect_strip 16 passed, 128-none roots 6 passed, screen/palette/leaf8 18 passed. --- crates/ec-av1/examples/decode_probe.rs | 14 + crates/ec-av1/src/decode.rs | 484 ++++++++++++++++++++++++- crates/ec-av1/src/refusal_inventory.rs | 168 +++++++-- crates/ec-av1/src/stream.rs | 201 ++++++++++ 4 files changed, 823 insertions(+), 44 deletions(-) diff --git a/crates/ec-av1/examples/decode_probe.rs b/crates/ec-av1/examples/decode_probe.rs index 2d3a9fc6..576ca44d 100644 --- a/crates/ec-av1/examples/decode_probe.rs +++ b/crates/ec-av1/examples/decode_probe.rs @@ -63,6 +63,12 @@ fn main() { ec_av1::decode::intrabc_rect_hits(), ec_av1::decode::intrabc_rect_vartx_hits() ); + // lane-av1-ibcrect: `use_intrabc` on a 128-root HORZ/VERT strip -- + // the shape `decode_block_128rect` used to refuse. + println!( + "intrabc_128rect: {}", + ec_av1::stream::intrabc_128rect_hits() + ); let (rtu, rsplit, robmc) = ec_av1::stream::rect_inter_tu_counters(); println!("rect_inter: tu={rtu} txsplit={rsplit} obmc_leaf={robmc}"); println!( @@ -142,6 +148,14 @@ fn main() { "sb128_rect: edge_horz={} edge_vert={} inter_128x64={} inter_64x128={}", sb.0, sb.1, sb.2, sb.3 ); + // lane-av1-ibcrect: the interior 128-root partition arms and the key + // frame's intra 128-axis blocks, so a recipe sweep can tell "the + // encoder never chose HORZ/VERT at the 128 root" from "it did". + let p128 = ec_av1::stream::part128_census(); + println!( + "part128: split={} none={} horz={} vert={} ab={:?} intra_horz={} intra_vert={}", + p128.0, p128.1, p128.2, p128.3, p128.4, p128.5, p128.6 + ); // lane-sbab r1: the superblock-level inter AB arms. let sbab = ec_av1::decode::sb_ab_inter_hits_by_arm(); println!( diff --git a/crates/ec-av1/src/decode.rs b/crates/ec-av1/src/decode.rs index 132726fe..c7c73749 100644 --- a/crates/ec-av1/src/decode.rs +++ b/crates/ec-av1/src/decode.rs @@ -3810,6 +3810,27 @@ pub fn intrabc_rect_vartx_hits() -> usize { INTRABC_RECT_VARTX_HITS.with(|c| c.get()) } +thread_local! { + /// lane-av1-ibcrect: `use_intrabc` blocks on a 128-root HORZ/VERT strip + /// (BLOCK_128X64 / BLOCK_64X128) whose reconstruction + /// [`decode_intrabc_128rect`] ran -- the shape the named refusal used to + /// guard (`decode_block_128rect`). A refused block bumps + /// [`INTRABC_HITS`] but never this one. + static INTRABC_128RECT_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; +} + +/// Current value of [`INTRABC_128RECT_HITS`]. +#[allow(dead_code)] // read only from the `#[cfg(test)]` gates +pub fn intrabc_128rect_hits() -> usize { + INTRABC_128RECT_HITS.with(|c| c.get()) +} + +/// Zeroes [`INTRABC_128RECT_HITS`]. +#[allow(dead_code)] // read only from the `#[cfg(test)]` gates +pub(crate) fn reset_intrabc_128rect_hits() { + INTRABC_128RECT_HITS.with(|c| c.set(0)); +} + /// Current value of [`INTRABC_VARTX_HITS`]. #[allow(dead_code)] // read only from the `#[cfg(test)]` gates pub(crate) fn intrabc_vartx_hits() -> usize { @@ -11409,6 +11430,447 @@ fn decode_intrabc_rect( Ok(()) } +/// lane-av1-ibcrect: reconstruction for a `use_intrabc` block on a 128-root +/// HORZ/VERT strip (`BLOCK_128X64` / `BLOCK_64X128`) -- the shape +/// `decode_block_128rect` refused by name before this port. libaom decodes +/// such a block through the INTER machinery (an intrabc block +/// `is_inter_block`): `predict_inter_block` copies the whole block from this +/// frame's own reconstruction at the integer block vector once, then +/// `decode_token_recon_block`'s inter arm walks 64x64 "mu" chunks -- +/// per chunk every plane, luma units at the block's own resolved transform +/// (`read_block_tx_size_rect`, TX_64X64 roots) and chroma at +/// `av1_get_max_uv_txsize(BLOCK_128X64)` = TX_32X32, one unit per plane per +/// chunk at 4:2:0. Chroma never codes its own `tx_type`; each unit inherits +/// the coded type of the luma leaf covering its quadrant (`av1_get_tx_type`, +/// blockd.h:1291). `mode`/`uv_mode` read as `DC_PRED`/`UV_DC_PRED` back in +/// [`read_intra_mode_rect`]; no palette/filter-intra/CFL symbol exists here. +#[allow(clippy::too_many_arguments)] +fn decode_intrabc_128rect( + dec: &mut SymbolDecoder, + cdfs: &mut Cdfs, + neighbours: &mut Neighbours, + (mi_r, mi_c): (usize, usize), + (bw, bh): (usize, usize), + skip: bool, + (dv_row, dv_col): (i32, i32), + y: &mut PlaneBuf<'static>, + u: &mut PlaneBuf<'static>, + v: &mut PlaneBuf<'static>, + base_q_idx: u8, + fctx: &crate::decode::FrameCtx, +) -> Result<()> { + hit!(INTRABC_128RECT_HITS); + if crate::envflags::env_flag!("EC_AV1_TRACE") { + let (rng, _) = dec.debug_state(); + eprintln!( + "EC_IBC128 mi_row={mi_r} mi_col={mi_c} bw={bw} bh={bh} skip={skip} dv=({dv_row},{dv_col}) rng={rng}" + ); + } + let (px, py) = (mi_c * MI, mi_r * MI); + let (cpx, cpy) = (px / 2, py / 2); + let (cw, ch) = (bw / 2, bh / 2); + // The square strides the proven INTER path lays its residual grids, + // prediction windows and `TxParams` at (see [`decode_intrabc_rect`]'s r2 + // note): 128/64 here. + let side = bw.max(bh); + let cside = cw.max(ch); + // `av1_calc_mi_size`'s 8-px-aligned grid: units past the frame edge code + // nothing (`decode_reconstruct_tx`'s max_blocks_* early return). + let mi_cols = 2 * y.true_width.div_ceil(8); + let mi_rows = 2 * y.true_height.div_ceil(8); + // An intrabc block is is_inter_block: the tx tree is the INTER one, and + // [`read_block_tx_size_rect`]'s 128-root branch already carries the + // LARGEST (no symbol, two TX_64X64 units), TX_MODE_SELECT (var-tx tree + // rooted at TX_64X64), skip (band stamp only) and lossless (TX_4X4 grid) + // arms (lane-sb128c r7). + let leaves = read_block_tx_size_rect( + dec, + cdfs, + neighbours, + (mi_r, mi_c), + (bw, bh), + (mi_cols, mi_rows), + skip, fctx, + )?; + // Whole-block prediction, once, before any coefficient is read + // (`predict_inter_block`); the source is this frame's own + // reconstruction, including the writes this superblock has queued. + flush_recon(fctx, y, u, v); + let mut pred_y_dense = vec![0u16; bw * bh]; + mc::predict_with_filter( + &y.data, y.width, y.true_width, y.true_height, + mv_to_q4(px, dv_col, true), mv_to_q4(py, dv_row, true), + bw, bh, mc::InterpFilterKind::Bilinear, &mut pred_y_dense, fctx, + ); + let mut pred_y = vec![0u16; side * side]; + for row in 0..bh { + pred_y[row * side..][..bw].copy_from_slice(&pred_y_dense[row * bw..][..bw]); + } + let mut pred_u_dense = vec![0u16; cw * ch]; + mc::predict_with_filter( + &u.data, u.width, u.true_width, u.true_height, + mv_to_q4(cpx, dv_col, false), mv_to_q4(cpy, dv_row, false), + cw, ch, mc::InterpFilterKind::Bilinear, &mut pred_u_dense, fctx, + ); + let mut pred_u = vec![0u16; cside * cside]; + for row in 0..ch { + pred_u[row * cside..][..cw].copy_from_slice(&pred_u_dense[row * cw..][..cw]); + } + let mut pred_v_dense = vec![0u16; cw * ch]; + mc::predict_with_filter( + &v.data, v.width, v.true_width, v.true_height, + mv_to_q4(cpx, dv_col, false), mv_to_q4(cpy, dv_row, false), + cw, ch, mc::InterpFilterKind::Bilinear, &mut pred_v_dense, fctx, + ); + let mut pred_v = vec![0u16; cside * cside]; + for row in 0..ch { + pred_v[row * cside..][..cw].copy_from_slice(&pred_v_dense[row * cw..][..cw]); + } + let (luma_grid, u_grid, v_grid); + // lane-av1-ibcrect: whether the coded arm stamped its CHROMA neighbour + // contexts per transform unit -- the replay after this fn's end-of-block + // record restores them (the record itself re-stamps both planes with ONE + // composed state, class `override-slot-on-one-arm`). + let mut mu_chroma = false; + if skip { + // No residual syntax at all: the prediction IS the block. Strides are + // `side`/`cside`, not `bw` -- `reconstruct_mc_rect` indexes + // `row * stride + w` for row in 0..h (the r5 VERT-strip overrun). + push_mc_rect(0, px, py, side, bw, bh, Pred::Inline(&pred_y, side), &ZERO_RESIDUAL[..side * side], fctx); + push_mc_rect(1, cpx, cpy, cside, cw, ch, Pred::Inline(&pred_u, cside), &ZERO_RESIDUAL[..cside * cside], fctx); + push_mc_rect(2, cpx, cpy, cside, cw, ch, Pred::Inline(&pred_v, cside), &ZERO_RESIDUAL[..cside * cside], fctx); + if let Some(ls) = leaves.as_ref() { + // A LOSSLESS frame's `read_block_tx_size_rect` resolves the TX_4X4 + // grid before it looks at `skip`; the skipped block still zeroes + // its entropy-band footprint over every unit (libaom + // `av1_reset_entropy_context` under `if (mbmi->skip_txfm)`) -- + // the same arm [`decode_intrabc_rect`]'s loss64 merge added. + hit!(SKIP_LOSSLESS_BAND_RESET_HITS); + for &(row, col, tw, th) in ls { + neighbours.record_mi_luma_rect( + (mi_r + row, mi_c + col), + tw, + th, + &ZERO_RESIDUAL[..tw * th], + ); + } + } + luma_grid = Grid::Zero(side * side); + u_grid = Grid::Zero(cside * cside); + v_grid = Grid::Zero(cside * cside); + } else { + let leaves = leaves.expect( + "read_block_tx_size_rect returns None only for skip below 128 at this shape", + ); + // libaom `get_transform_size`'s split override applies to LUMA only, + // per leaf -- each unit's own transform edges get filtered + // ([`decode_intrabc_rect`]'s P2, the proven inter path's step). + for &(row, col, tw, th) in leaves.iter() { + neighbours.fill_lf_grid_leaf_luma( + (mi_r + row, mi_c + col), + tw / MI, + th / MI, + tw as u8, + th as u8, + ); + } + let reduced = fctx.reduced_tx_set_inter.with(std::cell::Cell::get); + let mut u_units: Vec = Vec::new(); + let mut v_units: Vec = Vec::new(); + let mut leaf_tx_types: Vec<(usize, usize, usize, usize, TxType)> = Vec::new(); + // Frame-edge clip of the mu walk (`max_block_wide/high`): a unit whose + // top-left sample is outside the frame codes nothing. + let max_w_mi = (bw / MI).min(mi_cols.saturating_sub(mi_c)); + let max_h_mi = (bh / MI).min(mi_rows.saturating_sub(mi_r)); + for (idx, &(row, col, tw, th)) in leaves.iter().enumerate() { + debug_assert_eq!(tw, th, "a square TX_64X64 tree root only yields square leaves"); + let tu_mi = (mi_r + row, mi_c + col); + let (tu_px, tu_py) = (px + col * MI, py + row * MI); + if tu_px >= y.true_width || tu_py >= y.true_height { + continue; + } + let tu_pred = Pred::Inline(&pred_y, side).offset(row * MI * side + col * MI); + let scan = default_scan(tw.min(32)); + let tu_skip_ctx = neighbours.luma_skip_ctx(tu_mi, tw / MI); + let (tu_grid, tu_tx_type) = read_inter_plane( + dec, + cdfs, + inter_txbset_for(tw, reduced), + &scan, + 0, + neighbours.around_mi(tu_mi, tw)[0], + 0, + y, + tu_px, + tu_py, + tw, + base_q_idx, + tu_pred, + None, + Some(tu_skip_ctx), fctx, + )?; + leaf_tx_types.push((row, col, tw, th, tu_tx_type)); + neighbours.record_mi_luma_rect(tu_mi, tw, th, &tu_grid); + // libaom `decode_token_recon_block` codes EVERY PLANE of a 64x64 + // mu chunk before the next one starts: once this chunk's leaves + // are done, its chroma is read immediately (the inter 128 path's + // interleave). + let chunk = (row / 16, col / 16); + let done = idx + 1 == leaves.len() + || (leaves[idx + 1].0 / 16, leaves[idx + 1].1 / 16) != chunk; + if done { + let (cr, cc) = chunk; + // `av1_get_max_uv_txsize(BLOCK_128X64)` = TX_32X32: one + // TX_32X32 chroma unit per plane per chunk at 4:2:0, raster + // within the chunk, plane-major inside the chunk. + let cu_tx = 32usize; + let chunk_chroma = cside * 64 / side; + let unit_luma = cu_tx * (side / cside); + let chunk_w_mi = 16.min(max_w_mi.saturating_sub(cc * 16)); + let chunk_h_mi = 16.min(max_h_mi.saturating_sub(cr * 16)); + let units_x = chunk_w_mi / (unit_luma / MI); + let units_y = chunk_h_mi / (unit_luma / MI); + if lossless(fctx) { + // TX_4X4 chroma units over this chunk (lane-lossless2's + // walk, shared with the inter 128 path). + read_inter_chroma_lossless( + dec, cdfs, neighbours, u, v, + Pred::Inline(&pred_u, cside), Pred::Inline(&pred_v, cside), + (mi_r, mi_c), (cpx, cpy), + (cc * chunk_chroma, cr * chunk_chroma), + (chunk_chroma, chunk_chroma), + (cw, ch), + cside, 0, base_q_idx, + &mut u_units, &mut v_units, fctx, + )?; + // lane-av1-ibcrect: read_inter_chroma_lossless stamped + // every TX_4X4 unit's own context (`record_mi_chroma` + // inside the walk) -- the end-of-block record below must + // not overwrite them with the composed grid (the inter + // 128 path sets the same flag on this arm). + mu_chroma = true; + continue; + } + let cu_scan = default_scan(cu_tx); + for plane_idx in 1..3 { + let (src, buf) = if plane_idx == 1 { + (Pred::Inline(&pred_u, cside), &mut *u) + } else { + (Pred::Inline(&pred_v, cside), &mut *v) + }; + for ur in 0..units_y { + for uc in 0..units_x { + let unit_mi = ( + mi_r + cr * 16 + ur * (unit_luma / MI), + mi_c + cc * 16 + uc * (unit_luma / MI), + ); + // Per unit, AFTER the earlier units' stamps: this + // unit's coefficient context must see them. + let cu_around = neighbours.around_mi(unit_mi, unit_luma); + if crate::envflags::env_flag!("EC_ECDUMP") { + for p in 1..3 { + let ab: Vec = (0..unit_luma / MI) + .map(|k| { + format!( + "{:?}/{}", + neighbours.above[unit_mi.1 + k][p].dc, + neighbours.above[unit_mi.1 + k][p].level + ) + }) + .collect(); + let lf: Vec = (0..unit_luma / MI) + .map(|k| { + format!( + "{:?}/{}", + neighbours.left[unit_mi.0 + k][p].dc, + neighbours.left[unit_mi.0 + k][p].level + ) + }) + .collect(); + eprintln!( + "EC_IBC128_BANDS mi=({mi_r},{mi_c}) unit=({cr},{cc}) plane={p} ctx=({},{},{}) above=[{}] left=[{}]", + cu_around[p].0, cu_around[p].1, cu_around[p].2, ab.join(","), lf.join(",") + ); + } + } + let (cu_x, cu_y) = ( + cpx + cc * chunk_chroma + uc * cu_tx, + cpy + cr * chunk_chroma + ur * cu_tx, + ); + // `av1_get_tx_type` (blockd.h:1291): an inter + // block's chroma unit never codes a tx_type; it + // inherits the coded type of the luma leaf + // covering its own quadrant (all of this chunk's + // leaves are read by now). + let unit_rel_mi = ( + unit_mi.0 - mi_r, + unit_mi.1 - mi_c, + ); + let covering = leaf_tx_types + .iter() + .copied() + .find(|&(lr, lc, lw, lh, _)| { + lr <= unit_rel_mi.0 + && unit_rel_mi.0 < lr + lh / MI + && lc <= unit_rel_mi.1 + && unit_rel_mi.1 < lc + lw / MI + }) + .map(|(_, _, _, _, t)| t); + let cu_pred = src.offset( + (cr * chunk_chroma + ur * cu_tx) * cside + + cc * chunk_chroma + + uc * cu_tx, + ); + let cu_grid = read_inter_plane( + dec, + cdfs, + TxbSet::Chroma32, + &cu_scan, + plane_idx, + cu_around[plane_idx], + 0, + buf, + cu_x, + cu_y, + cu_tx, + base_q_idx, + cu_pred, + Some(covering.unwrap_or(TxType::DctDct)), + Some(3), fctx, + )? + .0; + // Immediately, so the NEXT unit reads this one's + // coefficient context. + neighbours.record_mi_chroma( + unit_mi, + unit_luma, + unit_luma, + plane_idx, + &cu_grid, + ); + if crate::envflags::env_flag!("EC_ECDUMP") { + let st = crate::decode::neighbour_state(&cu_grid); + eprintln!( + "EC_IBC128_STAMP mi=({mi_r},{mi_c}) unit=({cr},{cc}) plane={plane_idx} state=({:?},{})", + st.dc, st.level + ); + } + hit!(CHROMA_SPLIT_TX_HITS); + // lane-av1-ibcrect: per-unit chroma context -- the + // end-of-block record's composed-grid re-stamp + // must not stand (replayed below). + mu_chroma = true; + let dst = mu_units( + if plane_idx == 1 { &mut u_units } else { &mut v_units }, + cside * cside, + ); + for rr in 0..cu_tx { + let start = (cr * chunk_chroma + ur * cu_tx + rr) + * cside + + cc * chunk_chroma + + uc * cu_tx; + dst[start..start + cu_tx] + .copy_from_slice(&cu_grid[rr * cu_tx..][..cu_tx]); + } + } + } + } + } + } + // The block-level luma bands were recorded per leaf above; the + // composed chroma grids carry every unit in place. + luma_grid = Grid::Zero(side * side); + u_grid = if u_units.is_empty() { + Grid::Zero(cside * cside) + } else { + Grid::Own(std::mem::take(&mut u_units)) + }; + v_grid = if v_units.is_empty() { + Grid::Zero(cside * cside) + } else { + Grid::Own(std::mem::take(&mut v_units)) + }; + } + // Bookkeeping (see [`decode_intrabc_rect`]): DC_PRED everywhere a + // neighbour reads a mode, zeroed palette state, the skip grid, the + // TXFM_CONTEXT bands (`read_block_tx_size_rect` already stamped them), + // and the DV into the intrabc mi grid. + if skip { + neighbours.record_rect_mi( + (mi_r, mi_c), bw, bh, DC_PRED, DC_PRED, + &[&luma_grid[..], &u_grid[..], &v_grid[..]], + ); + } else { + neighbours.record_split_luma_rect_mi( + (mi_r, mi_c), bw, bh, DC_PRED, DC_PRED, [&u_grid[..], &v_grid[..]], + ); + } + // lane-av1-ibcrect: the coded arm's chroma contexts were stamped PER + // TRANSFORM UNIT (libaom `av1_set_entropy_contexts` inside + // `decode_reconstruct_tx`'s mu-chunk loop), but the record above re-stamps + // both planes with ONE `neighbour_state(composed_grid)` over the whole + // span -- level = the SUM of every unit's levels and dc = the top-left + // unit's sign (lane-vert46 r1 measured the same smearing at the 64x128 + // inter block: the next block read a stale `dc_sign_ctx` one row low). + // Measured on this shape: the 128x64 block at mi(64,32) of the + // `ibcrect-hunt/E2` sb128 screen stream left chunk-1 U's level 1 smeared + // into chunk-0's cells and the block below read `txb_skip` off the sum. + // Replay every coded unit's own state after the record, in mu-chunk order + // so a later unit still wins over an earlier one on the shared seam cells + // (the composed construction `mu_chroma_units` uses, transcribed here). + if mu_chroma { + let cu = if lossless(fctx) { 4usize } else { 32usize }; + // The unit's own footprint on the LUMA mi grid (the chroma context + // bands are luma-mi indexed, [`Self::record_mi_chroma`]'s + // convention): 8 px x2 per TX_4X4 unit, 64 px per TX_32X32 one. + let unit_luma = cu * 2; + // Raster over the block's chroma plane, `chunk_chroma` per mu chunk + // (the same extents the read loop above laid the composed grid out + // at) -- a unit the frame edge clipped codes nothing and carries no + // composed samples beyond the clip, so it replays as the zero state + // exactly like libaom's uncoded unit. + let chunk_chroma = cside * 64 / side; + let (rows, cols) = ((ch / chunk_chroma).max(1), (cw / chunk_chroma).max(1)); + for cr in 0..rows { + for cc in 0..cols { + let unit_mi = (mi_r + cr * (unit_luma / MI), mi_c + cc * (unit_luma / MI)); + for (plane_idx, grid) in [(1usize, &u_grid), (2usize, &v_grid)] { + let mut unit = Vec::with_capacity(cu * cu); + for rr in 0..cu { + let start = + (cr * chunk_chroma + rr) * cside + cc * chunk_chroma; + unit.extend_from_slice(&grid[start..start + cu]); + } + neighbours.record_mi_chroma( + unit_mi, unit_luma, unit_luma, plane_idx, &unit, + ); + } + } + } + } + neighbours.record_palette_y_rect((mi_r, mi_c), bw, bh, 0, [0u16; 8]); + neighbours.record_palette_uv_rect((mi_r, mi_c), bw, bh, 0, [0u16; 8]); + neighbours.fill_skip_grid_rect((mi_r, mi_c), bw / MI, bh / MI, skip); + neighbours.fill_lf_grid_rect( + (mi_r, mi_c), + bw / MI, + bh / MI, + bw.min(64) as u8, + bh.min(64) as u8, + 0, fctx, + ); + record_intrabc_mi_rect( + mi_r, + mi_c, + bw / MI, + bh / MI, + Some((dv_row, dv_col)), + neighbours, + fctx, + ); + Ok(()) +} + /// Decodes one true `bw`x`bh` `PARTITION_HORZ`/`PARTITION_VERT` intra strip /// (lane-intradisp r1, spec `decode_block` restricted to a 32x32 quadrant's /// two rect children). Only the `skip` case is supported: `skip`/`y_mode`/ @@ -16437,10 +16899,24 @@ fn decode_block_128rect( mi_r, mi_c, fctx, )?; - if intrabc.is_some() { - return Err(unsupported( - "intra block copy on a HORZ/VERT/1:4 rect intra strip (reconstruction is not ported at this shape)", - )); + if let Some((dv_row, dv_col)) = intrabc { + // lane-av1-ibcrect: the reconstruction is ported -- an intrabc block + // is is_inter_block, so libaom predicts the whole 128x64/64x128 strip + // from this frame's own reconstruction and runs the INTER residual + // walk (`decode_token_recon_block`'s else arm) over it. + return decode_intrabc_128rect( + dec, + cdfs, + neighbours, + (mi_r, mi_c), + (bw, bh), + skip, + (dv_row, dv_col), + y, + u, + v, + base_q_idx, fctx, + ); } if alpha.is_some() || filter_intra.is_some() || palette_y.is_some() || palette_uv.is_some() { return Err(unsupported( diff --git a/crates/ec-av1/src/refusal_inventory.rs b/crates/ec-av1/src/refusal_inventory.rs index 82d1dd3b..4a8aa314 100644 --- a/crates/ec-av1/src/refusal_inventory.rs +++ b/crates/ec-av1/src/refusal_inventory.rs @@ -63,7 +63,15 @@ const REFUSALS: &[&str] = &[ // reader a real ctx/cache pair, so no stream could reach either (audit // `every_read_intra_mode_call_site_hands_the_reader_a_palette_cache`, // which keeps that invariant now the refusal is gone). - "intra block copy on a HORZ/VERT/1:4 rect intra strip (reconstruction is not ported at this shape)", + // lane-av1-ibcrect: `intra block copy on a HORZ/VERT/1:4 rect intra strip + // (reconstruction is not ported at this shape)` is GONE -- lane-av1-intrabc + // and lane-av1-rect14 reconstructed the 16x16/32x32-level strips, and this + // lane ported the last site, `decode_block_128rect`'s 128-root HORZ/VERT + // strip (`decode_intrabc_128rect`; a 128 root has no 1:4 arm at all). + // Witness: + // `an_sb128_rect_strip_with_intrabc_decodes_pixel_exact` (real aomenc + // sb128 screen streams coding `use_intrabc` on BLOCK_128X64 strips, + // pixel-exact vs ffmpeg). // lane-av1txr: `a sub-8x8 leaf that uses intrabc (…)` is GONE -- the // capability landed in this lane (4x4 / 4x8 / 8x4 intrabc leaves read the // DV and reconstruct a frame copy + the INTER residual; gates @@ -367,15 +375,12 @@ const PROVEN: &[(&str, &str)] = &[ "a frame using quantisation matrices (using_qmatrix=1): dequantisation here is base_q_idx plus the plane DC/AC deltas only, so qm_y/qm_u/qm_v would be ignored and the frame would decode silently wrong pixels", "a_frame_using_quantisation_matrices_is_refused_by_name", ), - // lane-av1-rect14: the 16x16- and 32x32-level strips are reconstructed - // (`decode_intrabc_rect` / `decode_intrabc_pair_strip`). The string remains - // only in `decode_block_128rect`. No sb128 screen recipe in this lane - // reached that arm (256x192 cq50 sb128 decoded without entering it), so - // the pairing still names the rect-strip gate, which no longer refuses. - ( - "intra block copy on a HORZ/VERT/1:4 rect intra strip (reconstruction is not ported at this shape)", - "a_real_aomenc_screen_key_frame_reads_use_intrabc_on_rect_strips", - ), + // lane-av1-ibcrect: the pairing for "intra block copy on a HORZ/VERT/1:4 + // rect intra strip (reconstruction is not ported at this shape)" is GONE + // with the string -- lane-av1-intrabc/rect14 reconstructed the + // 16x16/32x32-level strips and this lane ported the last site, + // `decode_block_128rect`'s 128-root strip. Witness: + // `an_sb128_rect_strip_with_intrabc_decodes_pixel_exact`. // lane-t900 r26, enumeration: a y_mode symbol comes from a 13-symbol CDF // and all three guards refuse 13 and above. ( @@ -589,7 +594,11 @@ mod tests { .chain(REFUSALS) .map(|&s| s.to_owned()) .collect(); - assert!(found.len() >= 30, "the refusal scan found only {} reasons -- it is broken, not the decoder", found.len()); + assert!( + found.len() >= 30, + "the refusal scan found only {} reasons -- it is broken, not the decoder", + found.len() + ); let added: Vec<&String> = found.difference(&listed).collect(); assert!( @@ -635,9 +644,14 @@ mod tests { let mut found: BTreeSet = BTreeSet::new(); for (i, _) in src.match_indices("\"SKIP ") { let rest = &src[i + "\"SKIP ".len()..]; - let Some(colon) = rest.find(':') else { continue }; + let Some(colon) = rest.find(':') else { + continue; + }; let name = &rest[..colon]; - if !name.chars().all(|c| c.is_ascii_lowercase() || c.is_ascii_digit() || c == '_') { + if !name + .chars() + .all(|c| c.is_ascii_lowercase() || c.is_ascii_digit() || c == '_') + { continue; } // The tail of the message says what was skipped. Only "{e}" -- the @@ -650,7 +664,10 @@ mod tests { } } let listed: BTreeSet<&str> = GATES_THAT_SKIP_ON_A_DECODE_ERROR.iter().copied().collect(); - let added: Vec<&String> = found.iter().filter(|n| !listed.contains(n.as_str())).collect(); + let added: Vec<&String> = found + .iter() + .filter(|n| !listed.contains(n.as_str())) + .collect(); assert!( added.is_empty(), "these gates turn a decode error into a printed SKIP and are not declared: \ @@ -723,9 +740,18 @@ mod tests { fn every_partition_value_of_an_enumerated_alphabet_has_an_arm() { // (the refusal in the fallback arm, the alphabet its CDF codes) let blocks: [(&str, usize); 4] = [ - ("a 32x32 partition type this decoder does not code", crate::cdf::PARTITION_W32[0].len() - 1), - ("an INTER 32x32 partition type this decoder does not code", crate::cdf::PARTITION_W32[0].len() - 1), - ("a 128x128 superblock partition value outside the 8-symbol alphabet", crate::cdf::PARTITION_W128[0].len() - 1), + ( + "a 32x32 partition type this decoder does not code", + crate::cdf::PARTITION_W32[0].len() - 1, + ), + ( + "an INTER 32x32 partition type this decoder does not code", + crate::cdf::PARTITION_W32[0].len() - 1, + ), + ( + "a 128x128 superblock partition value outside the 8-symbol alphabet", + crate::cdf::PARTITION_W128[0].len() - 1, + ), // lane-t900 r24: the key-frame superblock root. Its `part` is // either a `partition_w64` symbol or, at a frame edge, one of the // three gathered outcomes (PARTITION_HORZ, PARTITION_VERT, @@ -779,7 +805,10 @@ mod tests { "the `match` at decode.rs:{} refuses {reason:?} but has no arm for {:?} -- that \ is a real gap in its {alphabet}-value alphabet, not a dead refusal", i + 1, - missing.iter().map(|v| PARTITION_NAMES[*v]).collect::>() + missing + .iter() + .map(|v| PARTITION_NAMES[*v]) + .collect::>() ); } assert_eq!( @@ -833,7 +862,11 @@ mod tests { .next() .unwrap_or("") .to_owned(); - assert!(!var.is_empty(), "the chain at decode.rs:{} tests nothing", head + 1); + assert!( + !var.is_empty(), + "the chain at decode.rs:{} tests nothing", + head + 1 + ); // Walk up collecting every branch head of this chain, each read to // the line that opens its body. @@ -843,7 +876,8 @@ mod tests { loop { i -= 1; let t = lines[i].trim_start(); - if indent(lines[i]) != outer || !(t.starts_with("} else if ") || t.starts_with("if ")) + if indent(lines[i]) != outer + || !(t.starts_with("} else if ") || t.starts_with("if ")) { if i == 0 { break; @@ -893,7 +927,10 @@ mod tests { "the chain at decode.rs:{} refuses {reason:?} but no branch names {:?} -- that \ is a real gap in its {alphabet}-value alphabet, not a dead refusal", head + 1, - missing.iter().map(|v| PARTITION_NAMES[*v]).collect::>() + missing + .iter() + .map(|v| PARTITION_NAMES[*v]) + .collect::>() ); } assert_eq!(found, chains.len()); @@ -996,11 +1033,18 @@ mod tests { values.insert(((1u64 << length) - 2) as u32); } let max = *values.iter().max().unwrap(); - assert_eq!(max, (1u32 << 20) - 2, "the enumeration misses the spec's own ceiling"); + assert_eq!( + max, + (1u32 << 20) - 2, + "the enumeration misses the spec's own ceiling" + ); // A coefficient is masked to 20 bits (spec 5.11.39), and the base and // base-range syntax contribute at most 15 of that before the tail, so // this is the largest tail a legal coefficient can need. - assert!(max >= 0xF_FFFF - 15, "the ceiling is below the largest legal tail"); + assert!( + max >= 0xF_FFFF - 15, + "the ceiling is below the largest legal tail" + ); for value in values { match roundtrip(value) { Ok(read) => assert_eq!(read, value, "the Golomb tail {value} read back as {read}"), @@ -1056,7 +1100,11 @@ mod tests { ]; assert_eq!(alphabets[0].1, 13, "the y_mode alphabet changed size"); for group in &crate::cdf::Y_MODE { - assert_eq!(group.len() - 1, alphabets[0].1, "the y_mode rows disagree on width"); + assert_eq!( + group.len() - 1, + alphabets[0].1, + "the y_mode rows disagree on width" + ); } let src = include_str!("decode.rs"); @@ -1064,12 +1112,17 @@ mod tests { let mut sites = 0usize; for (i, line) in lines.iter().enumerate() { let t = line.trim(); - let Some(rest) = t.strip_prefix("if mode >= ") else { continue }; + let Some(rest) = t.strip_prefix("if mode >= ") else { + continue; + }; let Some(threshold) = rest.trim_end_matches(" {").parse::().ok() else { continue; }; // Only the guards carrying THIS refusal. - if !lines[i..(i + 4).min(lines.len())].join("\n").contains(REFUSAL) { + if !lines[i..(i + 4).min(lines.len())] + .join("\n") + .contains(REFUSAL) + { continue; } sites += 1; @@ -1099,7 +1152,10 @@ mod tests { i + 1 ); } - assert_eq!(sites, 3, "the intra-mode guard is at three sites, found {sites}"); + assert_eq!( + sites, 3, + "the intra-mode guard is at three sites, found {sites}" + ); } /// lane-t900 r31, ENUMERATION for "a HORZ/VERT intra strip in a @@ -1159,7 +1215,10 @@ mod tests { } } } - assert!(with_128 > 0, "enumeration is vacuous -- no 128-sided footprint was tried"); + assert!( + with_128 > 0, + "enumeration is vacuous -- no 128-sided footprint was tried" + ); assert_eq!( allowed_at_128, 0, "a footprint with a 128-pixel side passed av1_allow_palette's bound -- the \ @@ -1271,11 +1330,17 @@ mod tests { // (3) The two tables, read out of decode_rect_split's own text: every // `(w, h) =>` / `(w, h) |` match arm head between the table's `let` // and the guard that follows it. - let body_at = src.find("fn decode_rect_split(").expect("decode_rect_split is gone"); + let body_at = src + .find("fn decode_rect_split(") + .expect("decode_rect_split is gone"); let body = &src[body_at..]; let slice = |from: &str, to: &str| -> &str { - let a = body.find(from).unwrap_or_else(|| panic!("{from:?} is gone from decode_rect_split")); - let b = body[a..].find(to).unwrap_or_else(|| panic!("{to:?} is gone from decode_rect_split")); + let a = body + .find(from) + .unwrap_or_else(|| panic!("{from:?} is gone from decode_rect_split")); + let b = body[a..] + .find(to) + .unwrap_or_else(|| panic!("{to:?} is gone from decode_rect_split")); &body[a..a + b] }; let arm_shapes = |text: &str| -> BTreeSet<(usize, usize)> { @@ -1348,7 +1413,10 @@ mod tests { } } } - assert_eq!(checked, 40, "the strip domain is not the ten rect shapes x four depths"); + assert_eq!( + checked, 40, + "the strip domain is not the ten rect shapes x four depths" + ); } /// lane-t900 r33, ENUMERATION for "CfL, filter intra or a palette on a @@ -1458,9 +1526,15 @@ mod tests { } continue; } - let Some(rest) = line.strip_prefix('(') else { continue }; - let Some((pair, _)) = rest.split_once(") =>") else { continue }; - let Some((a, b)) = pair.split_once(',') else { continue }; + let Some(rest) = line.strip_prefix('(') else { + continue; + }; + let Some((pair, _)) = rest.split_once(") =>") else { + continue; + }; + let Some((a, b)) = pair.split_once(',') else { + continue; + }; let bw: usize = a.trim().parse().expect("arm bw"); let bh: usize = b.trim().parse().expect("arm bh"); assert!( @@ -1472,9 +1546,18 @@ mod tests { seen.push((bw, bh)); arms += 1; } - assert!(arms >= 10, "only {arms} arms parsed -- the table's shape changed"); - assert!(saw_none_fallback, "filter_intra_size_class_rect lost its `_ => None` fallback"); - assert!(saw_square_delegate, "filter_intra_size_class_rect lost its square-delegate arm"); + assert!( + arms >= 10, + "only {arms} arms parsed -- the table's shape changed" + ); + assert!( + saw_none_fallback, + "filter_intra_size_class_rect lost its `_ => None` fallback" + ); + assert!( + saw_square_delegate, + "filter_intra_size_class_rect lost its square-delegate arm" + ); // The guard arm delegates square strips to `filter_intra_size_class`; // drive the delegate directly, so a widening there turns THIS test red // (the numeric walk never reaches the guard arm). @@ -1524,7 +1607,10 @@ mod tests { ); } } - assert_eq!(sites, 8, "the call-site audit found {sites} sites, not the 8 it enumerated"); + assert_eq!( + sites, 8, + "the call-site audit found {sites} sites, not the 8 it enumerated" + ); } /// Every entry of [`PROVEN`] must still name a live refusal and a test @@ -1543,7 +1629,9 @@ mod tests { "{reason:?} is listed as proven but is no longer a decode-path refusal -- drop it from PROVEN (the capability landed) or fix the string" ); assert!( - sources.iter().any(|src| src.contains(&format!("fn {gate}("))), + sources + .iter() + .any(|src| src.contains(&format!("fn {gate}("))), "{reason:?} names the proving test {gate}, which exists in neither stream.rs \ nor decode.rs" ); diff --git a/crates/ec-av1/src/stream.rs b/crates/ec-av1/src/stream.rs index 756cd549..8eb8b2a7 100644 --- a/crates/ec-av1/src/stream.rs +++ b/crates/ec-av1/src/stream.rs @@ -171,6 +171,30 @@ pub fn sb128_rect_counters() -> (usize, usize, usize, usize) { ) } +/// lane-av1-ibcrect: the 128 root's interior partition arms plus the key-frame +/// intra 128-axis blocks -- (split, none, horz, vert, ab[4], intra_horz, +/// intra_vert). Non-zero horz/vert mean a stream carried real PARTITION_HORZ/ +/// VERT at the 128 root, so an intrabc-rect hunt can tell "the partition was +/// never chosen" from "chosen and decoded intra (or refused)". +pub fn part128_census() -> (usize, usize, usize, usize, [usize; 4], usize, usize) { + ( + crate::decode::part128_split_hits(), + crate::decode::part128_none_hits(), + crate::decode::part128_horz_hits(), + crate::decode::part128_vert_hits(), + crate::decode::part128_ab_hits(), + crate::decode::intra_sb128_hits().0, + crate::decode::intra_sb128_hits().1, + ) +} + +/// lane-av1-ibcrect: `use_intrabc` blocks on a 128-root HORZ/VERT strip whose +/// reconstruction ([`crate::decode::decode_intrabc_128rect`]) ran -- the +/// engagement counter the sb128 intrabc-rect gate asserts on. +pub fn intrabc_128rect_hits() -> usize { + crate::decode::intrabc_128rect_hits() +} + /// Blocks reconstructed with intra block copy at an 8x8 LEAF specifically /// (lane-kf900 r7's shape); [`crate::decode::intrabc_hits`] counts every shape. pub fn leaf8_intrabc_hits() -> usize { @@ -7098,6 +7122,183 @@ pub(crate) mod tests { ); } + /// lane-av1-ibcrect: `use_intrabc` on a 128-root HORZ/VERT strip + /// (BLOCK_128X64 / BLOCK_64X128) decodes PIXEL-EXACT against the + /// instrumented oracle -- the witness the refusal inventory names after + /// `decode_block_128rect`'s rect-strip intrabc refusal was lifted + /// (`decode_intrabc_128rect`). The square-block twin is + /// [`an_sb128_screen_stream_with_intrabc_decodes_pixel_exact`] above. + /// + /// The recipes are the hunt's proven arms (lanes/ibcrect r1/r2, the same + /// `--sb-size=128 --min-partition-size=64 --enable-rect-partitions=1 + /// --enable-ab-partitions=0 --enable-1to4-partitions=0` partition recipe + /// [`a_real_aomenc_sb128_intra_rect_block_decodes_pixel_exact`] uses, plus + /// `--tune-content=screen --enable-intrabc=1` over the DETERMINISTIC geq + /// sinusoid sources -- lavfi `gradients` ignores its seed and re-rolls + /// every run, so a "flake" there was really this): + /// + /// * HORZ arm: 384x320 cq32, 5 all-key frames -- 14 unskipped 128x64 + /// intrabc blocks (`skip=false`, real residual reads); + /// * VERT arm: 512x512 cq45, 5 all-key frames -- an unskipped 64x128 + /// intrabc block at mi(64,96). + /// + /// Both arms HARD-assert `intrabc_128rect_hits() > 0` and decode-order + /// pixel-exactness of EVERY frame (hidden alt-refs included) against the + /// oracle's own dump, so a stream that stopped engaging the shape fails + /// the gate instead of passing vacuously (class `gate-blind-to-feature`). + /// + /// The 10-bit arm rides along DECODE-ONLY: measured (hunt r2), aomenc + /// never engages the 128-strip intrabc shape at these recipes at 10 bit + /// (no 128-root HORZ/VERT partition is taken at all), so there is nothing + /// to assert there beyond "decodes without refusing and matches the + /// oracle" -- the per-depth firing assert would be vacuous, and this is + /// the known, printed coverage gap, not a silent pass. + /// + /// The chroma context this shape reads was the r2 defect: per-unit chroma + /// entropy states were stamped inside the mu-chunk loop, then the + /// end-of-block `record_split_luma_rect_mi` re-stamped BOTH planes over + /// the whole 128x64 span with ONE composed state -- level = the SUM of + /// both 64x64 chunks' units, dc = chunk-0's top-left (class + /// `override-slot-on-one-arm`; the inter-128 path fixed the same class + /// with its `mu_chroma_units` replay, decode.rs). The next block then + /// read `txb_skip` off the smeared state. + #[test] + fn an_sb128_rect_strip_with_intrabc_decodes_pixel_exact() { + const NAME: &str = "an_sb128_rect_strip_with_intrabc_decodes_pixel_exact"; + let _gate_lock = lock_gate_counters(); + if !have_ffmpeg() { + eprintln!("SKIP {NAME}: no ffmpeg"); + return; + } + if !have_aomenc() { + eprintln!("SKIP {NAME}: no aomenc at {}", aomenc_path().display()); + return; + } + // (tag, width, height, cq, geq luma, 10-bit) + // The geq sources are the hunt's GEO_SMOOTH / GEO_SMOOTH_512, + // byte-identical across runs (see the sb128 intra-rect gate's note). + let arms: [(u32, usize, usize, &str, &str, bool); 3] = [ + ( + 1, + 384, + 320, + "32", + "128+90*sin((X+2*N)/37)+30*sin(Y/29)", + false, + ), + ( + 2, + 512, + 512, + "45", + "128+80*sin((X+3*N)/17)+50*sin(Y/29)+30*sin((X+Y)/13)", + false, + ), + (3, 384, 320, "32", "128+90*sin((X+2*N)/37)+30*sin(Y/29)", true), + ]; + let mut engaged_arms = 0u32; + let mut vert_arms = 0u32; + for (tag, width, height, cq, lum, ten_bit) in arms { + let pix = if ten_bit { "yuv420p10le" } else { "yuv420p" }; + let y4m = Command::new("ffmpeg") + .args([ + "-v", + "error", + "-f", + "lavfi", + "-i", + &format!( + "nullsrc=size={width}x{height}:rate=25,format=yuv420p,\ + geq=lum='{lum}':\ + cb='128+30*sin(X/23)':cr='128+30*sin((Y+N)/19)'" + ), + "-pix_fmt", + pix, + "-strict", + "-1", + "-t", + "0.2", + "-f", + "yuv4mpegpipe", + "-", + ]) + .stdin(Stdio::null()) + .stdout(Stdio::piped()) + .stderr(Stdio::piped()) + .output() + .expect("ffmpeg failed to run"); + assert!( + y4m.status.success(), + "{NAME}: ffmpeg fixture: {}", + String::from_utf8_lossy(&y4m.stderr) + ); + let cq_arg = format!("--cq-level={cq}"); + let mut args: Vec<&str> = vec![ + "--codec=av1", + "--passes=1", + "--end-usage=q", + &cq_arg, + "--cpu-used=0", + "--threads=1", + "--row-mt=0", + "--lag-in-frames=0", + "--kf-max-dist=1", + "--limit=5", + "--tile-columns=0", + "--sb-size=128", + "--min-partition-size=64", + "--enable-rect-partitions=1", + "--enable-ab-partitions=0", + "--enable-1to4-partitions=0", + "--enable-palette=0", + "--tune-content=screen", + "--enable-intrabc=1", + "--deltaq-mode=0", + "--enable-tx-size-search=0", + ]; + if ten_bit { + args.extend_from_slice(&["--input-bit-depth=10", "--bit-depth=10"]); + } + args.extend_from_slice(&["--obu", "-o", "-", "-"]); + let out = run_with_stdin(Command::new(aomenc_path()).args(&args), &y4m.stdout); + assert!( + out.status.success(), + "{NAME}: aomenc refused the arm {tag} fixture: {}", + String::from_utf8_lossy(&out.stderr) + ); + let stream = out.stdout; + let before = crate::decode::intrabc_128rect_hits(); + let (frames, hidden) = decode_all_frames_vs_oracle( + &stream, + &format!("ibcrect-strip-{tag}-{width}x{height}"), + ); + let hits = crate::decode::intrabc_128rect_hits() - before; + eprintln!( + "{NAME}: arm {tag} {width}x{height} cq={cq} {}bit: {frames} decode-order frames \ + pixel-exact ({hidden} hidden), intrabc_128rect_hits=+{hits}", + if ten_bit { 10 } else { 8 }, + ); + if hits > 0 { + engaged_arms += 1; + // The VERT arm is tag 2; its engagement is what proves the + // 64x128 orientation, not just 128x64. + if tag == 2 { + vert_arms += 1; + } + } + } + assert!( + engaged_arms > 0, + "{NAME}: {engaged_arms} arm(s) decoded pixel-exact but NOT ONE decoded a 128-root \ + rect-strip intrabc block -- the shape this gate exists for was never engaged" + ); + assert!( + vert_arms > 0, + "{NAME}: the VERT (64x128) orientation was never engaged -- only 128x64 HORZ strips \ + proved the lift" + ); + } + /// lane-t900 r33, CENSUS for "a sub-8x8 leaf that uses intrabc". /// /// The `use_intrabc` symbol IS read at that reader for every sub-8x8 leaf