[Audio] ADAT with u16 stream table decodes only 8 bogus streams instead of 503 #37

Closed
opened 2026-11-27 02:32:23 +00:00 by github-bot · 1 comment
Owner

@⁠crexlight on GitHub · 2026-11-22 12:42 UTC · original

PercyStar mis-parses some GTA6 ADAT (.awc) payloads that use a u16 stream table instead of the assumed u32 stream table.

For example this ADAT: audio.rpf/sound_5186_Resident_Frontend__Hud_503st.awc shows only 8 streams (they play garbage instead of proper sound), but it is actually 503 streams there.

Possible root cause
parse_adat_header() computes the chunk-table start as:
let mut off = 16 + sc * 4;
This assumes the stream table contains sc u32 entries. For this bank the stream table is u16[sc], so the chunk table starts at a different 8-byte alignment. PercyStar scans the wrong alignment, happens to find 8 fake 0x55 entries, and therefore skips the backward fallback that would have found the real 503 chunks.

**@⁠crexlight** on GitHub · 2026-11-22 12:42 UTC · [original](https://github.com/rpatty-dev/PercyStar/issues/37) PercyStar mis-parses some GTA6 ADAT (.awc) payloads that use a u16 stream table instead of the assumed u32 stream table. For example this ADAT: `audio.rpf/sound_5186_Resident_Frontend__Hud_503st.awc` shows only 8 streams (they play garbage instead of proper sound), but it is actually 503 streams there. **Possible root cause** `parse_adat_header()` computes the chunk-table start as: `let mut off = 16 + sc * 4;` This assumes the stream table contains `sc u32` entries. For this bank the stream table is `u16[sc]`, so the chunk table starts at a different 8-byte alignment. PercyStar scans the wrong alignment, happens to find 8 fake 0x55 entries, and therefore skips the backward fallback that would have found the real 503 chunks.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 02:32:23 +00:00
Author
Owner

@⁠rpatty-dev on GitHub · 2026-11-22 14:33 UTC · original

Fixed in main (6ca2efe)!

parse_adat_header() in src/awc.rs now evaluates candidate chunk-table offsets (16 + sc * 4 for u32 stream tables, 16 + sc * 2 and 8-byte aligned (16 + sc * 2 + 7) & !7 for u16 stream tables, plus backward fallback from hdr_sz), scoring each candidate by valid 0x55 chunks (sz > 0, coff >= hdr_sz, coff < data.len()), sc match, and minimal bogus tag hits.

Added unit test awc::tests::adat_u16_stream_table_parses_all_streams (66/66 tests passing).

**@⁠rpatty-dev** on GitHub · 2026-11-22 14:33 UTC · [original](https://github.com/rpatty-dev/PercyStar/issues/37#issuecomment-7080636874) Fixed in `main` (`6ca2efe`)! `parse_adat_header()` in `src/awc.rs` now evaluates candidate chunk-table offsets (`16 + sc * 4` for `u32` stream tables, `16 + sc * 2` and 8-byte aligned `(16 + sc * 2 + 7) & !7` for `u16` stream tables, plus backward fallback from `hdr_sz`), scoring each candidate by valid `0x55` chunks (`sz > 0`, `coff >= hdr_sz`, `coff < data.len()`), `sc` match, and minimal bogus tag hits. Added unit test `awc::tests::adat_u16_stream_table_parses_all_streams` (`66/66` tests passing).
This discussion has been locked. Commenting is limited to contributors.
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
github/rpatty-dev--PercyStar#37
No description provided.