Formats: treat XMA2 PacketSkipCount 0xff as end-of-stream #2503
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2505"
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 VastyViz on 2026-11-25T14:58:38Z.
Summary
Per the XMA2 packet header specification, the 8-bit
PacketSkipCountfield uses0xff(255) as an end-of-stream sentinel ("no further packets belong to this stream"), while0..=0xfegive the number of interleaved packets of other streams to skip.Previously,
victory-formats/src/xma.rsalways advanced by1 + skip:next_frame: after the last frame of a packet (or while stepping past zero-frame continuation packets), a packet withskip == 0xffjumped 256 packets forward instead of returningNone. Because an XMA input buffer can hold up to 4095 packets, any multi-stream or banked buffer with at least 257 packets past the stream's last packet would continue walking into unrelated stream data instead of ending the buffer and flushing/switching invictory-hle's audio decoder.Cursor::bit: a frame whose bit length ran past a packet withskip == 0xffjumped 256 packets forward and spliced bits from unrelated packets instead of failing to read.Changes
END_OF_STREAM: u32 = 0xffand a sharednext_packet(index, skip) -> Option<usize>helper incrates/victory-formats/src/xma.rsthat returnsNoneonskip == 0xff(and uses checked arithmetic for packet and bit offsets).Cursor::bitand both packet advances innext_frameto route throughnext_packet.crates/victory-formats/src/xma.rs:skip_count_ff_ends_the_stream_instead_of_jumping_255_packets(direct stop on the ending packet and stop insidenext_frame's zero-frame packet walk when valid packets exist 256 packets ahead).skip_count_ff_stops_cross_packet_frame_reads(frame crossing a0xffpacket returnsNoneinstead of splicing bits from 256 packets ahead).skip_count_fe_still_skips_254_packets(negative control verifying the largest non-sentinel skip0xfestill advances 254 packets for bothnext_frameand cross-packet frame reads).Verification
cargo test -p victory-formats --locked(41 passed, 0 failed)cargo test -p victory-hle --locked -- audio(8 passed, 0 failed)cargo clippy --workspace --all-targets --locked -- -D warnings(0 warnings)cargo clippy --workspace --all-targets --all-features --locked -- -D warnings(0 warnings)cargo xtask policy(asset policy: 182 files ok)git diff --check(clean)Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T15:56:58Z.
Automated triage for the maintainers.
The change in
crates/victory-formats/src/xma.rs(next_packet, used byCursor::bitandnext_frame) is cleanly done and well tested, but it changes how XMA streams are walked on the strength of "per the XMA2 packet header specification" with no reference anyone can check. Please point to public evidence that a skip count of0xffends the stream rather than meaning a 255-packet skip, for example FFmpeg's or another public decoder's handling, or a stream from the title where a0xffpacket is followed by unrelated data. Note that sources from the console's development kit cannot be cited or copied here (docs/asset-policy.md). With such a reference this would be a good candidate. CI (check) is passing.Generated by Claude Code
Imported from Marvisak/VIctory. Originally posted by VastyViz on 2026-11-25T17:09:01Z.
Closing this PR after double-checking public references and the title's XMA2 streams:
libavcodec/wmaprodec.c,libavcodec/xma_parser.c),hcs64'sxma_parse, upstream Xenia (xma_context.cc), nor the public June 2010 DirectX SDKxma2defs.h(GetXmaFrameBitPosition/GetLastXmaFrameBitPosition) treatPacketSkipCount == 0xffas an end-of-stream sentinel after decoding a packet's frames — all advance by1 + skipand stop on buffer bounds. (vgmstream'scoding_utils.candxenia-canary'sDecode()handle0xffdifferently as a full-packet skip to the next sequential packet rather than decoding and terminating.)skip == 0.Without a verifiable public reference or an affected stream from the title, changing the packet-walking semantics isn't justified. Thanks for the triage review!
Pull request closed