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>
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>
@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>
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>
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>
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.
csv.writer and csv.DictWriter default to lineterminator="\r\n", and every
one of these tools opens its report with newline="", which turns that into
CRLF on Windows and LF elsewhere: the same archive gave different report
bytes depending on the machine that exported it. awc_manifest and awc_shorts
already pin "\n" and bink_index documents why its stdout writer needs it, so
this brings the remaining 16 writers onto the same convention. A structural
test keeps new writers on it, and three tools are run end to end to check the
bytes.
Generated with Codebuff 🤖
Co-Authored-By: Codebuff <noreply@codebuff.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.
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>
On Windows a redirected stdout uses the console's ANSI code page, and python -I ignores PYTHONUTF8 and
PYTHONIOENCODING, so a caller path with a character outside that code page ended a run with
UnicodeEncodeError as soon as a tool printed it. #1406 fixed make_game.py; every CLI tool in tools/ now starts
its __main__ block the same way (stdout errors="replace").
tests/test_tool_stdout_encoding.py checks every tool's __main__ block and reruns two measured crashes
(analyze_4240_full.py, meshlet_page.py) with a private-use-named input. Found by @abilliontokens.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- 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.
awc_manifest, rsc8_audio and classify_carve stage their report in a 0600
temp file and os.replace it, so on POSIX the report ended up 0600.
rbf0_tree had its own copy of the umask(0)/umask(mask) read that file_mode
replaced (#750). All four now use file_mode.published_mode, and
tests/test_file_mode.py covers them with the other writers.