From cc3d46c36c52f146d041f6d13451c6bfdcb24cbb 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 18:02:04 +0300 Subject: [PATCH] diag(av1): sbpart r5 -- confirm entropy desync between the two rect64 VERT/HORZ calls Pinned-stream diagnostics only: TRACE_RECT32_END trace print, and an EC_SBPART_DIAG bbox/per-SB-column breakdown on the pinned replay test. No behavior change to the live gate. See lanes/sbpart-r5.report.md for the finding. --- crates/ec-av1/src/decode.rs | 3 +++ crates/ec-av1/src/stream.rs | 45 +++++++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+) diff --git a/crates/ec-av1/src/decode.rs b/crates/ec-av1/src/decode.rs index 42af385b..5edac841 100644 --- a/crates/ec-av1/src/decode.rs +++ b/crates/ec-av1/src/decode.rs @@ -2580,6 +2580,9 @@ fn decode_block_rect( 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); RECT_PARTITION_HITS.with(|c| c.set(c.get() + 1)); + if std::env::var_os("EC_AV1_TRACE").is_some() { + eprintln!("TRACE_RECT32_END mi_row={mi_r} mi_col={mi_c} bw={bw} bh={bh}"); + } Ok(()) } diff --git a/crates/ec-av1/src/stream.rs b/crates/ec-av1/src/stream.rs index 5666b82d..d057c628 100644 --- a/crates/ec-av1/src/stream.rs +++ b/crates/ec-av1/src/stream.rs @@ -6547,7 +6547,52 @@ mod tests { } let frames = decode_stream(&stream).expect("pinned stream must decode"); let ffmpeg_frames = ffmpeg_decode_sequence(&stream, 192, 128, 1); + let (width, height) = (192usize, 128usize); for (i, (got, want)) in frames.iter().zip(&ffmpeg_frames).enumerate() { + if std::env::var_os("EC_SBPART_DIAG").is_some() { + let (mut min_r, mut max_r, mut min_c, mut max_c, mut n) = + (usize::MAX, 0usize, usize::MAX, 0usize, 0usize); + for r in 0..height { + for c in 0..width { + let idx = r * width + c; + if got.y[idx] != want.y[idx] { + min_r = min_r.min(r); + max_r = max_r.max(r); + min_c = min_c.min(c); + max_c = max_c.max(c); + n += 1; + } + } + } + eprintln!( + "DIAG frame {i}: {n} luma mismatches, bbox rows [{min_r}..{max_r}] cols \ + [{min_c}..{max_c}] of {width}x{height}" + ); + // Per-64px-superblock-column mismatch counts, to see whether + // corruption starts exactly at the rect64 SB or bleeds into + // SBs decoded earlier (raster order). + for sb_col in 0..(width + 63) / 64 { + let c0 = sb_col * 64; + let c1 = (c0 + 64).min(width); + let mut cnt = 0usize; + let mut first = None; + for r in 0..height { + for c in c0..c1 { + let idx = r * width + c; + if got.y[idx] != want.y[idx] { + cnt += 1; + if first.is_none() { + first = Some((r, c)); + } + } + } + } + eprintln!( + "DIAG frame {i} sb_col {sb_col} (cols {c0}..{c1}): {cnt} mismatches, \ + first={first:?}" + ); + } + } 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)");