forge
Explore
Log in

Don't you dare go Hollow

Merge lane-av1-intrabc: rect-strip intrabc reconstruction (2:1 + skipped strips)

Browse files at this commit

8a082232d05860eb3aad78d5ef64135bae323accAhmet Kaan GümüşParent: 08d6d41c70a8ec
Conflict resolution with lane-av1-rect14 (both feature sets kept):
- decode_intrabc_rect (with the side*side skip-stride fix) at the three 2:1
  call sites; rect14's decode_intrabc_owned_rect kept at decode_block_rect64
  and for 1:4 pairs (its chroma spans the pair).
- rect14's lossless 16x4 chroma-pair walk + 5 gates intact.
- r5 INTRABC_RECT_SKIPPED_HITS counter + skipped-orientation gate arms intact.
- record_intrabc_mi_rect neighbours argument threaded through.
Reviewer verdicts: full-lane FAIL on the skip-stride P1 (fixed r5), r5
re-review PASS 0.97 zero flags. Lane suite 599/0/60; merged-tree suite
follows before push.
crates/ec-av1/examples/decode_probe.rsmodified+5 -0
@@ -58,6 +58,11 @@ fn main() {
58 "skipped_intrabc_chroma_arm_hits: {}",58 "skipped_intrabc_chroma_arm_hits: {}",
59 ec_av1::stream::skipped_intrabc_chroma_arm_hits()59 ec_av1::stream::skipped_intrabc_chroma_arm_hits()
60 );60 );
61+ println!(
62+ "intrabc_rect: {} (var-tx tree: {})",
63+ ec_av1::decode::intrabc_rect_hits(),
64+ ec_av1::decode::intrabc_rect_vartx_hits()
65+ );
61 let (rtu, rsplit, robmc) = ec_av1::stream::rect_inter_tu_counters();66 let (rtu, rsplit, robmc) = ec_av1::stream::rect_inter_tu_counters();
62 println!("rect_inter: tu={rtu} txsplit={rsplit} obmc_leaf={robmc}");67 println!("rect_inter: tu={rtu} txsplit={rsplit} obmc_leaf={robmc}");
63 println!(68 println!(
crates/ec-av1/src/decode.rsmodified+509 -26
@@ -130,6 +130,11 @@ pub(crate) struct FrameCtx {
130 /// decoder's inter-side publishing was wired. See130 /// decoder's inter-side publishing was wired. See
131 /// [`Neighbours::fill_lf_grid_rect`]'s band publish.131 /// [`Neighbours::fill_lf_grid_rect`]'s band publish.
132 pub(crate) intra_only: std::cell::Cell<bool>,132 pub(crate) intra_only: std::cell::Cell<bool>,
133+ /// This FRAME's own `tx_mode == TxMode::Select`, set for EVERY frame
134+ /// (intra included). [`Self::tx_select_inter`] cannot stand in for it:
135+ /// an intrabc block rides an INTRA frame, but libaom still reads its
136+ /// var-tx `txfm_partition` tree under the frame's `TxMode::Select`.
137+ pub(crate) tx_select_frame: std::cell::Cell<bool>,
133 pub(crate) reduced_tx_set_inter: std::cell::Cell<bool>,138 pub(crate) reduced_tx_set_inter: std::cell::Cell<bool>,
134 pub(crate) enable_filter_intra_inter: std::cell::Cell<bool>,139 pub(crate) enable_filter_intra_inter: std::cell::Cell<bool>,
135 pub(crate) palette_pred: std::cell::RefCell<Option<Vec<u16>>>,140 pub(crate) palette_pred: std::cell::RefCell<Option<Vec<u16>>>,
@@ -229,6 +234,7 @@ impl FrameCtx {
229 cur_segment_id: std::cell::Cell::new(0),234 cur_segment_id: std::cell::Cell::new(0),
230 seg_tile_origin: std::cell::Cell::new((0, 0)),235 seg_tile_origin: std::cell::Cell::new((0, 0)),
231 tx_select_inter: std::cell::Cell::new(false),236 tx_select_inter: std::cell::Cell::new(false),
237+ tx_select_frame: std::cell::Cell::new(false),
232 intra_only: std::cell::Cell::new(false),238 intra_only: std::cell::Cell::new(false),
233 reduced_tx_set_inter: std::cell::Cell::new(false),239 reduced_tx_set_inter: std::cell::Cell::new(false),
234 enable_filter_intra_inter: std::cell::Cell::new(false),240 enable_filter_intra_inter: std::cell::Cell::new(false),
@@ -1626,6 +1632,7 @@ pub(crate) fn set_inter_tx_mode(
1626 ) {1632 ) {
1627 fctx.tx_select_inter.with(|c| c.set(tx_select));1633 fctx.tx_select_inter.with(|c| c.set(tx_select));
1628 fctx.intra_only.with(|c| c.set(false));1634 fctx.intra_only.with(|c| c.set(false));
1635+ fctx.tx_select_frame.with(|c| c.set(tx_select));
1629 fctx.reduced_tx_set_inter.with(|c| c.set(reduced_tx_set));1636 fctx.reduced_tx_set_inter.with(|c| c.set(reduced_tx_set));
1630 fctx.enable_filter_intra_inter.with(|c| c.set(enable_filter_intra));1637 fctx.enable_filter_intra_inter.with(|c| c.set(enable_filter_intra));
1631 }1638 }
@@ -3743,6 +3750,64 @@ thread_local! {
3743 /// signal a transform size where a plain `BLOCK_4X4` does not. Reading no3750 /// signal a transform size where a plain `BLOCK_4X4` does not. Reading no
3744 /// symbol here desynced `warped.obu` at the very next block.3751 /// symbol here desynced `warped.obu` at the very next block.
3745 static RECT_INTRABC_VARTX_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };3752 static RECT_INTRABC_VARTX_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
3753+ /// lane-av1-intrabc: rect INTRABC blocks whose reconstruction
3754+ /// [`decode_intrabc_rect`] ran -- the engagement counter the rect-strip
3755+ /// gates assert on (a refused block bumps [`INTRABC_HITS`] but never
3756+ /// this one).
3757+ static INTRABC_RECT_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
3758+ /// Of those, how many read the INTER var-tx tree (unskipped, TX_MODE_SELECT).
3759+ static INTRABC_RECT_VARTX_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
3760+ /// lane-av1-intrabc r4: rect INTRABC blocks whose reconstruction
3761+ /// [`decode_intrabc_rect`] ran with `skip == 0` (a real residual read),
3762+ /// split by the strip's orientation -- `bw > bh` is a HORZ strip,
3763+ /// `bh > bw` a VERT one. The reviewer's unblock condition needs a CODED
3764+ /// witness in BOTH orientations, and the existing `INTRABC_RECT_HITS`
3765+ /// counts neither orientation nor the skip flag, so an arm that flipped
3766+ /// to an all-skip stream (no residual reader at all) would stay green.
3767+ static INTRABC_RECT_CODED_HITS: std::cell::Cell<[usize; 2]> =
3768+ const { std::cell::Cell::new([0, 0]) };
3769+ /// lane-av1-intrabc r5: the `skip == 1` twin of [`INTRABC_RECT_CODED_HITS`]
3770+ /// -- rect INTRABC blocks reconstructed as a bare prediction copy, split
3771+ /// by orientation. The r5 panic (residual stride `bw * bh` underrunning
3772+ /// `reconstruct_mc_rect`'s `row * side + w` index on a VERT strip) was
3773+ /// invisible to every gate because they only counted CODED strips.
3774+ static INTRABC_RECT_SKIPPED_HITS: std::cell::Cell<[usize; 2]> =
3775+ const { std::cell::Cell::new([0, 0]) };
3776+}
3777+
3778+/// lane-av1-intrabc r4: coded (`skip == 0`) rect intrabc blocks reconstructed,
3779+/// as `[horz, vert]` -- see [`INTRABC_RECT_CODED_HITS`].
3780+#[allow(dead_code)] // read only from the `#[cfg(test)]` gates
3781+pub fn intrabc_rect_coded_hits() -> [usize; 2] {
3782+ INTRABC_RECT_CODED_HITS.with(std::cell::Cell::get)
3783+}
3784+
3785+/// lane-av1-intrabc r5: skipped (`skip == 1`) rect intrabc blocks
3786+/// reconstructed, as `[horz, vert]` -- see [`INTRABC_RECT_SKIPPED_HITS`].
3787+#[allow(dead_code)] // read only from the `#[cfg(test)]` gates
3788+pub fn intrabc_rect_skipped_hits() -> [usize; 2] {
3789+ INTRABC_RECT_SKIPPED_HITS.with(std::cell::Cell::get)
3790+}
3791+
3792+/// Current value of [`INTRABC_RECT_HITS`].
3793+#[allow(dead_code)] // read only from the `#[cfg(test)]` gates
3794+pub fn intrabc_rect_hits() -> usize {
3795+ INTRABC_RECT_HITS.with(|c| c.get())
3796+}
3797+
3798+/// Zeroes [`INTRABC_RECT_HITS`]/[`INTRABC_RECT_VARTX_HITS`].
3799+#[allow(dead_code)] // read only from the `#[cfg(test)]` gates
3800+pub(crate) fn reset_intrabc_rect_hits() {
3801+ INTRABC_RECT_HITS.with(|c| c.set(0));
3802+ INTRABC_RECT_VARTX_HITS.with(|c| c.set(0));
3803+ INTRABC_RECT_CODED_HITS.with(|c| c.set([0, 0]));
3804+ INTRABC_RECT_SKIPPED_HITS.with(|c| c.set([0, 0]));
3805+}
3806+
3807+/// Current value of [`INTRABC_RECT_VARTX_HITS`].
3808+#[allow(dead_code)] // read only from the `#[cfg(test)]` gates
3809+pub fn intrabc_rect_vartx_hits() -> usize {
3810+ INTRABC_RECT_VARTX_HITS.with(|c| c.get())
3746 }3811 }
3747 3812
3748 /// Current value of [`INTRABC_VARTX_HITS`].3813 /// Current value of [`INTRABC_VARTX_HITS`].
@@ -7729,6 +7794,19 @@ impl Neighbours {
7729 }7794 }
7730 }7795 }
7731 }7796 }
7797+ // lane-av1-intrabc r4: publish this coded block's own mi footprint
7798+ // into the intrabc MV grid's block-COVERAGE map -- every coded block,
7799+ // not just the intrabc ones. A later intrabc block's DV predictor is
7800+ // built by libaom's own row/col scans over `xd->mi[]`, which holds an
7801+ // `MB_MODE_INFO` for EVERY block and steps by
7802+ // `mi_size_wide/height[candidate->bsize]`; without this footprint a
7803+ // non-intrabc neighbour reads as uncovered and the scan advances it
7804+ // by one cell instead of by its real width.
7805+ fctx.intrabc_mi_grid.with(|g| {
7806+ if let Some((grid, _, _)) = g.borrow_mut().as_mut() {
7807+ grid.cover_rect(mi_r, mi_c, w_mi, h_mi);
7808+ }
7809+ });
7732 }7810 }
7733 7811
7734 /// One var-tx / split-tx LEAF's own LUMA transform dims over its mi span.7812 /// One var-tx / split-tx LEAF's own LUMA transform dims over its mi span.
@@ -9258,7 +9336,13 @@ fn read_intra_mode_rect(
9258 Option<usize>,9336 Option<usize>,
9259 Option<PaletteY>,9337 Option<PaletteY>,
9260 Option<PaletteUv>,9338 Option<PaletteUv>,
9261- // lane-av1-rect14: Some(dv) for an intrabc 16x4/4x16 pair strip.9339+ // lane-av1-intrabc: the block vector, `Some` exactly when this block's
9340+ // `use_intrabc` symbol came out 1 -- libaom's `read_intrabc_info` returns
9341+ // straight out of `read_intra_frame_mode_info` then, so every later field
9342+ // of the tuple is at its default (mode/uv_mode DC, no angle, no palette,
9343+ // no filter intra). A caller that can reconstruct intrabc at its shape
9344+ // takes this and calls [`decode_intrabc_rect`]; one that cannot refuses by
9345+ // name with the same string it always did.
9262 Option<(i32, i32)>,9346 Option<(i32, i32)>,
9263 )> {9347 )> {
9264 // lane-av1mono: libaom guards every chroma symbol read with9348 // lane-av1mono: libaom guards every chroma symbol read with
@@ -9338,18 +9422,22 @@ fn read_intra_mode_rect(
9338 istep!("intrabc", use_intrabc as i32);9422 istep!("intrabc", use_intrabc as i32);
9339 if use_intrabc {9423 if use_intrabc {
9340 hit!(INTRABC_HITS);9424 hit!(INTRABC_HITS);
9341- // 16x4/4x16 is a chroma PAIR ([`decode_rect4_16_intrabc`]).9425+ // libaom `read_intrabc_info`: the DV read, then an immediate
9342- // Every other rect shape still refuses by name: its9426+ // return out of the mode-info read -- no `y_mode`, no `uv_mode`,
9343- // reconstruction is `decode_intrabc_rect` (lane-av1-intrabc,9427+ // no angle deltas, no palette, no filter intra. The caller owns
9344- // not on this tree). 32x8/8x32, 64x16/16x64 and 128-axis strips9428+ // the reconstruction at its own shape.
9345- // own their chroma and must not take the pair helper.
9346- // Every rect shape returns the DV. 16x4/4x16 reconstructs in
9347- // [`decode_rect4_16_intrabc`]; other shapes in
9348- // [`decode_intrabc_owned_rect`]. A shape with no coefficient
9349- // table still refuses there, by the same name.
9350 let dv = read_intrabc_dv(dec, cdfs, mi_r, mi_c, (bw / MI, bh / MI), fctx);9429 let dv = read_intrabc_dv(dec, cdfs, mi_r, mi_c, (bw / MI, bh / MI), fctx);
9351 return Ok((9430 return Ok((
9352- skip, DC_PRED, 0, DC_PRED, 0, None, None, None, None, Some(dv),9431+ skip,
9432+ DC_PRED,
9433+ 0,
9434+ DC_PRED,
9435+ 0,
9436+ None,
9437+ None,
9438+ None,
9439+ None,
9440+ Some(dv),
9353 ));9441 ));
9354 }9442 }
9355 }9443 }
@@ -10927,6 +11015,348 @@ fn decode_intra_rect_in_inter(
10927 Ok(())11015 Ok(())
10928 }11016 }
10929 11017
11018+/// Reconstructs one rectangular INTRABC block, `bw`x`bh` pixels at the real
11019+/// mi `(mi_r, mi_c)` (lane-av1-intrabc).
11020+///
11021+/// libaom treats an intrabc block as INTER for everything except the mode-info
11022+/// read itself: `is_inter_block` is `is_intrabc_block(mbmi) || ref > INTRA`
11023+/// (`blockd.h:373`), so
11024+///
11025+/// * `parse_decode_block` reads the transform size through the INTER var-tx
11026+/// tree (`read_tx_size_vartx`) -- [`read_block_tx_size_rect`], whose
11027+/// `txfm_partition` context comes off the real `TXFM_CONTEXT` bands and
11028+/// whose leaves publish their own resolved size back;
11029+/// * `predict_inter_block` predicts the WHOLE block once, from the CURRENT
11030+/// frame's own pre-loop-filter reconstruction, at the coded block vector
11031+/// with the BILINEAR kernel `read_intrabc_info` forces (`decodemv.c:913`);
11032+/// * `decode_token_recon_block`'s inter branch then reads one residual per
11033+/// transform unit, through the INTER coefficient sets
11034+/// ([`read_inter_plane_rect`]/[`read_inter_plane`]) with the chroma plane
11035+/// inheriting the colocated luma unit's coded `tx_type`.
11036+///
11037+/// Text order is libaom's: transform tree, prediction, luma residual, chroma
11038+/// residual, bookkeeping. A skipped block codes no residual at all -- the
11039+/// prediction is the reconstruction.
11040+#[allow(clippy::too_many_arguments)]
11041+fn decode_intrabc_rect(
11042+ dec: &mut SymbolDecoder,
11043+ cdfs: &mut Cdfs,
11044+ neighbours: &mut Neighbours,
11045+ (mi_r, mi_c): (usize, usize),
11046+ (bw, bh): (usize, usize),
11047+ skip: bool,
11048+ (dv_row, dv_col): (i32, i32),
11049+ y: &mut PlaneBuf<'static>,
11050+ u: &mut PlaneBuf<'static>,
11051+ v: &mut PlaneBuf<'static>,
11052+ base_q_idx: u8,
11053+ fctx: &crate::decode::FrameCtx,
11054+) -> Result<()> {
11055+ hit!(INTRABC_RECT_HITS);
11056+ // [horz, vert]: see `INTRABC_RECT_CODED_HITS` / `INTRABC_RECT_SKIPPED_HITS`.
11057+ let idx = usize::from(bh > bw);
11058+ if skip {
11059+ INTRABC_RECT_SKIPPED_HITS.with(|c| {
11060+ let mut seen = c.get();
11061+ seen[idx] += 1;
11062+ c.set(seen);
11063+ });
11064+ } else {
11065+ INTRABC_RECT_CODED_HITS.with(|c| {
11066+ let mut seen = c.get();
11067+ seen[idx] += 1;
11068+ c.set(seen);
11069+ });
11070+ }
11071+ let (px, py) = (mi_c * MI, mi_r * MI);
11072+ let (cpx, cpy) = (px / 2, py / 2);
11073+ // `av1_get_max_uv_txsize(bw x bh)`: 4:2:0 halves the footprint and the
11074+ // halved shape's own `max_txsize_rect_lookup` entry IS that size for every
11075+ // shape this helper is called at, so the uv plane block is ONE unit --
11076+ // the same call `decode_token_recon_block`'s own chroma loop makes.
11077+ let (cw, ch) = (bw / 2, bh / 2);
11078+ // lane-av1-intrabc r2: the square stride the proven INTER path uses
11079+ // (`side`). The residual grids, the prediction windows AND
11080+ // `TxParams::stride` are all laid out at it -- the block's own width
11081+ // panicked `TxParams::run` on every coded VERT strip (8x16/16x32: `h`
11082+ // exceeds the stride).
11083+ let side = bw.max(bh);
11084+ let cside = cw.max(ch);
11085+ // `av1_calc_mi_size`'s 8-px-aligned grid: a block hanging over the right
11086+ // or bottom frame edge reads no transform-tree symbol for the units
11087+ // outside it.
11088+ let mi_cols = 2 * y.true_width.div_ceil(8);
11089+ let mi_rows = 2 * y.true_height.div_ceil(8);
11090+ let leaves = read_block_tx_size_rect(
11091+ dec,
11092+ cdfs,
11093+ neighbours,
11094+ (mi_r, mi_c),
11095+ (bw, bh),
11096+ (mi_cols, mi_rows),
11097+ skip, fctx,
11098+ )?;
11099+ if leaves.is_some() {
11100+ hit!(INTRABC_RECT_VARTX_HITS);
11101+ }
11102+ // The whole-block prediction: `predict_inter_block` runs once, before any
11103+ // coefficient is read. `flush_recon` first -- the source is this frame's
11104+ // own reconstruction, including the writes this superblock has queued.
11105+ flush_recon(fctx, y, u, v);
11106+ // `mc::predict_with_filter` writes a DENSE window; the residual machinery
11107+ // reads it at the square stride, so re-lay it -- the same step the inter
11108+ // path takes for its own square prediction buffer.
11109+ let mut pred_y_dense = vec![0u16; bw * bh];
11110+ mc::predict_with_filter(
11111+ &y.data, y.width, y.true_width, y.true_height,
11112+ mv_to_q4(px, dv_col, true), mv_to_q4(py, dv_row, true),
11113+ bw, bh, mc::InterpFilterKind::Bilinear, &mut pred_y_dense, fctx,
11114+ );
11115+ let mut pred_y = vec![0u16; side * side];
11116+ for row in 0..bh {
11117+ pred_y[row * side..][..bw].copy_from_slice(&pred_y_dense[row * bw..][..bw]);
11118+ }
11119+ let mut pred_u_dense = vec![0u16; cw * ch];
11120+ mc::predict_with_filter(
11121+ &u.data, u.width, u.true_width, u.true_height,
11122+ mv_to_q4(cpx, dv_col, false), mv_to_q4(cpy, dv_row, false),
11123+ cw, ch, mc::InterpFilterKind::Bilinear, &mut pred_u_dense, fctx,
11124+ );
11125+ let mut pred_u = vec![0u16; cside * cside];
11126+ for row in 0..ch {
11127+ pred_u[row * cside..][..cw].copy_from_slice(&pred_u_dense[row * cw..][..cw]);
11128+ }
11129+ let mut pred_v_dense = vec![0u16; cw * ch];
11130+ mc::predict_with_filter(
11131+ &v.data, v.width, v.true_width, v.true_height,
11132+ mv_to_q4(cpx, dv_col, false), mv_to_q4(cpy, dv_row, false),
11133+ cw, ch, mc::InterpFilterKind::Bilinear, &mut pred_v_dense, fctx,
11134+ );
11135+ let mut pred_v = vec![0u16; cside * cside];
11136+ for row in 0..ch {
11137+ pred_v[row * cside..][..cw].copy_from_slice(&pred_v_dense[row * cw..][..cw]);
11138+ }
11139+ let reduced = fctx.reduced_tx_set_inter.with(std::cell::Cell::get);
11140+ let luma_tx_type: TxType;
11141+ let (luma_grid, u_grid, v_grid);
11142+ if skip {
11143+ // No residual syntax at all: the prediction IS the block.
11144+ // Residual stride is `side` (and `cside`), not `bw`: reconstruct_mc_rect indexes
11145+ // `residual[row * side .. row*side + w]` for row in 0..h, so a skipped VERT strip
11146+ // (bh > bw) overruns a `bw * bh` slice. Bug-for-bug with the inter skip arm.
11147+ push_mc_rect(0, px, py, side, bw, bh, Pred::Inline(&pred_y, side), &ZERO_RESIDUAL[..side * side], fctx);
11148+ push_mc_rect(1, cpx, cpy, cside, cw, ch, Pred::Inline(&pred_u, cside), &ZERO_RESIDUAL[..cside * cside], fctx);
11149+ push_mc_rect(2, cpx, cpy, cside, cw, ch, Pred::Inline(&pred_v, cside), &ZERO_RESIDUAL[..cside * cside], fctx);
11150+ luma_tx_type = TxType::DctDct;
11151+ luma_grid = Grid::Zero(side * side);
11152+ u_grid = Grid::Zero(cside * cside);
11153+ v_grid = Grid::Zero(cside * cside);
11154+ } else {
11155+ match leaves.as_ref() {
11156+ None => {
11157+ // One whole-block rectangular transform unit.
11158+ let around = neighbours.around_mi_rect((mi_r, mi_c), bw, bh);
11159+ let (grid, tx_type) = read_inter_plane_rect(
11160+ dec,
11161+ cdfs,
11162+ rect_inter_luma_set(bw, bh, fctx)?,
11163+ (bw, bh),
11164+ side,
11165+ 0,
11166+ around[0],
11167+ 0,
11168+ y,
11169+ px,
11170+ py,
11171+ Pred::Inline(&pred_y, side),
11172+ None,
11173+ None, fctx,
11174+ )?;
11175+ luma_tx_type = tx_type;
11176+ luma_grid = embed_grid_stride(&grid, bw, bh, side);
11177+ let (ug, _) = read_inter_plane_rect(
11178+ dec,
11179+ cdfs,
11180+ rect_inter_chroma_set(cw, ch)?,
11181+ (cw, ch),
11182+ cside,
11183+ 1,
11184+ around[1],
11185+ 0,
11186+ u,
11187+ cpx,
11188+ cpy,
11189+ Pred::Inline(&pred_u, cside),
11190+ Some(luma_tx_type),
11191+ None, fctx,
11192+ )?;
11193+ u_grid = embed_grid_stride(&ug, cw, ch, cside);
11194+ let (vg, _) = read_inter_plane_rect(
11195+ dec,
11196+ cdfs,
11197+ rect_inter_chroma_set(cw, ch)?,
11198+ (cw, ch),
11199+ cside,
11200+ 2,
11201+ around[2],
11202+ 0,
11203+ v,
11204+ cpx,
11205+ cpy,
11206+ Pred::Inline(&pred_v, cside),
11207+ Some(luma_tx_type),
11208+ None, fctx,
11209+ )?;
11210+ v_grid = embed_grid_stride(&vg, cw, ch, cside);
11211+ }
11212+ Some(leaves) => {
11213+ // P2 (lane-av1-intrabc r2): libaom `get_transform_size` applies
11214+ // the split override to LUMA only, per leaf -- the step the
11215+ // proven inter var-tx path applies right after its own residual
11216+ // loop ([`Neighbours::fill_lf_grid_leaf_luma`]). Without it the
11217+ // leaf's own transform edges are never filtered.
11218+ for &(row, col, tw, th) in leaves.iter() {
11219+ neighbours.fill_lf_grid_leaf_luma(
11220+ (mi_r + row, mi_c + col),
11221+ tw / MI,
11222+ th / MI,
11223+ tw as u8,
11224+ th as u8,
11225+ );
11226+ }
11227+ // One residual per transform unit, in the order the tree coded
11228+ // them; each unit reads its own neighbour-magnitude context off
11229+ // the units already decoded before it, and every unit adds onto
11230+ // its own window of the block's single prediction.
11231+ let mut first_tx_type = TxType::DctDct;
11232+ for (idx, &(row, col, tw, th)) in leaves.iter().enumerate() {
11233+ let tu_mi = (mi_r + row, mi_c + col);
11234+ let (tu_px, tu_py) = (px + col * MI, py + row * MI);
11235+ let tu_pred = Pred::Inline(&pred_y, side).offset(row * MI * side + col * MI);
11236+ let (tu_grid, tu_tx_type) = if tw == th {
11237+ let scan = default_scan(tw.min(32));
11238+ let tu_skip_ctx = neighbours.luma_skip_ctx(tu_mi, tw / MI);
11239+ read_inter_plane(
11240+ dec,
11241+ cdfs,
11242+ inter_txbset_for(tw, reduced),
11243+ scan,
11244+ 0,
11245+ neighbours.around_mi(tu_mi, tw)[0],
11246+ 0,
11247+ y,
11248+ tu_px,
11249+ tu_py,
11250+ tw,
11251+ base_q_idx,
11252+ tu_pred,
11253+ None,
11254+ Some(tu_skip_ctx), fctx,
11255+ )?
11256+ } else {
11257+ let tu_skip_ctx = neighbours.luma_skip_ctx_rect(tu_mi, tw / MI, th / MI);
11258+ read_inter_plane_rect(
11259+ dec,
11260+ cdfs,
11261+ rect_inter_luma_set(tw, th, fctx)?,
11262+ (tw, th),
11263+ side,
11264+ 0,
11265+ neighbours.around_mi_rect(tu_mi, tw, th)[0],
11266+ 0,
11267+ y,
11268+ tu_px,
11269+ tu_py,
11270+ tu_pred,
11271+ None,
11272+ Some(tu_skip_ctx), fctx,
11273+ )?
11274+ };
11275+ if idx == 0 {
11276+ first_tx_type = tu_tx_type;
11277+ }
11278+ neighbours.record_mi_luma_rect(tu_mi, tw, th, &tu_grid);
11279+ }
11280+ // `av1_get_tx_type`'s chroma lookup lands on the colocated
11281+ // LUMA unit, which for a split block is the top-left one.
11282+ luma_tx_type = first_tx_type;
11283+ let around = neighbours.around_mi_rect((mi_r, mi_c), bw, bh);
11284+ let (ug, _) = read_inter_plane_rect(
11285+ dec,
11286+ cdfs,
11287+ rect_inter_chroma_set(cw, ch)?,
11288+ (cw, ch),
11289+ cside,
11290+ 1,
11291+ around[1],
11292+ 0,
11293+ u,
11294+ cpx,
11295+ cpy,
11296+ Pred::Inline(&pred_u, cside),
11297+ Some(luma_tx_type),
11298+ None, fctx,
11299+ )?;
11300+ u_grid = embed_grid_stride(&ug, cw, ch, cside);
11301+ let (vg, _) = read_inter_plane_rect(
11302+ dec,
11303+ cdfs,
11304+ rect_inter_chroma_set(cw, ch)?,
11305+ (cw, ch),
11306+ cside,
11307+ 2,
11308+ around[2],
11309+ 0,
11310+ v,
11311+ cpx,
11312+ cpy,
11313+ Pred::Inline(&pred_v, cside),
11314+ Some(luma_tx_type),
11315+ None, fctx,
11316+ )?;
11317+ v_grid = embed_grid_stride(&vg, cw, ch, cside);
11318+ luma_grid = Grid::Zero(side * side);
11319+ }
11320+ }
11321+ }
11322+ let _ = luma_tx_type;
11323+ // Bookkeeping. An intrabc block publishes mode `DC_PRED` everywhere the
11324+ // next block reads a neighbour mode, its own block size in both `TXFM`
11325+ // bands (already done by `read_block_tx_size_rect`), a zeroed palette
11326+ // state (a stale entry would feed the next block's colour cache), and its
11327+ // DV into the intrabc mi grid the next block's DV predictor reads.
11328+ if leaves.is_some() {
11329+ neighbours.record_split_luma_rect_mi(
11330+ (mi_r, mi_c), bw, bh, DC_PRED, DC_PRED, [&u_grid, &v_grid],
11331+ );
11332+ } else {
11333+ neighbours.record_rect_mi(
11334+ (mi_r, mi_c), bw, bh, DC_PRED, DC_PRED, &[&luma_grid, &u_grid, &v_grid],
11335+ );
11336+ }
11337+ neighbours.record_palette_y_rect((mi_r, mi_c), bw, bh, 0, [0u16; 8]);
11338+ neighbours.record_palette_uv_rect((mi_r, mi_c), bw, bh, 0, [0u16; 8]);
11339+ neighbours.fill_skip_grid_rect((mi_r, mi_c), bw / MI, bh / MI, skip);
11340+ neighbours.fill_lf_grid_rect(
11341+ (mi_r, mi_c),
11342+ bw / MI,
11343+ bh / MI,
11344+ bw.min(64) as u8,
11345+ bh.min(64) as u8,
11346+ 0, fctx,
11347+ );
11348+ record_intrabc_mi_rect(
11349+ mi_r,
11350+ mi_c,
11351+ bw / MI,
11352+ bh / MI,
11353+ Some((dv_row, dv_col)),
11354+ neighbours,
11355+ fctx,
11356+ );
11357+ Ok(())
11358+}
11359+
10930 /// Decodes one true `bw`x`bh` `PARTITION_HORZ`/`PARTITION_VERT` intra strip11360 /// Decodes one true `bw`x`bh` `PARTITION_HORZ`/`PARTITION_VERT` intra strip
10931 /// (lane-intradisp r1, spec `decode_block` restricted to a 32x32 quadrant's11361 /// (lane-intradisp r1, spec `decode_block` restricted to a 32x32 quadrant's
10932 /// two rect children). Only the `skip` case is supported: `skip`/`y_mode`/11362 /// two rect children). Only the `skip` case is supported: `skip`/`y_mode`/
@@ -10977,10 +11407,20 @@ fn decode_block_rect(
10977 r * (SUB / MI),11407 r * (SUB / MI),
10978 c * (SUB / MI), fctx,11408 c * (SUB / MI), fctx,
10979 )?;11409 )?;
11410+
10980 if let Some((dv_row, dv_col)) = intrabc {11411 if let Some((dv_row, dv_col)) = intrabc {
10981- return decode_intrabc_owned_rect(11412+ return decode_intrabc_rect(
10982- dec, cdfs, neighbours, (r * (SUB / MI), c * (SUB / MI)), (bw, bh), skip,11413+ dec,
10983- (dv_row, dv_col), y, u, v, base_q_idx, tx_select, reduced_tx_set, fctx,11414+ cdfs,
11415+ neighbours,
11416+ (r * (SUB / MI), c * (SUB / MI)),
11417+ (bw, bh),
11418+ skip,
11419+ (dv_row, dv_col),
11420+ y,
11421+ u,
11422+ v,
11423+ base_q_idx, fctx,
10984 );11424 );
10985 }11425 }
10986 let smooth_neighbor = is_smooth_mode(nb_above_mode) || is_smooth_mode(nb_left_mode);11426 let smooth_neighbor = is_smooth_mode(nb_above_mode) || is_smooth_mode(nb_left_mode);
@@ -11033,6 +11473,14 @@ fn decode_block_rect(
11033 } else {11473 } else {
11034 011474 0
11035 };11475 };
11476+ // lane-av1-intrabc r3: this strip's own `set_txfm_ctxs` when the frame
11477+ // reads the `TXFM_CONTEXT` bands -- see [`publish_txfm_bands_if_in_inter`].
11478+ publish_txfm_bands_if_in_inter(
11479+ neighbours,
11480+ (mi_r, mi_c),
11481+ depth_to_tx_wh(bw, bh, depth, fctx),
11482+ (bw, bh), fctx,
11483+ );
11036 if depth != 0 || lossless(fctx) {11484 if depth != 0 || lossless(fctx) {
11037 hit!(TX_DEPTH_HITS);11485 hit!(TX_DEPTH_HITS);
11038 // lane-rectsplit r1: a split transform is predicted and reconstructed11486 // lane-rectsplit r1: a split transform is predicted and reconstructed
@@ -11478,10 +11926,11 @@ fn decode_leaf_rect(
11478 leaf_mi.0,11926 leaf_mi.0,
11479 leaf_mi.1, fctx,11927 leaf_mi.1, fctx,
11480 )?;11928 )?;
11929+
11481 if let Some((dv_row, dv_col)) = intrabc {11930 if let Some((dv_row, dv_col)) = intrabc {
11482- decode_intrabc_owned_rect(11931+ decode_intrabc_rect(
11483 dec, cdfs, neighbours, leaf_mi, (bw, bh), skip, (dv_row, dv_col),11932 dec, cdfs, neighbours, leaf_mi, (bw, bh), skip, (dv_row, dv_col),
11484- y, u, v, base_q_idx, tx_select, reduced_tx_set, fctx,11933+ y, u, v, base_q_idx, fctx,
11485 )?;11934 )?;
11486 return Ok(DC_PRED);11935 return Ok(DC_PRED);
11487 }11936 }
@@ -11548,6 +11997,14 @@ fn decode_leaf_rect(
11548 } else {11997 } else {
11549 011998 0
11550 };11999 };
12000+ // lane-av1-intrabc r3: this leaf's own `set_txfm_ctxs` when the frame reads
12001+ // the `TXFM_CONTEXT` bands -- see [`publish_txfm_bands_if_in_inter`].
12002+ publish_txfm_bands_if_in_inter(
12003+ neighbours,
12004+ leaf_mi,
12005+ depth_to_tx_wh(bw, bh, depth, fctx),
12006+ (bw, bh), fctx,
12007+ );
11551 if depth != 0 || lossless(fctx) {12008 if depth != 0 || lossless(fctx) {
11552 // The same per-transform-unit walk the bigger strips take12009 // The same per-transform-unit walk the bigger strips take
11553 // (`depth_to_tx_wh`: TX_16X8 -> TX_8X8 at depth 1, -> TX_4X4 at12010 // (`depth_to_tx_wh`: TX_16X8 -> TX_8X8 at depth 1, -> TX_4X4 at
@@ -11816,10 +12273,9 @@ fn decode_block_rect4(
11816 mi_c, fctx,12273 mi_c, fctx,
11817 )?;12274 )?;
11818 if let Some((dv_row, dv_col)) = intrabc {12275 if let Some((dv_row, dv_col)) = intrabc {
11819- decode_intrabc_owned_rect(12276+ decode_intrabc_rect(
11820- dec, cdfs, neighbours, (mi_r, mi_c), (bw, bh), skip, (dv_row, dv_col),12277+ dec, cdfs, neighbours, strip_mi, (bw, bh), skip, (dv_row, dv_col),
11821- y, u, v, base_q_idx, tx_select,12278+ y, u, v, base_q_idx, fctx,
11822- fctx.reduced_tx_set_inter.with(std::cell::Cell::get), fctx,
11823 )?;12279 )?;
11824 return Ok((DC_PRED, DC_PRED));12280 return Ok((DC_PRED, DC_PRED));
11825 }12281 }
@@ -16143,19 +16599,22 @@ fn decode_block_128rect(
16143 logical_tx as u8,16599 logical_tx as u8,
16144 0, fctx,16600 0, fctx,
16145 );16601 );
16146- if in_inter {16602+ if in_inter || allow_intrabc_frame(fctx) {
16147 // `set_txfm_ctxs(tx_size, n4_w, n4_h, skip && is_inter, xd)`16603 // `set_txfm_ctxs(tx_size, n4_w, n4_h, skip && is_inter, xd)`
16148 // (libaom `decodeframe.c` `decode_block`) runs for EVERY block of an16604 // (libaom `decodeframe.c` `decode_block`) runs for EVERY block of an
16149 // inter frame, intra ones included: an intra block stamps its16605 // inter frame, intra ones included: an intra block stamps its
16150 // TRANSFORM size over its own footprint in both TXFM_CONTEXT bands.16606 // TRANSFORM size over its own footprint in both TXFM_CONTEXT bands.
16151- // A key frame has no var-tx tree and its readers use the deblock grid,16607+ // A key frame reads those bands only when it allows intrabc
16152- // so this is the inter path's alone.16608+ // ([`read_block_tx_size_rect`]'s var-tx context), and then libaom
16609+ // stamps here too -- lane-av1-intrabc r3.
16153 txfm_partition_update_rect(16610 txfm_partition_update_rect(
16154 neighbours,16611 neighbours,
16155 (mi_r, mi_c),16612 (mi_r, mi_c),
16156 (logical_tx, logical_tx),16613 (logical_tx, logical_tx),
16157 (bw, bh),16614 (bw, bh),
16158 );16615 );
16616+ }
16617+ if in_inter {
16159 hit_do! {16618 hit_do! {
16160 INTRA128_IN_INTER_HITS.with(|c| {16619 INTRA128_IN_INTER_HITS.with(|c| {
16161 let mut h = c.get();16620 let mut h = c.get();
@@ -18892,13 +19351,26 @@ fn txfm_partition_update(
18892 /// `tx_size_cat1` row 1 instead of row 0 -- same depth VALUE, different CDF,19351 /// `tx_size_cat1` row 1 instead of row 0 -- same depth VALUE, different CDF,
18893 /// range 39156 where the reference has 54736 (class tx-grid-published-block-side19352 /// range 39156 where the reference has 54736 (class tx-grid-published-block-side
18894 /// / early-return-skips-tail).19353 /// / early-return-skips-tail).
19354+///
19355+/// lane-av1-intrabc r3: an `allow_intrabc` KEY frame reads the same bands --
19356+/// `read_intra_frame_mode_info` returns early for an intrabc block, so
19357+/// [`read_block_tx_size_rect`]'s var-tx tree is the intra path's one
19358+/// `txfm_partition_context` reader, and it reads whatever the block ABOVE and
19359+/// the block LEFT published. [`decode_block`] has published on such a frame
19360+/// since lane-t900 r32; the RECT strips did not, so the band still held the
19361+/// value of an older, smaller neighbour -- measured on the 256x192 testsrc2
19362+/// cq45 var-tx arm: the coded 16x8 intrabc strip at mi(38,48) read ctx 14
19363+/// where libaom reads 13 (`left_ctx` 4 vs the 8 the 16x8 intra strip at
19364+/// mi(38,44) should have published), desyncing the tile there.
18895 fn publish_txfm_bands_if_in_inter(19365 fn publish_txfm_bands_if_in_inter(
18896 n: &mut Neighbours,19366 n: &mut Neighbours,
18897 at_mi: (usize, usize),19367 at_mi: (usize, usize),
18898 (tx_w, tx_h): (usize, usize),19368 (tx_w, tx_h): (usize, usize),
18899 (bw, bh): (usize, usize), fctx: &crate::decode::FrameCtx,19369 (bw, bh): (usize, usize), fctx: &crate::decode::FrameCtx,
18900 ) {19370 ) {
18901- if fctx.intra_in_inter_mode.with(std::cell::Cell::get).is_none() {19371+ if fctx.intra_in_inter_mode.with(std::cell::Cell::get).is_none()
19372+ && !allow_intrabc_frame(fctx)
19373+ {
18902 return;19374 return;
18903 }19375 }
18904 let (mi_r, mi_c) = at_mi;19376 let (mi_r, mi_c) = at_mi;
@@ -19676,7 +20148,7 @@ fn read_block_tx_size_rect(
19676 (bh / MI).min(mi_rows.saturating_sub(at_mi.0)),20148 (bh / MI).min(mi_rows.saturating_sub(at_mi.0)),
19677 );20149 );
19678 let mut leaves = Vec::new();20150 let mut leaves = Vec::new();
19679- if !fctx.tx_select_inter.with(std::cell::Cell::get) {20151+ if !fctx.tx_select_frame.with(std::cell::Cell::get) {
19680 for row in (0..bh / MI).step_by(tx / MI) {20152 for row in (0..bh / MI).step_by(tx / MI) {
19681 for col in (0..bw / MI).step_by(tx / MI) {20153 for col in (0..bw / MI).step_by(tx / MI) {
19682 leaves.push((row, col, tx, tx));20154 leaves.push((row, col, tx, tx));
@@ -19712,7 +20184,7 @@ fn read_block_tx_size_rect(
19712 return Ok(Some(leaves));20184 return Ok(Some(leaves));
19713 }20185 }
19714 let (tx_w, tx_h) = (bw, bh);20186 let (tx_w, tx_h) = (bw, bh);
19715- if !fctx.tx_select_inter.with(std::cell::Cell::get) {20187+ if !fctx.tx_select_frame.with(std::cell::Cell::get) {
19716 // `TX_MODE_LARGEST`: no symbol at all, the whole block is one20188 // `TX_MODE_LARGEST`: no symbol at all, the whole block is one
19717 // transform, and `set_txfm_ctxs` records exactly what20189 // transform, and `set_txfm_ctxs` records exactly what
19718 // `txfm_partition_update` would for that same unit.20190 // `txfm_partition_update` would for that same unit.
@@ -19913,6 +20385,16 @@ fn extend_corner(corner: Grid, cw: usize, ch: usize, w: usize, h: usize) -> Grid
19913 Grid::Own(full)20385 Grid::Own(full)
19914 }20386 }
19915 20387
20388+/// [`embed_rect_grid`] that keeps the shared zero marker zero: an all-zero
20389+/// transform unit's grid IS `Grid::Zero` (whose deref is the shared
20390+/// `ZERO_RESIDUAL`), so re-laying it would read a zero-length slice.
20391+fn embed_grid_stride(grid: &Grid, w: usize, h: usize, stride: usize) -> Grid {
20392+ if is_zero_grid(grid) {
20393+ return Grid::Zero(stride * stride);
20394+ }
20395+ Grid::Own(embed_rect_grid(grid, w, h, stride))
20396+}
20397+
19916 /// A rect coefficient grid re-laid into the square `stride x stride` grid the20398 /// A rect coefficient grid re-laid into the square `stride x stride` grid the
19917 /// neighbour/deblock stamps downstream of the residual expect.20399 /// neighbour/deblock stamps downstream of the residual expect.
19918 fn embed_rect_grid(grid: &[i32], w: usize, h: usize, stride: usize) -> Vec<i32> {20400 fn embed_rect_grid(grid: &[i32], w: usize, h: usize, stride: usize) -> Vec<i32> {
@@ -23490,6 +23972,7 @@ pub(crate) fn decode_key_frame_tile_with_cdfs(
23490 // otherwise inherit it and read its `tx_depth` context off the inter23972 // otherwise inherit it and read its `tx_depth` context off the inter
23491 // frame's stale `TXFM_CONTEXT` bands.23973 // frame's stale `TXFM_CONTEXT` bands.
23492 fctx.tx_select_inter.with(|c| c.set(false));23974 fctx.tx_select_inter.with(|c| c.set(false));
23975+ fctx.tx_select_frame.with(|c| c.set(tx_select));
23493 // lane-av1-rect14: an intrabc block is `is_inter_block`, so its23976 // lane-av1-rect14: an intrabc block is `is_inter_block`, so its
23494 // `tx_type` CDF is the INTER set selected by this frame's23977 // `tx_type` CDF is the INTER set selected by this frame's
23495 // `reduced_tx_set`. Left at the cell default, the first coded23978 // `reduced_tx_set`. Left at the cell default, the first coded
crates/ec-av1/src/mvstack.rsmodified+71 -3
@@ -251,6 +251,30 @@ pub struct MiGrid {
251 cols: usize,251 cols: usize,
252 rows: usize,252 rows: usize,
253 cells: Vec<Option<MiInfo>>,253 cells: Vec<Option<MiInfo>>,
254+ /// lane-av1-intrabc r4: the CODED BLOCK's own `(width, height)` in mi
255+ /// units for every cell of the frame, whatever the block is -- the
256+ /// block-COVERAGE map a scan's run-length stepping needs.
257+ ///
258+ /// libaom's candidate scans walk `xd->mi[]`, which holds an
259+ /// `MB_MODE_INFO` for EVERY coded block, and step by
260+ /// `mi_size_wide/height[candidate->bsize]`. A decoder grid that only
261+ /// holds the blocks with an MV (the intrabc blocks here) makes every
262+ /// intra neighbour read as *uncovered*: the scan then advances that cell
263+ /// by one instead of by the neighbour's real width, which walks it
264+ /// straight into a cell libaom never probes -- and can even vote.
265+ /// Measured on the 512x384 `testsrc2` cq45 `--enable-tx-size-search=0`
266+ /// arm: at `mi(84,104)` the row scan's extended offset `-3` over-reached
267+ /// from `(81,106)` (libaom's last probe, an 8x16 intrabc voting
268+ /// `-520`) to `(81,108)` (a 16x16 intrabc voting `-512` with a 16-wide
269+ /// weight), flipping the sorted stack so `nearestmv` became `-512` where
270+ /// libaom's is `-520` -- one whole-pel-wrong DV predictor, identical
271+ /// coded diff, 528 wrong luma samples.
272+ ///
273+ /// `[0, 0]` means "no block recorded here" and reads as uncovered, so
274+ /// every grid that never fills this map (the tile writer's own, and
275+ /// every synthetic test grid) keeps exactly its old `None`-per-cell
276+ /// behaviour.
277+ cover: Vec<[u8; 2]>,
254 /// One `skip` flag per cell, beside `cells` rather than inside `MiInfo`278 /// One `skip` flag per cell, beside `cells` rather than inside `MiInfo`
255 /// -- the mv-stack scan walks `cells` for every inter block, so the CELL279 /// -- the mv-stack scan walks `cells` for every inter block, so the CELL
256 /// must stay 16 bytes (`mi_info_cell_stays_compact`), and nothing on the280 /// must stay 16 bytes (`mi_info_cell_stays_compact`), and nothing on the
@@ -287,6 +311,7 @@ impl MiGrid {
287 cols,311 cols,
288 rows,312 rows,
289 cells: vec![None; cols * rows],313 cells: vec![None; cols * rows],
314+ cover: vec![[0, 0]; cols * rows],
290 skips: vec![false; cols * rows],315 skips: vec![false; cols * rows],
291 tile_row0: 0,316 tile_row0: 0,
292 tile_col0: 0,317 tile_col0: 0,
@@ -415,8 +440,33 @@ impl MiGrid {
415 }440 }
416 }441 }
417 442
443+ /// Records the `w_mi` x `h_mi` footprint of the coded block at
444+ /// `(row, col)` in this grid's block-coverage map (see `cover`) -- called
445+ /// for EVERY coded block, not just the ones that carry an MV. Out-of-range
446+ /// coordinates are a no-op, and an overhanging width is clipped to the
447+ /// grid (the recorded width still names the block's real one, exactly as
448+ /// `mi_size_wide[bsize]` does).
449+ pub fn cover_rect(&mut self, row: usize, col: usize, w_mi: usize, h_mi: usize) {
450+ if row >= self.rows || col >= self.cols || w_mi == 0 || h_mi == 0 {
451+ return;
452+ }
453+ let w = w_mi.min(self.cols - col);
454+ let cell = [w_mi as u8, h_mi as u8];
455+ for r in row..(row + h_mi).min(self.rows) {
456+ let base = r * self.cols + col;
457+ self.cover[base..base + w].fill(cell);
458+ }
459+ }
460+
418 /// The unit at `(row, col)`, or `None` when it is outside the grid, hasn't461 /// The unit at `(row, col)`, or `None` when it is outside the grid, hasn't
419 /// been coded, or sits outside the current tile's own bounds ([`Self::set_tile_bounds`]).462 /// been coded, or sits outside the current tile's own bounds ([`Self::set_tile_bounds`]).
463+ ///
464+ /// A cell that holds no MV but IS covered by a recorded block
465+ /// ([`Self::cover_rect`]) reads as that block's own footprint with
466+ /// `is_inter == false` -- libaom's `xd->mi[]` always holds an
467+ /// `MB_MODE_INFO`, and a candidate that casts no vote still advances the
468+ /// scan by its own width. Such an entry can never match
469+ /// (`single_ref_match` rejects a non-inter unit) and carries a zero MV.
420 pub fn get(&self, row: usize, col: usize) -> Option<MiInfo> {470 pub fn get(&self, row: usize, col: usize) -> Option<MiInfo> {
421 if row < self.rows471 if row < self.rows
422 && col < self.cols472 && col < self.cols
@@ -425,10 +475,28 @@ impl MiGrid {
425 && col >= self.tile_col0475 && col >= self.tile_col0
426 && col < self.tile_col1476 && col < self.tile_col1
427 {477 {
428- self.cells[row * self.cols + col]478+ let idx = row * self.cols + col;
429- } else {479+ if let Some(info) = self.cells[idx] {
430- None480+ return Some(info);
431 }481 }
482+ let [w, h] = self.cover[idx];
483+ if w == 0 {
484+ return None;
485+ }
486+ return Some(MiInfo {
487+ is_inter: false,
488+ ref_frame: 0,
489+ ref_frame1: NO_REF1,
490+ mv: (0, 0),
491+ mv1: (0, 0),
492+ is_new_mv: false,
493+ is_global_mv0: false,
494+ is_global_mv1: false,
495+ size: w,
496+ size_h: h,
497+ });
498+ }
499+ None
432 }500 }
433 501
434 /// The unit at `(row, col)` ignoring the tile window -- the frame-level502 /// The unit at `(row, col)` ignoring the tile window -- the frame-level
crates/ec-av1/src/stream.rsmodified+305 -4
@@ -6330,6 +6330,12 @@ pub(crate) mod tests {
6330 // (arm, source, per-arm overrides AFTER the base recipe, expect_refusal,6330 // (arm, source, per-arm overrides AFTER the base recipe, expect_refusal,
6331 // must_read_use_intrabc_on_a_rect_strip)6331 // must_read_use_intrabc_on_a_rect_strip)
6332 let arms: [(&str, &str, &[&str], bool, bool); 8] = [6332 let arms: [(&str, &str, &[&str], bool, bool); 8] = [
6333+ // lane-av1-intrabc (2026-09-20): this arm used to REFUSE here -- the
6334+ // 16x8 rect strip it decodes is the first block on main that reaches
6335+ // `decode_intrabc_rect`, so the whole arm stopped at a named refusal.
6336+ // Reconstruction is ported now, so the arm decodes pixel-exact and
6337+ // the `rect_total` assert below keeps it from quietly falling back
6338+ // to an ordinary-intra decode of the same block.
6333 ("testsrc2-cq50-txs0", TS, &["--cq-level=50", "--enable-palette=0", "--enable-tx-size-search=0"], false, true),6339 ("testsrc2-cq50-txs0", TS, &["--cq-level=50", "--enable-palette=0", "--enable-tx-size-search=0"], false, true),
6334 ("smptebars-cq40-txs0", SB, &["--cq-level=40", "--enable-palette=0", "--enable-tx-size-search=0"], false, false),6340 ("smptebars-cq40-txs0", SB, &["--cq-level=40", "--enable-palette=0", "--enable-tx-size-search=0"], false, false),
6335 ("smptebars-cq45-txs0", SB, &["--cq-level=45", "--enable-palette=0", "--enable-tx-size-search=0"], false, true),6341 ("smptebars-cq45-txs0", SB, &["--cq-level=45", "--enable-palette=0", "--enable-tx-size-search=0"], false, true),
@@ -6348,6 +6354,7 @@ pub(crate) mod tests {
6348 let (mut blocks_total, mut fired_arms, mut out_of_scope, mut out_of_scope_mismatch) =6354 let (mut blocks_total, mut fired_arms, mut out_of_scope, mut out_of_scope_mismatch) =
6349 (0usize, 0u32, 0u32, 0u32);6355 (0usize, 0u32, 0u32, 0u32);
6350 let mut leaf8_total = 0usize;6356 let mut leaf8_total = 0usize;
6357+ let mut rect_total = 0usize;
6351 for (arm, src, extra, expect_refusal, must_read) in &arms {6358 for (arm, src, extra, expect_refusal, must_read) in &arms {
6352 let render = || {6359 let render = || {
6353 let out = Command::new("ffmpeg")6360 let out = Command::new("ffmpeg")
@@ -6420,6 +6427,7 @@ pub(crate) mod tests {
6420 decode::reset_rect_intrabc_reads();6427 decode::reset_rect_intrabc_reads();
6421 crate::decode::reset_intrabc_hits();6428 crate::decode::reset_intrabc_hits();
6422 crate::decode::reset_leaf8_intrabc_hits();6429 crate::decode::reset_leaf8_intrabc_hits();
6430+ crate::decode::reset_intrabc_rect_hits();
6423 let decoded = decode_stream(&stream);6431 let decoded = decode_stream(&stream);
6424 let reads = decode::rect_intrabc_reads();6432 let reads = decode::rect_intrabc_reads();
6425 // Blocks that decoded `use_intrabc == 1` (square path), i.e. that6433 // Blocks that decoded `use_intrabc == 1` (square path), i.e. that
@@ -6434,6 +6442,7 @@ pub(crate) mod tests {
6434 // `gate-blind-to-feature`).6442 // `gate-blind-to-feature`).
6435 let leaf8 = crate::decode::leaf8_intrabc_hits();6443 let leaf8 = crate::decode::leaf8_intrabc_hits();
6436 leaf8_total += leaf8;6444 leaf8_total += leaf8;
6445+ rect_total += crate::decode::intrabc_rect_hits();
6437 if *arm == "testsrc2-cq55-leaf8" {6446 if *arm == "testsrc2-cq55-leaf8" {
6438 assert!(6447 assert!(
6439 leaf8 > 0,6448 leaf8 > 0,
@@ -6510,7 +6519,9 @@ pub(crate) mod tests {
6510 {refused} refused by name, {frames_compared} frames compared, \6519 {refused} refused by name, {frames_compared} frames compared, \
6511 {out_of_scope} out of scope ({out_of_scope_mismatch} mismatched)"6520 {out_of_scope} out of scope ({out_of_scope_mismatch} mismatched)"
6512 );6521 );
6513- eprintln!("{NAME}: {leaf8_total} intrabc block(s) at an 8x8 leaf");6522+ eprintln!(
6523+ "{NAME}: {rect_total} intrabc block(s) on a HORZ/VERT rect strip (decode_intrabc_rect)"
6524+ );
6514 assert!(reads_total > 0, "{NAME}: gate is vacuous -- no arm read the symbol");6525 assert!(reads_total > 0, "{NAME}: gate is vacuous -- no arm read the symbol");
6515 assert!(6526 assert!(
6516 leaf8_total > 0,6527 leaf8_total > 0,
@@ -6520,10 +6531,16 @@ pub(crate) mod tests {
6520 blocks_total > 0 && fired_arms > 0,6531 blocks_total > 0 && fired_arms > 0,
6521 "{NAME}: gate is vacuous -- no compared arm actually decoded an intrabc block"6532 "{NAME}: gate is vacuous -- no compared arm actually decoded an intrabc block"
6522 );6533 );
6523- assert_eq!(6534+ assert!(
6524- refused, 0,6535+ rect_total > 0,
6525- "{NAME}: a rect-strip intrabc block refused -- reconstruction regressed"6536+ "{NAME}: no arm decoded an intrabc block on a HORZ/VERT rect strip -- \
6537+ `decode_intrabc_rect` is untested"
6526 );6538 );
6539+ // lane-av1-intrabc: this used to be exactly one -- the 2:1 rect strips
6540+ // now reconstruct. The 1:4 pair strips (`decode_rect4_16_strip` et al.)
6541+ // still refuse by name, but no arm HERE reaches that shape; it stays
6542+ // pinned by `refusal_inventory`'s own gate.
6543+ assert_eq!(refused, 0, "{NAME}: an arm still refuses by name");
6527 assert!(frames_compared > 0, "{NAME}: no frame was compared pixel-exact");6544 assert!(frames_compared > 0, "{NAME}: no frame was compared pixel-exact");
6528 assert_eq!(6545 assert_eq!(
6529 out_of_scope_mismatch, 0,6546 out_of_scope_mismatch, 0,
@@ -6646,6 +6663,290 @@ pub(crate) mod tests {
6646 // even if some other prefix sample happens to match.6663 // even if some other prefix sample happens to match.
6647 assert_eq!(frames[0].y[108], refs[0].y[108], "{NAME}: measured byte 108");6664 assert_eq!(frames[0].y[108], refs[0].y[108], "{NAME}: measured byte 108");
6648 }6665 }
6666+ /// lane-av1-intrabc r4: the reviewer's unblock witness for the rect-strip
6667+ /// reconstruction -- a CODED `use_intrabc` block (so its residual reader
6668+ /// runs, not just the prediction copy) on a 2:1 strip in BOTH
6669+ /// orientations, plus the `TX_MODE_SELECT` (var-tx) shape, every arm
6670+ /// byte-exact against ffmpeg.
6671+ ///
6672+ /// The orientation counters (`intrabc_rect_coded_hits`) are the
6673+ /// non-vacuity instrument: [`intrabc_rect_hits`] counts neither the skip
6674+ /// flag nor the orientation, so an arm that silently became an all-skip
6675+ /// stream (or a stream with only one orientation) would keep the old gate
6676+ /// green while the coded residual path went untested
6677+ /// (class `gate-blind-to-feature`).
6678+ ///
6679+ /// # The VERT arm is also the DV-PREDICTOR regression witness
6680+ ///
6681+ /// The 512x384 arm is the stream that exposed r4's defect: 528 of 294912
6682+ /// luma samples were wrong, all inside one `skip == 1` intrabc copy at
6683+ /// `mi(84,104)`. Its coded diff was identical to aomdec's and the post-read
6684+ /// range matched exactly (`rng=33207` both), so nothing was misread -- the
6685+ /// DV PREDICTOR differed. libaom picks `nearestmv` (`-520`) from the
6686+ /// `INTRA_FRAME` MV stack; this decoder picked `-512`, one stack entry
6687+ /// lower, because the scan that builds that stack walked further than
6688+ /// libaom's. The scans step by the candidate BLOCK's own width
6689+ /// (`mi_size_wide[bsize]`) over `xd->mi[]`, which holds an entry for every
6690+ /// coded block; this decoder's MV grid held only the intrabc blocks, so a
6691+ /// non-intrabc neighbour read as uncovered and the scan advanced that cell
6692+ /// by one instead of by its real width. See `MiGrid::cover` for the
6693+ /// measured walk. A stream that decodes the DV predictor from the wrong
6694+ /// stack entry cannot pass this arm's pixel comparison.
6695+ #[test]
6696+ fn a_coded_rect_intrabc_block_reconstructs_in_both_orientations() {
6697+ const NAME: &str = "a_coded_rect_intrabc_block_reconstructs_in_both_orientations";
6698+ if !have_ffmpeg() {
6699+ eprintln!("SKIP {NAME}: no ffmpeg");
6700+ return;
6701+ }
6702+ if !have_aomenc() {
6703+ eprintln!("SKIP {NAME}: no aomenc at {}", aomenc_path().display());
6704+ return;
6705+ }
6706+ const TS256: &str = "testsrc2=s=256x192:r=25";
6707+ const TS512: &str = "testsrc2=s=512x384:r=25";
6708+ // (arm, source, width, height, per-arm overrides, the coded orientation
6709+ // this arm must exercise, and whether the frame must code
6710+ // `TX_MODE_SELECT` with `allow_intrabc` still set)
6711+ let arms: [(&str, &str, usize, usize, &[&str], u8, bool); 3] = [
6712+ // HORZ (16x8) coded strip -- the shape the in-gate witness above
6713+ // already reconstructs, pinned here with its own orientation counter.
6714+ ("horz-coded-256-cq45-pal0-txs0", TS256, 256, 192, &["--cq-level=45", "--enable-palette=0", "--enable-tx-size-search=0"], 0, false),
6715+ // VERT (8x16) coded strip AND the DV-predictor regression stream.
6716+ ("vert-coded-512-cq45-pal1-txs0", TS512, 512, 384, &["--cq-level=45", "--enable-palette=1", "--enable-tx-size-search=0"], 1, false),
6717+ // The `TX_MODE_SELECT` (stream A) shape: `--enable-tx-size-search=1`
6718+ // makes the frame code `tx_mode == Select`, so the intrabc block's
6719+ // transform size comes off the INTER var-tx tree.
6720+ ("txmode-select-256-cq45-pal0-txs1", TS256, 256, 192, &["--cq-level=45", "--enable-palette=0", "--enable-tx-size-search=1"], 0, true),
6721+ ];
6722+ let mut coded_total = [0usize; 2];
6723+ let mut frames_compared = 0usize;
6724+ for (arm, src, width, height, extra, want_orient, want_select) in &arms {
6725+ let render = || {
6726+ let out = Command::new("ffmpeg")
6727+ .args([
6728+ "-v", "error", "-f", "lavfi", "-i", *src, "-t", "0.2", "-pix_fmt",
6729+ "yuv420p", "-strict", "-1", "-f", "yuv4mpegpipe", "-",
6730+ ])
6731+ .stdin(Stdio::null())
6732+ .stdout(Stdio::piped())
6733+ .stderr(Stdio::piped())
6734+ .output()
6735+ .expect("ffmpeg failed to run");
6736+ assert!(out.status.success(), "{NAME}: ffmpeg failed for {arm}");
6737+ out.stdout
6738+ };
6739+ let y4m = render();
6740+ let mut child = Command::new(aomenc_path())
6741+ .args([
6742+ "--codec=av1",
6743+ "--bit-depth=8",
6744+ "--input-bit-depth=8",
6745+ "--passes=1",
6746+ "--end-usage=q",
6747+ "--cpu-used=0",
6748+ "--lag-in-frames=0",
6749+ "--kf-max-dist=1",
6750+ "--limit=1",
6751+ "--threads=1",
6752+ "--tile-columns=0",
6753+ "--enable-rect-partitions=1",
6754+ "--enable-1to4-partitions=1",
6755+ "--min-partition-size=8",
6756+ "--max-partition-size=32",
6757+ "--sb-size=64",
6758+ "--tune-content=screen",
6759+ "--enable-intrabc=1",
6760+ ])
6761+ // aomenc keeps the LAST occurrence of a repeated flag.
6762+ .args(*extra)
6763+ .args(["--obu", "-o", "-", "-"])
6764+ .stdin(Stdio::piped())
6765+ .stdout(Stdio::piped())
6766+ .stderr(Stdio::piped())
6767+ .spawn()
6768+ .expect("aomenc failed to start");
6769+ child
6770+ .stdin
6771+ .take()
6772+ .expect("aomenc stdin")
6773+ .write_all(&y4m)
6774+ .or_else(|e| match e.kind() {
6775+ std::io::ErrorKind::BrokenPipe => Ok(()),
6776+ _ => Err(e),
6777+ })
6778+ .expect("writing y4m to aomenc");
6779+ let out = child.wait_with_output().expect("aomenc failed to run");
6780+ assert!(
6781+ out.status.success(),
6782+ "{NAME}: aomenc refused {arm}: {}",
6783+ String::from_utf8_lossy(&out.stderr)
6784+ );
6785+ let stream = out.stdout;
6786+ if *want_select {
6787+ let (select, premise) = tx_select_and_intrabc_frames(&stream);
6788+ assert!(
6789+ select > 0 && premise > 0,
6790+ "{NAME}: {arm} no longer codes a frame with both tx_mode == Select and \
6791+ allow_intrabc (select={select} premise={premise}), so the TX_MODE_SELECT \
6792+ shape is untested here"
6793+ );
6794+ }
6795+ crate::decode::reset_intrabc_rect_hits();
6796+ let frames = decode_stream(&stream)
6797+ .unwrap_or_else(|e| panic!("{NAME}: {arm} refused: {e}"));
6798+ assert!(!frames.is_empty(), "{NAME}: {arm} decoded no frame");
6799+ let coded = crate::decode::intrabc_rect_coded_hits();
6800+ coded_total[0] += coded[0];
6801+ coded_total[1] += coded[1];
6802+ assert!(
6803+ coded[*want_orient as usize] > 0,
6804+ "{NAME}: {arm} reconstructed no CODED ({}) rect intrabc block -- the residual \
6805+ reader for this orientation is untested (coded horz/vert = {coded:?})",
6806+ if *want_orient == 0 { "HORZ" } else { "VERT" }
6807+ );
6808+ let theirs = ffmpeg_decode_sequence(&stream, *width, *height, frames.len());
6809+ assert_eq!(frames.len(), theirs.len(), "{NAME}: {arm} frame count");
6810+ for (i, (ours, ref_frame)) in frames.iter().zip(theirs.iter()).enumerate() {
6811+ assert!(
6812+ ours.y == ref_frame.y && ours.u == ref_frame.u && ours.v == ref_frame.v,
6813+ "{NAME}: {arm} frame {i} does not match ffmpeg"
6814+ );
6815+ frames_compared += 1;
6816+ }
6817+ eprintln!(
6818+ "{NAME}: {arm} {} frame(s) exact, coded rect intrabc horz={} vert={}",
6819+ frames.len(),
6820+ coded[0],
6821+ coded[1]
6822+ );
6823+ }
6824+ assert!(
6825+ coded_total[0] > 0 && coded_total[1] > 0,
6826+ "{NAME}: gate is vacuous -- coded rect intrabc blocks seen: horz={} vert={}",
6827+ coded_total[0],
6828+ coded_total[1]
6829+ );
6830+ assert!(frames_compared > 0, "{NAME}: no frame was compared pixel-exact");
6831+
6832+ // lane-av1-intrabc r5: the SKIPPED VERT 2:1 strip -- the arm the
6833+ // reviewer's sweep panicked on (a skipped 8x32 strip passed a
6834+ // `bw * bh`-sized ZERO_RESIDUAL slice at stride `side`, and
6835+ // `reconstruct_mc_rect` indexed `row * side + w` past its end).
6836+ // Skip-heavy recipes (low cq, palette off AND on), each decoded
6837+ // byte-exact vs ffmpeg on BOTH the default single-threaded path
6838+ // (`EC_AV1_RECON_THREADS == 1`, the inline ReconPlanes arm that
6839+ // panicked pre-fix) AND the wavefront path. The skipped-orientation
6840+ // counter is asserted per arm (`gate-blind-to-feature`): a recipe
6841+ // that stops producing a skipped VERT strip fails instead of passing
6842+ // vacuously. `lock_gate_counters` because `set_recon_threads` is a
6843+ // process-wide knob.
6844+ let _par_lock = lock_gate_counters();
6845+ let skip_arms: [(&str, &str, usize, usize, &[&str]); 2] = [
6846+ ("vert-skip-512-cq30-pal0-txs0", TS512, 512, 384, &["--cq-level=30", "--enable-palette=0", "--enable-tx-size-search=0"]),
6847+ ("vert-skip-512-cq30-pal1-txs0", TS512, 512, 384, &["--cq-level=30", "--enable-palette=1", "--enable-tx-size-search=0"]),
6848+ ];
6849+ for (arm, src, width, height, extra) in &skip_arms {
6850+ let y4m = {
6851+ let out = Command::new("ffmpeg")
6852+ .args([
6853+ "-v", "error", "-f", "lavfi", "-i", *src, "-t", "0.2", "-pix_fmt",
6854+ "yuv420p", "-strict", "-1", "-f", "yuv4mpegpipe", "-",
6855+ ])
6856+ .stdin(Stdio::null())
6857+ .stdout(Stdio::piped())
6858+ .stderr(Stdio::piped())
6859+ .output()
6860+ .expect("ffmpeg failed to run");
6861+ assert!(out.status.success(), "{NAME}: ffmpeg failed for {arm}");
6862+ out.stdout
6863+ };
6864+ let mut child = Command::new(aomenc_path())
6865+ .args([
6866+ "--codec=av1", "--bit-depth=8", "--input-bit-depth=8", "--passes=1",
6867+ "--end-usage=q", "--cpu-used=0", "--lag-in-frames=0", "--kf-max-dist=1",
6868+ "--limit=1", "--threads=1", "--tile-columns=0",
6869+ "--enable-rect-partitions=1", "--enable-1to4-partitions=1",
6870+ "--min-partition-size=8", "--max-partition-size=32", "--sb-size=64",
6871+ "--tune-content=screen", "--enable-intrabc=1",
6872+ ])
6873+ // aomenc keeps the LAST occurrence of a repeated flag.
6874+ .args(*extra)
6875+ .args(["--obu", "-o", "-", "-"])
6876+ .stdin(Stdio::piped())
6877+ .stdout(Stdio::piped())
6878+ .stderr(Stdio::piped())
6879+ .spawn()
6880+ .expect("aomenc failed to start");
6881+ child
6882+ .stdin
6883+ .take()
6884+ .expect("aomenc stdin")
6885+ .write_all(&y4m)
6886+ .or_else(|e| match e.kind() {
6887+ std::io::ErrorKind::BrokenPipe => Ok(()),
6888+ _ => Err(e),
6889+ })
6890+ .expect("writing y4m to aomenc");
6891+ let out = child.wait_with_output().expect("aomenc failed to run");
6892+ assert!(
6893+ out.status.success(),
6894+ "{NAME}: aomenc refused {arm}: {}",
6895+ String::from_utf8_lossy(&out.stderr)
6896+ );
6897+ let stream = out.stdout;
6898+ // Default single-threaded path first (the arm that panicked
6899+ // pre-fix), then the wavefront path; both must match ffmpeg.
6900+ let mut skipped_vert = 0usize;
6901+ for threads in [1usize, 4] {
6902+ crate::par::set_recon_threads(threads);
6903+ crate::decode::reset_intrabc_rect_hits();
6904+ let frames = match decode_stream(&stream) {
6905+ Ok(frames) => frames,
6906+ Err(e) => {
6907+ crate::par::set_recon_threads(1);
6908+ panic!("{NAME}: {arm} refused at {threads} recon thread(s): {e}")
6909+ }
6910+ };
6911+ let skipped = crate::decode::intrabc_rect_skipped_hits();
6912+ assert!(
6913+ !frames.is_empty(),
6914+ "{NAME}: {arm} decoded no frame at {threads} recon thread(s)"
6915+ );
6916+ let theirs = ffmpeg_decode_sequence(&stream, *width, *height, frames.len());
6917+ assert_eq!(
6918+ frames.len(),
6919+ theirs.len(),
6920+ "{NAME}: {arm} frame count at {threads} recon thread(s)"
6921+ );
6922+ for (i, (ours, ref_frame)) in frames.iter().zip(theirs.iter()).enumerate() {
6923+ assert!(
6924+ ours.y == ref_frame.y && ours.u == ref_frame.u && ours.v == ref_frame.v,
6925+ "{NAME}: {arm} frame {i} does not match ffmpeg at {threads} recon thread(s)"
6926+ );
6927+ }
6928+ if threads == 1 {
6929+ skipped_vert = skipped[1];
6930+ } else {
6931+ assert_eq!(
6932+ skipped[1], skipped_vert,
6933+ "{NAME}: {arm} skipped VERT strip count changed across recon paths"
6934+ );
6935+ }
6936+ eprintln!(
6937+ "{NAME}: {arm} {} frame(s) exact at {threads} recon thread(s), skipped rect intrabc horz={} vert={}",
6938+ frames.len(),
6939+ skipped[0],
6940+ skipped[1]
6941+ );
6942+ }
6943+ crate::par::set_recon_threads(1);
6944+ assert!(
6945+ skipped_vert > 0,
6946+ "{NAME}: {arm} reconstructed no SKIPPED VERT rect intrabc strip -- the r5 stride arm is untested"
6947+ );
6948+ }
6949+ }
6649 6950
6650 /// lane-t900 r31: builds one `--tune-content=screen --enable-intrabc=1`6951 /// lane-t900 r31: builds one `--tune-content=screen --enable-intrabc=1`
6651 /// key frame, 256x192 8-bit, from a deterministic lavfi source. `tiled`6952 /// key frame, 256x192 8-bit, from a deterministic lavfi source. `tiled`
lanes/av1intrabc.report.mdadded+539 -0
@@ -0,0 +1,539 @@
1+# lane-av1-intrabc - rect-strip intrabc reconstruction (HORZ/VERT 2:1 shapes)
2+
3+Base `main` **3ecd4a10**. Worktree `../edith_codecs-av1ibc`, branch
4+`lane-av1-intrabc`, `CARGO_TARGET_DIR=$HOME/.cache/cargo-target-av1ibc`.
5+
6+## 1. What landed
7+
8+`decode_intrabc_rect` (`crates/ec-av1/src/decode.rs`, ~10910): the missing
9+reconstruction arm for a `use_intrabc` block on a **2:1 rect strip**, ported
10+from libaom's `av1_predict_intra_block`/`predict_inter_block` intrabc path:
11+
12+- whole-block prediction once (`predict_inter_block`), for luma at the block
13+ footprint and for both chroma planes at `av1_get_max_uv_txsize(bw x bh)`;
14+- skip case: prediction IS the block (`push_mc_rect`, zero residual);
15+- coded case: residual per transform unit -- one whole-block rect TU
16+ (`read_inter_plane_rect`, `TxbSet::LumaRect32x16`/`ChromaRect16x8` and the
17+ real rect scan/context tables) or one residual per var-tx leaf;
18+- bookkeeping identical in shape to the square intrabc path: mode
19+ `DC_PRED` into the mode maps, coefficient contexts, zeroed palette state,
20+ skip/LF grids, and the DV into the intrabc mi grid.
21+
22+Wired at all 2:1 rect intrabc slots: `decode_block_rect` (16x32/32x16),
23+`decode_block_rect4` (32x8/8x32 + 16x8/8x16), `decode_leaf_rect`; in
24+`decode_block_rect64`/`decode_block_128rect` the wiring REFUSES the shape (a
25+named refusal slot, not a reconstruction); engagement counters
26+`intrabc_rect_hits` / `intrabc_rect_vartx_hits` exposed on `decode_probe`.
27+
28+## 2. Byte-exactness witnesses
29+
30+In-gate (flipped pin -> witness): `stream::tests::
31+a_real_aomenc_screen_key_frame_reads_use_intrabc_on_rect_strips`. Its
32+`testsrc2-cq50-txs0` arm used to stop at the rect-strip refusal; it now decodes
33+1 frame, **1 intrabc block on a HORZ/VERT rect strip**, pixel-exact vs ffmpeg.
34+Gate totals (re-measured at r4, on the committed tree): **5** intrabc blocks
35+over **5** arms -- 3 arms decode ZERO intrabc blocks (out of scope), 187 rect
36+`use_intrabc` reads, 8 frames compared, 0 mismatches, 0 named refusals, 1
37+intrabc block on a HORZ/VERT rect strip. The r4 gate
38+`a_coded_rect_intrabc_block_reconstructs_in_both_orientations` adds 3 more
39+byte-exact frames (HORZ coded, VERT coded, TX_MODE_SELECT).
40+
41+Standalone recipes (aomenc oracle at `~/.cache/aom-oracle/build/aomenc`, probe
42+`cargo run --release -p ec-av1 --example decode_probe -- <obu>`):
43+
44+| recipe (base: `--cpu-used=0 --tune-content=screen --enable-intrabc=1
45+--min-partition-size=8 --max-partition-size=32 --sb-size=64 --enable-palette=1
46+--enable-tx-size-search=0 --enable-rect-partitions=1 --enable-1to4-partitions=1`) | intrabc rect blocks | shape (mi) | skip | result |
47+|---|---|---|---|---|
48+|`testsrc2=s=256x192:r=25 --cq-level=50 --enable-palette=0`, 1:4 off|0|--|--|REFUSED (16x8 CPR block, `--enable-1to4-partitions=0`)|
49+|`testsrc2=s=256x192:r=25 --cq-level=50 --enable-palette=0 --min-partition-size=4 --max-partition-size=16`|1|16x8 @(38,48)|0|**EXACT**|
50+|`testsrc2=s=256x192:r=25 --cq-level=45 --enable-palette=0`|1|16x8 @(38,48)|0|**EXACT**|
51+|`testsrc2=s=256x192:r=25 --cq-level=45 --enable-palette=1`|1|16x8 @(38,48)|0|**EXACT**|
52+|`testsrc2=s=256x192:r=25 --cq-level=50`, 1:4 off, `--enable-tx-size-search=1`|0|--|--|REFUSED|
53+
54+Every `EXACT` row is `cmp` of the probe's raw output against ffmpeg
55+`-pix_fmt yuv420p` decoded from the same `.obu`, i.e. byte-identical planes.
56+The 16x8 witnesses exercise the residual reader (`skip=0`); the 8x32
57+witnesses exercise `decode_block_rect4`'s wiring through the same helper.
58+
59+## 3. Still refused by name
60+
61+**1:4 pair strips** (`PARTITION_HORZ_4`/`VERT_4`, 16x4/4x16):
62+`intra block copy on a HORZ/VERT/1:4 rect intra strip (reconstruction is not
63+ported at this shape)` at `decode_rect4_16_strip`, `decode_block_rect4`'s 1:4
64+arm and `decode_block_128rect`. Reason this is NOT this lane's helper: a 1:4
65+strip is coded as a PAIR (both children share one chroma block). The chroma is
66+sourced at the pair's **odd-mi member** -- the BOTTOM strip of a `HORZ_4` pair,
67+the RIGHT strip of a `VERT_4` one (`is_chroma_reference`, `av1_common_int.h`
68+-- the reviewer corrected an earlier, inverted note in this report) -- and the
69+pair's chroma transform is read once for the pair, so its neighbour and
70+coefficient bookkeeping is a different model from the 2:1 helper above. Reachable witnesses for whoever takes it next:
71+`aomenc --allintra` (already stops there today), `--allintra` cpu-used 0
72+(lands there after the tx-depth/tx-band work, see lane-av1-txbands), and this
73+hand-made recipe: `testsrc2=s=640x480:r=25 --cq-level=60 --enable-palette=1
74+--enable-tx-size-search=0 --enable-rect-partitions=1 --enable-1to4-partitions=1
75+--sb-size=64` (16x4 @ mi(76,108), skip=0).
76+
77+**Mixed-leaf var-tx intrabc** (`decode.rs:14816`): unchanged. The census gate
78+`an_intrabc_vartx_census_measures_the_mixed_leaf_refusal` (green) shows the
79+four-quantiser census still produces UNIFORM var-tx trees only, so no reachable
80+stream exercises it -- census-pinned, as the wave plan expected. The 2:1 helper
81+itself already handles a var-tx tree's leaves (`INTRABC_RECT_VARTX_HITS`), so
82+the refusal that remains is only the square/leaf path's.
83+
84+## 4. Gates run
85+
86+- `cargo check -p ec-av1 --all-targets` -> 0 warnings.
87+- `cargo test -p ec-av1 --lib -- --exact stream::tests::
88+ a_real_aomenc_screen_key_frame_reads_use_intrabc_on_rect_strips` -> ok.
89+- `cargo test -p ec-av1 --lib -- refusal` -> 21 passed.
90+- Full `--lib` suite: NOT run to completion by this lane (budget); sibling lane
91+ lane-av1-txbands is editing the same file, so the workspace-wide run belongs
92+ to the batch-level gate.
93+
94+## 4b. Review round 2 (2026-09-20) -- what the fixes did and what is STILL open
95+
96+Fixed on this branch (reviewer findings P1-2 / P2 and part of P1-1):
97+
98+- **P1-2 (panic)**: every rect residual/prediction in `decode_intrabc_rect` now
99+ uses the proven INTER path's square stride (`side = bw.max(bh)`,
100+ `cside = cw.max(ch)`), and the prediction window is re-laid at that stride.
101+ Before: `TxParams::run` panicked (`range end index 8 out of range`) on every
102+ coded VERT strip.
103+- **P2 (LF grid)**: the var-tx arm now applies
104+ `Neighbours::fill_lf_grid_leaf_luma` per leaf (LUMA only), the step the
105+ proven inter var-tx path applies.
106+- **P1-1 (tx-mode)**: the intrabc tx-size read no longer keys on
107+ `fctx.tx_select_inter` (forced false by the key-frame tile decoder) but on a
108+ new frame-level `fctx.tx_select_frame`, set for EVERY frame from the frame
109+ header's own `tx_mode == TxMode::Select`. Measured effect: the var-tx arm now
110+ fires (`intrabc_rect_vartx_hits == 1`) on the encode below.
111+
112+**STILL NOT BYTE-EXACT** -- two repros, both with the mismatch confined to the
113+frame's BOTTOM 64-row band (luma rows h-64..h-1, chroma rows h/2-32..h/2-1):
114+
115+```
116+# var-tx leaf arm (intrabc_rect=1, var-tx tree=1): 4520/73728 bytes differ
117+ffmpeg -v error -f lavfi -i testsrc2=s=256x192:r=25 -t 0.2 -pix_fmt yuv420p -strict -1 -f yuv4mpegpipe - | ~/.cache/aom-oracle/build/aomenc --codec=av1 --bit-depth=8 --input-bit-depth=8 --passes=1 --end-usage=q --cpu-used=0 --lag-in-frames=0 --kf-max-dist=1 --limit=1 --threads=1 --tile-columns=0 --min-partition-size=8 --max-partition-size=32 --sb-size=64 --tune-content=screen --enable-intrabc=1 --cq-level=45 --enable-palette=0 --enable-tx-size-search=1 --enable-rect-partitions=1 --enable-1to4-partitions=1 --obu -o /tmp/a31.obu -
118+# coded rect arm (intrabc_rect=2): no panic now, 7900/294912 bytes differ
119+# ... same recipe, testsrc2=s=512x384:r=25 --cq-level=45 --enable-palette=1
120+# --enable-tx-size-search=0
121+```
122+
123+First divergence of the 256x192 arm: luma row 128, column 224 (the bottom
124+superblock row); of the 512x384 arm: luma row 320, column 424. So a coded rect
125+intrabc block in the bottom band still reconstructs wrong -- the shapes the
126+in-gate witness covers (`testsrc2-cq50-txs0`, `--enable-tx-size-search=0`,
127+skip and coded 16x8) stay pixel-exact, and every `smptebars`/`testsrc2` recipe
128+above is EXACT, so the defect is specific to these two arms and is the first
129+thing the next round must localize (per-block DV/prediction trace against
130+`EC_VARTX`/`EC_ISTEP`).
131+
132+**Verdict: NOT merge-ready.** The two P1s are addressed structurally (no panic,
133+correct tx-mode keying) and the P2 step is in, but the reviewer's merge
134+unblock condition -- a coded rect intrabc witness in BOTH orientations plus a
135+TX_MODE_SELECT one, all byte-exact -- is NOT met: the TX_MODE_SELECT arm is
136+exactly the 256x192 repro above and it is still 4520 bytes off.
137+
138+## 5. Deferred
139+
140+1. **1:4 pair-strip intrabc** -- named above, with the model difference and the
141+ witness recipes. `deferred(1:4 pair-chroma model)`
142+2. **Full-suite gate** -- `deferred(batch-level run after lane-av1-txbands
143+ merges; same file, mid-flight run would measure a half-built tree)`
144+
145+## 4c. Round 3 (2026-09-20) -- two frame-level root causes found, one stream now exact
146+
147+Both repros were localized with a per-symbol range ladder
148+(`EC_TRACE_MODE_STEP` on our decoder vs the instrumented aomdec), then the
149+first untraced region with `EC_TRACE_COEFF`/`EC_ISTEP`.
150+
151+### Root cause 1 (stream A, and latent for every rect strip): the key-frame RECT path never published the `TXFM_CONTEXT` bands
152+
153+`read_intra_frame_mode_info` (libaom `decodemv.c:909`) returns EARLY for an
154+intrabc block, so the block's transform size comes from
155+`parse_decode_block`'s INTER var-tx branch -- `read_tx_size_vartx`, whose
156+depth-0 context is `txfm_partition_context(above_txfm[mi_col],
157+left_txfm[mi_row], bsize, tx_size)`. Those bands are written by libaom's
158+`set_txfm_ctxs` at the end of EVERY `decode_block`/`decode_token_recon_block`,
159+key frames included.
160+
161+Only `decode_block` (lane-t900 r32, gated on the frame's `allow_intrabc`) and
162+`decode_block_rect4`/`decode_block_rect64`/`decode_rect4_16_strip`/
163+`decode_leaf_rect8` (gated on `INTRA_IN_INTER_MODE`) published. The 2:1 strip
164+readers reached on a key frame -- `decode_block_rect` (16x32/32x16),
165+`decode_leaf_rect` (8x16/16x8 leaves of a 16x16 HORZ/VERT split) and
166+`decode_block_128rect` -- published nothing.
167+
168+Measured (256x192 testsrc2 cq45 var-tx arm): the coded intrabc 16x8 strip at
169+mi(38,48) read `txfm_split_rect ctx=14` where aomdec reads `ctx=13`; the left
170+band held 4 (from the 8x8 at mi(38,42)) where libaom had 8 (published by the
171+non-intrabc 16x8 intra strip at mi(38,44), `tx_depth=0` -> `TX_16X8`,
172+`tx_size_high=8`), i.e. `left = 4 < 8` (true) instead of `8 < 8` (false). From
173+that wrong CDF row the tile desynced at the very next symbol.
174+
175+Fix: `publish_txfm_bands_if_in_inter`'s guard now also fires when
176+`allow_intrabc_frame(fctx)`, and the three missing readers above call it with
177+`depth_to_tx_wh(bw, bh, depth, fctx)` (one call each, placed before their
178+`depth != 0` split branch so both arms publish once).
179+
180+### Root cause 2 (stream B): a key frame never published the frame's `reduced_tx_set`
181+
182+`decode_key_frame_tile_with_cdfs` set `tx_select_inter=false` and the (r2)
183+`tx_select_frame`, but not `reduced_tx_set_inter`, which therefore kept its
184+`true` DEFAULT (or an inter frame's stale value). An intrabc block is
185+`is_inter_block`, so `read_tx_type` resolves its `tx_type` through the INTER
186+sets -- `av1_get_ext_tx_set_type` off `cm->features.reduced_tx_set_used`.
187+
188+Measured (512x384 testsrc2 cq45 `--enable-tx-size-search=0`): the first rect
189+(8x16) intrabc block at mi(80,106) read `tx_type` from a 2-symbol CDF
190+(`inter_tx_type_8`, `head=[4167,32768,0]`) where aomdec read the 16-symbol
191+`EXT_TX_SET_ALL16` row (`inter_ext_tx_cdf[1][TX_8X8]`,
192+`eset=1 set=5 sqr=1 nsym=16`, `head=[31123,30195,27990,27057]`); post-read
193+range 37912 vs 62176. Every earlier intrabc block in that frame was 16x16
194+(square), which never consults this cell, so the defect surfaced exactly at the
195+first rect strip.
196+
197+Fix: `decode_key_frame_tile_with_cdfs` now publishes the header's
198+`reduced_tx_set` into `fctx.reduced_tx_set_inter`, mirroring `tx_select_frame`.
199+
200+### State after the two fixes (no push; committed on the lane)
201+
202+| stream | bytes differ before | now |
203+|---|---|---|
204+| A 256x192 var-tx 16x8 | 4520/73728 | **BYTE-EXACT** (Y/U/V, `cmp` vs ffmpeg) |
205+| B 512x384 coded 8x16 | 7900/294912 | 528 luma samples |
206+
207+### What is STILL open on B (precise)
208+
209+The mode-info ladder is now fully IN SYNC (identical symbol sequence AND
210+identical post-read ranges through the end of the frame), and the residual
211+reads agree. The single remaining difference is a **DV VALUE**:
212+
213+```
214+O EC_DV mi_row=84 mi_col=104 dv_col=0 dv_row=-512 rng=33207
215+U EC_DV mi_row=84 mi_col=104 dv_col=0 dv_row=-504 rng=33207
216+```
217+
218+Same pre-range (33207 after the read on both sides) means the coded
219+`diff` is identical; the reconstructed DV differs because the **DV predictor**
220+differs. aomdec's own `EC_IBC` line for that block reads
221+`bsize=6 skip=1 nstack=2 nearest=(-520,0) near=(-512,0) dv_ref=(-520,0)
222+dv=(-512,0)`, i.e. `ref = nearest = -520`; our result `-504` is consistent with
223+`ref = -512` (the `nearmv`), so our intrabc `INTRA_FRAME` MV-stack ORDERING at
224+that block differs from libaom's (`av1_find_mv_refs` -> `setup_ref_mv_list` ->
225+`av1_find_best_ref_mvs`, then `dv_ref = nearestmv != 0 ? nearestmv : nearmv`).
226+
227+The 528 mismatched luma samples (`rows 351..383`, `cols 416..431`) are all
228+inside this one wrong copy: the block is `skip=1`, so the wrong DV is a wrong
229+pixel copy, and the region below it inherits the shift.
230+
231+Next step for whoever takes it: instrument `read_intrabc_dv`'s candidate
232+gathering (`record_intrabc_mi_rect` / the mv-stack build) with the candidate
233+list for mi(84,104) and diff it against aomdec's `EC_IBC`
234+`nstack/nearest/near/dv_ref` (already printed) -- the defect is candidate
235+ORDER/WEIGHT, not the DV syntax.
236+
237+### Gates run this round
238+
239+- `cargo check -p ec-av1 --all-targets` -> 0 warnings.
240+- Standalone: A byte-exact; B 528 luma samples (from 7900).
241+- **Not run**: the in-gate `--lib` arms, the refusal suite, and the full suite.
242+ The lane is NOT merge-ready (B is not byte-exact and the reviewer's
243+ TX_MODE_SELECT gate is still red); the batch-level suite run stays deferred.
244+
245+`deferred(DV-predictor candidate ordering at mi(84,104))`
246+
247+## 4d. Round 4 (2026-09-20) -- the DV predictor's root cause is BLOCK COVERAGE, not candidate weighting; stream B is byte-exact
248+
249+The remaining defect was localized to a single wrong DV at `mi(84,104)` on the
250+512x384 stream, with identical coded diff and identical post-read range. The
251+task named candidate ORDER/WEIGHT; the order was indeed wrong, but the cause is
252+one level down: **our intrabc MV grid only contained the intrabc blocks.**
253+
254+### Mechanism (measured, not inferred)
255+
256+libaom's `setup_ref_mv_list` row/col scans walk `xd->mi[]`, which holds an
257+`MB_MODE_INFO` for EVERY coded block, and step by
258+`mi_size_wide/height[candidate->bsize]`. Our `MiGrid` was filled only by
259+`record_intrabc_mi_rect`, so every intra non-intrabc neighbour read as
260+`None` and the scan advanced that cell by ONE instead of by the neighbour's
261+real width. At `mi(84,104)` (16x16, `bsize=6`) the row scan's extended offset
262+`-3` therefore over-reached from libaom's last probe `(81,106)` (the 8x16
263+intrabc voting `-520`) to `(81,108)` -- a 16x16 intrabc voting `-512` with a
264+16-wide (`len 4 * weight 4`) contribution libaom never makes.
265+
266+Instrumented oracle (`~/.cache/aom-oracle`, new `EC_TRACE_STACK` /
267+`EC_TRACE_STACK2` prints in `setup_ref_mv_list` + `scan_row_mbmi` /
268+`scan_col_mbmi` / `scan_blk_mbmi`):
269+
270+```
271+O EC_STACK mi_row=84 mi_col=104 ref=0 w=4 h=4 cnt=2 near_match=1 ref_match=1 \
272+ [0 w=656 mv=(-520,0)] [1 w=648 mv=(-512,0)]
273+U EC_STACK_OURS mi_row=84 mi_col=104 ... n=2 near_match=1 ref_match=1 prows=6 pcols=0
274+ [0 w=648 mv=(-520,0)] [1 w=664 mv=(-512,0)]
275+```
276+
277+libaom's `-520` votes: `4` (row `-1`) + `4` (row `-3`) + `8` (row `-5`) = `16`
278+(`640 + 16 = 656`); `-512`'s: `4` (top-right `(83,108)`) + `4` (corner
279+`(83,103)`) = `8` (`648`). Ours lost `-520`'s `8` (the row `-5` contribution)
280+and gained `-512` `+16` from the over-reach, so the weight sort flipped:
281+`nearestmv` became `-512` where libaom's is `-520`, and
282+`dv = ref + diff = -512 + 8 = -504` instead of `-520 + 8 = -512`. One whole-pel
283+wrong `skip == 1` copy; the 528 wrong luma samples are that copy plus the
284+region that inherits its 1-px shift.
285+
286+### Fix
287+
288+`MiGrid` gained a block-COVERAGE map (`cover: Vec<[u8; 2]>`, the covering
289+coded block's own `(width, height)` in mi units) with `MiGrid::cover_rect`;
290+`MiGrid::get` returns the stored `MiInfo` when there is one and otherwise
291+synthesizes a non-inter entry (`is_inter == false`, zero MV) from the cover, so
292+a candidate that casts no vote still advances the scan by its real width --
293+exactly libaom's `xd->mi[]` semantics. `single_ref_match` rejects a non-inter
294+unit, so a synthetic entry can never vote.
295+
296+The map is published for EVERY coded block from `Neighbours::fill_lf_grid_rect`
297+(the one place every block's mi span already passes through, paired 1:1 with
298+`fill_skip_grid_rect`), and only when the frame has an MV grid at all
299+(`intrabc_mi_grid` is `Some` exactly when `allow_intrabc`), so an inter frame
300+and the tile writer's own grid are untouched: an unfilled cover reads as
301+uncovered and reproduces the old `None`-per-cell behaviour exactly.
302+
303+### Byte-exactness after the fix
304+
305+| stream | before | now |
306+|---|---|---|
307+| B 512x384 testsrc2 cq45 `--enable-palette=1 --enable-tx-size-search=0` | 528/294912 luma | **BYTE-EXACT** (`cmp` vs ffmpeg `-pix_fmt yuv420p`) |
308+| A 256x192 testsrc2 cq45 var-tx (`--enable-tx-size-search=1`) | BYTE-EXACT | **BYTE-EXACT** |
309+
310+Standalone arms re-run (all `cmp`-exact against ffmpeg): `cq50p0-txs0`,
311+`cq45p0-txs0`, `cq45p1-txs0`, `cq50p0-txs0`, `cq50p0-1to4-off`, `minp4`
312+(`--min-partition-size=4 --max-partition-size=16`), `cq50-txs1-1to4-off`. The
313+`(84,104)` DV trace now reads `dv_row=-512 rng=33207`, the oracle's own value.
314+
315+### New reviewer-unblock gate
316+
317+`stream::tests::a_coded_rect_intrabc_block_reconstructs_in_both_orientations`
318+-- three arms, ALL frames byte-exact against ffmpeg, each asserting the arm
319+reconstructed a CODED (`skip == 0`) rect intrabc block in the orientation it
320+names:
321+
322+- `horz-coded-256-cq45-pal0-txs0` -- 16x8 coded strip, HORZ.
323+- `vert-coded-512-cq45-pal1-txs0` -- 8x16 coded strip, VERT, **and the
324+ DV-predictor regression stream** (this is stream B).
325+- `txmode-select-256-cq45-pal0-txs1` -- stream A's shape; the arm re-derives
326+ `tx_mode == Select && allow_intrabc` out of the frame header rather than
327+ trusting the encoder flags.
328+
329+New instrument `decode::intrabc_rect_coded_hits() -> [horz, vert]` (bumped in
330+`decode_intrabc_rect` when `!skip`, indexed by `bh > bw`): the old
331+`intrabc_rect_hits` counts neither the skip flag nor the orientation, so an arm
332+that quietly became all-skip or single-orientation would keep it green
333+(`gate-blind-to-feature`).
334+
335+**Non-vacuity (fail-pre-fix, measured):** with only the `MiGrid::get` cover
336+fallback neutralized (the fix's load-bearing line) and nothing else touched,
337+the gate fails exactly where it must --
338+
339+```
340+horz-coded-256-cq45-pal0-txs0 ... exact, coded rect intrabc horz=1 vert=0
341+vert-coded-512-cq45-pal1-txs0 frame 0 does not match ffmpeg
342+test ... FAILED
343+```
344+
345+and passes again with the line restored.
346+
347+### Gates run this round
348+
349+- `cargo check -p ec-av1 --all-targets` -> 0 warnings.
350+- New gate (3 arms, 3 frames, byte-exact; fail-pre-fix proven above).
351+- `a_real_aomenc_screen_key_frame_reads_use_intrabc_on_rect_strips` -> ok
352+ (187 rect reads, 5 intrabc blocks over 5 arms, 8 frames compared, 0
353+ refused, 0 mismatched, 1 rect-strip block).
354+- `an_intrabc_block_under_tx_mode_select_decodes_pixel_exact` -> ok
355+ (cq30 16 blocks / 1 var-tx, cq45 12 blocks / 3 var-tx).
356+- Refusal suite `-- refusal` -> **21 passed**. `reelb` -> 3 passed.
357+ `monochrome` -> 1 passed. `cdf` -> 13 passed. `non_420` -> 1 passed.
358+- Full `--lib` suite, re-measured 2026-09-23 on commit `db15bb5a` (see below):
359+ `test result: ok. 599 passed; 0 failed; 60 ignored; 0 measured; 0 filtered out; finished in 10087.77s`
360+
361+### Deferred / open
362+
363+- 1:4 pair-strip intrabc -- unchanged, named in §3.
364+- The cover records the mi span its `fill_lf_grid_rect` caller passes; a
365+ sub-8x8 leaf publishes a 4x4 (1x1 mi) or an 8x8-square span exactly as its
366+ own `fill_skip_grid`/`fill_lf_grid` call already does, so the coverage map
367+ inherits that convention. No gate or arm reaches a sub-8x8 neighbour of an
368+ intrabc block today; if one ever does, the leaf's true `bsize` dims are what
369+ libaom's `mi_size_wide/height[candidate->bsize]` would report.
370+
371+
372+### Verified 2026-09-23 (r4 commit `db15bb5a` was UNVERIFIED)
373+
374+Re-measured on that committed tree. Probe rebuilt from it
375+(`CARGO_TARGET_DIR=$HOME/.cache/cargo-target-av1ibc`). 8-bit comparison is
376+`decode_probe <obu> <raw>` vs `ffmpeg -pix_fmt yuv420p -f rawvideo`. `git
377+status --porcelain` was empty before the suite and empty after it: the suite
378+ran these bytes.
379+
380+| stream | verdict |
381+|---|---|
382+| A 256x192 testsrc2 cq45 `--enable-palette=0 --enable-tx-size-search=1` | **BYTE-EXACT** (73728 B) |
383+| B 512x384 testsrc2 cq45 `--enable-palette=1 --enable-tx-size-search=0` | **BYTE-EXACT** (294912 B; was 528/294912 luma) |
384+
385+Previously-green arms, all `cmp`-exact: `cq50p0-txs0`, `cq45p0-txs0`,
386+`cq45p1-txs0`, `minp4` (`--min-partition-size=4 --max-partition-size=16`),
387+`smptebars` cq40 and cq45.
388+
389+Unblock gate
390+`a_coded_rect_intrabc_block_reconstructs_in_both_orientations` (with the
391+in-gate and the tx-mode-select witness, one `cargo test` invocation):
392+
393+```
394+horz-coded-256-cq45-pal0-txs0 1 frame(s) exact, coded rect intrabc horz=1 vert=0
395+vert-coded-512-cq45-pal1-txs0 1 frame(s) exact, coded rect intrabc horz=0 vert=1
396+txmode-select-256-cq45-pal0-txs1 1 frame(s) exact, coded rect intrabc horz=1 vert=0
397+test result: ok. 3 passed; 0 failed; 0 ignored; 0 measured; 656 filtered out; finished in 3.45s
398+```
399+
400+In-gate `a_real_aomenc_screen_key_frame_reads_use_intrabc_on_rect_strips`: 187
401+rect-strip `use_intrabc` reads, 5 intrabc blocks over 5 arms, 8 frames
402+compared, 0 refused, 0 mismatched, 1 rect-strip block.
403+`an_intrabc_block_under_tx_mode_select_decodes_pixel_exact`: cq=30 16 blocks /
404+1 var-tx, cq=45 12 blocks / 3 var-tx.
405+
406+Regression filters (same tree, `--nocapture --test-threads=1`):
407+
408+- `-- refusal` -> **21 passed** (111.09s).
409+- `monochrome` -> 1 passed: 4:2:0 twin 60 frames, monochrome 60 frames
410+ byte-exact vs ffmpeg.
411+- `non_420` -> 1 passed.
412+- `quantisation` -> 1 passed: qm-off control 3 frames, qm-on refused by name
413+ (`a frame using quantisation matrices`).
414+- `cdf_update` -> 1 passed: 3 `disable_cdf_update` frame headers, all frames
415+ sample-exact.
416+- `reelb` -> 3 passed.
417+- `a_10bit_film` -> 5 passed (126.80s), including
418+ `reelb_rect64` 33 frames, `reelb_arf` 37 frames, `reelb_head_mvclamp` 52 frames.
419+
420+Wave-1 probes (release `decode_probe`, not the debug suite):
421+
422+- gray 60-frame key frame (`testsrc2` 320x240 2s `-pix_fmt gray -c:v
423+ libaom-av1`): `OK: 60 frames`, low byte of `EC_PROBE_OUT16` EQUAL to
424+ `ffmpeg -pix_fmt gray` (4,608,000 B).
425+- `fixtures/bitstreams/av1-monochrome.ivf` remuxed to OBU: `OK: 60 frames`,
426+ EQUAL the same way.
427+- `av1-profile1-444.ivf` remuxed to OBU: REFUSED by name (`a chroma format
428+ other than 4:2:0`).
429+- every `crates/ec-av1/fixtures/reelb_*.obu` (8 files) EQUAL to
430+ `ffmpeg -pix_fmt yuv420p10le` (`EC_PROBE_OUT16`).
431+
432+`cargo check -p ec-av1 --all-targets` after `touch` of `lib.rs`: 0 warnings
433+(`Finished dev profile in 1.15s`, `CHECK_RC=0`, no `warning:` lines).
434+
435+Full suite, hub process `av1ibc-suite`, `cargo test -p ec-av1 --lib --
436+--test-threads=1`, `EC_AV1_REQUIRE_AOMENC=1`, `TMPDIR` on `$HOME`. Literal
437+line:
438+
439+```
440+test result: ok. 599 passed; 0 failed; 60 ignored; 0 measured; 0 filtered out; finished in 10087.77s
441+```
442+
443+599 = 598 (this branch's base, the txrouting merge at `3ecd4a10`, before
444+txbands) + this lane's one new gate. Main's `600/0/60` includes txbands' two
445+gates, which are not on this branch. Not a missing test. Hub log grep for
446+`FAILED` was empty. Exit 0.
447+
448+The first suite attempt (default threads) did not finish. After 3h20m it was
449+deadlocked in `run_8x8_leaf_motion_gate`
450+(`a_real_warped_causal_8x8_leaf_stream_decodes_pixel_exact`): `write_all` of
451+the y4m runs before `wait_with_output`, and that aomenc's stdout pipe had been
452+shrunk to 8192 bytes (a fresh pipe on this box is 65536). Both sides sat in
453+`anon_pipe_write`. Pre-existing spawn pattern, not this lane's diff. Stopped
454+(exit 143) and re-run single-threaded; that run is the line above.
455+`deferred(concurrent stdin/stdout drain for aomenc spawns that write_all
456+before wait_with_output -- unblocked by a charter that may edit the spawn
457+helper)`.
458+
459+## 4e. Round 5 (2026-09-23) -- the skip arm's residual slice was sized `bw * bh`, not `side * side`
460+
461+### Root cause (the reviewer's one P1)
462+
463+`decode_intrabc_rect`'s skip arm (pre-fix `decode.rs:11047-11049`) passed
464+`push_mc_rect(..., stride = side = bw.max(bh), w = bw, h = bh, ...,
465+&ZERO_RESIDUAL[..bw * bh])` (chroma: `cw * ch`). `PlaneBuf::reconstruct_mc_rect`
466+(`decode.rs:25726-25731`) indexes `residual[row * side .. row*side + w]` for
467+`row in 0..h`, needing up to `(bh-1)*side + bw` elements. For a VERT strip
468+(`bh > bw`) that EXCEEDS the slice: a skipped 8x32 strip reads a 256-element
469+slice at stride 32 and panics at row 8 -- `range end index 264 out of range
470+for slice of length 256`. The panic is a bounds check, never silent
471+corruption; a HORZ strip (`bw > bh`) never overruns (`(bh-1)*side + bw <=
472+bw*bh` when `bw == side`).
473+
474+### Why every gate missed it
475+
476+Two stacked blind spots. (1) Only the default single-threaded path crashes:
477+at `EC_AV1_RECON_THREADS == 1` the rect is reconstructed inline through
478+`ReconPlanes` (the `dense_residual` read above); on the wavefront path the
479+`Residual::done` ZERO_RESIDUAL pointer-compare maps the slice to the empty
480+marker and never indexes it. (2) Every existing VERT intrabc witness was
481+CODED (`skip == 0`), so no gate ever walked the skip arm on a VERT strip
482+(`gate-blind-to-feature`: the counters counted neither the skip flag nor the
483+orientation for skipped blocks).
484+
485+### Fix (bug-for-bug with the proven inter path)
486+
487+Three lines, `decode.rs` skip arm: `&ZERO_RESIDUAL[..side * side]` and
488+`&ZERO_RESIDUAL[..cside * cside]` (x2), exactly what the inter skip arm at
489+`decode.rs:28906-28916` passes. `(h-1)*side + w <= side*side` for every rect
490+shape.
491+
492+### Repro (before) / verdict (after)
493+
494+Reviewer's corpus at `~/.cache/tmp-av1ibcreview/repro`. Pre-fix, stock
495+release `decode_probe sweep_testsrc2_cq30_p0.obu` panics with the exact
496+message above (`decode.rs:25731:32`); post-fix it decodes clean, rc=0. The
497+new gate arm was also proven fail-pre-fix: with only the three fix lines
498+reverted, `a_coded_rect_intrabc_block_reconstructs_in_both_orientations`
499+panics at the same index (`264 out of range for slice of length 256`,
500+`decode.rs:25755:32` after the counter edit shifted lines).
501+
502+### New gate arm (non-vacuous)
503+
504+`stream::tests::a_coded_rect_intrabc_block_reconstructs_in_both_orientations`
505+gains two SKIPPED-strip arms, `vert-skip-512-cq30-pal0-txs0` and
506+`vert-skip-512-cq30-pal1-txs0` (testsrc2 512x384, `--cq-level=30`, palette
507+off AND on, txs off -- the reviewer's panic recipe family). Each arm decodes
508+the stream at 1 AND 4 recon threads and asserts byte-exact vs ffmpeg on
509+BOTH paths, and a new counter `decode::intrabc_rect_skipped_hits()` (bump in
510+`decode_intrabc_rect`, `[horz, vert]` split, reset with the coded one)
511+HARD-asserts a SKIPPED VERT 2:1 strip was actually reconstructed -- an arm
512+that stops producing one fails instead of passing vacuously. Measured this
513+round:
514+
515+```
516+vert-skip-512-cq30-pal0-txs0 1 frame(s) exact at 1 recon thread(s), skipped rect intrabc horz=11 vert=2
517+vert-skip-512-cq30-pal0-txs0 1 frame(s) exact at 4 recon thread(s), skipped rect intrabc horz=11 vert=2
518+vert-skip-512-cq30-pal1-txs0 1 frame(s) exact at 1 recon thread(s), skipped rect intrabc horz=1 vert=2
519+vert-skip-512-cq30-pal1-txs0 1 frame(s) exact at 4 recon thread(s), skipped rect intrabc horz=1 vert=2
520+```
521+
522+### Corpus sweep (post-fix, release `decode_probe` on the committed tree)
523+
524+All 39 obus in `~/.cache/tmp-av1ibcreview/repro` decode without panic
525+(rc=0, no `panicked` in output). Byte-exactness where the reviewer compared:
526+
527+| group | result |
528+|---|---|
529+| sweep_* 16 streams with a non-zero ffmpeg ref | all 16 `cmp`-EXACT (294912 B each) |
530+| sweep_* 14 streams whose ref is 0 B (the reviewer's panicking cells) | all decode clean now, no ref to compare |
531+| A.obu / B.obu / C_gradients / C_mandelbrot / C_smptebars | all `cmp`-EXACT vs `*_ref.raw` |
532+| D.obu | probe dispatches 0 frames (unchanged: reviewer's own `D_ours.raw`/`D_ours2.raw` are 0 B too) |
533+| gray60.obu, av1-monochrome.obu | `cmp`-EXACT vs `gray_ref.raw` / `mono_ref.raw` |
534+| reelb_* 10-bit (8 fixtures, `EC_PROBE_OUT16`) | all 8 `cmp`-EXACT vs `ref_reelb_*.raw` |
535+| av1-profile1-444.obu | still REFUSED by name (`a chroma format other than 4:2:0`) |
536+
537+### Full suite
538+
539+`test result: ok. 599 passed; 0 failed; 60 ignored; 0 measured; 0 filtered out; finished in 9555.99s` — hub-supervised `--test-threads=1` on the committed tree (`86ba99f6`), exit 0.