Skip to content

rsc8_audio: the AWC start/end cue records matched into region pairs, record by record (ASSET-320) - #5518

Open
zzEmmazz wants to merge 1 commit into
ItsNotRexed:mainfrom
zzEmmazz:asset-320-awc-region-pairs
Open

zzEmmazz wants to merge 1 commit into
ItsNotRexed:mainfrom
zzEmmazz:asset-320-awc-region-pairs

Conversation

@zzEmmazz

Copy link
Copy Markdown
Contributor

ASSET-320, claimed in the coordination issue: #5361 (comment)

What and why

docs/rsc8_audio.md said that five AWC cue names store joaat("start") or joaat("end") in their value word
"in equal or near-equal numbers (196/197, 101/101, 54/54, 49/49, 20/19), which reads as region start/end pairs",
and labelled it a hypothesis because the split was counted, not matched. This matches them record by record.

  • tools/rsc8_audio.py: marker_records (the raw records of a 0xbd tag), pair_marker_regions (the matching)
    and marker_region_overlaps. Every scan summary gets a marker_regions block: per name hash the starts, ends,
    pairs, each kind of exception and the pair lengths (min / median / max in samples); pairs per tag; overlaps
    between names; and a list of the exceptions with where each sits in its tag. Counts, sample offsets and 32-bit
    hashes only. No new option and no new output file.
  • The rule: inside one tag, take the records of one name in stored order; a pair is a start whose next record
    of the same name is an end at the same or a later offset. Every other record of such a name is an exception
    (start_without_end, end_without_start, end_before_start, other_value), so per name
    starts == pairs + start_without_end + end_before_start and the same for ends. Tags that fail the existing
    checks (size, offsets never decrease) are counted as marker_invalid as before and are not paired.
  • docs/rsc8_audio.md: the hypothesis sentence is replaced by a "Region cues" section with the counts below.
  • No file in common with docs, tools: the AWC 0xBD marker events of the music banks, awc_markers.py (ASSET-303) #3916 (tools/awc_markers.py, which counts these records per type); either can land
    first.

Measured

audio.rpf of the Xbox Series 1.0.2.1 package, whole archive: 7,162 banks, 1,606,241 streams, 420,168 0xbd
tags, 781,350 records, 0 invalid (the page's existing numbers; the summary differs from main's only in the new
block). 22 tags hold region cues: 841 records of the five names, 420 start, 420 end, one with a third value.

Name Tags start end Pairs Not paired Pair length in samples (min / median / max)
0xda559149 22 196 197 196 1 end 172,602 / 857,823 / 3,899,077
0x1df219ec 1 101 101 101 none 25,289 / 95,237 / 497,606
0x77edd3a2 1 54 54 53 1 start, 1 end, the record with the third value 44,984 / 90,546 / 209,958
0x994ee645 1 49 49 49 none 22,233 / 93,644 / 212,156
0xccb465d1 1 20 19 19 1 start 36,146 / 92,928 / 186,375
Total 22 420 420 418 5 records
  • 418 pairs; 20 of 22 tags pair completely; a tag holds 1 to 181 pairs (median 3). The five exceptions are in
    two tags. The 54/54 name has two unpaired records, so equal counts did not prove the pairing.
  • 0xda559149: a second end 16,717 samples after the end that closes the region before it (record 744 of
    1,435).
  • 0x77edd3a2: a start (record 40 of 834) followed 118,171 samples later by a record of the same name whose
    value is 0xdaa2d5ec, the only value on these names that is neither word. Hypothesis: it closes the region.
  • 0xccb465d1: a start (record 773 of the same tag, the last of its name) directly followed by a 0x77edd3a2
    end that no start opens (record 774), 114,697 samples later. Hypothesis: one region whose two records
    carry different names. Both distances are inside the pair lengths of the names involved.
  • No exception is a region left open at an edge of its tag: none is the tag's first or last record, and the
    unclosed 0xccb465d1 start is 18,219,408 samples before its tag's last offset.
  • No zero-length pair; extra is the same on both records of all 418 pairs.
  • Regions of different names overlap: 54 pairs of regions share samples, 43 nested and 11 crossing, all between
    0xda559149 and one of the other four (13 / 7, 19 / 4, 2 / 0, 9 / 0). The other four never overlap each other.
  • None of the 22 streams has a 0x76 tag, so there is no sample count to compare a region's end with.
  • story000.rpf, shared_minigame000.rpf and story000_restofworld.rpf (226,788, 1,959 and 22 0xbd tags):
    no record with either value.

Reproduce (prints the summary; nothing is written):

python -I tools/rsc8_audio.py <package>\audio.rpf --summary-only --quiet

Tested

  • python -I tests/test_rsc8_audio.py: 46 tests, OK (35 before, 11 new in MarkerRegionsTest). The new tests
    build their records and banks by hand: well-formed pairs (touching and zero-length ones included), an unmatched
    start, an unmatched end, an end before its start (in record order and in offsets), nesting inside one name,
    two names interleaved (crossing, nested, touching), a third value, and the bank / archive / directory /
    single-bank / CLI JSON paths with the merged counts and the listed exceptions.

  • Negative control: the same test file against main's tools/rsc8_audio.py (3faac557): the 11 new tests
    error, the 35 old ones pass.

  • python -m compileall -q make_game.py tools tests; tests/test_docs_links.py (6), test_docs_repo_paths.py
    (2), test_docs_list_items.py (2), test_docs_design_rows.py (4), test_text_write_line_endings.py (3),
    test_audio_config.py (21), test_awc_manifest.py (18), test_file_mode.py (5, 2 skipped),
    test_rpf9_carve.py (17): all OK.

  • Full scans on Windows 11, Python 3.14.0: audio.rpf (28.5 GB) in 57, 58 and 87 s over three runs (the tests
    were running beside the last one), against 55 s for main's tool on the same file; story000.rpf in 37 s. The
    pairing was also run by a second walk of the archive (bank by bank, reading only the 0xbd tags) with the
    same per-name counts, and the overlap counts were checked against a brute-force comparison of every two
    regions in a tag.

  • No GPU involved.

  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.

Not checked

  • The words behind the five names and behind 0xdaa2d5ec; nothing was tried against game strings.
  • The two hypotheses about the exceptions, and what a region does in the game.
  • Positions against the stream's length: these 22 streams have no 0x76 tag and the tool does not read the
    streamed-music descriptor, so "at the edge" is judged against the tag's own records. Lengths are not converted
    to seconds for the same reason.
  • Other platforms or package versions.

AI-assisted.

…cord by record (ASSET-320)

docs/rsc8_audio.md read the near-equal start/end counts on five cue names
(196/197, 101/101, 54/54, 49/49, 20/19) as region pairs and labelled it a
hypothesis, because the split was counted and not matched. pair_marker_regions()
matches them: inside one 0xbd tag, a pair is a start whose next record of the
same name is an end at the same or a later offset; every other record of such
a name is an exception. Every scan summary gets a marker_regions block (per
name hash: starts, ends, pairs, exceptions by kind, pair lengths; pairs per
tag; overlaps between names; where each exception sits in its tag). Counts,
sample offsets and 32-bit hashes only.

Measured over all of audio.rpf (7,162 banks, 420,168 0xbd tags, 781,350
records): 841 region records in 22 tags, 420 start, 420 end, one third value;
418 pairs, 20 of 22 tags pair completely, 5 exceptions in two tags, none at
an edge of its tag. The other three archives with ADAT banks have none.

Tests build their records and banks by hand.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@Kev-Ball

Copy link
Copy Markdown

The streamed-music descriptors provide a length check for all 22 region-cue tags. I scanned the complete 1.0.2.1 audio archive at 2e214199 (7,162 banks, 420,168 marker tags). For each region-bearing tag I joined its stream ID to the channel IDs returned by awc_opus.music_channels(..., collect_packets=False) within the same bank. Every tag had exactly one matching channel; all 22 were stereo Opus at 48 kHz.

Using the decoded per-channel frame count (the helper accounts for the descriptor’s interleaved count), all 418 region starts, all 418 ends, all five exceptions, and the final marker record of each of the 22 tags were strictly between zero and that channel’s length. For the five exceptions, the smallest distance to either boundary was 17,556,673 in those sample units. That rules out an exception at sample zero or at the declared channel end under the sample-offset interpretation. It leaves the meaning of the unmatched cue records open.

CPU only, CachyOS, AI-assisted (OpenAI Codex). Aggregate measurements only.

@zzEmmazz

Copy link
Copy Markdown
Contributor Author

@Kev-Ball thanks, that closes the one item this PR listed as not checkable from its own tool: rsc8_audio.py has no length for these 22 streams (no 0x76 tag), so "not at an edge" was only judged against the tag's own records. With the descriptor lengths from awc_opus.music_channels it now holds against the stream itself: all 418 pairs and the five exceptions strictly inside, the nearest exception 17,556,673 samples from a boundary. I'm leaving the head as it is so the checks stay valid; the page's "no sample count to compare with" sentence can take your result in a follow-up once #3916 (which reads the same descriptor) is in.

AI-assisted.

@kacper-serewis kacper-serewis left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AI-assisted CPU review at 2e21419 using the existing bank-header parser and an independent cue matcher. All 418 pairs across 22 retail tags matched on both record indices and both endpoint timestamps. All five exceptions matched (two unmatched starts, two unmatched ends, one other value). Exhaustive comparison found 43 contained and 11 crossing overlaps. Of the contained overlaps, 26 shared an endpoint. Two additional cross-name pairs only touched and shared zero samples. No consecutive same-name cue records tied in timestamp. The proposed alternate closures remain hypotheses.

@Kam471 Kam471 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review at head 2e2141993 (Windows 11).

Commands:

python -I -m pytest tests/test_rsc8_audio.py -q
git diff --check 3faac557b..HEAD

Results: 46 passed; diff --check clean.

Negative control: copied this PR's test file into a clean 3faac557b worktree and ran the same command against main's tools/rsc8_audio.py — 11 failed, 35 passed. Every new MarkerRegionsTest fails on main, so the tests do exercise the new pairing; the 35 existing tests are unaffected.

The change is additive (marker_regions block; no new option/file). Per-name invariants (starts == pairs + start_without_end + end_before_start) are asserted by the tests, and the fast 0xbd walk only adds records.

Verdict: approve. The docs section matches the measured table; no file overlap with #3916.

@shayderrr shayderrr left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review

Reviewed change in PR #5518: rsc8_audio: the AWC start/end cue records matched into region pairs, record by record (ASSET-320).

Scope: docs/rsc8_audio.md, tests/test_rsc8_audio.py, tools/rsc8_audio.py
Diff: +617 / -13 across 3 file(s).

The change stays inside the stated scope and the touched files line up with the description. No unrelated production paths are pulled in, and the stated behavior is directly exercised by the diff. I'm approving this one.

Reviewed by shayderrr via automated batch review.

@shayderrr

Copy link
Copy Markdown
Collaborator

Thanks @zzEmmazz - I went through rsc8_audio: the AWC start/end cue records matched into region pairs, record by record (... and the diff around docs/rsc8_audio.md. The change is tight, the rationale matches the code, and there's nothing here that needs another pass from my side. Approved and squash-merging it into main now. Nice work.

@ramenbellic

ramenbellic commented Nov 23, 2026 •

Copy link
Copy Markdown

Merging the current head 2e2141993 onto main 867d922f0 changes no file: main already has this change. There's nothing left to merge, so it can be closed.

(Checked with git merge-tree --write-tree main <head>: the result is identical to main's tree.)

(PR cleanup: #8919.) AI-assisted (Claude Code).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants