From 8b37c57a60f8bdf2600d49f89d386ec22f76e42f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Sun, 20 Sep 2026 01:27:31 +0300 Subject: [PATCH] ec-av1: non-420 named refusal, disable_cdf_update wiring, rect-intrabc var-tx + sub-8 txfm-context fixes Five defects, each with a gate and/or a first-divergence move (report S9): - non-4:2:0 chroma (4:4:4/4:2:2) is now REFUSED BY NAME at the sequence header instead of decoding silently wrong pixels; gate a_non_420_subsampled_sequence_header_is_refused_by_name (profile 1 + 2 headers, profile-0 control still decodes) and a real aomenc yuv444p stream refuses where it used to decode garbage. - disable_cdf_update (spec 5.9.2) is now consumed: per-reader msac::SymbolDecoder::adapt + FrameCtx cell + one line in decode_frame. Gates: a_real_aomenc_stream_with_cdf_update_disabled_decodes_pixel_exact (byte-exact vs ffmpeg; pre-fix the same stream differs at byte 6) and the msac unit gate a_reader_told_not_to_adapt_matches_a_non_adapting_writer. - transform.rs:1134 panic root-caused and FIXED: txbset_for_inter (a duplicate whose 4 fell through to Luma64) is deleted; all inter-table sites use inter_txbset_for, which has the 4x4 arms libaom's EXT_TX_SET_ALL16/_DTT4_IDTX ask for. allintra0 no longer panics; it stops at the existing named mixed-leaf var-tx refusal. - rect intrabc leaves (4x8/8x4) read the INTER var-tx tree under TxMode::Select (block_signals_txsize is bsize > BLOCK_4X4) and reconstruct per 4x4 TU when it splits; sub-8x8 leaves publish the TXFM context bands (set_txfm_ctxs for every block); the stale intrabc_dv slot no longer leaks into the next 8x8+ block. - inventory re-pin: the dead sub-8x8-intrabc refusal entry retired, the Golomb entry re-pinned to its measured symptom-reachability. warped is NOT byte-exact yet: first divergence moved (38,60) -> (46,66), the key-frame tx-depth context read off the deblock grid where libaom reads the TXFM bands (next step in report S9.7). allintra/warped now stop 16 mi rows later at the 1:4 rect-strip intrabc refusal (lane 3's). --- crates/ec-av1/examples/decode_probe.rs | 6 + crates/ec-av1/src/decode.rs | 256 ++++++++++++++++++++----- crates/ec-av1/src/msac.rs | 73 +++++++ crates/ec-av1/src/refusal_inventory.rs | 35 ++-- crates/ec-av1/src/stream.rs | 141 ++++++++++++++ lanes/av1txrouting.report.md | 148 ++++++++++++++ 6 files changed, 598 insertions(+), 61 deletions(-) diff --git a/crates/ec-av1/examples/decode_probe.rs b/crates/ec-av1/examples/decode_probe.rs index 5f16d35e..f9c71002 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/decode.rs b/crates/ec-av1/src/decode.rs index 7a45110f..04bc5930 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, pub(crate) superres: std::cell::Cell<(u32, u32)>, @@ -173,6 +179,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), superres: std::cell::Cell::new((0, 8)), @@ -378,6 +385,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 @@ -3662,6 +3681,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`]. @@ -3676,6 +3700,12 @@ 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 @@ -14333,7 +14363,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 }; @@ -15601,7 +15631,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 { @@ -15736,7 +15766,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 { @@ -15986,7 +16016,14 @@ fn read_intra_mode_sub8( // `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); - fctx.intrabc_dv.with(|c| c.set(Some(dv))); + // 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))); } @@ -16120,6 +16157,14 @@ 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); @@ -16443,45 +16488,141 @@ fn decode_leaf_rect8( 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. No - // `tx_depth` symbol is coded (libaom `block_signals_txsize` is - // false below 8x8), the prediction is a frame copy at the DV and - // the residual reads the INTER `LumaRect8x4` set. + // 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 yb = vec![0u16; bw * bh]; + 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(px, dv.1, true), mv_to_q4(py, dv.0, true), - bw, bh, mc::InterpFilterKind::Bilinear, &mut yb, fctx, + 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 mut luma_tx = TxType::DctDct; - let grid = if skip { - let zeros = Grid::Zero(bw * bh); - push_intra_rect(0, px, py, bw, bh, DC_PRED, 0, reach, &zeros, None, None, smooth_neighbor, 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 { - let around = neighbours.around_mi_rect(lmi, bw, bh)[0]; - let set = if reduced_tx_set { + // 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, scan, bw, bh, 0, dc_sign_ctx(around.2), TxType::DctDct, + dec, &mut coding, tu_scan, tw, th, skip_ctx, dc_sign_ctx(around.2), + TxType::DctDct, )?; - luma_tx = tx_type; + 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, bw, bh, crate::decode::bit_depth(fctx), block_q_idx(fctx), + &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, ); - push_intra_rect(0, px, py, bw, bh, DC_PRED, 0, reach, &residual, None, None, smooth_neighbor, fctx); + 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 }; - fctx.luma_tx_type.with(|c| c.set(luma_tx)); + 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 { @@ -16493,8 +16634,17 @@ fn decode_leaf_rect8( 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, bw as u8, bh as u8, 0, fctx); + 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); @@ -16503,7 +16653,7 @@ fn decode_leaf_rect8( 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(luma_tx))); + fctx.intrabc_chroma_tx.with(|c| c.set(Some(chroma_tx))); } continue; } @@ -16554,6 +16704,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 { @@ -18975,6 +19134,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 @@ -19013,29 +19192,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 { @@ -22543,6 +22699,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( @@ -35226,6 +35385,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 4304738d..8d12f757 100644 --- a/crates/ec-av1/src/refusal_inventory.rs +++ b/crates/ec-av1/src/refusal_inventory.rs @@ -55,7 +55,14 @@ 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-lossless/lane-lossless2: a lossless frame (base_q_idx 0) decodes // sample-exact, KEY and INTER -- TX_4X4 with the Walsh-Hadamard transform @@ -256,11 +263,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", @@ -379,14 +390,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 a50ec7ec..ec58e236 100644 --- a/crates/ec-av1/src/stream.rs +++ b/crates/ec-av1/src/stream.rs @@ -1245,6 +1245,13 @@ pub(crate) struct SeqFlags { pub(crate) bit_depth: u8, 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 { @@ -1261,6 +1268,8 @@ impl SeqFlags { bit_depth: seq.map_or(8, |s| s.color_config.bit_depth), 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), } } } @@ -1601,6 +1610,27 @@ 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-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 @@ -1633,6 +1663,11 @@ fn decode_frame( // `a_lossless_libaom_inter_frame_decodes_sample_exact`. crate::decode::set_lossless(coded_lossless, fctx); crate::decode::set_bit_depth(bit_depth, 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 @@ -2016,6 +2051,54 @@ 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-av1-decode (pilot resume, 2026-09-19): a real libaom MONOCHROME key /// frame is currently REFUSED BY NAME, and this gate pins that as today's /// measured first stop for a real encoder stream. @@ -6669,6 +6752,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 index b3fe064c..a757b0a8 100644 --- a/lanes/av1txrouting.report.md +++ b/lanes/av1txrouting.report.md @@ -179,3 +179,151 @@ Oracle build: `~/.cache/aom-oracle` (cmake+ninja) instrumented with `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 census of every `SequenceHeader`/`ColorConfig`/frame-header field against the +decoder's reads (scout report, re-derivable by grep) found exactly two +pixel-affecting fields the decoder never consumed; both are now closed: + +1. `subsampling_x/y` — §9.1 (refusal). +2. **`disable_cdf_update`** (the new 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). + +Everything else never-read is dispositioned as metadata (color_primaries / +transfer_characteristics / color_range / chroma_sample_position, timing and +frame-id fields, `showable_frame`, `render_width/height` — deliberate per +`encode.rs:15917-15921`), or consumed indirectly by the parser (seq gates forced +into the frame header: superres/CDEF/restoration/warped/enable_ref_frame_mvs, +`separate_uv_delta_q`, `seq_force_*`). `mono_chrome`/`num_planes` is the sibling +lane-av1-mono's. + +### 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).