forge
Explore
Log in

Don't you dare go Hollow

lane-av1422warp: instrument -- EC_SYMR names its own block (mi on every read)

Browse files at this commit

5e7ae321c0c39fb6ae42fcfb98811a20c75b654bAhmet Kaan GümüşParent: 8eb0217
No behaviour change: the three `set_symr_mi` calls and the new thread-local
only feed an env-gated print. Identity re-proved after the edit: 4:2:0
control a420.obu byte-identical to aomdec --rawvideo, 4:4:4
444_sb128rect_lr_witness.obu byte-identical to the pre-lane build, pinned
422_allskip_2f.obu and 422_sb128_3f.obu still pixel-exact.

A symbol read carries no mi, so the per-read stream could only be located
by correlating it against a SEPARATE trace. That correlation is what
mis-attributed reads in rounds 22 and 23: the divergence was pinned on a
4x4 leaf at mi(24,57) that the EC_SYMR stream shows is nowhere near it.
With mi on every read the same divergence names its OWN block, and the
answer changes: it is the 32x32 intra block at **mi(64,56)** -- the
frame's bottom-right corner at 4:2:2 -- whose mode-info reads pair
exactly (skip/cdef/dq/mode=3/angle_y=-2/uv_mode=8/angle_uv=-1) and
whose COEFFICIENT reads diverge.

The oracle side is the same edit, already snapshotted in the oracle tree
as 35d97e5, so both sides carry mi and the streams are directly
comparable read for read. `mi` is a LABEL for attribution and is
deliberately NOT part of the divergence criterion: the oracle publishes it
one read later than we do, so requiring equality on it would report a
spurious divergence at read 5.
crates/ec-av1/src/decode.rsmodified+3 -0
@@ -9981,6 +9981,7 @@ fn read_intra_mode_rect(
9981 // `palette_uv` even on a chroma-reference strip. Fold the plane count9981 // `palette_uv` even on a chroma-reference strip. Fold the plane count
9982 // into the same `has_chroma` this reader already gates on.9982 // into the same `has_chroma` this reader already gates on.
9983 let has_chroma = has_chroma && !mono(fctx);9983 let has_chroma = has_chroma && !mono(fctx);
9984+ crate::msac::SymbolDecoder::set_symr_mi(mi_r as i64, mi_c as i64);
9984 let ec_istep = crate::envflags::env_flag!("EC_TRACE_MODE_STEP");9985 let ec_istep = crate::envflags::env_flag!("EC_TRACE_MODE_STEP");
9985 if ec_istep {9986 if ec_istep {
9986 // Mirrors the oracle's own `EC_IMODE mi_row=.. mi_col=.. rng=..` line9987 // Mirrors the oracle's own `EC_IMODE mi_row=.. mi_col=.. rng=..` line
@@ -16581,6 +16582,7 @@ fn read_intra_mode(
16581 // shape the oracle's own `ec_read_intra_frame_mode_info_impl` prints16582 // shape the oracle's own `ec_read_intra_frame_mode_info_impl` prints
16582 // under `EC_TRACE_MODE_STEP`) so a range ladder can be diffed line for16583 // under `EC_TRACE_MODE_STEP`) so a range ladder can be diffed line for
16583 // line against the instrumented aomdec, not just `tell()`.16584 // line against the instrumented aomdec, not just `tell()`.
16585+ crate::msac::SymbolDecoder::set_symr_mi(mi_r as i64, mi_c as i64);
16584 let ec_istep = crate::envflags::env_flag!("EC_TRACE_MODE_STEP");16586 let ec_istep = crate::envflags::env_flag!("EC_TRACE_MODE_STEP");
16585 if ec_istep {16587 if ec_istep {
16586 // Mirrors the oracle's own `EC_IMODE mi_row=.. mi_col=.. rng=..` line16588 // Mirrors the oracle's own `EC_IMODE mi_row=.. mi_col=.. rng=..` line
@@ -20330,6 +20332,7 @@ fn read_intra_mode_sub8(
20330 let has_chroma = has_chroma && !mono(fctx);20332 let has_chroma = has_chroma && !mono(fctx);
20331 let trace = crate::envflags::env_flag!("EC_AV1_TRACE");20333 let trace = crate::envflags::env_flag!("EC_AV1_TRACE");
20332 let ec_istep = crate::envflags::env_flag!("EC_TRACE_MODE_STEP");20334 let ec_istep = crate::envflags::env_flag!("EC_TRACE_MODE_STEP");
20335+ crate::msac::SymbolDecoder::set_symr_mi(mi_r as i64, mi_c as i64);
20333 if ec_istep {20336 if ec_istep {
20334 eprintln!("EC_IMODE mi_row={mi_r} mi_col={mi_c} fn=sub8 rng={}", dec.debug_state().0);20337 eprintln!("EC_IMODE mi_row={mi_r} mi_col={mi_c} fn=sub8 rng={}", dec.debug_state().0);
20335 }20338 }
crates/ec-av1/src/msac.rsmodified+17 -1
@@ -321,6 +321,16 @@ impl Drop for SymbolDecoder<'_> {
321 }321 }
322 }322 }
323 323
324+thread_local! {
325+ /// The `(mi_row, mi_col)` the enclosing block reader is inside, for the
326+ /// `EC_SYMR` trace. A symbol read carries no mi of its own, so without it
327+ /// the per-read stream can only be located by correlating it against a
328+ /// SEPARATE trace -- and that correlation is what mis-attributed reads in
329+ /// rounds 22 and 23. Set by the mode readers at entry; `(-1,-1)` outside.
330+ pub(crate) static SYMR_MI: std::cell::Cell<(i64, i64)> =
331+ const { std::cell::Cell::new((-1, -1)) };
332+}
333+
324 impl<'a> SymbolDecoder<'a> {334 impl<'a> SymbolDecoder<'a> {
325 /// `init_symbol` (spec 8.2.2).335 /// `init_symbol` (spec 8.2.2).
326 #[must_use]336 #[must_use]
@@ -397,6 +407,10 @@ impl<'a> SymbolDecoder<'a> {
397 407
398 /// `decode_symbol` (spec 8.2.6), with the adaptation of 8.3.2.408 /// `decode_symbol` (spec 8.2.6), with the adaptation of 8.3.2.
399 ///409 ///
410+ pub(crate) fn set_symr_mi(mi_r: i64, mi_c: i64) {
411+ SYMR_MI.with(|c| c.set((mi_r, mi_c)));
412+ }
413+
400 /// `EC_SYMR=1` dumps every symbol read's PRE state (before the read and414 /// `EC_SYMR=1` dumps every symbol read's PRE state (before the read and
401 /// before the adaptation) together with the symbol and the post-read415 /// before the adaptation) together with the symbol and the post-read
402 /// range, so a divergence against a reference decoder can be bisected416 /// range, so a divergence against a reference decoder can be bisected
@@ -431,7 +445,9 @@ impl<'a> SymbolDecoder<'a> {
431 }445 }
432 if symr {446 if symr {
433 eprintln!(447 eprintln!(
434- "EC_SYMR pre=({},{},{}) cdf0={} n={} s={} post_rng={}",448+ "EC_SYMR mi=({},{}) pre=({},{},{}) cdf0={} n={} s={} post_rng={}",
449+ SYMR_MI.with(std::cell::Cell::get).0,
450+ SYMR_MI.with(std::cell::Cell::get).1,
435 pre_value,451 pre_value,
436 pre_range,452 pre_range,
437 pre_bit,453 pre_bit,