Clamping only the last page's granule made it smaller than the previous
page's when the trim target fell before that page started: a 27-packet
real-libopus fixture declared 24,000 frames but decoded 24,960, and the
Ogg granule went 24,960 -> 24,000. Emit the EOS page at the first packet
that reaches pre_skip + length and drop the remaining padding packets.
Also require +0x0C to agree with the interleaved +0 count before using
it, and clamp an oversized pre-skip to the stream length so the final
granule never falls below it.
Measured on real streams: with pre-skip 0, the 5%/10% attack point is
312 samples (30 streams from four banks, median 312; the 10% point ranges
278..868, none near 1920), so the default is measured, not just assumed
from libopus. 20 real streams at 48 and 32 kHz now decode to exactly
their declared counts.
awc_opus.py exports streams with an empty OpusTags header, so players show
only the stream id. opus_tags.py fills that header in place from the
awc_names.py CSV (TITLE) and the text_tables.py dialogue CSV (LABEL,
SPEAKER, SUBTITLE and SUBTITLE_<LANG>). Only page 1 is rewritten; the audio
pages stay byte for byte. Synthetic tests only.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Its dialogue pairs give the 1,019 lines the measured run was missing;
with it the conversation path names 267,800 streams. Also state the
dictionary size and that it came from our own harvest, not hashdict.py.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- decode_grid20_table: 8-byte header (u32 12345678 marker + unknown) and N 20-byte
entries, with the invariants measured on all 1,185 audio.rpf streams that carry
the tag (counter strictly increasing, p a multiple of 32; 387,233 entries,
0 violations).
- decode_index_runs: K groups of {u32 2; u32 len; u32 hash; len ascending u32s}
whose values index the sibling 0x5a entries (804 streams, 4,853 groups,
0 violations, 0 overruns).
- Per-stream tallies in decode_awc_bank and the scan summaries (grid20_*/indexrun_*
keys), facts in _decode_companion_tags; other archives carry 0 of either tag.
- Five synthetic tests (hand-built bytes only); docs rows in rsc8_audio.md,
audio.md and the docs index, hypotheses labelled as such.
The format block carries the per-channel count at +0x0C: equal to +0 for mono
and half of it for stereo in 7,451 measured streams (0 mismatches), matching
rpf9-explorer's OpusFrameCountPerChannel. Use it (with +0/channels as fallback)
instead of inferring the division, and document the field.
OpusHead declared pre-skip 0, so every exported stream started with 312
samples of libopus priming and the end trim removed the same amount of real
audio. Write the lookahead (312 by default, --pre-skip overrides it) and make
the trimmed final granule pre_skip + length.
The plain-stream length also scaled the format tag's sample count by
48000/rate and ignored stereo interleaving. Measured over 1,598,151 plain
streams: packet samples - declared is 1920..2879 for every 48 kHz and 32 kHz
stream, which is only possible if the declared count is already 48 kHz frames;
after halving stereo counts the same 1920..2879 window holds for all 17,983
stereo streams. Scaling a 32 kHz stream by 1.5 left the padding untrimmed.
Tests cover the pre-skip, the 48 kHz frame count, stereo halving and the
--pre-skip bounds. libopus round-trip: the fixed output matches the reference
Ogg sample-for-sample (max |diff| 0); before the fix it was shifted 312
samples and differed by up to 12,188.
AWC stream tables keep only joaat(lowercase name) & 0x1FFFFFFF. With ~1.8M
distinct ids in a 2^29 space, ~0.3% of arbitrary words collide, so
awc_names.py accepts a hit only as an exact dialogue-wave word
(<root>au_<4 letters>_<NN>) or as a numbered family in one bank (3+
members or 2 adjacent, common-token base, one member a dictionary word).
A salted control run estimates the false names and sets each rule's
threshold per source.
The dictionary takes word lists or a hashdict.py JSON, and builds dialogue
wave names from conversation key/label pairs (<key>_01.._N per label).
Banks come from .awc files, directories or rpf9dump's audio_manifest.json.
On 1.0.2.1: 266,781 of 1.85M ids named (story000 73.7%, audio 5.7%),
with 417 control hits. Standard library only; tests are synthetic.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The credited song is the Home Sweet Home mission song, not a radio track. The mission and its localized objective/fail strings are in data.rpf; the song audio is absent from every searched container.
Records the measured coverage (story000 streamed/plain/Bink, movies.rpf Bink, audio.rpf short and all banks, loop banks, packs/data/script/common inflated, raw levels.rpf ADAT/KB2), the 19,807-file / 653-hour Chromaprint sweep with its tempo range, the positive controls, the 12 joaat(burn) data hashes that are not audio, and the remaining levels.rpf/RSC8 uncertainty. No game audio or localized strings are included.
README: audio row now says lossless Ogg Opus, PCM codec 0/2 as WAV, XMA2 via ffmpeg and 16-bit --wav; D3D12 row reflects the design doc and xmem/d3d12_xs shims with no device proxy; LLVM_MC is documented as a whole command; link the two new docs. docs/audio.md covers the ADAT layout, tags, codecs, exporters, song/station/venue distinctions and the no-sharing rule. docs/related_projects.md records the PercyStar and americas-recomp licence boundaries.