fixture-preflight: kill the fixture-absent silent-skip class, generate the fixture library manifest
Browse files at this commit60e26539d424852a85c115e82b2fabaa57f6aff2Parent: a460dca16 changed files +2474 -482
- crates/ec-aac/tests/oracle.rs +29 -10
- crates/ec-aac/tests/sbr_real_library.rs +260 -88
- crates/ec-flac/tests/encode_matrix.rs +56 -11
- crates/ec-flac/tests/xiph_vectors.rs +69 -6
- crates/ec-h264/tests/conformance.rs +96 -27
- crates/ec-h264/tests/encode.rs +35 -3
- crates/ec-mp3/tests/encode_matrix.rs +52 -8
- crates/ec-opus/tests/conformance.rs +808 -246
- crates/ec-vorbis/tests/oracle.rs +212 -51
- crates/ec-vp9/tests/hbd_exact.rs +35 -9
- crates/ec-vp9/tests/inter_pixels_exact.rs +30 -9
- crates/ec-vp9/tests/scratch_interdump.rs +36 -4
- crates/ec-vp9/tests/subsampling_exact.rs +36 -10
- scripts/fixture-library.tsv +280 -0
- scripts/gen-fixture-library.sh +257 -0
- scripts/verify-fixture-library.sh +183 -0
crates/ec-aac/tests/oracle.rsmodified+29 -10
| @@ -19,6 +19,30 @@ fn have_ffmpeg() -> bool { | |||
| 19 | .unwrap_or(false) | 19 | .unwrap_or(false) |
| 20 | } | 20 | } |
| 21 | 21 | ||
| 22 | +/// Fixture-presence probe for the committed `fixtures/audio` media this file | ||
| 23 | +/// decodes. Returns whether the fixture is present, but never silently: under | ||
| 24 | +/// `EC_REQUIRE_FIXTURES=1` an absent fixture is a hard failure naming the path | ||
| 25 | +/// and the script that regenerates it, so a host whose fixture library drifted | ||
| 26 | +/// reports RED instead of a green SKIP (class: gate-skips-on-its-own-failure; | ||
| 27 | +/// model `have_ffmpeg` in crates/ec-av1/src/stream.rs, which was silently | ||
| 28 | +/// short-circuited because the probe ran first in a compound `if`). | ||
| 29 | +/// | ||
| 30 | +/// Order is load-bearing: probe, assert, return. Never merge the probe into | ||
| 31 | +/// the same `if` as the escape. | ||
| 32 | +fn require_fixture(path: &Path, generator: &str) -> bool { | ||
| 33 | + let present = path.exists(); | ||
| 34 | + assert!( | ||
| 35 | + present || std::env::var_os("EC_REQUIRE_FIXTURES").is_none(), | ||
| 36 | + "EC_REQUIRE_FIXTURES=1 but fixture {} is absent -- regenerate with: {}", | ||
| 37 | + path.display(), | ||
| 38 | + generator | ||
| 39 | + ); | ||
| 40 | + if !present { | ||
| 41 | + eprintln!("SKIP: fixture {} absent", path.display()); | ||
| 42 | + } | ||
| 43 | + present | ||
| 44 | +} | ||
| 45 | + | ||
| 22 | /// ffmpeg's decode of a file, as planar-by-channel `f32`. | 46 | /// ffmpeg's decode of a file, as planar-by-channel `f32`. |
| 23 | fn ffmpeg_decode(path: &Path, channels: usize) -> Vec<Vec<f32>> { | 47 | fn ffmpeg_decode(path: &Path, channels: usize) -> Vec<Vec<f32>> { |
| 24 | let out = Command::new("ffmpeg") | 48 | let out = Command::new("ffmpeg") |
| @@ -128,8 +152,7 @@ fn adts_fixtures_match_ffmpeg_per_channel() { | |||
| 128 | "aac-adts-5.1-48000.aac", | 152 | "aac-adts-5.1-48000.aac", |
| 129 | ] { | 153 | ] { |
| 130 | let path = dir.join(name); | 154 | let path = dir.join(name); |
| 131 | - if !path.exists() { | 155 | + if !require_fixture(&path, "scripts/gen-fixtures.sh") { |
| 132 | - eprintln!("SKIP {name}: fixture missing"); | ||
| 133 | continue; | 156 | continue; |
| 134 | } | 157 | } |
| 135 | let corr = compare(&path); | 158 | let corr = compare(&path); |
| @@ -164,8 +187,7 @@ fn mp4_fixtures_match_ffmpeg_per_channel() { | |||
| 164 | "aac-mp4-5.1-48000.mp4", | 187 | "aac-mp4-5.1-48000.mp4", |
| 165 | ] { | 188 | ] { |
| 166 | let path = dir.join(name); | 189 | let path = dir.join(name); |
| 167 | - if !path.exists() { | 190 | + if !require_fixture(&path, "scripts/gen-fixtures.sh") { |
| 168 | - eprintln!("SKIP {name}: fixture missing"); | ||
| 169 | continue; | 191 | continue; |
| 170 | } | 192 | } |
| 171 | // The mp4 side of the family is another slice; the elementary stream | 193 | // The mp4 side of the family is another slice; the elementary stream |
| @@ -209,8 +231,7 @@ fn aac_coding_tools_match_ffmpeg_in_isolation() { | |||
| 209 | for tool in ["pns", "is", "ms", "tns", "all"] { | 231 | for tool in ["pns", "is", "ms", "tns", "all"] { |
| 210 | let name = format!("aac-tool-{tool}-mp4-stereo-48000.m4a"); | 232 | let name = format!("aac-tool-{tool}-mp4-stereo-48000.m4a"); |
| 211 | let path = dir.join(&name); | 233 | let path = dir.join(&name); |
| 212 | - if !path.exists() { | 234 | + if !require_fixture(&path, "scripts/gen-fixtures.sh") { |
| 213 | - eprintln!("SKIP {name}: fixture missing"); | ||
| 214 | continue; | 235 | continue; |
| 215 | } | 236 | } |
| 216 | let adts = tmp.join(format!("{name}.aac")); | 237 | let adts = tmp.join(format!("{name}.aac")); |
| @@ -421,8 +442,7 @@ fn encoder_beats_the_incumbent_bar() { | |||
| 421 | let mut checked = 0; | 442 | let mut checked = 0; |
| 422 | for (name, channels, kbps, bar) in INCUMBENT_BAR { | 443 | for (name, channels, kbps, bar) in INCUMBENT_BAR { |
| 423 | let src = dir.join(format!("flac-{name}-48000.flac")); | 444 | let src = dir.join(format!("flac-{name}-48000.flac")); |
| 424 | - if !src.exists() { | 445 | + if !require_fixture(&src, "scripts/gen-fixtures.sh") { |
| 425 | - eprintln!("SKIP {name}: fixture missing"); | ||
| 426 | continue; | 446 | continue; |
| 427 | } | 447 | } |
| 428 | let source = ffmpeg_decode(&src, *channels); | 448 | let source = ffmpeg_decode(&src, *channels); |
| @@ -801,8 +821,7 @@ fn aac_stream(path: &Path) -> Option<(usize, usize, String)> { | |||
| 801 | #[test] | 821 | #[test] |
| 802 | fn five_one_decodes_faster_than_realtime() { | 822 | fn five_one_decodes_faster_than_realtime() { |
| 803 | let path = fixtures().join("audio/aac-adts-5.1-48000.aac"); | 823 | let path = fixtures().join("audio/aac-adts-5.1-48000.aac"); |
| 804 | - if !path.exists() { | 824 | + if !require_fixture(&path, "scripts/gen-fixtures.sh") { |
| 805 | - eprintln!("SKIP: 5.1 fixture missing"); | ||
| 806 | return; | 825 | return; |
| 807 | } | 826 | } |
| 808 | let data = std::fs::read(&path).expect("fixture readable"); | 827 | let data = std::fs::read(&path).expect("fixture readable"); |
crates/ec-aac/tests/sbr_real_library.rsmodified+260 -88
| @@ -38,6 +38,33 @@ fn have_ffmpeg() -> bool { | |||
| 38 | .unwrap_or(false) | 38 | .unwrap_or(false) |
| 39 | } | 39 | } |
| 40 | 40 | ||
| 41 | +/// Fixture-presence probe for the generated HE-AAC matrix under | ||
| 42 | +/// `<repo>/.cache/heaac-fixtures` (`scripts/aac-tables/make-heaac-fixtures.sh`). | ||
| 43 | +/// Returns whether the fixture is present, but never silently: under | ||
| 44 | +/// `EC_REQUIRE_FIXTURES=1` an absent fixture is a hard failure naming the path | ||
| 45 | +/// and the script that regenerates it, so a host whose fixture library drifted | ||
| 46 | +/// reports RED instead of a green SKIP (class: gate-skips-on-its-own-failure; | ||
| 47 | +/// model `have_ffmpeg` in crates/ec-av1/src/stream.rs, which was silently | ||
| 48 | +/// short-circuited because the probe ran first in a compound `if`). | ||
| 49 | +/// | ||
| 50 | +/// Order is load-bearing: probe, assert, return. Never merge the probe into | ||
| 51 | +/// the same `if` as the escape. The `~/Music` / `~/Downloads` / `~/Videos` | ||
| 52 | +/// scans in this file are host corpora, not the committed fixture library, and | ||
| 53 | +/// keep their plain skip. | ||
| 54 | +fn require_fixture(path: &Path, generator: &str) -> bool { | ||
| 55 | + let present = path.exists(); | ||
| 56 | + assert!( | ||
| 57 | + present || std::env::var_os("EC_REQUIRE_FIXTURES").is_none(), | ||
| 58 | + "EC_REQUIRE_FIXTURES=1 but fixture {} is absent -- regenerate with: {}", | ||
| 59 | + path.display(), | ||
| 60 | + generator | ||
| 61 | + ); | ||
| 62 | + if !present { | ||
| 63 | + eprintln!("SKIP: fixture {} absent", path.display()); | ||
| 64 | + } | ||
| 65 | + present | ||
| 66 | +} | ||
| 67 | + | ||
| 41 | /// A film's audio track is hours long; the correlation only needs a bounded | 68 | /// A film's audio track is hours long; the correlation only needs a bounded |
| 42 | /// window near the start, so both sides cap how much they ever decode. | 69 | /// window near the start, so both sides cap how much they ever decode. |
| 43 | const MAX_SAMPLES: usize = 1_000_000; | 70 | const MAX_SAMPLES: usize = 1_000_000; |
| @@ -437,7 +464,13 @@ fn exhaustive_lag_correlation(ours: &[f32], theirs: &[f32], lag_max: i64) -> (i6 | |||
| 437 | } | 464 | } |
| 438 | 465 | ||
| 439 | /// bucket (true if ITS coarse lag sat at the +/-`lag_max` search bound). | 466 | /// bucket (true if ITS coarse lag sat at the +/-`lag_max` search bound). |
| 440 | -fn robust_lag_topk(ours: &[f32], theirs: &[f32], lag_max: i64, rate: u32, k: usize) -> (i64, f64, bool) { | 467 | +fn robust_lag_topk( |
| 468 | + ours: &[f32], | ||
| 469 | + theirs: &[f32], | ||
| 470 | + lag_max: i64, | ||
| 471 | + rate: u32, | ||
| 472 | + k: usize, | ||
| 473 | +) -> (i64, f64, bool) { | ||
| 441 | const COARSE: usize = 4_096; | 474 | const COARSE: usize = 4_096; |
| 442 | let start = ours | 475 | let start = ours |
| 443 | .len() | 476 | .len() |
| @@ -2111,7 +2144,10 @@ fn our_decode_core_only(path: &Path, stream_index: usize) -> Option<(Vec<Vec<f32 | |||
| 2111 | if dump && au_idx < 40 { | 2144 | if dump && au_idx < 40 { |
| 2112 | for c in 0..ch { | 2145 | for c in 0..ch { |
| 2113 | let plane: Vec<f32> = frame.samples.iter().skip(c).step_by(ch).copied().collect(); | 2146 | let plane: Vec<f32> = frame.samples.iter().skip(c).step_by(ch).copied().collect(); |
| 2114 | - let rms = (plane.iter().map(|v| f64::from(*v) * f64::from(*v)).sum::<f64>() | 2147 | + let rms = (plane |
| 2148 | + .iter() | ||
| 2149 | + .map(|v| f64::from(*v) * f64::from(*v)) | ||
| 2150 | + .sum::<f64>() | ||
| 2115 | / plane.len().max(1) as f64) | 2151 | / plane.len().max(1) as f64) |
| 2116 | .sqrt(); | 2152 | .sqrt(); |
| 2117 | eprintln!( | 2153 | eprintln!( |
| @@ -2229,7 +2265,11 @@ fn core_only_matches_reference() { | |||
| 2229 | if at_edge { | 2265 | if at_edge { |
| 2230 | (lag, corr, at_edge) = exhaustive_lag_correlation(&ol, &tl, SEARCH_LAG_MAX); | 2266 | (lag, corr, at_edge) = exhaustive_lag_correlation(&ol, &tl, SEARCH_LAG_MAX); |
| 2231 | } | 2267 | } |
| 2232 | - let edge = if at_edge { " (AT SEARCH BOUND -- noise, not a measurement)" } else { "" }; | 2268 | + let edge = if at_edge { |
| 2269 | + " (AT SEARCH BOUND -- noise, not a measurement)" | ||
| 2270 | + } else { | ||
| 2271 | + "" | ||
| 2272 | + }; | ||
| 2233 | println!(" ch{ch}: below {cutoff:.0}Hz lag {lag}, corr {corr:.6}{edge}"); | 2273 | println!(" ch{ch}: below {cutoff:.0}Hz lag {lag}, corr {corr:.6}{edge}"); |
| 2234 | } | 2274 | } |
| 2235 | } | 2275 | } |
| @@ -2428,15 +2468,10 @@ fn synthetic_heaac_matrix() { | |||
| 2428 | eprintln!("SKIP: ffmpeg not on PATH"); | 2468 | eprintln!("SKIP: ffmpeg not on PATH"); |
| 2429 | return; | 2469 | return; |
| 2430 | } | 2470 | } |
| 2431 | - let dir = std::env::var("EC_AAC_HEAAC_FIXTURES").unwrap_or_else(|_| { | 2471 | + let dir = std::env::var("EC_AAC_HEAAC_FIXTURES") |
| 2432 | - format!("{}/../../.cache/heaac-fixtures", env!("CARGO_MANIFEST_DIR")) | 2472 | + .unwrap_or_else(|_| format!("{}/../../.cache/heaac-fixtures", env!("CARGO_MANIFEST_DIR"))); |
| 2433 | - }); | ||
| 2434 | let dir = PathBuf::from(dir); | 2473 | let dir = PathBuf::from(dir); |
| 2435 | - if !dir.is_dir() { | 2474 | + if !require_fixture(&dir, "scripts/aac-tables/make-heaac-fixtures.sh") { |
| 2436 | - eprintln!( | ||
| 2437 | - "SKIP: {} absent -- run scripts/aac-tables/make-heaac-fixtures.sh first", | ||
| 2438 | - dir.display() | ||
| 2439 | - ); | ||
| 2440 | return; | 2475 | return; |
| 2441 | } | 2476 | } |
| 2442 | unsafe { | 2477 | unsafe { |
| @@ -2444,14 +2479,31 @@ fn synthetic_heaac_matrix() { | |||
| 2444 | } | 2479 | } |
| 2445 | println!( | 2480 | println!( |
| 2446 | "{:>5} {:>6} {:>4} {:>4} {:>4} {:>8} {:>8} {:>8} {:>6} {:>11} {:>8} {:>10} {:>8} {:>9} {:>9}", | 2481 | "{:>5} {:>6} {:>4} {:>4} {:>4} {:>8} {:>8} {:>8} {:>6} {:>11} {:>8} {:>10} {:>8} {:>9} {:>9}", |
| 2447 | - "rate", "kbps", "prof", "kx", "k2", "full", "below", "above", "lag", "ours_v_core", "ovc_lag", | 2482 | + "rate", |
| 2448 | - "core_v_ref", "cvr_lag", "core_rate", "full_rate" | 2483 | + "kbps", |
| 2484 | + "prof", | ||
| 2485 | + "kx", | ||
| 2486 | + "k2", | ||
| 2487 | + "full", | ||
| 2488 | + "below", | ||
| 2489 | + "above", | ||
| 2490 | + "lag", | ||
| 2491 | + "ours_v_core", | ||
| 2492 | + "ovc_lag", | ||
| 2493 | + "core_v_ref", | ||
| 2494 | + "cvr_lag", | ||
| 2495 | + "core_rate", | ||
| 2496 | + "full_rate" | ||
| 2449 | ); | 2497 | ); |
| 2450 | // Wide enough that the WIDE_LAG_MAX==LC's own decoder priming delay | 2498 | // Wide enough that the WIDE_LAG_MAX==LC's own decoder priming delay |
| 2451 | // (2048) plus a full SBR-chain worth of extra delay (a few thousand | 2499 | // (2048) plus a full SBR-chain worth of extra delay (a few thousand |
| 2452 | // samples at the doubled/full output rate) both land well inside it, | 2500 | // samples at the doubled/full output rate) both land well inside it, |
| 2453 | // not right at the edge the way the plain (LAG_MAX=4000) search did. | 2501 | // not right at the edge the way the plain (LAG_MAX=4000) search did. |
| 2454 | const WIDE_LAG_MAX: i64 = 20_000; | 2502 | const WIDE_LAG_MAX: i64 = 20_000; |
| 2503 | + // Floor: the matrix is 2 rates x 4 bitrates x 2 profiles. Without a count | ||
| 2504 | + // the whole test is green having probed nothing, which is the same | ||
| 2505 | + // false-green this file's `require_fixture` exists to kill. | ||
| 2506 | + let mut probed = 0usize; | ||
| 2455 | for rate in [48_000u32, 44_100] { | 2507 | for rate in [48_000u32, 44_100] { |
| 2456 | for br in ["32k", "48k", "64k", "96k"] { | 2508 | for br in ["32k", "48k", "64k", "96k"] { |
| 2457 | // LC first: its winning lag is the pure container/decoder | 2509 | // LC first: its winning lag is the pure container/decoder |
| @@ -2460,10 +2512,10 @@ fn synthetic_heaac_matrix() { | |||
| 2460 | let mut lc_lag: Option<i64> = None; | 2512 | let mut lc_lag: Option<i64> = None; |
| 2461 | for (profile, prefix) in [("LC", "lc"), ("HE", "heaac")] { | 2513 | for (profile, prefix) in [("LC", "lc"), ("HE", "heaac")] { |
| 2462 | let path = dir.join(format!("{prefix}_{rate}_{br}.m4a")); | 2514 | let path = dir.join(format!("{prefix}_{rate}_{br}.m4a")); |
| 2463 | - if !path.exists() { | 2515 | + if !require_fixture(&path, "scripts/aac-tables/make-heaac-fixtures.sh") { |
| 2464 | - eprintln!("SKIP {}: missing", path.display()); | ||
| 2465 | continue; | 2516 | continue; |
| 2466 | } | 2517 | } |
| 2518 | + probed += 1; | ||
| 2467 | let before = ec_aac::sbr_sideinfo_log().len(); | 2519 | let before = ec_aac::sbr_sideinfo_log().len(); |
| 2468 | let Some((ours, _sbr, our_rate)) = our_decode(&path, 0) else { | 2520 | let Some((ours, _sbr, our_rate)) = our_decode(&path, 0) else { |
| 2469 | eprintln!("SKIP {}: could not decode", path.display()); | 2521 | eprintln!("SKIP {}: could not decode", path.display()); |
| @@ -2479,8 +2531,7 @@ fn synthetic_heaac_matrix() { | |||
| 2479 | let o = &ours[0]; | 2531 | let o = &ours[0]; |
| 2480 | let t = &theirs[0]; | 2532 | let t = &theirs[0]; |
| 2481 | const TOPK: usize = 5; | 2533 | const TOPK: usize = 5; |
| 2482 | - let (mut lag, mut full, edge) = | 2534 | + let (mut lag, mut full, edge) = robust_lag_topk(o, t, WIDE_LAG_MAX, our_rate, TOPK); |
| 2483 | - robust_lag_topk(o, t, WIDE_LAG_MAX, our_rate, TOPK); | ||
| 2484 | assert!( | 2535 | assert!( |
| 2485 | !edge, | 2536 | !edge, |
| 2486 | "{}: {profile} row's refined winning lag {lag} sits at the \ | 2537 | "{}: {profile} row's refined winning lag {lag} sits at the \ |
| @@ -2504,8 +2555,11 @@ fn synthetic_heaac_matrix() { | |||
| 2504 | if profile == "HE" && ours.len() >= 2 && theirs.len() >= 2 { | 2555 | if profile == "HE" && ours.len() >= 2 && theirs.len() >= 2 { |
| 2505 | let mono_o: Vec<f32> = | 2556 | let mono_o: Vec<f32> = |
| 2506 | ours[0].iter().zip(&ours[1]).map(|(a, b)| a + b).collect(); | 2557 | ours[0].iter().zip(&ours[1]).map(|(a, b)| a + b).collect(); |
| 2507 | - let mono_t: Vec<f32> = | 2558 | + let mono_t: Vec<f32> = theirs[0] |
| 2508 | - theirs[0].iter().zip(&theirs[1]).map(|(a, b)| a + b).collect(); | 2559 | + .iter() |
| 2560 | + .zip(&theirs[1]) | ||
| 2561 | + .map(|(a, b)| a + b) | ||
| 2562 | + .collect(); | ||
| 2509 | let (mono_lag, _, mono_edge) = | 2563 | let (mono_lag, _, mono_edge) = |
| 2510 | robust_lag_topk(&mono_o, &mono_t, WIDE_LAG_MAX, our_rate, TOPK); | 2564 | robust_lag_topk(&mono_o, &mono_t, WIDE_LAG_MAX, our_rate, TOPK); |
| 2511 | assert!( | 2565 | assert!( |
| @@ -2548,7 +2602,9 @@ fn synthetic_heaac_matrix() { | |||
| 2548 | } else { | 2602 | } else { |
| 2549 | ((-lag) as usize, 0usize) | 2603 | ((-lag) as usize, 0usize) |
| 2550 | }; | 2604 | }; |
| 2551 | - let n = WINDOW.min(o.len().saturating_sub(oa)).min(t.len().saturating_sub(ob)); | 2605 | + let n = WINDOW |
| 2606 | + .min(o.len().saturating_sub(oa)) | ||
| 2607 | + .min(t.len().saturating_sub(ob)); | ||
| 2552 | let above = if n >= 1024 { | 2608 | let above = if n >= 1024 { |
| 2553 | correlation( | 2609 | correlation( |
| 2554 | &highpass(&o[oa..oa + n], our_rate, crossover_hz), | 2610 | &highpass(&o[oa..oa + n], our_rate, crossover_hz), |
| @@ -2704,6 +2760,11 @@ fn synthetic_heaac_matrix() { | |||
| 2704 | } | 2760 | } |
| 2705 | } | 2761 | } |
| 2706 | } | 2762 | } |
| 2763 | + assert!( | ||
| 2764 | + probed >= 16, | ||
| 2765 | + "only {probed} of 16 HE-AAC matrix fixtures were present -- rerun \ | ||
| 2766 | + scripts/aac-tables/make-heaac-fixtures.sh" | ||
| 2767 | + ); | ||
| 2707 | } | 2768 | } |
| 2708 | 2769 | ||
| 2709 | fn candidates() -> Vec<Candidate> { | 2770 | fn candidates() -> Vec<Candidate> { |
| @@ -2886,8 +2947,14 @@ fn sbr_real_library_matches_reference() { | |||
| 2886 | let high = if n >= 1024 { | 2947 | let high = if n >= 1024 { |
| 2887 | let oh = highpass(&o[oa..oa + n], rate, c.crossover_hz); | 2948 | let oh = highpass(&o[oa..oa + n], rate, c.crossover_hz); |
| 2888 | let th = highpass(&t[ob..ob + n], rate, c.crossover_hz); | 2949 | let th = highpass(&t[ob..ob + n], rate, c.crossover_hz); |
| 2889 | - let rms = |v: &[f32]| (v.iter().map(|x| f64::from(*x).powi(2)).sum::<f64>() / v.len().max(1) as f64).sqrt(); | 2950 | + let rms = |v: &[f32]| { |
| 2890 | - println!(" ch{ch} above-crossover RMS ours/ref = {:.4}", rms(&oh) / rms(&th).max(1e-12)); | 2951 | + (v.iter().map(|x| f64::from(*x).powi(2)).sum::<f64>() / v.len().max(1) as f64) |
| 2952 | + .sqrt() | ||
| 2953 | + }; | ||
| 2954 | + println!( | ||
| 2955 | + " ch{ch} above-crossover RMS ours/ref = {:.4}", | ||
| 2956 | + rms(&oh) / rms(&th).max(1e-12) | ||
| 2957 | + ); | ||
| 2891 | correlation(&oh, &th) | 2958 | correlation(&oh, &th) |
| 2892 | } else { | 2959 | } else { |
| 2893 | 0.0 | 2960 | 0.0 |
| @@ -3154,7 +3221,10 @@ fn sbr_real_library_matches_reference() { | |||
| 3154 | ci += c.im; | 3221 | ci += c.im; |
| 3155 | } | 3222 | } |
| 3156 | let coh = (cr * cr + ci * ci).sqrt() / (eo * et).sqrt().max(1e-30); | 3223 | let coh = (cr * cr + ci * ci).sqrt() / (eo * et).sqrt().max(1e-30); |
| 3157 | - println!(" band{band:>3}: {:>7.2} dB coh {coh:.4}", 10.0 * (eo / et.max(1e-30)).log10()); | 3224 | + println!( |
| 3225 | + " band{band:>3}: {:>7.2} dB coh {coh:.4}", | ||
| 3226 | + 10.0 * (eo / et.max(1e-30)).log10() | ||
| 3227 | + ); | ||
| 3158 | } | 3228 | } |
| 3159 | } | 3229 | } |
| 3160 | let mean_in = |rows: &[(usize, f64)], lo: usize, hi: usize| { | 3230 | let mean_in = |rows: &[(usize, f64)], lo: usize, hi: usize| { |
| @@ -3559,7 +3629,10 @@ fn sbr_actual_noise_fraction() { | |||
| 3559 | // has nonzero entries for QMF bands up to `k2`). | 3629 | // has nonzero entries for QMF bands up to `k2`). |
| 3560 | let band_hz = f64::from(rate) / 128.0; | 3630 | let band_hz = f64::from(rate) / 128.0; |
| 3561 | let kx_band = bookkept.iter().map(|(b, ..)| *b).min().unwrap_or(0); | 3631 | let kx_band = bookkept.iter().map(|(b, ..)| *b).min().unwrap_or(0); |
| 3562 | - println!(" (crossover: QMF band {kx_band}, {:.0} Hz -- rows below it are core-decoded and excluded from the total)", kx_band as f64 * band_hz); | 3632 | + println!( |
| 3633 | + " (crossover: QMF band {kx_band}, {:.0} Hz -- rows below it are core-decoded and excluded from the total)", | ||
| 3634 | + kx_band as f64 * band_hz | ||
| 3635 | + ); | ||
| 3563 | println!( | 3636 | println!( |
| 3564 | " ACTUAL noise fraction (band_hz, energy_on, energy_off, actual_fraction, bookkept_fraction):" | 3637 | " ACTUAL noise fraction (band_hz, energy_on, energy_off, actual_fraction, bookkept_fraction):" |
| 3565 | ); | 3638 | ); |
| @@ -3712,15 +3785,14 @@ fn sbr_header_feature_table() { | |||
| 3712 | ffmpeg_stream: c.ffmpeg_stream, | 3785 | ffmpeg_stream: c.ffmpeg_stream, |
| 3713 | }) | 3786 | }) |
| 3714 | .collect(); | 3787 | .collect(); |
| 3715 | - let fixtures = std::env::var("EC_AAC_HEAAC_FIXTURES").unwrap_or_else(|_| { | 3788 | + let fixtures = std::env::var("EC_AAC_HEAAC_FIXTURES") |
| 3716 | - format!("{}/../../.cache/heaac-fixtures", env!("CARGO_MANIFEST_DIR")) | 3789 | + .unwrap_or_else(|_| format!("{}/../../.cache/heaac-fixtures", env!("CARGO_MANIFEST_DIR"))); |
| 3717 | - }); | ||
| 3718 | let fixtures = PathBuf::from(fixtures); | 3790 | let fixtures = PathBuf::from(fixtures); |
| 3719 | - if fixtures.is_dir() { | 3791 | + if require_fixture(&fixtures, "scripts/aac-tables/make-heaac-fixtures.sh") { |
| 3720 | for rate in [48_000u32, 44_100] { | 3792 | for rate in [48_000u32, 44_100] { |
| 3721 | for br in ["32k", "48k", "64k", "96k"] { | 3793 | for br in ["32k", "48k", "64k", "96k"] { |
| 3722 | let p = fixtures.join(format!("heaac_{rate}_{br}.m4a")); | 3794 | let p = fixtures.join(format!("heaac_{rate}_{br}.m4a")); |
| 3723 | - if p.exists() { | 3795 | + if require_fixture(&p, "scripts/aac-tables/make-heaac-fixtures.sh") { |
| 3724 | rows.push(Row { | 3796 | rows.push(Row { |
| 3725 | label: format!("synth-{rate}-{br}"), | 3797 | label: format!("synth-{rate}-{br}"), |
| 3726 | path: p, | 3798 | path: p, |
| @@ -3730,11 +3802,6 @@ fn sbr_header_feature_table() { | |||
| 3730 | } | 3802 | } |
| 3731 | } | 3803 | } |
| 3732 | } | 3804 | } |
| 3733 | - } else { | ||
| 3734 | - eprintln!( | ||
| 3735 | - "SKIP synthetic rows: {} absent -- run scripts/aac-tables/make-heaac-fixtures.sh first", | ||
| 3736 | - fixtures.display() | ||
| 3737 | - ); | ||
| 3738 | } | 3805 | } |
| 3739 | if rows.is_empty() { | 3806 | if rows.is_empty() { |
| 3740 | eprintln!("SKIP: no real HE-AAC files and no synthetic fixtures found"); | 3807 | eprintln!("SKIP: no real HE-AAC files and no synthetic fixtures found"); |
| @@ -3746,8 +3813,25 @@ fn sbr_header_feature_table() { | |||
| 3746 | const WIDE_LAG_MAX: i64 = 20_000; | 3813 | const WIDE_LAG_MAX: i64 = 20_000; |
| 3747 | println!( | 3814 | println!( |
| 3748 | "{:<20} {:>6} {:>4} {:>4} {:>4} {:>4} {:>4} {:>4} {:>4} {:>4} {:>4} {:>4} {:>5} {:>10} {:>10} {:>8} {:>8} {:>10} {:>6}", | 3815 | "{:<20} {:>6} {:>4} {:>4} {:>4} {:>4} {:>4} {:>4} {:>4} {:>4} {:>4} {:>4} {:>5} {:>10} {:>10} {:>8} {:>8} {:>10} {:>6}", |
| 3749 | - "stream", "rate", "kx", "k2", "xovr", "sfrq", "efrq", "fscl", "ascl", "nbnd", "lbnd", "lgn", | 3816 | + "stream", |
| 3750 | - "ifrq", "smooth", "envs", "invf", "harm", "df%", "corr" | 3817 | + "rate", |
| 3818 | + "kx", | ||
| 3819 | + "k2", | ||
| 3820 | + "xovr", | ||
| 3821 | + "sfrq", | ||
| 3822 | + "efrq", | ||
| 3823 | + "fscl", | ||
| 3824 | + "ascl", | ||
| 3825 | + "nbnd", | ||
| 3826 | + "lbnd", | ||
| 3827 | + "lgn", | ||
| 3828 | + "ifrq", | ||
| 3829 | + "smooth", | ||
| 3830 | + "envs", | ||
| 3831 | + "invf", | ||
| 3832 | + "harm", | ||
| 3833 | + "df%", | ||
| 3834 | + "corr" | ||
| 3751 | ); | 3835 | ); |
| 3752 | for r in &rows { | 3836 | for r in &rows { |
| 3753 | let before = ec_aac::sbr_sideinfo_log().len(); | 3837 | let before = ec_aac::sbr_sideinfo_log().len(); |
| @@ -3760,7 +3844,11 @@ fn sbr_header_feature_table() { | |||
| 3760 | continue; | 3844 | continue; |
| 3761 | } | 3845 | } |
| 3762 | let log = ec_aac::sbr_sideinfo_log(); | 3846 | let log = ec_aac::sbr_sideinfo_log(); |
| 3763 | - let frames: Vec<_> = log[before..].iter().filter(|row| row.ch == 0).take(20).collect(); | 3847 | + let frames: Vec<_> = log[before..] |
| 3848 | + .iter() | ||
| 3849 | + .filter(|row| row.ch == 0) | ||
| 3850 | + .take(20) | ||
| 3851 | + .collect(); | ||
| 3764 | if frames.is_empty() { | 3852 | if frames.is_empty() { |
| 3765 | eprintln!("SKIP {}: no sideinfo rows captured", r.label); | 3853 | eprintln!("SKIP {}: no sideinfo rows captured", r.label); |
| 3766 | continue; | 3854 | continue; |
| @@ -3772,13 +3860,24 @@ fn sbr_header_feature_table() { | |||
| 3772 | let mut df_total = 0usize; | 3860 | let mut df_total = 0usize; |
| 3773 | let mut df_ones = 0usize; | 3861 | let mut df_ones = 0usize; |
| 3774 | for row in &frames { | 3862 | for row in &frames { |
| 3775 | - *env_counts.entry(row.t_env.len().saturating_sub(1)).or_default() += 1; | 3863 | + *env_counts |
| 3864 | + .entry(row.t_env.len().saturating_sub(1)) | ||
| 3865 | + .or_default() += 1; | ||
| 3776 | invf_seen.extend(&row.invf_mode); | 3866 | invf_seen.extend(&row.invf_mode); |
| 3777 | - if row.add_harmonic.as_ref().is_some_and(|h| h.iter().any(|&v| v != 0)) { | 3867 | + if row |
| 3868 | + .add_harmonic | ||
| 3869 | + .as_ref() | ||
| 3870 | + .is_some_and(|h| h.iter().any(|&v| v != 0)) | ||
| 3871 | + { | ||
| 3778 | any_harmonic = true; | 3872 | any_harmonic = true; |
| 3779 | } | 3873 | } |
| 3780 | df_total += row.df_env.len() + row.df_noise.len(); | 3874 | df_total += row.df_env.len() + row.df_noise.len(); |
| 3781 | - df_ones += row.df_env.iter().chain(&row.df_noise).filter(|&&b| b != 0).count(); | 3875 | + df_ones += row |
| 3876 | + .df_env | ||
| 3877 | + .iter() | ||
| 3878 | + .chain(&row.df_noise) | ||
| 3879 | + .filter(|&&b| b != 0) | ||
| 3880 | + .count(); | ||
| 3782 | } | 3881 | } |
| 3783 | let df_pct = if df_total > 0 { | 3882 | let df_pct = if df_total > 0 { |
| 3784 | 100.0 * df_ones as f64 / df_total as f64 | 3883 | 100.0 * df_ones as f64 / df_total as f64 |
| @@ -3790,20 +3889,36 @@ fn sbr_header_feature_table() { | |||
| 3790 | .map(|(k, v)| format!("{k}x{v}")) | 3889 | .map(|(k, v)| format!("{k}x{v}")) |
| 3791 | .collect::<Vec<_>>() | 3890 | .collect::<Vec<_>>() |
| 3792 | .join(","); | 3891 | .join(","); |
| 3793 | - let invf_str: String = invf_seen.iter().map(|v| v.to_string()).collect::<Vec<_>>().join(""); | 3892 | + let invf_str: String = invf_seen |
| 3893 | + .iter() | ||
| 3894 | + .map(|v| v.to_string()) | ||
| 3895 | + .collect::<Vec<_>>() | ||
| 3896 | + .join(""); | ||
| 3794 | let theirs = ffmpeg_decode(&r.path, r.ffmpeg_stream, ours.len()); | 3897 | let theirs = ffmpeg_decode(&r.path, r.ffmpeg_stream, ours.len()); |
| 3795 | let (_, corr) = best_lag_correlation_wide(&ours[0], &theirs[0], WIDE_LAG_MAX); | 3898 | let (_, corr) = best_lag_correlation_wide(&ours[0], &theirs[0], WIDE_LAG_MAX); |
| 3796 | println!( | 3899 | println!( |
| 3797 | "{:<20} {:>6} {:>4} {:>4} {:>4} {:>4} {:>4} {:>4} {:>4} {:>4} {:>4} {:>4} {:>5} {:>10} {:>10} {:>8} {:>8} {:>10.1} {:>6.3}", | 3900 | "{:<20} {:>6} {:>4} {:>4} {:>4} {:>4} {:>4} {:>4} {:>4} {:>4} {:>4} {:>4} {:>5} {:>10} {:>10} {:>8} {:>8} {:>10.1} {:>6.3}", |
| 3798 | - r.label, our_rate, f0.kx, f0.k2, f0.xover_band, f0.start_freq, f0.stop_freq, | 3901 | + r.label, |
| 3799 | - f0.freq_scale, f0.alter_scale, f0.noise_bands, f0.limiter_bands, f0.limiter_gains, | 3902 | + our_rate, |
| 3800 | - f0.interpol_freq, f0.smoothing_mode, envs_hist, invf_str, | 3903 | + f0.kx, |
| 3801 | - any_harmonic, df_pct, corr | 3904 | + f0.k2, |
| 3802 | - ); | 3905 | + f0.xover_band, |
| 3803 | - println!( | 3906 | + f0.start_freq, |
| 3804 | - " patches (frame0): {:?}", | 3907 | + f0.stop_freq, |
| 3805 | - f0.patch_lengths | 3908 | + f0.freq_scale, |
| 3909 | + f0.alter_scale, | ||
| 3910 | + f0.noise_bands, | ||
| 3911 | + f0.limiter_bands, | ||
| 3912 | + f0.limiter_gains, | ||
| 3913 | + f0.interpol_freq, | ||
| 3914 | + f0.smoothing_mode, | ||
| 3915 | + envs_hist, | ||
| 3916 | + invf_str, | ||
| 3917 | + any_harmonic, | ||
| 3918 | + df_pct, | ||
| 3919 | + corr | ||
| 3806 | ); | 3920 | ); |
| 3921 | + println!(" patches (frame0): {:?}", f0.patch_lengths); | ||
| 3807 | } | 3922 | } |
| 3808 | } | 3923 | } |
| 3809 | 3924 | ||
| @@ -3874,7 +3989,11 @@ fn per_au_low_band_probe(label: &str, path: &Path, aac_stream: usize) { | |||
| 3874 | } | 3989 | } |
| 3875 | } | 3990 | } |
| 3876 | if core_ch0.is_empty() || full_ch0.is_empty() { | 3991 | if core_ch0.is_empty() || full_ch0.is_empty() { |
| 3877 | - eprintln!("SKIP {label}: empty decode (core {} full {})", core_ch0.len(), full_ch0.len()); | 3992 | + eprintln!( |
| 3993 | + "SKIP {label}: empty decode (core {} full {})", | ||
| 3994 | + core_ch0.len(), | ||
| 3995 | + full_ch0.len() | ||
| 3996 | + ); | ||
| 3878 | return; | 3997 | return; |
| 3879 | } | 3998 | } |
| 3880 | 3999 | ||
| @@ -3949,14 +4068,11 @@ fn per_au_low_band_divergence() { | |||
| 3949 | for c in &candidates() { | 4068 | for c in &candidates() { |
| 3950 | per_au_low_band_probe(&c.path.display().to_string(), &c.path, c.aac_stream); | 4069 | per_au_low_band_probe(&c.path.display().to_string(), &c.path, c.aac_stream); |
| 3951 | } | 4070 | } |
| 3952 | - let dir = std::env::var("EC_AAC_HEAAC_FIXTURES").unwrap_or_else(|_| { | 4071 | + let dir = std::env::var("EC_AAC_HEAAC_FIXTURES") |
| 3953 | - format!("{}/../../.cache/heaac-fixtures", env!("CARGO_MANIFEST_DIR")) | 4072 | + .unwrap_or_else(|_| format!("{}/../../.cache/heaac-fixtures", env!("CARGO_MANIFEST_DIR"))); |
| 3954 | - }); | ||
| 3955 | let failing = PathBuf::from(&dir).join("heaac_44100_48k.m4a"); | 4073 | let failing = PathBuf::from(&dir).join("heaac_44100_48k.m4a"); |
| 3956 | - if failing.exists() { | 4074 | + if require_fixture(&failing, "scripts/aac-tables/make-heaac-fixtures.sh") { |
| 3957 | per_au_low_band_probe("synthetic 44100 48k (failing)", &failing, 0); | 4075 | per_au_low_band_probe("synthetic 44100 48k (failing)", &failing, 0); |
| 3958 | - } else { | ||
| 3959 | - eprintln!("SKIP synthetic 44100 48k: {} absent", failing.display()); | ||
| 3960 | } | 4076 | } |
| 3961 | } | 4077 | } |
| 3962 | 4078 | ||
| @@ -4003,7 +4119,20 @@ fn probe_explicit_config_and_wide_lag() { | |||
| 4003 | (planes, rate) | 4119 | (planes, rate) |
| 4004 | } | 4120 | } |
| 4005 | 4121 | ||
| 4006 | - for (label, path, aac_stream, ffmpeg_stream, core_sf_index, core_rate, ext_rate, channels) in [ | 4122 | + // `synthetic` marks the case as coming from the committed fixture library |
| 4123 | + // (`scripts/aac-tables/make-heaac-fixtures.sh`); the FMJ row is a | ||
| 4124 | + // `~/Downloads` host corpus and keeps its plain skip. | ||
| 4125 | + for ( | ||
| 4126 | + label, | ||
| 4127 | + path, | ||
| 4128 | + aac_stream, | ||
| 4129 | + ffmpeg_stream, | ||
| 4130 | + core_sf_index, | ||
| 4131 | + core_rate, | ||
| 4132 | + ext_rate, | ||
| 4133 | + channels, | ||
| 4134 | + synthetic, | ||
| 4135 | + ) in [ | ||
| 4007 | ( | 4136 | ( |
| 4008 | "FMJ", | 4137 | "FMJ", |
| 4009 | format!( | 4138 | format!( |
| @@ -4016,6 +4145,7 @@ fn probe_explicit_config_and_wide_lag() { | |||
| 4016 | 24_000u32, | 4145 | 24_000u32, |
| 4017 | 48_000u32, | 4146 | 48_000u32, |
| 4018 | 2u16, | 4147 | 2u16, |
| 4148 | + false, | ||
| 4019 | ), | 4149 | ), |
| 4020 | ( | 4150 | ( |
| 4021 | "heaac_44100_48k", | 4151 | "heaac_44100_48k", |
| @@ -4029,10 +4159,15 @@ fn probe_explicit_config_and_wide_lag() { | |||
| 4029 | 44_100, | 4159 | 44_100, |
| 4030 | 0, // filled below from parsed cfg's own extension_sample_rate | 4160 | 0, // filled below from parsed cfg's own extension_sample_rate |
| 4031 | 2, | 4161 | 2, |
| 4162 | + true, | ||
| 4032 | ), | 4163 | ), |
| 4033 | ] { | 4164 | ] { |
| 4034 | let path = PathBuf::from(path); | 4165 | let path = PathBuf::from(path); |
| 4035 | - if !path.exists() { | 4166 | + if synthetic { |
| 4167 | + if !require_fixture(&path, "scripts/aac-tables/make-heaac-fixtures.sh") { | ||
| 4168 | + continue; | ||
| 4169 | + } | ||
| 4170 | + } else if !path.exists() { | ||
| 4036 | eprintln!("SKIP {label}: {} absent", path.display()); | 4171 | eprintln!("SKIP {label}: {} absent", path.display()); |
| 4037 | continue; | 4172 | continue; |
| 4038 | } | 4173 | } |
| @@ -4097,7 +4232,9 @@ fn probe_explicit_config_and_wide_lag() { | |||
| 4097 | let theirs = ffmpeg_decode(&path, ffmpeg_stream, hand_planes.len()); | 4232 | let theirs = ffmpeg_decode(&path, ffmpeg_stream, hand_planes.len()); |
| 4098 | if let (Some(o), Some(t)) = (hand_planes.first(), theirs.first()) { | 4233 | if let (Some(o), Some(t)) = (hand_planes.first(), theirs.first()) { |
| 4099 | let (lag, corr) = best_lag_correlation_wide(o, t, 100_000); | 4234 | let (lag, corr) = best_lag_correlation_wide(o, t, 100_000); |
| 4100 | - println!(" hand-built explicit config: full-band vs reference: lag={lag} corr={corr:.6}"); | 4235 | + println!( |
| 4236 | + " hand-built explicit config: full-band vs reference: lag={lag} corr={corr:.6}" | ||
| 4237 | + ); | ||
| 4101 | } | 4238 | } |
| 4102 | } | 4239 | } |
| 4103 | 4240 | ||
| @@ -4111,10 +4248,9 @@ fn probe_explicit_config_and_wide_lag() { | |||
| 4111 | "{home}/Downloads/reelp/reelp.mkv" | 4248 | "{home}/Downloads/reelp/reelp.mkv" |
| 4112 | )); | 4249 | )); |
| 4113 | if fmj.exists() { | 4250 | if fmj.exists() { |
| 4114 | - if let (Some((core, core_rate)), Some((full, sbr, full_rate))) = ( | 4251 | + if let (Some((core, core_rate)), Some((full, sbr, full_rate))) = |
| 4115 | - our_decode_core_only(&fmj, 1), | 4252 | + (our_decode_core_only(&fmj, 1), our_decode(&fmj, 1)) |
| 4116 | - our_decode(&fmj, 1), | 4253 | + { |
| 4117 | - ) { | ||
| 4118 | if sbr == ec_aac::SbrSupport::V1 { | 4254 | if sbr == ec_aac::SbrSupport::V1 { |
| 4119 | let up: Vec<f32> = core[0].iter().flat_map(|&s| [s, s]).collect(); | 4255 | let up: Vec<f32> = core[0].iter().flat_map(|&s| [s, s]).collect(); |
| 4120 | let cutoff = f64::from(core_rate) * 0.4; | 4256 | let cutoff = f64::from(core_rate) * 0.4; |
| @@ -4239,12 +4375,10 @@ fn coupled_cpe_channel_swap_probe() { | |||
| 4239 | eprintln!("SKIP: ffmpeg not on PATH"); | 4375 | eprintln!("SKIP: ffmpeg not on PATH"); |
| 4240 | return; | 4376 | return; |
| 4241 | } | 4377 | } |
| 4242 | - let dir = std::env::var("EC_AAC_HEAAC_FIXTURES").unwrap_or_else(|_| { | 4378 | + let dir = std::env::var("EC_AAC_HEAAC_FIXTURES") |
| 4243 | - format!("{}/../../.cache/heaac-fixtures", env!("CARGO_MANIFEST_DIR")) | 4379 | + .unwrap_or_else(|_| format!("{}/../../.cache/heaac-fixtures", env!("CARGO_MANIFEST_DIR"))); |
| 4244 | - }); | ||
| 4245 | let path = PathBuf::from(&dir).join("heaac_44100_48k.m4a"); | 4380 | let path = PathBuf::from(&dir).join("heaac_44100_48k.m4a"); |
| 4246 | - if !path.exists() { | 4381 | + if !require_fixture(&path, "scripts/aac-tables/make-heaac-fixtures.sh") { |
| 4247 | - eprintln!("SKIP: {} absent", path.display()); | ||
| 4248 | return; | 4382 | return; |
| 4249 | } | 4383 | } |
| 4250 | let Some((ours, sbr, out_rate)) = our_decode(&path, 0) else { | 4384 | let Some((ours, sbr, out_rate)) = our_decode(&path, 0) else { |
| @@ -4256,7 +4390,10 @@ fn coupled_cpe_channel_swap_probe() { | |||
| 4256 | let ref_r = ffmpeg_decode_pan_channel(&path, 0, 1); | 4390 | let ref_r = ffmpeg_decode_pan_channel(&path, 0, 1); |
| 4257 | { | 4391 | { |
| 4258 | let n = ref_l.len().min(ref_r.len()).min(WINDOW); | 4392 | let n = ref_l.len().min(ref_r.len()).min(WINDOW); |
| 4259 | - println!("ref L vs ref R (no lag): corr={:.6}", correlation(&ref_l[..n], &ref_r[..n])); | 4393 | + println!( |
| 4394 | + "ref L vs ref R (no lag): corr={:.6}", | ||
| 4395 | + correlation(&ref_l[..n], &ref_r[..n]) | ||
| 4396 | + ); | ||
| 4260 | let (lag, corr) = best_lag_correlation_wide(&ref_l, &ref_r, SEARCH_LAG_MAX); | 4397 | let (lag, corr) = best_lag_correlation_wide(&ref_l, &ref_r, SEARCH_LAG_MAX); |
| 4261 | println!("ref L vs ref R (best lag search): lag={lag} corr={corr:.6}"); | 4398 | println!("ref L vs ref R (best lag search): lag={lag} corr={corr:.6}"); |
| 4262 | } | 4399 | } |
| @@ -4329,11 +4466,17 @@ fn coupled_cpe_channel_swap_probe() { | |||
| 4329 | let (core_lag0, core_corr0) = | 4466 | let (core_lag0, core_corr0) = |
| 4330 | best_lag_correlation_wide(&core_planes[0], &ref_core[0], SEARCH_LAG_MAX); | 4467 | best_lag_correlation_wide(&core_planes[0], &ref_core[0], SEARCH_LAG_MAX); |
| 4331 | let core_implied_lag = core_lag0 * 2; | 4468 | let core_implied_lag = core_lag0 * 2; |
| 4332 | - println!("core ch0 vs ref L best lag={core_lag0} corr={core_corr0:.6} -> implied full-rate lag={core_implied_lag}"); | 4469 | + println!( |
| 4470 | + "core ch0 vs ref L best lag={core_lag0} corr={core_corr0:.6} -> implied full-rate lag={core_implied_lag}" | ||
| 4471 | + ); | ||
| 4333 | let mono_ours: Vec<f32> = ours[0].iter().zip(&ours[1]).map(|(a, b)| a + b).collect(); | 4472 | let mono_ours: Vec<f32> = ours[0].iter().zip(&ours[1]).map(|(a, b)| a + b).collect(); |
| 4334 | let mono_ref: Vec<f32> = { | 4473 | let mono_ref: Vec<f32> = { |
| 4335 | let n = ref_l.len().min(ref_r.len()); | 4474 | let n = ref_l.len().min(ref_r.len()); |
| 4336 | - ref_l[..n].iter().zip(&ref_r[..n]).map(|(a, b)| a + b).collect() | 4475 | + ref_l[..n] |
| 4476 | + .iter() | ||
| 4477 | + .zip(&ref_r[..n]) | ||
| 4478 | + .map(|(a, b)| a + b) | ||
| 4479 | + .collect() | ||
| 4337 | }; | 4480 | }; |
| 4338 | let (mono_lag, mono_corr) = best_lag_correlation_wide(&mono_ours, &mono_ref, SEARCH_LAG_MAX); | 4481 | let (mono_lag, mono_corr) = best_lag_correlation_wide(&mono_ours, &mono_ref, SEARCH_LAG_MAX); |
| 4339 | println!("mono (ch0+ch1) vs ref (L+R) best lag={mono_lag} corr={mono_corr:.6}"); | 4482 | println!("mono (ch0+ch1) vs ref (L+R) best lag={mono_lag} corr={mono_corr:.6}"); |
| @@ -4349,7 +4492,15 @@ fn coupled_cpe_channel_swap_probe() { | |||
| 4349 | // corr=0.873 above). So the TRUE best lag among our 4 candidates is | 4492 | // corr=0.873 above). So the TRUE best lag among our 4 candidates is |
| 4350 | // whichever one actually maximizes the fixed-lag mono correlation, not | 4493 | // whichever one actually maximizes the fixed-lag mono correlation, not |
| 4351 | // whatever `mono_lag` the free search reported. | 4494 | // whatever `mono_lag` the free search reported. |
| 4352 | - let mut true_best = (mono_lag, "mono-best lag (free search)", 0.0f64, 0.0f64, 0.0f64, 0.0f64, mono_corr); | 4495 | + let mut true_best = ( |
| 4496 | + mono_lag, | ||
| 4497 | + "mono-best lag (free search)", | ||
| 4498 | + 0.0f64, | ||
| 4499 | + 0.0f64, | ||
| 4500 | + 0.0f64, | ||
| 4501 | + 0.0f64, | ||
| 4502 | + mono_corr, | ||
| 4503 | + ); | ||
| 4353 | for (lag, label) in fixed_lags { | 4504 | for (lag, label) in fixed_lags { |
| 4354 | let c0l = correlation_at_lag(&ours[0], &ref_l, lag); | 4505 | let c0l = correlation_at_lag(&ours[0], &ref_l, lag); |
| 4355 | let c0r = correlation_at_lag(&ours[0], &ref_r, lag); | 4506 | let c0r = correlation_at_lag(&ours[0], &ref_r, lag); |
| @@ -4398,7 +4549,9 @@ fn coupled_cpe_channel_swap_probe() { | |||
| 4398 | } | 4549 | } |
| 4399 | let cl = correlation(&ours[0][oa..oa + step], &ref_l[ob..ob + step]); | 4550 | let cl = correlation(&ours[0][oa..oa + step], &ref_l[ob..ob + step]); |
| 4400 | let cr = correlation(&ours[0][oa..oa + step], &ref_r[ob..ob + step]); | 4551 | let cr = correlation(&ours[0][oa..oa + step], &ref_r[ob..ob + step]); |
| 4401 | - println!("subwindow t={w}s ch0 vs ref L/R @ lag {best_lag}: corr(L)={cl:.6} corr(R)={cr:.6}"); | 4552 | + println!( |
| 4553 | + "subwindow t={w}s ch0 vs ref L/R @ lag {best_lag}: corr(L)={cl:.6} corr(R)={cr:.6}" | ||
| 4554 | + ); | ||
| 4402 | w += 1; | 4555 | w += 1; |
| 4403 | } | 4556 | } |
| 4404 | } | 4557 | } |
| @@ -4569,15 +4722,18 @@ fn sbr441_family_sample_drift_probe() { | |||
| 4569 | eprintln!("SKIP: ffmpeg not on PATH"); | 4722 | eprintln!("SKIP: ffmpeg not on PATH"); |
| 4570 | return; | 4723 | return; |
| 4571 | } | 4724 | } |
| 4572 | - let dir = std::env::var("EC_AAC_HEAAC_FIXTURES").unwrap_or_else(|_| { | 4725 | + let dir = std::env::var("EC_AAC_HEAAC_FIXTURES") |
| 4573 | - format!("{}/../../.cache/heaac-fixtures", env!("CARGO_MANIFEST_DIR")) | 4726 | + .unwrap_or_else(|_| format!("{}/../../.cache/heaac-fixtures", env!("CARGO_MANIFEST_DIR"))); |
| 4574 | - }); | ||
| 4575 | let home = std::env::var("HOME").unwrap_or_default(); | 4727 | let home = std::env::var("HOME").unwrap_or_default(); |
| 4576 | - let cases: [(&str, PathBuf, i64); 3] = [ | 4728 | + // `synthetic` marks the rows served by the committed fixture library |
| 4729 | + // (`scripts/aac-tables/make-heaac-fixtures.sh`); the reeln control is | ||
| 4730 | + // a `~/Music` host corpus and keeps its plain skip. | ||
| 4731 | + let cases: [(&str, PathBuf, i64, bool); 3] = [ | ||
| 4577 | ( | 4732 | ( |
| 4578 | "heaac_44100_48k (FAIL family)", | 4733 | "heaac_44100_48k (FAIL family)", |
| 4579 | PathBuf::from(&dir).join("heaac_44100_48k.m4a"), | 4734 | PathBuf::from(&dir).join("heaac_44100_48k.m4a"), |
| 4580 | -4674, | 4735 | -4674, |
| 4736 | + true, | ||
| 4581 | ), | 4737 | ), |
| 4582 | ( | 4738 | ( |
| 4583 | "heaac_48000_48k (48k control)", | 4739 | "heaac_48000_48k (48k control)", |
| @@ -4586,6 +4742,7 @@ fn sbr441_family_sample_drift_probe() { | |||
| 4586 | // (below) -- 0 was a bad guess, true fixed lag is -4673, same | 4742 | // (below) -- 0 was a bad guess, true fixed lag is -4673, same |
| 4587 | // as the failing family's. | 4743 | // as the failing family's. |
| 4588 | -4673, | 4744 | -4673, |
| 4745 | + true, | ||
| 4589 | ), | 4746 | ), |
| 4590 | ( | 4747 | ( |
| 4591 | "reeln (44.1k control)", | 4748 | "reeln (44.1k control)", |
| @@ -4595,11 +4752,16 @@ fn sbr441_family_sample_drift_probe() { | |||
| 4595 | // from an earlier probe, not its full-chain-vs-ffmpeg-reference | 4752 | // from an earlier probe, not its full-chain-vs-ffmpeg-reference |
| 4596 | // lag, which is +385. | 4753 | // lag, which is +385. |
| 4597 | 385, | 4754 | 385, |
| 4755 | + false, | ||
| 4598 | ), | 4756 | ), |
| 4599 | ]; | 4757 | ]; |
| 4600 | - for (label, path, seed_lag) in cases { | 4758 | + for (label, path, seed_lag, synthetic) in cases { |
| 4601 | println!("\n=== {label}: {} ===", path.display()); | 4759 | println!("\n=== {label}: {} ===", path.display()); |
| 4602 | - if !path.exists() { | 4760 | + if synthetic { |
| 4761 | + if !require_fixture(&path, "scripts/aac-tables/make-heaac-fixtures.sh") { | ||
| 4762 | + continue; | ||
| 4763 | + } | ||
| 4764 | + } else if !path.exists() { | ||
| 4603 | eprintln!("SKIP {label}: {} absent", path.display()); | 4765 | eprintln!("SKIP {label}: {} absent", path.display()); |
| 4604 | continue; | 4766 | continue; |
| 4605 | } | 4767 | } |
| @@ -4690,12 +4852,10 @@ fn sbr_hf_window_band_probe() { | |||
| 4690 | eprintln!("SKIP: ffmpeg not on PATH"); | 4852 | eprintln!("SKIP: ffmpeg not on PATH"); |
| 4691 | return; | 4853 | return; |
| 4692 | } | 4854 | } |
| 4693 | - let dir = std::env::var("EC_AAC_HEAAC_FIXTURES").unwrap_or_else(|_| { | 4855 | + let dir = std::env::var("EC_AAC_HEAAC_FIXTURES") |
| 4694 | - format!("{}/../../.cache/heaac-fixtures", env!("CARGO_MANIFEST_DIR")) | 4856 | + .unwrap_or_else(|_| format!("{}/../../.cache/heaac-fixtures", env!("CARGO_MANIFEST_DIR"))); |
| 4695 | - }); | ||
| 4696 | let path = PathBuf::from(&dir).join("heaac_48000_64k.m4a"); | 4857 | let path = PathBuf::from(&dir).join("heaac_48000_64k.m4a"); |
| 4697 | - if !path.exists() { | 4858 | + if !require_fixture(&path, "scripts/aac-tables/make-heaac-fixtures.sh") { |
| 4698 | - eprintln!("SKIP: {} absent", path.display()); | ||
| 4699 | return; | 4859 | return; |
| 4700 | } | 4860 | } |
| 4701 | const LAG: i64 = -4673; | 4861 | const LAG: i64 = -4673; |
| @@ -4748,7 +4908,10 @@ fn sbr_hf_window_band_probe() { | |||
| 4748 | let mean_t: f64 = mags_t.iter().sum::<f64>() / 8.0; | 4908 | let mean_t: f64 = mags_t.iter().sum::<f64>() / 8.0; |
| 4749 | println!( | 4909 | println!( |
| 4750 | " band{band:>3}: |ours|dB mean={mean_o:>7.2} |ref|dB mean={mean_t:>7.2} dphase(deg)={:?}", | 4910 | " band{band:>3}: |ours|dB mean={mean_o:>7.2} |ref|dB mean={mean_t:>7.2} dphase(deg)={:?}", |
| 4751 | - dphase_deg.iter().map(|d| format!("{d:.0}")).collect::<Vec<_>>() | 4911 | + dphase_deg |
| 4912 | + .iter() | ||
| 4913 | + .map(|d| format!("{d:.0}")) | ||
| 4914 | + .collect::<Vec<_>>() | ||
| 4752 | ); | 4915 | ); |
| 4753 | } | 4916 | } |
| 4754 | } | 4917 | } |
| @@ -4803,7 +4966,9 @@ fn sbr_residual_locator() { | |||
| 4803 | if !path.exists() { | 4966 | if !path.exists() { |
| 4804 | return; | 4967 | return; |
| 4805 | } | 4968 | } |
| 4806 | - let Some((ours, _, rate)) = our_decode(&path, 0) else { return }; | 4969 | + let Some((ours, _, rate)) = our_decode(&path, 0) else { |
| 4970 | + return; | ||
| 4971 | + }; | ||
| 4807 | let theirs = ffmpeg_decode(&path, 0, ours.len()); | 4972 | let theirs = ffmpeg_decode(&path, 0, ours.len()); |
| 4808 | const W: usize = 2048; | 4973 | const W: usize = 2048; |
| 4809 | const FFT_LEN: usize = 2048; | 4974 | const FFT_LEN: usize = 2048; |
| @@ -4815,7 +4980,12 @@ fn sbr_residual_locator() { | |||
| 4815 | let n = ours[ch].len().min(theirs[ch].len()); | 4980 | let n = ours[ch].len().min(theirs[ch].len()); |
| 4816 | let (o, t) = (&ours[ch][..n], &theirs[ch][..n]); | 4981 | let (o, t) = (&ours[ch][..n], &theirs[ch][..n]); |
| 4817 | let mut wins: Vec<(f64, usize)> = (0..n / W) | 4982 | let mut wins: Vec<(f64, usize)> = (0..n / W) |
| 4818 | - .map(|w| (correlation(&o[w * W..(w + 1) * W], &t[w * W..(w + 1) * W]), w)) | 4983 | + .map(|w| { |
| 4984 | + ( | ||
| 4985 | + correlation(&o[w * W..(w + 1) * W], &t[w * W..(w + 1) * W]), | ||
| 4986 | + w, | ||
| 4987 | + ) | ||
| 4988 | + }) | ||
| 4819 | .collect(); | 4989 | .collect(); |
| 4820 | wins.sort_by(|a, b| a.0.partial_cmp(&b.0).unwrap()); | 4990 | wins.sort_by(|a, b| a.0.partial_cmp(&b.0).unwrap()); |
| 4821 | println!("ch{ch} worst windows (corr, frame): {:?}", &wins[..12]); | 4991 | println!("ch{ch} worst windows (corr, frame): {:?}", &wins[..12]); |
| @@ -4865,7 +5035,9 @@ fn sbr_residual_locator() { | |||
| 4865 | } | 5035 | } |
| 4866 | } | 5036 | } |
| 4867 | // group into 250 Hz bands up to 8 kHz, then 1 kHz | 5037 | // group into 250 Hz bands up to 8 kHz, then 1 kHz |
| 4868 | - let mut edges: Vec<usize> = (0..=32).map(|i| ((i as f64 * 250.0) / hz) as usize).collect(); | 5038 | + let mut edges: Vec<usize> = (0..=32) |
| 5039 | + .map(|i| ((i as f64 * 250.0) / hz) as usize) | ||
| 5040 | + .collect(); | ||
| 4869 | edges.extend((9..=22).map(|i| ((i as f64 * 1000.0) / hz) as usize)); | 5041 | edges.extend((9..=22).map(|i| ((i as f64 * 1000.0) / hz) as usize)); |
| 4870 | for e in edges.windows(2) { | 5042 | for e in edges.windows(2) { |
| 4871 | let (mut c, mut po, mut pt) = (0.0, 0.0, 0.0); | 5043 | let (mut c, mut po, mut pt) = (0.0, 0.0, 0.0); |
crates/ec-flac/tests/encode_matrix.rsmodified+56 -11
| @@ -20,6 +20,30 @@ struct Source { | |||
| 20 | bits: u32, | 20 | bits: u32, |
| 21 | } | 21 | } |
| 22 | 22 | ||
| 23 | +/// Fixture-presence probe for the encoder matrix corpus. | ||
| 24 | +/// Returns whether the fixture is present, but never silently: under | ||
| 25 | +/// `EC_REQUIRE_FIXTURES=1` an absent fixture is a hard failure naming the path | ||
| 26 | +/// and the script that regenerates it, so a host whose fixture library drifted | ||
| 27 | +/// reports RED instead of a green SKIP (class: gate-skips-on-its-own-failure; | ||
| 28 | +/// model `have_ffmpeg` in crates/ec-av1/src/stream.rs, which was silently | ||
| 29 | +/// short-circuited because the probe ran first in a compound `if`). | ||
| 30 | +/// | ||
| 31 | +/// Order is load-bearing: probe, assert, return. Never merge the probe into | ||
| 32 | +/// the same `if` as the escape. | ||
| 33 | +fn require_fixture(path: &Path, generator: &str) -> bool { | ||
| 34 | + let present = path.exists(); | ||
| 35 | + assert!( | ||
| 36 | + present || std::env::var_os("EC_REQUIRE_FIXTURES").is_none(), | ||
| 37 | + "EC_REQUIRE_FIXTURES=1 but fixture {} is absent -- regenerate with: {}", | ||
| 38 | + path.display(), | ||
| 39 | + generator | ||
| 40 | + ); | ||
| 41 | + if !present { | ||
| 42 | + eprintln!("SKIP: fixture {} absent", path.display()); | ||
| 43 | + } | ||
| 44 | + present | ||
| 45 | +} | ||
| 46 | + | ||
| 23 | fn fixtures() -> PathBuf { | 47 | fn fixtures() -> PathBuf { |
| 24 | Path::new(env!("CARGO_MANIFEST_DIR")).join("../../fixtures") | 48 | Path::new(env!("CARGO_MANIFEST_DIR")).join("../../fixtures") |
| 25 | } | 49 | } |
| @@ -124,7 +148,12 @@ fn matrix() -> Vec<Source> { | |||
| 124 | let audio = fixtures().join("audio"); | 148 | let audio = fixtures().join("audio"); |
| 125 | let vectors = fixtures().join("vectors/flac-xiph/flac-test-files-main/subset"); | 149 | let vectors = fixtures().join("vectors/flac-xiph/flac-test-files-main/subset"); |
| 126 | let mut paths: Vec<PathBuf> = Vec::new(); | 150 | let mut paths: Vec<PathBuf> = Vec::new(); |
| 127 | - if let Ok(entries) = std::fs::read_dir(&audio) { | 151 | + // Probe first, assert inside the helper, and only then take the empty-list |
| 152 | + // branch: under EC_REQUIRE_FIXTURES the assert fires instead of a silent | ||
| 153 | + // skip that leaves every loop below running zero times. | ||
| 154 | + if require_fixture(&audio, "scripts/gen-fixtures.sh") { | ||
| 155 | + let entries = std::fs::read_dir(&audio) | ||
| 156 | + .unwrap_or_else(|e| panic!("read fixture dir {}: {e}", audio.display())); | ||
| 128 | let mut found: Vec<PathBuf> = entries | 157 | let mut found: Vec<PathBuf> = entries |
| 129 | .filter_map(|e| e.ok().map(|e| e.path())) | 158 | .filter_map(|e| e.ok().map(|e| e.path())) |
| 130 | .filter(|p| { | 159 | .filter(|p| { |
| @@ -136,13 +165,15 @@ fn matrix() -> Vec<Source> { | |||
| 136 | paths.append(&mut found); | 165 | paths.append(&mut found); |
| 137 | } | 166 | } |
| 138 | // Depth coverage the generated fixtures do not have: 24- and 20-bit. | 167 | // Depth coverage the generated fixtures do not have: 24- and 20-bit. |
| 139 | - for name in [ | 168 | + if require_fixture(&vectors, "scripts/fetch-vectors.sh") { |
| 140 | - "28 - high resolution audio, default settings.flac", | 169 | + for name in [ |
| 141 | - "37 - 20 bit per sample.flac", | 170 | + "28 - high resolution audio, default settings.flac", |
| 142 | - ] { | 171 | + "37 - 20 bit per sample.flac", |
| 143 | - let p = vectors.join(name); | 172 | + ] { |
| 144 | - if p.exists() { | 173 | + let p = vectors.join(name); |
| 145 | - paths.push(p); | 174 | + if p.exists() { |
| 175 | + paths.push(p); | ||
| 176 | + } | ||
| 146 | } | 177 | } |
| 147 | } | 178 | } |
| 148 | paths.iter().filter_map(|p| probe(p)).collect() | 179 | paths.iter().filter_map(|p| probe(p)).collect() |
| @@ -155,6 +186,12 @@ fn encoded_streams_decode_back_bit_exact_through_ffmpeg() { | |||
| 155 | eprintln!("skipped: fixtures not generated"); | 186 | eprintln!("skipped: fixtures not generated"); |
| 156 | return; | 187 | return; |
| 157 | } | 188 | } |
| 189 | + // Non-empty floor: the loop below must run, not zero times. | ||
| 190 | + assert!( | ||
| 191 | + sources.len() >= 5, | ||
| 192 | + "encoder matrix holds {} usable sources, expected at least 5", | ||
| 193 | + sources.len() | ||
| 194 | + ); | ||
| 158 | let dir = workdir("roundtrip"); | 195 | let dir = workdir("roundtrip"); |
| 159 | let config = EncoderConfig::default(); | 196 | let config = EncoderConfig::default(); |
| 160 | let mut failures = Vec::new(); | 197 | let mut failures = Vec::new(); |
| @@ -227,10 +264,18 @@ fn encoded_streams_decode_back_bit_exact_through_ffmpeg() { | |||
| 227 | 264 | ||
| 228 | #[test] | 265 | #[test] |
| 229 | fn our_streams_survive_a_probe_and_state_their_shape() { | 266 | fn our_streams_survive_a_probe_and_state_their_shape() { |
| 230 | - let Some(source) = matrix().into_iter().find(|s| s.channels == 6) else { | 267 | + // The 5.1 source this test needs is a named fixture, not a shape we hope the |
| 231 | - eprintln!("skipped: no 5.1 fixture"); | 268 | + // matrix happens to contain: probe it first so EC_REQUIRE_FIXTURES fails on |
| 269 | + // a drifted library instead of skipping. | ||
| 270 | + let surround = fixtures().join("audio/flac-5.1-44100.flac"); | ||
| 271 | + if !require_fixture(&surround, "scripts/gen-fixtures.sh") { | ||
| 232 | return; | 272 | return; |
| 233 | - }; | 273 | + } |
| 274 | + let source = matrix() | ||
| 275 | + .into_iter() | ||
| 276 | + .find(|s| s.channels == 6) | ||
| 277 | + .or_else(|| probe(&surround)) | ||
| 278 | + .expect("5.1 source in the encoder matrix"); | ||
| 234 | let dir = workdir("probe"); | 279 | let dir = workdir("probe"); |
| 235 | let pcm = ffmpeg_pcm(&source.path, source.bits); | 280 | let pcm = ffmpeg_pcm(&source.path, source.bits); |
| 236 | let samples = samples_from_pcm(&pcm, source.bits); | 281 | let samples = samples_from_pcm(&pcm, source.bits); |
crates/ec-flac/tests/xiph_vectors.rsmodified+69 -6
| @@ -6,7 +6,11 @@ | |||
| 6 | //! must be identical. Lossless codec, no tolerance. | 6 | //! must be identical. Lossless codec, no tolerance. |
| 7 | //! | 7 | //! |
| 8 | //! The corpus is fetched by `scripts/fetch-vectors.sh`; without it every test | 8 | //! The corpus is fetched by `scripts/fetch-vectors.sh`; without it every test |
| 9 | -//! here skips rather than fails, so a fresh clone still runs green. | 9 | +//! here skips rather than fails, so a fresh clone still runs green. Set |
| 10 | +//! `EC_REQUIRE_FIXTURES=1` to turn an absent or empty corpus into a hard | ||
| 11 | +//! failure instead (class: gate-skips-on-its-own-failure; model `have_ffmpeg` | ||
| 12 | +//! in crates/ec-av1/src/stream.rs, silently short-circuited because the probe | ||
| 13 | +//! ran first in a compound `if`). | ||
| 10 | //! | 14 | //! |
| 11 | //! Run the tables: | 15 | //! Run the tables: |
| 12 | //! cargo test -p ec-flac --release --test xiph_vectors -- --nocapture | 16 | //! cargo test -p ec-flac --release --test xiph_vectors -- --nocapture |
| @@ -17,15 +21,47 @@ use std::process::Command; | |||
| 17 | use ec_flac::checksum::md5_of_samples; | 21 | use ec_flac::checksum::md5_of_samples; |
| 18 | use ec_flac::decode::FlacReader; | 22 | use ec_flac::decode::FlacReader; |
| 19 | 23 | ||
| 24 | +/// Fixture-presence probe for the Xiph FLAC corpus. | ||
| 25 | +/// Returns whether the fixture is present, but never silently: under | ||
| 26 | +/// `EC_REQUIRE_FIXTURES=1` an absent fixture is a hard failure naming the path | ||
| 27 | +/// and the script that regenerates it, so a host whose fixture library drifted | ||
| 28 | +/// reports RED instead of a green SKIP (class: gate-skips-on-its-own-failure; | ||
| 29 | +/// model `have_ffmpeg` in crates/ec-av1/src/stream.rs, which was silently | ||
| 30 | +/// short-circuited because the probe ran first in a compound `if`). | ||
| 31 | +/// | ||
| 32 | +/// Order is load-bearing: probe, assert, return. Never merge the probe into | ||
| 33 | +/// the same `if` as the escape. | ||
| 34 | +fn require_fixture(path: &Path, generator: &str) -> bool { | ||
| 35 | + let present = path.exists(); | ||
| 36 | + assert!( | ||
| 37 | + present || std::env::var_os("EC_REQUIRE_FIXTURES").is_none(), | ||
| 38 | + "EC_REQUIRE_FIXTURES=1 but fixture {} is absent -- regenerate with: {}", | ||
| 39 | + path.display(), | ||
| 40 | + generator | ||
| 41 | + ); | ||
| 42 | + if !present { | ||
| 43 | + eprintln!("SKIP: fixture {} absent", path.display()); | ||
| 44 | + } | ||
| 45 | + present | ||
| 46 | +} | ||
| 47 | + | ||
| 20 | fn corpus(kind: &str) -> Option<Vec<PathBuf>> { | 48 | fn corpus(kind: &str) -> Option<Vec<PathBuf>> { |
| 21 | let dir = Path::new(env!("CARGO_MANIFEST_DIR")) | 49 | let dir = Path::new(env!("CARGO_MANIFEST_DIR")) |
| 22 | .join("../../fixtures/vectors/flac-xiph/flac-test-files-main") | 50 | .join("../../fixtures/vectors/flac-xiph/flac-test-files-main") |
| 23 | .join(kind); | 51 | .join(kind); |
| 24 | - let mut files: Vec<PathBuf> = std::fs::read_dir(dir) | 52 | + // Probe first, and never as part of the `ok()?` escape: a missing directory |
| 25 | - .ok()? | 53 | + // must assert under EC_REQUIRE_FIXTURES instead of short-circuiting the |
| 26 | - .filter_map(|e| e.ok().map(|e| e.path())) | 54 | + // whole helper into a silent skip. |
| 27 | - .filter(|p| p.extension().is_some_and(|e| e == "flac")) | 55 | + if !require_fixture(&dir, "scripts/fetch-vectors.sh") { |
| 28 | - .collect(); | 56 | + return None; |
| 57 | + } | ||
| 58 | + let mut files: Vec<PathBuf> = match std::fs::read_dir(&dir) { | ||
| 59 | + Ok(entries) => entries | ||
| 60 | + .filter_map(|e| e.ok().map(|e| e.path())) | ||
| 61 | + .filter(|p| p.extension().is_some_and(|e| e == "flac")) | ||
| 62 | + .collect(), | ||
| 63 | + Err(e) => panic!("read fixture dir {}: {e}", dir.display()), | ||
| 64 | + }; | ||
| 29 | files.sort(); | 65 | files.sort(); |
| 30 | match files.is_empty() { | 66 | match files.is_empty() { |
| 31 | true => None, | 67 | true => None, |
| @@ -64,6 +100,12 @@ fn subset_vectors_decode_bit_exact_against_ffmpeg() { | |||
| 64 | eprintln!("skipped: fixtures/vectors/flac-xiph not fetched"); | 100 | eprintln!("skipped: fixtures/vectors/flac-xiph not fetched"); |
| 65 | return; | 101 | return; |
| 66 | }; | 102 | }; |
| 103 | + // Non-empty floor: a zero-file corpus would loop zero times and pass. | ||
| 104 | + assert!( | ||
| 105 | + files.len() >= 5, | ||
| 106 | + "subset corpus holds {} .flac files, expected at least 5", | ||
| 107 | + files.len() | ||
| 108 | + ); | ||
| 67 | let mut failures = Vec::new(); | 109 | let mut failures = Vec::new(); |
| 68 | let mut passed = 0; | 110 | let mut passed = 0; |
| 69 | for path in &files { | 111 | for path in &files { |
| @@ -135,6 +177,11 @@ fn uncommon_vectors_decode_bit_exact_or_refuse_by_name() { | |||
| 135 | eprintln!("skipped: fixtures/vectors/flac-xiph not fetched"); | 177 | eprintln!("skipped: fixtures/vectors/flac-xiph not fetched"); |
| 136 | return; | 178 | return; |
| 137 | }; | 179 | }; |
| 180 | + assert!( | ||
| 181 | + files.len() >= 5, | ||
| 182 | + "uncommon corpus holds {} .flac files, expected at least 5", | ||
| 183 | + files.len() | ||
| 184 | + ); | ||
| 138 | let mut failures = Vec::new(); | 185 | let mut failures = Vec::new(); |
| 139 | for path in &files { | 186 | for path in &files { |
| 140 | let bytes = std::fs::read(path).expect("read fixture"); | 187 | let bytes = std::fs::read(path).expect("read fixture"); |
| @@ -170,6 +217,11 @@ fn faulty_vectors_error_and_never_panic() { | |||
| 170 | eprintln!("skipped: fixtures/vectors/flac-xiph not fetched"); | 217 | eprintln!("skipped: fixtures/vectors/flac-xiph not fetched"); |
| 171 | return; | 218 | return; |
| 172 | }; | 219 | }; |
| 220 | + assert!( | ||
| 221 | + files.len() >= 5, | ||
| 222 | + "faulty corpus holds {} .flac files, expected at least 5", | ||
| 223 | + files.len() | ||
| 224 | + ); | ||
| 173 | // Faults our reader is expected to catch outright rather than decode past: | 225 | // Faults our reader is expected to catch outright rather than decode past: |
| 174 | // these break the structure a decoder must trust. | 226 | // these break the structure a decoder must trust. |
| 175 | let must_reject = ["06 - ", "07 - ", "08 - ", "09 - ", "11 - "]; | 227 | let must_reject = ["06 - ", "07 - ", "08 - ", "09 - ", "11 - "]; |
| @@ -196,6 +248,11 @@ fn seek_table_positions_the_reader_at_a_frame() { | |||
| 196 | eprintln!("skipped: fixtures/vectors/flac-xiph not fetched"); | 248 | eprintln!("skipped: fixtures/vectors/flac-xiph not fetched"); |
| 197 | return; | 249 | return; |
| 198 | }; | 250 | }; |
| 251 | + assert!( | ||
| 252 | + files.len() >= 5, | ||
| 253 | + "subset corpus holds {} .flac files, expected at least 5", | ||
| 254 | + files.len() | ||
| 255 | + ); | ||
| 199 | // "48 - Extremely large SEEKTABLE" is the file with a seek table worth | 256 | // "48 - Extremely large SEEKTABLE" is the file with a seek table worth |
| 200 | // exercising; any file carrying one proves the hook. | 257 | // exercising; any file carrying one proves the hook. |
| 201 | let mut checked = 0; | 258 | let mut checked = 0; |
| @@ -226,4 +283,10 @@ fn seek_table_positions_the_reader_at_a_frame() { | |||
| 226 | } | 283 | } |
| 227 | } | 284 | } |
| 228 | println!("seek: {checked} files with a seek table exercised"); | 285 | println!("seek: {checked} files with a seek table exercised"); |
| 286 | + // The loop skips every file without a seek table, so it can reach zero | ||
| 287 | + // iterations even with a full corpus: floor the exercised count. | ||
| 288 | + assert!( | ||
| 289 | + checked >= 1, | ||
| 290 | + "no subset fixture carried a SEEKTABLE, so the seek hook went unexercised" | ||
| 291 | + ); | ||
| 229 | } | 292 | } |
crates/ec-h264/tests/conformance.rsmodified+96 -27
| @@ -68,6 +68,47 @@ fn vectors_dir() -> PathBuf { | |||
| 68 | Path::new(env!("CARGO_MANIFEST_DIR")).join("../../fixtures/vectors/h264-jvt") | 68 | Path::new(env!("CARGO_MANIFEST_DIR")).join("../../fixtures/vectors/h264-jvt") |
| 69 | } | 69 | } |
| 70 | 70 | ||
| 71 | +/// Fixture-presence probe for the JVT vector library these tests decode. | ||
| 72 | +/// Returns whether the fixture is present, but never silently: under | ||
| 73 | +/// `EC_REQUIRE_FIXTURES=1` an absent fixture is a hard failure naming the path | ||
| 74 | +/// and the script that populates it, so a host whose fixture library drifted | ||
| 75 | +/// reports RED instead of a green SKIP (class: gate-skips-on-its-own-failure; | ||
| 76 | +/// model `have_ffmpeg` in crates/ec-av1/src/stream.rs, which was silently | ||
| 77 | +/// short-circuited because the probe ran first in a compound `if`). | ||
| 78 | +/// | ||
| 79 | +/// Order is load-bearing: probe, assert, return. Never merge the probe into | ||
| 80 | +/// the same `if` as the escape. | ||
| 81 | +fn require_fixture(path: &std::path::Path, generator: &str) -> bool { | ||
| 82 | + let present = path.exists(); | ||
| 83 | + assert!( | ||
| 84 | + present || std::env::var_os("EC_REQUIRE_FIXTURES").is_none(), | ||
| 85 | + "EC_REQUIRE_FIXTURES=1 but fixture {} is absent -- regenerate with: {}", | ||
| 86 | + path.display(), | ||
| 87 | + generator | ||
| 88 | + ); | ||
| 89 | + if !present { | ||
| 90 | + eprintln!("SKIP: fixture {} absent", path.display()); | ||
| 91 | + } | ||
| 92 | + present | ||
| 93 | +} | ||
| 94 | +/// The same probe for one vector directory: `find_stream` returning `None` | ||
| 95 | +/// means the JVT vector was extracted without its bitstream, which is a hole | ||
| 96 | +/// in the fixture library and not a reason to test one vector fewer silently. | ||
| 97 | +/// Probe first, assert unconditionally, return last — same order as | ||
| 98 | +/// [`require_fixture`]. | ||
| 99 | +fn require_stream(dir: &Path) -> Option<PathBuf> { | ||
| 100 | + let found = find_stream(dir); | ||
| 101 | + assert!( | ||
| 102 | + found.is_some() || std::env::var_os("EC_REQUIRE_FIXTURES").is_none(), | ||
| 103 | + "EC_REQUIRE_FIXTURES=1 but {} holds no bitstream file -- regenerate with: scripts/fetch-vectors.sh", | ||
| 104 | + dir.display() | ||
| 105 | + ); | ||
| 106 | + if found.is_none() { | ||
| 107 | + eprintln!("SKIP: no bitstream file in {}", dir.display()); | ||
| 108 | + } | ||
| 109 | + found | ||
| 110 | +} | ||
| 111 | + | ||
| 71 | /// Every vector directory `scripts/fetch-vectors.sh` has populated, in name | 112 | /// Every vector directory `scripts/fetch-vectors.sh` has populated, in name |
| 72 | /// order. | 113 | /// order. |
| 73 | /// | 114 | /// |
| @@ -76,6 +117,9 @@ fn vectors_dir() -> PathBuf { | |||
| 76 | /// regressed from bit-exact to refused would be invisible. Walking the | 117 | /// regressed from bit-exact to refused would be invisible. Walking the |
| 77 | /// directory makes every fixture on disk a claim this test has to account for. | 118 | /// directory makes every fixture on disk a claim this test has to account for. |
| 78 | fn all_vectors(base: &Path) -> Vec<String> { | 119 | fn all_vectors(base: &Path) -> Vec<String> { |
| 120 | + // Probe first, assert inside the helper, build the list last: a missing | ||
| 121 | + // vector directory must not read as "zero vectors, nothing to check". | ||
| 122 | + require_fixture(base, "scripts/fetch-vectors.sh"); | ||
| 79 | let mut names: Vec<String> = std::fs::read_dir(base) | 123 | let mut names: Vec<String> = std::fs::read_dir(base) |
| 80 | .into_iter() | 124 | .into_iter() |
| 81 | .flatten() | 125 | .flatten() |
| @@ -102,6 +146,23 @@ fn find_stream(dir: &Path) -> Option<PathBuf> { | |||
| 102 | fallback | 146 | fallback |
| 103 | } | 147 | } |
| 104 | 148 | ||
| 149 | +/// Same shape for a file the JVT vector is supposed to carry besides its | ||
| 150 | +/// bitstream: the reference decoder YUV. Every vector `scripts/fetch-vectors.sh` | ||
| 151 | +/// populates ships one, so its absence is a hole in the fixture library, not a | ||
| 152 | +/// licence to verify that vector against nothing. | ||
| 153 | +fn require_ref_yuv(dir: &Path) -> Option<PathBuf> { | ||
| 154 | + let found = find_ref_yuv(dir); | ||
| 155 | + assert!( | ||
| 156 | + found.is_some() || std::env::var_os("EC_REQUIRE_FIXTURES").is_none(), | ||
| 157 | + "EC_REQUIRE_FIXTURES=1 but {} holds no reference YUV -- regenerate with: scripts/fetch-vectors.sh", | ||
| 158 | + dir.display() | ||
| 159 | + ); | ||
| 160 | + if found.is_none() { | ||
| 161 | + eprintln!("SKIP: no reference YUV in {}", dir.display()); | ||
| 162 | + } | ||
| 163 | + found | ||
| 164 | +} | ||
| 165 | + | ||
| 105 | fn find_ref_yuv(dir: &Path) -> Option<PathBuf> { | 166 | fn find_ref_yuv(dir: &Path) -> Option<PathBuf> { |
| 106 | for entry in std::fs::read_dir(dir).ok()? { | 167 | for entry in std::fs::read_dir(dir).ok()? { |
| 107 | let p = entry.ok()?.path(); | 168 | let p = entry.ok()?.path(); |
| @@ -289,11 +350,7 @@ fn compare_sequence(stream: &Path) -> Result<usize, String> { | |||
| 289 | #[test] | 350 | #[test] |
| 290 | fn jvt_cavlc_first_idr_bit_exact() { | 351 | fn jvt_cavlc_first_idr_bit_exact() { |
| 291 | let base = vectors_dir(); | 352 | let base = vectors_dir(); |
| 292 | - if !base.is_dir() { | 353 | + if !require_fixture(&base, "scripts/fetch-vectors.sh") { |
| 293 | - eprintln!( | ||
| 294 | - "SKIP: {} missing — run scripts/fetch-vectors.sh", | ||
| 295 | - base.display() | ||
| 296 | - ); | ||
| 297 | return; | 354 | return; |
| 298 | } | 355 | } |
| 299 | let mut passed = Vec::new(); | 356 | let mut passed = Vec::new(); |
| @@ -302,8 +359,7 @@ fn jvt_cavlc_first_idr_bit_exact() { | |||
| 302 | for name in all_vectors(&base) { | 359 | for name in all_vectors(&base) { |
| 303 | let name = name.as_str(); | 360 | let name = name.as_str(); |
| 304 | let dir = base.join(name); | 361 | let dir = base.join(name); |
| 305 | - let Some(stream) = find_stream(&dir) else { | 362 | + let Some(stream) = require_stream(&dir) else { |
| 306 | - eprintln!("SKIP {name}: no bitstream file"); | ||
| 307 | continue; | 363 | continue; |
| 308 | }; | 364 | }; |
| 309 | let bytes = std::fs::read(&stream).unwrap(); | 365 | let bytes = std::fs::read(&stream).unwrap(); |
| @@ -312,7 +368,7 @@ fn jvt_cavlc_first_idr_bit_exact() { | |||
| 312 | let frame_len = w * h * 3 / 2; | 368 | let frame_len = w * h * 3 / 2; |
| 313 | // Oracle 1: reference decoder YUV, first frame. | 369 | // Oracle 1: reference decoder YUV, first frame. |
| 314 | let mut ok = true; | 370 | let mut ok = true; |
| 315 | - if let Some(ref_path) = find_ref_yuv(&dir) { | 371 | + if let Some(ref_path) = require_ref_yuv(&dir) { |
| 316 | let reference = std::fs::read(&ref_path).unwrap(); | 372 | let reference = std::fs::read(&ref_path).unwrap(); |
| 317 | assert!( | 373 | assert!( |
| 318 | reference.len() >= frame_len, | 374 | reference.len() >= frame_len, |
| @@ -396,14 +452,13 @@ fn jvt_cavlc_first_idr_bit_exact() { | |||
| 396 | #[test] | 452 | #[test] |
| 397 | fn steady_state_decode_loop_zero_alloc() { | 453 | fn steady_state_decode_loop_zero_alloc() { |
| 398 | let base = vectors_dir(); | 454 | let base = vectors_dir(); |
| 399 | - if !base.is_dir() { | 455 | + if !require_fixture(&base, "scripts/fetch-vectors.sh") { |
| 400 | - eprintln!("SKIP: fixtures missing"); | ||
| 401 | return; | 456 | return; |
| 402 | } | 457 | } |
| 403 | // One stream per entropy coder, and one with B slices and multiple | 458 | // One stream per entropy coder, and one with B slices and multiple |
| 404 | // reference frames so the decoded picture buffer really recycles pictures. | 459 | // reference frames so the decoded picture buffer really recycles pictures. |
| 405 | for name in ["BA1_Sony_D", "CABA1_SVA_B", "CABA3_SVA_B"] { | 460 | for name in ["BA1_Sony_D", "CABA1_SVA_B", "CABA3_SVA_B"] { |
| 406 | - let Some(stream) = find_stream(&base.join(name)) else { | 461 | + let Some(stream) = require_stream(&base.join(name)) else { |
| 407 | continue; | 462 | continue; |
| 408 | }; | 463 | }; |
| 409 | let bytes = std::fs::read(stream).unwrap(); | 464 | let bytes = std::fs::read(stream).unwrap(); |
| @@ -480,10 +535,11 @@ fn steady_state_decode_loop_zero_alloc() { | |||
| 480 | #[test] | 535 | #[test] |
| 481 | fn ns_per_macroblock_measurement() { | 536 | fn ns_per_macroblock_measurement() { |
| 482 | let base = vectors_dir(); | 537 | let base = vectors_dir(); |
| 483 | - if !base.is_dir() { | 538 | + if !require_fixture(&base, "scripts/fetch-vectors.sh") { |
| 484 | - eprintln!("SKIP: fixtures missing"); | ||
| 485 | return; | 539 | return; |
| 486 | } | 540 | } |
| 541 | + | ||
| 542 | + let mut measured = 0usize; | ||
| 487 | for name in [ | 543 | for name in [ |
| 488 | "BA1_Sony_D", | 544 | "BA1_Sony_D", |
| 489 | "CI_MW_D", | 545 | "CI_MW_D", |
| @@ -491,7 +547,7 @@ fn ns_per_macroblock_measurement() { | |||
| 491 | "CABA1_SVA_B", | 547 | "CABA1_SVA_B", |
| 492 | "CABA3_SVA_B", | 548 | "CABA3_SVA_B", |
| 493 | ] { | 549 | ] { |
| 494 | - let Some(stream) = find_stream(&base.join(name)) else { | 550 | + let Some(stream) = require_stream(&base.join(name)) else { |
| 495 | continue; | 551 | continue; |
| 496 | }; | 552 | }; |
| 497 | let bytes = std::fs::read(stream).unwrap(); | 553 | let bytes = std::fs::read(stream).unwrap(); |
| @@ -520,7 +576,11 @@ fn ns_per_macroblock_measurement() { | |||
| 520 | "PERF {name}: {w}x{h}, {mbs} MBs, {ns_per_mb:.0} ns/MB, {mpx_s:.1} Mpx/s \ | 576 | "PERF {name}: {w}x{h}, {mbs} MBs, {ns_per_mb:.0} ns/MB, {mpx_s:.1} Mpx/s \ |
| 521 | (intra IDR, single thread, deblock included, output copy excluded)" | 577 | (intra IDR, single thread, deblock included, output copy excluded)" |
| 522 | ); | 578 | ); |
| 579 | + measured += 1; | ||
| 523 | } | 580 | } |
| 581 | + // A run that measured nothing printed no number and proved nothing: the | ||
| 582 | + // floor keeps a fixture-less host from reporting PASS for it. | ||
| 583 | + assert!(measured > 0, "no vector was measured: {measured}"); | ||
| 524 | perf_whole_sequence(); | 584 | perf_whole_sequence(); |
| 525 | } | 585 | } |
| 526 | 586 | ||
| @@ -529,7 +589,7 @@ fn ns_per_macroblock_measurement() { | |||
| 529 | fn perf_whole_sequence() { | 589 | fn perf_whole_sequence() { |
| 530 | let base = vectors_dir(); | 590 | let base = vectors_dir(); |
| 531 | for name in ["BA_MW_D", "CABA3_SVA_B", "MR1_BT_A"] { | 591 | for name in ["BA_MW_D", "CABA3_SVA_B", "MR1_BT_A"] { |
| 532 | - let Some(stream) = find_stream(&base.join(name)) else { | 592 | + let Some(stream) = require_stream(&base.join(name)) else { |
| 533 | continue; | 593 | continue; |
| 534 | }; | 594 | }; |
| 535 | let bytes = std::fs::read(stream).unwrap(); | 595 | let bytes = std::fs::read(stream).unwrap(); |
| @@ -564,8 +624,7 @@ fn perf_whole_sequence() { | |||
| 564 | #[test] | 624 | #[test] |
| 565 | fn corrupt_streams_never_panic() { | 625 | fn corrupt_streams_never_panic() { |
| 566 | let base = vectors_dir(); | 626 | let base = vectors_dir(); |
| 567 | - if !base.is_dir() { | 627 | + if !require_fixture(&base, "scripts/fetch-vectors.sh") { |
| 568 | - eprintln!("SKIP: fixtures missing"); | ||
| 569 | return; | 628 | return; |
| 570 | } | 629 | } |
| 571 | // One stream per entropy coder, plus one with B slices and multiple | 630 | // One stream per entropy coder, plus one with B slices and multiple |
| @@ -573,12 +632,17 @@ fn corrupt_streams_never_panic() { | |||
| 573 | // arrays from stream-derived values, and inter prediction indexes the | 632 | // arrays from stream-derived values, and inter prediction indexes the |
| 574 | // decoded picture buffer, the reference lists and the motion arrays from | 633 | // decoded picture buffer, the reference lists and the motion arrays from |
| 575 | // them too. All of it needs the same no-panic floor as the CAVLC tables. | 634 | // them too. All of it needs the same no-panic floor as the CAVLC tables. |
| 635 | + let mut swept = 0usize; | ||
| 576 | for name in ["BA1_Sony_D", "CABA1_SVA_B", "CABA3_SVA_B", "BA_MW_D"] { | 636 | for name in ["BA1_Sony_D", "CABA1_SVA_B", "CABA3_SVA_B", "BA_MW_D"] { |
| 577 | - let Some(stream) = find_stream(&base.join(name)) else { | 637 | + let Some(stream) = require_stream(&base.join(name)) else { |
| 578 | continue; | 638 | continue; |
| 579 | }; | 639 | }; |
| 580 | corrupt_sweep(&std::fs::read(stream).unwrap()); | 640 | corrupt_sweep(&std::fs::read(stream).unwrap()); |
| 641 | + swept += 1; | ||
| 581 | } | 642 | } |
| 643 | + // A sweep over zero streams never panics because it never decodes | ||
| 644 | + // anything; the invariant is only proven by real inputs. | ||
| 645 | + assert!(swept > 0, "no vector streams were swept: {swept}"); | ||
| 582 | } | 646 | } |
| 583 | 647 | ||
| 584 | /// Truncate and bit-flip `bytes` many ways; every decode must return, error or | 648 | /// Truncate and bit-flip `bytes` many ways; every decode must return, error or |
| @@ -1070,8 +1134,7 @@ fn p_only_gop_matches_ffmpeg_every_frame() { | |||
| 1070 | #[test] | 1134 | #[test] |
| 1071 | fn jvt_full_sequence_bit_exact() { | 1135 | fn jvt_full_sequence_bit_exact() { |
| 1072 | let base = vectors_dir(); | 1136 | let base = vectors_dir(); |
| 1073 | - if !base.is_dir() { | 1137 | + if !require_fixture(&base, "scripts/fetch-vectors.sh") { |
| 1074 | - eprintln!("SKIP: {} missing", base.display()); | ||
| 1075 | return; | 1138 | return; |
| 1076 | } | 1139 | } |
| 1077 | let mut table = String::new(); | 1140 | let mut table = String::new(); |
| @@ -1080,7 +1143,7 @@ fn jvt_full_sequence_bit_exact() { | |||
| 1080 | let mut failed = Vec::new(); | 1143 | let mut failed = Vec::new(); |
| 1081 | for name in all_vectors(&base) { | 1144 | for name in all_vectors(&base) { |
| 1082 | let dir = base.join(&name); | 1145 | let dir = base.join(&name); |
| 1083 | - let Some(stream) = find_stream(&dir) else { | 1146 | + let Some(stream) = require_stream(&dir) else { |
| 1084 | continue; | 1147 | continue; |
| 1085 | }; | 1148 | }; |
| 1086 | let bytes = std::fs::read(&stream).unwrap(); | 1149 | let bytes = std::fs::read(&stream).unwrap(); |
| @@ -1090,7 +1153,7 @@ fn jvt_full_sequence_bit_exact() { | |||
| 1090 | } | 1153 | } |
| 1091 | Ok(frames) => { | 1154 | Ok(frames) => { |
| 1092 | let len = frames[0].len(); | 1155 | let len = frames[0].len(); |
| 1093 | - let Some(ref_path) = find_ref_yuv(&dir) else { | 1156 | + let Some(ref_path) = require_ref_yuv(&dir) else { |
| 1094 | table.push_str(&format!( | 1157 | table.push_str(&format!( |
| 1095 | "{name:<16} {:>3} frames, no reference YUV\n", | 1158 | "{name:<16} {:>3} frames, no reference YUV\n", |
| 1096 | frames.len() | 1159 | frames.len() |
| @@ -1159,6 +1222,13 @@ fn jvt_full_sequence_bit_exact() { | |||
| 1159 | failed.len() | 1222 | failed.len() |
| 1160 | ); | 1223 | ); |
| 1161 | assert!(failed.is_empty(), "{failed:#?}"); | 1224 | assert!(failed.is_empty(), "{failed:#?}"); |
| 1225 | + // `failed.is_empty()` over a loop that can run zero times is vacuously | ||
| 1226 | + // green; the floor is the one its first-IDR sibling at the top of this | ||
| 1227 | + // file already carries. | ||
| 1228 | + assert!( | ||
| 1229 | + passed >= 5, | ||
| 1230 | + "fewer than 5 full-sequence JVT conformance streams verified bit-exact: {passed}" | ||
| 1231 | + ); | ||
| 1162 | } | 1232 | } |
| 1163 | 1233 | ||
| 1164 | /// Decode a whole stream in decode order rather than display order. | 1234 | /// Decode a whole stream in decode order rather than display order. |
| @@ -1850,10 +1920,10 @@ fn real_library_streams_match_ffmpeg() { | |||
| 1850 | } | 1920 | } |
| 1851 | let manifest = | 1921 | let manifest = |
| 1852 | Path::new(env!("CARGO_MANIFEST_DIR")).join("../../fixtures/real-library-manifest.tsv"); | 1922 | Path::new(env!("CARGO_MANIFEST_DIR")).join("../../fixtures/real-library-manifest.tsv"); |
| 1853 | - let Ok(text) = std::fs::read_to_string(&manifest) else { | 1923 | + if !require_fixture(&manifest, "scripts/scan-real-library.sh") { |
| 1854 | - eprintln!("SKIP: {} missing", manifest.display()); | ||
| 1855 | return; | 1924 | return; |
| 1856 | - }; | 1925 | + } |
| 1926 | + let text = std::fs::read_to_string(&manifest).expect("manifest reads"); | ||
| 1857 | let dir = scratch("real-library"); | 1927 | let dir = scratch("real-library"); |
| 1858 | const FRAMES: usize = 500; | 1928 | const FRAMES: usize = 500; |
| 1859 | /// A file counts as swept only when the oracle stayed with us this long. | 1929 | /// A file counts as swept only when the oracle stayed with us this long. |
| @@ -2313,8 +2383,7 @@ fn h264_seek_matches_linear_open_gop() { | |||
| 2313 | return; | 2383 | return; |
| 2314 | } | 2384 | } |
| 2315 | let src = Path::new(env!("CARGO_MANIFEST_DIR")).join("../../fixtures/video/h264-open-gop.mp4"); | 2385 | let src = Path::new(env!("CARGO_MANIFEST_DIR")).join("../../fixtures/video/h264-open-gop.mp4"); |
| 2316 | - if !src.is_file() { | 2386 | + if !require_fixture(&src, "scripts/gen-fixtures.sh") { |
| 2317 | - eprintln!("SKIP: no fixtures/video/h264-open-gop.mp4 (run scripts/gen-fixtures.sh)"); | ||
| 2318 | return; | 2387 | return; |
| 2319 | } | 2388 | } |
| 2320 | let dir = scratch("open-gop"); | 2389 | let dir = scratch("open-gop"); |
crates/ec-h264/tests/encode.rsmodified+35 -3
| @@ -435,6 +435,30 @@ fn have_ffmpeg() -> bool { | |||
| 435 | .is_ok_and(|s| s.success()) | 435 | .is_ok_and(|s| s.success()) |
| 436 | } | 436 | } |
| 437 | 437 | ||
| 438 | +/// Fixture-presence probe for `<what this test needs>`. | ||
| 439 | +/// Returns whether the fixture is present, but never silently: under | ||
| 440 | +/// `EC_REQUIRE_FIXTURES=1` an absent fixture is a hard failure naming the path | ||
| 441 | +/// and the script that regenerates it, so a host whose fixture library drifted | ||
| 442 | +/// reports RED instead of a green SKIP (class: gate-skips-on-its-own-failure; | ||
| 443 | +/// model `have_ffmpeg` in crates/ec-av1/src/stream.rs, which was silently | ||
| 444 | +/// short-circuited because the probe ran first in a compound `if`). | ||
| 445 | +/// | ||
| 446 | +/// Order is load-bearing: probe, assert, return. Never merge the probe into | ||
| 447 | +/// the same `if` as the escape. | ||
| 448 | +fn require_fixture(path: &std::path::Path, generator: &str) -> bool { | ||
| 449 | + let present = path.exists(); | ||
| 450 | + assert!( | ||
| 451 | + present || std::env::var_os("EC_REQUIRE_FIXTURES").is_none(), | ||
| 452 | + "EC_REQUIRE_FIXTURES=1 but fixture {} is absent -- regenerate with: {}", | ||
| 453 | + path.display(), | ||
| 454 | + generator | ||
| 455 | + ); | ||
| 456 | + if !present { | ||
| 457 | + eprintln!("SKIP: fixture {} absent", path.display()); | ||
| 458 | + } | ||
| 459 | + present | ||
| 460 | +} | ||
| 461 | + | ||
| 438 | /// Decode an Annex B stream with ffmpeg, returning one I420 triple per picture. | 462 | /// Decode an Annex B stream with ffmpeg, returning one I420 triple per picture. |
| 439 | fn ffmpeg_decode(stream: &[u8], w: usize, h: usize, extra: &[&str]) -> Option<Vec<Planes>> { | 463 | fn ffmpeg_decode(stream: &[u8], w: usize, h: usize, extra: &[&str]) -> Option<Vec<Planes>> { |
| 440 | // Distinct per call, not per process: several #[test]s in this binary | 464 | // Distinct per call, not per process: several #[test]s in this binary |
| @@ -702,10 +726,10 @@ fn real_library_frames_encode_and_decode_exactly() { | |||
| 702 | } | 726 | } |
| 703 | let manifest = std::path::Path::new(env!("CARGO_MANIFEST_DIR")) | 727 | let manifest = std::path::Path::new(env!("CARGO_MANIFEST_DIR")) |
| 704 | .join("../../fixtures/real-library-manifest.tsv"); | 728 | .join("../../fixtures/real-library-manifest.tsv"); |
| 705 | - let Ok(text) = std::fs::read_to_string(&manifest) else { | 729 | + if !require_fixture(&manifest, "scripts/scan-real-library.sh") { |
| 706 | - eprintln!("SKIP real_library_frames: {} missing", manifest.display()); | ||
| 707 | return; | 730 | return; |
| 708 | - }; | 731 | + } |
| 732 | + let text = std::fs::read_to_string(&manifest).expect("manifest reads"); | ||
| 709 | // The first 8-bit 4:2:0 H.264 mp4 of at least 720p in the manifest. | 733 | // The first 8-bit 4:2:0 H.264 mp4 of at least 720p in the manifest. |
| 710 | let mut source = None; | 734 | let mut source = None; |
| 711 | for line in text.lines().skip(1) { | 735 | for line in text.lines().skip(1) { |
| @@ -726,6 +750,14 @@ fn real_library_frames_encode_and_decode_exactly() { | |||
| 726 | break; | 750 | break; |
| 727 | } | 751 | } |
| 728 | let Some((path, w, h)) = source else { | 752 | let Some((path, w, h)) = source else { |
| 753 | + // A manifest with no qualifying row is a corpus that drifted, not a | ||
| 754 | + // reason to report PASS for a sweep that never ran. | ||
| 755 | + assert!( | ||
| 756 | + std::env::var_os("EC_REQUIRE_FIXTURES").is_none(), | ||
| 757 | + "EC_REQUIRE_FIXTURES=1 but {} lists no H.264 4:2:0 mp4 of at least \ | ||
| 758 | + 720p -- regenerate with: scripts/scan-real-library.sh", | ||
| 759 | + manifest.display() | ||
| 760 | + ); | ||
| 729 | eprintln!("SKIP real_library_frames: no H.264 4:2:0 mp4 in the manifest"); | 761 | eprintln!("SKIP real_library_frames: no H.264 4:2:0 mp4 in the manifest"); |
| 730 | return; | 762 | return; |
| 731 | }; | 763 | }; |
crates/ec-mp3/tests/encode_matrix.rsmodified+52 -8
| @@ -45,6 +45,30 @@ fn fixtures() -> PathBuf { | |||
| 45 | Path::new(env!("CARGO_MANIFEST_DIR")).join("../../fixtures") | 45 | Path::new(env!("CARGO_MANIFEST_DIR")).join("../../fixtures") |
| 46 | } | 46 | } |
| 47 | 47 | ||
| 48 | +/// Fixture-presence probe for the encoder matrix corpus. | ||
| 49 | +/// Returns whether the fixture is present, but never silently: under | ||
| 50 | +/// `EC_REQUIRE_FIXTURES=1` an absent fixture is a hard failure naming the path | ||
| 51 | +/// and the script that regenerates it, so a host whose fixture library drifted | ||
| 52 | +/// reports RED instead of a green SKIP (class: gate-skips-on-its-own-failure; | ||
| 53 | +/// model `have_ffmpeg` in crates/ec-av1/src/stream.rs, which was silently | ||
| 54 | +/// short-circuited because the probe ran first in a compound `if`). | ||
| 55 | +/// | ||
| 56 | +/// Order is load-bearing: probe, assert, return. Never merge the probe into | ||
| 57 | +/// the same `if` as the escape. | ||
| 58 | +fn require_fixture(path: &Path, generator: &str) -> bool { | ||
| 59 | + let present = path.exists(); | ||
| 60 | + assert!( | ||
| 61 | + present || std::env::var_os("EC_REQUIRE_FIXTURES").is_none(), | ||
| 62 | + "EC_REQUIRE_FIXTURES=1 but fixture {} is absent -- regenerate with: {}", | ||
| 63 | + path.display(), | ||
| 64 | + generator | ||
| 65 | + ); | ||
| 66 | + if !present { | ||
| 67 | + eprintln!("SKIP: fixture {} absent", path.display()); | ||
| 68 | + } | ||
| 69 | + present | ||
| 70 | +} | ||
| 71 | + | ||
| 48 | fn workdir(test: &str) -> PathBuf { | 72 | fn workdir(test: &str) -> PathBuf { |
| 49 | let dir = std::env::temp_dir().join(format!("ec-mp3-{}-{test}", std::process::id())); | 73 | let dir = std::env::temp_dir().join(format!("ec-mp3-{}-{test}", std::process::id())); |
| 50 | std::fs::create_dir_all(&dir).expect("create work dir"); | 74 | std::fs::create_dir_all(&dir).expect("create work dir"); |
| @@ -360,11 +384,15 @@ fn vbr_mean_bitrate_tracks_quality_on_music() { | |||
| 360 | #[test] | 384 | #[test] |
| 361 | fn encodes_above_the_incumbent_bar() { | 385 | fn encodes_above_the_incumbent_bar() { |
| 362 | let dir = fixtures().join("audio"); | 386 | let dir = fixtures().join("audio"); |
| 387 | + // Probe first, assert inside the helper, and only then take the empty-list | ||
| 388 | + // branch: under EC_REQUIRE_FIXTURES the assert fires instead of a silent | ||
| 389 | + // skip that leaves every row below running zero times. | ||
| 390 | + if !require_fixture(&dir, "scripts/gen-fixtures.sh") { | ||
| 391 | + return; | ||
| 392 | + } | ||
| 363 | let mut sources: Vec<PathBuf> = std::fs::read_dir(&dir) | 393 | let mut sources: Vec<PathBuf> = std::fs::read_dir(&dir) |
| 364 | - .into_iter() | 394 | + .unwrap_or_else(|e| panic!("read fixture dir {}: {e}", dir.display())) |
| 365 | - .flatten() | 395 | + .filter_map(|e| e.ok().map(|e| e.path())) |
| 366 | - .flatten() | ||
| 367 | - .map(|e| e.path()) | ||
| 368 | .filter(|p| { | 396 | .filter(|p| { |
| 369 | let name = p.file_name().map(|n| n.to_string_lossy().to_string()); | 397 | let name = p.file_name().map(|n| n.to_string_lossy().to_string()); |
| 370 | name.is_some_and(|n| n.starts_with("wav16-") || n.starts_with("mp3src-")) | 398 | name.is_some_and(|n| n.starts_with("wav16-") || n.starts_with("mp3src-")) |
| @@ -376,10 +404,17 @@ fn encodes_above_the_incumbent_bar() { | |||
| 376 | let name = p.file_name().unwrap().to_string_lossy().to_string(); | 404 | let name = p.file_name().unwrap().to_string_lossy().to_string(); |
| 377 | name.contains("mono") || name.contains("stereo") | 405 | name.contains("mono") || name.contains("stereo") |
| 378 | }); | 406 | }); |
| 379 | - if sources.is_empty() { | 407 | + // The corpus is eight committed WAVs (four `mp3src-*`, four `wav16-*`), |
| 380 | - eprintln!("no WAV fixtures: run scripts/gen-fixtures.sh"); | 408 | + // all produced by `scripts/gen-fixtures.sh`. Fewer than all eight means |
| 381 | - return; | 409 | + // the library drifted, not that the rows passed. |
| 382 | - } | 410 | + assert!( |
| 411 | + sources.len() >= 8, | ||
| 412 | + "only {} of the 8 mp3 encoder-matrix WAV fixtures are present in {} -- \ | ||
| 413 | + regenerate with: scripts/gen-fixtures.sh", | ||
| 414 | + sources.len(), | ||
| 415 | + dir.display() | ||
| 416 | + ); | ||
| 417 | + let mut decoded_rows = 0usize; | ||
| 383 | let work = workdir("encode"); | 418 | let work = workdir("encode"); |
| 384 | println!( | 419 | println!( |
| 385 | "{:<30} {:>5} {:>6} {:>3} {:>9} {:>8} {:>9}", | 420 | "{:<30} {:>5} {:>6} {:>3} {:>9} {:>8} {:>9}", |
| @@ -390,6 +425,7 @@ fn encodes_above_the_incumbent_bar() { | |||
| 390 | let Some((pcm, rate, channels)) = read_wav(source) else { | 425 | let Some((pcm, rate, channels)) = read_wav(source) else { |
| 391 | continue; | 426 | continue; |
| 392 | }; | 427 | }; |
| 428 | + decoded_rows += 1; | ||
| 393 | for kbps in BITRATES { | 429 | for kbps in BITRATES { |
| 394 | let bar = bar_for(&source.file_name().unwrap().to_string_lossy(), kbps); | 430 | let bar = bar_for(&source.file_name().unwrap().to_string_lossy(), kbps); |
| 395 | let bytes = encode(&pcm, rate, channels, kbps); | 431 | let bytes = encode(&pcm, rate, channels, kbps); |
| @@ -455,6 +491,14 @@ fn encodes_above_the_incumbent_bar() { | |||
| 455 | } | 491 | } |
| 456 | } | 492 | } |
| 457 | } | 493 | } |
| 494 | + // A present-but-unreadable WAV takes the `read_wav` skip above, so the | ||
| 495 | + // corpus count alone would leave this green having measured nothing. | ||
| 496 | + assert!( | ||
| 497 | + decoded_rows == sources.len(), | ||
| 498 | + "only {decoded_rows} of {} fixtures decoded; a present fixture that \ | ||
| 499 | + ffmpeg cannot read is a broken fixture, not a passing row", | ||
| 500 | + sources.len() | ||
| 501 | + ); | ||
| 458 | assert!(failures.is_empty(), "{failures:#?}"); | 502 | assert!(failures.is_empty(), "{failures:#?}"); |
| 459 | } | 503 | } |
| 460 | 504 | ||
crates/ec-opus/tests/conformance.rsmodified+808 -246
| @@ -87,6 +87,62 @@ fn vectors_dir() -> PathBuf { | |||
| 87 | .join("../../fixtures/vectors/opus-rfc6716/opus_testvectors") | 87 | .join("../../fixtures/vectors/opus-rfc6716/opus_testvectors") |
| 88 | } | 88 | } |
| 89 | 89 | ||
| 90 | +/// Fixture-presence probe for the fixtures these tests read. | ||
| 91 | +/// Returns whether the fixture is present, but never silently: under | ||
| 92 | +/// `EC_REQUIRE_FIXTURES=1` an absent fixture is a hard failure naming the path | ||
| 93 | +/// and the script that regenerates it, so a host whose fixture library drifted | ||
| 94 | +/// reports RED instead of a green SKIP (class: gate-skips-on-its-own-failure; | ||
| 95 | +/// model `have_ffmpeg` in crates/ec-av1/src/stream.rs, which was silently | ||
| 96 | +/// short-circuited because the probe ran first in a compound `if`). | ||
| 97 | +/// | ||
| 98 | +/// Order is load-bearing: probe, assert, return. Never merge the probe into | ||
| 99 | +/// the same `if` as the escape. | ||
| 100 | +fn require_fixture(path: &Path, generator: &str) -> bool { | ||
| 101 | + let present = path.exists(); | ||
| 102 | + assert!( | ||
| 103 | + present || std::env::var_os("EC_REQUIRE_FIXTURES").is_none(), | ||
| 104 | + "EC_REQUIRE_FIXTURES=1 but fixture {} is absent -- regenerate with: {}", | ||
| 105 | + path.display(), | ||
| 106 | + generator | ||
| 107 | + ); | ||
| 108 | + if !present { | ||
| 109 | + eprintln!("SKIP: fixture {} absent", path.display()); | ||
| 110 | + } | ||
| 111 | + present | ||
| 112 | +} | ||
| 113 | + | ||
| 114 | +/// Presence probe for a HOST media file (`~/Music/...`, `~/Downloads/...`). | ||
| 115 | +/// Deliberately NOT [`require_fixture`]: those paths are a developer's | ||
| 116 | +/// personal corpus, not the committed fixture library, so `EC_REQUIRE_FIXTURES` | ||
| 117 | +/// must not turn one person's home directory into a red suite on every other | ||
| 118 | +/// host. It skips, and says so. | ||
| 119 | +fn require_host_media(path: &Path, tag: &str) -> bool { | ||
| 120 | + let present = path.exists(); | ||
| 121 | + if !present { | ||
| 122 | + eprintln!("SKIP {tag}: host media file {} absent", path.display()); | ||
| 123 | + } | ||
| 124 | + present | ||
| 125 | +} | ||
| 126 | + | ||
| 127 | +/// An RFC 6716 test vector, probed through [`require_fixture`]. `None` means | ||
| 128 | +/// absent (and already reported, or already asserted). | ||
| 129 | +fn vector(name: &str) -> Option<PathBuf> { | ||
| 130 | + let path = vectors_dir().join(format!("{name}.bit")); | ||
| 131 | + match require_fixture(&path, "scripts/fetch-vectors.sh") { | ||
| 132 | + true => Some(path), | ||
| 133 | + false => None, | ||
| 134 | + } | ||
| 135 | +} | ||
| 136 | + | ||
| 137 | +/// One of the generated `fixtures/audio` files, probed the same way. | ||
| 138 | +fn audio_fixture(name: &str) -> Option<PathBuf> { | ||
| 139 | + let path = fixture(name); | ||
| 140 | + match require_fixture(&path, "scripts/gen-fixtures.sh") { | ||
| 141 | + true => Some(path), | ||
| 142 | + false => None, | ||
| 143 | + } | ||
| 144 | +} | ||
| 145 | + | ||
| 90 | /// Decodes a vector at 48 kHz stereo, returning the samples and how many | 146 | /// Decodes a vector at 48 kHz stereo, returning the samples and how many |
| 91 | /// packets ended with the reference range state. | 147 | /// packets ended with the reference range state. |
| 92 | fn decode_vector(packets: &[VectorPacket]) -> (Vec<f32>, usize, usize) { | 148 | fn decode_vector(packets: &[VectorPacket]) -> (Vec<f32>, usize, usize) { |
| @@ -413,12 +469,12 @@ const VECTORS: [&str; 12] = [ | |||
| 413 | #[test] | 469 | #[test] |
| 414 | fn rfc6716_test_vectors() { | 470 | fn rfc6716_test_vectors() { |
| 415 | let mut table = Vec::new(); | 471 | let mut table = Vec::new(); |
| 472 | + let mut ran = 0usize; | ||
| 416 | for name in VECTORS { | 473 | for name in VECTORS { |
| 417 | - let path = vectors_dir().join(format!("{name}.bit")); | 474 | + let Some(path) = vector(name) else { |
| 418 | - if !path.exists() { | ||
| 419 | - eprintln!("{name}: missing, skipped (run scripts/fetch-vectors.sh)"); | ||
| 420 | continue; | 475 | continue; |
| 421 | - } | 476 | + }; |
| 477 | + ran += 1; | ||
| 422 | let packets = read_vector(&path); | 478 | let packets = read_vector(&path); |
| 423 | let (pcm, matched, decoded) = decode_vector(&packets); | 479 | let (pcm, matched, decoded) = decode_vector(&packets); |
| 424 | let reference = read_i16(&vectors_dir().join(format!("{name}.dec"))); | 480 | let reference = read_i16(&vectors_dir().join(format!("{name}.dec"))); |
| @@ -446,6 +502,13 @@ fn rfc6716_test_vectors() { | |||
| 446 | "{name}: opus_compare quality {quality:.2} %" | 502 | "{name}: opus_compare quality {quality:.2} %" |
| 447 | ); | 503 | ); |
| 448 | } | 504 | } |
| 505 | + // Non-empty floor: without a vector the loop above runs zero times and the | ||
| 506 | + // table prints nothing at all. | ||
| 507 | + assert!( | ||
| 508 | + ran >= 5, | ||
| 509 | + "only {ran} of {} RFC 6716 vectors were exercised, expected at least 5", | ||
| 510 | + VECTORS.len() | ||
| 511 | + ); | ||
| 449 | for line in table { | 512 | for line in table { |
| 450 | println!("{line}"); | 513 | println!("{line}"); |
| 451 | } | 514 | } |
| @@ -606,16 +669,16 @@ fn ogg_opus_fixtures_match_ffmpeg() { | |||
| 606 | // Mapping family 1 puts 5.1 in Vorbis order; ffmpeg hands its own order | 669 | // Mapping family 1 puts 5.1 in Vorbis order; ffmpeg hands its own order |
| 607 | // back, so the comparison permutes one into the other. | 670 | // back, so the comparison permutes one into the other. |
| 608 | const VORBIS_TO_FFMPEG_5_1: [usize; 6] = [0, 2, 1, 4, 5, 3]; | 671 | const VORBIS_TO_FFMPEG_5_1: [usize; 6] = [0, 2, 1, 4, 5, 3]; |
| 672 | + let mut ran = 0usize; | ||
| 609 | for (name, channels) in [ | 673 | for (name, channels) in [ |
| 610 | ("opus-ogg-mono-48000.opus", 1usize), | 674 | ("opus-ogg-mono-48000.opus", 1usize), |
| 611 | ("opus-ogg-stereo-48000.opus", 2), | 675 | ("opus-ogg-stereo-48000.opus", 2), |
| 612 | ("opus-ogg-5.1-48000.opus", 6), | 676 | ("opus-ogg-5.1-48000.opus", 6), |
| 613 | ] { | 677 | ] { |
| 614 | - let path = fixture(name); | 678 | + let Some(path) = audio_fixture(name) else { |
| 615 | - if !path.exists() { | ||
| 616 | - eprintln!("{name}: missing, skipped (run scripts/gen-fixtures.sh)"); | ||
| 617 | continue; | 679 | continue; |
| 618 | - } | 680 | + }; |
| 681 | + ran += 1; | ||
| 619 | let Some(reference) = ffmpeg_decode(&path, channels) else { | 682 | let Some(reference) = ffmpeg_decode(&path, channels) else { |
| 620 | eprintln!("{name}: ffmpeg unavailable, skipped"); | 683 | eprintln!("{name}: ffmpeg unavailable, skipped"); |
| 621 | continue; | 684 | continue; |
| @@ -642,6 +705,11 @@ fn ogg_opus_fixtures_match_ffmpeg() { | |||
| 642 | "{name}: worst channel correlation {worst:.5}" | 705 | "{name}: worst channel correlation {worst:.5}" |
| 643 | ); | 706 | ); |
| 644 | } | 707 | } |
| 708 | + // Non-empty floor: the loop above must have compared something. | ||
| 709 | + assert!( | ||
| 710 | + ran >= 2, | ||
| 711 | + "only {ran} of 3 Ogg-Opus fixtures were compared against ffmpeg, expected at least 2" | ||
| 712 | + ); | ||
| 645 | } | 713 | } |
| 646 | 714 | ||
| 647 | #[test] | 715 | #[test] |
| @@ -653,11 +721,9 @@ fn five_one_channels_land_in_the_right_places() { | |||
| 653 | // Vorbis-order output is the reference's 5.1-order output permuted. | 721 | // Vorbis-order output is the reference's 5.1-order output permuted. |
| 654 | const VORBIS_TO_FFMPEG_5_1: [usize; 6] = [0, 2, 1, 4, 5, 3]; | 722 | const VORBIS_TO_FFMPEG_5_1: [usize; 6] = [0, 2, 1, 4, 5, 3]; |
| 655 | const TONES: [f64; 6] = [220.0, 440.0, 660.0, 55.0, 880.0, 1320.0]; | 723 | const TONES: [f64; 6] = [220.0, 440.0, 660.0, 55.0, 880.0, 1320.0]; |
| 656 | - let path = fixture("opus-ogg-5.1-48000.opus"); | 724 | + let Some(path) = audio_fixture("opus-ogg-5.1-48000.opus") else { |
| 657 | - if !path.exists() { | ||
| 658 | - eprintln!("5.1 fixture missing, skipped"); | ||
| 659 | return; | 725 | return; |
| 660 | - } | 726 | + }; |
| 661 | let Some(reference) = ffmpeg_decode(&path, 6) else { | 727 | let Some(reference) = ffmpeg_decode(&path, 6) else { |
| 662 | eprintln!("ffmpeg unavailable, skipped"); | 728 | eprintln!("ffmpeg unavailable, skipped"); |
| 663 | return; | 729 | return; |
| @@ -694,14 +760,15 @@ fn decode_speed() { | |||
| 694 | eprintln!("decode speed is only meaningful in release; skipped"); | 760 | eprintln!("decode speed is only meaningful in release; skipped"); |
| 695 | return; | 761 | return; |
| 696 | } | 762 | } |
| 763 | + let mut measured = 0usize; | ||
| 697 | for (name, channels) in [ | 764 | for (name, channels) in [ |
| 698 | ("opus-ogg-stereo-48000.opus", 2usize), | 765 | ("opus-ogg-stereo-48000.opus", 2usize), |
| 699 | ("opus-ogg-5.1-48000.opus", 6), | 766 | ("opus-ogg-5.1-48000.opus", 6), |
| 700 | ] { | 767 | ] { |
| 701 | - let path = fixture(name); | 768 | + let Some(path) = audio_fixture(name) else { |
| 702 | - if !path.exists() { | ||
| 703 | continue; | 769 | continue; |
| 704 | - } | 770 | + }; |
| 771 | + measured += 1; | ||
| 705 | let data = fs::read(&path).unwrap(); | 772 | let data = fs::read(&path).unwrap(); |
| 706 | let packets = ogg_packets(&data); | 773 | let packets = ogg_packets(&data); |
| 707 | let head = parse_opus_head(&packets[0]); | 774 | let head = parse_opus_head(&packets[0]); |
| @@ -734,11 +801,17 @@ fn decode_speed() { | |||
| 734 | "{name}: {realtime:.0}x realtime is below the {floor}x floor" | 801 | "{name}: {realtime:.0}x realtime is below the {floor}x floor" |
| 735 | ); | 802 | ); |
| 736 | } | 803 | } |
| 804 | + // Non-empty floor: with both fixtures absent the loop measured nothing and | ||
| 805 | + // every speed floor above went unexercised. | ||
| 806 | + assert!( | ||
| 807 | + measured >= 1, | ||
| 808 | + "no Ogg-Opus fixture was measured, so the decode-speed floor went untested" | ||
| 809 | + ); | ||
| 737 | 810 | ||
| 738 | // The fixtures are sine tones, which are cheap; testvector01 is real music | 811 | // The fixtures are sine tones, which are cheap; testvector01 is real music |
| 739 | // at a high rate and is the honest stereo number. | 812 | // at a high rate and is the honest stereo number. |
| 740 | - let path = vectors_dir().join("testvector01.bit"); | 813 | + let stereo_music = vector("testvector01"); |
| 741 | - if path.exists() { | 814 | + if let Some(path) = stereo_music { |
| 742 | let packets = read_vector(&path); | 815 | let packets = read_vector(&path); |
| 743 | let mut dec = Decoder::new(48000, 2).unwrap(); | 816 | let mut dec = Decoder::new(48000, 2).unwrap(); |
| 744 | let mut out = vec![0.0f32; 5760 * 2]; | 817 | let mut out = vec![0.0f32; 5760 * 2]; |
| @@ -1595,7 +1668,14 @@ fn ogg_opus_round_trip_duration_is_exact() { | |||
| 1595 | let packets = encode_packets(&mut enc, &pcm, 2); | 1668 | let packets = encode_packets(&mut enc, &pcm, 2); |
| 1596 | let path = temp_path("duration.opus"); | 1669 | let path = temp_path("duration.opus"); |
| 1597 | let pre_skip = enc.look_ahead(960); | 1670 | let pre_skip = enc.look_ahead(960); |
| 1598 | - write_ogg_opus(&path, &packets, opus_head(2, pre_skip as u16, None), 2, total, pre_skip as i64); | 1671 | + write_ogg_opus( |
| 1672 | + &path, | ||
| 1673 | + &packets, | ||
| 1674 | + opus_head(2, pre_skip as u16, None), | ||
| 1675 | + 2, | ||
| 1676 | + total, | ||
| 1677 | + pre_skip as i64, | ||
| 1678 | + ); | ||
| 1599 | let probe = Command::new("ffprobe") | 1679 | let probe = Command::new("ffprobe") |
| 1600 | .args([ | 1680 | .args([ |
| 1601 | "-v", | 1681 | "-v", |
| @@ -1849,8 +1929,7 @@ fn garbage_payloads_never_panic() { | |||
| 1849 | } | 1929 | } |
| 1850 | } | 1930 | } |
| 1851 | // Truncations of a real packet, which exercise the mid-frame paths. | 1931 | // Truncations of a real packet, which exercise the mid-frame paths. |
| 1852 | - let path = vectors_dir().join("testvector10.bit"); | 1932 | + if let Some(path) = vector("testvector10") { |
| 1853 | - if path.exists() { | ||
| 1854 | for p in read_vector(&path).iter().take(200) { | 1933 | for p in read_vector(&path).iter().take(200) { |
| 1855 | for cut in 1..p.payload.len().min(64) { | 1934 | for cut in 1..p.payload.len().min(64) { |
| 1856 | let _ = dec.decode_float(&p.payload[..cut], &mut out); | 1935 | let _ = dec.decode_float(&p.payload[..cut], &mut out); |
| @@ -2031,9 +2110,8 @@ fn aligned_corr(reference: &[f32], decoded: &[f32], max_lag: usize) -> (f64, usi | |||
| 2031 | 2110 | ||
| 2032 | #[test] | 2111 | #[test] |
| 2033 | fn silk_mono_nb_wb_roundtrip() { | 2112 | fn silk_mono_nb_wb_roundtrip() { |
| 2034 | - let wav = fixture("wav16-mono-48000.wav"); | ||
| 2035 | let mut sources = vec![("synthetic", speech_like())]; | 2113 | let mut sources = vec![("synthetic", speech_like())]; |
| 2036 | - if wav.exists() { | 2114 | + if let Some(wav) = audio_fixture("wav16-mono-48000.wav") { |
| 2037 | let w = read_wav_mono(&wav); | 2115 | let w = read_wav_mono(&wav); |
| 2038 | sources.push(("wav16-mono-48000", w[..w.len().min(96000)].to_vec())); | 2116 | sources.push(("wav16-mono-48000", w[..w.len().min(96000)].to_vec())); |
| 2039 | } | 2117 | } |
| @@ -2380,7 +2458,14 @@ fn oracle_decode( | |||
| 2380 | return None; | 2458 | return None; |
| 2381 | } | 2459 | } |
| 2382 | let path = temp_path(&format!("{name}.opus")); | 2460 | let path = temp_path(&format!("{name}.opus")); |
| 2383 | - write_ogg_opus(&path, packets, opus_head(1, pre_skip as u16, None), 1, samples, pre_skip as i64); | 2461 | + write_ogg_opus( |
| 2462 | + &path, | ||
| 2463 | + packets, | ||
| 2464 | + opus_head(1, pre_skip as u16, None), | ||
| 2465 | + 1, | ||
| 2466 | + samples, | ||
| 2467 | + pre_skip as i64, | ||
| 2468 | + ); | ||
| 2384 | let out = Command::new("ffmpeg") | 2469 | let out = Command::new("ffmpeg") |
| 2385 | .args(["-v", "warning", "-c:a", "libopus", "-i"]) | 2470 | .args(["-v", "warning", "-c:a", "libopus", "-i"]) |
| 2386 | .arg(&path) | 2471 | .arg(&path) |
| @@ -2398,9 +2483,8 @@ fn oracle_decode( | |||
| 2398 | } | 2483 | } |
| 2399 | 2484 | ||
| 2400 | fn silk_sources() -> Vec<(&'static str, Vec<f32>)> { | 2485 | fn silk_sources() -> Vec<(&'static str, Vec<f32>)> { |
| 2401 | - let wav = fixture("wav16-mono-48000.wav"); | ||
| 2402 | let mut sources = vec![("synthetic", speech_like())]; | 2486 | let mut sources = vec![("synthetic", speech_like())]; |
| 2403 | - if wav.exists() { | 2487 | + if let Some(wav) = audio_fixture("wav16-mono-48000.wav") { |
| 2404 | let w = read_wav_mono(&wav); | 2488 | let w = read_wav_mono(&wav); |
| 2405 | sources.push(("wav16-mono-48000", w[..w.len().min(96000)].to_vec())); | 2489 | sources.push(("wav16-mono-48000", w[..w.len().min(96000)].to_vec())); |
| 2406 | } | 2490 | } |
| @@ -2557,7 +2641,10 @@ fn hybrid_layers_align() { | |||
| 2557 | (plb - phb).abs() <= 3, | 2641 | (plb - phb).abs() <= 3, |
| 2558 | "layers misaligned: LB +{plb} vs HB +{phb}" | 2642 | "layers misaligned: LB +{plb} vs HB +{phb}" |
| 2559 | ); | 2643 | ); |
| 2560 | - assert!((phb - delay).abs() <= 2, "HB peak +{phb}, look_ahead {delay}"); | 2644 | + assert!( |
| 2645 | + (phb - delay).abs() <= 2, | ||
| 2646 | + "HB peak +{phb}, look_ahead {delay}" | ||
| 2647 | + ); | ||
| 2561 | } | 2648 | } |
| 2562 | 2649 | ||
| 2563 | /// 20 ms FB hybrid at 32 kbps: decodes in our decoder range-exactly, tracks | 2650 | /// 20 ms FB hybrid at 32 kbps: decodes in our decoder range-exactly, tracks |
| @@ -2845,7 +2932,12 @@ fn ffmpeg_encode_libopus(src: &Path, kbps: u32, out: &Path, secs: f64) { | |||
| 2845 | /// file — and the correlation is computed inline without per-lag allocations. | 2932 | /// file — and the correlation is computed inline without per-lag allocations. |
| 2846 | /// The delay lands the peak at a positive lag; the symmetric scan keeps the | 2933 | /// The delay lands the peak at a positive lag; the symmetric scan keeps the |
| 2847 | /// gate honest if a reference decoder shifts the other way. | 2934 | /// gate honest if a reference decoder shifts the other way. |
| 2848 | -fn align_to_source(source: &[f32], decoded: &[f32], channels: usize, max_lag: usize) -> (i32, Vec<f32>) { | 2935 | +fn align_to_source( |
| 2936 | + source: &[f32], | ||
| 2937 | + decoded: &[f32], | ||
| 2938 | + channels: usize, | ||
| 2939 | + max_lag: usize, | ||
| 2940 | +) -> (i32, Vec<f32>) { | ||
| 2849 | let sf = source.len() / channels; | 2941 | let sf = source.len() / channels; |
| 2850 | let df = decoded.len() / channels; | 2942 | let df = decoded.len() / channels; |
| 2851 | let scan_frames = sf.min(df).min(48000 * 10); | 2943 | let scan_frames = sf.min(df).min(48000 * 10); |
| @@ -2881,7 +2973,11 @@ fn align_to_source(source: &[f32], decoded: &[f32], channels: usize, max_lag: us | |||
| 2881 | } | 2973 | } |
| 2882 | // Build a source-length aligned copy using the chosen lag. | 2974 | // Build a source-length aligned copy using the chosen lag. |
| 2883 | let mut aligned = vec![0.0f32; sf * channels]; | 2975 | let mut aligned = vec![0.0f32; sf * channels]; |
| 2884 | - let i0 = if best_lag < 0 { (-best_lag) as usize } else { 0 }; | 2976 | + let i0 = if best_lag < 0 { |
| 2977 | + (-best_lag) as usize | ||
| 2978 | + } else { | ||
| 2979 | + 0 | ||
| 2980 | + }; | ||
| 2885 | let j0 = if best_lag < 0 { 0 } else { best_lag as usize }; | 2981 | let j0 = if best_lag < 0 { 0 } else { best_lag as usize }; |
| 2886 | let len = sf.saturating_sub(i0).min(df.saturating_sub(j0)); | 2982 | let len = sf.saturating_sub(i0).min(df.saturating_sub(j0)); |
| 2887 | for i in 0..len { | 2983 | for i in 0..len { |
| @@ -3017,7 +3113,9 @@ fn reelm64_persecond_diag() { | |||
| 3017 | let (_, ours_aligned) = align_to_source(&source_pcm, &ours_dec, CHANNELS, MAX_LAG); | 3113 | let (_, ours_aligned) = align_to_source(&source_pcm, &ours_dec, CHANNELS, MAX_LAG); |
| 3018 | 3114 | ||
| 3019 | // Per-second correlation for both | 3115 | // Per-second correlation for both |
| 3020 | - let n_frames = (source_frames).min(ours_aligned.len() / CHANNELS).min(ref_aligned.len() / CHANNELS); | 3116 | + let n_frames = (source_frames) |
| 3117 | + .min(ours_aligned.len() / CHANNELS) | ||
| 3118 | + .min(ref_aligned.len() / CHANNELS); | ||
| 3021 | let sec_samples = 48000usize; | 3119 | let sec_samples = 48000usize; |
| 3022 | let frames_per_sec = sec_samples / FRAME; // 50 | 3120 | let frames_per_sec = sec_samples / FRAME; // 50 |
| 3023 | 3121 | ||
| @@ -3034,11 +3132,19 @@ fn reelm64_persecond_diag() { | |||
| 3034 | let s = source_pcm[(start + i) * CHANNELS + ch] as f64; | 3132 | let s = source_pcm[(start + i) * CHANNELS + ch] as f64; |
| 3035 | let o = ours_aligned[(start + i) * CHANNELS + ch] as f64; | 3133 | let o = ours_aligned[(start + i) * CHANNELS + ch] as f64; |
| 3036 | let r = ref_aligned[(start + i) * CHANNELS + ch] as f64; | 3134 | let r = ref_aligned[(start + i) * CHANNELS + ch] as f64; |
| 3037 | - sxy_o += s * o; sxx_o += s * s; syy_o += o * o; | 3135 | + sxy_o += s * o; |
| 3038 | - sxy_r += s * r; sxx_r += s * s; syy_r += r * r; | 3136 | + sxx_o += s * s; |
| 3137 | + syy_o += o * o; | ||
| 3138 | + sxy_r += s * r; | ||
| 3139 | + sxx_r += s * s; | ||
| 3140 | + syy_r += r * r; | ||
| 3141 | + } | ||
| 3142 | + if sxx_o > 0.0 && syy_o > 0.0 { | ||
| 3143 | + acc_o += sxy_o / (sxx_o * syy_o).sqrt(); | ||
| 3144 | + } | ||
| 3145 | + if sxx_r > 0.0 && syy_r > 0.0 { | ||
| 3146 | + acc_r += sxy_r / (sxx_r * syy_r).sqrt(); | ||
| 3039 | } | 3147 | } |
| 3040 | - if sxx_o > 0.0 && syy_o > 0.0 { acc_o += sxy_o / (sxx_o * syy_o).sqrt(); } | ||
| 3041 | - if sxx_r > 0.0 && syy_r > 0.0 { acc_r += sxy_r / (sxx_r * syy_r).sqrt(); } | ||
| 3042 | } | 3148 | } |
| 3043 | let co = acc_o / CHANNELS as f64; | 3149 | let co = acc_o / CHANNELS as f64; |
| 3044 | let cr = acc_r / CHANNELS as f64; | 3150 | let cr = acc_r / CHANNELS as f64; |
| @@ -3054,10 +3160,19 @@ fn reelm64_persecond_diag() { | |||
| 3054 | let mut out_str = String::new(); | 3160 | let mut out_str = String::new(); |
| 3055 | out_str.push_str("# reelm@64k per-second diagnostic (r1, current code)\n"); | 3161 | out_str.push_str("# reelm@64k per-second diagnostic (r1, current code)\n"); |
| 3056 | out_str.push_str("# 120s cap, 20ms frames, VBR constrained, 48kHz stereo\n"); | 3162 | out_str.push_str("# 120s cap, 20ms frames, VBR constrained, 48kHz stereo\n"); |
| 3057 | - out_str.push_str(&format!("# total frames: ours={} ref={}\n", diags.len(), ref_payload.len())); | 3163 | + out_str.push_str(&format!( |
| 3164 | + "# total frames: ours={} ref={}\n", | ||
| 3165 | + diags.len(), | ||
| 3166 | + ref_payload.len() | ||
| 3167 | + )); | ||
| 3058 | let total_corr_o: f64 = sec_rows.iter().map(|r| r.1).sum::<f64>() / sec_rows.len() as f64; | 3168 | let total_corr_o: f64 = sec_rows.iter().map(|r| r.1).sum::<f64>() / sec_rows.len() as f64; |
| 3059 | let total_corr_r: f64 = sec_rows.iter().map(|r| r.2).sum::<f64>() / sec_rows.len() as f64; | 3169 | let total_corr_r: f64 = sec_rows.iter().map(|r| r.2).sum::<f64>() / sec_rows.len() as f64; |
| 3060 | - out_str.push_str(&format!("# avg corr: ours={:.4} ref={:.4} gap={:+.4}\n\n", total_corr_o, total_corr_r, total_corr_r - total_corr_o)); | 3170 | + out_str.push_str(&format!( |
| 3171 | + "# avg corr: ours={:.4} ref={:.4} gap={:+.4}\n\n", | ||
| 3172 | + total_corr_o, | ||
| 3173 | + total_corr_r, | ||
| 3174 | + total_corr_r - total_corr_o | ||
| 3175 | + )); | ||
| 3061 | 3176 | ||
| 3062 | // Per-second summary table | 3177 | // Per-second summary table |
| 3063 | out_str.push_str("# sec\tcorr_ours\tcorr_ref\tgap\tavg_trim\tdual_n\tint_typ\tavg_B_ours\tavg_B_ref\ttf_chng_n\ttrans_n\n"); | 3178 | out_str.push_str("# sec\tcorr_ours\tcorr_ref\tgap\tavg_trim\tdual_n\tint_typ\tavg_B_ours\tavg_B_ref\ttf_chng_n\ttrans_n\n"); |
| @@ -3067,19 +3182,35 @@ fn reelm64_persecond_diag() { | |||
| 3067 | let sec_diags = &diags[f0..f1.min(diags.len())]; | 3182 | let sec_diags = &diags[f0..f1.min(diags.len())]; |
| 3068 | let avg_trim: f64 = if !sec_diags.is_empty() { | 3183 | let avg_trim: f64 = if !sec_diags.is_empty() { |
| 3069 | sec_diags.iter().map(|d| d.alloc_trim as f64).sum::<f64>() / sec_diags.len() as f64 | 3184 | sec_diags.iter().map(|d| d.alloc_trim as f64).sum::<f64>() / sec_diags.len() as f64 |
| 3070 | - } else { -1.0 }; | 3185 | + } else { |
| 3186 | + -1.0 | ||
| 3187 | + }; | ||
| 3071 | let dual_n = sec_diags.iter().filter(|d| d.dual_stereo).count(); | 3188 | let dual_n = sec_diags.iter().filter(|d| d.dual_stereo).count(); |
| 3072 | let int_typ = if !sec_diags.is_empty() { | 3189 | let int_typ = if !sec_diags.is_empty() { |
| 3073 | sec_diags.iter().map(|d| d.intensity).max().unwrap_or(0) | 3190 | sec_diags.iter().map(|d| d.intensity).max().unwrap_or(0) |
| 3074 | - } else { 0 }; | 3191 | + } else { |
| 3192 | + 0 | ||
| 3193 | + }; | ||
| 3075 | let avg_b_o: f64 = if !sec_diags.is_empty() { | 3194 | let avg_b_o: f64 = if !sec_diags.is_empty() { |
| 3076 | - sec_diags.iter().map(|d| d.nb_compressed as f64).sum::<f64>() / sec_diags.len() as f64 | 3195 | + sec_diags |
| 3077 | - } else { 0.0 }; | 3196 | + .iter() |
| 3197 | + .map(|d| d.nb_compressed as f64) | ||
| 3198 | + .sum::<f64>() | ||
| 3199 | + / sec_diags.len() as f64 | ||
| 3200 | + } else { | ||
| 3201 | + 0.0 | ||
| 3202 | + }; | ||
| 3078 | let ref_f0 = f0.min(ref_payload.len()); | 3203 | let ref_f0 = f0.min(ref_payload.len()); |
| 3079 | let ref_f1 = f1.min(ref_payload.len()); | 3204 | let ref_f1 = f1.min(ref_payload.len()); |
| 3080 | let avg_b_r: f64 = if ref_f1 > ref_f0 { | 3205 | let avg_b_r: f64 = if ref_f1 > ref_f0 { |
| 3081 | - ref_payload[ref_f0..ref_f1].iter().map(|&b| b as f64).sum::<f64>() / (ref_f1 - ref_f0) as f64 | 3206 | + ref_payload[ref_f0..ref_f1] |
| 3082 | - } else { 0.0 }; | 3207 | + .iter() |
| 3208 | + .map(|&b| b as f64) | ||
| 3209 | + .sum::<f64>() | ||
| 3210 | + / (ref_f1 - ref_f0) as f64 | ||
| 3211 | + } else { | ||
| 3212 | + 0.0 | ||
| 3213 | + }; | ||
| 3083 | // tf_changed: count bands where tf_res != 0 (we don't have tf_res in diag, | 3214 | // tf_changed: count bands where tf_res != 0 (we don't have tf_res in diag, |
| 3084 | // but is_transient tells us if short blocks were used) | 3215 | // but is_transient tells us if short blocks were used) |
| 3085 | let trans_n = sec_diags.iter().filter(|d| d.is_transient).count(); | 3216 | let trans_n = sec_diags.iter().filter(|d| d.is_transient).count(); |
| @@ -3103,10 +3234,23 @@ fn reelm64_persecond_diag() { | |||
| 3103 | let f5: Vec<String> = (0..5).map(|i| format!("{}", d.fine_quant[i])).collect(); | 3234 | let f5: Vec<String> = (0..5).map(|i| format!("{}", d.fine_quant[i])).collect(); |
| 3104 | out_str.push_str(&format!( | 3235 | out_str.push_str(&format!( |
| 3105 | "{}\t{}\t{}\t{}\t{}\t{}\t{}\t{}\t{}\t{}\t{}\t{}\t{}\t{}\t{}\t{}\t{}\n", | 3236 | "{}\t{}\t{}\t{}\t{}\t{}\t{}\t{}\t{}\t{}\t{}\t{}\t{}\t{}\t{}\t{}\t{}\n", |
| 3106 | - fi, fi * 20, d.nb_compressed, b_ref, | 3237 | + fi, |
| 3107 | - d.is_transient as u8, d.short_blocks, d.intra as u8, d.silence as u8, | 3238 | + fi * 20, |
| 3108 | - d.lm, d.start, d.coded_bands, d.intensity, d.dual_stereo as u8, | 3239 | + d.nb_compressed, |
| 3109 | - d.alloc_trim, d.vbr_reservoir, p5.join(","), f5.join(",") | 3240 | + b_ref, |
| 3241 | + d.is_transient as u8, | ||
| 3242 | + d.short_blocks, | ||
| 3243 | + d.intra as u8, | ||
| 3244 | + d.silence as u8, | ||
| 3245 | + d.lm, | ||
| 3246 | + d.start, | ||
| 3247 | + d.coded_bands, | ||
| 3248 | + d.intensity, | ||
| 3249 | + d.dual_stereo as u8, | ||
| 3250 | + d.alloc_trim, | ||
| 3251 | + d.vbr_reservoir, | ||
| 3252 | + p5.join(","), | ||
| 3253 | + f5.join(",") | ||
| 3110 | )); | 3254 | )); |
| 3111 | } | 3255 | } |
| 3112 | out_str.push('\n'); | 3256 | out_str.push('\n'); |
| @@ -3116,30 +3260,50 @@ fn reelm64_persecond_diag() { | |||
| 3116 | out_str.push_str("# --- global stats ---\n"); | 3260 | out_str.push_str("# --- global stats ---\n"); |
| 3117 | let trim_hist: Vec<(i32, usize)> = { | 3261 | let trim_hist: Vec<(i32, usize)> = { |
| 3118 | let mut h = std::collections::HashMap::new(); | 3262 | let mut h = std::collections::HashMap::new(); |
| 3119 | - for d in &diags { *h.entry(d.alloc_trim).or_insert(0) += 1; } | 3263 | + for d in &diags { |
| 3264 | + *h.entry(d.alloc_trim).or_insert(0) += 1; | ||
| 3265 | + } | ||
| 3120 | let mut v: Vec<_> = h.into_iter().collect(); | 3266 | let mut v: Vec<_> = h.into_iter().collect(); |
| 3121 | v.sort(); | 3267 | v.sort(); |
| 3122 | v | 3268 | v |
| 3123 | }; | 3269 | }; |
| 3124 | out_str.push_str(&format!("# alloc_trim histogram: {:?}\n", trim_hist)); | 3270 | out_str.push_str(&format!("# alloc_trim histogram: {:?}\n", trim_hist)); |
| 3125 | let dual_count = diags.iter().filter(|d| d.dual_stereo).count(); | 3271 | let dual_count = diags.iter().filter(|d| d.dual_stereo).count(); |
| 3126 | - out_str.push_str(&format!("# dual_stereo frames: {}/{}\n", dual_count, diags.len())); | 3272 | + out_str.push_str(&format!( |
| 3273 | + "# dual_stereo frames: {}/{}\n", | ||
| 3274 | + dual_count, | ||
| 3275 | + diags.len() | ||
| 3276 | + )); | ||
| 3127 | let trans_count = diags.iter().filter(|d| d.is_transient).count(); | 3277 | let trans_count = diags.iter().filter(|d| d.is_transient).count(); |
| 3128 | - out_str.push_str(&format!("# transient frames: {}/{}\n", trans_count, diags.len())); | 3278 | + out_str.push_str(&format!( |
| 3279 | + "# transient frames: {}/{}\n", | ||
| 3280 | + trans_count, | ||
| 3281 | + diags.len() | ||
| 3282 | + )); | ||
| 3129 | let intensity_hist: Vec<(usize, usize)> = { | 3283 | let intensity_hist: Vec<(usize, usize)> = { |
| 3130 | let mut h = std::collections::HashMap::new(); | 3284 | let mut h = std::collections::HashMap::new(); |
| 3131 | - for d in &diags { *h.entry(d.intensity).or_insert(0) += 1; } | 3285 | + for d in &diags { |
| 3286 | + *h.entry(d.intensity).or_insert(0) += 1; | ||
| 3287 | + } | ||
| 3132 | let mut v: Vec<_> = h.into_iter().collect(); | 3288 | let mut v: Vec<_> = h.into_iter().collect(); |
| 3133 | v.sort(); | 3289 | v.sort(); |
| 3134 | v | 3290 | v |
| 3135 | }; | 3291 | }; |
| 3136 | out_str.push_str(&format!("# intensity histogram: {:?}\n", intensity_hist)); | 3292 | out_str.push_str(&format!("# intensity histogram: {:?}\n", intensity_hist)); |
| 3137 | - let avg_b_ours: f64 = diags.iter().map(|d| d.nb_compressed as f64).sum::<f64>() / diags.len() as f64; | 3293 | + let avg_b_ours: f64 = |
| 3138 | - let avg_b_ref: f64 = ref_payload.iter().map(|&b| b as f64).sum::<f64>() / ref_payload.len() as f64; | 3294 | + diags.iter().map(|d| d.nb_compressed as f64).sum::<f64>() / diags.len() as f64; |
| 3139 | - out_str.push_str(&format!("# avg bytes/frame: ours={:.1} ref={:.1}\n", avg_b_ours, avg_b_ref)); | 3295 | + let avg_b_ref: f64 = |
| 3296 | + ref_payload.iter().map(|&b| b as f64).sum::<f64>() / ref_payload.len() as f64; | ||
| 3297 | + out_str.push_str(&format!( | ||
| 3298 | + "# avg bytes/frame: ours={:.1} ref={:.1}\n", | ||
| 3299 | + avg_b_ours, avg_b_ref | ||
| 3300 | + )); | ||
| 3140 | let ours_kbps = ours_bytes.iter().map(|&b| b as f64).sum::<f64>() * 8.0 / seconds / 1000.0; | 3301 | let ours_kbps = ours_bytes.iter().map(|&b| b as f64).sum::<f64>() * 8.0 / seconds / 1000.0; |
| 3141 | let ref_kbps = ref_payload.iter().map(|&b| b as f64).sum::<f64>() * 8.0 / seconds / 1000.0; | 3302 | let ref_kbps = ref_payload.iter().map(|&b| b as f64).sum::<f64>() * 8.0 / seconds / 1000.0; |
| 3142 | - out_str.push_str(&format!("# realised kbps: ours={:.1} ref={:.1}\n", ours_kbps, ref_kbps)); | 3303 | + out_str.push_str(&format!( |
| 3304 | + "# realised kbps: ours={:.1} ref={:.1}\n", | ||
| 3305 | + ours_kbps, ref_kbps | ||
| 3306 | + )); | ||
| 3143 | 3307 | ||
| 3144 | let out_path = lanes_dir.join("opus-64-r1.seconds.txt"); | 3308 | let out_path = lanes_dir.join("opus-64-r1.seconds.txt"); |
| 3145 | fs::write(&out_path, out_str).unwrap(); | 3309 | fs::write(&out_path, out_str).unwrap(); |
| @@ -3160,7 +3324,10 @@ fn encoder_library_gate_vs_libopus() { | |||
| 3160 | ("reell", "~/Music/reell.mp4"), | 3324 | ("reell", "~/Music/reell.mp4"), |
| 3161 | ("reelm", "~/Music/reelm.wav"), | 3325 | ("reelm", "~/Music/reelm.wav"), |
| 3162 | ("dl8a", "~/Downloads/8a3b6d1d19.mp3"), | 3326 | ("dl8a", "~/Downloads/8a3b6d1d19.mp3"), |
| 3163 | - ("hein", "~/Downloads/reelm.mp3"), | 3327 | + ( |
| 3328 | + "hein", | ||
| 3329 | + "~/Downloads/reelm.mp3", | ||
| 3330 | + ), | ||
| 3164 | ]; | 3331 | ]; |
| 3165 | let only: Vec<String> = std::env::var("SWEEP_ONLY") | 3332 | let only: Vec<String> = std::env::var("SWEEP_ONLY") |
| 3166 | .unwrap_or_default() | 3333 | .unwrap_or_default() |
| @@ -3183,12 +3350,14 @@ fn encoder_library_gate_vs_libopus() { | |||
| 3183 | let mut rows: Vec<String> = Vec::new(); | 3350 | let mut rows: Vec<String> = Vec::new(); |
| 3184 | let mut rate_violations: Vec<String> = Vec::new(); | 3351 | let mut rate_violations: Vec<String> = Vec::new(); |
| 3185 | let mut dropout_violations: Vec<String> = Vec::new(); | 3352 | let mut dropout_violations: Vec<String> = Vec::new(); |
| 3353 | + let mut swept = 0usize; | ||
| 3186 | 3354 | ||
| 3187 | for (tag, src) in &sources { | 3355 | for (tag, src) in &sources { |
| 3188 | - if !src.exists() { | 3356 | + if !require_host_media(src, tag) { |
| 3189 | eprintln!("SKIP {tag}: missing {}", src.display()); | 3357 | eprintln!("SKIP {tag}: missing {}", src.display()); |
| 3190 | continue; | 3358 | continue; |
| 3191 | } | 3359 | } |
| 3360 | + swept += 1; | ||
| 3192 | let source_pcm = ffmpeg_decode_pcm(src, SECS); | 3361 | let source_pcm = ffmpeg_decode_pcm(src, SECS); |
| 3193 | let source_frames = source_pcm.len() / CHANNELS; | 3362 | let source_frames = source_pcm.len() / CHANNELS; |
| 3194 | assert!(source_frames > 48_000, "{tag}: source too short"); | 3363 | assert!(source_frames > 48_000, "{tag}: source too short"); |
| @@ -3198,7 +3367,9 @@ fn encoder_library_gate_vs_libopus() { | |||
| 3198 | for &kbps in &[64u32, 96u32] { | 3367 | for &kbps in &[64u32, 96u32] { |
| 3199 | // Reference: ffmpeg libopus, VBR on, realised rate from file size. | 3368 | // Reference: ffmpeg libopus, VBR on, realised rate from file size. |
| 3200 | ffmpeg_encode_libopus(src, kbps, &scratch, SECS); | 3369 | ffmpeg_encode_libopus(src, kbps, &scratch, SECS); |
| 3201 | - let ref_bytes = fs::metadata(&scratch).map(|m| m.len() as usize).unwrap_or(0); | 3370 | + let ref_bytes = fs::metadata(&scratch) |
| 3371 | + .map(|m| m.len() as usize) | ||
| 3372 | + .unwrap_or(0); | ||
| 3202 | let ref_kbps = ref_bytes as f64 * 8.0 / seconds / 1000.0; | 3373 | let ref_kbps = ref_bytes as f64 * 8.0 / seconds / 1000.0; |
| 3203 | let (ref_dec, ref_ch) = decode_ogg(&scratch); | 3374 | let (ref_dec, ref_ch) = decode_ogg(&scratch); |
| 3204 | assert_eq!(ref_ch, CHANNELS, "{tag}@{kbps}: ref not stereo"); | 3375 | assert_eq!(ref_ch, CHANNELS, "{tag}@{kbps}: ref not stereo"); |
| @@ -3206,8 +3377,7 @@ fn encoder_library_gate_vs_libopus() { | |||
| 3206 | 3377 | ||
| 3207 | // Ours: ec-opus encoder at the reference's realised rate, decoded | 3378 | // Ours: ec-opus encoder at the reference's realised rate, decoded |
| 3208 | // by our own decoder; payload bytes give the realised rate. | 3379 | // by our own decoder; payload bytes give the realised rate. |
| 3209 | - let mut enc = | 3380 | + let mut enc = Encoder::new(48000, CHANNELS, Application::Audio).expect("encoder"); |
| 3210 | - Encoder::new(48000, CHANNELS, Application::Audio).expect("encoder"); | ||
| 3211 | enc.set_bitrate((ref_kbps * 1000.0).round() as u32); | 3381 | enc.set_bitrate((ref_kbps * 1000.0).round() as u32); |
| 3212 | enc.set_vbr_constrained(true); | 3382 | enc.set_vbr_constrained(true); |
| 3213 | let (ours_dec, ours_bytes) = roundtrip_own(&mut enc, &source_pcm, CHANNELS, FRAME); | 3383 | let (ours_dec, ours_bytes) = roundtrip_own(&mut enc, &source_pcm, CHANNELS, FRAME); |
| @@ -3233,7 +3403,11 @@ fn encoder_library_gate_vs_libopus() { | |||
| 3233 | let q_ref = opus_compare(&s_i, &r_i, CHANNELS); | 3403 | let q_ref = opus_compare(&s_i, &r_i, CHANNELS); |
| 3234 | let err_ours = opus_compare_err(&s_i, &o_i, CHANNELS); | 3404 | let err_ours = opus_compare_err(&s_i, &o_i, CHANNELS); |
| 3235 | let err_ref = opus_compare_err(&s_i, &r_i, CHANNELS); | 3405 | let err_ref = opus_compare_err(&s_i, &r_i, CHANNELS); |
| 3236 | - let err_ratio = if err_ref > 0.0 { err_ours / err_ref } else { f64::INFINITY }; | 3406 | + let err_ratio = if err_ref > 0.0 { |
| 3407 | + err_ours / err_ref | ||
| 3408 | + } else { | ||
| 3409 | + f64::INFINITY | ||
| 3410 | + }; | ||
| 3237 | 3411 | ||
| 3238 | let corr_ours = corr_interleaved(&source_pcm, &ours_aligned, CHANNELS); | 3412 | let corr_ours = corr_interleaved(&source_pcm, &ours_aligned, CHANNELS); |
| 3239 | let corr_ref = corr_interleaved(&source_pcm, &ref_aligned, CHANNELS); | 3413 | let corr_ref = corr_interleaved(&source_pcm, &ref_aligned, CHANNELS); |
| @@ -3266,13 +3440,20 @@ fn encoder_library_gate_vs_libopus() { | |||
| 3266 | )); | 3440 | )); |
| 3267 | } | 3441 | } |
| 3268 | } | 3442 | } |
| 3443 | + // Non-empty floor: no source means the whole gate measured nothing. | ||
| 3444 | + assert!( | ||
| 3445 | + swept >= 1, | ||
| 3446 | + "no library-gate source was present, so the gate measured nothing" | ||
| 3447 | + ); | ||
| 3269 | let _ = fs::remove_file(&scratch); | 3448 | let _ = fs::remove_file(&scratch); |
| 3270 | 3449 | ||
| 3271 | let mut table = String::new(); | 3450 | let mut table = String::new(); |
| 3272 | table.push_str("# ec-opus encoder vs ffmpeg libopus — encoders-only gate (r1)\n"); | 3451 | table.push_str("# ec-opus encoder vs ffmpeg libopus — encoders-only gate (r1)\n"); |
| 3273 | table.push_str("# both bitstreams decoded by ec-opus; 120s cap; VBR; 48kHz stereo\n"); | 3452 | table.push_str("# both bitstreams decoded by ec-opus; 120s cap; VBR; 48kHz stereo\n"); |
| 3274 | - table.push_str("# source\tkbps\tours_kbps\tref_kbps\trate%\tcorr_ours\tcorr_ref\tgap\t\ | 3453 | + table.push_str( |
| 3275 | - Q_ours\tQ_ref\terr_ratio\tminsec_ours\tminsec_ref\tdrop_ours\tdrop_ref\n"); | 3454 | + "# source\tkbps\tours_kbps\tref_kbps\trate%\tcorr_ours\tcorr_ref\tgap\t\ |
| 3455 | + Q_ours\tQ_ref\terr_ratio\tminsec_ours\tminsec_ref\tdrop_ours\tdrop_ref\n", | ||
| 3456 | + ); | ||
| 3276 | for r in &rows { | 3457 | for r in &rows { |
| 3277 | table.push_str(r); | 3458 | table.push_str(r); |
| 3278 | table.push('\n'); | 3459 | table.push('\n'); |
| @@ -3335,8 +3516,18 @@ fn ffmpeg_decode_pcm_mono(path: &Path, secs: f64) -> Vec<f32> { | |||
| 3335 | .args(["-v", "error", "-i"]) | 3516 | .args(["-v", "error", "-i"]) |
| 3336 | .arg(path) | 3517 | .arg(path) |
| 3337 | .args([ | 3518 | .args([ |
| 3338 | - "-vn", "-t", &format!("{secs}"), "-ac", "1", "-ar", "48000", "-f", "f32le", | 3519 | + "-vn", |
| 3339 | - "-acodec", "pcm_f32le", "-", | 3520 | + "-t", |
| 3521 | + &format!("{secs}"), | ||
| 3522 | + "-ac", | ||
| 3523 | + "1", | ||
| 3524 | + "-ar", | ||
| 3525 | + "48000", | ||
| 3526 | + "-f", | ||
| 3527 | + "f32le", | ||
| 3528 | + "-acodec", | ||
| 3529 | + "pcm_f32le", | ||
| 3530 | + "-", | ||
| 3340 | ]) | 3531 | ]) |
| 3341 | .output() | 3532 | .output() |
| 3342 | .expect("ffmpeg runs"); | 3533 | .expect("ffmpeg runs"); |
| @@ -3359,8 +3550,21 @@ fn ffmpeg_encode_libopus_mono_voip(src: &Path, kbps: u32, out: &Path, secs: f64) | |||
| 3359 | .args(["-y", "-v", "error", "-i"]) | 3550 | .args(["-y", "-v", "error", "-i"]) |
| 3360 | .arg(src) | 3551 | .arg(src) |
| 3361 | .args([ | 3552 | .args([ |
| 3362 | - "-vn", "-t", &format!("{secs}"), "-ac", "1", "-ar", "48000", "-c:a", "libopus", | 3553 | + "-vn", |
| 3363 | - "-application", "voip", "-b:a", &format!("{kbps}k"), "-vbr", "on", | 3554 | + "-t", |
| 3555 | + &format!("{secs}"), | ||
| 3556 | + "-ac", | ||
| 3557 | + "1", | ||
| 3558 | + "-ar", | ||
| 3559 | + "48000", | ||
| 3560 | + "-c:a", | ||
| 3561 | + "libopus", | ||
| 3562 | + "-application", | ||
| 3563 | + "voip", | ||
| 3564 | + "-b:a", | ||
| 3565 | + &format!("{kbps}k"), | ||
| 3566 | + "-vbr", | ||
| 3567 | + "on", | ||
| 3364 | ]) | 3568 | ]) |
| 3365 | .arg(out) | 3569 | .arg(out) |
| 3366 | .output() | 3570 | .output() |
| @@ -3475,7 +3679,9 @@ fn silk_library_gate_vs_libopus() { | |||
| 3475 | 3679 | ||
| 3476 | // Reference: ffmpeg libopus, mono, voip, VBR; realised rate from size. | 3680 | // Reference: ffmpeg libopus, mono, voip, VBR; realised rate from size. |
| 3477 | ffmpeg_encode_libopus_mono_voip(&src, kbps, &ref_ogg, SECS); | 3681 | ffmpeg_encode_libopus_mono_voip(&src, kbps, &ref_ogg, SECS); |
| 3478 | - let ref_bytes = fs::metadata(&ref_ogg).map(|m| m.len() as usize).unwrap_or(0); | 3682 | + let ref_bytes = fs::metadata(&ref_ogg) |
| 3683 | + .map(|m| m.len() as usize) | ||
| 3684 | + .unwrap_or(0); | ||
| 3479 | let ref_kbps = ref_bytes as f64 * 8.0 / seconds / 1000.0; | 3685 | let ref_kbps = ref_bytes as f64 * 8.0 / seconds / 1000.0; |
| 3480 | // SYMMETRY: ref decoded through ffmpeg libopus (the reference decoder), | 3686 | // SYMMETRY: ref decoded through ffmpeg libopus (the reference decoder), |
| 3481 | // NOT our own decoder — so both sides cross the same decoder. (r1 used | 3687 | // NOT our own decoder — so both sides cross the same decoder. (r1 used |
| @@ -3526,17 +3732,24 @@ fn silk_library_gate_vs_libopus() { | |||
| 3526 | pre_skip, | 3732 | pre_skip, |
| 3527 | ); | 3733 | ); |
| 3528 | let ours_dec = ffmpeg_decode(&ours_ogg, CHANNELS).expect("ffmpeg libopus decode of ours"); | 3734 | let ours_dec = ffmpeg_decode(&ours_ogg, CHANNELS).expect("ffmpeg libopus decode of ours"); |
| 3529 | - let ours_trim: Vec<f32> = ours_dec.into_iter().take(source_frames * CHANNELS).collect(); | 3735 | + let ours_trim: Vec<f32> = ours_dec |
| 3736 | + .into_iter() | ||
| 3737 | + .take(source_frames * CHANNELS) | ||
| 3738 | + .collect(); | ||
| 3530 | let (lag_ours, ours_aligned) = align_to_source(&source_pcm, &ours_trim, CHANNELS, MAX_LAG); | 3739 | let (lag_ours, ours_aligned) = align_to_source(&source_pcm, &ours_trim, CHANNELS, MAX_LAG); |
| 3531 | 3740 | ||
| 3532 | // Own-decoder aligned (extra column: decoder drift visibility). | 3741 | // Own-decoder aligned (extra column: decoder drift visibility). |
| 3533 | - let ours_own_trim: Vec<f32> = | 3742 | + let ours_own_trim: Vec<f32> = ours_own_dec |
| 3534 | - ours_own_dec.into_iter().take(source_frames * CHANNELS).collect(); | 3743 | + .into_iter() |
| 3744 | + .take(source_frames * CHANNELS) | ||
| 3745 | + .collect(); | ||
| 3535 | let (_, ours_own_aligned) = align_to_source(&source_pcm, &ours_own_trim, CHANNELS, MAX_LAG); | 3746 | let (_, ours_own_aligned) = align_to_source(&source_pcm, &ours_own_trim, CHANNELS, MAX_LAG); |
| 3536 | 3747 | ||
| 3537 | // LAG GATE: a lag at the scan bound is an invalid measurement, not a result. | 3748 | // LAG GATE: a lag at the scan bound is an invalid measurement, not a result. |
| 3538 | if (lag_ours as i64).abs() >= MAX_LAG as i64 { | 3749 | if (lag_ours as i64).abs() >= MAX_LAG as i64 { |
| 3539 | - lag_violations.push(format!("{tag}: ours lag {lag_ours} hit scan bound {MAX_LAG}")); | 3750 | + lag_violations.push(format!( |
| 3751 | + "{tag}: ours lag {lag_ours} hit scan bound {MAX_LAG}" | ||
| 3752 | + )); | ||
| 3540 | } | 3753 | } |
| 3541 | if (lag_ref as i64).abs() >= MAX_LAG as i64 { | 3754 | if (lag_ref as i64).abs() >= MAX_LAG as i64 { |
| 3542 | lag_violations.push(format!("{tag}: ref lag {lag_ref} hit scan bound {MAX_LAG}")); | 3755 | lag_violations.push(format!("{tag}: ref lag {lag_ref} hit scan bound {MAX_LAG}")); |
| @@ -3555,7 +3768,11 @@ fn silk_library_gate_vs_libopus() { | |||
| 3555 | let q_ref = opus_compare(&s_i, &r_i, CHANNELS); | 3768 | let q_ref = opus_compare(&s_i, &r_i, CHANNELS); |
| 3556 | let err_ours = opus_compare_err(&s_i, &o_i, CHANNELS); | 3769 | let err_ours = opus_compare_err(&s_i, &o_i, CHANNELS); |
| 3557 | let err_ref = opus_compare_err(&s_i, &r_i, CHANNELS); | 3770 | let err_ref = opus_compare_err(&s_i, &r_i, CHANNELS); |
| 3558 | - let err_ratio = if err_ref > 0.0 { err_ours / err_ref } else { f64::INFINITY }; | 3771 | + let err_ratio = if err_ref > 0.0 { |
| 3772 | + err_ours / err_ref | ||
| 3773 | + } else { | ||
| 3774 | + f64::INFINITY | ||
| 3775 | + }; | ||
| 3559 | 3776 | ||
| 3560 | // Primary corr: band-limited reference. Secondary: full-band source. | 3777 | // Primary corr: band-limited reference. Secondary: full-band source. |
| 3561 | let corr_ours_bl = corr_interleaved(&ref_source, &ours_aligned, CHANNELS); | 3778 | let corr_ours_bl = corr_interleaved(&ref_source, &ours_aligned, CHANNELS); |
| @@ -3672,7 +3889,9 @@ fn silk_silkq_persecond_diag() { | |||
| 3672 | 3889 | ||
| 3673 | // Reference: ffmpeg libopus mono voip VBR at 12k; realised rate from size. | 3890 | // Reference: ffmpeg libopus mono voip VBR at 12k; realised rate from size. |
| 3674 | ffmpeg_encode_libopus_mono_voip(&src, KBPS, &ref_ogg, SECS); | 3891 | ffmpeg_encode_libopus_mono_voip(&src, KBPS, &ref_ogg, SECS); |
| 3675 | - let ref_bytes = fs::metadata(&ref_ogg).map(|m| m.len() as usize).unwrap_or(0); | 3892 | + let ref_bytes = fs::metadata(&ref_ogg) |
| 3893 | + .map(|m| m.len() as usize) | ||
| 3894 | + .unwrap_or(0); | ||
| 3676 | let ref_kbps = ref_bytes as f64 * 8.0 / seconds / 1000.0; | 3895 | let ref_kbps = ref_bytes as f64 * 8.0 / seconds / 1000.0; |
| 3677 | let ref_dec = ffmpeg_decode(&ref_ogg, CHANNELS).expect("ffmpeg libopus decode of ref"); | 3896 | let ref_dec = ffmpeg_decode(&ref_ogg, CHANNELS).expect("ffmpeg libopus decode of ref"); |
| 3678 | let ref_trim: Vec<f32> = ref_dec.into_iter().take(source_frames * CHANNELS).collect(); | 3897 | let ref_trim: Vec<f32> = ref_dec.into_iter().take(source_frames * CHANNELS).collect(); |
| @@ -3711,11 +3930,16 @@ fn silk_silkq_persecond_diag() { | |||
| 3711 | let len = enc.encode_float(block, FRAME, &mut out).expect("encode"); | 3930 | let len = enc.encode_float(block, FRAME, &mut out).expect("encode"); |
| 3712 | let d = enc.last_silk_diag().cloned(); | 3931 | let d = enc.last_silk_diag().cloned(); |
| 3713 | ours_bytes.push(len); | 3932 | ours_bytes.push(len); |
| 3714 | - if let Some(d) = d { diags.push(d); } | 3933 | + if let Some(d) = d { |
| 3934 | + diags.push(d); | ||
| 3935 | + } | ||
| 3715 | let n = dec.decode_float(&out[..len], &mut buf).expect("decode"); | 3936 | let n = dec.decode_float(&out[..len], &mut buf).expect("decode"); |
| 3716 | ours_dec.extend_from_slice(&buf[..n * CHANNELS]); | 3937 | ours_dec.extend_from_slice(&buf[..n * CHANNELS]); |
| 3717 | } | 3938 | } |
| 3718 | - let ours_trim: Vec<f32> = ours_dec.into_iter().take(source_frames * CHANNELS).collect(); | 3939 | + let ours_trim: Vec<f32> = ours_dec |
| 3940 | + .into_iter() | ||
| 3941 | + .take(source_frames * CHANNELS) | ||
| 3942 | + .collect(); | ||
| 3719 | let (_, ours_aligned) = align_to_source(&source_pcm, &ours_trim, CHANNELS, MAX_LAG); | 3943 | let (_, ours_aligned) = align_to_source(&source_pcm, &ours_trim, CHANNELS, MAX_LAG); |
| 3720 | 3944 | ||
| 3721 | // Per-second correlation ours vs ref against the full-band source (matches | 3945 | // Per-second correlation ours vs ref against the full-band source (matches |
| @@ -3736,11 +3960,23 @@ fn silk_silkq_persecond_diag() { | |||
| 3736 | let s = source_pcm[start + i] as f64; | 3960 | let s = source_pcm[start + i] as f64; |
| 3737 | let o = ours_aligned[start + i] as f64; | 3961 | let o = ours_aligned[start + i] as f64; |
| 3738 | let r = ref_aligned[start + i] as f64; | 3962 | let r = ref_aligned[start + i] as f64; |
| 3739 | - sxy_o += s * o; sxx_o += s * s; syy_o += o * o; | 3963 | + sxy_o += s * o; |
| 3740 | - sxy_r += s * r; sxx_r += s * s; syy_r += r * r; | 3964 | + sxx_o += s * s; |
| 3965 | + syy_o += o * o; | ||
| 3966 | + sxy_r += s * r; | ||
| 3967 | + sxx_r += s * s; | ||
| 3968 | + syy_r += r * r; | ||
| 3741 | } | 3969 | } |
| 3742 | - let co = if sxx_o > 0.0 && syy_o > 0.0 { sxy_o / (sxx_o * syy_o).sqrt() } else { 0.0 }; | 3970 | + let co = if sxx_o > 0.0 && syy_o > 0.0 { |
| 3743 | - let cr = if sxx_r > 0.0 && syy_r > 0.0 { sxy_r / (sxx_r * syy_r).sqrt() } else { 0.0 }; | 3971 | + sxy_o / (sxx_o * syy_o).sqrt() |
| 3972 | + } else { | ||
| 3973 | + 0.0 | ||
| 3974 | + }; | ||
| 3975 | + let cr = if sxx_r > 0.0 && syy_r > 0.0 { | ||
| 3976 | + sxy_r / (sxx_r * syy_r).sqrt() | ||
| 3977 | + } else { | ||
| 3978 | + 0.0 | ||
| 3979 | + }; | ||
| 3744 | sec_rows.push((sec_idx, co, cr, cr - co)); | 3980 | sec_rows.push((sec_idx, co, cr, cr - co)); |
| 3745 | start += sec_samples; | 3981 | start += sec_samples; |
| 3746 | sec_idx += 1; | 3982 | sec_idx += 1; |
| @@ -3752,13 +3988,20 @@ fn silk_silkq_persecond_diag() { | |||
| 3752 | let mut out_str = String::new(); | 3988 | let mut out_str = String::new(); |
| 3753 | out_str.push_str("# reelm@12k SILK per-second diagnostic (r1)\n"); | 3989 | out_str.push_str("# reelm@12k SILK per-second diagnostic (r1)\n"); |
| 3754 | out_str.push_str("# mono, 120s cap, 20ms frames, VBR constrained, 48kHz, Application::Voip\n"); | 3990 | out_str.push_str("# mono, 120s cap, 20ms frames, VBR constrained, 48kHz, Application::Voip\n"); |
| 3755 | - out_str.push_str(&format!("# total frames: ours={} ref={}\n", diags.len(), ref_payload.len())); | 3991 | + out_str.push_str(&format!( |
| 3992 | + "# total frames: ours={} ref={}\n", | ||
| 3993 | + diags.len(), | ||
| 3994 | + ref_payload.len() | ||
| 3995 | + )); | ||
| 3756 | let avg_o: f64 = sec_rows.iter().map(|r| r.1).sum::<f64>() / sec_rows.len().max(1) as f64; | 3996 | let avg_o: f64 = sec_rows.iter().map(|r| r.1).sum::<f64>() / sec_rows.len().max(1) as f64; |
| 3757 | let avg_r: f64 = sec_rows.iter().map(|r| r.2).sum::<f64>() / sec_rows.len().max(1) as f64; | 3997 | let avg_r: f64 = sec_rows.iter().map(|r| r.2).sum::<f64>() / sec_rows.len().max(1) as f64; |
| 3758 | let gap_avg = avg_r - avg_o; | 3998 | let gap_avg = avg_r - avg_o; |
| 3759 | out_str.push_str(&format!( | 3999 | out_str.push_str(&format!( |
| 3760 | "# avg corr: ours={:.4} ref={:.4} gap={:+.4} ref_kbps={:.1} ours_kbps={:.1}\n\n", | 4000 | "# avg corr: ours={:.4} ref={:.4} gap={:+.4} ref_kbps={:.1} ours_kbps={:.1}\n\n", |
| 3761 | - avg_o, avg_r, gap_avg, ref_kbps, | 4001 | + avg_o, |
| 4002 | + avg_r, | ||
| 4003 | + gap_avg, | ||
| 4004 | + ref_kbps, | ||
| 3762 | ours_bytes.iter().map(|&b| b as f64).sum::<f64>() * 8.0 / seconds / 1000.0 | 4005 | ours_bytes.iter().map(|&b| b as f64).sum::<f64>() * 8.0 / seconds / 1000.0 |
| 3763 | )); | 4006 | )); |
| 3764 | 4007 | ||
| @@ -3770,27 +4013,45 @@ fn silk_silkq_persecond_diag() { | |||
| 3770 | let sd = &diags[f0..f1.min(diags.len())]; | 4013 | let sd = &diags[f0..f1.min(diags.len())]; |
| 3771 | let gain_mean: f64 = if !sd.is_empty() { | 4014 | let gain_mean: f64 = if !sd.is_empty() { |
| 3772 | sd.iter().map(|d| d.gain_idx[0] as f64).sum::<f64>() / sd.len() as f64 | 4015 | sd.iter().map(|d| d.gain_idx[0] as f64).sum::<f64>() / sd.len() as f64 |
| 3773 | - } else { -1.0 }; | 4016 | + } else { |
| 4017 | + -1.0 | ||
| 4018 | + }; | ||
| 3774 | let voiced_n = sd.iter().filter(|d| d.voiced).count(); | 4019 | let voiced_n = sd.iter().filter(|d| d.voiced).count(); |
| 3775 | let nlsf_int = if !sd.is_empty() { | 4020 | let nlsf_int = if !sd.is_empty() { |
| 3776 | sd.iter().map(|d| d.nlsf_interp).max().unwrap_or(0) | 4021 | sd.iter().map(|d| d.nlsf_interp).max().unwrap_or(0) |
| 3777 | - } else { 0 }; | 4022 | + } else { |
| 4023 | + 0 | ||
| 4024 | + }; | ||
| 3778 | let avg_b_o: f64 = if !sd.is_empty() { | 4025 | let avg_b_o: f64 = if !sd.is_empty() { |
| 3779 | sd.iter().map(|d| d.bytes as f64).sum::<f64>() / sd.len() as f64 | 4026 | sd.iter().map(|d| d.bytes as f64).sum::<f64>() / sd.len() as f64 |
| 3780 | - } else { 0.0 }; | 4027 | + } else { |
| 4028 | + 0.0 | ||
| 4029 | + }; | ||
| 3781 | let ref_f0 = f0.min(ref_payload.len()); | 4030 | let ref_f0 = f0.min(ref_payload.len()); |
| 3782 | let ref_f1 = f1.min(ref_payload.len()); | 4031 | let ref_f1 = f1.min(ref_payload.len()); |
| 3783 | let avg_b_r: f64 = if ref_f1 > ref_f0 { | 4032 | let avg_b_r: f64 = if ref_f1 > ref_f0 { |
| 3784 | - ref_payload[ref_f0..ref_f1].iter().map(|&b| b as f64).sum::<f64>() | 4033 | + ref_payload[ref_f0..ref_f1] |
| 4034 | + .iter() | ||
| 4035 | + .map(|&b| b as f64) | ||
| 4036 | + .sum::<f64>() | ||
| 3785 | / (ref_f1 - ref_f0) as f64 | 4037 | / (ref_f1 - ref_f0) as f64 |
| 3786 | - } else { 0.0 }; | 4038 | + } else { |
| 4039 | + 0.0 | ||
| 4040 | + }; | ||
| 3787 | let ltp_mean: f64 = if !sd.is_empty() { | 4041 | let ltp_mean: f64 = if !sd.is_empty() { |
| 3788 | sd.iter().map(|d| d.ltp_gain as f64).sum::<f64>() / sd.len() as f64 | 4042 | sd.iter().map(|d| d.ltp_gain as f64).sum::<f64>() / sd.len() as f64 |
| 3789 | - } else { 0.0 }; | 4043 | + } else { |
| 4044 | + 0.0 | ||
| 4045 | + }; | ||
| 3790 | let pitch_mean: f64 = if !sd.is_empty() { | 4046 | let pitch_mean: f64 = if !sd.is_empty() { |
| 3791 | - sd.iter().filter(|d| d.voiced).map(|d| d.pitch_l[0] as f64).sum::<f64>() | 4047 | + sd.iter() |
| 4048 | + .filter(|d| d.voiced) | ||
| 4049 | + .map(|d| d.pitch_l[0] as f64) | ||
| 4050 | + .sum::<f64>() | ||
| 3792 | / sd.iter().filter(|d| d.voiced).count().max(1) as f64 | 4051 | / sd.iter().filter(|d| d.voiced).count().max(1) as f64 |
| 3793 | - } else { 0.0 }; | 4052 | + } else { |
| 4053 | + 0.0 | ||
| 4054 | + }; | ||
| 3794 | out_str.push_str(&format!( | 4055 | out_str.push_str(&format!( |
| 3795 | "{}\t{:.4}\t{:.4}\t{:+.4}\t{:.1}\t{}\t{}\t{:.1}\t{:.1}\t{:.3}\t{:.1}\n", | 4056 | "{}\t{:.4}\t{:.4}\t{:+.4}\t{:.1}\t{}\t{}\t{:.1}\t{:.1}\t{:.3}\t{:.1}\n", |
| 3796 | s, co, cr, g, gain_mean, voiced_n, nlsf_int, avg_b_o, avg_b_r, ltp_mean, pitch_mean | 4057 | s, co, cr, g, gain_mean, voiced_n, nlsf_int, avg_b_o, avg_b_r, ltp_mean, pitch_mean |
| @@ -3809,9 +4070,18 @@ fn silk_silkq_persecond_diag() { | |||
| 3809 | let b_ref = ref_payload.get(fi).copied().unwrap_or(0); | 4070 | let b_ref = ref_payload.get(fi).copied().unwrap_or(0); |
| 3810 | out_str.push_str(&format!( | 4071 | out_str.push_str(&format!( |
| 3811 | "{}\t{}\t{}\t{}\t{}\t{}\t{}\t{}\t{}\t{}\t{:.3}\t{}\n", | 4072 | "{}\t{}\t{}\t{}\t{}\t{}\t{}\t{}\t{}\t{}\t{:.3}\t{}\n", |
| 3812 | - fi, fi * 20, d.bytes, b_ref, | 4073 | + fi, |
| 3813 | - d.voiced as u8, d.signal_type, d.gain_idx[0], d.lag_index, | 4074 | + fi * 20, |
| 3814 | - d.pitch_l[0], d.nlsf_interp, d.ltp_gain, d.nb_subfr | 4075 | + d.bytes, |
| 4076 | + b_ref, | ||
| 4077 | + d.voiced as u8, | ||
| 4078 | + d.signal_type, | ||
| 4079 | + d.gain_idx[0], | ||
| 4080 | + d.lag_index, | ||
| 4081 | + d.pitch_l[0], | ||
| 4082 | + d.nlsf_interp, | ||
| 4083 | + d.ltp_gain, | ||
| 4084 | + d.nb_subfr | ||
| 3815 | )); | 4085 | )); |
| 3816 | } | 4086 | } |
| 3817 | out_str.push('\n'); | 4087 | out_str.push('\n'); |
| @@ -3820,10 +4090,16 @@ fn silk_silkq_persecond_diag() { | |||
| 3820 | // Global stats. | 4090 | // Global stats. |
| 3821 | out_str.push_str("# --- global stats ---\n"); | 4091 | out_str.push_str("# --- global stats ---\n"); |
| 3822 | let voiced_count = diags.iter().filter(|d| d.voiced).count(); | 4092 | let voiced_count = diags.iter().filter(|d| d.voiced).count(); |
| 3823 | - out_str.push_str(&format!("# voiced frames: {}/{}\n", voiced_count, diags.len())); | 4093 | + out_str.push_str(&format!( |
| 4094 | + "# voiced frames: {}/{}\n", | ||
| 4095 | + voiced_count, | ||
| 4096 | + diags.len() | ||
| 4097 | + )); | ||
| 3824 | let gain_hist: Vec<(i8, usize)> = { | 4098 | let gain_hist: Vec<(i8, usize)> = { |
| 3825 | let mut h = std::collections::HashMap::new(); | 4099 | let mut h = std::collections::HashMap::new(); |
| 3826 | - for d in &diags { *h.entry(d.gain_idx[0]).or_insert(0) += 1; } | 4100 | + for d in &diags { |
| 4101 | + *h.entry(d.gain_idx[0]).or_insert(0) += 1; | ||
| 4102 | + } | ||
| 3827 | let mut v: Vec<_> = h.into_iter().collect(); | 4103 | let mut v: Vec<_> = h.into_iter().collect(); |
| 3828 | v.sort(); | 4104 | v.sort(); |
| 3829 | v | 4105 | v |
| @@ -3831,16 +4107,24 @@ fn silk_silkq_persecond_diag() { | |||
| 3831 | out_str.push_str(&format!("# gain_idx[0] histogram: {:?}\n", gain_hist)); | 4107 | out_str.push_str(&format!("# gain_idx[0] histogram: {:?}\n", gain_hist)); |
| 3832 | let nlsf_hist: Vec<(i32, usize)> = { | 4108 | let nlsf_hist: Vec<(i32, usize)> = { |
| 3833 | let mut h = std::collections::HashMap::new(); | 4109 | let mut h = std::collections::HashMap::new(); |
| 3834 | - for d in &diags { *h.entry(d.nlsf_interp).or_insert(0) += 1; } | 4110 | + for d in &diags { |
| 4111 | + *h.entry(d.nlsf_interp).or_insert(0) += 1; | ||
| 4112 | + } | ||
| 3835 | let mut v: Vec<_> = h.into_iter().collect(); | 4113 | let mut v: Vec<_> = h.into_iter().collect(); |
| 3836 | v.sort(); | 4114 | v.sort(); |
| 3837 | v | 4115 | v |
| 3838 | }; | 4116 | }; |
| 3839 | out_str.push_str(&format!("# nlsf_interp histogram: {:?}\n", nlsf_hist)); | 4117 | out_str.push_str(&format!("# nlsf_interp histogram: {:?}\n", nlsf_hist)); |
| 3840 | - let avg_b_ours: f64 = diags.iter().map(|d| d.bytes as f64).sum::<f64>() / diags.len().max(1) as f64; | 4118 | + let avg_b_ours: f64 = |
| 3841 | - let avg_b_ref: f64 = ref_payload.iter().map(|&b| b as f64).sum::<f64>() / ref_payload.len().max(1) as f64; | 4119 | + diags.iter().map(|d| d.bytes as f64).sum::<f64>() / diags.len().max(1) as f64; |
| 3842 | - out_str.push_str(&format!("# avg bytes/frame: ours={:.1} ref={:.1}\n", avg_b_ours, avg_b_ref)); | 4120 | + let avg_b_ref: f64 = |
| 3843 | - let ltp_mean_all: f64 = diags.iter().map(|d| d.ltp_gain as f64).sum::<f64>() / diags.len().max(1) as f64; | 4121 | + ref_payload.iter().map(|&b| b as f64).sum::<f64>() / ref_payload.len().max(1) as f64; |
| 4122 | + out_str.push_str(&format!( | ||
| 4123 | + "# avg bytes/frame: ours={:.1} ref={:.1}\n", | ||
| 4124 | + avg_b_ours, avg_b_ref | ||
| 4125 | + )); | ||
| 4126 | + let ltp_mean_all: f64 = | ||
| 4127 | + diags.iter().map(|d| d.ltp_gain as f64).sum::<f64>() / diags.len().max(1) as f64; | ||
| 3844 | out_str.push_str(&format!("# mean ltp_gain: {:.4}\n", ltp_mean_all)); | 4128 | out_str.push_str(&format!("# mean ltp_gain: {:.4}\n", ltp_mean_all)); |
| 3845 | 4129 | ||
| 3846 | let out_path = lanes_dir.join("opus-silkq-r1.seconds.txt"); | 4130 | let out_path = lanes_dir.join("opus-silkq-r1.seconds.txt"); |
| @@ -3902,25 +4186,37 @@ fn silk_silkq_oracle() { | |||
| 3902 | ours_packets.push(out[..len].to_vec()); | 4186 | ours_packets.push(out[..len].to_vec()); |
| 3903 | } | 4187 | } |
| 3904 | 4188 | ||
| 3905 | - | ||
| 3906 | let ours_ix = collect_indices(&ours_packets); | 4189 | let ours_ix = collect_indices(&ours_packets); |
| 3907 | let ref_ix = collect_indices(&ref_packets); | 4190 | let ref_ix = collect_indices(&ref_packets); |
| 3908 | 4191 | ||
| 3909 | - eprintln!("ours frames: {} ref frames: {}", ours_ix.len(), ref_ix.len()); | 4192 | + eprintln!( |
| 4193 | + "ours frames: {} ref frames: {}", | ||
| 4194 | + ours_ix.len(), | ||
| 4195 | + ref_ix.len() | ||
| 4196 | + ); | ||
| 3910 | 4197 | ||
| 3911 | // Print side-by-side for target seconds (50 frames/sec at 20ms). | 4198 | // Print side-by-side for target seconds (50 frames/sec at 20ms). |
| 3912 | let frames_per_sec = 50usize; | 4199 | let frames_per_sec = 50usize; |
| 3913 | let mut out_str = String::new(); | 4200 | let mut out_str = String::new(); |
| 3914 | out_str.push_str("# reelm@12k SILK oracle: ours vs ffmpeg-libopus indices (r1)\n"); | 4201 | out_str.push_str("# reelm@12k SILK oracle: ours vs ffmpeg-libopus indices (r1)\n"); |
| 3915 | out_str.push_str("# mono, 120s, 20ms frames, VBR constrained, 48kHz, Application::Voip\n"); | 4202 | out_str.push_str("# mono, 120s, 20ms frames, VBR constrained, 48kHz, Application::Voip\n"); |
| 3916 | - out_str.push_str(&format!("# ours_frames={} ref_frames={}\n", ours_ix.len(), ref_ix.len())); | 4203 | + out_str.push_str(&format!( |
| 4204 | + "# ours_frames={} ref_frames={}\n", | ||
| 4205 | + ours_ix.len(), | ||
| 4206 | + ref_ix.len() | ||
| 4207 | + )); | ||
| 3917 | out_str.push_str("# sig: 0=unvoiced 2=voiced | per: LTP codebook | nlsf_i: 4=nointerp\n"); | 4208 | out_str.push_str("# sig: 0=unvoiced 2=voiced | per: LTP codebook | nlsf_i: 4=nointerp\n"); |
| 3918 | out_str.push_str("# gains/ltp are 4 subframe indices; lag/contour only for voiced\n\n"); | 4209 | out_str.push_str("# gains/ltp are 4 subframe indices; lag/contour only for voiced\n\n"); |
| 3919 | 4210 | ||
| 3920 | for &sec in TARGET_SECS { | 4211 | for &sec in TARGET_SECS { |
| 3921 | let start = sec * frames_per_sec; | 4212 | let start = sec * frames_per_sec; |
| 3922 | let end = start + frames_per_sec; | 4213 | let end = start + frames_per_sec; |
| 3923 | - out_str.push_str(&format!("=== second {} (frames {}–{}) ===\n", sec, start, end - 1)); | 4214 | + out_str.push_str(&format!( |
| 4215 | + "=== second {} (frames {}–{}) ===\n", | ||
| 4216 | + sec, | ||
| 4217 | + start, | ||
| 4218 | + end - 1 | ||
| 4219 | + )); | ||
| 3924 | out_str.push_str("frame side sig qoff gains[4] nlsf_i lag cont per ltp[4] ltpscl seed bytes\n"); | 4220 | out_str.push_str("frame side sig qoff gains[4] nlsf_i lag cont per ltp[4] ltpscl seed bytes\n"); |
| 3925 | for f in start..end { | 4221 | for f in start..end { |
| 3926 | let ours = ours_ix.get(f); | 4222 | let ours = ours_ix.get(f); |
| @@ -3948,7 +4244,10 @@ fn silk_silkq_oracle() { | |||
| 3948 | "-".to_string() | 4244 | "-".to_string() |
| 3949 | }; | 4245 | }; |
| 3950 | let ltp_str = if voiced { | 4246 | let ltp_str = if voiced { |
| 3951 | - format!("[{},{},{},{}]", ix.ltp_index[0], ix.ltp_index[1], ix.ltp_index[2], ix.ltp_index[3]) | 4247 | + format!( |
| 4248 | + "[{},{},{},{}]", | ||
| 4249 | + ix.ltp_index[0], ix.ltp_index[1], ix.ltp_index[2], ix.ltp_index[3] | ||
| 4250 | + ) | ||
| 3952 | } else { | 4251 | } else { |
| 3953 | "[-,-,-,-]".to_string() | 4252 | "[-,-,-,-]".to_string() |
| 3954 | }; | 4253 | }; |
| @@ -3990,14 +4289,26 @@ fn silk_silkq_oracle() { | |||
| 3990 | for i in 0..n { | 4289 | for i in 0..n { |
| 3991 | let (o, ob) = &ours_ix[i]; | 4290 | let (o, ob) = &ours_ix[i]; |
| 3992 | let (r, rb) = &ref_ix[i]; | 4291 | let (r, rb) = &ref_ix[i]; |
| 3993 | - if o.signal_type != r.signal_type { sig_mismatch += 1; } | 4292 | + if o.signal_type != r.signal_type { |
| 3994 | - if o.quant_offset_type != r.quant_offset_type { qoff_mismatch += 1; } | 4293 | + sig_mismatch += 1; |
| 3995 | - for k in 0..4 { gain_diff_sum += (o.gains[k] as i64 - r.gains[k] as i64).abs(); } | 4294 | + } |
| 3996 | - if o.nlsf_interp_coef_q2 != r.nlsf_interp_coef_q2 { nlsf_interp_diff += 1; } | 4295 | + if o.quant_offset_type != r.quant_offset_type { |
| 4296 | + qoff_mismatch += 1; | ||
| 4297 | + } | ||
| 4298 | + for k in 0..4 { | ||
| 4299 | + gain_diff_sum += (o.gains[k] as i64 - r.gains[k] as i64).abs(); | ||
| 4300 | + } | ||
| 4301 | + if o.nlsf_interp_coef_q2 != r.nlsf_interp_coef_q2 { | ||
| 4302 | + nlsf_interp_diff += 1; | ||
| 4303 | + } | ||
| 3997 | if o.signal_type == 2 && r.signal_type == 2 { | 4304 | if o.signal_type == 2 && r.signal_type == 2 { |
| 3998 | voiced_both += 1; | 4305 | voiced_both += 1; |
| 3999 | - if o.per_index != r.per_index { ltp_per_mismatch += 1; } | 4306 | + if o.per_index != r.per_index { |
| 4000 | - for k in 0..4 { ltp_idx_diff_sum += (o.ltp_index[k] as i64 - r.ltp_index[k] as i64).abs(); } | 4307 | + ltp_per_mismatch += 1; |
| 4308 | + } | ||
| 4309 | + for k in 0..4 { | ||
| 4310 | + ltp_idx_diff_sum += (o.ltp_index[k] as i64 - r.ltp_index[k] as i64).abs(); | ||
| 4311 | + } | ||
| 4001 | lag_diff_sum += (o.lag_index as i64 - r.lag_index as i64).abs(); | 4312 | lag_diff_sum += (o.lag_index as i64 - r.lag_index as i64).abs(); |
| 4002 | } | 4313 | } |
| 4003 | bytes_ours += *ob as u64; | 4314 | bytes_ours += *ob as u64; |
| @@ -4005,15 +4316,45 @@ fn silk_silkq_oracle() { | |||
| 4005 | } | 4316 | } |
| 4006 | out_str.push_str("=== divergence summary (all frames) ===\n"); | 4317 | out_str.push_str("=== divergence summary (all frames) ===\n"); |
| 4007 | out_str.push_str(&format!("frames compared: {}\n", n)); | 4318 | out_str.push_str(&format!("frames compared: {}\n", n)); |
| 4008 | - out_str.push_str(&format!("signal_type mismatch: {} ({:.1}%)\n", sig_mismatch, 100.0 * sig_mismatch as f64 / n as f64)); | 4319 | + out_str.push_str(&format!( |
| 4009 | - out_str.push_str(&format!("quant_offset mismatch: {} ({:.1}%)\n", qoff_mismatch, 100.0 * qoff_mismatch as f64 / n as f64)); | 4320 | + "signal_type mismatch: {} ({:.1}%)\n", |
| 4010 | - out_str.push_str(&format!("avg |gain diff| per subframe: {:.2}\n", gain_diff_sum as f64 / (n as f64 * 4.0))); | 4321 | + sig_mismatch, |
| 4011 | - out_str.push_str(&format!("nlsf_interp mismatch: {} ({:.1}%)\n", nlsf_interp_diff, 100.0 * nlsf_interp_diff as f64 / n as f64)); | 4322 | + 100.0 * sig_mismatch as f64 / n as f64 |
| 4323 | + )); | ||
| 4324 | + out_str.push_str(&format!( | ||
| 4325 | + "quant_offset mismatch: {} ({:.1}%)\n", | ||
| 4326 | + qoff_mismatch, | ||
| 4327 | + 100.0 * qoff_mismatch as f64 / n as f64 | ||
| 4328 | + )); | ||
| 4329 | + out_str.push_str(&format!( | ||
| 4330 | + "avg |gain diff| per subframe: {:.2}\n", | ||
| 4331 | + gain_diff_sum as f64 / (n as f64 * 4.0) | ||
| 4332 | + )); | ||
| 4333 | + out_str.push_str(&format!( | ||
| 4334 | + "nlsf_interp mismatch: {} ({:.1}%)\n", | ||
| 4335 | + nlsf_interp_diff, | ||
| 4336 | + 100.0 * nlsf_interp_diff as f64 / n as f64 | ||
| 4337 | + )); | ||
| 4012 | out_str.push_str(&format!("voiced_both: {}\n", voiced_both)); | 4338 | out_str.push_str(&format!("voiced_both: {}\n", voiced_both)); |
| 4013 | - out_str.push_str(&format!(" LTP per_index mismatch: {} ({:.1}%)\n", ltp_per_mismatch, 100.0 * ltp_per_mismatch as f64 / voiced_both.max(1) as f64)); | 4339 | + out_str.push_str(&format!( |
| 4014 | - out_str.push_str(&format!(" avg |ltp_index diff| per subframe: {:.2}\n", ltp_idx_diff_sum as f64 / (voiced_both.max(1) as f64 * 4.0))); | 4340 | + " LTP per_index mismatch: {} ({:.1}%)\n", |
| 4015 | - out_str.push_str(&format!(" avg |lag diff|: {:.2}\n", lag_diff_sum as f64 / voiced_both.max(1) as f64)); | 4341 | + ltp_per_mismatch, |
| 4016 | - out_str.push_str(&format!("total bytes: ours={} ref={} ratio={:.3}\n", bytes_ours, bytes_ref, bytes_ours as f64 / bytes_ref.max(1) as f64)); | 4342 | + 100.0 * ltp_per_mismatch as f64 / voiced_both.max(1) as f64 |
| 4343 | + )); | ||
| 4344 | + out_str.push_str(&format!( | ||
| 4345 | + " avg |ltp_index diff| per subframe: {:.2}\n", | ||
| 4346 | + ltp_idx_diff_sum as f64 / (voiced_both.max(1) as f64 * 4.0) | ||
| 4347 | + )); | ||
| 4348 | + out_str.push_str(&format!( | ||
| 4349 | + " avg |lag diff|: {:.2}\n", | ||
| 4350 | + lag_diff_sum as f64 / voiced_both.max(1) as f64 | ||
| 4351 | + )); | ||
| 4352 | + out_str.push_str(&format!( | ||
| 4353 | + "total bytes: ours={} ref={} ratio={:.3}\n", | ||
| 4354 | + bytes_ours, | ||
| 4355 | + bytes_ref, | ||
| 4356 | + bytes_ours as f64 / bytes_ref.max(1) as f64 | ||
| 4357 | + )); | ||
| 4017 | 4358 | ||
| 4018 | let out_path = lanes_dir.join("opus-silkq-r1.oracle.txt"); | 4359 | let out_path = lanes_dir.join("opus-silkq-r1.oracle.txt"); |
| 4019 | fs::write(&out_path, &out_str).unwrap(); | 4360 | fs::write(&out_path, &out_str).unwrap(); |
| @@ -4059,14 +4400,7 @@ fn collect_indices(packets: &[Vec<u8>]) -> Vec<(ec_opus::SilkDecIndices, usize)> | |||
| 4059 | continue; | 4400 | continue; |
| 4060 | } | 4401 | } |
| 4061 | let mut dec = ec_opus::RangeDecoder::new(frame_data); | 4402 | let mut dec = ec_opus::RangeDecoder::new(frame_data); |
| 4062 | - let _ = silk.decode( | 4403 | + let _ = silk.decode(&mut dec, &mut silk_pcm, payload_ms, internal_rate, 1, first); |
| 4063 | - &mut dec, | ||
| 4064 | - &mut silk_pcm, | ||
| 4065 | - payload_ms, | ||
| 4066 | - internal_rate, | ||
| 4067 | - 1, | ||
| 4068 | - first, | ||
| 4069 | - ); | ||
| 4070 | let ix = silk.last_indices(); | 4404 | let ix = silk.last_indices(); |
| 4071 | let bytes = frame_data.len(); | 4405 | let bytes = frame_data.len(); |
| 4072 | results.push((ix, bytes)); | 4406 | results.push((ix, bytes)); |
| @@ -4110,7 +4444,9 @@ fn silk_spectral_divergence_12k() { | |||
| 4110 | 4444 | ||
| 4111 | // Reference: ffmpeg libopus mono voip at 12k, decoded by ffmpeg libopus. | 4445 | // Reference: ffmpeg libopus mono voip at 12k, decoded by ffmpeg libopus. |
| 4112 | ffmpeg_encode_libopus_mono_voip(&src, KBPS, &ref_ogg, SECS); | 4446 | ffmpeg_encode_libopus_mono_voip(&src, KBPS, &ref_ogg, SECS); |
| 4113 | - let ref_bytes = fs::metadata(&ref_ogg).map(|m| m.len() as usize).unwrap_or(0); | 4447 | + let ref_bytes = fs::metadata(&ref_ogg) |
| 4448 | + .map(|m| m.len() as usize) | ||
| 4449 | + .unwrap_or(0); | ||
| 4114 | let ref_kbps = ref_bytes as f64 * 8.0 / seconds / 1000.0; | 4450 | let ref_kbps = ref_bytes as f64 * 8.0 / seconds / 1000.0; |
| 4115 | let ref_dec = ffmpeg_decode(&ref_ogg, CHANNELS).expect("ffmpeg libopus decode of ref"); | 4451 | let ref_dec = ffmpeg_decode(&ref_ogg, CHANNELS).expect("ffmpeg libopus decode of ref"); |
| 4116 | let ref_trim: Vec<f32> = ref_dec.into_iter().take(source_frames * CHANNELS).collect(); | 4452 | let ref_trim: Vec<f32> = ref_dec.into_iter().take(source_frames * CHANNELS).collect(); |
| @@ -4156,7 +4492,10 @@ fn silk_spectral_divergence_12k() { | |||
| 4156 | let ours_kbps = ours_bytes as f64 * 8.0 / seconds / 1000.0; | 4492 | let ours_kbps = ours_bytes as f64 * 8.0 / seconds / 1000.0; |
| 4157 | let ours_dec = ffmpeg_decode(&ours_ogg, CHANNELS).expect("ffmpeg libopus decode of ours"); | 4493 | let ours_dec = ffmpeg_decode(&ours_ogg, CHANNELS).expect("ffmpeg libopus decode of ours"); |
| 4158 | let _ = fs::remove_file(&ours_ogg); | 4494 | let _ = fs::remove_file(&ours_ogg); |
| 4159 | - let ours_trim: Vec<f32> = ours_dec.into_iter().take(source_frames * CHANNELS).collect(); | 4495 | + let ours_trim: Vec<f32> = ours_dec |
| 4496 | + .into_iter() | ||
| 4497 | + .take(source_frames * CHANNELS) | ||
| 4498 | + .collect(); | ||
| 4160 | let (_, ours_aligned) = align_to_source(&source_pcm, &ours_trim, CHANNELS, MAX_LAG); | 4499 | let (_, ours_aligned) = align_to_source(&source_pcm, &ours_trim, CHANNELS, MAX_LAG); |
| 4161 | 4500 | ||
| 4162 | // opus_compare totals, per-band eb², per-frame ef² — both vs the source. | 4501 | // opus_compare totals, per-band eb², per-frame ef² — both vs the source. |
| @@ -4178,9 +4517,27 @@ fn silk_spectral_divergence_12k() { | |||
| 4178 | let mut bands_o = Vec::new(); | 4517 | let mut bands_o = Vec::new(); |
| 4179 | let mut bands_r = Vec::new(); | 4518 | let mut bands_r = Vec::new(); |
| 4180 | let mut scratch_ps = Vec::new(); | 4519 | let mut scratch_ps = Vec::new(); |
| 4181 | - band_energy(&as_f64(&s_i), CHANNELS, nframes, &mut Some(&mut bands_s), &mut scratch_ps); | 4520 | + band_energy( |
| 4182 | - band_energy(&as_f64(&o_i), CHANNELS, nframes, &mut Some(&mut bands_o), &mut scratch_ps); | 4521 | + &as_f64(&s_i), |
| 4183 | - band_energy(&as_f64(&r_i), CHANNELS, nframes, &mut Some(&mut bands_r), &mut scratch_ps); | 4522 | + CHANNELS, |
| 4523 | + nframes, | ||
| 4524 | + &mut Some(&mut bands_s), | ||
| 4525 | + &mut scratch_ps, | ||
| 4526 | + ); | ||
| 4527 | + band_energy( | ||
| 4528 | + &as_f64(&o_i), | ||
| 4529 | + CHANNELS, | ||
| 4530 | + nframes, | ||
| 4531 | + &mut Some(&mut bands_o), | ||
| 4532 | + &mut scratch_ps, | ||
| 4533 | + ); | ||
| 4534 | + band_energy( | ||
| 4535 | + &as_f64(&r_i), | ||
| 4536 | + CHANNELS, | ||
| 4537 | + nframes, | ||
| 4538 | + &mut Some(&mut bands_r), | ||
| 4539 | + &mut scratch_ps, | ||
| 4540 | + ); | ||
| 4184 | 4541 | ||
| 4185 | // Oracle indices both sides; FFT frame xi -> 20 ms packet index. | 4542 | // Oracle indices both sides; FFT frame xi -> 20 ms packet index. |
| 4186 | let ours_ix = collect_indices(&ours_packets); | 4543 | let ours_ix = collect_indices(&ours_packets); |
| @@ -4213,7 +4570,11 @@ fn silk_spectral_divergence_12k() { | |||
| 4213 | } | 4570 | } |
| 4214 | dol /= nframes as f64; | 4571 | dol /= nframes as f64; |
| 4215 | drl /= nframes as f64; | 4572 | drl /= nframes as f64; |
| 4216 | - let ratio = if eb2_r[bi] > 0.0 { eb2_o[bi] / eb2_r[bi] } else { f64::INFINITY }; | 4573 | + let ratio = if eb2_r[bi] > 0.0 { |
| 4574 | + eb2_o[bi] / eb2_r[bi] | ||
| 4575 | + } else { | ||
| 4576 | + f64::INFINITY | ||
| 4577 | + }; | ||
| 4217 | report.push_str(&format!( | 4578 | report.push_str(&format!( |
| 4218 | "{:5} {:5} {:6} {:+.3} {:+.3} {:.3e} {:.3e} {:>7} {:5.1}% {:5.1}%\n", | 4579 | "{:5} {:5} {:6} {:+.3} {:+.3} {:.3e} {:.3e} {:>7} {:5.1}% {:5.1}%\n", |
| 4219 | bi, | 4580 | bi, |
| @@ -4318,7 +4679,10 @@ fn silk_spectral_divergence_12k() { | |||
| 4318 | "# tail: top-1% ({k} frames) carry {:.2}% of ours' Σef2 vs {:.2}% of ref's; \ | 4679 | "# tail: top-1% ({k} frames) carry {:.2}% of ours' Σef2 vs {:.2}% of ref's; \ |
| 4319 | 50% of ours' err sits in the worst {half_o} frames ({:.2}%) \ | 4680 | 50% of ours' err sits in the worst {half_o} frames ({:.2}%) \ |
| 4320 | vs ref's worst {half_r} ({:.2}%)\n", | 4681 | vs ref's worst {half_r} ({:.2}%)\n", |
| 4321 | - 100.0 * sh1_o, 100.0 * sh1_r, 100.0 * halff_o, 100.0 * halff_r | 4682 | + 100.0 * sh1_o, |
| 4683 | + 100.0 * sh1_r, | ||
| 4684 | + 100.0 * halff_o, | ||
| 4685 | + 100.0 * halff_r | ||
| 4322 | )); | 4686 | )); |
| 4323 | // De-tailed: drop each side's worst 50 frames (of 24k FFT frames/pkt-mapped). | 4687 | // De-tailed: drop each side's worst 50 frames (of 24k FFT frames/pkt-mapped). |
| 4324 | let clip50 = |ef2: &[f64]| -> f64 { | 4688 | let clip50 = |ef2: &[f64]| -> f64 { |
| @@ -4351,7 +4715,11 @@ fn silk_spectral_divergence_12k() { | |||
| 4351 | if i >= pkt_ef2.len() { | 4715 | if i >= pkt_ef2.len() { |
| 4352 | break; | 4716 | break; |
| 4353 | } | 4717 | } |
| 4354 | - let mean = if pkt_cnt[i] > 0 { pkt_ef2[i] / pkt_cnt[i] as f64 } else { 0.0 }; | 4718 | + let mean = if pkt_cnt[i] > 0 { |
| 4719 | + pkt_ef2[i] / pkt_cnt[i] as f64 | ||
| 4720 | + } else { | ||
| 4721 | + 0.0 | ||
| 4722 | + }; | ||
| 4355 | if ix.gains[0] >= 60 { | 4723 | if ix.gains[0] >= 60 { |
| 4356 | g_hi.0 += mean; | 4724 | g_hi.0 += mean; |
| 4357 | g_hi.1 += 1; | 4725 | g_hi.1 += 1; |
| @@ -4373,12 +4741,28 @@ fn silk_spectral_divergence_12k() { | |||
| 4373 | >20 bytes: mean ef2 {:.3e}\n", | 4741 | >20 bytes: mean ef2 {:.3e}\n", |
| 4374 | g_hi.1, | 4742 | g_hi.1, |
| 4375 | g_hi.1 + g_lo.1, | 4743 | g_hi.1 + g_lo.1, |
| 4376 | - if g_hi.1 > 0 { g_hi.0 / g_hi.1 as f64 } else { f64::NAN }, | 4744 | + if g_hi.1 > 0 { |
| 4377 | - if g_lo.1 > 0 { g_lo.0 / g_lo.1 as f64 } else { f64::NAN }, | 4745 | + g_hi.0 / g_hi.1 as f64 |
| 4746 | + } else { | ||
| 4747 | + f64::NAN | ||
| 4748 | + }, | ||
| 4749 | + if g_lo.1 > 0 { | ||
| 4750 | + g_lo.0 / g_lo.1 as f64 | ||
| 4751 | + } else { | ||
| 4752 | + f64::NAN | ||
| 4753 | + }, | ||
| 4378 | b_lo.1, | 4754 | b_lo.1, |
| 4379 | b_lo.1 + b_hi.1, | 4755 | b_lo.1 + b_hi.1, |
| 4380 | - if b_lo.1 > 0 { b_lo.0 / b_lo.1 as f64 } else { f64::NAN }, | 4756 | + if b_lo.1 > 0 { |
| 4381 | - if b_hi.1 > 0 { b_hi.0 / b_hi.1 as f64 } else { f64::NAN }, | 4757 | + b_lo.0 / b_lo.1 as f64 |
| 4758 | + } else { | ||
| 4759 | + f64::NAN | ||
| 4760 | + }, | ||
| 4761 | + if b_hi.1 > 0 { | ||
| 4762 | + b_hi.0 / b_hi.1 as f64 | ||
| 4763 | + } else { | ||
| 4764 | + f64::NAN | ||
| 4765 | + }, | ||
| 4382 | )); | 4766 | )); |
| 4383 | 4767 | ||
| 4384 | let out_path = lanes_dir.join("opus-silkq-r2.bands.txt"); | 4768 | let out_path = lanes_dir.join("opus-silkq-r2.bands.txt"); |
| @@ -4415,7 +4799,10 @@ fn opus_compare_harness() { | |||
| 4415 | ); | 4799 | ); |
| 4416 | let err = opus_compare_err(&x, &y, channels); | 4800 | let err = opus_compare_err(&x, &y, channels); |
| 4417 | let q = opus_compare(&x, &y, channels); | 4801 | let q = opus_compare(&x, &y, channels); |
| 4418 | - println!("HARNESS err={err:.6} Q={q:.4} ch={channels} n={}", x.len() / channels); | 4802 | + println!( |
| 4803 | + "HARNESS err={err:.6} Q={q:.4} ch={channels} n={}", | ||
| 4804 | + x.len() / channels | ||
| 4805 | + ); | ||
| 4419 | } | 4806 | } |
| 4420 | 4807 | ||
| 4421 | // --------------------------------------------------------------------------- | 4808 | // --------------------------------------------------------------------------- |
| @@ -4454,10 +4841,12 @@ fn opus_compare_harness_ours() { | |||
| 4454 | let mut d_i16 = vec![0i16; n * channels]; | 4841 | let mut d_i16 = vec![0i16; n * channels]; |
| 4455 | for i in 0..n { | 4842 | for i in 0..n { |
| 4456 | for ch in 0..channels { | 4843 | for ch in 0..channels { |
| 4457 | - s_i16[i * channels + ch] = | 4844 | + s_i16[i * channels + ch] = (src_f32[i * channels + ch] * 32768.0) |
| 4458 | - (src_f32[i * channels + ch] * 32768.0).round().clamp(-32768.0, 32767.0) as i16; | 4845 | + .round() |
| 4459 | - d_i16[i * channels + ch] = | 4846 | + .clamp(-32768.0, 32767.0) as i16; |
| 4460 | - (aligned[i * channels + ch] * 32768.0).round().clamp(-32768.0, 32767.0) as i16; | 4847 | + d_i16[i * channels + ch] = (aligned[i * channels + ch] * 32768.0) |
| 4848 | + .round() | ||
| 4849 | + .clamp(-32768.0, 32767.0) as i16; | ||
| 4461 | } | 4850 | } |
| 4462 | } | 4851 | } |
| 4463 | fs::write(&out_src, bytemap(&s_i16)).unwrap(); | 4852 | fs::write(&out_src, bytemap(&s_i16)).unwrap(); |
| @@ -4465,9 +4854,7 @@ fn opus_compare_harness_ours() { | |||
| 4465 | let err = opus_compare_err(&s_i16, &d_i16, channels); | 4854 | let err = opus_compare_err(&s_i16, &d_i16, channels); |
| 4466 | let q = opus_compare(&s_i16, &d_i16, channels); | 4855 | let q = opus_compare(&s_i16, &d_i16, channels); |
| 4467 | let c = corr_interleaved(&src_f32[..n * channels], &aligned, channels); | 4856 | let c = corr_interleaved(&src_f32[..n * channels], &aligned, channels); |
| 4468 | - println!( | 4857 | + println!("HARNESS_OURS lag={lag} corr={c:.4} err={err:.6} Q={q:.4} kbps={kbps} n={n}"); |
| 4469 | - "HARNESS_OURS lag={lag} corr={c:.4} err={err:.6} Q={q:.4} kbps={kbps} n={n}" | ||
| 4470 | - ); | ||
| 4471 | } | 4858 | } |
| 4472 | 4859 | ||
| 4473 | fn bytemap(p: &[i16]) -> Vec<u8> { | 4860 | fn bytemap(p: &[i16]) -> Vec<u8> { |
| @@ -4533,7 +4920,8 @@ fn opus_compare_err_pinned_against_c() { | |||
| 4533 | 4920 | ||
| 4534 | // Case 2: mild perturbation (+0.5 dB on L, quiet 1500 Hz partial on L). | 4921 | // Case 2: mild perturbation (+0.5 dB on L, quiet 1500 Hz partial on L). |
| 4535 | let gain = 10f64.powf(0.5 / 10.0); | 4922 | let gain = 10f64.powf(0.5 / 10.0); |
| 4536 | - let lp: Vec<f64> = t.iter() | 4923 | + let lp: Vec<f64> = t |
| 4924 | + .iter() | ||
| 4537 | .zip(b0.iter()) | 4925 | .zip(b0.iter()) |
| 4538 | .map(|(&tt, &bv)| bv * gain + 0.02 * (2.0 * std::f64::consts::PI * 1500.0 * tt).sin()) | 4926 | .map(|(&tt, &bv)| bv * gain + 0.02 * (2.0 * std::f64::consts::PI * 1500.0 * tt).sin()) |
| 4539 | .collect(); | 4927 | .collect(); |
| @@ -4575,7 +4963,10 @@ fn spectral_divergence_vs_libopus() { | |||
| 4575 | const FRAME: usize = 960; | 4963 | const FRAME: usize = 960; |
| 4576 | const CHANNELS: usize = 2; | 4964 | const CHANNELS: usize = 2; |
| 4577 | const MAX_LAG: usize = 2000; | 4965 | const MAX_LAG: usize = 2000; |
| 4578 | - let kbps_env: u32 = std::env::var("SWEEP_KBPS").ok().and_then(|v| v.parse().ok()).unwrap_or(96); | 4966 | + let kbps_env: u32 = std::env::var("SWEEP_KBPS") |
| 4967 | + .ok() | ||
| 4968 | + .and_then(|v| v.parse().ok()) | ||
| 4969 | + .unwrap_or(96); | ||
| 4579 | #[allow(non_snake_case)] | 4970 | #[allow(non_snake_case)] |
| 4580 | let KBPS: u32 = kbps_env; | 4971 | let KBPS: u32 = kbps_env; |
| 4581 | 4972 | ||
| @@ -4586,7 +4977,10 @@ fn spectral_divergence_vs_libopus() { | |||
| 4586 | ("dl8a", "~/Downloads/8a3b6d1d19.mp3"), | 4977 | ("dl8a", "~/Downloads/8a3b6d1d19.mp3"), |
| 4587 | ("her", "~/Music/reeli.mp3"), | 4978 | ("her", "~/Music/reeli.mp3"), |
| 4588 | ("reelm", "~/Music/reelm.wav"), | 4979 | ("reelm", "~/Music/reelm.wav"), |
| 4589 | - ("hein", "~/Downloads/reelm.mp3"), | 4980 | + ( |
| 4981 | + "hein", | ||
| 4982 | + "~/Downloads/reelm.mp3", | ||
| 4983 | + ), | ||
| 4590 | ]; | 4984 | ]; |
| 4591 | let only: Vec<String> = std::env::var("SWEEP_ONLY") | 4985 | let only: Vec<String> = std::env::var("SWEEP_ONLY") |
| 4592 | .unwrap_or_else(|_| "reell,dl8a".to_owned()) | 4986 | .unwrap_or_else(|_| "reell,dl8a".to_owned()) |
| @@ -4609,12 +5003,14 @@ fn spectral_divergence_vs_libopus() { | |||
| 4609 | let scratch = lanes_dir.join("opus-reell-r1.scratch.ogg"); | 5003 | let scratch = lanes_dir.join("opus-reell-r1.scratch.ogg"); |
| 4610 | let mut frames_all = String::new(); | 5004 | let mut frames_all = String::new(); |
| 4611 | let mut report = String::new(); | 5005 | let mut report = String::new(); |
| 5006 | + let mut swept = 0usize; | ||
| 4612 | 5007 | ||
| 4613 | for (tag, src) in &sources { | 5008 | for (tag, src) in &sources { |
| 4614 | - if !src.exists() { | 5009 | + if !require_host_media(src, tag) { |
| 4615 | eprintln!("SKIP {tag}: missing {}", src.display()); | 5010 | eprintln!("SKIP {tag}: missing {}", src.display()); |
| 4616 | continue; | 5011 | continue; |
| 4617 | } | 5012 | } |
| 5013 | + swept += 1; | ||
| 4618 | let source_pcm = ffmpeg_decode_pcm(src, SECS); | 5014 | let source_pcm = ffmpeg_decode_pcm(src, SECS); |
| 4619 | let source_frames = source_pcm.len() / CHANNELS; | 5015 | let source_frames = source_pcm.len() / CHANNELS; |
| 4620 | let seconds = source_frames as f64 / 48000.0; | 5016 | let seconds = source_frames as f64 / 48000.0; |
| @@ -4622,13 +5018,15 @@ fn spectral_divergence_vs_libopus() { | |||
| 4622 | 5018 | ||
| 4623 | // Reference: ffmpeg libopus at 96k, VBR, decoded by our decoder. | 5019 | // Reference: ffmpeg libopus at 96k, VBR, decoded by our decoder. |
| 4624 | ffmpeg_encode_libopus(src, KBPS, &scratch, SECS); | 5020 | ffmpeg_encode_libopus(src, KBPS, &scratch, SECS); |
| 4625 | - let ref_bytes = fs::metadata(&scratch).map(|m| m.len() as usize).unwrap_or(0); | 5021 | + let ref_bytes = fs::metadata(&scratch) |
| 5022 | + .map(|m| m.len() as usize) | ||
| 5023 | + .unwrap_or(0); | ||
| 4626 | let ref_kbps = ref_bytes as f64 * 8.0 / seconds / 1000.0; | 5024 | let ref_kbps = ref_bytes as f64 * 8.0 / seconds / 1000.0; |
| 4627 | let ref_pkts: Vec<Vec<u8>> = ogg_packets(&fs::read(&scratch).unwrap()) | 5025 | let ref_pkts: Vec<Vec<u8>> = ogg_packets(&fs::read(&scratch).unwrap()) |
| 4628 | .into_iter() | 5026 | .into_iter() |
| 4629 | .skip(2) | 5027 | .skip(2) |
| 4630 | .collect(); | 5028 | .collect(); |
| 4631 | - let (ref_dec, ref_ch) = decode_ogg(&scratch); | 5029 | + let (ref_dec, ref_ch) = decode_ogg(&scratch); |
| 4632 | assert_eq!(ref_ch, CHANNELS, "{tag}: ref not stereo"); | 5030 | assert_eq!(ref_ch, CHANNELS, "{tag}: ref not stereo"); |
| 4633 | let (_, ref_aligned) = align_to_source(&source_pcm, &ref_dec, CHANNELS, MAX_LAG); | 5031 | let (_, ref_aligned) = align_to_source(&source_pcm, &ref_dec, CHANNELS, MAX_LAG); |
| 4634 | 5032 | ||
| @@ -4641,16 +5039,18 @@ fn spectral_divergence_vs_libopus() { | |||
| 4641 | let mut dbuf = vec![0.0f32; 5760 * CHANNELS]; | 5039 | let mut dbuf = vec![0.0f32; 5760 * CHANNELS]; |
| 4642 | let mut ours_dec = Vec::new(); | 5040 | let mut ours_dec = Vec::new(); |
| 4643 | let mut first_pkts: Vec<Vec<u8>> = Vec::new(); | 5041 | let mut first_pkts: Vec<Vec<u8>> = Vec::new(); |
| 4644 | - let mut diags = Vec::new(); | 5042 | + let mut diags = Vec::new(); |
| 4645 | let mut ours_bytes = 0usize; | 5043 | let mut ours_bytes = 0usize; |
| 4646 | for block in source_pcm.chunks(FRAME * CHANNELS) { | 5044 | for block in source_pcm.chunks(FRAME * CHANNELS) { |
| 4647 | let mut padded = block.to_vec(); | 5045 | let mut padded = block.to_vec(); |
| 4648 | padded.resize(FRAME * CHANNELS, 0.0); | 5046 | padded.resize(FRAME * CHANNELS, 0.0); |
| 4649 | - let len = enc.encode_float(&padded, FRAME, &mut packet).expect("encode"); | 5047 | + let len = enc |
| 5048 | + .encode_float(&padded, FRAME, &mut packet) | ||
| 5049 | + .expect("encode"); | ||
| 4650 | if first_pkts.len() < 10 { | 5050 | if first_pkts.len() < 10 { |
| 4651 | first_pkts.push(packet[..len].to_vec()); | 5051 | first_pkts.push(packet[..len].to_vec()); |
| 4652 | } | 5052 | } |
| 4653 | - ours_bytes += len; | 5053 | + ours_bytes += len; |
| 4654 | let n = dec.decode_float(&packet[..len], &mut dbuf).expect("decode"); | 5054 | let n = dec.decode_float(&packet[..len], &mut dbuf).expect("decode"); |
| 4655 | ours_dec.extend_from_slice(&dbuf[..n * CHANNELS]); | 5055 | ours_dec.extend_from_slice(&dbuf[..n * CHANNELS]); |
| 4656 | diags.push(enc.last_celt_diag().clone()); | 5056 | diags.push(enc.last_celt_diag().clone()); |
| @@ -4674,7 +5074,10 @@ fn spectral_divergence_vs_libopus() { | |||
| 4674 | "{tag}@{KBPS}k transient frames: ours {ours_tr}/{} ref {ref_tr}/{ref_n}", | 5074 | "{tag}@{KBPS}k transient frames: ours {ours_tr}/{} ref {ref_tr}/{ref_n}", |
| 4675 | diags.len() | 5075 | diags.len() |
| 4676 | ); | 5076 | ); |
| 4677 | - let ours_trim: Vec<f32> = ours_dec.into_iter().take(source_frames * CHANNELS).collect(); | 5077 | + let ours_trim: Vec<f32> = ours_dec |
| 5078 | + .into_iter() | ||
| 5079 | + .take(source_frames * CHANNELS) | ||
| 5080 | + .collect(); | ||
| 4678 | let (_, ours_aligned) = align_to_source(&source_pcm, &ours_trim, CHANNELS, MAX_LAG); | 5081 | let (_, ours_aligned) = align_to_source(&source_pcm, &ours_trim, CHANNELS, MAX_LAG); |
| 4679 | let ours_i16 = to_i16(&ours_aligned); | 5082 | let ours_i16 = to_i16(&ours_aligned); |
| 4680 | let ref_i16 = to_i16(&ref_aligned); | 5083 | let ref_i16 = to_i16(&ref_aligned); |
| @@ -4700,9 +5103,27 @@ fn spectral_divergence_vs_libopus() { | |||
| 4700 | let mut bands_o = Vec::new(); | 5103 | let mut bands_o = Vec::new(); |
| 4701 | let mut bands_r = Vec::new(); | 5104 | let mut bands_r = Vec::new(); |
| 4702 | let mut scratch_ps = Vec::new(); | 5105 | let mut scratch_ps = Vec::new(); |
| 4703 | - band_energy(&as_f64(&s_i), CHANNELS, nframes, &mut Some(&mut bands_s), &mut scratch_ps); | 5106 | + band_energy( |
| 4704 | - band_energy(&as_f64(&o_i), CHANNELS, nframes, &mut Some(&mut bands_o), &mut scratch_ps); | 5107 | + &as_f64(&s_i), |
| 4705 | - band_energy(&as_f64(&r_i), CHANNELS, nframes, &mut Some(&mut bands_r), &mut scratch_ps); | 5108 | + CHANNELS, |
| 5109 | + nframes, | ||
| 5110 | + &mut Some(&mut bands_s), | ||
| 5111 | + &mut scratch_ps, | ||
| 5112 | + ); | ||
| 5113 | + band_energy( | ||
| 5114 | + &as_f64(&o_i), | ||
| 5115 | + CHANNELS, | ||
| 5116 | + nframes, | ||
| 5117 | + &mut Some(&mut bands_o), | ||
| 5118 | + &mut scratch_ps, | ||
| 5119 | + ); | ||
| 5120 | + band_energy( | ||
| 5121 | + &as_f64(&r_i), | ||
| 5122 | + CHANNELS, | ||
| 5123 | + nframes, | ||
| 5124 | + &mut Some(&mut bands_r), | ||
| 5125 | + &mut scratch_ps, | ||
| 5126 | + ); | ||
| 4706 | 5127 | ||
| 4707 | report.push_str(&format!( | 5128 | report.push_str(&format!( |
| 4708 | "\n# source {tag} @{KBPS}k: ours {ours_kbps:.1} kbps, ref {ref_kbps:.1} kbps; \ | 5129 | "\n# source {tag} @{KBPS}k: ours {ours_kbps:.1} kbps, ref {ref_kbps:.1} kbps; \ |
| @@ -4800,11 +5221,9 @@ fn spectral_divergence_vs_libopus() { | |||
| 4800 | let dual = fr.iter().filter(|d| d.dual_stereo).count(); | 5221 | let dual = fr.iter().filter(|d| d.dual_stereo).count(); |
| 4801 | let intra = fr.iter().filter(|d| d.intra).count(); | 5222 | let intra = fr.iter().filter(|d| d.intra).count(); |
| 4802 | let cbb_min = fr.iter().map(|d| d.coded_bands).min().unwrap_or(0); | 5223 | let cbb_min = fr.iter().map(|d| d.coded_bands).min().unwrap_or(0); |
| 4803 | - let cbb_mean = | 5224 | + let cbb_mean = fr.iter().map(|d| d.coded_bands).sum::<usize>() as f64 / dn as f64; |
| 4804 | - fr.iter().map(|d| d.coded_bands).sum::<usize>() as f64 / dn as f64; | ||
| 4805 | let int_mean = fr.iter().map(|d| d.intensity).sum::<usize>() as f64 / dn as f64; | 5225 | let int_mean = fr.iter().map(|d| d.intensity).sum::<usize>() as f64 / dn as f64; |
| 4806 | - let bits = | 5226 | + let bits = fr.iter().map(|d| d.nb_compressed).sum::<usize>() as f64 * 8.0 / dn as f64; |
| 4807 | - fr.iter().map(|d| d.nb_compressed).sum::<usize>() as f64 * 8.0 / dn as f64; | ||
| 4808 | report.push_str(&format!( | 5227 | report.push_str(&format!( |
| 4809 | "{}\t{:.3e}\t{}/{}\t{}\t{}\t{}\t{}/{}\t{}/{}\t{:.0}\n", | 5228 | "{}\t{:.3e}\t{}/{}\t{}\t{}\t{}\t{}/{}\t{}/{}\t{:.0}\n", |
| 4810 | s, | 5229 | s, |
| @@ -4829,8 +5248,7 @@ fn spectral_divergence_vs_libopus() { | |||
| 4829 | let dual = diags.iter().filter(|d| d.dual_stereo).count(); | 5248 | let dual = diags.iter().filter(|d| d.dual_stereo).count(); |
| 4830 | let intra = diags.iter().filter(|d| d.intra).count(); | 5249 | let intra = diags.iter().filter(|d| d.intra).count(); |
| 4831 | let cbb_min = diags.iter().map(|d| d.coded_bands).min().unwrap_or(0); | 5250 | let cbb_min = diags.iter().map(|d| d.coded_bands).min().unwrap_or(0); |
| 4832 | - let cbb_mean = | 5251 | + let cbb_mean = diags.iter().map(|d| d.coded_bands).sum::<usize>() as f64 / dn as f64; |
| 4833 | - diags.iter().map(|d| d.coded_bands).sum::<usize>() as f64 / dn as f64; | ||
| 4834 | let int_mean = diags.iter().map(|d| d.intensity).sum::<usize>() as f64 / dn as f64; | 5252 | let int_mean = diags.iter().map(|d| d.intensity).sum::<usize>() as f64 / dn as f64; |
| 4835 | let bits = | 5253 | let bits = |
| 4836 | diags.iter().map(|d| d.nb_compressed).sum::<usize>() as f64 * 8.0 / dn as f64; | 5254 | diags.iter().map(|d| d.nb_compressed).sum::<usize>() as f64 * 8.0 / dn as f64; |
| @@ -4854,9 +5272,14 @@ fn spectral_divergence_vs_libopus() { | |||
| 4854 | // frame each window lands in. | 5272 | // frame each window lands in. |
| 4855 | let mut byf: Vec<(usize, f64)> = ef2_o.iter().cloned().enumerate().collect(); | 5273 | let mut byf: Vec<(usize, f64)> = ef2_o.iter().cloned().enumerate().collect(); |
| 4856 | byf.sort_by(|a, b| b.1.partial_cmp(&a.1).unwrap()); | 5274 | byf.sort_by(|a, b| b.1.partial_cmp(&a.1).unwrap()); |
| 4857 | - report.push_str("# top-8 metric windows by ours ef²: offset_ms ours ref | enc frame diag\n"); | 5275 | + report |
| 5276 | + .push_str("# top-8 metric windows by ours ef²: offset_ms ours ref | enc frame diag\n"); | ||
| 4858 | for &(xi, v) in &byf[..byf.len().min(8)] { | 5277 | for &(xi, v) in &byf[..byf.len().min(8)] { |
| 4859 | - let rv = if xi < ef2_r.len() { ef2_r[xi] } else { f64::NAN }; | 5278 | + let rv = if xi < ef2_r.len() { |
| 5279 | + ef2_r[xi] | ||
| 5280 | + } else { | ||
| 5281 | + f64::NAN | ||
| 5282 | + }; | ||
| 4860 | let ms = xi * WIN_STEP * 1000 / 48000; | 5283 | let ms = xi * WIN_STEP * 1000 / 48000; |
| 4861 | let eidx = xi * WIN_STEP / FRAME; | 5284 | let eidx = xi * WIN_STEP / FRAME; |
| 4862 | let d = diags.get(eidx); | 5285 | let d = diags.get(eidx); |
| @@ -4882,9 +5305,8 @@ fn spectral_divergence_vs_libopus() { | |||
| 4882 | } | 5305 | } |
| 4883 | 5306 | ||
| 4884 | // Startup behavior: first 10 encoder frames. | 5307 | // Startup behavior: first 10 encoder frames. |
| 4885 | - report.push_str( | 5308 | + report |
| 4886 | - "# first encoder frames: idx trans intra silence cbb_hz int_hz dual bytes\n", | 5309 | + .push_str("# first encoder frames: idx trans intra silence cbb_hz int_hz dual bytes\n"); |
| 4887 | - ); | ||
| 4888 | for (i, d) in diags.iter().take(10).enumerate() { | 5310 | for (i, d) in diags.iter().take(10).enumerate() { |
| 4889 | report.push_str(&format!( | 5311 | report.push_str(&format!( |
| 4890 | "{}\t{}\t{}\t{}\t{}\t{}\t{}\t{}\n", | 5312 | "{}\t{}\t{}\t{}\t{}\t{}\t{}\t{}\n", |
| @@ -4901,11 +5323,12 @@ fn spectral_divergence_vs_libopus() { | |||
| 4901 | 5323 | ||
| 4902 | // Per-window per-band ln-energies for the metric windows 12..=20 | 5324 | // Per-window per-band ln-energies for the metric windows 12..=20 |
| 4903 | // (+120..+200 ms): the leak's shape, band by band. | 5325 | // (+120..+200 ms): the leak's shape, band by band. |
| 4904 | - report.push_str( | 5326 | + report.push_str("# windows 12..=20: win +ms band lo-hi | lnE src/ours/ref, ch L then R\n"); |
| 4905 | - "# windows 12..=20: win +ms band lo-hi | lnE src/ours/ref, ch L then R\n", | ||
| 4906 | - ); | ||
| 4907 | // WIN_CENTRE=<window index> recentres the dump on another window. | 5327 | // WIN_CENTRE=<window index> recentres the dump on another window. |
| 4908 | - let wc: usize = std::env::var("WIN_CENTRE").ok().and_then(|v| v.parse().ok()).unwrap_or(16); | 5328 | + let wc: usize = std::env::var("WIN_CENTRE") |
| 5329 | + .ok() | ||
| 5330 | + .and_then(|v| v.parse().ok()) | ||
| 5331 | + .unwrap_or(16); | ||
| 4909 | for xi in wc.saturating_sub(4)..=wc + 4 { | 5332 | for xi in wc.saturating_sub(4)..=wc + 4 { |
| 4910 | if xi >= nframes { | 5333 | if xi >= nframes { |
| 4911 | break; | 5334 | break; |
| @@ -4951,7 +5374,8 @@ fn spectral_divergence_vs_libopus() { | |||
| 4951 | g.total_bits, | 5374 | g.total_bits, |
| 4952 | )); | 5375 | )); |
| 4953 | for (ch, name) in [(0usize, 'L'), (1usize, 'R')] { | 5376 | for (ch, name) in [(0usize, 'L'), (1usize, 'R')] { |
| 4954 | - let band = &g.old_band_e[ch * ec_opus::celt::NB_BANDS..(ch + 1) * ec_opus::celt::NB_BANDS]; | 5377 | + let band = &g.old_band_e |
| 5378 | + [ch * ec_opus::celt::NB_BANDS..(ch + 1) * ec_opus::celt::NB_BANDS]; | ||
| 4955 | let e: Vec<String> = band.iter().map(|v| format!("{v:+6.1}")).collect(); | 5379 | let e: Vec<String> = band.iter().map(|v| format!("{v:+6.1}")).collect(); |
| 4956 | frames_all.push_str(&format!(" {name} {}\n", e.join(" "))); | 5380 | frames_all.push_str(&format!(" {name} {}\n", e.join(" "))); |
| 4957 | } | 5381 | } |
| @@ -4962,6 +5386,12 @@ fn spectral_divergence_vs_libopus() { | |||
| 4962 | err_o / err_r | 5386 | err_o / err_r |
| 4963 | ); | 5387 | ); |
| 4964 | } | 5388 | } |
| 5389 | + // Non-empty floor: no source means the report below is empty and the whole | ||
| 5390 | + // divergence analysis went unexercised. | ||
| 5391 | + assert!( | ||
| 5392 | + swept >= 1, | ||
| 5393 | + "no spectral-divergence source was present, so nothing was measured" | ||
| 5394 | + ); | ||
| 4965 | let _ = fs::remove_file(&scratch); | 5395 | let _ = fs::remove_file(&scratch); |
| 4966 | let header = format!( | 5396 | let header = format!( |
| 4967 | "# spectral divergence vs libopus @ {KBPS}k, {SECS:.0}s cap, sources {}\n", | 5397 | "# spectral divergence vs libopus @ {KBPS}k, {SECS:.0}s cap, sources {}\n", |
| @@ -4981,8 +5411,7 @@ fn celt_silence_then_attack_decodes_bounded() { | |||
| 4981 | let fs = 960usize; | 5411 | let fs = 960usize; |
| 4982 | let ch = 2usize; | 5412 | let ch = 2usize; |
| 4983 | let src = shellexpand("~/Music/reell.mp4"); | 5413 | let src = shellexpand("~/Music/reell.mp4"); |
| 4984 | - if !src.exists() { | 5414 | + if !require_host_media(&src, "host-media") { |
| 4985 | - eprintln!("SKIP: missing {}", src.display()); | ||
| 4986 | return; | 5415 | return; |
| 4987 | } | 5416 | } |
| 4988 | let pcm = ffmpeg_decode_pcm(&src, 1.0); | 5417 | let pcm = ffmpeg_decode_pcm(&src, 1.0); |
| @@ -5021,16 +5450,23 @@ fn celt_silence_then_attack_decodes_bounded() { | |||
| 5021 | fn reell_startup_hop_energies() { | 5450 | fn reell_startup_hop_energies() { |
| 5022 | const CH: usize = 2; | 5451 | const CH: usize = 2; |
| 5023 | // HOP_SRC / HOP_MS pick another source and window centre (diagnostic). | 5452 | // HOP_SRC / HOP_MS pick another source and window centre (diagnostic). |
| 5024 | - let src_s = std::env::var("HOP_SRC").unwrap_or_else(|_| "~/Music/reell.mp4".into()); | 5453 | + let src_s = |
| 5025 | - let centre_ms: f64 = std::env::var("HOP_MS").ok().and_then(|v| v.parse().ok()).unwrap_or(42.5); | 5454 | + std::env::var("HOP_SRC").unwrap_or_else(|_| "~/Music/reell.mp4".into()); |
| 5455 | + let centre_ms: f64 = std::env::var("HOP_MS") | ||
| 5456 | + .ok() | ||
| 5457 | + .and_then(|v| v.parse().ok()) | ||
| 5458 | + .unwrap_or(42.5); | ||
| 5026 | let src = shellexpand(&src_s); | 5459 | let src = shellexpand(&src_s); |
| 5027 | - if !src.exists() { | 5460 | + if !require_host_media(&src, "host-media") { |
| 5028 | return; | 5461 | return; |
| 5029 | } | 5462 | } |
| 5030 | let secs = (centre_ms / 1000.0 + 1.0).max(2.0); | 5463 | let secs = (centre_ms / 1000.0 + 1.0).max(2.0); |
| 5031 | let pcm = ffmpeg_decode_pcm(&src, secs); | 5464 | let pcm = ffmpeg_decode_pcm(&src, secs); |
| 5032 | let scratch = std::env::temp_dir().join("ec-opus-reell-startup.opus"); | 5465 | let scratch = std::env::temp_dir().join("ec-opus-reell-startup.opus"); |
| 5033 | - let kbps: u32 = std::env::var("HOP_KBPS").ok().and_then(|v| v.parse().ok()).unwrap_or(96); | 5466 | + let kbps: u32 = std::env::var("HOP_KBPS") |
| 5467 | + .ok() | ||
| 5468 | + .and_then(|v| v.parse().ok()) | ||
| 5469 | + .unwrap_or(96); | ||
| 5034 | ffmpeg_encode_libopus(&src, kbps, &scratch, secs); | 5470 | ffmpeg_encode_libopus(&src, kbps, &scratch, secs); |
| 5035 | let (ref_dec, _) = decode_ogg(&scratch); | 5471 | let (ref_dec, _) = decode_ogg(&scratch); |
| 5036 | let (lag_r, ref_al) = align_to_source(&pcm, &ref_dec, CH, 2000); | 5472 | let (lag_r, ref_al) = align_to_source(&pcm, &ref_dec, CH, 2000); |
| @@ -5048,11 +5484,22 @@ fn reell_startup_hop_energies() { | |||
| 5048 | ours_dec.extend_from_slice(&buf[..m * CH]); | 5484 | ours_dec.extend_from_slice(&buf[..m * CH]); |
| 5049 | let e = enc.last_celt_diag().clone(); | 5485 | let e = enc.last_celt_diag().clone(); |
| 5050 | let d = dec.last_celt_diag().clone(); | 5486 | let d = dec.last_celt_diag().clone(); |
| 5051 | - frames_diag.push((n, e.is_transient, e.intra, d.tf_res.clone(), d.anti_collapse)); | 5487 | + frames_diag.push(( |
| 5488 | + n, | ||
| 5489 | + e.is_transient, | ||
| 5490 | + e.intra, | ||
| 5491 | + d.tf_res.clone(), | ||
| 5492 | + d.anti_collapse, | ||
| 5493 | + )); | ||
| 5052 | } | 5494 | } |
| 5053 | let (lag_o, ours_al) = align_to_source(&pcm, &ours_dec, CH, 2000); | 5495 | let (lag_o, ours_al) = align_to_source(&pcm, &ours_dec, CH, 2000); |
| 5054 | let first = |v: &[f32]| v.iter().position(|x| x.abs() > 1e-4).map(|i| i / CH); | 5496 | let first = |v: &[f32]| v.iter().position(|x| x.abs() > 1e-4).map(|i| i / CH); |
| 5055 | - println!("lag ref {lag_r} ours {lag_o}; first>1e-4: src {:?} ours {:?} ref {:?}", first(&pcm), first(&ours_al), first(&ref_al)); | 5497 | + println!( |
| 5498 | + "lag ref {lag_r} ours {lag_o}; first>1e-4: src {:?} ours {:?} ref {:?}", | ||
| 5499 | + first(&pcm), | ||
| 5500 | + first(&ours_al), | ||
| 5501 | + first(&ref_al) | ||
| 5502 | + ); | ||
| 5056 | let e = |v: &[f32], h: usize| -> f64 { | 5503 | let e = |v: &[f32], h: usize| -> f64 { |
| 5057 | let a = (h * 120 * CH).min(v.len()); | 5504 | let a = (h * 120 * CH).min(v.len()); |
| 5058 | let b = ((h + 1) * 120 * CH).min(v.len()); | 5505 | let b = ((h + 1) * 120 * CH).min(v.len()); |
| @@ -5061,12 +5508,21 @@ fn reell_startup_hop_energies() { | |||
| 5061 | let hc = (centre_ms / 2.5) as usize; | 5508 | let hc = (centre_ms / 2.5) as usize; |
| 5062 | for f in (hc / 8).saturating_sub(1)..=(hc / 8 + 1) { | 5509 | for f in (hc / 8).saturating_sub(1)..=(hc / 8 + 1) { |
| 5063 | if let Some((n, t, i, tf, ac)) = frames_diag.get(f) { | 5510 | if let Some((n, t, i, tf, ac)) = frames_diag.get(f) { |
| 5064 | - println!("frame {f} ({:.1} ms): bytes {n} trans {t} intra {i} ac {ac} tf {tf:?}", f as f64 * 20.0); | 5511 | + println!( |
| 5512 | + "frame {f} ({:.1} ms): bytes {n} trans {t} intra {i} ac {ac} tf {tf:?}", | ||
| 5513 | + f as f64 * 20.0 | ||
| 5514 | + ); | ||
| 5065 | } | 5515 | } |
| 5066 | } | 5516 | } |
| 5067 | println!("hop(ms)\tsrc\tours\tref"); | 5517 | println!("hop(ms)\tsrc\tours\tref"); |
| 5068 | for h in hc.saturating_sub(8)..hc + 8 { | 5518 | for h in hc.saturating_sub(8)..hc + 8 { |
| 5069 | - println!("{:.1}\t{:.3e}\t{:.3e}\t{:.3e}", h as f64 * 2.5, e(&pcm, h), e(&ours_al, h), e(&ref_al, h)); | 5519 | + println!( |
| 5520 | + "{:.1}\t{:.3e}\t{:.3e}\t{:.3e}", | ||
| 5521 | + h as f64 * 2.5, | ||
| 5522 | + e(&pcm, h), | ||
| 5523 | + e(&ours_al, h), | ||
| 5524 | + e(&ref_al, h) | ||
| 5525 | + ); | ||
| 5070 | } | 5526 | } |
| 5071 | } | 5527 | } |
| 5072 | 5528 | ||
| @@ -5083,9 +5539,18 @@ fn celt_click_peak_offset() { | |||
| 5083 | enc.set_mode(Some(ec_opus::Mode::Celt)); | 5539 | enc.set_mode(Some(ec_opus::Mode::Celt)); |
| 5084 | enc.set_bitrate(bps); | 5540 | enc.set_bitrate(bps); |
| 5085 | let (dec, _) = roundtrip_own(&mut enc, &click, 1, 960); | 5541 | let (dec, _) = roundtrip_own(&mut enc, &click, 1, 960); |
| 5086 | - let p = dec.iter().enumerate().max_by(|a, b| a.1.abs().partial_cmp(&b.1.abs()).unwrap()).unwrap().0; | 5542 | + let p = dec |
| 5543 | + .iter() | ||
| 5544 | + .enumerate() | ||
| 5545 | + .max_by(|a, b| a.1.abs().partial_cmp(&b.1.abs()).unwrap()) | ||
| 5546 | + .unwrap() | ||
| 5547 | + .0; | ||
| 5087 | let d = enc.last_celt_diag().clone(); | 5548 | let d = enc.last_celt_diag().clone(); |
| 5088 | - println!("celt click {bps}: peak +{} (lm {})", p as i64 - at as i64, d.lm); | 5549 | + println!( |
| 5550 | + "celt click {bps}: peak +{} (lm {})", | ||
| 5551 | + p as i64 - at as i64, | ||
| 5552 | + d.lm | ||
| 5553 | + ); | ||
| 5089 | } | 5554 | } |
| 5090 | } | 5555 | } |
| 5091 | 5556 | ||
| @@ -5136,18 +5601,22 @@ fn short_block_bits_vs_libopus() { | |||
| 5136 | let scratch = lanes_dir.join("opus-sb-r1.scratch.ogg"); | 5601 | let scratch = lanes_dir.join("opus-sb-r1.scratch.ogg"); |
| 5137 | let nb = ec_opus::celt::NB_BANDS; | 5602 | let nb = ec_opus::celt::NB_BANDS; |
| 5138 | let mut report = String::new(); | 5603 | let mut report = String::new(); |
| 5604 | + let mut swept = 0usize; | ||
| 5139 | 5605 | ||
| 5140 | for (tag, src) in &sources { | 5606 | for (tag, src) in &sources { |
| 5141 | - if !src.exists() { | 5607 | + if !require_host_media(src, tag) { |
| 5142 | eprintln!("SKIP {tag}: missing {}", src.display()); | 5608 | eprintln!("SKIP {tag}: missing {}", src.display()); |
| 5143 | continue; | 5609 | continue; |
| 5144 | } | 5610 | } |
| 5611 | + swept += 1; | ||
| 5145 | let source_pcm = ffmpeg_decode_pcm(src, SECS); | 5612 | let source_pcm = ffmpeg_decode_pcm(src, SECS); |
| 5146 | let seconds = source_pcm.len() as f64 / CHANNELS as f64 / 48000.0; | 5613 | let seconds = source_pcm.len() as f64 / CHANNELS as f64 / 48000.0; |
| 5147 | 5614 | ||
| 5148 | // Reference: ffmpeg libopus at KBPS, VBR. | 5615 | // Reference: ffmpeg libopus at KBPS, VBR. |
| 5149 | ffmpeg_encode_libopus(src, KBPS, &scratch, SECS); | 5616 | ffmpeg_encode_libopus(src, KBPS, &scratch, SECS); |
| 5150 | - let ref_bytes = fs::metadata(&scratch).map(|m| m.len() as usize).unwrap_or(0); | 5617 | + let ref_bytes = fs::metadata(&scratch) |
| 5618 | + .map(|m| m.len() as usize) | ||
| 5619 | + .unwrap_or(0); | ||
| 5151 | let ref_kbps = ref_bytes as f64 * 8.0 / seconds / 1000.0; | 5620 | let ref_kbps = ref_bytes as f64 * 8.0 / seconds / 1000.0; |
| 5152 | let ref_pkts: Vec<Vec<u8>> = ogg_packets(&fs::read(&scratch).unwrap()) | 5621 | let ref_pkts: Vec<Vec<u8>> = ogg_packets(&fs::read(&scratch).unwrap()) |
| 5153 | .into_iter() | 5622 | .into_iter() |
| @@ -5182,7 +5651,9 @@ fn short_block_bits_vs_libopus() { | |||
| 5182 | for block in source_pcm.chunks(FRAME * CHANNELS) { | 5651 | for block in source_pcm.chunks(FRAME * CHANNELS) { |
| 5183 | let mut padded = block.to_vec(); | 5652 | let mut padded = block.to_vec(); |
| 5184 | padded.resize(FRAME * CHANNELS, 0.0); | 5653 | padded.resize(FRAME * CHANNELS, 0.0); |
| 5185 | - let len = enc.encode_float(&padded, FRAME, &mut packet).expect("encode"); | 5654 | + let len = enc |
| 5655 | + .encode_float(&padded, FRAME, &mut packet) | ||
| 5656 | + .expect("encode"); | ||
| 5186 | ours_bytes += len; | 5657 | ours_bytes += len; |
| 5187 | let toc = ec_opus::Toc::new(packet[0]); | 5658 | let toc = ec_opus::Toc::new(packet[0]); |
| 5188 | if dec.decode_float(&packet[..len], &mut dbuf).is_ok() && toc.mode() != Mode::Silk { | 5659 | if dec.decode_float(&packet[..len], &mut dbuf).is_ok() && toc.mode() != Mode::Silk { |
| @@ -5199,10 +5670,14 @@ fn short_block_bits_vs_libopus() { | |||
| 5199 | )); | 5670 | )); |
| 5200 | 5671 | ||
| 5201 | for (label, is_trans) in [("LONG", false), ("SHORT", true)] { | 5672 | for (label, is_trans) in [("LONG", false), ("SHORT", true)] { |
| 5202 | - let ours_t: Vec<&ec_opus::celt::CeltDecDiag> = | 5673 | + let ours_t: Vec<&ec_opus::celt::CeltDecDiag> = ours_diags |
| 5203 | - ours_diags.iter().filter(|d| d.transient == is_trans).collect(); | 5674 | + .iter() |
| 5204 | - let ref_t: Vec<&ec_opus::celt::CeltDecDiag> = | 5675 | + .filter(|d| d.transient == is_trans) |
| 5205 | - ref_diags.iter().filter(|d| d.transient == is_trans).collect(); | 5676 | + .collect(); |
| 5677 | + let ref_t: Vec<&ec_opus::celt::CeltDecDiag> = ref_diags | ||
| 5678 | + .iter() | ||
| 5679 | + .filter(|d| d.transient == is_trans) | ||
| 5680 | + .collect(); | ||
| 5206 | let on = ours_t.len(); | 5681 | let on = ours_t.len(); |
| 5207 | let rn = ref_t.len(); | 5682 | let rn = ref_t.len(); |
| 5208 | if on == 0 && rn == 0 { | 5683 | if on == 0 && rn == 0 { |
| @@ -5235,19 +5710,18 @@ fn short_block_bits_vs_libopus() { | |||
| 5235 | ours_t.iter().map(|d| d.fine_quant[i] as f64).sum::<f64>() / on.max(1) as f64; | 5710 | ours_t.iter().map(|d| d.fine_quant[i] as f64).sum::<f64>() / on.max(1) as f64; |
| 5236 | let rm: f64 = | 5711 | let rm: f64 = |
| 5237 | ref_t.iter().map(|d| d.fine_quant[i] as f64).sum::<f64>() / rn.max(1) as f64; | 5712 | ref_t.iter().map(|d| d.fine_quant[i] as f64).sum::<f64>() / rn.max(1) as f64; |
| 5238 | - report.push_str(&format!( | 5713 | + report.push_str(&format!("{}\t{:.2}\t{:.2}\n", CELT_EBANDS[i] * 240, om, rm)); |
| 5239 | - "{}\t{:.2}\t{:.2}\n", | ||
| 5240 | - CELT_EBANDS[i] * 240, | ||
| 5241 | - om, | ||
| 5242 | - rm | ||
| 5243 | - )); | ||
| 5244 | } | 5714 | } |
| 5245 | 5715 | ||
| 5246 | // Aggregate stats. | 5716 | // Aggregate stats. |
| 5247 | - let mean = |v: &[&ec_opus::celt::CeltDecDiag], f: &dyn Fn(&ec_opus::celt::CeltDecDiag) -> f64| -> f64 { | 5717 | + let mean = |v: &[&ec_opus::celt::CeltDecDiag], |
| 5718 | + f: &dyn Fn(&ec_opus::celt::CeltDecDiag) -> f64| | ||
| 5719 | + -> f64 { | ||
| 5248 | v.iter().map(|d| f(d)).sum::<f64>() / v.len().max(1) as f64 | 5720 | v.iter().map(|d| f(d)).sum::<f64>() / v.len().max(1) as f64 |
| 5249 | }; | 5721 | }; |
| 5250 | - let mean_band_hz = |v: &[&ec_opus::celt::CeltDecDiag], f: &dyn Fn(&ec_opus::celt::CeltDecDiag) -> usize| -> f64 { | 5722 | + let mean_band_hz = |v: &[&ec_opus::celt::CeltDecDiag], |
| 5723 | + f: &dyn Fn(&ec_opus::celt::CeltDecDiag) -> usize| | ||
| 5724 | + -> f64 { | ||
| 5251 | let m = v.iter().map(|d| f(d)).sum::<usize>() / v.len().max(1); | 5725 | let m = v.iter().map(|d| f(d)).sum::<usize>() / v.len().max(1); |
| 5252 | CELT_EBANDS[m] as f64 * 240.0 | 5726 | CELT_EBANDS[m] as f64 * 240.0 |
| 5253 | }; | 5727 | }; |
| @@ -5291,16 +5765,22 @@ fn short_block_bits_vs_libopus() { | |||
| 5291 | )); | 5765 | )); |
| 5292 | report.push_str("# mean dynalloc boost per band (1/8 bit) ours / ref\n"); | 5766 | report.push_str("# mean dynalloc boost per band (1/8 bit) ours / ref\n"); |
| 5293 | for b in 0..nb { | 5767 | for b in 0..nb { |
| 5294 | - let mo = mean(&ours_t, &|d: &ec_opus::celt::CeltDecDiag| d.offsets[b] as f64); | 5768 | + let mo = mean(&ours_t, &|d: &ec_opus::celt::CeltDecDiag| { |
| 5295 | - let mr = mean(&ref_t, &|d: &ec_opus::celt::CeltDecDiag| d.offsets[b] as f64); | 5769 | + d.offsets[b] as f64 |
| 5770 | + }); | ||
| 5771 | + let mr = mean(&ref_t, &|d: &ec_opus::celt::CeltDecDiag| { | ||
| 5772 | + d.offsets[b] as f64 | ||
| 5773 | + }); | ||
| 5296 | if mo != 0.0 || mr != 0.0 { | 5774 | if mo != 0.0 || mr != 0.0 { |
| 5297 | report.push_str(&format!("{}\t{:.1}\t{:.1}\n", CELT_EBANDS[b] * 240, mo, mr)); | 5775 | report.push_str(&format!("{}\t{:.1}\t{:.1}\n", CELT_EBANDS[b] * 240, mo, mr)); |
| 5298 | } | 5776 | } |
| 5299 | } | 5777 | } |
| 5300 | report.push_str(&format!( | 5778 | report.push_str(&format!( |
| 5301 | "# alloc_trim mean: ours {:.2} ref {:.2}\n", | 5779 | "# alloc_trim mean: ours {:.2} ref {:.2}\n", |
| 5302 | - mean(&ours_t, &|d: &ec_opus::celt::CeltDecDiag| d.alloc_trim as f64), | 5780 | + mean(&ours_t, &|d: &ec_opus::celt::CeltDecDiag| d.alloc_trim |
| 5303 | - mean(&ref_t, &|d: &ec_opus::celt::CeltDecDiag| d.alloc_trim as f64), | 5781 | + as f64), |
| 5782 | + mean(&ref_t, &|d: &ec_opus::celt::CeltDecDiag| d.alloc_trim | ||
| 5783 | + as f64), | ||
| 5304 | )); | 5784 | )); |
| 5305 | report.push_str(&format!( | 5785 | report.push_str(&format!( |
| 5306 | "# coded_bands mean Hz: ours {:.0} ref {:.0}\n", | 5786 | "# coded_bands mean Hz: ours {:.0} ref {:.0}\n", |
| @@ -5319,8 +5799,10 @@ fn short_block_bits_vs_libopus() { | |||
| 5319 | )); | 5799 | )); |
| 5320 | report.push_str(&format!( | 5800 | report.push_str(&format!( |
| 5321 | "# total_bits mean: ours {:.0} ref {:.0}\n", | 5801 | "# total_bits mean: ours {:.0} ref {:.0}\n", |
| 5322 | - mean(&ours_t, &|d: &ec_opus::celt::CeltDecDiag| d.total_bits as f64), | 5802 | + mean(&ours_t, &|d: &ec_opus::celt::CeltDecDiag| d.total_bits |
| 5323 | - mean(&ref_t, &|d: &ec_opus::celt::CeltDecDiag| d.total_bits as f64), | 5803 | + as f64), |
| 5804 | + mean(&ref_t, &|d: &ec_opus::celt::CeltDecDiag| d.total_bits | ||
| 5805 | + as f64), | ||
| 5324 | )); | 5806 | )); |
| 5325 | report.push_str(&format!( | 5807 | report.push_str(&format!( |
| 5326 | "# balance mean: ours {:.0} ref {:.0}\n", | 5808 | "# balance mean: ours {:.0} ref {:.0}\n", |
| @@ -5339,6 +5821,11 @@ fn short_block_bits_vs_libopus() { | |||
| 5339 | )); | 5821 | )); |
| 5340 | } | 5822 | } |
| 5341 | } | 5823 | } |
| 5824 | + // Non-empty floor: no source means an empty report and no measurement. | ||
| 5825 | + assert!( | ||
| 5826 | + swept >= 1, | ||
| 5827 | + "no short-block-bits source was present, so nothing was measured" | ||
| 5828 | + ); | ||
| 5342 | 5829 | ||
| 5343 | fs::write(&out_path, &report).unwrap(); | 5830 | fs::write(&out_path, &report).unwrap(); |
| 5344 | eprintln!("wrote {}", out_path.display()); | 5831 | eprintln!("wrote {}", out_path.display()); |
| @@ -5377,8 +5864,7 @@ fn err_map_vs_libopus() { | |||
| 5377 | let src = shellexpand( | 5864 | let src = shellexpand( |
| 5378 | &std::env::var("EC_ERRMAP_SRC").unwrap_or_else(|_| "~/Music/reeli.mp3".to_string()), | 5865 | &std::env::var("EC_ERRMAP_SRC").unwrap_or_else(|_| "~/Music/reeli.mp3".to_string()), |
| 5379 | ); | 5866 | ); |
| 5380 | - if !src.exists() { | 5867 | + if !require_host_media(&src, "host-media") { |
| 5381 | - eprintln!("SKIP: missing {}", src.display()); | ||
| 5382 | return; | 5868 | return; |
| 5383 | } | 5869 | } |
| 5384 | let lanes_dir = Path::new(env!("CARGO_MANIFEST_DIR")).join("../../lanes"); | 5870 | let lanes_dir = Path::new(env!("CARGO_MANIFEST_DIR")).join("../../lanes"); |
| @@ -5393,7 +5879,9 @@ fn err_map_vs_libopus() { | |||
| 5393 | 5879 | ||
| 5394 | // Reference: ffmpeg libopus, VBR — the gate's path. | 5880 | // Reference: ffmpeg libopus, VBR — the gate's path. |
| 5395 | ffmpeg_encode_libopus(&src, kbps_env, &scratch, SECS); | 5881 | ffmpeg_encode_libopus(&src, kbps_env, &scratch, SECS); |
| 5396 | - let ref_bytes = fs::metadata(&scratch).map(|m| m.len() as usize).unwrap_or(0); | 5882 | + let ref_bytes = fs::metadata(&scratch) |
| 5883 | + .map(|m| m.len() as usize) | ||
| 5884 | + .unwrap_or(0); | ||
| 5397 | let ref_kbps = ref_bytes as f64 * 8.0 / seconds / 1000.0; | 5885 | let ref_kbps = ref_bytes as f64 * 8.0 / seconds / 1000.0; |
| 5398 | let (ref_dec, ref_ch) = decode_ogg(&scratch); | 5886 | let (ref_dec, ref_ch) = decode_ogg(&scratch); |
| 5399 | assert_eq!(ref_ch, CH, "ref not stereo"); | 5887 | assert_eq!(ref_ch, CH, "ref not stereo"); |
| @@ -5421,7 +5909,11 @@ fn err_map_vs_libopus() { | |||
| 5421 | let toc = ec_opus::Toc::new(p[0]); | 5909 | let toc = ec_opus::Toc::new(p[0]); |
| 5422 | let got = d.decode_float(p, &mut buf).unwrap_or(0); | 5910 | let got = d.decode_float(p, &mut buf).unwrap_or(0); |
| 5423 | if toc.mode() != Mode::Silk { | 5911 | if toc.mode() != Mode::Silk { |
| 5424 | - ref_fd.push(FD { sample: at, enc: None, dec: d.last_celt_diag().clone() }); | 5912 | + ref_fd.push(FD { |
| 5913 | + sample: at, | ||
| 5914 | + enc: None, | ||
| 5915 | + dec: d.last_celt_diag().clone(), | ||
| 5916 | + }); | ||
| 5425 | } | 5917 | } |
| 5426 | at += got; | 5918 | at += got; |
| 5427 | } | 5919 | } |
| @@ -5465,7 +5957,11 @@ fn err_map_vs_libopus() { | |||
| 5465 | 5957 | ||
| 5466 | // 1 s windows. | 5958 | // 1 s windows. |
| 5467 | let nwin = hop_o.len() / HOPS_PER_WIN; | 5959 | let nwin = hop_o.len() / HOPS_PER_WIN; |
| 5468 | - let sum = |h: &[f64], w: usize| h[w * HOPS_PER_WIN..(w + 1) * HOPS_PER_WIN].iter().sum::<f64>(); | 5960 | + let sum = |h: &[f64], w: usize| { |
| 5961 | + h[w * HOPS_PER_WIN..(w + 1) * HOPS_PER_WIN] | ||
| 5962 | + .iter() | ||
| 5963 | + .sum::<f64>() | ||
| 5964 | + }; | ||
| 5469 | let tot_o: f64 = hop_o.iter().sum(); | 5965 | let tot_o: f64 = hop_o.iter().sum(); |
| 5470 | let tot_r: f64 = hop_r.iter().sum(); | 5966 | let tot_r: f64 = hop_r.iter().sum(); |
| 5471 | let mut wins: Vec<(usize, f64, f64, f64)> = (0..nwin) | 5967 | let mut wins: Vec<(usize, f64, f64, f64)> = (0..nwin) |
| @@ -5500,9 +5996,9 @@ fn err_map_vs_libopus() { | |||
| 5500 | f.dec.spread, | 5996 | f.dec.spread, |
| 5501 | f.dec.anti_collapse as u8, | 5997 | f.dec.anti_collapse as u8, |
| 5502 | f.dec.total_bits, | 5998 | f.dec.total_bits, |
| 5503 | - ) + &e.map(|e| format!( | 5999 | + ) + &e |
| 5504 | - " | ENC sb{} vbr{}", e.short_blocks, e.vbr_reservoir | 6000 | + .map(|e| format!(" | ENC sb{} vbr{}", e.short_blocks, e.vbr_reservoir)) |
| 5505 | - )).unwrap_or_default() | 6001 | + .unwrap_or_default() |
| 5506 | }; | 6002 | }; |
| 5507 | let ref_at = |s: usize| -> Option<&FD> { | 6003 | let ref_at = |s: usize| -> Option<&FD> { |
| 5508 | let i = ref_fd.partition_point(|f| f.sample <= s); | 6004 | let i = ref_fd.partition_point(|f| f.sample <= s); |
| @@ -5569,13 +6065,19 @@ fn err_map_vs_libopus() { | |||
| 5569 | ) | 6065 | ) |
| 5570 | }) | 6066 | }) |
| 5571 | .collect(); | 6067 | .collect(); |
| 5572 | - out.push_str(&format!(" Δlog2E L {}\n R {}\n", d0.join(" "), d1.join(" "))); | 6068 | + out.push_str(&format!( |
| 6069 | + " Δlog2E L {}\n R {}\n", | ||
| 6070 | + d0.join(" "), | ||
| 6071 | + d1.join(" ") | ||
| 6072 | + )); | ||
| 5573 | } | 6073 | } |
| 5574 | } | 6074 | } |
| 5575 | } | 6075 | } |
| 5576 | 6076 | ||
| 5577 | // The single worst ours window, frame by frame: where do decisions diverge. | 6077 | // The single worst ours window, frame by frame: where do decisions diverge. |
| 5578 | - let worst = (0..nwin).max_by(|&a, &b| wins[a].1.total_cmp(&wins[b].1)).unwrap(); | 6078 | + let worst = (0..nwin) |
| 6079 | + .max_by(|&a, &b| wins[a].1.total_cmp(&wins[b].1)) | ||
| 6080 | + .unwrap(); | ||
| 5579 | out.push_str(&format!( | 6081 | out.push_str(&format!( |
| 5580 | "\n== WORST WINDOW t={}..{}s, ALL FRAMES (OUR | REF) ==\n", | 6082 | "\n== WORST WINDOW t={}..{}s, ALL FRAMES (OUR | REF) ==\n", |
| 5581 | worst, | 6083 | worst, |
| @@ -5583,7 +6085,9 @@ fn err_map_vs_libopus() { | |||
| 5583 | )); | 6085 | )); |
| 5584 | for fi in worst * 50..(worst + 1) * 50 { | 6086 | for fi in worst * 50..(worst + 1) * 50 { |
| 5585 | let our = ours_fd.get(fi).map(&fmt_fd).unwrap_or_else(|| "-".into()); | 6087 | let our = ours_fd.get(fi).map(&fmt_fd).unwrap_or_else(|| "-".into()); |
| 5586 | - let rf = ref_at(fi * FRAME + 480).map(&fmt_fd).unwrap_or_else(|| "-".into()); | 6088 | + let rf = ref_at(fi * FRAME + 480) |
| 6089 | + .map(&fmt_fd) | ||
| 6090 | + .unwrap_or_else(|| "-".into()); | ||
| 5587 | out.push_str(&format!("f{fi}: OUR {our}\n REF {rf}\n")); | 6091 | out.push_str(&format!("f{fi}: OUR {our}\n REF {rf}\n")); |
| 5588 | } | 6092 | } |
| 5589 | 6093 | ||
| @@ -5599,31 +6103,52 @@ fn err_map_vs_libopus() { | |||
| 5599 | #[ignore] | 6103 | #[ignore] |
| 5600 | fn frame_decisions_vs_libopus() { | 6104 | fn frame_decisions_vs_libopus() { |
| 5601 | const CH: usize = 2; | 6105 | const CH: usize = 2; |
| 5602 | - let src_s = std::env::var("FRAME_SRC") | 6106 | + let src_s = |
| 5603 | - .unwrap_or_else(|_| "~/Music/reell.mp4".into()); | 6107 | + std::env::var("FRAME_SRC").unwrap_or_else(|_| "~/Music/reell.mp4".into()); |
| 5604 | let src = shellexpand(&src_s); | 6108 | let src = shellexpand(&src_s); |
| 5605 | - if !src.exists() { | 6109 | + if !require_host_media(&src, "host-media") { |
| 5606 | - eprintln!("SKIP: missing {}", src.display()); | ||
| 5607 | return; | 6110 | return; |
| 5608 | } | 6111 | } |
| 5609 | - let kbps: u32 = std::env::var("FRAME_KBPS").ok().and_then(|v| v.parse().ok()).unwrap_or(64); | 6112 | + let kbps: u32 = std::env::var("FRAME_KBPS") |
| 5610 | - let from: usize = std::env::var("FRAME_FROM").ok().and_then(|v| v.parse().ok()).unwrap_or(0); | 6113 | + .ok() |
| 5611 | - let to: usize = std::env::var("FRAME_TO").ok().and_then(|v| v.parse().ok()).unwrap_or(6); | 6114 | + .and_then(|v| v.parse().ok()) |
| 6115 | + .unwrap_or(64); | ||
| 6116 | + let from: usize = std::env::var("FRAME_FROM") | ||
| 6117 | + .ok() | ||
| 6118 | + .and_then(|v| v.parse().ok()) | ||
| 6119 | + .unwrap_or(0); | ||
| 6120 | + let to: usize = std::env::var("FRAME_TO") | ||
| 6121 | + .ok() | ||
| 6122 | + .and_then(|v| v.parse().ok()) | ||
| 6123 | + .unwrap_or(6); | ||
| 5612 | let secs = (to as f64 * 0.02 + 1.0).max(2.0); | 6124 | let secs = (to as f64 * 0.02 + 1.0).max(2.0); |
| 5613 | let pcm = ffmpeg_decode_pcm(&src, secs); | 6125 | let pcm = ffmpeg_decode_pcm(&src, secs); |
| 5614 | let scratch = std::env::temp_dir().join("ec-opus-frame-dec.opus"); | 6126 | let scratch = std::env::temp_dir().join("ec-opus-frame-dec.opus"); |
| 5615 | ffmpeg_encode_libopus(&src, kbps, &scratch, secs); | 6127 | ffmpeg_encode_libopus(&src, kbps, &scratch, secs); |
| 5616 | - let ref_pkts: Vec<Vec<u8>> = | 6128 | + let ref_pkts: Vec<Vec<u8>> = ogg_packets(&fs::read(&scratch).unwrap()) |
| 5617 | - ogg_packets(&fs::read(&scratch).unwrap()).into_iter().skip(2).collect(); | 6129 | + .into_iter() |
| 6130 | + .skip(2) | ||
| 6131 | + .collect(); | ||
| 5618 | 6132 | ||
| 5619 | let show = |tag: &str, f: usize, bytes: usize, d: &ec_opus::celt::CeltDecDiag| { | 6133 | let show = |tag: &str, f: usize, bytes: usize, d: &ec_opus::celt::CeltDecDiag| { |
| 5620 | - let e: Vec<String> = d.old_band_e[..NB_BANDS_DIAG].iter().map(|v| format!("{v:.1}")).collect(); | 6134 | + let e: Vec<String> = d.old_band_e[..NB_BANDS_DIAG] |
| 6135 | + .iter() | ||
| 6136 | + .map(|v| format!("{v:.1}")) | ||
| 6137 | + .collect(); | ||
| 5621 | println!( | 6138 | println!( |
| 5622 | "f{f} {tag}: bytes {bytes} sil {} intra {} trans {} ac {} trim {} spread {} cb {} \ | 6139 | "f{f} {tag}: bytes {bytes} sil {} intra {} trans {} ac {} trim {} spread {} cb {} \ |
| 5623 | tf {:?} pulses {:?} fine {:?} E {}", | 6140 | tf {:?} pulses {:?} fine {:?} E {}", |
| 5624 | - d.silence, d.intra, d.transient, d.anti_collapse, d.alloc_trim, d.spread, | 6141 | + d.silence, |
| 5625 | - d.coded_bands, &d.tf_res[..NB_BANDS_DIAG], &d.pulses[..NB_BANDS_DIAG], | 6142 | + d.intra, |
| 5626 | - &d.fine_quant[..NB_BANDS_DIAG], e.join(",") | 6143 | + d.transient, |
| 6144 | + d.anti_collapse, | ||
| 6145 | + d.alloc_trim, | ||
| 6146 | + d.spread, | ||
| 6147 | + d.coded_bands, | ||
| 6148 | + &d.tf_res[..NB_BANDS_DIAG], | ||
| 6149 | + &d.pulses[..NB_BANDS_DIAG], | ||
| 6150 | + &d.fine_quant[..NB_BANDS_DIAG], | ||
| 6151 | + e.join(",") | ||
| 5627 | ); | 6152 | ); |
| 5628 | }; | 6153 | }; |
| 5629 | 6154 | ||
| @@ -5634,7 +6159,11 @@ fn frame_decisions_vs_libopus() { | |||
| 5634 | let ok = !p.is_empty() | 6159 | let ok = !p.is_empty() |
| 5635 | && ec_opus::Toc::new(p[0]).mode() != Mode::Silk | 6160 | && ec_opus::Toc::new(p[0]).mode() != Mode::Silk |
| 5636 | && d.decode_float(p, &mut buf).is_ok(); | 6161 | && d.decode_float(p, &mut buf).is_ok(); |
| 5637 | - ref_rows.push(if ok { Some((p.len(), d.last_celt_diag().clone())) } else { None }); | 6162 | + ref_rows.push(if ok { |
| 6163 | + Some((p.len(), d.last_celt_diag().clone())) | ||
| 6164 | + } else { | ||
| 6165 | + None | ||
| 6166 | + }); | ||
| 5638 | } | 6167 | } |
| 5639 | 6168 | ||
| 5640 | // Encode at the reference's REALISED rate, like the library gate does: | 6169 | // Encode at the reference's REALISED rate, like the library gate does: |
| @@ -5653,7 +6182,11 @@ fn frame_decisions_vs_libopus() { | |||
| 5653 | let n = enc.encode_float(block, 960, &mut out).unwrap(); | 6182 | let n = enc.encode_float(block, 960, &mut out).unwrap(); |
| 5654 | let ok = ec_opus::Toc::new(out[0]).mode() != Mode::Silk | 6183 | let ok = ec_opus::Toc::new(out[0]).mode() != Mode::Silk |
| 5655 | && dec.decode_float(&out[..n], &mut buf).is_ok(); | 6184 | && dec.decode_float(&out[..n], &mut buf).is_ok(); |
| 5656 | - ours_rows.push(if ok { Some((n, dec.last_celt_diag().clone())) } else { None }); | 6185 | + ours_rows.push(if ok { |
| 6186 | + Some((n, dec.last_celt_diag().clone())) | ||
| 6187 | + } else { | ||
| 6188 | + None | ||
| 6189 | + }); | ||
| 5657 | } | 6190 | } |
| 5658 | 6191 | ||
| 5659 | if to - from <= 40 { | 6192 | if to - from <= 40 { |
| @@ -5674,9 +6207,10 @@ fn frame_decisions_vs_libopus() { | |||
| 5674 | let mut agg = [(0usize, [0.0f64; 8]); 2]; | 6207 | let mut agg = [(0usize, [0.0f64; 8]); 2]; |
| 5675 | let mut trans_diff = 0usize; | 6208 | let mut trans_diff = 0usize; |
| 5676 | for f in from..to { | 6209 | for f in from..to { |
| 5677 | - let (Some((no, o)), Some((nr, r))) = | 6210 | + let (Some((no, o)), Some((nr, r))) = ( |
| 5678 | - (ours_rows.get(f).and_then(|x| x.as_ref()), ref_rows.get(f).and_then(|x| x.as_ref())) | 6211 | + ours_rows.get(f).and_then(|x| x.as_ref()), |
| 5679 | - else { | 6212 | + ref_rows.get(f).and_then(|x| x.as_ref()), |
| 6213 | + ) else { | ||
| 5680 | continue; | 6214 | continue; |
| 5681 | }; | 6215 | }; |
| 5682 | if o.transient != r.transient { | 6216 | if o.transient != r.transient { |
| @@ -5689,10 +6223,14 @@ fn frame_decisions_vs_libopus() { | |||
| 5689 | let a = &mut agg[slot]; | 6223 | let a = &mut agg[slot]; |
| 5690 | a.0 += 1; | 6224 | a.0 += 1; |
| 5691 | for (k, v) in [ | 6225 | for (k, v) in [ |
| 5692 | - *no as f64, *nr as f64, | 6226 | + *no as f64, |
| 5693 | - o.alloc_trim as f64, r.alloc_trim as f64, | 6227 | + *nr as f64, |
| 5694 | - tf(o), tf(r), | 6228 | + o.alloc_trim as f64, |
| 5695 | - f64::from(u8::from(o.anti_collapse)), f64::from(u8::from(r.anti_collapse)), | 6229 | + r.alloc_trim as f64, |
| 6230 | + tf(o), | ||
| 6231 | + tf(r), | ||
| 6232 | + f64::from(u8::from(o.anti_collapse)), | ||
| 6233 | + f64::from(u8::from(r.anti_collapse)), | ||
| 5696 | ] | 6234 | ] |
| 5697 | .into_iter() | 6235 | .into_iter() |
| 5698 | .enumerate() | 6236 | .enumerate() |
| @@ -5710,7 +6248,14 @@ fn frame_decisions_vs_libopus() { | |||
| 5710 | println!( | 6248 | println!( |
| 5711 | "{name} n={n}: bytes o {:.1} r {:.1} | trim o {:.2} r {:.2} | mean tf_res o {:.3} \ | 6249 | "{name} n={n}: bytes o {:.1} r {:.1} | trim o {:.2} r {:.2} | mean tf_res o {:.3} \ |
| 5712 | r {:.3} | anti_collapse o {:.2} r {:.2}", | 6250 | r {:.3} | anti_collapse o {:.2} r {:.2}", |
| 5713 | - m(0), m(1), m(2), m(3), m(4), m(5), m(6), m(7) | 6251 | + m(0), |
| 6252 | + m(1), | ||
| 6253 | + m(2), | ||
| 6254 | + m(3), | ||
| 6255 | + m(4), | ||
| 6256 | + m(5), | ||
| 6257 | + m(6), | ||
| 6258 | + m(7) | ||
| 5714 | ); | 6259 | ); |
| 5715 | } | 6260 | } |
| 5716 | } | 6261 | } |
| @@ -5730,7 +6275,11 @@ fn analysis_music_prob_separates_speech_from_music() { | |||
| 5730 | const FRAME: usize = 960; | 6275 | const FRAME: usize = 960; |
| 5731 | const CHANNELS: usize = 2; | 6276 | const CHANNELS: usize = 2; |
| 5732 | let sources: &[(&str, &str, bool)] = &[ | 6277 | let sources: &[(&str, &str, bool)] = &[ |
| 5733 | - ("hein", "~/Downloads/reelm.mp3", false), | 6278 | + ( |
| 6279 | + "hein", | ||
| 6280 | + "~/Downloads/reelm.mp3", | ||
| 6281 | + false, | ||
| 6282 | + ), | ||
| 5734 | ("reell", "~/Music/reell.mp4", true), | 6283 | ("reell", "~/Music/reell.mp4", true), |
| 5735 | ("reelo", "~/Music/reelo.mp3", true), | 6284 | ("reelo", "~/Music/reelo.mp3", true), |
| 5736 | ]; | 6285 | ]; |
| @@ -5749,7 +6298,7 @@ fn analysis_music_prob_separates_speech_from_music() { | |||
| 5749 | let mut means: Vec<(String, bool, f64)> = Vec::new(); | 6298 | let mut means: Vec<(String, bool, f64)> = Vec::new(); |
| 5750 | for (tag, path, is_music) in sources { | 6299 | for (tag, path, is_music) in sources { |
| 5751 | let src = shellexpand(path); | 6300 | let src = shellexpand(path); |
| 5752 | - if !src.exists() { | 6301 | + if !require_host_media(&src, "host-media") { |
| 5753 | eprintln!("SKIP {tag}: missing {}", src.display()); | 6302 | eprintln!("SKIP {tag}: missing {}", src.display()); |
| 5754 | continue; | 6303 | continue; |
| 5755 | } | 6304 | } |
| @@ -5781,7 +6330,10 @@ fn analysis_music_prob_separates_speech_from_music() { | |||
| 5781 | bw_hist[(d.analysis_bandwidth.clamp(0, 20)) as usize] += 1; | 6330 | bw_hist[(d.analysis_bandwidth.clamp(0, 20)) as usize] += 1; |
| 5782 | } | 6331 | } |
| 5783 | } | 6332 | } |
| 5784 | - assert!(valid * 10 > n * 9, "{tag}: analysis valid on only {valid}/{n} frames"); | 6333 | + assert!( |
| 6334 | + valid * 10 > n * 9, | ||
| 6335 | + "{tag}: analysis valid on only {valid}/{n} frames" | ||
| 6336 | + ); | ||
| 5785 | let bw: Vec<String> = bw_hist | 6337 | let bw: Vec<String> = bw_hist |
| 5786 | .iter() | 6338 | .iter() |
| 5787 | .enumerate() | 6339 | .enumerate() |
| @@ -5816,7 +6368,12 @@ fn analysis_music_prob_separates_speech_from_music() { | |||
| 5816 | let speech: Vec<_> = means.iter().filter(|m| !m.1).collect(); | 6368 | let speech: Vec<_> = means.iter().filter(|m| !m.1).collect(); |
| 5817 | let music: Vec<_> = means.iter().filter(|m| m.1).collect(); | 6369 | let music: Vec<_> = means.iter().filter(|m| m.1).collect(); |
| 5818 | for s in &speech { | 6370 | for s in &speech { |
| 5819 | - assert!(s.2 < 0.5, "{}: speech music_prob {:.3} should be < 0.5", s.0, s.2); | 6371 | + assert!( |
| 6372 | + s.2 < 0.5, | ||
| 6373 | + "{}: speech music_prob {:.3} should be < 0.5", | ||
| 6374 | + s.0, | ||
| 6375 | + s.2 | ||
| 6376 | + ); | ||
| 5820 | for m in &music { | 6377 | for m in &music { |
| 5821 | assert!( | 6378 | assert!( |
| 5822 | m.2 - s.2 > 0.2, | 6379 | m.2 - s.2 > 0.2, |
| @@ -5829,6 +6386,11 @@ fn analysis_music_prob_separates_speech_from_music() { | |||
| 5829 | } | 6386 | } |
| 5830 | } | 6387 | } |
| 5831 | for m in &music { | 6388 | for m in &music { |
| 5832 | - assert!(m.2 > 0.5, "{}: music music_prob {:.3} should be > 0.5", m.0, m.2); | 6389 | + assert!( |
| 6390 | + m.2 > 0.5, | ||
| 6391 | + "{}: music music_prob {:.3} should be > 0.5", | ||
| 6392 | + m.0, | ||
| 6393 | + m.2 | ||
| 6394 | + ); | ||
| 5833 | } | 6395 | } |
| 5834 | } | 6396 | } |
crates/ec-vorbis/tests/oracle.rsmodified+212 -51
| @@ -603,7 +603,11 @@ fn onset_after_silence_has_no_pre_echo() { | |||
| 603 | // last few hundred samples before it cannot hide behind a guard band, and | 603 | // last few hundred samples before it cannot hide behind a guard band, and |
| 604 | // the peak is barred too. | 604 | // the peak is barred too. |
| 605 | let amp = 0.7f64; | 605 | let amp = 0.7f64; |
| 606 | - for (rate, layouts) in [(44_100u32, &[1usize, 2][..]), (48_000, &[1, 2, 6]), (96_000, &[6])] { | 606 | + for (rate, layouts) in [ |
| 607 | + (44_100u32, &[1usize, 2][..]), | ||
| 608 | + (48_000, &[1, 2, 6]), | ||
| 609 | + (96_000, &[6]), | ||
| 610 | + ] { | ||
| 607 | let grid = 16 * 1024usize; | 611 | let grid = 16 * 1024usize; |
| 608 | let onsets = [0.3333f64, 0.5, 0.7321, 0.9137, 1.0] | 612 | let onsets = [0.3333f64, 0.5, 0.7321, 0.9137, 1.0] |
| 609 | .into_iter() | 613 | .into_iter() |
| @@ -618,7 +622,8 @@ fn onset_after_silence_has_no_pre_echo() { | |||
| 618 | let start = onset + 11 * c; | 622 | let start = onset + 11 * c; |
| 619 | for i in 0..tone_len { | 623 | for i in 0..tone_len { |
| 620 | let t = i as f64 / f64::from(rate); | 624 | let t = i as f64 / f64::from(rate); |
| 621 | - plane[start + i] = (amp * (2.0 * std::f64::consts::PI * hz * t).sin()) as f32; | 625 | + plane[start + i] = |
| 626 | + (amp * (2.0 * std::f64::consts::PI * hz * t).sin()) as f32; | ||
| 622 | } | 627 | } |
| 623 | } | 628 | } |
| 624 | let name = format!("onset-{rate}-{channels}ch-{onset}.ogg"); | 629 | let name = format!("onset-{rate}-{channels}ch-{onset}.ogg"); |
| @@ -650,7 +655,10 @@ fn onset_after_silence_has_no_pre_echo() { | |||
| 650 | gap_rms <= 0.002 * tone_rms, | 655 | gap_rms <= 0.002 * tone_rms, |
| 651 | "{name}/{label} ch{c}: gap RMS {gap_rms:.6} vs tone RMS {tone_rms:.6}" | 656 | "{name}/{label} ch{c}: gap RMS {gap_rms:.6} vs tone RMS {tone_rms:.6}" |
| 652 | ); | 657 | ); |
| 653 | - assert!(f64::from(peak) <= 0.01 * amp, "{name}/{label} ch{c}: gap peak {peak:.4}"); | 658 | + assert!( |
| 659 | + f64::from(peak) <= 0.01 * amp, | ||
| 660 | + "{name}/{label} ch{c}: gap peak {peak:.4}" | ||
| 661 | + ); | ||
| 654 | } | 662 | } |
| 655 | }; | 663 | }; |
| 656 | let (ours, _) = our_decode(&path); | 664 | let (ours, _) = our_decode(&path); |
| @@ -717,8 +725,8 @@ fn the_rate_loop_tracks_the_target_bitrate() { | |||
| 717 | fn quiet_content_reaches_the_target_or_is_transparent() { | 725 | fn quiet_content_reaches_the_target_or_is_transparent() { |
| 718 | let rate = 48_000u32; | 726 | let rate = 48_000u32; |
| 719 | let samples = rate as usize * 3; | 727 | let samples = rate as usize * 3; |
| 720 | - let fixture = ffmpeg_decode(&fixtures().join("audio/wav16-stereo-48000.wav")) | 728 | + let fixture = |
| 721 | - .expect("fixture decodes"); | 729 | + ffmpeg_decode(&fixtures().join("audio/wav16-stereo-48000.wav")).expect("fixture decodes"); |
| 722 | assert_eq!(fixture.1, rate); | 730 | assert_eq!(fixture.1, rate); |
| 723 | let attenuate = |mut source: Vec<Vec<f32>>| { | 731 | let attenuate = |mut source: Vec<Vec<f32>>| { |
| 724 | for channel in source.iter_mut() { | 732 | for channel in source.iter_mut() { |
| @@ -740,7 +748,10 @@ fn quiet_content_reaches_the_target_or_is_transparent() { | |||
| 740 | .fold(1.0f64, f64::min) | 748 | .fold(1.0f64, f64::min) |
| 741 | }; | 749 | }; |
| 742 | let loud = busy(2, rate, samples); | 750 | let loud = busy(2, rate, samples); |
| 743 | - let loud_corr = corr_at(&encode_to_file(&loud, rate, 128_000, "loud-128k.ogg"), &loud); | 751 | + let loud_corr = corr_at( |
| 752 | + &encode_to_file(&loud, rate, 128_000, "loud-128k.ogg"), | ||
| 753 | + &loud, | ||
| 754 | + ); | ||
| 744 | let quiet_noise = attenuate(loud); | 755 | let quiet_noise = attenuate(loud); |
| 745 | let mut quiet_tones = attenuate(tones(2, rate, samples)); | 756 | let mut quiet_tones = attenuate(tones(2, rate, samples)); |
| 746 | for (channel, noise) in quiet_tones.iter_mut().zip(busy(2, rate, samples)) { | 757 | for (channel, noise) in quiet_tones.iter_mut().zip(busy(2, rate, samples)) { |
| @@ -757,11 +768,19 @@ fn quiet_content_reaches_the_target_or_is_transparent() { | |||
| 757 | let mut measured = Vec::new(); | 768 | let mut measured = Vec::new(); |
| 758 | let mut spent = Vec::new(); | 769 | let mut spent = Vec::new(); |
| 759 | for target in [96_000i32, 128_000, 192_000] { | 770 | for target in [96_000i32, 128_000, 192_000] { |
| 760 | - let path = encode_to_file(source, rate, target, &format!("{name}-{}k.ogg", target / 1000)); | 771 | + let path = encode_to_file( |
| 772 | + source, | ||
| 773 | + rate, | ||
| 774 | + target, | ||
| 775 | + &format!("{name}-{}k.ogg", target / 1000), | ||
| 776 | + ); | ||
| 761 | let bytes = std::fs::metadata(&path).expect("file").len(); | 777 | let bytes = std::fs::metadata(&path).expect("file").len(); |
| 762 | let kbps = bytes as f64 * 8.0 * f64::from(rate) / source[0].len() as f64 / 1000.0; | 778 | let kbps = bytes as f64 * 8.0 * f64::from(rate) / source[0].len() as f64 / 1000.0; |
| 763 | let corr = corr_at(&path, source); | 779 | let corr = corr_at(&path, source); |
| 764 | - println!("{name}: target {} kbps -> {kbps:.0} kbps, corr {corr:.4}", target / 1000); | 780 | + println!( |
| 781 | + "{name}: target {} kbps -> {kbps:.0} kbps, corr {corr:.4}", | ||
| 782 | + target / 1000 | ||
| 783 | + ); | ||
| 765 | let target_kbps = f64::from(target) / 1000.0; | 784 | let target_kbps = f64::from(target) / 1000.0; |
| 766 | let within_25pct = (kbps - target_kbps).abs() / target_kbps < 0.25; | 785 | let within_25pct = (kbps - target_kbps).abs() / target_kbps < 0.25; |
| 767 | let transparent_undershoot = kbps < target_kbps && corr >= 0.999; | 786 | let transparent_undershoot = kbps < target_kbps && corr >= 0.999; |
| @@ -776,7 +795,10 @@ fn quiet_content_reaches_the_target_or_is_transparent() { | |||
| 776 | } | 795 | } |
| 777 | } | 796 | } |
| 778 | if spent.iter().all(|&s| s) { | 797 | if spent.iter().all(|&s| s) { |
| 779 | - assert!(measured[0] < measured[1] && measured[1] < measured[2], "{name}: {measured:?}"); | 798 | + assert!( |
| 799 | + measured[0] < measured[1] && measured[1] < measured[2], | ||
| 800 | + "{name}: {measured:?}" | ||
| 801 | + ); | ||
| 780 | } | 802 | } |
| 781 | } | 803 | } |
| 782 | } | 804 | } |
| @@ -800,7 +822,10 @@ fn residue_histogram_vs_reference() { | |||
| 800 | ("reell", "~/Music/reell.mp4"), | 822 | ("reell", "~/Music/reell.mp4"), |
| 801 | ("reelm", "~/Music/reelm.wav"), | 823 | ("reelm", "~/Music/reelm.wav"), |
| 802 | ("dl8a", "~/Downloads/8a3b6d1d19.mp3"), | 824 | ("dl8a", "~/Downloads/8a3b6d1d19.mp3"), |
| 803 | - ("hein", "~/Downloads/reelm.mp3"), | 825 | + ( |
| 826 | + "hein", | ||
| 827 | + "~/Downloads/reelm.mp3", | ||
| 828 | + ), | ||
| 804 | ]; | 829 | ]; |
| 805 | let bitrate = 128_000i32; | 830 | let bitrate = 128_000i32; |
| 806 | let rate = 48_000u32; | 831 | let rate = 48_000u32; |
| @@ -812,11 +837,17 @@ fn residue_histogram_vs_reference() { | |||
| 812 | std::fs::create_dir_all(&out_dir).expect("out dir"); | 837 | std::fs::create_dir_all(&out_dir).expect("out dir"); |
| 813 | let mut report = String::new(); | 838 | let mut report = String::new(); |
| 814 | report.push_str("# Residue histogram: ours vs libvorbis reference\n\n"); | 839 | report.push_str("# Residue histogram: ours vs libvorbis reference\n\n"); |
| 815 | - report.push_str(&format!("Bitrate: {} kbps, {} Hz, {}ch, {} s max\n\n", | 840 | + report.push_str(&format!( |
| 816 | - bitrate / 1000, rate, channels, max_samples / rate as usize)); | 841 | + "Bitrate: {} kbps, {} Hz, {}ch, {} s max\n\n", |
| 842 | + bitrate / 1000, | ||
| 843 | + rate, | ||
| 844 | + channels, | ||
| 845 | + max_samples / rate as usize | ||
| 846 | + )); | ||
| 817 | let mut total_ours_bytes = 0u64; | 847 | let mut total_ours_bytes = 0u64; |
| 818 | let mut total_ref_bytes = 0u64; | 848 | let mut total_ref_bytes = 0u64; |
| 819 | 849 | ||
| 850 | + let mut rows = 0usize; | ||
| 820 | for &(name, src_path) in sources { | 851 | for &(name, src_path) in sources { |
| 821 | let expanded = shellexpand(src_path); | 852 | let expanded = shellexpand(src_path); |
| 822 | let src = PathBuf::from(&expanded); | 853 | let src = PathBuf::from(&expanded); |
| @@ -824,6 +855,7 @@ fn residue_histogram_vs_reference() { | |||
| 824 | report.push_str(&format!("## {name}: SKIP (file not found: {expanded})\n\n")); | 855 | report.push_str(&format!("## {name}: SKIP (file not found: {expanded})\n\n")); |
| 825 | continue; | 856 | continue; |
| 826 | } | 857 | } |
| 858 | + rows += 1; | ||
| 827 | // Decode source with ffmpeg, limit duration. | 859 | // Decode source with ffmpeg, limit duration. |
| 828 | let Some((source_pcm, src_rate)) = ffmpeg_decode_limited(&src, rate, max_samples) else { | 860 | let Some((source_pcm, src_rate)) = ffmpeg_decode_limited(&src, rate, max_samples) else { |
| 829 | report.push_str(&format!("## {name}: SKIP (ffmpeg decode failed)\n\n")); | 861 | report.push_str(&format!("## {name}: SKIP (ffmpeg decode failed)\n\n")); |
| @@ -856,9 +888,19 @@ fn residue_histogram_vs_reference() { | |||
| 856 | // target; audio-only input encodes at the requested rate. | 888 | // target; audio-only input encodes at the requested rate. |
| 857 | .args(["-y", "-v", "error", "-i"]) | 889 | .args(["-y", "-v", "error", "-i"]) |
| 858 | .arg(&src) | 890 | .arg(&src) |
| 859 | - .args(["-vn", "-t", &format!("{}", max_samples / rate as usize), | 891 | + .args([ |
| 860 | - "-ac", "2", "-ar", "48000", | 892 | + "-vn", |
| 861 | - "-c:a", "libvorbis", "-b:a", "128k"]) | 893 | + "-t", |
| 894 | + &format!("{}", max_samples / rate as usize), | ||
| 895 | + "-ac", | ||
| 896 | + "2", | ||
| 897 | + "-ar", | ||
| 898 | + "48000", | ||
| 899 | + "-c:a", | ||
| 900 | + "libvorbis", | ||
| 901 | + "-b:a", | ||
| 902 | + "128k", | ||
| 903 | + ]) | ||
| 862 | .arg(&ref_ogg) | 904 | .arg(&ref_ogg) |
| 863 | .status(); | 905 | .status(); |
| 864 | let (ref_residue, ref_split) = match ref_status { | 906 | let (ref_residue, ref_split) = match ref_status { |
| @@ -919,11 +961,27 @@ fn residue_histogram_vs_reference() { | |||
| 919 | let r_spend: u64 = r[1..].iter().sum(); | 961 | let r_spend: u64 = r[1..].iter().sum(); |
| 920 | let ratio = if r_spend > 0 { | 962 | let ratio = if r_spend > 0 { |
| 921 | o_spend as f64 / r_spend as f64 | 963 | o_spend as f64 / r_spend as f64 |
| 922 | - } else { f64::INFINITY }; | 964 | + } else { |
| 965 | + f64::INFINITY | ||
| 966 | + }; | ||
| 923 | report.push_str(&format!( | 967 | report.push_str(&format!( |
| 924 | "| {} | {}/{} | {}/{} | {}/{} | {}/{} | {}/{} | {}/{} | {}/{} | {:.2} |\n", | 968 | "| {} | {}/{} | {}/{} | {}/{} | {}/{} | {}/{} | {}/{} | {}/{} | {:.2} |\n", |
| 925 | - band, o[0], r[0], o[1], r[1], o[2], r[2], o[3], r[3], o[4], r[4], o[5], r[5], | 969 | + band, |
| 926 | - o_total, r_total, ratio, | 970 | + o[0], |
| 971 | + r[0], | ||
| 972 | + o[1], | ||
| 973 | + r[1], | ||
| 974 | + o[2], | ||
| 975 | + r[2], | ||
| 976 | + o[3], | ||
| 977 | + r[3], | ||
| 978 | + o[4], | ||
| 979 | + r[4], | ||
| 980 | + o[5], | ||
| 981 | + r[5], | ||
| 982 | + o_total, | ||
| 983 | + r_total, | ||
| 984 | + ratio, | ||
| 927 | )); | 985 | )); |
| 928 | } | 986 | } |
| 929 | 987 | ||
| @@ -967,18 +1025,26 @@ fn residue_histogram_vs_reference() { | |||
| 967 | report.push_str(&format!( | 1025 | report.push_str(&format!( |
| 968 | "\nshape Bark 3-22: max dist {max_d:.3}, bands >= 0.15: {over}/{} — {}\n", | 1026 | "\nshape Bark 3-22: max dist {max_d:.3}, bands >= 0.15: {over}/{} — {}\n", |
| 969 | in_scope.len(), | 1027 | in_scope.len(), |
| 970 | - if over == 0 { "SHAPE PASS" } else { "shape fail" }, | 1028 | + if over == 0 { |
| 1029 | + "SHAPE PASS" | ||
| 1030 | + } else { | ||
| 1031 | + "shape fail" | ||
| 1032 | + }, | ||
| 971 | )); | 1033 | )); |
| 972 | } | 1034 | } |
| 973 | report.push_str("\n"); | 1035 | report.push_str("\n"); |
| 974 | } | 1036 | } |
| 975 | 1037 | ||
| 1038 | + // The seven sources are the user's own library, so each may be absent on a | ||
| 1039 | + // given host -- but a run that encoded none of them is a measurement of | ||
| 1040 | + // nothing, and the report it writes looks the same as a real one. | ||
| 1041 | + assert!(rows > 0, "no library sources were readable"); | ||
| 976 | report.push_str(&format!( | 1042 | report.push_str(&format!( |
| 977 | "\nTotal bytes: ours {total_ours_bytes} vs ref {total_ref_bytes} ({:.2}x)\n", | 1043 | "\nTotal bytes: ours {total_ours_bytes} vs ref {total_ref_bytes} ({:.2}x)\n", |
| 978 | total_ours_bytes as f64 / total_ref_bytes as f64, | 1044 | total_ours_bytes as f64 / total_ref_bytes as f64, |
| 979 | )); | 1045 | )); |
| 980 | - let report_path = PathBuf::from(env!("CARGO_MANIFEST_DIR")) | 1046 | + let report_path = |
| 981 | - .join("../../lanes/vorbis-psy-r1.histogram.txt"); | 1047 | + PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("../../lanes/vorbis-psy-r1.histogram.txt"); |
| 982 | let mut f = File::create(&report_path).expect("create report"); | 1048 | let mut f = File::create(&report_path).expect("create report"); |
| 983 | f.write_all(report.as_bytes()).expect("write report"); | 1049 | f.write_all(report.as_bytes()).expect("write report"); |
| 984 | println!("Histogram report: {}", report_path.display()); | 1050 | println!("Histogram report: {}", report_path.display()); |
| @@ -1028,7 +1094,10 @@ fn decode_capture(path: &Path) -> Vec<(usize, Vec<Vec<i32>>)> { | |||
| 1028 | 1094 | ||
| 1029 | /// Bit split summed over the stream: (floor bits, residue bits, packet bits, | 1095 | /// Bit split summed over the stream: (floor bits, residue bits, packet bits, |
| 1030 | /// non-zero residue count) — bits per coded value is the coding-efficiency oracle. | 1096 | /// non-zero residue count) — bits per coded value is the coding-efficiency oracle. |
| 1031 | -fn bit_split_summary(split: &[(u64, u64, u64)], residue: &[(usize, Vec<Vec<i32>>)]) -> (u64, u64, u64, u64) { | 1097 | +fn bit_split_summary( |
| 1098 | + split: &[(u64, u64, u64)], | ||
| 1099 | + residue: &[(usize, Vec<Vec<i32>>)], | ||
| 1100 | +) -> (u64, u64, u64, u64) { | ||
| 1032 | let (mut f, mut r, mut p) = (0u64, 0u64, 0u64); | 1101 | let (mut f, mut r, mut p) = (0u64, 0u64, 0u64); |
| 1033 | for &(a, b, c) in split { | 1102 | for &(a, b, c) in split { |
| 1034 | f += a; | 1103 | f += a; |
| @@ -1037,7 +1106,11 @@ fn bit_split_summary(split: &[(u64, u64, u64)], residue: &[(usize, Vec<Vec<i32>> | |||
| 1037 | } | 1106 | } |
| 1038 | let nz: u64 = residue | 1107 | let nz: u64 = residue |
| 1039 | .iter() | 1108 | .iter() |
| 1040 | - .map(|(_, chs)| chs.iter().map(|c| c.iter().filter(|&&v| v != 0).count() as u64).sum::<u64>()) | 1109 | + .map(|(_, chs)| { |
| 1110 | + chs.iter() | ||
| 1111 | + .map(|c| c.iter().filter(|&&v| v != 0).count() as u64) | ||
| 1112 | + .sum::<u64>() | ||
| 1113 | + }) | ||
| 1041 | .sum(); | 1114 | .sum(); |
| 1042 | (f, r, p, nz) | 1115 | (f, r, p, nz) |
| 1043 | } | 1116 | } |
| @@ -1100,25 +1173,45 @@ fn compare_captures( | |||
| 1100 | } | 1173 | } |
| 1101 | } | 1174 | } |
| 1102 | if diffs.is_empty() { | 1175 | if diffs.is_empty() { |
| 1103 | - (true, format!("identical histograms ({} vs {} blocks)", a.len(), b.len())) | 1176 | + ( |
| 1177 | + true, | ||
| 1178 | + format!("identical histograms ({} vs {} blocks)", a.len(), b.len()), | ||
| 1179 | + ) | ||
| 1104 | } else { | 1180 | } else { |
| 1105 | - (false, format!( | 1181 | + ( |
| 1106 | - "{} vs {} blocks; first diffs: {}", | 1182 | + false, |
| 1107 | - a.len(), | 1183 | + format!( |
| 1108 | - b.len(), | 1184 | + "{} vs {} blocks; first diffs: {}", |
| 1109 | - diffs.iter().take(5).cloned().collect::<Vec<_>>().join("; ") | 1185 | + a.len(), |
| 1110 | - )) | 1186 | + b.len(), |
| 1187 | + diffs.iter().take(5).cloned().collect::<Vec<_>>().join("; ") | ||
| 1188 | + ), | ||
| 1189 | + ) | ||
| 1111 | } | 1190 | } |
| 1112 | } | 1191 | } |
| 1113 | 1192 | ||
| 1114 | /// Decode with ffmpeg into planar f32, resampled to `rate`, limited to `max_samples`. | 1193 | /// Decode with ffmpeg into planar f32, resampled to `rate`, limited to `max_samples`. |
| 1115 | -fn ffmpeg_decode_limited(path: &Path, rate: u32, max_samples: usize) -> Option<(Vec<Vec<f32>>, u32)> { | 1194 | +fn ffmpeg_decode_limited( |
| 1195 | + path: &Path, | ||
| 1196 | + rate: u32, | ||
| 1197 | + max_samples: usize, | ||
| 1198 | +) -> Option<(Vec<Vec<f32>>, u32)> { | ||
| 1116 | let out = Command::new("ffmpeg") | 1199 | let out = Command::new("ffmpeg") |
| 1117 | .args(["-v", "error", "-i"]) | 1200 | .args(["-v", "error", "-i"]) |
| 1118 | .arg(path) | 1201 | .arg(path) |
| 1119 | - .args(["-t", &format!("{}", max_samples / rate as usize), | 1202 | + .args([ |
| 1120 | - "-ac", "2", "-ar", &rate.to_string(), | 1203 | + "-t", |
| 1121 | - "-f", "f32le", "-acodec", "pcm_f32le", "-"]) | 1204 | + &format!("{}", max_samples / rate as usize), |
| 1205 | + "-ac", | ||
| 1206 | + "2", | ||
| 1207 | + "-ar", | ||
| 1208 | + &rate.to_string(), | ||
| 1209 | + "-f", | ||
| 1210 | + "f32le", | ||
| 1211 | + "-acodec", | ||
| 1212 | + "pcm_f32le", | ||
| 1213 | + "-", | ||
| 1214 | + ]) | ||
| 1122 | .output() | 1215 | .output() |
| 1123 | .expect("ffmpeg runs"); | 1216 | .expect("ffmpeg runs"); |
| 1124 | if !out.stderr.is_empty() { | 1217 | if !out.stderr.is_empty() { |
| @@ -1179,7 +1272,6 @@ fn shellexpand(path: &str) -> String { | |||
| 1179 | } | 1272 | } |
| 1180 | } | 1273 | } |
| 1181 | 1274 | ||
| 1182 | - | ||
| 1183 | /// Full-file sweep over the user's library at the two managed rates: ours | 1275 | /// Full-file sweep over the user's library at the two managed rates: ours |
| 1184 | /// encoded at the size libvorbis actually produced (ffmpeg's -b:a is | 1276 | /// encoded at the size libvorbis actually produced (ffmpeg's -b:a is |
| 1185 | /// unmanaged VBR, 10-30% under nominal on real music), bytes within ±3% of | 1277 | /// unmanaged VBR, 10-30% under nominal on real music), bytes within ±3% of |
| @@ -1196,19 +1288,28 @@ fn real_library_sweep_vs_reference() { | |||
| 1196 | ("reell", "~/Music/reell.mp4"), | 1288 | ("reell", "~/Music/reell.mp4"), |
| 1197 | ("reelm", "~/Music/reelm.wav"), | 1289 | ("reelm", "~/Music/reelm.wav"), |
| 1198 | ("dl8a", "~/Downloads/8a3b6d1d19.mp3"), | 1290 | ("dl8a", "~/Downloads/8a3b6d1d19.mp3"), |
| 1199 | - ("hein", "~/Downloads/reelm.mp3"), | 1291 | + ( |
| 1292 | + "hein", | ||
| 1293 | + "~/Downloads/reelm.mp3", | ||
| 1294 | + ), | ||
| 1200 | ]; | 1295 | ]; |
| 1201 | let rate = 48_000u32; | 1296 | let rate = 48_000u32; |
| 1202 | let max_samples = rate as usize * 600; | 1297 | let max_samples = rate as usize * 600; |
| 1203 | let out_dir = scratch().join("vorbis7-sweep"); | 1298 | let out_dir = scratch().join("vorbis7-sweep"); |
| 1204 | std::fs::create_dir_all(&out_dir).expect("out dir"); | 1299 | std::fs::create_dir_all(&out_dir).expect("out dir"); |
| 1205 | - let mut table = String::from("source kbps ours_kbps ref_kbps rate% corr_ours corr_ref gap minsec_o minsec_r drops verdict\n"); | 1300 | + let mut table = String::from( |
| 1301 | + "source kbps ours_kbps ref_kbps rate% corr_ours corr_ref gap minsec_o minsec_r drops verdict\n", | ||
| 1302 | + ); | ||
| 1206 | let mut failures = Vec::new(); | 1303 | let mut failures = Vec::new(); |
| 1207 | let only = std::env::var("SWEEP_ONLY").ok(); | 1304 | let only = std::env::var("SWEEP_ONLY").ok(); |
| 1208 | let dump_drops = std::env::var("DROPS_DUMP").is_ok(); | 1305 | let dump_drops = std::env::var("DROPS_DUMP").is_ok(); |
| 1209 | let mut drops = String::new(); | 1306 | let mut drops = String::new(); |
| 1307 | + let mut rows = 0usize; | ||
| 1210 | for &(name, src_path) in sources { | 1308 | for &(name, src_path) in sources { |
| 1211 | - if only.as_deref().is_some_and(|o| !o.split(',').any(|n| n == name)) { | 1309 | + if only |
| 1310 | + .as_deref() | ||
| 1311 | + .is_some_and(|o| !o.split(',').any(|n| n == name)) | ||
| 1312 | + { | ||
| 1212 | continue; | 1313 | continue; |
| 1213 | } | 1314 | } |
| 1214 | let src = PathBuf::from(shellexpand(src_path)); | 1315 | let src = PathBuf::from(shellexpand(src_path)); |
| @@ -1216,6 +1317,7 @@ fn real_library_sweep_vs_reference() { | |||
| 1216 | table.push_str(&format!("{name:<7} - SKIP (missing)\n")); | 1317 | table.push_str(&format!("{name:<7} - SKIP (missing)\n")); |
| 1217 | continue; | 1318 | continue; |
| 1218 | } | 1319 | } |
| 1320 | + rows += 1; | ||
| 1219 | let Some((source_pcm, _)) = ffmpeg_decode_limited(&src, rate, max_samples) else { | 1321 | let Some((source_pcm, _)) = ffmpeg_decode_limited(&src, rate, max_samples) else { |
| 1220 | table.push_str(&format!("{name:<7} - SKIP (decode)\n")); | 1322 | table.push_str(&format!("{name:<7} - SKIP (decode)\n")); |
| 1221 | continue; | 1323 | continue; |
| @@ -1229,14 +1331,31 @@ fn real_library_sweep_vs_reference() { | |||
| 1229 | let status = Command::new("ffmpeg") | 1331 | let status = Command::new("ffmpeg") |
| 1230 | .args(["-y", "-v", "error", "-i"]) | 1332 | .args(["-y", "-v", "error", "-i"]) |
| 1231 | .arg(&src) | 1333 | .arg(&src) |
| 1232 | - .args(["-vn", "-t", "600", "-ac", "2", "-ar", "48000", "-c:a", "libvorbis", "-b:a", &format!("{kbps}k")]) | 1334 | + .args([ |
| 1335 | + "-vn", | ||
| 1336 | + "-t", | ||
| 1337 | + "600", | ||
| 1338 | + "-ac", | ||
| 1339 | + "2", | ||
| 1340 | + "-ar", | ||
| 1341 | + "48000", | ||
| 1342 | + "-c:a", | ||
| 1343 | + "libvorbis", | ||
| 1344 | + "-b:a", | ||
| 1345 | + &format!("{kbps}k"), | ||
| 1346 | + ]) | ||
| 1233 | .arg(&reference) | 1347 | .arg(&reference) |
| 1234 | .status() | 1348 | .status() |
| 1235 | .expect("ffmpeg runs"); | 1349 | .expect("ffmpeg runs"); |
| 1236 | assert!(status.success(), "libvorbis encode of {name} at {kbps}k"); | 1350 | assert!(status.success(), "libvorbis encode of {name} at {kbps}k"); |
| 1237 | let bytes = |p: &Path| std::fs::metadata(p).expect("size").len() as f64; | 1351 | let bytes = |p: &Path| std::fs::metadata(p).expect("size").len() as f64; |
| 1238 | let ref_kbps = bytes(&reference) * 8.0 / seconds / 1000.0; | 1352 | let ref_kbps = bytes(&reference) * 8.0 / seconds / 1000.0; |
| 1239 | - let (ours, block_log) = encode_to_file_with_log(&source_pcm, rate, (ref_kbps * 1000.0).round() as i32, &format!("vorbis7-sweep/ours-{name}-{kbps}k.ogg")); | 1353 | + let (ours, block_log) = encode_to_file_with_log( |
| 1354 | + &source_pcm, | ||
| 1355 | + rate, | ||
| 1356 | + (ref_kbps * 1000.0).round() as i32, | ||
| 1357 | + &format!("vorbis7-sweep/ours-{name}-{kbps}k.ogg"), | ||
| 1358 | + ); | ||
| 1240 | let ours_kbps = bytes(&ours) * 8.0 / seconds / 1000.0; | 1359 | let ours_kbps = bytes(&ours) * 8.0 / seconds / 1000.0; |
| 1241 | let rate_pct = (ours_kbps / ref_kbps - 1.0) * 100.0; | 1360 | let rate_pct = (ours_kbps / ref_kbps - 1.0) * 100.0; |
| 1242 | // Whole-file corr plus a per-second trace: a dropout (the | 1361 | // Whole-file corr plus a per-second trace: a dropout (the |
| @@ -1246,12 +1365,18 @@ fn real_library_sweep_vs_reference() { | |||
| 1246 | let corr_of = |p: &Path| -> (f64, Vec<f64>) { | 1365 | let corr_of = |p: &Path| -> (f64, Vec<f64>) { |
| 1247 | let (pcm, _) = our_decode(p); | 1366 | let (pcm, _) = our_decode(p); |
| 1248 | let n = pcm[0].len().min(source_pcm[0].len()); | 1367 | let n = pcm[0].len().min(source_pcm[0].len()); |
| 1249 | - let mean = (0..2).map(|c| correlation(&pcm[c][..n], &source_pcm[c][..n])).sum::<f64>() / 2.0; | 1368 | + let mean = (0..2) |
| 1369 | + .map(|c| correlation(&pcm[c][..n], &source_pcm[c][..n])) | ||
| 1370 | + .sum::<f64>() | ||
| 1371 | + / 2.0; | ||
| 1250 | let step = rate as usize; | 1372 | let step = rate as usize; |
| 1251 | let per_second = (0..n / step) | 1373 | let per_second = (0..n / step) |
| 1252 | .map(|s| { | 1374 | .map(|s| { |
| 1253 | let r = s * step..(s + 1) * step; | 1375 | let r = s * step..(s + 1) * step; |
| 1254 | - (0..2).map(|c| correlation(&pcm[c][r.clone()], &source_pcm[c][r.clone()])).sum::<f64>() / 2.0 | 1376 | + (0..2) |
| 1377 | + .map(|c| correlation(&pcm[c][r.clone()], &source_pcm[c][r.clone()])) | ||
| 1378 | + .sum::<f64>() | ||
| 1379 | + / 2.0 | ||
| 1255 | }) | 1380 | }) |
| 1256 | .collect(); | 1381 | .collect(); |
| 1257 | (mean, per_second) | 1382 | (mean, per_second) |
| @@ -1275,7 +1400,9 @@ fn real_library_sweep_vs_reference() { | |||
| 1275 | .collect(); | 1400 | .collect(); |
| 1276 | let pass = rate_pct.abs() <= 3.0 && gap <= 0.005 && dropouts == 0; | 1401 | let pass = rate_pct.abs() <= 3.0 && gap <= 0.005 && dropouts == 0; |
| 1277 | if !pass { | 1402 | if !pass { |
| 1278 | - failures.push(format!("{name}@{kbps}k rate {rate_pct:+.2}% gap {gap:.4} dropouts {dropouts}")); | 1403 | + failures.push(format!( |
| 1404 | + "{name}@{kbps}k rate {rate_pct:+.2}% gap {gap:.4} dropouts {dropouts}" | ||
| 1405 | + )); | ||
| 1279 | } | 1406 | } |
| 1280 | table.push_str(&format!( | 1407 | table.push_str(&format!( |
| 1281 | "{name:<7} {kbps:<6} {ours_kbps:<9.1} {ref_kbps:<8.1} {rate_pct:+6.2} {corr_ours:<9.4} {corr_ref:<8.4} {gap:<7.4} {min_ours:<8.3} {min_ref:<7.3} {dropouts:<5} {}\n", | 1408 | "{name:<7} {kbps:<6} {ours_kbps:<9.1} {ref_kbps:<8.1} {rate_pct:+6.2} {corr_ours:<9.4} {corr_ref:<8.4} {gap:<7.4} {min_ours:<8.3} {min_ref:<7.3} {dropouts:<5} {}\n", |
| @@ -1326,6 +1453,7 @@ fn real_library_sweep_vs_reference() { | |||
| 1326 | Path::new(env!("CARGO_MANIFEST_DIR")).join("../../lanes/vorbis-psy-r1.sweep.txt"), | 1453 | Path::new(env!("CARGO_MANIFEST_DIR")).join("../../lanes/vorbis-psy-r1.sweep.txt"), |
| 1327 | &table, | 1454 | &table, |
| 1328 | ); | 1455 | ); |
| 1456 | + assert!(rows > 0, "no library sources were readable"); | ||
| 1329 | assert!(failures.is_empty(), "sweep failures: {failures:?}"); | 1457 | assert!(failures.is_empty(), "sweep failures: {failures:?}"); |
| 1330 | } | 1458 | } |
| 1331 | 1459 | ||
| @@ -1385,7 +1513,10 @@ fn band_error_vs_reference() { | |||
| 1385 | ("reell", "~/Music/reell.mp4"), | 1513 | ("reell", "~/Music/reell.mp4"), |
| 1386 | ("reelm", "~/Music/reelm.wav"), | 1514 | ("reelm", "~/Music/reelm.wav"), |
| 1387 | ("dl8a", "~/Downloads/8a3b6d1d19.mp3"), | 1515 | ("dl8a", "~/Downloads/8a3b6d1d19.mp3"), |
| 1388 | - ("hein", "~/Downloads/reelm.mp3"), | 1516 | + ( |
| 1517 | + "hein", | ||
| 1518 | + "~/Downloads/reelm.mp3", | ||
| 1519 | + ), | ||
| 1389 | ]; | 1520 | ]; |
| 1390 | let rate = 48_000u32; | 1521 | let rate = 48_000u32; |
| 1391 | let max_samples = rate as usize * 600; | 1522 | let max_samples = rate as usize * 600; |
| @@ -1412,8 +1543,12 @@ fn band_error_vs_reference() { | |||
| 1412 | let mut bands = String::from("# Band error: ours vs libvorbis, both via our decoder\n\n"); | 1543 | let mut bands = String::from("# Band error: ours vs libvorbis, both via our decoder\n\n"); |
| 1413 | let mut bits = String::from("# Bit split over full sources, same rows as the band error\n\n"); | 1544 | let mut bits = String::from("# Bit split over full sources, same rows as the band error\n\n"); |
| 1414 | let only = std::env::var("SWEEP_ONLY").ok(); | 1545 | let only = std::env::var("SWEEP_ONLY").ok(); |
| 1546 | + let mut rows = 0usize; | ||
| 1415 | for &(name, src_path) in sources { | 1547 | for &(name, src_path) in sources { |
| 1416 | - if only.as_deref().is_some_and(|o| !o.split(',').any(|n| n == name)) { | 1548 | + if only |
| 1549 | + .as_deref() | ||
| 1550 | + .is_some_and(|o| !o.split(',').any(|n| n == name)) | ||
| 1551 | + { | ||
| 1417 | continue; | 1552 | continue; |
| 1418 | } | 1553 | } |
| 1419 | let src = PathBuf::from(shellexpand(src_path)); | 1554 | let src = PathBuf::from(shellexpand(src_path)); |
| @@ -1421,6 +1556,7 @@ fn band_error_vs_reference() { | |||
| 1421 | bands.push_str(&format!("## {name}: SKIP (missing)\n\n")); | 1556 | bands.push_str(&format!("## {name}: SKIP (missing)\n\n")); |
| 1422 | continue; | 1557 | continue; |
| 1423 | } | 1558 | } |
| 1559 | + rows += 1; | ||
| 1424 | let Some((source_pcm, _)) = ffmpeg_decode_limited(&src, rate, max_samples) else { | 1560 | let Some((source_pcm, _)) = ffmpeg_decode_limited(&src, rate, max_samples) else { |
| 1425 | bands.push_str(&format!("## {name}: SKIP (decode)\n\n")); | 1561 | bands.push_str(&format!("## {name}: SKIP (decode)\n\n")); |
| 1426 | continue; | 1562 | continue; |
| @@ -1433,7 +1569,19 @@ fn band_error_vs_reference() { | |||
| 1433 | let status = Command::new("ffmpeg") | 1569 | let status = Command::new("ffmpeg") |
| 1434 | .args(["-y", "-v", "error", "-i"]) | 1570 | .args(["-y", "-v", "error", "-i"]) |
| 1435 | .arg(&src) | 1571 | .arg(&src) |
| 1436 | - .args(["-vn", "-t", "600", "-ac", "2", "-ar", "48000", "-c:a", "libvorbis", "-b:a", &format!("{kbps}k")]) | 1572 | + .args([ |
| 1573 | + "-vn", | ||
| 1574 | + "-t", | ||
| 1575 | + "600", | ||
| 1576 | + "-ac", | ||
| 1577 | + "2", | ||
| 1578 | + "-ar", | ||
| 1579 | + "48000", | ||
| 1580 | + "-c:a", | ||
| 1581 | + "libvorbis", | ||
| 1582 | + "-b:a", | ||
| 1583 | + &format!("{kbps}k"), | ||
| 1584 | + ]) | ||
| 1437 | .arg(&reference) | 1585 | .arg(&reference) |
| 1438 | .status() | 1586 | .status() |
| 1439 | .expect("ffmpeg runs"); | 1587 | .expect("ffmpeg runs"); |
| @@ -1457,7 +1605,10 @@ fn band_error_vs_reference() { | |||
| 1457 | }; | 1605 | }; |
| 1458 | let (ref_pcm, ref_split) = { | 1606 | let (ref_pcm, ref_split) = { |
| 1459 | let (residue, split) = decode_capture_with_bits(&reference); | 1607 | let (residue, split) = decode_capture_with_bits(&reference); |
| 1460 | - (our_decode(&reference).0, bit_split_summary(&split, &residue)) | 1608 | + ( |
| 1609 | + our_decode(&reference).0, | ||
| 1610 | + bit_split_summary(&split, &residue), | ||
| 1611 | + ) | ||
| 1461 | }; | 1612 | }; |
| 1462 | 1613 | ||
| 1463 | // Bit-split block: (floor, residue, packet, non-zero) per stream. | 1614 | // Bit-split block: (floor, residue, packet, non-zero) per stream. |
| @@ -1494,8 +1645,9 @@ fn band_error_vs_reference() { | |||
| 1494 | let (mut e_src, mut e_ours, mut e_ref) = | 1645 | let (mut e_src, mut e_ours, mut e_ref) = |
| 1495 | (vec![0f64; nb], vec![0f64; nb], vec![0f64; nb]); | 1646 | (vec![0f64; nb], vec![0f64; nb], vec![0f64; nb]); |
| 1496 | let (mut err_ours, mut err_ref) = (vec![0f64; nb], vec![0f64; nb]); | 1647 | let (mut err_ours, mut err_ref) = (vec![0f64; nb], vec![0f64; nb]); |
| 1497 | - let mut spec: Vec<(Vec<f64>, Vec<f64>)> = | 1648 | + let mut spec: Vec<(Vec<f64>, Vec<f64>)> = (0..3) |
| 1498 | - (0..3).map(|_| (vec![0.0; FRAME], vec![0.0; FRAME])).collect(); | 1649 | + .map(|_| (vec![0.0; FRAME], vec![0.0; FRAME])) |
| 1650 | + .collect(); | ||
| 1499 | let mut start = 0; | 1651 | let mut start = 0; |
| 1500 | while start + FRAME <= n { | 1652 | while start + FRAME <= n { |
| 1501 | for ch in 0..2 { | 1653 | for ch in 0..2 { |
| @@ -1523,7 +1675,13 @@ fn band_error_vs_reference() { | |||
| 1523 | } | 1675 | } |
| 1524 | start += HOP; | 1676 | start += HOP; |
| 1525 | } | 1677 | } |
| 1526 | - let db = |e: f64, s: f64| if s > 0.0 { 10.0 * (e / s).log10() } else { f64::NAN }; | 1678 | + let db = |e: f64, s: f64| { |
| 1679 | + if s > 0.0 { | ||
| 1680 | + 10.0 * (e / s).log10() | ||
| 1681 | + } else { | ||
| 1682 | + f64::NAN | ||
| 1683 | + } | ||
| 1684 | + }; | ||
| 1527 | bands.push_str(&format!( | 1685 | bands.push_str(&format!( |
| 1528 | "## {name} @ {kbps}k (ours {ours_kbps:.1} vs ref {ref_kbps:.1} kbps)\n" | 1686 | "## {name} @ {kbps}k (ours {ours_kbps:.1} vs ref {ref_kbps:.1} kbps)\n" |
| 1529 | )); | 1687 | )); |
| @@ -1560,13 +1718,16 @@ fn band_error_vs_reference() { | |||
| 1560 | ); | 1718 | ); |
| 1561 | } | 1719 | } |
| 1562 | } | 1720 | } |
| 1721 | + // Both report files above are written unconditionally, so a run that | ||
| 1722 | + // measured no source writes a report indistinguishable from a real one. | ||
| 1723 | + assert!(rows > 0, "no library sources were readable"); | ||
| 1563 | for (text, file) in [ | 1724 | for (text, file) in [ |
| 1564 | (&bands, "vorbis-psy-r1.bands.txt"), | 1725 | (&bands, "vorbis-psy-r1.bands.txt"), |
| 1565 | (&bits, "vorbis-psy-r1.bits.txt"), | 1726 | (&bits, "vorbis-psy-r1.bits.txt"), |
| 1566 | ] { | 1727 | ] { |
| 1567 | let path = PathBuf::from(env!("CARGO_MANIFEST_DIR")) | 1728 | let path = PathBuf::from(env!("CARGO_MANIFEST_DIR")) |
| 1568 | .join("../../lanes") | 1729 | .join("../../lanes") |
| 1569 | - .join(file); | 1730 | + .join(file); |
| 1570 | let mut f = File::create(&path).expect("create report"); | 1731 | let mut f = File::create(&path).expect("create report"); |
| 1571 | f.write_all(text.as_bytes()).expect("write report"); | 1732 | f.write_all(text.as_bytes()).expect("write report"); |
| 1572 | println!("{file}: {}", path.display()); | 1733 | println!("{file}: {}", path.display()); |
crates/ec-vp9/tests/hbd_exact.rsmodified+35 -9
| @@ -3,21 +3,47 @@ | |||
| 3 | //! yuv420p10le -`). Pre-fix the decoder refuses `profile 2` by name, so this | 3 | //! yuv420p10le -`). Pre-fix the decoder refuses `profile 2` by name, so this |
| 4 | //! test fails at the first frame; post-fix every shown frame matches. | 4 | //! test fails at the first frame; post-fix every shown frame matches. |
| 5 | //! | 5 | //! |
| 6 | -//! Media-gated: the 10-bit corpus streams are gitignored, so the test skips | 6 | +//! Media-gated: the 10-bit corpus streams are gitignored, so the test prints |
| 7 | -//! by name when the fixture is absent (set the fixture tree up per the lane | 7 | +//! SKIP when the fixture is absent (set the fixture tree up per the lane |
| 8 | -//! notes). The 4:4:4 and 12-bit shapes are covered by `subsampling_exact.rs`. | 8 | +//! notes) -- and goes RED instead under `EC_REQUIRE_FIXTURES=1`, so a drifted |
| 9 | +//! fixture library can never read as a pass. The 4:4:4 and 12-bit shapes are | ||
| 10 | +//! covered by `subsampling_exact.rs`. | ||
| 9 | 11 | ||
| 10 | mod ivf; | 12 | mod ivf; |
| 11 | 13 | ||
| 12 | use ec_vp9::decode::Decoder; | 14 | use ec_vp9::decode::Decoder; |
| 13 | use std::path::{Path, PathBuf}; | 15 | use std::path::{Path, PathBuf}; |
| 14 | 16 | ||
| 15 | -fn fixture(name: &str) -> Option<PathBuf> { | 17 | +/// Fixture-presence probe for the 10-bit corpus IVF `profile2_10bit_is_byte_exact` |
| 18 | +/// decodes and compares against ffmpeg. | ||
| 19 | +/// Returns whether the fixture is present, but never silently: under | ||
| 20 | +/// `EC_REQUIRE_FIXTURES=1` an absent fixture is a hard failure naming the path | ||
| 21 | +/// and the script that regenerates it, so a host whose fixture library drifted | ||
| 22 | +/// reports RED instead of a green SKIP (class: gate-skips-on-its-own-failure; | ||
| 23 | +/// model `have_ffmpeg` in crates/ec-av1/src/stream.rs, which was silently | ||
| 24 | +/// short-circuited because the probe ran first in a compound `if`). | ||
| 25 | +/// | ||
| 26 | +/// Order is load-bearing: probe, assert, return. Never merge the probe into | ||
| 27 | +/// the same `if` as the escape. | ||
| 28 | +fn require_fixture(path: &std::path::Path, generator: &str) -> bool { | ||
| 29 | + let present = path.exists(); | ||
| 30 | + assert!( | ||
| 31 | + present || std::env::var_os("EC_REQUIRE_FIXTURES").is_none(), | ||
| 32 | + "EC_REQUIRE_FIXTURES=1 but fixture {} is absent -- regenerate with: {}", | ||
| 33 | + path.display(), | ||
| 34 | + generator | ||
| 35 | + ); | ||
| 36 | + if !present { | ||
| 37 | + eprintln!("SKIP: fixture {} absent", path.display()); | ||
| 38 | + } | ||
| 39 | + present | ||
| 40 | +} | ||
| 41 | + | ||
| 42 | +fn fixture(name: &str) -> PathBuf { | ||
| 16 | let mut p = PathBuf::from(env!("CARGO_MANIFEST_DIR")); | 43 | let mut p = PathBuf::from(env!("CARGO_MANIFEST_DIR")); |
| 17 | p.pop(); | 44 | p.pop(); |
| 18 | p.pop(); | 45 | p.pop(); |
| 19 | - p = p.join("fixtures/bitstreams").join(name); | 46 | + p.join("fixtures/bitstreams").join(name) |
| 20 | - p.exists().then_some(p) | ||
| 21 | } | 47 | } |
| 22 | 48 | ||
| 23 | /// ffmpeg's rawvideo `yuv420p10le` bytes (little-endian u16 samples, | 49 | /// ffmpeg's rawvideo `yuv420p10le` bytes (little-endian u16 samples, |
| @@ -56,10 +82,10 @@ fn decode_all(path: &Path) -> (Vec<Vec<u8>>, u8) { | |||
| 56 | /// produces, sample for sample. | 82 | /// produces, sample for sample. |
| 57 | #[test] | 83 | #[test] |
| 58 | fn profile2_10bit_is_byte_exact() { | 84 | fn profile2_10bit_is_byte_exact() { |
| 59 | - let Some(a) = fixture("vp9-1080p-23.976-10bit.ivf") else { | 85 | + let a = fixture("vp9-1080p-23.976-10bit.ivf"); |
| 60 | - eprintln!("SKIP profile2_10bit_is_byte_exact: 10-bit fixture absent"); | 86 | + if !require_fixture(&a, "scripts/gen-bitstream-fixtures.sh") { |
| 61 | return; | 87 | return; |
| 62 | - }; | 88 | + } |
| 63 | let (ours, bd) = decode_all(&a); | 89 | let (ours, bd) = decode_all(&a); |
| 64 | assert_eq!(bd, 10, "the fixture must decode at 10 bits"); | 90 | assert_eq!(bd, 10, "the fixture must decode at 10 bits"); |
| 65 | let want = ffmpeg_raw_yuv10(&a); | 91 | let want = ffmpeg_raw_yuv10(&a); |
crates/ec-vp9/tests/inter_pixels_exact.rsmodified+30 -9
| @@ -9,6 +9,30 @@ | |||
| 9 | mod ivf; | 9 | mod ivf; |
| 10 | 10 | ||
| 11 | use ec_vp9::decode::Decoder; | 11 | use ec_vp9::decode::Decoder; |
| 12 | +/// Fixture-presence probe for the 120-frame 1080p corpus IVF | ||
| 13 | +/// `corpus_1080p_60fps_matches_ffmpeg_past_frame_72` decodes. | ||
| 14 | +/// Returns whether the fixture is present, but never silently: under | ||
| 15 | +/// `EC_REQUIRE_FIXTURES=1` an absent fixture is a hard failure naming the path | ||
| 16 | +/// and the script that regenerates it, so a host whose fixture library drifted | ||
| 17 | +/// reports RED instead of a green SKIP (class: gate-skips-on-its-own-failure; | ||
| 18 | +/// model `have_ffmpeg` in crates/ec-av1/src/stream.rs, which was silently | ||
| 19 | +/// short-circuited because the probe ran first in a compound `if`). | ||
| 20 | +/// | ||
| 21 | +/// Order is load-bearing: probe, assert, return. Never merge the probe into | ||
| 22 | +/// the same `if` as the escape. | ||
| 23 | +fn require_fixture(path: &std::path::Path, generator: &str) -> bool { | ||
| 24 | + let present = path.exists(); | ||
| 25 | + assert!( | ||
| 26 | + present || std::env::var_os("EC_REQUIRE_FIXTURES").is_none(), | ||
| 27 | + "EC_REQUIRE_FIXTURES=1 but fixture {} is absent -- regenerate with: {}", | ||
| 28 | + path.display(), | ||
| 29 | + generator | ||
| 30 | + ); | ||
| 31 | + if !present { | ||
| 32 | + eprintln!("SKIP: fixture {} absent", path.display()); | ||
| 33 | + } | ||
| 34 | + present | ||
| 35 | +} | ||
| 12 | 36 | ||
| 13 | /// Generate a GOP fixture with libvpx: 6 frames of testsrc2 at 320x240, | 37 | /// Generate a GOP fixture with libvpx: 6 frames of testsrc2 at 320x240, |
| 14 | /// `-g 10` so frames 1..5 are inter frames. | 38 | /// `-g 10` so frames 1..5 are inter frames. |
| @@ -137,17 +161,14 @@ fn inter_gop_with_tile_columns_matches_ffmpeg() { | |||
| 137 | /// TAIL slot set (`write_tx_context`), and the next row of blocks read it | 161 | /// TAIL slot set (`write_tx_context`), and the next row of blocks read it |
| 138 | /// as an entropy context. Every shown frame must match ffmpeg. | 162 | /// as an entropy context. Every shown frame must match ffmpeg. |
| 139 | /// | 163 | /// |
| 140 | -/// Media-gated: the corpus fixture is not versioned, so the witness skips | 164 | +/// Media-gated: the corpus fixture is not versioned, so the witness prints |
| 141 | -/// when `fixtures/bitstreams/vp9-1080p-60-8bit.ivf` is absent. | 165 | +/// SKIP when `fixtures/bitstreams/vp9-1080p-60-8bit.ivf` is absent -- and goes |
| 166 | +/// RED instead under `EC_REQUIRE_FIXTURES=1`. | ||
| 142 | #[test] | 167 | #[test] |
| 143 | fn corpus_1080p_60fps_matches_ffmpeg_past_frame_72() { | 168 | fn corpus_1080p_60fps_matches_ffmpeg_past_frame_72() { |
| 144 | - let Some(dir) = ivf::fixture_dir() else { | 169 | + let path = std::path::Path::new(env!("CARGO_MANIFEST_DIR")) |
| 145 | - println!("SKIP: fixtures/bitstreams absent (media-gated witness)"); | 170 | + .join("../../fixtures/bitstreams/vp9-1080p-60-8bit.ivf"); |
| 146 | - return; | 171 | + if !require_fixture(&path, "scripts/gen-bitstream-fixtures.sh") { |
| 147 | - }; | ||
| 148 | - let path = dir.join("vp9-1080p-60-8bit.ivf"); | ||
| 149 | - if !path.exists() { | ||
| 150 | - println!("SKIP: {} absent (media-gated witness)", path.display()); | ||
| 151 | return; | 172 | return; |
| 152 | } | 173 | } |
| 153 | let shown = compare(&path); | 174 | let shown = compare(&path); |
crates/ec-vp9/tests/scratch_interdump.rsmodified+36 -4
| @@ -27,6 +27,30 @@ | |||
| 27 | mod ivf; | 27 | mod ivf; |
| 28 | 28 | ||
| 29 | use ec_vp9::decode::Decoder; | 29 | use ec_vp9::decode::Decoder; |
| 30 | +/// Fixture-presence probe for the inter-frame IVF this gate parses (the | ||
| 31 | +/// `INTER_IVF` path, or its generated `/tmp/inter1.ivf` default). | ||
| 32 | +/// Returns whether the fixture is present, but never silently: under | ||
| 33 | +/// `EC_REQUIRE_FIXTURES=1` an absent fixture is a hard failure naming the path | ||
| 34 | +/// and how to regenerate it, so a host whose fixture library drifted reports | ||
| 35 | +/// RED instead of a green SKIP (class: gate-skips-on-its-own-failure; model | ||
| 36 | +/// `have_ffmpeg` in crates/ec-av1/src/stream.rs, which was silently | ||
| 37 | +/// short-circuited because the probe ran first in a compound `if`). | ||
| 38 | +/// | ||
| 39 | +/// Order is load-bearing: probe, assert, return. Never merge the probe into | ||
| 40 | +/// the same `if` as the escape. | ||
| 41 | +fn require_fixture(path: &std::path::Path, generator: &str) -> bool { | ||
| 42 | + let present = path.exists(); | ||
| 43 | + assert!( | ||
| 44 | + present || std::env::var_os("EC_REQUIRE_FIXTURES").is_none(), | ||
| 45 | + "EC_REQUIRE_FIXTURES=1 but fixture {} is absent -- regenerate with: {}", | ||
| 46 | + path.display(), | ||
| 47 | + generator | ||
| 48 | + ); | ||
| 49 | + if !present { | ||
| 50 | + eprintln!("SKIP: fixture {} absent", path.display()); | ||
| 51 | + } | ||
| 52 | + present | ||
| 53 | +} | ||
| 30 | 54 | ||
| 31 | #[test] | 55 | #[test] |
| 32 | fn inter_syntax_dump() { | 56 | fn inter_syntax_dump() { |
| @@ -43,17 +67,25 @@ fn inter_syntax_dump() { | |||
| 43 | } else { | 67 | } else { |
| 44 | expect_raw | 68 | expect_raw |
| 45 | .split(',') | 69 | .split(',') |
| 46 | - .map(|t| t.trim().parse().expect("INTER_EXPECT entries are block counts")) | 70 | + .map(|t| { |
| 71 | + t.trim() | ||
| 72 | + .parse() | ||
| 73 | + .expect("INTER_EXPECT entries are block counts") | ||
| 74 | + }) | ||
| 47 | .collect() | 75 | .collect() |
| 48 | }; | 76 | }; |
| 49 | - let Ok(bytes) = std::fs::read(&path) else { | 77 | + if !require_fixture( |
| 78 | + std::path::Path::new(&path), | ||
| 79 | + "INTER_IVF=<file>; the default is generated, not committed \ | ||
| 80 | + (ffmpeg -f lavfi -i testsrc2=... -c:v libvpx-vp9 -f ivf)", | ||
| 81 | + ) { | ||
| 50 | assert!( | 82 | assert!( |
| 51 | explicit.is_none(), | 83 | explicit.is_none(), |
| 52 | "INTER_IVF={path} was set explicitly but the file does not exist" | 84 | "INTER_IVF={path} was set explicitly but the file does not exist" |
| 53 | ); | 85 | ); |
| 54 | - println!("SKIP: fixture {path} not found - set INTER_IVF=<file> to run"); | ||
| 55 | return; | 86 | return; |
| 56 | - }; | 87 | + } |
| 88 | + let bytes = std::fs::read(&path).expect("fixture presence was just probed"); | ||
| 57 | let (_fourcc, w, h, frames) = ivf::parse_ivf(&bytes); | 89 | let (_fourcc, w, h, frames) = ivf::parse_ivf(&bytes); |
| 58 | println!("IVF {w}x{h} frames={}", frames.len()); | 90 | println!("IVF {w}x{h} frames={}", frames.len()); |
| 59 | let mut dec = Decoder::new(); | 91 | let mut dec = Decoder::new(); |
crates/ec-vp9/tests/subsampling_exact.rsmodified+36 -10
| @@ -5,7 +5,9 @@ | |||
| 5 | //! Every fixture under `tests/data/` is committed (see the lane report for | 5 | //! Every fixture under `tests/data/` is committed (see the lane report for |
| 6 | //! the exact generator commands), so these cases always run; the two | 6 | //! the exact generator commands), so these cases always run; the two |
| 7 | //! `corpus_*` cases additionally cover the media-gated 4:4:4 corpus streams | 7 | //! `corpus_*` cases additionally cover the media-gated 4:4:4 corpus streams |
| 8 | -//! and skip by name when the fixture tree is absent. | 8 | +//! and print SKIP when the fixture is absent -- RED instead under |
| 9 | +//! `EC_REQUIRE_FIXTURES=1`, so a drifted fixture library can never read as a | ||
| 10 | +//! pass. | ||
| 9 | //! | 11 | //! |
| 10 | //! The comparison is the whole flattened plane stream (u16 samples) against | 12 | //! The comparison is the whole flattened plane stream (u16 samples) against |
| 11 | //! ffmpeg's `rawvideo` output for the matching `pix_fmt` — full-resolution | 13 | //! ffmpeg's `rawvideo` output for the matching `pix_fmt` — full-resolution |
| @@ -17,18 +19,42 @@ mod ivf; | |||
| 17 | use ec_vp9::decode::Decoder; | 19 | use ec_vp9::decode::Decoder; |
| 18 | use std::path::{Path, PathBuf}; | 20 | use std::path::{Path, PathBuf}; |
| 19 | 21 | ||
| 22 | +/// Fixture-presence probe for the media-gated 4:4:4 corpus IVFs the `corpus_*` | ||
| 23 | +/// cases decode (`corpus()` below, and any path a `scripts/*` generator makes). | ||
| 24 | +/// Returns whether the fixture is present, but never silently: under | ||
| 25 | +/// `EC_REQUIRE_FIXTURES=1` an absent fixture is a hard failure naming the path | ||
| 26 | +/// and the script that regenerates it, so a host whose fixture library drifted | ||
| 27 | +/// reports RED instead of a green SKIP (class: gate-skips-on-its-own-failure; | ||
| 28 | +/// model `have_ffmpeg` in crates/ec-av1/src/stream.rs, which was silently | ||
| 29 | +/// short-circuited because the probe ran first in a compound `if`). | ||
| 30 | +/// | ||
| 31 | +/// Order is load-bearing: probe, assert, return. Never merge the probe into | ||
| 32 | +/// the same `if` as the escape. | ||
| 33 | +fn require_fixture(path: &std::path::Path, generator: &str) -> bool { | ||
| 34 | + let present = path.exists(); | ||
| 35 | + assert!( | ||
| 36 | + present || std::env::var_os("EC_REQUIRE_FIXTURES").is_none(), | ||
| 37 | + "EC_REQUIRE_FIXTURES=1 but fixture {} is absent -- regenerate with: {}", | ||
| 38 | + path.display(), | ||
| 39 | + generator | ||
| 40 | + ); | ||
| 41 | + if !present { | ||
| 42 | + eprintln!("SKIP: fixture {} absent", path.display()); | ||
| 43 | + } | ||
| 44 | + present | ||
| 45 | +} | ||
| 46 | + | ||
| 20 | fn data(name: &str) -> PathBuf { | 47 | fn data(name: &str) -> PathBuf { |
| 21 | Path::new(env!("CARGO_MANIFEST_DIR")) | 48 | Path::new(env!("CARGO_MANIFEST_DIR")) |
| 22 | .join("tests/data") | 49 | .join("tests/data") |
| 23 | .join(name) | 50 | .join(name) |
| 24 | } | 51 | } |
| 25 | 52 | ||
| 26 | -fn corpus(name: &str) -> Option<PathBuf> { | 53 | +fn corpus(name: &str) -> PathBuf { |
| 27 | let mut p = PathBuf::from(env!("CARGO_MANIFEST_DIR")); | 54 | let mut p = PathBuf::from(env!("CARGO_MANIFEST_DIR")); |
| 28 | p.pop(); | 55 | p.pop(); |
| 29 | p.pop(); | 56 | p.pop(); |
| 30 | - let p = p.join("fixtures/bitstreams").join(name); | 57 | + p.join("fixtures/bitstreams").join(name) |
| 31 | - p.exists().then_some(p) | ||
| 32 | } | 58 | } |
| 33 | 59 | ||
| 34 | /// ffmpeg's decoded samples as a flat u16 stream (8-bit zero-extended, | 60 | /// ffmpeg's decoded samples as a flat u16 stream (8-bit zero-extended, |
| @@ -133,18 +159,18 @@ fn profile2_420_12bit_is_byte_exact() { | |||
| 133 | 159 | ||
| 134 | #[test] | 160 | #[test] |
| 135 | fn corpus_profile1_444_matches_ffmpeg() { | 161 | fn corpus_profile1_444_matches_ffmpeg() { |
| 136 | - let Some(p) = corpus("vp9-profile1-444.ivf") else { | 162 | + let p = corpus("vp9-profile1-444.ivf"); |
| 137 | - eprintln!("SKIP corpus_profile1_444_matches_ffmpeg: fixture absent"); | 163 | + if !require_fixture(&p, "scripts/gen-bitstream-fixtures.sh") { |
| 138 | return; | 164 | return; |
| 139 | - }; | 165 | + } |
| 140 | check(&p, "yuv444p", 8); | 166 | check(&p, "yuv444p", 8); |
| 141 | } | 167 | } |
| 142 | 168 | ||
| 143 | #[test] | 169 | #[test] |
| 144 | fn corpus_profile3_444_10bit_matches_ffmpeg() { | 170 | fn corpus_profile3_444_10bit_matches_ffmpeg() { |
| 145 | - let Some(p) = corpus("vp9-profile3-444-10bit.ivf") else { | 171 | + let p = corpus("vp9-profile3-444-10bit.ivf"); |
| 146 | - eprintln!("SKIP corpus_profile3_444_10bit_matches_ffmpeg: fixture absent"); | 172 | + if !require_fixture(&p, "scripts/gen-bitstream-fixtures.sh") { |
| 147 | return; | 173 | return; |
| 148 | - }; | 174 | + } |
| 149 | check(&p, "yuv444p10le", 10); | 175 | check(&p, "yuv444p10le", 10); |
| 150 | } | 176 | } |
scripts/fixture-library.tsvadded+280 -0
| @@ -0,0 +1,280 @@ | |||
| 1 | +# GENERATED by scripts/gen-fixture-library.sh -- do not hand-edit. | ||
| 2 | +# Regenerate: scripts/gen-fixture-library.sh | ||
| 3 | +# Verify: scripts/verify-fixture-library.sh | ||
| 4 | +# path <TAB> required-by file:line <TAB> provenance <TAB> status <TAB> sha256 | ||
| 5 | +# | ||
| 6 | +# Enumeration is grep-derived. It cannot see a fixture name that is not a | ||
| 7 | +# string literal in the same file (manifest rows, vectors.sha256 names, | ||
| 8 | +# format! interpolation); such names are only covered through their parent | ||
| 9 | +# directory, which the verifier requires to exist AND be non-empty. | ||
| 10 | +# 191 media-name literal(s) in this tree resolved under no enumerated | ||
| 11 | +# fixture directory and are therefore not listed individually. | ||
| 12 | +# | ||
| 13 | +# ROOT FIXTURE ROOT: /home/user/.cache/wt/av1fixlib/fixtures | ||
| 14 | +# | ||
| 15 | +# VECTORS consumers (fixtures/vectors/*): crates/ec-flac/tests/xiph_vectors.rs crates/ec-h264/tests/conformance.rs crates/ec-opus/tests/conformance.rs | ||
| 16 | +# VECTORS .tar.gz blob referenced by: nothing | ||
| 17 | +# The three fleet hosts carry the EXTRACTED vector sets (~470 files) and the | ||
| 18 | +# sync deliberately excluded the .tar.gz blobs; nothing in crates/ reads a | ||
| 19 | +# blob, so the extracted directories are the whole requirement. | ||
| 20 | +# Unreferenced committed pins carried as rows: 4 | ||
| 21 | +crates/ec-av1/fixtures/420_intrabc_rect4_witness.obu crates/ec-av1/src/stream.rs:7434 none (prose provenance only) ok d01352af5059919cdce733abdcbae8e8240ac3c2a6190fa1bd96d3c6f945b979 | ||
| 22 | +crates/ec-av1/fixtures/422_allskip_2f.obu crates/ec-av1/src/stream.rs:2295 none (prose provenance only) ok ba4932c14f95971b5f25321b04abce80c9fdd5de4b1fe6fffcdad82aaea87ce1 | ||
| 23 | +crates/ec-av1/fixtures/422_intrabc_sb128_strip_notxsearch.obu crates/ec-av1/src/stream.rs:2357 none (prose provenance only) ok 80dd0d4e93fd6c3d4b7188a43e69d9638f2bece38edfab60ff3582628314b5ec | ||
| 24 | +crates/ec-av1/fixtures/422_intrabc_sb128_strip.obu crates/ec-av1/src/stream.rs:2352 none (prose provenance only) ok f92000db86df7acc577d60dd1d0d97454bff4705799ea59d9de34eb5a71dbbcd | ||
| 25 | +crates/ec-av1/fixtures/422_residual_compound_warp_16f.obu crates/ec-av1/src/stream.rs:2574 none (prose provenance only) ok d78e2afb43ce311d3d82335a945c6f80f62db4537966d881c1349a68b3aecb95 | ||
| 26 | +crates/ec-av1/fixtures/422_residual_compound_warp_nolr_16f.obu crates/ec-av1/src/stream.rs:2653 none (prose provenance only) ok 8bed368f7ec4bca772137c6a9c2af89e1b2767ed5f937b91bd9e72ec60aeb42f | ||
| 27 | +crates/ec-av1/fixtures/422_sb128_3f.obu crates/ec-av1/src/stream.rs:2296 none (prose provenance only) ok 0b851799d99cb4d141a7d042138a3999aad7e0fb24d69c670bca1d38c286dce9 | ||
| 28 | +crates/ec-av1/fixtures/444_intrabc_rect4_witness.obu crates/ec-av1/src/stream.rs:7428 none (prose provenance only) ok 7fe888edf18caa74bdb415f0de643dc59963e87e0255d77191200b7a62eb2542 | ||
| 29 | +crates/ec-av1/fixtures/444_leaf8_oob.obu crates/ec-av1/src/stream.rs:7853 none (prose provenance only) ok 72bed2791d1ceba8be7926a052c7838c5d96d4f9d56d28fb69789a753d3593af | ||
| 30 | +crates/ec-av1/fixtures/444_lossy_rect4_inter_witness.obu crates/ec-av1/src/stream.rs:7248 none (prose provenance only) ok 77f727e76d81fe48cd03709f799131677c04869b163e18d78e96bc742ec69153 | ||
| 31 | +crates/ec-av1/fixtures/444_quad_leaf_tx_type.obu crates/ec-av1/src/stream.rs:19221 none (prose provenance only) ok a06c9f7a0862252f6ab7ebdcec340d0602e730e38089365f14747db37f8e78d5 | ||
| 32 | +crates/ec-av1/fixtures/444_sb128rect_lr_witness.obu crates/ec-av1/src/stream.rs:13207 none (prose provenance only) ok 27825e14633a4b23e37d48a2acdc7f5d814ca4fadd0b8797d72a1ffb34061e80 | ||
| 33 | +crates/ec-av1/fixtures/444_sb128rect_lr_witness.obu crates/ec-av1/src/stream.rs:7042 none (prose provenance only) ok 27825e14633a4b23e37d48a2acdc7f5d814ca4fadd0b8797d72a1ffb34061e80 | ||
| 34 | +crates/ec-av1/fixtures/444_sb128rect_lr_witness.obu crates/ec-av1/src/stream.rs:7525 none (prose provenance only) ok 27825e14633a4b23e37d48a2acdc7f5d814ca4fadd0b8797d72a1ffb34061e80 | ||
| 35 | +crates/ec-av1/fixtures/av112bit-compound-masked.obu (committed pin: NO source reference found) none (prose provenance only) ok 83625de2ed347d457eb67f9781eed3fea598ef035f29bbc311d7025fe178c691 | ||
| 36 | +crates/ec-av1/fixtures/av112bit-compound.obu (committed pin: NO source reference found) none (prose provenance only) ok a839cff534b89d5cd52681dd43a7dedc10131d8dd7725bdfa5502d6bc4421740 | ||
| 37 | +crates/ec-av1/fixtures/av112bit-inter.obu (committed pin: NO source reference found) none (prose provenance only) ok e679d577e61b4a8bc99685355cca8c0473cfb637284b07786a6c53b1755553d9 | ||
| 38 | +crates/ec-av1/fixtures/av112bit-key.obu (committed pin: NO source reference found) none (prose provenance only) ok c74f62b57f71f7c36c49ea1feeb482786a2650e5c7f66610949b5f65fbbed8d1 | ||
| 39 | +crates/ec-av1/fixtures/av1_192x128_8bit_intra64_in_inter.obu crates/ec-av1/src/stream.rs:19154 none (prose provenance only) ok e4cff46cb1700527c68efc866db27a2835705e949d646f73f0c9df577d594bd6 | ||
| 40 | +crates/ec-av1/fixtures/av1_192x128_8bit_intra64_in_inter.obu crates/ec-av1/src/stream.rs:19254 none (prose provenance only) ok e4cff46cb1700527c68efc866db27a2835705e949d646f73f0c9df577d594bd6 | ||
| 41 | +crates/ec-av1/fixtures crates/ec-av1/src/stream.rs:13210 scripts/gen-fixtures.sh ok - | ||
| 42 | +crates/ec-av1/fixtures crates/ec-av1/src/stream.rs:13259 scripts/gen-fixtures.sh ok - | ||
| 43 | +crates/ec-av1/fixtures crates/ec-av1/src/stream.rs:13316 scripts/gen-fixtures.sh ok - | ||
| 44 | +crates/ec-av1/fixtures crates/ec-av1/src/stream.rs:2299 scripts/gen-fixtures.sh ok - | ||
| 45 | +crates/ec-av1/fixtures crates/ec-av1/src/stream.rs:2363 scripts/gen-fixtures.sh ok - | ||
| 46 | +crates/ec-av1/fixtures crates/ec-av1/src/stream.rs:2578 scripts/gen-fixtures.sh ok - | ||
| 47 | +crates/ec-av1/fixtures crates/ec-av1/src/stream.rs:2657 scripts/gen-fixtures.sh ok - | ||
| 48 | +crates/ec-av1/fixtures crates/ec-av1/src/stream.rs:42059 scripts/gen-fixtures.sh ok - | ||
| 49 | +crates/ec-av1/fixtures crates/ec-av1/src/stream.rs:42136 scripts/gen-fixtures.sh ok - | ||
| 50 | +crates/ec-av1/fixtures crates/ec-av1/src/stream.rs:8661 scripts/gen-fixtures.sh ok - | ||
| 51 | +crates/ec-av1/fixtures/filter_intra_8x16_strip_seed49.obu crates/ec-av1/src/stream.rs:36907 none (prose provenance only) ok 6f837e47ad0a67f31c3998aa789cf0811e7540ac2114981853a0148744cb76c2 | ||
| 52 | +crates/ec-av1/fixtures/gm_small_side_witness.obu crates/ec-av1/src/stream.rs:42064 none (prose provenance only) ok f1cdbcbb8d6d469c7957d70252ab42b24ab75f48a717600ffa25991458775dca | ||
| 53 | +crates/ec-av1/fixtures/gm_small_side_witness.obu crates/ec-av1/src/stream.rs:42141 none (prose provenance only) ok f1cdbcbb8d6d469c7957d70252ab42b24ab75f48a717600ffa25991458775dca | ||
| 54 | +crates/ec-av1/fixtures/gm_small_side_witness.obu crates/ec-av1/src/stream.rs:42224 none (prose provenance only) ok f1cdbcbb8d6d469c7957d70252ab42b24ab75f48a717600ffa25991458775dca | ||
| 55 | +crates/ec-av1/fixtures/grain_cdef_lr_128x128.obu crates/ec-av1/src/stream.rs:13313 none (prose provenance only) ok 06f210b87b5c79eb729c559050e073abbe226c4dad1df3dcaa113b03011ad732 | ||
| 56 | +crates/ec-av1/fixtures/reelb_arf_witness.obu crates/ec-av1/src/stream.rs:13198 none (prose provenance only) ok 7f3b060da5aa9c537633e760c4af71316237db7692f6ae0d459bd2c2dd867d37 | ||
| 57 | +crates/ec-av1/fixtures/reelb_arf_witness.obu crates/ec-av1/src/stream.rs:41286 none (prose provenance only) ok 7f3b060da5aa9c537633e760c4af71316237db7692f6ae0d459bd2c2dd867d37 | ||
| 58 | +crates/ec-av1/fixtures/reelb_arf_witness.obu crates/ec-av1/src/stream.rs:41368 none (prose provenance only) ok 7f3b060da5aa9c537633e760c4af71316237db7692f6ae0d459bd2c2dd867d37 | ||
| 59 | +crates/ec-av1/fixtures/reelb_head_key_frame.obu crates/ec-av1/src/stream.rs:13451 none (prose provenance only) ok 53c311dec790bb2413afdde92cb24de498a7c4f66f6f0c7f4f5910ab0d2c65dc | ||
| 60 | +crates/ec-av1/fixtures/reelb_head_mvclamp_witness.obu crates/ec-av1/src/stream.rs:42306 none (prose provenance only) ok 451a9b138995e636f22308847a123b5c8621d4908cd93772cf5bbf2b37df39d7 | ||
| 61 | +crates/ec-av1/fixtures/reelb_intra14_witness.obu crates/ec-av1/src/stream.rs:41115 none (prose provenance only) ok 0eff603bf1608e47faf5e6729670c4c77cf5c674dbad3a1533ac6660151fd90e | ||
| 62 | +crates/ec-av1/fixtures/reelb_kf900.obu crates/ec-av1/src/stream.rs:13593 none (prose provenance only) ok a273ae99328388be14a1ff8fa1c5a6d391a9948159eaef120e1b50e02015eb83 | ||
| 63 | +crates/ec-av1/fixtures/reelb_kf900.obu crates/ec-av1/src/stream.rs:43081 none (prose provenance only) ok a273ae99328388be14a1ff8fa1c5a6d391a9948159eaef120e1b50e02015eb83 | ||
| 64 | +crates/ec-av1/fixtures/reelb_rect64_intra16x4_witness.obu crates/ec-av1/src/stream.rs:41204 none (prose provenance only) ok c9e721088766163b9dbeb9fa8dd8b257ff0ec7f9157fc350de4d3c33cd9ec4e4 | ||
| 65 | +crates/ec-av1/fixtures/reelb_ss300_key_frame.obu crates/ec-av1/src/stream.rs:13542 none (prose provenance only) ok 7e3ddf0d602f9496b2f7eb11f051fd4a045020e094d5bc02f83825e2c494ef12 | ||
| 66 | +crates/ec-av1/fixtures/reelb_ss600_key_frame.obu crates/ec-av1/src/stream.rs:13634 none (prose provenance only) ok 36de46676ed7de7049d4dabe8571d8cd31c8a1f53d72011c0ee532a7c6725cd6 | ||
| 67 | +crates/ec-av1/fixtures/intra128_in_inter_screen_witness.obu crates/ec-av1/src/stream.rs:41786 none (prose provenance only) ok c84a493f90327f5d2bea038a42e87cbfe56762b5c6a856d76b4bff9797c5ea09 | ||
| 68 | +crates/ec-av1/fixtures/intra128_in_inter_witness2.obu crates/ec-av1/src/stream.rs:41718 none (prose provenance only) ok cace4cc3a5ba4dc5f8c7c219e87c9052351e832cad3d7f4c8ffe09288a6d7ccf | ||
| 69 | +crates/ec-av1/fixtures/intra128_in_inter_witness2.obu crates/ec-av1/src/stream.rs:42063 none (prose provenance only) ok cace4cc3a5ba4dc5f8c7c219e87c9052351e832cad3d7f4c8ffe09288a6d7ccf | ||
| 70 | +crates/ec-av1/fixtures/intra128_in_inter_witness2.obu crates/ec-av1/src/stream.rs:42140 none (prose provenance only) ok cace4cc3a5ba4dc5f8c7c219e87c9052351e832cad3d7f4c8ffe09288a6d7ccf | ||
| 71 | +crates/ec-av1/fixtures/intra128_in_inter_witness.obu crates/ec-av1/src/stream.rs:41622 none (prose provenance only) ok dd41fc39367a3d38bf8a8a8106dc30d91b716b2a9123fdfa4716930f4f98caf9 | ||
| 72 | +crates/ec-av1/fixtures/intrabc_tx4_chroma_kf.obu crates/ec-av1/src/stream.rs:11185 none (prose provenance only) ok bc699af4a6e7c1c5657f041e8cbdf2d3d899ddb80ec2a549a950b7cebb5b41bd | ||
| 73 | +crates/ec-av1/fixtures/ll444_128root_lossless.obu crates/ec-av1/src/stream.rs:6791 none (prose provenance only) ok bbffb979d20d581deb271aac75b7ee779dde57c024524ed6b1389356f55ca0fa | ||
| 74 | +crates/ec-av1/fixtures/ll444_defaultp_inter_strip.obu crates/ec-av1/src/stream.rs:7701 none (prose provenance only) ok 1e6dd4e05038c8d51e2c8d29f8c337130c4fea0aed629415535e6e53af9a2c72 | ||
| 75 | +crates/ec-av1/fixtures/ll444_ibc_rect.obu crates/ec-av1/src/stream.rs:8270 none (prose provenance only) ok 482dedca0201beea9b0a05720b5da7fe93c350c9fea7699cdb010c3fbc227ec0 | ||
| 76 | +crates/ec-av1/fixtures/ll444_minp64_128root_control.obu crates/ec-av1/src/stream.rs:6842 none (prose provenance only) ok 4cadce41e1f8967567b32f5cf8abaa46ffdf4fd6d4afe784c8d99a7f6bf1ae4c | ||
| 77 | +crates/ec-av1/fixtures/ll444_minp64_inter.obu crates/ec-av1/src/stream.rs:6640 none (prose provenance only) ok 5a070fa351a3f2109de855234f2b3d0a872970f3e7f658db21f65c12eeb135b4 | ||
| 78 | +crates/ec-av1/fixtures/ll444_minp8_inter.obu crates/ec-av1/src/stream.rs:6899 none (prose provenance only) ok 04fb6d38de5382e647bfb70b6a17802f1fccc5502e6698c0394167891f2b27dc | ||
| 79 | +crates/ec-av1/fixtures/ll444_rect16x4_chroma_reach.obu crates/ec-av1/src/stream.rs:10259 none (prose provenance only) ok 382e67c0cc0988d14c500a62f5c3457a3f3b5f76d05acce2f655b1089bb8e7e3 | ||
| 80 | +crates/ec-av1/fixtures/lossless_sb128_rect_kf.obu crates/ec-av1/src/stream.rs:7949 none (prose provenance only) ok 013b07979c8be999c70d47f32768c2bf959be086a893f60dde1b0f5e35d4f475 | ||
| 81 | +crates/ec-av1/fixtures/palette_screen_leaf8_witness.obu crates/ec-av1/src/stream.rs:41962 none (prose provenance only) ok 8d036606116913c82b774286bb0a3efe616d54151784897ba62b13d12fdef06e | ||
| 82 | +crates/ec-av1/fixtures/palette_screen_strip16_witness_10bit.obu crates/ec-av1/src/stream.rs:42006 none (prose provenance only) ok aaabbb001d87f61ee534fd17c2d558ad906d1c33d357decb86cfd26e593da0db | ||
| 83 | +crates/ec-av1/fixtures/palette_screen_witness_10bit.obu crates/ec-av1/src/stream.rs:13200 none (prose provenance only) ok a60a8bc132e5db7bed3eb46e03e9ed9828811bdffb96914958f3c94b107c3cda | ||
| 84 | +crates/ec-av1/fixtures/palette_screen_witness_10bit.obu crates/ec-av1/src/stream.rs:41881 none (prose provenance only) ok a60a8bc132e5db7bed3eb46e03e9ed9828811bdffb96914958f3c94b107c3cda | ||
| 85 | +crates/ec-av1/fixtures/palette_screen_witness.obu crates/ec-av1/src/stream.rs:13199 none (prose provenance only) ok 635a512b866f0fab7d45eb4f94f2a5b15008fe5a5317ac1ca45ffd3381198b8b | ||
| 86 | +crates/ec-av1/fixtures/palette_screen_witness.obu crates/ec-av1/src/stream.rs:41287 none (prose provenance only) ok 635a512b866f0fab7d45eb4f94f2a5b15008fe5a5317ac1ca45ffd3381198b8b | ||
| 87 | +crates/ec-av1/fixtures/palette_screen_witness.obu crates/ec-av1/src/stream.rs:41880 none (prose provenance only) ok 635a512b866f0fab7d45eb4f94f2a5b15008fe5a5317ac1ca45ffd3381198b8b | ||
| 88 | +crates/ec-av1/fixtures/superres_alltools_sb128_320x180.obu crates/ec-av1/src/stream.rs:13260 none (prose provenance only) ok e2b515ce487acd2d720d5a000a6f26e66fd03ef2b1a4cb12daa6fdf31a55d519 | ||
| 89 | +crates/ec-av1/fixtures/superres_alltools_sb128_320x180.obu crates/ec-av1/src/stream.rs:13312 none (prose provenance only) ok e2b515ce487acd2d720d5a000a6f26e66fd03ef2b1a4cb12daa6fdf31a55d519 | ||
| 90 | +crates/ec-av1/fixtures/superres_alltools_sb128_320x180.obu crates/ec-av1/src/stream.rs:13415 none (prose provenance only) ok e2b515ce487acd2d720d5a000a6f26e66fd03ef2b1a4cb12daa6fdf31a55d519 | ||
| 91 | +crates/ec-av1/fixtures/superres_kf_cdef_lr_64x64.obu crates/ec-av1/src/stream.rs:13145 none (prose provenance only) ok 5912e251bcd5d0f284f647616f91b19b579238c16fa85c0294a06548088d7336 | ||
| 92 | +crates/ec-av1/fixtures/reelc_kf2700.obu crates/ec-av1/src/stream.rs:13489 none (prose provenance only) ok 16981094eaab516bd1007b0a47d1fc653fbb58b7e18a40af6c12d934bf96fe63 | ||
| 93 | +crates/ec-av1/fixtures/reelc_sb128_inter_witness.obu crates/ec-av1/src/stream.rs:41459 none (prose provenance only) ok 09d995946d27695ef4b7b1a24a4d7ad85f8e2c8176d58ee54e825efc061f9cbc | ||
| 94 | +crates/ec-av1/fixtures/reelc_sb128_inter_witness.obu crates/ec-av1/src/stream.rs:42062 none (prose provenance only) ok 09d995946d27695ef4b7b1a24a4d7ad85f8e2c8176d58ee54e825efc061f9cbc | ||
| 95 | +crates/ec-av1/fixtures/reelc_sb128_inter_witness.obu crates/ec-av1/src/stream.rs:42139 none (prose provenance only) ok 09d995946d27695ef4b7b1a24a4d7ad85f8e2c8176d58ee54e825efc061f9cbc | ||
| 96 | +fixtures/audio/aac-adts-5.1-44100.aac crates/ec-aac/tests/oracle.rs:151 scripts/gen-fixtures.sh ok 2b615b45e7c45136e2d477bd5ed489822ddadcb5f1b7fe2da0a66dcc288881b4 | ||
| 97 | +fixtures/audio/aac-adts-5.1-48000.aac crates/ec-aac/tests/oracle.rs:152 scripts/gen-fixtures.sh ok f416a2059766b6ce751bdf272836897c191073ca9f4f302552e949eeeeb01a44 | ||
| 98 | +fixtures/audio/aac-adts-5.1-48000.aac crates/ec-probe/tests/matrix.rs:95 scripts/gen-fixtures.sh ok f416a2059766b6ce751bdf272836897c191073ca9f4f302552e949eeeeb01a44 | ||
| 99 | +fixtures/audio/aac-adts-mono-44100.aac crates/ec-aac/tests/oracle.rs:147 scripts/gen-fixtures.sh ok 19b3870bc9e6e87dd20f448795899514e8cf5abfc770173c4c928468811dbdb7 | ||
| 100 | +fixtures/audio/aac-adts-mono-44100.aac crates/ec-probe/tests/matrix.rs:93 scripts/gen-fixtures.sh ok 19b3870bc9e6e87dd20f448795899514e8cf5abfc770173c4c928468811dbdb7 | ||
| 101 | +fixtures/audio/aac-adts-mono-48000.aac crates/ec-aac/tests/oracle.rs:148 scripts/gen-fixtures.sh ok 8e65736140a0dc7939060569250611ab822c7f489bddca3c0934728648c99180 | ||
| 102 | +fixtures/audio/aac-adts-stereo-44100.aac crates/ec-aac/tests/oracle.rs:149 scripts/gen-fixtures.sh ok 99cf6fad337acd097dabfb22b165984feedcf0f47427d093be7f5f76b5f515dd | ||
| 103 | +fixtures/audio/aac-adts-stereo-48000.aac crates/ec-aac/tests/oracle.rs:150 scripts/gen-fixtures.sh ok 3a8ce7512b5d8f9bda4f4e605023a2e68d793f4bc7697bbcd7c92e419b21edca | ||
| 104 | +fixtures/audio/aac-adts-stereo-48000.aac crates/ec-probe/tests/matrix.rs:94 scripts/gen-fixtures.sh ok 3a8ce7512b5d8f9bda4f4e605023a2e68d793f4bc7697bbcd7c92e419b21edca | ||
| 105 | +fixtures/audio/aac-mka-stereo-48000.mka crates/ec-probe/src/lib.rs:1145 scripts/gen-fixtures.sh ok 5ca5f13047f8f5a3e1876aa0d8d0c22251a45d0220e7c95326aea52e184c9260 | ||
| 106 | +fixtures/audio/aac-mp4-5.1-44100.mp4 crates/ec-probe/tests/matrix.rs:97 scripts/gen-fixtures.sh ok 6e9ec3be717f3dcd011a1ac832f04405897a406ef21f831dc7ee04ab70880680 | ||
| 107 | +fixtures/audio/aac-mp4-5.1-48000.mp4 crates/ec-aac/tests/oracle.rs:187 scripts/gen-fixtures.sh ok 5896e86836a0717e34b27ee44510cb879fe5460e53dfdd9f4c75cf0be432ba8a | ||
| 108 | +fixtures/audio/aac-mp4-mono-48000.mp4 crates/ec-aac/tests/oracle.rs:185 scripts/gen-fixtures.sh ok 787b45a7348acdde7fc8f9793ce9edc587b1df5ab98cba79eea0f2744c10c633 | ||
| 109 | +fixtures/audio/aac-mp4-stereo-48000.mp4 crates/ec-aac/tests/oracle.rs:186 scripts/gen-fixtures.sh ok 68b9f0d0e99868c010743362ffc03126a1a6b69fce4f3740bdfa0c8c06f7e57b | ||
| 110 | +fixtures/audio/aac-mp4-stereo-48000.mp4 crates/ec-probe/tests/matrix.rs:96 scripts/gen-fixtures.sh ok 68b9f0d0e99868c010743362ffc03126a1a6b69fce4f3740bdfa0c8c06f7e57b | ||
| 111 | +fixtures/audio/alac24-mp4-5.1-48000.m4a crates/ec-alac/tests/oracle.rs:72 scripts/gen-fixtures.sh ok b9007c453614808e4f5f777e51bef7baab1419c80b7d502c9e30a60878aa6de5 | ||
| 112 | +fixtures/audio/alac24-mp4-stereo-48000.m4a crates/ec-alac/tests/oracle.rs:71 scripts/gen-fixtures.sh ok cf3fffc6723e86344c1d2d626d4e1e22f5164bdf7ccccad1d6052b2ce70409ae | ||
| 113 | +fixtures/audio/alac24-mp4-stereo-48000.m4a crates/ec-probe/tests/matrix.rs:100 scripts/gen-fixtures.sh ok cf3fffc6723e86344c1d2d626d4e1e22f5164bdf7ccccad1d6052b2ce70409ae | ||
| 114 | +fixtures/audio/alac-mp4-5.1-44100.m4a crates/ec-alac/tests/oracle.rs:69 scripts/gen-fixtures.sh ok 037c576aa9f0ebe4dff5a0b41278d9ea1967b3a1eaf0fb9b893ff00e2dbccdf1 | ||
| 115 | +fixtures/audio/alac-mp4-5.1-48000.m4a crates/ec-alac/tests/oracle.rs:70 scripts/gen-fixtures.sh ok d9e224c52f2efc71cb6be4d18e840d58a941eafe96d80fe6b219f605aebb7d01 | ||
| 116 | +fixtures/audio/alac-mp4-5.1-48000.m4a crates/ec-probe/tests/matrix.rs:99 scripts/gen-fixtures.sh ok d9e224c52f2efc71cb6be4d18e840d58a941eafe96d80fe6b219f605aebb7d01 | ||
| 117 | +fixtures/audio/alac-mp4-mono-44100.m4a crates/ec-alac/tests/oracle.rs:65 scripts/gen-fixtures.sh ok c390c7674f81a3bdea622f4bcace2b593aae848e26563e09929b32a99a2a9869 | ||
| 118 | +fixtures/audio/alac-mp4-mono-48000.m4a crates/ec-alac/tests/oracle.rs:66 scripts/gen-fixtures.sh ok d765d1adbba124e97c8bcb27a0a2e5aa7b3a181c0c1d7d134a18675f62597205 | ||
| 119 | +fixtures/audio/alac-mp4-stereo-44100.m4a crates/ec-alac/tests/oracle.rs:112 scripts/gen-fixtures.sh ok 014d2691a0f8490e4d5da626e046d2680ff554db72cfdc688c5697c1bc350114 | ||
| 120 | +fixtures/audio/alac-mp4-stereo-44100.m4a crates/ec-alac/tests/oracle.rs:67 scripts/gen-fixtures.sh ok 014d2691a0f8490e4d5da626e046d2680ff554db72cfdc688c5697c1bc350114 | ||
| 121 | +fixtures/audio/alac-mp4-stereo-44100.m4a crates/ec-probe/tests/matrix.rs:98 scripts/gen-fixtures.sh ok 014d2691a0f8490e4d5da626e046d2680ff554db72cfdc688c5697c1bc350114 | ||
| 122 | +fixtures/audio/alac-mp4-stereo-48000.m4a crates/ec-alac/tests/oracle.rs:68 scripts/gen-fixtures.sh ok f35830614c8f32a0f00ac689377ea45cd281740485322daa0fcb6aa131a398e5 | ||
| 123 | +fixtures/audio/av-h264-aac-stereo-48000.mkv crates/ec-probe/tests/matrix.rs:110 scripts/gen-fixtures.sh ok da4cd8ad5a9be7b148926fdda36969569c3528279c73bdd2f4a36d8266612560 | ||
| 124 | +fixtures/audio/cover-mp4-stereo-44100.m4a crates/ec-probe/tests/matrix.rs:260 scripts/gen-fixtures.sh ok b8ef543bdc0aa4d05628efaa9648121af00a159fb1d80cfb1c8a53dfdb9d6941 | ||
| 125 | +fixtures/audio crates/ec-ac3/tests/decode_matrix.rs:23 scripts/gen-fixtures.sh ok - | ||
| 126 | +fixtures/audio crates/ec-ac3/tests/decode_matrix.rs:25 scripts/gen-fixtures.sh ok - | ||
| 127 | +fixtures/audio crates/ec-ac3/tests/encode_matrix.rs:291 scripts/gen-fixtures.sh ok - | ||
| 128 | +fixtures/audio crates/ec-alac/tests/encode.rs:15 scripts/gen-fixtures.sh ok - | ||
| 129 | +fixtures/audio crates/ec-alac/tests/oracle.rs:17 scripts/gen-fixtures.sh ok - | ||
| 130 | +fixtures/audio crates/ec-ogg/tests/ogg.rs:32 scripts/gen-fixtures.sh ok - | ||
| 131 | +fixtures/audio crates/ec-opus/tests/conformance.rs:584 scripts/gen-fixtures.sh ok - | ||
| 132 | +fixtures/audio crates/ec-probe/tests/matrix.rs:17 scripts/gen-fixtures.sh ok - | ||
| 133 | +fixtures/audio crates/ec-riff/tests/wav.rs:432 scripts/gen-fixtures.sh ok - | ||
| 134 | +fixtures/audio/flac-5.1-44100.flac crates/ec-probe/tests/matrix.rs:90 scripts/gen-fixtures.sh ok 83f3731bcf67f9f4ff12f793ed89c6cf73f17a985403648e2f3c7908b4705e99 | ||
| 135 | +fixtures/audio/flac-mono-44100.flac crates/ec-probe/tests/matrix.rs:88 scripts/gen-fixtures.sh ok f55187711aaf27af6bbb5cd493ce2fdc53c82dff33472b7918eda7e76c024258 | ||
| 136 | +fixtures/audio/flac-stereo-48000.flac crates/ec-probe/tests/matrix.rs:300 scripts/gen-fixtures.sh ok 50cfaa89da637107348d1986711d37e4f313a502df72fb2b6b53ca699d5f17b0 | ||
| 137 | +fixtures/audio/flac-stereo-48000.flac crates/ec-probe/tests/matrix.rs:89 scripts/gen-fixtures.sh ok 50cfaa89da637107348d1986711d37e4f313a502df72fb2b6b53ca699d5f17b0 | ||
| 138 | +fixtures/audio/opus-ogg-5.1-48000.opus crates/ec-opus/tests/conformance.rs:676 scripts/gen-fixtures.sh ok b005631cb93ed64166199cdcacfb2d22635abe703d6d6750ad0f900d03766c69 | ||
| 139 | +fixtures/audio/opus-ogg-5.1-48000.opus crates/ec-opus/tests/conformance.rs:724 scripts/gen-fixtures.sh ok b005631cb93ed64166199cdcacfb2d22635abe703d6d6750ad0f900d03766c69 | ||
| 140 | +fixtures/audio/opus-ogg-5.1-48000.opus crates/ec-opus/tests/conformance.rs:766 scripts/gen-fixtures.sh ok b005631cb93ed64166199cdcacfb2d22635abe703d6d6750ad0f900d03766c69 | ||
| 141 | +fixtures/audio/opus-ogg-5.1-48000.opus crates/ec-probe/tests/matrix.rs:106 scripts/gen-fixtures.sh ok b005631cb93ed64166199cdcacfb2d22635abe703d6d6750ad0f900d03766c69 | ||
| 142 | +fixtures/audio/opus-ogg-mono-48000.opus crates/ec-opus/tests/conformance.rs:674 scripts/gen-fixtures.sh ok bf6b453b057bf0fbaffc8a84c417d667fc70e7545fe6af1aaa51d873ef7403dc | ||
| 143 | +fixtures/audio/opus-ogg-mono-48000.opus crates/ec-probe/tests/matrix.rs:104 scripts/gen-fixtures.sh ok bf6b453b057bf0fbaffc8a84c417d667fc70e7545fe6af1aaa51d873ef7403dc | ||
| 144 | +fixtures/audio/opus-ogg-stereo-48000.opus crates/ec-opus/tests/conformance.rs:675 scripts/gen-fixtures.sh ok 829e1a5d104b6d161d748dca82fef1fe28b35d10398b230bbddb39f8b1769cc9 | ||
| 145 | +fixtures/audio/opus-ogg-stereo-48000.opus crates/ec-opus/tests/conformance.rs:765 scripts/gen-fixtures.sh ok 829e1a5d104b6d161d748dca82fef1fe28b35d10398b230bbddb39f8b1769cc9 | ||
| 146 | +fixtures/audio/opus-ogg-stereo-48000.opus crates/ec-probe/tests/matrix.rs:105 scripts/gen-fixtures.sh ok 829e1a5d104b6d161d748dca82fef1fe28b35d10398b230bbddb39f8b1769cc9 | ||
| 147 | +fixtures/audio/vorbis-ogg-5.1-48000.ogg crates/ec-probe/tests/matrix.rs:103 scripts/gen-fixtures.sh ok 571dc4a174c340e29f3dfba1f5bee42c32d3b537106816e511e18ebbe1b8e717 | ||
| 148 | +fixtures/audio/vorbis-ogg-mono-44100.ogg crates/ec-probe/tests/matrix.rs:101 scripts/gen-fixtures.sh ok e77309d1a04df5a5a76f3ed4e121c0c427787fd85c81f13fb84b99d801ef9483 | ||
| 149 | +fixtures/audio/vorbis-ogg-stereo-48000.ogg crates/ec-probe/tests/matrix.rs:102 scripts/gen-fixtures.sh ok ce3b2c4d5c5be06ba85d6dab9c32f8e94cd27062c4cff161e1fde04cb96c832a | ||
| 150 | +fixtures/audio/wav16-5.1-48000.wav crates/ec-probe/tests/matrix.rs:87 scripts/gen-fixtures.sh ok 96a432a3138c9d5055f9cdce8ab9306001f825d948cbd2d337568e34b0c806de | ||
| 151 | +fixtures/audio/wav16-mono-44100.wav crates/ec-probe/tests/matrix.rs:85 scripts/gen-fixtures.sh ok 855f3b42a349299bae47db14cc76aceca2822071a55cf82f9423ff9de9f9d169 | ||
| 152 | +fixtures/audio/wav16-mono-48000.wav crates/ec-opus/tests/conformance.rs:2107 scripts/gen-fixtures.sh ok 739259114f735e36fa603b6d48457fd2953b5026cc33a7637aaad8b0b3d86f7d | ||
| 153 | +fixtures/audio/wav16-mono-48000.wav crates/ec-opus/tests/conformance.rs:2473 scripts/gen-fixtures.sh ok 739259114f735e36fa603b6d48457fd2953b5026cc33a7637aaad8b0b3d86f7d | ||
| 154 | +fixtures/audio/wav16-stereo-48000.wav crates/ec-alac/tests/encode.rs:102 scripts/gen-fixtures.sh ok 75a89990315315eb3f64ece40c791a8a0c7b72f71c7c4b9f46ed6a9f60200207 | ||
| 155 | +fixtures/audio/wav16-stereo-48000.wav crates/ec-alac/tests/encode.rs:185 scripts/gen-fixtures.sh ok 75a89990315315eb3f64ece40c791a8a0c7b72f71c7c4b9f46ed6a9f60200207 | ||
| 156 | +fixtures/audio/wav16-stereo-48000.wav crates/ec-alac/tests/encode.rs:210 scripts/gen-fixtures.sh ok 75a89990315315eb3f64ece40c791a8a0c7b72f71c7c4b9f46ed6a9f60200207 | ||
| 157 | +fixtures/audio/wav16-stereo-48000.wav crates/ec-probe/tests/matrix.rs:86 scripts/gen-fixtures.sh ok 75a89990315315eb3f64ece40c791a8a0c7b72f71c7c4b9f46ed6a9f60200207 | ||
| 158 | +fixtures/bitstreams/av1-altref.ivf crates/ec-av1-syntax/tests/streams.rs:239 scripts/gen-bitstream-fixtures.sh ok 3904cc9fd01624689f824b91c83530943027ac0097e80332daf310c660fec48f | ||
| 159 | +fixtures/bitstreams/av1-profile1-444.ivf crates/ec-hw/tests/gpu.rs:495 scripts/gen-bitstream-fixtures.sh ok 2e04b08114aeba5af059f93026046675584af940e23d0cfde325caf7969ca783 | ||
| 160 | +fixtures/bitstreams crates/ec-av1-syntax/tests/streams.rs:14 scripts/gen-fixtures.sh ok - | ||
| 161 | +fixtures/bitstreams crates/ec-hw/tests/gpu.rs:28 scripts/gen-fixtures.sh ok - | ||
| 162 | +fixtures/bitstreams crates/ec-vp9-syntax/tests/streams.rs:14 scripts/gen-fixtures.sh ok - | ||
| 163 | +fixtures/bitstreams crates/ec-vp9/tests/hbd_exact.rs:46 scripts/gen-fixtures.sh ok - | ||
| 164 | +fixtures/bitstreams crates/ec-vp9/tests/ivf.rs:54 scripts/gen-fixtures.sh ok - | ||
| 165 | +fixtures/bitstreams crates/ec-vp9/tests/subsampling_exact.rs:57 scripts/gen-fixtures.sh ok - | ||
| 166 | +fixtures/bitstreams/h264-1080p-23.976-8bit.264 crates/ec-hw/tests/gpu.rs:1841 scripts/gen-bitstream-fixtures.sh ok 44dc00696534ba5302b44e8791347439216c9e40068ae0e45009faf08bddfaae | ||
| 167 | +fixtures/bitstreams/h264-1080p-23.976-8bit.264 crates/ec-hw/tests/gpu.rs:1920 scripts/gen-bitstream-fixtures.sh ok 44dc00696534ba5302b44e8791347439216c9e40068ae0e45009faf08bddfaae | ||
| 168 | +fixtures/bitstreams/h264-1080p-23.976-8bit.264 crates/ec-hw/tests/gpu.rs:1988 scripts/gen-bitstream-fixtures.sh ok 44dc00696534ba5302b44e8791347439216c9e40068ae0e45009faf08bddfaae | ||
| 169 | +fixtures/bitstreams/h264-1080p-23.976-8bit.264 crates/ec-hw/tests/gpu.rs:711 scripts/gen-bitstream-fixtures.sh ok 44dc00696534ba5302b44e8791347439216c9e40068ae0e45009faf08bddfaae | ||
| 170 | +fixtures/bitstreams/vp9-1080p-23.976-10bit.ivf crates/ec-vp9/tests/hbd_exact.rs:85 scripts/gen-bitstream-fixtures.sh ok 731abcc45857ade311689065defae7166e25394386de01300174f5f4f122cef3 | ||
| 171 | +fixtures/bitstreams/vp9-1080p-60-8bit.ivf crates/ec-vp9/tests/inter_pixels_exact.rs:170 scripts/gen-bitstream-fixtures.sh ok - | ||
| 172 | +fixtures/bitstreams/vp9-profile1-444.ivf crates/ec-hw/tests/gpu.rs:490 scripts/gen-bitstream-fixtures.sh ok ceebede9c2df73b3e8c1b279f70eb8af658096abc2d8bd00aaa97afdd7900d86 | ||
| 173 | +fixtures/bitstreams/vp9-profile1-444.ivf crates/ec-vp9/tests/subsampling_exact.rs:122 scripts/gen-bitstream-fixtures.sh ok ceebede9c2df73b3e8c1b279f70eb8af658096abc2d8bd00aaa97afdd7900d86 | ||
| 174 | +fixtures/bitstreams/vp9-profile1-444.ivf crates/ec-vp9/tests/subsampling_exact.rs:162 scripts/gen-bitstream-fixtures.sh ok ceebede9c2df73b3e8c1b279f70eb8af658096abc2d8bd00aaa97afdd7900d86 | ||
| 175 | +fixtures/bitstreams/vp9-profile3-444-10bit.ivf crates/ec-vp9/tests/subsampling_exact.rs:127 scripts/gen-bitstream-fixtures.sh ok ba1af75f2b270b9e0ebb877cef72d9e741748482bd19924a4e1721682ee3f197 | ||
| 176 | +fixtures/bitstreams/vp9-profile3-444-10bit.ivf crates/ec-vp9/tests/subsampling_exact.rs:171 scripts/gen-bitstream-fixtures.sh ok ba1af75f2b270b9e0ebb877cef72d9e741748482bd19924a4e1721682ee3f197 | ||
| 177 | +fixtures/bitstreams/vp9-superframe-altref.ivf crates/ec-vp9-syntax/tests/streams.rs:200 scripts/gen-bitstream-fixtures.sh ok bfc59a9604aaddc6709971e0e81eca1178b0c0a32be83a3d5c7b5c078aa7a873 | ||
| 178 | +fixtures/bitstreams/vp9-superframe-altref.ivf crates/ec-vp9/tests/keyframe_exact.rs:163 scripts/gen-bitstream-fixtures.sh ok bfc59a9604aaddc6709971e0e81eca1178b0c0a32be83a3d5c7b5c078aa7a873 | ||
| 179 | +fixtures/bitstreams/vp9-superframe-altref.ivf crates/ec-vp9/tests/scratch_err.rs:10 scripts/gen-bitstream-fixtures.sh ok bfc59a9604aaddc6709971e0e81eca1178b0c0a32be83a3d5c7b5c078aa7a873 | ||
| 180 | +fixtures/bitstreams/vp9-superframe-altref.ivf crates/ec-vp9/tests/scratch_err.rs:6 scripts/gen-bitstream-fixtures.sh ok bfc59a9604aaddc6709971e0e81eca1178b0c0a32be83a3d5c7b5c078aa7a873 | ||
| 181 | +fixtures/bitstreams/vp9-superframe-altref.ivf crates/ec-vp9/tests/scratch_hdr3.rs:6 scripts/gen-bitstream-fixtures.sh ok bfc59a9604aaddc6709971e0e81eca1178b0c0a32be83a3d5c7b5c078aa7a873 | ||
| 182 | +fixtures crates/ec-aac/tests/oracle.rs:11 scripts/gen-fixtures.sh ok - | ||
| 183 | +fixtures crates/ec-av1/src/encode.rs:16812 scripts/gen-fixtures.sh ok - | ||
| 184 | +fixtures crates/ec-av1/src/encode.rs:19755 scripts/gen-fixtures.sh ok - | ||
| 185 | +fixtures crates/ec-av1/src/encode.rs:21170 scripts/gen-fixtures.sh ok - | ||
| 186 | +fixtures crates/ec-av1/src/encode.rs:21552 scripts/gen-fixtures.sh ok - | ||
| 187 | +fixtures crates/ec-av1/src/encode.rs:22103 scripts/gen-fixtures.sh ok - | ||
| 188 | +fixtures crates/ec-av1/src/encode.rs:22659 scripts/gen-fixtures.sh ok - | ||
| 189 | +fixtures crates/ec-av1/src/stream.rs:29415 scripts/gen-fixtures.sh ok - | ||
| 190 | +fixtures crates/ec-av1/src/stream.rs:8659 scripts/gen-fixtures.sh ok - | ||
| 191 | +fixtures crates/ec-flac/tests/encode_matrix.rs:48 scripts/gen-fixtures.sh ok - | ||
| 192 | +fixtures crates/ec-matroska/tests/matroska.rs:89 scripts/gen-fixtures.sh ok - | ||
| 193 | +fixtures crates/ec-mp3/tests/decode_matrix.rs:19 scripts/gen-fixtures.sh ok - | ||
| 194 | +fixtures crates/ec-mp3/tests/encode_matrix.rs:45 scripts/gen-fixtures.sh ok - | ||
| 195 | +fixtures crates/ec-mp4/tests/mp4.rs:19 scripts/gen-fixtures.sh ok - | ||
| 196 | +fixtures crates/ec-vorbis/tests/oracle.rs:18 scripts/gen-fixtures.sh ok - | ||
| 197 | +fixtures/golden3-pin.obu (named absent pin) absent pin -- gate is #[ignore]d; no encoder recipe recorded absent-pin - | ||
| 198 | +fixtures/golden4-pin.obu crates/ec-av1/src/stream.rs:22046 none (prose provenance only) ok 1754023e44e46edaebc2c05065bf1c65db1a41354577cbf71c0e8ebe737ae14a | ||
| 199 | +fixtures/golden6-mismatch.obu crates/ec-av1/src/stream.rs:31517 none (prose provenance only) ok c56909b98542192b03f3a945e153475aa57a58a1586bf166513297296cb225b3 | ||
| 200 | +fixtures/golden7-forwarding-mismatch.obu crates/ec-av1/src/stream.rs:22083 none (prose provenance only) ok 81b3bf657a85e95085287b30d97dee93ba5aea0ed1db1e1f4fcd19a06afc17be | ||
| 201 | +fixtures/ll444-lossless-key.obu (named absent pin) absent pin -- gate a_real_aomenc_lossless_444_key_frame (converted to an EC_REQUIRE_FIXTURES hard fail; pin never committed) absent-pin - | ||
| 202 | +fixtures/lr-sgr-r7.obu crates/ec-av1/src/stream.rs:28582 none (prose provenance only) ok 6b95b20e3377430ffae0b2ce86fad9502e0dedf13cd6c38ab7f5af4a8b21f33d | ||
| 203 | +fixtures/sbpart-pin.obu (named absent pin) absent pin -- gate is #[ignore]d; no encoder recipe recorded absent-pin - | ||
| 204 | +fixtures/stills crates/ec-image/tests/differential.rs:24 scripts/gen-fixtures.sh ok - | ||
| 205 | +fixtures/stills crates/ec-image/tests/fuzz.rs:15 scripts/gen-fixtures.sh ok - | ||
| 206 | +fixtures/subs crates/ec-subs/tests/real_library.rs:15 scripts/gen-fixtures.sh ok - | ||
| 207 | +fixtures/subs/real.ass crates/ec-subs/tests/real_library.rs:55 scripts/gen-subtitle-fixtures.sh ok 519a838783208edd8140e7d034e6969298b66c6435594336326c6996b95b3bf6 | ||
| 208 | +fixtures/subs/real.srt crates/ec-subs/tests/real_library.rs:28 scripts/gen-subtitle-fixtures.sh ok 0b4b59d1044e78c3520c9baa265e25d3eb55decb514c61a97712beac070953c2 | ||
| 209 | +fixtures/vectors/flac-xiph/flac-test-files-main crates/ec-flac/tests/xiph_vectors.rs:50 scripts/fetch-vectors.sh ok - | ||
| 210 | +fixtures/vectors/h264-jvt crates/ec-h264/tests/conformance.rs:68 scripts/fetch-vectors.sh ok - | ||
| 211 | +fixtures/vectors/opus-rfc6716/opus_testvectors crates/ec-opus/tests/conformance.rs:87 scripts/fetch-vectors.sh ok - | ||
| 212 | +fixtures/video crates/ec-av1/src/encode.rs:20484 scripts/gen-fixtures.sh ok - | ||
| 213 | +fixtures/video/h264-1080p-23.976-8bit.mp4 crates/ec-av1/src/encoder.rs:3263 scripts/gen-fixtures.sh ok db7275c361b07985088e80337a6c8c144d232d12f4d57cb84645effe27195784 | ||
| 214 | +fixtures/video/h264-1080p-23.976-8bit.mp4 crates/ec-av1/src/encoder.rs:6032 scripts/gen-fixtures.sh ok db7275c361b07985088e80337a6c8c144d232d12f4d57cb84645effe27195784 | ||
| 215 | +fixtures/video/h264-1080p-23.976-8bit.mp4 crates/ec-av1/src/encode.rs:20335 scripts/gen-fixtures.sh ok db7275c361b07985088e80337a6c8c144d232d12f4d57cb84645effe27195784 | ||
| 216 | +fixtures/video/h264-1080p-23.976-8bit.mp4 crates/ec-av1/src/encode.rs:20400 scripts/gen-fixtures.sh ok db7275c361b07985088e80337a6c8c144d232d12f4d57cb84645effe27195784 | ||
| 217 | +fixtures/video/h264-1080p-23.976-8bit.mp4 crates/ec-av1/src/encode.rs:20480 scripts/gen-fixtures.sh ok db7275c361b07985088e80337a6c8c144d232d12f4d57cb84645effe27195784 | ||
| 218 | +fixtures/video/h264-1080p-23.976-8bit.mp4 crates/ec-av1/src/encode.rs:20903 scripts/gen-fixtures.sh ok db7275c361b07985088e80337a6c8c144d232d12f4d57cb84645effe27195784 | ||
| 219 | +fixtures/video/h264-1080p-23.976-8bit.mp4 crates/ec-av1/src/encode.rs:21258 scripts/gen-fixtures.sh ok db7275c361b07985088e80337a6c8c144d232d12f4d57cb84645effe27195784 | ||
| 220 | +fixtures/video/h264-1080p-23.976-8bit.mp4 crates/ec-av1/src/encode.rs:21557 scripts/gen-fixtures.sh ok db7275c361b07985088e80337a6c8c144d232d12f4d57cb84645effe27195784 | ||
| 221 | +fixtures/video/h264-1080p-23.976-8bit.mp4 crates/ec-av1/src/encode.rs:22117 scripts/gen-fixtures.sh ok db7275c361b07985088e80337a6c8c144d232d12f4d57cb84645effe27195784 | ||
| 222 | +fixtures/video/h264-1080p-23.976-8bit.mp4 crates/ec-av1/src/encode.rs:22661 scripts/gen-fixtures.sh ok db7275c361b07985088e80337a6c8c144d232d12f4d57cb84645effe27195784 | ||
| 223 | +fixtures/video/h264-1080p-23.976-8bit.mp4 crates/ec-av1/src/stream.rs:42809 scripts/gen-fixtures.sh ok db7275c361b07985088e80337a6c8c144d232d12f4d57cb84645effe27195784 | ||
| 224 | +fixtures/video/h264-1080p-60-8bit.mp4 crates/ec-av1/src/encode.rs:20481 scripts/gen-fixtures.sh ok - | ||
| 225 | +fixtures/video/h264-2160p-23.976-8bit.mp4 crates/ec-av1/src/encode.rs:21259 scripts/gen-fixtures.sh ok - | ||
| 226 | +fixtures/video/h264-2160p-23.976-8bit.mp4 crates/ec-av1/src/encode.rs:21558 scripts/gen-fixtures.sh ok - | ||
| 227 | +fixtures/video/h264-2160p-23.976-8bit.mp4 crates/ec-av1/src/encode.rs:22118 scripts/gen-fixtures.sh ok - | ||
| 228 | +fixtures/video/h264-2160p-23.976-8bit.mp4 crates/ec-av1/src/encode.rs:22662 scripts/gen-fixtures.sh ok - | ||
| 229 | +fixtures/video/h264-2160p-23.976-8bit.mp4 crates/ec-av1/src/stream.rs:6090 scripts/gen-fixtures.sh ok - | ||
| 230 | +fixtures/video/h264-open-gop.mp4 crates/ec-h264/tests/conformance.rs:2386 scripts/gen-fixtures.sh ok 0b3b316c3f786cf4cb158de1b9c81aa871b1bb0d8e2da30d451f741cacd5d0ff | ||
| 231 | +fixtures/video/h264-open-gop.mp4 crates/ec-hw/tests/gpu.rs:2793 scripts/gen-fixtures.sh ok 0b3b316c3f786cf4cb158de1b9c81aa871b1bb0d8e2da30d451f741cacd5d0ff | ||
| 232 | +fixtures/vp8/altref-160x96.ivf crates/ec-vp8/tests/keyframe_exact.rs:108 scripts/gen_vp8_fixtures.sh ok 32d610dc278e528a7d69c3543764cb000e927c6988e61ef0c4ba560e7d89b49e | ||
| 233 | +fixtures/vp8/altref-160x96.ivf crates/ec-vp8/tests/keyframe_exact.rs:110 scripts/gen_vp8_fixtures.sh ok 32d610dc278e528a7d69c3543764cb000e927c6988e61ef0c4ba560e7d89b49e | ||
| 234 | +fixtures/vp8/altref-160x96.ivf crates/ec-vp8/tests/stream_exact.rs:23 scripts/gen_vp8_fixtures.sh ok 32d610dc278e528a7d69c3543764cb000e927c6988e61ef0c4ba560e7d89b49e | ||
| 235 | +fixtures/vp8/altref-160x96.ivf crates/ec-vp8/tests/stream_exact.rs:65 scripts/gen_vp8_fixtures.sh ok 32d610dc278e528a7d69c3543764cb000e927c6988e61ef0c4ba560e7d89b49e | ||
| 236 | +fixtures/vp8/clip-obs-320x192.ivf crates/ec-vp8/tests/keyframe_exact.rs:107 scripts/gen_vp8_fixtures.sh ok e55b3dd585d6ea918cb7ffa9319e53b5e43b73db2d1db2c8b6a0ea7750e99cf2 | ||
| 237 | +fixtures/vp8/clip-obs-320x192.ivf crates/ec-vp8/tests/stream_exact.rs:24 scripts/gen_vp8_fixtures.sh ok e55b3dd585d6ea918cb7ffa9319e53b5e43b73db2d1db2c8b6a0ea7750e99cf2 | ||
| 238 | +fixtures/vp8 crates/ec-vp8/tests/ivf.rs:81 scripts/gen-fixtures.sh ok - | ||
| 239 | +fixtures/vp8/gop-160x96.ivf crates/ec-vp8/tests/header_parse.rs:114 scripts/gen_vp8_fixtures.sh ok 96a8cfbde1923df7f8df945f553cf20d0bf7088e025a2498c8910e98ffa43155 | ||
| 240 | +fixtures/vp8/gop-160x96.ivf crates/ec-vp8/tests/keyframe_exact.rs:106 scripts/gen_vp8_fixtures.sh ok 96a8cfbde1923df7f8df945f553cf20d0bf7088e025a2498c8910e98ffa43155 | ||
| 241 | +fixtures/vp8/gop-160x96.ivf crates/ec-vp8/tests/stream_exact.rs:124 scripts/gen_vp8_fixtures.sh ok 96a8cfbde1923df7f8df945f553cf20d0bf7088e025a2498c8910e98ffa43155 | ||
| 242 | +fixtures/vp8/gop-160x96.ivf crates/ec-vp8/tests/stream_exact.rs:21 scripts/gen_vp8_fixtures.sh ok 96a8cfbde1923df7f8df945f553cf20d0bf7088e025a2498c8910e98ffa43155 | ||
| 243 | +fixtures/vp8/gop-96x80-v1.ivf crates/ec-vp8/tests/stream_exact.rs:20 scripts/gen_vp8_fixtures.sh ok 5d4ed5fc0884e283de2c7508a9bcaa33e5d46a0ae10aa55dcca61bed63d5d786 | ||
| 244 | +fixtures/vp8/kf-160x96-q20.ivf crates/ec-vp8/tests/header_parse.rs:11 scripts/gen_vp8_fixtures.sh ok dd4ff6bd44711c98356687867fd724bd8ce5fc5e0f7262d993c31dffd58b438a | ||
| 245 | +fixtures/vp8/kf-160x96-q20.ivf crates/ec-vp8/tests/keyframe_exact.rs:82 scripts/gen_vp8_fixtures.sh ok dd4ff6bd44711c98356687867fd724bd8ce5fc5e0f7262d993c31dffd58b438a | ||
| 246 | +fixtures/vp8/kf-160x96-q20.ivf crates/ec-vp8/tests/stream_exact.rs:17 scripts/gen_vp8_fixtures.sh ok dd4ff6bd44711c98356687867fd724bd8ce5fc5e0f7262d993c31dffd58b438a | ||
| 247 | +fixtures/vp8/kf-160x96-q40.ivf crates/ec-vp8/tests/header_parse.rs:12 scripts/gen_vp8_fixtures.sh ok d079b3ee1c16c2b566f31c9bd57aa0a1af7b4a9fd13d555b0581d1e8d84f9ab2 | ||
| 248 | +fixtures/vp8/kf-160x96-q40.ivf crates/ec-vp8/tests/keyframe_exact.rs:83 scripts/gen_vp8_fixtures.sh ok d079b3ee1c16c2b566f31c9bd57aa0a1af7b4a9fd13d555b0581d1e8d84f9ab2 | ||
| 249 | +fixtures/vp8/kf-160x96-q40.ivf crates/ec-vp8/tests/stream_exact.rs:18 scripts/gen_vp8_fixtures.sh ok d079b3ee1c16c2b566f31c9bd57aa0a1af7b4a9fd13d555b0581d1e8d84f9ab2 | ||
| 250 | +fixtures/vp8/kf-16x16-black-q0.ivf crates/ec-vp8/tests/stream_exact.rs:13 scripts/gen_vp8_fixtures.sh ok 1e95a39ffe58f3046f675412c51bfbdc17344ff10c47ee0af3ca4b382022f43e | ||
| 251 | +fixtures/vp8/kf-172x144-q25.ivf crates/ec-vp8/tests/header_parse.rs:15 scripts/gen_vp8_fixtures.sh ok 4e29b24c86091051381a877d17a68a3195e44f65cc9ed1e01311e6e72d8d249d | ||
| 252 | +fixtures/vp8/kf-172x144-q25.ivf crates/ec-vp8/tests/keyframe_exact.rs:86 scripts/gen_vp8_fixtures.sh ok 4e29b24c86091051381a877d17a68a3195e44f65cc9ed1e01311e6e72d8d249d | ||
| 253 | +fixtures/vp8/kf-172x144-q25.ivf crates/ec-vp8/tests/stream_exact.rs:19 scripts/gen_vp8_fixtures.sh ok 4e29b24c86091051381a877d17a68a3195e44f65cc9ed1e01311e6e72d8d249d | ||
| 254 | +fixtures/vp8/kf-32x16-q35.ivf crates/ec-vp8/tests/header_parse.rs:14 scripts/gen_vp8_fixtures.sh ok 3d9bad9c985539ac24fb2f58b34d064b42e2e736584a2a250fccf0233a9c9eb3 | ||
| 255 | +fixtures/vp8/kf-32x16-q35.ivf crates/ec-vp8/tests/keyframe_exact.rs:85 scripts/gen_vp8_fixtures.sh ok 3d9bad9c985539ac24fb2f58b34d064b42e2e736584a2a250fccf0233a9c9eb3 | ||
| 256 | +fixtures/vp8/kf-32x16-q35.ivf crates/ec-vp8/tests/stream_exact.rs:14 scripts/gen_vp8_fixtures.sh ok 3d9bad9c985539ac24fb2f58b34d064b42e2e736584a2a250fccf0233a9c9eb3 | ||
| 257 | +fixtures/vp8/kf-76x52-q30.ivf crates/ec-vp8/tests/header_parse.rs:13 scripts/gen_vp8_fixtures.sh ok 15d05cb9ebd6bbfd4d8519b30256b28f2f55738754f68f00afef1cae9e66ad3a | ||
| 258 | +fixtures/vp8/kf-76x52-q30.ivf crates/ec-vp8/tests/keyframe_exact.rs:84 scripts/gen_vp8_fixtures.sh ok 15d05cb9ebd6bbfd4d8519b30256b28f2f55738754f68f00afef1cae9e66ad3a | ||
| 259 | +fixtures/vp8/kf-76x52-q30.ivf crates/ec-vp8/tests/stream_exact.rs:15 scripts/gen_vp8_fixtures.sh ok 15d05cb9ebd6bbfd4d8519b30256b28f2f55738754f68f00afef1cae9e66ad3a | ||
| 260 | +fixtures/vp8/kf-96x80-q63.ivf crates/ec-vp8/tests/header_parse.rs:16 scripts/gen_vp8_fixtures.sh ok 9c6052448106ad6adf84e905be881815befb3d45abf80bc3c8b17507c324555e | ||
| 261 | +fixtures/vp8/kf-96x80-q63.ivf crates/ec-vp8/tests/keyframe_exact.rs:87 scripts/gen_vp8_fixtures.sh ok 9c6052448106ad6adf84e905be881815befb3d45abf80bc3c8b17507c324555e | ||
| 262 | +fixtures/vp8/kf-96x80-q63.ivf crates/ec-vp8/tests/stream_exact.rs:16 scripts/gen_vp8_fixtures.sh ok 9c6052448106ad6adf84e905be881815befb3d45abf80bc3c8b17507c324555e | ||
| 263 | +fixtures/vp8/mparts-160x96.ivf crates/ec-vp8/tests/header_parse.rs:17 scripts/gen_vp8_fixtures.sh ok eb656c9e4547ad99bfe5a3a4ce5bf9c54daa4ba657fb7c3327d448a059760282 | ||
| 264 | +fixtures/vp8/mparts-160x96.ivf crates/ec-vp8/tests/header_parse.rs:81 scripts/gen_vp8_fixtures.sh ok eb656c9e4547ad99bfe5a3a4ce5bf9c54daa4ba657fb7c3327d448a059760282 | ||
| 265 | +fixtures/vp8/mparts-160x96.ivf crates/ec-vp8/tests/keyframe_exact.rs:95 scripts/gen_vp8_fixtures.sh ok eb656c9e4547ad99bfe5a3a4ce5bf9c54daa4ba657fb7c3327d448a059760282 | ||
| 266 | +fixtures/vp8/mparts-160x96.ivf crates/ec-vp8/tests/stream_exact.rs:22 scripts/gen_vp8_fixtures.sh ok eb656c9e4547ad99bfe5a3a4ce5bf9c54daa4ba657fb7c3327d448a059760282 | ||
| 267 | +fixtures/vp9 crates/ec-vp9/tests/keyframe_exact.rs:116 scripts/gen-fixtures.sh ok - | ||
| 268 | +fixtures/vp9 crates/ec-vp9/tests/scratch_hdr.rs:7 scripts/gen-fixtures.sh ok - | ||
| 269 | +fixtures/vp9/key-320.ivf crates/ec-vp9/tests/dump_probe.rs:11 scripts/gen-fixtures.sh ok bcd5a1df6c944a79b1f52cfe669e7c12f7f9b84ffbec8d3daf33475c4a0b7e67 | ||
| 270 | +fixtures/vp9/key-320.ivf crates/ec-vp9/tests/dump_probe.rs:6 scripts/gen-fixtures.sh ok bcd5a1df6c944a79b1f52cfe669e7c12f7f9b84ffbec8d3daf33475c4a0b7e67 | ||
| 271 | +fixtures/vp9/key-320.ivf crates/ec-vp9/tests/keyframe_exact.rs:117 scripts/gen-fixtures.sh ok bcd5a1df6c944a79b1f52cfe669e7c12f7f9b84ffbec8d3daf33475c4a0b7e67 | ||
| 272 | +fixtures/vp9/key-320.ivf crates/ec-vp9/tests/scratch_hdr.rs:4 scripts/gen-fixtures.sh ok bcd5a1df6c944a79b1f52cfe669e7c12f7f9b84ffbec8d3daf33475c4a0b7e67 | ||
| 273 | +fixtures/vp9/key-320.ivf crates/ec-vp9/tests/scratch_lfdump.rs:22 scripts/gen-fixtures.sh ok bcd5a1df6c944a79b1f52cfe669e7c12f7f9b84ffbec8d3daf33475c4a0b7e67 | ||
| 274 | +fixtures/vp9/key-320.ivf crates/ec-vp9/tests/scratch_tok.rs:11 scripts/gen-fixtures.sh ok bcd5a1df6c944a79b1f52cfe669e7c12f7f9b84ffbec8d3daf33475c4a0b7e67 | ||
| 275 | +fixtures/vp9/lossless-64.ivf crates/ec-vp9/tests/keyframe_exact.rs:125 scripts/gen-fixtures.sh ok 2cf9473fa47ec47f7ab94d77640aa0d58494edacc72cf151a784a76283c55147 | ||
| 276 | +fixtures/vp9/lossless-64.ivf crates/ec-vp9/tests/scratch_bool.rs:7 scripts/gen-fixtures.sh ok 2cf9473fa47ec47f7ab94d77640aa0d58494edacc72cf151a784a76283c55147 | ||
| 277 | +fixtures/vp9/lossless-64.ivf crates/ec-vp9/tests/scratch_hdr2.rs:6 scripts/gen-fixtures.sh ok 2cf9473fa47ec47f7ab94d77640aa0d58494edacc72cf151a784a76283c55147 | ||
| 278 | +fixtures/vp9/lossless-64.ivf crates/ec-vp9/tests/scratch_hdr.rs:4 scripts/gen-fixtures.sh ok 2cf9473fa47ec47f7ab94d77640aa0d58494edacc72cf151a784a76283c55147 | ||
| 279 | +fixtures/vp9/lossless-64.ivf crates/ec-vp9/tests/scratch_lossless.rs:6 scripts/gen-fixtures.sh ok 2cf9473fa47ec47f7ab94d77640aa0d58494edacc72cf151a784a76283c55147 | ||
| 280 | +fixtures/vp9/lossless-64.ivf crates/ec-vp9/tests/scratch_sweep.rs:8 scripts/gen-fixtures.sh ok 2cf9473fa47ec47f7ab94d77640aa0d58494edacc72cf151a784a76283c55147 | ||
scripts/gen-fixture-library.shadded+257 -0
| @@ -0,0 +1,257 @@ | |||
| 1 | +#!/usr/bin/env bash | ||
| 2 | +# gen-fixture-library.sh — GENERATE scripts/fixture-library.tsv from source. | ||
| 3 | +# | ||
| 4 | +# The tsv is committed output, never hand-typed. Regenerate with: | ||
| 5 | +# scripts/gen-fixture-library.sh && git diff --exit-code scripts/fixture-library.tsv | ||
| 6 | +# so drift between "what the tests reach for" and "the manifest" is a | ||
| 7 | +# one-command diff. `scripts/verify-fixture-library.sh` runs that same diff as | ||
| 8 | +# part of its exit status. | ||
| 9 | +# | ||
| 10 | +# COLUMNS (tab separated) | ||
| 11 | +# 1 path repo-relative; `fixtures/...` is relative to $EC_FIXTURES | ||
| 12 | +# 2 required-by file:line of every reference (one row per reference) | ||
| 13 | +# 3 provenance the script/recipe that reproduces the bytes, or | ||
| 14 | +# `none (prose provenance only)` — a FINDING, not a | ||
| 15 | +# placeholder: a pinned fixture claim must cite the | ||
| 16 | +# originating encoder program and the artifact sha256, or the | ||
| 17 | +# pin is unreproducible (the IVF-container drift incident is | ||
| 18 | +# why that rule exists) | ||
| 19 | +# 4 status ok | missing | empty-dir | absent-pin | ||
| 20 | +# 5 sha256 of the artefact, when it is a regular file under 4 MiB | ||
| 21 | +# | ||
| 22 | +# ENUMERATION SHAPES the scan is derived from: | ||
| 23 | +# CARGO_MANIFEST_DIR env!("CARGO_MANIFEST_DIR") / concat!(env!(...)) | ||
| 24 | +# concat!(env!( a fixture root assembled from the manifest dir | ||
| 25 | +# include_bytes! include_bytes!/include_str! argument literals | ||
| 26 | +# "fixtures/ any string literal naming the fixture tree | ||
| 27 | +# ../../fixtures crate-relative literals (CWD is the crate dir) | ||
| 28 | +# Path::new( Path::new("...") argument literals | ||
| 29 | +# fs::read fs::read / read_dir / File::open argument literals | ||
| 30 | +# | ||
| 31 | +# TWO PASSES: | ||
| 32 | +# 1. fixture-root / fixture-path literals -> the row is the literal itself. | ||
| 33 | +# 2. bare media-file literals ("aac-adts-5.1-44100.aac", "entry-tx3g.mp4") | ||
| 34 | +# joined onto each fixture directory literal seen in the SAME file, then | ||
| 35 | +# onto the standard top-level library directories. Only joins that | ||
| 36 | +# resolve are emitted; unresolved names are counted in the header as the | ||
| 37 | +# declared blind spot. | ||
| 38 | +# | ||
| 39 | +# BLIND SPOT (honest: this is a preflight, not a proof). The scan is literal- | ||
| 40 | +# and grep-derived, so it cannot see a path assembled at runtime from a value | ||
| 41 | +# that is not a literal in the same file -- a vector name read from | ||
| 42 | +# scripts/vectors.sha256, a row from fixtures/real-library-manifest.tsv, a | ||
| 43 | +# format! interpolation, a name in a table. For those, the parent DIRECTORY is | ||
| 44 | +# still enumerated, and the verifier requires every listed directory to exist | ||
| 45 | +# AND be non-empty -- that is what catches the "three hosts whose fixture | ||
| 46 | +# libraries differed" class. A single missing member of a runtime-named corpus | ||
| 47 | +# shows up as a regeneration diff, not as a resolve failure. | ||
| 48 | + | ||
| 49 | +set -uo pipefail | ||
| 50 | + | ||
| 51 | +ROOT=$(cd -- "$(dirname -- "$0")/.." && pwd) | ||
| 52 | +OUT=${1:-$ROOT/scripts/fixture-library.tsv} | ||
| 53 | +FIXTURES=${EC_FIXTURES:-$ROOT/fixtures} | ||
| 54 | + | ||
| 55 | +MEDIA_RE='\.(mp4|m4a|m4s|m4v|mkv|ivf|obu|flac|opus|ogg|oga|webm|265|264|h264|h265|hevc|y4m|yuv|wav|aac|ts|bin|ttml|srt|vtt|ass|json)' | ||
| 56 | + | ||
| 57 | +# Pins that are KNOWN ABSENT and must not vanish from the manifest. Each is | ||
| 58 | +# recorded as an `absent-pin` row naming the gate that wants it, so the gap is | ||
| 59 | +# visible instead of silently skipped. | ||
| 60 | +absent_pin() { | ||
| 61 | + case $1 in | ||
| 62 | + fixtures/ll444-lossless-key.obu) | ||
| 63 | + echo "absent pin -- gate a_real_aomenc_lossless_444_key_frame (converted to an EC_REQUIRE_FIXTURES hard fail; pin never committed)" ;; | ||
| 64 | + fixtures/golden3-pin.obu | fixtures/sbpart-pin.obu) | ||
| 65 | + echo "absent pin -- gate is #[ignore]d; no encoder recipe recorded" ;; | ||
| 66 | + *) return 1 ;; | ||
| 67 | + esac | ||
| 68 | +} | ||
| 69 | + | ||
| 70 | +# --- 1. collect the source files that can name a fixture ----------------- | ||
| 71 | +mapfile -t FILES < <( | ||
| 72 | + grep -rl --include='*.rs' \ | ||
| 73 | + -e 'fixtures' -e 'include_bytes!' -e 'include_str!' \ | ||
| 74 | + "$ROOT"/crates/*/tests "$ROOT"/crates/*/src 2>/dev/null | sort | ||
| 75 | +) | ||
| 76 | + | ||
| 77 | +is_fixture_literal() { # $1 = literal without quotes | ||
| 78 | + local lit=$1 | ||
| 79 | + case $lit in | ||
| 80 | + *[[:space:]]* | *'{'* | *'}'* | *'$'* | *'%'* | *'*'* | *'?'* | \ | ||
| 81 | + *'('* | *')'* | *','* | *'='* | *';'* | *':'*) return 1 ;; | ||
| 82 | + *.sh | *.py | *.md | *.tsv) return 1 ;; # a script name, not a path | ||
| 83 | + /home/* | /Users/* | /tmp/*) return 1 ;; # developer path, not the library | ||
| 84 | + esac | ||
| 85 | + [[ $lit == *fixtures* || $lit == */vectors/* ]] || return 1 | ||
| 86 | + return 0 | ||
| 87 | +} | ||
| 88 | + | ||
| 89 | +# Provenance: which script reproduces these bytes. An empty answer is a | ||
| 90 | +# finding -- committed pins whose only provenance is prose in a gate comment. | ||
| 91 | +generator_for() { # $1 = repo-relative path | ||
| 92 | + case $1 in | ||
| 93 | + fixtures/vectors/*) echo "scripts/fetch-vectors.sh" ;; | ||
| 94 | + fixtures/bitstreams/*) echo "scripts/gen-bitstream-fixtures.sh" ;; | ||
| 95 | + fixtures/stills/*) echo "scripts/gen-still-fixtures.sh" ;; | ||
| 96 | + fixtures/subs/*) echo "scripts/gen-subtitle-fixtures.sh" ;; | ||
| 97 | + fixtures/real-library-manifest.tsv) echo "scripts/scan-real-library.sh" ;; | ||
| 98 | + fixtures/vp8/*) echo "scripts/gen_vp8_fixtures.sh" ;; | ||
| 99 | + fixtures/*.obu) echo "none (prose provenance only)" ;; | ||
| 100 | + crates/*/fixtures/*.obu) echo "none (prose provenance only)" ;; | ||
| 101 | + fixtures/audio/mp3* | fixtures/audio/*mp3*) echo "scripts/gen-mp3-fixtures.sh" ;; | ||
| 102 | + *) echo "scripts/gen-fixtures.sh" ;; | ||
| 103 | + esac | ||
| 104 | +} | ||
| 105 | + | ||
| 106 | +abs_path() { # $1 = manifest path -> absolute path | ||
| 107 | + case $1 in | ||
| 108 | + fixtures/*) printf '%s\n' "$FIXTURES/${1#fixtures/}" ;; | ||
| 109 | + *) printf '%s\n' "$ROOT/$1" ;; | ||
| 110 | + esac | ||
| 111 | +} | ||
| 112 | + | ||
| 113 | +# Resolve a source literal to a manifest path. Cargo runs tests with the crate | ||
| 114 | +# directory as CWD, so `../../fixtures` and `CARGO_MANIFEST_DIR` both anchor at | ||
| 115 | +# the crate; a bare `fixtures/...` is accepted from either anchor. | ||
| 116 | +resolve() { # $1 = literal, $2 = crate dir; prints manifest path | ||
| 117 | + local lit=$1 crate=$2 base cand | ||
| 118 | + for base in "$crate" "$ROOT" "$ROOT/crates"; do | ||
| 119 | + if [ -e "$base/$lit" ]; then | ||
| 120 | + cand=$(realpath -m -- "$base/$lit") | ||
| 121 | + printf '%s\n' "${cand#"$ROOT"/}" | ||
| 122 | + return 0 | ||
| 123 | + fi | ||
| 124 | + done | ||
| 125 | + # Unresolved: normalise against the repo root so the verifier reports the | ||
| 126 | + # row loudly instead of it silently vanishing from the manifest. | ||
| 127 | + cand=$(realpath -m -- "$ROOT/$lit") | ||
| 128 | + printf '%s\n' "${cand#"$ROOT"/}" | ||
| 129 | +} | ||
| 130 | + | ||
| 131 | +row() { # $1 path, $2 required-by, $3 provenance (optional), $4 status override | ||
| 132 | + local path=$1 required_by=$2 prov=${3:-} status_override=${4:-} | ||
| 133 | + local abs status sum | ||
| 134 | + abs=$(abs_path "$path") | ||
| 135 | + if [ -n "$status_override" ]; then | ||
| 136 | + status=$status_override | ||
| 137 | + elif [ ! -e "$abs" ]; then | ||
| 138 | + status=missing | ||
| 139 | + elif [ -d "$abs" ] && [ -z "$(ls -A -- "$abs" 2>/dev/null)" ]; then | ||
| 140 | + status=empty-dir | ||
| 141 | + else | ||
| 142 | + status=ok | ||
| 143 | + fi | ||
| 144 | + if [ -z "$prov" ]; then prov=$(generator_for "$path"); fi | ||
| 145 | + if [ -f "$abs" ] && [ "$(stat -c %s -- "$abs")" -lt 4194304 ]; then | ||
| 146 | + sum=$(sha256sum -- "$abs" | cut -d' ' -f1) | ||
| 147 | + else | ||
| 148 | + sum='-' | ||
| 149 | + fi | ||
| 150 | + printf '%s\t%s\t%s\t%s\t%s\n' "$path" "$required_by" "$prov" "$status" "$sum" | ||
| 151 | +} | ||
| 152 | + | ||
| 153 | +tmp=$(mktemp) | ||
| 154 | +trap 'rm -f "$tmp"' EXIT | ||
| 155 | +unnamed=0 | ||
| 156 | +seen_absent=() | ||
| 157 | + | ||
| 158 | +for f in "${FILES[@]}"; do | ||
| 159 | + crate=$(dirname "$(dirname "$f")") | ||
| 160 | + rel=${f#"$ROOT"/} | ||
| 161 | + file_dirs=() | ||
| 162 | + | ||
| 163 | + # Pass 1 -- fixture-root / fixture-path literals. | ||
| 164 | + while IFS= read -r hit; do | ||
| 165 | + lineno=${hit%%:*} | ||
| 166 | + lit=${hit#*:} | ||
| 167 | + lit=${lit#\"} | ||
| 168 | + lit=${lit%\"} | ||
| 169 | + is_fixture_literal "$lit" || continue | ||
| 170 | + path=$(resolve "$lit" "$crate") | ||
| 171 | + prov=$(absent_pin "$path") && { | ||
| 172 | + row "$path" "$rel:$lineno" "$prov" absent-pin >>"$tmp" | ||
| 173 | + seen_absent+=("$path") | ||
| 174 | + continue | ||
| 175 | + } | ||
| 176 | + row "$path" "$rel:$lineno" >>"$tmp" | ||
| 177 | + [ -d "$(abs_path "$path")" ] && file_dirs+=("$path") | ||
| 178 | + done < <(grep -noE '"[^"]*"' "$f") | ||
| 179 | + | ||
| 180 | + # Pass 2 -- bare media names joined onto this file's fixture directories, | ||
| 181 | + # then onto the standard top-level library directories (a file may name | ||
| 182 | + # its corpus directory in a helper module rather than in this file). | ||
| 183 | + for d in audio video bitstreams subs stills realworld vp8 vp9 hbd-r5; do | ||
| 184 | + [ -d "$FIXTURES/$d" ] && file_dirs+=("fixtures/$d") | ||
| 185 | + done | ||
| 186 | + ((${#file_dirs[@]})) || continue | ||
| 187 | + while IFS= read -r hit; do | ||
| 188 | + lineno=${hit%%:*} | ||
| 189 | + name=${hit#*:} | ||
| 190 | + name=${name#\"} | ||
| 191 | + name=${name%\"} | ||
| 192 | + for d in "${file_dirs[@]}"; do | ||
| 193 | + if [ -e "$(abs_path "$d/$name")" ]; then | ||
| 194 | + row "$d/$name" "$rel:$lineno" >>"$tmp" | ||
| 195 | + continue 2 | ||
| 196 | + fi | ||
| 197 | + done | ||
| 198 | + unnamed=$((unnamed + 1)) | ||
| 199 | + done < <(grep -noE '"[^"/]*'"$MEDIA_RE"'"' "$f") | ||
| 200 | +done | ||
| 201 | + | ||
| 202 | +# Pass 3 -- committed pins that NO source literal reaches. A committed | ||
| 203 | +# fixture nothing references is either dead weight or a reference built at | ||
| 204 | +# runtime from a name the grep cannot see; either way it must be a row, not a | ||
| 205 | +# gap. Scanned over the crate-local committed pin directories. | ||
| 206 | +orphans=0 | ||
| 207 | +while IFS= read -r pin; do | ||
| 208 | + [ -n "$pin" ] || continue | ||
| 209 | + if ! grep -qP "^\Q$pin\E\t" "$tmp"; then | ||
| 210 | + row "$pin" "(committed pin: NO source reference found)" \ | ||
| 211 | + "none (prose provenance only)" >>"$tmp" | ||
| 212 | + orphans=$((orphans + 1)) | ||
| 213 | + fi | ||
| 214 | +done < <(find "$ROOT"/crates/*/fixtures -maxdepth 1 -type f 2>/dev/null | | ||
| 215 | + sed "s#^$ROOT/##" | sort) | ||
| 216 | + | ||
| 217 | +# Known-absent pins that no source literal reached still belong in the | ||
| 218 | +# manifest: a missing pin must be a row, not a gap. | ||
| 219 | +for p in fixtures/ll444-lossless-key.obu fixtures/golden3-pin.obu fixtures/sbpart-pin.obu; do | ||
| 220 | + grep -qP "^\Q$p\E\t" "$tmp" && continue | ||
| 221 | + row "$p" "(named absent pin)" "$(absent_pin "$p")" absent-pin >>"$tmp" | ||
| 222 | +done | ||
| 223 | + | ||
| 224 | +# Which tests consume the fetched vector sets, and does anything need the | ||
| 225 | +# .tar.gz blobs? The fleet sync excluded them deliberately, so a test that | ||
| 226 | +# wanted a blob would be red on three hosts for a reason nobody wrote down. | ||
| 227 | +vector_consumers=$(awk -F'\t' '$1 ~ /^fixtures\/vectors\// {split($2,a,":"); print a[1]}' "$tmp" | sort -u | tr '\n' ' ') | ||
| 228 | +blob_users=$(grep -rl --include='*.rs' '\.tar\.gz' "$ROOT"/crates 2>/dev/null | tr '\n' ' ') | ||
| 229 | + | ||
| 230 | +{ | ||
| 231 | + cat <<EOF | ||
| 232 | +# GENERATED by scripts/gen-fixture-library.sh -- do not hand-edit. | ||
| 233 | +# Regenerate: scripts/gen-fixture-library.sh | ||
| 234 | +# Verify: scripts/verify-fixture-library.sh | ||
| 235 | +# path <TAB> required-by file:line <TAB> provenance <TAB> status <TAB> sha256 | ||
| 236 | +# | ||
| 237 | +# Enumeration is grep-derived. It cannot see a fixture name that is not a | ||
| 238 | +# string literal in the same file (manifest rows, vectors.sha256 names, | ||
| 239 | +# format! interpolation); such names are only covered through their parent | ||
| 240 | +# directory, which the verifier requires to exist AND be non-empty. | ||
| 241 | +# $unnamed media-name literal(s) in this tree resolved under no enumerated | ||
| 242 | +# fixture directory and are therefore not listed individually. | ||
| 243 | +# | ||
| 244 | +# ROOT FIXTURE ROOT: $FIXTURES | ||
| 245 | +# | ||
| 246 | +# VECTORS consumers (fixtures/vectors/*): ${vector_consumers:-none} | ||
| 247 | +# VECTORS .tar.gz blob referenced by: ${blob_users:-nothing} | ||
| 248 | +# The three fleet hosts carry the EXTRACTED vector sets (~470 files) and the | ||
| 249 | +# sync deliberately excluded the .tar.gz blobs; nothing in crates/ reads a | ||
| 250 | +# blob, so the extracted directories are the whole requirement. | ||
| 251 | +# Unreferenced committed pins carried as rows: $orphans | ||
| 252 | +EOF | ||
| 253 | + sort -u "$tmp" | ||
| 254 | +} >"$OUT" | ||
| 255 | + | ||
| 256 | +rows=$(grep -cv '^#' "$OUT") | ||
| 257 | +echo "gen-fixture-library: $rows rows -> ${OUT#"$ROOT"/} ($unnamed unnamed media literals, $orphans unreferenced committed pins)" >&2 | ||
scripts/verify-fixture-library.shadded+183 -0
| @@ -0,0 +1,183 @@ | |||
| 1 | +#!/usr/bin/env bash | ||
| 2 | +# verify-fixture-library.sh — preflight: does the on-disk fixture library match | ||
| 3 | +# what the tests actually reach for? | ||
| 4 | +# | ||
| 5 | +# CHECKS | ||
| 6 | +# SHAPE the manifest exists, is non-empty, and every row has 5 columns | ||
| 7 | +# RESOLVE every referenced path exists, and every referenced DIRECTORY is | ||
| 8 | +# non-empty (a present-but-empty corpus is the same false green as | ||
| 9 | +# an absent one) | ||
| 10 | +# DRIFT regenerating the manifest from source reproduces the committed | ||
| 11 | +# file -- so a host whose library is behind the code fails here | ||
| 12 | +# instead of reporting a green suite full of SKIPs | ||
| 13 | +# | ||
| 14 | +# TWO FAILURE MODES ARE DISTINGUISHED, because they have different fixes: | ||
| 15 | +# (i) the fixture ROOT itself is absent. Root `fixtures/` is .gitignore:2, | ||
| 16 | +# so no linked worktree ever has it: every vector gate skips GREEN in | ||
| 17 | +# every worktree run. Fix: link or provision the library, not the code. | ||
| 18 | +# (ii) a path under a PRESENT root is absent (or an empty dir). Fix: the | ||
| 19 | +# generator named in the row, or the pin is genuinely missing. | ||
| 20 | +# | ||
| 21 | +# ENFORCEMENT ENV: EC_REQUIRE_FIXTURES=1 -- the same env the per-crate | ||
| 22 | +# `require_fixture` asserts honour, so one convention covers the fleet batch | ||
| 23 | +# units and a local run: | ||
| 24 | +# set -> any absent referenced path is RED, and the drift diff is RED | ||
| 25 | +# unset -> the same findings are printed SKIP-shaped and the exit stays 0, | ||
| 26 | +# so an unprepared local checkout is not blocked | ||
| 27 | +# | ||
| 28 | +# Usage: scripts/verify-fixture-library.sh | ||
| 29 | +# Env: EC_FIXTURES=<dir> fixture root, as every generator takes | ||
| 30 | +# EC_REQUIRE_FIXTURES=1|0 enforcement (see above) | ||
| 31 | +# | ||
| 32 | +# ENUMERATION BLIND SPOT: the scan is grep-derived, so a fixture name that is | ||
| 33 | +# not a string literal in the same file (a row of | ||
| 34 | +# fixtures/real-library-manifest.tsv, a name in scripts/vectors.sha256, a | ||
| 35 | +# format! interpolation) is not enumerated individually. Its parent directory | ||
| 36 | +# is, and RESOLVE requires that directory to exist and be non-empty. This is a | ||
| 37 | +# preflight against silent drift, not a proof that every byte a test reads is | ||
| 38 | +# present. | ||
| 39 | + | ||
| 40 | +set -uo pipefail | ||
| 41 | + | ||
| 42 | +ROOT=$(cd -- "$(dirname -- "$0")/.." && pwd) | ||
| 43 | +MANIFEST=$ROOT/scripts/fixture-library.tsv | ||
| 44 | +FIXTURES=${EC_FIXTURES:-$ROOT/fixtures} | ||
| 45 | +REQUIRE=${EC_REQUIRE_FIXTURES:-0} | ||
| 46 | +LINK_SCRIPT=$ROOT/scripts/link-fixtures.sh | ||
| 47 | + | ||
| 48 | +fail=0 | ||
| 49 | +note() { [ "$REQUIRE" = 0 ] || echo "$@"; } | ||
| 50 | + | ||
| 51 | +echo "verify-fixture-library: root=$ROOT fixtures=$FIXTURES EC_REQUIRE_FIXTURES=${REQUIRE:-0}" | ||
| 52 | + | ||
| 53 | +# --- SHAPE --------------------------------------------------------------- | ||
| 54 | +if [ ! -f "$MANIFEST" ]; then | ||
| 55 | + echo "FAIL: $MANIFEST is missing -- run scripts/gen-fixture-library.sh" >&2 | ||
| 56 | + exit 1 | ||
| 57 | +fi | ||
| 58 | +rows=$(grep -cv '^#' "$MANIFEST") | ||
| 59 | +if [ "$rows" -eq 0 ]; then | ||
| 60 | + echo "FAIL: $MANIFEST has no rows" >&2 | ||
| 61 | + exit 1 | ||
| 62 | +fi | ||
| 63 | +malformed=$(awk -F'\t' '!/^#/ && NF != 5 { print NR": "$0 }' "$MANIFEST") | ||
| 64 | +if [ -n "$malformed" ]; then | ||
| 65 | + echo "FAIL: malformed rows in $MANIFEST (want 5 tab-separated columns):" >&2 | ||
| 66 | + echo "$malformed" >&2 | ||
| 67 | + exit 1 | ||
| 68 | +fi | ||
| 69 | +note " shape: $rows rows" | ||
| 70 | + | ||
| 71 | +# --- ROOT MODE (i) -------------------------------------------------------- | ||
| 72 | +root_present=1 | ||
| 73 | +[ -d "$FIXTURES" ] || root_present=0 | ||
| 74 | +if [ "$root_present" -eq 0 ]; then | ||
| 75 | + tag=SKIP | ||
| 76 | + [ "$REQUIRE" != 0 ] && tag=FAIL | ||
| 77 | + echo "$tag [mode i]: fixture root $FIXTURES does not exist." >&2 | ||
| 78 | + echo " Root fixtures/ is .gitignore:2, so a linked worktree never has it --" >&2 | ||
| 79 | + echo " that is why the vector gates skip GREEN here. Fix the TREE, not the" >&2 | ||
| 80 | + echo " code: provision the library, or run the fixture-linking script once" >&2 | ||
| 81 | + if [ -x "$LINK_SCRIPT" ]; then | ||
| 82 | + echo " it lands: $LINK_SCRIPT" | ||
| 83 | + else | ||
| 84 | + echo " it exists (scripts/link-fixtures.sh -- another lane; not in this tree yet)." | ||
| 85 | + fi | ||
| 86 | + [ "$REQUIRE" != 0 ] && fail=1 | ||
| 87 | +fi | ||
| 88 | + | ||
| 89 | +# --- RESOLVE -------------------------------------------------------------- | ||
| 90 | +missing=() | ||
| 91 | +empty=() | ||
| 92 | +while IFS=$'\t' read -r path required_by provenance status sum; do | ||
| 93 | + case $path in | ||
| 94 | + \#* | '') continue ;; | ||
| 95 | + esac | ||
| 96 | + [ "$status" = absent-pin ] && continue # known gap, reported as a finding | ||
| 97 | + case $path in | ||
| 98 | + fixtures/*) abs=$FIXTURES/${path#fixtures/} ;; | ||
| 99 | + *) abs=$ROOT/$path ;; | ||
| 100 | + esac | ||
| 101 | + if [ ! -e "$abs" ]; then | ||
| 102 | + missing+=("$path <- $required_by (provenance: $provenance)") | ||
| 103 | + elif [ -d "$abs" ] && [ -z "$(ls -A -- "$abs" 2>/dev/null)" ]; then | ||
| 104 | + empty+=("$path <- $required_by (provenance: $provenance)") | ||
| 105 | + fi | ||
| 106 | +done <"$MANIFEST" | ||
| 107 | + | ||
| 108 | +if ((${#missing[@]})) && [ "$root_present" -eq 1 ]; then | ||
| 109 | + if [ "$REQUIRE" != 0 ]; then | ||
| 110 | + echo "FAIL [mode ii]: ${#missing[@]} referenced fixture path(s) do not resolve," >&2 | ||
| 111 | + echo " inside a tree that HAS a fixture root -- the generator or the pin is" >&2 | ||
| 112 | + echo " genuinely missing:" >&2 | ||
| 113 | + printf ' %s\n' "${missing[@]}" >&2 | ||
| 114 | + fail=1 | ||
| 115 | + else | ||
| 116 | + echo "SKIP: ${#missing[@]} referenced fixture path(s) do not resolve" >&2 | ||
| 117 | + echo " (EC_REQUIRE_FIXTURES unset, so this is reported, not failed):" >&2 | ||
| 118 | + printf ' %s\n' "${missing[@]}" >&2 | ||
| 119 | + fi | ||
| 120 | +fi | ||
| 121 | +if ((${#empty[@]})); then | ||
| 122 | + if [ "$REQUIRE" != 0 ]; then | ||
| 123 | + echo "FAIL [mode ii]: ${#empty[@]} referenced fixture DIRECTORY(ies) exist but are empty:" >&2 | ||
| 124 | + printf ' %s\n' "${empty[@]}" >&2 | ||
| 125 | + fail=1 | ||
| 126 | + else | ||
| 127 | + echo "SKIP: ${#empty[@]} referenced fixture DIRECTORY(ies) exist but are empty:" >&2 | ||
| 128 | + printf ' %s\n' "${empty[@]}" >&2 | ||
| 129 | + fi | ||
| 130 | +fi | ||
| 131 | +note " resolve: ${#missing[@]} missing, ${#empty[@]} empty" | ||
| 132 | + | ||
| 133 | +# --- FINDINGS (not failures, but stated) --------------------------------- | ||
| 134 | +no_prov=$(awk -F'\t' '!/^#/ && $3 ~ /^none/ {print $1}' "$MANIFEST" | sort -u) | ||
| 135 | +absent=$(awk -F'\t' '!/^#/ && $4 == "absent-pin" {print $1"\t"$3}' "$MANIFEST" | sort -u) | ||
| 136 | +if [ -n "$no_prov" ]; then | ||
| 137 | + n=$(printf '%s\n' "$no_prov" | wc -l) | ||
| 138 | + echo "FINDING: $n pinned fixture(s) have NO generator -- provenance is prose in a" >&2 | ||
| 139 | + echo " gate comment only. A pin claim must cite the originating encoder" >&2 | ||
| 140 | + echo " program and the artefact sha256 (the sha256 IS recorded in column 5):" >&2 | ||
| 141 | + printf ' %s\n' $no_prov >&2 | ||
| 142 | +fi | ||
| 143 | +if [ -n "$absent" ]; then | ||
| 144 | + echo "FINDING: $(printf '%s\n' "$absent" | wc -l) KNOWN-ABSENT pin(s), kept as rows so the gap stays visible:" >&2 | ||
| 145 | + printf ' %s\n' "$absent" >&2 | ||
| 146 | +fi | ||
| 147 | + | ||
| 148 | +# --- VECTORS ------------------------------------------------------------- | ||
| 149 | +vec_rows=$(awk -F'\t' '!/^#/ && $1 ~ /^fixtures\/vectors\//' "$MANIFEST" | wc -l) | ||
| 150 | +vec_missing=$(awk -F'\t' '!/^#/ && $1 ~ /^fixtures\/vectors\// && $4 != "ok"' "$MANIFEST" | wc -l) | ||
| 151 | +echo " vectors: $vec_rows referenced rows, $vec_missing not ok" >&2 | ||
| 152 | +echo " vectors: nothing in crates/ reads a .tar.gz; the fleet hosts carry the" >&2 | ||
| 153 | +echo " EXTRACTED sets, so the blobs are not required at test time" >&2 | ||
| 154 | + | ||
| 155 | +# --- DRIFT ---------------------------------------------------------------- | ||
| 156 | +regen=$(mktemp) | ||
| 157 | +patch=$(mktemp) | ||
| 158 | +trap 'rm -f "$regen" "$patch"' EXIT | ||
| 159 | +if ! "$ROOT/scripts/gen-fixture-library.sh" "$regen" >/dev/null 2>&1; then | ||
| 160 | + echo "FAIL: scripts/gen-fixture-library.sh did not run" >&2 | ||
| 161 | + exit 1 | ||
| 162 | +fi | ||
| 163 | +if ! diff -u "$MANIFEST" "$regen" >"$patch" 2>&1; then | ||
| 164 | + if [ "$REQUIRE" != 0 ]; then | ||
| 165 | + echo "FAIL: scripts/fixture-library.tsv is stale -- the code reaches fixtures" >&2 | ||
| 166 | + echo " this host does not have. Commit the regenerated manifest, or fetch" >&2 | ||
| 167 | + echo " the missing library. (patch follows)" >&2 | ||
| 168 | + sed -n '1,40p' "$patch" >&2 | ||
| 169 | + fail=1 | ||
| 170 | + else | ||
| 171 | + echo "SKIP: scripts/fixture-library.tsv is stale (EC_REQUIRE_FIXTURES unset, so this" >&2 | ||
| 172 | + echo " is reported, not failed). The code reaches fixtures this host lacks." >&2 | ||
| 173 | + sed -n '1,20p' "$patch" >&2 | ||
| 174 | + fi | ||
| 175 | +else | ||
| 176 | + note " drift: manifest matches the code" | ||
| 177 | +fi | ||
| 178 | + | ||
| 179 | +if [ "$fail" -ne 0 ]; then | ||
| 180 | + echo "verify-fixture-library: RED" >&2 | ||
| 181 | + exit 1 | ||
| 182 | +fi | ||
| 183 | +echo "verify-fixture-library: GREEN ($rows rows)" | ||