diff --git a/crates/ec-av1/examples/decode_probe.rs b/crates/ec-av1/examples/decode_probe.rs index 771ade05..2ce169ee 100644 --- a/crates/ec-av1/examples/decode_probe.rs +++ b/crates/ec-av1/examples/decode_probe.rs @@ -92,6 +92,12 @@ fn main() { println!("inter16_1to4: horz4={h4} vert4={v4} chroma_pairs={pairs} sub8_pieces={sub8}"); let leaf4 = ec_av1::stream::vartx_rect_leaf4_hits(); println!("vartx_rect_leaf4: 8x4={} 4x8={}", leaf4[0], leaf4[1]); + // lane-av1txr: intrabc 4x8/8x4 leaves that read the inter var-tx tree + // (the symbol whose absence desynced `warped.obu`). + println!( + "rect_intrabc_vartx: {}", + ec_av1::decode::rect_intrabc_vartx_hits() + ); let rw = ec_av1::stream::rect_wedge_hits(); let rwi = ec_av1::stream::rect_wii_hits(); println!( diff --git a/crates/ec-av1/src/cdf_state.rs b/crates/ec-av1/src/cdf_state.rs index 2ce94401..27c3e006 100644 --- a/crates/ec-av1/src/cdf_state.rs +++ b/crates/ec-av1/src/cdf_state.rs @@ -322,9 +322,9 @@ impl TxbSet { /// lane-txi: this set's `reduced_tx_set == 0` counterpart -- the WIDER /// `tx_type` alphabet the same coefficient tables are read with when the - /// frame header's bit is off. Every pair here is the one - /// `decode::txbset_for`/`txbset_for_inter`/`inter_txbset_for` resolve off - /// that bit, transcribed from the DECODER's own map so writer and reader + /// frame header's bit is off. Every pair here is the counterpart + /// `decode::txbset_for`/`inter_txbset_for` resolve off that bit, + /// transcribed from the DECODER's own map so writer and reader /// cannot drift (class `table-and-reader-move-together`); a set with no /// counterpart -- intra 16x16 and 32x32, inter 32x32, 64x64, every /// chroma set -- is its own, and widening an already-wide set is the diff --git a/crates/ec-av1/src/decode.rs b/crates/ec-av1/src/decode.rs index 76463d6b..a3b7d5af 100644 --- a/crates/ec-av1/src/decode.rs +++ b/crates/ec-av1/src/decode.rs @@ -84,6 +84,12 @@ pub(crate) struct FrameCtx { /// (`decodeframe.c`), `read_tx_type` (`decodetxb.c`), `is_cfl_allowed` /// (`blockd.h`)). pub(crate) lossless_flag: std::cell::Cell, + /// lane-av1txr: this frame header's `disable_cdf_update` (spec 5.9.2). + /// When set, the tile reader must not adapt any CDF it reads, or its + /// tables drift away from the encoder's and the frame desyncs mid-tile + /// (libaom: `allow_update_cdf = allow_update_cdf && + /// !cm->features.disable_cdf_update`, `decodeframe.c:2909`). + pub(crate) disable_cdf_update: std::cell::Cell, pub(crate) cdef_bits: std::cell::Cell, pub(crate) bit_depth: std::cell::Cell, /// lane-av1mono: the sequence header's `color_config.mono_chrome` (spec @@ -183,6 +189,7 @@ impl FrameCtx { sb128_flag: std::cell::Cell::new(false), interp_filter: std::cell::Cell::new(crate::mc::InterpFilterKind::Regular), lossless_flag: std::cell::Cell::new(false), + disable_cdf_update: std::cell::Cell::new(false), cdef_bits: std::cell::Cell::new(0), bit_depth: std::cell::Cell::new(8), mono_chrome: std::cell::Cell::new(false), @@ -390,6 +397,18 @@ pub(crate) fn lossless(fctx: &crate::decode::FrameCtx) -> bool { fctx.lossless_flag.with(|c| c.get()) } +/// Sets [`FrameCtx::disable_cdf_update`] (called once per frame from +/// `stream.rs`). +pub(crate) fn set_disable_cdf_update(v: bool, fctx: &crate::decode::FrameCtx) { + fctx.disable_cdf_update.with(|c| c.set(v)); +} + +/// This frame's `disable_cdf_update`, for the tile readers -- +/// [`msac::SymbolDecoder::set_cdf_update`](crate::msac::SymbolDecoder::set_cdf_update). +pub(crate) fn cdf_update_disabled(fctx: &crate::decode::FrameCtx) -> bool { + fctx.disable_cdf_update.with(|c| c.get()) +} + /// The transform side a block of `side` pixels codes: its own (capped at the /// caller's own largest) normally, 4 on a lossless frame, where libaom's /// `read_tx_size` returns TX_4X4 before it looks at anything else @@ -3687,6 +3706,11 @@ thread_local! { /// var-tx partition tree (unskipped, `TX_MODE_SELECT`) -- the capability /// that replaced the refusal "an intrabc block under TxMode::Select". static INTRABC_VARTX_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; + /// lane-av1txr: as above for a `BLOCK_4X8`/`BLOCK_8X4` intrabc leaf -- + /// libaom's `block_signals_txsize` is `bsize > BLOCK_4X4`, so these leaves + /// signal a transform size where a plain `BLOCK_4X4` does not. Reading no + /// symbol here desynced `warped.obu` at the very next block. + static RECT_INTRABC_VARTX_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; } /// Current value of [`INTRABC_VARTX_HITS`]. @@ -3701,11 +3725,31 @@ pub(crate) fn reset_intrabc_vartx_hits() { INTRABC_VARTX_HITS.with(|c| c.set(0)); } +/// Current value of [`RECT_INTRABC_VARTX_HITS`]. +#[allow(dead_code)] // read only from the `#[cfg(test)]` gates +pub fn rect_intrabc_vartx_hits() -> usize { + RECT_INTRABC_VARTX_HITS.with(|c| c.get()) +} + /// Records one coded block into [`INTRABC_MI_GRID`]: every block contributes /// its size (libaom's `scan_row_mbmi` advances `processed_rows` off any /// candidate's `bsize`, ref-match or not), an intrabc one also its DV as an /// `INTRA_FRAME` candidate (libaom treats intrabc as `is_inter_block`). fn record_intrabc_mi(mi_r: usize, mi_c: usize, n4: usize, dv: Option<(i32, i32)>, fctx: &crate::decode::FrameCtx) { + record_intrabc_mi_rect(mi_r, mi_c, n4, n4, dv, fctx); +} + +/// [`record_intrabc_mi`] with a true rectangular footprint: `av1_find_mv_refs` +/// takes the block's real `bsize`, so a sub-8x8 `BLOCK_4X8`/`BLOCK_8X4` +/// intrabc leaf must publish a 1x2/2x1 mi span, not a square (lane-av1txr). +fn record_intrabc_mi_rect( + mi_r: usize, + mi_c: usize, + n4_w: usize, + n4_h: usize, + dv: Option<(i32, i32)>, + fctx: &crate::decode::FrameCtx, +) { fctx.intrabc_mi_grid.with(|g| { let mut g = g.borrow_mut(); 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)> is_new_mv: dv.is_some(), is_global_mv0: false, is_global_mv1: false, - size: n4 as u8, - size_h: n4 as u8, + size: n4_w as u8, + size_h: n4_h as u8, }; - for r in mi_r..mi_r + n4 { - for c in mi_c..mi_c + n4 { + for r in mi_r..mi_r + n4_h { + for c in mi_c..mi_c + n4_w { grid.set(r, c, info); } } @@ -11399,7 +11443,11 @@ fn decode_leaf_rect( // the range diverges silently at the first such leaf and every later // symbol in the tile is read from the wrong place (class // `wrong-alphabet-same-value`, here same alphabet / wrong row). - dec.symbol(&mut cdfs.tx_size_cat1[ctx]) + let d = dec.symbol(&mut cdfs.tx_size_cat1[ctx]); + if crate::envflags::env_flag!("EC_TRACE_MODE_STEP") { + 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); + } + d } else { 0 }; @@ -13318,11 +13366,14 @@ fn read_intra_mode( // that merely allows (but never uses) intrabc. if allow_intrabc { let use_intrabc = dec.symbol(&mut cdfs.intrabc) != 0; + if crate::envflags::env_flag!("EC_TRACE_MODE_STEP") { + eprintln!("EC_ISTEP mi_row={mi_r} mi_col={mi_c} name=intrabc val={} rng={}", u8::from(use_intrabc), dec.debug_state().0); + } if trace { eprintln!("TRACE use_intrabc value={}", use_intrabc as i32); } if use_intrabc { - let dv = read_intrabc_dv(dec, cdfs, mi_r, mi_c, side, fctx); + let dv = read_intrabc_dv(dec, cdfs, mi_r, mi_c, (side / MI, side / MI), fctx); if trace { eprintln!("TRACE intrabc dv={dv:?}"); } @@ -14418,7 +14469,7 @@ fn decode_block( luma_set }; let luma_set = if intrabc_dv.is_some() { - txbset_for_inter(logical_tx, reduced_tx_set) + inter_txbset_for(logical_tx, reduced_tx_set) } else { luma_set }; @@ -15686,7 +15737,7 @@ fn decode_leaf8( dec, cdfs, if intrabc_dv.is_some() { - txbset_for_inter(8, reduced_tx_set) + inter_txbset_for(8, reduced_tx_set) } else if reduced_tx_set { TxbSet::Luma8 } else { @@ -15821,7 +15872,7 @@ fn decode_leaf8( dec, cdfs, if intrabc_dv.is_some() { - txbset_for_inter(4, reduced_tx_set) + inter_txbset_for(4, reduced_tx_set) } else if reduced_tx_set { TxbSet::Luma4 } else { @@ -16021,7 +16072,7 @@ fn read_intra_mode_sub8( // neighbour's `cdf_index`/prediction two blocks later. seg_w_mi: usize, seg_h_mi: usize, fctx: &crate::decode::FrameCtx, -) -> Result<(bool, usize, i32, Option<(usize, i32, Option<(i32, i32)>)>, Option)> { +) -> Result<(bool, usize, i32, Option<(usize, i32, Option<(i32, i32)>)>, Option, Option<(i32, i32)>)> { // lane-av1mono: a monochrome leaf codes no chroma mode (libaom // `decodemv.c:933`), so fold `NumPlanes == 1` into `has_chroma`. let has_chroma = has_chroma && !mono(fctx); @@ -16063,10 +16114,27 @@ fn read_intra_mode_sub8( istep!("dq", 0); if allow_intrabc { let use_intrabc = dec.symbol(&mut cdfs.intrabc) != 0; + if ec_istep { + eprintln!("EC_ISTEP mi_row={mi_r} mi_col={mi_c} name=intrabc val={} rng={}", u8::from(use_intrabc), dec.debug_state().0); + } if use_intrabc { - return Err(unsupported( - "a sub-8x8 leaf that uses intrabc (this reader has no block-vector path; the 8x8-and-up reader reconstructs one)", - )); + // lane-av1txr: `read_intrabc_info` (spec 5.11.13) reads the block + // vector right after the flag and RETURNS -- no y/uv mode, angle + // delta, palette, CfL or filter-intra syntax follows, and the + // block is reconstructed by the INTER path (libaom's + // `is_inter_block` counts an intrabc block), so the caller takes + // the frame-copy prediction + inter residual. + let dv = read_intrabc_dv(dec, cdfs, mi_r, mi_c, (seg_w_mi, seg_h_mi), fctx); + // lane-av1txr: the DV travels back in the RETURN value -- it is + // NOT published through `FrameCtx::intrabc_dv`. That slot is the + // SQUARE paths' handoff (`decode_block`/`decode_leaf8` arm it, + // then `take()` it in the same call), so a sub-8x8 leaf that + // armed it left the vector standing for the NEXT >=8x8 block: + // `warped.obu`'s (38,60) 8x8 intra block took it as its own + // intrabc and read an inter var-tx `txfm_split` where libaom read + // an intra `tx_depth` (class `stale-slot-handoff`). + hit!(INTRABC_HITS); + return Ok((skip, DC_PRED, 0, None, None, Some(dv))); } } let above_ctx = INTRA_MODE_CTX[above_mode]; @@ -16116,7 +16184,7 @@ fn read_intra_mode_sub8( filter_intra = Some(fi_mode); } } - Ok((skip, mode, angle_delta_y, chroma, filter_intra)) + Ok((skip, mode, angle_delta_y, chroma, filter_intra, None)) } /// Decodes a `PARTITION_SPLIT` of one 8x8 block into four `BLOCK_4X4` leaves @@ -16167,6 +16235,10 @@ fn decode_leaf_split4( let mut leaf_modes = [0usize; 4]; let mut leaf_skips = [false; 4]; let mut last_uv: Option<(usize, i32, Option<(i32, i32)>)> = None; + // lane-av1txr: the chroma-reference (i==3) leaf's block vector when that + // leaf is an intrabc block -- its prediction/reconstruction below is a + // frame copy at this DV, not an intra one. + let mut last_intrabc: Option<(i32, i32)> = None; for i in 0..4usize { let (dr, dc) = (i / 2, i % 2); let lmi = (leaf_mi.0 + dr, leaf_mi.1 + dc); @@ -16186,7 +16258,7 @@ fn decode_leaf_split4( }; let has_chroma = i == 3; let skip_ctx = neighbours.skip_txfm_ctx(lmi.0, lmi.1); - let (skip, mode, angle_delta_y, chroma, filter_intra) = read_intra_mode_sub8( + let (skip, mode, angle_delta_y, chroma, filter_intra, intrabc) = read_intra_mode_sub8( dec, cdfs, leaf_above, leaf_left, has_chroma, enable_filter_intra, filter_intra_size_class(4).expect("BLOCK_4X4 has its own filter_intra row"), skip_ctx, allow_intrabc, lmi.0, lmi.1, 1, 1, fctx, @@ -16194,12 +16266,81 @@ fn decode_leaf_split4( leaf_modes[i] = mode; leaf_skips[i] = skip; neighbours.record_mode_mi(lmi.0, lmi.1, 1, 1, mode); + // lane-av1txr: libaom `parse_decode_block`'s `set_txfm_ctxs` for this + // `BLOCK_4X4` leaf -- EVERY block publishes its transform size into + // the TXFM context bands, and an intrabc block's later `txfm_split` + // context is read off them (`txfm_partition_context`). A 4x4 never + // signals a tx size, so it is always TX_4X4 (`set_txfm_ctxs`'s + // `skip && is_inter` branch writes the block's own 4 pixels -- the + // same value). + set_txfm_ctxs(neighbours, lmi, 4, 1, 1, false); let smooth_neighbor = is_smooth_mode(leaf_above) || is_smooth_mode(leaf_left); if smooth_neighbor { hit!(SMOOTH_LUMA_HITS); } let (px, py) = (lmi.1 * MI, lmi.0 * MI); let reach = Reach::of(4, px, py, y.width, y.height, fctx); + if let Some(dv) = intrabc { + // lane-av1txr: an intrabc `BLOCK_4X4` leaf -- prediction is the + // CURRENT frame at the block vector (`predict_inter_block`'s + // intrabc arm, spec 7.11.3.4), residual the INTER coefficient set + // (libaom reads `tx_type` off `inter_ext_tx_cdf` for + // `is_inter_block`, which counts intrabc). Published into + // `intrabc_dv` so the group's chroma arm (below, when the + // chroma-reference leaf is the intrabc one) and + // [`record_intrabc_mi`] see it. + flush_recon(fctx, y, u, v); + let mut yb = vec![0u16; 16]; + mc::predict_with_filter( + &y.data, y.width, y.true_width, y.true_height, + mv_to_q4(px, dv.1, true), mv_to_q4(py, dv.0, true), + 4, 4, mc::InterpFilterKind::Bilinear, &mut yb, fctx, + ); + set_palette_pred(yb.clone(), fctx); + if skip { + push_intra(0, px, py, 4, DC_PRED, 0, reach, &ZERO_RESIDUAL[..16], None, None, smooth_neighbor, fctx); + neighbours.record_mi_luma(lmi, 4, &ZERO_RESIDUAL[..16]); + } else { + let tu_around = neighbours.around_mi(lmi, 4)[0]; + let tu_grid = read_plane( + dec, + cdfs, + if reduced_tx_set { TxbSet::Luma4Inter } else { TxbSet::Luma4InterSet1 }, + scan4, + 0, + tu_around, + DC_PRED, + DC_PRED, + 0, + reach, + y, + px, + py, + 4, + 4, + base_q_idx, + None, + None, + None, + smooth_neighbor, fctx, + )?; + neighbours.record_mi_luma(lmi, 4, &tu_grid); + } + neighbours.fill_skip_grid(lmi, 1, skip); + neighbours.fill_lf_grid(lmi, 1, 4, 0, fctx); + record_intrabc_mi(lmi.0, lmi.1, 1, Some(dv), fctx); + if has_chroma { + last_uv = Some((DC_PRED, 0, None)); + // An intrabc block is an INTER block for `av1_get_tx_type`, so + // the group's chroma inherits the LUMA's coded transform type + // (`xd->tx_type_map` at the co-located luma position) -- the + // luma `read_plane` above just set [`LUMA_TX_TYPE`]. Armed for + // exactly this group's two chroma reads. + fctx.intrabc_chroma_tx.with(|c| c.set(Some(fctx.luma_tx_type.with(std::cell::Cell::get)))); + } + last_intrabc = Some(dv); + continue; + } if skip { push_intra(0, px, py, 4, mode, angle_delta_y, reach, &ZERO_RESIDUAL[..16], None, filter_intra, smooth_neighbor, fctx); neighbours.record_mi_luma(lmi, 4, &ZERO_RESIDUAL[..16]); @@ -16271,6 +16412,38 @@ fn decode_leaf_split4( 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); 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); (Grid::Zero(16), Grid::Zero(16)) + } else if let Some(dv) = last_intrabc { + // lane-av1txr: the chroma-reference leaf was an intrabc block, so the + // group's one chroma unit is a frame copy at that DV too (its residual + // still reads the ordinary `Chroma4` coefficient tables -- libaom + // codes a chroma `tx_type` nowhere). + let mut ub = vec![0u16; 16]; + mc::predict_with_filter( + &u.data, u.width, u.true_width, u.true_height, + mv_to_q4(cpx, dv.1, false), mv_to_q4(cpy, dv.0, false), + 4, 4, mc::InterpFilterKind::Bilinear, &mut ub, fctx, + ); + let mut vb = vec![0u16; 16]; + mc::predict_with_filter( + &v.data, v.width, v.true_width, v.true_height, + mv_to_q4(cpx, dv.1, false), mv_to_q4(cpy, dv.0, false), + 4, 4, mc::InterpFilterKind::Bilinear, &mut vb, fctx, + ); + let chroma_around = neighbours.around_mi(leaf_mi, 8); + set_palette_pred(ub, fctx); + let ug = read_plane( + dec, cdfs, TxbSet::Chroma4, scan4, 1, chroma_around[1], DC_PRED, DC_PRED, + 0, group_reach, u, cpx, cpy, 4, TX4, base_q_idx, + None, None, None, smooth_neighbor_uv, fctx, + )?; + set_palette_pred(vb, fctx); + let vg = read_plane( + dec, cdfs, TxbSet::Chroma4, scan4, 2, chroma_around[2], DC_PRED, DC_PRED, + 0, group_reach, v, cpx, cpy, 4, TX4, base_q_idx, + None, None, None, smooth_neighbor_uv, fctx, + )?; + fctx.intrabc_chroma_tx.with(|c| c.set(None)); + (ug, vg) } else { let ac = alpha.map(|_| cfl_src(gpx, gpy, 8)); let chroma_around = neighbours.around_mi(leaf_mi, 8); @@ -16398,6 +16571,8 @@ fn decode_leaf_rect8( let mut leaf_modes = [0usize; 2]; let mut leaf_skips = [false; 2]; let mut last_uv: Option<(usize, i32, Option<(i32, i32)>)> = None; + // lane-av1txr: as [`decode_leaf_split4`]'s own `last_intrabc`. + let mut last_intrabc: Option<(i32, i32)> = None; for i in 0..2usize { let lmi = if vert { (leaf_mi.0, leaf_mi.1 + i) @@ -16418,12 +16593,186 @@ fn decode_leaf_rect8( }; let has_chroma = i == 1; let skip_ctx = neighbours.skip_txfm_ctx(lmi.0, lmi.1); - let (skip, mode, angle_delta_y, chroma, filter_intra) = read_intra_mode_sub8( + let (skip, mode, angle_delta_y, chroma, filter_intra, intrabc) = read_intra_mode_sub8( dec, cdfs, leaf_above, leaf_left, has_chroma, enable_filter_intra, filter_intra_size_class_rect(bw, bh) .expect("BLOCK_4X8/BLOCK_8X4 are inside av1_filter_intra_allowed_bsize"), skip_ctx, allow_intrabc, lmi.0, lmi.1, bw / 4, bh / 4, fctx, )?; + leaf_modes[i] = mode; + leaf_skips[i] = skip; + neighbours.record_mode_mi(lmi.0, lmi.1, w_mi, h_mi, mode); + let smooth_neighbor = is_smooth_mode(leaf_above) || is_smooth_mode(leaf_left); + if let Some(dv) = intrabc { + // lane-av1txr: an intrabc `BLOCK_4X8`/`BLOCK_8X4` leaf. The + // prediction is a frame copy at the DV and the residual reads the + // INTER `LumaRect8x4` set -- but with `TxMode::Select` the leaf + // reads the INTER var-tx tree, exactly like every other intrabc + // block: libaom's `block_signals_txsize` is `bsize > BLOCK_4X4` + // (`blockd.h:1027`), TRUE at `BLOCK_4X8`/`BLOCK_8X4`, so + // `parse_decode_block` sends an unskipped `inter_block_tx` block + // (intrabc counts, `is_inter_block`) of a signalling bsize into + // `read_tx_size_vartx` over `max_txsize_rect_lookup[BLOCK_4X8] == + // TX_4X8`; only `BLOCK_4X4` reads no tx symbol at all. Measured on + // `warped.obu` mi (37,62): reading NO symbol here left the + // arithmetic decoder one symbol short and desynced the very next + // block's `skip` (ours 60320 vs aomdec 48630, class + // `symbol-consumption-gap`). + let (px, py) = (lmi.1 * MI, lmi.0 * MI); + let reach = Reach::of_rect(bw, bh, px, py, y.width, y.height, fctx); + flush_recon(fctx, y, u, v); + let mut luma_leaves: Vec<(usize, usize, usize, usize)> = Vec::new(); + if tx_select && !skip { + // `max_block_wide`/`max_block_high`: the frame's own mi grid, + // so a leaf hanging over the right/bottom edge reads no split + // symbol for the units outside it (as in `decode_block`). + let mi_cols = 2 * y.true_width.div_ceil(8); + let mi_rows = 2 * y.true_height.div_ceil(8); + let max_w_mi = w_mi.min(mi_cols.saturating_sub(lmi.1)); + let max_h_mi = h_mi.min(mi_rows.saturating_sub(lmi.0)); + read_var_tx_size( + dec, + cdfs, + neighbours, + lmi, + bw.max(bh), + (max_w_mi, max_h_mi), + (bw, bh), + 0, + 0, + 0, + &mut luma_leaves, + ); + hit!(RECT_INTRABC_VARTX_HITS); + } else { + luma_leaves.push((0, 0, bw, bh)); + // The non-var-tx arm: a SKIPPED intrabc leaf (or a frame + // outside `TxMode::Select`) publishes its own rect transform + // (`set_txfm_ctxs`'s `skip && is_inter` branch writes the + // block's own pixels -- the same size here). + txfm_partition_update_rect(neighbours, lmi, (bw, bh), (bw, bh)); + } + // The transform type an intrabc block's CHROMA inherits is the + // `tx_type_map` entry at the chroma unit's co-located luma + // position (`av1_get_tx_type`, `blockd.h:1278`), i.e. the FIRST + // luma unit the tree resolved. + let single = luma_leaves.len() == 1; + let mut chroma_tx = TxType::DctDct; + let mut grid = Grid::Zero(bw * bh); + for (li, &(tu_row, tu_col, tw, th)) in luma_leaves.iter().enumerate() { + let tu_mi = (lmi.0 + tu_row, lmi.1 + tu_col); + let (tu_px, tu_py) = (tu_mi.1 * MI, tu_mi.0 * MI); + let tu_reach = if single { + reach + } else { + tu_reach( + bw, bh, tu_px - px, tu_py - py, tw, reach, px, py, y.width, y.height, fctx, + ) + }; + let mut yb = vec![0u16; tw * th]; + mc::predict_with_filter( + &y.data, y.width, y.true_width, y.true_height, + mv_to_q4(tu_px, dv.1, true), mv_to_q4(tu_py, dv.0, true), + tw, th, mc::InterpFilterKind::Bilinear, &mut yb, fctx, + ); + set_palette_pred(yb, fctx); + let tu_grid = if skip { + let zeros = Grid::Zero(tw * th); + if (tw, th) == (4, 4) { + push_intra(0, tu_px, tu_py, 4, DC_PRED, 0, tu_reach, &zeros, None, None, smooth_neighbor, fctx); + } else { + push_intra_rect(0, tu_px, tu_py, tw, th, DC_PRED, 0, tu_reach, &zeros, None, None, smooth_neighbor, fctx); + } + zeros + } else { + // A unit smaller than its own block (the var-tx split) + // reads its `txb_skip_ctx` off the neighbours; the + // whole-leaf unit's `plane_bsize == txsize_to_bsize` fixes + // it at 0. + let (set, tu_scan, around, skip_ctx) = if (tw, th) == (4, 4) { + ( + inter_txbset_for(4, reduced_tx_set), + scan4, + neighbours.around_mi(tu_mi, 4)[0], + neighbours.luma_skip_ctx(tu_mi, 1), + ) + } else { + ( + if reduced_tx_set { + TxbSet::LumaRect8x4Inter + } else { + TxbSet::LumaRect8x4InterSet1 + }, + scan, + neighbours.around_mi_rect(tu_mi, tw, th)[0], + 0, + ) + }; + let mut coding = cdfs.txb(set, DC_PRED); + let (levels, tx_type) = read_coeffs_rect( + dec, &mut coding, tu_scan, tw, th, skip_ctx, dc_sign_ctx(around.2), + TxType::DctDct, + )?; + if li == 0 { + chroma_tx = tx_type; + fctx.luma_tx_type.with(|c| c.set(tx_type)); + } + let residual = dequant_and_inverse_typed_wh( + &levels, tw, th, crate::decode::bit_depth(fctx), block_q_idx(fctx), + plane_q_delta(0, fctx).0, plane_q_delta(0, fctx).1, tx_type, + ); + if (tw, th) == (4, 4) { + push_intra(0, tu_px, tu_py, 4, DC_PRED, 0, tu_reach, &residual, None, None, smooth_neighbor, fctx); + } else { + push_intra_rect(0, tu_px, tu_py, tw, th, DC_PRED, 0, tu_reach, &residual, None, None, smooth_neighbor, fctx); + } + levels + }; + if single { + grid = tu_grid; + } else { + // Per-unit neighbour state, the same shape the intra rect + // leaf's own split path runs (`decode_leaf8`'s depth-1 + // loop): a transform unit inside a block is not a block at + // that position. + neighbours.record_mi_luma(tu_mi, 4, &tu_grid); + } + } + if single { + let state = neighbour_state(&grid); + for cell in 0..h_mi { + if lmi.0 + cell < neighbours.mi_rows { + neighbours.left[lmi.0 + cell][0] = state; + } + } + for cell in 0..w_mi { + if lmi.1 + cell < neighbours.mi_cols { + neighbours.above[lmi.1 + cell][0] = state; + } + } + } + neighbours.fill_skip_grid_rect(lmi, w_mi, h_mi, skip); + neighbours.fill_lf_grid_rect( + lmi, + w_mi, + h_mi, + if single { bw as u8 } else { 4 }, + if single { bh as u8 } else { 4 }, + 0, + fctx, + ); + // `record_intrabc_mi` publishes a square `n4`x`n4` footprint; a + // 4x8/8x4 leaf needs its true `w_mi`x`h_mi` (lane-av1txr). + record_intrabc_mi_rect(lmi.0, lmi.1, w_mi, h_mi, Some(dv), fctx); + if has_chroma { + last_uv = Some((DC_PRED, 0, None)); + last_intrabc = Some(dv); + // See [`decode_leaf_split4`]: an intrabc block's chroma + // inherits the luma transform type. + fctx.intrabc_chroma_tx.with(|c| c.set(Some(chroma_tx))); + } + continue; + } if filter_intra.is_some() { // lane-fi8 r1: `predict_filter_intra` walks its 4x2 patches over // a true `bw`x`bh` block, so a 4x8/8x4 leaf predicts through the @@ -16459,10 +16808,6 @@ fn decode_leaf_rect8( hit!(TX_DEPTH_HITS); hit!(RECT8_SPLIT_TX_HITS); } - leaf_modes[i] = mode; - leaf_skips[i] = skip; - neighbours.record_mode_mi(lmi.0, lmi.1, w_mi, h_mi, mode); - let smooth_neighbor = is_smooth_mode(leaf_above) || is_smooth_mode(leaf_left); if smooth_neighbor { hit!(SMOOTH_LUMA_HITS); } @@ -16475,6 +16820,15 @@ fn decode_leaf_rect8( // four. The per-TU path writes its own neighbour state, so the // block-level write below is skipped for it. let split = depth != 0 || lossless(fctx); + // lane-av1txr: libaom `parse_decode_block`'s `set_txfm_ctxs` for this + // leaf -- the size the `tx_depth` symbol resolved (depth 1 -> TX_4X4, + // else the leaf's own rect transform), published over the leaf's own + // mi span. An intrabc block's `txfm_partition_context` reads these + // bands, and the key-frame sub-8x8 leaves had no write at all: + // `warped.obu` mi (37,62) read a stale 8 where aomdec read 4 (ctx 18 + // vs 19) and the tile desynced (class `context-band-not-published`). + let (ctx_tx_w, ctx_tx_h) = if split { (4, 4) } else { (bw, bh) }; + txfm_partition_update_rect(neighbours, lmi, (ctx_tx_w, ctx_tx_h), (bw, bh)); if split { let mut done = 0usize; for tu in 0..2usize { @@ -16666,6 +17020,38 @@ fn decode_leaf_rect8( 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); 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); (Grid::Zero(16), Grid::Zero(16)) + } else if let Some(dv) = last_intrabc { + // lane-av1txr: the chroma-reference leaf was an intrabc block, so the + // group's one chroma unit is a frame copy at that DV too (its residual + // still reads the ordinary `Chroma4` coefficient tables -- libaom + // codes a chroma `tx_type` nowhere). + let mut ub = vec![0u16; 16]; + mc::predict_with_filter( + &u.data, u.width, u.true_width, u.true_height, + mv_to_q4(cpx, dv.1, false), mv_to_q4(cpy, dv.0, false), + 4, 4, mc::InterpFilterKind::Bilinear, &mut ub, fctx, + ); + let mut vb = vec![0u16; 16]; + mc::predict_with_filter( + &v.data, v.width, v.true_width, v.true_height, + mv_to_q4(cpx, dv.1, false), mv_to_q4(cpy, dv.0, false), + 4, 4, mc::InterpFilterKind::Bilinear, &mut vb, fctx, + ); + let chroma_around = neighbours.around_mi(leaf_mi, 8); + set_palette_pred(ub, fctx); + let ug = read_plane( + dec, cdfs, TxbSet::Chroma4, scan4, 1, chroma_around[1], DC_PRED, DC_PRED, + 0, group_reach, u, cpx, cpy, 4, TX4, base_q_idx, + None, None, None, smooth_neighbor_uv, fctx, + )?; + set_palette_pred(vb, fctx); + let vg = read_plane( + dec, cdfs, TxbSet::Chroma4, scan4, 2, chroma_around[2], DC_PRED, DC_PRED, + 0, group_reach, v, cpx, cpy, 4, TX4, base_q_idx, + None, None, None, smooth_neighbor_uv, fctx, + )?; + fctx.intrabc_chroma_tx.with(|c| c.set(None)); + (ug, vg) } else { let ac = alpha.map(|_| cfl_src(gpx, gpy, 8)); 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 if allowed.contains(&t) { t } else { DctDct } } +/// The [`TxbSet`] a resolved luma transform side reads its coefficient tables +/// from for a block libaom's `is_inter_block` calls inter -- which an intrabc +/// block is (`blockd.h:373`), so its `tx_type` comes off the inter `ext_tx` +/// sets, never the mode-indexed intra ones ([`txbset_for`]). +/// +/// 64 is only ever the 64x64-block, depth-0, corner-scanned case +/// ([`TxbSet::Luma64`]); every other resolved side maps to its own matching +/// set. `get_tx_set` (spec 5.11.48) only splits on `reduced_tx_set` at +/// `TX_8X8`/`TX_4X4`: an intra `TX_16X16` always reads `TX_SET_INTRA_2` +/// regardless of the flag (`av1_get_ext_tx_set_type`'s +/// `tx_size_sqr == TX_16X16` branch ignores `use_reduced_set` once it is past +/// the `TX_32X32`/reduced-set checks), so only the 8x8 and 4x4 cases have a +/// second table ([`TxbSet::Luma8Inter`]/[`TxbSet::Luma4Inter`]). +/// +/// lane-av1txr: the intrabc leaf sites used to call a near-duplicate +/// `txbset_for_inter` whose `4` fell through to `Luma64` -- 32x32-class tables +/// (a 1024-entry grid) handed to a 4x4 dequant, which panicked at +/// `transform.rs`'s `inverse_transform_2d_typed_wh` the first time an intrabc +/// 4x4 TU coded a non-zero coefficient (`allintra0`/cpu-used=0). The +/// duplicate is gone; every inter-table site goes through this one mapping. fn inter_txbset_for(tx_px: usize, reduced_tx_set: bool) -> TxbSet { match tx_px { // lane-sb128c r1: a 128x128 inter block's own luma unit @@ -18915,29 +19321,6 @@ fn scan_for<'a>( } } -/// The [`TxbSet`] a resolved luma transform side reads its coefficient tables -/// from -- 64 is only ever the 64x64-block, depth-0, corner-scanned case -/// ([`TxbSet::Luma64`]); every other resolved side maps to its own matching -/// set. `get_tx_set` (spec 5.11.48) only splits on `reduced_tx_set` at -/// `TX_8X8`/`TX_4X4`: an intra `TX_16X16` always reads `TX_SET_INTRA_2` -/// regardless of the flag (`av1_get_ext_tx_set_type`'s -/// `tx_size_sqr == TX_16X16` branch ignores `use_reduced_set` once it is past -/// the `TX_32X32`/reduced-set checks), so only the 8x8 and 4x4 cases have a -/// second table ([`TxbSet::Luma8Set1`]/[`TxbSet::Luma4Set1`]). -/// [`txbset_for`], for a block libaom's `is_inter_block` calls inter -- which -/// an intrabc block is (`blockd.h:373`), so its `tx_type` comes off the -/// inter `ext_tx` sets, never the mode-indexed intra ones. -fn txbset_for_inter(tx_px: usize, reduced_tx_set: bool) -> TxbSet { - match tx_px { - 64 => TxbSet::Luma64, - 32 => TxbSet::Luma32Inter, - 16 if reduced_tx_set => TxbSet::Luma16Inter, - 16 => TxbSet::Luma16InterSet1, - 8 if reduced_tx_set => TxbSet::Luma8Inter, - 8 => TxbSet::Luma8InterSet1, - _ => TxbSet::Luma64, - } -} fn txbset_for(tx_px: usize, reduced_tx_set: bool) -> TxbSet { match tx_px { @@ -22445,6 +22828,9 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( ); } let mut dec = SymbolDecoder::new(tile_bytes); + // lane-av1txr: spec 5.9.2's `disable_cdf_update` -- a frame that sets + // it codes every symbol against the tables it started with. + dec.set_cdf_update(!cdf_update_disabled(fctx)); crate::census::register_cdfs(&cdfs); neighbours.start_tile(mi_row0 as usize, mi_col0 as usize, mi_col1 as usize, fctx); y.set_tile_origin( @@ -24716,15 +25102,17 @@ fn read_intrabc_dv( cdfs: &mut Cdfs, mi_r: usize, mi_c: usize, - side: usize, fctx: &crate::decode::FrameCtx, + // The block's own mi footprint (`av1_find_mv_refs` takes the real bsize, + // so a sub-8x8 `BLOCK_4X8`/`BLOCK_8X4` leaf scans a 1x2/2x1 neighbourhood + // -- lane-av1txr). + (n4_w, n4_h): (usize, usize), fctx: &crate::decode::FrameCtx, ) -> (i32, i32) { const INTRABC_DELAY_PIXELS: i32 = 256; - let n4 = side / MI; let stack_pred = fctx.intrabc_mi_grid.with(|g| { let g = g.borrow(); g.as_ref().map(|(grid, mi_cols, mi_rows)| { let stack = crate::mvstack::find_mv_stack( - grid, mi_r, mi_c, n4, n4, 0, /* INTRA_FRAME */ + grid, mi_r, mi_c, n4_w, n4_h, 0, /* INTRA_FRAME */ *mi_cols, *mi_rows, ); if stack.nearest_mv == (0, 0) { @@ -24752,7 +25140,12 @@ fn read_intrabc_dv( } // "Ref DV should not have sub-pel" (`assign_dv`): floor to full pel. let pred = ((pred.0 >> 3) * 8, (pred.1 >> 3) * 8); - read_mv(dec, &mut cdfs.dv_comp, &mut cdfs.dv_joint, pred, false, true) + let dv = read_mv(dec, &mut cdfs.dv_comp, &mut cdfs.dv_joint, pred, false, true); + if crate::envflags::env_flag!("EC_TRACE_MODE_STEP") { + let (rng, _) = dec.debug_state(); + eprintln!("EC_DV mi_row={mi_r} mi_col={mi_c} dv_col={} dv_row={} rng={rng}", dv.1, dv.0); + } + dv } /// 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( fctx.quant_deltas.with(|c| c.set(deltas)); fctx.current_delta_lf.with(|c| c.set([0; 4])); let mut dec = SymbolDecoder::new(data); + // lane-av1txr: spec 5.9.2's `disable_cdf_update` -- a frame that sets + // it codes every symbol against the tables it started with. + dec.set_cdf_update(!cdf_update_disabled(fctx)); crate::census::register_cdfs(&cdfs); // lane-comppin r9: tile-entry range, the earliest point comparable // against aomdec's own `r->ec.rng` right after `aom_reader_init` -- the diff --git a/crates/ec-av1/src/msac.rs b/crates/ec-av1/src/msac.rs index 636c7956..51193acd 100644 --- a/crates/ec-av1/src/msac.rs +++ b/crates/ec-av1/src/msac.rs @@ -305,6 +305,14 @@ pub struct SymbolDecoder<'a> { /// Bits left before the decoder starts padding with zeros (spec /// `SymbolMaxBits`), which goes negative at the end of the string. max_bits: i32, + /// Whether [`SymbolDecoder::symbol`] adapts the CDF it reads (spec 8.3.2). + /// `false` for a frame whose header sets `disable_cdf_update` -- libaom's + /// tile entry (`decodeframe.c:2909`, `allow_update_cdf = allow_update_cdf + /// && !cm->features.disable_cdf_update`) skips the adaptation there, so + /// reading on would drift this decoder's tables away from the encoder's + /// and desync mid-frame. Per-READER, not global: frames of one stream can + /// decode on different worker threads. + adapt: bool, } impl Drop for SymbolDecoder<'_> { @@ -326,6 +334,7 @@ impl<'a> SymbolDecoder<'a> { value: 0, range: 1 << 15, max_bits: 8 * data.len() as i32 - 15, + adapt: true, }; let num_bits = usize::min(data.len() * 8, 15) as u32; let buf = d.f(num_bits); @@ -333,6 +342,15 @@ impl<'a> SymbolDecoder<'a> { d } + /// Spec 5.9.2's `disable_cdf_update`, the reader side: `false` (the + /// default) adapts every CDF [`symbol`](Self::symbol) reads; `true` + /// leaves each table exactly as it was read, matching libaom's + /// `allow_update_cdf` (decodeframe.c:2909). Set once per tile reader by + /// the frame's own header bit. + pub(crate) fn set_cdf_update(&mut self, update: bool) { + self.adapt = update; + } + /// `f(n)`: the next `n` bits, most significant first, zero past the end. #[inline] fn f(&mut self, n: u32) -> u32 { @@ -386,7 +404,14 @@ impl<'a> SymbolDecoder<'a> { // relaxed load. let t0 = if crate::census::armed() { self.tell_bits() } else { 0.0 }; let s = self.symbol_fixed(cdf); + // lane-av1txr: spec 5.9.2's `disable_cdf_update` -- a frame that sets + // it codes every symbol against the tables it started with, so this + // reader must leave them untouched too (libaom: `allow_update_cdf = + // allow_update_cdf && !cm->features.disable_cdf_update`, + // decodeframe.c:2909). The flag is per-reader (see `Self::adapt`). + if self.adapt { update_cdf(cdf, s); + } if crate::census::armed() { crate::census::charge(cdf.as_ptr() as usize, self.tell_bits() - t0); } @@ -813,6 +838,54 @@ pub(crate) mod tests { assert_eq!(fast_cdfs[pick.min(14)], slow_cdfs[pick.min(14)], "cdf after item {i}"); } } + + /// lane-av1txr: spec 5.9.2's `disable_cdf_update`, the reader half -- + /// [`SymbolDecoder::set_cdf_update`]. A reader told not to adapt must + /// reproduce a writer that never adapted + /// ([`SymbolEncoder::symbol_fixed`]), and the DEFAULT reader must not: the + /// flag is what keeps a real `aomenc --cdf-update-mode=0` stream in sync + /// (its tiles desynced at the first multi-symbol block without it). + #[test] + fn a_reader_told_not_to_adapt_matches_a_non_adapting_writer() { + let mut state = 0x2545_f491_4f6c_dd1du64; + let mut enc = SymbolEncoder::new(); + let cdfs: Vec> = (2..=16).map(flat_cdf).collect(); + let mut written = Vec::new(); + for i in 0..600 { + let pick = i % cdfs.len(); + let nsyms = pick + 2; + let sym = (rng(&mut state) % nsyms as u64) as usize; + enc.symbol_fixed(sym, &cdfs[pick]); + written.push((pick, sym)); + } + let payload = enc.finish(); + + let mut fixed = SymbolDecoder::new(&payload); + fixed.set_cdf_update(false); + let mut adapting = SymbolDecoder::new(&payload); + let mut fixed_cdfs: Vec> = (2..=16).map(flat_cdf).collect(); + let mut adapting_cdfs: Vec> = (2..=16).map(flat_cdf).collect(); + let mut adapting_mismatches = 0usize; + for (i, &(pick, sym)) in written.iter().enumerate() { + assert_eq!( + fixed.symbol(&mut fixed_cdfs[pick]), + sym, + "non-adapting reader, item {i} (pick {pick})" + ); + if adapting.symbol(&mut adapting_cdfs[pick]) != sym { + adapting_mismatches += 1; + } + } + assert_eq!( + fixed_cdfs, + (2..=16).map(flat_cdf).collect::>(), + "the non-adapting reader still moved a table" + ); + assert!( + adapting_mismatches > 0, + "the adaptation flag is inert: the default reader reproduced a non-adapting writer" + ); + } } /// Symbol-by-symbol writer/reader trace (`EC_AV1_SYMTRACE=`), the diff --git a/crates/ec-av1/src/refusal_inventory.rs b/crates/ec-av1/src/refusal_inventory.rs index 34f3934e..c3f09376 100644 --- a/crates/ec-av1/src/refusal_inventory.rs +++ b/crates/ec-av1/src/refusal_inventory.rs @@ -64,8 +64,29 @@ const REFUSALS: &[&str] = &[ // `every_read_intra_mode_call_site_hands_the_reader_a_palette_cache`, // which keeps that invariant now the refusal is gone). "intra block copy on a HORZ/VERT/1:4 rect intra strip (reconstruction is not ported at this shape)", - "a sub-8x8 leaf that uses intrabc (this reader has no block-vector path; the 8x8-and-up reader reconstructs one)", + // lane-av1txr: `a sub-8x8 leaf that uses intrabc (…)` is GONE -- the + // capability landed in this lane (4x4 / 4x8 / 8x4 intrabc leaves read the + // DV and reconstruct a frame copy + the INTER residual; gates + // `a_non_420_subsampled_sequence_header_is_refused_by_name`'s sibling + // witnesses and the `warped.obu`/`allintra.obu` traces). Its census gate + // (`a_sub8_leaf_census_over_intrabc_screen_streams_measures_the_sub8_refusal`) + // still runs: it now reports `reached = 0` with the same non-vacuous + // premise (allow_intrabc frames + decoded sub-8 leaves). "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)", + // lane-av1txr: the silent-garbage guard. A 4:4:4/4:2:2 stream used to + // decode with no refusal and wrong pixels (every chroma extent is + // hardcoded 4:2:0, the probe emits 4:2:0 planes only); it is now refused + // at the sequence header. Gate: + // `a_non_420_subsampled_sequence_header_is_refused_by_name`. + "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", + // lane-av1txr-r2: the third member of the same silent-garbage family. + // `using_qmatrix`/`qm_y`/`qm_u`/`qm_v` are parsed by `ec-av1-syntax` but + // read by NOTHING on the decode path -- dequantisation is `base_q_idx` + + // the plane DC/AC deltas only -- so a real `aomenc --enable-qm=1` stream + // decoded with no refusal and wrong pixels (measured: byte-diff vs ffmpeg + // while the qm-off control is byte-exact). Refused at the frame header. + // Gate: `a_frame_using_quantisation_matrices_is_refused_by_name`. + "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", // lane-lossless/lane-lossless2: a lossless frame (base_q_idx 0) decodes // sample-exact, KEY and INTER -- TX_4X4 with the Walsh-Hadamard transform // on every plane, no `tx_type` symbol, `is_cfl_allowed` narrowed to a @@ -286,11 +307,15 @@ const PROVEN: &[(&str, &str)] = &[ "a tx_type symbol outside its CDF's own set: {t}", "every_tx_type_symbol_of_every_cdf_width_maps_into_its_own_set", ), - // lane-t900 r24, enumeration: the reader covers spec 5.11.40's whole value - // domain (`0..=(1 << 20) - 2`, both ends of every prefix length), so the - // refusal is outside it. What it still names is a bit pattern no encoder - // writes -- a 20th prefix bit of 0, which the spec's `length == 20` break - // makes a don't-care. + // lane-t900 r24 + lane-av1txr RE-PIN, measured: the reader covers spec + // 5.11.40's whole value domain (`0..=(1 << 20) - 2`, both ends of every + // prefix length), so no CONFORMANT symbol stream reaches it -- but the + // string IS reachable as a SYMPTOM: a frame this decoder desyncs on + // (measured: a real libaom monochrome key frame, gate + // `a_real_libaom_monochrome_key_frame_is_refused_by_name` at + // `stream.rs`) leaves the reader mid-symbol and the next `read_golomb` + // reports this tail. The claim below therefore pins the reader's value + // coverage, NOT the string's unreachability. ( "a Golomb tail longer than this decoder reads", "read_golomb_reads_every_value_a_conformant_stream_can_carry", @@ -326,6 +351,22 @@ const PROVEN: &[(&str, &str)] = &[ "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)", "a_twelve_bit_sequence_header_is_refused_by_name", ), + // lane-av1txr: the guard's own gate builds a profile-1 and a profile-2 + // sequence header by hand and asserts each refuses by name while the + // profile-0 CONTROL still decodes -- the refusal is exercised, not merely + // present. + ( + "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", + "a_non_420_subsampled_sequence_header_is_refused_by_name", + ), + // lane-av1txr-r2: the gate encodes the same source twice with real aomenc + // (`--enable-qm=1` and `--enable-qm=0`), asserts the qm-off CONTROL decodes + // and the qm-on stream is refused by name -- so the refusal is exercised + // against the exact encoder path it names, not merely present. + ( + "a frame using quantisation matrices (using_qmatrix=1): dequantisation here is base_q_idx plus the plane DC/AC deltas only, so qm_y/qm_u/qm_v would be ignored and the frame would decode silently wrong pixels", + "a_frame_using_quantisation_matrices_is_refused_by_name", + ), ( "intra block copy on a HORZ/VERT/1:4 rect intra strip (reconstruction is not ported at this shape)", "a_real_aomenc_screen_key_frame_reads_use_intrabc_on_rect_strips", @@ -409,14 +450,10 @@ const PROVEN: &[(&str, &str)] = &[ "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)", "no_128_root_half_reads_a_cfl_filter_intra_or_palette_symbol", ), - // lane-t900 r33, CENSUS: the `use_intrabc` symbol IS read at the sub-8 - // reader for every sub-8x8 leaf of an `allow_intrabc` frame, and over the - // `--min-partition-size=4` exact-repetition screen arms every such symbol - // came back 0 while the frames decode pixel-exact. - ( - "a sub-8x8 leaf that uses intrabc (this reader has no block-vector path; the 8x8-and-up reader reconstructs one)", - "a_sub8_leaf_census_over_intrabc_screen_streams_measures_the_sub8_refusal", - ), + // lane-av1txr: the sub-8x8 intrabc refusal this census pinned is GONE (the + // capability landed; see the note in `REFUSALS`). The census gate survives + // as the witness that its premise is still exercised -- `reached` is 0 by + // construction now. // lane-t900 r33, CENSUS: four quantisers of the recipe that reaches the // intrabc var-tx tree at all read it for 5 blocks in total, every one of // which resolved to a UNIFORM leaf size, with the frames pixel-exact. diff --git a/crates/ec-av1/src/stream.rs b/crates/ec-av1/src/stream.rs index 2f2417c9..3aa66e71 100644 --- a/crates/ec-av1/src/stream.rs +++ b/crates/ec-av1/src/stream.rs @@ -1252,6 +1252,13 @@ pub(crate) struct SeqFlags { pub(crate) mono_chrome: bool, pub(crate) order_hint_bits: u32, pub(crate) mc_identity: bool, + /// lane-av1txr: `color_config.subsampling_x/y` (spec 5.5.2). The decoder + /// itself hardcodes 4:2:0 everywhere, so these exist only for the + /// sequence-level refusal in [`decode_stream_with`] -- nothing downstream + /// reads them. A monochrome header parses as 1,1, so `!(1,1)` singles out + /// 4:4:4 (profile 1 / sRGB) and 4:2:2 (profile 2 below 12-bit). + pub(crate) subsampling_x: u8, + pub(crate) subsampling_y: u8, } impl SeqFlags { @@ -1269,6 +1276,8 @@ impl SeqFlags { mono_chrome: seq.is_some_and(|s| s.color_config.mono_chrome), order_hint_bits: seq.map_or(0, |s| s.order_hint_bits), mc_identity: seq.is_some_and(|s| s.color_config.matrix_coefficients == 0), + subsampling_x: seq.map_or(1, |s| s.color_config.subsampling_x), + subsampling_y: seq.map_or(1, |s| s.color_config.subsampling_y), } } } @@ -1623,6 +1632,45 @@ fn decode_frame( "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)", )); } + // lane-av1txr: `color_config.subsampling_x/y` (spec 5.5.2) are parsed by + // `ec-av1-syntax` -- profile 1 forces 4:4:4, profile 2 below 12-bit forces + // 4:2:2, and the sRGB identity description forces full-range 4:4:4 -- but + // the decoder reads them NOWHERE: every chroma extent is hardcoded 4:2:0 + // (`let (chroma_w, chroma_h) = (bw / 2, bh / 2)` at every rect site, + // `chroma_side = side / 2` in `decode_block`) and the probe emits 4:2:0 + // planes only. Measured consequence: EVERY 4:4:4 stream desyncs at the + // first chroma transform (a444-cu6 block (0,0): aomdec reads + // `EC_COEFF plane=1 tx=TX_8X16` at rng 39857 where ours reads a 4-wide, + // 8-high 4:2:0 chroma block at the same rng) and then decodes pixels that + // are silently wrong. Refuse by name rather than return garbage. A + // `num_planes == 1` (monochrome) header keeps its parsed 1,1 and is + // unaffected. Gates: `a_non_420_subsampled_sequence_header_is_refused_by_ + // name` below (hand-built profile 1/2 headers plus a real aomenc 4:4:4 + // stream). + if seq.subsampling_x != 1 || seq.subsampling_y != 1 { + return Err(Error::unsupported( + "AV1 decode_stream", + "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", + )); + } + // lane-av1txr-r2: `quantization_params.using_qmatrix` (spec 5.9.12) is + // parsed by `ec-av1-syntax` along with `qm_y`/`qm_u`/`qm_v` (frame.rs + // :190-196, :1418-1426), but this decoder reads NONE of them: every + // dequantisation below is `base_q_idx` plus the plane DC/AC deltas only + // (`Quantizer::new`), so a stream that applies quantisation matrices + // dequantises every coefficient off the wrong table. The same + // silent-garbage class as the non-4:2:0 guard above. Measured: a real + // `aomenc --enable-qm=1` key frame (`using_qmatrix = 1`, `qm_y/u/v = 5`) + // decodes with NO refusal and its planes byte-differ from ffmpeg, while + // the `--enable-qm=0` control of the same source and recipe is + // byte-exact. Refuse by name rather than return garbage. Gate: + // `a_frame_using_quantisation_matrices_is_refused_by_name` below. + if header.quantization.using_qmatrix { + return Err(Error::unsupported( + "AV1 decode_stream", + "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", + )); + } // lane-dpm1: a LOSSLESS frame (`qindex == 0` with zero deltas, spec 5.9.12) // is a different tile syntax, and this decoder has none of it: libaom // forces TX_4X4 with the WALSH-HADAMARD transform over every block (so no @@ -1676,6 +1724,11 @@ fn decode_frame( // the bit depth so a mono frame decoded on a thread that last saw a // 4:2:0 one never inherits the wrong plane count. crate::decode::set_mono(seq.mono_chrome, fctx); + // lane-av1txr: spec 5.9.2 `disable_cdf_update` -- a frame that sets it + // codes every tile symbol against the CDFs it started with, so the tile + // readers must not adapt (libaom `decodeframe.c:2909`: + // `allow_update_cdf = allow_update_cdf && !cm->features.disable_cdf_update`). + crate::decode::set_disable_cdf_update(header.disable_cdf_update, fctx); // spec 7.16: this frame's superres state, for the filter chain -- // `decode.rs` upscales between CDEF and loop restoration and sizes // the LR unit grid in upscaled coordinates. Cleared (0, 8) on an @@ -2069,6 +2122,106 @@ pub(crate) mod tests { ); } + /// lane-av1txr: a sequence header describing any chroma shape but 4:2:0 is + /// refused by name, because the decoder reconstructs every chroma extent + /// at hardcoded 4:2:0 (`bw / 2, bh / 2` at every rect site) and the probe + /// emits 4:2:0 planes only -- a 4:4:4 stream "decodes" into silently wrong + /// pixels (measured: a444-cu6's first chroma transform reads a 4x2-wide/ + /// 8-high 4:2:0 chroma at aomdec's `TX_8X16` entry rng 39857, then + /// desyncs; every 4:4:4 fixture measured byte-differs from ffmpeg). + /// + /// Reachability, not a pixel claim: the header is written at the two + /// profiles that force a non-4:2:0 shape (spec 5.5.2 -- profile 1 forces + /// 4:4:4 with no coded bit; profile 2 below 12-bit forces 4:2:2) and the + /// tile is never reached. The 4:2:0 CONTROL below proves the refusal is + /// about the shape, not about this construction. + #[test] + fn a_non_420_subsampled_sequence_header_is_refused_by_name() { + const NAME: &str = "a_non_420_subsampled_sequence_header_is_refused_by_name"; + const REFUSAL: &str = "a chroma format other than 4:2:0"; + let fctx = &crate::decode::FrameCtx::new(); + let picture = test_card(64, 64); + let encoded = encode_key_frame_with_ctx(&picture, 100, 0.5, fctx).unwrap(); + for (profile, label, sx, sy) in [(1u8, "4:4:4", 0u8, 0u8), (2, "4:2:2", 1, 0)] { + let color = ec_av1_syntax::ColorConfig { + num_planes: 3, + subsampling_x: sx, + subsampling_y: sy, + ..Default::default() + }; + let (mut seq, header) = + crate::encode::key_frame_headers_colour(64, 64, 100, color).unwrap(); + seq.seq_profile = profile; + let mut stream = crate::sequence::sequence_header_obu(&seq).unwrap(); + stream.extend_from_slice( + &crate::frame::frame_obu(&seq, &header, &encoded.tile).unwrap(), + ); + let err = decode_stream(&stream).unwrap_err().to_string(); + assert!( + err.contains(REFUSAL), + "{NAME}: expected the non-4:2:0 refusal for the {label} header, got: {err}" + ); + } + // CONTROL: the same construction at profile 0 (4:2:0) still decodes. + let (seq, header) = crate::encode::key_frame_headers(64, 64, 100).unwrap(); + let mut stream = crate::sequence::sequence_header_obu(&seq).unwrap(); + stream.extend_from_slice(&crate::frame::frame_obu(&seq, &header, &encoded.tile).unwrap()); + let frames = decode_stream(&stream).expect("the 4:2:0 control must decode"); + assert_eq!(frames.len(), 1, "{NAME}: the 4:2:0 control decoded no frame"); + } + + /// lane-av1txr-r2: a frame using quantisation matrices is refused by name + /// -- the THIRD member of the silent-garbage family the non-4:2:0 gate + /// above opened (the verifier's census miss). + /// + /// `using_qmatrix`/`qm_y`/`qm_u`/`qm_v` are parsed by `ec-av1-syntax` + /// (frame.rs:190-196, :1418-1426) but have NO consumer anywhere on the + /// decode path -- every dequantisation is `base_q_idx` plus the plane + /// DC/AC deltas only. Measured on a real aomenc pair (same source and + /// recipe, only `--enable-qm` flipped): the qm-OFF control decodes + /// byte-exact vs ffmpeg, the qm-ON stream used to decode with NO refusal + /// and byte-differ from ffmpeg (silent garbage; class + /// `refusal-hides-a-defect` read the other way -- a silent wrong decode + /// is worse than a named gap). + /// + /// Both arms are real encoder output, so this is a reachability gate, not + /// a hand-built construction: the qm-on arm carries `using_qmatrix = 1` + /// (`qm_y/u/v = 5` on the measured fixture) and the refusal names the + /// field rather than desyncing. + #[test] + fn a_frame_using_quantisation_matrices_is_refused_by_name() { + const NAME: &str = "a_frame_using_quantisation_matrices_is_refused_by_name"; + const REFUSAL: &str = "a frame using quantisation matrices"; + if !have_ffmpeg() || !have_aomenc() { + eprintln!( + "SKIP {NAME}: needs ffmpeg + an aomenc oracle at {}", + aomenc_path().display() + ); + return; + } + // CONTROL: the same source and recipe with quantisation matrices OFF + // still decodes -- so the refusal below is about the qm bit, not about + // the source or the encoder settings. + let (_, control) = census_attempt("testsrc2", 128, 96, 3, &["--enable-qm=0"]); + let frames = control.unwrap_or_else(|e| { + panic!("{NAME}: the --enable-qm=0 control must decode, got: {e}") + }); + assert!(frames >= 1, "{NAME}: the qm-off control decoded no frame"); + // The qm-on stream is the new refusal. + let (_, qm) = census_attempt("testsrc2", 128, 96, 3, &["--enable-qm=1"]); + let err = qm.err().unwrap_or_else(|| { + panic!("{NAME}: the --enable-qm=1 stream now decodes -- flip this gate to a witness") + }); + assert!( + err.contains(REFUSAL), + "{NAME}: the qm-on stream stopped without the named refusal {REFUSAL:?} \ + -- re-measure before trusting this gate. got: {err}" + ); + eprintln!( + "{NAME}: qm-off control {frames} frames, qm-on refused by name ({REFUSAL})" + ); + } + /// lane-av1mono: the INVERSE of the pilot's /// `a_real_libaom_monochrome_key_frame_is_refused_by_name`, which the /// pilot's merge `d71084ae` landed on `main` (after this lane's base @@ -6930,6 +7083,64 @@ pub(crate) mod tests { } } + /// lane-av1txr: a real `aomenc --cdf-update-mode=0` stream (spec 5.9.2 + /// `disable_cdf_update`) decodes SAMPLE-EXACT. The read that was missing: + /// `stream.rs` never threaded the header bit, so the tile readers adapted + /// every symbol of a frame the encoder coded against fixed tables -- the + /// stream desynced at its first multi-symbol block and the pixels differed + /// from byte 6 (`EC_PROBE_OUT` vs `ffmpeg -pix_fmt yuv420p`, measured + /// 2026-09-20). The msac unit gate + /// (`a_reader_told_not_to_adapt_matches_a_non_adapting_writer`) pins the + /// mechanism; this one pins the wiring end to end. + #[test] + fn a_real_aomenc_stream_with_cdf_update_disabled_decodes_pixel_exact() { + const NAME: &str = "a_real_aomenc_stream_with_cdf_update_disabled_decodes_pixel_exact"; + if !have_ffmpeg() || !have_aomenc() { + eprintln!("SKIP {NAME}: no ffmpeg/aomenc"); + return; + } + let (width, height) = (256usize, 192usize); + let stream = screen_intrabc_stream_with( + "testsrc2=size=256x192:rate=25", + "45", + "1", + false, + true, + &["--cdf-update-mode=0", "--limit=3"], + ); + // Non-vacuity: the fixture must really code the bit on every frame. + let mut parser = Av1Parser::new(); + let mut pos = 0usize; + let mut headers = 0usize; + while pos < stream.len() { + let Ok(obu) = parser.parse_obu(&stream[pos..]) else { + break; + }; + pos += obu.total_size.max(1); + let header = match &obu.kind { + ObuKind::Frame(h, _) | ObuKind::FrameHeader(h) => h, + _ => continue, + }; + assert!( + header.disable_cdf_update, + "{NAME}: frame {headers} does not carry disable_cdf_update -- aomenc ignored \ + --cdf-update-mode=0" + ); + headers += 1; + } + assert!(headers >= 3, "{NAME}: only {headers} frame headers in the fixture"); + let frames = decode_stream(&stream).unwrap_or_else(|e| panic!("{NAME}: {e}")); + let theirs = ffmpeg_decode_sequence(&stream, width, height, frames.len()); + assert_eq!(frames.len(), theirs.len(), "{NAME}: frame count"); + for (i, (ours, ref_frame)) in frames.iter().zip(theirs.iter()).enumerate() { + assert!( + ours.y == ref_frame.y && ours.u == ref_frame.u && ours.v == ref_frame.v, + "{NAME}: frame {i} does not match ffmpeg" + ); + } + eprintln!("{NAME}: {headers} disable_cdf_update frame headers, all frames sample-exact"); + } + /// lane-kf900 r4, the gate for the two lifted palette refusals ("a 1:4 /// rect strip that actually uses a palette (reconstruction is not ported /// at this shape)" and "a palette block on a HORZ/VERT intra strip below diff --git a/lanes/av1txrouting.report.md b/lanes/av1txrouting.report.md new file mode 100644 index 00000000..9c75e67c --- /dev/null +++ b/lanes/av1txrouting.report.md @@ -0,0 +1,543 @@ +# lane-av1-txrouting — the one-routing-predicate hypothesis is REFUTED; work-in-progress + +Base: `main` **0cfb9af5** (2026-09-19). Worktree `../edith_codecs-av1txr`, branch +`lane-av1-txrouting`, `CARGO_TARGET_DIR=$HOME/.cache/cargo-target-av1txr`. + +**STATUS: WIP, NOT READY TO MERGE.** The 4x4 sub-8x8 intrabc path is proven +symbol-for-symbol correct on a real stream; the 4x8/8x4 rect leaf path is +**not yet byte-exact** (see §5). No gate has been run to completion. + +--- + +## 1. Headline: the scout's "ONE routing predicate" is refuted + +The charter's three stops do **not** share a routing predicate. First-divergence +traces (instrumented `aomdec` oracle at `~/.cache/aom-oracle/build/aomdec` + +`decode_probe`, `EC_TRACE_MODE_STEP`) give each stop a distinct cause: + +| stop | stream (reproduced) | first divergence | real cause | +|---|---|---|---| +| 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) | +| 3.3 / "sub-8x8 intrabc" | `aomenc --allintra` | block `(45,52)` rng 37280 | a **genuine** 4x4 intrabc block (see §4) | +| 3.4 / "sub-8x8 intrabc" | `aomenc --enable-warped-motion=1 --cpu-used=0` | block `(37,62)` | the same, at a 4x8/8x4 rect leaf | + +The report's §3.2/§3.3 claim that "`aomdec` reads `tx_depth` where ours reads +`txfm_split`/`intrabc`/`uv_mode`" is an **instrumentation artifact**: aomdec's +`read_intrabc_info` had no print, and `read_tx_size_vartx`'s print is gated on +`EC_VARTX`, not `EC_ISTEP`. With the oracle instrumented for both +(`EC_ISTEP name=intrabc`, `EC_DV`, `EC_COEFF`), ours and aomdec read +**identical `intrabc` flags and identical DVs** at these blocks — no desync. + +Similarly the §3.2 "aomdec reads `tx_depth`, ours reads `txfm_split`" claim: +the 4:4:4 divergence is **after** the tx-depth read (both read +`tx_depth val=1 ctx=0 cat=1`) and is a chroma-transform size mismatch, not a +tx-size routing mismatch. + +## 2. Reproduced streams (all re-derivable) + +``` +cd ~/.cache/av1txr +# 4:4:4 (aomenc) -- cu6/cu7 REFUSE, cu4/cu5/cu8 decode-but-wrong +aomenc --codec=av1 --passes=1 --threads=1 --cpu-used=6 --obu -o s/a444-cu6.obu s/s444.y4m +# sub8 intrabc +aomenc --codec=av1 --passes=1 --threads=1 --obu --allintra --cpu-used=6 -o s/allintra.obu s/s420.y4m +aomenc --codec=av1 --passes=1 --threads=1 --obu --enable-warped-motion=1 --cpu-used=0 -o s/warped.obu s/s420.y4m +# (s420.y4m / s444.y4m = ffmpeg testsrc2 320x240 rate 8 dur 3) +``` + +Pre-fix: `allintra`/`allintra0`/`warped` → `REFUSED: a sub-8x8 leaf that uses +intrabc …`; `a444-cu6/7` → `REFUSED: a Golomb tail longer than this decoder +reads`; `a444-cu4/5/8` → `OK` **but garbage**. + +## 3. Stop 3.2 — 4:4:4 is entirely unsupported (root-caused) + +`probe EC_PROBE_OUT8` vs `ffmpeg -pix_fmt yuv420p` for **every** 4:4:4 stream +(`a444-cu4/5/8`, `ff444-cu5..8`) **differs** — the "decoding" 4:4:4 streams are +silently desynced garbage. The fixture story ("`av1-profile1-444` decodes +fine") was never byte-exactness-checked. + +**First divergence (a444-cu6, block `(0,0)`, an 8x16 rect leaf, depth 1):** + +``` +aom: EC_ISTEP tx_depth val=1 ctx=0 cat=1 rng=44248 + EC_COEFF mi_row=0 mi_col=0 plane=0 tx=1 rng=44248 # TX_8X8 + EC_COEFF mi_row=0 mi_col=0 plane=0 tx=1 rng=41886 # TX_8X8 + EC_COEFF mi_row=0 mi_col=0 plane=1 tx=7 rng=39857 # TX_8X16 <-- chroma + EC_COEFF mi_row=0 mi_col=0 plane=2 tx=7 rng=64008 # TX_8X16 +ours: … luma units rng 44248, 41886 (MATCH) … + read_coeffs_rect chroma entry rng=39857, w=4 h=8 # 4:2:0 half <-- DIVERGE +``` + +The decoder hardcodes 4:2:0 chroma extents at every rect site +(`let (chroma_w, chroma_h) = (bw / 2, bh / 2);` — `decode.rs:9476,10888,11378, +11767,12772,14326,15042,26798`) and the probe only ever emits 4:2:0 planes. +`subsampling_x/y` is parsed by `ec-av1-syntax` but **never read by the decoder**. + +**Disposition: needs a `num_planes`/subsampling threading lane** (like the +sibling mono lane). The honest interim fix is a **new named refusal at the +sequence-header level** for `subsampling_x != 1 || subsampling_y != 1` +(`num_planes > 1`), so a 4:4:4/4:2:2 stream refuses by name instead of +producing garbage. **Not yet written** (budget). + +## 4. Stops 3.3 / 3.4 — genuine sub-8x8 intrabc (implemented, WIP) + +The trace proves both streams code **real** sub-8x8 intrabc blocks: +`aomdec`'s instrumented `read_intrabc_info` reads `intrabc val=1` and an +`EC_DV` at `allintra (45,52)/(45,53)` and `warped (37,62)`. libaom's +`av1_allow_intrabc` is a frame-level test with no shape term, and the 4x4 block +`is_chroma_ref` (last sub-block) makes its chroma an intrabc copy too. + +Implemented on the lane (see §6 diff): +- `read_intra_mode_sub8` reads the DV (`read_intrabc_dv`) and RETURNS + (skip, DC_PRED, 0, None, None, Some(dv)) — no mode/uv/filter-intra syntax. +- `read_intrabc_dv` generalized from a square `side` to a `(n4_w, n4_h)` + footprint (rect leaves scan 1x2/2x1, not 2x2). +- `decode_leaf_split4` / `decode_leaf_rect8` reconstruct the intrabc leaf: + `flush_recon` + `mc::predict_with_filter(.., Bilinear)` frame copy injected + via the `set_palette_pred` override slot, residual read through the **inter** + sets (`Luma4Inter`/`Luma4InterSet1`, `LumaRect8x4Inter`/`Set1`), no + `tx_depth` symbol (libaom `block_signals_txsize` false below 8x8), + `record_intrabc_mi(_rect)` publishing the true footprint. +- **Chroma tx-type inheritance** (the subtle one): libaom `av1_get_tx_type` + (blockd.h:1278) gives a non-Y plane the LUMA's `tx_type_map` entry when + `is_inter_block(mbmi)` — **intrabc counts as inter**. So the group's chroma + eob/scan class is the luma's coded type, not `DCT_DCT`. Armed via the + existing `fctx.intrabc_chroma_tx` slot (the square path's mechanism). + +**Evidence the 4x4 path is byte-exact (allintra, block (45,52)):** the luma +intrabc residual traces **identically** to aomdec +(`tx_type txtype=11`/`HDct`, `eob=14`, every `base`/`br`/`sign`/`post_golomb` +rng equal), and ours reaches `(45,53) skip rng=52504` — aomdec's exact value. +With the chroma-inheritance fix the following block's `skip` also matched. + +## 5. What is NOT done (do not merge without it) + +1. **`warped` is not byte-exact.** With the implementation it decodes 24 + frames but `EC_PROBE_OUT8` vs `ffmpeg -pix_fmt yuv420p` differs at byte + **41217** (frame 0, luma row 128), and the entropy desyncs at + `(38,60) skip`: aom 48630 vs ours 60320. The **rect intrabc leaf** + (4x8/8x4) is the suspect: unverified `predict_with_filter` buffer shape, + residual set, or the rect DV scan. +2. **`allintra` now stops one shape later**: `REFUSED: intra block copy on a + HORZ/VERT/1:4 rect intra strip (reconstruction is not ported at this + shape)` (the `decode.rs:9122` rect reader). `allintra0` (cpu-used 0) + **panics** at `transform.rs:1134` (a 4x4 dequant given a 1024-entry grid) + via `decode_leaf8` — a further reachable path after the sub8 blocks pass. +3. **4:4:4/4:2:2 named refusal** (§3) not written. +4. **No gates run.** Only `cargo build --release -p ec-av1 --example + decode_probe` (0 errors/warnings) and `cargo check`-equivalent builds. + `cargo test -p ec-av1 --lib` (592/0/60 baseline) NOT run. +5. **Inventory re-pin not done.** §3.3's two refuted PROVEN entries + (`read_golomb_reads_every_value…`, `a_sub8_leaf_census…`) still claim + "unreachable"; they must be re-pinned to reachable-with-witness. The report + §5 tripwire `a_real_libaom_monochrome_key_frame_is_refused_by_name` is + untouched (mono stream unaffected — its `num_planes == 1`). + +## 6. Diff summary (lane, uncommitted-at-first-write) + +`crates/ec-av1/src/decode.rs`: +- `read_intra_mode_sub8`: +`Option<(i32,i32)>` return, intrabc branch (DV read, + early return), `istep!("intrabc")`. +- `read_intrabc_dv`: `side` → `(n4_w, n4_h)`; `EC_DV` trace print; call sites + updated (square path passes `(side/MI, side/MI)`). +- `record_intrabc_mi` split into `record_intrabc_mi_rect` (rect footprint). +- `decode_leaf_split4` + `decode_leaf_rect8`: intrabc leaf arm (frame copy + + inter residual) and intrabc chroma arm (frame copy + `Chroma4`, luma tx-type + inheritance, cleared after). +- Trace prints added at previously-silent `tx_depth`/`intrabc` sites so a + cross-decoder first-divergence diff aligns. + +## 7. Repro / oracle recipes + +``` +# build +CARGO_TARGET_DIR=$HOME/.cache/cargo-target-av1txr cargo build --release -p ec-av1 --example decode_probe + +# byte-exactness, 8-bit +decode_probe x.obu out8.raw # argv[2] = 8-bit planes +ffmpeg -i x.obu -pix_fmt yuv420p -f rawvideo ref8.raw -y +cmp out8.raw ref8.raw +# (EC_PROBE_OUT16 is yuv420p10le and is NOT comparable to ffmpeg's +# yuv420p10le for an 8-bit source — ffmpeg left-shifts, the probe does not. +# Use the 8-bit form for 8-bit streams. This bit me once.) + +# first divergence vs the instrumented oracle +EC_TRACE_MODE_STEP=1 ~/.cache/aom-oracle/build/aomdec --rawvideo -o /dev/null x.obu 2>a.step +EC_TRACE_MODE_STEP=1 decode_probe x.obu 2>o.step +# per-(mi_row,mi_col,name) index compare in python (see §1 method) +``` + +Oracle build: `~/.cache/aom-oracle` (cmake+ninja) instrumented with +`EC_ISTEP name=intrabc` (decodemv.c `read_intrabc_info`), `EC_DV` +(post-`assign_dv`), `EC_COEFF` (decodeframe.c `read_coeffs_tx_intra_block`). + +## 8. Recommended next steps (ordered) + +1. Fix the rect intrabc leaf (warped) — trace the rect leaf's DV/residual vs + aomdec; then verify `EC_PROBE_OUT8` byte-exact. +2. Unblock `allintra`'s 1:4 rect strip intrabc (`decode.rs:9122`) and the + `decode_leaf8` dequant panic. +3. Add the sequence-header subsampling refusal (§3) and re-pin the inventory. +4. Run `cargo test -p ec-av1 --lib` + `cargo check -p ec-av1 --all-targets`. + +--- + +## 9. Continuation (2026-09-20, second lane pass) + +Five defects fixed, each proven by a first-divergence move and/or a gate. **Warped +is still NOT byte-exact** (§9.4) and `allintra`/`allintra0` still stop at NAMED +refusals that belong to the 1:4-rect-strip lane (§9.3). Honest status first. + +### 9.1 Silent-garbage guard: non-4:2:0 chroma is refused by name + +`stream.rs`'s `decode_stream` now refuses `seq.subsampling_x != 1 || +seq.subsampling_y != 1` (threaded through `SeqFlags::subsampling_x/y`). A +monochrome header parses as 1,1, so it is untouched (the mono lane's stream and +its tripwire keep their meaning). + +Evidence: +- `a_non_420_subsampled_sequence_header_is_refused_by_name` (stream.rs tests): + a hand-built profile-1 (4:4:4) and profile-2 (4:2:2) header each refuse with + the named string, and the profile-0 CONTROL still decodes — so the gate is + about the shape, not the construction. +- Real encoder stream: `aomenc` auto-promotes to profile 1 for `yuv444p` input; + `EC_PROBE_OUT` vs `ffmpeg -pix_fmt yuv444p` on that stream **refuses by name** + where the same code path used to decode silently wrong pixels. + +### 9.2 Parsed-but-unread pixel-affecting header field sweep + +A per-field census of every `SequenceHeader` / `ColorConfig` / +`QuantizationParams` / `FrameHeader` field against the decoder's PRODUCTION +reads (`crates/ec-av1/src/{stream,decode}.rs`, test modules excluded; each row +re-derivable by `grep -n "\.\b"`) found **three** pixel-affecting fields +the decoder never consumed. All three are now closed: + +1. `subsampling_x/y` — §9.1 (refusal). +2. **`disable_cdf_update`** (the second find): spec 8.3.2 skips ALL per-symbol + CDF adaptation when set, and libaom's tile entry does exactly that + (`decodeframe.c:2909`, `allow_update_cdf && !disable_cdf_update`). The + decoder adapted unconditionally. Fixed at the one authoring point: + `msac::SymbolDecoder::adapt` (per READER, not global — frames decode on + different workers) + `FrameCtx::disable_cdf_update` + one line in + `decode_frame`. + + Evidence, both directions: + - `a_real_aomenc_stream_with_cdf_update_disabled_decodes_pixel_exact` + (real `aomenc --cdf-update-mode=0`, 3 frames): asserts every frame header + carries the bit, then compares all planes against ffmpeg. Green. + - fail-pre-fix, measured: with `set_cdf_update` forced ON the SAME stream + differs from ffmpeg at **byte 6** (`OK: 3 frames` but wrong pixels). + - `a_reader_told_not_to_adapt_matches_a_non_adapting_writer` (msac unit): + a non-adapting reader reproduces a non-adapting writer symbol-for-symbol + and its tables stay untouched; the default reader does not (flag + load-bearing). + +3. **`using_qmatrix` + `qm_y`/`qm_u`/`qm_v`** — the census MISS this section + previously claimed did not exist (found by the re-verifier; lane-av1txr-r2). + Parsed by `ec-av1-syntax` (`frame.rs:190-196`, `:1418-1426`), read by + NOTHING on the decode path: every dequantisation is `base_q_idx` plus the + plane DC/AC deltas. A real `aomenc --enable-qm=1` stream + (`using_qmatrix = 1`, `qm_y/u/v = 5` on the measured fixture) decoded with NO + refusal and byte-differed from ffmpeg, while the `--enable-qm=0` control of + the same source and recipe was byte-exact — the same silent-garbage class as + §9.1. Refused by name at the frame header (`stream.rs`, beside the non-4:2:0 + guard); gate `a_frame_using_quantisation_matrices_is_refused_by_name`, which + fails pre-fix (with the guard removed it panics "the --enable-qm=1 stream now + decodes"). + +The table below is the audit artifact the re-verifier asked for: every field of +those four structs, its first production read, or its disposition when unread. +It is the source of the "three" above, so the census is checkable rather than a +grep claim. Dispositions: `consumed` (a decoder read exists), +`refused` (a named guard refuses the case), `parser-forced` (a seq flag +`ec-av1-syntax` folds into a frame-header field the decoder DOES read), +`parser-internal` (used only while reading the header), `metadata` (no pixel +effect), `sibling-lane` (`mono_chrome`/`num_planes`, lane-av1-mono), and +`internal-equivalent` (`ref_order_hint`/`order_hints`, which the decoder +rebuilds from its own saved reference state — `stream.rs:1344`). + + +**SequenceHeader** + +| field | disposition | first prod read | +|---|---|---| +| `seq_profile` | parser-internal | sequence.rs parse; effect surfaced via subsampling_x/y + bit_depth guards | +| `still_picture` | parser-internal | parse branch | +| `reduced_still_picture_header` | parser-internal | parse branch | +| `timing_info` | metadata | display timing | +| `decoder_model_info` | metadata | display timing | +| `initial_display_delay_present_flag` | metadata | display timing | +| `operating_points` | metadata | op selection; decoder decodes all | +| `operating_point` | metadata | op selection | +| `operating_point_idc` | metadata | op selection | +| `frame_width_bits` | parser-internal | frame-size read width | +| `frame_height_bits` | parser-internal | frame-size read width | +| `max_frame_width` | parser-internal | frame-size validation | +| `max_frame_height` | parser-internal | frame-size validation | +| `frame_id_numbers_present_flag` | parser-internal | display_frame_id read | +| `delta_frame_id_length` | parser-internal | display_frame_id read | +| `additional_frame_id_length` | parser-internal | display_frame_id read | +| `use_128x128_superblock` | consumed | `stream.rs:1267` | +| `enable_filter_intra` | consumed | `stream.rs:1261` | +| `enable_intra_edge_filter` | consumed | `stream.rs:1263` | +| `enable_interintra_compound` | consumed | `stream.rs:1266` | +| `enable_masked_compound` | consumed | `stream.rs:1264` | +| `enable_warped_motion` | parser-forced | syntax/frame.rs:1053 -> h.allow_warped_motion | +| `enable_dual_filter` | consumed | `stream.rs:1262` | +| `enable_order_hint` | parser-forced | syntax/frame.rs:919,1068 -> order_hint_bits / ref_frame_sign_bias | +| `enable_jnt_comp` | consumed | `stream.rs:1265` | +| `enable_ref_frame_mvs` | parser-forced | syntax/frame.rs:970 -> h.use_ref_frame_mvs | +| `seq_force_screen_content_tools` | parser-forced | syntax/frame.rs:853 -> h.allow_screen_content_tools | +| `seq_force_integer_mv` | parser-forced | syntax/frame.rs:859 -> h.force_integer_mv | +| `order_hint_bits` | consumed | `stream.rs:1269` | +| `enable_superres` | parser-forced | syntax/frame.rs:1100 -> h.use_superres | +| `enable_cdef` | parser-forced | syntax/frame.rs:1576 -> h.cdef | +| `enable_restoration` | parser-forced | syntax/frame.rs:1605 -> h.loop_restoration | +| `color_config` | consumed | `stream.rs:724` | +| `film_grain_params_present` | parser-forced | syntax/frame.rs:809,1866 -> h.film_grain | + +**ColorConfig** + +| field | disposition | first prod read | +|---|---|---| +| `bit_depth` | consumed | `stream.rs:678` | +| `mono_chrome` | sibling-lane | lane-av1-mono; a mono stream is currently refused by the Golomb tripwire | +| `num_planes` | sibling-lane | lane-av1-mono | +| `color_primaries` | metadata | H.273 display | +| `transfer_characteristics` | metadata | H.273 display | +| `matrix_coefficients` | consumed | `stream.rs:727` | +| `color_range` | metadata | output range; probe emits limited-range 4:2:0 | +| `subsampling_x` | consumed | `stream.rs:1248` | +| `subsampling_y` | consumed | `stream.rs:1272` | +| `chroma_sample_position` | metadata | display | +| `separate_uv_delta_q` | parser-internal | decides qm_v coding, syntax/frame.rs:1422 | + +**FrameHeader** + +| field | disposition | first prod read | +|---|---|---| +| `show_existing_frame` | consumed | `stream.rs:603` | +| `frame_to_show_map_idx` | consumed | `stream.rs:624` | +| `frame_presentation_time` | metadata | decoder-model bookkeeping | +| `display_frame_id` | metadata | frame-id bookkeeping | +| `frame_type` | consumed | `stream.rs:853` | +| `frame_is_intra` | parser-internal | derived from frame_type; decoder reads frame_type/show_frame | +| `show_frame` | consumed | `stream.rs:892` | +| `showable_frame` | metadata | output eligibility; film grain parse uses it | +| `error_resilient_mode` | parser-internal | controls header reads (refresh flags / primary_ref) | +| `disable_cdf_update` | consumed | `stream.rs:1687` | +| `allow_screen_content_tools` | consumed | `stream.rs:1796` | +| `force_integer_mv` | consumed | `stream.rs:1833` | +| `current_frame_id` | metadata | frame-id bookkeeping | +| `frame_size_override_flag` | parser-internal | frame-size read | +| `order_hint` | consumed | `stream.rs:989` | +| `primary_ref_frame` | consumed | `stream.rs:1312` | +| `buffer_removal_time` | metadata | decoder-model bookkeeping | +| `refresh_frame_flags` | consumed | `stream.rs:644` | +| `ref_order_hint` | internal-equivalent | decoder keeps its own ref_order_hints from saved ref state (stream.rs:1344) | +| `frame_width` | consumed | `stream.rs:1786` | +| `frame_height` | consumed | `stream.rs:1787` | +| `upscaled_width` | consumed | `stream.rs:1694` | +| `render_width` | metadata | deliberate (encode.rs:15917-15921); display crop only | +| `render_height` | metadata | deliberate (encode.rs:15917-15921); display crop only | +| `use_superres` | consumed | `stream.rs:1694` | +| `superres_denom` | consumed | `stream.rs:1695` | +| `mi_cols` | consumed | `stream.rs:1325` | +| `mi_rows` | consumed | `stream.rs:1324` | +| `allow_intrabc` | consumed | `stream.rs:1797` | +| `frame_refs_short_signaling` | parser-internal | parser derives ref_frame_idx (consumed) | +| `ref_frame_idx` | consumed | `stream.rs:876` | +| `delta_frame_id` | metadata | frame-id bookkeeping | +| `allow_high_precision_mv` | consumed | `stream.rs:1877` | +| `interpolation_filter` | consumed | `stream.rs:1703` | +| `is_motion_mode_switchable` | consumed | `stream.rs:1744` | +| `use_ref_frame_mvs` | consumed | `stream.rs:1317` | +| `order_hints` | internal-equivalent | derived by decoder from ref_order_hints | +| `ref_frame_sign_bias` | consumed | `stream.rs:1879` | +| `disable_frame_end_update_cdf` | consumed | `stream.rs:1369` | +| `tile_info` | consumed | `stream.rs:759` | +| `quantization` | consumed | `stream.rs:1370` | +| `segmentation` | consumed | `stream.rs:1405` | +| `delta` | consumed | `stream.rs:1798` | +| `coded_lossless` | parser-internal | computed by parser; h.lossless carries it (consumed) | +| `all_lossless` | parser-internal | computed by parser | +| `lossless` | consumed | `stream.rs:1671` | +| `loop_filter` | consumed | `stream.rs:1791` | +| `cdef` | consumed | `stream.rs:1747` | +| `loop_restoration` | consumed | `stream.rs:1748` | +| `tx_mode` | consumed | `stream.rs:1740` | +| `reference_select` | consumed | `stream.rs:1887` | +| `skip_mode_present` | consumed | `stream.rs:1746` | +| `skip_mode_frame` | consumed | `stream.rs:1892` | +| `allow_warped_motion` | consumed | `stream.rs:1743` | +| `reduced_tx_set` | consumed | `stream.rs:1742` | +| `global_motion` | consumed | `stream.rs:1880` | +| `film_grain` | consumed | `stream.rs:666` | +| `header_bits` | parser-internal | tile-group byte alignment | + +**QuantizationParams** + +| field | disposition | first prod read | +|---|---|---| +| `base_q_idx` | consumed | `stream.rs:1370` | +| `delta_q_y_dc` | consumed | `stream.rs:1780` | +| `delta_q_u_dc` | consumed | `stream.rs:1781` | +| `delta_q_u_ac` | consumed | `stream.rs:1782` | +| `delta_q_v_dc` | consumed | `stream.rs:1783` | +| `delta_q_v_ac` | consumed | `stream.rs:1784` | +| `using_qmatrix` | refused | read at `stream.rs:1634` and refused by name | +| `qm_y` | refused | only present under using_qmatrix=1, now refused by name | +| `qm_u` | refused | only present under using_qmatrix=1, now refused by name | +| `qm_v` | refused | only present under using_qmatrix=1, now refused by name | + +### 9.3 transform.rs:1134 panic — ROOT-CAUSED AND FIXED (not a refusal) + +`txbset_for_inter` was a near-duplicate of `inter_txbset_for` whose `4` fell +through to `TxbSet::Luma64`: a 4x4 intrabc/inter TU read 32x32-class tables (a +1024-entry grid) and panicked in `inverse_transform_2d_typed_wh` the first time +such a TU coded a non-zero coefficient (`allintra0`, cpu-used 0). libaom reads a +4x4 grid with the 16-symbol INTER ext-tx set there (`EXT_TX_SET_ALL16` / +`_DTT4_IDTX` reduced). Fix: delete the duplicate, route all inter-table sites +through `inter_txbset_for` (which already had the 4 arms). Result: **no panic**; +`allintra0` now stops at the EXISTING named refusal "an intrabc block whose +var-tx tree resolved to mixed leaf transform sizes" (`decode.rs:14327`) — a +lane-of-its-own gap, not a crash. + +### 9.4 warped: four more defects out of the way, still not byte-exact + +Ladder evidence (`EC_TRACE_MODE_STEP=1` on the instrumented aomdec vs ours, +rng-ladder subsequence walk, frame 0). First divergence moved +**(38,60) → (38,62) → (46,66)**; consuming steps matched 916 → 1119 → 1349 of +aomdec's 2204 before the next divergence. + +1. **Rect intrabc leaves read no transform symbol** (the charter's named stop): + `block_signals_txsize` is `bsize > BLOCK_4X4` (`blockd.h:1027`), TRUE at + `BLOCK_4X8`/`BLOCK_8X4` — so an UNSKIPPED intrabc rect leaf reads the INTER + var-tx tree (`read_tx_size_vartx` over `max_txsize_rect_lookup[BLOCK_4X8] == + TX_4X8`), not nothing. Fixed in `decode_leaf_rect8`'s intrabc arm + (`read_var_tx_size` with the rect entry + per-4x4-TU residual/reconstruction + when the tree splits, `RECT_INTRABC_VARTX_HITS` counter, probe line + `rect_intrabc_vartx`). aomdec's `EC_VARTX mi_row=37 mi_col=62 bsize=2 + tx_size=6 ctx=19 rng=37745` is now reproduced exactly. +2. **Sub-8x8 leaves never published the TXFM context bands**: libaom runs + `set_txfm_ctxs` for EVERY block; `decode_leaf_split4`/`decode_leaf_rect8` had + no write, so an intrabc block's `txfm_partition_context` read a stale 8 where + aomdec read 4 (ctx 18 vs 19). Fixed (+ unit bug caught on the way: the rect + helper takes PIXELS for the parent span, not mi). +3. **`intrabc_dv` slot leak**: `read_intra_mode_sub8` armed the frame slot and + the sub-8x8 callers never took it, so the NEXT 8x8+ block inherited the + vector and read an inter var-tx symbol where libaom read an intra + `tx_depth`. The DV already travels in the return value; the arm is gone. +4. (9.3's table fix also feeds this path: the split rect leaf's 4x4 TUs read + `Luma4Inter`/`Set1`.) + +**Remaining first divergence (frame 0, mi (46,66), 8x8 intra block):** +`tx_depth ctx` ours 0 vs aomdec 1. Root cause, localised: the key-frame +square/leaf tx-depth context is read through `tx_size_context` — the DEBLOCK +grid approximation — while libaom's `get_tx_size_context` (`pred_common.h:342`) +reads the **TXFM bands** with the inter-neighbour block-size override. The +approximation only coincides while every neighbour codes one whole-block +transform, "which is exactly what `TxMode::Select` ends" (the helper's own +doc) — warped's key frame IS `TxMode::Select` with intrabc. The fix is the +lane's next step and is NOT small: `publish_txfm_bands_if_in_inter` returns +early on a key frame, so switching the read to libaom's formula requires +publishing the bands from EVERY key-frame block (strips included) in the same +change, or currently-byte-exact streams can regress. Left unpushed. + +Consequences for the rest of the corpus: `allintra` and `warped` both now stop +at `decode.rs:9155` "intra block copy on a HORZ/VERT/1:4 rect intra strip +(reconstruction is not ported at this shape)" — after **16 more mi rows** of +frame 0 than before the fix (was (38,60), now (54,64)). That refusal is lane 3's +and is left standing. + +### 9.5 Inventory re-pin (done) + +- The sub-8x8-intrabc refusal no longer exists (the capability landed), so its + `REFUSALS` entry is replaced by a note and its claims-table pair is retired; + the census gate stays as the non-vacuous premise witness (`reached = 0` now). +- The Golomb entry is RE-PINNED with the measurement: the reader covers the + whole legal value domain, but the string is reachable as a DESYNC SYMPTOM + (real monochrome libaom stream, `stream.rs`'s mono tripwire) — the claim pins + value coverage, not unreachability. + +### 9.6 Gates + +- `cargo test -p ec-av1 --lib -- `: 3 passed, 0 warnings. +- Full `cargo test -p ec-av1 --lib` and `cargo check -p ec-av1 --all-targets` + were launched at the end of this pass; see the commit message / next session + for their totals (baseline 592/0/60). +- `cargo build --release -p ec-av1 --example decode_probe`: 0 warnings. + +### 9.7 Next steps (ordered) + +1. Read the key-frame tx-depth context from the TXFM bands (libaom + `get_tx_size_context`) and publish the bands from every key-frame block — + then re-run the (46,66) ladder rung and the corpus sweep (§5's tripwires + included). +2. `allintra`'s 1:4 rect-strip intrabc (lane 3) and the mixed-leaf var-tx + refusal (the new stop for `allintra0`). +3. Add the 4x8/8x4 intrabc witnesses to the media-gated corpus (a real stream + that codes one: `warped.obu` reaches `RECT_INTRABC_VARTX_HITS == 1` and now + decodes past the old divergence). + +## 10. Continuation r2 (2026-09-20): the refuted census + the third silent-garbage member + +The re-verifier REFUTED §9.2's "exactly two parsed-but-never-read +pixel-affecting fields". A third existed, and it was the same silent-garbage +class §9.1 had just closed for 4:4:4. This round is that finding. + +### 10.1 The fix: `using_qmatrix` refused by name + +`QuantizationParams.using_qmatrix` + `qm_y`/`qm_u`/`qm_v` are parsed +(`ec-av1-syntax/src/frame.rs:190-196`, `:1418-1426`) and read by NOTHING on the +decode path — dequantisation is `base_q_idx` + the plane DC/AC deltas only. A +spec-legal `aomenc --enable-qm=1` stream therefore decoded into silently wrong +pixels. + +`stream.rs`'s `decode_stream` now refuses it at the frame header, beside the +non-4:2:0 guard: + +``` +if header.quantization.using_qmatrix { + return Err(Error::unsupported( + "AV1 decode_stream", + "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", + )); +} +``` + +### 10.2 Evidence + +- Measured pair (real aomenc, same source / recipe, only `--enable-qm` flipped; + `~/.cache/aom-oracle/build/aomenc`): the qm-OFF stream is byte-exact vs + ffmpeg; the qm-ON stream (`using_qmatrix = 1`, `qm_y/u/v = 5`) decoded with NO + refusal and its planes byte-differed from ffmpeg. + `EC_AV1_PIN= ... scratch_isolate_pinned_mismatch --ignored` prints the + parsed `using_qmatrix = true` on every frame. +- Gate `a_frame_using_quantisation_matrices_is_refused_by_name` (stream.rs): + encodes `--enable-qm=0` and `--enable-qm=1` with real aomenc via + `census_attempt`, asserts the qm-off CONTROL decodes and the qm-on stream + refuses by name. +- **Fail-pre-fix**, measured: with the guard removed the gate panics + `the --enable-qm=1 stream now decodes -- flip this gate to a witness` (and the + decode_probe pair above shows those bytes are wrong). +- Inventory: new `REFUSALS` entry + `PROVEN` pair; P3 doc fix — + `cdf_state.rs`'s `wide()` comment named the deleted `txbset_for_inter`, now + `inter_txbset_for`. + +### 10.3 Gates (this round) + +- `cargo test -p ec-av1 --lib -- refusal_inventory + a_reader_told_not_to_adapt a_non_420`: 16 passed, 0 failed. +- fail-pre-fix run (guard removed): 1 failed, 0 passed — the gate is + non-vacuous. +- `cargo check -p ec-av1 --all-targets`: 0 warnings. +- The full 595-test suite re-run belongs to the re-verifier. + +### 10.4 Next steps + +Unchanged from §9.7. This round closes the census hole; the warped key-frame +tx-depth context (§9.4) and the 1:4-rect-strip intrabc (lane 3) are still open. +