From 1677429f5792d03d85ed0fd8b13f9ed10275ea74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Sun, 30 Aug 2026 17:49:26 +0300 Subject: [PATCH] wip(av1): sbpart r4's in-flight rect64 trace edits, committed verbatim at the turn cap The builder stopped while adding "one more targeted trace print to pin down whether the desync is in symbol reading or purely in reconstruction". Diagnostic prints are expected in this diff. State unverified by me. --- crates/ec-av1/src/decode.rs | 4 ++++ crates/ec-av1/src/stream.rs | 31 +++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/crates/ec-av1/src/decode.rs b/crates/ec-av1/src/decode.rs index 08a74022..42af385b 100644 --- a/crates/ec-av1/src/decode.rs +++ b/crates/ec-av1/src/decode.rs @@ -2848,6 +2848,10 @@ fn decode_block_rect64( neighbours.fill_skip_grid_rect((mi_r, mi_c), bw / MI, bh / MI, skip); neighbours.fill_lf_grid_rect((mi_r, mi_c), bw / MI, bh / MI, tx_w as u8, tx_h as u8, 0); SB_RECT_HITS.with(|c| c.set(c.get() + 1)); + if std::env::var_os("EC_AV1_TRACE").is_some() { + let (rng, _) = dec.debug_state(); + eprintln!("TRACE_RECT64_END mi_row={mi_r} mi_col={mi_c} bw={bw} bh={bh} rng={rng}"); + } Ok(()) } diff --git a/crates/ec-av1/src/stream.rs b/crates/ec-av1/src/stream.rs index 4e8c7a87..5666b82d 100644 --- a/crates/ec-av1/src/stream.rs +++ b/crates/ec-av1/src/stream.rs @@ -6522,4 +6522,35 @@ mod tests { crate::decode::sb_rect_hits() ); } + + /// lane-sbpart r4: replays a pinned mismatch byte-for-byte off disk (no + /// aomenc/ffmpeg re-encode), same pattern as `pinned_golden3/4_stream_ + /// decodes_pixel_exact` -- fast red/green loop for the bisect, and lets + /// `EC_AV1_TRACE=1` be set for one run without re-driving the encoder. + #[test] + #[ignore = "reads a pinned fixture path outside the repo; run manually"] + fn pinned_sbpart_stream_decodes_pixel_exact() { + let path = std::env::var("EC_AV1_GATE_DUMP_PIN") + .map(std::path::PathBuf::from) + .unwrap_or_else(|_| pin_dir().join("sbpart-pin.obu")); + let Ok(stream) = std::fs::read(&path) else { + eprintln!( + "SKIP pinned_sbpart_stream_decodes_pixel_exact: no pinned bytes at {} \ + -- re-capture with EC_AV1_GATE_DUMP off the sbpart gate", + path.display() + ); + return; + }; + if !have_ffmpeg() { + eprintln!("SKIP pinned_sbpart_stream_decodes_pixel_exact: no ffmpeg"); + return; + } + let frames = decode_stream(&stream).expect("pinned stream must decode"); + let ffmpeg_frames = ffmpeg_decode_sequence(&stream, 192, 128, 1); + for (i, (got, want)) in frames.iter().zip(&ffmpeg_frames).enumerate() { + assert_eq!(got.y, want.y, "frame {i} luma vs ffmpeg (pinned sbpart)"); + assert_eq!(got.u, want.u, "frame {i} U vs ffmpeg (pinned sbpart)"); + assert_eq!(got.v, want.v, "frame {i} V vs ffmpeg (pinned sbpart)"); + } + } }