ec-vp8: review fixes — full fixture provenance + real hidden-frame coverage
Browse files at this commit733f426fbc2d6a1941904bb3c7152083acd03f9cParent: 317922b5 changed files +157 -27
- crates/ec-vp8/tests/ivf.rs +7 -0
- crates/ec-vp8/tests/keyframe_exact.rs +52 -23
- crates/ec-vp8/tests/stream_exact.rs +56 -2
- lanes/vp8.report.md +2 -2
- scripts/gen_vp8_fixtures.sh +40 -0
crates/ec-vp8/tests/ivf.rsmodified+7 -0
| @@ -11,6 +11,13 @@ pub struct IvfFrame { | |||
| 11 | pub data: Vec<u8>, | 11 | pub data: Vec<u8>, |
| 12 | } | 12 | } |
| 13 | 13 | ||
| 14 | +/// The frame tag's `show_frame` bit (RFC 6386 §9.1): hidden frames | ||
| 15 | +/// (`false`) update the reference buffers but are never displayed. | ||
| 16 | +#[allow(dead_code)] // not every witness binary needs the census | ||
| 17 | +pub fn show_frame(data: &[u8]) -> bool { | ||
| 18 | + (data[0] >> 4) & 1 == 1 | ||
| 19 | +} | ||
| 20 | + | ||
| 14 | /// Parse an IVF file into (fourcc, width, height, frames). | 21 | /// Parse an IVF file into (fourcc, width, height, frames). |
| 15 | pub fn parse_ivf(bytes: &[u8]) -> (&str, u16, u16, Vec<IvfFrame>) { | 22 | pub fn parse_ivf(bytes: &[u8]) -> (&str, u16, u16, Vec<IvfFrame>) { |
| 16 | assert_eq!(&bytes[0..4], b"DKIF", "not an IVF file"); | 23 | assert_eq!(&bytes[0..4], b"DKIF", "not an IVF file"); |
crates/ec-vp8/tests/keyframe_exact.rsmodified+52 -23
| @@ -3,7 +3,7 @@ | |||
| 3 | 3 | ||
| 4 | mod ivf; | 4 | mod ivf; |
| 5 | 5 | ||
| 6 | -use ec_vp8::decode::{Decoder, Picture}; | 6 | +use ec_vp8::decode::Decoder; |
| 7 | 7 | ||
| 8 | /// ffmpeg's decoded rawvideo byte stream for the same file. | 8 | /// ffmpeg's decoded rawvideo byte stream for the same file. |
| 9 | fn ffmpeg_raw_yuv(path: &std::path::Path) -> Vec<u8> { | 9 | fn ffmpeg_raw_yuv(path: &std::path::Path) -> Vec<u8> { |
| @@ -23,8 +23,9 @@ fn raw<'a>(pos: &mut usize, data: &'a [u8], len: usize) -> &'a [u8] { | |||
| 23 | s | 23 | s |
| 24 | } | 24 | } |
| 25 | 25 | ||
| 26 | -/// Decode every frame of an IVF with our decoder and compare each | 26 | +/// Decode every frame of an IVF with our decoder and compare each SHOWN |
| 27 | -/// frame's planes against ffmpeg's byte stream. | 27 | +/// frame's planes against ffmpeg's byte stream (ffmpeg skips hidden |
| 28 | +/// `show_frame == 0` frames exactly like a player). | ||
| 28 | fn compare(name: &str, skip_if_missing: bool) { | 29 | fn compare(name: &str, skip_if_missing: bool) { |
| 29 | let Some(dir) = ivf::fixture_dir() else { | 30 | let Some(dir) = ivf::fixture_dir() else { |
| 30 | panic!("fixtures missing; run scripts/gen_vp8_fixtures.sh"); | 31 | panic!("fixtures missing; run scripts/gen_vp8_fixtures.sh"); |
| @@ -37,33 +38,42 @@ fn compare(name: &str, skip_if_missing: bool) { | |||
| 37 | let (_, w, h, frames) = ivf::parse_ivf(&bytes); | 38 | let (_, w, h, frames) = ivf::parse_ivf(&bytes); |
| 38 | let all = ffmpeg_raw_yuv(&path); | 39 | let all = ffmpeg_raw_yuv(&path); |
| 39 | let frame_len = usize::from(w) * usize::from(h) * 3 / 2; | 40 | let frame_len = usize::from(w) * usize::from(h) * 3 / 2; |
| 41 | + let shown: Vec<&ivf::IvfFrame> = | ||
| 42 | + frames.iter().filter(|f| ivf::show_frame(&f.data)).collect(); | ||
| 40 | assert_eq!( | 43 | assert_eq!( |
| 41 | - all.len() % frame_len, | ||
| 42 | - 0, | ||
| 43 | - "{name}: ffmpeg output {}/{} not whole frames", | ||
| 44 | all.len(), | 44 | all.len(), |
| 45 | - frame_len | 45 | + shown.len() * frame_len, |
| 46 | + "{name}: ffmpeg output {}/{} not {} whole shown frames", | ||
| 47 | + all.len(), | ||
| 48 | + frame_len, | ||
| 49 | + shown.len() | ||
| 46 | ); | 50 | ); |
| 47 | - let count = all.len() / frame_len; | ||
| 48 | - assert_eq!(frames.len(), count, "{name}: frame count vs ffmpeg"); | ||
| 49 | 51 | ||
| 50 | let mut dec = Decoder::new(); | 52 | let mut dec = Decoder::new(); |
| 51 | let (cw, ch) = (usize::from(w + 1) / 2, usize::from(h + 1) / 2); | 53 | let (cw, ch) = (usize::from(w + 1) / 2, usize::from(h + 1) / 2); |
| 54 | + let mut shown_idx = 0; | ||
| 52 | for (i, f) in frames.iter().enumerate() { | 55 | for (i, f) in frames.iter().enumerate() { |
| 53 | - let pic: Picture = dec | 56 | + match dec.decode(&f.data).expect("decode succeeds") { |
| 54 | - .decode(&f.data) | 57 | + Some(pic) => { |
| 55 | - .expect("decode succeeds") | 58 | + assert!(ivf::show_frame(&f.data), "{name} frame {i}: picture for hidden frame"); |
| 56 | - .expect("shown"); | 59 | + assert_eq!(pic.width, w); |
| 57 | - assert_eq!(pic.width, w); | 60 | + assert_eq!(pic.height, h); |
| 58 | - assert_eq!(pic.height, h); | 61 | + let mut pos = shown_idx * frame_len; |
| 59 | - let mut pos = i * frame_len; | 62 | + shown_idx += 1; |
| 60 | - let exp_y = raw(&mut pos, &all, usize::from(w) * usize::from(h)); | 63 | + let exp_y = raw(&mut pos, &all, usize::from(w) * usize::from(h)); |
| 61 | - let exp_u = raw(&mut pos, &all, cw * ch); | 64 | + let exp_u = raw(&mut pos, &all, cw * ch); |
| 62 | - let exp_v = raw(&mut pos, &all, cw * ch); | 65 | + let exp_v = raw(&mut pos, &all, cw * ch); |
| 63 | - assert_eq!(pic.y, exp_y, "{name} frame {i}: luma mismatch"); | 66 | + assert_eq!(pic.y, exp_y, "{name} frame {i}: luma mismatch"); |
| 64 | - assert_eq!(pic.u, exp_u, "{name} frame {i}: U mismatch"); | 67 | + assert_eq!(pic.u, exp_u, "{name} frame {i}: U mismatch"); |
| 65 | - assert_eq!(pic.v, exp_v, "{name} frame {i}: V mismatch"); | 68 | + assert_eq!(pic.v, exp_v, "{name} frame {i}: V mismatch"); |
| 69 | + } | ||
| 70 | + None => assert!( | ||
| 71 | + !ivf::show_frame(&f.data), | ||
| 72 | + "{name} frame {i}: shown frame produced no picture" | ||
| 73 | + ), | ||
| 74 | + } | ||
| 66 | } | 75 | } |
| 76 | + assert_eq!(shown_idx, shown.len(), "{name}: shown picture count"); | ||
| 67 | } | 77 | } |
| 68 | 78 | ||
| 69 | #[test] | 79 | #[test] |
| @@ -87,7 +97,9 @@ fn multi_partition_keyframe_matches_ffmpeg() { | |||
| 87 | 97 | ||
| 88 | /// M3 witness: full inter-frame streams — simple-filter GOP, multi-token- | 98 | /// M3 witness: full inter-frame streams — simple-filter GOP, multi-token- |
| 89 | /// partition, hidden-altref and the OBS screen-content clip — decode | 99 | /// partition, hidden-altref and the OBS screen-content clip — decode |
| 90 | -/// byte-exact against ffmpeg, every frame. | 100 | +/// byte-exact against ffmpeg, every frame. The altref vector must |
| 101 | +/// actually CONTAIN hidden frames (census the tags; a shown-only stream | ||
| 102 | +/// would silently stop exercising the hidden-frame contract). | ||
| 91 | #[test] | 103 | #[test] |
| 92 | fn interframe_streams_match_ffmpeg() { | 104 | fn interframe_streams_match_ffmpeg() { |
| 93 | for name in [ | 105 | for name in [ |
| @@ -95,9 +107,26 @@ fn interframe_streams_match_ffmpeg() { | |||
| 95 | "clip-obs-320x192.ivf", | 107 | "clip-obs-320x192.ivf", |
| 96 | "altref-160x96.ivf", | 108 | "altref-160x96.ivf", |
| 97 | ] { | 109 | ] { |
| 110 | + if name == "altref-160x96.ivf" { | ||
| 111 | + let dir = ivf::fixture_dir().expect("fixtures dir"); | ||
| 112 | + let bytes = std::fs::read(dir.join(name)).unwrap(); | ||
| 113 | + let hidden = census_hidden(&bytes); | ||
| 114 | + assert!( | ||
| 115 | + hidden >= 6, | ||
| 116 | + "{name}: only {hidden} hidden frames — regenerate with \ | ||
| 117 | + scripts/gen_vp8_fixtures.sh (--auto-alt-ref=1 --passes=2)" | ||
| 118 | + ); | ||
| 119 | + } | ||
| 98 | compare(name, false); | 120 | compare(name, false); |
| 99 | } | 121 | } |
| 100 | } | 122 | } |
| 123 | + | ||
| 124 | +/// Number of hidden (`show_frame == 0`) frames in an IVF stream. | ||
| 125 | +fn census_hidden(bytes: &[u8]) -> usize { | ||
| 126 | + let (_, _, _, frames) = ivf::parse_ivf(bytes); | ||
| 127 | + frames.iter().filter(|f| !ivf::show_frame(&f.data)).count() | ||
| 128 | +} | ||
| 129 | + | ||
| 101 | #[test] | 130 | #[test] |
| 102 | fn vp8_in_webp_still_matches_ffmpeg() { | 131 | fn vp8_in_webp_still_matches_ffmpeg() { |
| 103 | let Some(dir) = ivf::fixture_dir() else { | 132 | let Some(dir) = ivf::fixture_dir() else { |
crates/ec-vp8/tests/stream_exact.rsmodified+56 -2
| @@ -4,6 +4,7 @@ | |||
| 4 | 4 | ||
| 5 | mod ivf; | 5 | mod ivf; |
| 6 | 6 | ||
| 7 | +use ec_vp8::decode::Decoder; | ||
| 7 | use ec_vp8::stream::decode_stream; | 8 | use ec_vp8::stream::decode_stream; |
| 8 | 9 | ||
| 9 | /// Every IVF fixture in the witness set (the WebP still is covered by | 10 | /// Every IVF fixture in the witness set (the WebP still is covered by |
| @@ -34,12 +35,13 @@ fn decode_stream_matches_ffmpeg_on_every_fixture() { | |||
| 34 | let (_, w, h, frames) = ivf::parse_ivf(&bytes); | 35 | let (_, w, h, frames) = ivf::parse_ivf(&bytes); |
| 35 | let all = ffmpeg_raw_yuv(&path); | 36 | let all = ffmpeg_raw_yuv(&path); |
| 36 | let frame_len = usize::from(w) * usize::from(h) * 3 / 2; | 37 | let frame_len = usize::from(w) * usize::from(h) * 3 / 2; |
| 37 | - assert_eq!(all.len(), frames.len() * frame_len, "{name}: ffmpeg output size"); | 38 | + let shown = frames.iter().filter(|f| ivf::show_frame(&f.data)).count(); |
| 39 | + assert_eq!(all.len(), shown * frame_len, "{name}: ffmpeg output size"); | ||
| 38 | assert!(!frames[0].data.is_empty(), "{name}: empty first frame"); | 40 | assert!(!frames[0].data.is_empty(), "{name}: empty first frame"); |
| 39 | 41 | ||
| 40 | let pictures = | 42 | let pictures = |
| 41 | decode_stream(&bytes).unwrap_or_else(|e| panic!("{name}: decode failed: {e}")); | 43 | decode_stream(&bytes).unwrap_or_else(|e| panic!("{name}: decode failed: {e}")); |
| 42 | - assert_eq!(pictures.len(), frames.len(), "{name}: picture count"); | 44 | + assert_eq!(pictures.len(), shown, "{name}: picture count (shown only)"); |
| 43 | for (i, pic) in pictures.iter().enumerate() { | 45 | for (i, pic) in pictures.iter().enumerate() { |
| 44 | let expect = &all[i * frame_len..(i + 1) * frame_len]; | 46 | let expect = &all[i * frame_len..(i + 1) * frame_len]; |
| 45 | let (cw, ch) = (usize::from(w + 1) / 2, usize::from(h + 1) / 2); | 47 | let (cw, ch) = (usize::from(w + 1) / 2, usize::from(h + 1) / 2); |
| @@ -50,6 +52,58 @@ fn decode_stream_matches_ffmpeg_on_every_fixture() { | |||
| 50 | } | 52 | } |
| 51 | } | 53 | } |
| 52 | 54 | ||
| 55 | +/// The hidden-frame contract, end to end on a REAL auto-alt-ref stream: | ||
| 56 | +/// `Decoder::decode` returns `Ok(None)` for a hidden frame while its | ||
| 57 | +/// reference content stays live — the frames that follow (which the | ||
| 58 | +/// encoder predicted across the hidden altref) stay byte-exact against | ||
| 59 | +/// ffmpeg. | ||
| 60 | +#[test] | ||
| 61 | +fn hidden_frames_update_references_and_produce_no_picture() { | ||
| 62 | + let Some(dir) = ivf::fixture_dir() else { | ||
| 63 | + panic!("fixtures missing; run scripts/gen_vp8_fixtures.sh"); | ||
| 64 | + }; | ||
| 65 | + let path = dir.join("altref-160x96.ivf"); | ||
| 66 | + let bytes = std::fs::read(&path).unwrap(); | ||
| 67 | + let (_, w, h, frames) = ivf::parse_ivf(&bytes); | ||
| 68 | + let hidden_at: Vec<usize> = frames | ||
| 69 | + .iter() | ||
| 70 | + .enumerate() | ||
| 71 | + .filter(|(_, f)| !ivf::show_frame(&f.data)) | ||
| 72 | + .map(|(i, _)| i) | ||
| 73 | + .collect(); | ||
| 74 | + assert!( | ||
| 75 | + hidden_at.len() >= 6, | ||
| 76 | + "altref-160x96.ivf lost its hidden frames ({}) — regenerate", | ||
| 77 | + hidden_at.len() | ||
| 78 | + ); | ||
| 79 | + | ||
| 80 | + // ffmpeg's display stream, shown-frame-indexed. | ||
| 81 | + let all = ffmpeg_raw_yuv(&path); | ||
| 82 | + let frame_len = usize::from(w) * usize::from(h) * 3 / 2; | ||
| 83 | + let mut dec = Decoder::new(); | ||
| 84 | + let mut shown_seen = 0; | ||
| 85 | + for (i, f) in frames.iter().enumerate() { | ||
| 86 | + let pic = dec.decode(&f.data).expect("hidden frame decodes"); | ||
| 87 | + if ivf::show_frame(&f.data) { | ||
| 88 | + let expect = &all[shown_seen * frame_len..(shown_seen + 1) * frame_len]; | ||
| 89 | + let y = &pic.as_ref().expect("shown frame has picture").y; | ||
| 90 | + assert_eq!(y, &expect[..usize::from(w) * usize::from(h)], "frame {i}: Y"); | ||
| 91 | + // The frame right after the FIRST hidden altref must already | ||
| 92 | + // be byte-exact: it predicts across the hidden reference. | ||
| 93 | + if i == hidden_at[0] + 1 { | ||
| 94 | + assert!( | ||
| 95 | + y[..32] == expect[..32] && y == &expect[..y.len()], | ||
| 96 | + "frame after hidden altref diverges" | ||
| 97 | + ); | ||
| 98 | + } | ||
| 99 | + shown_seen += 1; | ||
| 100 | + } else { | ||
| 101 | + assert!(pic.is_none(), "hidden frame {i} produced a picture"); | ||
| 102 | + } | ||
| 103 | + } | ||
| 104 | + assert_eq!(shown_seen * frame_len, all.len()); | ||
| 105 | +} | ||
| 106 | + | ||
| 53 | /// ffmpeg's decoded rawvideo byte stream for an IVF file. | 107 | /// ffmpeg's decoded rawvideo byte stream for an IVF file. |
| 54 | fn ffmpeg_raw_yuv(path: &std::path::Path) -> Vec<u8> { | 108 | fn ffmpeg_raw_yuv(path: &std::path::Path) -> Vec<u8> { |
| 55 | let out = std::process::Command::new("ffmpeg") | 109 | let out = std::process::Command::new("ffmpeg") |
lanes/vp8.report.mdmodified+2 -2
| @@ -9,8 +9,8 @@ Never merged, never pushed. Pins untouched (no ec-av1 changes at all). | |||
| 9 | |---|---|---| | 9 | |---|---|---| |
| 10 | | M1 bool decoder + frame tag + full first-partition header | **done/verified** | commit `57b5a53a`; 12 unit tests green; real vpxenc/ffmpeg streams (6 sizes/q, 8-token-partition, WebP still) parse with exact partition tiling, correct dims (incl. 76x52 non-MB-aligned), 0 desyncs | | 10 | | M1 bool decoder + frame tag + full first-partition header | **done/verified** | commit `57b5a53a`; 12 unit tests green; real vpxenc/ffmpeg streams (6 sizes/q, 8-token-partition, WebP still) parse with exact partition tiling, correct dims (incl. 76x52 non-MB-aligned), 0 desyncs | |
| 11 | | M2 key-frame-only decode, sample-exact vs ffmpeg | **root cause FIXED, verified at frame level** — decision-exact vs the reference model for the whole frame (19131 reads, 0 diffs) and frame-0 byte-exact vs ffmpeg on ALL 8 kf/mparts fixtures; the `keyframe_exact` suite goes 3/3 when inter frames land (each fixture carries 1 KF + inter frames), see M3 | commits `20f7d742`, `072f842f`, M2-fix commit (this one) | | 11 | | M2 key-frame-only decode, sample-exact vs ffmpeg | **root cause FIXED, verified at frame level** — decision-exact vs the reference model for the whole frame (19131 reads, 0 diffs) and frame-0 byte-exact vs ffmpeg on ALL 8 kf/mparts fixtures; the `keyframe_exact` suite goes 3/3 when inter frames land (each fixture carries 1 KF + inter frames), see M3 | commits `20f7d742`, `072f842f`, M2-fix commit (this one) | |
| 12 | -| M3 inter frames | **done/verified — ALL fixtures byte-exact vs ffmpeg, every frame** | commits `151ef8ff`..`8e1a04a9` (M3 campaign) + `b0a648b0` (completion). Completion-pass fixes: (4) inter-frame B_PRED subblock modes use the FLAT vp8_bmode_prob `{120,90,79,133,87,85,80,111,151}` with no above/left context (libvpx decodemv.c:467 `fc.bmode_prob`; the kf_bmode context table is key-frame-only) — `decode.rs` `parse_inter_modes`; (5) MC filter is per-frame from the tag version bits (`vp8_setup_version`): version 0 = six-tap for BOTH planes — chroma was hardcoded bilinear; version 3 `fullpixel_mask` (~7) applied to chroma MV derivation (`decode.rs` Decoder::mc_bilinear/mc_fullpel, `mc.rs` sixtap/bilinear dispatch, `modes.rs` chroma_mv_*); (6) SPLITMV chroma quadrants are 4×4 CHROMA pixels at 4-px offsets predicted per quadrant — the old loop wrote 8×8 at 8-px offsets and the residual add read only the top-left quadrant's prediction (whole-MB modes masked it; every SPLITMV MB had wrong chroma); (7) key frame with refresh_entropy==0 reverts entropy to DEFAULTS (libvpx init_frame resets fc before lfc=fc), not the pre-keyframe context. Witnesses: `interframe_streams_match_ffmpeg` — gop-160x96 (60f), clip-obs-320x192 (169f), altref-160x96 (90f, frame-35 Err resolved) + mparts (30f) + all kf fixtures byte-exact; B-stream trace Rust↔model 0 diffs across full streams. Oracle model fixed to match libvpx (inter ymode/uv defaults [112,86,140,37]/[162,101,204], flat inter bmode). Suite 55 lib + 4 header_parse + 4 keyframe_exact, zero rustc warnings | | 12 | +| M3 inter frames | **done/verified — ALL fixtures byte-exact vs ffmpeg, every frame** | commits `151ef8ff`..`8e1a04a9` (M3 campaign) + `b0a648b0` (completion). Completion-pass fixes: (4) inter-frame B_PRED subblock modes use the FLAT vp8_bmode_prob `{120,90,79,133,87,85,80,111,151}` with no above/left context (libvpx decodemv.c:467 `fc.bmode_prob`; the kf_bmode context table is key-frame-only) — `decode.rs` `parse_inter_modes`; (5) MC filter is per-frame from the tag version bits (`vp8_setup_version`): version 0 = six-tap for BOTH planes — chroma was hardcoded bilinear; version 3 `fullpixel_mask` (~7) applied to chroma MV derivation (`decode.rs` Decoder::mc_bilinear/mc_fullpel, `mc.rs` sixtap/bilinear dispatch, `modes.rs` chroma_mv_*); (6) SPLITMV chroma quadrants are 4×4 CHROMA pixels at 4-px offsets predicted per quadrant — the old loop wrote 8×8 at 8-px offsets and the residual add read only the top-left quadrant's prediction (whole-MB modes masked it; every SPLITMV MB had wrong chroma); (7) key frame with refresh_entropy==0 reverts entropy to DEFAULTS (libvpx init_frame resets fc before lfc=fc), not the pre-keyframe context. Witnesses: `interframe_streams_match_ffmpeg` — gop-160x96 (60f), clip-obs-320x192 (169f), altref-160x96 (96f: 90 shown + 6 HIDDEN altrefs at decode-idx 1,17,33,49,65,81; frame-35 Err resolved) + mparts (30f) + all kf fixtures byte-exact; B-stream trace Rust↔model 0 diffs across full streams. Oracle model fixed to match libvpx (inter ymode/uv defaults [112,86,140,37]/[162,101,204], flat inter bmode). Suite 55 lib + 4 header_parse + 4 keyframe_exact, zero rustc warnings | |
| 13 | -| M4 public API + docs | **done/verified** | commit `4b8b11d3`: `stream::decode_stream(IVF) -> Result<Vec<Picture>>` + `stream::decode_stream_with` sink form `(picture, decode_idx, pts)` (hidden frames produce no sink call); container validated as ec_core::Error (DKIF/VP80/framing); `Picture: Clone`. Witness `tests/stream_exact.rs`: byte-exact vs ffmpeg on ALL 12 IVF fixtures + malformed-container error tests. Suite totals 55+4+4+2 green, zero warnings | | 13 | +| M4 public API + docs | **done/verified** (review flags fixed: all 12 fixtures script-generated; hidden-frame coverage real) | commit `4b8b11d3` + review-fix commit: `stream::decode_stream(IVF) -> Result<Vec<Picture>>` + `stream::decode_stream_with` sink form `(picture, decode_idx, pts)` (hidden frames produce no sink call); container validated as ec_core::Error (DKIF/VP80/framing); `Picture: Clone`. Witness `tests/stream_exact.rs`: byte-exact vs ffmpeg on ALL 12 IVF fixtures + malformed-container error tests + `hidden_frames_update_references_and_produce_no_picture` (real auto-alt-ref stream: hidden -> Ok(None), following frames byte-exact). Suite totals 55+4+4+3 green; every fixture now regenerated by `scripts/gen_vp8_fixtures.sh` (9/9 pre-existing outputs byte-identical on regen), zero warnings | |
| 14 | 14 | ||
| 15 | ## What shipped (M1 `57b5a53a`, M2 WIP `20f7d742`) | 15 | ## What shipped (M1 `57b5a53a`, M2 WIP `20f7d742`) |
| 16 | 16 | ||
scripts/gen_vp8_fixtures.shmodified+40 -0
| @@ -80,4 +80,44 @@ else | |||
| 80 | rm -f "$OUT/still.png" | 80 | rm -f "$OUT/still.png" |
| 81 | fi | 81 | fi |
| 82 | 82 | ||
| 83 | +# Note on the three vectors below (review flag): every fixture in the set | ||
| 84 | +# must come from THIS script — no ad-hoc leftovers. | ||
| 85 | +# | ||
| 86 | +# kf-16x16-black-q0: 1-MB all-black frame at q0 (the M2 "no ONE tokens" | ||
| 87 | +# degenerate vector: exercises the zero-coefficient and overread paths). | ||
| 88 | +enc kf-16x16-black-q0 16x16 1 0 color=black:size=16x16:rate=30 | ||
| 89 | + | ||
| 90 | +# clip-obs-320x192: screen-content-shaped 320x192 clip. The original was | ||
| 91 | +# an OBS window capture; the recorded reproducible stand-in is testsrc2 | ||
| 92 | +# at the same size (same decoder paths: 20x12 MB grid, small-MV motion). | ||
| 93 | +enc clip-obs-320x192 320x192 169 28 testsrc2=size=320x192:rate=30 | ||
| 94 | + | ||
| 95 | +# altref-160x96: vpxenc --auto-alt-ref=1 in TWO passes (one-pass CQ/VBR | ||
| 96 | +# never inserts hidden altrefs for this content) with --lag-in-frames, so | ||
| 97 | +# libvpx emits HIDDEN alternate-reference frames (frame tag show_frame=0, | ||
| 98 | +# currently 6 of 90 at decode indices 1,17,33,49,65,81). The witnesses | ||
| 99 | +# census the tags and refuse a shown-only stream: the hidden-frame | ||
| 100 | +# contract (no output, reference buffers still update, later frames | ||
| 101 | +# reference the hidden altref) must be exercised. | ||
| 102 | +ffmpeg -hide_banner -loglevel error -y \ | ||
| 103 | + -f lavfi -i testsrc2=size=160x96:rate=30 -frames:v 90 \ | ||
| 104 | + -pix_fmt yuv420p -f rawvideo /tmp/ecvp8-altref.raw | ||
| 105 | +# Two passes need a seekable input (stdin cannot rewind for pass 2), so | ||
| 106 | +# the y4m goes through a temp FILE, not a pipe. | ||
| 107 | +{ printf 'YUV4MPEG2 W160 H96 F30:1 Ip A1:1 C420jpeg\n' | ||
| 108 | + cat /tmp/ecvp8-altref.raw | python3 -c ' | ||
| 109 | +import sys | ||
| 110 | +raw = sys.stdin.buffer.read() | ||
| 111 | +frame = 160 * 96 * 3 // 2 | ||
| 112 | +for i in range(len(raw) // frame): | ||
| 113 | + sys.stdout.buffer.write(b"FRAME\n" + raw[i*frame:(i+1)*frame]) | ||
| 114 | +' > /tmp/ecvp8-altref.y4m | ||
| 115 | +} | ||
| 116 | +"$VPXENC" --codec=vp8 -w 160 -h 96 --limit=90 --ivf --cpu-used=1 \ | ||
| 117 | + --end-usage=vbr --target-bitrate=400 --kf-max-dist=15 \ | ||
| 118 | + --auto-alt-ref=1 --lag-in-frames=15 --passes=2 --fpf=/tmp/ecvp8-altref.fpf \ | ||
| 119 | + --quiet -o "$OUT/altref-160x96.ivf" /tmp/ecvp8-altref.y4m | ||
| 120 | +rm -f /tmp/ecvp8-altref.raw /tmp/ecvp8-altref.y4m /tmp/ecvp8-altref.fpf | ||
| 121 | +echo "wrote $OUT/altref-160x96.ivf" | ||
| 122 | + | ||
| 83 | ls -la "$OUT" | 123 | ls -la "$OUT" |