forge
Explore
Log in

Don't you dare go Hollow

Wire reduced_tx_set=false inter tx_type gating through decode

Browse files at this commit

8cc4428d650eff2a92b749747d49de160d737a80Ahmet Kaan GümüşParent: 8dbd683
  • feat
    • wire reduced_tx_set=false inter tx_type gating through decode
Show full message
feat(av1): wire reduced_tx_set=false inter tx_type gating through decode

Threads header.reduced_tx_set from stream.rs into
decode_inter_frame_tile_with_cdfs -> decode_inter_block (16x16, gated to
Luma16InterSet1) and the new decode_inter_block8 parameter (8x8, gated to
Luma8InterSet1). 32x32 inter stays fixed on Luma32Inter -- get_tx_set never
splits TX_32X32 on reduced_tx_set. TX_4X4 inter has no reachable path
(decode_inter_block8 never resolves a further tx_depth split; the only TX4
reads on the inter side are the fixed Chroma4 UV transform), so no
Luma4Inter table is needed.

cdfflake-stream-seed45.bin pin: luma now MATCH on all 4 frames (was 359/2734
mismatched px on frames 2/3 pre-wiring); a residual ~33px delta-1 chroma-U
mismatch on frames 2/3 remains and is out of scope (chroma never reads a
tx_type symbol, so reduced_tx_set cannot reach it) -- a separate, smaller,
pre-existing defect.

Also removes the r1 bisect scratch instrumentation (msac.rs EC_RNG decoder
trace, decode.rs scratch_dump_prefilt/EC_AV1_PREFILT_DUMP_OURS) now that the
gap it was hunting is wired; scratch_isolate_pinned_mismatch,
scratch_decode_pinned_stream_once, and the pin fixtures stay.
crates/ec-av1/src/decode.rsmodified+25 -29
@@ -2493,30 +2493,6 @@ fn cdef_filter_block(
24932493 /// size. `cdef_bits == 0` is this crate's only supported case so far (see the
24942494 /// refusal in `stream.rs`), so every 64x64 filter block always uses index 0's
24952495 /// strengths -- no per-block `cdef_idx` selection is implemented yet.
2496-/// bisect scratch (lane-cdffwd2): dump this frame's Y/U/V exactly the way
2497-/// the instrumented `aomdec` build's `EC_AV1_PREFILT_DUMP` does (raw
2498-/// `true_width`x`true_height` bytes per plane, decode order, one file per
2499-/// frame index), gated on env so it is zero-cost/zero-behavior off. Called
2500-/// from both the key-frame and inter-frame tile decoders so the frame index
2501-/// lines up with aomdec's own (which dumps unconditionally every frame).
2502-fn scratch_dump_prefilt(y: &PlaneBuf, u: &PlaneBuf, v: &PlaneBuf) {
2503- let Some(base) = std::env::var_os("EC_AV1_PREFILT_DUMP_OURS") else {
2504- return;
2505- };
2506- use std::sync::atomic::{AtomicUsize, Ordering};
2507- static IDX: AtomicUsize = AtomicUsize::new(0);
2508- let idx = IDX.fetch_add(1, Ordering::SeqCst);
2509- let path = format!("{}.f{}", base.to_string_lossy(), idx);
2510- let mut out = Vec::new();
2511- for plane in [y, u, v] {
2512- for row in 0..plane.true_height {
2513- let start = row * plane.width;
2514- out.extend_from_slice(&plane.data[start..start + plane.true_width]);
2515- }
2516- }
2517- let _ = std::fs::write(path, out);
2518-}
2519-
25202496 /// Spec 7.14: the in-loop deblocking filter, applied once per frame after
25212497 /// tile reconstruction and before [`apply_cdef`]. Uniform-level path only --
25222498 /// `stream.rs` already refuses `delta_lf_present`/segmentation upstream, so
@@ -3620,7 +3596,6 @@ pub(crate) fn decode_key_frame_tile_with_cdfs(
36203596 }
36213597 }
36223598
3623- scratch_dump_prefilt(&y, &u, &v);
36243599 apply_deblock(&mut y, &mut u, &mut v, loop_filter, &neighbours);
36253600 apply_cdef(&mut y, &mut u, &mut v, cdef, &neighbours);
36263601
@@ -5428,6 +5403,9 @@ fn decode_inter_block8(
54285403 // just above).
54295404 skip_mode_present: bool,
54305405 skip_mode_frame: [u8; 2],
5406+ // lane-cdffwd2: this frame header's own `reduced_tx_set` bit -- see
5407+ // [`decode_inter_frame_tile_with_cdfs`]'s own doc.
5408+ reduced_tx_set: bool,
54315409 // lane-av1comp: `Some((ref1, comp_group_idx, compound_idx))` only for a
54325410 // real `COMPOUND_REFERENCE` leaf, for the caller's own end-of-16x16
54335411 // `record_compound_ctx` call -- mirrors [`decode_inter_block`]'s own
@@ -5751,7 +5729,11 @@ fn decode_inter_block8(
57515729 luma_grid = read_inter_plane(
57525730 dec,
57535731 cdfs,
5754- TxbSet::Luma8Inter,
5732+ if reduced_tx_set {
5733+ TxbSet::Luma8Inter
5734+ } else {
5735+ TxbSet::Luma8InterSet1
5736+ },
57555737 scan8,
57565738 0,
57575739 around[0],
@@ -5945,7 +5927,11 @@ fn decode_inter_block8(
59455927 luma_grid = read_inter_plane(
59465928 dec,
59475929 cdfs,
5948- TxbSet::Luma8Inter,
5930+ if reduced_tx_set {
5931+ TxbSet::Luma8Inter
5932+ } else {
5933+ TxbSet::Luma8InterSet1
5934+ },
59495935 scan8,
59505936 0,
59515937 around[0],
@@ -6193,6 +6179,7 @@ pub fn decode_inter_frame_tile(
61936179 false,
61946180 false,
61956181 [0; 2],
6182+ true,
61966183 )
61976184 .map(|(picture, _, _)| picture)
61986185 }
@@ -6238,6 +6225,11 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
62386225 // `decode_inter_block8` call below.
62396226 skip_mode_present: bool,
62406227 skip_mode_frame: [u8; 2],
6228+ // lane-cdffwd2: this frame header's own `reduced_tx_set` bit, threaded to
6229+ // every inter `tx_type` read below (`false` needs the 12-/16-symbol
6230+ // `Set1` coefficient tables at 16x16/8x8 rather than the reduced
6231+ // 2-symbol ones -- see [`TxbSet::Luma16InterSet1`]/[`TxbSet::Luma8InterSet1`]).
6232+ reduced_tx_set: bool,
62416233 ) -> Result<(Picture, Cdfs, crate::motion_field::MotionField)> {
62426234 let tpl_frame = tpl_field.map(|field| TplFrameArgs {
62436235 field,
@@ -6489,7 +6481,11 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
64896481 &sign_bias_table,
64906482 base_q_idx,
64916483 TxbSet::Luma16,
6492- TxbSet::Luma16Inter,
6484+ if reduced_tx_set {
6485+ TxbSet::Luma16Inter
6486+ } else {
6487+ TxbSet::Luma16InterSet1
6488+ },
64936489 TxbSet::Chroma8,
64946490 TX16,
64956491 TX8,
@@ -6569,6 +6565,7 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
65696565 ref_order_hints,
65706566 skip_mode_present,
65716567 skip_mode_frame,
6568+ reduced_tx_set,
65726569 )?;
65736570 prev_leaf = Some((leaf_mi, skip, is_inter));
65746571 last_skip_mode = skip_mode_leaf;
@@ -6622,7 +6619,6 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
66226619 }
66236620 }
66246621
6625- scratch_dump_prefilt(&y, &u, &v);
66266622 apply_deblock(&mut y, &mut u, &mut v, loop_filter, &neighbours);
66276623 apply_cdef(&mut y, &mut u, &mut v, cdef, &neighbours);
66286624
crates/ec-av1/src/msac.rsmodified+0 -12
@@ -303,9 +303,6 @@ impl<'a> SymbolDecoder<'a> {
303303 let mut cur = self.range;
304304 let mut prev;
305305 let mut symbol = 0;
306- // bisect scratch (lane-cdffwd2): rng_before, matching libaom
307- // entdec.c's own EC_RNG trace field of the same name.
308- let rng_before = self.range;
309306 loop {
310307 prev = cur;
311308 let f = u32::from(CDF_TOP - cdf[symbol]);
@@ -318,15 +315,6 @@ impl<'a> SymbolDecoder<'a> {
318315 }
319316 self.range = prev - cur;
320317 self.value -= cur;
321- if std::env::var_os("EC_RNG").is_some() {
322- use std::sync::atomic::{AtomicU64, Ordering};
323- static N: AtomicU64 = AtomicU64::new(0);
324- let n = N.fetch_add(1, Ordering::SeqCst);
325- eprintln!(
326- "EC_RNG n={n} rng_before={rng_before} rng_after={} nsyms={nsyms} symbol={symbol}",
327- self.range
328- );
329- }
330318
331319 // Renormalise back into `[2^15, 2^16)`, the same shift the encoder
332320 // applied when it narrowed to this symbol.
crates/ec-av1/src/stream.rsmodified+1 -0
@@ -378,6 +378,7 @@ pub fn decode_stream(data: &[u8]) -> Result<Vec<Picture>> {
378378 enable_jnt_comp,
379379 header.skip_mode_present,
380380 header.skip_mode_frame,
381+ header.reduced_tx_set,
381382 )?
382383 };
383384 // Spec 7.20: `disable_frame_end_update_cdf` stores the frame's