stream: pin four more oracle counts, one of them off the wire itself
Browse files at this commit31ca7609a2a742af3f288879dee205c821ea8c79Parent: 6e9d8a01 changed file +38 -4
- crates/ec-av1/src/stream.rs +38 -4
crates/ec-av1/src/stream.rsmodified+38 -4
| @@ -13249,6 +13249,21 @@ pub(crate) mod tests { | |||
| 13249 | "{NAME}: only {headers} frame headers in the fixture" | 13249 | "{NAME}: only {headers} frame headers in the fixture" |
| 13250 | ); | 13250 | ); |
| 13251 | let frames = decode_stream(&stream).unwrap_or_else(|e| panic!("{NAME}: {e}")); | 13251 | let frames = decode_stream(&stream).unwrap_or_else(|e| panic!("{NAME}: {e}")); |
| 13252 | + // The frame count, and it comes from the WIRE, not from our decode: the | ||
| 13253 | + // loop above parsed this stream's own OBU frame headers with | ||
| 13254 | + // `Av1Parser` and counted `headers` of them (>= 3, from the arm's | ||
| 13255 | + // `--limit=3` at 13127, which overrides the helper's `--limit=1` because | ||
| 13256 | + // aomenc keeps the last occurrence of a repeated flag). Asserted ABOVE | ||
| 13257 | + // the oracle call, so a decode that showed fewer frames than the bitstream | ||
| 13258 | + // codes reds naming the wire instead of asking ffmpeg for the same short | ||
| 13259 | + // count. Deriving it from `headers` rather than a literal keeps the pin | ||
| 13260 | + // honest if aomenc's frame count ever drifts. | ||
| 13261 | + assert_eq!( | ||
| 13262 | + frames.len(), | ||
| 13263 | + headers, | ||
| 13264 | + "{NAME}: the stream codes {headers} frame(s), the decode showed {}", | ||
| 13265 | + frames.len() | ||
| 13266 | + ); | ||
| 13252 | let theirs = ffmpeg_decode_sequence(&stream, width, height, frames.len()); | 13267 | let theirs = ffmpeg_decode_sequence(&stream, width, height, frames.len()); |
| 13253 | assert_eq!(frames.len(), theirs.len(), "{NAME}: frame count"); | 13268 | assert_eq!(frames.len(), theirs.len(), "{NAME}: frame count"); |
| 13254 | for (i, (ours, ref_frame)) in frames.iter().zip(theirs.iter()).enumerate() { | 13269 | for (i, (ours, ref_frame)) in frames.iter().zip(theirs.iter()).enumerate() { |
| @@ -13454,15 +13469,19 @@ pub(crate) mod tests { | |||
| 13454 | Err(e) => panic!("{NAME}: decode failed on {arm} at {depth}-bit: {e}"), | 13469 | Err(e) => panic!("{NAME}: decode failed on {arm} at {depth}-bit: {e}"), |
| 13455 | }; | 13470 | }; |
| 13456 | let fired = decode::rect4_palette_hits() - before; | 13471 | let fired = decode::rect4_palette_hits() - before; |
| 13472 | + // The ENCODE's frame count, asserted ABOVE the oracle call: the | ||
| 13473 | + // y4m renders 5 frames (`-t 0.2` at every arm's `rate=25`, | ||
| 13474 | + // 13275) but aomenc is given `--limit=1` (13313), so the stream | ||
| 13475 | + // codes exactly 1 frame at both depths on every arm. Asserted | ||
| 13476 | + // here it is NOT the tautology the old comment below claimed: | ||
| 13477 | + // `frames.len() == 1` is a fact about the encode, checked before | ||
| 13478 | + // `frames.len()` is spent as ffmpeg's frame budget. | ||
| 13479 | + assert_eq!(frames.len(), 1, "{NAME}: {arm} at {depth}-bit key frame"); | ||
| 13457 | let ffmpeg_frames = if depth == 10 { | 13480 | let ffmpeg_frames = if depth == 10 { |
| 13458 | ffmpeg_decode_sequence_10bit(&stream, width, height, frames.len()) | 13481 | ffmpeg_decode_sequence_10bit(&stream, width, height, frames.len()) |
| 13459 | } else { | 13482 | } else { |
| 13460 | ffmpeg_decode_sequence(&stream, width, height, frames.len()) | 13483 | ffmpeg_decode_sequence(&stream, width, height, frames.len()) |
| 13461 | }; | 13484 | }; |
| 13462 | - // No frame-count assert here: `ffmpeg_decode_sequence{,_10bit}` | ||
| 13463 | - // was handed `frames.len()` as its frame budget, so | ||
| 13464 | - // `ffmpeg_frames.len() == frames.len()` holds by construction | ||
| 13465 | - // and the assert was tautological. | ||
| 13466 | assert!( | 13485 | assert!( |
| 13467 | !frames.is_empty(), | 13486 | !frames.is_empty(), |
| 13468 | "{NAME}: {arm} at {depth}-bit decoded no frame" | 13487 | "{NAME}: {arm} at {depth}-bit decoded no frame" |
| @@ -15592,6 +15611,21 @@ pub(crate) mod tests { | |||
| 15592 | .map(|((label, _), d)| format!("{label}={d}")) | 15611 | .map(|((label, _), d)| format!("{label}={d}")) |
| 15593 | .collect(); | 15612 | .collect(); |
| 15594 | let fired = fired.join(" "); | 15613 | let fired = fired.join(" "); |
| 15614 | + // The ENCODE's frame count, and it is this helper's `frames` PARAMETER | ||
| 15615 | + // (15446) -- not our decode's length. It is the same value handed to | ||
| 15616 | + // `encode_10bit_gradients_seed` (15469), which renders | ||
| 15617 | + // `frames / 25.0` seconds at `rate=25` (15928, 15940) and runs | ||
| 15618 | + // aomenc with no `--limit` of its own, so the stream codes exactly | ||
| 15619 | + // `frames` frames: 1 for the single-key-frame callers, 24 for the | ||
| 15620 | + // `--lag-in-frames=16` inter callers. Asserted ABOVE the oracle call, | ||
| 15621 | + // so a decode that showed fewer reds naming the encode rather than | ||
| 15622 | + // handing ffmpeg the same short count. | ||
| 15623 | + assert_eq!( | ||
| 15624 | + decoded.len(), | ||
| 15625 | + frames, | ||
| 15626 | + "{name}: seed {seed}: the encode codes {frames} frame(s), the decode showed {}", | ||
| 15627 | + decoded.len() | ||
| 15628 | + ); | ||
| 15595 | let reference = ffmpeg_decode_sequence_10bit(&stream, width, height, decoded.len()); | 15629 | let reference = ffmpeg_decode_sequence_10bit(&stream, width, height, decoded.len()); |
| 15596 | assert_eq!( | 15630 | assert_eq!( |
| 15597 | decoded.len(), | 15631 | decoded.len(), |