forge
Explore
Log in

Don't you dare go Hollow

Give pinned_lr_sgr the pixel asserts it lacked, and un-ignore it

Browse files at this commit

0777cd0bfa391cc84a0fa63f8dea6640d5726ab9Ahmet Kaan GümüşParent: 9ca92c7
  • test
    • give pinned_lr_sgr the pixel asserts it lacked, and un-ignore it
Show full message
test(av1): give pinned_lr_sgr the pixel asserts it lacked, and un-ignore it

r3 left this gate `#[ignore]`d on a FACT, not a judgement: its body `eprintln!`d
per-frame mismatch flags and returned, so it could not go red on a decode
regression. That is now fixed and the ignore is gone.

THE SUBSTANTIVE FIX is the frame count, not the asserts. The old body passed
OUR OWN decode's length as ffmpeg's expected count:

    let reference = ffmpeg_decode_sequence(&stream, 192, 128, pics.len());

so a decoder that emitted ZERO frames asked ffmpeg for zero frames, the zip
compared no pairs, and the gate passed having proved nothing -- the exact
vacuous-pass shape `cmpaudit` swept elsewhere in this crate. The count now comes
from the FIXTURE (`FRAMES = 1`, measured), so a lost frame reds on the count.

Also added, matching the three sibling pins: a dimensions assert per frame, an
explicit `reference.len() == FRAMES` before the zip, and per-plane per-frame
pixel asserts. The diagnostic print is KEPT and now runs BEFORE the asserts, so a
failure still names the shape of the divergence.

On "does it compare only frame 0": it does not, and the loop is unchanged in
that respect -- it always visited every frame. This pin simply holds ONE frame,
which is why the pre-r4 run printed `frame 0` and nothing else.

RED-BEFORE, on a PIXEL assertion, by mutating the decoder arithmetic the pin
exercises -- `restoration.rs::apply_sgrproj_stripe`, +1 on its first output
sample:

  frame 0: y_mismatch=false u_mismatch=true v_mismatch=true
  panicked at stream.rs:30374: assertion `left == right` failed:
    pinned_lr_sgr_stream_call_unique_dump frame 0 U vs ffmpeg (pinned lr-sgr)
  test result: FAILED. 0 passed; 1 failed

Worth stating: the mutation landed in a CHROMA plane, so the gate caught it on
the U assert while luma stayed clean. A luma-only compare would have missed it.
Reverted (restoration.rs is clean) and the gate returns green.

The count assert is proven separately: `FRAMES = 2` reds at stream.rs:30328
with "decoded 1 frame(s), the pinned stream holds 2 -- a short decode would
otherwise ask ffmpeg for the same short count and compare nothing", not on a
pixel.

Plain run (no `--ignored`): 1 passed; 0 failed; 0 ignored; 0 measured; 0.10s,
printing "1 frame(s) byte-exact vs ffmpeg from .../crates/ec-av1/fixtures/
lr-sgr-r7.obu". The ignore was never justified by cost -- it was 0.10 s under
`--ignored` too.

`#[ignore]` in stream.rs 37 -> 36. gate_coverage 10 passed, refusal_inventory
15 passed. Tests only, no decoder change (the sgrproj mutation was reverted
before this commit; `git status` on restoration.rs is empty).
crates/ec-av1/src/stream.rsmodified+70 -15
@@ -30290,27 +30290,67 @@ pub(crate) mod tests {
30290 /// `EC_LR_CALL_DUMP=1` set (see `restoration.rs`'s `apply_sgrproj_stripe`)30290 /// `EC_LR_CALL_DUMP=1` set (see `restoration.rs`'s `apply_sgrproj_stripe`)
30291 /// to get the real window on stderr, call-uniquely keyed to `xqd ==30291 /// to get the real window on stderr, call-uniquely keyed to `xqd ==
30292 /// [-16,-32]` rather than any coordinate.30292 /// [-16,-32]` rather than any coordinate.
30293+ /// lane-av1pinslive r4: this gate asserted NOTHING. It `eprintln!`d per-frame
30294+ /// mismatch flags and returned, so it could not go red on a decode regression
30295+ /// -- which is why r3 left it `#[ignore]`d on that fact rather than un-ignoring
30296+ /// it. It now carries the same three things its three siblings have: a pinned
30297+ /// FRAME COUNT, a length assert before the zip, and per-plane per-frame pixel
30298+ /// asserts. The diagnostic print is kept, and now runs BEFORE the asserts so a
30299+ /// failure still names the shape of the divergence.
30300+ ///
30301+ /// The frame count is the substantive fix. The old body passed `pics.len()` as
30302+ /// ffmpeg's EXPECTED count:
30303+ /// let reference = ffmpeg_decode_sequence(&stream, 192, 128, pics.len());
30304+ /// so a decoder that emitted ZERO frames asked ffmpeg for zero frames, the zip
30305+ /// compared no pairs, and the gate passed having proved nothing -- the exact
30306+ /// vacuous-pass shape the `cmpaudit` lane swept elsewhere in this crate. The
30307+ /// count now comes from the FIXTURE (`FRAMES`), so losing the frame reds on the
30308+ /// count instead of comparing nothing.
30309+ ///
30310+ /// On "does it compare only frame 0": the loop always visited every frame; this
30311+ /// pin simply holds one (`frame 0` was the only line the pre-r4 run printed).
30312+ /// The loop is unchanged in that respect and still visits every frame it gets.
30313+ ///
30314+ /// The `EC_LR_CALL_DUMP=1` window is unchanged and still needs that env -- but
30315+ /// it is a debugging session layered on a real gate now, not the gate itself.
30293 #[test]30316 #[test]
30294- // Stays `#[ignore]`d, and here are FACTS, not a judgement: (1) this gate
30295- // asserts NOTHING -- it `eprintln!`s per-frame mismatch counts and returns,
30296- // so it cannot go red on a decode regression and un-ignoring it would add a
30297- // test that reports pass unconditionally; (2) its bytes ARE now committed
30298- // at `crates/ec-av1/fixtures/lr-sgr-r7.obu` (192 bytes; sha256
30299- // `6b95b20e3377430ffae0b2ce86fad9502e0dedf13cd6c38ab7f5af4a8b21f33d`,
30300- // recovered byte-for-byte from the runner library), so the old "reads a
30301- // pinned fixture under the gitignored fixtures dir" reason is false; (3) it
30302- // yields a window only with `EC_LR_CALL_DUMP=1`, a debugging session rather
30303- // than a suite run. What would close it: give it the pixel asserts its
30304- // siblings have, then un-ignore.
30305- #[ignore = "diagnostic only -- asserts nothing, so it cannot fail on a decode regression; run with --ignored and EC_LR_CALL_DUMP=1 for the Sgrproj window"]
30306 fn pinned_lr_sgr_stream_call_unique_dump() {30317 fn pinned_lr_sgr_stream_call_unique_dump() {
30318+ const NAME: &str = "pinned_lr_sgr_stream_call_unique_dump";
30319+ const W: usize = 192;
30320+ const H: usize = 128;
30321+ /// Measured: the pre-r4 run printed `frame 0` and no other frame line.
30322+ const FRAMES: usize = 1;
30307 let path = std::env::var("EC_AV1_GATE_DUMP_PIN")30323 let path = std::env::var("EC_AV1_GATE_DUMP_PIN")
30308 .map(std::path::PathBuf::from)30324 .map(std::path::PathBuf::from)
30309 .unwrap_or_else(|_| crate_pin("lr-sgr-r7.obu"));30325 .unwrap_or_else(|_| crate_pin("lr-sgr-r7.obu"));
30310 let stream = require_pin(&path, "lr-sgr-r7.obu");30326 let stream = require_pin(&path, "lr-sgr-r7.obu");
30311 let pics = decode_stream(&stream).expect("pinned lr-sgr-r7.obu must decode");30327 let pics = decode_stream(&stream).expect("pinned lr-sgr-r7.obu must decode");
30312- if have_ffmpeg() {30328+ assert_eq!(
30313- let reference = ffmpeg_decode_sequence(&stream, 192, 128, pics.len());30329+ pics.len(),
30330+ FRAMES,
30331+ "{NAME}: decoded {} frame(s), the pinned stream holds {FRAMES} -- a short \
30332+ decode would otherwise ask ffmpeg for the same short count and compare \
30333+ nothing",
30334+ pics.len()
30335+ );
30336+ for f in &pics {
30337+ assert_eq!((f.width, f.height), (W, H), "{NAME}: dimensions");
30338+ }
30339+ if !have_ffmpeg() {
30340+ eprintln!(
30341+ "SKIP {NAME}: no ffmpeg -- the pixel compare IS this gate's claim, so it \
30342+ proves nothing here; set EC_AV1_REQUIRE_FFMPEG=1 to make that a hard \
30343+ failure instead"
30344+ );
30345+ return;
30346+ }
30347+ let reference = ffmpeg_decode_sequence(&stream, W, H, FRAMES);
30348+ assert_eq!(
30349+ reference.len(),
30350+ FRAMES,
30351+ "{NAME}: ffmpeg returned {} frame(s), expected {FRAMES}",
30352+ reference.len()
30353+ );
30314 for (i, (got, want)) in pics.iter().zip(&reference).enumerate() {30354 for (i, (got, want)) in pics.iter().zip(&reference).enumerate() {
30315 let y_mismatch = got.y != want.y;30355 let y_mismatch = got.y != want.y;
30316 let u_mismatch = got.u != want.u;30356 let u_mismatch = got.u != want.u;
@@ -30330,8 +30370,23 @@ pub(crate) mod tests {
30330 }30370 }
30331 }30371 }
30332 }30372 }
30373+ assert_eq!(
30374+ got.y, want.y,
30375+ "{NAME} frame {i} luma vs ffmpeg (pinned lr-sgr)"
30376+ );
30377+ assert_eq!(
30378+ got.u, want.u,
30379+ "{NAME} frame {i} U vs ffmpeg (pinned lr-sgr)"
30380+ );
30381+ assert_eq!(
30382+ got.v, want.v,
30383+ "{NAME} frame {i} V vs ffmpeg (pinned lr-sgr)"
30384+ );
30333 }30385 }
30334- }30386+ eprintln!(
30387+ "{NAME}: {FRAMES} frame(s) byte-exact vs ffmpeg from {}",
30388+ path.display()
30389+ );
30335 }30390 }
30336 30391
30337 /// lane-realworld r2: `read_cdef` (spec 5.11.56) ported -- per-superblock30392 /// lane-realworld r2: `read_cdef` (spec 5.11.56) ported -- per-superblock