diff --git a/crates/ec-av1/src/decode.rs b/crates/ec-av1/src/decode.rs index 6c18da55..0dc7f071 100644 --- a/crates/ec-av1/src/decode.rs +++ b/crates/ec-av1/src/decode.rs @@ -33045,6 +33045,11 @@ fn decode_inter_block( // combinations that don't implement scaled MC yet. frame_width: usize, fctx: &crate::decode::FrameCtx, ) -> Result<()> { + // Round 27: the per-read trace is the only instrument that reaches the inter + // path (the coefficient rungs stop well before the frame-3 divergence), + // so publish the phase and the block's mi for every read it makes. + crate::msac::SymbolDecoder::set_symr_phase("inter"); + crate::msac::SymbolDecoder::set_symr_mi(at.0 as i64, at.1 as i64); // lane-inter4 r1: `at` is in MI units (4 px) so a 32-level 1:4 strip can // name an 8-px offset; `(r, c)` stays the enclosing 16-px cell for the @@ -40400,6 +40405,13 @@ fn decode_inter_block8( // (`use_superres`) -- mirrors [`decode_inter_block`]'s own param. frame_width: usize, fctx: &crate::decode::FrameCtx, ) -> Result<(bool, bool, bool, Option<(i8, i8, u8, u8)>, [u8; 2], (i8, Option))> { + // Round 27: this is the function whose mode read carries the block's real + // mi (the `EC_MODE_VAL8` rung prints it). The `decode_inter_block` + // entry sets the same label from ITS `at`, which is a different block -- + // publishing from here is what makes the EC_SYMR mi trustworthy on the + // inter path, which is what round 22 got wrong by assuming it was not. + crate::msac::SymbolDecoder::set_symr_phase("inter8"); + crate::msac::SymbolDecoder::set_symr_mi(leaf_mi.0 as i64, leaf_mi.1 as i64); const LAST_FRAME: i8 = 1; // lane-gmaffine r2: the leaf's OWN switchable-filter symbols, handed back // so the caller stamps them into `Neighbours` instead of the `[3, 3]` diff --git a/crates/ec-av1/src/msac.rs b/crates/ec-av1/src/msac.rs index c127ed01..4f4b208e 100644 --- a/crates/ec-av1/src/msac.rs +++ b/crates/ec-av1/src/msac.rs @@ -329,6 +329,12 @@ thread_local! { /// rounds 22 and 23. Set by the mode readers at entry; `(-1,-1)` outside. pub(crate) static SYMR_MI: std::cell::Cell<(i64, i64)> = const { std::cell::Cell::new((-1, -1)) }; + /// A short tag for the READER PHASE ("intra", "inter", "mv", ...), printed + /// on every `EC_SYMR` line. The coefficient rungs stop well before some + /// divergences, so the per-read stream is the only instrument that covers + /// the inter path; without a phase its reads are unattributable. + pub(crate) static SYMR_PHASE: std::cell::Cell<&'static str> = + const { std::cell::Cell::new("") }; } impl<'a> SymbolDecoder<'a> { @@ -407,6 +413,10 @@ impl<'a> SymbolDecoder<'a> { /// `decode_symbol` (spec 8.2.6), with the adaptation of 8.3.2. /// + pub(crate) fn set_symr_phase(p: &'static str) { + SYMR_PHASE.with(|c| c.set(p)); + } + pub(crate) fn set_symr_mi(mi_r: i64, mi_c: i64) { SYMR_MI.with(|c| c.set((mi_r, mi_c))); } @@ -445,7 +455,8 @@ impl<'a> SymbolDecoder<'a> { } if symr { eprintln!( - "EC_SYMR mi=({},{}) pre=({},{},{}) cdf0={} n={} s={} post_rng={}", + "EC_SYMR ph={} mi=({},{}) pre=({},{},{}) cdf0={} n={} s={} post_rng={}", + SYMR_PHASE.with(std::cell::Cell::get), SYMR_MI.with(std::cell::Cell::get).0, SYMR_MI.with(std::cell::Cell::get).1, pre_value,