fix(libSceAjm.native): keep an ATRAC9 gapless segment ended after its total #18522
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/18522"
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 kali113 on 2026-11-11T20:01:18Z.
What
A run of an ATRAC9 instance with a gapless total stopped decoding when the output reached the total, left the rest of its input unconsumed, and the next run started a new segment. On a PS5 it does neither. This makes the library match the console, as measured below.
Measured on a PS5 (firmware 13.590.001, the real
libSceAjm.nativecalled from a payload process) with 16 consecutive superframes of a title's own ATRAC9 file (stereo, 48 kHz, configFE 74 0B F0, 384-byte superframes of four frames; the bytes are not attached). The full table, with the probe source, is in this comment on #11700:totalsamples: totals 300, 512, 1100 and 1500, the last ending inside a run of two superframes (inputConsumed384 or 768,frames4 or 8,outputWritten1200, 2048, 304 for the 76 samples left of 1100, and 6000 bytes).totalDecodedSamplesstays at the total.SetGaplessDecodewith the same total and reset 0 changes nothing.SetGaplessDecodewith the reset flag starts a new segment: the next run wrote 2048 bytes again for total 512.RunAt9no longer breaks out of its loop at the total (output was already capped per frame) and no longer zeroes the segment counter after a run that ended it. Resets still do (the reset flag,ClearContext, initialization).TestAt9GaplessSegmentspinned the opposite for a mono synthetic stream (the next run decodes a new segment). It now checks the measured behaviour for totals 512, 300, 1500 and 1100, plus the reset.TestAt9GaplessResetRestartsTotalfeeds a whole superframe on its last run, since the previous run now consumes the whole input.Not measured, and said so in the debt entry: a new total without the reset flag after the end (the segment resumes up to it here), a nonzero skip, mono, other codecs. The tests use the repository's mono synthetic stream, not the measured stereo one.
Risk. The debt entry this replaces says FMOD in PPSA29141 needed the frames after the total decoded as a new segment (#2052). The console does not do that, so I expect the change to be right for that title too, but I did not run PPSA29141 myself. Ratchet & Clank: Rift Apart (PPSA01474, which hangs on the old behaviour per #11700) was run by @Tamalero on Linux/NVIDIA, one run per build (comment): on the same
mainit freezes before "Press X"; with this PR the title screen appears and the opening plays. A second run by @Tamalero on a Radeon PRO V620 (RADV),main4e2acc2120+ this PR, reaches the title screen, goes through the menus and the opening and hands the player control, with the #13538 limit set; there is no run ofmainon that GPU, so it does not show what the PR changes there. PPSA29141 is still unverified.Tested
Linux x86-64 (Ubuntu container, GCC 15.2): all six
guest_ajm*tests pass. WithAjm.cppreverted tomain,guest_ajmaborts, so the rewritten test pins the behaviour. Not run on Windows or macOS. Console measurements as above, one console, one stream.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 copilot-pull-request-reviewer[bot] on 2026-11-11T20:01:27Z.
Review: COMMENTED
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-12T06:08:34Z.
Review: APPROVED
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against
7436b8db6d:tools/check_conventions.pypassed;git diff --checkclean.guest_ajm_testsbuilt cleanly.guest_ajm,guest_ajm_aac_multichannel,guest_ajm_vibration,guest_ajm_driver_queries,guest_ajm_wvorbis,guest_ajm_teardown):core/libs/prx/libSceAjm.native/src/Ajm.cppreverted tomainand the new tests kept, the suite fails: Restoring the change makes it pass again.Looks Good To Me