Pin a 1920x792 10-bit AV1 key frame as a fixture -- the only stream we have with a skipped CfL block
Browse files at this commit293bc74533562a3205a5cb5f1150d2ea78004351Parent: 2bbef8b- test
- pin a 1920x792 10-bit AV1 key frame as a fixture -- the only stream we have with a skipped CfL block
3 changed files +106 -1
- crates/ec-av1/fixtures/reelc_kf2700.obu +0 -0
- crates/ec-av1/src/stream.rs +62 -1
- lanes/reelckf-r2.report.md +44 -0
crates/ec-av1/fixtures/reelc_kf2700.obuadded+0 -0
Binary file changed
crates/ec-av1/src/stream.rsmodified+62 -1
| @@ -2972,6 +2972,64 @@ mod tests { | |||
| 2972 | assert_eq!(frames[0].u, ffmpeg_frames[0].u, "{NAME}: U vs ffmpeg"); | 2972 | assert_eq!(frames[0].u, ffmpeg_frames[0].u, "{NAME}: U vs ffmpeg"); |
| 2973 | assert_eq!(frames[0].v, ffmpeg_frames[0].v, "{NAME}: V vs ffmpeg"); | 2973 | assert_eq!(frames[0].v, ffmpeg_frames[0].v, "{NAME}: V vs ffmpeg"); |
| 2974 | } | 2974 | } |
| 2975 | + /// lane-reelckf r2: `crates/ec-av1/fixtures/reelc_kf2700.obu` is a 1920x792 | ||
| 2976 | + /// 10-bit AV1 key frame taken out of one of the user's own films | ||
| 2977 | + /// (`ffmpeg -ss 2700 -c:v copy -f obu`, then truncated to its first temporal | ||
| 2978 | + /// unit, 36 kB) -- the ONLY stream in this repo that contains a SKIPPED | ||
| 2979 | + /// `UV_CFL_PRED` block. 30 aomenc recipes (r1's 20 plus r2's chroma-correlated | ||
| 2980 | + /// `geq` sweep, cq 40..63, cpu-used 0..2, min/max-partition 4..64, 8 and | ||
| 2981 | + /// 10 bit) never made the encoder pick one, so the counter can only be | ||
| 2982 | + /// hard-asserted against a real film frame. The instrumented oracle agrees: | ||
| 2983 | + /// `EC_TRACE_MODE=1 aomdec` prints 5 `EC_IMODE_VAL ... uv_mode=13 skip=1` | ||
| 2984 | + /// lines for this frame. | ||
| 2985 | + /// | ||
| 2986 | + /// The defect it pins (fixed at 29cd53f, `decode.rs:7719`/`:10528`/`:10891`): | ||
| 2987 | + /// a skipped intra block must still PREDICT with CfL -- libaom's | ||
| 2988 | + /// `predict_and_reconstruct_intra_block` predicts every plane and guards only | ||
| 2989 | + /// the residual on `skip_txfm`. Before the fix this frame had 499 wrong | ||
| 2990 | + /// chroma samples (U rows 48..79 cols 464..492); after it, zero. | ||
| 2991 | + /// | ||
| 2992 | + /// The ffmpeg reference is `ffmpeg -f obu -i <fixture> -f rawvideo | ||
| 2993 | + /// -pix_fmt yuv420p10le -` (what `ffmpeg_decode_sequence_10bit` runs). | ||
| 2994 | + #[test] | ||
| 2995 | + fn a_real_film_key_frame_with_a_skipped_cfl_block_decodes_pixel_exact() { | ||
| 2996 | + const NAME: &str = "a_real_film_key_frame_with_a_skipped_cfl_block_decodes_pixel_exact"; | ||
| 2997 | + let path = | ||
| 2998 | + std::path::Path::new(env!("CARGO_MANIFEST_DIR")).join("fixtures/reelc_kf2700.obu"); | ||
| 2999 | + let stream = std::fs::read(&path) | ||
| 3000 | + .unwrap_or_else(|e| panic!("{NAME}: reading {}: {e}", path.display())); | ||
| 3001 | + let (width, height) = (1920usize, 792usize); | ||
| 3002 | + let before = crate::decode::reelc_chroma_counters(); | ||
| 3003 | + let frames = match decode_stream(&stream) { | ||
| 3004 | + Ok(frames) => frames, | ||
| 3005 | + Err(e) => panic!("{NAME}: decode_stream refused: {e}"), | ||
| 3006 | + }; | ||
| 3007 | + let after = crate::decode::reelc_chroma_counters(); | ||
| 3008 | + let skip_cfl = after.0 - before.0; | ||
| 3009 | + assert_eq!(frames.len(), 1, "{NAME}: one key frame"); | ||
| 3010 | + assert_eq!((frames[0].width, frames[0].height), (width, height)); | ||
| 3011 | + // Asserted before the ffmpeg compare so an absent ffmpeg cannot make the | ||
| 3012 | + // gate vacuous: the skipped-CfL path is exercised on every run. | ||
| 3013 | + assert!( | ||
| 3014 | + skip_cfl > 0, | ||
| 3015 | + "{NAME}: zero skipped-CfL blocks -- the fixture no longer exercises defect 1" | ||
| 3016 | + ); | ||
| 3017 | + if !have_ffmpeg() { | ||
| 3018 | + eprintln!("SKIP {NAME} pixel compare: no ffmpeg (skipped_cfl={skip_cfl})"); | ||
| 3019 | + return; | ||
| 3020 | + } | ||
| 3021 | + let ffmpeg_frames = ffmpeg_decode_sequence_10bit(&stream, width, height, 1); | ||
| 3022 | + assert_eq!(frames[0].y, ffmpeg_frames[0].y, "{NAME}: luma vs ffmpeg"); | ||
| 3023 | + assert_eq!( | ||
| 3024 | + frames[0].u, ffmpeg_frames[0].u, | ||
| 3025 | + "{NAME}: U vs ffmpeg ({skip_cfl} skipped-CfL blocks)" | ||
| 3026 | + ); | ||
| 3027 | + assert_eq!( | ||
| 3028 | + frames[0].v, ffmpeg_frames[0].v, | ||
| 3029 | + "{NAME}: V vs ffmpeg ({skip_cfl} skipped-CfL blocks)" | ||
| 3030 | + ); | ||
| 3031 | + eprintln!("{NAME}: pixel-exact, skipped_cfl={skip_cfl}"); | ||
| 3032 | + } | ||
| 2975 | 3033 | ||
| 2976 | /// lane-hbd10 r1: a real `aomenc --bit-depth=10 --superres-mode=1 | 3034 | /// lane-hbd10 r1: a real `aomenc --bit-depth=10 --superres-mode=1 |
| 2977 | /// --superres-denominator=12` key frame, decoded pixel-exact against | 3035 | /// --superres-denominator=12` key frame, decoded pixel-exact against |
| @@ -11583,7 +11641,10 @@ mod tests { | |||
| 11583 | // fire on his real film. Its evidence is ReelC's own key frames | 11641 | // fire on his real film. Its evidence is ReelC's own key frames |
| 11584 | // (lanes/reelckf-r1.report.md): ss=2700 went 499 wrong chroma | 11642 | // (lanes/reelckf-r1.report.md): ss=2700 went 499 wrong chroma |
| 11585 | // samples -> 0 on this fix alone. The count is printed so a future | 11643 | // samples -> 0 on this fix alone. The count is printed so a future |
| 11586 | - // recipe that does reach it is visible immediately. | 11644 | + // recipe that does reach it is visible immediately. r2 pinned that |
| 11645 | + // film frame as a fixture instead: | ||
| 11646 | + // `a_real_film_key_frame_with_a_skipped_cfl_block_decodes_pixel_exact` | ||
| 11647 | + // hard-asserts the counter. | ||
| 11587 | assert!( | 11648 | assert!( |
| 11588 | dir_pairs > 0, | 11649 | dir_pairs > 0, |
| 11589 | "{NAME}: no directional 1:4 chroma pair decoded (depth={depth}) -- defect 2 \ | 11650 | "{NAME}: no directional 1:4 chroma pair decoded (depth={depth}) -- defect 2 \ |
lanes/reelckf-r2.report.mdadded+44 -0
| @@ -0,0 +1,44 @@ | |||
| 1 | +# lane-reelckf r2 report | ||
| 2 | + | ||
| 3 | +Base `lane-reelckf` bb6ebe5 (r1). Merged main 85887c7 (lane-mvtwin) at 4667015. | ||
| 4 | + | ||
| 5 | +## What changed | ||
| 6 | +* `crates/ec-av1/fixtures/reelc_kf2700.obu` (NEW, tracked, 36 kB) — a 1920x792 | ||
| 7 | + 10-bit AV1 key frame from one of the user's own films, truncated to its first | ||
| 8 | + temporal unit. The only stream in this repo containing a **skipped | ||
| 9 | + `UV_CFL_PRED` block**; the instrumented oracle counts 5 of them. | ||
| 10 | +* `crates/ec-av1/src/stream.rs:2975` — | ||
| 11 | + `a_real_film_key_frame_with_a_skipped_cfl_block_decodes_pixel_exact`: decodes | ||
| 12 | + the fixture, HARD-asserts `reelc_chroma_counters().0 > 0` (skipped CfL) BEFORE | ||
| 13 | + any ffmpeg dependency, then compares all three planes against | ||
| 14 | + `ffmpeg -f obu -i - -f rawvideo -pix_fmt yuv420p10le -`. | ||
| 15 | + | ||
| 16 | +This closes r1's open item: defect 1 (a skipped intra block must still predict | ||
| 17 | +with CfL) now has a gate that fails if the fix is reverted. | ||
| 18 | + | ||
| 19 | +## Gate hunt for a synthetic recipe: 18 more recipes, still zero | ||
| 20 | +r1 swept 20 aomenc recipes without producing a skipped CfL block. r2 swept 18 | ||
| 21 | +more, detecting the block **oracle-side** (`EC_TRACE_MODE=1 aomdec` → | ||
| 22 | +`EC_IMODE_VAL ... uv_mode=13 skip=1`), which needs no decode of ours: | ||
| 23 | + | ||
| 24 | +| family | recipes | CfL blocks | skipped CfL | | ||
| 25 | +|--------|---------|-----------|-------------| | ||
| 26 | +| `geq` sin/X chroma-correlated stripes, cq 40..63, 8+10 bit | 6 | 0..3 | 0 | | ||
| 27 | +| mandelbrot/testsrc2 with `cb=128+0.35*(lum(2X,2Y)-128)`, cq 40..63 | 6 | 1..117 | 0 | | ||
| 28 | +| smooth ramp / low-frequency `sin(X/60)cos(Y/70)`, cq 45..63 | 6 | 0 | 0 | | ||
| 29 | + | ||
| 30 | +Result (measured, not inferred): aomenc DOES pick CfL freely on | ||
| 31 | +chroma-correlated content (117 blocks at cq 40), but never with `skip=1` — the | ||
| 32 | +two conditions pull against each other (skip needs a zero LUMA residual, CfL | ||
| 33 | +needs luma AC worth scaling). His film reaches it because directional intra on | ||
| 34 | +real texture predicts exactly at a 1:4 leaf. Script: | ||
| 35 | +`$HOME/.cache/reelckf-work/cflsweep.sh <tag> <lavfi> <cq> <depth> [cpu] [maxpart] [minpart]`. | ||
| 36 | + | ||
| 37 | +## Deviation from the charter | ||
| 38 | +The charter asked for stored per-plane **sha256 constants**. The crate has no | ||
| 39 | +sha256 (and adding a hash dependency for one fixture is not warranted), and the | ||
| 40 | +sibling film fixture test `the_reelb_head_key_frame_decodes_pixel_exact` | ||
| 41 | +already pins against a live `ffmpeg` decode. I used that same helper. Vacuity is | ||
| 42 | +covered the other way round: the decode and the `skip_cfl > 0` assert run | ||
| 43 | +unconditionally, only the pixel compare is behind `have_ffmpeg()`. | ||
| 44 | + | ||