Commit Graph

22 Commits

Author SHA1 Message Date
01f04caccf rsc8_audio: restore writable mode before removing staging file on failure 2026-11-24 20:57:44 +08:00
1f4d841f69 rsc8_audio: keep scan progress off JSON stdout (#6776)
Squash-merged after diff review of PR #6776 - rsc8_audio: send archive scan progress to stderr
2026-11-23 09:59:13 -06:00
0a8a5522f9 Invalidate previous music cue regions before a bank re-export (#6867)
Squash-merged after diff review of PR #6867 - Invalidate previous music cue regions before a bank re-export
2026-11-23 09:48:53 -06:00
1f79ba5093 Merge pull request #3591 from kotorvr
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 23:07:56 -05:00
c295b5772c rsc8_audio --curves: decode only structurally valid clips; no resource copy
Review on #3591: a clip whose first block size was cut to its header
(valid False) still had its keyframes decoded, and a block grown into
the next block's header passed both. Keyframes are now decoded only
when the clip is valid and no two blocks, or a block and the track
directory, share a byte; otherwise the clip counts as a curve error
("structural checks failed" / "block or track extents overlap").
decode_facial_curves decodes a contiguous view in place instead of
copying the whole resource (a non-contiguous view is still copied).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 22:18:58 +00:00
9aa16b2e39 Merge pull request #3591 from kotorvr 2026-11-22 17:02:53 -05:00
2d5d73a42b Merge pull request #3257 from zGLados 2026-11-22 17:01:08 -05:00
0a0e8182c9 rsc8_audio: the facial keyframes are anim_clips sequences; count them with --curves
docs/rsc8_audio.md listed the keyframe curves inside the RSC8 0x5c blocks
as undecoded. A packed block is one sequence of docs/animation.md (0x20
header, version 2, 11 channel types) and the track directory's constant
0x364D3BDB is joaat("facialtranslation"), so tools/anim_clips.py already
reads them. decode_facial_curves() hands a clip's blocks to that decoder
and --curves counts the outcome for every clip (counts only).

On one 1.0.2.1 package all 641,428 clips decode and 88,012,668 of
88,012,668 type-10 chunk boundaries close.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-22 20:38:09 +00:00
1f5a7c0fd0 Merge pull request #3272 from kotorvr 2026-11-22 15:16:23 -05:00
e3b3a7367a Merge pull request #3257 from zGLados 2026-11-22 15:16:15 -05:00
c6cdc785c2 rsc8_audio: frame the 0x5a entries as {position, pitch, ...} with an f32 trailer
@kotorvr's finding in #3232: the entries start 4 bytes earlier than the
decoder read them. Each is {u32 sample position, f32 value, 6 x u16},
and the table ends in an f32 trailer (2/3 on 1,182 streams). Read 4
bytes later, every entry paired one entry's fields with the next one's
position, the first position looked like a header "unknown" and the
trailer looked like the last counter.

Recounted on my copy: positions ascend strictly and stay below the 0x76
sample count on all 1,185 streams; one entry lasts one period of its
value (within 1% on 365,803 of 386,048 pairs), so value reads as a
pitch in Hz; p is a multiple of 512 on every entry.

decode_grid20_table returns position_first/last/increasing and the
trailer as tail_f32; the tally key becomes grid20_position_past_samples.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 21:09:56 +01:00
4cf7e3e718 rsc8_audio: decode the AWC 0xbd tag as cue records, not a header with a magic
The tool read only the first word of a 0xbd tag and called it a magic
(0xE5C74063); docs/rsc8_audio.md described the tag as a 16-byte header.
Over all of audio.rpf the tag is a headerless list of 16-byte records
{name joaat, value, sample offset, extra}, sorted by offset, and that
value is the first word of only 88,082 of 420,168 tags.

decode_marker_records() decodes the list, every scan counts it in new
marker_* summary keys, and the doc carries the measured counts. The
record layout and the tag-id rule (low byte of the chunk name's joaat)
were read in TrinitronClient/GTA6-Asset-Info structure/03-audio-awc.md
(029e4c3) and re-measured here; no code was copied.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-22 19:57:12 +00:00
5027156fef rsc8_audio: the 0x5a counter is a sample position; the last entry holds an f32 (ASSET-256)
Over all 1,185 audio.rpf streams with a 0x5a table, the counter of every
entry but the last ascends strictly and stays below the stream's 0x76
sample count (largest 0.9986 of it). The last entry holds an f32 at +16
(2/3 on 1,182 streams), about 1.06e9 read as a u32, which made the
counter look 2^11-2^13 times finer than a sample.

decode_grid20_table reports that float as tail_f32 and leaves the last
entry out of the counter checks; the scan tallies
grid20_counter_past_samples (0 over the package). docs/rsc8_audio.md
records the measurement.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 20:54:05 +01:00
10c1c407dc rsc8_audio: use max(run) for non-ascending 0xd9 runs and avoid empty-run overruns
In tools/rsc8_audio.py decode_index_runs(), index_max was updated from run[-1] (missing out-of-range values on non-ascending runs like [100, 0]) and initialized to 0 instead of None (falsely reporting indices_within_grid=False when values==0 and grid_entries==0). Track max(run) starting from None, treat empty runs as within-grid, and add synthetic regression tests.
2026-11-22 17:18:49 +00:00
1b7adb4451 Merge pull request #1483 from abilliontokens
# Conflicts:
#	docs/README.md
2026-11-22 07:07:51 -05:00
7099cf520f rsc8_audio: decode the undocumented 0x5a/0xd9 AWC companion tags
- 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.
2026-11-22 03:41:52 -08:00
58f695ac55 Merge pull request #1457 from Rafael 2026-11-22 06:38:08 -05:00
4e87570eef rsc8_audio: --start/--limit window edges
Two problems with archive windows, both on main:

- A bank that starts inside the window but ends past it added its full size to adat_bytes, so
  adat_bytes could exceed span. adat_bytes is now the window's bytes that belong to a bank; the
  bank is still decoded whole, and its bytes past the window are adat_bytes_past_window
  (adat_banks_past_window counts such banks).
- A window starting inside a bank never saw that bank's header, so every RSC8 clip in the rest of
  it was reported as rsc8_outside_adat. The scan now looks back from --start (at most
  MAX_AWC_FILE_BYTES) for the nearest bank header; if that bank covers --start, its range is
  known (offset in window_starts_in_bank) and its bytes inside the window count in adat_bytes,
  but it is not counted as a bank of this window.

With both, adjacent windows add up to a full scan.

Real data (counts only), each archive cut into 7 adjacent windows, every cut 4 KiB inside a bank
that holds RSC8 clips:
- shared_minigame000.rpf: main reports 18 clips outside ADAT and one window with adat_bytes >
  span; with this change 0 and 0, and banks / clips / adat_bytes equal the full scan
  (638 / 1,957 / 359,078,504).
- story000_restofworld.rpf: main reports 9 clips outside ADAT; now 0, totals equal the full scan
  (15 / 9 / 8,908,216).
Full scans are unchanged.

Tests: test_window_edges_inside_a_bank ends a window halfway through a bank (main: adat_bytes
9784 for a 4892-byte span), checks the two halves add up to the bank, and starts windows inside
the bank with a 256-byte scan chunk so the look-back crosses several chunks.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 08:29:21 -03:00
3162124c62 rsc8_audio: accept zero-stream ADAT banks (ASSET-105)
- parse_adat_header_bytes/parse_adat_at_file rejected count == 0 outright, so the validated
  walk missed audio.rpf's two 20-byte zero-stream banks that the encrypted TOC lists and
  AwcRecovery.ReadValidated accepts (docs said 7,160 banks vs design.md's 7,162).
- A zero-stream bank is now accepted only when the flag-selected tables end exactly at the
  declared header size; slop, truncation and out-of-bounds stay rejected.
- Three synthetic tests (no game bytes); docs/rsc8_audio.md corpus row updated to the
  re-measured 7,162 banks / 28,505,691,532 bytes with a note on the layout.
2026-11-22 03:18:52 -08:00
0ec3d8bc42 rsc8_audio: prevent the report from overwriting its input 2026-11-22 05:04:40 -03:00
ab0d061652 rsc8_audio: skip malformed files in scan_dir and omit duration check under --no-deep
(cherry picked from commit 2575a9bf4eb0013e0ba55115f5bd342b9ce0f96b)
2026-11-22 00:33:44 -05:00
9d74f443a4 ASSET-56: decode RSC8 (v8001) AWC 0x5c facial/lip-sync resources
Add stdlib-only decoder tools/rsc8_audio.py, 15 synthetic unit tests in tests/test_rsc8_audio.py, and full-corpus layout/count documentation in docs/rsc8_audio.md (641,428/641,428 valid across 4 archives, 0 outside ADAT, 0 embedded audio containers).
2026-11-22 00:51:12 -03:00