Formats: append XMA PCM by channel layout #3631

Open
andrewpozdnakov7-jpg wants to merge 1 commit from upstream-pr/3631 into main
andrewpozdnakov7-jpg commented 2026-11-28 00:22:17 +00:00 (Migrated from github.com)

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


Choose the mono or stereo PCM append path once per output block. Both paths use the existing sample conversion. Decode and flush share the append routine, and stereo samples remain interleaved left then right.

On Windows x86-64, 15 alternating A/B pairs of an isolated release benchmark with preallocated output gave these median microseconds per block.

Channels Samples per channel Main PR
Mono 256 6.03 5.10
Mono 512 12.13 10.44
Stereo 256 12.46 11.13
Stereo 512 24.15 22.95

The same 62 generated mono frames plus the final flush produced byte-identical PCM on main and this head's production code. The included regression checks the output prefix, stereo order, clipping, rounding and reset through the actual flush path. All 47 active victory-formats release tests, strict Clippy and the asset policy check passed.

Coordination claim

AI-assisted with OpenAI Codex.

<!-- greyfinch-sync:Marvisak/VIctory:issue:5534872694 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3631). Originally posted by [andrewpozdnakov7-jpg](https://github.com/andrewpozdnakov7-jpg) on 2026-11-28T00:22:17Z. --- Choose the mono or stereo PCM append path once per output block. Both paths use the existing sample conversion. Decode and flush share the append routine, and stereo samples remain interleaved left then right. On Windows x86-64, 15 alternating A/B pairs of an isolated release benchmark with preallocated output gave these median microseconds per block. | Channels | Samples per channel | Main | PR | | --- | ---: | ---: | ---: | | Mono | 256 | 6.03 | 5.10 | | Mono | 512 | 12.13 | 10.44 | | Stereo | 256 | 12.46 | 11.13 | | Stereo | 512 | 24.15 | 22.95 | The same 62 generated mono frames plus the final flush produced byte-identical PCM on main and this head's production code. The included regression checks the output prefix, stereo order, clipping, rounding and reset through the actual flush path. All 47 active victory-formats release tests, strict Clippy and the asset policy check passed. [Coordination claim](https://github.com/Marvisak/VIctory/issues/1633#issuecomment-7230735653) AI-assisted with OpenAI Codex.
andrewpozdnakov7-jpg commented 2026-11-28 00:22:54 +00:00 (Migrated from github.com)

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


On Windows, the isolated PCM append benchmark took 5–16% less time across the mono and stereo block sizes. This is the median of 15 alternating A/B pairs per size with preallocated output. The complete synthetic mono decode timings overlapped, so the measured speedup is for the append step.

Every sample from 62 generated mono frames and the final flush matched main byte for byte. The committed test also checks the flush path with distinct left and right samples, a pre-existing output prefix, clipping, rounding and a second flush after reset. All 47 active release tests and strict Clippy passed.

If you reuse the code or 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:7230867110 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3631#issuecomment-7230867110). Originally posted by [andrewpozdnakov7-jpg](https://github.com/andrewpozdnakov7-jpg) on 2026-11-28T00:22:54Z. --- On Windows, the isolated PCM append benchmark took 5–16% less time across the mono and stereo block sizes. This is the median of 15 alternating A/B pairs per size with preallocated output. The complete synthetic mono decode timings overlapped, so the measured speedup is for the append step. Every sample from 62 generated mono frames and the final flush matched main byte for byte. The committed test also checks the flush path with distinct left and right samples, a pre-existing output prefix, clipping, rounding and a second flush after reset. All 47 active release tests and strict Clippy passed. If you reuse the code or 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 00:26:41 +00:00 (Migrated from github.com)

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


I resolved the overlap with #3383 in the decode and flush output loops. This integration uses #3631's shared append_pcm and moves #3383's reservation into that helper, so each append reserves the whole interleaved block once. It also carries the verified #3629 overlap-add change. The branch keeps all three exact heads on 63bcca4. Integration branch 7713c9a

I repeated the 48 kHz generated-stream check from #3629 in a separate Windows x64 release binary. It decoded 16 frames each of mono and stereo, alternated the active stereo channel, and flushed both streams. All 8,448 mono samples and 16,896 interleaved stereo samples matched #3383 byte for byte, including the flush tail. The output prefix and the reusable input buffer's pointer and capacity were preserved. Fixture results for #3383 + #3629

The combined formats release suite passed 49 tests, including the new clipping, interleave and flush-reset regression, with five ignored. Strict formats Clippy passed. This was a decoder check on generated audio. AI-assisted with Codex.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7230915696 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3631#issuecomment-7230915696). Originally posted by [andrewpozdnakov7-jpg](https://github.com/andrewpozdnakov7-jpg) on 2026-11-28T00:26:41Z. --- I resolved the overlap with #3383 in the `decode` and `flush` output loops. This integration uses #3631's shared `append_pcm` and moves #3383's reservation into that helper, so each append reserves the whole interleaved block once. It also carries the verified #3629 overlap-add change. The branch keeps all three exact heads on `63bcca4`. [Integration branch `7713c9a`](https://github.com/andrewpozdnakov7-jpg/VIctory/tree/review/xma-pcm-overlap-and-buffer-reuse) I repeated the 48 kHz generated-stream check from #3629 in a separate Windows x64 release binary. It decoded 16 frames each of mono and stereo, alternated the active stereo channel, and flushed both streams. All 8,448 mono samples and 16,896 interleaved stereo samples matched #3383 byte for byte, including the flush tail. The output prefix and the reusable input buffer's pointer and capacity were preserved. [Fixture results for #3383 + #3629](https://github.com/Marvisak/VIctory/pull/3629#issuecomment-7230875619) The combined formats release suite passed 49 tests, including the new clipping, interleave and flush-reset regression, with five ignored. Strict formats Clippy passed. This was a decoder check on generated audio. AI-assisted with Codex.
andrewpozdnakov7-jpg commented 2026-11-28 03:27:45 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-28T03:27:45Z.


I checked the rounding change from #3656 with the current 92ba3fb head. Combined commit 3aa473c preserves both PR heads. The merge keeps this PR's shared channel-specific append routine and both regression tests. The rounding patch changes only the sample conversion and its test relative to this head.

The exact sources produced the same 301,056 interleaved PCM samples for 288 generated stereo frames with 96 nonzero coefficients per channel and the final flush. The combined formats suite passed 43 tests, with five ignored and five unrelated noise tests filtered from the local run. Strict formats Clippy and asset policy passed.

Please retain the Git authors on cherry-pick or rebase, or add Co-authored-by: andrewpozdnakov7-jpg <[email protected]> if folding the change into another commit.

AI-assisted with OpenAI Codex.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7233090960 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3631#issuecomment-7233090960). Originally posted by [andrewpozdnakov7-jpg](https://github.com/andrewpozdnakov7-jpg) on 2026-11-28T03:27:45Z. --- I checked the rounding change from #3656 with the current `92ba3fb` head. [Combined commit `3aa473c`](https://github.com/andrewpozdnakov7-jpg/VIctory/commit/3aa473c7a53e966b9d9b608082e72fecef16ef17) preserves both PR heads. The merge keeps this PR's shared channel-specific append routine and both regression tests. The rounding patch changes only the sample conversion and its test relative to this head. The exact sources produced the same 301,056 interleaved PCM samples for 288 generated stereo frames with 96 nonzero coefficients per channel and the final flush. The combined formats suite passed 43 tests, with five ignored and five unrelated noise tests filtered from the local run. Strict formats Clippy and asset policy passed. Please retain the Git authors on cherry-pick or rebase, or add `Co-authored-by: andrewpozdnakov7-jpg <[email protected]>` if folding the change into another commit. AI-assisted with OpenAI Codex.
cloph-dsp commented 2026-11-28 10:00:15 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by cloph-dsp on 2026-11-28T10:00:15Z.


Independent local verification (Windows, Rust 1.100.0/MSVC, no game data):

  • PR #3631 at head 92ba3fb135bfa9e2182046a77727a81d4c8399bd, base/parent 63bcca43c6a00a758510398fa43096ce7e4f7df0.
  • cargo test --locked -p victory-formats --lib -- xma::tests::flush_appends_mono_or_interleaved_stereo_and_resets --exact --test-threads=1 --quiet → 1 passed, 0 failed, 51 filtered, exit 0.
  • git grep -F for the test name on the base returned no match (test is new on this PR); git diff --check 63bcca4 HEAD clean (1 file, +41/-10).
  • Used a per-worktree CARGO_TARGET_DIR (never shared) with CARGO_BUILD_JOBS=2.
  • Only the named synthetic test was replayed; full workspace suite and clippy were not run locally.
  • GPU/driver: N/A (CPU-only XMA format test). No game data, assets, extracted shaders, DRM or decrypt involved.

AI-assisted (Hy4 flash).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7237605376 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3631#issuecomment-7237605376). Originally posted by [cloph-dsp](https://github.com/cloph-dsp) on 2026-11-28T10:00:15Z. --- Independent local verification (Windows, Rust 1.100.0/MSVC, no game data): - PR #3631 at head `92ba3fb135bfa9e2182046a77727a81d4c8399bd`, base/parent `63bcca43c6a00a758510398fa43096ce7e4f7df0`. - `cargo test --locked -p victory-formats --lib -- xma::tests::flush_appends_mono_or_interleaved_stereo_and_resets --exact --test-threads=1 --quiet` → 1 passed, 0 failed, 51 filtered, exit 0. - `git grep -F` for the test name on the base returned no match (test is new on this PR); `git diff --check 63bcca4 HEAD` clean (1 file, +41/-10). - Used a per-worktree `CARGO_TARGET_DIR` (never shared) with `CARGO_BUILD_JOBS=2`. - Only the named synthetic test was replayed; full workspace suite and clippy were not run locally. - GPU/driver: N/A (CPU-only XMA format test). No game data, assets, extracted shaders, DRM or decrypt involved. AI-assisted (Hy4 flash).
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/3631:upstream-pr/3631'
git switch 'upstream-pr/3631'

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