fix(ajm): a decode job fits the 64-byte batch titles allocate #420

Merged
MichonGoddijn231849 merged 1 commit from upstream-pr/420 into main 2026-10-04 01:02:48 +00:00
MichonGoddijn231849 commented 2026-10-02 23:21:05 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MichonGoddijn231849 on 2026-10-02T23:21:05Z.


What

libSceAjm.native stored each batch job as a 72-byte header plus 16 bytes per buffer, so one sceAjmBatchJobDecode took 104 bytes. GTA V initializes each MP3 batch with a 0x40-byte buffer, so every decode returned SCE_AJM_ERROR_OUT_OF_RESOURCES. No batch ever started, and the game gave up on its streams and requested them again. Music and character speech were silent, and INTERACTIVE_MUSIC.rpf was read at about 100 MB/s.

A job is now a 32-byte record, followed by its buffers, then its parameters only when it has any. A decode job takes 64 bytes. The set-gapless job now records its parameter size, which it copied without setting before. sceAjmBatchStart unpacks the record into the same JobHeader that Execute reads, so decoding itself is unchanged.

Tested

Windows 11 Pro, AMD Ryzen 5 7600, NVIDIA GeForce RTX 5080 (driver 32.0.16.1074), 32 GB DDR5-5600, MinGW-w64 GCC 15.2.0.

  • ctest: all tests pass. guest_ajm now decodes its MP3 frames through a 64-byte batch; the old encoding fails it.
  • GTA V (PPSA04264):
    • Menu music, in-game music and character speech now play.
    • Reads of INTERACTIVE_MUSIC.rpf dropped from about 1 GB per 10 s to a few MB.
    • Tested on my branch that combines this change with my other open PRs.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt
  • No notes, investigation .md files or images added to the repository
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • AI-assisted: yes. Written with Claude (Anthropic) under my direction; I reviewed and tested it.

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4722487701 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/420). Originally posted by [MichonGoddijn231849](https://github.com/MichonGoddijn231849) on 2026-10-02T23:21:05Z. --- ### What `libSceAjm.native` stored each batch job as a 72-byte header plus 16 bytes per buffer, so one `sceAjmBatchJobDecode` took 104 bytes. GTA V initializes each MP3 batch with a 0x40-byte buffer, so every decode returned `SCE_AJM_ERROR_OUT_OF_RESOURCES`. No batch ever started, and the game gave up on its streams and requested them again. Music and character speech were silent, and `INTERACTIVE_MUSIC.rpf` was read at about 100 MB/s. A job is now a 32-byte record, followed by its buffers, then its parameters only when it has any. A decode job takes 64 bytes. The set-gapless job now records its parameter size, which it copied without setting before. `sceAjmBatchStart` unpacks the record into the same `JobHeader` that `Execute` reads, so decoding itself is unchanged. ### Tested Windows 11 Pro, AMD Ryzen 5 7600, NVIDIA GeForce RTX 5080 (driver 32.0.16.1074), 32 GB DDR5-5600, MinGW-w64 GCC 15.2.0. - `ctest`: all tests pass. `guest_ajm` now decodes its MP3 frames through a 64-byte batch; the old encoding fails it. - GTA V (PPSA04264): - Menu music, in-game music and character speech now play. - Reads of `INTERACTIVE_MUSIC.rpf` dropped from about 1 GB per 10 s to a few MB. - Tested on my branch that combines this change with my other open PRs. ### Checklist - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except technical debt - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed in TechnicalDebt - [x] No notes, investigation `.md` files or images added to the repository - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] AI-assisted: yes. Written with Claude (Anthropic) under my direction; I reviewed and tested it. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Sign in to join this conversation.
No reviewers
No labels
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.

Reference
boykopovar/AnyPS5!420
No description provided.