Preserve fractional-millisecond decoder evidence in timing evaluator
This commit is contained in:
1 parent
2c3c91179b
commit
f15ee07ed0
2 files changed
+35
-5
No files matched your search
@@ -60,6 +60,18 @@ fn file_hash(path: &Path) -> Result<String> {
|
||||
}
|
||||
Ok(format!("{:x}", state.finalize()))
|
||||
}
|
||||
fn validate_sample_coverage(samples: usize, duration_ms: u32) -> Result<()> {
|
||||
let expected = duration_ms as usize * 16;
|
||||
ensure!(
|
||||
samples > 0
|
||||
&& samples <= 480000
|
||||
&& expected > 0
|
||||
&& expected <= 480000
|
||||
&& samples.abs_diff(expected) <= 16,
|
||||
"Fixture source clock coverage differs beyond existing one-millisecond bound"
|
||||
);
|
||||
Ok(())
|
||||
}
|
||||
fn write_new(path: &Path, value: &Value) -> Result<()> {
|
||||
let mut file = fs::OpenOptions::new()
|
||||
.write(true)
|
||||
@@ -174,16 +186,13 @@ fn run_case(
|
||||
let mut source_windows = Vec::new();
|
||||
for window in windows(metadata.audio_start_ms, metadata.audio_end_ms, max_windows)? {
|
||||
let pcm = decode_audio_aligned(&assets.tools, &path, window, &limits)?;
|
||||
ensure!(
|
||||
pcm.len() == window.duration_ms as usize * 16,
|
||||
"Fixture source clock coverage differs"
|
||||
);
|
||||
validate_sample_coverage(pcm.len(), window.duration_ms)?;
|
||||
let sha = hash(
|
||||
&pcm.iter()
|
||||
.flat_map(|value| value.to_le_bytes())
|
||||
.collect::<Vec<_>>(),
|
||||
);
|
||||
let record = json!({"asset":id,"start_ms":window.start_ms,"duration_ms":window.duration_ms,"samples":pcm.len(),"pcm_sha256":sha});
|
||||
let record = json!({"asset":id,"start_ms":window.start_ms,"duration_ms":window.duration_ms,"samples":pcm.len(),"nominal_samples":window.duration_ms as usize*16,"coverage_difference_samples":pcm.len() as i64-i64::from(window.duration_ms)*16,"pcm_sha256":sha});
|
||||
expected.entry(sha).or_default().push(record.clone());
|
||||
source_windows.push(record);
|
||||
}
|
||||
@@ -487,6 +496,13 @@ mod tests {
|
||||
assert!(values.iter().all(|window| window.duration_ms <= 30000));
|
||||
}
|
||||
#[test]
|
||||
fn fractional_millisecond_tail_preserves_real_samples() {
|
||||
assert!(validate_sample_coverage(32618, 2039).is_ok());
|
||||
assert!(validate_sample_coverage(32607, 2039).is_err());
|
||||
assert!(validate_sample_coverage(0, 1).is_err());
|
||||
assert!(validate_sample_coverage(480001, 30000).is_err());
|
||||
}
|
||||
#[test]
|
||||
#[ignore = "Requires the five hash-verified real media fixture files; no inference"]
|
||||
fn timing_mode_preflight_checks_all_real_frozen_sources_without_models() -> Result<()> {
|
||||
let root = Path::new(env!("CARGO_MANIFEST_DIR")).join("../../../fixtures/media");
|
||||
|
||||
Reference in new issue
Block a user