feat(libSceNgs2.native): parse looped PCM waveforms #9149
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/9149"
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 boykopovar/AnyPS5. Originally posted by MarrasFederico on 2026-10-21T13:35:50Z.
What
sceNgs2ParseWaveformDatathrew for a PCM file whosesmplchunk declares a loop ("parsing looped waveforms is not implemented"). PCM loops now follow prosper's reading oflibSceNgs2.native.sprx: its loop point code and block list code.smpl+0x2c) and inclusive end (+0x30) are read. They are stored as the loop begin andend + 1, which wraps in 32 bits. The loop count beyond non-zero, the type, the fraction, the play count and any further loops are ignored.0xFFFFFFFF), and a tail when the end is not the last sample.smplchunk: a chunk too short for its loop count or its first loop, where the module reads the bytes that follow it.ATRAC9 loop parsing is unchanged and keeps its own rules.
This builds on #9148, which generalizes the PCM parser this change extends. #9148 is merged and this branch is merged with current
main, so the diff holds only this PR's commits.Tested
Ubuntu 26.04.1, kernel 7.0.0-38, GCC 15.2.0, Release, full build with
BUILD_TESTING=ON. Windows was not compiled. No title was run.ngs2_parse,TestParsePcmLoops:0xFFFFFFFF(wrapping to 0) keep the single block and store the loop positions. Asmplchunk with no loops also keeps the single block.smplchunk too short for its count or first loop), so the test does not pin them as unimplemented.INVALID_WAVEFORM_DATAfor an end not after the start;ngs2_atrac9and its loop cases still pass.main(#9148 and #9324 included, conflicts inNgs2Parse.cppand the PCM parsing debt entry resolved by keeping both changes), the full build succeeds and the 45ngs2tests pass.tools/check_conventions.py --base origin/mainpasses.tools/pr_overlap.pyfinds no conflicting lines. It could not compare #5797 and #8609, which conflict withmain; neither touches loop parsing.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by KernelPanicNT on 2026-10-21T14:56:52Z.
I had a branch for the same change (not opened, since this one came first), built from the same prosper reading. A few places where this PR differs from what that reading says the native module does, in case they are worth aligning or recording:
begin >= endreturnsINVALID_WAVEFORM_DATA. In prosper's loop point code (0x116cd..0x11729) the module stores the loop positions and keeps the single block, returning success.0x11a20..0x11cdd) reads only the first loop's start and end (smpl+0x2c, +0x30). It does not read the loop count beyond "non-zero", the type, the fraction or the play count. So a file with two loops, or a ping-pong first loop, parses on the console, but throws here. The play count difference is already in the debt entry; the others could be listed there too.INVALID_WAVEFORM_DATA. The module does not check it and the tail block size wraps, so a throw recorded as debt may be closer than an error code the module never returns.Cases worth a test either way: a two-loop chunk with a ping-pong first loop, a backwards loop, an end that wraps to 0 (
0xFFFFFFFF), a loop from 0 to the last sample, and a loop from 0 with a tail. I am dropping my branch, so this is only for reference.Imported from boykopovar/AnyPS5. Originally posted by MarrasFederico on 2026-10-21T15:06:31Z.
@KernelPanicNT thanks, all three hold against those lines, so PCM loops now follow the module in
403956973. ATRAC9 keeps its own loop parser, unchanged:end + 1stored.smplchunk too short for its count or first loop also throws, since the module reads the bytes after it.TestParsePcmLoopscovers your cases:0xFFFFFFFF(wrapping to 0);It fails if the error code, the play count mapping or a 64-bit end come back. I updated the description too.
Imported from boykopovar/AnyPS5. Originally posted by ycbuzi on 2026-10-21T20:49:08Z.
Windows run of
4039569737merged ontomain0c6a5bd593(66d404c184, clean), the platform the description lists as not tested. Windows 11 Home 10.0.26200, MinGW-w64 GCC 15.2.0 (ucrt-posix-seh r7), Release,BUILD_TESTING=ON.Built
libSceNgs2.nativeandngs2_parse_testswith no errors or warnings.ctest --repeat until-fail:2onngs2_parse: passes on both repeats. The head carries the PRs below it in its stack (#9148) too. Not run: a title.