Formats/XMA: add 10-bit VLC lookup table, u64 bit-peek, and quant-factor LUT #2661

Open
RVZO6 wants to merge 1 commit from upstream-pr/2663 into main
RVZO6 commented 2026-11-25 17:44:02 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by RVZO6 on 2026-11-25T17:44:02Z.


Claimed in #1633: https://github.com/Marvisak/VIctory/issues/1633#issuecomment-7158204478

Summary

Speeds up hot XMA2 frame decoding paths in crates/victory-formats/src/xma.rs (+212/-2) with bit-for-bit identical decoded output:

  1. Bits::peek32: reads a single unaligned u64::from_be_bytes word on the hot path (>= 8 bytes remaining) with a 5-byte tail fallback.
  2. Vlc 10-bit primary table: precomputes a Box<[(i32, u8); 1024]> table in Vlc::new resolving >99% of Huffman symbols in O(1), falling back to prefix-bounded binary search for codes > 10 bits.
  3. quant_factor LUT: caches 10.0_f32.powf(exp as f32 / 16.0) in a bit-exact OnceLock<[f32; 384]> table for exp in -128..256 (verified via .to_bits() equality across the full range).

Measured (--release xma::tests::vlc_and_quant_throughput)

Operation Before (main) After Speedup
VLC coef0 28.09 ns/sym 6.30 ns/sym 4.46×
VLC coef1 23.47 ns/sym 5.86 ns/sym 4.00×
VLC vec4 23.76 ns/sym 5.58 ns/sym 4.26×
quant_factor 10.69 ns/op 1.18 ns/op 9.05×

Not a duplicate of

  • Checked open PRs and #1633; no open PR or claim touches crates/victory-formats/src/xma.rs.

Verification

  • Verified on windows-latest MSVC + WARP SM 6.6 CI (both clippy -D warnings profiles, xtask policy 6/6, victory-formats 41/41 including exhaustive bit-exact equivalence tests for peek32, Vlc, and quant_factor): https://github.com/RVZO6/VIctory/actions/runs/45666985023
  • Not run: the title; any hardware GPU.

AI-assisted: T3 Code (Antigravity, gemini-4-neon)

<!-- greyfinch-sync:Marvisak/VIctory:issue:5496253961 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2663). Originally posted by [RVZO6](https://github.com/RVZO6) on 2026-11-25T17:44:02Z. --- Claimed in #1633: https://github.com/Marvisak/VIctory/issues/1633#issuecomment-7158204478 ### Summary Speeds up hot XMA2 frame decoding paths in `crates/victory-formats/src/xma.rs` (`+212/-2`) with bit-for-bit identical decoded output: 1. **`Bits::peek32`:** reads a single unaligned `u64::from_be_bytes` word on the hot path (`>= 8` bytes remaining) with a 5-byte tail fallback. 2. **`Vlc` 10-bit primary table:** precomputes a `Box<[(i32, u8); 1024]>` table in `Vlc::new` resolving >99% of Huffman symbols in O(1), falling back to prefix-bounded binary search for codes > 10 bits. 3. **`quant_factor` LUT:** caches `10.0_f32.powf(exp as f32 / 16.0)` in a bit-exact `OnceLock<[f32; 384]>` table for `exp in -128..256` (verified via `.to_bits()` equality across the full range). ### Measured (`--release xma::tests::vlc_and_quant_throughput`) | Operation | Before (`main`) | After | Speedup | |---|---:|---:|---:| | VLC `coef0` | `28.09 ns/sym` | `6.30 ns/sym` | **4.46×** | | VLC `coef1` | `23.47 ns/sym` | `5.86 ns/sym` | **4.00×** | | VLC `vec4` | `23.76 ns/sym` | `5.58 ns/sym` | **4.26×** | | `quant_factor` | `10.69 ns/op` | `1.18 ns/op` | **9.05×** | ### Not a duplicate of - Checked open PRs and #1633; no open PR or claim touches `crates/victory-formats/src/xma.rs`. ### Verification - Verified on `windows-latest` MSVC + WARP SM 6.6 CI (both clippy `-D warnings` profiles, `xtask` policy 6/6, `victory-formats` 41/41 including exhaustive bit-exact equivalence tests for `peek32`, `Vlc`, and `quant_factor`): https://github.com/RVZO6/VIctory/actions/runs/45666985023 - **Not run:** the title; any hardware GPU. AI-assisted: T3 Code (Antigravity, gemini-4-neon)
kotekompotek commented 2026-11-25 18:02:56 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by kotekompotek on 2026-11-25T17:57:06Z.


Reviewed: the 10-bit direct lookup is the standard ff_vlc optimization — prefix span fill for len ≤ FAST_BITS, else first-encountered fallback index; peek32's u64 big-endian read covers bit offsets 0–7 for a full 32-bit window, tail path preserved for the last 8 bytes. CI green.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7170229153 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2663#issuecomment-7170229153). Originally posted by [kotekompotek](https://github.com/kotekompotek) on 2026-11-25T17:57:06Z. --- Reviewed: the 10-bit direct lookup is the standard ff_vlc optimization — prefix span fill for len ≤ FAST_BITS, else first-encountered fallback index; `peek32`'s u64 big-endian read covers bit offsets 0–7 for a full 32-bit window, tail path preserved for the last 8 bytes. CI green.
oni-swr commented 2026-11-25 19:06:17 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by oni-swr on 2026-11-25T18:22:59Z.


Independent verification of #2663 (XMA: 10-bit VLC lookup, u64 bit-peek, quant-factor LUT)

PR head 485fb82b4dcf0c8075677b9d5006a3bb3b4c8f12, merges cleanly onto origin/main 13f91caee25f2fdf2c062be5f7a27f058e51cbca.

Environment: Windows 11 Pro 10.0.26200, rustc 1.98.1, CPU only (VICTORY_WARP=1 / VICTORY_D3D12_WARP=1 still set; this crate touches no GPU), cargo ... -j 4 --locked.

Tests/clippy vs baseline. origin/main: cargo test -p victory-formats --lib --locked = 38 passed, 0 failed, 5 ignored. With #2663: 41 passed, 0 failed, 6 ignored (+3 tests, +1 ignored benchmark). cargo clippy -p victory-formats --all-targets --locked: 0 warnings on both.

Equivalence. Full diff read. peek32: the 8-byte path reads bits pos..pos+32 from one u64 (at most 7+32 bits) and falls back to the old zero-padding loop whenever fewer than 8 bytes remain, so reads past the buffer still see zeros as before. VLC: codes are contiguous, so the first code with a given 10-bit prefix starts that prefix's region; prefixes with no code (the unused tail of an incomplete table) fall back to a search from index 0, which reproduces the old "last code <= v". quant_factor is the same powf evaluated once at startup, so it is bit-exact within a build, with a powf fallback outside [-128, 256). Tests added: peek32 vs the byte loop at every position for lengths 0-24; all 7 Huffman tables vs binary search at each code's first and last value plus a 4 KiB random stream; quant_factor bits vs powf for -200..300.

Perf (release, in-PR benchmark). VLC read 21.5-24.6 -> 4.1-4.3 ns/symbol (5.3-5.7x) on the coef0/coef1/vec4 tables; quant factor 8.63 -> 0.74 ns (11.6x). Synthetic random bitstreams.

Findings: no bugs. Observation: each Vlc now owns an 8 KiB lookup table (7 tables), negligible.

Limits: no game files, so no real XMA streams were decoded; coverage is synthetic (exhaustive at code boundaries plus random streams).

AI-assisted: independent verification by Claude Code / Claude Sonnet 5.5, run on behalf of oni-swr. Claims for #1633.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7170831525 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2663#issuecomment-7170831525). Originally posted by [oni-swr](https://github.com/oni-swr) on 2026-11-25T18:22:59Z. --- **Independent verification of #2663** (XMA: 10-bit VLC lookup, u64 bit-peek, quant-factor LUT) PR head `485fb82b4dcf0c8075677b9d5006a3bb3b4c8f12`, merges cleanly onto `origin/main` `13f91caee25f2fdf2c062be5f7a27f058e51cbca`. **Environment:** Windows 11 Pro 10.0.26200, rustc 1.98.1, CPU only (`VICTORY_WARP=1` / `VICTORY_D3D12_WARP=1` still set; this crate touches no GPU), `cargo ... -j 4 --locked`. **Tests/clippy vs baseline.** `origin/main`: `cargo test -p victory-formats --lib --locked` = 38 passed, 0 failed, 5 ignored. With #2663: **41 passed, 0 failed, 6 ignored** (+3 tests, +1 ignored benchmark). `cargo clippy -p victory-formats --all-targets --locked`: 0 warnings on both. **Equivalence.** Full diff read. `peek32`: the 8-byte path reads bits `pos..pos+32` from one `u64` (at most 7+32 bits) and falls back to the old zero-padding loop whenever fewer than 8 bytes remain, so reads past the buffer still see zeros as before. VLC: codes are contiguous, so the first code with a given 10-bit prefix starts that prefix's region; prefixes with no code (the unused tail of an incomplete table) fall back to a search from index 0, which reproduces the old "last code <= v". `quant_factor` is the same `powf` evaluated once at startup, so it is bit-exact within a build, with a `powf` fallback outside [-128, 256). Tests added: `peek32` vs the byte loop at every position for lengths 0-24; all 7 Huffman tables vs binary search at each code's first and last value plus a 4 KiB random stream; `quant_factor` bits vs `powf` for -200..300. **Perf (release, in-PR benchmark).** VLC read 21.5-24.6 -> 4.1-4.3 ns/symbol (5.3-5.7x) on the coef0/coef1/vec4 tables; quant factor 8.63 -> 0.74 ns (11.6x). Synthetic random bitstreams. **Findings:** no bugs. Observation: each `Vlc` now owns an 8 KiB lookup table (7 tables), negligible. **Limits:** no game files, so no real XMA streams were decoded; coverage is synthetic (exhaustive at code boundaries plus random streams). AI-assisted: independent verification by Claude Code / Claude Sonnet 5.5, run on behalf of oni-swr. Claims for #1633.
Marvisak commented 2026-11-25 23:06:14 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T22:22:14Z.


Automated triage for the maintainers.

Merge candidate (performance, same output). In crates/victory-formats/src/xma.rs:

  • Bits::peek32 reads one big-endian u64 when 8 bytes remain and otherwise falls back to the old loop.
  • Vlc gains a 10-bit direct lookup table, with the old binary search kept for longer codes.
  • quant_factor caches 10^(exp/20) for exponents in [-128, 256), computed once with the same powf.

I checked that codes are handed out contiguously, so a 10-bit region holds either one short code or long codes starting at the region's start. The slow-path search from that index therefore cannot underflow, and the empty tail falls back to a full search, as before. The tests compare against the old paths at every code boundary, at every bit position and for exponents -200..300. The "title" (XMA) data path is unchanged in semantics; the LUT memory is about 8 KiB per table. It merges cleanly; CI check: passing.


Generated by Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:comment:7176276956 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2663#issuecomment-7176276956). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T22:22:14Z. --- <!-- victory-triage v1 head=485fb82b4dcf0c8075677b9d5006a3bb3b4c8f12 verdict=merge-candidate at=2026-11-25T22:25:30Z --> Automated triage for the maintainers. **Merge candidate** (performance, same output). In `crates/victory-formats/src/xma.rs`: - `Bits::peek32` reads one big-endian u64 when 8 bytes remain and otherwise falls back to the old loop. - `Vlc` gains a 10-bit direct lookup table, with the old binary search kept for longer codes. - `quant_factor` caches `10^(exp/20)` for exponents in [-128, 256), computed once with the same `powf`. I checked that codes are handed out contiguously, so a 10-bit region holds either one short code or long codes starting at the region's start. The slow-path search from that index therefore cannot underflow, and the empty tail falls back to a full search, as before. The tests compare against the old paths at every code boundary, at every bit position and for exponents -200..300. The "title" (XMA) data path is unchanged in semantics; the LUT memory is about 8 KiB per table. It merges cleanly; CI `check`: passing. --- _Generated by [Claude Code](https://claude.ai/code)_
fuzeofficlal commented 2026-11-26 01:04:14 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-26T00:50:43Z.


Code review and Windows 11 release benchmark verification at head 485fb82b4dcf merged cleanly onto main (63bcca43c6a0):

  • Code & boundary audit (crates/victory-formats/src/xma.rs):
    • Bits::peek32 (xma.rs:203-210): takes the u64::from_be_bytes fast path only when self.data.get(byte..byte + 8) is Some, falling back safely to peek32_tail() near stream end; bit shifts match across all bit offsets (fast_peek32_matches_byte_loop checks len in 0..=24, pos in 0..=(len*8 + 16)).
    • 10-bit VLC table (xma.rs:258-306): fills 1 << (10 - len) prefix slots for len <= 10, stores the first sorted-table index (idx, 0) for len > 10 falling back to #[cold] read_slow (partition_point(|c| c.0 <= v) - 1; since codes[0].0 == 0 <= v, partition_point >= 1 never underflows). Verified across all 7 XMA2 Huffman tables.
    • Quant-factor LUT (xma.rs:320-338, line 1169): OnceLock 384-entry table for exp in [-128, 256) with single unsigned range check via wrapping_sub, falling back to 10f32.powf(...) out of range; quant_table_matches_powf_bits verifies exact bit equality across -200..=300.
  • Verified (Windows 11, Rust 1.98.1):
    • cargo xtask policy: 191 files ok; cargo clippy -p victory-formats --all-targets -- -D warnings: 0 warnings
    • cargo test --locked -p victory-formats --all-targets: 49/49 passed (6 ignored)
    • --release xma::tests::vlc_and_quant_throughput:
      • vlc coef0: 21.13 -> 3.45 ns/sym (6.12x)
      • vlc coef1: 18.60 -> 3.15 ns/sym (5.90x)
      • vlc vec4: 16.66 -> 3.00 ns/sym (5.55x)
      • quant: 4.84 -> 0.42 ns/op (11.56x)

Clean, bit-exact, and a huge speedup; LGTM.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7179170214 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2663#issuecomment-7179170214). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-26T00:50:43Z. --- Code review and Windows 11 release benchmark verification at head `485fb82b4dcf` merged cleanly onto `main` (`63bcca43c6a0`): - **Code & boundary audit (`crates/victory-formats/src/xma.rs`)**: - `Bits::peek32` (`xma.rs:203-210`): takes the `u64::from_be_bytes` fast path only when `self.data.get(byte..byte + 8)` is `Some`, falling back safely to `peek32_tail()` near stream end; bit shifts match across all bit offsets (`fast_peek32_matches_byte_loop` checks `len in 0..=24`, `pos in 0..=(len*8 + 16)`). - 10-bit VLC table (`xma.rs:258-306`): fills `1 << (10 - len)` prefix slots for `len <= 10`, stores the first sorted-table index `(idx, 0)` for `len > 10` falling back to `#[cold] read_slow` (`partition_point(|c| c.0 <= v) - 1`; since `codes[0].0 == 0 <= v`, `partition_point >= 1` never underflows). Verified across all 7 XMA2 Huffman tables. - Quant-factor LUT (`xma.rs:320-338`, line 1169): `OnceLock` 384-entry table for `exp in [-128, 256)` with single unsigned range check via `wrapping_sub`, falling back to `10f32.powf(...)` out of range; `quant_table_matches_powf_bits` verifies exact bit equality across `-200..=300`. - **Verified (Windows 11, Rust 1.98.1)**: - `cargo xtask policy`: `191 files ok`; `cargo clippy -p victory-formats --all-targets -- -D warnings`: 0 warnings - `cargo test --locked -p victory-formats --all-targets`: **49/49 passed** (6 ignored) - `--release` `xma::tests::vlc_and_quant_throughput`: - `vlc coef0`: `21.13 -> 3.45 ns/sym` (**6.12x**) - `vlc coef1`: `18.60 -> 3.15 ns/sym` (**5.90x**) - `vlc vec4`: `16.66 -> 3.00 ns/sym` (**5.55x**) - `quant`: `4.84 -> 0.42 ns/op` (**11.56x**) Clean, bit-exact, and a huge speedup; LGTM.
Dukestar69 commented 2026-11-26 04:31:52 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Dukestar69 on 2026-11-26T04:31:52Z.

Review: APPROVED


Tested merged onto origin/main (63bcca4) on Windows 11 x64:

  • cargo test -p victory-formats --lib xma::: 23 passed, 0 failed, 4 ignored (including new fast_peek32_matches_byte_loop, quant_table_matches_powf_bits, and tabled_vlc_matches_binary_search).
  • cargo clippy -p victory-formats --all-targets -- -D warnings: clean.
  • cargo xtask policy: 191 files ok.

Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).

<!-- greyfinch-sync:Marvisak/VIctory:review:6068577919 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2663#pullrequestreview-6068577919). Originally posted by [Dukestar69](https://github.com/Dukestar69) on 2026-11-26T04:31:52Z. **Review:** APPROVED --- Tested merged onto `origin/main` (`63bcca4`) on Windows 11 x64: - `cargo test -p victory-formats --lib xma::`: **23 passed, 0 failed, 4 ignored** (including new `fast_peek32_matches_byte_loop`, `quant_table_matches_powf_bits`, and `tabled_vlc_matches_binary_search`). - `cargo clippy -p victory-formats --all-targets -- -D warnings`: clean. - `cargo xtask policy`: 191 files ok. Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
futurepro62 commented 2026-11-26 12:05:58 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by futurepro62 on 2026-11-26T11:40:48Z.


NVIDIA full-suite run, to go with the reports above by Dukestar69, fuzeofficlal, oni-swr, since none of them names a GPU run. Tested exact head 485fb82 (on its base 13f91ca).

Tested

  • NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 621.40, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.98.1 MSVC (pinned), dxil.dll from Windows SDK 10.0.26100 (the loader's default), debug.
  • cargo build --workspace --locked, then cargo test --workspace --locked --no-fail-fast -- --test-threads=4 --skip emit::memory_tests::heap_direct_texture_reads_mark_their_heap_index --skip descriptor::host::tests::dynamic_slots_are_held_until_released --skip memory::tests::lists_share_a_table_and_copies_keep_their_views --skip emit::stride_tests::a_heap_buffer_read_by_element_takes_the_views_stride --skip emit::stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros --skip emit::synthetic_tests::gathers_at_a_level_match_the_hardware: 776 passed, 0 failed, 10 ignored.
  • The new tests ran and passed: fast_peek32_matches_byte_loop, tabled_vlc_matches_binary_search, quant_table_matches_powf_bits.
  • --skip leaves out tests that fail on main 63bcca4 on this card too, not because of this PR: heap_direct_texture_reads_mark_their_heap_index ends the victory-shader test process with 0xc0000005 (#2571), so without the skip the rest of that crate never reports; dynamic_slots_are_held_until_released, lists_share_a_table_and_copies_keep_their_views and the two stride_tests hit the 1,000,000-view heap cap of NVIDIA drivers (#1835, #2317); gathers_at_a_level_match_the_hardware fails on lane 0 (#1744).

Not tested

  • AMD (the tests take the default adapter), a release build, the title (test run only).

AI use

  • Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.
<!-- greyfinch-sync:Marvisak/VIctory:comment:7191032242 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2663#issuecomment-7191032242). Originally posted by [futurepro62](https://github.com/futurepro62) on 2026-11-26T11:40:48Z. --- NVIDIA full-suite run, to go with the reports above by Dukestar69, fuzeofficlal, oni-swr, since none of them names a GPU run. Tested exact head `485fb82` (on its base `13f91ca`). **Tested** - NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 621.40, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.98.1 MSVC (pinned), `dxil.dll` from Windows SDK 10.0.26100 (the loader's default), debug. - `cargo build --workspace --locked`, then `cargo test --workspace --locked --no-fail-fast -- --test-threads=4 --skip emit::memory_tests::heap_direct_texture_reads_mark_their_heap_index --skip descriptor::host::tests::dynamic_slots_are_held_until_released --skip memory::tests::lists_share_a_table_and_copies_keep_their_views --skip emit::stride_tests::a_heap_buffer_read_by_element_takes_the_views_stride --skip emit::stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros --skip emit::synthetic_tests::gathers_at_a_level_match_the_hardware`: **776 passed, 0 failed, 10 ignored**. - The new tests ran and passed: `fast_peek32_matches_byte_loop`, `tabled_vlc_matches_binary_search`, `quant_table_matches_powf_bits`. - `--skip` leaves out tests that fail on main `63bcca4` on this card too, not because of this PR: `heap_direct_texture_reads_mark_their_heap_index` ends the `victory-shader` test process with `0xc0000005` (#2571), so without the skip the rest of that crate never reports; `dynamic_slots_are_held_until_released`, `lists_share_a_table_and_copies_keep_their_views` and the two `stride_tests` hit the 1,000,000-view heap cap of NVIDIA drivers (#1835, #2317); `gathers_at_a_level_match_the_hardware` fails on lane 0 (#1744). **Not tested** - AMD (the tests take the default adapter), a release build, the title (test run only). **AI use** - Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.
fuzeofficlal commented 2026-11-26 12:10:58 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-26T12:10:58Z.

Review: APPROVED


Reviewed and verified 485fb82b against origin/main (63bcca43; clean git merge-tree):

  • Bits::peek32 (crates/victory-formats/src/xma.rs:203-218) extracts identical bits to the 5-byte tail path across all bit alignments, short buffers, and past physical EOF without byte + 8 overflow.
  • For valid canonical aligned VLC tables, any 10-bit bucket holding codes > 10 bits starts at prefix << 22 <= v and empty buckets fall back to index 0, so partition_point(|c| c.0 <= v) - 1 in Vlc::read_slow (xma.rs:300-306) cannot underflow; documenting or asserting that invariant in Vlc::new would make the safety contract explicit.
  • quant_factor (xma.rs:323-338, 1169) matches baseline's exp / 20.0 across [-128, 255] and falls back cleanly outside that range.

Minor non-blocking notes: the PR description says / 16.0 whereas both the baseline and LUT use / 20.0, and cargo fmt flags line wrapping in the new test lines (xma.rs:1460..1554).

Local verification on Windows 11 (Ryzen 9 9950X):

  • xtask policy (184 files ok) and cargo clippy -p victory-formats --all-targets -- -D warnings (default and --all-features): clean.
  • cargo test -p victory-formats --locked (both debug and --release): 41 passed; 0 failed; 6 ignored.
  • --release vlc_and_quant_throughput: coef0 5.85x (19.89 -> 3.40 ns/sym), coef1 5.83x (18.04 -> 3.10 ns/sym), vec4 5.58x (16.15 -> 2.90 ns/sym), quant 12.48x (4.64 -> 0.37 ns/op).
<!-- greyfinch-sync:Marvisak/VIctory:review:6073904752 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2663#pullrequestreview-6073904752). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-26T12:10:58Z. **Review:** APPROVED --- Reviewed and verified `485fb82b` against `origin/main` (`63bcca43`; clean `git merge-tree`): - `Bits::peek32` (`crates/victory-formats/src/xma.rs:203-218`) extracts identical bits to the 5-byte tail path across all bit alignments, short buffers, and past physical EOF without `byte + 8` overflow. - For valid canonical aligned VLC tables, any 10-bit bucket holding codes > 10 bits starts at `prefix << 22 <= v` and empty buckets fall back to index `0`, so `partition_point(|c| c.0 <= v) - 1` in `Vlc::read_slow` (`xma.rs:300-306`) cannot underflow; documenting or asserting that invariant in `Vlc::new` would make the safety contract explicit. - `quant_factor` (`xma.rs:323-338, 1169`) matches baseline's `exp / 20.0` across `[-128, 255]` and falls back cleanly outside that range. Minor non-blocking notes: the PR description says `/ 16.0` whereas both the baseline and LUT use `/ 20.0`, and `cargo fmt` flags line wrapping in the new test lines (`xma.rs:1460..1554`). Local verification on Windows 11 (Ryzen 9 9950X): - `xtask policy` (`184 files ok`) and `cargo clippy -p victory-formats --all-targets -- -D warnings` (default and `--all-features`): clean. - `cargo test -p victory-formats --locked` (both debug and `--release`): `41 passed; 0 failed; 6 ignored`. - `--release vlc_and_quant_throughput`: `coef0` **5.85x** (`19.89 -> 3.40 ns/sym`), `coef1` **5.83x** (`18.04 -> 3.10 ns/sym`), `vec4` **5.58x** (`16.15 -> 2.90 ns/sym`), `quant` **12.48x** (`4.64 -> 0.37 ns/op`).
rezioliver-collab commented 2026-11-26 18:00:57 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by rezioliver-collab on 2026-11-26T18:00:57Z.


The speedup from the 10-bit lookup on Apple M1 depended on how many symbols reached the fallback. I compared 485fb82b with its base 13f91cae using identical synthetic bitstreams.

Codes longer than 10 bits coef0 speedup coef1 speedup vec4 speedup
0% 7.73× 7.18× 6.44×
50% 1.79× 1.69× 1.60×
100% 1.02× 0.97× 0.92×

With all-long codes, vec4 went from 33.40 to 36.35 ns/symbol. A fresh build reproduced that result (33.94 to 36.90 ns/symbol). The long-code fractions were chosen explicitly to measure fallback cost.

Each cell used 5,000 deterministic symbols encoded with the corresponding table. I checked every decoded symbol and its ending bit position against the encoder’s record. All 45,000 matched on both revisions. The factors are median base/PR ratios from 12 paired release runs with alternating order, macOS 14.7, Rust 1.98.1.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7199955356 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2663#issuecomment-7199955356). Originally posted by [rezioliver-collab](https://github.com/rezioliver-collab) on 2026-11-26T18:00:57Z. --- The speedup from the 10-bit lookup on Apple M1 depended on how many symbols reached the fallback. I compared `485fb82b` with its base `13f91cae` using identical synthetic bitstreams. | Codes longer than 10 bits | `coef0` speedup | `coef1` speedup | `vec4` speedup | |---:|---:|---:|---:| | 0% | 7.73× | 7.18× | 6.44× | | 50% | 1.79× | 1.69× | 1.60× | | 100% | 1.02× | 0.97× | 0.92× | With all-long codes, `vec4` went from **33.40 to 36.35 ns/symbol**. A fresh build reproduced that result (33.94 to 36.90 ns/symbol). The long-code fractions were chosen explicitly to measure fallback cost. Each cell used 5,000 deterministic symbols encoded with the corresponding table. I checked every decoded symbol and its ending bit position against the encoder’s record. All 45,000 matched on both revisions. The factors are median base/PR ratios from 12 paired release runs with alternating order, macOS 14.7, Rust 1.98.1.
andrewpozdnakov7-jpg commented 2026-11-28 00:11:05 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-28T00:11:05Z.


On Windows I decoded the same 62 generated mono frames on main 63bcca4 and on 485fb82 merged onto it. The fixture varies every ordinary signed quantizer step, then flushes the decoder. All four outputs matched byte for byte, with 32,000 PCM samples per run and 31,721 nonzero samples.

I put the full-decoder regression in test-only commit 165f0a7. It compares every PCM sample with the direct gain formula and the existing untabled inverse-transform reference. The generated single-bin frame came from #2795. On that commit, 50 release tests passed with six ignored, and strict Clippy and the asset policy check passed.

One description nit: the gain divisor shown in the summary is 16.0. The implementation and the reference both use 20.0.

If you reuse the test, please retain the Git author on cherry-pick or rebase, or add Co-authored-by: andrewpozdnakov7-jpg [email protected] if folding it into another commit.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7230713223 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2663#issuecomment-7230713223). Originally posted by [andrewpozdnakov7-jpg](https://github.com/andrewpozdnakov7-jpg) on 2026-11-28T00:11:05Z. --- On Windows I decoded the same 62 generated mono frames on main 63bcca4 and on 485fb82 merged onto it. The fixture varies every ordinary signed quantizer step, then flushes the decoder. All four outputs matched byte for byte, with 32,000 PCM samples per run and 31,721 nonzero samples. I put the full-decoder regression in [test-only commit 165f0a7](https://github.com/andrewpozdnakov7-jpg/VIctory/commit/165f0a7a2fabffb65369d6511d8d8ec5569fbb00). It compares every PCM sample with the direct gain formula and the existing untabled inverse-transform reference. The generated single-bin frame came from #2795. On that commit, 50 release tests passed with six ignored, and strict Clippy and the asset policy check passed. One description nit: the gain divisor shown in the summary is 16.0. The implementation and the reference both use 20.0. If you reuse the test, please retain the Git author on cherry-pick or rebase, or add Co-authored-by: andrewpozdnakov7-jpg <[email protected]> if folding it into another commit.
andrewpozdnakov7-jpg commented 2026-11-28 19:09:56 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-28T19:09:56Z.


I combined the XMA table changes at 485fb82 with the in-place coefficient scaling from #3783. Combined ad7d8d5 has both tested commits as parents. The dequantizer keeps this PR's quantization lookup and scales the decoded coefficient slices in place.

Against this PR with current main, 1,152 generated mono and stereo frames at four sample rates gave 1,053,696 bit-identical PCM samples and 1,769,472 bit-identical float output words. The optimized Windows CPU benchmark medians were 0.998x, 0.997x and 0.996x for the 128-, 256- and 512-sample subframes. All 49 active formats tests, strict all-feature Clippy and the asset policy passed.

RVZO6 can use the combined branch if both changes are picked up. Please retain the Git authors on cherry-pick or rebase, or include Co-authored-by: andrewpozdnakov7-jpg [email protected] if folding the in-place change into another commit.

AI-assisted with OpenAI Codex.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7244338124 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2663#issuecomment-7244338124). Originally posted by [andrewpozdnakov7-jpg](https://github.com/andrewpozdnakov7-jpg) on 2026-11-28T19:09:56Z. --- I combined the XMA table changes at 485fb82 with the in-place coefficient scaling from #3783. [Combined ad7d8d5](https://github.com/andrewpozdnakov7-jpg/VIctory/commit/ad7d8d52799ef82aa440ca319be7bedf07c82bf1) has both tested commits as parents. The dequantizer keeps this PR's quantization lookup and scales the decoded coefficient slices in place. Against this PR with current main, 1,152 generated mono and stereo frames at four sample rates gave 1,053,696 bit-identical PCM samples and 1,769,472 bit-identical float output words. The optimized Windows CPU benchmark medians were 0.998x, 0.997x and 0.996x for the 128-, 256- and 512-sample subframes. All 49 active formats tests, strict all-feature Clippy and the asset policy passed. RVZO6 can use the combined branch if both changes are picked up. Please retain the Git authors on cherry-pick or rebase, or include Co-authored-by: andrewpozdnakov7-jpg <[email protected]> if folding the in-place change into another commit. AI-assisted with OpenAI Codex.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/2663:upstream-pr/2663'
git switch 'upstream-pr/2663'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/2663'
git switch 'upstream-pr/2663'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/2663'
git switch 'upstream-pr/2663'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/2663'
git switch 'main'
git merge --squash 'upstream-pr/2663'
git switch 'main'
git merge --ff-only 'upstream-pr/2663'
git switch 'main'
git merge 'upstream-pr/2663'
git push origin 'main'
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!2661
No description provided.