forge
Explore
Log in

Don't you dare go Hollow

Merge lane-film10fix: the two 'pre-existing 10-bit film' divergences are ALREADY EXACT (report + two controls)

Browse files at this commit

60a01163c4adde0b3c45fc2a02e5ce118b7d0e8aAhmet Kaan GümüşParent: 7430eb4e2357b9
Both charter-named cases measure 0 wrong on every plane on main: reelc_sb128_inter_witness.obu
(177773 B, sha256 09d99594...) with 15 shown frames and 13/13 counters firing (warp_plane_suppress=15,
cdef_idx=852, interintra_rect=118, obmc_edge_span=33, tr_reach_longer_side=600 ...), and
gm_small_side_witness.obu (1158066 B, sha256 f1cdbcbb...) with 33 shown frames and 3/3 counters
(gm_nontrans_small_side=1, tr_reach_longer_side=2295, uv_mode_grid_override=138). Both are also
byte-exact against the instrumented aomdec on ALL 50 decode-order frames, including the one hidden
frame each. The debt line was STALE: no lane report defers these to a '10-bit film round' -- the
nearest record (lanes/av1444.report.md:251-269) says they FAILED at 1ad7e0fc/b9530604, were attributed
to that lane's own record_uv_mode_mi change and were fixed there.
Lands two controls the previous audit left as read-only: every_ffmpeg_comparator_reds_on_a_one_sample_wrong_ffmpeg
(7 arms -- a PATH shim running the REAL ffmpeg and rotating one sample per plane, so the helpers are
red on Y, U and V separately and a chroma-dropping helper cannot pass a luma-only arm; the ffmpeg half
is exactly what both film gates rest on) and
the_two_10bit_film_pins_match_aomdec_on_every_decode_order_frame.
Report hygiene: the lane's JSON quoted tip sha 9944fa1b9c1c0b2e6b7e5b1e8f3d2a4c6b8e0f12, which does
not exist -- the real tip is 9944fa1bd6cbf0c5906ad3f7eeeae5e4b3a09ba7 (correct prefix, invented tail).
The other full shas quoted by lanes this wave were each verified to exist.
crates/ec-av1/src/stream.rsmodified+481 -9
@@ -5797,7 +5797,7 @@ pub(crate) mod tests {
5797 frames: usize,5797 frames: usize,
5798 ) -> Vec<Pic> {5798 ) -> Vec<Pic> {
5799 let out = run_with_stdin(5799 let out = run_with_stdin(
5800- Command::new("ffmpeg").args([5800+ Command::new(ffmpeg_path()).args([
5801 "-v", "error", "-f", "obu", "-i", "-", "-f", "rawvideo", "-pix_fmt", "yuv420p", "-",5801 "-v", "error", "-f", "obu", "-i", "-", "-f", "rawvideo", "-pix_fmt", "yuv420p", "-",
5802 ]),5802 ]),
5803 stream,5803 stream,
@@ -5857,7 +5857,7 @@ pub(crate) mod tests {
5857 frames: usize,5857 frames: usize,
5858 ) -> Vec<u8> {5858 ) -> Vec<u8> {
5859 let out = run_with_stdin(5859 let out = run_with_stdin(
5860- Command::new("ffmpeg").args([5860+ Command::new(ffmpeg_path()).args([
5861 "-v", "error", "-f", "obu", "-i", "-", "-f", "rawvideo", "-pix_fmt", "gray", "-",5861 "-v", "error", "-f", "obu", "-i", "-", "-f", "rawvideo", "-pix_fmt", "gray", "-",
5862 ]),5862 ]),
5863 stream,5863 stream,
@@ -5888,7 +5888,7 @@ pub(crate) mod tests {
5888 frames: usize,5888 frames: usize,
5889 ) -> Vec<Pic> {5889 ) -> Vec<Pic> {
5890 let out = run_with_stdin(5890 let out = run_with_stdin(
5891- Command::new("ffmpeg").args([5891+ Command::new(ffmpeg_path()).args([
5892 "-v",5892 "-v",
5893 "error",5893 "error",
5894 "-f",5894 "-f",
@@ -10221,6 +10221,33 @@ pub(crate) mod tests {
10221 ORACLE_PATH.with(|c| *c.borrow_mut() = path);10221 ORACLE_PATH.with(|c| *c.borrow_mut() = path);
10222 }10222 }
10223 10223
10224+ // lane-film10fix: this thread's ffmpeg override, set by
10225+ // `set_ffmpeg_path` and consulted by `ffmpeg_path` ahead of the bare
10226+ // name. Same shape and same reason as `ORACLE_PATH` above: the control
10227+ // test `every_ffmpeg_comparator_reds_on_a_one_sample_wrong_ffmpeg` has
10228+ // to hand the `ffmpeg_decode_sequence*` helpers a DELIBERATELY WRONG
10229+ // reference, and a process-global PATH edit would leak that wrong
10230+ // reference into every sibling test decoding on another thread. The
10231+ // crate denies `unsafe_code`, so `std::env::set_var` is not available
10232+ // either; a thread-local confines the tamper to the one thread.
10233+ thread_local! {
10234+ static FFMPEG_PATH: std::cell::RefCell<Option<std::path::PathBuf>> =
10235+ const { std::cell::RefCell::new(None) };
10236+ }
10237+
10238+ /// Points this thread's `ffmpeg_decode_sequence*` helpers at `path`.
10239+ /// `None` restores the real `ffmpeg` on PATH.
10240+ fn set_ffmpeg_path(path: Option<std::path::PathBuf>) {
10241+ FFMPEG_PATH.with(|c| *c.borrow_mut() = path);
10242+ }
10243+
10244+ /// The `ffmpeg` every reference helper in this module spawns.
10245+ fn ffmpeg_path() -> std::path::PathBuf {
10246+ if let Some(p) = FFMPEG_PATH.with(|c| c.borrow().clone()) {
10247+ return p;
10248+ }
10249+ std::path::PathBuf::from("ffmpeg")
10250+ }
10224 10251
10225 /// The instrumented `aomdec` beside the `aomenc` oracle10252 /// The instrumented `aomdec` beside the `aomenc` oracle
10226 /// (`scripts/build-aom-oracle.sh` + `scripts/instrument-aom-oracle.sh`).10253 /// (`scripts/build-aom-oracle.sh` + `scripts/instrument-aom-oracle.sh`).
@@ -10509,8 +10536,7 @@ pub(crate) mod tests {
10509 (1, 0),10536 (1, 0),
10510 "{NAME}: arm 1 expects one decode-order frame and no hidden frames"10537 "{NAME}: arm 1 expects one decode-order frame and no hidden frames"
10511 );10538 );
10512- let (wy, wu, wv, n, exact) =10539+ let (wy, wu, wv, n, exact) = count_rawvideo_diffs(&stream, "oracle-control-arm1-count")
10513- count_rawvideo_diffs(&stream, "oracle-control-arm1-count")
10514 .expect("arm 1: the two sides must be byte-comparable");10540 .expect("arm 1: the two sides must be byte-comparable");
10515 assert_eq!(10541 assert_eq!(
10516 (wy, wu, wv),10542 (wy, wu, wv),
@@ -10545,7 +10571,10 @@ pub(crate) mod tests {
10545 // The real oracle's path rides in a sibling file rather than inside10571 // The real oracle's path rides in a sibling file rather than inside
10546 // the script, so a path with a quote or a space cannot mangle it and10572 // the script, so a path with a quote or a space cannot mangle it and
10547 // the script body needs no `format!` escaping at all.10573 // the script body needs no `format!` escaping at all.
10548- std::fs::write(dir.join("real-aomdec"), aomdec_path().as_os_str().as_encoded_bytes())10574+ std::fs::write(
10575+ dir.join("real-aomdec"),
10576+ aomdec_path().as_os_str().as_encoded_bytes(),
10577+ )
10549 .expect("recording the real oracle's path for the shim");10578 .expect("recording the real oracle's path for the shim");
10550 // Byte 7 of both the `--rawvideo` output and the `EC_AV1_FINAL_DUMP`10579 // Byte 7 of both the `--rawvideo` output and the `EC_AV1_FINAL_DUMP`
10551 // frame 0 is inside the Y plane, and its value is rotated by 128 so10580 // frame 0 is inside the Y plane, and its value is rotated by 128 so
@@ -10591,9 +10620,8 @@ exit 0
10591 let reds: [bool; 5];10620 let reds: [bool; 5];
10592 {10621 {
10593 set_oracle_path(Some(shim.clone()));10622 set_oracle_path(Some(shim.clone()));
10594- let panicked = |f: &dyn Fn()| {10623+ let panicked =
10595- std::panic::catch_unwind(std::panic::AssertUnwindSafe(f)).is_err()10624+ |f: &dyn Fn()| std::panic::catch_unwind(std::panic::AssertUnwindSafe(f)).is_err();
10596- };
10597 let rawvideo_red = panicked(&|| {10625 let rawvideo_red = panicked(&|| {
10598 let obu = std::env::temp_dir().join(format!("{NAME}-arm2.obu"));10626 let obu = std::env::temp_dir().join(format!("{NAME}-arm2.obu"));
10599 std::fs::write(&obu, &stream).expect("writing the pin for arm 2");10627 std::fs::write(&obu, &stream).expect("writing the pin for arm 2");
@@ -10651,6 +10679,397 @@ exit 0
10651 eprintln!("{NAME}: all five oracle comparators red on a one-byte-wrong oracle");10679 eprintln!("{NAME}: all five oracle comparators red on a one-byte-wrong oracle");
10652 }10680 }
10653 10681
10682+ /// lane-film10fix: the permanent CONTROL for the ffmpeg half of the class
10683+ /// `comparator-that-never-reads-the-oracle`.
10684+ ///
10685+ /// Its sibling above covers the five `aomdec` comparators. The `ffmpeg`
10686+ /// half had no such control, and it is the half the two 10-bit FILM gates
10687+ /// rest on: `a_10bit_128sb_film_frames_with_warp_cdef_and_interintra_...`
10688+ /// and `a_10bit_film_frames_with_small_side_globalmv_and_rect_warp_...`
10689+ /// both declare "pixel-exact" purely as
10690+ /// `assert_eq!(ours.<plane>, ffmpeg_decode_sequence_10bit(...).<plane>)`
10691+ /// over 15 and 33 shown frames. If `ffmpeg_decode_sequence_10bit` ever
10692+ /// stopped reading ffmpeg's stdout -- packed our own samples into the
10693+ /// buffer it returns, say -- both gates would report exact on a decoder
10694+ /// that could be arbitrarily wrong, and nothing in the crate would go
10695+ /// red. Reading the helper's source proves it is live TODAY; only a
10696+ /// deliberately wrong reference proves it can FAIL.
10697+ ///
10698+ /// So this is the same two-arm shape, pointed at ffmpeg. The shim runs the
10699+ /// REAL ffmpeg and then rotates ONE byte of its rawvideo stdout per
10700+ /// offset in a sibling file, leaving the stream, the geometry, the frame
10701+ /// count and every other sample a genuine decode. On a pin that IS
10702+ /// byte-exact against real ffmpeg:
10703+ ///
10704+ /// 1. **arm 1, real ffmpeg: every helper is GREEN.** Without this arm,
10705+ /// arm 2's red could just be a stream that was never exact.
10706+ /// 2. **arm 2, one-sample-wrong ffmpeg, PER PLANE: every helper is RED
10707+ /// and the red names the plane that was tampered with.** Three arms,
10708+ /// one per plane, because a helper that only ever compared luma would
10709+ /// pass the Y arm and fail U and V -- and a 10-bit film gate that
10710+ /// reported "exact" while ignoring chroma entirely would be exactly
10711+ /// the class this controls.
10712+ ///
10713+ /// The three helpers are the whole reference surface in this module:
10714+ /// `ffmpeg_decode_sequence` (4:2:0 8-bit), `ffmpeg_decode_gray_sequence`
10715+ /// (monochrome, one plane) and `ffmpeg_decode_sequence_10bit` (the
10716+ /// `yuv420p10le` family both film gates use). Each is driven on a pin it
10717+ /// is known to be exact against: the 8-bit `420_odd65x65_key.obu` for the
10718+ /// first, the same stream for the third's shape arithmetic, and the
10719+ /// monochrome recipe the mono gate already builds for the second. The
10720+ /// override is thread-local, so a red arm cannot leave a tampered ffmpeg
10721+ /// behind for a sibling test on another thread.
10722+ #[test]
10723+ fn every_ffmpeg_comparator_reds_on_a_one_sample_wrong_ffmpeg() {
10724+ const NAME: &str = "every_ffmpeg_comparator_reds_on_a_one_sample_wrong_ffmpeg";
10725+ if !have_ffmpeg() {
10726+ eprintln!("SKIP {NAME}: no ffmpeg");
10727+ return;
10728+ }
10729+ // Same mutex the oracle control takes: this test's shim is
10730+ // thread-local, but the SCREAM it produces must not interleave with a
10731+ // sibling's decode in the captured log.
10732+ let _gate_lock = lock_gate_counters();
10733+
10734+ // The 4:2:0 8-bit arm. It BUILDS its stream with the same
10735+ // `libaom-av1` lavfi recipe the mono gate below uses rather than
10736+ // pinning one: `ffmpeg_decode_sequence` derives its frame size as
10737+ // `w*h + 2*(w*h/4)`, which is only right for EVEN dimensions -- on a
10738+ // 65x65 stream 4:2:0 chroma is ceil(65/2)^2 = 1089, not 4225/4 =
10739+ // 1056, and the helper's length assert fires (loudly, by design --
10740+ // see `frame_count_diagnosis`). 320x240 keeps the offsets below
10741+ // exact: luma 76800 samples, chroma 160x120 = 19200 each.
10742+ let (w, h) = (320usize, 240usize);
10743+ let (ys, cs) = (w * h, (w / 2) * (h / 2));
10744+ assert_eq!(
10745+ (ys, cs),
10746+ (76800, 19200),
10747+ "{NAME}: the byte offsets in this test are computed from this geometry"
10748+ );
10749+ let build_8bit = {
10750+ let out = Command::new(ffmpeg_path())
10751+ .args([
10752+ "-v",
10753+ "error",
10754+ "-f",
10755+ "lavfi",
10756+ "-i",
10757+ "testsrc2=size=320x240:rate=30:duration=1",
10758+ "-pix_fmt",
10759+ "yuv420p",
10760+ "-c:v",
10761+ "libaom-av1",
10762+ "-cpu-used",
10763+ "8",
10764+ "-b:v",
10765+ "300k",
10766+ "-f",
10767+ "obu",
10768+ "-",
10769+ ])
10770+ .stdin(Stdio::null())
10771+ .stdout(Stdio::piped())
10772+ .stderr(Stdio::piped())
10773+ .output()
10774+ .expect("ffmpeg failed to build the 4:2:0 8-bit arm");
10775+ assert!(
10776+ out.status.success(),
10777+ "{NAME}: ffmpeg could not build the 8-bit arm: {}",
10778+ String::from_utf8_lossy(&out.stderr)
10779+ );
10780+ out.stdout
10781+ };
10782+ assert_eq!(
10783+ stream_bit_depth(&build_8bit, NAME),
10784+ 8,
10785+ "{NAME}: this arm is the 8-bit cell the byte offsets below are computed for"
10786+ );
10787+ let our_8bit =
10788+ decode_stream(&build_8bit).expect("the 8-bit arm must decode -- arm 1 needs it exact");
10789+ assert!(
10790+ !our_8bit.is_empty(),
10791+ "{NAME}: the 8-bit arm decoded nothing"
10792+ );
10793+ let frames_8bit = our_8bit.len();
10794+
10795+ // The monochrome recipe, byte-identical to the one
10796+ // `a_real_libaom_monochrome_key_frame_decodes_pixel_exact` builds, so
10797+ // the gray helper is driven on a stream that gate already proves
10798+ // exact. A MONOCHROME stream is also this test's 4:2:0 4:2:0-free
10799+ // arm: `ffmpeg_decode_gray_sequence` returns a flat luma buffer, so
10800+ // the one flipped offset must be attributed to Y and to nothing else.
10801+ let gray_stream = {
10802+ let out = Command::new(ffmpeg_path())
10803+ .args([
10804+ "-v",
10805+ "error",
10806+ "-f",
10807+ "lavfi",
10808+ "-i",
10809+ "testsrc2=size=64x64:rate=30:duration=1",
10810+ "-pix_fmt",
10811+ "gray",
10812+ "-c:v",
10813+ "libaom-av1",
10814+ "-cpu-used",
10815+ "8",
10816+ "-b:v",
10817+ "100k",
10818+ "-f",
10819+ "obu",
10820+ "-",
10821+ ])
10822+ .stdin(Stdio::null())
10823+ .stdout(Stdio::piped())
10824+ .stderr(Stdio::piped())
10825+ .output()
10826+ .expect("ffmpeg failed to build the monochrome arm");
10827+ assert!(
10828+ out.status.success(),
10829+ "{NAME}: ffmpeg could not build the monochrome arm: {}",
10830+ String::from_utf8_lossy(&out.stderr)
10831+ );
10832+ out.stdout
10833+ };
10834+ let our_gray = decode_stream(&gray_stream).expect("the monochrome arm must decode");
10835+ assert!(
10836+ !our_gray.is_empty(),
10837+ "{NAME}: the monochrome arm decoded nothing"
10838+ );
10839+ let frames_gray = our_gray.len();
10840+
10841+ // ---- the one-sample-wrong ffmpeg shim ---------------------------
10842+ let dir = std::env::temp_dir().join(format!("ec-av1-{NAME}-{}", std::process::id()));
10843+ let _ = std::fs::remove_dir_all(&dir);
10844+ std::fs::create_dir_all(&dir).expect("scratch dir");
10845+ // The real ffmpeg's path rides in a sibling file rather than inside
10846+ // the script, so a path with a space or a quote cannot mangle it and
10847+ // the script body needs no `format!` escaping.
10848+ let real = if let Some(p) = std::env::var_os("EC_AV1_FFMPEG") {
10849+ std::path::PathBuf::from(p)
10850+ } else {
10851+ let found = Command::new("ffmpeg")
10852+ .arg("-version")
10853+ .stdout(Stdio::null())
10854+ .stderr(Stdio::null())
10855+ .status()
10856+ .is_ok_and(|s| s.success());
10857+ assert!(found, "{NAME}: no working ffmpeg on PATH to wrap");
10858+ // Resolve the bare name through PATH so the shim does not depend
10859+ // on inheriting whatever PATH the test runner had.
10860+ let path = std::env::var_os("PATH").unwrap_or_default();
10861+ std::env::split_paths(&path)
10862+ .map(|d| d.join("ffmpeg"))
10863+ .find(|p| p.is_file())
10864+ .expect("{NAME}: ffmpeg is on PATH but not resolvable to a file")
10865+ };
10866+ std::fs::write(dir.join("real-ffmpeg"), real.as_os_str().as_encoded_bytes())
10867+ .expect("recording the real ffmpeg's path for the shim");
10868+ // Each line of `offsets` is one byte of the rawvideo stdout to rotate
10869+ // by 128, so the write always changes it. Everything else -- the
10870+ // stream, the geometry, the frame count, every other sample -- is a
10871+ // genuine ffmpeg decode. stdin is inherited so the shim is a drop-in
10872+ // for the helpers' `run_with_stdin` call.
10873+ let script = r#"#!/bin/sh
10874+REAL=$(cat "$(dirname "$0")/real-ffmpeg")
10875+OUT=$(mktemp)
10876+"$REAL" "$@" > "$OUT" || exit $?
10877+while read -r o; do
10878+ [ -n "$o" ] || continue
10879+ b=$(od -An -tu1 -j "$o" -N 1 "$OUT" 2>/dev/null | tr -d ' \n')
10880+ [ -n "$b" ] || continue
10881+ esc=$(printf '\\%03o' $(( (b + 128) % 256 )))
10882+ printf "$esc" | dd of="$OUT" bs=1 seek="$o" count=1 conv=notrunc 2>/dev/null
10883+done < "$(dirname "$0")/offsets"
10884+cat "$OUT"
10885+rm -f "$OUT"
10886+exit 0
10887+"#;
10888+ let shim = dir.join("one-sample-wrong-ffmpeg.sh");
10889+ std::fs::write(&shim, script).expect("writing the ffmpeg shim");
10890+ #[cfg(unix)]
10891+ {
10892+ use std::os::unix::fs::PermissionsExt;
10893+ std::fs::set_permissions(&shim, std::fs::Permissions::from_mode(0o755))
10894+ .expect("the ffmpeg shim must be executable");
10895+ }
10896+ let set_offsets = |bytes: &[usize]| {
10897+ let body: String = bytes
10898+ .iter()
10899+ .map(|b| format!("{b}\n"))
10900+ .collect::<Vec<_>>()
10901+ .concat();
10902+ std::fs::write(dir.join("offsets"), body).expect("writing the offsets file");
10903+ };
10904+ // A comparator that cannot report a difference is worse than none, so
10905+ // each arm is scored as a COUNT of differing samples, not as a panic.
10906+ let count8 = |theirs: &[Pic]| -> [usize; 3] {
10907+ let mut wrong = [0usize; 3];
10908+ for (plane, (x, y)) in [
10909+ (0usize, (&our_8bit[0].y, &theirs[0].y)),
10910+ (1, (&our_8bit[0].u, &theirs[0].u)),
10911+ (2, (&our_8bit[0].v, &theirs[0].v)),
10912+ ] {
10913+ wrong[plane] = x.iter().zip(y).filter(|(a, b)| a != b).count();
10914+ }
10915+ wrong
10916+ };
10917+
10918+ // The 10-bit FILM pin, and the comparator both charter-named film
10919+ // gates rest on. Driven on the real stream rather than a synthetic
10920+ // one: `ffmpeg_decode_sequence_10bit` is the only reference helper
10921+ // with a per-plane split, so it is the one that could silently lose a
10922+ // plane. 1920x792 at 10 bits: luma 1920*792*2 bytes per frame, chroma
10923+ // 960*396*2.
10924+ let film = std::fs::read(crate_pin("reelc_sb128_inter_witness.obu")).unwrap_or_else(|e| {
10925+ panic!(
10926+ "{NAME}: the 10-bit film pin reelc_sb128_inter_witness.obu is missing ({e}) -- \
10927+ restore the committed copy"
10928+ )
10929+ });
10930+ assert_eq!(
10931+ stream_bit_depth(&film, NAME),
10932+ 10,
10933+ "{NAME}: this arm is the 10-bit cell the byte offsets below are computed for"
10934+ );
10935+ let our_10bit =
10936+ decode_stream(&film).expect("the 10-bit film pin must decode -- arm 1 needs it exact");
10937+ let (fw, fh) = (1920usize, 792usize);
10938+ let film_frames = our_10bit.len();
10939+ let (fys, fcs) = (fw * fh * 2, (fw / 2) * (fh / 2) * 2);
10940+ let count10 = |theirs: &[Pic]| -> [usize; 3] {
10941+ let mut wrong = [0usize; 3];
10942+ for (a, b) in our_10bit.iter().zip(theirs) {
10943+ for (plane, (x, y)) in
10944+ [(0usize, (&a.y, &b.y)), (1, (&a.u, &b.u)), (2, (&a.v, &b.v))]
10945+ {
10946+ wrong[plane] += x.iter().zip(y).filter(|(p, q)| p != q).count();
10947+ }
10948+ }
10949+ wrong
10950+ };
10951+ let count_gray = |theirs: &[u8]| -> usize {
10952+ our_gray[0]
10953+ .y
10954+ .iter()
10955+ .zip(theirs)
10956+ .filter(|(a, b)| **a != u16::from(**b))
10957+ .count()
10958+ };
10959+
10960+ // ---- arm 1: the real ffmpeg, every comparator GREEN ------------
10961+ {
10962+ set_offsets(&[]);
10963+ set_ffmpeg_path(None);
10964+ let theirs = ffmpeg_decode_sequence(&build_8bit, w, h, frames_8bit);
10965+ assert_eq!(
10966+ count8(&theirs),
10967+ [0, 0, 0],
10968+ "{NAME}: arm 1 runs against the REAL ffmpeg, so every plane must be zero -- if \
10969+ this is red the stream is not the byte-exact pin this control needs"
10970+ );
10971+ let their_gray = ffmpeg_decode_gray_sequence(&gray_stream, 64, 64, frames_gray);
10972+ assert_eq!(
10973+ count_gray(&their_gray),
10974+ 0,
10975+ "{NAME}: arm 1's monochrome plane must be zero against the real ffmpeg"
10976+ );
10977+ // arm 1's 10-bit half: the film pin is byte-exact against real
10978+ // ffmpeg on every plane of every shown frame -- that is exactly
10979+ // what `a_10bit_128sb_film_frames_with_warp_cdef_and_interintra_...`
10980+ // asserts -- so this is the cell the two charter-named film gates
10981+ // claim.
10982+ let their_10bit = ffmpeg_decode_sequence_10bit(&film, fw, fh, film_frames);
10983+ assert_eq!(
10984+ count10(&their_10bit),
10985+ [0, 0, 0],
10986+ "{NAME}: arm 1's 10-bit film pin must be zero on every plane against the real \
10987+ ffmpeg -- if this is red the control's pin is not the byte-exact stream it needs"
10988+ );
10989+ }
10990+
10991+ // ---- arm 2: one sample wrong, PER PLANE -------------------------
10992+ // The shim is thread-local, so the tampered reference is confined to
10993+ // this thread; it is cleared before anything is asserted, so a red arm
10994+ // cannot leave this test's own later work reading a wrong ffmpeg.
10995+ let mut blind: Vec<String> = Vec::new();
10996+ {
10997+ set_ffmpeg_path(Some(shim.clone()));
10998+ for (plane, (_name, base)) in [("Y", 0usize), ("U", ys), ("V", ys + cs)]
10999+ .into_iter()
11000+ .enumerate()
11001+ {
11002+ // Byte 1000 of the named plane: inside the 4:2:0 8-bit pin's
11003+ // luma (4225), inside its chroma (1024), or past both.
11004+ set_offsets(&[base + 1000]);
11005+ let theirs = ffmpeg_decode_sequence(&build_8bit, w, h, frames_8bit);
11006+ let got = count8(&theirs);
11007+ let want = [0usize, 0, 0];
11008+ let mut expected = want;
11009+ expected[plane] = 1;
11010+ if got != expected {
11011+ blind.push(format!(
11012+ "ffmpeg_decode_sequence {plane} arm: counted {got:?}, expected \
11013+ {expected:?} (exactly the one tampered sample)"
11014+ ));
11015+ }
11016+ }
11017+ // The 10-bit helper, per plane, on the 10-bit FILM pin. This is the
11018+ // arm that matters for the charter: both
11019+ // `a_10bit_128sb_film_frames_with_warp_cdef_and_interintra_...`
11020+ // and
11021+ // `a_10bit_film_frames_with_small_side_globalmv_and_rect_warp_...`
11022+ // declare "pixel-exact on every plane" using nothing but this
11023+ // helper's output. A helper that dropped U or V would leave both
11024+ // gates green while chroma went unchecked for 15 and 33 frames.
11025+ for (plane, (_name, base)) in [("Y", 0usize), ("U", fys), ("V", fys + fcs)]
11026+ .into_iter()
11027+ .enumerate()
11028+ {
11029+ // Sample 1000 of the named plane, two bytes per sample.
11030+ set_offsets(&[base + 2000]);
11031+ let theirs = ffmpeg_decode_sequence_10bit(&film, fw, fh, film_frames);
11032+ let got = count10(&theirs);
11033+ let mut expected = [0usize, 0, 0];
11034+ expected[plane] = 1;
11035+ if got != expected {
11036+ blind.push(format!(
11037+ "ffmpeg_decode_sequence_10bit {plane} arm: counted {got:?}, expected \
11038+ {expected:?} (exactly the one tampered sample)"
11039+ ));
11040+ }
11041+ }
11042+ // The monochrome helper: one plane, so the single flipped offset
11043+ // must show up as luma and nothing else can absorb it.
11044+ set_offsets(&[1000]);
11045+ let their_gray = ffmpeg_decode_gray_sequence(&gray_stream, 64, 64, frames_gray);
11046+ if count_gray(&their_gray) != 1 {
11047+ blind.push(format!(
11048+ "ffmpeg_decode_gray_sequence arm: counted {} differing luma samples, expected \
11049+ exactly 1",
11050+ count_gray(&their_gray)
11051+ ));
11052+ }
11053+ set_ffmpeg_path(None);
11054+ }
11055+ let _ = std::fs::remove_dir_all(&dir);
11056+ // One assert, naming EVERY helper that failed to notice: a partial run
11057+ // would report the first and hide whether the others are covered.
11058+ assert!(
11059+ blind.is_empty(),
11060+ "{NAME}: {} of 7 ffmpeg comparator arms stayed GREEN against an ffmpeg that is wrong \
11061+ by exactly one sample -- {blind:#?} -- they cannot fail, so their green proves \
11062+ nothing (class `comparator-that-never-reads-the-oracle`)",
11063+ blind.len()
11064+ );
11065+ eprintln!(
11066+ "{NAME}: ffmpeg_decode_sequence red on a one-sample-wrong Y, U and V separately; \
11067+ ffmpeg_decode_gray_sequence red on one wrong luma sample; \
11068+ ffmpeg_decode_sequence_10bit red on a one-sample-wrong Y, U and V of the 10-bit \
11069+ film pin"
11070+ );
11071+ }
11072+
10654 /// lane-av1422anom: the odd-frame-HEIGHT 4:2:0 reconstruction defect,11073 /// lane-av1422anom: the odd-frame-HEIGHT 4:2:0 reconstruction defect,
10655 /// pinned and ratcheted.11074 /// pinned and ratcheted.
10656 ///11075 ///
@@ -46437,6 +46856,59 @@ exit 0
46437 );46856 );
46438 }46857 }
46439 46858
46859+ /// lane-film10fix: the DECODE-ORDER half of the two charter-named 10-bit
46860+ /// film gates, against the instrumented `aomdec` rather than ffmpeg.
46861+ ///
46862+ /// `a_10bit_128sb_film_frames_with_warp_cdef_and_interintra_...` (15 shown
46863+ /// frames) and `a_10bit_film_frames_with_small_side_globalmv_and_rect_warp_...`
46864+ /// (33 shown) each hold exactly ONE hidden alt-ref frame, and both
46865+ /// compare through `ffmpeg_decode_sequence_10bit`, which emits SHOWN
46866+ /// frames only. So one frame in 16 and one in 34 of each stream is
46867+ /// outside both gates' reach -- class `gate-blind-to-hidden-frames`: a
46868+ /// defect in a hidden frame surfaces only as drift on some later shown
46869+ /// frame, if at all. Their doc comments claim the hidden frames were
46870+ /// compared byte-exact against aomdec, but that measurement lived in a
46871+ /// lane report, not in a test, so nothing re-ran it.
46872+ ///
46873+ /// This gate is that measurement, committed.
46874+ /// [`decode_all_frames_vs_oracle`] writes `EC_AV1_FINAL_DUMP` on both
46875+ /// sides (ours in `decode_stream`, the oracle's in rung 12 of
46876+ /// `scripts/instrument-aom-oracle.sh`) and byte-compares EVERY decode-order
46877+ /// frame, hidden included. Both fixtures are the same 1920x792 10-bit
46878+ /// films their own gates pin, at the sha256 those gates record.
46879+ ///
46880+ /// The frame counts are asserted, not just reported: 16 = 15 shown + 1
46881+ /// hidden, 34 = 33 shown + 1. A stream that quietly lost its hidden ARF
46882+ /// would make this compare fewer frames and would otherwise read as a
46883+ /// pass.
46884+ #[test]
46885+ fn the_two_10bit_film_pins_match_aomdec_on_every_decode_order_frame() {
46886+ const NAME: &str = "the_two_10bit_film_pins_match_aomdec_on_every_decode_order_frame";
46887+ let _gate_lock = lock_gate_counters();
46888+ if !aomdec_available(NAME) {
46889+ return;
46890+ }
46891+ for (pin, frames, shown) in [
46892+ ("reelc_sb128_inter_witness.obu", 16usize, 15usize),
46893+ ("gm_small_side_witness.obu", 34, 33),
46894+ ] {
46895+ let stream = std::fs::read(crate_pin(pin))
46896+ .unwrap_or_else(|e| panic!("{NAME}: reading {pin}: {e}"));
46897+ let (decoded, hidden) = decode_all_frames_vs_oracle(&stream, NAME);
46898+ assert_eq!(
46899+ (decoded, hidden),
46900+ (frames, frames - shown),
46901+ "{NAME}: {pin} must decode to {frames} decode-order frames of which {shown} are \
46902+ shown -- a stream that lost its hidden alt-ref would make the byte compare below \
46903+ cover less than it claims"
46904+ );
46905+ eprintln!(
46906+ "{NAME}: {pin} {decoded} decode-order frames ({hidden} hidden) byte-exact vs \
46907+ aomdec EC_AV1_FINAL_DUMP on every plane"
46908+ );
46909+ }
46910+ }
46911+
46440 /// lane-t900 r11: the frame-edge MV clamp witness.46912 /// lane-t900 r11: the frame-edge MV clamp witness.
46441 ///46913 ///
46442 /// `crates/ec-av1/fixtures/reelb_head_mvclamp_witness.obu` (72158 bytes,46914 /// `crates/ec-av1/fixtures/reelb_head_mvclamp_witness.obu` (72158 bytes,
lanes/film10fix.report.mdadded+196 -0
@@ -0,0 +1,196 @@
1+# lane-film10fix — the two "pre-existing 10-BIT FILM divergences": MEASURED, both already exact
2+
3+Branch `lane-film10fix`, base `main` = `3f08ae3f`.
4+
5+## 0. The charter's premise, measured first
6+
7+The ticket asked me to fix or narrow two divergences recorded as deferred to a
8+"dedicated 10-bit-film round": (1) a film sample with warp + CDEF + inter-intra,
9+(2) small-side globalmv. Per the ticket's own instruction I reproduced both on
10+current `main` before believing the debt line. **Both are already exact.** The
11+debt line is stale.
12+
13+There is no `lanes/` report that names a 10-bit-film deferral of these two
14+cases. The nearest match, `lanes/av1444.report.md:251-269`, records the
15+opposite: those two gates FAILED at `1ad7e0fc` and `b9530604` and were
16+attributed to that lane's own 4:4:4 `record_uv_mode_mi` change (class
17+`override-slot-on-one-arm`), then FIXED there. Six suite logs
18+(`lanes/dq-suite.log`, `fi-suite.log`, `libdet-suite.log`, `rdoq-suite.log`,
19+`sse-suite.log`, `tw-suite.log`, `tpl2/3-suite.log`, `i64/suite2.log`) carry
20+both gates as `... ok`.
21+
22+### Case 1 — warp + CDEF + inter-intra
23+`crates/ec-av1/fixtures/reelc_sb128_inter_witness.obu`, 177773 B,
24+sha256 `09d995946d27695ef4b7b1a24a4d7ad85f8e2c8176d58ee54e825efc061f9cbc`.
25+
26+```
27+$ cargo test -p ec-av1 --lib -- a_10bit_128sb_film_frames_with_warp_cdef_and_interintra_decode_pixel_exact --nocapture --test-threads=1
28+a_10bit_128sb_film_frames_with_warp_cdef_and_interintra_decode_pixel_exact:
29+ 15 shown frames pixel-exact on every plane; warp_plane_suppress=15
30+ cdef_idx=852 inter_sb128_vert=76 interintra_rect=118
31+ non_chroma_ref_ctx_skip=194 intra_in_inter_txctx=3787 edge_filter_mi_fix=206
32+ intra16x4_in_inter=(80, 163, 113) sub8_chroma_tx_from_ref=2
33+ inter_neighbour_not_smooth=370 tr_reach_longer_side=600 obmc_edge_span=33
34+test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 780 filtered out; finished in 8.44s
35+```
36+
37+All 13 path counters fire (every one `assert!(n > 0)` in the gate), so this is
38+not a gate that passes by not reaching the code.
39+
40+### Case 2 — small-side globalmv
41+`crates/ec-av1/fixtures/gm_small_side_witness.obu`, 1158066 B,
42+sha256 `f1cdbcbb8d6d469c7957d70252ab42b24ab75f48a717600ffa25991458775dca`.
43+
44+```
45+$ cargo test -p ec-av1 --lib -- a_10bit_film_frames_with_small_side_globalmv_and_rect_warp_reach_decode_pixel_exact --nocapture --test-threads=1
46+a_10bit_film_frames_with_small_side_globalmv_and_rect_warp_reach_decode_pixel_exact:
47+ 33 shown frames pixel-exact on every plane; gm_nontrans_small_side=1
48+ tr_reach_longer_side=2295 uv_mode_grid_override=138
49+test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 780 filtered out; finished in 21.33s
50+```
51+
52+### Against `aomdec` too, on ALL decode-order frames
53+Both gates compare SHOWN frames only (ffmpeg emits shown frames only), so 1 of
54+16 and 1 of 34 decode-order frames per stream sit outside both gates — class
55+`gate-blind-to-hidden-frames`. Measured against the instrumented oracle's
56+`EC_AV1_FINAL_DUMP` (rung 12):
57+
58+```
59+reelc_sb128_inter_witness.obu: 16 decode-order frames (1 hidden) byte-exact vs aomdec
60+gm_small_side_witness.obu: 34 decode-order frames (1 hidden) byte-exact vs aomdec
61+```
62+
63+**0 wrong on all three planes, all 50 decode-order frames, both cells.** No
64+PREFILT/POSTDEBLOCK/POSTCDEF/FINAL stage ladder was needed: there is no
65+divergence to localize, so no stage is suspect and none is exonerated by
66+comparison. Naming a mechanism and a libaom file:line here would be fabrication.
67+
68+## 1. Non-vacuity control (the batch rule)
69+
70+A green comparator is a measurement only if it can go red. Both film gates
71+declare "pixel-exact on every plane" using nothing but
72+`ffmpeg_decode_sequence_10bit`'s output — a helper that stopped reading
73+ffmpeg's stdout would leave both green on a decoder that could be arbitrarily
74+wrong.
75+
76+**Measured with a PATH-level shim that runs the REAL ffmpeg and rotates exactly
77+one byte of its rawvideo stdout** (per plane, sample 1000; 1920x792 10-bit
78+frame = luma 3041280 B + chroma 760320 B, so byte 2000 / 3043280 / 3803600):
79+
80+| case | arm | result |
81+|---|---|---|
82+| warp+cdef+interintra | byte 2000 (Y) | `FAILED … frame 0 luma vs ffmpeg` |
83+| warp+cdef+interintra | byte 3043280 (U) | `FAILED … frame 0 U vs ffmpeg` |
84+| warp+cdef+interintra | byte 3803600 (V) | `FAILED … frame 0 V vs ffmpeg` |
85+| small-side globalmv | byte 2000 (Y) | `FAILED … frame 0 luma vs ffmpeg` |
86+| small-side globalmv | byte 3043280 (U) | `FAILED … frame 0 U vs ffmpeg` |
87+| small-side globalmv | byte 3803600 (V) | `FAILED … frame 0 V vs ffmpeg` |
88+
89+Six of six red, each naming the plane that was tampered with. The comparators
90+read the oracle.
91+
92+## 2. What I found instead, and committed
93+
94+Two real gaps, both closed.
95+
96+### 2a. The ffmpeg comparator family had NO committed control
97+
98+`every_oracle_comparator_reds_on_a_one_byte_wrong_oracle` (lane-av1cmpaudit2,
99+`3f08ae3f`) controls the five `aomdec` comparators. The `ffmpeg` half — the
100+half both charter-named film gates rest on — was audited **by reading only**
101+(`lanes/av1cmpaudit2.report.md:48-52`: "all reach ffmpeg through a real
102+`Command::output()` and compare the stdout — LIVE"). Reading proves it is live
103+today; only a deliberately wrong reference proves it can FAIL.
104+
105+New gate **`every_ffmpeg_comparator_reds_on_a_one_sample_wrong_ffmpeg`**
106+(`crates/ec-av1/src/stream.rs`), 7 arms:
107+
108+- `set_ffmpeg_path` / `ffmpeg_path()` — a THREAD-LOCAL ffmpeg override, same
109+ shape and same reason as the existing `set_oracle_path`: a process-global
110+ PATH edit would leak the tampered reference into every sibling test on
111+ another thread, and the crate denies `unsafe_code` so `set_var` is out.
112+- arm 1, real ffmpeg: 4:2:0 8-bit (320x240), monochrome (64x64 gray) and the
113+ 10-bit film pin (1920x792) all count `[0, 0, 0]` / `0`. Without this arm,
114+ arm 2's red could just be a stream that was never exact.
115+- arm 2, one sample wrong **per plane**: `ffmpeg_decode_sequence` red on Y,
116+ U and V separately; `ffmpeg_decode_gray_sequence` red on one luma sample;
117+ `ffmpeg_decode_sequence_10bit` red on Y, U and V separately **of the 10-bit
118+ film pin** — the comparator both charter-named gates use. Per-plane arms, not
119+ one: a helper that dropped chroma would pass a luma-only arm and leave both
120+ film gates green with chroma unchecked for 15 and 33 frames.
121+- All three reference helpers now spawn through the override.
122+
123+Mutation proofs (both reverted before commit):
124+
125+1. Revert `ffmpeg_decode_sequence` to the bare `"ffmpeg"` (the override no
126+ longer reaches it) → `3 of 7 ffmpeg comparator arms stayed GREEN …
127+ counted [0, 0, 0], expected [1, 0, 0]`, `test result: FAILED`.
128+2. Make `ffmpeg_decode_sequence_10bit` return zeros for V instead of ffmpeg's
129+ samples → `arm 1's 10-bit film pin must be zero on every plane …
130+ left: [0, 0, 5702400], right: [0, 0, 0]`, `test result: FAILED`. That is
131+ the retracted `av1422remeasure` defect reproduced inside the 10-bit helper.
132+
133+### 2b. The hidden alt-ref frame of each film stream was outside every gate
134+
135+Both film gates' doc comments claim their hidden frames were compared
136+byte-exact against aomdec, but that measurement lived in a lane report
137+(`t900-r7`, `t900-r10`), not in a test, so nothing re-ran it. New gate
138+**`the_two_10bit_film_pins_match_aomdec_on_every_decode_order_frame`** runs
139+`decode_all_frames_vs_oracle` on both pins and asserts the frame COUNTS
140+(16 = 15 shown + 1 hidden, 34 = 33 + 1) before the byte compare, so a stream
141+that quietly lost its hidden ARF cannot make the compare cover less than it
142+claims.
143+
144+Mutation proof (reverted before commit): one byte wrong in our own
145+`EC_AV1_FINAL_DUMP` write →
146+
147+```
148+decode-order frame 0 of 16 (15 shown, 1 hidden) differs from the oracle at
149+byte 7 (ours 128 vs 0), 1 bytes differ
150+test result: FAILED
151+```
152+
153+## 3. Sweep
154+
155+Re-ran, on this branch, `EC_AV1_REQUIRE_AOMDEC=1 EC_AV1_REQUIRE_AOMENC=1
156+EC_AV1_REQUIRE_FIXTURES=1 EC_NOMEMGUARD=1`:
157+
158+| cell | result |
159+|---|---|
160+| `a_10bit_128sb_film_frames_with_warp_cdef_and_interintra_...` | ok, 15 frames, 13/13 counters fire |
161+| `a_10bit_film_frames_with_small_side_globalmv_and_rect_warp_...` | ok, 33 frames, 3/3 counters fire |
162+| `a_10bit_film_frames_with_frame_edge_mv_clamping_...` | ok, 52 frames, mv_clamp_edge_overhang=5 |
163+| `a_10bit_film_frames_with_rect64_corner_tus_...` | ok, 33 frames, 64x32=148 32x64=123 |
164+| `a_10bit_film_hidden_arf_with_split_superblock_strips_...` | ok, 37 frames, rect64_split_txfm_publish=4 |
165+| `a_10bit_film_inter_frame_with_intra_1to4_strips_...` | ok, 127 strips, shown frame exact |
166+| `a_real_aomenc_10bit_film_grain_stream_...` | ok, grain_hits=1 |
167+| `the_two_10bit_film_pins_match_aomdec_on_every_decode_order_frame` (new) | ok, 16 + 34 decode-order frames |
168+| `every_ffmpeg_comparator_reds_on_a_one_sample_wrong_ffmpeg` (new) | ok, 7/7 arms red |
169+| `every_oracle_comparator_reds_on_a_one_byte_wrong_oracle` | ok, 5/5 comparators red |
170+| `a_real_libaom_monochrome_key_frame_...` (the gray arm's pin) | ok |
171+
172+`cargo check -p ec-av1 --all-targets`: 0 errors, 0 warnings.
173+
174+No 10-bit cell regressed. Nothing outside `crates/ec-av1/src/stream.rs` is
175+touched, so no other crate's gates are affected.
176+
177+## 4. not_done
178+
179+- **The 4:2:0 8-bit reference helper cannot be driven on an ODD-dimension
180+ stream.** `ffmpeg_decode_sequence` derives its frame size as `w*h + 2*(w*h/4)`,
181+ which is wrong for odd dimensions: 4:2:0 chroma on 65x65 is
182+ `ceil(65/2)^2 = 1089`, not `4225/4 = 1056`. Measured: it fails LOUDLY
183+ (`FRAME COUNT MISMATCH (4:2:0 65x65) … 6403 bytes, 66 byte(s) not a whole
184+ frame, at 6337 B/frame`), which is the designed behaviour of
185+ `frame_count_diagnosis` — not a silent wrong answer — so nothing is
186+ mis-gated. Left alone: out of charter, and the loud failure is the correct
187+ behaviour. Unblocked by a lane that teaches the helper
188+ `((w+1)/2)*((h+1)/2)`. My control uses 320x240 for this reason and says so.
189+- **No full suite run.** Per the batch rule, project-wide validation is Main's
190+ job. My sweep is the 11 cells above.
191+- **The 10-bit `aomdec` per-plane WRONG-SAMPLE COUNTS are 0 by whole-buffer
192+ byte equality**, not by a counting comparator: `decode_all_frames_vs_oracle`
193+ panics at the first differing byte. A per-plane count on a 10-bit cell would
194+ need a 10-bit arm of `count_rawvideo_diffs`; the zero here is "0 differing
195+ bytes across all 50 frames on all three planes", which is stronger than a
196+ count but is not a count.