forge
Explore
Log in

Don't you dare go Hollow

stream: pin the encode's frame count above 7 oracle calls (palette, rect-tx tool, screen intrabc, 16x4 pair)

Browse files at this commit

68670623fd50d29f73f1b9dc35c45cd57e35ff9dAhmet Kaan GümüşParent: d9e6745
These seven count sites handed ffmpeg_decode_sequence{,_10bit} the length of
OUR OWN decode as the oracle's expected frame count. A decode that showed
fewer frames therefore asked ffmpeg for the same short count, and the helper's
byte-length assert fired naming ffmpeg for a number our decoder chose. The
count is now asserted against the ENCODE -- '-frames:v 1', '-vframes 1',
'--limit=1', or 'rate=25 x -t 0.60' = 15 for rect_tx_tool_gate -- and that
assert sits ABOVE the call, so a dropped frame reds naming the encode.

Three of the seven already carried the literal but BELOW the call, where the
oracle had already been handed frames.len(); those are hoisted, not
duplicated. rect_tx_tool_gate is the one multi-frame site and the count is
named, since 15 comes from an arithmetic fact about the fixture
(rate 25 x -t 0.60) rather than from a flag someone typed.

count-vacuity sweep: 43 unpinned -> 36. The call still spends frames.len();
the assert above makes that value a spec, which is the shape the 17
already-pinned sites use, so the site population stays 60 and the class stays
enumerable.
crates/ec-av1/src/stream.rsmodified+50 -5
@@ -10502,6 +10502,15 @@ pub(crate) mod tests {
1050210502 match decoded {
1050310503 Ok(frames) => {
1050410504 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");
1050510514 let theirs = if depth == 10 {
1050610515 ffmpeg_decode_sequence_10bit(
1050710516 &stream,
@@ -10728,6 +10737,23 @@ pub(crate) mod tests {
1072810737 // report can still say whether the arm fired.
1072910738 let parts = decode::rect_partition_hits() - parts_before;
1073010739 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+ );
1073110757 let reference = if ten_bit {
1073210758 ffmpeg_decode_sequence_10bit(&stream, width, height, decoded.len())
1073310759 } else {
@@ -11208,12 +11234,18 @@ pub(crate) mod tests {
1120811234 reconstruction is not ported, it must refuse by name"
1120911235 );
1121011236 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");
1121111247 let ffmpeg_frames =
1121211248 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.
1121711249 // EVERY frame is compared; an arm whose decode never hit an
1121811250 // intrabc block proves nothing about the DV/prediction path,
1121911251 // so it is counted OUT OF SCOPE -- but a mismatch there is
@@ -11380,8 +11412,14 @@ pub(crate) mod tests {
1138011412 crate::decode::rect4_16_intrabc_hits() > 0,
1138111413 "{NAME}: no 16x4/4x16 intrabc strip -- the pair body was not reached"
1138211414 );
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");
1138311422 let refs = ffmpeg_decode_sequence(&out.stdout, width, height, frames.len());
11384- assert_eq!(frames.len(), 1);
1138511423 assert_eq!(frames[0].y, refs[0].y, "{NAME}: luma");
1138611424 assert_eq!(frames[0].u, refs[0].u, "{NAME}: u");
1138711425 assert_eq!(frames[0].v, refs[0].v, "{NAME}: v");
@@ -11452,6 +11490,13 @@ pub(crate) mod tests {
1145211490 crate::decode::rect4_16_lossless_chroma_hits() > 0,
1145311491 "{NAME}: no lossless 16x4/4x16 chroma pair -- the walk was not reached"
1145411492 );
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");
1145511500 let refs = ffmpeg_decode_sequence(&out.stdout, width, height, frames.len());
1145611501 let repaired = 128 * width;
1145711502 assert_eq!(