Formats: walk paired XMA overlap samples directly #3629

Open
andrewpozdnakov7-jpg wants to merge 1 commit from upstream-pr/3629 into main
andrewpozdnakov7-jpg commented 2026-11-27 23:42:23 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-27T23:42:23Z.


XMA joins each decoded block to the previous one with a windowed overlap. Split each slice once and iterate the matching sample and window pairs directly. Each pair uses the same floating-point expressions in the same order.

On Windows x86-64, the median time for the isolated step across 15 alternating A/B measurements was 216 to 143 ns for 128 samples, 416 to 323 ns for 256, and 831 to 675 ns for 512. Each timing includes copying the same generated input into the working buffer.

The same 16 generated mono frames and final flush produced byte-identical PCM on main and this head. That check uses the single-bin synthetic frame from #2795. The 46 active release tests in victory-formats passed, along with strict Clippy and the asset policy check.

Coordination claim

AI-assisted with OpenAI Codex.

<!-- greyfinch-sync:Marvisak/VIctory:issue:5534548090 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3629). Originally posted by [andrewpozdnakov7-jpg](https://github.com/andrewpozdnakov7-jpg) on 2026-11-27T23:42:23Z. --- XMA joins each decoded block to the previous one with a windowed overlap. Split each slice once and iterate the matching sample and window pairs directly. Each pair uses the same floating-point expressions in the same order. On Windows x86-64, the median time for the isolated step across 15 alternating A/B measurements was 216 to 143 ns for 128 samples, 416 to 323 ns for 256, and 831 to 675 ns for 512. Each timing includes copying the same generated input into the working buffer. The same 16 generated mono frames and final flush produced byte-identical PCM on main and this head. That check uses the single-bin synthetic frame from #2795. The 46 active release tests in victory-formats passed, along with strict Clippy and the asset policy check. [Coordination claim](https://github.com/Marvisak/VIctory/issues/1633#issuecomment-7230305691) AI-assisted with OpenAI Codex.
andrewpozdnakov7-jpg commented 2026-11-27 23:42:51 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-27T23:42:51Z.


The Windows comparison used two distinct release test binaries at 63bcca4 and a5142ae. All four outputs from decoding 16 generated mono frames plus the final flush matched byte for byte, with 8,430 nonzero samples out of 8,448. The isolated 128-, 256-, and 512-sample checks also matched bit for bit, including signed zero and very small finite samples.

The isolated overlap-add step took roughly 19–34% less time on this host. The timings are for the synthetic operation in this PR. The 46 active victory-formats release tests and strict Clippy passed.

If you reuse the code, 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:7230351836 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3629#issuecomment-7230351836). Originally posted by [andrewpozdnakov7-jpg](https://github.com/andrewpozdnakov7-jpg) on 2026-11-27T23:42:51Z. --- The Windows comparison used two distinct release test binaries at 63bcca4 and a5142ae. All four outputs from decoding 16 generated mono frames plus the final flush matched byte for byte, with 8,430 nonzero samples out of 8,448. The isolated 128-, 256-, and 512-sample checks also matched bit for bit, including signed zero and very small finite samples. The isolated overlap-add step took roughly 19–34% less time on this host. The timings are for the synthetic operation in this PR. The 46 active victory-formats release tests and strict Clippy passed. If you reuse the code, 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:23:33 +00:00 (Migrated from github.com)

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


I checked a5142ae together with #3383 at 23e62b7 on 63bcca4. The merge preserves both heads. Integration branch 9df74dd

I compared Windows x64 release binaries for #3383 alone and the merge. Each ran a 16-frame mono stream and a 16-frame stereo stream at 48 kHz. I used #2795's generated single-bin fixture and alternated the active channel in its stereo version. Both builds decoded every frame and appended the flush tail. The PCM matched byte for byte across the two builds for all 8,448 mono samples and all 16,896 interleaved stereo samples. The first stereo frame's right channel was zero, and both channels produced nonzero output over the stream.

The reusable encoded-frame buffer kept the same pointer and capacity through each stream. The allocating and reusable frame paths produced identical PCM within each build, including the flush, and both preserved the two samples already in the output vector.

The combined victory-formats release suite passed 48 tests with five ignored. Strict formats Clippy passed. The fixture exercises the decoder and packet-buffer path. The HLE worker is outside this run. AI-assisted with Codex.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7230875619 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3629#issuecomment-7230875619). Originally posted by [andrewpozdnakov7-jpg](https://github.com/andrewpozdnakov7-jpg) on 2026-11-28T00:23:33Z. --- I checked `a5142ae` together with #3383 at `23e62b7` on `63bcca4`. The merge preserves both heads. [Integration branch `9df74dd`](https://github.com/andrewpozdnakov7-jpg/VIctory/tree/review/xma-overlap-and-reused-frames) I compared Windows x64 release binaries for #3383 alone and the merge. Each ran a 16-frame mono stream and a 16-frame stereo stream at 48 kHz. I used #2795's generated single-bin fixture and alternated the active channel in its stereo version. Both builds decoded every frame and appended the flush tail. The PCM matched byte for byte across the two builds for all 8,448 mono samples and all 16,896 interleaved stereo samples. The first stereo frame's right channel was zero, and both channels produced nonzero output over the stream. The reusable encoded-frame buffer kept the same pointer and capacity through each stream. The allocating and reusable frame paths produced identical PCM within each build, including the flush, and both preserved the two samples already in the output vector. The combined `victory-formats` release suite passed 48 tests with five ignored. Strict formats Clippy passed. The fixture exercises the decoder and packet-buffer path. The HLE worker is outside this run. AI-assisted with Codex.
andrewpozdnakov7-jpg commented 2026-11-28 11:43:52 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-28T11:43:52Z.


I closed my duplicate #3721 and replayed the extra fixture on this exact a5142ae head against 63bcca4. The production inverse transform and each version of the overlap ran through four 64-subframe sequences. All 74,752 float values and PCM conversions matched in each run.

Across four Windows release processes, with 24 balanced timing pairs per process and sequence, run-level medians were 1.3–3.8% faster for 128-sample sequences, 0.9% slower to 1.3% faster for 256, and 0.1–2.1% faster for 512. The mixed sequence ranged from 3.4% slower to 2.9% faster. These measurements cover the transform and overlap together. The original PR discussion has the isolated overlap results.

The next step is maintainer review of #3629.

AI-assisted with OpenAI Codex.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7238744994 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3629#issuecomment-7238744994). Originally posted by [andrewpozdnakov7-jpg](https://github.com/andrewpozdnakov7-jpg) on 2026-11-28T11:43:52Z. --- I closed my duplicate #3721 and replayed the extra fixture on this exact `a5142ae` head against `63bcca4`. The production inverse transform and each version of the overlap ran through four 64-subframe sequences. All 74,752 float values and PCM conversions matched in each run. Across four Windows release processes, with 24 balanced timing pairs per process and sequence, run-level medians were 1.3–3.8% faster for 128-sample sequences, 0.9% slower to 1.3% faster for 256, and 0.1–2.1% faster for 512. The mixed sequence ranged from 3.4% slower to 2.9% faster. These measurements cover the transform and overlap together. The original PR discussion has the isolated overlap results. The next step is maintainer review of #3629. AI-assisted with OpenAI Codex.
andrewpozdnakov7-jpg commented 2026-11-28 23:25:58 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-28T23:25:58Z.


I replayed the complete XMA decoder on exact a5142ae and 63bcca4 with a wider generated fixture. It covers 128-, 256-, and 512-sample subframes at 24, 32, 44.1, and 48 kHz, with mono and three stereo configurations at each size and rate.

Both Windows x64 release processes matched all 1,053,696 PCM samples through the final flush and all 1,769,472 intermediate floating-point state words across 1,152 generated frames. Each stream produced nonzero audio. A parallel fixed-width experiment matched the same data and ran faster in the isolated overlap loop. Full-decoder timings stayed within the run-to-run spread of this PR's paired loop. The next step is maintainer review.

AI-assisted with OpenAI Codex.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7247426719 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3629#issuecomment-7247426719). Originally posted by [andrewpozdnakov7-jpg](https://github.com/andrewpozdnakov7-jpg) on 2026-11-28T23:25:58Z. --- I replayed the complete XMA decoder on exact `a5142ae` and `63bcca4` with a wider generated fixture. It covers 128-, 256-, and 512-sample subframes at 24, 32, 44.1, and 48 kHz, with mono and three stereo configurations at each size and rate. Both Windows x64 release processes matched all 1,053,696 PCM samples through the final flush and all 1,769,472 intermediate floating-point state words across 1,152 generated frames. Each stream produced nonzero audio. A parallel fixed-width experiment matched the same data and ran faster in the isolated overlap loop. Full-decoder timings stayed within the run-to-run spread of this PR's paired loop. The next step is maintainer review. AI-assisted with OpenAI Codex.
javi12olivar commented 2026-11-29 12:36:32 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by javi12olivar on 2026-11-29T12:36:32Z.


Independent Windows verification at a5142ae (parent 63bcca4): cargo test -p victory-formats passed (46 passed, 0 failed, 5 ignored); git diff --check is clean. I also compared the old and new overlap loops using deterministic synthetic buffers (32 each at window sizes 128, 256, and 512); outputs were bit-identical. This verifies the overlap change, but not decoding a full real PCM corpus or the reported performance gain.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7255934998 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3629#issuecomment-7255934998). Originally posted by [javi12olivar](https://github.com/javi12olivar) on 2026-11-29T12:36:32Z. --- Independent Windows verification at `a5142ae` (parent `63bcca4`): `cargo test -p victory-formats` passed (46 passed, 0 failed, 5 ignored); `git diff --check` is clean. I also compared the old and new overlap loops using deterministic synthetic buffers (32 each at window sizes 128, 256, and 512); outputs were bit-identical. This verifies the overlap change, but not decoding a full real PCM corpus or the reported performance gain.
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/3629:upstream-pr/3629'
git switch 'upstream-pr/3629'

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