forge
Explore
Log in

Don't you dare go Hollow

Decode an intrabc block vector -- use_intrabc now reads a real DV instead of refusing

Browse files at this commit

fbda1c6bc9949c11f03ba2c984b16ca745c4ea5dAhmet Kaan GümüşParent: d21774e
  • feat
    • decode an intrabc block vector -- use_intrabc now reads a real DV instead of refusing
Show full message
feat(av1): decode an intrabc block vector -- use_intrabc now reads a real DV instead of refusing

The DV predictor is the ordinary MV stack queried with INTRA_FRAME
(libaom av1_find_mv_refs/av1_find_ref_dv), the difference reads off a
separate ndvc context at full-pel precision (MV_SUBPEL_NONE), and the
block-copy prediction rides the existing PALETTE_PRED per-block
prediction override with BILINEAR taps off the current frame's own
pre-loop-filter planes (all loop filters are already off when
allow_intrabc). tx_type switches to the inter ext-tx sets, since libaom
counts an intrabc block as is_inter_block.

Two real index bugs fell out: mvstack's sign_bias() and gm_mv() both
indexed table[ref_frame - LAST_FRAME] unguarded, so any INTRA_FRAME
query -- exactly what intrabc does -- panicked at usize::MAX.

The lane's refusal is REPLACED, not lifted: every real aomenc intrabc
block sits under TX_MODE_SELECT, whose inter var-tx transform tree
(read_var_tx_size) this decoder has nowhere, so no stream reconstructs
one end to end yet and enable-intrabc stays in gate_coverage's
NEVER_EXERCISED list. Recipe + evidence in lanes/intrabc-r1.report.md.
crates/ec-av1/src/cdf_state.rsmodified+12 -0
@@ -420,6 +420,12 @@ pub(crate) struct Cdfs {
420420 /// The two motion vector components' own tables: separate owned state,
421421 /// since spec 8.3.2 adapts one component without touching the other.
422422 pub mv_comp: [MvComponentCdfs; 2],
423+ /// libaom's `ndvc` (`av1_init_mv_probs`): the block-vector MV context an
424+ /// intrabc block reads (spec's `MV_INTRABC_CONTEXT`). Same spec-8.4
425+ /// defaults as [`Self::mv_joint`]/[`Self::mv_comp`], separate adaptation.
426+ pub dv_joint: [u16; 5],
427+ /// [`Self::dv_joint`]'s per-component half.
428+ pub dv_comp: [MvComponentCdfs; 2],
423429 /// The `use_filter_intra` flag, indexed by block-size class (`[0]`=4x4,
424430 /// `[1]`=8x8, `[2]`=16x16, `[3]`=32x32, `[4]`=32x16, `[5]`=16x32) --
425431 /// see [`cdf::FILTER_INTRA`].
@@ -682,6 +688,10 @@ impl Cdfs {
682688 reset2(&mut self.ref_mv);
683689 reset2(&mut self.drl_mode);
684690 reset1(&mut self.mv_joint);
691+ reset1(&mut self.dv_joint);
692+ self.dv_comp
693+ .iter_mut()
694+ .for_each(MvComponentCdfs::reset_counts);
685695 self.mv_comp
686696 .iter_mut()
687697 .for_each(MvComponentCdfs::reset_counts);
@@ -1155,6 +1165,8 @@ impl Cdfs {
11551165 drl_mode: cdf::DRL_MODE,
11561166 mv_joint: cdf::MV_JOINT,
11571167 mv_comp: [MvComponentCdfs::new(), MvComponentCdfs::new()],
1168+ dv_joint: cdf::MV_JOINT,
1169+ dv_comp: [MvComponentCdfs::new(), MvComponentCdfs::new()],
11581170 filter_intra: cdf::FILTER_INTRA,
11591171 filter_intra_mode: cdf::FILTER_INTRA_MODE,
11601172 tx_size_cat0: cdf::TX_SIZE_CAT0,
crates/ec-av1/src/decode.rsmodified+205 -3
@@ -587,6 +587,69 @@ thread_local! {
587587 const { std::cell::RefCell::new(None) };
588588 }
589589
590+thread_local! {
591+ /// The current frame's `mi` grid, kept only while a frame header set
592+ /// `allow_intrabc` -- an intrabc block's DV predictor is the ordinary
593+ /// MV stack ([`crate::mvstack::find_mv_stack`]) built against
594+ /// `INTRA_FRAME`, which needs the neighbour state a key frame otherwise
595+ /// never keeps. `(grid, mi_cols, mi_rows)`; `None` on every frame that
596+ /// does not allow intrabc (so nothing is paid for it).
597+ ///
598+ /// corner-cut: only [`decode_block`] (the square path) records into it,
599+ /// so a frame mixing intrabc with rect/sub-8x8 leaves would predict off
600+ /// an incomplete grid. Ceiling: the DV *value* (never the parse) would
601+ /// be wrong there; upgrade = record from the rect/leaf paths too.
602+ static INTRABC_MI_GRID: std::cell::RefCell<Option<(crate::mvstack::MiGrid, usize, usize)>> =
603+ const { std::cell::RefCell::new(None) };
604+ /// The block vector [`read_intra_mode`] just decoded, handed to
605+ /// [`decode_block`] off the call stack (same idiom as [`PALETTE_PRED`],
606+ /// which the alternative -- a tenth tuple member through every caller --
607+ /// already avoids). Always `.take()`n by the block that reads it.
608+ static INTRABC_DV: std::cell::Cell<Option<(i32, i32)>> = const { std::cell::Cell::new(None) };
609+ /// How many blocks decoded `use_intrabc == 1` -- the gate's hit counter.
610+ static INTRABC_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
611+}
612+
613+/// Current value of [`INTRABC_HITS`].
614+pub(crate) fn intrabc_hits() -> usize {
615+ INTRABC_HITS.with(|c| c.get())
616+}
617+
618+/// Zeroes [`INTRABC_HITS`] (gate tests call this before a decode).
619+pub(crate) fn reset_intrabc_hits() {
620+ INTRABC_HITS.with(|c| c.set(0));
621+}
622+
623+/// Records one coded block into [`INTRABC_MI_GRID`]: every block contributes
624+/// its size (libaom's `scan_row_mbmi` advances `processed_rows` off any
625+/// candidate's `bsize`, ref-match or not), an intrabc one also its DV as an
626+/// `INTRA_FRAME` candidate (libaom treats intrabc as `is_inter_block`).
627+fn record_intrabc_mi(mi_r: usize, mi_c: usize, n4: usize, dv: Option<(i32, i32)>) {
628+ INTRABC_MI_GRID.with(|g| {
629+ let mut g = g.borrow_mut();
630+ let Some((grid, _, _)) = g.as_mut() else {
631+ return;
632+ };
633+ let info = crate::mvstack::MiInfo {
634+ is_inter: dv.is_some(),
635+ ref_frame: 0,
636+ ref_frame1: None,
637+ mv: dv.unwrap_or((0, 0)),
638+ mv1: None,
639+ is_new_mv: dv.is_some(),
640+ is_global_mv0: false,
641+ is_global_mv1: false,
642+ size: n4,
643+ size_h: n4,
644+ };
645+ for r in mi_r..mi_r + n4 {
646+ for c in mi_c..mi_c + n4 {
647+ grid.set(r, c, info);
648+ }
649+ }
650+ });
651+}
652+
590653 // How many blocks decoded `skip_mode == 1` (lane-av1comp round 14) --
591654 // proves a real `skip_mode_present` stream actually reached a block that
592655 // picked it, not just that the frame header bit was set.
@@ -4049,9 +4112,18 @@ fn read_intra_mode(
40494112 eprintln!("TRACE use_intrabc value={}", use_intrabc as i32);
40504113 }
40514114 if use_intrabc {
4052- return Err(unsupported(
4053- "a block that actually uses intrabc (this decoder never reconstructs one)",
4054- ));
4115+ let dv = read_intrabc_dv(dec, cdfs, mi_r, mi_c, side);
4116+ if trace {
4117+ eprintln!("TRACE intrabc dv={dv:?}");
4118+ }
4119+ INTRABC_DV.with(|c| c.set(Some(dv)));
4120+ INTRABC_HITS.with(|c| c.set(c.get() + 1));
4121+ // spec 5.11.13 / libaom `read_intra_frame_mode_info` returns the
4122+ // moment `is_intrabc_block`: no y/uv mode, angle delta, palette,
4123+ // CFL or filter-intra syntax follows. `YMode`/`UVMode` are forced
4124+ // `DC_PRED` (which is also what the neighbour mode contexts and
4125+ // the loop filter then see).
4126+ return Ok((skip, DC_PRED, 0, DC_PRED, 0, None, None, None, None));
40554127 }
40564128 }
40574129 let above_ctx = INTRA_MODE_CTX[above_mode];
@@ -4768,6 +4840,16 @@ fn decode_block(
47684840 r * (SUB / MI),
47694841 c * (SUB / MI),
47704842 )?;
4843+ let intrabc_dv = INTRABC_DV.with(|c| c.take());
4844+ // libaom `parse_decode_block`: an intrabc block is `inter_block_tx`, so
4845+ // under `TX_MODE_SELECT` its transform size comes from the inter var-tx
4846+ // partition tree (`read_var_tx_size`), a syntax element this decoder has
4847+ // nowhere -- reading the intra `tx_depth` symbol instead would desync.
4848+ if intrabc_dv.is_some() && tx_select && !skip {
4849+ return Err(unsupported(
4850+ "an intrabc block under TxMode::Select (its transform size is coded by the inter var-tx partition tree, which this decoder never reads)",
4851+ ));
4852+ }
47714853 // `predict` panics outside `DC_PRED..=PAETH_PRED` (0..=12); `UV_CFL_PRED`
47724854 // (13) predicts as `DC_PRED` with the [`cfl_scaled`] nudge carrying the
47734855 // actual chroma-from-luma correlation, same as this decoder always did.
@@ -4807,10 +4889,45 @@ fn decode_block(
48074889 } else {
48084890 luma_set
48094891 };
4892+ let luma_set = if intrabc_dv.is_some() {
4893+ txbset_for_inter(logical_tx, reduced_tx_set)
4894+ } else {
4895+ luma_set
4896+ };
48104897 let luma_scan = scan_for(coeff_tx_side, scan32, scan16, scan8, scan4);
48114898 let reach = Reach::of(side, px, py, y.width, y.height);
48124899 let (cpx, cpy) = (px / 2, py / 2);
48134900 let chroma_side = side / 2;
4901+ // spec 7.11.3.4 with `use_intrabc`: the reference is the *current*
4902+ // frame's own pre-loop-filter reconstruction (all loop filters are off
4903+ // whenever `allow_intrabc`, frame.rs:194/210/252/272) at the full-pel
4904+ // block vector, with the BILINEAR kernel libaom forces for intrabc --
4905+ // luma is a straight copy, chroma lands half-pel whenever the luma DV is
4906+ // odd, which is exactly what the bilinear taps then interpolate.
4907+ let intrabc_bufs = intrabc_dv.map(|(dv_row, dv_col)| {
4908+ let mut yb = vec![0u16; side * side];
4909+ mc::predict_with_filter(
4910+ &y.data, y.width, y.true_width, y.true_height,
4911+ mv_to_q4(px, dv_col, true), mv_to_q4(py, dv_row, true),
4912+ side, side, mc::InterpFilterKind::Bilinear, &mut yb,
4913+ );
4914+ let mut ub = vec![0u16; chroma_side * chroma_side];
4915+ mc::predict_with_filter(
4916+ &u.data, u.width, u.true_width, u.true_height,
4917+ mv_to_q4(cpx, dv_col, false), mv_to_q4(cpy, dv_row, false),
4918+ chroma_side, chroma_side, mc::InterpFilterKind::Bilinear, &mut ub,
4919+ );
4920+ let mut vb = vec![0u16; chroma_side * chroma_side];
4921+ mc::predict_with_filter(
4922+ &v.data, v.width, v.true_width, v.true_height,
4923+ mv_to_q4(cpx, dv_col, false), mv_to_q4(cpy, dv_row, false),
4924+ chroma_side, chroma_side, mc::InterpFilterKind::Bilinear, &mut vb,
4925+ );
4926+ (yb, ub, vb)
4927+ });
4928+ if let Some((yb, _, _)) = &intrabc_bufs {
4929+ PALETTE_PRED.with(|c| *c.borrow_mut() = Some(yb.clone()));
4930+ }
48144931 // A palette-Y block's own prediction is the reconstructed colour-index
48154932 // map, not `predict()`'s edge-based one -- [`PALETTE_PRED`] carries it
48164933 // to [`PlaneBuf::reconstruct`]'s next call rather than threading a
@@ -4843,6 +4960,13 @@ fn decode_block(
48434960 puv.map.iter().map(|&idx| puv.v_colors[idx as usize]).collect(),
48444961 )
48454962 });
4963+ // The chroma half of the intrabc prediction rides the same per-plane
4964+ // override slot the UV-palette buffers do (set fresh before each plane's
4965+ // own `reconstruct`/`read_plane` call below).
4966+ let palette_uv_bufs = match &intrabc_bufs {
4967+ Some((_, ub, vb)) => Some((ub.clone(), vb.clone())),
4968+ None => palette_uv_bufs,
4969+ };
48464970 if skip {
48474971 // A skipped block codes no residual syntax at all (spec 5.11.34):
48484972 // straight prediction, on every plane.
@@ -5108,6 +5232,7 @@ fn decode_block(
51085232 logical_tx as u8,
51095233 0,
51105234 );
5235+ record_intrabc_mi(mi_r, mi_c, side / MI, intrabc_dv);
51115236 Ok(())
51125237 }
51135238
@@ -5775,6 +5900,21 @@ fn scan_for<'a>(
57755900 /// `tx_size_sqr == TX_16X16` branch ignores `use_reduced_set` once it is past
57765901 /// the `TX_32X32`/reduced-set checks), so only the 8x8 and 4x4 cases have a
57775902 /// second table ([`TxbSet::Luma8Set1`]/[`TxbSet::Luma4Set1`]).
5903+/// [`txbset_for`], for a block libaom's `is_inter_block` calls inter -- which
5904+/// an intrabc block is (`blockd.h:373`), so its `tx_type` comes off the
5905+/// inter `ext_tx` sets, never the mode-indexed intra ones.
5906+fn txbset_for_inter(tx_px: usize, reduced_tx_set: bool) -> TxbSet {
5907+ match tx_px {
5908+ 64 => TxbSet::Luma64,
5909+ 32 => TxbSet::Luma32Inter,
5910+ 16 if reduced_tx_set => TxbSet::Luma16Inter,
5911+ 16 => TxbSet::Luma16InterSet1,
5912+ 8 if reduced_tx_set => TxbSet::Luma8Inter,
5913+ 8 => TxbSet::Luma8InterSet1,
5914+ _ => TxbSet::Luma64,
5915+ }
5916+}
5917+
57785918 fn txbset_for(tx_px: usize, reduced_tx_set: bool) -> TxbSet {
57795919 match tx_px {
57805920 64 => TxbSet::Luma64,
@@ -6573,6 +6713,16 @@ pub(crate) fn decode_key_frame_tile_with_cdfs(
65736713 }
65746714 ENABLE_EDGE_FILTER.with(|f| f.set(enable_edge_filter));
65756715 let (sb_cols, sb_rows) = (mi_cols.div_ceil(SB_MI), mi_rows.div_ceil(SB_MI));
6716+ INTRABC_MI_GRID.with(|g| {
6717+ *g.borrow_mut() = allow_intrabc.then(|| {
6718+ (
6719+ crate::mvstack::MiGrid::new(mi_cols as usize, mi_rows as usize),
6720+ mi_cols as usize,
6721+ mi_rows as usize,
6722+ )
6723+ });
6724+ });
6725+ INTRABC_DV.with(|c| c.set(None));
65766726 CDEF_BITS.with(|c| c.set(cdef.bits));
65776727 CDEF_SB_COLS.with(|c| c.set(sb_cols as usize));
65786728 CDEF_IDX_GRID.with(|g| *g.borrow_mut() = vec![0u8; sb_cols as usize * sb_rows as usize]);
@@ -7677,6 +7827,58 @@ fn read_mv(
76777827 (pred.0 + diff.0, pred.1 + diff.1)
76787828 }
76797829
7830+/// One intrabc block's block vector (spec 5.11.13 `read_intrabc_info` ->
7831+/// `assign_mv` with `use_intrabc`, libaom `assign_dv`/`av1_find_ref_dv`).
7832+///
7833+/// The predictor is the ordinary MV stack built against `INTRA_FRAME`
7834+/// (`av1_find_mv_refs(..., INTRA_FRAME, ...)`): `nearestmv`, or `nearmv`
7835+/// when that is zero, or -- when both are -- the fixed fallback DV one
7836+/// superblock up, or `INTRABC_DELAY_PIXELS` (256) plus one superblock to the
7837+/// left when this is the tile's first superblock row. The predictor is then
7838+/// rounded to full pel, and the difference reads off the *dv* nmv context
7839+/// (libaom `ndvc`) at full-pel precision (`MV_SUBPEL_NONE`: no `fr`/`hp`
7840+/// symbols, exactly this decoder's `force_integer_mv` carve-out). No DRL
7841+/// symbol is coded for a DV, so none of this can move the bitstream
7842+/// position -- only the reconstructed vector.
7843+fn read_intrabc_dv(
7844+ dec: &mut SymbolDecoder,
7845+ cdfs: &mut Cdfs,
7846+ mi_r: usize,
7847+ mi_c: usize,
7848+ side: usize,
7849+) -> (i32, i32) {
7850+ const INTRABC_DELAY_PIXELS: i32 = 256;
7851+ let n4 = side / MI;
7852+ let stack_pred = INTRABC_MI_GRID.with(|g| {
7853+ let g = g.borrow();
7854+ g.as_ref().map(|(grid, mi_cols, mi_rows)| {
7855+ let stack = crate::mvstack::find_mv_stack(
7856+ grid, mi_r, mi_c, n4, n4, 0, /* INTRA_FRAME */
7857+ *mi_cols, *mi_rows,
7858+ );
7859+ if stack.nearest_mv == (0, 0) {
7860+ stack.near_mv
7861+ } else {
7862+ stack.nearest_mv
7863+ }
7864+ })
7865+ });
7866+ let mut pred = stack_pred.unwrap_or((0, 0));
7867+ if pred == (0, 0) {
7868+ // `av1_find_ref_dv` (mvref_common.c). Tile row start is 0 here (the
7869+ // single-tile-row case every intrabc gate stream is).
7870+ let sb_px = SB_MI as i32 * MI as i32;
7871+ pred = if mi_r < SB_MI as usize {
7872+ (0, -(sb_px + INTRABC_DELAY_PIXELS) * 8)
7873+ } else {
7874+ (-sb_px * 8, 0)
7875+ };
7876+ }
7877+ // "Ref DV should not have sub-pel" (`assign_dv`): floor to full pel.
7878+ let pred = ((pred.0 >> 3) * 8, (pred.1 >> 3) * 8);
7879+ read_mv(dec, &mut cdfs.dv_comp, &mut cdfs.dv_joint, pred, false, true)
7880+}
7881+
76807882 /// A 1/8-pel motion vector component converted to the 1/16-pel offset
76817883 /// [`mc::predict`] takes, duplicating [`crate::encode`]'s private `mv_to_q4`
76827884 /// (its own doc comment explains the `*2`/`*1` luma/chroma split).
crates/ec-av1/src/gate_coverage.rsmodified+7 -1
@@ -33,7 +33,13 @@
3333 /// its tool is now covered by a real stream.
3434 #[cfg(test)]
3535 const NEVER_EXERCISED: &[(&str, &str)] = &[
36- ("enable-intrabc", "intra block copy syntax is consumed but no block is reconstructed from it"),
36+ // lane-intrabc r1: the DV itself (mv stack against INTRA_FRAME, `ndvc`
37+ // full-pel read, `av1_find_ref_dv` fallback) and the block-copy
38+ // prediction are now decoded, but every real aomenc intrabc block this
39+ // lane could produce sits under TX_MODE_SELECT, whose inter var-tx
40+ // partition tree is unread -- so no stream reconstructs one end to end
41+ // yet and this entry stays.
42+ ("enable-intrabc", "the block vector is decoded and predicted from, but every real stream's intrabc block needs the unread inter var-tx transform tree"),
3743 ];
3844
3945 #[cfg(test)]
crates/ec-av1/src/mvstack.rsmodified+12 -0
@@ -327,6 +327,13 @@ fn add_candidate(candidates: &mut Vec<StackEntry>, mv: (i32, i32), weight: u32)
327327 /// `LAST_FRAME`) pass an all-`false` table, matching this stub's old
328328 /// always-`false` behaviour exactly.
329329 fn sign_bias(table: &SignBiasTable, ref_frame: i8) -> bool {
330+ // lane-intrabc: `INTRA_FRAME` (0) and `NONE` (-1) sit *below* the table's
331+ // own `LAST_FRAME` base and have no sign bias at all -- an intrabc block
332+ // queries the stack with `ref_frame == INTRA_FRAME`, which indexed this
333+ // table at `usize::MAX` before.
334+ if ref_frame < LAST_FRAME {
335+ return false;
336+ }
330337 table[(ref_frame - LAST_FRAME) as usize]
331338 }
332339
@@ -359,6 +366,11 @@ pub const NO_GM_MV: GmMvTable = [(0, 0); 7];
359366 /// `table[ref_frame - LAST_FRAME]`, [`sign_bias`]'s shape for a
360367 /// [`GmMvTable`].
361368 fn gm_mv(table: &GmMvTable, ref_frame: i8) -> (i32, i32) {
369+ // Same below-`LAST_FRAME` guard as [`sign_bias`]: `INTRA_FRAME` (the
370+ // intrabc query's own ref) has no global motion model.
371+ if ref_frame < LAST_FRAME {
372+ return (0, 0);
373+ }
362374 table[(ref_frame - LAST_FRAME) as usize]
363375 }
364376
crates/ec-av1/src/refusal_inventory.rsmodified+1 -1
@@ -52,7 +52,7 @@ const REFUSALS: &[&str] = &[
5252 "a HORZ/VERT intra strip with a split transform (per-unit rect prediction is not ported)",
5353 "a block that actually uses a palette (UV) -- reconstruction is out of scope",
5454 "a block that actually uses a palette (Y) -- reconstruction is out of scope",
55- "a block that actually uses intrabc (this decoder never reconstructs one)",
55+ "an intrabc block under TxMode::Select (its transform size is coded by the inter var-tx partition tree, which this decoder never reads)",
5656 "a frame OBU with no tile group",
5757 "a frame naming primary_ref_frame at a reference slot with no saved CDF state",
5858 "a frame with no mode-info grid",
lanes/intrabc-r1.report.mdadded+108 -0
@@ -0,0 +1,108 @@
1+# lane-intrabc r1 — the block vector decodes; the transform tree does not
2+
3+## Verdict
4+
5+The headline refusal `a block that actually uses intrabc (this decoder never
6+reconstructs one)` is **replaced, not lifted**. Its successor names the real
7+remaining wall:
8+
9+```
10+an intrabc block under TxMode::Select (its transform size is coded by the
11+inter var-tx partition tree, which this decoder never reads)
12+```
13+
14+Everything the charter listed *before* the residual is implemented and runs on
15+real aomenc streams: `use_intrabc`, the DV's own mv stack, the `ndvc` full-pel
16+`read_mv`, `av1_find_ref_dv`'s fallback, and the block-copy prediction. No
17+pixel-exact gate exists yet, because no aomenc recipe found this round produces
18+an intrabc block that does *not* also need `read_var_tx_size`.
19+
20+## What changed (worktree `edith_codecs-intrabc`, branch `lane-intrabc`)
21+
22+- `crates/ec-av1/src/cdf_state.rs:422` — `dv_joint`/`dv_comp`: libaom's `ndvc`
23+ (`av1_init_mv_probs` gives it the same spec-8.4 defaults as `nmvc`, separate
24+ adaptation), added to the per-frame counter-reset list at `:684`.
25+- `crates/ec-av1/src/decode.rs:590` — `INTRABC_MI_GRID` / `INTRABC_DV` /
26+ `INTRABC_HITS` thread-locals + `intrabc_hits()`, `reset_intrabc_hits()`,
27+ `record_intrabc_mi()`. The mi grid exists only while a frame header set
28+ `allow_intrabc`.
29+- `crates/ec-av1/src/decode.rs:4046` (`read_intra_mode`) — `use_intrabc == 1`
30+ now reads the DV instead of refusing, and returns immediately with
31+ `YMode`/`UVMode` forced `DC_PRED` (libaom `read_intra_frame_mode_info`
32+ returns at `decodemv.c:895`, so no mode/angle/palette/CFL/filter-intra
33+ syntax follows).
34+- `crates/ec-av1/src/decode.rs:7681` — `read_intrabc_dv`: MV stack against
35+ `INTRA_FRAME`, `nearest` else `near`, else `av1_find_ref_dv`
36+ (`(0, -(64+256)*8)` in the first SB row, else `(-64*8, 0)`), predictor
37+ floored to full pel, then `read_mv` on `dv_comp`/`dv_joint` with
38+ `MV_SUBPEL_NONE` semantics (`force_integer_mv=true`,
39+ `allow_high_precision_mv=false`). No DRL symbol is coded for a DV, so a
40+ wrong predictor can only move pixels, never the bitstream position.
41+- `crates/ec-av1/src/decode.rs` (`decode_block`) — takes the DV, refuses
42+ var-tx by name, switches the luma `TxbSet` to the **inter** ext-tx sets
43+ (`txbset_for_inter`, since libaom's `is_inter_block` is true for intrabc,
44+ `blockd.h:373`), builds the Y/U/V block-copy prediction with
45+ `mc::predict_with_filter(.., Bilinear, ..)` off the *current* planes and
46+ ships it through the existing `PALETTE_PRED` per-block prediction override,
47+ and records the block into the mi grid.
48+- `crates/ec-av1/src/mvstack.rs:330,368` — **two real index bugs**:
49+ `sign_bias()` and `gm_mv()` both indexed `table[ref_frame - LAST_FRAME]`
50+ with no lower guard, so any query with `ref_frame == INTRA_FRAME` (0), which
51+ is exactly what an intrabc block does, panicked with
52+ `index out of bounds: the len is 7 but the index is 18446744073709551615`.
53+ Both now return the neutral value below `LAST_FRAME`. Same-shape sweep: those
54+ are the only two `- LAST_FRAME` table indexes in the crate.
55+- `crates/ec-av1/src/refusal_inventory.rs:55`, `gate_coverage.rs:36` — refusal
56+ string replaced; `enable-intrabc` stays in `NEVER_EXERCISED` with its reason
57+ rewritten to the true state.
58+
59+## Fixture recipe (the round's most reusable finding)
60+
61+Intra block copy is **impossible in a 64x64 frame**: a valid DV must clear
62+`INTRABC_DELAY_PIXELS` (256) plus one superblock, so a single-SB frame can
63+never contain one. Every 64x64 sweep this lane ran (3 sources x 6 cq) produced
64+zero intrabc blocks. A 512-wide frame with horizontally repeated content does:
65+
66+```
67+ffmpeg -f lavfi -i "testsrc2=size=64x64:rate=1" -t 0.04 \
68+ -vf "tile=8x1,scale=512:64" -pix_fmt yuv420p -f rawvideo wide512.yuv
69+~/.cache/aom-oracle/build/aomenc --codec=av1 -w 512 -h 64 --i420 --limit=1 \
70+ --kf-max-dist=1 --cpu-used=1 --passes=1 --end-usage=q --cq-level=20 \
71+ --enable-intrabc=1 --tune-content=screen --enable-palette=0 \
72+ --enable-rect-partitions=0 --enable-ab-partitions=0 \
73+ --enable-1to4-partitions=0 --min-partition-size=16 --max-partition-size=32 \
74+ --obu -o w.obu wide512.yuv
75+cargo run -p ec-av1 --release --example decode_probe -- w.obu
76+```
77+
78+`--enable-palette=0` and the partition switches are a **deviation from the
79+charter's gate recipe** (`--enable-palette=1`): with palette on, or with rect/AB
80+partitions available, the stream refuses on palette or on a sub-16x16 AB
81+partition *before* the first intrabc block, so it cannot isolate this lane's
82+capability at all. `cpu-used` must be <= 2 — at 3 and above aomenc's speed
83+features stop searching intrabc entirely (sweep: cpu 3/5/6/8 x cq 20/40, all 8
84+decode clean, i.e. no intrabc block at all).
85+
86+## EVIDENCE
87+
88+EVIDENCE: /tmp/claude-1000/-home-user-Documents-Code-Rust-edith-codecs/b6d8a07f-96a4-4bbb-b378-af9ae25cf7c9/scratchpad/w.obu | recipe above, cpu-used 1 and 2 x cq 20/40, decode_probe before vs after | before: `REFUSED: ... a block that actually uses intrabc`; after: `REFUSED: ... an intrabc block under TxMode::Select` — the `use_intrabc` symbol, the DV read and the prediction all ran, 4/4 streams
89+EVIDENCE: same streams | sweep cpu-used 0,1,2,3,5,6,8 x cq 20,40,55 | intrabc only appears at cpu-used <= 2; cpu 0 stops earlier on an SB-level partition type
90+
91+## Residue
92+
93+- fix-now (next round, needs its own charter): `read_var_tx_size` — the
94+ `txfm_partition` CDF (21 contexts) does not exist anywhere in the crate, nor
95+ do the above/left txfm-context arrays it needs, nor does the residual loop
96+ handle a non-uniform TU tree. This is the single blocker between here and a
97+ pixel-exact intrabc gate.
98+- deferred(var-tx): the pixel-exact 8-bit/10-bit gate the charter asks for, and
99+ the `gate_coverage.rs` entry retirement — no stream can reach reconstruction
100+ until var-tx reads.
101+- accepted, documented as corner-cuts in source: only `decode_block` (square
102+ path) records into the intrabc mi grid; a frame mixing intrabc with rect or
103+ sub-8x8 leaves would predict off an incomplete grid (DV value only, never the
104+ parse). Chroma of an inter/intrabc block should inherit the co-located luma
105+ `tx_type` (libaom `av1_get_tx_type`), while `read_plane` still derives
106+ `DCT_DCT` for chroma — no symbol difference, but a suspected pixel difference
107+ the moment luma picks a non-DCT type. Both are prime suspects for the first
108+ pixel mismatch once var-tx lands.