forge
Explore
Log in

Don't you dare go Hollow

wip(tiny): per-symbol mode-info tracing, and the fixture-path probe

Browse files at this commit

c690c6706673644b56dc2f50465348ca75c19554Ahmet Kaan GümüşParent: d931dba
EC_TRACE_MODE_STEP-gated EC_ISTEP prints in the square read_intra_mode
and read_tx_size, plus an #[ignore]d probe_tiny_fixture_trace that
decodes a raw .obu from EC_TINY_FIXTURE_PATH so traces line up
byte-for-byte with a saved fixture instead of a regenerated one.

Purely additive; no logic changed. Committed by the orchestrator at the
agent's turn cap.
crates/ec-av1/src/decode.rsmodified+32 -0
@@ -3723,15 +3723,34 @@ fn read_intra_mode(
37233723 Option<PaletteUv>,
37243724 )> {
37253725 let trace = std::env::var_os("EC_AV1_TRACE").is_some();
3726+ // lane-tiny r2: EC_ISTEP-format trace (same "name=... val=... rng=..."
3727+ // shape the oracle's own `ec_read_intra_frame_mode_info_impl` prints
3728+ // under `EC_TRACE_MODE_STEP`) so a range ladder can be diffed line for
3729+ // line against the instrumented aomdec, not just `tell()`.
3730+ let ec_istep = std::env::var_os("EC_TRACE_MODE_STEP").is_some();
3731+ macro_rules! istep {
3732+ ($name:literal, $val:expr) => {
3733+ if ec_istep {
3734+ let (rng, _) = dec.debug_state();
3735+ eprintln!(
3736+ "EC_ISTEP mi_row={mi_r} mi_col={mi_c} name={} val={} rng={rng}",
3737+ $name, $val
3738+ );
3739+ }
3740+ };
3741+ }
37263742 let skip = dec.symbol(&mut cdfs.skip[skip_ctx]) != 0;
37273743 if trace {
37283744 eprintln!("TRACE skip value={}", skip as i32);
37293745 }
3746+ istep!("skip", skip as i32);
37303747 // spec order (see the comment below on `read_intrabc_info`): `skip`,
37313748 // `segment_id`, `cdef`, `delta_q` -- `cdef` lands right here.
37323749 maybe_read_cdef_idx(dec, mi_r, mi_c, skip);
3750+ istep!("cdef", 0);
37333751 maybe_read_delta_q(dec, cdfs, mi_r, mi_c, side == 64, skip);
37343752 maybe_read_delta_lf(dec, cdfs, mi_r, mi_c, side == 64, skip);
3753+ istep!("dq", 0);
37353754 // `read_intrabc_info` (spec 5.11.13, libaom decodemv.c:693, called at
37363755 // :811 right after `skip_txfm`/`segment_id`/`cdef`/`delta_q` and before
37373756 // `mbmi->mode` is ever read): a `use_intrabc` symbol only present on an
@@ -3758,6 +3777,7 @@ fn read_intra_mode(
37583777 if trace {
37593778 eprintln!("TRACE y_mode ctx=({above_ctx},{left_ctx}) value={mode}");
37603779 }
3780+ istep!("mode", mode as i32);
37613781 let angle_delta_y = if (V_PRED..=D67_PRED).contains(&mode) {
37623782 let delta = read_angle_delta(dec, &mut cdfs.angle_delta[mode - V_PRED]);
37633783 if trace {
@@ -3770,6 +3790,7 @@ fn read_intra_mode(
37703790 } else {
37713791 0
37723792 };
3793+ istep!("angle_y", angle_delta_y);
37733794 let uv_mode = if cfl {
37743795 dec.symbol(&mut cdfs.uv_mode_cfl[mode])
37753796 } else {
@@ -3778,6 +3799,7 @@ fn read_intra_mode(
37783799 if trace {
37793800 eprintln!("TRACE uv_mode cfl={cfl} y_mode={mode} value={uv_mode}");
37803801 }
3802+ istep!("uv_mode", uv_mode as i32);
37813803 let alpha = if cfl && uv_mode == UV_CFL_PRED {
37823804 Some(read_cfl_alphas(dec, cdfs))
37833805 } else {
@@ -3804,6 +3826,7 @@ fn read_intra_mode(
38043826 } else {
38053827 0
38063828 };
3829+ istep!("angle_uv", angle_delta_uv);
38073830 // `read_palette_mode_info` (spec 5.11.13, libaom decodemv.c:567, called
38083831 // at :840 right after `xd->cfl.store_y` and before `read_filter_intra_mode_info`):
38093832 // gated by `av1_allow_palette` (blockd.h -- size bound only,
@@ -3897,12 +3920,14 @@ fn read_intra_mode(
38973920 use_filter_intra as i32
38983921 );
38993922 }
3923+ istep!("use_filter_intra", use_filter_intra as i32);
39003924 if use_filter_intra {
39013925 FILTER_INTRA_HITS.with(|c| c.set(c.get() + 1));
39023926 let fi_mode = dec.symbol(&mut cdfs.filter_intra_mode);
39033927 if trace {
39043928 eprintln!("TRACE filter_intra_mode value={fi_mode}");
39053929 }
3930+ istep!("filter_intra_mode", fi_mode as i32);
39063931 filter_intra = Some(fi_mode);
39073932 }
39083933 }
@@ -5414,6 +5439,13 @@ fn read_tx_size(
54145439 }
54155440 _ => unreachable!("decode_block/decode_leaf8 only call this at 8/16/32/64"),
54165441 };
5442+ if std::env::var_os("EC_TRACE_MODE_STEP").is_some() {
5443+ let (rng, _) = dec.debug_state();
5444+ let (mi_r, mi_c) = at_mi;
5445+ eprintln!(
5446+ "EC_ISTEP mi_row={mi_r} mi_col={mi_c} name=tx_depth val={depth} ctx={ctx} rng={rng}"
5447+ );
5448+ }
54175449 if depth != 0 {
54185450 TX_DEPTH_HITS.with(|c| c.set(c.get() + 1));
54195451 }
crates/ec-av1/src/stream.rsmodified+22 -0
@@ -6398,6 +6398,28 @@ mod tests {
63986398 let mismatched = frames[0].y != ffmpeg_frames[0].y;
63996399 eprintln!("mismatched={mismatched}");
64006400 }
6401+
6402+ /// lane-tiny r2: decodes a raw OBU stream at `EC_TINY_FIXTURE_PATH` --
6403+ /// no ffmpeg/aomenc invocation -- so a range ladder can be run
6404+ /// (`EC_TRACE_MODE_STEP=1`) against the exact same bytes fed to the
6405+ /// oracle aomdec, byte for byte. `#[ignore]`d diagnostic, no assertion.
6406+ #[test]
6407+ #[ignore = "diagnostic, run manually with --nocapture and EC_TINY_FIXTURE_PATH set"]
6408+ fn probe_tiny_fixture_trace() {
6409+ let path = std::env::var("EC_TINY_FIXTURE_PATH")
6410+ .expect("set EC_TINY_FIXTURE_PATH to an .obu file");
6411+ let stream = std::fs::read(&path).expect("reading fixture");
6412+ match decode_stream(&stream) {
6413+ Ok(frames) => {
6414+ eprintln!("decoded {} frame(s)", frames.len());
6415+ if let Ok(dump) = std::env::var("EC_TINY_FIXTURE_Y_DUMP") {
6416+ let bytes: Vec<u8> = frames[0].y.iter().map(|&v| v as u8).collect();
6417+ std::fs::write(&dump, &bytes).expect("dump y plane");
6418+ }
6419+ }
6420+ Err(e) => eprintln!("REFUSED: {e}"),
6421+ }
6422+ }
64016423 /// Pinned streams captured by `EC_AV1_GATE_DUMP` off
64026424 /// `a_real_aomenc_stream_with_warped_motion_refuses_or_matches` -- each
64036425 /// one is a former mismatch, kept as a regression pin (warp-mismatch: