Files
Sylpheed/crates/sylpheed-formats/examples/voice_region_chunk_census.rs
sylph-decoder 5f386111ad re: count the voice-region population properly -- 25 three-chunk, and 17 of them were broken
Pays the debt from the truncated audit. The census prints population, coverage
and skips in the same output, and ends with an explicit END line, so a cut-short
run cannot be read as a complete one.

  POPULATION 104 movies; COVERAGE 95 resolved, 9 unresolved, 0 unreadable
  70 one-chunk regions, 25 three-chunk regions

The port's 25 was right; my '8 of 10' was not a count.

Cross-referenced against the fix's own sweep, which also ran to completion
(78 + 17 + 9 = 104): all 17 changed regions are three-chunk, none is one-chunk,
and 8 three-chunk regions were never affected -- which the 1.5 MB cap predicts,
since a region only trips the filter if its span exceeds it.

So 'the defect is specific to the multichannel regions' survives with complete
populations on both sides, while 'all three-chunk regions were broken' does not.
The original 8-of-10 was wrong in its denominator and coincidentally shares a
digit with the 8 that are unaffected, which is the kind of resemblance that
carries a dead number into a later document.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Wuu56cE8vJGTBtn1ppsk8v
2026-08-30 09:46:08 +00:00

51 lines
2.5 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 sylpheed_formats::media::{self, DirectorySource, DiscSource};
use sylpheed_formats::movie_manifest;
use sylpheed_formats::slb::{self, VoiceLang};
use std::collections::BTreeMap;
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) ---");
}