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(
99819981 // `palette_uv` even on a chroma-reference strip. Fold the plane count
99829982 // into the same `has_chroma` this reader already gates on.
99839983 let has_chroma = has_chroma && !mono(fctx);
9984+ crate::msac::SymbolDecoder::set_symr_mi(mi_r as i64, mi_c as i64);
99849985 let ec_istep = crate::envflags::env_flag!("EC_TRACE_MODE_STEP");
99859986 if ec_istep {
99869987 // Mirrors the oracle's own `EC_IMODE mi_row=.. mi_col=.. rng=..` line
@@ -16581,6 +16582,7 @@ fn read_intra_mode(
1658116582 // shape the oracle's own `ec_read_intra_frame_mode_info_impl` prints
1658216583 // under `EC_TRACE_MODE_STEP`) so a range ladder can be diffed line for
1658316584 // line against the instrumented aomdec, not just `tell()`.
16585+ crate::msac::SymbolDecoder::set_symr_mi(mi_r as i64, mi_c as i64);
1658416586 let ec_istep = crate::envflags::env_flag!("EC_TRACE_MODE_STEP");
1658516587 if ec_istep {
1658616588 // Mirrors the oracle's own `EC_IMODE mi_row=.. mi_col=.. rng=..` line
@@ -20330,6 +20332,7 @@ fn read_intra_mode_sub8(
2033020332 let has_chroma = has_chroma && !mono(fctx);
2033120333 let trace = crate::envflags::env_flag!("EC_AV1_TRACE");
2033220334 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);
2033320336 if ec_istep {
2033420337 eprintln!("EC_IMODE mi_row={mi_r} mi_col={mi_c} fn=sub8 rng={}", dec.debug_state().0);
2033520338 }
crates/ec-av1/src/msac.rsmodified+17 -1
@@ -321,6 +321,16 @@ impl Drop for SymbolDecoder<'_> {
321321 }
322322 }
323323
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+
324334 impl<'a> SymbolDecoder<'a> {
325335 /// `init_symbol` (spec 8.2.2).
326336 #[must_use]
@@ -397,6 +407,10 @@ impl<'a> SymbolDecoder<'a> {
397407
398408 /// `decode_symbol` (spec 8.2.6), with the adaptation of 8.3.2.
399409 ///
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+
400414 /// `EC_SYMR=1` dumps every symbol read's PRE state (before the read and
401415 /// before the adaptation) together with the symbol and the post-read
402416 /// range, so a divergence against a reference decoder can be bisected
@@ -431,7 +445,9 @@ impl<'a> SymbolDecoder<'a> {
431445 }
432446 if symr {
433447 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,
435451 pre_value,
436452 pre_range,
437453 pre_bit,