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(
3723 Option<PaletteUv>,3723 Option<PaletteUv>,
3724 )> {3724 )> {
3725 let trace = std::env::var_os("EC_AV1_TRACE").is_some();3725 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+ }
3726 let skip = dec.symbol(&mut cdfs.skip[skip_ctx]) != 0;3742 let skip = dec.symbol(&mut cdfs.skip[skip_ctx]) != 0;
3727 if trace {3743 if trace {
3728 eprintln!("TRACE skip value={}", skip as i32);3744 eprintln!("TRACE skip value={}", skip as i32);
3729 }3745 }
3746+ istep!("skip", skip as i32);
3730 // spec order (see the comment below on `read_intrabc_info`): `skip`,3747 // spec order (see the comment below on `read_intrabc_info`): `skip`,
3731 // `segment_id`, `cdef`, `delta_q` -- `cdef` lands right here.3748 // `segment_id`, `cdef`, `delta_q` -- `cdef` lands right here.
3732 maybe_read_cdef_idx(dec, mi_r, mi_c, skip);3749 maybe_read_cdef_idx(dec, mi_r, mi_c, skip);
3750+ istep!("cdef", 0);
3733 maybe_read_delta_q(dec, cdfs, mi_r, mi_c, side == 64, skip);3751 maybe_read_delta_q(dec, cdfs, mi_r, mi_c, side == 64, skip);
3734 maybe_read_delta_lf(dec, cdfs, mi_r, mi_c, side == 64, skip);3752 maybe_read_delta_lf(dec, cdfs, mi_r, mi_c, side == 64, skip);
3753+ istep!("dq", 0);
3735 // `read_intrabc_info` (spec 5.11.13, libaom decodemv.c:693, called at3754 // `read_intrabc_info` (spec 5.11.13, libaom decodemv.c:693, called at
3736 // :811 right after `skip_txfm`/`segment_id`/`cdef`/`delta_q` and before3755 // :811 right after `skip_txfm`/`segment_id`/`cdef`/`delta_q` and before
3737 // `mbmi->mode` is ever read): a `use_intrabc` symbol only present on an3756 // `mbmi->mode` is ever read): a `use_intrabc` symbol only present on an
@@ -3758,6 +3777,7 @@ fn read_intra_mode(
3758 if trace {3777 if trace {
3759 eprintln!("TRACE y_mode ctx=({above_ctx},{left_ctx}) value={mode}");3778 eprintln!("TRACE y_mode ctx=({above_ctx},{left_ctx}) value={mode}");
3760 }3779 }
3780+ istep!("mode", mode as i32);
3761 let angle_delta_y = if (V_PRED..=D67_PRED).contains(&mode) {3781 let angle_delta_y = if (V_PRED..=D67_PRED).contains(&mode) {
3762 let delta = read_angle_delta(dec, &mut cdfs.angle_delta[mode - V_PRED]);3782 let delta = read_angle_delta(dec, &mut cdfs.angle_delta[mode - V_PRED]);
3763 if trace {3783 if trace {
@@ -3770,6 +3790,7 @@ fn read_intra_mode(
3770 } else {3790 } else {
3771 03791 0
3772 };3792 };
3793+ istep!("angle_y", angle_delta_y);
3773 let uv_mode = if cfl {3794 let uv_mode = if cfl {
3774 dec.symbol(&mut cdfs.uv_mode_cfl[mode])3795 dec.symbol(&mut cdfs.uv_mode_cfl[mode])
3775 } else {3796 } else {
@@ -3778,6 +3799,7 @@ fn read_intra_mode(
3778 if trace {3799 if trace {
3779 eprintln!("TRACE uv_mode cfl={cfl} y_mode={mode} value={uv_mode}");3800 eprintln!("TRACE uv_mode cfl={cfl} y_mode={mode} value={uv_mode}");
3780 }3801 }
3802+ istep!("uv_mode", uv_mode as i32);
3781 let alpha = if cfl && uv_mode == UV_CFL_PRED {3803 let alpha = if cfl && uv_mode == UV_CFL_PRED {
3782 Some(read_cfl_alphas(dec, cdfs))3804 Some(read_cfl_alphas(dec, cdfs))
3783 } else {3805 } else {
@@ -3804,6 +3826,7 @@ fn read_intra_mode(
3804 } else {3826 } else {
3805 03827 0
3806 };3828 };
3829+ istep!("angle_uv", angle_delta_uv);
3807 // `read_palette_mode_info` (spec 5.11.13, libaom decodemv.c:567, called3830 // `read_palette_mode_info` (spec 5.11.13, libaom decodemv.c:567, called
3808 // at :840 right after `xd->cfl.store_y` and before `read_filter_intra_mode_info`):3831 // at :840 right after `xd->cfl.store_y` and before `read_filter_intra_mode_info`):
3809 // gated by `av1_allow_palette` (blockd.h -- size bound only,3832 // gated by `av1_allow_palette` (blockd.h -- size bound only,
@@ -3897,12 +3920,14 @@ fn read_intra_mode(
3897 use_filter_intra as i323920 use_filter_intra as i32
3898 );3921 );
3899 }3922 }
3923+ istep!("use_filter_intra", use_filter_intra as i32);
3900 if use_filter_intra {3924 if use_filter_intra {
3901 FILTER_INTRA_HITS.with(|c| c.set(c.get() + 1));3925 FILTER_INTRA_HITS.with(|c| c.set(c.get() + 1));
3902 let fi_mode = dec.symbol(&mut cdfs.filter_intra_mode);3926 let fi_mode = dec.symbol(&mut cdfs.filter_intra_mode);
3903 if trace {3927 if trace {
3904 eprintln!("TRACE filter_intra_mode value={fi_mode}");3928 eprintln!("TRACE filter_intra_mode value={fi_mode}");
3905 }3929 }
3930+ istep!("filter_intra_mode", fi_mode as i32);
3906 filter_intra = Some(fi_mode);3931 filter_intra = Some(fi_mode);
3907 }3932 }
3908 }3933 }
@@ -5414,6 +5439,13 @@ fn read_tx_size(
5414 }5439 }
5415 _ => unreachable!("decode_block/decode_leaf8 only call this at 8/16/32/64"),5440 _ => unreachable!("decode_block/decode_leaf8 only call this at 8/16/32/64"),
5416 };5441 };
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+ }
5417 if depth != 0 {5449 if depth != 0 {
5418 TX_DEPTH_HITS.with(|c| c.set(c.get() + 1));5450 TX_DEPTH_HITS.with(|c| c.set(c.get() + 1));
5419 }5451 }
crates/ec-av1/src/stream.rsmodified+22 -0
@@ -6398,6 +6398,28 @@ mod tests {
6398 let mismatched = frames[0].y != ffmpeg_frames[0].y;6398 let mismatched = frames[0].y != ffmpeg_frames[0].y;
6399 eprintln!("mismatched={mismatched}");6399 eprintln!("mismatched={mismatched}");
6400 }6400 }
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+ }
6401 /// Pinned streams captured by `EC_AV1_GATE_DUMP` off6423 /// Pinned streams captured by `EC_AV1_GATE_DUMP` off
6402 /// `a_real_aomenc_stream_with_warped_motion_refuses_or_matches` -- each6424 /// `a_real_aomenc_stream_with_warped_motion_refuses_or_matches` -- each
6403 /// one is a former mismatch, kept as a regression pin (warp-mismatch:6425 /// one is a former mismatch, kept as a regression pin (warp-mismatch: