feat(opus): decode to float and with a priority in libSceOpusDec and libSceOpusCeltDec #9752
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/9752"
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 hypermoist on 2026-10-22T12:41:18Z.
What
Eight decode exports of
libSceOpusDecandlibSceOpusCeltDecthrew. In both modules every decode export is a wrapper around one worker, so these differ from the existingDecodeonly in a priority check, the float output and, for two of them, a timeout. This PR implements them on top of the existing decoder:sceOpusDecDecodeWithPriority,sceOpusDecDecodeWithPriorityAndTimeout,sceOpusDecDecodeFloat,sceOpusDecDecodeFloatWithPriority,sceOpusDecDecodeFloatWithPriorityAndTimeoutsceOpusCeltDecDecodeWithPriority,sceOpusCeltDecDecodeFloat,sceOpusCeltDecDecodeFloatWithPriorityThey follow the decrypted PS5 13.60
libSceOpusDec.sprxandlibSceOpusCeltDec.sprx(read from disassembly, not measured on a console). Both workers sit at 0x550:(state, data, bytes, pcm, capacity, priority). TheAndTimeoutexports add auint32_ttimeout, which goes to the AJM batch wait, and auint32_t*that gets the batch ID only when that wait fails (0x734 to 0x743).Decodepasses priority 40 and timeout -1.Decodealready makes, soDecode's own order does not change.capacity >> 2samples of the caller's buffer (0x69f), then widens it in place: positive samples are divided by 32767, the rest by 32768 (constants at 0x46dc in OpusDec, 0x4324 in CeltDec). The result is the float byte count (0x8a6).The variants are in a new
include/OpusDecodeVariants.hpp, which bothExport.cppfiles call.OpusDecoder.hppis unchanged.Differences, listed in the new debt entry:
AndTimeoutexports decode only for the infinite timeout 0xFFFFFFFF, the valueDecodepasses. The batch ID is then never written, as on the console when the wait succeeds. Any other timeout returns the argument errors and then throws (NotImplemented_nid_no_patch), because on the console it either succeeds or returns 0x81740015 with the batch ID, depending on how long the decode takes.Not included, still throwing:
sceOpusDecCtlandsceOpusCeltDecCtl. They areopus_decoder_ctl-style requests. The module stores each SET value in the state and sends it to AJM with the next decode, so they need a backend that applies gain, FEC and phase inversion. That fits after #8739.sceOpusDecCancel. It cancels an AJM batch ID, and this decoder never hands one out.The code is written from the observed behaviour; nothing from the modules is copied.
Tested
New
guest_opus_dec_variantstest. It checks:Decode, over three frames;Changing either float divisor or the lower priority bound makes it fail, and so does letting a finite timeout decode. On
mainall eight calls throw.Run on
main7e69be6793merged in (e879fbf700), headaff42e2c4b:guest_opus_dec_variants,guest_opus_decandguest_opus_celt_decpass.tools/check_conventions.pyis clean. Overlap:OpusDecoder.hpp, the Functional entries of both debt files and the first 12 lines of both CMake files. This PR changes none of those lines: it adds a header, appends a test registration after line 16 oflibSceOpusDec/CMakeLists.txtand edits the Unknown function info entries.tools/pr_overlap.pycould not compare them automatically because #8739 conflicts withmain.sceOpusDecCtl/sceOpusCeltDecCtl, also ours) conflicts with this PR in bothExport.cppfiles and both debt files. Merge order: this PR first, since #9764 also waits on #8739. #9764 declaresDepends on: #8739, #9752and will mergemainand resolve the conflicts after this lands.add_library_test. Whichever of the two lands second converts theguest_opus_dec_variantsregistration: if #6044 lands first, I'll mergemainhere and switch it toadd_library_test.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)🤖 Generated with Claude Code
https://claude.ai/code/session_01SNqSvnFwRBz3D76n476yw6
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-22T14:53:01Z.
Review: CHANGES_REQUESTED
Local focused check: compiled and ran the exact
OpusDecodeVarianthelper with boundary samples (-32768, -1, 1, 32767), buffer guards, and undersized capacity; it passed.git diff --checkand current-main conventions pass. I could not runguest_opus_dec_variants: this checkout has no Opus headers/submodule and less than 700 MB free, and hosted product Linux/Windows jobs are skipped.I found a behavior gap in the timeout exports, plus required integration work. See the inline comment for the timeout behavior. The current branch is based on
8b3a6ba, 50 commits behindmainb7d1d47; refresh it and rerun the focused Linux/Windows tests. Also agree and record the order for this PR and #9764, whose Opus exports and debt files have pairwise merge conflicts; #9764 already carries #8739. The CMake test registration also needs coordination with #6044'sadd_library_testmigration. UpdateDepends onon whichever branch must land second/rebase first. No local semantic blocker found in the ordinary priority and float paths beyond the documented timeout mismatch.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-22T17:03:36Z.
Review: DISMISSED
The ordinary priority and float paths remain well supported by the reported Linux and WinLibs/Wine runs, but the timeout exports still discard the timeout and batch-ID parameters and report the synchronous decode result. The focused test explicitly exercises timeout 0 and expects the same completed PCM while asserting the batch ID remains untouched. The PR’s own disassembly notes say the console passes timeout to the AJM batch wait and writes the batch ID when that wait fails, so this does not establish equivalent behavior for a finite timeout. Please implement the timeout/batch-ID path or throw for timeout cases that cannot be modeled, with a test for the chosen contract.
Integration is also outstanding: this head is based on
8b3a6ba88d, 71 commits behind currentmain(11f976b27c16ed91633f00039dba5dfd97dd7cc1); current main includes the separate #9764 CTL implementation, whose exports overlap this branch. The PR still saysDepends on: none, while #9764’s own dependency is #8739. Please coordinate and record a merge order, rebase both contributions as needed, and adapt the CMake registration to #6044’s test-registration migration. Current-main merge-tree, diff-check, and conventions pass. Hosted product jobs are skipped, and I did not run the Opus suite locally.