`cargo fmt --all -- --check` has failed on every run in this repository's history, identically on `main` and on every branch. This is #12. Mechanical: `cargo fmt --all`, nothing else. 154 files, all `.rs`, no other extension touched. `cargo check --workspace` exits 0 afterwards, so nothing changed semantically. ON THE ORDERING, WHICH WAS THE REAL QUESTION. HANDOFF-2026-09-06 section 7 warns this is the expensive fix: a whole-tree reformat before #7 and #8 return "would put a conflict in every file of 861 commits and make the reviews those items exist to enable unreadable". That is measurably too pessimistic, and it had been reasoned rather than tested. Measured here by three-way merging a rustfmt'd `main` against both unmerged branches, file by file: file/branch pairs tested 32 merges CLEAN 28 merges CONFLICTING 4 (8 conflict hunks total) sylpheed-cli/src/main.rs 1 hunk sylpheed-export/src/check.rs 1 sylpheed-export/src/screen.rs 4 sylpheed-export/src/video.rs 2 All four are against `auto/frame-blend-draw-path` only; `auto/port-p6-audio` does not conflict anywhere. The earlier framing -- 154 dirty files, 133 that cannot collide, 21 that can, the collision set carrying 147 of 774 hunks (19%) -- reproduces exactly. What it did not say is that most of the 21 still merge cleanly, because rustfmt's edits and the branches' edits rarely land on the same lines. So the cost of sweeping now is 4 files and 8 hunks for one branch, against a check that is otherwise red forever. Deliberately NOT folded into the WASM PR: 154 reformatted files would make that one unreviewable. Closes #12
88 lines
4.1 KiB
Rust
88 lines
4.1 KiB
Rust
//! How many sub-waves does each resupply voice bank hold?
|
|
//!
|
|
//! The corpus records `VOICE_D_452` as the binding the game rejected in-game
|
|
//! ("wrong recording"), and separately notes that `VOICE_D_453`/`454` decode to
|
|
//! 0.14 s / 0.43 s — "far too short for the spoken line". Both observations are
|
|
//! explained if these banks are multi-sub-wave and the extractor plays only the
|
|
//! first. This prints the shape so that stops being a guess.
|
|
use sylpheed_formats::{slb, PakArchive};
|
|
|
|
fn main() {
|
|
let disc = std::env::var("SYLPHEED_DISC").expect("set SYLPHEED_DISC");
|
|
let snd = PakArchive::open(format!("{disc}/dat/sound.pak")).expect("sound.pak");
|
|
println!(
|
|
"{:<14} {:>7} {:>6} {:>6} {:>7} sub-wave data sizes",
|
|
"bank", "bytes", "RIFFs", "waves", "cover"
|
|
);
|
|
for n in 450..=454 {
|
|
for dir in ["etc", "Voice", "Movie"] {
|
|
let path = format!("eng\\{dir}\\VOICE_D_{n}.slb");
|
|
let Some(entry) = snd.find_by_name(&path) else {
|
|
continue;
|
|
};
|
|
let bytes = snd.read(entry).expect("read");
|
|
let riffs = slb::to_xma_riffs(&bytes);
|
|
let sizes: Vec<usize> = riffs.iter().map(|r| r.len()).collect();
|
|
// How many RIFF magics does the bank actually contain, versus how
|
|
// many sub-waves the walker recovered? A gap means the walk stops
|
|
// early, and the missing bytes are the missing audio.
|
|
let magics = bytes.windows(4).filter(|w| *w == b"RIFF").count();
|
|
let covered: usize = sizes.iter().sum();
|
|
// What are the UNCOVERED bytes? If the tail past the last data
|
|
// chunk is all zero it is padding and the short duration is real;
|
|
// if it is high-entropy it is audio the parse is throwing away.
|
|
let last = bytes
|
|
.windows(4)
|
|
.rposition(|w| w == b"data")
|
|
.map(|i| {
|
|
let sz = u32::from_le_bytes(bytes[i + 4..i + 8].try_into().unwrap()) as usize;
|
|
(i + 8 + sz).min(bytes.len())
|
|
})
|
|
.unwrap_or(0);
|
|
// Where does the RIFF structure START? If it begins far into the
|
|
// file, the uncovered bytes are a leading region the parse skips,
|
|
// not a missed sub-wave.
|
|
let first_riff = bytes.windows(4).position(|w| w == b"RIFF").unwrap_or(0);
|
|
let datas = bytes.windows(4).filter(|w| *w == b"data").count();
|
|
// Is the leading region padding, or content? Padding is nearly all
|
|
// zero and uses few distinct byte values.
|
|
let head = &bytes[..first_riff];
|
|
let head_zero = head.iter().filter(|b| **b == 0).count();
|
|
let head_distinct = {
|
|
let mut seen = [false; 256];
|
|
for b in head {
|
|
seen[*b as usize] = true;
|
|
}
|
|
seen.iter().filter(|s| **s).count()
|
|
};
|
|
let tail = &bytes[last..];
|
|
let zeros = tail.iter().filter(|b| **b == 0).count();
|
|
// Dump the first bytes of the leading region so its structure is
|
|
// visible rather than guessed at.
|
|
let hex: String = head
|
|
.iter()
|
|
.take(48)
|
|
.map(|b| format!("{b:02x}"))
|
|
.collect::<Vec<_>>()
|
|
.join(" ");
|
|
println!(" head[0..48] {hex}");
|
|
println!(
|
|
"{:<14} {:>7} {:>6} {:>6} {:>6.1}% 1st RIFF @{:>6} data chunks {} head {:>5.1}% zero/{:>3} distinct tail {:>5} B ({:>5.1}% zero) {:?}",
|
|
format!("VOICE_D_{n}"),
|
|
bytes.len(),
|
|
magics,
|
|
riffs.len(),
|
|
100.0 * covered as f64 / bytes.len() as f64,
|
|
first_riff,
|
|
datas,
|
|
if head.is_empty() { 0.0 } else { 100.0 * head_zero as f64 / head.len() as f64 },
|
|
head_distinct,
|
|
tail.len(),
|
|
if tail.is_empty() { 0.0 } else { 100.0 * zeros as f64 / tail.len() as f64 },
|
|
sizes
|
|
);
|
|
break;
|
|
}
|
|
}
|
|
}
|