From a45ccae00a952718b1c128479c332c61e817a794 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Thu, 27 Aug 2026 16:03:47 +0300 Subject: [PATCH] debug(av1): env-gated dump of frame-2 saved CDF tables, decisive negative result MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit EC_AV1_DUMP_TABLES dumps the reference-slot CDF tables a frame saves (partition_w64/w32/w16, skip, new_mv, zero_mv, ref_mv, mv_joint) in the spec's cumulative-probability orientation. Cross-checked against a matching libaom decodeframe.c dump (converting its inverted icdf storage back to the same orientation) on the pinned cdffwd stream: frame 2's saved tables are byte-identical between the two decoders across every table sampled. This falsifies the CDF-forwarding hypothesis (stale/never-adapted forwarded table, specifically the gathered-partition-never-adapted theory) for the frame-3 partition_w32[ctx=8] divergence — the bug is elsewhere (context computation entering frame 3, an untabled CDF, or an actual bitstream desync inside frame 3 itself). Also confirmed by libaom source (bitreader.h aom_read_symbol_ vs aom_read_cdf_) that libaom's own gathered partition reads never call update_cdf on the full table either, matching our symbol_fixed's behavior -- the gathered-adaptation theory was wrong on both sides independently. --- crates/ec-av1/src/stream.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/crates/ec-av1/src/stream.rs b/crates/ec-av1/src/stream.rs index 6cc208ed..e7090b04 100644 --- a/crates/ec-av1/src/stream.rs +++ b/crates/ec-av1/src/stream.rs @@ -236,6 +236,24 @@ pub fn decode_stream(data: &[u8]) -> Result> { end_cdfs.reset_counts(); end_cdfs }; + if let Ok(path) = std::env::var("EC_AV1_DUMP_TABLES") { + use std::io::Write; + if let Ok(mut f) = std::fs::OpenOptions::new() + .create(true) + .append(true) + .open(&path) + { + let _ = writeln!(f, "=== frame idx={} ===", pictures.len()); + let _ = writeln!(f, "partition_w64 {:?}", stored_cdfs.partition_w64); + let _ = writeln!(f, "partition_w32 {:?}", stored_cdfs.partition_w32); + let _ = writeln!(f, "partition_w16 {:?}", stored_cdfs.partition_w16); + let _ = writeln!(f, "skip {:?}", stored_cdfs.skip); + let _ = writeln!(f, "new_mv {:?}", stored_cdfs.new_mv); + let _ = writeln!(f, "zero_mv {:?}", stored_cdfs.zero_mv); + let _ = writeln!(f, "ref_mv {:?}", stored_cdfs.ref_mv); + let _ = writeln!(f, "mv_joint {:?}", stored_cdfs.mv_joint); + } + } for i in 0..NUM_REF_FRAMES { if header.refresh_frame_flags & (1 << i) != 0 { cdf_slots[i] = Some(stored_cdfs.clone());