ec-av1: merge lane-av1-txrouting (non-4:2:0 + qmatrix refusals, cdf-update wiring, rect intrabc)
Browse files at this commit7 changed files +1330 -64
- crates/ec-av1/examples/decode_probe.rs +6 -0
- crates/ec-av1/src/cdf_state.rs +3 -3
- crates/ec-av1/src/decode.rs +443 -47
- crates/ec-av1/src/msac.rs +73 -0
- crates/ec-av1/src/refusal_inventory.rs +51 -14
- crates/ec-av1/src/stream.rs +211 -0
- lanes/av1txrouting.report.md +543 -0
crates/ec-av1/examples/decode_probe.rsmodified+6 -0
| @@ -92,6 +92,12 @@ fn main() { | ||
| 92 | 92 | println!("inter16_1to4: horz4={h4} vert4={v4} chroma_pairs={pairs} sub8_pieces={sub8}"); |
| 93 | 93 | let leaf4 = ec_av1::stream::vartx_rect_leaf4_hits(); |
| 94 | 94 | println!("vartx_rect_leaf4: 8x4={} 4x8={}", leaf4[0], leaf4[1]); |
| 95 | + // lane-av1txr: intrabc 4x8/8x4 leaves that read the inter var-tx tree | |
| 96 | + // (the symbol whose absence desynced `warped.obu`). | |
| 97 | + println!( | |
| 98 | + "rect_intrabc_vartx: {}", | |
| 99 | + ec_av1::decode::rect_intrabc_vartx_hits() | |
| 100 | + ); | |
| 95 | 101 | let rw = ec_av1::stream::rect_wedge_hits(); |
| 96 | 102 | let rwi = ec_av1::stream::rect_wii_hits(); |
| 97 | 103 | println!( |
crates/ec-av1/src/cdf_state.rsmodified+3 -3
| @@ -322,9 +322,9 @@ impl TxbSet { | ||
| 322 | 322 | |
| 323 | 323 | /// lane-txi: this set's `reduced_tx_set == 0` counterpart -- the WIDER |
| 324 | 324 | /// `tx_type` alphabet the same coefficient tables are read with when the |
| 325 | - /// frame header's bit is off. Every pair here is the one | |
| 326 | - /// `decode::txbset_for`/`txbset_for_inter`/`inter_txbset_for` resolve off | |
| 327 | - /// that bit, transcribed from the DECODER's own map so writer and reader | |
| 325 | + /// frame header's bit is off. Every pair here is the counterpart | |
| 326 | + /// `decode::txbset_for`/`inter_txbset_for` resolve off that bit, | |
| 327 | + /// transcribed from the DECODER's own map so writer and reader | |
| 328 | 328 | /// cannot drift (class `table-and-reader-move-together`); a set with no |
| 329 | 329 | /// counterpart -- intra 16x16 and 32x32, inter 32x32, 64x64, every |
| 330 | 330 | /// chroma set -- is its own, and widening an already-wide set is the |
crates/ec-av1/src/decode.rsmodified+443 -47
| @@ -84,6 +84,12 @@ pub(crate) struct FrameCtx { | ||
| 84 | 84 | /// (`decodeframe.c`), `read_tx_type` (`decodetxb.c`), `is_cfl_allowed` |
| 85 | 85 | /// (`blockd.h`)). |
| 86 | 86 | pub(crate) lossless_flag: std::cell::Cell<bool>, |
| 87 | + /// lane-av1txr: this frame header's `disable_cdf_update` (spec 5.9.2). | |
| 88 | + /// When set, the tile reader must not adapt any CDF it reads, or its | |
| 89 | + /// tables drift away from the encoder's and the frame desyncs mid-tile | |
| 90 | + /// (libaom: `allow_update_cdf = allow_update_cdf && | |
| 91 | + /// !cm->features.disable_cdf_update`, `decodeframe.c:2909`). | |
| 92 | + pub(crate) disable_cdf_update: std::cell::Cell<bool>, | |
| 87 | 93 | pub(crate) cdef_bits: std::cell::Cell<u8>, |
| 88 | 94 | pub(crate) bit_depth: std::cell::Cell<u8>, |
| 89 | 95 | /// lane-av1mono: the sequence header's `color_config.mono_chrome` (spec |
| @@ -183,6 +189,7 @@ impl FrameCtx { | ||
| 183 | 189 | sb128_flag: std::cell::Cell::new(false), |
| 184 | 190 | interp_filter: std::cell::Cell::new(crate::mc::InterpFilterKind::Regular), |
| 185 | 191 | lossless_flag: std::cell::Cell::new(false), |
| 192 | + disable_cdf_update: std::cell::Cell::new(false), | |
| 186 | 193 | cdef_bits: std::cell::Cell::new(0), |
| 187 | 194 | bit_depth: std::cell::Cell::new(8), |
| 188 | 195 | mono_chrome: std::cell::Cell::new(false), |
| @@ -390,6 +397,18 @@ pub(crate) fn lossless(fctx: &crate::decode::FrameCtx) -> bool { | ||
| 390 | 397 | fctx.lossless_flag.with(|c| c.get()) |
| 391 | 398 | } |
| 392 | 399 | |
| 400 | +/// Sets [`FrameCtx::disable_cdf_update`] (called once per frame from | |
| 401 | +/// `stream.rs`). | |
| 402 | +pub(crate) fn set_disable_cdf_update(v: bool, fctx: &crate::decode::FrameCtx) { | |
| 403 | + fctx.disable_cdf_update.with(|c| c.set(v)); | |
| 404 | +} | |
| 405 | + | |
| 406 | +/// This frame's `disable_cdf_update`, for the tile readers -- | |
| 407 | +/// [`msac::SymbolDecoder::set_cdf_update`](crate::msac::SymbolDecoder::set_cdf_update). | |
| 408 | +pub(crate) fn cdf_update_disabled(fctx: &crate::decode::FrameCtx) -> bool { | |
| 409 | + fctx.disable_cdf_update.with(|c| c.get()) | |
| 410 | +} | |
| 411 | + | |
| 393 | 412 | /// The transform side a block of `side` pixels codes: its own (capped at the |
| 394 | 413 | /// caller's own largest) normally, 4 on a lossless frame, where libaom's |
| 395 | 414 | /// `read_tx_size` returns TX_4X4 before it looks at anything else |
| @@ -3687,6 +3706,11 @@ thread_local! { | ||
| 3687 | 3706 | /// var-tx partition tree (unskipped, `TX_MODE_SELECT`) -- the capability |
| 3688 | 3707 | /// that replaced the refusal "an intrabc block under TxMode::Select". |
| 3689 | 3708 | static INTRABC_VARTX_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; |
| 3709 | + /// lane-av1txr: as above for a `BLOCK_4X8`/`BLOCK_8X4` intrabc leaf -- | |
| 3710 | + /// libaom's `block_signals_txsize` is `bsize > BLOCK_4X4`, so these leaves | |
| 3711 | + /// signal a transform size where a plain `BLOCK_4X4` does not. Reading no | |
| 3712 | + /// symbol here desynced `warped.obu` at the very next block. | |
| 3713 | + static RECT_INTRABC_VARTX_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | |
| 3690 | 3714 | } |
| 3691 | 3715 | |
| 3692 | 3716 | /// Current value of [`INTRABC_VARTX_HITS`]. |
| @@ -3701,11 +3725,31 @@ pub(crate) fn reset_intrabc_vartx_hits() { | ||
| 3701 | 3725 | INTRABC_VARTX_HITS.with(|c| c.set(0)); |
| 3702 | 3726 | } |
| 3703 | 3727 | |
| 3728 | +/// Current value of [`RECT_INTRABC_VARTX_HITS`]. | |
| 3729 | +#[allow(dead_code)] // read only from the `#[cfg(test)]` gates | |
| 3730 | +pub fn rect_intrabc_vartx_hits() -> usize { | |
| 3731 | + RECT_INTRABC_VARTX_HITS.with(|c| c.get()) | |
| 3732 | +} | |
| 3733 | + | |
| 3704 | 3734 | /// Records one coded block into [`INTRABC_MI_GRID`]: every block contributes |
| 3705 | 3735 | /// its size (libaom's `scan_row_mbmi` advances `processed_rows` off any |
| 3706 | 3736 | /// candidate's `bsize`, ref-match or not), an intrabc one also its DV as an |
| 3707 | 3737 | /// `INTRA_FRAME` candidate (libaom treats intrabc as `is_inter_block`). |
| 3708 | 3738 | fn record_intrabc_mi(mi_r: usize, mi_c: usize, n4: usize, dv: Option<(i32, i32)>, fctx: &crate::decode::FrameCtx) { |
| 3739 | + record_intrabc_mi_rect(mi_r, mi_c, n4, n4, dv, fctx); | |
| 3740 | +} | |
| 3741 | + | |
| 3742 | +/// [`record_intrabc_mi`] with a true rectangular footprint: `av1_find_mv_refs` | |
| 3743 | +/// takes the block's real `bsize`, so a sub-8x8 `BLOCK_4X8`/`BLOCK_8X4` | |
| 3744 | +/// intrabc leaf must publish a 1x2/2x1 mi span, not a square (lane-av1txr). | |
| 3745 | +fn record_intrabc_mi_rect( | |
| 3746 | + mi_r: usize, | |
| 3747 | + mi_c: usize, | |
| 3748 | + n4_w: usize, | |
| 3749 | + n4_h: usize, | |
| 3750 | + dv: Option<(i32, i32)>, | |
| 3751 | + fctx: &crate::decode::FrameCtx, | |
| 3752 | +) { | |
| 3709 | 3753 | fctx.intrabc_mi_grid.with(|g| { |
| 3710 | 3754 | let mut g = g.borrow_mut(); |
| 3711 | 3755 | 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)> | ||
| 3720 | 3764 | is_new_mv: dv.is_some(), |
| 3721 | 3765 | is_global_mv0: false, |
| 3722 | 3766 | is_global_mv1: false, |
| 3723 | - size: n4 as u8, | |
| 3724 | - size_h: n4 as u8, | |
| 3767 | + size: n4_w as u8, | |
| 3768 | + size_h: n4_h as u8, | |
| 3725 | 3769 | }; |
| 3726 | - for r in mi_r..mi_r + n4 { | |
| 3727 | - for c in mi_c..mi_c + n4 { | |
| 3770 | + for r in mi_r..mi_r + n4_h { | |
| 3771 | + for c in mi_c..mi_c + n4_w { | |
| 3728 | 3772 | grid.set(r, c, info); |
| 3729 | 3773 | } |
| 3730 | 3774 | } |
| @@ -11399,7 +11443,11 @@ fn decode_leaf_rect( | ||
| 11399 | 11443 | // the range diverges silently at the first such leaf and every later |
| 11400 | 11444 | // symbol in the tile is read from the wrong place (class |
| 11401 | 11445 | // `wrong-alphabet-same-value`, here same alphabet / wrong row). |
| 11402 | - dec.symbol(&mut cdfs.tx_size_cat1[ctx]) | |
| 11446 | + let d = dec.symbol(&mut cdfs.tx_size_cat1[ctx]); | |
| 11447 | + if crate::envflags::env_flag!("EC_TRACE_MODE_STEP") { | |
| 11448 | + eprintln!("EC_ISTEP mi_row={} mi_col={} name=tx_depth val={d} ctx={ctx} cat=1 rng={}", leaf_mi.0, leaf_mi.1, dec.debug_state().0); | |
| 11449 | + } | |
| 11450 | + d | |
| 11403 | 11451 | } else { |
| 11404 | 11452 | 0 |
| 11405 | 11453 | }; |
| @@ -13318,11 +13366,14 @@ fn read_intra_mode( | ||
| 13318 | 13366 | // that merely allows (but never uses) intrabc. |
| 13319 | 13367 | if allow_intrabc { |
| 13320 | 13368 | let use_intrabc = dec.symbol(&mut cdfs.intrabc) != 0; |
| 13369 | + if crate::envflags::env_flag!("EC_TRACE_MODE_STEP") { | |
| 13370 | + eprintln!("EC_ISTEP mi_row={mi_r} mi_col={mi_c} name=intrabc val={} rng={}", u8::from(use_intrabc), dec.debug_state().0); | |
| 13371 | + } | |
| 13321 | 13372 | if trace { |
| 13322 | 13373 | eprintln!("TRACE use_intrabc value={}", use_intrabc as i32); |
| 13323 | 13374 | } |
| 13324 | 13375 | if use_intrabc { |
| 13325 | - let dv = read_intrabc_dv(dec, cdfs, mi_r, mi_c, side, fctx); | |
| 13376 | + let dv = read_intrabc_dv(dec, cdfs, mi_r, mi_c, (side / MI, side / MI), fctx); | |
| 13326 | 13377 | if trace { |
| 13327 | 13378 | eprintln!("TRACE intrabc dv={dv:?}"); |
| 13328 | 13379 | } |
| @@ -14418,7 +14469,7 @@ fn decode_block( | ||
| 14418 | 14469 | luma_set |
| 14419 | 14470 | }; |
| 14420 | 14471 | let luma_set = if intrabc_dv.is_some() { |
| 14421 | - txbset_for_inter(logical_tx, reduced_tx_set) | |
| 14472 | + inter_txbset_for(logical_tx, reduced_tx_set) | |
| 14422 | 14473 | } else { |
| 14423 | 14474 | luma_set |
| 14424 | 14475 | }; |
| @@ -15686,7 +15737,7 @@ fn decode_leaf8( | ||
| 15686 | 15737 | dec, |
| 15687 | 15738 | cdfs, |
| 15688 | 15739 | if intrabc_dv.is_some() { |
| 15689 | - txbset_for_inter(8, reduced_tx_set) | |
| 15740 | + inter_txbset_for(8, reduced_tx_set) | |
| 15690 | 15741 | } else if reduced_tx_set { |
| 15691 | 15742 | TxbSet::Luma8 |
| 15692 | 15743 | } else { |
| @@ -15821,7 +15872,7 @@ fn decode_leaf8( | ||
| 15821 | 15872 | dec, |
| 15822 | 15873 | cdfs, |
| 15823 | 15874 | if intrabc_dv.is_some() { |
| 15824 | - txbset_for_inter(4, reduced_tx_set) | |
| 15875 | + inter_txbset_for(4, reduced_tx_set) | |
| 15825 | 15876 | } else if reduced_tx_set { |
| 15826 | 15877 | TxbSet::Luma4 |
| 15827 | 15878 | } else { |
| @@ -16021,7 +16072,7 @@ fn read_intra_mode_sub8( | ||
| 16021 | 16072 | // neighbour's `cdf_index`/prediction two blocks later. |
| 16022 | 16073 | seg_w_mi: usize, |
| 16023 | 16074 | seg_h_mi: usize, fctx: &crate::decode::FrameCtx, |
| 16024 | -) -> Result<(bool, usize, i32, Option<(usize, i32, Option<(i32, i32)>)>, Option<usize>)> { | |
| 16075 | +) -> Result<(bool, usize, i32, Option<(usize, i32, Option<(i32, i32)>)>, Option<usize>, Option<(i32, i32)>)> { | |
| 16025 | 16076 | // lane-av1mono: a monochrome leaf codes no chroma mode (libaom |
| 16026 | 16077 | // `decodemv.c:933`), so fold `NumPlanes == 1` into `has_chroma`. |
| 16027 | 16078 | let has_chroma = has_chroma && !mono(fctx); |
| @@ -16063,10 +16114,27 @@ fn read_intra_mode_sub8( | ||
| 16063 | 16114 | istep!("dq", 0); |
| 16064 | 16115 | if allow_intrabc { |
| 16065 | 16116 | let use_intrabc = dec.symbol(&mut cdfs.intrabc) != 0; |
| 16117 | + if ec_istep { | |
| 16118 | + eprintln!("EC_ISTEP mi_row={mi_r} mi_col={mi_c} name=intrabc val={} rng={}", u8::from(use_intrabc), dec.debug_state().0); | |
| 16119 | + } | |
| 16066 | 16120 | if use_intrabc { |
| 16067 | - return Err(unsupported( | |
| 16068 | - "a sub-8x8 leaf that uses intrabc (this reader has no block-vector path; the 8x8-and-up reader reconstructs one)", | |
| 16069 | - )); | |
| 16121 | + // lane-av1txr: `read_intrabc_info` (spec 5.11.13) reads the block | |
| 16122 | + // vector right after the flag and RETURNS -- no y/uv mode, angle | |
| 16123 | + // delta, palette, CfL or filter-intra syntax follows, and the | |
| 16124 | + // block is reconstructed by the INTER path (libaom's | |
| 16125 | + // `is_inter_block` counts an intrabc block), so the caller takes | |
| 16126 | + // the frame-copy prediction + inter residual. | |
| 16127 | + let dv = read_intrabc_dv(dec, cdfs, mi_r, mi_c, (seg_w_mi, seg_h_mi), fctx); | |
| 16128 | + // lane-av1txr: the DV travels back in the RETURN value -- it is | |
| 16129 | + // NOT published through `FrameCtx::intrabc_dv`. That slot is the | |
| 16130 | + // SQUARE paths' handoff (`decode_block`/`decode_leaf8` arm it, | |
| 16131 | + // then `take()` it in the same call), so a sub-8x8 leaf that | |
| 16132 | + // armed it left the vector standing for the NEXT >=8x8 block: | |
| 16133 | + // `warped.obu`'s (38,60) 8x8 intra block took it as its own | |
| 16134 | + // intrabc and read an inter var-tx `txfm_split` where libaom read | |
| 16135 | + // an intra `tx_depth` (class `stale-slot-handoff`). | |
| 16136 | + hit!(INTRABC_HITS); | |
| 16137 | + return Ok((skip, DC_PRED, 0, None, None, Some(dv))); | |
| 16070 | 16138 | } |
| 16071 | 16139 | } |
| 16072 | 16140 | let above_ctx = INTRA_MODE_CTX[above_mode]; |
| @@ -16116,7 +16184,7 @@ fn read_intra_mode_sub8( | ||
| 16116 | 16184 | filter_intra = Some(fi_mode); |
| 16117 | 16185 | } |
| 16118 | 16186 | } |
| 16119 | - Ok((skip, mode, angle_delta_y, chroma, filter_intra)) | |
| 16187 | + Ok((skip, mode, angle_delta_y, chroma, filter_intra, None)) | |
| 16120 | 16188 | } |
| 16121 | 16189 | |
| 16122 | 16190 | /// Decodes a `PARTITION_SPLIT` of one 8x8 block into four `BLOCK_4X4` leaves |
| @@ -16167,6 +16235,10 @@ fn decode_leaf_split4( | ||
| 16167 | 16235 | let mut leaf_modes = [0usize; 4]; |
| 16168 | 16236 | let mut leaf_skips = [false; 4]; |
| 16169 | 16237 | let mut last_uv: Option<(usize, i32, Option<(i32, i32)>)> = None; |
| 16238 | + // lane-av1txr: the chroma-reference (i==3) leaf's block vector when that | |
| 16239 | + // leaf is an intrabc block -- its prediction/reconstruction below is a | |
| 16240 | + // frame copy at this DV, not an intra one. | |
| 16241 | + let mut last_intrabc: Option<(i32, i32)> = None; | |
| 16170 | 16242 | for i in 0..4usize { |
| 16171 | 16243 | let (dr, dc) = (i / 2, i % 2); |
| 16172 | 16244 | let lmi = (leaf_mi.0 + dr, leaf_mi.1 + dc); |
| @@ -16186,7 +16258,7 @@ fn decode_leaf_split4( | ||
| 16186 | 16258 | }; |
| 16187 | 16259 | let has_chroma = i == 3; |
| 16188 | 16260 | let skip_ctx = neighbours.skip_txfm_ctx(lmi.0, lmi.1); |
| 16189 | - let (skip, mode, angle_delta_y, chroma, filter_intra) = read_intra_mode_sub8( | |
| 16261 | + let (skip, mode, angle_delta_y, chroma, filter_intra, intrabc) = read_intra_mode_sub8( | |
| 16190 | 16262 | dec, cdfs, leaf_above, leaf_left, has_chroma, enable_filter_intra, |
| 16191 | 16263 | filter_intra_size_class(4).expect("BLOCK_4X4 has its own filter_intra row"), |
| 16192 | 16264 | skip_ctx, allow_intrabc, lmi.0, lmi.1, 1, 1, fctx, |
| @@ -16194,12 +16266,81 @@ fn decode_leaf_split4( | ||
| 16194 | 16266 | leaf_modes[i] = mode; |
| 16195 | 16267 | leaf_skips[i] = skip; |
| 16196 | 16268 | neighbours.record_mode_mi(lmi.0, lmi.1, 1, 1, mode); |
| 16269 | + // lane-av1txr: libaom `parse_decode_block`'s `set_txfm_ctxs` for this | |
| 16270 | + // `BLOCK_4X4` leaf -- EVERY block publishes its transform size into | |
| 16271 | + // the TXFM context bands, and an intrabc block's later `txfm_split` | |
| 16272 | + // context is read off them (`txfm_partition_context`). A 4x4 never | |
| 16273 | + // signals a tx size, so it is always TX_4X4 (`set_txfm_ctxs`'s | |
| 16274 | + // `skip && is_inter` branch writes the block's own 4 pixels -- the | |
| 16275 | + // same value). | |
| 16276 | + set_txfm_ctxs(neighbours, lmi, 4, 1, 1, false); | |
| 16197 | 16277 | let smooth_neighbor = is_smooth_mode(leaf_above) || is_smooth_mode(leaf_left); |
| 16198 | 16278 | if smooth_neighbor { |
| 16199 | 16279 | hit!(SMOOTH_LUMA_HITS); |
| 16200 | 16280 | } |
| 16201 | 16281 | let (px, py) = (lmi.1 * MI, lmi.0 * MI); |
| 16202 | 16282 | let reach = Reach::of(4, px, py, y.width, y.height, fctx); |
| 16283 | + if let Some(dv) = intrabc { | |
| 16284 | + // lane-av1txr: an intrabc `BLOCK_4X4` leaf -- prediction is the | |
| 16285 | + // CURRENT frame at the block vector (`predict_inter_block`'s | |
| 16286 | + // intrabc arm, spec 7.11.3.4), residual the INTER coefficient set | |
| 16287 | + // (libaom reads `tx_type` off `inter_ext_tx_cdf` for | |
| 16288 | + // `is_inter_block`, which counts intrabc). Published into | |
| 16289 | + // `intrabc_dv` so the group's chroma arm (below, when the | |
| 16290 | + // chroma-reference leaf is the intrabc one) and | |
| 16291 | + // [`record_intrabc_mi`] see it. | |
| 16292 | + flush_recon(fctx, y, u, v); | |
| 16293 | + let mut yb = vec![0u16; 16]; | |
| 16294 | + mc::predict_with_filter( | |
| 16295 | + &y.data, y.width, y.true_width, y.true_height, | |
| 16296 | + mv_to_q4(px, dv.1, true), mv_to_q4(py, dv.0, true), | |
| 16297 | + 4, 4, mc::InterpFilterKind::Bilinear, &mut yb, fctx, | |
| 16298 | + ); | |
| 16299 | + set_palette_pred(yb.clone(), fctx); | |
| 16300 | + if skip { | |
| 16301 | + push_intra(0, px, py, 4, DC_PRED, 0, reach, &ZERO_RESIDUAL[..16], None, None, smooth_neighbor, fctx); | |
| 16302 | + neighbours.record_mi_luma(lmi, 4, &ZERO_RESIDUAL[..16]); | |
| 16303 | + } else { | |
| 16304 | + let tu_around = neighbours.around_mi(lmi, 4)[0]; | |
| 16305 | + let tu_grid = read_plane( | |
| 16306 | + dec, | |
| 16307 | + cdfs, | |
| 16308 | + if reduced_tx_set { TxbSet::Luma4Inter } else { TxbSet::Luma4InterSet1 }, | |
| 16309 | + scan4, | |
| 16310 | + 0, | |
| 16311 | + tu_around, | |
| 16312 | + DC_PRED, | |
| 16313 | + DC_PRED, | |
| 16314 | + 0, | |
| 16315 | + reach, | |
| 16316 | + y, | |
| 16317 | + px, | |
| 16318 | + py, | |
| 16319 | + 4, | |
| 16320 | + 4, | |
| 16321 | + base_q_idx, | |
| 16322 | + None, | |
| 16323 | + None, | |
| 16324 | + None, | |
| 16325 | + smooth_neighbor, fctx, | |
| 16326 | + )?; | |
| 16327 | + neighbours.record_mi_luma(lmi, 4, &tu_grid); | |
| 16328 | + } | |
| 16329 | + neighbours.fill_skip_grid(lmi, 1, skip); | |
| 16330 | + neighbours.fill_lf_grid(lmi, 1, 4, 0, fctx); | |
| 16331 | + record_intrabc_mi(lmi.0, lmi.1, 1, Some(dv), fctx); | |
| 16332 | + if has_chroma { | |
| 16333 | + last_uv = Some((DC_PRED, 0, None)); | |
| 16334 | + // An intrabc block is an INTER block for `av1_get_tx_type`, so | |
| 16335 | + // the group's chroma inherits the LUMA's coded transform type | |
| 16336 | + // (`xd->tx_type_map` at the co-located luma position) -- the | |
| 16337 | + // luma `read_plane` above just set [`LUMA_TX_TYPE`]. Armed for | |
| 16338 | + // exactly this group's two chroma reads. | |
| 16339 | + fctx.intrabc_chroma_tx.with(|c| c.set(Some(fctx.luma_tx_type.with(std::cell::Cell::get)))); | |
| 16340 | + } | |
| 16341 | + last_intrabc = Some(dv); | |
| 16342 | + continue; | |
| 16343 | + } | |
| 16203 | 16344 | if skip { |
| 16204 | 16345 | push_intra(0, px, py, 4, mode, angle_delta_y, reach, &ZERO_RESIDUAL[..16], None, filter_intra, smooth_neighbor, fctx); |
| 16205 | 16346 | neighbours.record_mi_luma(lmi, 4, &ZERO_RESIDUAL[..16]); |
| @@ -16271,6 +16412,38 @@ fn decode_leaf_split4( | ||
| 16271 | 16412 | 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); |
| 16272 | 16413 | 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); |
| 16273 | 16414 | (Grid::Zero(16), Grid::Zero(16)) |
| 16415 | + } else if let Some(dv) = last_intrabc { | |
| 16416 | + // lane-av1txr: the chroma-reference leaf was an intrabc block, so the | |
| 16417 | + // group's one chroma unit is a frame copy at that DV too (its residual | |
| 16418 | + // still reads the ordinary `Chroma4` coefficient tables -- libaom | |
| 16419 | + // codes a chroma `tx_type` nowhere). | |
| 16420 | + let mut ub = vec![0u16; 16]; | |
| 16421 | + mc::predict_with_filter( | |
| 16422 | + &u.data, u.width, u.true_width, u.true_height, | |
| 16423 | + mv_to_q4(cpx, dv.1, false), mv_to_q4(cpy, dv.0, false), | |
| 16424 | + 4, 4, mc::InterpFilterKind::Bilinear, &mut ub, fctx, | |
| 16425 | + ); | |
| 16426 | + let mut vb = vec![0u16; 16]; | |
| 16427 | + mc::predict_with_filter( | |
| 16428 | + &v.data, v.width, v.true_width, v.true_height, | |
| 16429 | + mv_to_q4(cpx, dv.1, false), mv_to_q4(cpy, dv.0, false), | |
| 16430 | + 4, 4, mc::InterpFilterKind::Bilinear, &mut vb, fctx, | |
| 16431 | + ); | |
| 16432 | + let chroma_around = neighbours.around_mi(leaf_mi, 8); | |
| 16433 | + set_palette_pred(ub, fctx); | |
| 16434 | + let ug = read_plane( | |
| 16435 | + dec, cdfs, TxbSet::Chroma4, scan4, 1, chroma_around[1], DC_PRED, DC_PRED, | |
| 16436 | + 0, group_reach, u, cpx, cpy, 4, TX4, base_q_idx, | |
| 16437 | + None, None, None, smooth_neighbor_uv, fctx, | |
| 16438 | + )?; | |
| 16439 | + set_palette_pred(vb, fctx); | |
| 16440 | + let vg = read_plane( | |
| 16441 | + dec, cdfs, TxbSet::Chroma4, scan4, 2, chroma_around[2], DC_PRED, DC_PRED, | |
| 16442 | + 0, group_reach, v, cpx, cpy, 4, TX4, base_q_idx, | |
| 16443 | + None, None, None, smooth_neighbor_uv, fctx, | |
| 16444 | + )?; | |
| 16445 | + fctx.intrabc_chroma_tx.with(|c| c.set(None)); | |
| 16446 | + (ug, vg) | |
| 16274 | 16447 | } else { |
| 16275 | 16448 | let ac = alpha.map(|_| cfl_src(gpx, gpy, 8)); |
| 16276 | 16449 | let chroma_around = neighbours.around_mi(leaf_mi, 8); |
| @@ -16398,6 +16571,8 @@ fn decode_leaf_rect8( | ||
| 16398 | 16571 | let mut leaf_modes = [0usize; 2]; |
| 16399 | 16572 | let mut leaf_skips = [false; 2]; |
| 16400 | 16573 | let mut last_uv: Option<(usize, i32, Option<(i32, i32)>)> = None; |
| 16574 | + // lane-av1txr: as [`decode_leaf_split4`]'s own `last_intrabc`. | |
| 16575 | + let mut last_intrabc: Option<(i32, i32)> = None; | |
| 16401 | 16576 | for i in 0..2usize { |
| 16402 | 16577 | let lmi = if vert { |
| 16403 | 16578 | (leaf_mi.0, leaf_mi.1 + i) |
| @@ -16418,12 +16593,186 @@ fn decode_leaf_rect8( | ||
| 16418 | 16593 | }; |
| 16419 | 16594 | let has_chroma = i == 1; |
| 16420 | 16595 | let skip_ctx = neighbours.skip_txfm_ctx(lmi.0, lmi.1); |
| 16421 | - let (skip, mode, angle_delta_y, chroma, filter_intra) = read_intra_mode_sub8( | |
| 16596 | + let (skip, mode, angle_delta_y, chroma, filter_intra, intrabc) = read_intra_mode_sub8( | |
| 16422 | 16597 | dec, cdfs, leaf_above, leaf_left, has_chroma, enable_filter_intra, |
| 16423 | 16598 | filter_intra_size_class_rect(bw, bh) |
| 16424 | 16599 | .expect("BLOCK_4X8/BLOCK_8X4 are inside av1_filter_intra_allowed_bsize"), |
| 16425 | 16600 | skip_ctx, allow_intrabc, lmi.0, lmi.1, bw / 4, bh / 4, fctx, |
| 16426 | 16601 | )?; |
| 16602 | + leaf_modes[i] = mode; | |
| 16603 | + leaf_skips[i] = skip; | |
| 16604 | + neighbours.record_mode_mi(lmi.0, lmi.1, w_mi, h_mi, mode); | |
| 16605 | + let smooth_neighbor = is_smooth_mode(leaf_above) || is_smooth_mode(leaf_left); | |
| 16606 | + if let Some(dv) = intrabc { | |
| 16607 | + // lane-av1txr: an intrabc `BLOCK_4X8`/`BLOCK_8X4` leaf. The | |
| 16608 | + // prediction is a frame copy at the DV and the residual reads the | |
| 16609 | + // INTER `LumaRect8x4` set -- but with `TxMode::Select` the leaf | |
| 16610 | + // reads the INTER var-tx tree, exactly like every other intrabc | |
| 16611 | + // block: libaom's `block_signals_txsize` is `bsize > BLOCK_4X4` | |
| 16612 | + // (`blockd.h:1027`), TRUE at `BLOCK_4X8`/`BLOCK_8X4`, so | |
| 16613 | + // `parse_decode_block` sends an unskipped `inter_block_tx` block | |
| 16614 | + // (intrabc counts, `is_inter_block`) of a signalling bsize into | |
| 16615 | + // `read_tx_size_vartx` over `max_txsize_rect_lookup[BLOCK_4X8] == | |
| 16616 | + // TX_4X8`; only `BLOCK_4X4` reads no tx symbol at all. Measured on | |
| 16617 | + // `warped.obu` mi (37,62): reading NO symbol here left the | |
| 16618 | + // arithmetic decoder one symbol short and desynced the very next | |
| 16619 | + // block's `skip` (ours 60320 vs aomdec 48630, class | |
| 16620 | + // `symbol-consumption-gap`). | |
| 16621 | + let (px, py) = (lmi.1 * MI, lmi.0 * MI); | |
| 16622 | + let reach = Reach::of_rect(bw, bh, px, py, y.width, y.height, fctx); | |
| 16623 | + flush_recon(fctx, y, u, v); | |
| 16624 | + let mut luma_leaves: Vec<(usize, usize, usize, usize)> = Vec::new(); | |
| 16625 | + if tx_select && !skip { | |
| 16626 | + // `max_block_wide`/`max_block_high`: the frame's own mi grid, | |
| 16627 | + // so a leaf hanging over the right/bottom edge reads no split | |
| 16628 | + // symbol for the units outside it (as in `decode_block`). | |
| 16629 | + let mi_cols = 2 * y.true_width.div_ceil(8); | |
| 16630 | + let mi_rows = 2 * y.true_height.div_ceil(8); | |
| 16631 | + let max_w_mi = w_mi.min(mi_cols.saturating_sub(lmi.1)); | |
| 16632 | + let max_h_mi = h_mi.min(mi_rows.saturating_sub(lmi.0)); | |
| 16633 | + read_var_tx_size( | |
| 16634 | + dec, | |
| 16635 | + cdfs, | |
| 16636 | + neighbours, | |
| 16637 | + lmi, | |
| 16638 | + bw.max(bh), | |
| 16639 | + (max_w_mi, max_h_mi), | |
| 16640 | + (bw, bh), | |
| 16641 | + 0, | |
| 16642 | + 0, | |
| 16643 | + 0, | |
| 16644 | + &mut luma_leaves, | |
| 16645 | + ); | |
| 16646 | + hit!(RECT_INTRABC_VARTX_HITS); | |
| 16647 | + } else { | |
| 16648 | + luma_leaves.push((0, 0, bw, bh)); | |
| 16649 | + // The non-var-tx arm: a SKIPPED intrabc leaf (or a frame | |
| 16650 | + // outside `TxMode::Select`) publishes its own rect transform | |
| 16651 | + // (`set_txfm_ctxs`'s `skip && is_inter` branch writes the | |
| 16652 | + // block's own pixels -- the same size here). | |
| 16653 | + txfm_partition_update_rect(neighbours, lmi, (bw, bh), (bw, bh)); | |
| 16654 | + } | |
| 16655 | + // The transform type an intrabc block's CHROMA inherits is the | |
| 16656 | + // `tx_type_map` entry at the chroma unit's co-located luma | |
| 16657 | + // position (`av1_get_tx_type`, `blockd.h:1278`), i.e. the FIRST | |
| 16658 | + // luma unit the tree resolved. | |
| 16659 | + let single = luma_leaves.len() == 1; | |
| 16660 | + let mut chroma_tx = TxType::DctDct; | |
| 16661 | + let mut grid = Grid::Zero(bw * bh); | |
| 16662 | + for (li, &(tu_row, tu_col, tw, th)) in luma_leaves.iter().enumerate() { | |
| 16663 | + let tu_mi = (lmi.0 + tu_row, lmi.1 + tu_col); | |
| 16664 | + let (tu_px, tu_py) = (tu_mi.1 * MI, tu_mi.0 * MI); | |
| 16665 | + let tu_reach = if single { | |
| 16666 | + reach | |
| 16667 | + } else { | |
| 16668 | + tu_reach( | |
| 16669 | + bw, bh, tu_px - px, tu_py - py, tw, reach, px, py, y.width, y.height, fctx, | |
| 16670 | + ) | |
| 16671 | + }; | |
| 16672 | + let mut yb = vec![0u16; tw * th]; | |
| 16673 | + mc::predict_with_filter( | |
| 16674 | + &y.data, y.width, y.true_width, y.true_height, | |
| 16675 | + mv_to_q4(tu_px, dv.1, true), mv_to_q4(tu_py, dv.0, true), | |
| 16676 | + tw, th, mc::InterpFilterKind::Bilinear, &mut yb, fctx, | |
| 16677 | + ); | |
| 16678 | + set_palette_pred(yb, fctx); | |
| 16679 | + let tu_grid = if skip { | |
| 16680 | + let zeros = Grid::Zero(tw * th); | |
| 16681 | + if (tw, th) == (4, 4) { | |
| 16682 | + push_intra(0, tu_px, tu_py, 4, DC_PRED, 0, tu_reach, &zeros, None, None, smooth_neighbor, fctx); | |
| 16683 | + } else { | |
| 16684 | + push_intra_rect(0, tu_px, tu_py, tw, th, DC_PRED, 0, tu_reach, &zeros, None, None, smooth_neighbor, fctx); | |
| 16685 | + } | |
| 16686 | + zeros | |
| 16687 | + } else { | |
| 16688 | + // A unit smaller than its own block (the var-tx split) | |
| 16689 | + // reads its `txb_skip_ctx` off the neighbours; the | |
| 16690 | + // whole-leaf unit's `plane_bsize == txsize_to_bsize` fixes | |
| 16691 | + // it at 0. | |
| 16692 | + let (set, tu_scan, around, skip_ctx) = if (tw, th) == (4, 4) { | |
| 16693 | + ( | |
| 16694 | + inter_txbset_for(4, reduced_tx_set), | |
| 16695 | + scan4, | |
| 16696 | + neighbours.around_mi(tu_mi, 4)[0], | |
| 16697 | + neighbours.luma_skip_ctx(tu_mi, 1), | |
| 16698 | + ) | |
| 16699 | + } else { | |
| 16700 | + ( | |
| 16701 | + if reduced_tx_set { | |
| 16702 | + TxbSet::LumaRect8x4Inter | |
| 16703 | + } else { | |
| 16704 | + TxbSet::LumaRect8x4InterSet1 | |
| 16705 | + }, | |
| 16706 | + scan, | |
| 16707 | + neighbours.around_mi_rect(tu_mi, tw, th)[0], | |
| 16708 | + 0, | |
| 16709 | + ) | |
| 16710 | + }; | |
| 16711 | + let mut coding = cdfs.txb(set, DC_PRED); | |
| 16712 | + let (levels, tx_type) = read_coeffs_rect( | |
| 16713 | + dec, &mut coding, tu_scan, tw, th, skip_ctx, dc_sign_ctx(around.2), | |
| 16714 | + TxType::DctDct, | |
| 16715 | + )?; | |
| 16716 | + if li == 0 { | |
| 16717 | + chroma_tx = tx_type; | |
| 16718 | + fctx.luma_tx_type.with(|c| c.set(tx_type)); | |
| 16719 | + } | |
| 16720 | + let residual = dequant_and_inverse_typed_wh( | |
| 16721 | + &levels, tw, th, crate::decode::bit_depth(fctx), block_q_idx(fctx), | |
| 16722 | + plane_q_delta(0, fctx).0, plane_q_delta(0, fctx).1, tx_type, | |
| 16723 | + ); | |
| 16724 | + if (tw, th) == (4, 4) { | |
| 16725 | + push_intra(0, tu_px, tu_py, 4, DC_PRED, 0, tu_reach, &residual, None, None, smooth_neighbor, fctx); | |
| 16726 | + } else { | |
| 16727 | + push_intra_rect(0, tu_px, tu_py, tw, th, DC_PRED, 0, tu_reach, &residual, None, None, smooth_neighbor, fctx); | |
| 16728 | + } | |
| 16729 | + levels | |
| 16730 | + }; | |
| 16731 | + if single { | |
| 16732 | + grid = tu_grid; | |
| 16733 | + } else { | |
| 16734 | + // Per-unit neighbour state, the same shape the intra rect | |
| 16735 | + // leaf's own split path runs (`decode_leaf8`'s depth-1 | |
| 16736 | + // loop): a transform unit inside a block is not a block at | |
| 16737 | + // that position. | |
| 16738 | + neighbours.record_mi_luma(tu_mi, 4, &tu_grid); | |
| 16739 | + } | |
| 16740 | + } | |
| 16741 | + if single { | |
| 16742 | + let state = neighbour_state(&grid); | |
| 16743 | + for cell in 0..h_mi { | |
| 16744 | + if lmi.0 + cell < neighbours.mi_rows { | |
| 16745 | + neighbours.left[lmi.0 + cell][0] = state; | |
| 16746 | + } | |
| 16747 | + } | |
| 16748 | + for cell in 0..w_mi { | |
| 16749 | + if lmi.1 + cell < neighbours.mi_cols { | |
| 16750 | + neighbours.above[lmi.1 + cell][0] = state; | |
| 16751 | + } | |
| 16752 | + } | |
| 16753 | + } | |
| 16754 | + neighbours.fill_skip_grid_rect(lmi, w_mi, h_mi, skip); | |
| 16755 | + neighbours.fill_lf_grid_rect( | |
| 16756 | + lmi, | |
| 16757 | + w_mi, | |
| 16758 | + h_mi, | |
| 16759 | + if single { bw as u8 } else { 4 }, | |
| 16760 | + if single { bh as u8 } else { 4 }, | |
| 16761 | + 0, | |
| 16762 | + fctx, | |
| 16763 | + ); | |
| 16764 | + // `record_intrabc_mi` publishes a square `n4`x`n4` footprint; a | |
| 16765 | + // 4x8/8x4 leaf needs its true `w_mi`x`h_mi` (lane-av1txr). | |
| 16766 | + record_intrabc_mi_rect(lmi.0, lmi.1, w_mi, h_mi, Some(dv), fctx); | |
| 16767 | + if has_chroma { | |
| 16768 | + last_uv = Some((DC_PRED, 0, None)); | |
| 16769 | + last_intrabc = Some(dv); | |
| 16770 | + // See [`decode_leaf_split4`]: an intrabc block's chroma | |
| 16771 | + // inherits the luma transform type. | |
| 16772 | + fctx.intrabc_chroma_tx.with(|c| c.set(Some(chroma_tx))); | |
| 16773 | + } | |
| 16774 | + continue; | |
| 16775 | + } | |
| 16427 | 16776 | if filter_intra.is_some() { |
| 16428 | 16777 | // lane-fi8 r1: `predict_filter_intra` walks its 4x2 patches over |
| 16429 | 16778 | // a true `bw`x`bh` block, so a 4x8/8x4 leaf predicts through the |
| @@ -16459,10 +16808,6 @@ fn decode_leaf_rect8( | ||
| 16459 | 16808 | hit!(TX_DEPTH_HITS); |
| 16460 | 16809 | hit!(RECT8_SPLIT_TX_HITS); |
| 16461 | 16810 | } |
| 16462 | - leaf_modes[i] = mode; | |
| 16463 | - leaf_skips[i] = skip; | |
| 16464 | - neighbours.record_mode_mi(lmi.0, lmi.1, w_mi, h_mi, mode); | |
| 16465 | - let smooth_neighbor = is_smooth_mode(leaf_above) || is_smooth_mode(leaf_left); | |
| 16466 | 16811 | if smooth_neighbor { |
| 16467 | 16812 | hit!(SMOOTH_LUMA_HITS); |
| 16468 | 16813 | } |
| @@ -16475,6 +16820,15 @@ fn decode_leaf_rect8( | ||
| 16475 | 16820 | // four. The per-TU path writes its own neighbour state, so the |
| 16476 | 16821 | // block-level write below is skipped for it. |
| 16477 | 16822 | let split = depth != 0 || lossless(fctx); |
| 16823 | + // lane-av1txr: libaom `parse_decode_block`'s `set_txfm_ctxs` for this | |
| 16824 | + // leaf -- the size the `tx_depth` symbol resolved (depth 1 -> TX_4X4, | |
| 16825 | + // else the leaf's own rect transform), published over the leaf's own | |
| 16826 | + // mi span. An intrabc block's `txfm_partition_context` reads these | |
| 16827 | + // bands, and the key-frame sub-8x8 leaves had no write at all: | |
| 16828 | + // `warped.obu` mi (37,62) read a stale 8 where aomdec read 4 (ctx 18 | |
| 16829 | + // vs 19) and the tile desynced (class `context-band-not-published`). | |
| 16830 | + let (ctx_tx_w, ctx_tx_h) = if split { (4, 4) } else { (bw, bh) }; | |
| 16831 | + txfm_partition_update_rect(neighbours, lmi, (ctx_tx_w, ctx_tx_h), (bw, bh)); | |
| 16478 | 16832 | if split { |
| 16479 | 16833 | let mut done = 0usize; |
| 16480 | 16834 | for tu in 0..2usize { |
| @@ -16666,6 +17020,38 @@ fn decode_leaf_rect8( | ||
| 16666 | 17020 | 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); |
| 16667 | 17021 | 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); |
| 16668 | 17022 | (Grid::Zero(16), Grid::Zero(16)) |
| 17023 | + } else if let Some(dv) = last_intrabc { | |
| 17024 | + // lane-av1txr: the chroma-reference leaf was an intrabc block, so the | |
| 17025 | + // group's one chroma unit is a frame copy at that DV too (its residual | |
| 17026 | + // still reads the ordinary `Chroma4` coefficient tables -- libaom | |
| 17027 | + // codes a chroma `tx_type` nowhere). | |
| 17028 | + let mut ub = vec![0u16; 16]; | |
| 17029 | + mc::predict_with_filter( | |
| 17030 | + &u.data, u.width, u.true_width, u.true_height, | |
| 17031 | + mv_to_q4(cpx, dv.1, false), mv_to_q4(cpy, dv.0, false), | |
| 17032 | + 4, 4, mc::InterpFilterKind::Bilinear, &mut ub, fctx, | |
| 17033 | + ); | |
| 17034 | + let mut vb = vec![0u16; 16]; | |
| 17035 | + mc::predict_with_filter( | |
| 17036 | + &v.data, v.width, v.true_width, v.true_height, | |
| 17037 | + mv_to_q4(cpx, dv.1, false), mv_to_q4(cpy, dv.0, false), | |
| 17038 | + 4, 4, mc::InterpFilterKind::Bilinear, &mut vb, fctx, | |
| 17039 | + ); | |
| 17040 | + let chroma_around = neighbours.around_mi(leaf_mi, 8); | |
| 17041 | + set_palette_pred(ub, fctx); | |
| 17042 | + let ug = read_plane( | |
| 17043 | + dec, cdfs, TxbSet::Chroma4, scan4, 1, chroma_around[1], DC_PRED, DC_PRED, | |
| 17044 | + 0, group_reach, u, cpx, cpy, 4, TX4, base_q_idx, | |
| 17045 | + None, None, None, smooth_neighbor_uv, fctx, | |
| 17046 | + )?; | |
| 17047 | + set_palette_pred(vb, fctx); | |
| 17048 | + let vg = read_plane( | |
| 17049 | + dec, cdfs, TxbSet::Chroma4, scan4, 2, chroma_around[2], DC_PRED, DC_PRED, | |
| 17050 | + 0, group_reach, v, cpx, cpy, 4, TX4, base_q_idx, | |
| 17051 | + None, None, None, smooth_neighbor_uv, fctx, | |
| 17052 | + )?; | |
| 17053 | + fctx.intrabc_chroma_tx.with(|c| c.set(None)); | |
| 17054 | + (ug, vg) | |
| 16669 | 17055 | } else { |
| 16670 | 17056 | let ac = alpha.map(|_| cfl_src(gpx, gpy, 8)); |
| 16671 | 17057 | 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 | ||
| 18877 | 19263 | if allowed.contains(&t) { t } else { DctDct } |
| 18878 | 19264 | } |
| 18879 | 19265 | |
| 19266 | +/// The [`TxbSet`] a resolved luma transform side reads its coefficient tables | |
| 19267 | +/// from for a block libaom's `is_inter_block` calls inter -- which an intrabc | |
| 19268 | +/// block is (`blockd.h:373`), so its `tx_type` comes off the inter `ext_tx` | |
| 19269 | +/// sets, never the mode-indexed intra ones ([`txbset_for`]). | |
| 19270 | +/// | |
| 19271 | +/// 64 is only ever the 64x64-block, depth-0, corner-scanned case | |
| 19272 | +/// ([`TxbSet::Luma64`]); every other resolved side maps to its own matching | |
| 19273 | +/// set. `get_tx_set` (spec 5.11.48) only splits on `reduced_tx_set` at | |
| 19274 | +/// `TX_8X8`/`TX_4X4`: an intra `TX_16X16` always reads `TX_SET_INTRA_2` | |
| 19275 | +/// regardless of the flag (`av1_get_ext_tx_set_type`'s | |
| 19276 | +/// `tx_size_sqr == TX_16X16` branch ignores `use_reduced_set` once it is past | |
| 19277 | +/// the `TX_32X32`/reduced-set checks), so only the 8x8 and 4x4 cases have a | |
| 19278 | +/// second table ([`TxbSet::Luma8Inter`]/[`TxbSet::Luma4Inter`]). | |
| 19279 | +/// | |
| 19280 | +/// lane-av1txr: the intrabc leaf sites used to call a near-duplicate | |
| 19281 | +/// `txbset_for_inter` whose `4` fell through to `Luma64` -- 32x32-class tables | |
| 19282 | +/// (a 1024-entry grid) handed to a 4x4 dequant, which panicked at | |
| 19283 | +/// `transform.rs`'s `inverse_transform_2d_typed_wh` the first time an intrabc | |
| 19284 | +/// 4x4 TU coded a non-zero coefficient (`allintra0`/cpu-used=0). The | |
| 19285 | +/// duplicate is gone; every inter-table site goes through this one mapping. | |
| 18880 | 19286 | fn inter_txbset_for(tx_px: usize, reduced_tx_set: bool) -> TxbSet { |
| 18881 | 19287 | match tx_px { |
| 18882 | 19288 | // lane-sb128c r1: a 128x128 inter block's own luma unit |
| @@ -18915,29 +19321,6 @@ fn scan_for<'a>( | ||
| 18915 | 19321 | } |
| 18916 | 19322 | } |
| 18917 | 19323 | |
| 18918 | -/// The [`TxbSet`] a resolved luma transform side reads its coefficient tables | |
| 18919 | -/// from -- 64 is only ever the 64x64-block, depth-0, corner-scanned case | |
| 18920 | -/// ([`TxbSet::Luma64`]); every other resolved side maps to its own matching | |
| 18921 | -/// set. `get_tx_set` (spec 5.11.48) only splits on `reduced_tx_set` at | |
| 18922 | -/// `TX_8X8`/`TX_4X4`: an intra `TX_16X16` always reads `TX_SET_INTRA_2` | |
| 18923 | -/// regardless of the flag (`av1_get_ext_tx_set_type`'s | |
| 18924 | -/// `tx_size_sqr == TX_16X16` branch ignores `use_reduced_set` once it is past | |
| 18925 | -/// the `TX_32X32`/reduced-set checks), so only the 8x8 and 4x4 cases have a | |
| 18926 | -/// second table ([`TxbSet::Luma8Set1`]/[`TxbSet::Luma4Set1`]). | |
| 18927 | -/// [`txbset_for`], for a block libaom's `is_inter_block` calls inter -- which | |
| 18928 | -/// an intrabc block is (`blockd.h:373`), so its `tx_type` comes off the | |
| 18929 | -/// inter `ext_tx` sets, never the mode-indexed intra ones. | |
| 18930 | -fn txbset_for_inter(tx_px: usize, reduced_tx_set: bool) -> TxbSet { | |
| 18931 | - match tx_px { | |
| 18932 | - 64 => TxbSet::Luma64, | |
| 18933 | - 32 => TxbSet::Luma32Inter, | |
| 18934 | - 16 if reduced_tx_set => TxbSet::Luma16Inter, | |
| 18935 | - 16 => TxbSet::Luma16InterSet1, | |
| 18936 | - 8 if reduced_tx_set => TxbSet::Luma8Inter, | |
| 18937 | - 8 => TxbSet::Luma8InterSet1, | |
| 18938 | - _ => TxbSet::Luma64, | |
| 18939 | - } | |
| 18940 | -} | |
| 18941 | 19324 | |
| 18942 | 19325 | fn txbset_for(tx_px: usize, reduced_tx_set: bool) -> TxbSet { |
| 18943 | 19326 | match tx_px { |
| @@ -22445,6 +22828,9 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | ||
| 22445 | 22828 | ); |
| 22446 | 22829 | } |
| 22447 | 22830 | let mut dec = SymbolDecoder::new(tile_bytes); |
| 22831 | + // lane-av1txr: spec 5.9.2's `disable_cdf_update` -- a frame that sets | |
| 22832 | + // it codes every symbol against the tables it started with. | |
| 22833 | + dec.set_cdf_update(!cdf_update_disabled(fctx)); | |
| 22448 | 22834 | crate::census::register_cdfs(&cdfs); |
| 22449 | 22835 | neighbours.start_tile(mi_row0 as usize, mi_col0 as usize, mi_col1 as usize, fctx); |
| 22450 | 22836 | y.set_tile_origin( |
| @@ -24716,15 +25102,17 @@ fn read_intrabc_dv( | ||
| 24716 | 25102 | cdfs: &mut Cdfs, |
| 24717 | 25103 | mi_r: usize, |
| 24718 | 25104 | mi_c: usize, |
| 24719 | - side: usize, fctx: &crate::decode::FrameCtx, | |
| 25105 | + // The block's own mi footprint (`av1_find_mv_refs` takes the real bsize, | |
| 25106 | + // so a sub-8x8 `BLOCK_4X8`/`BLOCK_8X4` leaf scans a 1x2/2x1 neighbourhood | |
| 25107 | + // -- lane-av1txr). | |
| 25108 | + (n4_w, n4_h): (usize, usize), fctx: &crate::decode::FrameCtx, | |
| 24720 | 25109 | ) -> (i32, i32) { |
| 24721 | 25110 | const INTRABC_DELAY_PIXELS: i32 = 256; |
| 24722 | - let n4 = side / MI; | |
| 24723 | 25111 | let stack_pred = fctx.intrabc_mi_grid.with(|g| { |
| 24724 | 25112 | let g = g.borrow(); |
| 24725 | 25113 | g.as_ref().map(|(grid, mi_cols, mi_rows)| { |
| 24726 | 25114 | let stack = crate::mvstack::find_mv_stack( |
| 24727 | - grid, mi_r, mi_c, n4, n4, 0, /* INTRA_FRAME */ | |
| 25115 | + grid, mi_r, mi_c, n4_w, n4_h, 0, /* INTRA_FRAME */ | |
| 24728 | 25116 | *mi_cols, *mi_rows, |
| 24729 | 25117 | ); |
| 24730 | 25118 | if stack.nearest_mv == (0, 0) { |
| @@ -24752,7 +25140,12 @@ fn read_intrabc_dv( | ||
| 24752 | 25140 | } |
| 24753 | 25141 | // "Ref DV should not have sub-pel" (`assign_dv`): floor to full pel. |
| 24754 | 25142 | let pred = ((pred.0 >> 3) * 8, (pred.1 >> 3) * 8); |
| 24755 | - read_mv(dec, &mut cdfs.dv_comp, &mut cdfs.dv_joint, pred, false, true) | |
| 25143 | + let dv = read_mv(dec, &mut cdfs.dv_comp, &mut cdfs.dv_joint, pred, false, true); | |
| 25144 | + if crate::envflags::env_flag!("EC_TRACE_MODE_STEP") { | |
| 25145 | + let (rng, _) = dec.debug_state(); | |
| 25146 | + eprintln!("EC_DV mi_row={mi_r} mi_col={mi_c} dv_col={} dv_row={} rng={rng}", dv.1, dv.0); | |
| 25147 | + } | |
| 25148 | + dv | |
| 24756 | 25149 | } |
| 24757 | 25150 | |
| 24758 | 25151 | /// 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( | ||
| 35164 | 35557 | fctx.quant_deltas.with(|c| c.set(deltas)); |
| 35165 | 35558 | fctx.current_delta_lf.with(|c| c.set([0; 4])); |
| 35166 | 35559 | let mut dec = SymbolDecoder::new(data); |
| 35560 | + // lane-av1txr: spec 5.9.2's `disable_cdf_update` -- a frame that sets | |
| 35561 | + // it codes every symbol against the tables it started with. | |
| 35562 | + dec.set_cdf_update(!cdf_update_disabled(fctx)); | |
| 35167 | 35563 | crate::census::register_cdfs(&cdfs); |
| 35168 | 35564 | // lane-comppin r9: tile-entry range, the earliest point comparable |
| 35169 | 35565 | // against aomdec's own `r->ec.rng` right after `aom_reader_init` -- the |
crates/ec-av1/src/msac.rsmodified+73 -0
| @@ -305,6 +305,14 @@ pub struct SymbolDecoder<'a> { | ||
| 305 | 305 | /// Bits left before the decoder starts padding with zeros (spec |
| 306 | 306 | /// `SymbolMaxBits`), which goes negative at the end of the string. |
| 307 | 307 | max_bits: i32, |
| 308 | + /// Whether [`SymbolDecoder::symbol`] adapts the CDF it reads (spec 8.3.2). | |
| 309 | + /// `false` for a frame whose header sets `disable_cdf_update` -- libaom's | |
| 310 | + /// tile entry (`decodeframe.c:2909`, `allow_update_cdf = allow_update_cdf | |
| 311 | + /// && !cm->features.disable_cdf_update`) skips the adaptation there, so | |
| 312 | + /// reading on would drift this decoder's tables away from the encoder's | |
| 313 | + /// and desync mid-frame. Per-READER, not global: frames of one stream can | |
| 314 | + /// decode on different worker threads. | |
| 315 | + adapt: bool, | |
| 308 | 316 | } |
| 309 | 317 | |
| 310 | 318 | impl Drop for SymbolDecoder<'_> { |
| @@ -326,6 +334,7 @@ impl<'a> SymbolDecoder<'a> { | ||
| 326 | 334 | value: 0, |
| 327 | 335 | range: 1 << 15, |
| 328 | 336 | max_bits: 8 * data.len() as i32 - 15, |
| 337 | + adapt: true, | |
| 329 | 338 | }; |
| 330 | 339 | let num_bits = usize::min(data.len() * 8, 15) as u32; |
| 331 | 340 | let buf = d.f(num_bits); |
| @@ -333,6 +342,15 @@ impl<'a> SymbolDecoder<'a> { | ||
| 333 | 342 | d |
| 334 | 343 | } |
| 335 | 344 | |
| 345 | + /// Spec 5.9.2's `disable_cdf_update`, the reader side: `false` (the | |
| 346 | + /// default) adapts every CDF [`symbol`](Self::symbol) reads; `true` | |
| 347 | + /// leaves each table exactly as it was read, matching libaom's | |
| 348 | + /// `allow_update_cdf` (decodeframe.c:2909). Set once per tile reader by | |
| 349 | + /// the frame's own header bit. | |
| 350 | + pub(crate) fn set_cdf_update(&mut self, update: bool) { | |
| 351 | + self.adapt = update; | |
| 352 | + } | |
| 353 | + | |
| 336 | 354 | /// `f(n)`: the next `n` bits, most significant first, zero past the end. |
| 337 | 355 | #[inline] |
| 338 | 356 | fn f(&mut self, n: u32) -> u32 { |
| @@ -386,7 +404,14 @@ impl<'a> SymbolDecoder<'a> { | ||
| 386 | 404 | // relaxed load. |
| 387 | 405 | let t0 = if crate::census::armed() { self.tell_bits() } else { 0.0 }; |
| 388 | 406 | let s = self.symbol_fixed(cdf); |
| 407 | + // lane-av1txr: spec 5.9.2's `disable_cdf_update` -- a frame that sets | |
| 408 | + // it codes every symbol against the tables it started with, so this | |
| 409 | + // reader must leave them untouched too (libaom: `allow_update_cdf = | |
| 410 | + // allow_update_cdf && !cm->features.disable_cdf_update`, | |
| 411 | + // decodeframe.c:2909). The flag is per-reader (see `Self::adapt`). | |
| 412 | + if self.adapt { | |
| 389 | 413 | update_cdf(cdf, s); |
| 414 | + } | |
| 390 | 415 | if crate::census::armed() { |
| 391 | 416 | crate::census::charge(cdf.as_ptr() as usize, self.tell_bits() - t0); |
| 392 | 417 | } |
| @@ -813,6 +838,54 @@ pub(crate) mod tests { | ||
| 813 | 838 | assert_eq!(fast_cdfs[pick.min(14)], slow_cdfs[pick.min(14)], "cdf after item {i}"); |
| 814 | 839 | } |
| 815 | 840 | } |
| 841 | + | |
| 842 | + /// lane-av1txr: spec 5.9.2's `disable_cdf_update`, the reader half -- | |
| 843 | + /// [`SymbolDecoder::set_cdf_update`]. A reader told not to adapt must | |
| 844 | + /// reproduce a writer that never adapted | |
| 845 | + /// ([`SymbolEncoder::symbol_fixed`]), and the DEFAULT reader must not: the | |
| 846 | + /// flag is what keeps a real `aomenc --cdf-update-mode=0` stream in sync | |
| 847 | + /// (its tiles desynced at the first multi-symbol block without it). | |
| 848 | + #[test] | |
| 849 | + fn a_reader_told_not_to_adapt_matches_a_non_adapting_writer() { | |
| 850 | + let mut state = 0x2545_f491_4f6c_dd1du64; | |
| 851 | + let mut enc = SymbolEncoder::new(); | |
| 852 | + let cdfs: Vec<Vec<u16>> = (2..=16).map(flat_cdf).collect(); | |
| 853 | + let mut written = Vec::new(); | |
| 854 | + for i in 0..600 { | |
| 855 | + let pick = i % cdfs.len(); | |
| 856 | + let nsyms = pick + 2; | |
| 857 | + let sym = (rng(&mut state) % nsyms as u64) as usize; | |
| 858 | + enc.symbol_fixed(sym, &cdfs[pick]); | |
| 859 | + written.push((pick, sym)); | |
| 860 | + } | |
| 861 | + let payload = enc.finish(); | |
| 862 | + | |
| 863 | + let mut fixed = SymbolDecoder::new(&payload); | |
| 864 | + fixed.set_cdf_update(false); | |
| 865 | + let mut adapting = SymbolDecoder::new(&payload); | |
| 866 | + let mut fixed_cdfs: Vec<Vec<u16>> = (2..=16).map(flat_cdf).collect(); | |
| 867 | + let mut adapting_cdfs: Vec<Vec<u16>> = (2..=16).map(flat_cdf).collect(); | |
| 868 | + let mut adapting_mismatches = 0usize; | |
| 869 | + for (i, &(pick, sym)) in written.iter().enumerate() { | |
| 870 | + assert_eq!( | |
| 871 | + fixed.symbol(&mut fixed_cdfs[pick]), | |
| 872 | + sym, | |
| 873 | + "non-adapting reader, item {i} (pick {pick})" | |
| 874 | + ); | |
| 875 | + if adapting.symbol(&mut adapting_cdfs[pick]) != sym { | |
| 876 | + adapting_mismatches += 1; | |
| 877 | + } | |
| 878 | + } | |
| 879 | + assert_eq!( | |
| 880 | + fixed_cdfs, | |
| 881 | + (2..=16).map(flat_cdf).collect::<Vec<_>>(), | |
| 882 | + "the non-adapting reader still moved a table" | |
| 883 | + ); | |
| 884 | + assert!( | |
| 885 | + adapting_mismatches > 0, | |
| 886 | + "the adaptation flag is inert: the default reader reproduced a non-adapting writer" | |
| 887 | + ); | |
| 888 | + } | |
| 816 | 889 | } |
| 817 | 890 | |
| 818 | 891 | /// Symbol-by-symbol writer/reader trace (`EC_AV1_SYMTRACE=<dir>`), the |
crates/ec-av1/src/refusal_inventory.rsmodified+51 -14
| @@ -64,8 +64,29 @@ const REFUSALS: &[&str] = &[ | ||
| 64 | 64 | // `every_read_intra_mode_call_site_hands_the_reader_a_palette_cache`, |
| 65 | 65 | // which keeps that invariant now the refusal is gone). |
| 66 | 66 | "intra block copy on a HORZ/VERT/1:4 rect intra strip (reconstruction is not ported at this shape)", |
| 67 | - "a sub-8x8 leaf that uses intrabc (this reader has no block-vector path; the 8x8-and-up reader reconstructs one)", | |
| 67 | + // lane-av1txr: `a sub-8x8 leaf that uses intrabc (…)` is GONE -- the | |
| 68 | + // capability landed in this lane (4x4 / 4x8 / 8x4 intrabc leaves read the | |
| 69 | + // DV and reconstruct a frame copy + the INTER residual; gates | |
| 70 | + // `a_non_420_subsampled_sequence_header_is_refused_by_name`'s sibling | |
| 71 | + // witnesses and the `warped.obu`/`allintra.obu` traces). Its census gate | |
| 72 | + // (`a_sub8_leaf_census_over_intrabc_screen_streams_measures_the_sub8_refusal`) | |
| 73 | + // still runs: it now reports `reached = 0` with the same non-vacuous | |
| 74 | + // premise (allow_intrabc frames + decoded sub-8 leaves). | |
| 68 | 75 | "a bit depth of 12 (this decoder is gated at 8 and 10 only: warp/MC/wiener rounding shifts change at 12-bit and no 12-bit gate exists)", |
| 76 | + // lane-av1txr: the silent-garbage guard. A 4:4:4/4:2:2 stream used to | |
| 77 | + // decode with no refusal and wrong pixels (every chroma extent is | |
| 78 | + // hardcoded 4:2:0, the probe emits 4:2:0 planes only); it is now refused | |
| 79 | + // at the sequence header. Gate: | |
| 80 | + // `a_non_420_subsampled_sequence_header_is_refused_by_name`. | |
| 81 | + "a chroma format other than 4:2:0 (subsampling_x/y != 1/1): every chroma extent in this decoder is hardcoded to 4:2:0 and the probe emits 4:2:0 planes only, so a 4:4:4/4:2:2 stream would decode silently wrong pixels", | |
| 82 | + // lane-av1txr-r2: the third member of the same silent-garbage family. | |
| 83 | + // `using_qmatrix`/`qm_y`/`qm_u`/`qm_v` are parsed by `ec-av1-syntax` but | |
| 84 | + // read by NOTHING on the decode path -- dequantisation is `base_q_idx` + | |
| 85 | + // the plane DC/AC deltas only -- so a real `aomenc --enable-qm=1` stream | |
| 86 | + // decoded with no refusal and wrong pixels (measured: byte-diff vs ffmpeg | |
| 87 | + // while the qm-off control is byte-exact). Refused at the frame header. | |
| 88 | + // Gate: `a_frame_using_quantisation_matrices_is_refused_by_name`. | |
| 89 | + "a frame using quantisation matrices (using_qmatrix=1): dequantisation here is base_q_idx plus the plane DC/AC deltas only, so qm_y/qm_u/qm_v would be ignored and the frame would decode silently wrong pixels", | |
| 69 | 90 | // lane-lossless/lane-lossless2: a lossless frame (base_q_idx 0) decodes |
| 70 | 91 | // sample-exact, KEY and INTER -- TX_4X4 with the Walsh-Hadamard transform |
| 71 | 92 | // on every plane, no `tx_type` symbol, `is_cfl_allowed` narrowed to a |
| @@ -286,11 +307,15 @@ const PROVEN: &[(&str, &str)] = &[ | ||
| 286 | 307 | "a tx_type symbol outside its CDF's own set: {t}", |
| 287 | 308 | "every_tx_type_symbol_of_every_cdf_width_maps_into_its_own_set", |
| 288 | 309 | ), |
| 289 | - // lane-t900 r24, enumeration: the reader covers spec 5.11.40's whole value | |
| 290 | - // domain (`0..=(1 << 20) - 2`, both ends of every prefix length), so the | |
| 291 | - // refusal is outside it. What it still names is a bit pattern no encoder | |
| 292 | - // writes -- a 20th prefix bit of 0, which the spec's `length == 20` break | |
| 293 | - // makes a don't-care. | |
| 310 | + // lane-t900 r24 + lane-av1txr RE-PIN, measured: the reader covers spec | |
| 311 | + // 5.11.40's whole value domain (`0..=(1 << 20) - 2`, both ends of every | |
| 312 | + // prefix length), so no CONFORMANT symbol stream reaches it -- but the | |
| 313 | + // string IS reachable as a SYMPTOM: a frame this decoder desyncs on | |
| 314 | + // (measured: a real libaom monochrome key frame, gate | |
| 315 | + // `a_real_libaom_monochrome_key_frame_is_refused_by_name` at | |
| 316 | + // `stream.rs`) leaves the reader mid-symbol and the next `read_golomb` | |
| 317 | + // reports this tail. The claim below therefore pins the reader's value | |
| 318 | + // coverage, NOT the string's unreachability. | |
| 294 | 319 | ( |
| 295 | 320 | "a Golomb tail longer than this decoder reads", |
| 296 | 321 | "read_golomb_reads_every_value_a_conformant_stream_can_carry", |
| @@ -326,6 +351,22 @@ const PROVEN: &[(&str, &str)] = &[ | ||
| 326 | 351 | "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)", |
| 327 | 352 | "a_twelve_bit_sequence_header_is_refused_by_name", |
| 328 | 353 | ), |
| 354 | + // lane-av1txr: the guard's own gate builds a profile-1 and a profile-2 | |
| 355 | + // sequence header by hand and asserts each refuses by name while the | |
| 356 | + // profile-0 CONTROL still decodes -- the refusal is exercised, not merely | |
| 357 | + // present. | |
| 358 | + ( | |
| 359 | + "a chroma format other than 4:2:0 (subsampling_x/y != 1/1): every chroma extent in this decoder is hardcoded to 4:2:0 and the probe emits 4:2:0 planes only, so a 4:4:4/4:2:2 stream would decode silently wrong pixels", | |
| 360 | + "a_non_420_subsampled_sequence_header_is_refused_by_name", | |
| 361 | + ), | |
| 362 | + // lane-av1txr-r2: the gate encodes the same source twice with real aomenc | |
| 363 | + // (`--enable-qm=1` and `--enable-qm=0`), asserts the qm-off CONTROL decodes | |
| 364 | + // and the qm-on stream is refused by name -- so the refusal is exercised | |
| 365 | + // against the exact encoder path it names, not merely present. | |
| 366 | + ( | |
| 367 | + "a frame using quantisation matrices (using_qmatrix=1): dequantisation here is base_q_idx plus the plane DC/AC deltas only, so qm_y/qm_u/qm_v would be ignored and the frame would decode silently wrong pixels", | |
| 368 | + "a_frame_using_quantisation_matrices_is_refused_by_name", | |
| 369 | + ), | |
| 329 | 370 | ( |
| 330 | 371 | "intra block copy on a HORZ/VERT/1:4 rect intra strip (reconstruction is not ported at this shape)", |
| 331 | 372 | "a_real_aomenc_screen_key_frame_reads_use_intrabc_on_rect_strips", |
| @@ -409,14 +450,10 @@ const PROVEN: &[(&str, &str)] = &[ | ||
| 409 | 450 | "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)", |
| 410 | 451 | "no_128_root_half_reads_a_cfl_filter_intra_or_palette_symbol", |
| 411 | 452 | ), |
| 412 | - // lane-t900 r33, CENSUS: the `use_intrabc` symbol IS read at the sub-8 | |
| 413 | - // reader for every sub-8x8 leaf of an `allow_intrabc` frame, and over the | |
| 414 | - // `--min-partition-size=4` exact-repetition screen arms every such symbol | |
| 415 | - // came back 0 while the frames decode pixel-exact. | |
| 416 | - ( | |
| 417 | - "a sub-8x8 leaf that uses intrabc (this reader has no block-vector path; the 8x8-and-up reader reconstructs one)", | |
| 418 | - "a_sub8_leaf_census_over_intrabc_screen_streams_measures_the_sub8_refusal", | |
| 419 | - ), | |
| 453 | + // lane-av1txr: the sub-8x8 intrabc refusal this census pinned is GONE (the | |
| 454 | + // capability landed; see the note in `REFUSALS`). The census gate survives | |
| 455 | + // as the witness that its premise is still exercised -- `reached` is 0 by | |
| 456 | + // construction now. | |
| 420 | 457 | // lane-t900 r33, CENSUS: four quantisers of the recipe that reaches the |
| 421 | 458 | // intrabc var-tx tree at all read it for 5 blocks in total, every one of |
| 422 | 459 | // which resolved to a UNIFORM leaf size, with the frames pixel-exact. |
crates/ec-av1/src/stream.rsmodified+211 -0
| @@ -1252,6 +1252,13 @@ pub(crate) struct SeqFlags { | ||
| 1252 | 1252 | pub(crate) mono_chrome: bool, |
| 1253 | 1253 | pub(crate) order_hint_bits: u32, |
| 1254 | 1254 | pub(crate) mc_identity: bool, |
| 1255 | + /// lane-av1txr: `color_config.subsampling_x/y` (spec 5.5.2). The decoder | |
| 1256 | + /// itself hardcodes 4:2:0 everywhere, so these exist only for the | |
| 1257 | + /// sequence-level refusal in [`decode_stream_with`] -- nothing downstream | |
| 1258 | + /// reads them. A monochrome header parses as 1,1, so `!(1,1)` singles out | |
| 1259 | + /// 4:4:4 (profile 1 / sRGB) and 4:2:2 (profile 2 below 12-bit). | |
| 1260 | + pub(crate) subsampling_x: u8, | |
| 1261 | + pub(crate) subsampling_y: u8, | |
| 1255 | 1262 | } |
| 1256 | 1263 | |
| 1257 | 1264 | impl SeqFlags { |
| @@ -1269,6 +1276,8 @@ impl SeqFlags { | ||
| 1269 | 1276 | mono_chrome: seq.is_some_and(|s| s.color_config.mono_chrome), |
| 1270 | 1277 | order_hint_bits: seq.map_or(0, |s| s.order_hint_bits), |
| 1271 | 1278 | mc_identity: seq.is_some_and(|s| s.color_config.matrix_coefficients == 0), |
| 1279 | + subsampling_x: seq.map_or(1, |s| s.color_config.subsampling_x), | |
| 1280 | + subsampling_y: seq.map_or(1, |s| s.color_config.subsampling_y), | |
| 1272 | 1281 | } |
| 1273 | 1282 | } |
| 1274 | 1283 | } |
| @@ -1623,6 +1632,45 @@ fn decode_frame( | ||
| 1623 | 1632 | "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)", |
| 1624 | 1633 | )); |
| 1625 | 1634 | } |
| 1635 | + // lane-av1txr: `color_config.subsampling_x/y` (spec 5.5.2) are parsed by | |
| 1636 | + // `ec-av1-syntax` -- profile 1 forces 4:4:4, profile 2 below 12-bit forces | |
| 1637 | + // 4:2:2, and the sRGB identity description forces full-range 4:4:4 -- but | |
| 1638 | + // the decoder reads them NOWHERE: every chroma extent is hardcoded 4:2:0 | |
| 1639 | + // (`let (chroma_w, chroma_h) = (bw / 2, bh / 2)` at every rect site, | |
| 1640 | + // `chroma_side = side / 2` in `decode_block`) and the probe emits 4:2:0 | |
| 1641 | + // planes only. Measured consequence: EVERY 4:4:4 stream desyncs at the | |
| 1642 | + // first chroma transform (a444-cu6 block (0,0): aomdec reads | |
| 1643 | + // `EC_COEFF plane=1 tx=TX_8X16` at rng 39857 where ours reads a 4-wide, | |
| 1644 | + // 8-high 4:2:0 chroma block at the same rng) and then decodes pixels that | |
| 1645 | + // are silently wrong. Refuse by name rather than return garbage. A | |
| 1646 | + // `num_planes == 1` (monochrome) header keeps its parsed 1,1 and is | |
| 1647 | + // unaffected. Gates: `a_non_420_subsampled_sequence_header_is_refused_by_ | |
| 1648 | + // name` below (hand-built profile 1/2 headers plus a real aomenc 4:4:4 | |
| 1649 | + // stream). | |
| 1650 | + if seq.subsampling_x != 1 || seq.subsampling_y != 1 { | |
| 1651 | + return Err(Error::unsupported( | |
| 1652 | + "AV1 decode_stream", | |
| 1653 | + "a chroma format other than 4:2:0 (subsampling_x/y != 1/1): every chroma extent in this decoder is hardcoded to 4:2:0 and the probe emits 4:2:0 planes only, so a 4:4:4/4:2:2 stream would decode silently wrong pixels", | |
| 1654 | + )); | |
| 1655 | + } | |
| 1656 | + // lane-av1txr-r2: `quantization_params.using_qmatrix` (spec 5.9.12) is | |
| 1657 | + // parsed by `ec-av1-syntax` along with `qm_y`/`qm_u`/`qm_v` (frame.rs | |
| 1658 | + // :190-196, :1418-1426), but this decoder reads NONE of them: every | |
| 1659 | + // dequantisation below is `base_q_idx` plus the plane DC/AC deltas only | |
| 1660 | + // (`Quantizer::new`), so a stream that applies quantisation matrices | |
| 1661 | + // dequantises every coefficient off the wrong table. The same | |
| 1662 | + // silent-garbage class as the non-4:2:0 guard above. Measured: a real | |
| 1663 | + // `aomenc --enable-qm=1` key frame (`using_qmatrix = 1`, `qm_y/u/v = 5`) | |
| 1664 | + // decodes with NO refusal and its planes byte-differ from ffmpeg, while | |
| 1665 | + // the `--enable-qm=0` control of the same source and recipe is | |
| 1666 | + // byte-exact. Refuse by name rather than return garbage. Gate: | |
| 1667 | + // `a_frame_using_quantisation_matrices_is_refused_by_name` below. | |
| 1668 | + if header.quantization.using_qmatrix { | |
| 1669 | + return Err(Error::unsupported( | |
| 1670 | + "AV1 decode_stream", | |
| 1671 | + "a frame using quantisation matrices (using_qmatrix=1): dequantisation here is base_q_idx plus the plane DC/AC deltas only, so qm_y/qm_u/qm_v would be ignored and the frame would decode silently wrong pixels", | |
| 1672 | + )); | |
| 1673 | + } | |
| 1626 | 1674 | // lane-dpm1: a LOSSLESS frame (`qindex == 0` with zero deltas, spec 5.9.12) |
| 1627 | 1675 | // is a different tile syntax, and this decoder has none of it: libaom |
| 1628 | 1676 | // forces TX_4X4 with the WALSH-HADAMARD transform over every block (so no |
| @@ -1676,6 +1724,11 @@ fn decode_frame( | ||
| 1676 | 1724 | // the bit depth so a mono frame decoded on a thread that last saw a |
| 1677 | 1725 | // 4:2:0 one never inherits the wrong plane count. |
| 1678 | 1726 | crate::decode::set_mono(seq.mono_chrome, fctx); |
| 1727 | + // lane-av1txr: spec 5.9.2 `disable_cdf_update` -- a frame that sets it | |
| 1728 | + // codes every tile symbol against the CDFs it started with, so the tile | |
| 1729 | + // readers must not adapt (libaom `decodeframe.c:2909`: | |
| 1730 | + // `allow_update_cdf = allow_update_cdf && !cm->features.disable_cdf_update`). | |
| 1731 | + crate::decode::set_disable_cdf_update(header.disable_cdf_update, fctx); | |
| 1679 | 1732 | // spec 7.16: this frame's superres state, for the filter chain -- |
| 1680 | 1733 | // `decode.rs` upscales between CDEF and loop restoration and sizes |
| 1681 | 1734 | // the LR unit grid in upscaled coordinates. Cleared (0, 8) on an |
| @@ -2069,6 +2122,106 @@ pub(crate) mod tests { | ||
| 2069 | 2122 | ); |
| 2070 | 2123 | } |
| 2071 | 2124 | |
| 2125 | + /// lane-av1txr: a sequence header describing any chroma shape but 4:2:0 is | |
| 2126 | + /// refused by name, because the decoder reconstructs every chroma extent | |
| 2127 | + /// at hardcoded 4:2:0 (`bw / 2, bh / 2` at every rect site) and the probe | |
| 2128 | + /// emits 4:2:0 planes only -- a 4:4:4 stream "decodes" into silently wrong | |
| 2129 | + /// pixels (measured: a444-cu6's first chroma transform reads a 4x2-wide/ | |
| 2130 | + /// 8-high 4:2:0 chroma at aomdec's `TX_8X16` entry rng 39857, then | |
| 2131 | + /// desyncs; every 4:4:4 fixture measured byte-differs from ffmpeg). | |
| 2132 | + /// | |
| 2133 | + /// Reachability, not a pixel claim: the header is written at the two | |
| 2134 | + /// profiles that force a non-4:2:0 shape (spec 5.5.2 -- profile 1 forces | |
| 2135 | + /// 4:4:4 with no coded bit; profile 2 below 12-bit forces 4:2:2) and the | |
| 2136 | + /// tile is never reached. The 4:2:0 CONTROL below proves the refusal is | |
| 2137 | + /// about the shape, not about this construction. | |
| 2138 | + #[test] | |
| 2139 | + fn a_non_420_subsampled_sequence_header_is_refused_by_name() { | |
| 2140 | + const NAME: &str = "a_non_420_subsampled_sequence_header_is_refused_by_name"; | |
| 2141 | + const REFUSAL: &str = "a chroma format other than 4:2:0"; | |
| 2142 | + let fctx = &crate::decode::FrameCtx::new(); | |
| 2143 | + let picture = test_card(64, 64); | |
| 2144 | + let encoded = encode_key_frame_with_ctx(&picture, 100, 0.5, fctx).unwrap(); | |
| 2145 | + for (profile, label, sx, sy) in [(1u8, "4:4:4", 0u8, 0u8), (2, "4:2:2", 1, 0)] { | |
| 2146 | + let color = ec_av1_syntax::ColorConfig { | |
| 2147 | + num_planes: 3, | |
| 2148 | + subsampling_x: sx, | |
| 2149 | + subsampling_y: sy, | |
| 2150 | + ..Default::default() | |
| 2151 | + }; | |
| 2152 | + let (mut seq, header) = | |
| 2153 | + crate::encode::key_frame_headers_colour(64, 64, 100, color).unwrap(); | |
| 2154 | + seq.seq_profile = profile; | |
| 2155 | + let mut stream = crate::sequence::sequence_header_obu(&seq).unwrap(); | |
| 2156 | + stream.extend_from_slice( | |
| 2157 | + &crate::frame::frame_obu(&seq, &header, &encoded.tile).unwrap(), | |
| 2158 | + ); | |
| 2159 | + let err = decode_stream(&stream).unwrap_err().to_string(); | |
| 2160 | + assert!( | |
| 2161 | + err.contains(REFUSAL), | |
| 2162 | + "{NAME}: expected the non-4:2:0 refusal for the {label} header, got: {err}" | |
| 2163 | + ); | |
| 2164 | + } | |
| 2165 | + // CONTROL: the same construction at profile 0 (4:2:0) still decodes. | |
| 2166 | + let (seq, header) = crate::encode::key_frame_headers(64, 64, 100).unwrap(); | |
| 2167 | + let mut stream = crate::sequence::sequence_header_obu(&seq).unwrap(); | |
| 2168 | + stream.extend_from_slice(&crate::frame::frame_obu(&seq, &header, &encoded.tile).unwrap()); | |
| 2169 | + let frames = decode_stream(&stream).expect("the 4:2:0 control must decode"); | |
| 2170 | + assert_eq!(frames.len(), 1, "{NAME}: the 4:2:0 control decoded no frame"); | |
| 2171 | + } | |
| 2172 | + | |
| 2173 | + /// lane-av1txr-r2: a frame using quantisation matrices is refused by name | |
| 2174 | + /// -- the THIRD member of the silent-garbage family the non-4:2:0 gate | |
| 2175 | + /// above opened (the verifier's census miss). | |
| 2176 | + /// | |
| 2177 | + /// `using_qmatrix`/`qm_y`/`qm_u`/`qm_v` are parsed by `ec-av1-syntax` | |
| 2178 | + /// (frame.rs:190-196, :1418-1426) but have NO consumer anywhere on the | |
| 2179 | + /// decode path -- every dequantisation is `base_q_idx` plus the plane | |
| 2180 | + /// DC/AC deltas only. Measured on a real aomenc pair (same source and | |
| 2181 | + /// recipe, only `--enable-qm` flipped): the qm-OFF control decodes | |
| 2182 | + /// byte-exact vs ffmpeg, the qm-ON stream used to decode with NO refusal | |
| 2183 | + /// and byte-differ from ffmpeg (silent garbage; class | |
| 2184 | + /// `refusal-hides-a-defect` read the other way -- a silent wrong decode | |
| 2185 | + /// is worse than a named gap). | |
| 2186 | + /// | |
| 2187 | + /// Both arms are real encoder output, so this is a reachability gate, not | |
| 2188 | + /// a hand-built construction: the qm-on arm carries `using_qmatrix = 1` | |
| 2189 | + /// (`qm_y/u/v = 5` on the measured fixture) and the refusal names the | |
| 2190 | + /// field rather than desyncing. | |
| 2191 | + #[test] | |
| 2192 | + fn a_frame_using_quantisation_matrices_is_refused_by_name() { | |
| 2193 | + const NAME: &str = "a_frame_using_quantisation_matrices_is_refused_by_name"; | |
| 2194 | + const REFUSAL: &str = "a frame using quantisation matrices"; | |
| 2195 | + if !have_ffmpeg() || !have_aomenc() { | |
| 2196 | + eprintln!( | |
| 2197 | + "SKIP {NAME}: needs ffmpeg + an aomenc oracle at {}", | |
| 2198 | + aomenc_path().display() | |
| 2199 | + ); | |
| 2200 | + return; | |
| 2201 | + } | |
| 2202 | + // CONTROL: the same source and recipe with quantisation matrices OFF | |
| 2203 | + // still decodes -- so the refusal below is about the qm bit, not about | |
| 2204 | + // the source or the encoder settings. | |
| 2205 | + let (_, control) = census_attempt("testsrc2", 128, 96, 3, &["--enable-qm=0"]); | |
| 2206 | + let frames = control.unwrap_or_else(|e| { | |
| 2207 | + panic!("{NAME}: the --enable-qm=0 control must decode, got: {e}") | |
| 2208 | + }); | |
| 2209 | + assert!(frames >= 1, "{NAME}: the qm-off control decoded no frame"); | |
| 2210 | + // The qm-on stream is the new refusal. | |
| 2211 | + let (_, qm) = census_attempt("testsrc2", 128, 96, 3, &["--enable-qm=1"]); | |
| 2212 | + let err = qm.err().unwrap_or_else(|| { | |
| 2213 | + panic!("{NAME}: the --enable-qm=1 stream now decodes -- flip this gate to a witness") | |
| 2214 | + }); | |
| 2215 | + assert!( | |
| 2216 | + err.contains(REFUSAL), | |
| 2217 | + "{NAME}: the qm-on stream stopped without the named refusal {REFUSAL:?} \ | |
| 2218 | + -- re-measure before trusting this gate. got: {err}" | |
| 2219 | + ); | |
| 2220 | + eprintln!( | |
| 2221 | + "{NAME}: qm-off control {frames} frames, qm-on refused by name ({REFUSAL})" | |
| 2222 | + ); | |
| 2223 | + } | |
| 2224 | + | |
| 2072 | 2225 | /// lane-av1mono: the INVERSE of the pilot's |
| 2073 | 2226 | /// `a_real_libaom_monochrome_key_frame_is_refused_by_name`, which the |
| 2074 | 2227 | /// pilot's merge `d71084ae` landed on `main` (after this lane's base |
| @@ -6930,6 +7083,64 @@ pub(crate) mod tests { | ||
| 6930 | 7083 | } |
| 6931 | 7084 | } |
| 6932 | 7085 | |
| 7086 | + /// lane-av1txr: a real `aomenc --cdf-update-mode=0` stream (spec 5.9.2 | |
| 7087 | + /// `disable_cdf_update`) decodes SAMPLE-EXACT. The read that was missing: | |
| 7088 | + /// `stream.rs` never threaded the header bit, so the tile readers adapted | |
| 7089 | + /// every symbol of a frame the encoder coded against fixed tables -- the | |
| 7090 | + /// stream desynced at its first multi-symbol block and the pixels differed | |
| 7091 | + /// from byte 6 (`EC_PROBE_OUT` vs `ffmpeg -pix_fmt yuv420p`, measured | |
| 7092 | + /// 2026-09-20). The msac unit gate | |
| 7093 | + /// (`a_reader_told_not_to_adapt_matches_a_non_adapting_writer`) pins the | |
| 7094 | + /// mechanism; this one pins the wiring end to end. | |
| 7095 | + #[test] | |
| 7096 | + fn a_real_aomenc_stream_with_cdf_update_disabled_decodes_pixel_exact() { | |
| 7097 | + const NAME: &str = "a_real_aomenc_stream_with_cdf_update_disabled_decodes_pixel_exact"; | |
| 7098 | + if !have_ffmpeg() || !have_aomenc() { | |
| 7099 | + eprintln!("SKIP {NAME}: no ffmpeg/aomenc"); | |
| 7100 | + return; | |
| 7101 | + } | |
| 7102 | + let (width, height) = (256usize, 192usize); | |
| 7103 | + let stream = screen_intrabc_stream_with( | |
| 7104 | + "testsrc2=size=256x192:rate=25", | |
| 7105 | + "45", | |
| 7106 | + "1", | |
| 7107 | + false, | |
| 7108 | + true, | |
| 7109 | + &["--cdf-update-mode=0", "--limit=3"], | |
| 7110 | + ); | |
| 7111 | + // Non-vacuity: the fixture must really code the bit on every frame. | |
| 7112 | + let mut parser = Av1Parser::new(); | |
| 7113 | + let mut pos = 0usize; | |
| 7114 | + let mut headers = 0usize; | |
| 7115 | + while pos < stream.len() { | |
| 7116 | + let Ok(obu) = parser.parse_obu(&stream[pos..]) else { | |
| 7117 | + break; | |
| 7118 | + }; | |
| 7119 | + pos += obu.total_size.max(1); | |
| 7120 | + let header = match &obu.kind { | |
| 7121 | + ObuKind::Frame(h, _) | ObuKind::FrameHeader(h) => h, | |
| 7122 | + _ => continue, | |
| 7123 | + }; | |
| 7124 | + assert!( | |
| 7125 | + header.disable_cdf_update, | |
| 7126 | + "{NAME}: frame {headers} does not carry disable_cdf_update -- aomenc ignored \ | |
| 7127 | + --cdf-update-mode=0" | |
| 7128 | + ); | |
| 7129 | + headers += 1; | |
| 7130 | + } | |
| 7131 | + assert!(headers >= 3, "{NAME}: only {headers} frame headers in the fixture"); | |
| 7132 | + let frames = decode_stream(&stream).unwrap_or_else(|e| panic!("{NAME}: {e}")); | |
| 7133 | + let theirs = ffmpeg_decode_sequence(&stream, width, height, frames.len()); | |
| 7134 | + assert_eq!(frames.len(), theirs.len(), "{NAME}: frame count"); | |
| 7135 | + for (i, (ours, ref_frame)) in frames.iter().zip(theirs.iter()).enumerate() { | |
| 7136 | + assert!( | |
| 7137 | + ours.y == ref_frame.y && ours.u == ref_frame.u && ours.v == ref_frame.v, | |
| 7138 | + "{NAME}: frame {i} does not match ffmpeg" | |
| 7139 | + ); | |
| 7140 | + } | |
| 7141 | + eprintln!("{NAME}: {headers} disable_cdf_update frame headers, all frames sample-exact"); | |
| 7142 | + } | |
| 7143 | + | |
| 6933 | 7144 | /// lane-kf900 r4, the gate for the two lifted palette refusals ("a 1:4 |
| 6934 | 7145 | /// rect strip that actually uses a palette (reconstruction is not ported |
| 6935 | 7146 | /// at this shape)" and "a palette block on a HORZ/VERT intra strip below |
lanes/av1txrouting.report.mdadded+543 -0
| @@ -0,0 +1,543 @@ | ||
| 1 | +# lane-av1-txrouting — the one-routing-predicate hypothesis is REFUTED; work-in-progress | |
| 2 | + | |
| 3 | +Base: `main` **0cfb9af5** (2026-09-19). Worktree `../edith_codecs-av1txr`, branch | |
| 4 | +`lane-av1-txrouting`, `CARGO_TARGET_DIR=$HOME/.cache/cargo-target-av1txr`. | |
| 5 | + | |
| 6 | +**STATUS: WIP, NOT READY TO MERGE.** The 4x4 sub-8x8 intrabc path is proven | |
| 7 | +symbol-for-symbol correct on a real stream; the 4x8/8x4 rect leaf path is | |
| 8 | +**not yet byte-exact** (see §5). No gate has been run to completion. | |
| 9 | + | |
| 10 | +--- | |
| 11 | + | |
| 12 | +## 1. Headline: the scout's "ONE routing predicate" is refuted | |
| 13 | + | |
| 14 | +The charter's three stops do **not** share a routing predicate. First-divergence | |
| 15 | +traces (instrumented `aomdec` oracle at `~/.cache/aom-oracle/build/aomdec` + | |
| 16 | +`decode_probe`, `EC_TRACE_MODE_STEP`) give each stop a distinct cause: | |
| 17 | + | |
| 18 | +| stop | stream (reproduced) | first divergence | real cause | | |
| 19 | +|---|---|---|---| | |
| 20 | +| 3.2 / "Golomb tail" | `aomenc 4:4:4 --cpu-used=6/7` | block `(0,0)`, chroma transform entry rng **39857** | **4:4:4 chroma-subsampling is not implemented** (see §3) | | |
| 21 | +| 3.3 / "sub-8x8 intrabc" | `aomenc --allintra` | block `(45,52)` rng 37280 | a **genuine** 4x4 intrabc block (see §4) | | |
| 22 | +| 3.4 / "sub-8x8 intrabc" | `aomenc --enable-warped-motion=1 --cpu-used=0` | block `(37,62)` | the same, at a 4x8/8x4 rect leaf | | |
| 23 | + | |
| 24 | +The report's §3.2/§3.3 claim that "`aomdec` reads `tx_depth` where ours reads | |
| 25 | +`txfm_split`/`intrabc`/`uv_mode`" is an **instrumentation artifact**: aomdec's | |
| 26 | +`read_intrabc_info` had no print, and `read_tx_size_vartx`'s print is gated on | |
| 27 | +`EC_VARTX`, not `EC_ISTEP`. With the oracle instrumented for both | |
| 28 | +(`EC_ISTEP name=intrabc`, `EC_DV`, `EC_COEFF`), ours and aomdec read | |
| 29 | +**identical `intrabc` flags and identical DVs** at these blocks — no desync. | |
| 30 | + | |
| 31 | +Similarly the §3.2 "aomdec reads `tx_depth`, ours reads `txfm_split`" claim: | |
| 32 | +the 4:4:4 divergence is **after** the tx-depth read (both read | |
| 33 | +`tx_depth val=1 ctx=0 cat=1`) and is a chroma-transform size mismatch, not a | |
| 34 | +tx-size routing mismatch. | |
| 35 | + | |
| 36 | +## 2. Reproduced streams (all re-derivable) | |
| 37 | + | |
| 38 | +``` | |
| 39 | +cd ~/.cache/av1txr | |
| 40 | +# 4:4:4 (aomenc) -- cu6/cu7 REFUSE, cu4/cu5/cu8 decode-but-wrong | |
| 41 | +aomenc --codec=av1 --passes=1 --threads=1 --cpu-used=6 --obu -o s/a444-cu6.obu s/s444.y4m | |
| 42 | +# sub8 intrabc | |
| 43 | +aomenc --codec=av1 --passes=1 --threads=1 --obu --allintra --cpu-used=6 -o s/allintra.obu s/s420.y4m | |
| 44 | +aomenc --codec=av1 --passes=1 --threads=1 --obu --enable-warped-motion=1 --cpu-used=0 -o s/warped.obu s/s420.y4m | |
| 45 | +# (s420.y4m / s444.y4m = ffmpeg testsrc2 320x240 rate 8 dur 3) | |
| 46 | +``` | |
| 47 | + | |
| 48 | +Pre-fix: `allintra`/`allintra0`/`warped` → `REFUSED: a sub-8x8 leaf that uses | |
| 49 | +intrabc …`; `a444-cu6/7` → `REFUSED: a Golomb tail longer than this decoder | |
| 50 | +reads`; `a444-cu4/5/8` → `OK` **but garbage**. | |
| 51 | + | |
| 52 | +## 3. Stop 3.2 — 4:4:4 is entirely unsupported (root-caused) | |
| 53 | + | |
| 54 | +`probe EC_PROBE_OUT8` vs `ffmpeg -pix_fmt yuv420p` for **every** 4:4:4 stream | |
| 55 | +(`a444-cu4/5/8`, `ff444-cu5..8`) **differs** — the "decoding" 4:4:4 streams are | |
| 56 | +silently desynced garbage. The fixture story ("`av1-profile1-444` decodes | |
| 57 | +fine") was never byte-exactness-checked. | |
| 58 | + | |
| 59 | +**First divergence (a444-cu6, block `(0,0)`, an 8x16 rect leaf, depth 1):** | |
| 60 | + | |
| 61 | +``` | |
| 62 | +aom: EC_ISTEP tx_depth val=1 ctx=0 cat=1 rng=44248 | |
| 63 | + EC_COEFF mi_row=0 mi_col=0 plane=0 tx=1 rng=44248 # TX_8X8 | |
| 64 | + EC_COEFF mi_row=0 mi_col=0 plane=0 tx=1 rng=41886 # TX_8X8 | |
| 65 | + EC_COEFF mi_row=0 mi_col=0 plane=1 tx=7 rng=39857 # TX_8X16 <-- chroma | |
| 66 | + EC_COEFF mi_row=0 mi_col=0 plane=2 tx=7 rng=64008 # TX_8X16 | |
| 67 | +ours: … luma units rng 44248, 41886 (MATCH) … | |
| 68 | + read_coeffs_rect chroma entry rng=39857, w=4 h=8 # 4:2:0 half <-- DIVERGE | |
| 69 | +``` | |
| 70 | + | |
| 71 | +The decoder hardcodes 4:2:0 chroma extents at every rect site | |
| 72 | +(`let (chroma_w, chroma_h) = (bw / 2, bh / 2);` — `decode.rs:9476,10888,11378, | |
| 73 | +11767,12772,14326,15042,26798`) and the probe only ever emits 4:2:0 planes. | |
| 74 | +`subsampling_x/y` is parsed by `ec-av1-syntax` but **never read by the decoder**. | |
| 75 | + | |
| 76 | +**Disposition: needs a `num_planes`/subsampling threading lane** (like the | |
| 77 | +sibling mono lane). The honest interim fix is a **new named refusal at the | |
| 78 | +sequence-header level** for `subsampling_x != 1 || subsampling_y != 1` | |
| 79 | +(`num_planes > 1`), so a 4:4:4/4:2:2 stream refuses by name instead of | |
| 80 | +producing garbage. **Not yet written** (budget). | |
| 81 | + | |
| 82 | +## 4. Stops 3.3 / 3.4 — genuine sub-8x8 intrabc (implemented, WIP) | |
| 83 | + | |
| 84 | +The trace proves both streams code **real** sub-8x8 intrabc blocks: | |
| 85 | +`aomdec`'s instrumented `read_intrabc_info` reads `intrabc val=1` and an | |
| 86 | +`EC_DV` at `allintra (45,52)/(45,53)` and `warped (37,62)`. libaom's | |
| 87 | +`av1_allow_intrabc` is a frame-level test with no shape term, and the 4x4 block | |
| 88 | +`is_chroma_ref` (last sub-block) makes its chroma an intrabc copy too. | |
| 89 | + | |
| 90 | +Implemented on the lane (see §6 diff): | |
| 91 | +- `read_intra_mode_sub8` reads the DV (`read_intrabc_dv`) and RETURNS | |
| 92 | + (skip, DC_PRED, 0, None, None, Some(dv)) — no mode/uv/filter-intra syntax. | |
| 93 | +- `read_intrabc_dv` generalized from a square `side` to a `(n4_w, n4_h)` | |
| 94 | + footprint (rect leaves scan 1x2/2x1, not 2x2). | |
| 95 | +- `decode_leaf_split4` / `decode_leaf_rect8` reconstruct the intrabc leaf: | |
| 96 | + `flush_recon` + `mc::predict_with_filter(.., Bilinear)` frame copy injected | |
| 97 | + via the `set_palette_pred` override slot, residual read through the **inter** | |
| 98 | + sets (`Luma4Inter`/`Luma4InterSet1`, `LumaRect8x4Inter`/`Set1`), no | |
| 99 | + `tx_depth` symbol (libaom `block_signals_txsize` false below 8x8), | |
| 100 | + `record_intrabc_mi(_rect)` publishing the true footprint. | |
| 101 | +- **Chroma tx-type inheritance** (the subtle one): libaom `av1_get_tx_type` | |
| 102 | + (blockd.h:1278) gives a non-Y plane the LUMA's `tx_type_map` entry when | |
| 103 | + `is_inter_block(mbmi)` — **intrabc counts as inter**. So the group's chroma | |
| 104 | + eob/scan class is the luma's coded type, not `DCT_DCT`. Armed via the | |
| 105 | + existing `fctx.intrabc_chroma_tx` slot (the square path's mechanism). | |
| 106 | + | |
| 107 | +**Evidence the 4x4 path is byte-exact (allintra, block (45,52)):** the luma | |
| 108 | +intrabc residual traces **identically** to aomdec | |
| 109 | +(`tx_type txtype=11`/`HDct`, `eob=14`, every `base`/`br`/`sign`/`post_golomb` | |
| 110 | +rng equal), and ours reaches `(45,53) skip rng=52504` — aomdec's exact value. | |
| 111 | +With the chroma-inheritance fix the following block's `skip` also matched. | |
| 112 | + | |
| 113 | +## 5. What is NOT done (do not merge without it) | |
| 114 | + | |
| 115 | +1. **`warped` is not byte-exact.** With the implementation it decodes 24 | |
| 116 | + frames but `EC_PROBE_OUT8` vs `ffmpeg -pix_fmt yuv420p` differs at byte | |
| 117 | + **41217** (frame 0, luma row 128), and the entropy desyncs at | |
| 118 | + `(38,60) skip`: aom 48630 vs ours 60320. The **rect intrabc leaf** | |
| 119 | + (4x8/8x4) is the suspect: unverified `predict_with_filter` buffer shape, | |
| 120 | + residual set, or the rect DV scan. | |
| 121 | +2. **`allintra` now stops one shape later**: `REFUSED: intra block copy on a | |
| 122 | + HORZ/VERT/1:4 rect intra strip (reconstruction is not ported at this | |
| 123 | + shape)` (the `decode.rs:9122` rect reader). `allintra0` (cpu-used 0) | |
| 124 | + **panics** at `transform.rs:1134` (a 4x4 dequant given a 1024-entry grid) | |
| 125 | + via `decode_leaf8` — a further reachable path after the sub8 blocks pass. | |
| 126 | +3. **4:4:4/4:2:2 named refusal** (§3) not written. | |
| 127 | +4. **No gates run.** Only `cargo build --release -p ec-av1 --example | |
| 128 | + decode_probe` (0 errors/warnings) and `cargo check`-equivalent builds. | |
| 129 | + `cargo test -p ec-av1 --lib` (592/0/60 baseline) NOT run. | |
| 130 | +5. **Inventory re-pin not done.** §3.3's two refuted PROVEN entries | |
| 131 | + (`read_golomb_reads_every_value…`, `a_sub8_leaf_census…`) still claim | |
| 132 | + "unreachable"; they must be re-pinned to reachable-with-witness. The report | |
| 133 | + §5 tripwire `a_real_libaom_monochrome_key_frame_is_refused_by_name` is | |
| 134 | + untouched (mono stream unaffected — its `num_planes == 1`). | |
| 135 | + | |
| 136 | +## 6. Diff summary (lane, uncommitted-at-first-write) | |
| 137 | + | |
| 138 | +`crates/ec-av1/src/decode.rs`: | |
| 139 | +- `read_intra_mode_sub8`: +`Option<(i32,i32)>` return, intrabc branch (DV read, | |
| 140 | + early return), `istep!("intrabc")`. | |
| 141 | +- `read_intrabc_dv`: `side` → `(n4_w, n4_h)`; `EC_DV` trace print; call sites | |
| 142 | + updated (square path passes `(side/MI, side/MI)`). | |
| 143 | +- `record_intrabc_mi` split into `record_intrabc_mi_rect` (rect footprint). | |
| 144 | +- `decode_leaf_split4` + `decode_leaf_rect8`: intrabc leaf arm (frame copy + | |
| 145 | + inter residual) and intrabc chroma arm (frame copy + `Chroma4`, luma tx-type | |
| 146 | + inheritance, cleared after). | |
| 147 | +- Trace prints added at previously-silent `tx_depth`/`intrabc` sites so a | |
| 148 | + cross-decoder first-divergence diff aligns. | |
| 149 | + | |
| 150 | +## 7. Repro / oracle recipes | |
| 151 | + | |
| 152 | +``` | |
| 153 | +# build | |
| 154 | +CARGO_TARGET_DIR=$HOME/.cache/cargo-target-av1txr cargo build --release -p ec-av1 --example decode_probe | |
| 155 | + | |
| 156 | +# byte-exactness, 8-bit | |
| 157 | +decode_probe x.obu out8.raw # argv[2] = 8-bit planes | |
| 158 | +ffmpeg -i x.obu -pix_fmt yuv420p -f rawvideo ref8.raw -y | |
| 159 | +cmp out8.raw ref8.raw | |
| 160 | +# (EC_PROBE_OUT16 is yuv420p10le and is NOT comparable to ffmpeg's | |
| 161 | +# yuv420p10le for an 8-bit source — ffmpeg left-shifts, the probe does not. | |
| 162 | +# Use the 8-bit form for 8-bit streams. This bit me once.) | |
| 163 | + | |
| 164 | +# first divergence vs the instrumented oracle | |
| 165 | +EC_TRACE_MODE_STEP=1 ~/.cache/aom-oracle/build/aomdec --rawvideo -o /dev/null x.obu 2>a.step | |
| 166 | +EC_TRACE_MODE_STEP=1 decode_probe x.obu 2>o.step | |
| 167 | +# per-(mi_row,mi_col,name) index compare in python (see §1 method) | |
| 168 | +``` | |
| 169 | + | |
| 170 | +Oracle build: `~/.cache/aom-oracle` (cmake+ninja) instrumented with | |
| 171 | +`EC_ISTEP name=intrabc` (decodemv.c `read_intrabc_info`), `EC_DV` | |
| 172 | +(post-`assign_dv`), `EC_COEFF` (decodeframe.c `read_coeffs_tx_intra_block`). | |
| 173 | + | |
| 174 | +## 8. Recommended next steps (ordered) | |
| 175 | + | |
| 176 | +1. Fix the rect intrabc leaf (warped) — trace the rect leaf's DV/residual vs | |
| 177 | + aomdec; then verify `EC_PROBE_OUT8` byte-exact. | |
| 178 | +2. Unblock `allintra`'s 1:4 rect strip intrabc (`decode.rs:9122`) and the | |
| 179 | + `decode_leaf8` dequant panic. | |
| 180 | +3. Add the sequence-header subsampling refusal (§3) and re-pin the inventory. | |
| 181 | +4. Run `cargo test -p ec-av1 --lib` + `cargo check -p ec-av1 --all-targets`. | |
| 182 | + | |
| 183 | +--- | |
| 184 | + | |
| 185 | +## 9. Continuation (2026-09-20, second lane pass) | |
| 186 | + | |
| 187 | +Five defects fixed, each proven by a first-divergence move and/or a gate. **Warped | |
| 188 | +is still NOT byte-exact** (§9.4) and `allintra`/`allintra0` still stop at NAMED | |
| 189 | +refusals that belong to the 1:4-rect-strip lane (§9.3). Honest status first. | |
| 190 | + | |
| 191 | +### 9.1 Silent-garbage guard: non-4:2:0 chroma is refused by name | |
| 192 | + | |
| 193 | +`stream.rs`'s `decode_stream` now refuses `seq.subsampling_x != 1 || | |
| 194 | +seq.subsampling_y != 1` (threaded through `SeqFlags::subsampling_x/y`). A | |
| 195 | +monochrome header parses as 1,1, so it is untouched (the mono lane's stream and | |
| 196 | +its tripwire keep their meaning). | |
| 197 | + | |
| 198 | +Evidence: | |
| 199 | +- `a_non_420_subsampled_sequence_header_is_refused_by_name` (stream.rs tests): | |
| 200 | + a hand-built profile-1 (4:4:4) and profile-2 (4:2:2) header each refuse with | |
| 201 | + the named string, and the profile-0 CONTROL still decodes — so the gate is | |
| 202 | + about the shape, not the construction. | |
| 203 | +- Real encoder stream: `aomenc` auto-promotes to profile 1 for `yuv444p` input; | |
| 204 | + `EC_PROBE_OUT` vs `ffmpeg -pix_fmt yuv444p` on that stream **refuses by name** | |
| 205 | + where the same code path used to decode silently wrong pixels. | |
| 206 | + | |
| 207 | +### 9.2 Parsed-but-unread pixel-affecting header field sweep | |
| 208 | + | |
| 209 | +A per-field census of every `SequenceHeader` / `ColorConfig` / | |
| 210 | +`QuantizationParams` / `FrameHeader` field against the decoder's PRODUCTION | |
| 211 | +reads (`crates/ec-av1/src/{stream,decode}.rs`, test modules excluded; each row | |
| 212 | +re-derivable by `grep -n "\.<field>\b"`) found **three** pixel-affecting fields | |
| 213 | +the decoder never consumed. All three are now closed: | |
| 214 | + | |
| 215 | +1. `subsampling_x/y` — §9.1 (refusal). | |
| 216 | +2. **`disable_cdf_update`** (the second find): spec 8.3.2 skips ALL per-symbol | |
| 217 | + CDF adaptation when set, and libaom's tile entry does exactly that | |
| 218 | + (`decodeframe.c:2909`, `allow_update_cdf && !disable_cdf_update`). The | |
| 219 | + decoder adapted unconditionally. Fixed at the one authoring point: | |
| 220 | + `msac::SymbolDecoder::adapt` (per READER, not global — frames decode on | |
| 221 | + different workers) + `FrameCtx::disable_cdf_update` + one line in | |
| 222 | + `decode_frame`. | |
| 223 | + | |
| 224 | + Evidence, both directions: | |
| 225 | + - `a_real_aomenc_stream_with_cdf_update_disabled_decodes_pixel_exact` | |
| 226 | + (real `aomenc --cdf-update-mode=0`, 3 frames): asserts every frame header | |
| 227 | + carries the bit, then compares all planes against ffmpeg. Green. | |
| 228 | + - fail-pre-fix, measured: with `set_cdf_update` forced ON the SAME stream | |
| 229 | + differs from ffmpeg at **byte 6** (`OK: 3 frames` but wrong pixels). | |
| 230 | + - `a_reader_told_not_to_adapt_matches_a_non_adapting_writer` (msac unit): | |
| 231 | + a non-adapting reader reproduces a non-adapting writer symbol-for-symbol | |
| 232 | + and its tables stay untouched; the default reader does not (flag | |
| 233 | + load-bearing). | |
| 234 | + | |
| 235 | +3. **`using_qmatrix` + `qm_y`/`qm_u`/`qm_v`** — the census MISS this section | |
| 236 | + previously claimed did not exist (found by the re-verifier; lane-av1txr-r2). | |
| 237 | + Parsed by `ec-av1-syntax` (`frame.rs:190-196`, `:1418-1426`), read by | |
| 238 | + NOTHING on the decode path: every dequantisation is `base_q_idx` plus the | |
| 239 | + plane DC/AC deltas. A real `aomenc --enable-qm=1` stream | |
| 240 | + (`using_qmatrix = 1`, `qm_y/u/v = 5` on the measured fixture) decoded with NO | |
| 241 | + refusal and byte-differed from ffmpeg, while the `--enable-qm=0` control of | |
| 242 | + the same source and recipe was byte-exact — the same silent-garbage class as | |
| 243 | + §9.1. Refused by name at the frame header (`stream.rs`, beside the non-4:2:0 | |
| 244 | + guard); gate `a_frame_using_quantisation_matrices_is_refused_by_name`, which | |
| 245 | + fails pre-fix (with the guard removed it panics "the --enable-qm=1 stream now | |
| 246 | + decodes"). | |
| 247 | + | |
| 248 | +The table below is the audit artifact the re-verifier asked for: every field of | |
| 249 | +those four structs, its first production read, or its disposition when unread. | |
| 250 | +It is the source of the "three" above, so the census is checkable rather than a | |
| 251 | +grep claim. Dispositions: `consumed` (a decoder read exists), | |
| 252 | +`refused` (a named guard refuses the case), `parser-forced` (a seq flag | |
| 253 | +`ec-av1-syntax` folds into a frame-header field the decoder DOES read), | |
| 254 | +`parser-internal` (used only while reading the header), `metadata` (no pixel | |
| 255 | +effect), `sibling-lane` (`mono_chrome`/`num_planes`, lane-av1-mono), and | |
| 256 | +`internal-equivalent` (`ref_order_hint`/`order_hints`, which the decoder | |
| 257 | +rebuilds from its own saved reference state — `stream.rs:1344`). | |
| 258 | + | |
| 259 | + | |
| 260 | +**SequenceHeader** | |
| 261 | + | |
| 262 | +| field | disposition | first prod read | | |
| 263 | +|---|---|---| | |
| 264 | +| `seq_profile` | parser-internal | sequence.rs parse; effect surfaced via subsampling_x/y + bit_depth guards | | |
| 265 | +| `still_picture` | parser-internal | parse branch | | |
| 266 | +| `reduced_still_picture_header` | parser-internal | parse branch | | |
| 267 | +| `timing_info` | metadata | display timing | | |
| 268 | +| `decoder_model_info` | metadata | display timing | | |
| 269 | +| `initial_display_delay_present_flag` | metadata | display timing | | |
| 270 | +| `operating_points` | metadata | op selection; decoder decodes all | | |
| 271 | +| `operating_point` | metadata | op selection | | |
| 272 | +| `operating_point_idc` | metadata | op selection | | |
| 273 | +| `frame_width_bits` | parser-internal | frame-size read width | | |
| 274 | +| `frame_height_bits` | parser-internal | frame-size read width | | |
| 275 | +| `max_frame_width` | parser-internal | frame-size validation | | |
| 276 | +| `max_frame_height` | parser-internal | frame-size validation | | |
| 277 | +| `frame_id_numbers_present_flag` | parser-internal | display_frame_id read | | |
| 278 | +| `delta_frame_id_length` | parser-internal | display_frame_id read | | |
| 279 | +| `additional_frame_id_length` | parser-internal | display_frame_id read | | |
| 280 | +| `use_128x128_superblock` | consumed | `stream.rs:1267` | | |
| 281 | +| `enable_filter_intra` | consumed | `stream.rs:1261` | | |
| 282 | +| `enable_intra_edge_filter` | consumed | `stream.rs:1263` | | |
| 283 | +| `enable_interintra_compound` | consumed | `stream.rs:1266` | | |
| 284 | +| `enable_masked_compound` | consumed | `stream.rs:1264` | | |
| 285 | +| `enable_warped_motion` | parser-forced | syntax/frame.rs:1053 -> h.allow_warped_motion | | |
| 286 | +| `enable_dual_filter` | consumed | `stream.rs:1262` | | |
| 287 | +| `enable_order_hint` | parser-forced | syntax/frame.rs:919,1068 -> order_hint_bits / ref_frame_sign_bias | | |
| 288 | +| `enable_jnt_comp` | consumed | `stream.rs:1265` | | |
| 289 | +| `enable_ref_frame_mvs` | parser-forced | syntax/frame.rs:970 -> h.use_ref_frame_mvs | | |
| 290 | +| `seq_force_screen_content_tools` | parser-forced | syntax/frame.rs:853 -> h.allow_screen_content_tools | | |
| 291 | +| `seq_force_integer_mv` | parser-forced | syntax/frame.rs:859 -> h.force_integer_mv | | |
| 292 | +| `order_hint_bits` | consumed | `stream.rs:1269` | | |
| 293 | +| `enable_superres` | parser-forced | syntax/frame.rs:1100 -> h.use_superres | | |
| 294 | +| `enable_cdef` | parser-forced | syntax/frame.rs:1576 -> h.cdef | | |
| 295 | +| `enable_restoration` | parser-forced | syntax/frame.rs:1605 -> h.loop_restoration | | |
| 296 | +| `color_config` | consumed | `stream.rs:724` | | |
| 297 | +| `film_grain_params_present` | parser-forced | syntax/frame.rs:809,1866 -> h.film_grain | | |
| 298 | + | |
| 299 | +**ColorConfig** | |
| 300 | + | |
| 301 | +| field | disposition | first prod read | | |
| 302 | +|---|---|---| | |
| 303 | +| `bit_depth` | consumed | `stream.rs:678` | | |
| 304 | +| `mono_chrome` | sibling-lane | lane-av1-mono; a mono stream is currently refused by the Golomb tripwire | | |
| 305 | +| `num_planes` | sibling-lane | lane-av1-mono | | |
| 306 | +| `color_primaries` | metadata | H.273 display | | |
| 307 | +| `transfer_characteristics` | metadata | H.273 display | | |
| 308 | +| `matrix_coefficients` | consumed | `stream.rs:727` | | |
| 309 | +| `color_range` | metadata | output range; probe emits limited-range 4:2:0 | | |
| 310 | +| `subsampling_x` | consumed | `stream.rs:1248` | | |
| 311 | +| `subsampling_y` | consumed | `stream.rs:1272` | | |
| 312 | +| `chroma_sample_position` | metadata | display | | |
| 313 | +| `separate_uv_delta_q` | parser-internal | decides qm_v coding, syntax/frame.rs:1422 | | |
| 314 | + | |
| 315 | +**FrameHeader** | |
| 316 | + | |
| 317 | +| field | disposition | first prod read | | |
| 318 | +|---|---|---| | |
| 319 | +| `show_existing_frame` | consumed | `stream.rs:603` | | |
| 320 | +| `frame_to_show_map_idx` | consumed | `stream.rs:624` | | |
| 321 | +| `frame_presentation_time` | metadata | decoder-model bookkeeping | | |
| 322 | +| `display_frame_id` | metadata | frame-id bookkeeping | | |
| 323 | +| `frame_type` | consumed | `stream.rs:853` | | |
| 324 | +| `frame_is_intra` | parser-internal | derived from frame_type; decoder reads frame_type/show_frame | | |
| 325 | +| `show_frame` | consumed | `stream.rs:892` | | |
| 326 | +| `showable_frame` | metadata | output eligibility; film grain parse uses it | | |
| 327 | +| `error_resilient_mode` | parser-internal | controls header reads (refresh flags / primary_ref) | | |
| 328 | +| `disable_cdf_update` | consumed | `stream.rs:1687` | | |
| 329 | +| `allow_screen_content_tools` | consumed | `stream.rs:1796` | | |
| 330 | +| `force_integer_mv` | consumed | `stream.rs:1833` | | |
| 331 | +| `current_frame_id` | metadata | frame-id bookkeeping | | |
| 332 | +| `frame_size_override_flag` | parser-internal | frame-size read | | |
| 333 | +| `order_hint` | consumed | `stream.rs:989` | | |
| 334 | +| `primary_ref_frame` | consumed | `stream.rs:1312` | | |
| 335 | +| `buffer_removal_time` | metadata | decoder-model bookkeeping | | |
| 336 | +| `refresh_frame_flags` | consumed | `stream.rs:644` | | |
| 337 | +| `ref_order_hint` | internal-equivalent | decoder keeps its own ref_order_hints from saved ref state (stream.rs:1344) | | |
| 338 | +| `frame_width` | consumed | `stream.rs:1786` | | |
| 339 | +| `frame_height` | consumed | `stream.rs:1787` | | |
| 340 | +| `upscaled_width` | consumed | `stream.rs:1694` | | |
| 341 | +| `render_width` | metadata | deliberate (encode.rs:15917-15921); display crop only | | |
| 342 | +| `render_height` | metadata | deliberate (encode.rs:15917-15921); display crop only | | |
| 343 | +| `use_superres` | consumed | `stream.rs:1694` | | |
| 344 | +| `superres_denom` | consumed | `stream.rs:1695` | | |
| 345 | +| `mi_cols` | consumed | `stream.rs:1325` | | |
| 346 | +| `mi_rows` | consumed | `stream.rs:1324` | | |
| 347 | +| `allow_intrabc` | consumed | `stream.rs:1797` | | |
| 348 | +| `frame_refs_short_signaling` | parser-internal | parser derives ref_frame_idx (consumed) | | |
| 349 | +| `ref_frame_idx` | consumed | `stream.rs:876` | | |
| 350 | +| `delta_frame_id` | metadata | frame-id bookkeeping | | |
| 351 | +| `allow_high_precision_mv` | consumed | `stream.rs:1877` | | |
| 352 | +| `interpolation_filter` | consumed | `stream.rs:1703` | | |
| 353 | +| `is_motion_mode_switchable` | consumed | `stream.rs:1744` | | |
| 354 | +| `use_ref_frame_mvs` | consumed | `stream.rs:1317` | | |
| 355 | +| `order_hints` | internal-equivalent | derived by decoder from ref_order_hints | | |
| 356 | +| `ref_frame_sign_bias` | consumed | `stream.rs:1879` | | |
| 357 | +| `disable_frame_end_update_cdf` | consumed | `stream.rs:1369` | | |
| 358 | +| `tile_info` | consumed | `stream.rs:759` | | |
| 359 | +| `quantization` | consumed | `stream.rs:1370` | | |
| 360 | +| `segmentation` | consumed | `stream.rs:1405` | | |
| 361 | +| `delta` | consumed | `stream.rs:1798` | | |
| 362 | +| `coded_lossless` | parser-internal | computed by parser; h.lossless carries it (consumed) | | |
| 363 | +| `all_lossless` | parser-internal | computed by parser | | |
| 364 | +| `lossless` | consumed | `stream.rs:1671` | | |
| 365 | +| `loop_filter` | consumed | `stream.rs:1791` | | |
| 366 | +| `cdef` | consumed | `stream.rs:1747` | | |
| 367 | +| `loop_restoration` | consumed | `stream.rs:1748` | | |
| 368 | +| `tx_mode` | consumed | `stream.rs:1740` | | |
| 369 | +| `reference_select` | consumed | `stream.rs:1887` | | |
| 370 | +| `skip_mode_present` | consumed | `stream.rs:1746` | | |
| 371 | +| `skip_mode_frame` | consumed | `stream.rs:1892` | | |
| 372 | +| `allow_warped_motion` | consumed | `stream.rs:1743` | | |
| 373 | +| `reduced_tx_set` | consumed | `stream.rs:1742` | | |
| 374 | +| `global_motion` | consumed | `stream.rs:1880` | | |
| 375 | +| `film_grain` | consumed | `stream.rs:666` | | |
| 376 | +| `header_bits` | parser-internal | tile-group byte alignment | | |
| 377 | + | |
| 378 | +**QuantizationParams** | |
| 379 | + | |
| 380 | +| field | disposition | first prod read | | |
| 381 | +|---|---|---| | |
| 382 | +| `base_q_idx` | consumed | `stream.rs:1370` | | |
| 383 | +| `delta_q_y_dc` | consumed | `stream.rs:1780` | | |
| 384 | +| `delta_q_u_dc` | consumed | `stream.rs:1781` | | |
| 385 | +| `delta_q_u_ac` | consumed | `stream.rs:1782` | | |
| 386 | +| `delta_q_v_dc` | consumed | `stream.rs:1783` | | |
| 387 | +| `delta_q_v_ac` | consumed | `stream.rs:1784` | | |
| 388 | +| `using_qmatrix` | refused | read at `stream.rs:1634` and refused by name | | |
| 389 | +| `qm_y` | refused | only present under using_qmatrix=1, now refused by name | | |
| 390 | +| `qm_u` | refused | only present under using_qmatrix=1, now refused by name | | |
| 391 | +| `qm_v` | refused | only present under using_qmatrix=1, now refused by name | | |
| 392 | + | |
| 393 | +### 9.3 transform.rs:1134 panic — ROOT-CAUSED AND FIXED (not a refusal) | |
| 394 | + | |
| 395 | +`txbset_for_inter` was a near-duplicate of `inter_txbset_for` whose `4` fell | |
| 396 | +through to `TxbSet::Luma64`: a 4x4 intrabc/inter TU read 32x32-class tables (a | |
| 397 | +1024-entry grid) and panicked in `inverse_transform_2d_typed_wh` the first time | |
| 398 | +such a TU coded a non-zero coefficient (`allintra0`, cpu-used 0). libaom reads a | |
| 399 | +4x4 grid with the 16-symbol INTER ext-tx set there (`EXT_TX_SET_ALL16` / | |
| 400 | +`_DTT4_IDTX` reduced). Fix: delete the duplicate, route all inter-table sites | |
| 401 | +through `inter_txbset_for` (which already had the 4 arms). Result: **no panic**; | |
| 402 | +`allintra0` now stops at the EXISTING named refusal "an intrabc block whose | |
| 403 | +var-tx tree resolved to mixed leaf transform sizes" (`decode.rs:14327`) — a | |
| 404 | +lane-of-its-own gap, not a crash. | |
| 405 | + | |
| 406 | +### 9.4 warped: four more defects out of the way, still not byte-exact | |
| 407 | + | |
| 408 | +Ladder evidence (`EC_TRACE_MODE_STEP=1` on the instrumented aomdec vs ours, | |
| 409 | +rng-ladder subsequence walk, frame 0). First divergence moved | |
| 410 | +**(38,60) → (38,62) → (46,66)**; consuming steps matched 916 → 1119 → 1349 of | |
| 411 | +aomdec's 2204 before the next divergence. | |
| 412 | + | |
| 413 | +1. **Rect intrabc leaves read no transform symbol** (the charter's named stop): | |
| 414 | + `block_signals_txsize` is `bsize > BLOCK_4X4` (`blockd.h:1027`), TRUE at | |
| 415 | + `BLOCK_4X8`/`BLOCK_8X4` — so an UNSKIPPED intrabc rect leaf reads the INTER | |
| 416 | + var-tx tree (`read_tx_size_vartx` over `max_txsize_rect_lookup[BLOCK_4X8] == | |
| 417 | + TX_4X8`), not nothing. Fixed in `decode_leaf_rect8`'s intrabc arm | |
| 418 | + (`read_var_tx_size` with the rect entry + per-4x4-TU residual/reconstruction | |
| 419 | + when the tree splits, `RECT_INTRABC_VARTX_HITS` counter, probe line | |
| 420 | + `rect_intrabc_vartx`). aomdec's `EC_VARTX mi_row=37 mi_col=62 bsize=2 | |
| 421 | + tx_size=6 ctx=19 rng=37745` is now reproduced exactly. | |
| 422 | +2. **Sub-8x8 leaves never published the TXFM context bands**: libaom runs | |
| 423 | + `set_txfm_ctxs` for EVERY block; `decode_leaf_split4`/`decode_leaf_rect8` had | |
| 424 | + no write, so an intrabc block's `txfm_partition_context` read a stale 8 where | |
| 425 | + aomdec read 4 (ctx 18 vs 19). Fixed (+ unit bug caught on the way: the rect | |
| 426 | + helper takes PIXELS for the parent span, not mi). | |
| 427 | +3. **`intrabc_dv` slot leak**: `read_intra_mode_sub8` armed the frame slot and | |
| 428 | + the sub-8x8 callers never took it, so the NEXT 8x8+ block inherited the | |
| 429 | + vector and read an inter var-tx symbol where libaom read an intra | |
| 430 | + `tx_depth`. The DV already travels in the return value; the arm is gone. | |
| 431 | +4. (9.3's table fix also feeds this path: the split rect leaf's 4x4 TUs read | |
| 432 | + `Luma4Inter`/`Set1`.) | |
| 433 | + | |
| 434 | +**Remaining first divergence (frame 0, mi (46,66), 8x8 intra block):** | |
| 435 | +`tx_depth ctx` ours 0 vs aomdec 1. Root cause, localised: the key-frame | |
| 436 | +square/leaf tx-depth context is read through `tx_size_context` — the DEBLOCK | |
| 437 | +grid approximation — while libaom's `get_tx_size_context` (`pred_common.h:342`) | |
| 438 | +reads the **TXFM bands** with the inter-neighbour block-size override. The | |
| 439 | +approximation only coincides while every neighbour codes one whole-block | |
| 440 | +transform, "which is exactly what `TxMode::Select` ends" (the helper's own | |
| 441 | +doc) — warped's key frame IS `TxMode::Select` with intrabc. The fix is the | |
| 442 | +lane's next step and is NOT small: `publish_txfm_bands_if_in_inter` returns | |
| 443 | +early on a key frame, so switching the read to libaom's formula requires | |
| 444 | +publishing the bands from EVERY key-frame block (strips included) in the same | |
| 445 | +change, or currently-byte-exact streams can regress. Left unpushed. | |
| 446 | + | |
| 447 | +Consequences for the rest of the corpus: `allintra` and `warped` both now stop | |
| 448 | +at `decode.rs:9155` "intra block copy on a HORZ/VERT/1:4 rect intra strip | |
| 449 | +(reconstruction is not ported at this shape)" — after **16 more mi rows** of | |
| 450 | +frame 0 than before the fix (was (38,60), now (54,64)). That refusal is lane 3's | |
| 451 | +and is left standing. | |
| 452 | + | |
| 453 | +### 9.5 Inventory re-pin (done) | |
| 454 | + | |
| 455 | +- The sub-8x8-intrabc refusal no longer exists (the capability landed), so its | |
| 456 | + `REFUSALS` entry is replaced by a note and its claims-table pair is retired; | |
| 457 | + the census gate stays as the non-vacuous premise witness (`reached = 0` now). | |
| 458 | +- The Golomb entry is RE-PINNED with the measurement: the reader covers the | |
| 459 | + whole legal value domain, but the string is reachable as a DESYNC SYMPTOM | |
| 460 | + (real monochrome libaom stream, `stream.rs`'s mono tripwire) — the claim pins | |
| 461 | + value coverage, not unreachability. | |
| 462 | + | |
| 463 | +### 9.6 Gates | |
| 464 | + | |
| 465 | +- `cargo test -p ec-av1 --lib -- <the three new gates>`: 3 passed, 0 warnings. | |
| 466 | +- Full `cargo test -p ec-av1 --lib` and `cargo check -p ec-av1 --all-targets` | |
| 467 | + were launched at the end of this pass; see the commit message / next session | |
| 468 | + for their totals (baseline 592/0/60). | |
| 469 | +- `cargo build --release -p ec-av1 --example decode_probe`: 0 warnings. | |
| 470 | + | |
| 471 | +### 9.7 Next steps (ordered) | |
| 472 | + | |
| 473 | +1. Read the key-frame tx-depth context from the TXFM bands (libaom | |
| 474 | + `get_tx_size_context`) and publish the bands from every key-frame block — | |
| 475 | + then re-run the (46,66) ladder rung and the corpus sweep (§5's tripwires | |
| 476 | + included). | |
| 477 | +2. `allintra`'s 1:4 rect-strip intrabc (lane 3) and the mixed-leaf var-tx | |
| 478 | + refusal (the new stop for `allintra0`). | |
| 479 | +3. Add the 4x8/8x4 intrabc witnesses to the media-gated corpus (a real stream | |
| 480 | + that codes one: `warped.obu` reaches `RECT_INTRABC_VARTX_HITS == 1` and now | |
| 481 | + decodes past the old divergence). | |
| 482 | + | |
| 483 | +## 10. Continuation r2 (2026-09-20): the refuted census + the third silent-garbage member | |
| 484 | + | |
| 485 | +The re-verifier REFUTED §9.2's "exactly two parsed-but-never-read | |
| 486 | +pixel-affecting fields". A third existed, and it was the same silent-garbage | |
| 487 | +class §9.1 had just closed for 4:4:4. This round is that finding. | |
| 488 | + | |
| 489 | +### 10.1 The fix: `using_qmatrix` refused by name | |
| 490 | + | |
| 491 | +`QuantizationParams.using_qmatrix` + `qm_y`/`qm_u`/`qm_v` are parsed | |
| 492 | +(`ec-av1-syntax/src/frame.rs:190-196`, `:1418-1426`) and read by NOTHING on the | |
| 493 | +decode path — dequantisation is `base_q_idx` + the plane DC/AC deltas only. A | |
| 494 | +spec-legal `aomenc --enable-qm=1` stream therefore decoded into silently wrong | |
| 495 | +pixels. | |
| 496 | + | |
| 497 | +`stream.rs`'s `decode_stream` now refuses it at the frame header, beside the | |
| 498 | +non-4:2:0 guard: | |
| 499 | + | |
| 500 | +``` | |
| 501 | +if header.quantization.using_qmatrix { | |
| 502 | + return Err(Error::unsupported( | |
| 503 | + "AV1 decode_stream", | |
| 504 | + "a frame using quantisation matrices (using_qmatrix=1): dequantisation here is \ | |
| 505 | + base_q_idx plus the plane DC/AC deltas only, so qm_y/qm_u/qm_v would be ignored \ | |
| 506 | + and the frame would decode silently wrong pixels", | |
| 507 | + )); | |
| 508 | +} | |
| 509 | +``` | |
| 510 | + | |
| 511 | +### 10.2 Evidence | |
| 512 | + | |
| 513 | +- Measured pair (real aomenc, same source / recipe, only `--enable-qm` flipped; | |
| 514 | + `~/.cache/aom-oracle/build/aomenc`): the qm-OFF stream is byte-exact vs | |
| 515 | + ffmpeg; the qm-ON stream (`using_qmatrix = 1`, `qm_y/u/v = 5`) decoded with NO | |
| 516 | + refusal and its planes byte-differed from ffmpeg. | |
| 517 | + `EC_AV1_PIN=<qm.obu> ... scratch_isolate_pinned_mismatch --ignored` prints the | |
| 518 | + parsed `using_qmatrix = true` on every frame. | |
| 519 | +- Gate `a_frame_using_quantisation_matrices_is_refused_by_name` (stream.rs): | |
| 520 | + encodes `--enable-qm=0` and `--enable-qm=1` with real aomenc via | |
| 521 | + `census_attempt`, asserts the qm-off CONTROL decodes and the qm-on stream | |
| 522 | + refuses by name. | |
| 523 | +- **Fail-pre-fix**, measured: with the guard removed the gate panics | |
| 524 | + `the --enable-qm=1 stream now decodes -- flip this gate to a witness` (and the | |
| 525 | + decode_probe pair above shows those bytes are wrong). | |
| 526 | +- Inventory: new `REFUSALS` entry + `PROVEN` pair; P3 doc fix — | |
| 527 | + `cdf_state.rs`'s `wide()` comment named the deleted `txbset_for_inter`, now | |
| 528 | + `inter_txbset_for`. | |
| 529 | + | |
| 530 | +### 10.3 Gates (this round) | |
| 531 | + | |
| 532 | +- `cargo test -p ec-av1 --lib -- refusal_inventory <the new gate> | |
| 533 | + a_reader_told_not_to_adapt a_non_420`: 16 passed, 0 failed. | |
| 534 | +- fail-pre-fix run (guard removed): 1 failed, 0 passed — the gate is | |
| 535 | + non-vacuous. | |
| 536 | +- `cargo check -p ec-av1 --all-targets`: 0 warnings. | |
| 537 | +- The full 595-test suite re-run belongs to the re-verifier. | |
| 538 | + | |
| 539 | +### 10.4 Next steps | |
| 540 | + | |
| 541 | +Unchanged from §9.7. This round closes the census hole; the warped key-frame | |
| 542 | +tx-depth context (§9.4) and the 1:4-rect-strip intrabc (lane 3) are still open. | |
| 543 | + |