xma: start the frame after a continuation at the next packet that has frames #96
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/96"
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 Marvisak/VIctory. Originally posted by tedin7 on 2026-11-24T00:26:45Z.
What
xma::next_framenow finds the frame after one that ends in a packet where no frame begins (headerframes == 0) by following each packet'sskipto the next packet that has frames, instead of returning the position inside that packet. Packets withframes == 0andfirst_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_framereturned the bit right after the frame, inside the padding.read_framethen 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.
cargo test -j4 -p victory-formats --lib xma::fails the new test (left: Some(32864),right: Some(49184)).cargo test -j4 -p victory-formatsgives 18 passed, 0 failed, 3 ignored (the ignored ones need files outside the repo).cargo clippy -j4 -p victory-formats --testsis clean.cargo fmt --checkalready 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.Imported from Marvisak/VIctory. Originally posted by DaviTostes on 2026-11-24T01:12:06Z.
Tested
ba42db6: pass.cargo test -p victory-formats: 18 passed, 0 failed, 3 ignored, including the 1 test this PR adds.No game data used.
Imported from Marvisak/VIctory. Originally posted by mercuryVM on 2026-11-24T08:50:49Z.
Review: APPROVED
Tested
ba42db6on Windows 11, RTX 5070, MSVC:cargo test --workspace --no-fail-fastpasses (228 passed, 0 failed; older base), includingthe_frame_after_continuation_packets_starts_in_the_next_packet_with_frames.frames == 0holds only a continuation tail and padding, so no frame can start in it. Before,next_framereturned the bit right after the tail, inside the padding, and the walk then read a zero length and stopped the stream.skipuntil a packet withframes > 0and starting at itsfirst_frame_bitfollows the packet layout. The loop is bounded, becausepacket()returnsNonepast the data.No issues found.
AI-assisted (Claude Code).
Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T00:24:09Z.
Automated triage for the maintainers.
Merge candidate.
next_frameincrates/victory-formats/src/xma.rslooked for the next frame in a packet's padding when a frame ended partway through a packet whose header hasframes == 0, so the frame walk stopped early. It now moves on viaskipto the next packet that has frames and steps overframes == 0continuation 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 becausepacket()returnsNonepast 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