lane-av1llpredgate2: pin the debug-exact minp8 444 stream for the ss-aware chroma-above skip
Browse files at this commit16748dc81f1da1225dcbc6a4bf9bb8bc60ebd47fParent: 0db45d13 changed files +204 -0
- crates/ec-av1/fixtures/ll444_minp8_inter.obu +0 -0
- crates/ec-av1/src/stream.rs +117 -0
- lanes/av1llpredgate2.report.md +87 -0
crates/ec-av1/fixtures/ll444_minp8_inter.obuadded+0 -0
Binary file changed
crates/ec-av1/src/stream.rsmodified+117 -0
| @@ -5628,6 +5628,123 @@ pub(crate) mod tests { | ||
| 5628 | 5628 | } |
| 5629 | 5629 | } |
| 5630 | 5630 | |
| 5631 | + /// lane-av1llpredgate2: the debug-exact pin for the ss-aware | |
| 5632 | + /// `obmc_skip_chroma_above` decision (lane-av1-llpred2). Fixture is the | |
| 5633 | + /// llpred/llpred2 reports' stream pinned into `fixtures/`: testsrc2 | |
| 5634 | + /// 128x96 yuv444p, aomenc `--profile=1 --lossless=1 --enable-palette=0 | |
| 5635 | + /// --enable-intrabc=0 --min-partition-size=8 --max-partition-size=64`, | |
| 5636 | + /// 6 frames; 34037 bytes, sha256 | |
| 5637 | + /// `04fb6d38de5382e647bfb70b6a17802f1fccc5502e6698c0394167891f2b27dc`. | |
| 5638 | + /// | |
| 5639 | + /// This is a DEBUG-build path by construction: the old ratio-based ss | |
| 5640 | + /// derivation read `write_h >> trailing_zeros(0)` = `>> 64` on this | |
| 5641 | + /// stream's 4:4:4 OBMC rect strips, a panic ONLY under | |
| 5642 | + /// debug_assertions (release wraps and was already byte-exact), so | |
| 5643 | + /// `cargo test`'s default dev profile is the profile where the defect | |
| 5644 | + /// class reproduces and where the parent's byte-exact proof was | |
| 5645 | + /// measured. | |
| 5646 | + /// | |
| 5647 | + /// No skip-arm counter gate is possible on this stream, measured: | |
| 5648 | + /// OBMC runs 77 times with 20 rect leaves, but | |
| 5649 | + /// `obmc_skip_chroma_above` returns true 0 times -- at 4:4:4 the skip | |
| 5650 | + /// needs a 4x4/8x4/4x8 PLANE block and min-partition-8 never codes one. | |
| 5651 | + /// So per the lane ticket the proof splits in two: the decision TABLE | |
| 5652 | + /// (4:2:0 rect strips still skip, 4:4:4 shifts never leave `usize`) | |
| 5653 | + /// stays pinned by `decode::obmc_skip_chroma_tests:: | |
| 5654 | + /// rect_strips_skip_above_chroma_at_420_and_shift_never_overflows`, | |
| 5655 | + /// and THIS stream gate pins the end-to-end behaviour -- every sample | |
| 5656 | + /// of every frame must match the oracle aomdec exactly, so a returning | |
| 5657 | + /// chroma diff (the lane-av1-llpred ss-blind re-blend class | |
| 5658 | + /// `obmc-ss-blind-chroma-above`) or the debug shift panic goes red | |
| 5659 | + /// here by name. | |
| 5660 | + #[test] | |
| 5661 | + fn a_lossless_444_min_partition8_inter_stream_decodes_sample_exact() { | |
| 5662 | + const NAME: &str = "a_lossless_444_min_partition8_inter_stream_decodes_sample_exact"; | |
| 5663 | + const FIXTURE_LEN: usize = 34037; | |
| 5664 | + const FIXTURE_FNV: u64 = 0x2c8f_4a2c_c025_52da; | |
| 5665 | + const W: usize = 128; | |
| 5666 | + const H: usize = 96; | |
| 5667 | + const FRAMES: usize = 6; | |
| 5668 | + let obu = std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR")) | |
| 5669 | + .join("fixtures/ll444_minp8_inter.obu"); | |
| 5670 | + let stream = std::fs::read(&obu).unwrap_or_else(|e| { | |
| 5671 | + panic!( | |
| 5672 | + "{NAME}: pinned fixture {} is missing ({e}) -- the gate cannot run, \ | |
| 5673 | + which is a failure, not a skip", | |
| 5674 | + obu.display() | |
| 5675 | + ) | |
| 5676 | + }); | |
| 5677 | + assert_eq!(stream.len(), FIXTURE_LEN, "{NAME}: fixture length moved"); | |
| 5678 | + assert_eq!(fnv1a64(&stream), FIXTURE_FNV, "{NAME}: fixture bytes moved"); | |
| 5679 | + | |
| 5680 | + let _guard = lock_gate_counters(); | |
| 5681 | + let frames = decode_stream(&stream).unwrap_or_else(|e| { | |
| 5682 | + panic!("{NAME}: the pinned stream no longer decodes cleanly: {e}") | |
| 5683 | + }); | |
| 5684 | + assert_eq!(frames.len(), FRAMES, "{NAME}: frame count"); | |
| 5685 | + for f in &frames { | |
| 5686 | + assert_eq!((f.width, f.height), (W, H), "{NAME}: dimensions"); | |
| 5687 | + } | |
| 5688 | + | |
| 5689 | + // The oracle aomdec, rawvideo out: FRAMES concatenated yuv444p frames. | |
| 5690 | + if aomdec_path().is_file() { | |
| 5691 | + let dir = std::env::temp_dir().join(format!("ec-av1-llminp8-{}", std::process::id())); | |
| 5692 | + let _ = std::fs::remove_dir_all(&dir); | |
| 5693 | + std::fs::create_dir_all(&dir).expect("scratch dir"); | |
| 5694 | + let raw = dir.join("aomdec.raw"); | |
| 5695 | + let out = Command::new(aomdec_path()) | |
| 5696 | + .args(["--codec=av1", "--rawvideo", "-o"]) | |
| 5697 | + .arg(&raw) | |
| 5698 | + .arg(&obu) | |
| 5699 | + .stdin(Stdio::null()) | |
| 5700 | + .stdout(Stdio::piped()) | |
| 5701 | + .stderr(Stdio::piped()) | |
| 5702 | + .output() | |
| 5703 | + .expect("aomdec failed to run"); | |
| 5704 | + assert!( | |
| 5705 | + out.status.success(), | |
| 5706 | + "{NAME}: the oracle aomdec refused the stream: {}", | |
| 5707 | + String::from_utf8_lossy(&out.stderr) | |
| 5708 | + ); | |
| 5709 | + let ref_raw = std::fs::read(&raw).expect("aomdec rawvideo output"); | |
| 5710 | + let _ = std::fs::remove_dir_all(&dir); | |
| 5711 | + assert_eq!(ref_raw.len(), W * H * 3 * FRAMES, "{NAME}: aomdec raw size"); | |
| 5712 | + for (i, f) in frames.iter().enumerate() { | |
| 5713 | + let base = i * W * H * 3; | |
| 5714 | + for ((plane, off), p) in [(&f.y, 0usize), (&f.u, W * H), (&f.v, 2 * W * H)] | |
| 5715 | + .into_iter() | |
| 5716 | + .zip(["y", "u", "v"]) | |
| 5717 | + { | |
| 5718 | + let want = &ref_raw[base + off..base + off + W * H]; | |
| 5719 | + let bad = plane.iter().zip(want).filter(|&(&a, &b)| a as u8 != b).count(); | |
| 5720 | + assert_eq!( | |
| 5721 | + bad, 0, | |
| 5722 | + "{NAME}: aomdec frame {i} plane {p}: {bad} samples differ \ | |
| 5723 | + (class obmc-ss-blind-chroma-above)" | |
| 5724 | + ); | |
| 5725 | + } | |
| 5726 | + } | |
| 5727 | + } else { | |
| 5728 | + eprintln!("SKIP {NAME} aomdec arm: no oracle aomdec at {}", aomdec_path().display()); | |
| 5729 | + } | |
| 5730 | + | |
| 5731 | + // ffmpeg's decoder: same frames, full-resolution chroma. | |
| 5732 | + if have_ffmpeg() { | |
| 5733 | + let refs = ffmpeg_decode_sequence_444(&stream, W, H, FRAMES); | |
| 5734 | + for (i, (got, want)) in frames.iter().zip(refs.iter()).enumerate() { | |
| 5735 | + for (p, (g, r)) in [(&got.y, &want.y), (&got.u, &want.u), (&got.v, &want.v)] | |
| 5736 | + .iter() | |
| 5737 | + .enumerate() | |
| 5738 | + { | |
| 5739 | + let bad = g.iter().zip(r.iter()).filter(|(a, b)| a != b).count(); | |
| 5740 | + assert_eq!(bad, 0, "{NAME}: ffmpeg frame {i} plane {p}: {bad} samples differ"); | |
| 5741 | + } | |
| 5742 | + } | |
| 5743 | + } else { | |
| 5744 | + eprintln!("SKIP {NAME} ffmpeg arm: no ffmpeg"); | |
| 5745 | + } | |
| 5746 | + } | |
| 5747 | + | |
| 5631 | 5748 | /// lane-lossless128: a LOSSLESS key frame that codes a 128-axis |
| 5632 | 5749 | /// (`BLOCK_64X128`) intra block -- the shape libaom's `read_tx_size` forces |
| 5633 | 5750 | /// to `TX_4X4` on its very first line (`decodeframe.c:1183`), so every plane |
lanes/av1llpredgate2.report.mdadded+87 -0
| @@ -0,0 +1,87 @@ | ||
| 1 | +# lane-av1llpredgate2: pin the debug-exact 6-frame stream for the ss-aware `obmc_skip_chroma_above` fix | |
| 2 | + | |
| 3 | +Tree: lane-av1-llpredgate2 @ 041e3eae (the lane-av1-llpred2 fix, under | |
| 4 | +review — no code change landed here). This lane adds ONLY the regression | |
| 5 | +gate. | |
| 6 | + | |
| 7 | +## Regression gate | |
| 8 | + | |
| 9 | +`stream::tests::a_lossless_444_min_partition8_inter_stream_decodes_sample_exact` | |
| 10 | +(crates/ec-av1/src/stream.rs), modelled on | |
| 11 | +`a_lossless_444_min_partition64_inter_stream_decodes_pixel_exact`. | |
| 12 | + | |
| 13 | +### Fixture provenance | |
| 14 | + | |
| 15 | +- Origin: lanes/av1llpred.report.md / lanes/av1llpred2.report.md stream — | |
| 16 | + `testsrc2=size=128x96:rate=?` ffmpeg source, yuv444p, encoded by the | |
| 17 | + shared aomenc (`$HOME/.cache/aom-oracle/build`, pre-2026 build) with | |
| 18 | + `--profile=1 --lossless=1 --enable-palette=0 --enable-intrabc=0 | |
| 19 | + --min-partition-size=8 --max-partition-size=64`, 6 frames. | |
| 20 | +- Committed at `crates/ec-av1/fixtures/ll444_minp8_inter.obu` | |
| 21 | + (gitignored pattern `fixtures`, force-added like every sibling fixture; | |
| 22 | + on-disk == `git ls-tree` blob verified at commit time). | |
| 23 | +- 34037 bytes, sha256 | |
| 24 | + `04fb6d38de5382e647bfb70b6a17802f1fccc5502e6698c0394167891f2b27dc` | |
| 25 | + (= the /tmp/llintra8 original, byte-identical copy), | |
| 26 | + FNV-1a64 `0x2c8f4a2cc02552da`. Both pinned as test consts; missing | |
| 27 | + file panics — no skip path. | |
| 28 | + | |
| 29 | +### Debug build path, not release-only | |
| 30 | + | |
| 31 | +The defect this gate pins is a DEBUG-only panic: the pre-llpred2 ratio | |
| 32 | +(`(write_h / chroma_side).trailing_zeros()` = 64 at 4:4:4) shifted by 64, | |
| 33 | +which panics under debug_assertions and silently wraps in release | |
| 34 | +(release was already byte-exact). The test runs under `cargo test`'s | |
| 35 | +default dev profile — the profile where the parent measured byte-exact | |
| 36 | +and where the old code dies — so a red run names the class instead of | |
| 37 | +silently passing. | |
| 38 | + | |
| 39 | +### Counter disposition: cited unit check, not a skip-arm counter | |
| 40 | + | |
| 41 | +A skip-arm counter was added and measured, then removed: | |
| 42 | + | |
| 43 | +- With the counter bumped at the ONE site the ss-aware decision returns | |
| 44 | + true (after the `obmc_skip_chroma_above` call in `obmc_plan`), the | |
| 45 | + pinned stream measured `OBMC_SS_SKIP_CHROMA_ABOVE_HITS 0 -> 0` while | |
| 46 | + OBMC itself fired (`OBMC_HITS 0 -> 77`, `OBMC_RECT_LEAF_HITS 0 -> 20`). | |
| 47 | + At 4:4:4 the skip needs a 4x4/8x4/4x8 PLANE block; min-partition-8 | |
| 48 | + never codes one, so the skip arm cannot fire on this stream and any | |
| 49 | + `delta > 0` assert would be permanently red — vacuity in reverse. | |
| 50 | +- Per the ticket's fallback: the decision TABLE is pinned by the existing | |
| 51 | + unit check | |
| 52 | + `decode::obmc_skip_chroma_tests::rect_strips_skip_above_chroma_at_420_and_shift_never_overflows` | |
| 53 | + (4:2:0 16x8/8x16 strips still skip; 4:4:4 shifts never leave `usize`), | |
| 54 | + and the stream gate pins the END-TO-END behaviour sample-for-sample. | |
| 55 | + | |
| 56 | +### Assertions (all before/without any skip path) | |
| 57 | + | |
| 58 | +1. Fixture bytes: exact length + FNV-1a64. | |
| 59 | +2. `decode_stream` of the pinned bytes succeeds (a returning `>> 64` | |
| 60 | + panic fails here) — 6 frames, 128x96. | |
| 61 | +3. Oracle aomdec (`--codec=av1 --rawvideo`): raw size 221184, then | |
| 62 | + per-frame per-plane `assert_eq!(bad, 0)` — 0 differing samples, | |
| 63 | + message carries class `obmc-ss-blind-chroma-above`. | |
| 64 | +4. ffmpeg arm (`ffmpeg_decode_sequence_444`): same sample-exact compare. | |
| 65 | + Neither arm skipped in the green run (aomdec + ffmpeg both present). | |
| 66 | + | |
| 67 | +## Red probes (mutation verification) | |
| 68 | + | |
| 69 | +1. Old-ratio probe: callsite swapped to the exact 71f07edd derivation | |
| 70 | + (`(write_w|write_h per chroma_side).trailing_zeros()` pair) → test | |
| 71 | + RED: `attempt to shift right with overflow` at decode.rs | |
| 72 | + `obmc_skip_chroma_above` — the debug-panic class reproduced. | |
| 73 | +2. Chroma-diff probe: `skip_chroma_above = true` forced at the callsite | |
| 74 | + (re-blend class) → test RED at the named assert: `aomdec frame 1 | |
| 75 | + plane u: 46 samples differ (class obmc-ss-blind-chroma-above)`. | |
| 76 | +3. decode.rs restored byte-identical after both probes | |
| 77 | + (`git diff --stat`: only stream.rs + the fixture). | |
| 78 | + | |
| 79 | +## Non-regression / hygiene | |
| 80 | + | |
| 81 | +- `cargo test -p ec-av1 --lib | |
| 82 | + a_lossless_444_min_partition8_inter_stream_decodes_sample_exact` | |
| 83 | + (CARGO_TARGET_DIR=$HOME/.cache/cargo-target-av1llpredgate2, dev | |
| 84 | + profile): 1 passed, 0 failed, no SKIP lines. | |
| 85 | +- `cargo check -p ec-av1 --all-targets`: 0 warnings, 0 errors. | |
| 86 | +- The skip expression itself is untouched (no diff in decode.rs); the | |
| 87 | + reserved 4:2:0 group-tail chroma arm untouched; no server, no full suite. |