feat(libSceAudiodec): decode MP3, M4AAC and ATRAC9 #236
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/236"
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 adriadam10 on 2026-10-01T17:37:43Z.
What
Implements all six
libSceAudiodecexports with real decoding: MP3 and M4AAC through the bundled FFmpeg, ATRAC9 through LibAtrac9 (both already used bylibSceAjm.native).libSceAudiodec.nativeonly exportedNotImplementedstubs of the same six functions; as asked in #228 and #241, itsExport.cppis nowAPS5_DUMMY_FUNonly, likelibkernel_sys, so the two libraries no longer export the same symbols.sceAudiodecInitLibrary/TermLibrarycount initialisations per codec type;CreateDecoderrequires one.CreateDecodervalidates the control block (pointers,uiSizeof param and BSI info, word size) and the codec parameters, and fills the BSI info: ATRAC9 from the config data (channels, rate, superframe size and frame count, bitrate); M4AAC from the configured rate index and channel count.Decodedecodes one unit per call and reports bytes consumed inuiAuSizeand bytes written inuiPcmSize: one MP3 frame (the header fields go to the MP3 info), one ADTS frame or one raw block for M4AAC (uiConfigNumber1 / 2; raw blocks get an AudioSpecificConfig built from the rate index and channel count), or one ATRAC9 superframe. Output is interleaved S16 or float. A too small PCM buffer returnsINVALID_PCM_SIZE; truncated or corrupt input returnsAPI_FAIL, withiResult-5 / -4 for M4AAC.ClearContextflushes the decoder;DeleteDecoderfrees it.References. Structs and error codes (
0x807F00xx,0x807F03xx,0x807F1000) agree in KytyPS5, fpPS4 and SharpProspero; the M4AAC parameter layout matches what prosper recovered from a title's call sites. Behavioural differences: KytyPS5 decodes only AAC and returns silence for MP3 and ATRAC9; fpPS4 does not decode.Known gaps, listed in
TechnicalDebt.md: the 24-bit word size (iBwPcm0) throws because its layout is unknown; ATRAC9 decoding is only covered by configuration and error tests, since there is no free ATRAC9 encoder for a fixture.Side finding, not changed here: this FFmpeg build has the fixed-point MP3 decoder, which outputs
S16P.RunMp3inlibSceAjm.nativeonly acceptsFLTPand throws otherwise, so AJM MP3 decoding probably always fails. Fixed in #237.Tested
Linux (CachyOS, GCC): new
guest_audiodectest (core/libs/tests/GuestAudiodec.cpp) with small fixtures generated by FFmpeg (1 kHz sine, 48 kHz): stereo AAC decoded both as ADTS and as raw blocks, checking bytes consumed and produced per frame, the reported format and the tone's zero-crossing rate; mono MP3 decoded to float, checking frame sizes, header fields and amplitude; ATRAC9 config parsing, BSI info and error paths; and the control block validation. It fails on injected bugs (no partial-input check, wrong raw sample-rate index, MP3 mode not reported, wrong S16P scaling). Full suite passes. Windows only through CI. No title tested.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-01T17:38:10Z.
Progress report (
c00bc19→569c2ec)📈 System libraries: 78.55% (+0.36%, +6 implemented, -6 removed functions)
✅ 6 implemented
sceAudiodecClearContextsceAudiodecCreateDecodersceAudiodecDecodesceAudiodecDeleteDecodersceAudiodecInitLibrarysceAudiodecTermLibrary🗑️ 6 removed
sceAudiodecClearContextsceAudiodecCreateDecodersceAudiodecDecodesceAudiodecDeleteDecodersceAudiodecInitLibrarysceAudiodecTermLibraryImported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-02T07:23:14Z.
Following the review on #228/#241:
libSceAudiodec.nativeno longer shares the sources. ItsExport.cppis nowAPS5_DUMMY_FUNonly, likelibkernel_sys, because all six of its exports are implemented inlibSceAudiodec.AudiodecLibrary.cmakeis gone. Rebased onmain.