XMA: gather frame payloads one byte at a time #1016

Merged
heromike405-arch merged 1 commit from upstream-pr/1016 into main 2026-11-25 00:20:58 +00:00
heromike405-arch commented 2026-11-24 15:05:26 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by heromike405-arch on 2026-11-24T15:05:26Z.


Read complete XMA2 payload bytes directly within a packet. The existing bit reader still handles headers, interleaved streams and the last partial byte.

On Windows x86-64 with Rust 1.98.1, the victory-formats test binary passed 24 tests with four ignored. A synthetic differential check against ffe310e returned identical frame bytes, bit lengths, start positions and next-frame positions for 36,720 cases, including truncated buffers.

Median read_frame time across nine optimized runs on this machine:

Synthetic frame Before After
128 bytes 1.01 µs 0.17 µs
1 KiB 7.98 µs 1.06 µs
1 KiB crossing interleaved packets 7.80 µs 1.07 µs

The benchmark cycles through all eight bit alignments. It measures frame extraction only. Full-workspace CI and in-game playback remain unverified.

<!-- greyfinch-sync:Marvisak/VIctory:issue:6584836650 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1016). Originally posted by [heromike405-arch](https://github.com/heromike405-arch) on 2026-11-24T15:05:26Z. --- Read complete XMA2 payload bytes directly within a packet. The existing bit reader still handles headers, interleaved streams and the last partial byte. On Windows x86-64 with Rust 1.98.1, the victory-formats test binary passed 24 tests with four ignored. A synthetic differential check against ffe310e returned identical frame bytes, bit lengths, start positions and next-frame positions for 36,720 cases, including truncated buffers. Median read_frame time across nine optimized runs on this machine: | Synthetic frame | Before | After | | --- | ---: | ---: | | 128 bytes | 1.01 µs | 0.17 µs | | 1 KiB | 7.98 µs | 1.06 µs | | 1 KiB crossing interleaved packets | 7.80 µs | 1.07 µs | The benchmark cycles through all eight bit alignments. It measures frame extraction only. Full-workspace CI and in-game playback remain unverified.
mercuryVM commented 2026-11-24 16:04:25 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by mercuryVM on 2026-11-24T15:15:55Z.

Review: APPROVED


Tested 03a6f229 on Windows 11, RTX 5070, MSVC: cargo test -p victory-formats 24 passed, including payload_bytes_match_bit_reads_at_packet_edges. cargo clippy -p victory-formats --all-targets -- -D warnings is clean.

  • Differential check: 20,000 seeded random inputs (mono and stereo Decoders, 8 to 608 bytes, random bit lengths) through Decoder::decode on mercuryVM/VIctory main and on this head give the same Ok/Err split (2,102 / 17,898), the same 15,391,232 samples and an identical hash over every sample. The byte path is a pure speedup, malformed streams included.
  • The fast path is taken only strictly inside a packet's payload. At a packet start (headers, other streams' packets) and within 8 bits of the end it falls back to the bit reader, which is where the skipping lives, so the test's edge positions are exactly the cases that matter.

AI-assisted (Claude Code).

<!-- greyfinch-sync:Marvisak/VIctory:review:6041971441 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1016#pullrequestreview-6041971441). Originally posted by [mercuryVM](https://github.com/mercuryVM) on 2026-11-24T15:15:55Z. **Review:** APPROVED --- Tested 03a6f229 on Windows 11, RTX 5070, MSVC: `cargo test -p victory-formats` 24 passed, including `payload_bytes_match_bit_reads_at_packet_edges`. `cargo clippy -p victory-formats --all-targets -- -D warnings` is clean. - Differential check: 20,000 seeded random inputs (mono and stereo `Decoder`s, 8 to 608 bytes, random bit lengths) through `Decoder::decode` on mercuryVM/VIctory main and on this head give the same Ok/Err split (2,102 / 17,898), the same 15,391,232 samples and an identical hash over every sample. The byte path is a pure speedup, malformed streams included. - The fast path is taken only strictly inside a packet's payload. At a packet start (headers, other streams' packets) and within 8 bits of the end it falls back to the bit reader, which is where the skipping lives, so the test's edge positions are exactly the cases that matter. AI-assisted (Claude Code).
Zipettte commented 2026-11-24 16:05:17 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Zipettte on 2026-11-24T15:40:22Z.


Tested on AMD Radeon RX 7700 XT (RDNA3, gfx1101), driver 32.0.32029.2010, Windows 11, Rust 1.98.1 MSVC at 03a6f22: cargo test -p victory-formats passes, 24 passed / 0 failed. Workspace baseline on main (ffe310e) is green on the same machine (342 passed).

Tested with AI assistance (Claude).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7136419226 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1016#issuecomment-7136419226). Originally posted by [Zipettte](https://github.com/Zipettte) on 2026-11-24T15:40:22Z. --- Tested on AMD Radeon RX 7700 XT (RDNA3, gfx1101), driver 32.0.32029.2010, Windows 11, Rust 1.98.1 MSVC at 03a6f22: `cargo test -p victory-formats` passes, 24 passed / 0 failed. Workspace baseline on main (ffe310e) is green on the same machine (342 passed). _Tested with AI assistance (Claude)._
upstream-sync closed this pull request 2026-11-25 01:05:16 +00:00
Sign in to join this conversation.
No reviewers
No labels
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.

Reference
Marvisak/VIctory!1016
No description provided.