feat(libSceAjm.native): implement M4AAC decoding #5307

Merged
MarcZX10 merged 2 commits from upstream-pr/5307 into main 2026-10-14 12:42:26 +00:00
MarcZX10 commented 2026-10-13 16:50:44 +00:00 (Migrated from github.com)

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


What

Fixes #3410. Adds the M4AAC decoder path for AJM codec 2 using the existing FFmpeg AAC decoder. It handles ADTS and raw access units, AAC-LC output, gapless trimming, resampling and multiple-frame jobs, and reports format and codec info. Unsupported profiles, channel layouts and input shapes throw explicitly. The behavior model follows shadPS4 and remains unverified on PS5 hardware.

The implementation commit retains screamm as author and its original coauthor metadata.

Tested

  • Debian 12, Linux x86_64, GCC 12.2: guest_ajm passed (1/1), including the embedded ADTS fixture, raw access units, gapless and multiple-frame cases, format and codec info, initialization validation, and unsupported-input cases.
  • Conventions check and git diff --check passed.
  • The issue report includes Windows builds; no Windows local run.

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; silent stubs are listed under technical debt
  • 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
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4846553644 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5307). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-13T16:50:44Z. --- ### What Fixes #3410. Adds the M4AAC decoder path for AJM codec 2 using the existing FFmpeg AAC decoder. It handles ADTS and raw access units, AAC-LC output, gapless trimming, resampling and multiple-frame jobs, and reports format and codec info. Unsupported profiles, channel layouts and input shapes throw explicitly. The behavior model follows shadPS4 and remains unverified on PS5 hardware. The implementation commit retains screamm as author and its original coauthor metadata. ### Tested - Debian 12, Linux x86_64, GCC 12.2: `guest_ajm` passed (1/1), including the embedded ADTS fixture, raw access units, gapless and multiple-frame cases, format and codec info, initialization validation, and unsupported-input cases. - Conventions check and `git diff --check` passed. - The issue report includes Windows builds; no Windows local run. ### 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; silent stubs are listed under technical debt - [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] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
github-actions[bot] commented 2026-10-13 16:51:32 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-13T16:51:32Z.


Progress report (145cb82 → b7c1293)

📉 System libraries: 88.33% (-0.03%, -1 reverted functions)

⚠️ 1 went back to stubs
Library Name
libSceAjm.native sceAjmInstanceCreate
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6150648959 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5307#issuecomment-6150648959). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-13T16:51:32Z. --- <!-- progress-report --> ### Progress report (145cb82 → b7c1293) 📉 **System libraries**: 88.33% (-0.03%, -1 reverted functions) <details> <summary>⚠️ 1 went back to stubs</summary> | Library | Name | | - | - | | libSceAjm.native | `sceAjmInstanceCreate` | </details>
CnRJay commented 2026-10-14 01:38:00 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by CnRJay on 2026-10-14T01:38:00Z.


Heads-up for reviewers: #4934 (also yours, opened earlier the same day) implements the same AJM M4AAC codec-2 decoder on the same FFmpeg AAC path, with ~547 lines each. This one carries screamm's commit (for #3410), and #4934 is a separate implementation (PPSA26344). Only one can merge. Could you say in both descriptions which one you want reviewed, close the other, and carry over anything only the other covers (e.g. #4934's reset/gapless fixture, or this one's resampling and multi-frame jobs)?

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6158943994 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5307#issuecomment-6158943994). Originally posted by [CnRJay](https://github.com/CnRJay) on 2026-10-14T01:38:00Z. --- Heads-up for reviewers: #4934 (also yours, opened earlier the same day) implements the same AJM M4AAC codec-2 decoder on the same FFmpeg AAC path, with ~547 lines each. This one carries screamm's commit (for #3410), and #4934 is a separate implementation (PPSA26344). Only one can merge. Could you say in both descriptions which one you want reviewed, close the other, and carry over anything only the other covers (e.g. #4934's reset/gapless fixture, or this one's resampling and multi-frame jobs)?
MarcZX10 commented 2026-10-14 06:51:05 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-14T06:51:05Z.


I compared the current file patches for #5307 and #4934: Ajm.cpp and GuestAjm.cpp are identical, including the reset/gapless and multiple-frame coverage; only the debt prose differs. I agree one PR should continue. #4934 is already closed as the duplicate, so #5307 is the review target and keeps screamm’s implementation commit authorship. No test-only material from #4934 appears to be missing.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6162663816 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5307#issuecomment-6162663816). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-14T06:51:05Z. --- I compared the current file patches for #5307 and #4934: `Ajm.cpp` and `GuestAjm.cpp` are identical, including the reset/gapless and multiple-frame coverage; only the debt prose differs. I agree one PR should continue. #4934 is already closed as the duplicate, so #5307 is the review target and keeps screamm’s implementation commit authorship. No test-only material from #4934 appears to be missing.
adriadam10 commented 2026-10-14 11:35:00 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-14T11:35:00Z.


Checked the M4AAC decoder against the new guest_ajm cases (ADTS, raw access units, gapless trim, multi-frame, format/codec info, rejected inputs): build and ctest pass, and the test fails without the change.

Added one commit on top: the M4AAC flag check in sceAjmInstanceCreate called NotImplemented_nid_no_patch directly, which made the progress report count sceAjmInstanceCreate as reverted to a stub. It now lives in a CheckAacFlags helper (same behaviour, same test); build and ctest are green again.

The PS4-derived behaviour (2-frame delay, bitrate, error results) stays unverified on PS5 and is listed in the debt entry. Merging.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6167402805 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5307#issuecomment-6167402805). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-14T11:35:00Z. --- Checked the M4AAC decoder against the new `guest_ajm` cases (ADTS, raw access units, gapless trim, multi-frame, format/codec info, rejected inputs): build and ctest pass, and the test fails without the change. Added one commit on top: the M4AAC flag check in `sceAjmInstanceCreate` called `NotImplemented_nid_no_patch` directly, which made the progress report count `sceAjmInstanceCreate` as reverted to a stub. It now lives in a `CheckAacFlags` helper (same behaviour, same test); build and ctest are green again. The PS4-derived behaviour (2-frame delay, bitrate, error results) stays unverified on PS5 and is listed in the debt entry. Merging.
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!5307
No description provided.