Skip superblock directory in awc_extract.py, fixing stereo tracks decoded as mono #33
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/rpatty-dev--PercyStar!33
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/33/head"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@worstgirlinamerica on GitHub · 2026-11-22 03:24 UTC · original
worstgirlinamerica:fix/awc-extract-superblock-stereo→main· +138 −38 · 1 files · 1 commits · merged 2026-11-22 10:20 UTCSummary
awc_extract.py read AWC data chunks flat from byte 0, treating the
superblock directory (0xFFFFFFFF marker + per-block count table) as
[u16 len][payload] Opus packets. Count-table integers in subsequent
blocks can look like valid in-bounds lengths, feeding bogus entries
into the packet list. Channel detection only checked packets[0], so
if a directory misread landed there, its arbitrary bit pattern decided
mono vs. stereo for the whole track -- while duration stayed accurate
(one bad packet among ~10,000), masking the bug entirely.
Confirmed live: unmodified main outputs channels=1 on
sound_4183_2st.awc despite every real audio frame's TOC byte reading
STEREO=True.
Changes
from src/awc.rs (PR #10) so directory bytes are skipped before
packet collection begins
which uses the largest packet -- guards against a leading DTX/silence
frame flipping the decision
_s00_1, ...) instead of silently dropping all but substream 0
collect_2kb_packets walk -- no behavior change on plain/SFX-bank AWCs
Testing
and a manual libopus decode -- all three agree
@worstgirlinamerica on GitHub · 2026-11-22 04:02 UTC · original
I also for extra reference, compared my output against a community .opus rip of the same file / song which results in the exact same file size and type.
This is the community 3.07MB opus file:
vs what this PR resolves for .opus files:
@rpatty-dev on GitHub · 2026-11-22 10:21 UTC · original · edited 2026-11-22 10:30 UTC
Merged onto main and released in v1.4.3! Also optimized
collect_2kb_packetsinscripts/awc_extract.pywithmemoryviewslicing to avoid intermediate block copies, and ported your largest-packet TOC channel fix into nativesrc/awc.rsso the built-in Rust player gets the same stereo fix. Great catch!