XMA: cache IMDCT rotation tables per subframe size #172
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/172"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from Marvisak/VIctory. Originally posted by TG0000 on 2026-11-24T01:05:36Z.
Summary
Caches the pre/post rotation tables, bit-reversal order, and butterfly twiddle factors once per XMA subframe size (128, 256, and 512 samples) in imdct_half (crates/victory-formats/src/xma.rs) and replaces the per-call heap Vec work buffers with stack arrays.
Why
Previously, imdct_half recomputed sin_cos for every pre- and post-rotation on every subframe call and allocated two fresh Vec buffers per call. Precomputing those tables once per subframe size removes the repeated trig work and per-subframe heap allocations while preserving bit-for-bit identical output (each table value uses the exact same floating-point expression and butterfly recurrence as before).
Measured performance (synthetic release benchmark)
3.2×–4.4× (3.7× overall) faster imdct_half across the 128/256/512 subframe sizes in MSVC release builds.Testing
AI-assisted (Claude Opus 5.5).
Imported from Marvisak/VIctory. Originally posted by DaviTostes on 2026-11-24T01:23:22Z.
Tested
4eb0898on Arch Linux x86_64, rustc 1.98.1: pass.cargo test -p victory-formats: 22 passed, 0 failed, 4 ignored (2 test binaries), including the 3 tests this PR adds.No game data used.
Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T00:20:46Z.
Automated triage for the maintainers.
Merge candidate.
imdct_halfincrates/victory-formats/src/xma.rsnow builds the pre/post rotations, bit-reversal order and butterfly twiddles once per subframe size (128/256/512, in aOnceLocklike the existingwindows()) and uses a stack buffer sized byFRAME_SAMPLESinstead of twoVecs per call. Each table entry uses the same expression and the same per-stage running product as the old per-call code; other sizes still build tables on the spot, andtabled_imdct_gives_the_same_bitscompares the output bit for bit against the old transform for n = 2…2048. The ~3.7x speed-up is for the transform alone; no in-title measurement.CI: no check runs on the head commit.
Generated by Claude Code