Skip to content

[BUNDLE] Formats (XMA, BCPack, texture detiling): 12 PRs, #96 #172 #183 #351 #364 #603 #629 #658 #992 #993 #1016 #1205 - #1452

Closed
MamaLeVrai wants to merge 25 commits into
Marvisak:mainfrom
MamaLeVrai:bundle/formats
Closed

MamaLeVrai wants to merge 25 commits into
Marvisak:mainfrom
MamaLeVrai:bundle/formats

Conversation

@MamaLeVrai

Copy link
Copy Markdown

One PR in place of 12. Twelve PRs on victory-formats: XMA decoding (frame boundaries, loops, tables, bit reads, VLC), BCPack (BC7 dictionary indices) and texture detiling. Every head is merged unchanged onto main (ffe310e), and the result is built and tested together.

For reviewers and for anyone verifying with an agent (Claude, Codex, a person): this is a [BUNDLE] PR. The re-verification commands are below, so one run covers all of it.

What is inside

PR Author Head Title
#96 tedin7 ba42db643 xma: start the frame after a continuation at the next packet that has frames
#172 TG0000 4eb0898b3 XMA: cache IMDCT rotation tables per subframe size
#183 AnoHunted d4d182204 XMA: noise tests, and end a frame at its data instead of looping forever
#351 pedrofort 93a24b7cd Formats: reject overlapping texture depth slices
#364 pedrofort e50375659 XMA: accelerate VLC decoding with an eight-bit prefix lookup
#603 AwsAli05 705a2f634 Formats: inline repeated micro-tile copies when detiling textures
#629 AlanQiang0418 350f91c23 Reject multisampled linear texture layouts
#658 coderanonymus 0ecaa8cb9 BCPack: read BC7 dictionary indices from the right offset
#992 NATON4 87f7cb894 Formats: XMA bit reads of 0 or more than 32 bits do not overflow a shift
#993 TG0000 64b80c310 Formats: share immutable texture swizzle tables
#1016 heromike405-arch 03a6f2290 XMA: gather frame payloads one byte at a time
#1205 geiyiliyabumo d3867e689 Formats: add 7 invariant unit tests for xma/tables.rs

All of them merge with no conflict and no change of mine.

Left out, and why

Verification

Windows 11, RX 6950 XT, Rust 1.98.1 (the pinned toolchain):

Check Result
cargo clippy --workspace --all-targets --locked -- -D warnings clean
cargo clippy --workspace --all-targets --all-features --locked -- -D warnings clean
cargo test --workspace --locked 365 passed, 0 failed, 8 ignored (main: 342 passed, 6 ignored)

The title was not run, so this says nothing about in-game effect. No game data is used or committed.

Re-verify in one go

git fetch https://github.com/MamaLeVrai/VIctory.git bundle/formats
git checkout FETCH_HEAD
cargo clippy --workspace --all-targets --locked -- -D warnings
cargo clippy --workspace --all-targets --all-features --locked -- -D warnings
cargo test --workspace --locked

To confirm that no component PR moved since this was built, compare each Head above with gh pr view <n> --repo Marvisak/VIctory --json headRefOid. If one differs, the branch needs a rebuild: merge the new head in the same order.

If this lands

The component heads are in the history unchanged, so each PR's commits and authorship are kept and GitHub should mark them merged. Merging them one by one instead works too, with the exceptions noted above.

AI-assisted (Claude Code); no game data.

🤖 Generated with Claude Code

tedin7 and others added 25 commits November 24, 2026 01:26
… frames

A frame that ends in a packet where no frame begins (the tail of a frame that crossed packets, then padding) left the next frame pointing into that padding, which ended the stream early. Now the next frame is found by following each packet's skip to the next packet with frames.
imdct_half worked out every pre- and post-rotation with sin_cos on each
call (n of them per subframe) and ran its FFT on two fresh Vecs. The
rotations, the bit-reversed order and the butterfly rotations now come
from a table built once for 128, 256 and 512 samples; the work buffers
live on the stack. Every value is computed with the same expression (the
butterflies with the same running product), so the output is bit for
bit what it was.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Decoder::decode took the caller's bit count as the end of the frame. Past
the data the bit reader returns zeros, and a stereo tile header reading
only zeros gives the subframe to no channel, so it never moves on; with a
count beyond the data it never overreads either, and looped for good.
Clamp the end to the bits the data holds. A frame from read_frame always
holds its bits, so its decoding does not change.

Add deterministic noise tests (xorshift64, fixed seeds, as BCPack's):
buffers of noise packets, streams of noise frames with clean and damaged
headers, frames in mono and stereo at each sample rate, bit counts past the
data, and read_frame and packet at any offset. Every walk is bounded and
every decode must give one frame of samples. The bit-count test hangs
without the fix; the others pass on main.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Each BC7 dictionary entry has two more bytes after the two index widths.
They repeat the widths in all entries but the first. The parser read
them as pixel 0 of set 0, so every index was off by one: pixel 0 was 4
in 253 of 255 entries, and set 0's last pixel landed in set 1, which no
entry uses. Any BC7 block whose index reference points into the
dictionary was built on the wrong indices.

Skip the two bytes and read 16 indices for set 0 and 15 for set 1. The
table size does not change. The new test checks the shipped table: a
set with 0 bits holds no indices, and pixel 0 is a valid anchor.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: GPT 6.2 Sol <noreply@openai.com>
`Bits::signed(0)` shifted by 32 (a panic in debug builds) and
`Bits::signed(n)` / `Bits::read(n)` for n > 32 underflowed `32 - n`.
Zero bits now read as 0; past 32 bits the low 32 are the value and all
n bits are consumed, for both. Widths 1 to 32 read as before.

No caller reaches these widths today (the decoder clamps to two channels,
so the widest read is 16 bits and `signed` is only called with 6); this
keeps a later caller or a damaged stream from panicking the decoder.
The new test panics on the old code and passes now.

Closes Marvisak#907.
Read complete payload bytes directly inside an XMA2 packet. Keep the bit reader for packet headers, interleaved stream skips and the final partial byte. Add coverage for all eight alignments at packet boundaries and EOF. On Windows x86-64, 36,720 synthetic reads matched the previous implementation, including returned bytes and the next frame position. A release microbenchmark of read_frame measured 1009 to 168 ns for 128-byte frames and 7977 to 1062 ns for 1 KiB frames (median of nine runs).
Merges Marvisak#96 Marvisak#172 Marvisak#183 Marvisak#351 Marvisak#364 Marvisak#603 Marvisak#629 Marvisak#658 Marvisak#992 Marvisak#993 Marvisak#1016 Marvisak#1205 onto
main (ffe310e), each head unchanged, no conflicts, no changes of mine.
cargo clippy --workspace --all-targets --locked -- -D warnings, with and
without --all-features, is clean and cargo test --workspace --locked passes
(365 passed, 8 ignored; main has 342 passed, 6 ignored).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings November 24, 2026 18:06

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@Marvisak

Copy link
Copy Markdown
Owner

Automated triage for the maintainers. Closing because this pull request re-packages other open pull requests. Each of those is reviewed on its own, so a bundle cannot be merged.

If this is mistaken, reply here with what was missed (or push a change and say so) and it will be looked at again. Thank you for the contribution.

@Marvisak Marvisak closed this Nov 25, 2026
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.