libSceAjm.native: no M4AAC decoder (Ghost of Yotei initialises AAC); implementation ready #3410

Closed
opened 2026-10-11 09:48:18 +00:00 by screamm · 2 comments
screamm commented 2026-10-11 09:48:18 +00:00 (Migrated from github.com)
Contributor

Imported from boykopovar/AnyPS5. Originally posted by screamm on 2026-10-11T09:48:18Z.


libSceAjm.native (Ajm.cpp) has no M4AAC decoder: sceAjmBatchJobControl INITIALIZE for codec id 2 reaches NotImplemented_nid_no_patch. Ghost of Yotei (PPSA26344 v1.008) initialises an AAC instance with flags 0x200000006000 (RESET, INITIALIZE, gapless decode), 8 bytes of gapless parameters plus 8 bytes of M4AAC parameters, and an 8-byte result (#884).

Fix branch ready: screamm:feat/ajm-m4aac (a395684b, one commit on main 0490ca18). I cannot open it as a PR because of the intake check; anyone eligible is welcome to carry it, keeping the commit as is.

  • Source: shadPS4 ajm_aac.h/ajm_aac.cpp, ajm.h, ajm_instance.cpp (443f0224), fdk-aac tpdec_lib.cpp and aacdecoder_lib.cpp (3e09594c) for raw transport and the bitrate formula. Codec id 2, channels from flag bits 3 to 6, ENABLE_SBR_DECODE/ENABLE_NONDELAY_OUTPUT/surround order from bits 32 to 35, other codec flags throw. INITIALIZE reads config type (1 ADTS, 2 raw) and sampling frequency index; bad values return the invalid-parameter result (4) as the ATRAC9 and Opus paths do. RUN decodes ADTS frames by header length, or one raw access unit per job, through the FFmpeg AAC decoder already linked, into S16/S32/float with the existing gapless, resampler, stream and multiple-frames handling; the first two frames after INITIALIZE/RESET produce no output unless non-delay is set, as in shadPS4; decoder errors return CODEC_ERROR | FATAL; the format reports fdk-aac's bitrate. Unsettled cases throw: ADTS not starting with a header, profiles other than AAC LC, more than one raw data block per frame, channel configurations other than 1, 2 and 6, more channels than the instance, HE-AAC without ENABLE_SBR_DECODE, raw input with multiple frames, a frame longer than the reserved room. TechnicalDebt records the shadPS4-only delay model and the unknown console result for decoder errors.
  • guest_ajm gains an 896-byte five-frame stereo ADTS fixture (two chirps encoded offline with FFmpeg 6.1.1; the linked FFmpeg has no AAC encoder) decoded through the exact PPSA26344 control shape: the two silent delay frames, sample counts, format (2 channels, mask 0x3, 48000 Hz, bitrate 78750), codec info, correlation above 0.9 with each input chirp and below 0.07 with the other channel (channel order), RESET, gapless trimming, multiple-frames float output, raw access units matching ADTS, not-enough-room, partial input, the result-4 validation cases and the throws.

Tested on Windows 11 Pro 26220, WinLibs MinGW-w64 GCC 15.2.0 r7, Ninja, Release, BUILD_TESTING=ON, full build including libs: guest_ajm 3/3; ctest -j8 -E "^agc_driver_|^video_out_flip" 524/525, the one failure being windows_exceptions, which fails identically on main 0490ca18 without this change (reported separately); with main's Ajm.cpp the extended test fails; tools/check_conventions.py --base main and git diff --check pass. Not run on Linux.

Written with Claude Code assistance (implementation by a subagent, reviewed and validated in this session).

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5799941046 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/3410). Originally posted by [screamm](https://github.com/screamm) on 2026-10-11T09:48:18Z. --- libSceAjm.native ([Ajm.cpp](https://github.com/boykopovar/AnyPS5/blob/main/core/libs/prx/libSceAjm.native/src/Ajm.cpp)) has no M4AAC decoder: `sceAjmBatchJobControl` INITIALIZE for codec id 2 reaches `NotImplemented_nid_no_patch`. Ghost of Yotei (PPSA26344 v1.008) initialises an AAC instance with flags `0x200000006000` (RESET, INITIALIZE, gapless decode), 8 bytes of gapless parameters plus 8 bytes of M4AAC parameters, and an 8-byte result (#884). **Fix branch ready:** [`screamm:feat/ajm-m4aac`](https://github.com/screamm/AnyPS5/tree/feat/ajm-m4aac) (`a395684b`, one commit on `main` `0490ca18`). I cannot open it as a PR because of the intake check; anyone eligible is welcome to carry it, keeping the commit as is. - Source: shadPS4 `ajm_aac.h`/`ajm_aac.cpp`, `ajm.h`, `ajm_instance.cpp` (`443f0224`), fdk-aac `tpdec_lib.cpp` and `aacdecoder_lib.cpp` (`3e09594c`) for raw transport and the bitrate formula. Codec id 2, channels from flag bits 3 to 6, `ENABLE_SBR_DECODE`/`ENABLE_NONDELAY_OUTPUT`/surround order from bits 32 to 35, other codec flags throw. INITIALIZE reads config type (1 ADTS, 2 raw) and sampling frequency index; bad values return the invalid-parameter result (4) as the ATRAC9 and Opus paths do. RUN decodes ADTS frames by header length, or one raw access unit per job, through the FFmpeg AAC decoder already linked, into S16/S32/float with the existing gapless, resampler, stream and multiple-frames handling; the first two frames after INITIALIZE/RESET produce no output unless non-delay is set, as in shadPS4; decoder errors return `CODEC_ERROR | FATAL`; the format reports fdk-aac's bitrate. Unsettled cases throw: ADTS not starting with a header, profiles other than AAC LC, more than one raw data block per frame, channel configurations other than 1, 2 and 6, more channels than the instance, HE-AAC without `ENABLE_SBR_DECODE`, raw input with multiple frames, a frame longer than the reserved room. TechnicalDebt records the shadPS4-only delay model and the unknown console result for decoder errors. - `guest_ajm` gains an 896-byte five-frame stereo ADTS fixture (two chirps encoded offline with FFmpeg 6.1.1; the linked FFmpeg has no AAC encoder) decoded through the exact PPSA26344 control shape: the two silent delay frames, sample counts, format (2 channels, mask 0x3, 48000 Hz, bitrate 78750), codec info, correlation above 0.9 with each input chirp and below 0.07 with the other channel (channel order), RESET, gapless trimming, multiple-frames float output, raw access units matching ADTS, not-enough-room, partial input, the result-4 validation cases and the throws. **Tested** on Windows 11 Pro 26220, WinLibs MinGW-w64 GCC 15.2.0 r7, Ninja, Release, `BUILD_TESTING=ON`, full build including `libs`: `guest_ajm` 3/3; `ctest -j8 -E "^agc_driver_|^video_out_flip"` 524/525, the one failure being `windows_exceptions`, which fails identically on `main` `0490ca18` without this change (reported separately); with `main`'s `Ajm.cpp` the extended test fails; `tools/check_conventions.py --base main` and `git diff --check` pass. Not run on Linux. Written with Claude Code assistance (implementation by a subagent, reviewed and validated in this session).
blawesom commented 2026-10-11 10:27:50 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by blawesom on 2026-10-11T10:27:50Z.


Independent verification on Linux (the gap noted in the report), with the negative control the report used: CachyOS, kernel 7.2.9, GCC 16.2.1, Ninja, Release, BUILD_TESTING=ON.

  • Rebased a395684b onto current main: one conflict in docs/dev/TechnicalDebt.md, resolved by keeping both this entry and main's newer entries; no code conflicts.
  • tools/check_conventions.py and git diff --check pass.
  • guest_ajm passes, stable across repeated runs. Negative control: with this branch's extended test but main's Ajm.cpp, the test aborts at sceAjmBatchJobControl (INITIALIZE for a codec other than MP3, ATRAC9 and Opus) not implemented — the M4AAC paths the test covers are exactly the ones this branch implements, and it passes only with the branch's decoder.
  • Full suite mirroring the Windows run (ctest -j8 -E "^agc_driver_|^video_out_flip"): 522/522 passed, including the windows_exceptions test that failed on the report's Windows machine.

The rebased branch is available at blawesom:verify/3410 for anyone carrying — the commit is otherwise unchanged.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6108072669 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/3410#issuecomment-6108072669). Originally posted by [blawesom](https://github.com/blawesom) on 2026-10-11T10:27:50Z. --- Independent verification on **Linux** (the gap noted in the report), with the negative control the report used: CachyOS, kernel 7.2.9, GCC 16.2.1, Ninja, Release, `BUILD_TESTING=ON`. - Rebased `a395684b` onto current `main`: one conflict in `docs/dev/TechnicalDebt.md`, resolved by keeping both this entry and main's newer entries; no code conflicts. - `tools/check_conventions.py` and `git diff --check` pass. - `guest_ajm` passes, stable across repeated runs. **Negative control**: with this branch's extended test but `main`'s `Ajm.cpp`, the test aborts at `sceAjmBatchJobControl (INITIALIZE for a codec other than MP3, ATRAC9 and Opus) not implemented` — the M4AAC paths the test covers are exactly the ones this branch implements, and it passes only with the branch's decoder. - Full suite mirroring the Windows run (`ctest -j8 -E "^agc_driver_|^video_out_flip"`): **522/522 passed**, including the `windows_exceptions` test that failed on the report's Windows machine. The rebased branch is available at [`blawesom:verify/3410`](https://github.com/blawesom/AnyPS5/tree/verify/3410) for anyone carrying — the commit is otherwise unchanged.
MarcZX10 commented 2026-10-13 16:50:50 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-13T16:50:50Z.


Carried the M4AAC implementation into PR #5307: https://github.com/boykopovar/AnyPS5/pull/5307. Linux guest_ajm passes (1/1), and conventions pass. The PS4-derived behavior assumptions and Windows-only testing from the issue are documented in the PR.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6150636408 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/3410#issuecomment-6150636408). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-13T16:50:50Z. --- Carried the M4AAC implementation into PR #5307: https://github.com/boykopovar/AnyPS5/pull/5307. Linux `guest_ajm` passes (1/1), and conventions pass. The PS4-derived behavior assumptions and Windows-only testing from the issue are documented in the PR.
Sign in to join this conversation.
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#3410
No description provided.