feat(ajm): implement sceAjmDecMp3ParseFrame #578

Merged
DotDebian merged 1 commit from upstream-pr/578 into main 2026-10-04 23:49:23 +00:00
DotDebian commented 2026-10-04 23:24:53 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by DotDebian on 2026-10-04T23:24:53Z.


What

Implements sceAjmDecMp3ParseFrame in libSceAjm.native. It was a throwing stub with no parameters.

  • Signature (const uint8_t* stream, uint32_t stream_size, int parse_ofl, AjmDecMp3ParseFrame* frame), the 40-byte result layout and the rate tables follow shadPS4's reimplementation of the PS4 library (src/core/libraries/ajm/ajm_mp3.cpp, ParseMp3Header). The header fields themselves are the MPEG audio frame header (ISO/IEC 11172-3, 13818-3).
  • Reads the 4-byte header and reports frame size, channel count, samples per channel, bitrate and sample rate; the original-file-length fields are zero.
  • Returns SCE_AJM_ERROR_INVALID_PARAMETER for a null pointer, fewer than 4 bytes, a broken sync word, the reserved version, the reserved sample rate index, and bitrate indexes 0 and 15.
  • As in that reference, the layer field is not checked and the MPEG-2.5 bitrate table stops at 64 kbps. This is why the function does not share the MP3 decoder's own header parser, which is left unchanged.
  • parse_ofl != 0 throws. shadPS4 reads only the Fraunhofer block and leaves Xing/Info and VBRI as TODO, so the full lookup could not be established.

Both limits are recorded in TechnicalDebt (unknown function info, functional). Not confirmed on a PS5 title.

Tested

Windows 11, MinGW-w64 GCC 15.2.0, ctest: 213/213 pass.

guest_ajm is extended with TestMp3ParseFrame: the six frames of the existing MP3 fixture (96 bytes, mono, 1152 samples, 32 kbps, 48 kHz, matching what the decoder test consumes), MPEG-1, MPEG-2 and MPEG-2.5 headers with and without padding and CRC, and each invalid-parameter case. On main the test aborts in the stub.

No title was 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 (NotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • AI-assisted: yes

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4738393945 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/578). Originally posted by [DotDebian](https://github.com/DotDebian) on 2026-10-04T23:24:53Z. --- ### What Implements `sceAjmDecMp3ParseFrame` in libSceAjm.native. It was a throwing stub with no parameters. - Signature `(const uint8_t* stream, uint32_t stream_size, int parse_ofl, AjmDecMp3ParseFrame* frame)`, the 40-byte result layout and the rate tables follow shadPS4's reimplementation of the PS4 library (`src/core/libraries/ajm/ajm_mp3.cpp`, `ParseMp3Header`). The header fields themselves are the MPEG audio frame header (ISO/IEC 11172-3, 13818-3). - Reads the 4-byte header and reports frame size, channel count, samples per channel, bitrate and sample rate; the original-file-length fields are zero. - Returns `SCE_AJM_ERROR_INVALID_PARAMETER` for a null pointer, fewer than 4 bytes, a broken sync word, the reserved version, the reserved sample rate index, and bitrate indexes 0 and 15. - As in that reference, the layer field is not checked and the MPEG-2.5 bitrate table stops at 64 kbps. This is why the function does not share the MP3 decoder's own header parser, which is left unchanged. - `parse_ofl != 0` throws. shadPS4 reads only the Fraunhofer block and leaves Xing/Info and VBRI as TODO, so the full lookup could not be established. Both limits are recorded in TechnicalDebt (unknown function info, functional). Not confirmed on a PS5 title. ### Tested Windows 11, MinGW-w64 GCC 15.2.0, `ctest`: 213/213 pass. `guest_ajm` is extended with `TestMp3ParseFrame`: the six frames of the existing MP3 fixture (96 bytes, mono, 1152 samples, 32 kbps, 48 kHz, matching what the decoder test consumes), MPEG-1, MPEG-2 and MPEG-2.5 headers with and without padding and CRC, and each invalid-parameter case. On `main` the test aborts in the stub. No title was 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](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed in [TechnicalDebt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/TechnicalDebt.md#silent-stubs) - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [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 🤖 Generated with [Claude Code](https://claude.com/claude-code)
oneandonlydean commented 2026-10-04 23:44:08 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-04T23:44:08Z.


Thanks. The name recomputes to eDFeTyi+G3Y, and the signature, the 40-byte result, both rate tables, the error order and the frame size formulas are the same as shadPS4's ParseMp3Header. The Layer III values match the MPEG spec (144 or 72 times bitrate over sample rate plus padding, 1152 or 576 samples, channel mode 3 as mono), and I recomputed every row of the new test, including the padded 418 and 53 byte frames.

On the TechnicalDebt line: shadPS4 says those tables were reversed from the AJM library itself, so the MPEG-2.5 limit at 64 kbps and the unchecked layer come from Sony's code rather than from a guess. If you like, the line could say that; it's fine as it is.

Throwing for parse_ofl is the right call while only the Fraunhofer path is known. guest_ajm passes here, and on main the test doesn't compile without the new struct. PPSA21564 doesn't import this function. CI is green; ready to merge from my side.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:5985703382 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/578#issuecomment-5985703382). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-04T23:44:08Z. --- Thanks. The name recomputes to eDFeTyi+G3Y, and the signature, the 40-byte result, both rate tables, the error order and the frame size formulas are the same as shadPS4's `ParseMp3Header`. The Layer III values match the MPEG spec (144 or 72 times bitrate over sample rate plus padding, 1152 or 576 samples, channel mode 3 as mono), and I recomputed every row of the new test, including the padded 418 and 53 byte frames. On the TechnicalDebt line: shadPS4 says those tables were reversed from the AJM library itself, so the MPEG-2.5 limit at 64 kbps and the unchecked layer come from Sony's code rather than from a guess. If you like, the line could say that; it's fine as it is. Throwing for `parse_ofl` is the right call while only the Fraunhofer path is known. `guest_ajm` passes here, and on main the test doesn't compile without the new struct. PPSA21564 doesn't import this function. CI is green; ready to merge from my side.
github-actions[bot] commented 2026-10-04 23:46:03 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-04T23:46:03Z.


Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.

Pull request Conflicting files (lines on main) Same exports Same new files
#567 docs/dev/TechnicalDebt.md L74
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:5985717119 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/578#issuecomment-5985717119). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-04T23:46:03Z. --- <!-- pr-overlap --> Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in **Depends on**. | Pull request | Conflicting files (lines on `main`) | Same exports | Same new files | |---|---|---|---| | #567 | `docs/dev/TechnicalDebt.md` [L74](https://github.com/boykopovar/AnyPS5/blob/d5cf8a0addadbda780d4f8cd05d22aa5059bfb13/docs/dev/TechnicalDebt.md#L74) | | |
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!578
No description provided.