From 31ca7609a2a742af3f288879dee205c821ea8c79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Wed, 30 Sep 2026 01:21:12 +0300 Subject: [PATCH] stream: pin four more oracle counts, one of them off the wire itself a_real_aomenc_stream_with_cdf_update_disabled is the one site whose spec is NOT a literal: the arm overrides screen_intrabc_stream_at_depth's '--limit=1' with '--limit=3', and aomenc keeps the LAST occurrence of a repeated flag, so '3' would be a claim about flag precedence rather than a fact about a stream. The gate already parses this stream's own OBU frame headers with Av1Parser in the loop sitting above the call, so the assert compares frames.len() against that header count -- derived from the bitstream, not from a rule and not from our decode. The mutation run in the lane report prints both sides (3 vs 4), so the pin is shown to bite. Also pins the rect-strip-palette gate, whose 'no frame-count assert here' comment is deleted: frames.len() == 1 is a fact about the encode, taken before frames.len() is spent as ffmpeg's budget, so it was never the tautology that comment described -- and ten_bit_tool_gate, whose count is its own 'frames' PARAMETER, the same value handed to encode_10bit_gradients_seed: 1 for the key-frame callers, 24 for the --lag-in-frames=16 inter ones. count-vacuity sweep: 29 unpinned -> 25. --- crates/ec-av1/src/stream.rs | 42 +++++++++++++++++++++++++++++++++---- 1 file changed, 38 insertions(+), 4 deletions(-) diff --git a/crates/ec-av1/src/stream.rs b/crates/ec-av1/src/stream.rs index d62229d3..f0303e98 100644 --- a/crates/ec-av1/src/stream.rs +++ b/crates/ec-av1/src/stream.rs @@ -13249,6 +13249,21 @@ pub(crate) mod tests { "{NAME}: only {headers} frame headers in the fixture" ); let frames = decode_stream(&stream).unwrap_or_else(|e| panic!("{NAME}: {e}")); + // The frame count, and it comes from the WIRE, not from our decode: the + // loop above parsed this stream's own OBU frame headers with + // `Av1Parser` and counted `headers` of them (>= 3, from the arm's + // `--limit=3` at 13127, which overrides the helper's `--limit=1` because + // aomenc keeps the last occurrence of a repeated flag). Asserted ABOVE + // the oracle call, so a decode that showed fewer frames than the bitstream + // codes reds naming the wire instead of asking ffmpeg for the same short + // count. Deriving it from `headers` rather than a literal keeps the pin + // honest if aomenc's frame count ever drifts. + assert_eq!( + frames.len(), + headers, + "{NAME}: the stream codes {headers} frame(s), the decode showed {}", + frames.len() + ); let theirs = ffmpeg_decode_sequence(&stream, width, height, frames.len()); assert_eq!(frames.len(), theirs.len(), "{NAME}: frame count"); for (i, (ours, ref_frame)) in frames.iter().zip(theirs.iter()).enumerate() { @@ -13454,15 +13469,19 @@ pub(crate) mod tests { Err(e) => panic!("{NAME}: decode failed on {arm} at {depth}-bit: {e}"), }; let fired = decode::rect4_palette_hits() - before; + // The ENCODE's frame count, asserted ABOVE the oracle call: the + // y4m renders 5 frames (`-t 0.2` at every arm's `rate=25`, + // 13275) but aomenc is given `--limit=1` (13313), so the stream + // codes exactly 1 frame at both depths on every arm. Asserted + // here it is NOT the tautology the old comment below claimed: + // `frames.len() == 1` is a fact about the encode, checked before + // `frames.len()` is spent as ffmpeg's frame budget. + assert_eq!(frames.len(), 1, "{NAME}: {arm} at {depth}-bit key frame"); let ffmpeg_frames = if depth == 10 { ffmpeg_decode_sequence_10bit(&stream, width, height, frames.len()) } else { ffmpeg_decode_sequence(&stream, width, height, frames.len()) }; - // No frame-count assert here: `ffmpeg_decode_sequence{,_10bit}` - // was handed `frames.len()` as its frame budget, so - // `ffmpeg_frames.len() == frames.len()` holds by construction - // and the assert was tautological. assert!( !frames.is_empty(), "{NAME}: {arm} at {depth}-bit decoded no frame" @@ -15592,6 +15611,21 @@ pub(crate) mod tests { .map(|((label, _), d)| format!("{label}={d}")) .collect(); let fired = fired.join(" "); + // The ENCODE's frame count, and it is this helper's `frames` PARAMETER + // (15446) -- not our decode's length. It is the same value handed to + // `encode_10bit_gradients_seed` (15469), which renders + // `frames / 25.0` seconds at `rate=25` (15928, 15940) and runs + // aomenc with no `--limit` of its own, so the stream codes exactly + // `frames` frames: 1 for the single-key-frame callers, 24 for the + // `--lag-in-frames=16` inter callers. Asserted ABOVE the oracle call, + // so a decode that showed fewer reds naming the encode rather than + // handing ffmpeg the same short count. + assert_eq!( + decoded.len(), + frames, + "{name}: seed {seed}: the encode codes {frames} frame(s), the decode showed {}", + decoded.len() + ); let reference = ffmpeg_decode_sequence_10bit(&stream, width, height, decoded.len()); assert_eq!( decoded.len(),