lane-av1422warp: instrument -- EC_SYMR names its own block (mi on every read)
Browse files at this commit5e7ae321c0c39fb6ae42fcfb98811a20c75b654bParent: 8eb02172 changed files +20 -1
- crates/ec-av1/src/decode.rs +3 -0
- crates/ec-av1/src/msac.rs +17 -1
crates/ec-av1/src/decode.rsmodified+3 -0
| @@ -9981,6 +9981,7 @@ fn read_intra_mode_rect( | ||
| 9981 | 9981 | // `palette_uv` even on a chroma-reference strip. Fold the plane count |
| 9982 | 9982 | // into the same `has_chroma` this reader already gates on. |
| 9983 | 9983 | let has_chroma = has_chroma && !mono(fctx); |
| 9984 | + crate::msac::SymbolDecoder::set_symr_mi(mi_r as i64, mi_c as i64); | |
| 9984 | 9985 | let ec_istep = crate::envflags::env_flag!("EC_TRACE_MODE_STEP"); |
| 9985 | 9986 | if ec_istep { |
| 9986 | 9987 | // Mirrors the oracle's own `EC_IMODE mi_row=.. mi_col=.. rng=..` line |
| @@ -16581,6 +16582,7 @@ fn read_intra_mode( | ||
| 16581 | 16582 | // shape the oracle's own `ec_read_intra_frame_mode_info_impl` prints |
| 16582 | 16583 | // under `EC_TRACE_MODE_STEP`) so a range ladder can be diffed line for |
| 16583 | 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 | 16586 | let ec_istep = crate::envflags::env_flag!("EC_TRACE_MODE_STEP"); |
| 16585 | 16587 | if ec_istep { |
| 16586 | 16588 | // Mirrors the oracle's own `EC_IMODE mi_row=.. mi_col=.. rng=..` line |
| @@ -20330,6 +20332,7 @@ fn read_intra_mode_sub8( | ||
| 20330 | 20332 | let has_chroma = has_chroma && !mono(fctx); |
| 20331 | 20333 | let trace = crate::envflags::env_flag!("EC_AV1_TRACE"); |
| 20332 | 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 | 20336 | if ec_istep { |
| 20334 | 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 | 334 | impl<'a> SymbolDecoder<'a> { |
| 325 | 335 | /// `init_symbol` (spec 8.2.2). |
| 326 | 336 | #[must_use] |
| @@ -397,6 +407,10 @@ impl<'a> SymbolDecoder<'a> { | ||
| 397 | 407 | |
| 398 | 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 | 414 | /// `EC_SYMR=1` dumps every symbol read's PRE state (before the read and |
| 401 | 415 | /// before the adaptation) together with the symbol and the post-read |
| 402 | 416 | /// range, so a divergence against a reference decoder can be bisected |
| @@ -431,7 +445,9 @@ impl<'a> SymbolDecoder<'a> { | ||
| 431 | 445 | } |
| 432 | 446 | if symr { |
| 433 | 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 | 451 | pre_value, |
| 436 | 452 | pre_range, |
| 437 | 453 | pre_bit, |