From d0ddce625dbafd4d03dcca42606e8de7427d8f01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Fri, 28 Aug 2026 11:27:59 +0300 Subject: [PATCH] wip(av1): r4 -- EC_RNG global trace finds the real desync read, r3's frame-8 fidx claim falsified STREAM_HEADER dump extended with is_motion_mode_switchable/enable_interintra_compound/ allow_warped_motion. Checked against the pin: all three are false on every one of its 20 frames -- the motion_mode/OBMC/interintra/warped-motion read paths (confirmed via libaom decodemv.c grep to be entirely unimplemented in decode.rs: zero hits for "motion_mode"/"obmc"/"warped"/"interintra") are a real capability gap but NOT this pin's defect, since the bits that would gate those reads are off throughout. Ran the existing EC_RNG global trace (msac.rs symbol_fixed, already instrumented a prior round) on both sides: ours 658 symbol reads for the whole 20-frame stream vs aomdec 655 -- a genuine 3-read count mismatch, confirming a structural desync somewhere, not a pure "same reads, wrong probs" bug. Diffed the two EC_RNG logs read-by-read (rng_before/rng_after/nsyms/symbol, ignoring the "n=" index since counts differ): identical for the first 538 reads, then: ours: rng_before=44723 rng_after=32887 nsyms=2 symbol=0 aom: rng_before=44723 rng_after=38110 nsyms=2 symbol=1 Same range state and same nsyms into the read, different decoded symbol -- a real context/CDF divergence, not a narrowing coincidence. Counting frame-boundary markers (rng_before=32768, i.e. every SymbolDecoder::new) up to that point: 10 boundaries passed, so this read is in decode-order frame index 10, NOT frame index 8. Frame index 8's segment (log lines 363-486, containing the nsyms=3 reads r3 attributed to the mi(0,0) dir1 switchable_interp mismatch) diffs byte-for-byte identical between ours and aomdec -- r3's "mismatch frame 8" identification was built on the fidx-offset trap the r2 handoff already warned about and does not hold up against this direct value/range trace. The real first divergence is a *later* frame, a different symbol (nsyms=2, not switchable_interp's nsyms=3), ~25 reads into that frame's tile. Not yet identified which flag nsyms=2 at that position corresponds to (no call-site tag on the shared EC_RNG print -- it's a global counter over every dec.symbol() call in the crate). Next step: tag EC_RNG (or add a parallel thread-local "current op" string set right before each dec.symbol() call near candidate binary reads -- skip_mode, is_inter, single/comp ref bits, comp_group_idx, delta_q/delta_lf presence, palette presence, filter_intra, tx_depth splits) so the divergent read's call site is named directly, then cross-check that site's context computation against libaom's matching function for real-frame-10 pixel content (not frame 8). Masks untouched (compound_references/reference_select refusals still in stream.rs). No pixel-level re-verification needed yet -- pin still mismatches, unchanged. --- crates/ec-av1/src/stream.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/crates/ec-av1/src/stream.rs b/crates/ec-av1/src/stream.rs index 88a96bc5..9dda6a62 100644 --- a/crates/ec-av1/src/stream.rs +++ b/crates/ec-av1/src/stream.rs @@ -268,9 +268,12 @@ pub fn decode_stream(data: &[u8]) -> Result> { }; if std::env::var_os("EC_AV1_SREF_DUMP").is_some() { eprintln!( - "STREAM_HEADER r17_before={} interpolation_filter={:?} interp_fixed={interp_fixed:?}", + "STREAM_HEADER r17_before={} interpolation_filter={:?} interp_fixed={interp_fixed:?} is_motion_mode_switchable={} enable_interintra_compound={:?} allow_warped_motion={}", crate::decode::r17_dump_frame_idx(), - header.interpolation_filter + header.interpolation_filter, + header.is_motion_mode_switchable, + parser.sequence_header().map(|s| s.enable_interintra_compound), + header.allow_warped_motion, ); }