This branch predates CI on `main`. `cargo fmt --all` only; no behaviour. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
72 lines
2.7 KiB
Rust
72 lines
2.7 KiB
Rust
//! How many voice regions hold three chunks? A COUNT, stated with its population.
|
|
//!
|
|
//! `voice-region-starts-late.md` published "8 of 10 three-chunk regions start
|
|
//! mid-stream". The port agent counts **25** three-chunk regions. Mine was not a
|
|
//! count: the audit that produced it was cut short and I read a partial file as a
|
|
//! complete one — it ends mid-list with no summary line.
|
|
//!
|
|
//! This does the cheap half properly. It does not step backwards looking for the
|
|
//! clip; it resolves each region once and counts its chunks, and it prints the
|
|
//! population, the coverage and the skips **in the same output** so a truncated run
|
|
//! cannot be mistaken for a complete one.
|
|
//!
|
|
//! cargo run -p sylpheed-formats --example voice_region_chunk_census
|
|
|
|
use std::collections::BTreeMap;
|
|
use sylpheed_formats::media::{self, DirectorySource, DiscSource};
|
|
use sylpheed_formats::movie_manifest;
|
|
use sylpheed_formats::slb::{self, VoiceLang};
|
|
|
|
fn main() {
|
|
let disc = std::env::var("SYLPHEED_DISC").expect("SYLPHEED_DISC");
|
|
let src = DirectorySource::new(std::path::PathBuf::from(&disc));
|
|
let tpak = src.open_pak("dat/tables.pak").expect("tables.pak");
|
|
let manifest = tpak
|
|
.entries()
|
|
.iter()
|
|
.find_map(|e| tpak.read(e).ok().filter(|b| movie_manifest::is_manifest(b)))
|
|
.expect("manifest");
|
|
let movies: Vec<String> = movie_manifest::parse(&manifest)
|
|
.into_iter()
|
|
.map(|m| m.movie)
|
|
.collect();
|
|
let total = movies.len();
|
|
|
|
let mut hist: BTreeMap<usize, Vec<String>> = BTreeMap::new();
|
|
let (mut resolved, mut unresolved, mut unreadable) = (0, 0, 0);
|
|
for movie in movies {
|
|
let Some((start, end)) =
|
|
media::resolve_movie_voice_region(&src, &movie, VoiceLang::English)
|
|
else {
|
|
unresolved += 1;
|
|
continue;
|
|
};
|
|
let Ok(b) = src.read_segment_range("dat/sound", start, (end - start) as usize) else {
|
|
unreadable += 1;
|
|
continue;
|
|
};
|
|
resolved += 1;
|
|
hist.entry(slb::to_xma_riffs(&b).len())
|
|
.or_default()
|
|
.push(movie);
|
|
}
|
|
println!("POPULATION: {total} movies in the manifest");
|
|
println!("COVERAGE: {resolved} resolved and read, {unresolved} unresolved, {unreadable} unreadable");
|
|
println!(
|
|
" {} accounted for\n",
|
|
resolved + unresolved + unreadable
|
|
);
|
|
for (n, ms) in &hist {
|
|
println!(
|
|
" {n} chunk(s): {:>3} region(s) {}",
|
|
ms.len(),
|
|
ms.iter().cloned().collect::<Vec<_>>().join(" ")
|
|
);
|
|
}
|
|
println!(
|
|
"\nTHREE-CHUNK REGIONS: {}",
|
|
hist.get(&3).map(|v| v.len()).unwrap_or(0)
|
|
);
|
|
println!("--- END OF CENSUS (if this line is missing, the run did not finish) ---");
|
|
}
|