feat(libSceAjm): parse CRC-protected and non-stereo MP3 metadata frames #8468
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/8468"
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 Gabrieljr42 on 2026-10-20T13:10:11Z.
What
Implement missing metadata paths for
sceAjmDecMp3ParseFrame:parseOfl == 0; reject unsupported OFL requests before modifying output.Tested
Linux, GCC 13, branch updated with upstream
mainat3e91c8edf:guest_ajm_teststarget with bundled dependencies;ctest --test-dir build-mp3 --no-tests=error -R '^guest_ajm$' --output-on-failurepassed 1/1.python3 tools/check_conventions.py --base upstream/mainandgit diff --checkpassed.Checklist
Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-20T13:10:48Z.
Progress report (47fa6ee →
df0a74e)📈 System libraries: 48.68% (+0.01%, +1 implemented functions)
✅ 1 implemented
sceAjmDecMp3ParseFrameImported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-21T02:53:37Z.
@Gabrieljr42 thanks for this. Two changes, and one question:
Protected frames: please fix the side-info offset instead of widening the searches.
ParseMp3Oflreads side info from byte 4 (stream[4 + bit / 8]inreadBits). In a CRC-protected frame (protection bit 0), bytes 4-5 are the CRC and the side info starts at byte 6, somainDataBitsandatcome from the wrong bytes. The extra candidates (at + 2, the fixed 38/23/15 Xing offsets, VBRI atat + 2/38, and the FGH scan from byte 4) compensate for that. StartingreadBitsat4 + (protected ? 2 : 0)makesatcorrect, and the tag lookups can stay atat(plus the standard fixed offsets, if you want them for encoders that don't zero the side info).Layer I/II now return
SCE_AJM_ERROR_INVALID_PARAMETEReven withparseOfl == 0. On main those headers parse successfully when no OFL lookup is asked for. If the firmware rejects them, please cite where (the decompiledsceAjmDecMp3ParseFramecheck or a console result). Otherwise, please keep main'sparseOfl == 0behaviour and only stop the OFL lookup outside Layer III.Question: the FGH loop now verifies the CRC-8 at every
0xB4from byte 4 to the end of the frame, where main checked only the first one at or afterat. Was scanning the side info and audio data intended? Each extra0xB4is another chance of a false FGH match.The bounded VBRI lookahead and the untouched-output check for invalid layers look good.
Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-21T02:57:31Z.
Windows data point for
78bf409ecmerged ontomain6696def6e(clean,git merge-treerc 0): Windows 10.0.19045, MinGW-w64 GCC 15.2.0, Release.ctest -N -R '^guest_ajm$'lists exactly that one test;ctest --no-tests=error -R '^guest_ajm$'was run three times per tree.core/libs/prx/libSceAjm.native/src/Ajm.cpprestored tomain(the new test cases kept): fails 3 of 3, exit code0xc0000409(the test process aborts).Not tested: other platforms, a title run.
AI-assisted (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-21T11:28:34Z.
Review: DISMISSED
Checked the diff against main and @oneandonlydean's review above; his three points are still open on this head (
78bf409), so this ischangeson the same items:core/libs/prx/libSceAjm.native/src/Ajm.cpp:874-950: in a CRC-protected frame the side info starts at byte 6, not 4. Read it from4 + (protected ? 2 : 0)soatis correct, then drop the compensating candidates (at + 2, the VBRIat + 2/38 probes, the FGH scan starting at byte 4). The fixed Xing offsets can stay only if you want them for encoders that zero the side info.Ajm.cpp:972:layer == 1uinvalidmakes Layer I/II fail withSCE_AJM_ERROR_INVALID_PARAMETERalso whenparseOfl == 0, which main parses fine. Either cite where the firmware rejects them (decompiled check or a console result), or keep main'sparseOfl == 0behaviour and only reject the OFL lookup outside Layer III. The test atGuestAjm.cpp:394-402and the debt line change with it.Ajm.cpp:939-955: the FGH loop now checks the CRC-8 at every0xB4to the end of the frame, where main checked only the first at or afterat. Every extra0xB4in side info or audio data is another chance of a false FGH match; please restrict it or say why it is intended.The bounded VBRI lookahead, the prefix-length test and the untouched-output check for invalid layers look good. @xXPBSXx's Windows run confirms
guest_ajmfails without theAjm.cppchange.Imported from boykopovar/AnyPS5. Originally posted by Gabrieljr42 on 2026-10-21T11:49:19Z.
Thanks @adriadam10 and @oneandonlydean. Fixed in
df0a74e7c, after updating the branch withmainat3e91c8edf.at + 2and VBRI byte-38 probes are removed.parseOfl == 0. Unsupported OFL requests are rejected before modifying output; reserved layer values remain invalid. The tests and debt entry now reflect this.atand checks only the first marker's CRC. A regression with a bad first CRC followed by a valid marker detects scanning past that first marker. The bounded VBRI lookahead stays in place.Validated on Linux with GCC 13:
guest_ajm_teststarget from bundled dependencies;ctest --test-dir build-mp3 --no-tests=error -R '^guest_ajm$' --output-on-failurepassed 1/1.TestMp3ParseFrame,TestMp3ParseOfl, andTestMp3MetadataBoundspassed AddressSanitizer/UBSan checks.git diff --checkpassed. The overlap tool still reports the existing shared-file warnings for #3205 and #6044.AI-assisted with Codex.
Imported from boykopovar/AnyPS5. Originally posted by ntamas94 on 2026-10-22T13:35:14Z.
#9637 (PS4 batch buffers through libSceAjm) adds entries to
docs/dev/debt/libSceAjm.native.mdnext to thesceAjmDecMp3ParseFramelines this PR rewrites, so the file will conflict on one hunk. This one is older, so I propose it lands first; I rebase #9637 the same day and list it under Depends on there. The code does not overlap.AI-assisted: yes (Claude Code)