Skip to content

feat(libSceAudiodecCpu): wrap Blu-ray LPCM output past the module's 0x43800-byte buffer - #17649

Merged
oneandonlydean merged 1 commit into
boykopovar:mainfrom
AasishDairelSahayaGrinspan:fix/audiodeccpu-lpcm-output-wrap
Nov 12, 2026
Merged

oneandonlydean merged 1 commit into
boykopovar:mainfrom
AasishDairelSahayaGrinspan:fix/audiodeccpu-lpcm-output-wrap

Conversation

@AasishDairelSahayaGrinspan

Copy link
Copy Markdown
Contributor

What

Implement the Blu-ray LPCM output wrap the firmware 13.42 measurement recorded instead of throwing: when a stereo frame decodes to more than the module's 0x43800-byte (69,120-float) output capacity, the decode still succeeds, writes the full decoded byte count to the caller's PCM buffer, reports it in ui_pcm_size and the BSI info, and every sample from 69,120 on repeats the sample 69,120 earlier. The sample loop reads its input index modulo the output capacity in samples, for every stereo rate and both sample widths. The PCM-buffer refusal stays, so the full write only reaches buffers the caller declared large enough; a second wrap is unreachable because the 0x43800-byte input cap bounds the decoded output at 138,240 samples.

Tested

macOS 26 (Apple Silicon), AppleClang, Release BUILD_TESTING=ON: guest_audiodec_cpu passes. The new TestDecodeWrap covers 143, 144 and 145 frames (the 145-frame case is the measured configuration: 139,200 bytes in, 278,400 out) and 255 frames (the measured upper end, 489,600 bytes out) at 48 kHz 16-bit through both exports, plus one 24-bit case, checking the full sample sweep against the repetition, the sizes, the BSI info and canaries beyond the written range; a negative control with the wrap removed aborts the test. python3 tools/check_conventions.py --base origin/main passed. The focused test needed a local uncommitted #include <thread> in RunReport.cpp to build on this host, already open as #16795. No console or title run; the behavior is the 13.42 measurement.

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 under Silent stubs in their library's technical debt file
  • 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
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes

…x43800-byte buffer

Firmware 13.42 does not refuse a stereo frame whose decoded PCM exceeds
276,480 bytes: it succeeds, writes the full decoded byte count to the
caller's buffer and to ui_pcm_size and the BSI info, and repeats the
samples from the start from sample 69,120 on (BunnyFl, PR 10042
comments, 145 to 255 frames at 48 kHz 16-bit). Decode that way instead
of throwing: the sample loop reads input sample index modulo the output
capacity in samples for every stereo rate and both widths, and the
PCM-buffer refusal stays, so the full write only reaches buffers the
caller declared large enough. A second wrap is unreachable: the
0x43800-byte input cap bounds 16-bit output at exactly two wraps' worth
of samples and 24-bit at less.

Tests: new TestDecodeWrap decodes 143, 144, 145 and 255 stereo frames
at 48 kHz 16-bit through both exports and one 24-bit frame, checking
the full sample sweep against the pattern, the sizes, the BSI info and
canaries beyond the written range; the 145- and 255-frame cases are the
measured configurations. A negative control with the wrap removed
aborts in the new test.
@JJenkx

JJenkx commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

Windows check of head 4bc5fdf9a6, merged onto main a82dcd06db (55459fa7ef, clean merge).

Setup: Windows 11 Enterprise 22621, WinLibs GCC 15.2 UCRT, Release. The hosted Windows check does not run these tests on pull requests.

  • guest_audiodec_cpu passes in 3 of 3 runs, none skipped.

AI-assisted: yes.

@AasishDairelSahayaGrinspan

Copy link
Copy Markdown
Contributor Author

Manual overlap re-check after the pr-overlap report (head 4bc5fdf):

PR 17691 shares these files only because it deletes them: it has 7,279 changed files with 1,445,257 deletions and 0 additions — a tree-wide deletion, not an implementation of anything in this area. It does not implement the LPCM output wrap or touch sceAudiodecCpu behavior; it conflicts with main wholesale. No build dependency: Depends on stays none.

@oneandonlydean
oneandonlydean merged commit e6efb39 into boykopovar:main Nov 12, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants