xma: start the frame after a continuation at the next packet that has frames #96

Manually merged
github merged 1 commit from gh-pr/96/head into gh-pr/96/base 2026-11-26 03:50:09 +00:00
Owner

@⁠tedin7 on GitHub · 2026-11-24 00:26 UTC · original
tedin7:vic-xma-continuation → main · +43 −4 · 1 files · 1 commits · merged 2026-11-25 00:15 UTC

What

xma::next_frame now finds the frame after one that ends in a packet where no frame begins (header frames == 0) by following each packet's skip to the next packet that has frames, instead of returning the position inside that packet. Packets with frames == 0 and first_frame_bit == 0x7fff (a frame spans all of them) are stepped over the same way.

Why

When a frame crosses a continuation packet and ends in a later packet that holds only the tail of that frame plus padding, next_frame returned the bit right after the frame, inside the padding. read_frame then read a zero length there and the walk stopped, so every later frame of the stream was lost (audio cut off early). Only the "last frame of its own packet" and "ends exactly on a packet boundary" cases jumped to the next packet.

Tested

Linux x86_64 only, synthetic in-memory packets (no game data). The new test builds 4 packets: a frame crossing a full continuation packet and ending 64 bits into a packet with no frames, then a packet with one frame.

  • Before the fix: cargo test -j4 -p victory-formats --lib xma:: fails the new test (left: Some(32864), right: Some(49184)).
  • After the fix: cargo test -j4 -p victory-formats gives 18 passed, 0 failed, 3 ignored (the ignored ones need files outside the repo).
  • cargo clippy -j4 -p victory-formats --tests is clean.
  • cargo fmt --check already reports diffs in untouched code in this crate; I did not reformat it. My lines follow the surrounding wide-line style.

Not run: Windows runtime, the GPU, and any real XMA stream or reference decoder (the #[ignore] tests need files outside the repo). The packet layout in the test follows the header description in the module docs; I could not confirm against a real encoder how often it emits a tail-only packet.

**@⁠tedin7** on GitHub · 2026-11-24 00:26 UTC · [original](https://github.com/Marvisak/VIctory/pull/96) `tedin7:vic-xma-continuation` → `main` · +43 −4 · 1 files · 1 commits · merged 2026-11-25 00:15 UTC **What** `xma::next_frame` now finds the frame after one that ends in a packet where no frame begins (header `frames == 0`) by following each packet's `skip` to the next packet that has frames, instead of returning the position inside that packet. Packets with `frames == 0` and `first_frame_bit == 0x7fff` (a frame spans all of them) are stepped over the same way. **Why** When a frame crosses a continuation packet and ends in a later packet that holds only the tail of that frame plus padding, `next_frame` returned the bit right after the frame, inside the padding. `read_frame` then read a zero length there and the walk stopped, so every later frame of the stream was lost (audio cut off early). Only the "last frame of its own packet" and "ends exactly on a packet boundary" cases jumped to the next packet. **Tested** Linux x86_64 only, synthetic in-memory packets (no game data). The new test builds 4 packets: a frame crossing a full continuation packet and ending 64 bits into a packet with no frames, then a packet with one frame. - Before the fix: `cargo test -j4 -p victory-formats --lib xma::` fails the new test (`left: Some(32864)`, `right: Some(49184)`). - After the fix: `cargo test -j4 -p victory-formats` gives 18 passed, 0 failed, 3 ignored (the ignored ones need files outside the repo). - `cargo clippy -j4 -p victory-formats --tests` is clean. - `cargo fmt --check` already reports diffs in untouched code in this crate; I did not reformat it. My lines follow the surrounding wide-line style. Not run: Windows runtime, the GPU, and any real XMA stream or reference decoder (the `#[ignore]` tests need files outside the repo). The packet layout in the test follows the header description in the module docs; I could not confirm against a real encoder how often it emits a tail-only packet.
A frame that ends in a packet where no frame begins (the tail of a frame that crossed packets, then padding) left the next frame pointing into that padding, which ended the stream early. Now the next frame is found by following each packet's skip to the next packet with frames.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:50:08 +00:00
github manually merged commit ba42db643c into gh-pr/96/base 2026-11-26 03:50:09 +00:00
Author
Owner

@⁠DaviTostes on GitHub · 2026-11-24 01:12 UTC · original

Tested ba42db6: pass.

  • Tested on Arch Linux x86_64, rustc 1.98.1, cargo test -p victory-formats: 18 passed, 0 failed, 3 ignored, including the 1 test this PR adds.

No game data used.

**@⁠DaviTostes** on GitHub · 2026-11-24 01:12 UTC · [original](https://github.com/Marvisak/VIctory/pull/96#issuecomment-7118861306) Tested `ba42db6`: **pass**. - Tested on **Arch Linux x86_64, rustc 1.98.1**, `cargo test -p victory-formats`: **18 passed, 0 failed, 3 ignored**, including the 1 test this PR adds. No game data used.
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 00:24 UTC · original

Automated triage for the maintainers.

Merge candidate. next_frame in crates/victory-formats/src/xma.rs looked for the next frame in a packet's padding when a frame ended partway through a packet whose header has frames == 0, so the frame walk stopped early. It now moves on via skip to the next packet that has frames and steps over frames == 0 continuation packets the same way; this follows from the header layout in the module docs (the count is of frames that begin in the packet), and the loop ends because packet() returns None past the data. The synthetic test checks the next-frame positions; no real stream was tested, as the PR says.

CI: no check runs on the head commit.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 00:24 UTC · [original](https://github.com/Marvisak/VIctory/pull/96#issuecomment-7148471900) <!-- victory-triage v1 head=ba42db643c15c1b7fb17ba40464dddda36c1db60 verdict=merge-candidate at=2026-11-25T00:18:46Z --> Automated triage for the maintainers. **Merge candidate.** `next_frame` in `crates/victory-formats/src/xma.rs` looked for the next frame in a packet's padding when a frame ended partway through a packet whose header has `frames == 0`, so the frame walk stopped early. It now moves on via `skip` to the next packet that has frames and steps over `frames == 0` continuation packets the same way; this follows from the header layout in the module docs (the count is of frames that begin in the packet), and the loop ends because `packet()` returns `None` past the data. The synthetic test checks the next-frame positions; no real stream was tested, as the PR says. CI: no check runs on the head commit. --- _Generated by [Claude Code](https://claude.ai/code)_
This discussion has been locked. Commenting is limited to contributors.
No reviewers
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.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory!96
No description provided.