stream: pin the encode's frame count above 7 oracle calls (palette, rect-tx tool, screen intrabc, 16x4 pair)
Browse files at this commit68670623fd50d29f73f1b9dc35c45cd57e35ff9dParent: d9e67451 changed file +50 -5
- crates/ec-av1/src/stream.rs +50 -5
crates/ec-av1/src/stream.rsmodified+50 -5
| @@ -10502,6 +10502,15 @@ pub(crate) mod tests { | ||
| 10502 | 10502 | match decoded { |
| 10503 | 10503 | Ok(frames) => { |
| 10504 | 10504 | assert!(!frames.is_empty(), "{NAME}: {arm} decoded no frame"); |
| 10505 | + // The ENCODE's frame count: the per-arm | |
| 10506 | + // render (10417) builds | |
| 10507 | + // `{src}=size=128x128:rate=25` with `-t 0.04` | |
| 10508 | + // (10427) -- one frame -- and the aomenc args | |
| 10509 | + // carry `--limit=1` (10467), so every | |
| 10510 | + // (src, depth, cq, txs, tiles) arm codes | |
| 10511 | + // exactly 1 frame. Asserted ABOVE the oracle | |
| 10512 | + // call. | |
| 10513 | + assert_eq!(frames.len(), 1, "{NAME}: {arm} key frame"); | |
| 10505 | 10514 | let theirs = if depth == 10 { |
| 10506 | 10515 | ffmpeg_decode_sequence_10bit( |
| 10507 | 10516 | &stream, |
| @@ -10728,6 +10737,23 @@ pub(crate) mod tests { | ||
| 10728 | 10737 | // report can still say whether the arm fired. |
| 10729 | 10738 | let parts = decode::rect_partition_hits() - parts_before; |
| 10730 | 10739 | let tus = decode::rect_coeff_tu_hits() - tus_before; |
| 10740 | + // The ENCODE's frame count: the fixture renders `mandelbrot=size=64x64:rate=25` | |
| 10741 | + // with `-t "0.60"` (10677-10691) -- 25 x 0.60 = 15 frames -- and the | |
| 10742 | + // caller's `args` carry no `--limit` (10823-10853), so every arm's stream | |
| 10743 | + // codes all 15. Asserted ABOVE the oracle call, which is the fix for the | |
| 10744 | + // misattribution this gate's own doc comment records: the | |
| 10745 | + // `--enable-tx-size-search=0` arm is a stream ffmpeg cannot decode past | |
| 10746 | + // frame 6 of 15, and with the count taken from our decode the helper's | |
| 10747 | + // byte-length assert fires FIRST and reads as an ffmpeg fault. Naming the | |
| 10748 | + // 15 here makes the shortfall ours to explain. | |
| 10749 | + const ENCODED_FRAMES: usize = 15; | |
| 10750 | + assert_eq!( | |
| 10751 | + decoded.len(), | |
| 10752 | + ENCODED_FRAMES, | |
| 10753 | + "{name}: the encode codes {ENCODED_FRAMES} frames, the decode showed {} (rect \ | |
| 10754 | + partitions {parts}, rect coefficient TUs {tus})", | |
| 10755 | + decoded.len() | |
| 10756 | + ); | |
| 10731 | 10757 | let reference = if ten_bit { |
| 10732 | 10758 | ffmpeg_decode_sequence_10bit(&stream, width, height, decoded.len()) |
| 10733 | 10759 | } else { |
| @@ -11208,12 +11234,18 @@ pub(crate) mod tests { | ||
| 11208 | 11234 | reconstruction is not ported, it must refuse by name" |
| 11209 | 11235 | ); |
| 11210 | 11236 | assert!(!frames.is_empty(), "{NAME}: {arm} decoded no frame"); |
| 11237 | + // The ENCODE's frame count, asserted ABOVE the oracle call: | |
| 11238 | + // the per-arm render (11100) uses `-t 0.2` at TS/SB's | |
| 11239 | + // `rate=25` (10987, 10988) -- 5 input frames -- and the aomenc | |
| 11240 | + // args carry `--limit=1` (11145), so all eight arms code | |
| 11241 | + // exactly 1 frame. The old comment below claimed a count | |
| 11242 | + // assert here would be tautological; that is true of | |
| 11243 | + // `ffmpeg_frames.len() == frames.len()` and false of this: | |
| 11244 | + // `frames.len() == 1` is a fact about the ENCODE, checked | |
| 11245 | + // before `frames.len()` is spent as ffmpeg's frame budget. | |
| 11246 | + assert_eq!(frames.len(), 1, "{NAME}: {arm} key frame"); | |
| 11211 | 11247 | let ffmpeg_frames = |
| 11212 | 11248 | ffmpeg_decode_sequence(&stream, width, height, frames.len()); |
| 11213 | - // No frame-count assert here: `ffmpeg_decode_sequence` was | |
| 11214 | - // handed `frames.len()` as its frame budget, so | |
| 11215 | - // `ffmpeg_frames.len() == frames.len()` holds by | |
| 11216 | - // construction and the assert was tautological. | |
| 11217 | 11249 | // EVERY frame is compared; an arm whose decode never hit an |
| 11218 | 11250 | // intrabc block proves nothing about the DV/prediction path, |
| 11219 | 11251 | // so it is counted OUT OF SCOPE -- but a mismatch there is |
| @@ -11380,8 +11412,14 @@ pub(crate) mod tests { | ||
| 11380 | 11412 | crate::decode::rect4_16_intrabc_hits() > 0, |
| 11381 | 11413 | "{NAME}: no 16x4/4x16 intrabc strip -- the pair body was not reached" |
| 11382 | 11414 | ); |
| 11415 | + // The ENCODE's frame count, asserted ABOVE the oracle call: the y4m is | |
| 11416 | + // rendered with `-frames:v 1` (11333) -- a single frame of | |
| 11417 | + // `testsrc2=s=640x480:r=25` -- and aomenc runs with | |
| 11418 | + // `--limit=1 --kf-max-dist=1` (11355, 11356), so the stream codes | |
| 11419 | + // exactly 1 key frame. Below the call this assert could not fire | |
| 11420 | + // first: `ffmpeg_decode_sequence` was already handed `frames.len()`. | |
| 11421 | + assert_eq!(frames.len(), 1, "{NAME}: expected one key frame"); | |
| 11383 | 11422 | let refs = ffmpeg_decode_sequence(&out.stdout, width, height, frames.len()); |
| 11384 | - assert_eq!(frames.len(), 1); | |
| 11385 | 11423 | assert_eq!(frames[0].y, refs[0].y, "{NAME}: luma"); |
| 11386 | 11424 | assert_eq!(frames[0].u, refs[0].u, "{NAME}: u"); |
| 11387 | 11425 | assert_eq!(frames[0].v, refs[0].v, "{NAME}: v"); |
| @@ -11452,6 +11490,13 @@ pub(crate) mod tests { | ||
| 11452 | 11490 | crate::decode::rect4_16_lossless_chroma_hits() > 0, |
| 11453 | 11491 | "{NAME}: no lossless 16x4/4x16 chroma pair -- the walk was not reached" |
| 11454 | 11492 | ); |
| 11493 | + // The ENCODE's frame count: the y4m is rendered with `-frames:v 1` | |
| 11494 | + // (11414) -- a single frame of `testsrc2=s=320x240:r=25` -- and aomenc | |
| 11495 | + // runs with `--limit=1 --kf-max-dist=1` (11434, 11435), so the stream | |
| 11496 | + // codes exactly 1 lossless key frame. Asserted ABOVE the oracle call: | |
| 11497 | + // this gate then indexes `frames[0]`/`refs[0]`, which a zero-frame | |
| 11498 | + // decode would panic on rather than report. | |
| 11499 | + assert_eq!(frames.len(), 1, "{NAME}: expected one lossless key frame"); | |
| 11455 | 11500 | let refs = ffmpeg_decode_sequence(&out.stdout, width, height, frames.len()); |
| 11456 | 11501 | let repaired = 128 * width; |
| 11457 | 11502 | assert_eq!( |