Merge lane-h264reallib @ 25c996b2 — real-media-library test sites reshaped to #[ignore] with fact-based reasons, plus four follow-ups
Browse files at this commit7 changed files +562 -96
- crates/ec-aac/tests/obs_real_content.rs +70 -16
- crates/ec-aac/tests/oracle.rs +10 -0
- crates/ec-aac/tests/sbr_real_library.rs +189 -63
- crates/ec-h264/tests/conformance.rs +26 -0
- crates/ec-matroska/tests/matroska.rs +49 -16
- crates/ec-probe/tests/library.rs +14 -1
- lanes/h264reallib.report.md +204 -0
crates/ec-aac/tests/obs_real_content.rsmodified+70 -16
| @@ -28,11 +28,23 @@ fn ffmpeg_decode(path: &Path, channels: usize) -> Vec<Vec<f32>> { | |||
| 28 | .args(["-v", "error", "-i"]) | 28 | .args(["-v", "error", "-i"]) |
| 29 | .arg(path) | 29 | .arg(path) |
| 30 | .args([ | 30 | .args([ |
| 31 | - "-map", "0:a:0", "-t", "10", "-f", "f32le", "-acodec", "pcm_f32le", "-", | 31 | + "-map", |
| 32 | + "0:a:0", | ||
| 33 | + "-t", | ||
| 34 | + "10", | ||
| 35 | + "-f", | ||
| 36 | + "f32le", | ||
| 37 | + "-acodec", | ||
| 38 | + "pcm_f32le", | ||
| 39 | + "-", | ||
| 32 | ]) | 40 | ]) |
| 33 | .output() | 41 | .output() |
| 34 | .expect("ffmpeg runs"); | 42 | .expect("ffmpeg runs"); |
| 35 | - assert!(out.status.success(), "{}", String::from_utf8_lossy(&out.stderr)); | 43 | + assert!( |
| 44 | + out.status.success(), | ||
| 45 | + "{}", | ||
| 46 | + String::from_utf8_lossy(&out.stderr) | ||
| 47 | + ); | ||
| 36 | let samples: Vec<f32> = out | 48 | let samples: Vec<f32> = out |
| 37 | .stdout | 49 | .stdout |
| 38 | .chunks_exact(4) | 50 | .chunks_exact(4) |
| @@ -48,7 +60,10 @@ fn ffmpeg_decode(path: &Path, channels: usize) -> Vec<Vec<f32>> { | |||
| 48 | fn extract_aac_track(path: &Path) -> Option<(Vec<u8>, Vec<Vec<u8>>)> { | 60 | fn extract_aac_track(path: &Path) -> Option<(Vec<u8>, Vec<Vec<u8>>)> { |
| 49 | let f = File::open(path).ok()?; | 61 | let f = File::open(path).ok()?; |
| 50 | let mut d = Mp4Demuxer::new(BufReader::new(f)).ok()?; | 62 | let mut d = Mp4Demuxer::new(BufReader::new(f)).ok()?; |
| 51 | - let aac = d.streams().iter().find(|s| s.params.codec == CodecId::Aac)?; | 63 | + let aac = d |
| 64 | + .streams() | ||
| 65 | + .iter() | ||
| 66 | + .find(|s| s.params.codec == CodecId::Aac)?; | ||
| 52 | let idx = aac.index; | 67 | let idx = aac.index; |
| 53 | let asc = aac.params.extradata.as_ref()?.to_vec(); | 68 | let asc = aac.params.extradata.as_ref()?.to_vec(); |
| 54 | let mut aus = Vec::new(); | 69 | let mut aus = Vec::new(); |
| @@ -90,11 +105,18 @@ fn our_decode(path: &Path) -> Option<Vec<Vec<f32>>> { | |||
| 90 | } | 105 | } |
| 91 | } | 106 | } |
| 92 | eprintln!(" {failed}/{} AUs failed", aus.len()); | 107 | eprintln!(" {failed}/{} AUs failed", aus.len()); |
| 93 | - if planes.is_empty() { None } else { Some(planes) } | 108 | + if planes.is_empty() { |
| 109 | + None | ||
| 110 | + } else { | ||
| 111 | + Some(planes) | ||
| 112 | + } | ||
| 94 | } | 113 | } |
| 95 | 114 | ||
| 96 | fn dot(a: &[f32], b: &[f32]) -> f64 { | 115 | fn dot(a: &[f32], b: &[f32]) -> f64 { |
| 97 | - a.iter().zip(b).map(|(x, y)| f64::from(*x) * f64::from(*y)).sum() | 116 | + a.iter() |
| 117 | + .zip(b) | ||
| 118 | + .map(|(x, y)| f64::from(*x) * f64::from(*y)) | ||
| 119 | + .sum() | ||
| 98 | } | 120 | } |
| 99 | 121 | ||
| 100 | fn correlation(a: &[f32], b: &[f32]) -> f64 { | 122 | fn correlation(a: &[f32], b: &[f32]) -> f64 { |
| @@ -114,14 +136,28 @@ fn correlation(a: &[f32], b: &[f32]) -> f64 { | |||
| 114 | 136 | ||
| 115 | fn best_lag_correlation(ours: &[f32], theirs: &[f32]) -> (i64, f64) { | 137 | fn best_lag_correlation(ours: &[f32], theirs: &[f32]) -> (i64, f64) { |
| 116 | const COARSE: usize = 4_096; | 138 | const COARSE: usize = 4_096; |
| 117 | - let start = ours.len().min(theirs.len()).saturating_sub(WINDOW).min(ours.len() / 4); | 139 | + let start = ours |
| 140 | + .len() | ||
| 141 | + .min(theirs.len()) | ||
| 142 | + .saturating_sub(WINDOW) | ||
| 143 | + .min(ours.len() / 4); | ||
| 118 | let slice_at = |lag: i64, len: usize| -> Option<(usize, usize)> { | 144 | let slice_at = |lag: i64, len: usize| -> Option<(usize, usize)> { |
| 119 | - let (oa, ob) = if lag >= 0 { (start, start + lag as usize) } else { (start + (-lag) as usize, start) }; | 145 | + let (oa, ob) = if lag >= 0 { |
| 120 | - if oa + len > ours.len() || ob + len > theirs.len() { None } else { Some((oa, ob)) } | 146 | + (start, start + lag as usize) |
| 147 | + } else { | ||
| 148 | + (start + (-lag) as usize, start) | ||
| 149 | + }; | ||
| 150 | + if oa + len > ours.len() || ob + len > theirs.len() { | ||
| 151 | + None | ||
| 152 | + } else { | ||
| 153 | + Some((oa, ob)) | ||
| 154 | + } | ||
| 121 | }; | 155 | }; |
| 122 | let mut coarse_best = (0i64, -1.0f64, 0.0f64); | 156 | let mut coarse_best = (0i64, -1.0f64, 0.0f64); |
| 123 | for lag in -(LAG_MAX as i64)..=(LAG_MAX as i64) { | 157 | for lag in -(LAG_MAX as i64)..=(LAG_MAX as i64) { |
| 124 | - let Some((oa, ob)) = slice_at(lag, COARSE) else { continue }; | 158 | + let Some((oa, ob)) = slice_at(lag, COARSE) else { |
| 159 | + continue; | ||
| 160 | + }; | ||
| 125 | let c = correlation(&ours[oa..oa + COARSE], &theirs[ob..ob + COARSE]); | 161 | let c = correlation(&ours[oa..oa + COARSE], &theirs[ob..ob + COARSE]); |
| 126 | if c.abs() > coarse_best.1 { | 162 | if c.abs() > coarse_best.1 { |
| 127 | coarse_best = (lag, c.abs(), c); | 163 | coarse_best = (lag, c.abs(), c); |
| @@ -129,7 +165,9 @@ fn best_lag_correlation(ours: &[f32], theirs: &[f32]) -> (i64, f64) { | |||
| 129 | } | 165 | } |
| 130 | let mut best = (coarse_best.0, -1.0f64, 0.0f64); | 166 | let mut best = (coarse_best.0, -1.0f64, 0.0f64); |
| 131 | for lag in (coarse_best.0 - 8)..=(coarse_best.0 + 8) { | 167 | for lag in (coarse_best.0 - 8)..=(coarse_best.0 + 8) { |
| 132 | - let Some((oa, ob)) = slice_at(lag, WINDOW) else { continue }; | 168 | + let Some((oa, ob)) = slice_at(lag, WINDOW) else { |
| 169 | + continue; | ||
| 170 | + }; | ||
| 133 | let c = correlation(&ours[oa..oa + WINDOW], &theirs[ob..ob + WINDOW]); | 171 | let c = correlation(&ours[oa..oa + WINDOW], &theirs[ob..ob + WINDOW]); |
| 134 | if c.abs() > best.1 { | 172 | if c.abs() > best.1 { |
| 135 | best = (lag, c.abs(), c); | 173 | best = (lag, c.abs(), c); |
| @@ -148,7 +186,13 @@ fn obs_content_table() { | |||
| 148 | eprintln!("skip: no ffmpeg"); | 186 | eprintln!("skip: no ffmpeg"); |
| 149 | return; | 187 | return; |
| 150 | } | 188 | } |
| 151 | - let dir = PathBuf::from(std::env::var("HOME").unwrap()).join("Videos/OBS"); | 189 | + // lane-h264reallib: `unwrap_or_default()` rather than a bare `unwrap()`. |
| 190 | + // A host with no HOME -- a fleet runner -- panicked here before reaching | ||
| 191 | + // the `read_dir` guard one line down, which already reports an absent | ||
| 192 | + // directory correctly. With an empty HOME the guard simply reports | ||
| 193 | + // `skip: no ./Videos/OBS`, so the test degrades to the silent skip its | ||
| 194 | + // own guard was written for instead of a red that says nothing about AAC. | ||
| 195 | + let dir = PathBuf::from(std::env::var("HOME").unwrap_or_default()).join("Videos/OBS"); | ||
| 152 | let Ok(rd) = std::fs::read_dir(&dir) else { | 196 | let Ok(rd) = std::fs::read_dir(&dir) else { |
| 153 | eprintln!("skip: no {}", dir.display()); | 197 | eprintln!("skip: no {}", dir.display()); |
| 154 | return; | 198 | return; |
| @@ -188,11 +232,21 @@ fn obs_content_table() { | |||
| 188 | let rows = &all_rows[before..]; | 232 | let rows = &all_rows[before..]; |
| 189 | let (mut pns, mut is_, mut ms, mut tns, mut cpe) = (0usize, 0usize, 0usize, 0usize, 0usize); | 233 | let (mut pns, mut is_, mut ms, mut tns, mut cpe) = (0usize, 0usize, 0usize, 0usize, 0usize); |
| 190 | for r in rows { | 234 | for r in rows { |
| 191 | - if r.pns_bands > 0 { pns += 1; } | 235 | + if r.pns_bands > 0 { |
| 192 | - if r.is_bands > 0 { is_ += 1; } | 236 | + pns += 1; |
| 193 | - if r.ms_bands > 0 { ms += 1; } | 237 | + } |
| 194 | - if r.tns_present { tns += 1; } | 238 | + if r.is_bands > 0 { |
| 195 | - if r.is_cpe { cpe += 1; } | 239 | + is_ += 1; |
| 240 | + } | ||
| 241 | + if r.ms_bands > 0 { | ||
| 242 | + ms += 1; | ||
| 243 | + } | ||
| 244 | + if r.tns_present { | ||
| 245 | + tns += 1; | ||
| 246 | + } | ||
| 247 | + if r.is_cpe { | ||
| 248 | + cpe += 1; | ||
| 249 | + } | ||
| 196 | } | 250 | } |
| 197 | eprintln!( | 251 | eprintln!( |
| 198 | " tools over {} AUs: cpe={cpe} pns_aus={pns} is_aus={is_} ms_aus={ms} tns_aus={tns}", | 252 | " tools over {} AUs: cpe={cpe} pns_aus={pns} is_aus={is_} ms_aus={ms} tns_aus={tns}", |
crates/ec-aac/tests/oracle.rsmodified+10 -0
| @@ -676,6 +676,16 @@ fn esds_asc(mp4: &[u8]) -> Option<Vec<u8>> { | |||
| 676 | 676 | ||
| 677 | /// AAC tracks from the machine's own library, not just generated fixtures: the | 677 | /// AAC tracks from the machine's own library, not just generated fixtures: the |
| 678 | /// elementary stream is copied out to ADTS and decoded both ways. | 678 | /// elementary stream is copied out to ADTS and decoded both ways. |
| 679 | +// lane-h264reallib: same shape as the ec-h264 `real_library_streams_match_ffmpeg` | ||
| 680 | +// fix, same reason. The manifest is generated by `scripts/scan-real-library.sh` | ||
| 681 | +// from `~/Videos ~/Downloads ~/Music` and is gitignored because it is | ||
| 682 | +// machine-local. The guard below makes a host with NO manifest print green | ||
| 683 | +// (nothing was checked), and a host that ran the scan but has since moved or | ||
| 684 | +// deleted files falls through to `checked >= 3` and goes red for a reason that | ||
| 685 | +// has nothing to do with the decoder. An ignore is visible in `--list` and | ||
| 686 | +// cannot go green silently, which an env gate would. | ||
| 687 | +// Run on the workstation: cargo test -p ec-aac --test oracle real_library_tracks_match_ffmpeg -- --ignored | ||
| 688 | +#[ignore = "sweeps the PERSONAL media library (~/Videos, ~/Downloads, ~/Music) through the gitignored fixtures/real-library-manifest.tsv and asserts >= 3 tracks swept; a runner host has no such library, so it is either a silent green or a red for the wrong reason. Run it on the workstation with --ignored."] | ||
| 679 | #[test] | 689 | #[test] |
| 680 | fn real_library_tracks_match_ffmpeg() { | 690 | fn real_library_tracks_match_ffmpeg() { |
| 681 | if !have_ffmpeg() { | 691 | if !have_ffmpeg() { |
crates/ec-aac/tests/sbr_real_library.rsmodified+189 -63
| @@ -437,7 +437,13 @@ fn exhaustive_lag_correlation(ours: &[f32], theirs: &[f32], lag_max: i64) -> (i6 | |||
| 437 | } | 437 | } |
| 438 | 438 | ||
| 439 | /// bucket (true if ITS coarse lag sat at the +/-`lag_max` search bound). | 439 | /// 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) { | 440 | +fn robust_lag_topk( |
| 441 | + ours: &[f32], | ||
| 442 | + theirs: &[f32], | ||
| 443 | + lag_max: i64, | ||
| 444 | + rate: u32, | ||
| 445 | + k: usize, | ||
| 446 | +) -> (i64, f64, bool) { | ||
| 441 | const COARSE: usize = 4_096; | 447 | const COARSE: usize = 4_096; |
| 442 | let start = ours | 448 | let start = ours |
| 443 | .len() | 449 | .len() |
| @@ -2111,7 +2117,10 @@ fn our_decode_core_only(path: &Path, stream_index: usize) -> Option<(Vec<Vec<f32 | |||
| 2111 | if dump && au_idx < 40 { | 2117 | if dump && au_idx < 40 { |
| 2112 | for c in 0..ch { | 2118 | for c in 0..ch { |
| 2113 | let plane: Vec<f32> = frame.samples.iter().skip(c).step_by(ch).copied().collect(); | 2119 | 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>() | 2120 | + let rms = (plane |
| 2121 | + .iter() | ||
| 2122 | + .map(|v| f64::from(*v) * f64::from(*v)) | ||
| 2123 | + .sum::<f64>() | ||
| 2115 | / plane.len().max(1) as f64) | 2124 | / plane.len().max(1) as f64) |
| 2116 | .sqrt(); | 2125 | .sqrt(); |
| 2117 | eprintln!( | 2126 | eprintln!( |
| @@ -2229,7 +2238,11 @@ fn core_only_matches_reference() { | |||
| 2229 | if at_edge { | 2238 | if at_edge { |
| 2230 | (lag, corr, at_edge) = exhaustive_lag_correlation(&ol, &tl, SEARCH_LAG_MAX); | 2239 | (lag, corr, at_edge) = exhaustive_lag_correlation(&ol, &tl, SEARCH_LAG_MAX); |
| 2231 | } | 2240 | } |
| 2232 | - let edge = if at_edge { " (AT SEARCH BOUND -- noise, not a measurement)" } else { "" }; | 2241 | + let edge = if at_edge { |
| 2242 | + " (AT SEARCH BOUND -- noise, not a measurement)" | ||
| 2243 | + } else { | ||
| 2244 | + "" | ||
| 2245 | + }; | ||
| 2233 | println!(" ch{ch}: below {cutoff:.0}Hz lag {lag}, corr {corr:.6}{edge}"); | 2246 | println!(" ch{ch}: below {cutoff:.0}Hz lag {lag}, corr {corr:.6}{edge}"); |
| 2234 | } | 2247 | } |
| 2235 | } | 2248 | } |
| @@ -2428,9 +2441,8 @@ fn synthetic_heaac_matrix() { | |||
| 2428 | eprintln!("SKIP: ffmpeg not on PATH"); | 2441 | eprintln!("SKIP: ffmpeg not on PATH"); |
| 2429 | return; | 2442 | return; |
| 2430 | } | 2443 | } |
| 2431 | - let dir = std::env::var("EC_AAC_HEAAC_FIXTURES").unwrap_or_else(|_| { | 2444 | + let dir = std::env::var("EC_AAC_HEAAC_FIXTURES") |
| 2432 | - format!("{}/../../.cache/heaac-fixtures", env!("CARGO_MANIFEST_DIR")) | 2445 | + .unwrap_or_else(|_| format!("{}/../../.cache/heaac-fixtures", env!("CARGO_MANIFEST_DIR"))); |
| 2433 | - }); | ||
| 2434 | let dir = PathBuf::from(dir); | 2446 | let dir = PathBuf::from(dir); |
| 2435 | if !dir.is_dir() { | 2447 | if !dir.is_dir() { |
| 2436 | eprintln!( | 2448 | eprintln!( |
| @@ -2444,8 +2456,21 @@ fn synthetic_heaac_matrix() { | |||
| 2444 | } | 2456 | } |
| 2445 | println!( | 2457 | println!( |
| 2446 | "{:>5} {:>6} {:>4} {:>4} {:>4} {:>8} {:>8} {:>8} {:>6} {:>11} {:>8} {:>10} {:>8} {:>9} {:>9}", | 2458 | "{:>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", | 2459 | + "rate", |
| 2448 | - "core_v_ref", "cvr_lag", "core_rate", "full_rate" | 2460 | + "kbps", |
| 2461 | + "prof", | ||
| 2462 | + "kx", | ||
| 2463 | + "k2", | ||
| 2464 | + "full", | ||
| 2465 | + "below", | ||
| 2466 | + "above", | ||
| 2467 | + "lag", | ||
| 2468 | + "ours_v_core", | ||
| 2469 | + "ovc_lag", | ||
| 2470 | + "core_v_ref", | ||
| 2471 | + "cvr_lag", | ||
| 2472 | + "core_rate", | ||
| 2473 | + "full_rate" | ||
| 2449 | ); | 2474 | ); |
| 2450 | // Wide enough that the WIDE_LAG_MAX==LC's own decoder priming delay | 2475 | // 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 | 2476 | // (2048) plus a full SBR-chain worth of extra delay (a few thousand |
| @@ -2479,8 +2504,7 @@ fn synthetic_heaac_matrix() { | |||
| 2479 | let o = &ours[0]; | 2504 | let o = &ours[0]; |
| 2480 | let t = &theirs[0]; | 2505 | let t = &theirs[0]; |
| 2481 | const TOPK: usize = 5; | 2506 | const TOPK: usize = 5; |
| 2482 | - let (mut lag, mut full, edge) = | 2507 | + 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!( | 2508 | assert!( |
| 2485 | !edge, | 2509 | !edge, |
| 2486 | "{}: {profile} row's refined winning lag {lag} sits at the \ | 2510 | "{}: {profile} row's refined winning lag {lag} sits at the \ |
| @@ -2504,8 +2528,11 @@ fn synthetic_heaac_matrix() { | |||
| 2504 | if profile == "HE" && ours.len() >= 2 && theirs.len() >= 2 { | 2528 | if profile == "HE" && ours.len() >= 2 && theirs.len() >= 2 { |
| 2505 | let mono_o: Vec<f32> = | 2529 | let mono_o: Vec<f32> = |
| 2506 | ours[0].iter().zip(&ours[1]).map(|(a, b)| a + b).collect(); | 2530 | ours[0].iter().zip(&ours[1]).map(|(a, b)| a + b).collect(); |
| 2507 | - let mono_t: Vec<f32> = | 2531 | + let mono_t: Vec<f32> = theirs[0] |
| 2508 | - theirs[0].iter().zip(&theirs[1]).map(|(a, b)| a + b).collect(); | 2532 | + .iter() |
| 2533 | + .zip(&theirs[1]) | ||
| 2534 | + .map(|(a, b)| a + b) | ||
| 2535 | + .collect(); | ||
| 2509 | let (mono_lag, _, mono_edge) = | 2536 | let (mono_lag, _, mono_edge) = |
| 2510 | robust_lag_topk(&mono_o, &mono_t, WIDE_LAG_MAX, our_rate, TOPK); | 2537 | robust_lag_topk(&mono_o, &mono_t, WIDE_LAG_MAX, our_rate, TOPK); |
| 2511 | assert!( | 2538 | assert!( |
| @@ -2548,7 +2575,9 @@ fn synthetic_heaac_matrix() { | |||
| 2548 | } else { | 2575 | } else { |
| 2549 | ((-lag) as usize, 0usize) | 2576 | ((-lag) as usize, 0usize) |
| 2550 | }; | 2577 | }; |
| 2551 | - let n = WINDOW.min(o.len().saturating_sub(oa)).min(t.len().saturating_sub(ob)); | 2578 | + let n = WINDOW |
| 2579 | + .min(o.len().saturating_sub(oa)) | ||
| 2580 | + .min(t.len().saturating_sub(ob)); | ||
| 2552 | let above = if n >= 1024 { | 2581 | let above = if n >= 1024 { |
| 2553 | correlation( | 2582 | correlation( |
| 2554 | &highpass(&o[oa..oa + n], our_rate, crossover_hz), | 2583 | &highpass(&o[oa..oa + n], our_rate, crossover_hz), |
| @@ -2886,8 +2915,14 @@ fn sbr_real_library_matches_reference() { | |||
| 2886 | let high = if n >= 1024 { | 2915 | let high = if n >= 1024 { |
| 2887 | let oh = highpass(&o[oa..oa + n], rate, c.crossover_hz); | 2916 | let oh = highpass(&o[oa..oa + n], rate, c.crossover_hz); |
| 2888 | let th = highpass(&t[ob..ob + n], rate, c.crossover_hz); | 2917 | 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(); | 2918 | + let rms = |v: &[f32]| { |
| 2890 | - println!(" ch{ch} above-crossover RMS ours/ref = {:.4}", rms(&oh) / rms(&th).max(1e-12)); | 2919 | + (v.iter().map(|x| f64::from(*x).powi(2)).sum::<f64>() / v.len().max(1) as f64) |
| 2920 | + .sqrt() | ||
| 2921 | + }; | ||
| 2922 | + println!( | ||
| 2923 | + " ch{ch} above-crossover RMS ours/ref = {:.4}", | ||
| 2924 | + rms(&oh) / rms(&th).max(1e-12) | ||
| 2925 | + ); | ||
| 2891 | correlation(&oh, &th) | 2926 | correlation(&oh, &th) |
| 2892 | } else { | 2927 | } else { |
| 2893 | 0.0 | 2928 | 0.0 |
| @@ -3154,7 +3189,10 @@ fn sbr_real_library_matches_reference() { | |||
| 3154 | ci += c.im; | 3189 | ci += c.im; |
| 3155 | } | 3190 | } |
| 3156 | let coh = (cr * cr + ci * ci).sqrt() / (eo * et).sqrt().max(1e-30); | 3191 | 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()); | 3192 | + println!( |
| 3193 | + " band{band:>3}: {:>7.2} dB coh {coh:.4}", | ||
| 3194 | + 10.0 * (eo / et.max(1e-30)).log10() | ||
| 3195 | + ); | ||
| 3158 | } | 3196 | } |
| 3159 | } | 3197 | } |
| 3160 | let mean_in = |rows: &[(usize, f64)], lo: usize, hi: usize| { | 3198 | let mean_in = |rows: &[(usize, f64)], lo: usize, hi: usize| { |
| @@ -3559,7 +3597,10 @@ fn sbr_actual_noise_fraction() { | |||
| 3559 | // has nonzero entries for QMF bands up to `k2`). | 3597 | // has nonzero entries for QMF bands up to `k2`). |
| 3560 | let band_hz = f64::from(rate) / 128.0; | 3598 | let band_hz = f64::from(rate) / 128.0; |
| 3561 | let kx_band = bookkept.iter().map(|(b, ..)| *b).min().unwrap_or(0); | 3599 | 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); | 3600 | + println!( |
| 3601 | + " (crossover: QMF band {kx_band}, {:.0} Hz -- rows below it are core-decoded and excluded from the total)", | ||
| 3602 | + kx_band as f64 * band_hz | ||
| 3603 | + ); | ||
| 3563 | println!( | 3604 | println!( |
| 3564 | " ACTUAL noise fraction (band_hz, energy_on, energy_off, actual_fraction, bookkept_fraction):" | 3605 | " ACTUAL noise fraction (band_hz, energy_on, energy_off, actual_fraction, bookkept_fraction):" |
| 3565 | ); | 3606 | ); |
| @@ -3712,9 +3753,8 @@ fn sbr_header_feature_table() { | |||
| 3712 | ffmpeg_stream: c.ffmpeg_stream, | 3753 | ffmpeg_stream: c.ffmpeg_stream, |
| 3713 | }) | 3754 | }) |
| 3714 | .collect(); | 3755 | .collect(); |
| 3715 | - let fixtures = std::env::var("EC_AAC_HEAAC_FIXTURES").unwrap_or_else(|_| { | 3756 | + let fixtures = std::env::var("EC_AAC_HEAAC_FIXTURES") |
| 3716 | - format!("{}/../../.cache/heaac-fixtures", env!("CARGO_MANIFEST_DIR")) | 3757 | + .unwrap_or_else(|_| format!("{}/../../.cache/heaac-fixtures", env!("CARGO_MANIFEST_DIR"))); |
| 3717 | - }); | ||
| 3718 | let fixtures = PathBuf::from(fixtures); | 3758 | let fixtures = PathBuf::from(fixtures); |
| 3719 | if fixtures.is_dir() { | 3759 | if fixtures.is_dir() { |
| 3720 | for rate in [48_000u32, 44_100] { | 3760 | for rate in [48_000u32, 44_100] { |
| @@ -3746,8 +3786,25 @@ fn sbr_header_feature_table() { | |||
| 3746 | const WIDE_LAG_MAX: i64 = 20_000; | 3786 | const WIDE_LAG_MAX: i64 = 20_000; |
| 3747 | println!( | 3787 | println!( |
| 3748 | "{:<20} {:>6} {:>4} {:>4} {:>4} {:>4} {:>4} {:>4} {:>4} {:>4} {:>4} {:>4} {:>5} {:>10} {:>10} {:>8} {:>8} {:>10} {:>6}", | 3788 | "{:<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", | 3789 | + "stream", |
| 3750 | - "ifrq", "smooth", "envs", "invf", "harm", "df%", "corr" | 3790 | + "rate", |
| 3791 | + "kx", | ||
| 3792 | + "k2", | ||
| 3793 | + "xovr", | ||
| 3794 | + "sfrq", | ||
| 3795 | + "efrq", | ||
| 3796 | + "fscl", | ||
| 3797 | + "ascl", | ||
| 3798 | + "nbnd", | ||
| 3799 | + "lbnd", | ||
| 3800 | + "lgn", | ||
| 3801 | + "ifrq", | ||
| 3802 | + "smooth", | ||
| 3803 | + "envs", | ||
| 3804 | + "invf", | ||
| 3805 | + "harm", | ||
| 3806 | + "df%", | ||
| 3807 | + "corr" | ||
| 3751 | ); | 3808 | ); |
| 3752 | for r in &rows { | 3809 | for r in &rows { |
| 3753 | let before = ec_aac::sbr_sideinfo_log().len(); | 3810 | let before = ec_aac::sbr_sideinfo_log().len(); |
| @@ -3760,7 +3817,11 @@ fn sbr_header_feature_table() { | |||
| 3760 | continue; | 3817 | continue; |
| 3761 | } | 3818 | } |
| 3762 | let log = ec_aac::sbr_sideinfo_log(); | 3819 | let log = ec_aac::sbr_sideinfo_log(); |
| 3763 | - let frames: Vec<_> = log[before..].iter().filter(|row| row.ch == 0).take(20).collect(); | 3820 | + let frames: Vec<_> = log[before..] |
| 3821 | + .iter() | ||
| 3822 | + .filter(|row| row.ch == 0) | ||
| 3823 | + .take(20) | ||
| 3824 | + .collect(); | ||
| 3764 | if frames.is_empty() { | 3825 | if frames.is_empty() { |
| 3765 | eprintln!("SKIP {}: no sideinfo rows captured", r.label); | 3826 | eprintln!("SKIP {}: no sideinfo rows captured", r.label); |
| 3766 | continue; | 3827 | continue; |
| @@ -3772,13 +3833,24 @@ fn sbr_header_feature_table() { | |||
| 3772 | let mut df_total = 0usize; | 3833 | let mut df_total = 0usize; |
| 3773 | let mut df_ones = 0usize; | 3834 | let mut df_ones = 0usize; |
| 3774 | for row in &frames { | 3835 | for row in &frames { |
| 3775 | - *env_counts.entry(row.t_env.len().saturating_sub(1)).or_default() += 1; | 3836 | + *env_counts |
| 3837 | + .entry(row.t_env.len().saturating_sub(1)) | ||
| 3838 | + .or_default() += 1; | ||
| 3776 | invf_seen.extend(&row.invf_mode); | 3839 | invf_seen.extend(&row.invf_mode); |
| 3777 | - if row.add_harmonic.as_ref().is_some_and(|h| h.iter().any(|&v| v != 0)) { | 3840 | + if row |
| 3841 | + .add_harmonic | ||
| 3842 | + .as_ref() | ||
| 3843 | + .is_some_and(|h| h.iter().any(|&v| v != 0)) | ||
| 3844 | + { | ||
| 3778 | any_harmonic = true; | 3845 | any_harmonic = true; |
| 3779 | } | 3846 | } |
| 3780 | df_total += row.df_env.len() + row.df_noise.len(); | 3847 | 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(); | 3848 | + df_ones += row |
| 3849 | + .df_env | ||
| 3850 | + .iter() | ||
| 3851 | + .chain(&row.df_noise) | ||
| 3852 | + .filter(|&&b| b != 0) | ||
| 3853 | + .count(); | ||
| 3782 | } | 3854 | } |
| 3783 | let df_pct = if df_total > 0 { | 3855 | let df_pct = if df_total > 0 { |
| 3784 | 100.0 * df_ones as f64 / df_total as f64 | 3856 | 100.0 * df_ones as f64 / df_total as f64 |
| @@ -3790,20 +3862,36 @@ fn sbr_header_feature_table() { | |||
| 3790 | .map(|(k, v)| format!("{k}x{v}")) | 3862 | .map(|(k, v)| format!("{k}x{v}")) |
| 3791 | .collect::<Vec<_>>() | 3863 | .collect::<Vec<_>>() |
| 3792 | .join(","); | 3864 | .join(","); |
| 3793 | - let invf_str: String = invf_seen.iter().map(|v| v.to_string()).collect::<Vec<_>>().join(""); | 3865 | + let invf_str: String = invf_seen |
| 3866 | + .iter() | ||
| 3867 | + .map(|v| v.to_string()) | ||
| 3868 | + .collect::<Vec<_>>() | ||
| 3869 | + .join(""); | ||
| 3794 | let theirs = ffmpeg_decode(&r.path, r.ffmpeg_stream, ours.len()); | 3870 | 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); | 3871 | let (_, corr) = best_lag_correlation_wide(&ours[0], &theirs[0], WIDE_LAG_MAX); |
| 3796 | println!( | 3872 | println!( |
| 3797 | "{:<20} {:>6} {:>4} {:>4} {:>4} {:>4} {:>4} {:>4} {:>4} {:>4} {:>4} {:>4} {:>5} {:>10} {:>10} {:>8} {:>8} {:>10.1} {:>6.3}", | 3873 | "{:<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, | 3874 | + r.label, |
| 3799 | - f0.freq_scale, f0.alter_scale, f0.noise_bands, f0.limiter_bands, f0.limiter_gains, | 3875 | + our_rate, |
| 3800 | - f0.interpol_freq, f0.smoothing_mode, envs_hist, invf_str, | 3876 | + f0.kx, |
| 3801 | - any_harmonic, df_pct, corr | 3877 | + f0.k2, |
| 3802 | - ); | 3878 | + f0.xover_band, |
| 3803 | - println!( | 3879 | + f0.start_freq, |
| 3804 | - " patches (frame0): {:?}", | 3880 | + f0.stop_freq, |
| 3805 | - f0.patch_lengths | 3881 | + f0.freq_scale, |
| 3882 | + f0.alter_scale, | ||
| 3883 | + f0.noise_bands, | ||
| 3884 | + f0.limiter_bands, | ||
| 3885 | + f0.limiter_gains, | ||
| 3886 | + f0.interpol_freq, | ||
| 3887 | + f0.smoothing_mode, | ||
| 3888 | + envs_hist, | ||
| 3889 | + invf_str, | ||
| 3890 | + any_harmonic, | ||
| 3891 | + df_pct, | ||
| 3892 | + corr | ||
| 3806 | ); | 3893 | ); |
| 3894 | + println!(" patches (frame0): {:?}", f0.patch_lengths); | ||
| 3807 | } | 3895 | } |
| 3808 | } | 3896 | } |
| 3809 | 3897 | ||
| @@ -3874,7 +3962,11 @@ fn per_au_low_band_probe(label: &str, path: &Path, aac_stream: usize) { | |||
| 3874 | } | 3962 | } |
| 3875 | } | 3963 | } |
| 3876 | if core_ch0.is_empty() || full_ch0.is_empty() { | 3964 | if core_ch0.is_empty() || full_ch0.is_empty() { |
| 3877 | - eprintln!("SKIP {label}: empty decode (core {} full {})", core_ch0.len(), full_ch0.len()); | 3965 | + eprintln!( |
| 3966 | + "SKIP {label}: empty decode (core {} full {})", | ||
| 3967 | + core_ch0.len(), | ||
| 3968 | + full_ch0.len() | ||
| 3969 | + ); | ||
| 3878 | return; | 3970 | return; |
| 3879 | } | 3971 | } |
| 3880 | 3972 | ||
| @@ -3949,9 +4041,8 @@ fn per_au_low_band_divergence() { | |||
| 3949 | for c in &candidates() { | 4041 | for c in &candidates() { |
| 3950 | per_au_low_band_probe(&c.path.display().to_string(), &c.path, c.aac_stream); | 4042 | per_au_low_band_probe(&c.path.display().to_string(), &c.path, c.aac_stream); |
| 3951 | } | 4043 | } |
| 3952 | - let dir = std::env::var("EC_AAC_HEAAC_FIXTURES").unwrap_or_else(|_| { | 4044 | + let dir = std::env::var("EC_AAC_HEAAC_FIXTURES") |
| 3953 | - format!("{}/../../.cache/heaac-fixtures", env!("CARGO_MANIFEST_DIR")) | 4045 | + .unwrap_or_else(|_| format!("{}/../../.cache/heaac-fixtures", env!("CARGO_MANIFEST_DIR"))); |
| 3954 | - }); | ||
| 3955 | let failing = PathBuf::from(&dir).join("heaac_44100_48k.m4a"); | 4046 | let failing = PathBuf::from(&dir).join("heaac_44100_48k.m4a"); |
| 3956 | if failing.exists() { | 4047 | if failing.exists() { |
| 3957 | per_au_low_band_probe("synthetic 44100 48k (failing)", &failing, 0); | 4048 | per_au_low_band_probe("synthetic 44100 48k (failing)", &failing, 0); |
| @@ -4097,7 +4188,9 @@ fn probe_explicit_config_and_wide_lag() { | |||
| 4097 | let theirs = ffmpeg_decode(&path, ffmpeg_stream, hand_planes.len()); | 4188 | let theirs = ffmpeg_decode(&path, ffmpeg_stream, hand_planes.len()); |
| 4098 | if let (Some(o), Some(t)) = (hand_planes.first(), theirs.first()) { | 4189 | if let (Some(o), Some(t)) = (hand_planes.first(), theirs.first()) { |
| 4099 | let (lag, corr) = best_lag_correlation_wide(o, t, 100_000); | 4190 | 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}"); | 4191 | + println!( |
| 4192 | + " hand-built explicit config: full-band vs reference: lag={lag} corr={corr:.6}" | ||
| 4193 | + ); | ||
| 4101 | } | 4194 | } |
| 4102 | } | 4195 | } |
| 4103 | 4196 | ||
| @@ -4111,10 +4204,9 @@ fn probe_explicit_config_and_wide_lag() { | |||
| 4111 | "{home}/Downloads/reelp/reelp.mkv" | 4204 | "{home}/Downloads/reelp/reelp.mkv" |
| 4112 | )); | 4205 | )); |
| 4113 | if fmj.exists() { | 4206 | if fmj.exists() { |
| 4114 | - if let (Some((core, core_rate)), Some((full, sbr, full_rate))) = ( | 4207 | + if let (Some((core, core_rate)), Some((full, sbr, full_rate))) = |
| 4115 | - our_decode_core_only(&fmj, 1), | 4208 | + (our_decode_core_only(&fmj, 1), our_decode(&fmj, 1)) |
| 4116 | - our_decode(&fmj, 1), | 4209 | + { |
| 4117 | - ) { | ||
| 4118 | if sbr == ec_aac::SbrSupport::V1 { | 4210 | if sbr == ec_aac::SbrSupport::V1 { |
| 4119 | let up: Vec<f32> = core[0].iter().flat_map(|&s| [s, s]).collect(); | 4211 | let up: Vec<f32> = core[0].iter().flat_map(|&s| [s, s]).collect(); |
| 4120 | let cutoff = f64::from(core_rate) * 0.4; | 4212 | let cutoff = f64::from(core_rate) * 0.4; |
| @@ -4239,9 +4331,8 @@ fn coupled_cpe_channel_swap_probe() { | |||
| 4239 | eprintln!("SKIP: ffmpeg not on PATH"); | 4331 | eprintln!("SKIP: ffmpeg not on PATH"); |
| 4240 | return; | 4332 | return; |
| 4241 | } | 4333 | } |
| 4242 | - let dir = std::env::var("EC_AAC_HEAAC_FIXTURES").unwrap_or_else(|_| { | 4334 | + let dir = std::env::var("EC_AAC_HEAAC_FIXTURES") |
| 4243 | - format!("{}/../../.cache/heaac-fixtures", env!("CARGO_MANIFEST_DIR")) | 4335 | + .unwrap_or_else(|_| format!("{}/../../.cache/heaac-fixtures", env!("CARGO_MANIFEST_DIR"))); |
| 4244 | - }); | ||
| 4245 | let path = PathBuf::from(&dir).join("heaac_44100_48k.m4a"); | 4336 | let path = PathBuf::from(&dir).join("heaac_44100_48k.m4a"); |
| 4246 | if !path.exists() { | 4337 | if !path.exists() { |
| 4247 | eprintln!("SKIP: {} absent", path.display()); | 4338 | eprintln!("SKIP: {} absent", path.display()); |
| @@ -4256,7 +4347,10 @@ fn coupled_cpe_channel_swap_probe() { | |||
| 4256 | let ref_r = ffmpeg_decode_pan_channel(&path, 0, 1); | 4347 | let ref_r = ffmpeg_decode_pan_channel(&path, 0, 1); |
| 4257 | { | 4348 | { |
| 4258 | let n = ref_l.len().min(ref_r.len()).min(WINDOW); | 4349 | 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])); | 4350 | + println!( |
| 4351 | + "ref L vs ref R (no lag): corr={:.6}", | ||
| 4352 | + correlation(&ref_l[..n], &ref_r[..n]) | ||
| 4353 | + ); | ||
| 4260 | let (lag, corr) = best_lag_correlation_wide(&ref_l, &ref_r, SEARCH_LAG_MAX); | 4354 | 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}"); | 4355 | println!("ref L vs ref R (best lag search): lag={lag} corr={corr:.6}"); |
| 4262 | } | 4356 | } |
| @@ -4329,11 +4423,17 @@ fn coupled_cpe_channel_swap_probe() { | |||
| 4329 | let (core_lag0, core_corr0) = | 4423 | let (core_lag0, core_corr0) = |
| 4330 | best_lag_correlation_wide(&core_planes[0], &ref_core[0], SEARCH_LAG_MAX); | 4424 | best_lag_correlation_wide(&core_planes[0], &ref_core[0], SEARCH_LAG_MAX); |
| 4331 | let core_implied_lag = core_lag0 * 2; | 4425 | 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}"); | 4426 | + println!( |
| 4427 | + "core ch0 vs ref L best lag={core_lag0} corr={core_corr0:.6} -> implied full-rate lag={core_implied_lag}" | ||
| 4428 | + ); | ||
| 4333 | let mono_ours: Vec<f32> = ours[0].iter().zip(&ours[1]).map(|(a, b)| a + b).collect(); | 4429 | let mono_ours: Vec<f32> = ours[0].iter().zip(&ours[1]).map(|(a, b)| a + b).collect(); |
| 4334 | let mono_ref: Vec<f32> = { | 4430 | let mono_ref: Vec<f32> = { |
| 4335 | let n = ref_l.len().min(ref_r.len()); | 4431 | let n = ref_l.len().min(ref_r.len()); |
| 4336 | - ref_l[..n].iter().zip(&ref_r[..n]).map(|(a, b)| a + b).collect() | 4432 | + ref_l[..n] |
| 4433 | + .iter() | ||
| 4434 | + .zip(&ref_r[..n]) | ||
| 4435 | + .map(|(a, b)| a + b) | ||
| 4436 | + .collect() | ||
| 4337 | }; | 4437 | }; |
| 4338 | let (mono_lag, mono_corr) = best_lag_correlation_wide(&mono_ours, &mono_ref, SEARCH_LAG_MAX); | 4438 | 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}"); | 4439 | println!("mono (ch0+ch1) vs ref (L+R) best lag={mono_lag} corr={mono_corr:.6}"); |
| @@ -4349,7 +4449,15 @@ fn coupled_cpe_channel_swap_probe() { | |||
| 4349 | // corr=0.873 above). So the TRUE best lag among our 4 candidates is | 4449 | // 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 | 4450 | // whichever one actually maximizes the fixed-lag mono correlation, not |
| 4351 | // whatever `mono_lag` the free search reported. | 4451 | // 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); | 4452 | + let mut true_best = ( |
| 4453 | + mono_lag, | ||
| 4454 | + "mono-best lag (free search)", | ||
| 4455 | + 0.0f64, | ||
| 4456 | + 0.0f64, | ||
| 4457 | + 0.0f64, | ||
| 4458 | + 0.0f64, | ||
| 4459 | + mono_corr, | ||
| 4460 | + ); | ||
| 4353 | for (lag, label) in fixed_lags { | 4461 | for (lag, label) in fixed_lags { |
| 4354 | let c0l = correlation_at_lag(&ours[0], &ref_l, lag); | 4462 | let c0l = correlation_at_lag(&ours[0], &ref_l, lag); |
| 4355 | let c0r = correlation_at_lag(&ours[0], &ref_r, lag); | 4463 | let c0r = correlation_at_lag(&ours[0], &ref_r, lag); |
| @@ -4398,7 +4506,9 @@ fn coupled_cpe_channel_swap_probe() { | |||
| 4398 | } | 4506 | } |
| 4399 | let cl = correlation(&ours[0][oa..oa + step], &ref_l[ob..ob + step]); | 4507 | 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]); | 4508 | 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}"); | 4509 | + println!( |
| 4510 | + "subwindow t={w}s ch0 vs ref L/R @ lag {best_lag}: corr(L)={cl:.6} corr(R)={cr:.6}" | ||
| 4511 | + ); | ||
| 4402 | w += 1; | 4512 | w += 1; |
| 4403 | } | 4513 | } |
| 4404 | } | 4514 | } |
| @@ -4569,9 +4679,8 @@ fn sbr441_family_sample_drift_probe() { | |||
| 4569 | eprintln!("SKIP: ffmpeg not on PATH"); | 4679 | eprintln!("SKIP: ffmpeg not on PATH"); |
| 4570 | return; | 4680 | return; |
| 4571 | } | 4681 | } |
| 4572 | - let dir = std::env::var("EC_AAC_HEAAC_FIXTURES").unwrap_or_else(|_| { | 4682 | + let dir = std::env::var("EC_AAC_HEAAC_FIXTURES") |
| 4573 | - format!("{}/../../.cache/heaac-fixtures", env!("CARGO_MANIFEST_DIR")) | 4683 | + .unwrap_or_else(|_| format!("{}/../../.cache/heaac-fixtures", env!("CARGO_MANIFEST_DIR"))); |
| 4574 | - }); | ||
| 4575 | let home = std::env::var("HOME").unwrap_or_default(); | 4684 | let home = std::env::var("HOME").unwrap_or_default(); |
| 4576 | let cases: [(&str, PathBuf, i64); 3] = [ | 4685 | let cases: [(&str, PathBuf, i64); 3] = [ |
| 4577 | ( | 4686 | ( |
| @@ -4690,9 +4799,8 @@ fn sbr_hf_window_band_probe() { | |||
| 4690 | eprintln!("SKIP: ffmpeg not on PATH"); | 4799 | eprintln!("SKIP: ffmpeg not on PATH"); |
| 4691 | return; | 4800 | return; |
| 4692 | } | 4801 | } |
| 4693 | - let dir = std::env::var("EC_AAC_HEAAC_FIXTURES").unwrap_or_else(|_| { | 4802 | + let dir = std::env::var("EC_AAC_HEAAC_FIXTURES") |
| 4694 | - format!("{}/../../.cache/heaac-fixtures", env!("CARGO_MANIFEST_DIR")) | 4803 | + .unwrap_or_else(|_| format!("{}/../../.cache/heaac-fixtures", env!("CARGO_MANIFEST_DIR"))); |
| 4695 | - }); | ||
| 4696 | let path = PathBuf::from(&dir).join("heaac_48000_64k.m4a"); | 4804 | let path = PathBuf::from(&dir).join("heaac_48000_64k.m4a"); |
| 4697 | if !path.exists() { | 4805 | if !path.exists() { |
| 4698 | eprintln!("SKIP: {} absent", path.display()); | 4806 | eprintln!("SKIP: {} absent", path.display()); |
| @@ -4748,7 +4856,10 @@ fn sbr_hf_window_band_probe() { | |||
| 4748 | let mean_t: f64 = mags_t.iter().sum::<f64>() / 8.0; | 4856 | let mean_t: f64 = mags_t.iter().sum::<f64>() / 8.0; |
| 4749 | println!( | 4857 | println!( |
| 4750 | " band{band:>3}: |ours|dB mean={mean_o:>7.2} |ref|dB mean={mean_t:>7.2} dphase(deg)={:?}", | 4858 | " 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<_>>() | 4859 | + dphase_deg |
| 4860 | + .iter() | ||
| 4861 | + .map(|d| format!("{d:.0}")) | ||
| 4862 | + .collect::<Vec<_>>() | ||
| 4752 | ); | 4863 | ); |
| 4753 | } | 4864 | } |
| 4754 | } | 4865 | } |
| @@ -4794,7 +4905,13 @@ fn sbr_residual_locator() { | |||
| 4794 | if !have_ffmpeg() { | 4905 | if !have_ffmpeg() { |
| 4795 | return; | 4906 | return; |
| 4796 | } | 4907 | } |
| 4797 | - let home = std::env::var("HOME").unwrap(); | 4908 | + // lane-h264reallib: `unwrap_or_default()`, the shape this file's five |
| 4909 | + // other HOME reads already use (:2710, :3426, :4109, :4182, :4575). A bare | ||
| 4910 | + // `unwrap()` panicked on any host with no HOME -- a fleet runner -- which | ||
| 4911 | + // is a red with no bearing on the decoder. The `path.exists()` guard below | ||
| 4912 | + // already handles the absent-file case, so an empty HOME just makes the | ||
| 4913 | + // fallback path relative-and-nonexistent and the test returns. | ||
| 4914 | + let home = std::env::var("HOME").unwrap_or_default(); | ||
| 4798 | // `EC_AAC_SBR_LOCATOR_FILE` points the same instrument at any other | 4915 | // `EC_AAC_SBR_LOCATOR_FILE` points the same instrument at any other |
| 4799 | // HE-AAC file (e.g. a mono, uncoupled, noise-only probe encode). | 4916 | // HE-AAC file (e.g. a mono, uncoupled, noise-only probe encode). |
| 4800 | let path = std::env::var("EC_AAC_SBR_LOCATOR_FILE") | 4917 | let path = std::env::var("EC_AAC_SBR_LOCATOR_FILE") |
| @@ -4803,7 +4920,9 @@ fn sbr_residual_locator() { | |||
| 4803 | if !path.exists() { | 4920 | if !path.exists() { |
| 4804 | return; | 4921 | return; |
| 4805 | } | 4922 | } |
| 4806 | - let Some((ours, _, rate)) = our_decode(&path, 0) else { return }; | 4923 | + let Some((ours, _, rate)) = our_decode(&path, 0) else { |
| 4924 | + return; | ||
| 4925 | + }; | ||
| 4807 | let theirs = ffmpeg_decode(&path, 0, ours.len()); | 4926 | let theirs = ffmpeg_decode(&path, 0, ours.len()); |
| 4808 | const W: usize = 2048; | 4927 | const W: usize = 2048; |
| 4809 | const FFT_LEN: usize = 2048; | 4928 | const FFT_LEN: usize = 2048; |
| @@ -4815,7 +4934,12 @@ fn sbr_residual_locator() { | |||
| 4815 | let n = ours[ch].len().min(theirs[ch].len()); | 4934 | let n = ours[ch].len().min(theirs[ch].len()); |
| 4816 | let (o, t) = (&ours[ch][..n], &theirs[ch][..n]); | 4935 | let (o, t) = (&ours[ch][..n], &theirs[ch][..n]); |
| 4817 | let mut wins: Vec<(f64, usize)> = (0..n / W) | 4936 | 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)) | 4937 | + .map(|w| { |
| 4938 | + ( | ||
| 4939 | + correlation(&o[w * W..(w + 1) * W], &t[w * W..(w + 1) * W]), | ||
| 4940 | + w, | ||
| 4941 | + ) | ||
| 4942 | + }) | ||
| 4819 | .collect(); | 4943 | .collect(); |
| 4820 | wins.sort_by(|a, b| a.0.partial_cmp(&b.0).unwrap()); | 4944 | wins.sort_by(|a, b| a.0.partial_cmp(&b.0).unwrap()); |
| 4821 | println!("ch{ch} worst windows (corr, frame): {:?}", &wins[..12]); | 4945 | println!("ch{ch} worst windows (corr, frame): {:?}", &wins[..12]); |
| @@ -4865,7 +4989,9 @@ fn sbr_residual_locator() { | |||
| 4865 | } | 4989 | } |
| 4866 | } | 4990 | } |
| 4867 | // group into 250 Hz bands up to 8 kHz, then 1 kHz | 4991 | // 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(); | 4992 | + let mut edges: Vec<usize> = (0..=32) |
| 4993 | + .map(|i| ((i as f64 * 250.0) / hz) as usize) | ||
| 4994 | + .collect(); | ||
| 4869 | edges.extend((9..=22).map(|i| ((i as f64 * 1000.0) / hz) as usize)); | 4995 | edges.extend((9..=22).map(|i| ((i as f64 * 1000.0) / hz) as usize)); |
| 4870 | for e in edges.windows(2) { | 4996 | for e in edges.windows(2) { |
| 4871 | let (mut c, mut po, mut pt) = (0.0, 0.0, 0.0); | 4997 | let (mut c, mut po, mut pt) = (0.0, 0.0, 0.0); |
crates/ec-h264/tests/conformance.rsmodified+26 -0
| @@ -1882,6 +1882,32 @@ fn compare_container_streamed( | |||
| 1882 | /// resolutions and GOP structures the fixtures never use, and they are the ones | 1882 | /// resolutions and GOP structures the fixtures never use, and they are the ones |
| 1883 | /// a user actually opens. Every file either decodes bit-exactly or is refused | 1883 | /// a user actually opens. Every file either decodes bit-exactly or is refused |
| 1884 | /// by name; a file that decodes to different pixels is a failure. | 1884 | /// by name; a file that decodes to different pixels is a failure. |
| 1885 | +// lane-h264reallib: LOCAL-ONLY, and the reason lives in the attribute so it | ||
| 1886 | +// shows in `cargo test -- --list` instead of hiding in a skip print. | ||
| 1887 | +// | ||
| 1888 | +// The precondition is a PERSONAL MEDIA LIBRARY: the manifest is generated by | ||
| 1889 | +// `scripts/scan-real-library.sh`, which scans `~/Videos ~/Downloads ~/Music` | ||
| 1890 | +// by default and is gitignored precisely because it is machine-local. A | ||
| 1891 | +// runner host has none of those directories, so both of this test's possible | ||
| 1892 | +// behaviours there are wrong: | ||
| 1893 | +// | ||
| 1894 | +// - manifest absent -> the `SKIP: ... missing` early return, which prints | ||
| 1895 | +// green. That is the silent-skip class this batch is removing: a green | ||
| 1896 | +// that means "nothing was checked". | ||
| 1897 | +// - manifest present but its absolute paths unresolvable (a host that ran | ||
| 1898 | +// the scan script against an empty library) -> zero files swept and | ||
| 1899 | +// `decoded >= 3` fails. That is the red every fleet run currently eats, | ||
| 1900 | +// and it is red for a reason that has nothing to do with the decoder. | ||
| 1901 | +// | ||
| 1902 | +// Hence `#[ignore]` rather than an env gate: an env gate whose variable is | ||
| 1903 | +// absent on the runner prints the same green the missing manifest already | ||
| 1904 | +// prints, which is the defect rather than the fix. An ignore is visible in | ||
| 1905 | +// `--list`, cannot go green silently, and leaves the assertion itself intact | ||
| 1906 | +// -- "the sweep is the point" still holds on the machine that can run it. | ||
| 1907 | +// | ||
| 1908 | +// Run it on the workstation, where the library is: | ||
| 1909 | +// cargo test -p ec-h264 --test conformance real_library_streams_match_ffmpeg -- --ignored | ||
| 1910 | +#[ignore = "sweeps the PERSONAL media library (~/Videos, ~/Downloads, ~/Music) through the gitignored fixtures/real-library-manifest.tsv; MINUTES of wall time (measured past 840 s on the workstation), so workstation only -- budget an hour, it is not wedged. A runner host has no such library, so the test is either a silent green or a red for the wrong reason. Run it on the workstation with --ignored."] | ||
| 1885 | #[test] | 1911 | #[test] |
| 1886 | fn real_library_streams_match_ffmpeg() { | 1912 | fn real_library_streams_match_ffmpeg() { |
| 1887 | if !have_ffmpeg() { | 1913 | if !have_ffmpeg() { |
crates/ec-matroska/tests/matroska.rsmodified+49 -16
| @@ -32,7 +32,9 @@ fn aac_priming_round_trips_through_codec_delay() { | |||
| 32 | let dst = work().join("aac-priming-round-trip.mkv"); | 32 | let dst = work().join("aac-priming-round-trip.mkv"); |
| 33 | let mut muxer = MatroskaMuxer::new(File::create(&dst).expect("output")); | 33 | let mut muxer = MatroskaMuxer::new(File::create(&dst).expect("output")); |
| 34 | let stream = muxer.add_stream(info).expect("stream declared"); | 34 | let stream = muxer.add_stream(info).expect("stream declared"); |
| 35 | - muxer.set_track_delay(stream, 21_333_333).expect("declare delay"); // 1024/48000s | 35 | + muxer |
| 36 | + .set_track_delay(stream, 21_333_333) | ||
| 37 | + .expect("declare delay"); // 1024/48000s | ||
| 36 | for _ in 0..10i64 { | 38 | for _ in 0..10i64 { |
| 37 | let mut packet = Packet::new(0, rate, vec![0u8; 8]); | 39 | let mut packet = Packet::new(0, rate, vec![0u8; 8]); |
| 38 | packet.duration = Some(1024); | 40 | packet.duration = Some(1024); |
| @@ -44,7 +46,8 @@ fn aac_priming_round_trips_through_codec_delay() { | |||
| 44 | let demuxer = | 46 | let demuxer = |
| 45 | MatroskaDemuxer::new(BufReader::new(File::open(&dst).expect("opens"))).expect("reopens"); | 47 | MatroskaDemuxer::new(BufReader::new(File::open(&dst).expect("opens"))).expect("reopens"); |
| 46 | assert_eq!( | 48 | assert_eq!( |
| 47 | - demuxer.streams()[0].initial_padding, 1024, | 49 | + demuxer.streams()[0].initial_padding, |
| 50 | + 1024, | ||
| 48 | "CodecDelay round trips to a sample count" | 51 | "CodecDelay round trips to a sample count" |
| 49 | ); | 52 | ); |
| 50 | } | 53 | } |
| @@ -802,7 +805,11 @@ fn truncated_prefixes_are_eof_not_corrupt() { | |||
| 802 | table.join("\n") | 805 | table.join("\n") |
| 803 | ); | 806 | ); |
| 804 | } | 807 | } |
| 805 | - println!("{}\nidx,cut,class,packets\n{}", path.display(), table.join("\n")); | 808 | + println!( |
| 809 | + "{}\nidx,cut,class,packets\n{}", | ||
| 810 | + path.display(), | ||
| 811 | + table.join("\n") | ||
| 812 | + ); | ||
| 806 | } | 813 | } |
| 807 | 814 | ||
| 808 | fn matroska_prefix_class(data: &[u8]) -> (&'static str, u64) { | 815 | fn matroska_prefix_class(data: &[u8]) -> (&'static str, u64) { |
| @@ -823,7 +830,6 @@ fn matroska_prefix_class(data: &[u8]) -> (&'static str, u64) { | |||
| 823 | } | 830 | } |
| 824 | } | 831 | } |
| 825 | 832 | ||
| 826 | - | ||
| 827 | /// Where our own demuxer's seek lands on a real 5.1 E-AC-3 Matroska, in | 833 | /// Where our own demuxer's seek lands on a real 5.1 E-AC-3 Matroska, in |
| 828 | /// *timestamp* -- split from decode, per the round's charter: this measures | 834 | /// *timestamp* -- split from decode, per the round's charter: this measures |
| 829 | /// only [`MatroskaDemuxer::seek`] plus the first packet's `pts`, against what | 835 | /// only [`MatroskaDemuxer::seek`] plus the first packet's `pts`, against what |
| @@ -963,7 +969,12 @@ fn same_class_sweep(path: &str, wants: &[f64], tolerance_ms: f64) { | |||
| 963 | #[test] | 969 | #[test] |
| 964 | #[ignore = "sweeps his real library, run manually with --ignored"] | 970 | #[ignore = "sweeps his real library, run manually with --ignored"] |
| 965 | fn laced_audio_sweep_across_his_library() { | 971 | fn laced_audio_sweep_across_his_library() { |
| 966 | - let manifest = Path::new("/home/user/Documents/Code/Rust/edith_codecs/fixtures/real-library-manifest.tsv"); | 972 | + // lane-h264reallib: `fixtures()` like every sibling, instead of a |
| 973 | + // hardcoded absolute path into the primary checkout. The absolute form | ||
| 974 | + // silently defeated worktree isolation: a run in a worktree or a gate tree | ||
| 975 | + // read the MAIN checkout's manifest, so this test measured a different | ||
| 976 | + // tree's library than the one it was compiled from. | ||
| 977 | + let manifest = &fixtures().join("real-library-manifest.tsv"); | ||
| 967 | let Ok(rows) = std::fs::read_to_string(manifest) else { | 978 | let Ok(rows) = std::fs::read_to_string(manifest) else { |
| 968 | eprintln!("skipped: {} not present", manifest.display()); | 979 | eprintln!("skipped: {} not present", manifest.display()); |
| 969 | return; | 980 | return; |
| @@ -987,8 +998,7 @@ fn laced_audio_sweep_across_his_library() { | |||
| 987 | if !film.exists() { | 998 | if !film.exists() { |
| 988 | continue; | 999 | continue; |
| 989 | } | 1000 | } |
| 990 | - let Ok(mut demux) = | 1001 | + let Ok(mut demux) = MatroskaDemuxer::new(BufReader::new(File::open(film).expect("opens"))) |
| 991 | - MatroskaDemuxer::new(BufReader::new(File::open(film).expect("opens"))) | ||
| 992 | else { | 1002 | else { |
| 993 | eprintln!("{path}: failed to open"); | 1003 | eprintln!("{path}: failed to open"); |
| 994 | continue; | 1004 | continue; |
| @@ -1004,8 +1014,7 @@ fn laced_audio_sweep_across_his_library() { | |||
| 1004 | for frac in [0.3, 0.7] { | 1014 | for frac in [0.3, 0.7] { |
| 1005 | let want = duration * frac; | 1015 | let want = duration * frac; |
| 1006 | let target = Timestamp::new( | 1016 | let target = Timestamp::new( |
| 1007 | - (want * audio.time_base.den() as f64 / audio.time_base.num() as f64).round() | 1017 | + (want * audio.time_base.den() as f64 / audio.time_base.num() as f64).round() as i64, |
| 1008 | - as i64, | ||
| 1009 | audio.time_base, | 1018 | audio.time_base, |
| 1010 | ); | 1019 | ); |
| 1011 | if demux | 1020 | if demux |
| @@ -1096,8 +1105,8 @@ fn real_hdr_film_container_states_no_light_metadata() { | |||
| 1096 | // duplication, pts) or the shared decoder crate, and which physical channel | 1105 | // duplication, pts) or the shared decoder crate, and which physical channel |
| 1097 | // our 5.1 decode calls "channel 0". | 1106 | // our 5.1 decode calls "channel 0". |
| 1098 | 1107 | ||
| 1099 | -use ec_ac3::Ac3Decoder; | ||
| 1100 | use ec_aac::AacDecoder; | 1108 | use ec_aac::AacDecoder; |
| 1109 | +use ec_ac3::Ac3Decoder; | ||
| 1101 | 1110 | ||
| 1102 | /// Opens whichever container `path` actually is — both crates implement the | 1111 | /// Opens whichever container `path` actually is — both crates implement the |
| 1103 | /// same `Demuxer` trait, so the rest of the harness never has to know which. | 1112 | /// same `Demuxer` trait, so the rest of the harness never has to know which. |
| @@ -1109,9 +1118,15 @@ fn open_any(path: &Path) -> Box<dyn Demuxer> { | |||
| 1109 | .read_exact(&mut head) | 1118 | .read_exact(&mut head) |
| 1110 | .expect("read head"); | 1119 | .expect("read head"); |
| 1111 | if ec_mp4::is_mp4(&head) { | 1120 | if ec_mp4::is_mp4(&head) { |
| 1112 | - Box::new(ec_mp4::Mp4Demuxer::new(BufReader::new(File::open(path).expect("open"))).expect("mp4 opens")) | 1121 | + Box::new( |
| 1122 | + ec_mp4::Mp4Demuxer::new(BufReader::new(File::open(path).expect("open"))) | ||
| 1123 | + .expect("mp4 opens"), | ||
| 1124 | + ) | ||
| 1113 | } else { | 1125 | } else { |
| 1114 | - Box::new(MatroskaDemuxer::new(BufReader::new(File::open(path).expect("open"))).expect("mkv opens")) | 1126 | + Box::new( |
| 1127 | + MatroskaDemuxer::new(BufReader::new(File::open(path).expect("open"))) | ||
| 1128 | + .expect("mkv opens"), | ||
| 1129 | + ) | ||
| 1115 | } | 1130 | } |
| 1116 | } | 1131 | } |
| 1117 | 1132 | ||
| @@ -1201,7 +1216,15 @@ fn ffmpeg_decode_planar(path: &Path, channels: usize) -> Vec<Vec<f32>> { | |||
| 1201 | .args(["-v", "error", "-i"]) | 1216 | .args(["-v", "error", "-i"]) |
| 1202 | .arg(path) | 1217 | .arg(path) |
| 1203 | .args([ | 1218 | .args([ |
| 1204 | - "-map", "0:a:0", "-t", "20", "-f", "f32le", "-acodec", "pcm_f32le", "-", | 1219 | + "-map", |
| 1220 | + "0:a:0", | ||
| 1221 | + "-t", | ||
| 1222 | + "20", | ||
| 1223 | + "-f", | ||
| 1224 | + "f32le", | ||
| 1225 | + "-acodec", | ||
| 1226 | + "pcm_f32le", | ||
| 1227 | + "-", | ||
| 1205 | ]) | 1228 | ]) |
| 1206 | .output() | 1229 | .output() |
| 1207 | .expect("ffmpeg runs"); | 1230 | .expect("ffmpeg runs"); |
| @@ -1251,8 +1274,14 @@ fn best_lag_correlation(ours: &[f32], theirs: &[f32]) -> (i64, f64) { | |||
| 1251 | let mut best_abs = -1.0f64; | 1274 | let mut best_abs = -1.0f64; |
| 1252 | let mut best = (0i64, 0.0f64); | 1275 | let mut best = (0i64, 0.0f64); |
| 1253 | for lag in -LAG_MAX..=LAG_MAX { | 1276 | for lag in -LAG_MAX..=LAG_MAX { |
| 1254 | - let (oa, ob) = if lag >= 0 { (0usize, lag as usize) } else { ((-lag) as usize, 0usize) }; | 1277 | + let (oa, ob) = if lag >= 0 { |
| 1255 | - let len = WINDOW.min(ours.len().saturating_sub(oa)).min(theirs.len().saturating_sub(ob)); | 1278 | + (0usize, lag as usize) |
| 1279 | + } else { | ||
| 1280 | + ((-lag) as usize, 0usize) | ||
| 1281 | + }; | ||
| 1282 | + let len = WINDOW | ||
| 1283 | + .min(ours.len().saturating_sub(oa)) | ||
| 1284 | + .min(theirs.len().saturating_sub(ob)); | ||
| 1256 | if len < 1024 { | 1285 | if len < 1024 { |
| 1257 | continue; | 1286 | continue; |
| 1258 | } | 1287 | } |
| @@ -1387,7 +1416,11 @@ fn mkv_51_channel_order() { | |||
| 1387 | pkts.iter().take(5).map(|(p, _)| *p).collect::<Vec<_>>() | 1416 | pkts.iter().take(5).map(|(p, _)| *p).collect::<Vec<_>>() |
| 1388 | ); | 1417 | ); |
| 1389 | let planes = decode_ac3(&pkts); | 1418 | let planes = decode_ac3(&pkts); |
| 1390 | - assert!(!planes.is_empty(), "{}: no channels decoded", path.display()); | 1419 | + assert!( |
| 1420 | + !planes.is_empty(), | ||
| 1421 | + "{}: no channels decoded", | ||
| 1422 | + path.display() | ||
| 1423 | + ); | ||
| 1391 | let ffref = ffmpeg_decode_planar(path, planes.len()); | 1424 | let ffref = ffmpeg_decode_planar(path, planes.len()); |
| 1392 | for (i, ch) in planes.iter().enumerate() { | 1425 | for (i, ch) in planes.iter().enumerate() { |
| 1393 | let (lag, c) = best_lag_correlation(ch, &ffref[0]); | 1426 | let (lag, c) = best_lag_correlation(ch, &ffref[0]); |
crates/ec-probe/tests/library.rsmodified+14 -1
| @@ -487,7 +487,20 @@ fn a_real_library_sweep() { | |||
| 487 | taken += 1; | 487 | taken += 1; |
| 488 | } | 488 | } |
| 489 | } | 489 | } |
| 490 | - assert!(!chosen.is_empty(), "no readable files in the manifest"); | 490 | + // lane-h264reallib: NOT an `assert!` here. The file's own header, lines |
| 491 | + // 5-6, is the spec: "Files that have since moved are skipped and | ||
| 492 | + // reported, never failed -- the manifest is a snapshot of a moving | ||
| 493 | + // library." An empty `chosen` IS the moved-files case, so failing on it | ||
| 494 | + // contradicted the contract this file declares. It was also red on any | ||
| 495 | + // host whose manifest paths no longer resolve, for a reason that had | ||
| 496 | + // nothing to do with the probe. Reported and returned, which is what | ||
| 497 | + // "skipped and reported, never failed" asks for. | ||
| 498 | + if chosen.is_empty() { | ||
| 499 | + eprintln!( | ||
| 500 | + "skipped: no readable file in the manifest (every row has moved or is unreadable)" | ||
| 501 | + ); | ||
| 502 | + return; | ||
| 503 | + } | ||
| 491 | 504 | ||
| 492 | let mut rows = Vec::new(); | 505 | let mut rows = Vec::new(); |
| 493 | let mut failures = Vec::new(); | 506 | let mut failures = Vec::new(); |
lanes/h264reallib.report.mdadded+204 -0
| @@ -0,0 +1,204 @@ | |||
| 1 | +# lane-h264reallib — real-library sweep: shape, local verdict, class sweep | ||
| 2 | + | ||
| 3 | +Branch `lane-h264reallib` (worktree `~/.cache/wt/h264reallib`, base `a21f3680`). | ||
| 4 | +Tests only. No decoder change, no assertion weakened. | ||
| 5 | + | ||
| 6 | +Three separate deliverables, per Main's request to keep them apart: | ||
| 7 | +(a) the local verdict on the real library, (b) the shape change that stops | ||
| 8 | +runners reporting a false red, (c) the count and table of the rest of the class. | ||
| 9 | + | ||
| 10 | +--- | ||
| 11 | + | ||
| 12 | +## (a) Local verdict — PASSES on the workstation, no decoder defect | ||
| 13 | + | ||
| 14 | +Run on the workstation, where the library is: | ||
| 15 | + | ||
| 16 | +``` | ||
| 17 | +EC_NOMEMGUARD=1 cargo test -p ec-h264 --test conformance \ | ||
| 18 | + real_library_streams_match_ffmpeg -- --ignored --nocapture | ||
| 19 | +``` | ||
| 20 | + | ||
| 21 | +`fixtures/real-library-manifest.tsv` is gitignored and generated by | ||
| 22 | +`scripts/scan-real-library.sh` (ffprobe sweep of `~/Videos ~/Downloads ~/Music`). | ||
| 23 | +Copied from the primary checkout into the worktree for the run; **111 h264 rows, | ||
| 24 | +all 111 paths resolve** on this host. | ||
| 25 | + | ||
| 26 | +Result — **15 decoded bit-exact, 0 refused by name, 0 failures**, 1918 s: | ||
| 27 | + | ||
| 28 | +| file | container | width | frames | | ||
| 29 | +|---|---|---|---| | ||
| 30 | +| reel-24f2c8 | matroska,webm | 2560px | 500 bit-exact | | ||
| 31 | +| reel-7538d2 | mov,mp4,m4a,3gp,3g2,mj2 | 2560px | 500 bit-exact | | ||
| 32 | +| reel-1c3a81 | matroska,webm | 1280px | 500 bit-exact | | ||
| 33 | +| reel-286c86 | mov,mp4,… | 3840px | 500 bit-exact | | ||
| 34 | +| reel-010d74 | mov,mp4,… | 576px | 500 bit-exact | | ||
| 35 | +| reel-ab1f6d | mov,mp4,… | 640px | 500 bit-exact | | ||
| 36 | +| reel-e99558 | mov,mp4,… | 1920px | 500 bit-exact (container demux) | | ||
| 37 | +| reel-436303 | mov,mp4,… | 1274px | 439 bit-exact | | ||
| 38 | +| reel-28cd87 | mov,mp4,… | 720px | 500 bit-exact | | ||
| 39 | +| reel-bf1a18 | matroska,webm | 1920px | 500 bit-exact | | ||
| 40 | +| reel-92d5fc | mov,mp4,… | 1080px | 500 bit-exact | | ||
| 41 | +| reel-6ee243 | mov,mp4,… | 1078px | 500 bit-exact | | ||
| 42 | +| reel-1db5fd | mov,mp4,… | 1280px | 185 bit-exact | | ||
| 43 | +| reel-4148f8 | mov,mp4,… | 1916px | 500 bit-exact | | ||
| 44 | +| reel-ccbe4e | mov,mp4,… | 1138px | 500 bit-exact | | ||
| 45 | + | ||
| 46 | +Both demuxers are exercised (matroska + mov/mp4), the sweep covers 576px→3840px, | ||
| 47 | +and one file took the container-demux fallback exactly as designed. **The | ||
| 48 | +decoder is fine; the fleet red was never about the decoder.** | ||
| 49 | + | ||
| 50 | +Runtime: **1918 s (~32 min)**, matching Main's independent observation that it | ||
| 51 | +runs past 840 s. That number is now in the ignore reason so the next person does | ||
| 52 | +not read the wall time as a wedge. | ||
| 53 | + | ||
| 54 | +## (b) Shape change — why `#[ignore]`, and what it stops | ||
| 55 | + | ||
| 56 | +`crates/ec-h264/tests/conformance.rs:1846` `real_library_streams_match_ffmpeg`. | ||
| 57 | + | ||
| 58 | +The precondition is a personal media library, which has exactly two possible | ||
| 59 | +behaviours on a runner, and **both are wrong**: | ||
| 60 | + | ||
| 61 | +- manifest absent → the existing `SKIP: … missing` early return prints | ||
| 62 | + **green**. That is the silent-skip class this batch is removing: a green that | ||
| 63 | + means "nothing was checked". | ||
| 64 | +- manifest present but its absolute paths unresolvable (a host that ran the scan | ||
| 65 | + script against an empty library) → zero files swept and `decoded >= 3` fails. | ||
| 66 | + That is **the red every fleet run currently eats**, and it is red for a reason | ||
| 67 | + that has nothing to do with the decoder. | ||
| 68 | + | ||
| 69 | +`#[ignore]` over an env-gated SKIP, justified: an env gate whose variable is | ||
| 70 | +absent on the runner prints *the same green the missing manifest already prints* — | ||
| 71 | +that is the defect, not the fix. An ignore is visible in | ||
| 72 | +`cargo test -- --list`, cannot go green silently, and needs no runner-side | ||
| 73 | +configuration that could itself drift. The assertion is untouched: `decoded >= 3` | ||
| 74 | +still stands, and still holds, on the machine that can run it (it did: 15 ≥ 3). | ||
| 75 | + | ||
| 76 | +Verified — the target is no longer red, and the reason is printed verbatim: | ||
| 77 | + | ||
| 78 | +``` | ||
| 79 | + | ||
| 80 | +test real_library_streams_match_ffmpeg ... ignored, sweeps the PERSONAL media | ||
| 81 | +library (~/Videos, ~/Downloads, ~/Music) through the gitignored | ||
| 82 | +fixtures/real-library-manifest.tsv; MINUTES of wall time (measured past 840 s on | ||
| 83 | +the workstation), so workstation only -- budget an hour, it is not wedged. ... | ||
| 84 | +test result: ok. 0 passed; 0 failed; 1 ignored; 0 measured; 22 filtered out | ||
| 85 | +``` | ||
| 86 | + | ||
| 87 | +Also fixed, because the fix is the *identical* one-line `#[ignore]` + reason and | ||
| 88 | +no judgement call: `crates/ec-aac/tests/oracle.rs:680` | ||
| 89 | +`real_library_tracks_match_ffmpeg` — same manifest, same | ||
| 90 | +"skip if manifest missing, then assert `checked >= 3`" shape, same two failure | ||
| 91 | +modes. Verified reporting `1 ignored`. | ||
| 92 | + | ||
| 93 | +## (c) Class sweep — 51 sites examined, 2 fixed, 3 need a decision, 46 already correct | ||
| 94 | + | ||
| 95 | +The class: a test that reads `~/Music`, `~/Videos`, `~/Downloads`, a hardcoded | ||
| 96 | +`/home/<user>/` path, or the generated manifest; **or** asserts a minimum count | ||
| 97 | +of personal files. Swept `crates/*/tests/**`, `crates/*/src/**` (incl. | ||
| 98 | +`#[cfg(test)]`), `tests/**`, `tools/**`, `shims/**`, and the scripts. | ||
| 99 | + | ||
| 100 | +**Members of the class that are RED-ON-RUNNER and not ignored — the ones that | ||
| 101 | +still need a decision (not fixed here, because the right fix is NOT the | ||
| 102 | +identical one-liner):** | ||
| 103 | + | ||
| 104 | +| file:line | what it needs | runs on a runner? | current behaviour | proposed shape | | ||
| 105 | +|---|---|---|---|---| | ||
| 106 | +| `crates/ec-probe/tests/library.rs:490` `a_real_library_sweep` | manifest + ≥1 row whose path still exists | partially | red-on-runner | **Remove the minimum-count assert, do not ignore.** The file's own header (:5-6) states moved files are "skipped and reported, never failed" — the `:490` assert contradicts the stated contract. This is a real bug in the test's own spec, not a shape problem. | | ||
| 107 | +| `crates/ec-aac/tests/sbr_real_library.rs:4797` `sbr_residual_locator` | `$HOME` set at all — bare `env::var("HOME").unwrap()` | partially | red-on-runner | **One-line `unwrap_or_default()`**, matching the five sibling HOME reads in the same file (:2710, :3426, :4109, :4182, :4575). The `:4803` `path.exists()` guard already handles the absent file; only the bare `unwrap` panics. | | ||
| 108 | +| `crates/ec-aac/tests/obs_real_content.rs:151` `obs_content_table` | `$HOME` set — bare `unwrap()` | partially | silent-skip | **One-line `unwrap_or_default()`**, same reason. The `read_dir` guard at :152 already handles the absent directory. | | ||
| 109 | + | ||
| 110 | +**Already correctly shaped — `leave alone` (14 named, rest by the same pattern):** | ||
| 111 | +these read personal paths but handle absence correctly, so they are NOT the | ||
| 112 | +class. The template worth copying: | ||
| 113 | + | ||
| 114 | +- `crates/ec-h264/tests/encode.rs:751` `real_library_frames_encode_and_decode_exactly` | ||
| 115 | + — **the reference "correct" shape of this class**: `:728-731` soft-skips when no | ||
| 116 | + qualifying row survives, so the `sources.len() >= 6` assert is only reachable | ||
| 117 | + once a real file was actually opened. This is what the two sites above should | ||
| 118 | + be rewritten to. | ||
| 119 | +- `crates/ec-aac/tests/oracle.rs:848` `he_aac_library_track_decodes_to_its_core` | ||
| 120 | + — sibling of the one I ignored, correctly shaped: prints a named SKIP at :919 | ||
| 121 | + and returns at :917, so the :912 assert only fires on a file it decoded. | ||
| 122 | +- `crates/ec-image/tests/real_library.rs:52`, `:132`; `crates/ec-truehd/tests/library.rs:78`, | ||
| 123 | + `crates/ec-truehd/tests/oracle.rs:87`; `crates/ec-probe/tests/library.rs:585`, `:621`, | ||
| 124 | + `:756`; `crates/ec-aac/tests/reelh_per_frame.rs:29`; `crates/ec-hw/tests/gpu.rs:2050` | ||
| 125 | + (and the three other gpu.rs personal-path sites, all GPU-guarded) — all guard | ||
| 126 | + on `exists()`/`read_dir` and print a named skip. | ||
| 127 | +- `crates/ec-aac/tests/sbr_real_library.rs:2710`, `:3690`, `:4176`, `:4566` — filter | ||
| 128 | + candidates on `.exists()`, empty list skips, no minimum-count assert. | ||
| 129 | + | ||
| 130 | +**Already `#[ignore]`d with a reason naming the precondition — `leave alone` | ||
| 131 | +(~20):** `ec-mp3/tests/encode_matrix.rs:639`, `:851`; `ec-mp4/tests/mp4.rs:789`; | ||
| 132 | +`ec-matroska/tests/matroska.rs:538`, `:965`, `:1058`, `:1282`, `:1400`; | ||
| 133 | +`ec-vorbis/tests/oracle.rs:1190`; `ec-opus/tests/conformance.rs:758`, `:2958`, | ||
| 134 | +`:3149`, `:3428`, `:3654`, `:3859`, `:4091`, `:4572`; `ec-av1/src/encode.rs:16808`, | ||
| 135 | +`:19748`, `:20068`, `:20175`, `:21054`, `:21163`, `:22857`, `:22982`. The repo's | ||
| 136 | +dominant convention is already "ignore + reason", which is why this lane's fix | ||
| 137 | +follows it rather than inventing a new shape. | ||
| 138 | + | ||
| 139 | +**False positives — do NOT touch (the class looks bigger than it is):** | ||
| 140 | + | ||
| 141 | +- `scripts/extract_vp8_tables.py:15`, `scripts/build-aom-oracle.sh:17`, | ||
| 142 | + `build-aom-affine-oracle.sh:23`, `instrument-aom-oracle.sh:73`, | ||
| 143 | + `gen_vp8_fixtures.sh:52`, `memguard-runner.sh:39` — `$HOME/.cache/{aom-oracle,vp8}` | ||
| 144 | + and `$HOME/.config/systemd`: build/toolchain locations, all env-overridable, | ||
| 145 | + none read media. | ||
| 146 | +- `tools/ec-bench/src/main.rs:82` — non-test bench binary; reports "no candidate". | ||
| 147 | +- `crates/ec-aac/tests/sbr_real_library.rs:3715`, `:4572` — `$CARGO_MANIFEST_DIR/../../.cache/heaac-fixtures`, | ||
| 148 | + a generated-fixture cache relative to the repo. | ||
| 149 | +- `crates/ec-vp9/tests/scaledref_exact.rs:18` — a doc comment recording how a | ||
| 150 | + *committed* .ivf was produced; the test reads the tracked file. | ||
| 151 | +- `crates/ec-mp4/tests/mp4.rs:635` — personal file is purely additive to a repo | ||
| 152 | + fixture that is always present; not a dependency. | ||
| 153 | + | ||
| 154 | +**Non-test dependents of the manifest** (why it exists on some hosts and not | ||
| 155 | +others — worth knowing when reading a red): | ||
| 156 | + | ||
| 157 | +- `scripts/scan-real-library.sh` — the generator; defaults to | ||
| 158 | + `$HOME/Videos $HOME/Downloads $HOME/Music`, writes the gitignored | ||
| 159 | + `fixtures/real-library-manifest.tsv`, honours `EC_FIXTURES`. | ||
| 160 | +- `lanes/b64b/bin-control:59261` — a built binary that reads the manifest. | ||
| 161 | +- No CI workflow file in the repo runs the scan, which is exactly why runner | ||
| 162 | + behaviour differs: a host that once ran the script by hand keeps a manifest | ||
| 163 | + whose paths no longer resolve, and that is the state that produces the false red. | ||
| 164 | + | ||
| 165 | +**One incidental finding, not fixed (out of scope, flagged not hidden):** | ||
| 166 | +`crates/ec-matroska/tests/matroska.rs:966` reads the manifest at a **hardcoded | ||
| 167 | +absolute** `/home/user/Documents/Code/Rust/edith_codecs/fixtures/…` instead | ||
| 168 | +of `CARGO_MANIFEST_DIR`-relative like every sibling. It is already `#[ignore]`d | ||
| 169 | +with a soft skip, so it is harmless today, and it also silently defeats | ||
| 170 | +worktree isolation. Worth converting to the relative form if that ignore is ever | ||
| 171 | +lifted. | ||
| 172 | + | ||
| 173 | +### Round 2 — the four approved follow-ups (all now fixed) | ||
| 174 | + | ||
| 175 | +| site | change | before | after | | ||
| 176 | +|---|---|---|---| | ||
| 177 | +| `crates/ec-probe/tests/library.rs:490` | `assert!(!chosen.is_empty())` → named SKIP + `return` | red-on-runner whenever every manifest path had moved | `1 passed; 0 failed; 0 ignored` | | ||
| 178 | +| `crates/ec-aac/tests/sbr_real_library.rs:4797` | `env::var("HOME").unwrap()` → `.unwrap_or_default()` | `FAILED. 0 passed; 1 failed` — `called Result::unwrap() on an Err value: NotPresent` | `1 passed; 0 failed; 0 ignored` | | ||
| 179 | +| `crates/ec-aac/tests/obs_real_content.rs:151` | same | `FAILED. 0 passed; 1 failed` — same panic | `1 passed; 0 failed; 0 ignored` | | ||
| 180 | +| `crates/ec-matroska/tests/matroska.rs:966` | hardcoded absolute manifest path → `fixtures()` | read the PRIMARY checkout's manifest from any worktree | `fixtures()` = `CARGO_MANIFEST_DIR/../../fixtures`, like every sibling | | ||
| 181 | + | ||
| 182 | +The two HOME fixes were proved by running them under `env -u HOME` (the | ||
| 183 | +runner shape) before and after; the probe fix was proved by running the test | ||
| 184 | +with its manifest paths unresolvable. | ||
| 185 | + | ||
| 186 | +**Sweep disposition after round 2: 6 fixed, 0 remaining, 14 already correct, | ||
| 187 | +the rest already `#[ignore]`d or false positives.** No member of this class is | ||
| 188 | +left red-on-runner. | ||
| 189 | + | ||
| 190 | +## Change list | ||
| 191 | + | ||
| 192 | +| file | change | | ||
| 193 | +|---|---| | ||
| 194 | +| `crates/ec-h264/tests/conformance.rs:1870` | `#[ignore = "…"]` + 25-line reason above the test; assertion untouched | | ||
| 195 | +| `crates/ec-aac/tests/oracle.rs:688` | `#[ignore = "…"]` + reason; identical shape, assertion untouched | | ||
| 196 | +| `crates/ec-probe/tests/library.rs:490` | minimum-count assert → named SKIP + return; restores the file's own :5-6 contract | | ||
| 197 | +| `crates/ec-aac/tests/sbr_real_library.rs:4797` | bare `env::var("HOME").unwrap()` → `unwrap_or_default()` | | ||
| 198 | +| `crates/ec-aac/tests/obs_real_content.rs:151` | same | | ||
| 199 | +| `crates/ec-matroska/tests/matroska.rs:966` | hardcoded absolute manifest path → `fixtures()` | | ||
| 200 | + | ||
| 201 | +No decoder change anywhere. Two new `#[ignore]`s, both previously | ||
| 202 | +red-on-runner and never green. The only assertion removed is the | ||
| 203 | +`ec-probe` minimum count, and removing it RESTORES the contract that file's | ||
| 204 | +own header declares rather than hiding a failure; no other assertion weakened. | ||