forge
Explore
Log in

Don't you dare go Hollow

ec-av1: sub-8x8 intrabc reconstruction (WIP) + trace alignment; report

Browse files at this commit

787e43e6eebd1172d7217c939de45a7b5c105656Ahmet Kaan GümüşParent: 153a67d
The charter's one-routing-predicate hypothesis is REFUTED: the three
real-stream stops have three distinct causes (see
lanes/av1txrouting.report.md).

- Stops 3.3/3.4 ('a sub-8x8 leaf that uses intrabc') are GENUINE sub-8x8
  intrabc blocks (instrumented aomdec reads intrabc val=1 and an EC_DV at
  the same mi positions). Implemented: read_intra_mode_sub8 reads the DV and
  returns early; read_intrabc_dv generalized to a (n4_w,n4_h) footprint;
  decode_leaf_split4 / decode_leaf_rect8 reconstruct the leaf via a
  mc::predict_with_filter frame copy injected through the set_palette_pred
  override, with the inter coefficient sets and no tx_depth symbol; chroma
  inherits the LUMA's coded tx_type (av1_get_tx_type treats intrabc as
  inter) via fctx.intrabc_chroma_tx. record_intrabc_mi_rect publishes a
  rect footprint.

  The 4x4 split path is proven symbol-identical to aomdec (luma residual
  full rng match at allintra (45,52)). The 4x8/8x4 RECT path is NOT yet
  byte-exact (warped differs at luma row 128, desync at (38,60)) -- WIP.

- Stop 3.2 ('a Golomb tail') root cause: 4:4:4 chroma subsampling is not
  implemented anywhere in the decoder (hardcoded /2 chroma extents); every
  4:4:4 stream is silently garbage, none is byte-exact. First divergence
  at a444-cu6 (0,0): aom chroma TX_8X16 entry rng 39857, ours 4x8. Needs a
  named sequence-header refusal + a subsampling-threading lane.

- Trace prints added at previously-silent tx_depth/intrabc sites so a
  cross-decoder first-divergence diff aligns.

NOT mergeable yet: see the report's section 5 (rect intrabc, the 1:4 rect
strip intrabc, the decode_leaf8 dequant panic, the 4:4:4 refusal, inventory
re-pin, suite run).
crates/ec-av1/src/decode.rsmodified+255 -21
@@ -3681,6 +3681,20 @@ pub(crate) fn reset_intrabc_vartx_hits() {
36813681 /// candidate's `bsize`, ref-match or not), an intrabc one also its DV as an
36823682 /// `INTRA_FRAME` candidate (libaom treats intrabc as `is_inter_block`).
36833683 fn record_intrabc_mi(mi_r: usize, mi_c: usize, n4: usize, dv: Option<(i32, i32)>, fctx: &crate::decode::FrameCtx) {
3684+ record_intrabc_mi_rect(mi_r, mi_c, n4, n4, dv, fctx);
3685+}
3686+
3687+/// [`record_intrabc_mi`] with a true rectangular footprint: `av1_find_mv_refs`
3688+/// takes the block's real `bsize`, so a sub-8x8 `BLOCK_4X8`/`BLOCK_8X4`
3689+/// intrabc leaf must publish a 1x2/2x1 mi span, not a square (lane-av1txr).
3690+fn record_intrabc_mi_rect(
3691+ mi_r: usize,
3692+ mi_c: usize,
3693+ n4_w: usize,
3694+ n4_h: usize,
3695+ dv: Option<(i32, i32)>,
3696+ fctx: &crate::decode::FrameCtx,
3697+) {
36843698 fctx.intrabc_mi_grid.with(|g| {
36853699 let mut g = g.borrow_mut();
36863700 let Some((grid, _, _)) = g.as_mut() else {
@@ -3695,11 +3709,11 @@ fn record_intrabc_mi(mi_r: usize, mi_c: usize, n4: usize, dv: Option<(i32, i32)>
36953709 is_new_mv: dv.is_some(),
36963710 is_global_mv0: false,
36973711 is_global_mv1: false,
3698- size: n4 as u8,
3699- size_h: n4 as u8,
3712+ size: n4_w as u8,
3713+ size_h: n4_h as u8,
37003714 };
3701- for r in mi_r..mi_r + n4 {
3702- for c in mi_c..mi_c + n4 {
3715+ for r in mi_r..mi_r + n4_h {
3716+ for c in mi_c..mi_c + n4_w {
37033717 grid.set(r, c, info);
37043718 }
37053719 }
@@ -11317,7 +11331,11 @@ fn decode_leaf_rect(
1131711331 // the range diverges silently at the first such leaf and every later
1131811332 // symbol in the tile is read from the wrong place (class
1131911333 // `wrong-alphabet-same-value`, here same alphabet / wrong row).
11320- dec.symbol(&mut cdfs.tx_size_cat1[ctx])
11334+ let d = dec.symbol(&mut cdfs.tx_size_cat1[ctx]);
11335+ if crate::envflags::env_flag!("EC_TRACE_MODE_STEP") {
11336+ eprintln!("EC_ISTEP mi_row={} mi_col={} name=tx_depth val={d} ctx={ctx} cat=1 rng={}", leaf_mi.0, leaf_mi.1, dec.debug_state().0);
11337+ }
11338+ d
1132111339 } else {
1132211340 0
1132311341 };
@@ -13232,11 +13250,14 @@ fn read_intra_mode(
1323213250 // that merely allows (but never uses) intrabc.
1323313251 if allow_intrabc {
1323413252 let use_intrabc = dec.symbol(&mut cdfs.intrabc) != 0;
13253+ if crate::envflags::env_flag!("EC_TRACE_MODE_STEP") {
13254+ eprintln!("EC_ISTEP mi_row={mi_r} mi_col={mi_c} name=intrabc val={} rng={}", u8::from(use_intrabc), dec.debug_state().0);
13255+ }
1323513256 if trace {
1323613257 eprintln!("TRACE use_intrabc value={}", use_intrabc as i32);
1323713258 }
1323813259 if use_intrabc {
13239- let dv = read_intrabc_dv(dec, cdfs, mi_r, mi_c, side, fctx);
13260+ let dv = read_intrabc_dv(dec, cdfs, mi_r, mi_c, (side / MI, side / MI), fctx);
1324013261 if trace {
1324113262 eprintln!("TRACE intrabc dv={dv:?}");
1324213263 }
@@ -15915,7 +15936,7 @@ fn read_intra_mode_sub8(
1591515936 // neighbour's `cdf_index`/prediction two blocks later.
1591615937 seg_w_mi: usize,
1591715938 seg_h_mi: usize, fctx: &crate::decode::FrameCtx,
15918-) -> Result<(bool, usize, i32, Option<(usize, i32, Option<(i32, i32)>)>, Option<usize>)> {
15939+) -> Result<(bool, usize, i32, Option<(usize, i32, Option<(i32, i32)>)>, Option<usize>, Option<(i32, i32)>)> {
1591915940 let trace = crate::envflags::env_flag!("EC_AV1_TRACE");
1592015941 let ec_istep = crate::envflags::env_flag!("EC_TRACE_MODE_STEP");
1592115942 if ec_istep {
@@ -15954,10 +15975,20 @@ fn read_intra_mode_sub8(
1595415975 istep!("dq", 0);
1595515976 if allow_intrabc {
1595615977 let use_intrabc = dec.symbol(&mut cdfs.intrabc) != 0;
15978+ if ec_istep {
15979+ eprintln!("EC_ISTEP mi_row={mi_r} mi_col={mi_c} name=intrabc val={} rng={}", u8::from(use_intrabc), dec.debug_state().0);
15980+ }
1595715981 if use_intrabc {
15958- return Err(unsupported(
15959- "a sub-8x8 leaf that uses intrabc (this reader has no block-vector path; the 8x8-and-up reader reconstructs one)",
15960- ));
15982+ // lane-av1txr: `read_intrabc_info` (spec 5.11.13) reads the block
15983+ // vector right after the flag and RETURNS -- no y/uv mode, angle
15984+ // delta, palette, CfL or filter-intra syntax follows, and the
15985+ // block is reconstructed by the INTER path (libaom's
15986+ // `is_inter_block` counts an intrabc block), so the caller takes
15987+ // the frame-copy prediction + inter residual.
15988+ let dv = read_intrabc_dv(dec, cdfs, mi_r, mi_c, (seg_w_mi, seg_h_mi), fctx);
15989+ fctx.intrabc_dv.with(|c| c.set(Some(dv)));
15990+ hit!(INTRABC_HITS);
15991+ return Ok((skip, DC_PRED, 0, None, None, Some(dv)));
1596115992 }
1596215993 }
1596315994 let above_ctx = INTRA_MODE_CTX[above_mode];
@@ -16007,7 +16038,7 @@ fn read_intra_mode_sub8(
1600716038 filter_intra = Some(fi_mode);
1600816039 }
1600916040 }
16010- Ok((skip, mode, angle_delta_y, chroma, filter_intra))
16041+ Ok((skip, mode, angle_delta_y, chroma, filter_intra, None))
1601116042 }
1601216043
1601316044 /// Decodes a `PARTITION_SPLIT` of one 8x8 block into four `BLOCK_4X4` leaves
@@ -16058,6 +16089,10 @@ fn decode_leaf_split4(
1605816089 let mut leaf_modes = [0usize; 4];
1605916090 let mut leaf_skips = [false; 4];
1606016091 let mut last_uv: Option<(usize, i32, Option<(i32, i32)>)> = None;
16092+ // lane-av1txr: the chroma-reference (i==3) leaf's block vector when that
16093+ // leaf is an intrabc block -- its prediction/reconstruction below is a
16094+ // frame copy at this DV, not an intra one.
16095+ let mut last_intrabc: Option<(i32, i32)> = None;
1606116096 for i in 0..4usize {
1606216097 let (dr, dc) = (i / 2, i % 2);
1606316098 let lmi = (leaf_mi.0 + dr, leaf_mi.1 + dc);
@@ -16077,7 +16112,7 @@ fn decode_leaf_split4(
1607716112 };
1607816113 let has_chroma = i == 3;
1607916114 let skip_ctx = neighbours.skip_txfm_ctx(lmi.0, lmi.1);
16080- let (skip, mode, angle_delta_y, chroma, filter_intra) = read_intra_mode_sub8(
16115+ let (skip, mode, angle_delta_y, chroma, filter_intra, intrabc) = read_intra_mode_sub8(
1608116116 dec, cdfs, leaf_above, leaf_left, has_chroma, enable_filter_intra,
1608216117 filter_intra_size_class(4).expect("BLOCK_4X4 has its own filter_intra row"),
1608316118 skip_ctx, allow_intrabc, lmi.0, lmi.1, 1, 1, fctx,
@@ -16091,6 +16126,67 @@ fn decode_leaf_split4(
1609116126 }
1609216127 let (px, py) = (lmi.1 * MI, lmi.0 * MI);
1609316128 let reach = Reach::of(4, px, py, y.width, y.height, fctx);
16129+ if let Some(dv) = intrabc {
16130+ // lane-av1txr: an intrabc `BLOCK_4X4` leaf -- prediction is the
16131+ // CURRENT frame at the block vector (`predict_inter_block`'s
16132+ // intrabc arm, spec 7.11.3.4), residual the INTER coefficient set
16133+ // (libaom reads `tx_type` off `inter_ext_tx_cdf` for
16134+ // `is_inter_block`, which counts intrabc). Published into
16135+ // `intrabc_dv` so the group's chroma arm (below, when the
16136+ // chroma-reference leaf is the intrabc one) and
16137+ // [`record_intrabc_mi`] see it.
16138+ flush_recon(fctx, y, u, v);
16139+ let mut yb = vec![0u16; 16];
16140+ mc::predict_with_filter(
16141+ &y.data, y.width, y.true_width, y.true_height,
16142+ mv_to_q4(px, dv.1, true), mv_to_q4(py, dv.0, true),
16143+ 4, 4, mc::InterpFilterKind::Bilinear, &mut yb, fctx,
16144+ );
16145+ set_palette_pred(yb.clone(), fctx);
16146+ if skip {
16147+ push_intra(0, px, py, 4, DC_PRED, 0, reach, &ZERO_RESIDUAL[..16], None, None, smooth_neighbor, fctx);
16148+ neighbours.record_mi_luma(lmi, 4, &ZERO_RESIDUAL[..16]);
16149+ } else {
16150+ let tu_around = neighbours.around_mi(lmi, 4)[0];
16151+ let tu_grid = read_plane(
16152+ dec,
16153+ cdfs,
16154+ if reduced_tx_set { TxbSet::Luma4Inter } else { TxbSet::Luma4InterSet1 },
16155+ scan4,
16156+ 0,
16157+ tu_around,
16158+ DC_PRED,
16159+ DC_PRED,
16160+ 0,
16161+ reach,
16162+ y,
16163+ px,
16164+ py,
16165+ 4,
16166+ 4,
16167+ base_q_idx,
16168+ None,
16169+ None,
16170+ None,
16171+ smooth_neighbor, fctx,
16172+ )?;
16173+ neighbours.record_mi_luma(lmi, 4, &tu_grid);
16174+ }
16175+ neighbours.fill_skip_grid(lmi, 1, skip);
16176+ neighbours.fill_lf_grid(lmi, 1, 4, 0, fctx);
16177+ record_intrabc_mi(lmi.0, lmi.1, 1, Some(dv), fctx);
16178+ if has_chroma {
16179+ last_uv = Some((DC_PRED, 0, None));
16180+ // An intrabc block is an INTER block for `av1_get_tx_type`, so
16181+ // the group's chroma inherits the LUMA's coded transform type
16182+ // (`xd->tx_type_map` at the co-located luma position) -- the
16183+ // luma `read_plane` above just set [`LUMA_TX_TYPE`]. Armed for
16184+ // exactly this group's two chroma reads.
16185+ fctx.intrabc_chroma_tx.with(|c| c.set(Some(fctx.luma_tx_type.with(std::cell::Cell::get))));
16186+ }
16187+ last_intrabc = Some(dv);
16188+ continue;
16189+ }
1609416190 if skip {
1609516191 push_intra(0, px, py, 4, mode, angle_delta_y, reach, &ZERO_RESIDUAL[..16], None, filter_intra, smooth_neighbor, fctx);
1609616192 neighbours.record_mi_luma(lmi, 4, &ZERO_RESIDUAL[..16]);
@@ -16157,6 +16253,38 @@ fn decode_leaf_split4(
1615716253 push_intra(1, cpx, cpy, 4, uv_predict_mode, angle_delta_uv, group_reach, &ZERO_RESIDUAL[..16], alpha.zip(ac).map(|((au, _), ac)| (au, ac)), None, smooth_neighbor_uv, fctx);
1615816254 push_intra(2, cpx, cpy, 4, uv_predict_mode, angle_delta_uv, group_reach, &ZERO_RESIDUAL[..16], alpha.zip(ac).map(|((_, av), ac)| (av, ac)), None, smooth_neighbor_uv, fctx);
1615916255 (Grid::Zero(16), Grid::Zero(16))
16256+ } else if let Some(dv) = last_intrabc {
16257+ // lane-av1txr: the chroma-reference leaf was an intrabc block, so the
16258+ // group's one chroma unit is a frame copy at that DV too (its residual
16259+ // still reads the ordinary `Chroma4` coefficient tables -- libaom
16260+ // codes a chroma `tx_type` nowhere).
16261+ let mut ub = vec![0u16; 16];
16262+ mc::predict_with_filter(
16263+ &u.data, u.width, u.true_width, u.true_height,
16264+ mv_to_q4(cpx, dv.1, false), mv_to_q4(cpy, dv.0, false),
16265+ 4, 4, mc::InterpFilterKind::Bilinear, &mut ub, fctx,
16266+ );
16267+ let mut vb = vec![0u16; 16];
16268+ mc::predict_with_filter(
16269+ &v.data, v.width, v.true_width, v.true_height,
16270+ mv_to_q4(cpx, dv.1, false), mv_to_q4(cpy, dv.0, false),
16271+ 4, 4, mc::InterpFilterKind::Bilinear, &mut vb, fctx,
16272+ );
16273+ let chroma_around = neighbours.around_mi(leaf_mi, 8);
16274+ set_palette_pred(ub, fctx);
16275+ let ug = read_plane(
16276+ dec, cdfs, TxbSet::Chroma4, scan4, 1, chroma_around[1], DC_PRED, DC_PRED,
16277+ 0, group_reach, u, cpx, cpy, 4, TX4, base_q_idx,
16278+ None, None, None, smooth_neighbor_uv, fctx,
16279+ )?;
16280+ set_palette_pred(vb, fctx);
16281+ let vg = read_plane(
16282+ dec, cdfs, TxbSet::Chroma4, scan4, 2, chroma_around[2], DC_PRED, DC_PRED,
16283+ 0, group_reach, v, cpx, cpy, 4, TX4, base_q_idx,
16284+ None, None, None, smooth_neighbor_uv, fctx,
16285+ )?;
16286+ fctx.intrabc_chroma_tx.with(|c| c.set(None));
16287+ (ug, vg)
1616016288 } else {
1616116289 let ac = alpha.map(|_| cfl_src(gpx, gpy, 8));
1616216290 let chroma_around = neighbours.around_mi(leaf_mi, 8);
@@ -16282,6 +16410,8 @@ fn decode_leaf_rect8(
1628216410 let mut leaf_modes = [0usize; 2];
1628316411 let mut leaf_skips = [false; 2];
1628416412 let mut last_uv: Option<(usize, i32, Option<(i32, i32)>)> = None;
16413+ // lane-av1txr: as [`decode_leaf_split4`]'s own `last_intrabc`.
16414+ let mut last_intrabc: Option<(i32, i32)> = None;
1628516415 for i in 0..2usize {
1628616416 let lmi = if vert {
1628716417 (leaf_mi.0, leaf_mi.1 + i)
@@ -16302,12 +16432,81 @@ fn decode_leaf_rect8(
1630216432 };
1630316433 let has_chroma = i == 1;
1630416434 let skip_ctx = neighbours.skip_txfm_ctx(lmi.0, lmi.1);
16305- let (skip, mode, angle_delta_y, chroma, filter_intra) = read_intra_mode_sub8(
16435+ let (skip, mode, angle_delta_y, chroma, filter_intra, intrabc) = read_intra_mode_sub8(
1630616436 dec, cdfs, leaf_above, leaf_left, has_chroma, enable_filter_intra,
1630716437 filter_intra_size_class_rect(bw, bh)
1630816438 .expect("BLOCK_4X8/BLOCK_8X4 are inside av1_filter_intra_allowed_bsize"),
1630916439 skip_ctx, allow_intrabc, lmi.0, lmi.1, bw / 4, bh / 4, fctx,
1631016440 )?;
16441+ leaf_modes[i] = mode;
16442+ leaf_skips[i] = skip;
16443+ neighbours.record_mode_mi(lmi.0, lmi.1, w_mi, h_mi, mode);
16444+ let smooth_neighbor = is_smooth_mode(leaf_above) || is_smooth_mode(leaf_left);
16445+ if let Some(dv) = intrabc {
16446+ // lane-av1txr: an intrabc `BLOCK_4X8`/`BLOCK_8X4` leaf. No
16447+ // `tx_depth` symbol is coded (libaom `block_signals_txsize` is
16448+ // false below 8x8), the prediction is a frame copy at the DV and
16449+ // the residual reads the INTER `LumaRect8x4` set.
16450+ let (px, py) = (lmi.1 * MI, lmi.0 * MI);
16451+ let reach = Reach::of_rect(bw, bh, px, py, y.width, y.height, fctx);
16452+ flush_recon(fctx, y, u, v);
16453+ let mut yb = vec![0u16; bw * bh];
16454+ mc::predict_with_filter(
16455+ &y.data, y.width, y.true_width, y.true_height,
16456+ mv_to_q4(px, dv.1, true), mv_to_q4(py, dv.0, true),
16457+ bw, bh, mc::InterpFilterKind::Bilinear, &mut yb, fctx,
16458+ );
16459+ set_palette_pred(yb, fctx);
16460+ let mut luma_tx = TxType::DctDct;
16461+ let grid = if skip {
16462+ let zeros = Grid::Zero(bw * bh);
16463+ push_intra_rect(0, px, py, bw, bh, DC_PRED, 0, reach, &zeros, None, None, smooth_neighbor, fctx);
16464+ zeros
16465+ } else {
16466+ let around = neighbours.around_mi_rect(lmi, bw, bh)[0];
16467+ let set = if reduced_tx_set {
16468+ TxbSet::LumaRect8x4Inter
16469+ } else {
16470+ TxbSet::LumaRect8x4InterSet1
16471+ };
16472+ let mut coding = cdfs.txb(set, DC_PRED);
16473+ let (levels, tx_type) = read_coeffs_rect(
16474+ dec, &mut coding, scan, bw, bh, 0, dc_sign_ctx(around.2), TxType::DctDct,
16475+ )?;
16476+ luma_tx = tx_type;
16477+ let residual = dequant_and_inverse_typed_wh(
16478+ &levels, bw, bh, crate::decode::bit_depth(fctx), block_q_idx(fctx),
16479+ plane_q_delta(0, fctx).0, plane_q_delta(0, fctx).1, tx_type,
16480+ );
16481+ push_intra_rect(0, px, py, bw, bh, DC_PRED, 0, reach, &residual, None, None, smooth_neighbor, fctx);
16482+ levels
16483+ };
16484+ fctx.luma_tx_type.with(|c| c.set(luma_tx));
16485+ let state = neighbour_state(&grid);
16486+ for cell in 0..h_mi {
16487+ if lmi.0 + cell < neighbours.mi_rows {
16488+ neighbours.left[lmi.0 + cell][0] = state;
16489+ }
16490+ }
16491+ for cell in 0..w_mi {
16492+ if lmi.1 + cell < neighbours.mi_cols {
16493+ neighbours.above[lmi.1 + cell][0] = state;
16494+ }
16495+ }
16496+ neighbours.fill_skip_grid_rect(lmi, w_mi, h_mi, skip);
16497+ neighbours.fill_lf_grid_rect(lmi, w_mi, h_mi, bw as u8, bh as u8, 0, fctx);
16498+ // `record_intrabc_mi` publishes a square `n4`x`n4` footprint; a
16499+ // 4x8/8x4 leaf needs its true `w_mi`x`h_mi` (lane-av1txr).
16500+ record_intrabc_mi_rect(lmi.0, lmi.1, w_mi, h_mi, Some(dv), fctx);
16501+ if has_chroma {
16502+ last_uv = Some((DC_PRED, 0, None));
16503+ last_intrabc = Some(dv);
16504+ // See [`decode_leaf_split4`]: an intrabc block's chroma
16505+ // inherits the luma transform type.
16506+ fctx.intrabc_chroma_tx.with(|c| c.set(Some(luma_tx)));
16507+ }
16508+ continue;
16509+ }
1631116510 if filter_intra.is_some() {
1631216511 // lane-fi8 r1: `predict_filter_intra` walks its 4x2 patches over
1631316512 // a true `bw`x`bh` block, so a 4x8/8x4 leaf predicts through the
@@ -16343,10 +16542,6 @@ fn decode_leaf_rect8(
1634316542 hit!(TX_DEPTH_HITS);
1634416543 hit!(RECT8_SPLIT_TX_HITS);
1634516544 }
16346- leaf_modes[i] = mode;
16347- leaf_skips[i] = skip;
16348- neighbours.record_mode_mi(lmi.0, lmi.1, w_mi, h_mi, mode);
16349- let smooth_neighbor = is_smooth_mode(leaf_above) || is_smooth_mode(leaf_left);
1635016545 if smooth_neighbor {
1635116546 hit!(SMOOTH_LUMA_HITS);
1635216547 }
@@ -16544,6 +16739,38 @@ fn decode_leaf_rect8(
1654416739 push_intra(1, cpx, cpy, 4, uv_predict_mode, angle_delta_uv, group_reach, &ZERO_RESIDUAL[..16], alpha.zip(ac).map(|((au, _), ac)| (au, ac)), None, smooth_neighbor_uv, fctx);
1654516740 push_intra(2, cpx, cpy, 4, uv_predict_mode, angle_delta_uv, group_reach, &ZERO_RESIDUAL[..16], alpha.zip(ac).map(|((_, av), ac)| (av, ac)), None, smooth_neighbor_uv, fctx);
1654616741 (Grid::Zero(16), Grid::Zero(16))
16742+ } else if let Some(dv) = last_intrabc {
16743+ // lane-av1txr: the chroma-reference leaf was an intrabc block, so the
16744+ // group's one chroma unit is a frame copy at that DV too (its residual
16745+ // still reads the ordinary `Chroma4` coefficient tables -- libaom
16746+ // codes a chroma `tx_type` nowhere).
16747+ let mut ub = vec![0u16; 16];
16748+ mc::predict_with_filter(
16749+ &u.data, u.width, u.true_width, u.true_height,
16750+ mv_to_q4(cpx, dv.1, false), mv_to_q4(cpy, dv.0, false),
16751+ 4, 4, mc::InterpFilterKind::Bilinear, &mut ub, fctx,
16752+ );
16753+ let mut vb = vec![0u16; 16];
16754+ mc::predict_with_filter(
16755+ &v.data, v.width, v.true_width, v.true_height,
16756+ mv_to_q4(cpx, dv.1, false), mv_to_q4(cpy, dv.0, false),
16757+ 4, 4, mc::InterpFilterKind::Bilinear, &mut vb, fctx,
16758+ );
16759+ let chroma_around = neighbours.around_mi(leaf_mi, 8);
16760+ set_palette_pred(ub, fctx);
16761+ let ug = read_plane(
16762+ dec, cdfs, TxbSet::Chroma4, scan4, 1, chroma_around[1], DC_PRED, DC_PRED,
16763+ 0, group_reach, u, cpx, cpy, 4, TX4, base_q_idx,
16764+ None, None, None, smooth_neighbor_uv, fctx,
16765+ )?;
16766+ set_palette_pred(vb, fctx);
16767+ let vg = read_plane(
16768+ dec, cdfs, TxbSet::Chroma4, scan4, 2, chroma_around[2], DC_PRED, DC_PRED,
16769+ 0, group_reach, v, cpx, cpy, 4, TX4, base_q_idx,
16770+ None, None, None, smooth_neighbor_uv, fctx,
16771+ )?;
16772+ fctx.intrabc_chroma_tx.with(|c| c.set(None));
16773+ (ug, vg)
1654716774 } else {
1654816775 let ac = alpha.map(|_| cfl_src(gpx, gpy, 8));
1654916776 let chroma_around = neighbours.around_mi(leaf_mi, 8);
@@ -24587,15 +24814,17 @@ fn read_intrabc_dv(
2458724814 cdfs: &mut Cdfs,
2458824815 mi_r: usize,
2458924816 mi_c: usize,
24590- side: usize, fctx: &crate::decode::FrameCtx,
24817+ // The block's own mi footprint (`av1_find_mv_refs` takes the real bsize,
24818+ // so a sub-8x8 `BLOCK_4X8`/`BLOCK_8X4` leaf scans a 1x2/2x1 neighbourhood
24819+ // -- lane-av1txr).
24820+ (n4_w, n4_h): (usize, usize), fctx: &crate::decode::FrameCtx,
2459124821 ) -> (i32, i32) {
2459224822 const INTRABC_DELAY_PIXELS: i32 = 256;
24593- let n4 = side / MI;
2459424823 let stack_pred = fctx.intrabc_mi_grid.with(|g| {
2459524824 let g = g.borrow();
2459624825 g.as_ref().map(|(grid, mi_cols, mi_rows)| {
2459724826 let stack = crate::mvstack::find_mv_stack(
24598- grid, mi_r, mi_c, n4, n4, 0, /* INTRA_FRAME */
24827+ grid, mi_r, mi_c, n4_w, n4_h, 0, /* INTRA_FRAME */
2459924828 *mi_cols, *mi_rows,
2460024829 );
2460124830 if stack.nearest_mv == (0, 0) {
@@ -24623,7 +24852,12 @@ fn read_intrabc_dv(
2462324852 }
2462424853 // "Ref DV should not have sub-pel" (`assign_dv`): floor to full pel.
2462524854 let pred = ((pred.0 >> 3) * 8, (pred.1 >> 3) * 8);
24626- read_mv(dec, &mut cdfs.dv_comp, &mut cdfs.dv_joint, pred, false, true)
24855+ let dv = read_mv(dec, &mut cdfs.dv_comp, &mut cdfs.dv_joint, pred, false, true);
24856+ if crate::envflags::env_flag!("EC_TRACE_MODE_STEP") {
24857+ let (rng, _) = dec.debug_state();
24858+ eprintln!("EC_DV mi_row={mi_r} mi_col={mi_c} dv_col={} dv_row={} rng={rng}", dv.1, dv.0);
24859+ }
24860+ dv
2462724861 }
2462824862
2462924863 /// A 1/8-pel motion vector component converted to the 1/16-pel offset
lanes/av1txrouting.report.mdadded+181 -0
@@ -0,0 +1,181 @@
1+# lane-av1-txrouting — the one-routing-predicate hypothesis is REFUTED; work-in-progress
2+
3+Base: `main` **0cfb9af5** (2026-09-19). Worktree `../edith_codecs-av1txr`, branch
4+`lane-av1-txrouting`, `CARGO_TARGET_DIR=$HOME/.cache/cargo-target-av1txr`.
5+
6+**STATUS: WIP, NOT READY TO MERGE.** The 4x4 sub-8x8 intrabc path is proven
7+symbol-for-symbol correct on a real stream; the 4x8/8x4 rect leaf path is
8+**not yet byte-exact** (see §5). No gate has been run to completion.
9+
10+---
11+
12+## 1. Headline: the scout's "ONE routing predicate" is refuted
13+
14+The charter's three stops do **not** share a routing predicate. First-divergence
15+traces (instrumented `aomdec` oracle at `~/.cache/aom-oracle/build/aomdec` +
16+`decode_probe`, `EC_TRACE_MODE_STEP`) give each stop a distinct cause:
17+
18+| stop | stream (reproduced) | first divergence | real cause |
19+|---|---|---|---|
20+| 3.2 / "Golomb tail" | `aomenc 4:4:4 --cpu-used=6/7` | block `(0,0)`, chroma transform entry rng **39857** | **4:4:4 chroma-subsampling is not implemented** (see §3) |
21+| 3.3 / "sub-8x8 intrabc" | `aomenc --allintra` | block `(45,52)` rng 37280 | a **genuine** 4x4 intrabc block (see §4) |
22+| 3.4 / "sub-8x8 intrabc" | `aomenc --enable-warped-motion=1 --cpu-used=0` | block `(37,62)` | the same, at a 4x8/8x4 rect leaf |
23+
24+The report's §3.2/§3.3 claim that "`aomdec` reads `tx_depth` where ours reads
25+`txfm_split`/`intrabc`/`uv_mode`" is an **instrumentation artifact**: aomdec's
26+`read_intrabc_info` had no print, and `read_tx_size_vartx`'s print is gated on
27+`EC_VARTX`, not `EC_ISTEP`. With the oracle instrumented for both
28+(`EC_ISTEP name=intrabc`, `EC_DV`, `EC_COEFF`), ours and aomdec read
29+**identical `intrabc` flags and identical DVs** at these blocks — no desync.
30+
31+Similarly the §3.2 "aomdec reads `tx_depth`, ours reads `txfm_split`" claim:
32+the 4:4:4 divergence is **after** the tx-depth read (both read
33+`tx_depth val=1 ctx=0 cat=1`) and is a chroma-transform size mismatch, not a
34+tx-size routing mismatch.
35+
36+## 2. Reproduced streams (all re-derivable)
37+
38+```
39+cd ~/.cache/av1txr
40+# 4:4:4 (aomenc) -- cu6/cu7 REFUSE, cu4/cu5/cu8 decode-but-wrong
41+aomenc --codec=av1 --passes=1 --threads=1 --cpu-used=6 --obu -o s/a444-cu6.obu s/s444.y4m
42+# sub8 intrabc
43+aomenc --codec=av1 --passes=1 --threads=1 --obu --allintra --cpu-used=6 -o s/allintra.obu s/s420.y4m
44+aomenc --codec=av1 --passes=1 --threads=1 --obu --enable-warped-motion=1 --cpu-used=0 -o s/warped.obu s/s420.y4m
45+# (s420.y4m / s444.y4m = ffmpeg testsrc2 320x240 rate 8 dur 3)
46+```
47+
48+Pre-fix: `allintra`/`allintra0`/`warped` → `REFUSED: a sub-8x8 leaf that uses
49+intrabc …`; `a444-cu6/7` → `REFUSED: a Golomb tail longer than this decoder
50+reads`; `a444-cu4/5/8` → `OK` **but garbage**.
51+
52+## 3. Stop 3.2 — 4:4:4 is entirely unsupported (root-caused)
53+
54+`probe EC_PROBE_OUT8` vs `ffmpeg -pix_fmt yuv420p` for **every** 4:4:4 stream
55+(`a444-cu4/5/8`, `ff444-cu5..8`) **differs** — the "decoding" 4:4:4 streams are
56+silently desynced garbage. The fixture story ("`av1-profile1-444` decodes
57+fine") was never byte-exactness-checked.
58+
59+**First divergence (a444-cu6, block `(0,0)`, an 8x16 rect leaf, depth 1):**
60+
61+```
62+aom: EC_ISTEP tx_depth val=1 ctx=0 cat=1 rng=44248
63+ EC_COEFF mi_row=0 mi_col=0 plane=0 tx=1 rng=44248 # TX_8X8
64+ EC_COEFF mi_row=0 mi_col=0 plane=0 tx=1 rng=41886 # TX_8X8
65+ EC_COEFF mi_row=0 mi_col=0 plane=1 tx=7 rng=39857 # TX_8X16 <-- chroma
66+ EC_COEFF mi_row=0 mi_col=0 plane=2 tx=7 rng=64008 # TX_8X16
67+ours: … luma units rng 44248, 41886 (MATCH) …
68+ read_coeffs_rect chroma entry rng=39857, w=4 h=8 # 4:2:0 half <-- DIVERGE
69+```
70+
71+The decoder hardcodes 4:2:0 chroma extents at every rect site
72+(`let (chroma_w, chroma_h) = (bw / 2, bh / 2);` — `decode.rs:9476,10888,11378,
73+11767,12772,14326,15042,26798`) and the probe only ever emits 4:2:0 planes.
74+`subsampling_x/y` is parsed by `ec-av1-syntax` but **never read by the decoder**.
75+
76+**Disposition: needs a `num_planes`/subsampling threading lane** (like the
77+sibling mono lane). The honest interim fix is a **new named refusal at the
78+sequence-header level** for `subsampling_x != 1 || subsampling_y != 1`
79+(`num_planes > 1`), so a 4:4:4/4:2:2 stream refuses by name instead of
80+producing garbage. **Not yet written** (budget).
81+
82+## 4. Stops 3.3 / 3.4 — genuine sub-8x8 intrabc (implemented, WIP)
83+
84+The trace proves both streams code **real** sub-8x8 intrabc blocks:
85+`aomdec`'s instrumented `read_intrabc_info` reads `intrabc val=1` and an
86+`EC_DV` at `allintra (45,52)/(45,53)` and `warped (37,62)`. libaom's
87+`av1_allow_intrabc` is a frame-level test with no shape term, and the 4x4 block
88+`is_chroma_ref` (last sub-block) makes its chroma an intrabc copy too.
89+
90+Implemented on the lane (see §6 diff):
91+- `read_intra_mode_sub8` reads the DV (`read_intrabc_dv`) and RETURNS
92+ (skip, DC_PRED, 0, None, None, Some(dv)) — no mode/uv/filter-intra syntax.
93+- `read_intrabc_dv` generalized from a square `side` to a `(n4_w, n4_h)`
94+ footprint (rect leaves scan 1x2/2x1, not 2x2).
95+- `decode_leaf_split4` / `decode_leaf_rect8` reconstruct the intrabc leaf:
96+ `flush_recon` + `mc::predict_with_filter(.., Bilinear)` frame copy injected
97+ via the `set_palette_pred` override slot, residual read through the **inter**
98+ sets (`Luma4Inter`/`Luma4InterSet1`, `LumaRect8x4Inter`/`Set1`), no
99+ `tx_depth` symbol (libaom `block_signals_txsize` false below 8x8),
100+ `record_intrabc_mi(_rect)` publishing the true footprint.
101+- **Chroma tx-type inheritance** (the subtle one): libaom `av1_get_tx_type`
102+ (blockd.h:1278) gives a non-Y plane the LUMA's `tx_type_map` entry when
103+ `is_inter_block(mbmi)` — **intrabc counts as inter**. So the group's chroma
104+ eob/scan class is the luma's coded type, not `DCT_DCT`. Armed via the
105+ existing `fctx.intrabc_chroma_tx` slot (the square path's mechanism).
106+
107+**Evidence the 4x4 path is byte-exact (allintra, block (45,52)):** the luma
108+intrabc residual traces **identically** to aomdec
109+(`tx_type txtype=11`/`HDct`, `eob=14`, every `base`/`br`/`sign`/`post_golomb`
110+rng equal), and ours reaches `(45,53) skip rng=52504` — aomdec's exact value.
111+With the chroma-inheritance fix the following block's `skip` also matched.
112+
113+## 5. What is NOT done (do not merge without it)
114+
115+1. **`warped` is not byte-exact.** With the implementation it decodes 24
116+ frames but `EC_PROBE_OUT8` vs `ffmpeg -pix_fmt yuv420p` differs at byte
117+ **41217** (frame 0, luma row 128), and the entropy desyncs at
118+ `(38,60) skip`: aom 48630 vs ours 60320. The **rect intrabc leaf**
119+ (4x8/8x4) is the suspect: unverified `predict_with_filter` buffer shape,
120+ residual set, or the rect DV scan.
121+2. **`allintra` now stops one shape later**: `REFUSED: intra block copy on a
122+ HORZ/VERT/1:4 rect intra strip (reconstruction is not ported at this
123+ shape)` (the `decode.rs:9122` rect reader). `allintra0` (cpu-used 0)
124+ **panics** at `transform.rs:1134` (a 4x4 dequant given a 1024-entry grid)
125+ via `decode_leaf8` — a further reachable path after the sub8 blocks pass.
126+3. **4:4:4/4:2:2 named refusal** (§3) not written.
127+4. **No gates run.** Only `cargo build --release -p ec-av1 --example
128+ decode_probe` (0 errors/warnings) and `cargo check`-equivalent builds.
129+ `cargo test -p ec-av1 --lib` (592/0/60 baseline) NOT run.
130+5. **Inventory re-pin not done.** §3.3's two refuted PROVEN entries
131+ (`read_golomb_reads_every_value…`, `a_sub8_leaf_census…`) still claim
132+ "unreachable"; they must be re-pinned to reachable-with-witness. The report
133+ §5 tripwire `a_real_libaom_monochrome_key_frame_is_refused_by_name` is
134+ untouched (mono stream unaffected — its `num_planes == 1`).
135+
136+## 6. Diff summary (lane, uncommitted-at-first-write)
137+
138+`crates/ec-av1/src/decode.rs`:
139+- `read_intra_mode_sub8`: +`Option<(i32,i32)>` return, intrabc branch (DV read,
140+ early return), `istep!("intrabc")`.
141+- `read_intrabc_dv`: `side` → `(n4_w, n4_h)`; `EC_DV` trace print; call sites
142+ updated (square path passes `(side/MI, side/MI)`).
143+- `record_intrabc_mi` split into `record_intrabc_mi_rect` (rect footprint).
144+- `decode_leaf_split4` + `decode_leaf_rect8`: intrabc leaf arm (frame copy +
145+ inter residual) and intrabc chroma arm (frame copy + `Chroma4`, luma tx-type
146+ inheritance, cleared after).
147+- Trace prints added at previously-silent `tx_depth`/`intrabc` sites so a
148+ cross-decoder first-divergence diff aligns.
149+
150+## 7. Repro / oracle recipes
151+
152+```
153+# build
154+CARGO_TARGET_DIR=$HOME/.cache/cargo-target-av1txr cargo build --release -p ec-av1 --example decode_probe
155+
156+# byte-exactness, 8-bit
157+decode_probe x.obu out8.raw # argv[2] = 8-bit planes
158+ffmpeg -i x.obu -pix_fmt yuv420p -f rawvideo ref8.raw -y
159+cmp out8.raw ref8.raw
160+# (EC_PROBE_OUT16 is yuv420p10le and is NOT comparable to ffmpeg's
161+# yuv420p10le for an 8-bit source — ffmpeg left-shifts, the probe does not.
162+# Use the 8-bit form for 8-bit streams. This bit me once.)
163+
164+# first divergence vs the instrumented oracle
165+EC_TRACE_MODE_STEP=1 ~/.cache/aom-oracle/build/aomdec --rawvideo -o /dev/null x.obu 2>a.step
166+EC_TRACE_MODE_STEP=1 decode_probe x.obu 2>o.step
167+# per-(mi_row,mi_col,name) index compare in python (see §1 method)
168+```
169+
170+Oracle build: `~/.cache/aom-oracle` (cmake+ninja) instrumented with
171+`EC_ISTEP name=intrabc` (decodemv.c `read_intrabc_info`), `EC_DV`
172+(post-`assign_dv`), `EC_COEFF` (decodeframe.c `read_coeffs_tx_intra_block`).
173+
174+## 8. Recommended next steps (ordered)
175+
176+1. Fix the rect intrabc leaf (warped) — trace the rect leaf's DV/residual vs
177+ aomdec; then verify `EC_PROBE_OUT8` byte-exact.
178+2. Unblock `allintra`'s 1:4 rect strip intrabc (`decode.rs:9122`) and the
179+ `decode_leaf8` dequant panic.
180+3. Add the sequence-header subsampling refusal (§3) and re-pin the inventory.
181+4. Run `cargo test -p ec-av1 --lib` + `cargo check -p ec-av1 --all-targets`.