forge
Explore
Log in

Don't you dare go Hollow

ec-av1: merge lane-av1-txrouting (non-4:2:0 + qmatrix refusals, cdf-update wiring, rect intrabc)

Browse files at this commit

f3428f0863e4f5f08c8a5acac0da17281664cc3dAhmet Kaan GümüşParent: 1aa3a99754210b
Merges lane-av1-txrouting (8d8413f0) into main, which had already absorbed
lane-av1-mono (7806fd0d) and lane-av1-hdr (e03f7173) since the lane's base --
both of them also touched stream.rs, so this is the day's cross-lane merge.

Three conflict hunks, resolved by combining the lineages, never a side:

- decode.rs read_intra_mode_sub8: the lane's return type (the third value
  carries an intrabc DV) plus mono's `has_chroma && !mono(fctx)` fold.
- stream.rs decode_frame: keep BOTH per-frame setters -- mono's set_mono and
  the lane's set_disable_cdf_update.
- stream.rs tests: the lane's non-4:2:0 and using_qmatrix gates land ahead of
  mono's witness; the pilot's monochrome pin stays dropped in favour of
  a_real_libaom_monochrome_key_frame_decodes_pixel_exact (its doc header
  dropped with it).

Two-way content proof: the staged tree's delta vs main is the lane's own delta
line-for-line (787 insertions / 64 deletions, same per-file counts) and its
delta vs the lane is main's delta (651/94). Marker grep on all six resolved
files: none.

Merged-tree gates: cargo check -p ec-av1 --all-targets -> 0 warnings; cargo
test -p ec-av1 --lib -> 598 passed, 0 failed, 60 ignored (6708 s). Probes: the
60-frame monochrome key frame and the monochrome fixture decode luma byte-exact
vs ffmpeg, a 4:4:4 stream and an aomenc --enable-qm=1 stream refused by name,
an aomenc --cdf-update-mode=0 stream byte-exact, and a 10-bit 4K OBU window
sha256 d7214bb7...4346784.
crates/ec-av1/examples/decode_probe.rsmodified+6 -0
@@ -92,6 +92,12 @@ fn main() {
9292 println!("inter16_1to4: horz4={h4} vert4={v4} chroma_pairs={pairs} sub8_pieces={sub8}");
9393 let leaf4 = ec_av1::stream::vartx_rect_leaf4_hits();
9494 println!("vartx_rect_leaf4: 8x4={} 4x8={}", leaf4[0], leaf4[1]);
95+ // lane-av1txr: intrabc 4x8/8x4 leaves that read the inter var-tx tree
96+ // (the symbol whose absence desynced `warped.obu`).
97+ println!(
98+ "rect_intrabc_vartx: {}",
99+ ec_av1::decode::rect_intrabc_vartx_hits()
100+ );
95101 let rw = ec_av1::stream::rect_wedge_hits();
96102 let rwi = ec_av1::stream::rect_wii_hits();
97103 println!(
crates/ec-av1/src/cdf_state.rsmodified+3 -3
@@ -322,9 +322,9 @@ impl TxbSet {
322322
323323 /// lane-txi: this set's `reduced_tx_set == 0` counterpart -- the WIDER
324324 /// `tx_type` alphabet the same coefficient tables are read with when the
325- /// frame header's bit is off. Every pair here is the one
326- /// `decode::txbset_for`/`txbset_for_inter`/`inter_txbset_for` resolve off
327- /// that bit, transcribed from the DECODER's own map so writer and reader
325+ /// frame header's bit is off. Every pair here is the counterpart
326+ /// `decode::txbset_for`/`inter_txbset_for` resolve off that bit,
327+ /// transcribed from the DECODER's own map so writer and reader
328328 /// cannot drift (class `table-and-reader-move-together`); a set with no
329329 /// counterpart -- intra 16x16 and 32x32, inter 32x32, 64x64, every
330330 /// chroma set -- is its own, and widening an already-wide set is the
crates/ec-av1/src/decode.rsmodified+443 -47
@@ -84,6 +84,12 @@ pub(crate) struct FrameCtx {
8484 /// (`decodeframe.c`), `read_tx_type` (`decodetxb.c`), `is_cfl_allowed`
8585 /// (`blockd.h`)).
8686 pub(crate) lossless_flag: std::cell::Cell<bool>,
87+ /// lane-av1txr: this frame header's `disable_cdf_update` (spec 5.9.2).
88+ /// When set, the tile reader must not adapt any CDF it reads, or its
89+ /// tables drift away from the encoder's and the frame desyncs mid-tile
90+ /// (libaom: `allow_update_cdf = allow_update_cdf &&
91+ /// !cm->features.disable_cdf_update`, `decodeframe.c:2909`).
92+ pub(crate) disable_cdf_update: std::cell::Cell<bool>,
8793 pub(crate) cdef_bits: std::cell::Cell<u8>,
8894 pub(crate) bit_depth: std::cell::Cell<u8>,
8995 /// lane-av1mono: the sequence header's `color_config.mono_chrome` (spec
@@ -183,6 +189,7 @@ impl FrameCtx {
183189 sb128_flag: std::cell::Cell::new(false),
184190 interp_filter: std::cell::Cell::new(crate::mc::InterpFilterKind::Regular),
185191 lossless_flag: std::cell::Cell::new(false),
192+ disable_cdf_update: std::cell::Cell::new(false),
186193 cdef_bits: std::cell::Cell::new(0),
187194 bit_depth: std::cell::Cell::new(8),
188195 mono_chrome: std::cell::Cell::new(false),
@@ -390,6 +397,18 @@ pub(crate) fn lossless(fctx: &crate::decode::FrameCtx) -> bool {
390397 fctx.lossless_flag.with(|c| c.get())
391398 }
392399
400+/// Sets [`FrameCtx::disable_cdf_update`] (called once per frame from
401+/// `stream.rs`).
402+pub(crate) fn set_disable_cdf_update(v: bool, fctx: &crate::decode::FrameCtx) {
403+ fctx.disable_cdf_update.with(|c| c.set(v));
404+}
405+
406+/// This frame's `disable_cdf_update`, for the tile readers --
407+/// [`msac::SymbolDecoder::set_cdf_update`](crate::msac::SymbolDecoder::set_cdf_update).
408+pub(crate) fn cdf_update_disabled(fctx: &crate::decode::FrameCtx) -> bool {
409+ fctx.disable_cdf_update.with(|c| c.get())
410+}
411+
393412 /// The transform side a block of `side` pixels codes: its own (capped at the
394413 /// caller's own largest) normally, 4 on a lossless frame, where libaom's
395414 /// `read_tx_size` returns TX_4X4 before it looks at anything else
@@ -3687,6 +3706,11 @@ thread_local! {
36873706 /// var-tx partition tree (unskipped, `TX_MODE_SELECT`) -- the capability
36883707 /// that replaced the refusal "an intrabc block under TxMode::Select".
36893708 static INTRABC_VARTX_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
3709+ /// lane-av1txr: as above for a `BLOCK_4X8`/`BLOCK_8X4` intrabc leaf --
3710+ /// libaom's `block_signals_txsize` is `bsize > BLOCK_4X4`, so these leaves
3711+ /// signal a transform size where a plain `BLOCK_4X4` does not. Reading no
3712+ /// symbol here desynced `warped.obu` at the very next block.
3713+ static RECT_INTRABC_VARTX_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
36903714 }
36913715
36923716 /// Current value of [`INTRABC_VARTX_HITS`].
@@ -3701,11 +3725,31 @@ pub(crate) fn reset_intrabc_vartx_hits() {
37013725 INTRABC_VARTX_HITS.with(|c| c.set(0));
37023726 }
37033727
3728+/// Current value of [`RECT_INTRABC_VARTX_HITS`].
3729+#[allow(dead_code)] // read only from the `#[cfg(test)]` gates
3730+pub fn rect_intrabc_vartx_hits() -> usize {
3731+ RECT_INTRABC_VARTX_HITS.with(|c| c.get())
3732+}
3733+
37043734 /// Records one coded block into [`INTRABC_MI_GRID`]: every block contributes
37053735 /// its size (libaom's `scan_row_mbmi` advances `processed_rows` off any
37063736 /// candidate's `bsize`, ref-match or not), an intrabc one also its DV as an
37073737 /// `INTRA_FRAME` candidate (libaom treats intrabc as `is_inter_block`).
37083738 fn record_intrabc_mi(mi_r: usize, mi_c: usize, n4: usize, dv: Option<(i32, i32)>, fctx: &crate::decode::FrameCtx) {
3739+ record_intrabc_mi_rect(mi_r, mi_c, n4, n4, dv, fctx);
3740+}
3741+
3742+/// [`record_intrabc_mi`] with a true rectangular footprint: `av1_find_mv_refs`
3743+/// takes the block's real `bsize`, so a sub-8x8 `BLOCK_4X8`/`BLOCK_8X4`
3744+/// intrabc leaf must publish a 1x2/2x1 mi span, not a square (lane-av1txr).
3745+fn record_intrabc_mi_rect(
3746+ mi_r: usize,
3747+ mi_c: usize,
3748+ n4_w: usize,
3749+ n4_h: usize,
3750+ dv: Option<(i32, i32)>,
3751+ fctx: &crate::decode::FrameCtx,
3752+) {
37093753 fctx.intrabc_mi_grid.with(|g| {
37103754 let mut g = g.borrow_mut();
37113755 let Some((grid, _, _)) = g.as_mut() else {
@@ -3720,11 +3764,11 @@ fn record_intrabc_mi(mi_r: usize, mi_c: usize, n4: usize, dv: Option<(i32, i32)>
37203764 is_new_mv: dv.is_some(),
37213765 is_global_mv0: false,
37223766 is_global_mv1: false,
3723- size: n4 as u8,
3724- size_h: n4 as u8,
3767+ size: n4_w as u8,
3768+ size_h: n4_h as u8,
37253769 };
3726- for r in mi_r..mi_r + n4 {
3727- for c in mi_c..mi_c + n4 {
3770+ for r in mi_r..mi_r + n4_h {
3771+ for c in mi_c..mi_c + n4_w {
37283772 grid.set(r, c, info);
37293773 }
37303774 }
@@ -11399,7 +11443,11 @@ fn decode_leaf_rect(
1139911443 // the range diverges silently at the first such leaf and every later
1140011444 // symbol in the tile is read from the wrong place (class
1140111445 // `wrong-alphabet-same-value`, here same alphabet / wrong row).
11402- dec.symbol(&mut cdfs.tx_size_cat1[ctx])
11446+ let d = dec.symbol(&mut cdfs.tx_size_cat1[ctx]);
11447+ if crate::envflags::env_flag!("EC_TRACE_MODE_STEP") {
11448+ 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);
11449+ }
11450+ d
1140311451 } else {
1140411452 0
1140511453 };
@@ -13318,11 +13366,14 @@ fn read_intra_mode(
1331813366 // that merely allows (but never uses) intrabc.
1331913367 if allow_intrabc {
1332013368 let use_intrabc = dec.symbol(&mut cdfs.intrabc) != 0;
13369+ if crate::envflags::env_flag!("EC_TRACE_MODE_STEP") {
13370+ eprintln!("EC_ISTEP mi_row={mi_r} mi_col={mi_c} name=intrabc val={} rng={}", u8::from(use_intrabc), dec.debug_state().0);
13371+ }
1332113372 if trace {
1332213373 eprintln!("TRACE use_intrabc value={}", use_intrabc as i32);
1332313374 }
1332413375 if use_intrabc {
13325- let dv = read_intrabc_dv(dec, cdfs, mi_r, mi_c, side, fctx);
13376+ let dv = read_intrabc_dv(dec, cdfs, mi_r, mi_c, (side / MI, side / MI), fctx);
1332613377 if trace {
1332713378 eprintln!("TRACE intrabc dv={dv:?}");
1332813379 }
@@ -14418,7 +14469,7 @@ fn decode_block(
1441814469 luma_set
1441914470 };
1442014471 let luma_set = if intrabc_dv.is_some() {
14421- txbset_for_inter(logical_tx, reduced_tx_set)
14472+ inter_txbset_for(logical_tx, reduced_tx_set)
1442214473 } else {
1442314474 luma_set
1442414475 };
@@ -15686,7 +15737,7 @@ fn decode_leaf8(
1568615737 dec,
1568715738 cdfs,
1568815739 if intrabc_dv.is_some() {
15689- txbset_for_inter(8, reduced_tx_set)
15740+ inter_txbset_for(8, reduced_tx_set)
1569015741 } else if reduced_tx_set {
1569115742 TxbSet::Luma8
1569215743 } else {
@@ -15821,7 +15872,7 @@ fn decode_leaf8(
1582115872 dec,
1582215873 cdfs,
1582315874 if intrabc_dv.is_some() {
15824- txbset_for_inter(4, reduced_tx_set)
15875+ inter_txbset_for(4, reduced_tx_set)
1582515876 } else if reduced_tx_set {
1582615877 TxbSet::Luma4
1582715878 } else {
@@ -16021,7 +16072,7 @@ fn read_intra_mode_sub8(
1602116072 // neighbour's `cdf_index`/prediction two blocks later.
1602216073 seg_w_mi: usize,
1602316074 seg_h_mi: usize, fctx: &crate::decode::FrameCtx,
16024-) -> Result<(bool, usize, i32, Option<(usize, i32, Option<(i32, i32)>)>, Option<usize>)> {
16075+) -> Result<(bool, usize, i32, Option<(usize, i32, Option<(i32, i32)>)>, Option<usize>, Option<(i32, i32)>)> {
1602516076 // lane-av1mono: a monochrome leaf codes no chroma mode (libaom
1602616077 // `decodemv.c:933`), so fold `NumPlanes == 1` into `has_chroma`.
1602716078 let has_chroma = has_chroma && !mono(fctx);
@@ -16063,10 +16114,27 @@ fn read_intra_mode_sub8(
1606316114 istep!("dq", 0);
1606416115 if allow_intrabc {
1606516116 let use_intrabc = dec.symbol(&mut cdfs.intrabc) != 0;
16117+ if ec_istep {
16118+ eprintln!("EC_ISTEP mi_row={mi_r} mi_col={mi_c} name=intrabc val={} rng={}", u8::from(use_intrabc), dec.debug_state().0);
16119+ }
1606616120 if use_intrabc {
16067- return Err(unsupported(
16068- "a sub-8x8 leaf that uses intrabc (this reader has no block-vector path; the 8x8-and-up reader reconstructs one)",
16069- ));
16121+ // lane-av1txr: `read_intrabc_info` (spec 5.11.13) reads the block
16122+ // vector right after the flag and RETURNS -- no y/uv mode, angle
16123+ // delta, palette, CfL or filter-intra syntax follows, and the
16124+ // block is reconstructed by the INTER path (libaom's
16125+ // `is_inter_block` counts an intrabc block), so the caller takes
16126+ // the frame-copy prediction + inter residual.
16127+ let dv = read_intrabc_dv(dec, cdfs, mi_r, mi_c, (seg_w_mi, seg_h_mi), fctx);
16128+ // lane-av1txr: the DV travels back in the RETURN value -- it is
16129+ // NOT published through `FrameCtx::intrabc_dv`. That slot is the
16130+ // SQUARE paths' handoff (`decode_block`/`decode_leaf8` arm it,
16131+ // then `take()` it in the same call), so a sub-8x8 leaf that
16132+ // armed it left the vector standing for the NEXT >=8x8 block:
16133+ // `warped.obu`'s (38,60) 8x8 intra block took it as its own
16134+ // intrabc and read an inter var-tx `txfm_split` where libaom read
16135+ // an intra `tx_depth` (class `stale-slot-handoff`).
16136+ hit!(INTRABC_HITS);
16137+ return Ok((skip, DC_PRED, 0, None, None, Some(dv)));
1607016138 }
1607116139 }
1607216140 let above_ctx = INTRA_MODE_CTX[above_mode];
@@ -16116,7 +16184,7 @@ fn read_intra_mode_sub8(
1611616184 filter_intra = Some(fi_mode);
1611716185 }
1611816186 }
16119- Ok((skip, mode, angle_delta_y, chroma, filter_intra))
16187+ Ok((skip, mode, angle_delta_y, chroma, filter_intra, None))
1612016188 }
1612116189
1612216190 /// Decodes a `PARTITION_SPLIT` of one 8x8 block into four `BLOCK_4X4` leaves
@@ -16167,6 +16235,10 @@ fn decode_leaf_split4(
1616716235 let mut leaf_modes = [0usize; 4];
1616816236 let mut leaf_skips = [false; 4];
1616916237 let mut last_uv: Option<(usize, i32, Option<(i32, i32)>)> = None;
16238+ // lane-av1txr: the chroma-reference (i==3) leaf's block vector when that
16239+ // leaf is an intrabc block -- its prediction/reconstruction below is a
16240+ // frame copy at this DV, not an intra one.
16241+ let mut last_intrabc: Option<(i32, i32)> = None;
1617016242 for i in 0..4usize {
1617116243 let (dr, dc) = (i / 2, i % 2);
1617216244 let lmi = (leaf_mi.0 + dr, leaf_mi.1 + dc);
@@ -16186,7 +16258,7 @@ fn decode_leaf_split4(
1618616258 };
1618716259 let has_chroma = i == 3;
1618816260 let skip_ctx = neighbours.skip_txfm_ctx(lmi.0, lmi.1);
16189- let (skip, mode, angle_delta_y, chroma, filter_intra) = read_intra_mode_sub8(
16261+ let (skip, mode, angle_delta_y, chroma, filter_intra, intrabc) = read_intra_mode_sub8(
1619016262 dec, cdfs, leaf_above, leaf_left, has_chroma, enable_filter_intra,
1619116263 filter_intra_size_class(4).expect("BLOCK_4X4 has its own filter_intra row"),
1619216264 skip_ctx, allow_intrabc, lmi.0, lmi.1, 1, 1, fctx,
@@ -16194,12 +16266,81 @@ fn decode_leaf_split4(
1619416266 leaf_modes[i] = mode;
1619516267 leaf_skips[i] = skip;
1619616268 neighbours.record_mode_mi(lmi.0, lmi.1, 1, 1, mode);
16269+ // lane-av1txr: libaom `parse_decode_block`'s `set_txfm_ctxs` for this
16270+ // `BLOCK_4X4` leaf -- EVERY block publishes its transform size into
16271+ // the TXFM context bands, and an intrabc block's later `txfm_split`
16272+ // context is read off them (`txfm_partition_context`). A 4x4 never
16273+ // signals a tx size, so it is always TX_4X4 (`set_txfm_ctxs`'s
16274+ // `skip && is_inter` branch writes the block's own 4 pixels -- the
16275+ // same value).
16276+ set_txfm_ctxs(neighbours, lmi, 4, 1, 1, false);
1619716277 let smooth_neighbor = is_smooth_mode(leaf_above) || is_smooth_mode(leaf_left);
1619816278 if smooth_neighbor {
1619916279 hit!(SMOOTH_LUMA_HITS);
1620016280 }
1620116281 let (px, py) = (lmi.1 * MI, lmi.0 * MI);
1620216282 let reach = Reach::of(4, px, py, y.width, y.height, fctx);
16283+ if let Some(dv) = intrabc {
16284+ // lane-av1txr: an intrabc `BLOCK_4X4` leaf -- prediction is the
16285+ // CURRENT frame at the block vector (`predict_inter_block`'s
16286+ // intrabc arm, spec 7.11.3.4), residual the INTER coefficient set
16287+ // (libaom reads `tx_type` off `inter_ext_tx_cdf` for
16288+ // `is_inter_block`, which counts intrabc). Published into
16289+ // `intrabc_dv` so the group's chroma arm (below, when the
16290+ // chroma-reference leaf is the intrabc one) and
16291+ // [`record_intrabc_mi`] see it.
16292+ flush_recon(fctx, y, u, v);
16293+ let mut yb = vec![0u16; 16];
16294+ mc::predict_with_filter(
16295+ &y.data, y.width, y.true_width, y.true_height,
16296+ mv_to_q4(px, dv.1, true), mv_to_q4(py, dv.0, true),
16297+ 4, 4, mc::InterpFilterKind::Bilinear, &mut yb, fctx,
16298+ );
16299+ set_palette_pred(yb.clone(), fctx);
16300+ if skip {
16301+ push_intra(0, px, py, 4, DC_PRED, 0, reach, &ZERO_RESIDUAL[..16], None, None, smooth_neighbor, fctx);
16302+ neighbours.record_mi_luma(lmi, 4, &ZERO_RESIDUAL[..16]);
16303+ } else {
16304+ let tu_around = neighbours.around_mi(lmi, 4)[0];
16305+ let tu_grid = read_plane(
16306+ dec,
16307+ cdfs,
16308+ if reduced_tx_set { TxbSet::Luma4Inter } else { TxbSet::Luma4InterSet1 },
16309+ scan4,
16310+ 0,
16311+ tu_around,
16312+ DC_PRED,
16313+ DC_PRED,
16314+ 0,
16315+ reach,
16316+ y,
16317+ px,
16318+ py,
16319+ 4,
16320+ 4,
16321+ base_q_idx,
16322+ None,
16323+ None,
16324+ None,
16325+ smooth_neighbor, fctx,
16326+ )?;
16327+ neighbours.record_mi_luma(lmi, 4, &tu_grid);
16328+ }
16329+ neighbours.fill_skip_grid(lmi, 1, skip);
16330+ neighbours.fill_lf_grid(lmi, 1, 4, 0, fctx);
16331+ record_intrabc_mi(lmi.0, lmi.1, 1, Some(dv), fctx);
16332+ if has_chroma {
16333+ last_uv = Some((DC_PRED, 0, None));
16334+ // An intrabc block is an INTER block for `av1_get_tx_type`, so
16335+ // the group's chroma inherits the LUMA's coded transform type
16336+ // (`xd->tx_type_map` at the co-located luma position) -- the
16337+ // luma `read_plane` above just set [`LUMA_TX_TYPE`]. Armed for
16338+ // exactly this group's two chroma reads.
16339+ fctx.intrabc_chroma_tx.with(|c| c.set(Some(fctx.luma_tx_type.with(std::cell::Cell::get))));
16340+ }
16341+ last_intrabc = Some(dv);
16342+ continue;
16343+ }
1620316344 if skip {
1620416345 push_intra(0, px, py, 4, mode, angle_delta_y, reach, &ZERO_RESIDUAL[..16], None, filter_intra, smooth_neighbor, fctx);
1620516346 neighbours.record_mi_luma(lmi, 4, &ZERO_RESIDUAL[..16]);
@@ -16271,6 +16412,38 @@ fn decode_leaf_split4(
1627116412 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);
1627216413 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);
1627316414 (Grid::Zero(16), Grid::Zero(16))
16415+ } else if let Some(dv) = last_intrabc {
16416+ // lane-av1txr: the chroma-reference leaf was an intrabc block, so the
16417+ // group's one chroma unit is a frame copy at that DV too (its residual
16418+ // still reads the ordinary `Chroma4` coefficient tables -- libaom
16419+ // codes a chroma `tx_type` nowhere).
16420+ let mut ub = vec![0u16; 16];
16421+ mc::predict_with_filter(
16422+ &u.data, u.width, u.true_width, u.true_height,
16423+ mv_to_q4(cpx, dv.1, false), mv_to_q4(cpy, dv.0, false),
16424+ 4, 4, mc::InterpFilterKind::Bilinear, &mut ub, fctx,
16425+ );
16426+ let mut vb = vec![0u16; 16];
16427+ mc::predict_with_filter(
16428+ &v.data, v.width, v.true_width, v.true_height,
16429+ mv_to_q4(cpx, dv.1, false), mv_to_q4(cpy, dv.0, false),
16430+ 4, 4, mc::InterpFilterKind::Bilinear, &mut vb, fctx,
16431+ );
16432+ let chroma_around = neighbours.around_mi(leaf_mi, 8);
16433+ set_palette_pred(ub, fctx);
16434+ let ug = read_plane(
16435+ dec, cdfs, TxbSet::Chroma4, scan4, 1, chroma_around[1], DC_PRED, DC_PRED,
16436+ 0, group_reach, u, cpx, cpy, 4, TX4, base_q_idx,
16437+ None, None, None, smooth_neighbor_uv, fctx,
16438+ )?;
16439+ set_palette_pred(vb, fctx);
16440+ let vg = read_plane(
16441+ dec, cdfs, TxbSet::Chroma4, scan4, 2, chroma_around[2], DC_PRED, DC_PRED,
16442+ 0, group_reach, v, cpx, cpy, 4, TX4, base_q_idx,
16443+ None, None, None, smooth_neighbor_uv, fctx,
16444+ )?;
16445+ fctx.intrabc_chroma_tx.with(|c| c.set(None));
16446+ (ug, vg)
1627416447 } else {
1627516448 let ac = alpha.map(|_| cfl_src(gpx, gpy, 8));
1627616449 let chroma_around = neighbours.around_mi(leaf_mi, 8);
@@ -16398,6 +16571,8 @@ fn decode_leaf_rect8(
1639816571 let mut leaf_modes = [0usize; 2];
1639916572 let mut leaf_skips = [false; 2];
1640016573 let mut last_uv: Option<(usize, i32, Option<(i32, i32)>)> = None;
16574+ // lane-av1txr: as [`decode_leaf_split4`]'s own `last_intrabc`.
16575+ let mut last_intrabc: Option<(i32, i32)> = None;
1640116576 for i in 0..2usize {
1640216577 let lmi = if vert {
1640316578 (leaf_mi.0, leaf_mi.1 + i)
@@ -16418,12 +16593,186 @@ fn decode_leaf_rect8(
1641816593 };
1641916594 let has_chroma = i == 1;
1642016595 let skip_ctx = neighbours.skip_txfm_ctx(lmi.0, lmi.1);
16421- let (skip, mode, angle_delta_y, chroma, filter_intra) = read_intra_mode_sub8(
16596+ let (skip, mode, angle_delta_y, chroma, filter_intra, intrabc) = read_intra_mode_sub8(
1642216597 dec, cdfs, leaf_above, leaf_left, has_chroma, enable_filter_intra,
1642316598 filter_intra_size_class_rect(bw, bh)
1642416599 .expect("BLOCK_4X8/BLOCK_8X4 are inside av1_filter_intra_allowed_bsize"),
1642516600 skip_ctx, allow_intrabc, lmi.0, lmi.1, bw / 4, bh / 4, fctx,
1642616601 )?;
16602+ leaf_modes[i] = mode;
16603+ leaf_skips[i] = skip;
16604+ neighbours.record_mode_mi(lmi.0, lmi.1, w_mi, h_mi, mode);
16605+ let smooth_neighbor = is_smooth_mode(leaf_above) || is_smooth_mode(leaf_left);
16606+ if let Some(dv) = intrabc {
16607+ // lane-av1txr: an intrabc `BLOCK_4X8`/`BLOCK_8X4` leaf. The
16608+ // prediction is a frame copy at the DV and the residual reads the
16609+ // INTER `LumaRect8x4` set -- but with `TxMode::Select` the leaf
16610+ // reads the INTER var-tx tree, exactly like every other intrabc
16611+ // block: libaom's `block_signals_txsize` is `bsize > BLOCK_4X4`
16612+ // (`blockd.h:1027`), TRUE at `BLOCK_4X8`/`BLOCK_8X4`, so
16613+ // `parse_decode_block` sends an unskipped `inter_block_tx` block
16614+ // (intrabc counts, `is_inter_block`) of a signalling bsize into
16615+ // `read_tx_size_vartx` over `max_txsize_rect_lookup[BLOCK_4X8] ==
16616+ // TX_4X8`; only `BLOCK_4X4` reads no tx symbol at all. Measured on
16617+ // `warped.obu` mi (37,62): reading NO symbol here left the
16618+ // arithmetic decoder one symbol short and desynced the very next
16619+ // block's `skip` (ours 60320 vs aomdec 48630, class
16620+ // `symbol-consumption-gap`).
16621+ let (px, py) = (lmi.1 * MI, lmi.0 * MI);
16622+ let reach = Reach::of_rect(bw, bh, px, py, y.width, y.height, fctx);
16623+ flush_recon(fctx, y, u, v);
16624+ let mut luma_leaves: Vec<(usize, usize, usize, usize)> = Vec::new();
16625+ if tx_select && !skip {
16626+ // `max_block_wide`/`max_block_high`: the frame's own mi grid,
16627+ // so a leaf hanging over the right/bottom edge reads no split
16628+ // symbol for the units outside it (as in `decode_block`).
16629+ let mi_cols = 2 * y.true_width.div_ceil(8);
16630+ let mi_rows = 2 * y.true_height.div_ceil(8);
16631+ let max_w_mi = w_mi.min(mi_cols.saturating_sub(lmi.1));
16632+ let max_h_mi = h_mi.min(mi_rows.saturating_sub(lmi.0));
16633+ read_var_tx_size(
16634+ dec,
16635+ cdfs,
16636+ neighbours,
16637+ lmi,
16638+ bw.max(bh),
16639+ (max_w_mi, max_h_mi),
16640+ (bw, bh),
16641+ 0,
16642+ 0,
16643+ 0,
16644+ &mut luma_leaves,
16645+ );
16646+ hit!(RECT_INTRABC_VARTX_HITS);
16647+ } else {
16648+ luma_leaves.push((0, 0, bw, bh));
16649+ // The non-var-tx arm: a SKIPPED intrabc leaf (or a frame
16650+ // outside `TxMode::Select`) publishes its own rect transform
16651+ // (`set_txfm_ctxs`'s `skip && is_inter` branch writes the
16652+ // block's own pixels -- the same size here).
16653+ txfm_partition_update_rect(neighbours, lmi, (bw, bh), (bw, bh));
16654+ }
16655+ // The transform type an intrabc block's CHROMA inherits is the
16656+ // `tx_type_map` entry at the chroma unit's co-located luma
16657+ // position (`av1_get_tx_type`, `blockd.h:1278`), i.e. the FIRST
16658+ // luma unit the tree resolved.
16659+ let single = luma_leaves.len() == 1;
16660+ let mut chroma_tx = TxType::DctDct;
16661+ let mut grid = Grid::Zero(bw * bh);
16662+ for (li, &(tu_row, tu_col, tw, th)) in luma_leaves.iter().enumerate() {
16663+ let tu_mi = (lmi.0 + tu_row, lmi.1 + tu_col);
16664+ let (tu_px, tu_py) = (tu_mi.1 * MI, tu_mi.0 * MI);
16665+ let tu_reach = if single {
16666+ reach
16667+ } else {
16668+ tu_reach(
16669+ bw, bh, tu_px - px, tu_py - py, tw, reach, px, py, y.width, y.height, fctx,
16670+ )
16671+ };
16672+ let mut yb = vec![0u16; tw * th];
16673+ mc::predict_with_filter(
16674+ &y.data, y.width, y.true_width, y.true_height,
16675+ mv_to_q4(tu_px, dv.1, true), mv_to_q4(tu_py, dv.0, true),
16676+ tw, th, mc::InterpFilterKind::Bilinear, &mut yb, fctx,
16677+ );
16678+ set_palette_pred(yb, fctx);
16679+ let tu_grid = if skip {
16680+ let zeros = Grid::Zero(tw * th);
16681+ if (tw, th) == (4, 4) {
16682+ push_intra(0, tu_px, tu_py, 4, DC_PRED, 0, tu_reach, &zeros, None, None, smooth_neighbor, fctx);
16683+ } else {
16684+ push_intra_rect(0, tu_px, tu_py, tw, th, DC_PRED, 0, tu_reach, &zeros, None, None, smooth_neighbor, fctx);
16685+ }
16686+ zeros
16687+ } else {
16688+ // A unit smaller than its own block (the var-tx split)
16689+ // reads its `txb_skip_ctx` off the neighbours; the
16690+ // whole-leaf unit's `plane_bsize == txsize_to_bsize` fixes
16691+ // it at 0.
16692+ let (set, tu_scan, around, skip_ctx) = if (tw, th) == (4, 4) {
16693+ (
16694+ inter_txbset_for(4, reduced_tx_set),
16695+ scan4,
16696+ neighbours.around_mi(tu_mi, 4)[0],
16697+ neighbours.luma_skip_ctx(tu_mi, 1),
16698+ )
16699+ } else {
16700+ (
16701+ if reduced_tx_set {
16702+ TxbSet::LumaRect8x4Inter
16703+ } else {
16704+ TxbSet::LumaRect8x4InterSet1
16705+ },
16706+ scan,
16707+ neighbours.around_mi_rect(tu_mi, tw, th)[0],
16708+ 0,
16709+ )
16710+ };
16711+ let mut coding = cdfs.txb(set, DC_PRED);
16712+ let (levels, tx_type) = read_coeffs_rect(
16713+ dec, &mut coding, tu_scan, tw, th, skip_ctx, dc_sign_ctx(around.2),
16714+ TxType::DctDct,
16715+ )?;
16716+ if li == 0 {
16717+ chroma_tx = tx_type;
16718+ fctx.luma_tx_type.with(|c| c.set(tx_type));
16719+ }
16720+ let residual = dequant_and_inverse_typed_wh(
16721+ &levels, tw, th, crate::decode::bit_depth(fctx), block_q_idx(fctx),
16722+ plane_q_delta(0, fctx).0, plane_q_delta(0, fctx).1, tx_type,
16723+ );
16724+ if (tw, th) == (4, 4) {
16725+ push_intra(0, tu_px, tu_py, 4, DC_PRED, 0, tu_reach, &residual, None, None, smooth_neighbor, fctx);
16726+ } else {
16727+ push_intra_rect(0, tu_px, tu_py, tw, th, DC_PRED, 0, tu_reach, &residual, None, None, smooth_neighbor, fctx);
16728+ }
16729+ levels
16730+ };
16731+ if single {
16732+ grid = tu_grid;
16733+ } else {
16734+ // Per-unit neighbour state, the same shape the intra rect
16735+ // leaf's own split path runs (`decode_leaf8`'s depth-1
16736+ // loop): a transform unit inside a block is not a block at
16737+ // that position.
16738+ neighbours.record_mi_luma(tu_mi, 4, &tu_grid);
16739+ }
16740+ }
16741+ if single {
16742+ let state = neighbour_state(&grid);
16743+ for cell in 0..h_mi {
16744+ if lmi.0 + cell < neighbours.mi_rows {
16745+ neighbours.left[lmi.0 + cell][0] = state;
16746+ }
16747+ }
16748+ for cell in 0..w_mi {
16749+ if lmi.1 + cell < neighbours.mi_cols {
16750+ neighbours.above[lmi.1 + cell][0] = state;
16751+ }
16752+ }
16753+ }
16754+ neighbours.fill_skip_grid_rect(lmi, w_mi, h_mi, skip);
16755+ neighbours.fill_lf_grid_rect(
16756+ lmi,
16757+ w_mi,
16758+ h_mi,
16759+ if single { bw as u8 } else { 4 },
16760+ if single { bh as u8 } else { 4 },
16761+ 0,
16762+ fctx,
16763+ );
16764+ // `record_intrabc_mi` publishes a square `n4`x`n4` footprint; a
16765+ // 4x8/8x4 leaf needs its true `w_mi`x`h_mi` (lane-av1txr).
16766+ record_intrabc_mi_rect(lmi.0, lmi.1, w_mi, h_mi, Some(dv), fctx);
16767+ if has_chroma {
16768+ last_uv = Some((DC_PRED, 0, None));
16769+ last_intrabc = Some(dv);
16770+ // See [`decode_leaf_split4`]: an intrabc block's chroma
16771+ // inherits the luma transform type.
16772+ fctx.intrabc_chroma_tx.with(|c| c.set(Some(chroma_tx)));
16773+ }
16774+ continue;
16775+ }
1642716776 if filter_intra.is_some() {
1642816777 // lane-fi8 r1: `predict_filter_intra` walks its 4x2 patches over
1642916778 // a true `bw`x`bh` block, so a 4x8/8x4 leaf predicts through the
@@ -16459,10 +16808,6 @@ fn decode_leaf_rect8(
1645916808 hit!(TX_DEPTH_HITS);
1646016809 hit!(RECT8_SPLIT_TX_HITS);
1646116810 }
16462- leaf_modes[i] = mode;
16463- leaf_skips[i] = skip;
16464- neighbours.record_mode_mi(lmi.0, lmi.1, w_mi, h_mi, mode);
16465- let smooth_neighbor = is_smooth_mode(leaf_above) || is_smooth_mode(leaf_left);
1646616811 if smooth_neighbor {
1646716812 hit!(SMOOTH_LUMA_HITS);
1646816813 }
@@ -16475,6 +16820,15 @@ fn decode_leaf_rect8(
1647516820 // four. The per-TU path writes its own neighbour state, so the
1647616821 // block-level write below is skipped for it.
1647716822 let split = depth != 0 || lossless(fctx);
16823+ // lane-av1txr: libaom `parse_decode_block`'s `set_txfm_ctxs` for this
16824+ // leaf -- the size the `tx_depth` symbol resolved (depth 1 -> TX_4X4,
16825+ // else the leaf's own rect transform), published over the leaf's own
16826+ // mi span. An intrabc block's `txfm_partition_context` reads these
16827+ // bands, and the key-frame sub-8x8 leaves had no write at all:
16828+ // `warped.obu` mi (37,62) read a stale 8 where aomdec read 4 (ctx 18
16829+ // vs 19) and the tile desynced (class `context-band-not-published`).
16830+ let (ctx_tx_w, ctx_tx_h) = if split { (4, 4) } else { (bw, bh) };
16831+ txfm_partition_update_rect(neighbours, lmi, (ctx_tx_w, ctx_tx_h), (bw, bh));
1647816832 if split {
1647916833 let mut done = 0usize;
1648016834 for tu in 0..2usize {
@@ -16666,6 +17020,38 @@ fn decode_leaf_rect8(
1666617020 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);
1666717021 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);
1666817022 (Grid::Zero(16), Grid::Zero(16))
17023+ } else if let Some(dv) = last_intrabc {
17024+ // lane-av1txr: the chroma-reference leaf was an intrabc block, so the
17025+ // group's one chroma unit is a frame copy at that DV too (its residual
17026+ // still reads the ordinary `Chroma4` coefficient tables -- libaom
17027+ // codes a chroma `tx_type` nowhere).
17028+ let mut ub = vec![0u16; 16];
17029+ mc::predict_with_filter(
17030+ &u.data, u.width, u.true_width, u.true_height,
17031+ mv_to_q4(cpx, dv.1, false), mv_to_q4(cpy, dv.0, false),
17032+ 4, 4, mc::InterpFilterKind::Bilinear, &mut ub, fctx,
17033+ );
17034+ let mut vb = vec![0u16; 16];
17035+ mc::predict_with_filter(
17036+ &v.data, v.width, v.true_width, v.true_height,
17037+ mv_to_q4(cpx, dv.1, false), mv_to_q4(cpy, dv.0, false),
17038+ 4, 4, mc::InterpFilterKind::Bilinear, &mut vb, fctx,
17039+ );
17040+ let chroma_around = neighbours.around_mi(leaf_mi, 8);
17041+ set_palette_pred(ub, fctx);
17042+ let ug = read_plane(
17043+ dec, cdfs, TxbSet::Chroma4, scan4, 1, chroma_around[1], DC_PRED, DC_PRED,
17044+ 0, group_reach, u, cpx, cpy, 4, TX4, base_q_idx,
17045+ None, None, None, smooth_neighbor_uv, fctx,
17046+ )?;
17047+ set_palette_pred(vb, fctx);
17048+ let vg = read_plane(
17049+ dec, cdfs, TxbSet::Chroma4, scan4, 2, chroma_around[2], DC_PRED, DC_PRED,
17050+ 0, group_reach, v, cpx, cpy, 4, TX4, base_q_idx,
17051+ None, None, None, smooth_neighbor_uv, fctx,
17052+ )?;
17053+ fctx.intrabc_chroma_tx.with(|c| c.set(None));
17054+ (ug, vg)
1666917055 } else {
1667017056 let ac = alpha.map(|_| cfl_src(gpx, gpy, 8));
1667117057 let chroma_around = neighbours.around_mi(leaf_mi, 8);
@@ -18877,6 +19263,26 @@ pub(crate) fn reduce_inherited_chroma_tx_type_flagged(t: TxType, w: usize, h: us
1887719263 if allowed.contains(&t) { t } else { DctDct }
1887819264 }
1887919265
19266+/// The [`TxbSet`] a resolved luma transform side reads its coefficient tables
19267+/// from for a block libaom's `is_inter_block` calls inter -- which an intrabc
19268+/// block is (`blockd.h:373`), so its `tx_type` comes off the inter `ext_tx`
19269+/// sets, never the mode-indexed intra ones ([`txbset_for`]).
19270+///
19271+/// 64 is only ever the 64x64-block, depth-0, corner-scanned case
19272+/// ([`TxbSet::Luma64`]); every other resolved side maps to its own matching
19273+/// set. `get_tx_set` (spec 5.11.48) only splits on `reduced_tx_set` at
19274+/// `TX_8X8`/`TX_4X4`: an intra `TX_16X16` always reads `TX_SET_INTRA_2`
19275+/// regardless of the flag (`av1_get_ext_tx_set_type`'s
19276+/// `tx_size_sqr == TX_16X16` branch ignores `use_reduced_set` once it is past
19277+/// the `TX_32X32`/reduced-set checks), so only the 8x8 and 4x4 cases have a
19278+/// second table ([`TxbSet::Luma8Inter`]/[`TxbSet::Luma4Inter`]).
19279+///
19280+/// lane-av1txr: the intrabc leaf sites used to call a near-duplicate
19281+/// `txbset_for_inter` whose `4` fell through to `Luma64` -- 32x32-class tables
19282+/// (a 1024-entry grid) handed to a 4x4 dequant, which panicked at
19283+/// `transform.rs`'s `inverse_transform_2d_typed_wh` the first time an intrabc
19284+/// 4x4 TU coded a non-zero coefficient (`allintra0`/cpu-used=0). The
19285+/// duplicate is gone; every inter-table site goes through this one mapping.
1888019286 fn inter_txbset_for(tx_px: usize, reduced_tx_set: bool) -> TxbSet {
1888119287 match tx_px {
1888219288 // lane-sb128c r1: a 128x128 inter block's own luma unit
@@ -18915,29 +19321,6 @@ fn scan_for<'a>(
1891519321 }
1891619322 }
1891719323
18918-/// The [`TxbSet`] a resolved luma transform side reads its coefficient tables
18919-/// from -- 64 is only ever the 64x64-block, depth-0, corner-scanned case
18920-/// ([`TxbSet::Luma64`]); every other resolved side maps to its own matching
18921-/// set. `get_tx_set` (spec 5.11.48) only splits on `reduced_tx_set` at
18922-/// `TX_8X8`/`TX_4X4`: an intra `TX_16X16` always reads `TX_SET_INTRA_2`
18923-/// regardless of the flag (`av1_get_ext_tx_set_type`'s
18924-/// `tx_size_sqr == TX_16X16` branch ignores `use_reduced_set` once it is past
18925-/// the `TX_32X32`/reduced-set checks), so only the 8x8 and 4x4 cases have a
18926-/// second table ([`TxbSet::Luma8Set1`]/[`TxbSet::Luma4Set1`]).
18927-/// [`txbset_for`], for a block libaom's `is_inter_block` calls inter -- which
18928-/// an intrabc block is (`blockd.h:373`), so its `tx_type` comes off the
18929-/// inter `ext_tx` sets, never the mode-indexed intra ones.
18930-fn txbset_for_inter(tx_px: usize, reduced_tx_set: bool) -> TxbSet {
18931- match tx_px {
18932- 64 => TxbSet::Luma64,
18933- 32 => TxbSet::Luma32Inter,
18934- 16 if reduced_tx_set => TxbSet::Luma16Inter,
18935- 16 => TxbSet::Luma16InterSet1,
18936- 8 if reduced_tx_set => TxbSet::Luma8Inter,
18937- 8 => TxbSet::Luma8InterSet1,
18938- _ => TxbSet::Luma64,
18939- }
18940-}
1894119324
1894219325 fn txbset_for(tx_px: usize, reduced_tx_set: bool) -> TxbSet {
1894319326 match tx_px {
@@ -22445,6 +22828,9 @@ pub(crate) fn decode_key_frame_tile_with_cdfs(
2244522828 );
2244622829 }
2244722830 let mut dec = SymbolDecoder::new(tile_bytes);
22831+ // lane-av1txr: spec 5.9.2's `disable_cdf_update` -- a frame that sets
22832+ // it codes every symbol against the tables it started with.
22833+ dec.set_cdf_update(!cdf_update_disabled(fctx));
2244822834 crate::census::register_cdfs(&cdfs);
2244922835 neighbours.start_tile(mi_row0 as usize, mi_col0 as usize, mi_col1 as usize, fctx);
2245022836 y.set_tile_origin(
@@ -24716,15 +25102,17 @@ fn read_intrabc_dv(
2471625102 cdfs: &mut Cdfs,
2471725103 mi_r: usize,
2471825104 mi_c: usize,
24719- side: usize, fctx: &crate::decode::FrameCtx,
25105+ // The block's own mi footprint (`av1_find_mv_refs` takes the real bsize,
25106+ // so a sub-8x8 `BLOCK_4X8`/`BLOCK_8X4` leaf scans a 1x2/2x1 neighbourhood
25107+ // -- lane-av1txr).
25108+ (n4_w, n4_h): (usize, usize), fctx: &crate::decode::FrameCtx,
2472025109 ) -> (i32, i32) {
2472125110 const INTRABC_DELAY_PIXELS: i32 = 256;
24722- let n4 = side / MI;
2472325111 let stack_pred = fctx.intrabc_mi_grid.with(|g| {
2472425112 let g = g.borrow();
2472525113 g.as_ref().map(|(grid, mi_cols, mi_rows)| {
2472625114 let stack = crate::mvstack::find_mv_stack(
24727- grid, mi_r, mi_c, n4, n4, 0, /* INTRA_FRAME */
25115+ grid, mi_r, mi_c, n4_w, n4_h, 0, /* INTRA_FRAME */
2472825116 *mi_cols, *mi_rows,
2472925117 );
2473025118 if stack.nearest_mv == (0, 0) {
@@ -24752,7 +25140,12 @@ fn read_intrabc_dv(
2475225140 }
2475325141 // "Ref DV should not have sub-pel" (`assign_dv`): floor to full pel.
2475425142 let pred = ((pred.0 >> 3) * 8, (pred.1 >> 3) * 8);
24755- read_mv(dec, &mut cdfs.dv_comp, &mut cdfs.dv_joint, pred, false, true)
25143+ let dv = read_mv(dec, &mut cdfs.dv_comp, &mut cdfs.dv_joint, pred, false, true);
25144+ if crate::envflags::env_flag!("EC_TRACE_MODE_STEP") {
25145+ let (rng, _) = dec.debug_state();
25146+ eprintln!("EC_DV mi_row={mi_r} mi_col={mi_c} dv_col={} dv_row={} rng={rng}", dv.1, dv.0);
25147+ }
25148+ dv
2475625149 }
2475725150
2475825151 /// A 1/8-pel motion vector component converted to the 1/16-pel offset
@@ -35164,6 +35557,9 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
3516435557 fctx.quant_deltas.with(|c| c.set(deltas));
3516535558 fctx.current_delta_lf.with(|c| c.set([0; 4]));
3516635559 let mut dec = SymbolDecoder::new(data);
35560+ // lane-av1txr: spec 5.9.2's `disable_cdf_update` -- a frame that sets
35561+ // it codes every symbol against the tables it started with.
35562+ dec.set_cdf_update(!cdf_update_disabled(fctx));
3516735563 crate::census::register_cdfs(&cdfs);
3516835564 // lane-comppin r9: tile-entry range, the earliest point comparable
3516935565 // against aomdec's own `r->ec.rng` right after `aom_reader_init` -- the
crates/ec-av1/src/msac.rsmodified+73 -0
@@ -305,6 +305,14 @@ pub struct SymbolDecoder<'a> {
305305 /// Bits left before the decoder starts padding with zeros (spec
306306 /// `SymbolMaxBits`), which goes negative at the end of the string.
307307 max_bits: i32,
308+ /// Whether [`SymbolDecoder::symbol`] adapts the CDF it reads (spec 8.3.2).
309+ /// `false` for a frame whose header sets `disable_cdf_update` -- libaom's
310+ /// tile entry (`decodeframe.c:2909`, `allow_update_cdf = allow_update_cdf
311+ /// && !cm->features.disable_cdf_update`) skips the adaptation there, so
312+ /// reading on would drift this decoder's tables away from the encoder's
313+ /// and desync mid-frame. Per-READER, not global: frames of one stream can
314+ /// decode on different worker threads.
315+ adapt: bool,
308316 }
309317
310318 impl Drop for SymbolDecoder<'_> {
@@ -326,6 +334,7 @@ impl<'a> SymbolDecoder<'a> {
326334 value: 0,
327335 range: 1 << 15,
328336 max_bits: 8 * data.len() as i32 - 15,
337+ adapt: true,
329338 };
330339 let num_bits = usize::min(data.len() * 8, 15) as u32;
331340 let buf = d.f(num_bits);
@@ -333,6 +342,15 @@ impl<'a> SymbolDecoder<'a> {
333342 d
334343 }
335344
345+ /// Spec 5.9.2's `disable_cdf_update`, the reader side: `false` (the
346+ /// default) adapts every CDF [`symbol`](Self::symbol) reads; `true`
347+ /// leaves each table exactly as it was read, matching libaom's
348+ /// `allow_update_cdf` (decodeframe.c:2909). Set once per tile reader by
349+ /// the frame's own header bit.
350+ pub(crate) fn set_cdf_update(&mut self, update: bool) {
351+ self.adapt = update;
352+ }
353+
336354 /// `f(n)`: the next `n` bits, most significant first, zero past the end.
337355 #[inline]
338356 fn f(&mut self, n: u32) -> u32 {
@@ -386,7 +404,14 @@ impl<'a> SymbolDecoder<'a> {
386404 // relaxed load.
387405 let t0 = if crate::census::armed() { self.tell_bits() } else { 0.0 };
388406 let s = self.symbol_fixed(cdf);
407+ // lane-av1txr: spec 5.9.2's `disable_cdf_update` -- a frame that sets
408+ // it codes every symbol against the tables it started with, so this
409+ // reader must leave them untouched too (libaom: `allow_update_cdf =
410+ // allow_update_cdf && !cm->features.disable_cdf_update`,
411+ // decodeframe.c:2909). The flag is per-reader (see `Self::adapt`).
412+ if self.adapt {
389413 update_cdf(cdf, s);
414+ }
390415 if crate::census::armed() {
391416 crate::census::charge(cdf.as_ptr() as usize, self.tell_bits() - t0);
392417 }
@@ -813,6 +838,54 @@ pub(crate) mod tests {
813838 assert_eq!(fast_cdfs[pick.min(14)], slow_cdfs[pick.min(14)], "cdf after item {i}");
814839 }
815840 }
841+
842+ /// lane-av1txr: spec 5.9.2's `disable_cdf_update`, the reader half --
843+ /// [`SymbolDecoder::set_cdf_update`]. A reader told not to adapt must
844+ /// reproduce a writer that never adapted
845+ /// ([`SymbolEncoder::symbol_fixed`]), and the DEFAULT reader must not: the
846+ /// flag is what keeps a real `aomenc --cdf-update-mode=0` stream in sync
847+ /// (its tiles desynced at the first multi-symbol block without it).
848+ #[test]
849+ fn a_reader_told_not_to_adapt_matches_a_non_adapting_writer() {
850+ let mut state = 0x2545_f491_4f6c_dd1du64;
851+ let mut enc = SymbolEncoder::new();
852+ let cdfs: Vec<Vec<u16>> = (2..=16).map(flat_cdf).collect();
853+ let mut written = Vec::new();
854+ for i in 0..600 {
855+ let pick = i % cdfs.len();
856+ let nsyms = pick + 2;
857+ let sym = (rng(&mut state) % nsyms as u64) as usize;
858+ enc.symbol_fixed(sym, &cdfs[pick]);
859+ written.push((pick, sym));
860+ }
861+ let payload = enc.finish();
862+
863+ let mut fixed = SymbolDecoder::new(&payload);
864+ fixed.set_cdf_update(false);
865+ let mut adapting = SymbolDecoder::new(&payload);
866+ let mut fixed_cdfs: Vec<Vec<u16>> = (2..=16).map(flat_cdf).collect();
867+ let mut adapting_cdfs: Vec<Vec<u16>> = (2..=16).map(flat_cdf).collect();
868+ let mut adapting_mismatches = 0usize;
869+ for (i, &(pick, sym)) in written.iter().enumerate() {
870+ assert_eq!(
871+ fixed.symbol(&mut fixed_cdfs[pick]),
872+ sym,
873+ "non-adapting reader, item {i} (pick {pick})"
874+ );
875+ if adapting.symbol(&mut adapting_cdfs[pick]) != sym {
876+ adapting_mismatches += 1;
877+ }
878+ }
879+ assert_eq!(
880+ fixed_cdfs,
881+ (2..=16).map(flat_cdf).collect::<Vec<_>>(),
882+ "the non-adapting reader still moved a table"
883+ );
884+ assert!(
885+ adapting_mismatches > 0,
886+ "the adaptation flag is inert: the default reader reproduced a non-adapting writer"
887+ );
888+ }
816889 }
817890
818891 /// Symbol-by-symbol writer/reader trace (`EC_AV1_SYMTRACE=<dir>`), the
crates/ec-av1/src/refusal_inventory.rsmodified+51 -14
@@ -64,8 +64,29 @@ const REFUSALS: &[&str] = &[
6464 // `every_read_intra_mode_call_site_hands_the_reader_a_palette_cache`,
6565 // which keeps that invariant now the refusal is gone).
6666 "intra block copy on a HORZ/VERT/1:4 rect intra strip (reconstruction is not ported at this shape)",
67- "a sub-8x8 leaf that uses intrabc (this reader has no block-vector path; the 8x8-and-up reader reconstructs one)",
67+ // lane-av1txr: `a sub-8x8 leaf that uses intrabc (…)` is GONE -- the
68+ // capability landed in this lane (4x4 / 4x8 / 8x4 intrabc leaves read the
69+ // DV and reconstruct a frame copy + the INTER residual; gates
70+ // `a_non_420_subsampled_sequence_header_is_refused_by_name`'s sibling
71+ // witnesses and the `warped.obu`/`allintra.obu` traces). Its census gate
72+ // (`a_sub8_leaf_census_over_intrabc_screen_streams_measures_the_sub8_refusal`)
73+ // still runs: it now reports `reached = 0` with the same non-vacuous
74+ // premise (allow_intrabc frames + decoded sub-8 leaves).
6875 "a bit depth of 12 (this decoder is gated at 8 and 10 only: warp/MC/wiener rounding shifts change at 12-bit and no 12-bit gate exists)",
76+ // lane-av1txr: the silent-garbage guard. A 4:4:4/4:2:2 stream used to
77+ // decode with no refusal and wrong pixels (every chroma extent is
78+ // hardcoded 4:2:0, the probe emits 4:2:0 planes only); it is now refused
79+ // at the sequence header. Gate:
80+ // `a_non_420_subsampled_sequence_header_is_refused_by_name`.
81+ "a chroma format other than 4:2:0 (subsampling_x/y != 1/1): every chroma extent in this decoder is hardcoded to 4:2:0 and the probe emits 4:2:0 planes only, so a 4:4:4/4:2:2 stream would decode silently wrong pixels",
82+ // lane-av1txr-r2: the third member of the same silent-garbage family.
83+ // `using_qmatrix`/`qm_y`/`qm_u`/`qm_v` are parsed by `ec-av1-syntax` but
84+ // read by NOTHING on the decode path -- dequantisation is `base_q_idx` +
85+ // the plane DC/AC deltas only -- so a real `aomenc --enable-qm=1` stream
86+ // decoded with no refusal and wrong pixels (measured: byte-diff vs ffmpeg
87+ // while the qm-off control is byte-exact). Refused at the frame header.
88+ // Gate: `a_frame_using_quantisation_matrices_is_refused_by_name`.
89+ "a frame using quantisation matrices (using_qmatrix=1): dequantisation here is base_q_idx plus the plane DC/AC deltas only, so qm_y/qm_u/qm_v would be ignored and the frame would decode silently wrong pixels",
6990 // lane-lossless/lane-lossless2: a lossless frame (base_q_idx 0) decodes
7091 // sample-exact, KEY and INTER -- TX_4X4 with the Walsh-Hadamard transform
7192 // on every plane, no `tx_type` symbol, `is_cfl_allowed` narrowed to a
@@ -286,11 +307,15 @@ const PROVEN: &[(&str, &str)] = &[
286307 "a tx_type symbol outside its CDF's own set: {t}",
287308 "every_tx_type_symbol_of_every_cdf_width_maps_into_its_own_set",
288309 ),
289- // lane-t900 r24, enumeration: the reader covers spec 5.11.40's whole value
290- // domain (`0..=(1 << 20) - 2`, both ends of every prefix length), so the
291- // refusal is outside it. What it still names is a bit pattern no encoder
292- // writes -- a 20th prefix bit of 0, which the spec's `length == 20` break
293- // makes a don't-care.
310+ // lane-t900 r24 + lane-av1txr RE-PIN, measured: the reader covers spec
311+ // 5.11.40's whole value domain (`0..=(1 << 20) - 2`, both ends of every
312+ // prefix length), so no CONFORMANT symbol stream reaches it -- but the
313+ // string IS reachable as a SYMPTOM: a frame this decoder desyncs on
314+ // (measured: a real libaom monochrome key frame, gate
315+ // `a_real_libaom_monochrome_key_frame_is_refused_by_name` at
316+ // `stream.rs`) leaves the reader mid-symbol and the next `read_golomb`
317+ // reports this tail. The claim below therefore pins the reader's value
318+ // coverage, NOT the string's unreachability.
294319 (
295320 "a Golomb tail longer than this decoder reads",
296321 "read_golomb_reads_every_value_a_conformant_stream_can_carry",
@@ -326,6 +351,22 @@ const PROVEN: &[(&str, &str)] = &[
326351 "a bit depth of 12 (this decoder is gated at 8 and 10 only: warp/MC/wiener rounding shifts change at 12-bit and no 12-bit gate exists)",
327352 "a_twelve_bit_sequence_header_is_refused_by_name",
328353 ),
354+ // lane-av1txr: the guard's own gate builds a profile-1 and a profile-2
355+ // sequence header by hand and asserts each refuses by name while the
356+ // profile-0 CONTROL still decodes -- the refusal is exercised, not merely
357+ // present.
358+ (
359+ "a chroma format other than 4:2:0 (subsampling_x/y != 1/1): every chroma extent in this decoder is hardcoded to 4:2:0 and the probe emits 4:2:0 planes only, so a 4:4:4/4:2:2 stream would decode silently wrong pixels",
360+ "a_non_420_subsampled_sequence_header_is_refused_by_name",
361+ ),
362+ // lane-av1txr-r2: the gate encodes the same source twice with real aomenc
363+ // (`--enable-qm=1` and `--enable-qm=0`), asserts the qm-off CONTROL decodes
364+ // and the qm-on stream is refused by name -- so the refusal is exercised
365+ // against the exact encoder path it names, not merely present.
366+ (
367+ "a frame using quantisation matrices (using_qmatrix=1): dequantisation here is base_q_idx plus the plane DC/AC deltas only, so qm_y/qm_u/qm_v would be ignored and the frame would decode silently wrong pixels",
368+ "a_frame_using_quantisation_matrices_is_refused_by_name",
369+ ),
329370 (
330371 "intra block copy on a HORZ/VERT/1:4 rect intra strip (reconstruction is not ported at this shape)",
331372 "a_real_aomenc_screen_key_frame_reads_use_intrabc_on_rect_strips",
@@ -409,14 +450,10 @@ const PROVEN: &[(&str, &str)] = &[
409450 "CfL, filter intra or a palette on a 128-root HORZ/VERT intra block (every one of their size gates caps at 64x64 or below, so none of these symbols exists there)",
410451 "no_128_root_half_reads_a_cfl_filter_intra_or_palette_symbol",
411452 ),
412- // lane-t900 r33, CENSUS: the `use_intrabc` symbol IS read at the sub-8
413- // reader for every sub-8x8 leaf of an `allow_intrabc` frame, and over the
414- // `--min-partition-size=4` exact-repetition screen arms every such symbol
415- // came back 0 while the frames decode pixel-exact.
416- (
417- "a sub-8x8 leaf that uses intrabc (this reader has no block-vector path; the 8x8-and-up reader reconstructs one)",
418- "a_sub8_leaf_census_over_intrabc_screen_streams_measures_the_sub8_refusal",
419- ),
453+ // lane-av1txr: the sub-8x8 intrabc refusal this census pinned is GONE (the
454+ // capability landed; see the note in `REFUSALS`). The census gate survives
455+ // as the witness that its premise is still exercised -- `reached` is 0 by
456+ // construction now.
420457 // lane-t900 r33, CENSUS: four quantisers of the recipe that reaches the
421458 // intrabc var-tx tree at all read it for 5 blocks in total, every one of
422459 // which resolved to a UNIFORM leaf size, with the frames pixel-exact.
crates/ec-av1/src/stream.rsmodified+211 -0
@@ -1252,6 +1252,13 @@ pub(crate) struct SeqFlags {
12521252 pub(crate) mono_chrome: bool,
12531253 pub(crate) order_hint_bits: u32,
12541254 pub(crate) mc_identity: bool,
1255+ /// lane-av1txr: `color_config.subsampling_x/y` (spec 5.5.2). The decoder
1256+ /// itself hardcodes 4:2:0 everywhere, so these exist only for the
1257+ /// sequence-level refusal in [`decode_stream_with`] -- nothing downstream
1258+ /// reads them. A monochrome header parses as 1,1, so `!(1,1)` singles out
1259+ /// 4:4:4 (profile 1 / sRGB) and 4:2:2 (profile 2 below 12-bit).
1260+ pub(crate) subsampling_x: u8,
1261+ pub(crate) subsampling_y: u8,
12551262 }
12561263
12571264 impl SeqFlags {
@@ -1269,6 +1276,8 @@ impl SeqFlags {
12691276 mono_chrome: seq.is_some_and(|s| s.color_config.mono_chrome),
12701277 order_hint_bits: seq.map_or(0, |s| s.order_hint_bits),
12711278 mc_identity: seq.is_some_and(|s| s.color_config.matrix_coefficients == 0),
1279+ subsampling_x: seq.map_or(1, |s| s.color_config.subsampling_x),
1280+ subsampling_y: seq.map_or(1, |s| s.color_config.subsampling_y),
12721281 }
12731282 }
12741283 }
@@ -1623,6 +1632,45 @@ fn decode_frame(
16231632 "a bit depth of 12 (this decoder is gated at 8 and 10 only: warp/MC/wiener rounding shifts change at 12-bit and no 12-bit gate exists)",
16241633 ));
16251634 }
1635+ // lane-av1txr: `color_config.subsampling_x/y` (spec 5.5.2) are parsed by
1636+ // `ec-av1-syntax` -- profile 1 forces 4:4:4, profile 2 below 12-bit forces
1637+ // 4:2:2, and the sRGB identity description forces full-range 4:4:4 -- but
1638+ // the decoder reads them NOWHERE: every chroma extent is hardcoded 4:2:0
1639+ // (`let (chroma_w, chroma_h) = (bw / 2, bh / 2)` at every rect site,
1640+ // `chroma_side = side / 2` in `decode_block`) and the probe emits 4:2:0
1641+ // planes only. Measured consequence: EVERY 4:4:4 stream desyncs at the
1642+ // first chroma transform (a444-cu6 block (0,0): aomdec reads
1643+ // `EC_COEFF plane=1 tx=TX_8X16` at rng 39857 where ours reads a 4-wide,
1644+ // 8-high 4:2:0 chroma block at the same rng) and then decodes pixels that
1645+ // are silently wrong. Refuse by name rather than return garbage. A
1646+ // `num_planes == 1` (monochrome) header keeps its parsed 1,1 and is
1647+ // unaffected. Gates: `a_non_420_subsampled_sequence_header_is_refused_by_
1648+ // name` below (hand-built profile 1/2 headers plus a real aomenc 4:4:4
1649+ // stream).
1650+ if seq.subsampling_x != 1 || seq.subsampling_y != 1 {
1651+ return Err(Error::unsupported(
1652+ "AV1 decode_stream",
1653+ "a chroma format other than 4:2:0 (subsampling_x/y != 1/1): every chroma extent in this decoder is hardcoded to 4:2:0 and the probe emits 4:2:0 planes only, so a 4:4:4/4:2:2 stream would decode silently wrong pixels",
1654+ ));
1655+ }
1656+ // lane-av1txr-r2: `quantization_params.using_qmatrix` (spec 5.9.12) is
1657+ // parsed by `ec-av1-syntax` along with `qm_y`/`qm_u`/`qm_v` (frame.rs
1658+ // :190-196, :1418-1426), but this decoder reads NONE of them: every
1659+ // dequantisation below is `base_q_idx` plus the plane DC/AC deltas only
1660+ // (`Quantizer::new`), so a stream that applies quantisation matrices
1661+ // dequantises every coefficient off the wrong table. The same
1662+ // silent-garbage class as the non-4:2:0 guard above. Measured: a real
1663+ // `aomenc --enable-qm=1` key frame (`using_qmatrix = 1`, `qm_y/u/v = 5`)
1664+ // decodes with NO refusal and its planes byte-differ from ffmpeg, while
1665+ // the `--enable-qm=0` control of the same source and recipe is
1666+ // byte-exact. Refuse by name rather than return garbage. Gate:
1667+ // `a_frame_using_quantisation_matrices_is_refused_by_name` below.
1668+ if header.quantization.using_qmatrix {
1669+ return Err(Error::unsupported(
1670+ "AV1 decode_stream",
1671+ "a frame using quantisation matrices (using_qmatrix=1): dequantisation here is base_q_idx plus the plane DC/AC deltas only, so qm_y/qm_u/qm_v would be ignored and the frame would decode silently wrong pixels",
1672+ ));
1673+ }
16261674 // lane-dpm1: a LOSSLESS frame (`qindex == 0` with zero deltas, spec 5.9.12)
16271675 // is a different tile syntax, and this decoder has none of it: libaom
16281676 // forces TX_4X4 with the WALSH-HADAMARD transform over every block (so no
@@ -1676,6 +1724,11 @@ fn decode_frame(
16761724 // the bit depth so a mono frame decoded on a thread that last saw a
16771725 // 4:2:0 one never inherits the wrong plane count.
16781726 crate::decode::set_mono(seq.mono_chrome, fctx);
1727+ // lane-av1txr: spec 5.9.2 `disable_cdf_update` -- a frame that sets it
1728+ // codes every tile symbol against the CDFs it started with, so the tile
1729+ // readers must not adapt (libaom `decodeframe.c:2909`:
1730+ // `allow_update_cdf = allow_update_cdf && !cm->features.disable_cdf_update`).
1731+ crate::decode::set_disable_cdf_update(header.disable_cdf_update, fctx);
16791732 // spec 7.16: this frame's superres state, for the filter chain --
16801733 // `decode.rs` upscales between CDEF and loop restoration and sizes
16811734 // the LR unit grid in upscaled coordinates. Cleared (0, 8) on an
@@ -2069,6 +2122,106 @@ pub(crate) mod tests {
20692122 );
20702123 }
20712124
2125+ /// lane-av1txr: a sequence header describing any chroma shape but 4:2:0 is
2126+ /// refused by name, because the decoder reconstructs every chroma extent
2127+ /// at hardcoded 4:2:0 (`bw / 2, bh / 2` at every rect site) and the probe
2128+ /// emits 4:2:0 planes only -- a 4:4:4 stream "decodes" into silently wrong
2129+ /// pixels (measured: a444-cu6's first chroma transform reads a 4x2-wide/
2130+ /// 8-high 4:2:0 chroma at aomdec's `TX_8X16` entry rng 39857, then
2131+ /// desyncs; every 4:4:4 fixture measured byte-differs from ffmpeg).
2132+ ///
2133+ /// Reachability, not a pixel claim: the header is written at the two
2134+ /// profiles that force a non-4:2:0 shape (spec 5.5.2 -- profile 1 forces
2135+ /// 4:4:4 with no coded bit; profile 2 below 12-bit forces 4:2:2) and the
2136+ /// tile is never reached. The 4:2:0 CONTROL below proves the refusal is
2137+ /// about the shape, not about this construction.
2138+ #[test]
2139+ fn a_non_420_subsampled_sequence_header_is_refused_by_name() {
2140+ const NAME: &str = "a_non_420_subsampled_sequence_header_is_refused_by_name";
2141+ const REFUSAL: &str = "a chroma format other than 4:2:0";
2142+ let fctx = &crate::decode::FrameCtx::new();
2143+ let picture = test_card(64, 64);
2144+ let encoded = encode_key_frame_with_ctx(&picture, 100, 0.5, fctx).unwrap();
2145+ for (profile, label, sx, sy) in [(1u8, "4:4:4", 0u8, 0u8), (2, "4:2:2", 1, 0)] {
2146+ let color = ec_av1_syntax::ColorConfig {
2147+ num_planes: 3,
2148+ subsampling_x: sx,
2149+ subsampling_y: sy,
2150+ ..Default::default()
2151+ };
2152+ let (mut seq, header) =
2153+ crate::encode::key_frame_headers_colour(64, 64, 100, color).unwrap();
2154+ seq.seq_profile = profile;
2155+ let mut stream = crate::sequence::sequence_header_obu(&seq).unwrap();
2156+ stream.extend_from_slice(
2157+ &crate::frame::frame_obu(&seq, &header, &encoded.tile).unwrap(),
2158+ );
2159+ let err = decode_stream(&stream).unwrap_err().to_string();
2160+ assert!(
2161+ err.contains(REFUSAL),
2162+ "{NAME}: expected the non-4:2:0 refusal for the {label} header, got: {err}"
2163+ );
2164+ }
2165+ // CONTROL: the same construction at profile 0 (4:2:0) still decodes.
2166+ let (seq, header) = crate::encode::key_frame_headers(64, 64, 100).unwrap();
2167+ let mut stream = crate::sequence::sequence_header_obu(&seq).unwrap();
2168+ stream.extend_from_slice(&crate::frame::frame_obu(&seq, &header, &encoded.tile).unwrap());
2169+ let frames = decode_stream(&stream).expect("the 4:2:0 control must decode");
2170+ assert_eq!(frames.len(), 1, "{NAME}: the 4:2:0 control decoded no frame");
2171+ }
2172+
2173+ /// lane-av1txr-r2: a frame using quantisation matrices is refused by name
2174+ /// -- the THIRD member of the silent-garbage family the non-4:2:0 gate
2175+ /// above opened (the verifier's census miss).
2176+ ///
2177+ /// `using_qmatrix`/`qm_y`/`qm_u`/`qm_v` are parsed by `ec-av1-syntax`
2178+ /// (frame.rs:190-196, :1418-1426) but have NO consumer anywhere on the
2179+ /// decode path -- every dequantisation is `base_q_idx` plus the plane
2180+ /// DC/AC deltas only. Measured on a real aomenc pair (same source and
2181+ /// recipe, only `--enable-qm` flipped): the qm-OFF control decodes
2182+ /// byte-exact vs ffmpeg, the qm-ON stream used to decode with NO refusal
2183+ /// and byte-differ from ffmpeg (silent garbage; class
2184+ /// `refusal-hides-a-defect` read the other way -- a silent wrong decode
2185+ /// is worse than a named gap).
2186+ ///
2187+ /// Both arms are real encoder output, so this is a reachability gate, not
2188+ /// a hand-built construction: the qm-on arm carries `using_qmatrix = 1`
2189+ /// (`qm_y/u/v = 5` on the measured fixture) and the refusal names the
2190+ /// field rather than desyncing.
2191+ #[test]
2192+ fn a_frame_using_quantisation_matrices_is_refused_by_name() {
2193+ const NAME: &str = "a_frame_using_quantisation_matrices_is_refused_by_name";
2194+ const REFUSAL: &str = "a frame using quantisation matrices";
2195+ if !have_ffmpeg() || !have_aomenc() {
2196+ eprintln!(
2197+ "SKIP {NAME}: needs ffmpeg + an aomenc oracle at {}",
2198+ aomenc_path().display()
2199+ );
2200+ return;
2201+ }
2202+ // CONTROL: the same source and recipe with quantisation matrices OFF
2203+ // still decodes -- so the refusal below is about the qm bit, not about
2204+ // the source or the encoder settings.
2205+ let (_, control) = census_attempt("testsrc2", 128, 96, 3, &["--enable-qm=0"]);
2206+ let frames = control.unwrap_or_else(|e| {
2207+ panic!("{NAME}: the --enable-qm=0 control must decode, got: {e}")
2208+ });
2209+ assert!(frames >= 1, "{NAME}: the qm-off control decoded no frame");
2210+ // The qm-on stream is the new refusal.
2211+ let (_, qm) = census_attempt("testsrc2", 128, 96, 3, &["--enable-qm=1"]);
2212+ let err = qm.err().unwrap_or_else(|| {
2213+ panic!("{NAME}: the --enable-qm=1 stream now decodes -- flip this gate to a witness")
2214+ });
2215+ assert!(
2216+ err.contains(REFUSAL),
2217+ "{NAME}: the qm-on stream stopped without the named refusal {REFUSAL:?} \
2218+ -- re-measure before trusting this gate. got: {err}"
2219+ );
2220+ eprintln!(
2221+ "{NAME}: qm-off control {frames} frames, qm-on refused by name ({REFUSAL})"
2222+ );
2223+ }
2224+
20722225 /// lane-av1mono: the INVERSE of the pilot's
20732226 /// `a_real_libaom_monochrome_key_frame_is_refused_by_name`, which the
20742227 /// pilot's merge `d71084ae` landed on `main` (after this lane's base
@@ -6930,6 +7083,64 @@ pub(crate) mod tests {
69307083 }
69317084 }
69327085
7086+ /// lane-av1txr: a real `aomenc --cdf-update-mode=0` stream (spec 5.9.2
7087+ /// `disable_cdf_update`) decodes SAMPLE-EXACT. The read that was missing:
7088+ /// `stream.rs` never threaded the header bit, so the tile readers adapted
7089+ /// every symbol of a frame the encoder coded against fixed tables -- the
7090+ /// stream desynced at its first multi-symbol block and the pixels differed
7091+ /// from byte 6 (`EC_PROBE_OUT` vs `ffmpeg -pix_fmt yuv420p`, measured
7092+ /// 2026-09-20). The msac unit gate
7093+ /// (`a_reader_told_not_to_adapt_matches_a_non_adapting_writer`) pins the
7094+ /// mechanism; this one pins the wiring end to end.
7095+ #[test]
7096+ fn a_real_aomenc_stream_with_cdf_update_disabled_decodes_pixel_exact() {
7097+ const NAME: &str = "a_real_aomenc_stream_with_cdf_update_disabled_decodes_pixel_exact";
7098+ if !have_ffmpeg() || !have_aomenc() {
7099+ eprintln!("SKIP {NAME}: no ffmpeg/aomenc");
7100+ return;
7101+ }
7102+ let (width, height) = (256usize, 192usize);
7103+ let stream = screen_intrabc_stream_with(
7104+ "testsrc2=size=256x192:rate=25",
7105+ "45",
7106+ "1",
7107+ false,
7108+ true,
7109+ &["--cdf-update-mode=0", "--limit=3"],
7110+ );
7111+ // Non-vacuity: the fixture must really code the bit on every frame.
7112+ let mut parser = Av1Parser::new();
7113+ let mut pos = 0usize;
7114+ let mut headers = 0usize;
7115+ while pos < stream.len() {
7116+ let Ok(obu) = parser.parse_obu(&stream[pos..]) else {
7117+ break;
7118+ };
7119+ pos += obu.total_size.max(1);
7120+ let header = match &obu.kind {
7121+ ObuKind::Frame(h, _) | ObuKind::FrameHeader(h) => h,
7122+ _ => continue,
7123+ };
7124+ assert!(
7125+ header.disable_cdf_update,
7126+ "{NAME}: frame {headers} does not carry disable_cdf_update -- aomenc ignored \
7127+ --cdf-update-mode=0"
7128+ );
7129+ headers += 1;
7130+ }
7131+ assert!(headers >= 3, "{NAME}: only {headers} frame headers in the fixture");
7132+ let frames = decode_stream(&stream).unwrap_or_else(|e| panic!("{NAME}: {e}"));
7133+ let theirs = ffmpeg_decode_sequence(&stream, width, height, frames.len());
7134+ assert_eq!(frames.len(), theirs.len(), "{NAME}: frame count");
7135+ for (i, (ours, ref_frame)) in frames.iter().zip(theirs.iter()).enumerate() {
7136+ assert!(
7137+ ours.y == ref_frame.y && ours.u == ref_frame.u && ours.v == ref_frame.v,
7138+ "{NAME}: frame {i} does not match ffmpeg"
7139+ );
7140+ }
7141+ eprintln!("{NAME}: {headers} disable_cdf_update frame headers, all frames sample-exact");
7142+ }
7143+
69337144 /// lane-kf900 r4, the gate for the two lifted palette refusals ("a 1:4
69347145 /// rect strip that actually uses a palette (reconstruction is not ported
69357146 /// at this shape)" and "a palette block on a HORZ/VERT intra strip below
lanes/av1txrouting.report.mdadded+543 -0
@@ -0,0 +1,543 @@
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`.
182+
183+---
184+
185+## 9. Continuation (2026-09-20, second lane pass)
186+
187+Five defects fixed, each proven by a first-divergence move and/or a gate. **Warped
188+is still NOT byte-exact** (§9.4) and `allintra`/`allintra0` still stop at NAMED
189+refusals that belong to the 1:4-rect-strip lane (§9.3). Honest status first.
190+
191+### 9.1 Silent-garbage guard: non-4:2:0 chroma is refused by name
192+
193+`stream.rs`'s `decode_stream` now refuses `seq.subsampling_x != 1 ||
194+seq.subsampling_y != 1` (threaded through `SeqFlags::subsampling_x/y`). A
195+monochrome header parses as 1,1, so it is untouched (the mono lane's stream and
196+its tripwire keep their meaning).
197+
198+Evidence:
199+- `a_non_420_subsampled_sequence_header_is_refused_by_name` (stream.rs tests):
200+ a hand-built profile-1 (4:4:4) and profile-2 (4:2:2) header each refuse with
201+ the named string, and the profile-0 CONTROL still decodes — so the gate is
202+ about the shape, not the construction.
203+- Real encoder stream: `aomenc` auto-promotes to profile 1 for `yuv444p` input;
204+ `EC_PROBE_OUT` vs `ffmpeg -pix_fmt yuv444p` on that stream **refuses by name**
205+ where the same code path used to decode silently wrong pixels.
206+
207+### 9.2 Parsed-but-unread pixel-affecting header field sweep
208+
209+A per-field census of every `SequenceHeader` / `ColorConfig` /
210+`QuantizationParams` / `FrameHeader` field against the decoder's PRODUCTION
211+reads (`crates/ec-av1/src/{stream,decode}.rs`, test modules excluded; each row
212+re-derivable by `grep -n "\.<field>\b"`) found **three** pixel-affecting fields
213+the decoder never consumed. All three are now closed:
214+
215+1. `subsampling_x/y` — §9.1 (refusal).
216+2. **`disable_cdf_update`** (the second find): spec 8.3.2 skips ALL per-symbol
217+ CDF adaptation when set, and libaom's tile entry does exactly that
218+ (`decodeframe.c:2909`, `allow_update_cdf && !disable_cdf_update`). The
219+ decoder adapted unconditionally. Fixed at the one authoring point:
220+ `msac::SymbolDecoder::adapt` (per READER, not global — frames decode on
221+ different workers) + `FrameCtx::disable_cdf_update` + one line in
222+ `decode_frame`.
223+
224+ Evidence, both directions:
225+ - `a_real_aomenc_stream_with_cdf_update_disabled_decodes_pixel_exact`
226+ (real `aomenc --cdf-update-mode=0`, 3 frames): asserts every frame header
227+ carries the bit, then compares all planes against ffmpeg. Green.
228+ - fail-pre-fix, measured: with `set_cdf_update` forced ON the SAME stream
229+ differs from ffmpeg at **byte 6** (`OK: 3 frames` but wrong pixels).
230+ - `a_reader_told_not_to_adapt_matches_a_non_adapting_writer` (msac unit):
231+ a non-adapting reader reproduces a non-adapting writer symbol-for-symbol
232+ and its tables stay untouched; the default reader does not (flag
233+ load-bearing).
234+
235+3. **`using_qmatrix` + `qm_y`/`qm_u`/`qm_v`** — the census MISS this section
236+ previously claimed did not exist (found by the re-verifier; lane-av1txr-r2).
237+ Parsed by `ec-av1-syntax` (`frame.rs:190-196`, `:1418-1426`), read by
238+ NOTHING on the decode path: every dequantisation is `base_q_idx` plus the
239+ plane DC/AC deltas. A real `aomenc --enable-qm=1` stream
240+ (`using_qmatrix = 1`, `qm_y/u/v = 5` on the measured fixture) decoded with NO
241+ refusal and byte-differed from ffmpeg, while the `--enable-qm=0` control of
242+ the same source and recipe was byte-exact — the same silent-garbage class as
243+ §9.1. Refused by name at the frame header (`stream.rs`, beside the non-4:2:0
244+ guard); gate `a_frame_using_quantisation_matrices_is_refused_by_name`, which
245+ fails pre-fix (with the guard removed it panics "the --enable-qm=1 stream now
246+ decodes").
247+
248+The table below is the audit artifact the re-verifier asked for: every field of
249+those four structs, its first production read, or its disposition when unread.
250+It is the source of the "three" above, so the census is checkable rather than a
251+grep claim. Dispositions: `consumed` (a decoder read exists),
252+`refused` (a named guard refuses the case), `parser-forced` (a seq flag
253+`ec-av1-syntax` folds into a frame-header field the decoder DOES read),
254+`parser-internal` (used only while reading the header), `metadata` (no pixel
255+effect), `sibling-lane` (`mono_chrome`/`num_planes`, lane-av1-mono), and
256+`internal-equivalent` (`ref_order_hint`/`order_hints`, which the decoder
257+rebuilds from its own saved reference state — `stream.rs:1344`).
258+
259+
260+**SequenceHeader**
261+
262+| field | disposition | first prod read |
263+|---|---|---|
264+| `seq_profile` | parser-internal | sequence.rs parse; effect surfaced via subsampling_x/y + bit_depth guards |
265+| `still_picture` | parser-internal | parse branch |
266+| `reduced_still_picture_header` | parser-internal | parse branch |
267+| `timing_info` | metadata | display timing |
268+| `decoder_model_info` | metadata | display timing |
269+| `initial_display_delay_present_flag` | metadata | display timing |
270+| `operating_points` | metadata | op selection; decoder decodes all |
271+| `operating_point` | metadata | op selection |
272+| `operating_point_idc` | metadata | op selection |
273+| `frame_width_bits` | parser-internal | frame-size read width |
274+| `frame_height_bits` | parser-internal | frame-size read width |
275+| `max_frame_width` | parser-internal | frame-size validation |
276+| `max_frame_height` | parser-internal | frame-size validation |
277+| `frame_id_numbers_present_flag` | parser-internal | display_frame_id read |
278+| `delta_frame_id_length` | parser-internal | display_frame_id read |
279+| `additional_frame_id_length` | parser-internal | display_frame_id read |
280+| `use_128x128_superblock` | consumed | `stream.rs:1267` |
281+| `enable_filter_intra` | consumed | `stream.rs:1261` |
282+| `enable_intra_edge_filter` | consumed | `stream.rs:1263` |
283+| `enable_interintra_compound` | consumed | `stream.rs:1266` |
284+| `enable_masked_compound` | consumed | `stream.rs:1264` |
285+| `enable_warped_motion` | parser-forced | syntax/frame.rs:1053 -> h.allow_warped_motion |
286+| `enable_dual_filter` | consumed | `stream.rs:1262` |
287+| `enable_order_hint` | parser-forced | syntax/frame.rs:919,1068 -> order_hint_bits / ref_frame_sign_bias |
288+| `enable_jnt_comp` | consumed | `stream.rs:1265` |
289+| `enable_ref_frame_mvs` | parser-forced | syntax/frame.rs:970 -> h.use_ref_frame_mvs |
290+| `seq_force_screen_content_tools` | parser-forced | syntax/frame.rs:853 -> h.allow_screen_content_tools |
291+| `seq_force_integer_mv` | parser-forced | syntax/frame.rs:859 -> h.force_integer_mv |
292+| `order_hint_bits` | consumed | `stream.rs:1269` |
293+| `enable_superres` | parser-forced | syntax/frame.rs:1100 -> h.use_superres |
294+| `enable_cdef` | parser-forced | syntax/frame.rs:1576 -> h.cdef |
295+| `enable_restoration` | parser-forced | syntax/frame.rs:1605 -> h.loop_restoration |
296+| `color_config` | consumed | `stream.rs:724` |
297+| `film_grain_params_present` | parser-forced | syntax/frame.rs:809,1866 -> h.film_grain |
298+
299+**ColorConfig**
300+
301+| field | disposition | first prod read |
302+|---|---|---|
303+| `bit_depth` | consumed | `stream.rs:678` |
304+| `mono_chrome` | sibling-lane | lane-av1-mono; a mono stream is currently refused by the Golomb tripwire |
305+| `num_planes` | sibling-lane | lane-av1-mono |
306+| `color_primaries` | metadata | H.273 display |
307+| `transfer_characteristics` | metadata | H.273 display |
308+| `matrix_coefficients` | consumed | `stream.rs:727` |
309+| `color_range` | metadata | output range; probe emits limited-range 4:2:0 |
310+| `subsampling_x` | consumed | `stream.rs:1248` |
311+| `subsampling_y` | consumed | `stream.rs:1272` |
312+| `chroma_sample_position` | metadata | display |
313+| `separate_uv_delta_q` | parser-internal | decides qm_v coding, syntax/frame.rs:1422 |
314+
315+**FrameHeader**
316+
317+| field | disposition | first prod read |
318+|---|---|---|
319+| `show_existing_frame` | consumed | `stream.rs:603` |
320+| `frame_to_show_map_idx` | consumed | `stream.rs:624` |
321+| `frame_presentation_time` | metadata | decoder-model bookkeeping |
322+| `display_frame_id` | metadata | frame-id bookkeeping |
323+| `frame_type` | consumed | `stream.rs:853` |
324+| `frame_is_intra` | parser-internal | derived from frame_type; decoder reads frame_type/show_frame |
325+| `show_frame` | consumed | `stream.rs:892` |
326+| `showable_frame` | metadata | output eligibility; film grain parse uses it |
327+| `error_resilient_mode` | parser-internal | controls header reads (refresh flags / primary_ref) |
328+| `disable_cdf_update` | consumed | `stream.rs:1687` |
329+| `allow_screen_content_tools` | consumed | `stream.rs:1796` |
330+| `force_integer_mv` | consumed | `stream.rs:1833` |
331+| `current_frame_id` | metadata | frame-id bookkeeping |
332+| `frame_size_override_flag` | parser-internal | frame-size read |
333+| `order_hint` | consumed | `stream.rs:989` |
334+| `primary_ref_frame` | consumed | `stream.rs:1312` |
335+| `buffer_removal_time` | metadata | decoder-model bookkeeping |
336+| `refresh_frame_flags` | consumed | `stream.rs:644` |
337+| `ref_order_hint` | internal-equivalent | decoder keeps its own ref_order_hints from saved ref state (stream.rs:1344) |
338+| `frame_width` | consumed | `stream.rs:1786` |
339+| `frame_height` | consumed | `stream.rs:1787` |
340+| `upscaled_width` | consumed | `stream.rs:1694` |
341+| `render_width` | metadata | deliberate (encode.rs:15917-15921); display crop only |
342+| `render_height` | metadata | deliberate (encode.rs:15917-15921); display crop only |
343+| `use_superres` | consumed | `stream.rs:1694` |
344+| `superres_denom` | consumed | `stream.rs:1695` |
345+| `mi_cols` | consumed | `stream.rs:1325` |
346+| `mi_rows` | consumed | `stream.rs:1324` |
347+| `allow_intrabc` | consumed | `stream.rs:1797` |
348+| `frame_refs_short_signaling` | parser-internal | parser derives ref_frame_idx (consumed) |
349+| `ref_frame_idx` | consumed | `stream.rs:876` |
350+| `delta_frame_id` | metadata | frame-id bookkeeping |
351+| `allow_high_precision_mv` | consumed | `stream.rs:1877` |
352+| `interpolation_filter` | consumed | `stream.rs:1703` |
353+| `is_motion_mode_switchable` | consumed | `stream.rs:1744` |
354+| `use_ref_frame_mvs` | consumed | `stream.rs:1317` |
355+| `order_hints` | internal-equivalent | derived by decoder from ref_order_hints |
356+| `ref_frame_sign_bias` | consumed | `stream.rs:1879` |
357+| `disable_frame_end_update_cdf` | consumed | `stream.rs:1369` |
358+| `tile_info` | consumed | `stream.rs:759` |
359+| `quantization` | consumed | `stream.rs:1370` |
360+| `segmentation` | consumed | `stream.rs:1405` |
361+| `delta` | consumed | `stream.rs:1798` |
362+| `coded_lossless` | parser-internal | computed by parser; h.lossless carries it (consumed) |
363+| `all_lossless` | parser-internal | computed by parser |
364+| `lossless` | consumed | `stream.rs:1671` |
365+| `loop_filter` | consumed | `stream.rs:1791` |
366+| `cdef` | consumed | `stream.rs:1747` |
367+| `loop_restoration` | consumed | `stream.rs:1748` |
368+| `tx_mode` | consumed | `stream.rs:1740` |
369+| `reference_select` | consumed | `stream.rs:1887` |
370+| `skip_mode_present` | consumed | `stream.rs:1746` |
371+| `skip_mode_frame` | consumed | `stream.rs:1892` |
372+| `allow_warped_motion` | consumed | `stream.rs:1743` |
373+| `reduced_tx_set` | consumed | `stream.rs:1742` |
374+| `global_motion` | consumed | `stream.rs:1880` |
375+| `film_grain` | consumed | `stream.rs:666` |
376+| `header_bits` | parser-internal | tile-group byte alignment |
377+
378+**QuantizationParams**
379+
380+| field | disposition | first prod read |
381+|---|---|---|
382+| `base_q_idx` | consumed | `stream.rs:1370` |
383+| `delta_q_y_dc` | consumed | `stream.rs:1780` |
384+| `delta_q_u_dc` | consumed | `stream.rs:1781` |
385+| `delta_q_u_ac` | consumed | `stream.rs:1782` |
386+| `delta_q_v_dc` | consumed | `stream.rs:1783` |
387+| `delta_q_v_ac` | consumed | `stream.rs:1784` |
388+| `using_qmatrix` | refused | read at `stream.rs:1634` and refused by name |
389+| `qm_y` | refused | only present under using_qmatrix=1, now refused by name |
390+| `qm_u` | refused | only present under using_qmatrix=1, now refused by name |
391+| `qm_v` | refused | only present under using_qmatrix=1, now refused by name |
392+
393+### 9.3 transform.rs:1134 panic — ROOT-CAUSED AND FIXED (not a refusal)
394+
395+`txbset_for_inter` was a near-duplicate of `inter_txbset_for` whose `4` fell
396+through to `TxbSet::Luma64`: a 4x4 intrabc/inter TU read 32x32-class tables (a
397+1024-entry grid) and panicked in `inverse_transform_2d_typed_wh` the first time
398+such a TU coded a non-zero coefficient (`allintra0`, cpu-used 0). libaom reads a
399+4x4 grid with the 16-symbol INTER ext-tx set there (`EXT_TX_SET_ALL16` /
400+`_DTT4_IDTX` reduced). Fix: delete the duplicate, route all inter-table sites
401+through `inter_txbset_for` (which already had the 4 arms). Result: **no panic**;
402+`allintra0` now stops at the EXISTING named refusal "an intrabc block whose
403+var-tx tree resolved to mixed leaf transform sizes" (`decode.rs:14327`) — a
404+lane-of-its-own gap, not a crash.
405+
406+### 9.4 warped: four more defects out of the way, still not byte-exact
407+
408+Ladder evidence (`EC_TRACE_MODE_STEP=1` on the instrumented aomdec vs ours,
409+rng-ladder subsequence walk, frame 0). First divergence moved
410+**(38,60) → (38,62) → (46,66)**; consuming steps matched 916 → 1119 → 1349 of
411+aomdec's 2204 before the next divergence.
412+
413+1. **Rect intrabc leaves read no transform symbol** (the charter's named stop):
414+ `block_signals_txsize` is `bsize > BLOCK_4X4` (`blockd.h:1027`), TRUE at
415+ `BLOCK_4X8`/`BLOCK_8X4` — so an UNSKIPPED intrabc rect leaf reads the INTER
416+ var-tx tree (`read_tx_size_vartx` over `max_txsize_rect_lookup[BLOCK_4X8] ==
417+ TX_4X8`), not nothing. Fixed in `decode_leaf_rect8`'s intrabc arm
418+ (`read_var_tx_size` with the rect entry + per-4x4-TU residual/reconstruction
419+ when the tree splits, `RECT_INTRABC_VARTX_HITS` counter, probe line
420+ `rect_intrabc_vartx`). aomdec's `EC_VARTX mi_row=37 mi_col=62 bsize=2
421+ tx_size=6 ctx=19 rng=37745` is now reproduced exactly.
422+2. **Sub-8x8 leaves never published the TXFM context bands**: libaom runs
423+ `set_txfm_ctxs` for EVERY block; `decode_leaf_split4`/`decode_leaf_rect8` had
424+ no write, so an intrabc block's `txfm_partition_context` read a stale 8 where
425+ aomdec read 4 (ctx 18 vs 19). Fixed (+ unit bug caught on the way: the rect
426+ helper takes PIXELS for the parent span, not mi).
427+3. **`intrabc_dv` slot leak**: `read_intra_mode_sub8` armed the frame slot and
428+ the sub-8x8 callers never took it, so the NEXT 8x8+ block inherited the
429+ vector and read an inter var-tx symbol where libaom read an intra
430+ `tx_depth`. The DV already travels in the return value; the arm is gone.
431+4. (9.3's table fix also feeds this path: the split rect leaf's 4x4 TUs read
432+ `Luma4Inter`/`Set1`.)
433+
434+**Remaining first divergence (frame 0, mi (46,66), 8x8 intra block):**
435+`tx_depth ctx` ours 0 vs aomdec 1. Root cause, localised: the key-frame
436+square/leaf tx-depth context is read through `tx_size_context` — the DEBLOCK
437+grid approximation — while libaom's `get_tx_size_context` (`pred_common.h:342`)
438+reads the **TXFM bands** with the inter-neighbour block-size override. The
439+approximation only coincides while every neighbour codes one whole-block
440+transform, "which is exactly what `TxMode::Select` ends" (the helper's own
441+doc) — warped's key frame IS `TxMode::Select` with intrabc. The fix is the
442+lane's next step and is NOT small: `publish_txfm_bands_if_in_inter` returns
443+early on a key frame, so switching the read to libaom's formula requires
444+publishing the bands from EVERY key-frame block (strips included) in the same
445+change, or currently-byte-exact streams can regress. Left unpushed.
446+
447+Consequences for the rest of the corpus: `allintra` and `warped` both now stop
448+at `decode.rs:9155` "intra block copy on a HORZ/VERT/1:4 rect intra strip
449+(reconstruction is not ported at this shape)" — after **16 more mi rows** of
450+frame 0 than before the fix (was (38,60), now (54,64)). That refusal is lane 3's
451+and is left standing.
452+
453+### 9.5 Inventory re-pin (done)
454+
455+- The sub-8x8-intrabc refusal no longer exists (the capability landed), so its
456+ `REFUSALS` entry is replaced by a note and its claims-table pair is retired;
457+ the census gate stays as the non-vacuous premise witness (`reached = 0` now).
458+- The Golomb entry is RE-PINNED with the measurement: the reader covers the
459+ whole legal value domain, but the string is reachable as a DESYNC SYMPTOM
460+ (real monochrome libaom stream, `stream.rs`'s mono tripwire) — the claim pins
461+ value coverage, not unreachability.
462+
463+### 9.6 Gates
464+
465+- `cargo test -p ec-av1 --lib -- <the three new gates>`: 3 passed, 0 warnings.
466+- Full `cargo test -p ec-av1 --lib` and `cargo check -p ec-av1 --all-targets`
467+ were launched at the end of this pass; see the commit message / next session
468+ for their totals (baseline 592/0/60).
469+- `cargo build --release -p ec-av1 --example decode_probe`: 0 warnings.
470+
471+### 9.7 Next steps (ordered)
472+
473+1. Read the key-frame tx-depth context from the TXFM bands (libaom
474+ `get_tx_size_context`) and publish the bands from every key-frame block —
475+ then re-run the (46,66) ladder rung and the corpus sweep (§5's tripwires
476+ included).
477+2. `allintra`'s 1:4 rect-strip intrabc (lane 3) and the mixed-leaf var-tx
478+ refusal (the new stop for `allintra0`).
479+3. Add the 4x8/8x4 intrabc witnesses to the media-gated corpus (a real stream
480+ that codes one: `warped.obu` reaches `RECT_INTRABC_VARTX_HITS == 1` and now
481+ decodes past the old divergence).
482+
483+## 10. Continuation r2 (2026-09-20): the refuted census + the third silent-garbage member
484+
485+The re-verifier REFUTED §9.2's "exactly two parsed-but-never-read
486+pixel-affecting fields". A third existed, and it was the same silent-garbage
487+class §9.1 had just closed for 4:4:4. This round is that finding.
488+
489+### 10.1 The fix: `using_qmatrix` refused by name
490+
491+`QuantizationParams.using_qmatrix` + `qm_y`/`qm_u`/`qm_v` are parsed
492+(`ec-av1-syntax/src/frame.rs:190-196`, `:1418-1426`) and read by NOTHING on the
493+decode path — dequantisation is `base_q_idx` + the plane DC/AC deltas only. A
494+spec-legal `aomenc --enable-qm=1` stream therefore decoded into silently wrong
495+pixels.
496+
497+`stream.rs`'s `decode_stream` now refuses it at the frame header, beside the
498+non-4:2:0 guard:
499+
500+```
501+if header.quantization.using_qmatrix {
502+ return Err(Error::unsupported(
503+ "AV1 decode_stream",
504+ "a frame using quantisation matrices (using_qmatrix=1): dequantisation here is \
505+ base_q_idx plus the plane DC/AC deltas only, so qm_y/qm_u/qm_v would be ignored \
506+ and the frame would decode silently wrong pixels",
507+ ));
508+}
509+```
510+
511+### 10.2 Evidence
512+
513+- Measured pair (real aomenc, same source / recipe, only `--enable-qm` flipped;
514+ `~/.cache/aom-oracle/build/aomenc`): the qm-OFF stream is byte-exact vs
515+ ffmpeg; the qm-ON stream (`using_qmatrix = 1`, `qm_y/u/v = 5`) decoded with NO
516+ refusal and its planes byte-differed from ffmpeg.
517+ `EC_AV1_PIN=<qm.obu> ... scratch_isolate_pinned_mismatch --ignored` prints the
518+ parsed `using_qmatrix = true` on every frame.
519+- Gate `a_frame_using_quantisation_matrices_is_refused_by_name` (stream.rs):
520+ encodes `--enable-qm=0` and `--enable-qm=1` with real aomenc via
521+ `census_attempt`, asserts the qm-off CONTROL decodes and the qm-on stream
522+ refuses by name.
523+- **Fail-pre-fix**, measured: with the guard removed the gate panics
524+ `the --enable-qm=1 stream now decodes -- flip this gate to a witness` (and the
525+ decode_probe pair above shows those bytes are wrong).
526+- Inventory: new `REFUSALS` entry + `PROVEN` pair; P3 doc fix —
527+ `cdf_state.rs`'s `wide()` comment named the deleted `txbset_for_inter`, now
528+ `inter_txbset_for`.
529+
530+### 10.3 Gates (this round)
531+
532+- `cargo test -p ec-av1 --lib -- refusal_inventory <the new gate>
533+ a_reader_told_not_to_adapt a_non_420`: 16 passed, 0 failed.
534+- fail-pre-fix run (guard removed): 1 failed, 0 passed — the gate is
535+ non-vacuous.
536+- `cargo check -p ec-av1 --all-targets`: 0 warnings.
537+- The full 595-test suite re-run belongs to the re-verifier.
538+
539+### 10.4 Next steps
540+
541+Unchanged from §9.7. This round closes the census hole; the warped key-frame
542+tx-depth context (§9.4) and the 1:4-rect-strip intrabc (lane 3) are still open.
543+