80 findings, not the 14 the first run showed -- clippy stops at the first failing compilation unit, so `--keep-going` is what makes the list complete. 60 were machine-applicable (`cargo clippy --fix`). The rest by hand: * five descending `sort_by` -> `sort_by_key(Reverse(..))` * `chunks_exact(4)` on both sides of four zips, so the compared items stay `[u8; 4]` rather than one array against one slice * three `type` aliases for the census maps and the captured-quad tuple * `&PathBuf` -> `&Path` in two disc tests * two range loops; one of them keeps `#[allow(needless_range_loop)]` with the reason -- the index is into a map's value, which changes each iteration * the module doc list in `invert_capture` re-indented to markdown's rules * `blit`'s eight arguments get `#[allow(too_many_arguments)]`, not a struct One dead `let off = b.len();` in a `ratc` test is dropped rather than renamed. The sibling test at :162 is the one that asserts an offset; if this one was meant to as well, that is a test change and not a lint fix. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
89 lines
3.2 KiB
Rust
89 lines
3.2 KiB
Rust
//! Does `resolve_movie_voice_region` start inside the first stream, disc-wide?
|
|
//!
|
|
//! Verified on `ADV`: the resolver starts **238 packets (487 424 B) late**, and
|
|
//! extending the span by exactly that reproduces the running decoder's three
|
|
//! byte_sizes to the byte. The decoder is the ground truth there, but it exists
|
|
//! for one movie only — so this asks a structural question instead.
|
|
//!
|
|
//! **If the region began at a stream boundary, stepping the start backwards would
|
|
//! immediately expose the PREVIOUS asset's chunks.** If it began mid-stream, the
|
|
//! first chunk instead *grows*, packet for packet, until the real boundary. The
|
|
//! number of packets it grows for is the clip.
|
|
//!
|
|
//! cargo run -p sylpheed-formats --example voice_region_start_audit
|
|
|
|
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();
|
|
|
|
println!(
|
|
"{:10} {:>8} {:>12} {:>10} verdict",
|
|
"movie", "chunks", "first chunk", "clip pkts"
|
|
);
|
|
let (mut clipped, mut clean, mut skipped) = (0, 0, 0);
|
|
for movie in movies {
|
|
let Some((start, end)) =
|
|
media::resolve_movie_voice_region(&src, &movie, VoiceLang::English)
|
|
else {
|
|
skipped += 1;
|
|
continue;
|
|
};
|
|
// ONE read of the region plus a lead-in, then slide inside it. Re-reading
|
|
// several MB per step made this too slow to finish at all.
|
|
const LEAD: u64 = 600 * 2048;
|
|
let lead = LEAD.min(start);
|
|
let buf = match src.read_segment_range(
|
|
"dat/sound",
|
|
start - lead,
|
|
(end - (start - lead)) as usize,
|
|
) {
|
|
Ok(b) => b,
|
|
Err(_) => {
|
|
skipped += 1;
|
|
continue;
|
|
}
|
|
};
|
|
let at = |back: usize| -> Vec<Vec<u8>> {
|
|
let off = lead as usize - back * 2048;
|
|
slb::to_xma_riffs(&buf[off..])
|
|
};
|
|
let base_riffs = at(0);
|
|
if base_riffs.is_empty() {
|
|
skipped += 1;
|
|
continue;
|
|
}
|
|
let n0 = base_riffs.len();
|
|
let first0 = base_riffs[0].len() - 60;
|
|
let mut clip = 0usize;
|
|
for k in 1..=(lead as usize / 2048) {
|
|
if at(k).len() != n0 {
|
|
break;
|
|
}
|
|
clip = k;
|
|
}
|
|
let verdict = if clip == 0 {
|
|
clean += 1;
|
|
"starts at a boundary"
|
|
} else {
|
|
clipped += 1;
|
|
"STARTS MID-STREAM"
|
|
};
|
|
println!("{movie:10} {n0:>8} {first0:>12} {clip:>10} {verdict}");
|
|
}
|
|
println!("\nclipped {clipped} clean {clean} skipped {skipped}");
|
|
}
|