tests: close the rest of the real-media-library class (4 sites)
Browse files at this commitb1bc5d62b6a0a86d14e8700824f8ae9a3aeddbeeParent: fcb9ffb5 changed files +349 -99
- crates/ec-aac/tests/obs_real_content.rs +70 -16
- crates/ec-aac/tests/sbr_real_library.rs +189 -63
- crates/ec-matroska/tests/matroska.rs +49 -16
- crates/ec-probe/tests/library.rs +14 -1
- lanes/h264reallib.report.md +27 -3
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 | 28 | .args(["-v", "error", "-i"]) |
| 29 | 29 | .arg(path) |
| 30 | 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 | 41 | .output() |
| 34 | 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 | 48 | let samples: Vec<f32> = out |
| 37 | 49 | .stdout |
| 38 | 50 | .chunks_exact(4) |
| @@ -48,7 +60,10 @@ fn ffmpeg_decode(path: &Path, channels: usize) -> Vec<Vec<f32>> { | ||
| 48 | 60 | fn extract_aac_track(path: &Path) -> Option<(Vec<u8>, Vec<Vec<u8>>)> { |
| 49 | 61 | let f = File::open(path).ok()?; |
| 50 | 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 | 67 | let idx = aac.index; |
| 53 | 68 | let asc = aac.params.extradata.as_ref()?.to_vec(); |
| 54 | 69 | let mut aus = Vec::new(); |
| @@ -90,11 +105,18 @@ fn our_decode(path: &Path) -> Option<Vec<Vec<f32>>> { | ||
| 90 | 105 | } |
| 91 | 106 | } |
| 92 | 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 | 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 | 122 | fn correlation(a: &[f32], b: &[f32]) -> f64 { |
| @@ -114,14 +136,28 @@ fn correlation(a: &[f32], b: &[f32]) -> f64 { | ||
| 114 | 136 | |
| 115 | 137 | fn best_lag_correlation(ours: &[f32], theirs: &[f32]) -> (i64, f64) { |
| 116 | 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 | 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) }; | |
| 120 | - if oa + len > ours.len() || ob + len > theirs.len() { None } else { Some((oa, ob)) } | |
| 145 | + let (oa, ob) = if lag >= 0 { | |
| 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 | 156 | let mut coarse_best = (0i64, -1.0f64, 0.0f64); |
| 123 | 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 | 161 | let c = correlation(&ours[oa..oa + COARSE], &theirs[ob..ob + COARSE]); |
| 126 | 162 | if c.abs() > coarse_best.1 { |
| 127 | 163 | coarse_best = (lag, c.abs(), c); |
| @@ -129,7 +165,9 @@ fn best_lag_correlation(ours: &[f32], theirs: &[f32]) -> (i64, f64) { | ||
| 129 | 165 | } |
| 130 | 166 | let mut best = (coarse_best.0, -1.0f64, 0.0f64); |
| 131 | 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 | 171 | let c = correlation(&ours[oa..oa + WINDOW], &theirs[ob..ob + WINDOW]); |
| 134 | 172 | if c.abs() > best.1 { |
| 135 | 173 | best = (lag, c.abs(), c); |
| @@ -148,7 +186,13 @@ fn obs_content_table() { | ||
| 148 | 186 | eprintln!("skip: no ffmpeg"); |
| 149 | 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 | 196 | let Ok(rd) = std::fs::read_dir(&dir) else { |
| 153 | 197 | eprintln!("skip: no {}", dir.display()); |
| 154 | 198 | return; |
| @@ -188,11 +232,21 @@ fn obs_content_table() { | ||
| 188 | 232 | let rows = &all_rows[before..]; |
| 189 | 233 | let (mut pns, mut is_, mut ms, mut tns, mut cpe) = (0usize, 0usize, 0usize, 0usize, 0usize); |
| 190 | 234 | for r in rows { |
| 191 | - if r.pns_bands > 0 { pns += 1; } | |
| 192 | - if r.is_bands > 0 { is_ += 1; } | |
| 193 | - if r.ms_bands > 0 { ms += 1; } | |
| 194 | - if r.tns_present { tns += 1; } | |
| 195 | - if r.is_cpe { cpe += 1; } | |
| 235 | + if r.pns_bands > 0 { | |
| 236 | + pns += 1; | |
| 237 | + } | |
| 238 | + if r.is_bands > 0 { | |
| 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 | 251 | eprintln!( |
| 198 | 252 | " tools over {} AUs: cpe={cpe} pns_aus={pns} is_aus={is_} ms_aus={ms} tns_aus={tns}", |
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 | 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 | 447 | const COARSE: usize = 4_096; |
| 442 | 448 | let start = ours |
| 443 | 449 | .len() |
| @@ -2111,7 +2117,10 @@ fn our_decode_core_only(path: &Path, stream_index: usize) -> Option<(Vec<Vec<f32 | ||
| 2111 | 2117 | if dump && au_idx < 40 { |
| 2112 | 2118 | for c in 0..ch { |
| 2113 | 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 | 2124 | / plane.len().max(1) as f64) |
| 2116 | 2125 | .sqrt(); |
| 2117 | 2126 | eprintln!( |
| @@ -2229,7 +2238,11 @@ fn core_only_matches_reference() { | ||
| 2229 | 2238 | if at_edge { |
| 2230 | 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 | 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 | 2441 | eprintln!("SKIP: ffmpeg not on PATH"); |
| 2429 | 2442 | return; |
| 2430 | 2443 | } |
| 2431 | - let dir = std::env::var("EC_AAC_HEAAC_FIXTURES").unwrap_or_else(|_| { | |
| 2432 | - format!("{}/../../.cache/heaac-fixtures", env!("CARGO_MANIFEST_DIR")) | |
| 2433 | - }); | |
| 2444 | + let dir = std::env::var("EC_AAC_HEAAC_FIXTURES") | |
| 2445 | + .unwrap_or_else(|_| format!("{}/../../.cache/heaac-fixtures", env!("CARGO_MANIFEST_DIR"))); | |
| 2434 | 2446 | let dir = PathBuf::from(dir); |
| 2435 | 2447 | if !dir.is_dir() { |
| 2436 | 2448 | eprintln!( |
| @@ -2444,8 +2456,21 @@ fn synthetic_heaac_matrix() { | ||
| 2444 | 2456 | } |
| 2445 | 2457 | println!( |
| 2446 | 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", | |
| 2448 | - "core_v_ref", "cvr_lag", "core_rate", "full_rate" | |
| 2459 | + "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 | 2475 | // Wide enough that the WIDE_LAG_MAX==LC's own decoder priming delay |
| 2451 | 2476 | // (2048) plus a full SBR-chain worth of extra delay (a few thousand |
| @@ -2479,8 +2504,7 @@ fn synthetic_heaac_matrix() { | ||
| 2479 | 2504 | let o = &ours[0]; |
| 2480 | 2505 | let t = &theirs[0]; |
| 2481 | 2506 | const TOPK: usize = 5; |
| 2482 | - let (mut lag, mut full, edge) = | |
| 2483 | - robust_lag_topk(o, t, WIDE_LAG_MAX, our_rate, TOPK); | |
| 2507 | + let (mut lag, mut full, edge) = robust_lag_topk(o, t, WIDE_LAG_MAX, our_rate, TOPK); | |
| 2484 | 2508 | assert!( |
| 2485 | 2509 | !edge, |
| 2486 | 2510 | "{}: {profile} row's refined winning lag {lag} sits at the \ |
| @@ -2504,8 +2528,11 @@ fn synthetic_heaac_matrix() { | ||
| 2504 | 2528 | if profile == "HE" && ours.len() >= 2 && theirs.len() >= 2 { |
| 2505 | 2529 | let mono_o: Vec<f32> = |
| 2506 | 2530 | ours[0].iter().zip(&ours[1]).map(|(a, b)| a + b).collect(); |
| 2507 | - let mono_t: Vec<f32> = | |
| 2508 | - theirs[0].iter().zip(&theirs[1]).map(|(a, b)| a + b).collect(); | |
| 2531 | + let mono_t: Vec<f32> = theirs[0] | |
| 2532 | + .iter() | |
| 2533 | + .zip(&theirs[1]) | |
| 2534 | + .map(|(a, b)| a + b) | |
| 2535 | + .collect(); | |
| 2509 | 2536 | let (mono_lag, _, mono_edge) = |
| 2510 | 2537 | robust_lag_topk(&mono_o, &mono_t, WIDE_LAG_MAX, our_rate, TOPK); |
| 2511 | 2538 | assert!( |
| @@ -2548,7 +2575,9 @@ fn synthetic_heaac_matrix() { | ||
| 2548 | 2575 | } else { |
| 2549 | 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 | 2581 | let above = if n >= 1024 { |
| 2553 | 2582 | correlation( |
| 2554 | 2583 | &highpass(&o[oa..oa + n], our_rate, crossover_hz), |
| @@ -2886,8 +2915,14 @@ fn sbr_real_library_matches_reference() { | ||
| 2886 | 2915 | let high = if n >= 1024 { |
| 2887 | 2916 | let oh = highpass(&o[oa..oa + n], rate, c.crossover_hz); |
| 2888 | 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(); | |
| 2890 | - println!(" ch{ch} above-crossover RMS ours/ref = {:.4}", rms(&oh) / rms(&th).max(1e-12)); | |
| 2918 | + let rms = |v: &[f32]| { | |
| 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 | 2926 | correlation(&oh, &th) |
| 2892 | 2927 | } else { |
| 2893 | 2928 | 0.0 |
| @@ -3154,7 +3189,10 @@ fn sbr_real_library_matches_reference() { | ||
| 3154 | 3189 | ci += c.im; |
| 3155 | 3190 | } |
| 3156 | 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 | 3198 | let mean_in = |rows: &[(usize, f64)], lo: usize, hi: usize| { |
| @@ -3559,7 +3597,10 @@ fn sbr_actual_noise_fraction() { | ||
| 3559 | 3597 | // has nonzero entries for QMF bands up to `k2`). |
| 3560 | 3598 | let band_hz = f64::from(rate) / 128.0; |
| 3561 | 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 | 3604 | println!( |
| 3564 | 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 | 3753 | ffmpeg_stream: c.ffmpeg_stream, |
| 3713 | 3754 | }) |
| 3714 | 3755 | .collect(); |
| 3715 | - let fixtures = std::env::var("EC_AAC_HEAAC_FIXTURES").unwrap_or_else(|_| { | |
| 3716 | - format!("{}/../../.cache/heaac-fixtures", env!("CARGO_MANIFEST_DIR")) | |
| 3717 | - }); | |
| 3756 | + let fixtures = std::env::var("EC_AAC_HEAAC_FIXTURES") | |
| 3757 | + .unwrap_or_else(|_| format!("{}/../../.cache/heaac-fixtures", env!("CARGO_MANIFEST_DIR"))); | |
| 3718 | 3758 | let fixtures = PathBuf::from(fixtures); |
| 3719 | 3759 | if fixtures.is_dir() { |
| 3720 | 3760 | for rate in [48_000u32, 44_100] { |
| @@ -3746,8 +3786,25 @@ fn sbr_header_feature_table() { | ||
| 3746 | 3786 | const WIDE_LAG_MAX: i64 = 20_000; |
| 3747 | 3787 | println!( |
| 3748 | 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", | |
| 3750 | - "ifrq", "smooth", "envs", "invf", "harm", "df%", "corr" | |
| 3789 | + "stream", | |
| 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 | 3809 | for r in &rows { |
| 3753 | 3810 | let before = ec_aac::sbr_sideinfo_log().len(); |
| @@ -3760,7 +3817,11 @@ fn sbr_header_feature_table() { | ||
| 3760 | 3817 | continue; |
| 3761 | 3818 | } |
| 3762 | 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 | 3825 | if frames.is_empty() { |
| 3765 | 3826 | eprintln!("SKIP {}: no sideinfo rows captured", r.label); |
| 3766 | 3827 | continue; |
| @@ -3772,13 +3833,24 @@ fn sbr_header_feature_table() { | ||
| 3772 | 3833 | let mut df_total = 0usize; |
| 3773 | 3834 | let mut df_ones = 0usize; |
| 3774 | 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 | 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 | 3845 | any_harmonic = true; |
| 3779 | 3846 | } |
| 3780 | 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 | 3855 | let df_pct = if df_total > 0 { |
| 3784 | 3856 | 100.0 * df_ones as f64 / df_total as f64 |
| @@ -3790,20 +3862,36 @@ fn sbr_header_feature_table() { | ||
| 3790 | 3862 | .map(|(k, v)| format!("{k}x{v}")) |
| 3791 | 3863 | .collect::<Vec<_>>() |
| 3792 | 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 | 3870 | let theirs = ffmpeg_decode(&r.path, r.ffmpeg_stream, ours.len()); |
| 3795 | 3871 | let (_, corr) = best_lag_correlation_wide(&ours[0], &theirs[0], WIDE_LAG_MAX); |
| 3796 | 3872 | println!( |
| 3797 | 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, | |
| 3799 | - f0.freq_scale, f0.alter_scale, f0.noise_bands, f0.limiter_bands, f0.limiter_gains, | |
| 3800 | - f0.interpol_freq, f0.smoothing_mode, envs_hist, invf_str, | |
| 3801 | - any_harmonic, df_pct, corr | |
| 3802 | - ); | |
| 3803 | - println!( | |
| 3804 | - " patches (frame0): {:?}", | |
| 3805 | - f0.patch_lengths | |
| 3874 | + r.label, | |
| 3875 | + our_rate, | |
| 3876 | + f0.kx, | |
| 3877 | + f0.k2, | |
| 3878 | + f0.xover_band, | |
| 3879 | + f0.start_freq, | |
| 3880 | + f0.stop_freq, | |
| 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 | 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 | 3970 | return; |
| 3879 | 3971 | } |
| 3880 | 3972 | |
| @@ -3949,9 +4041,8 @@ fn per_au_low_band_divergence() { | ||
| 3949 | 4041 | for c in &candidates() { |
| 3950 | 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(|_| { | |
| 3953 | - format!("{}/../../.cache/heaac-fixtures", env!("CARGO_MANIFEST_DIR")) | |
| 3954 | - }); | |
| 4044 | + let dir = std::env::var("EC_AAC_HEAAC_FIXTURES") | |
| 4045 | + .unwrap_or_else(|_| format!("{}/../../.cache/heaac-fixtures", env!("CARGO_MANIFEST_DIR"))); | |
| 3955 | 4046 | let failing = PathBuf::from(&dir).join("heaac_44100_48k.m4a"); |
| 3956 | 4047 | if failing.exists() { |
| 3957 | 4048 | per_au_low_band_probe("synthetic 44100 48k (failing)", &failing, 0); |
| @@ -4097,7 +4188,9 @@ fn probe_explicit_config_and_wide_lag() { | ||
| 4097 | 4188 | let theirs = ffmpeg_decode(&path, ffmpeg_stream, hand_planes.len()); |
| 4098 | 4189 | if let (Some(o), Some(t)) = (hand_planes.first(), theirs.first()) { |
| 4099 | 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 | 4204 | "{home}/Downloads/reelp/reelp.mkv" |
| 4112 | 4205 | )); |
| 4113 | 4206 | if fmj.exists() { |
| 4114 | - if let (Some((core, core_rate)), Some((full, sbr, full_rate))) = ( | |
| 4115 | - our_decode_core_only(&fmj, 1), | |
| 4116 | - our_decode(&fmj, 1), | |
| 4117 | - ) { | |
| 4207 | + if let (Some((core, core_rate)), Some((full, sbr, full_rate))) = | |
| 4208 | + (our_decode_core_only(&fmj, 1), our_decode(&fmj, 1)) | |
| 4209 | + { | |
| 4118 | 4210 | if sbr == ec_aac::SbrSupport::V1 { |
| 4119 | 4211 | let up: Vec<f32> = core[0].iter().flat_map(|&s| [s, s]).collect(); |
| 4120 | 4212 | let cutoff = f64::from(core_rate) * 0.4; |
| @@ -4239,9 +4331,8 @@ fn coupled_cpe_channel_swap_probe() { | ||
| 4239 | 4331 | eprintln!("SKIP: ffmpeg not on PATH"); |
| 4240 | 4332 | return; |
| 4241 | 4333 | } |
| 4242 | - let dir = std::env::var("EC_AAC_HEAAC_FIXTURES").unwrap_or_else(|_| { | |
| 4243 | - format!("{}/../../.cache/heaac-fixtures", env!("CARGO_MANIFEST_DIR")) | |
| 4244 | - }); | |
| 4334 | + let dir = std::env::var("EC_AAC_HEAAC_FIXTURES") | |
| 4335 | + .unwrap_or_else(|_| format!("{}/../../.cache/heaac-fixtures", env!("CARGO_MANIFEST_DIR"))); | |
| 4245 | 4336 | let path = PathBuf::from(&dir).join("heaac_44100_48k.m4a"); |
| 4246 | 4337 | if !path.exists() { |
| 4247 | 4338 | eprintln!("SKIP: {} absent", path.display()); |
| @@ -4256,7 +4347,10 @@ fn coupled_cpe_channel_swap_probe() { | ||
| 4256 | 4347 | let ref_r = ffmpeg_decode_pan_channel(&path, 0, 1); |
| 4257 | 4348 | { |
| 4258 | 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 | 4354 | let (lag, corr) = best_lag_correlation_wide(&ref_l, &ref_r, SEARCH_LAG_MAX); |
| 4261 | 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 | 4423 | let (core_lag0, core_corr0) = |
| 4330 | 4424 | best_lag_correlation_wide(&core_planes[0], &ref_core[0], SEARCH_LAG_MAX); |
| 4331 | 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 | 4429 | let mono_ours: Vec<f32> = ours[0].iter().zip(&ours[1]).map(|(a, b)| a + b).collect(); |
| 4334 | 4430 | let mono_ref: Vec<f32> = { |
| 4335 | 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 | 4438 | let (mono_lag, mono_corr) = best_lag_correlation_wide(&mono_ours, &mono_ref, SEARCH_LAG_MAX); |
| 4339 | 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 | 4449 | // corr=0.873 above). So the TRUE best lag among our 4 candidates is |
| 4350 | 4450 | // whichever one actually maximizes the fixed-lag mono correlation, not |
| 4351 | 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 | 4461 | for (lag, label) in fixed_lags { |
| 4354 | 4462 | let c0l = correlation_at_lag(&ours[0], &ref_l, lag); |
| 4355 | 4463 | let c0r = correlation_at_lag(&ours[0], &ref_r, lag); |
| @@ -4398,7 +4506,9 @@ fn coupled_cpe_channel_swap_probe() { | ||
| 4398 | 4506 | } |
| 4399 | 4507 | let cl = correlation(&ours[0][oa..oa + step], &ref_l[ob..ob + step]); |
| 4400 | 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 | 4512 | w += 1; |
| 4403 | 4513 | } |
| 4404 | 4514 | } |
| @@ -4569,9 +4679,8 @@ fn sbr441_family_sample_drift_probe() { | ||
| 4569 | 4679 | eprintln!("SKIP: ffmpeg not on PATH"); |
| 4570 | 4680 | return; |
| 4571 | 4681 | } |
| 4572 | - let dir = std::env::var("EC_AAC_HEAAC_FIXTURES").unwrap_or_else(|_| { | |
| 4573 | - format!("{}/../../.cache/heaac-fixtures", env!("CARGO_MANIFEST_DIR")) | |
| 4574 | - }); | |
| 4682 | + let dir = std::env::var("EC_AAC_HEAAC_FIXTURES") | |
| 4683 | + .unwrap_or_else(|_| format!("{}/../../.cache/heaac-fixtures", env!("CARGO_MANIFEST_DIR"))); | |
| 4575 | 4684 | let home = std::env::var("HOME").unwrap_or_default(); |
| 4576 | 4685 | let cases: [(&str, PathBuf, i64); 3] = [ |
| 4577 | 4686 | ( |
| @@ -4690,9 +4799,8 @@ fn sbr_hf_window_band_probe() { | ||
| 4690 | 4799 | eprintln!("SKIP: ffmpeg not on PATH"); |
| 4691 | 4800 | return; |
| 4692 | 4801 | } |
| 4693 | - let dir = std::env::var("EC_AAC_HEAAC_FIXTURES").unwrap_or_else(|_| { | |
| 4694 | - format!("{}/../../.cache/heaac-fixtures", env!("CARGO_MANIFEST_DIR")) | |
| 4695 | - }); | |
| 4802 | + let dir = std::env::var("EC_AAC_HEAAC_FIXTURES") | |
| 4803 | + .unwrap_or_else(|_| format!("{}/../../.cache/heaac-fixtures", env!("CARGO_MANIFEST_DIR"))); | |
| 4696 | 4804 | let path = PathBuf::from(&dir).join("heaac_48000_64k.m4a"); |
| 4697 | 4805 | if !path.exists() { |
| 4698 | 4806 | eprintln!("SKIP: {} absent", path.display()); |
| @@ -4748,7 +4856,10 @@ fn sbr_hf_window_band_probe() { | ||
| 4748 | 4856 | let mean_t: f64 = mags_t.iter().sum::<f64>() / 8.0; |
| 4749 | 4857 | println!( |
| 4750 | 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 | 4905 | if !have_ffmpeg() { |
| 4795 | 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 | 4915 | // `EC_AAC_SBR_LOCATOR_FILE` points the same instrument at any other |
| 4799 | 4916 | // HE-AAC file (e.g. a mono, uncoupled, noise-only probe encode). |
| 4800 | 4917 | let path = std::env::var("EC_AAC_SBR_LOCATOR_FILE") |
| @@ -4803,7 +4920,9 @@ fn sbr_residual_locator() { | ||
| 4803 | 4920 | if !path.exists() { |
| 4804 | 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 | 4926 | let theirs = ffmpeg_decode(&path, 0, ours.len()); |
| 4808 | 4927 | const W: usize = 2048; |
| 4809 | 4928 | const FFT_LEN: usize = 2048; |
| @@ -4815,7 +4934,12 @@ fn sbr_residual_locator() { | ||
| 4815 | 4934 | let n = ours[ch].len().min(theirs[ch].len()); |
| 4816 | 4935 | let (o, t) = (&ours[ch][..n], &theirs[ch][..n]); |
| 4817 | 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 | 4943 | .collect(); |
| 4820 | 4944 | wins.sort_by(|a, b| a.0.partial_cmp(&b.0).unwrap()); |
| 4821 | 4945 | println!("ch{ch} worst windows (corr, frame): {:?}", &wins[..12]); |
| @@ -4865,7 +4989,9 @@ fn sbr_residual_locator() { | ||
| 4865 | 4989 | } |
| 4866 | 4990 | } |
| 4867 | 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 | 4995 | edges.extend((9..=22).map(|i| ((i as f64 * 1000.0) / hz) as usize)); |
| 4870 | 4996 | for e in edges.windows(2) { |
| 4871 | 4997 | let (mut c, mut po, mut pt) = (0.0, 0.0, 0.0); |
crates/ec-matroska/tests/matroska.rsmodified+49 -16
| @@ -32,7 +32,9 @@ fn aac_priming_round_trips_through_codec_delay() { | ||
| 32 | 32 | let dst = work().join("aac-priming-round-trip.mkv"); |
| 33 | 33 | let mut muxer = MatroskaMuxer::new(File::create(&dst).expect("output")); |
| 34 | 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 | 38 | for _ in 0..10i64 { |
| 37 | 39 | let mut packet = Packet::new(0, rate, vec![0u8; 8]); |
| 38 | 40 | packet.duration = Some(1024); |
| @@ -44,7 +46,8 @@ fn aac_priming_round_trips_through_codec_delay() { | ||
| 44 | 46 | let demuxer = |
| 45 | 47 | MatroskaDemuxer::new(BufReader::new(File::open(&dst).expect("opens"))).expect("reopens"); |
| 46 | 48 | assert_eq!( |
| 47 | - demuxer.streams()[0].initial_padding, 1024, | |
| 49 | + demuxer.streams()[0].initial_padding, | |
| 50 | + 1024, | |
| 48 | 51 | "CodecDelay round trips to a sample count" |
| 49 | 52 | ); |
| 50 | 53 | } |
| @@ -802,7 +805,11 @@ fn truncated_prefixes_are_eof_not_corrupt() { | ||
| 802 | 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 | 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 | 833 | /// Where our own demuxer's seek lands on a real 5.1 E-AC-3 Matroska, in |
| 828 | 834 | /// *timestamp* -- split from decode, per the round's charter: this measures |
| 829 | 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 | 969 | #[test] |
| 964 | 970 | #[ignore = "sweeps his real library, run manually with --ignored"] |
| 965 | 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 | 978 | let Ok(rows) = std::fs::read_to_string(manifest) else { |
| 968 | 979 | eprintln!("skipped: {} not present", manifest.display()); |
| 969 | 980 | return; |
| @@ -987,8 +998,7 @@ fn laced_audio_sweep_across_his_library() { | ||
| 987 | 998 | if !film.exists() { |
| 988 | 999 | continue; |
| 989 | 1000 | } |
| 990 | - let Ok(mut demux) = | |
| 991 | - MatroskaDemuxer::new(BufReader::new(File::open(film).expect("opens"))) | |
| 1001 | + let Ok(mut demux) = MatroskaDemuxer::new(BufReader::new(File::open(film).expect("opens"))) | |
| 992 | 1002 | else { |
| 993 | 1003 | eprintln!("{path}: failed to open"); |
| 994 | 1004 | continue; |
| @@ -1004,8 +1014,7 @@ fn laced_audio_sweep_across_his_library() { | ||
| 1004 | 1014 | for frac in [0.3, 0.7] { |
| 1005 | 1015 | let want = duration * frac; |
| 1006 | 1016 | let target = Timestamp::new( |
| 1007 | - (want * audio.time_base.den() as f64 / audio.time_base.num() as f64).round() | |
| 1008 | - as i64, | |
| 1017 | + (want * audio.time_base.den() as f64 / audio.time_base.num() as f64).round() as i64, | |
| 1009 | 1018 | audio.time_base, |
| 1010 | 1019 | ); |
| 1011 | 1020 | if demux |
| @@ -1096,8 +1105,8 @@ fn real_hdr_film_container_states_no_light_metadata() { | ||
| 1096 | 1105 | // duplication, pts) or the shared decoder crate, and which physical channel |
| 1097 | 1106 | // our 5.1 decode calls "channel 0". |
| 1098 | 1107 | |
| 1099 | -use ec_ac3::Ac3Decoder; | |
| 1100 | 1108 | use ec_aac::AacDecoder; |
| 1109 | +use ec_ac3::Ac3Decoder; | |
| 1101 | 1110 | |
| 1102 | 1111 | /// Opens whichever container `path` actually is — both crates implement the |
| 1103 | 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 | 1118 | .read_exact(&mut head) |
| 1110 | 1119 | .expect("read head"); |
| 1111 | 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 | 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 | 1216 | .args(["-v", "error", "-i"]) |
| 1202 | 1217 | .arg(path) |
| 1203 | 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 | 1229 | .output() |
| 1207 | 1230 | .expect("ffmpeg runs"); |
| @@ -1251,8 +1274,14 @@ fn best_lag_correlation(ours: &[f32], theirs: &[f32]) -> (i64, f64) { | ||
| 1251 | 1274 | let mut best_abs = -1.0f64; |
| 1252 | 1275 | let mut best = (0i64, 0.0f64); |
| 1253 | 1276 | for lag in -LAG_MAX..=LAG_MAX { |
| 1254 | - let (oa, ob) = if lag >= 0 { (0usize, lag as usize) } else { ((-lag) as usize, 0usize) }; | |
| 1255 | - let len = WINDOW.min(ours.len().saturating_sub(oa)).min(theirs.len().saturating_sub(ob)); | |
| 1277 | + let (oa, ob) = if lag >= 0 { | |
| 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 | 1285 | if len < 1024 { |
| 1257 | 1286 | continue; |
| 1258 | 1287 | } |
| @@ -1387,7 +1416,11 @@ fn mkv_51_channel_order() { | ||
| 1387 | 1416 | pkts.iter().take(5).map(|(p, _)| *p).collect::<Vec<_>>() |
| 1388 | 1417 | ); |
| 1389 | 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 | 1424 | let ffref = ffmpeg_decode_planar(path, planes.len()); |
| 1392 | 1425 | for (i, ch) in planes.iter().enumerate() { |
| 1393 | 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 | 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 | 505 | let mut rows = Vec::new(); |
| 493 | 506 | let mut failures = Vec::new(); |
lanes/h264reallib.report.mdmodified+27 -3
| @@ -76,6 +76,7 @@ still stands, and still holds, on the machine that can run it (it did: 15 ≥ 3) | ||
| 76 | 76 | Verified — the target is no longer red, and the reason is printed verbatim: |
| 77 | 77 | |
| 78 | 78 | ``` |
| 79 | + | |
| 79 | 80 | test real_library_streams_match_ffmpeg ... ignored, sweeps the PERSONAL media |
| 80 | 81 | library (~/Videos, ~/Downloads, ~/Music) through the gitignored |
| 81 | 82 | fixtures/real-library-manifest.tsv; MINUTES of wall time (measured past 840 s on |
| @@ -169,12 +170,35 @@ with a soft skip, so it is harmless today, and it also silently defeats | ||
| 169 | 170 | worktree isolation. Worth converting to the relative form if that ignore is ever |
| 170 | 171 | lifted. |
| 171 | 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 | + | |
| 172 | 190 | ## Change list |
| 173 | 191 | |
| 174 | 192 | | file | change | |
| 175 | 193 | |---|---| |
| 176 | 194 | | `crates/ec-h264/tests/conformance.rs:1870` | `#[ignore = "…"]` + 25-line reason above the test; assertion untouched | |
| 177 | 195 | | `crates/ec-aac/tests/oracle.rs:688` | `#[ignore = "…"]` + reason; identical shape, assertion untouched | |
| 178 | - | |
| 179 | -No decoder change. No new `#[ignore]` beyond the two class members above (both | |
| 180 | -were red-on-runner, never green). No assertion weakened anywhere. | |
| 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. |