formats,hle(audio): optimize XMA VLC decoding, chain XMA overlap buffers, and add XApu rate conversion #91
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/91"
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 Androtim/MiniVI. Originally posted by Androtim on 2026-11-29T08:47:07Z.
Summary
Adapted from upstream
VIctory-NVIDIAcommits0a0ff43and462cd10(GPL-3.0), extracted cleanly offorigin/main(7fe6886) with zero overlap against open PRs:crates/victory-formats/src/xma.rs): Table-drives VLC decoding, bulk-copies decoded frames, and caches quantization powers.crates/victory-formats/src/xma.rs,crates/victory-hle/src/modules/{apu.rs,audio.rs}): Addsxma::Decoder::carry()/resume()and persists/restores overlap state in context overlap buffers inside the APU heap block so chained XMA contexts avoid seam clicks.crates/victory-hle/src/modules/{apu.rs,audio.rs}): ImplementsDecodeConvertOpusandConvertPCMwith clamped pitch (1/8to8), rate-limited ramping,256/480/512/960/1024output framing,Flushdraining, and decoder-only reset.Verification
cargo xtask policy:asset policy: 303 files okcargo test -p victory-formats --lib --locked -- xma::: 15 passed; 0 failed; 4 ignored (pre-existing benchmarks/external-data tests), includingvlc_tables_match_prefix_binary_searchanda_carried_stream_goes_on_in_another_decodercargo test -p victory-hle --lib --locked -- apu:: audio:: xaudio2::: 15 passed; 0 failed, includingpcm_converts_in_whole_outputs,decoded_opus_converts_at_its_pitch,consecutive_contexts_go_on_through_the_overlap_buffer, anddecodes_opus_as_the_title_drives_itcargo clippy --workspace --all-targets -- -D warnings&--features diagnostics: 0 warnings--release+objdump -p: standard Windows system DLLs onlypr92-xma-xapu-audio): 11/11 gates PASS12.6 fps(79.4 ms, vs8.9 fpsbaseline,+3.70 fps)5762 MB/6956 MBbudget (over=0 MB,-102 MBvs baseline)1712(vs7121baseline) |mapped()stall rate:7.16 ms/suntranslated=1| Crashes / host texture errors:0/0frame-8679.png,frame-8719.png, median luma103.7, edge energy7.12,0.0%near-black/magenta).Imported from Androtim/MiniVI. Originally posted by Androtim on 2026-11-29T09:04:23Z.
Automated triage for the maintainers (not an approval).
Verdict:
merge-candidate· CI (check):passingSummary
Clean, well-scoped audio optimization and feature PR across
victory-formatsandvictory-hlewith passing CI and thorough unit tests.Code Review
crates/victory-formats/src/xma.rsread_frame: bulk byte-copy path preserves packet-boundary and unaligned bit-shift behavior (avail_bytes == 0falls back tocursor.bits(8), andat..at + n + 1stays within the current packet whenshift != 0).Bits::peek32/peek32_tailand two-levelVlc(VLC_PRIMARY_BITS = 11): bit-exact with the previous prefix binary search;vlc_tables_match_prefix_binary_searchverifies every code boundary across all 7 tables.quant_table(): out-of-range exponents (including< QUANT_MIN, which wrap to a largeusize) safely fall back to10f32.powf(...).Decoder::carry()/Decoder::resume(): validates sample count and power-of-twoblock_leninMIN_SUBFRAME..=FRAME_SAMPLES. (Minor nit:resumecallsself.reset()before validatingblock_lenon all channels, which is harmless for theaudio.rscaller since it discards the fresh decoder onfalse.)crates/victory-hle/src/modules/audio.rssave_carry/resume_carry: bounds-checked viaheap_bytes(address, carry_bytes(channels)), tagged withVXO1+ channel count, and cleared on first resume so overlap state is consumed once.crates/victory-hle/src/modules/apu.rsXApuConnect/XApuEnqueueCommand/Stream::convert/Converter: properly validatesframes_per_output(256 | 480 | 512 | 960 | 1024), clamps pitch to0.125..=8.0(handling non-finitestart_pitch,target_pitch, andpitch_rampsafely), and bounds-checks both interleaved and deinterleaved unaligned writes againstoutput_length.DECODE_CONVERT_OPUS, aFLUSHcommand withinput_length == 0still passes an empty slice toOpusDecoder::decodebefore draining buffered output; fine if titles only flush with valid packets oropus_pureaccepts empty packets.)Verdict
merge-candidate— CPU-only audio decoding and HLE changes with passing CI, solid bounds/edge-case handling, and good unit test coverage; no local GPU test required.Generated with Antigravity CLI (
agy).