Skip to content

feat(opus): add the CELT decoder system library - #1829

Closed
kali113 wants to merge 17 commits into
boykopovar:mainfrom
kali113:feat/opus-celt-dec
Closed

kali113 wants to merge 17 commits into
boykopovar:mainfrom
kali113:feat/opus-celt-dec

Conversation

@kali113

@kali113 kali113 commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

What

Add six libSceOpusCeltDec lifecycle and decode exports backed by official libopus 1.6.1, pinned as a source submodule. The implementation decodes CELT-only raw packets to 48 kHz mono/stereo signed 16-bit interleaved PCM, validates decoder ownership and byte capacity, and copies PCM only after successful decoding. Unsupported modes and invalid calls throw; no console error codes are guessed.

The fork branch kali113:feat/opus-celt-dec has been rebuilt as one decoder-only commit (e3b8ae75) on main d70b8998. It contains none of #1265, #1913, #1986 or #1999. An old branch backup remains available locally. There are no shader or unrelated test changes in that candidate. GitHub retains the old commit/diff snapshot on this closed PR; review the cleaned branch comparison or linked candidate commit rather than this closed PR's historical Files changed tab.

The public ProsperoRadio caller at 2c4029c declares this interface; published decoder research describes the context pointer, caller allocation and byte counts. These sources establish the caller contract, not bit-exact console equivalence. Console state layout, context values and error behavior remain unverified and are recorded in TechnicalDebt.

This PR remains closed pending the runtime evidence requested in the closing review. The earlier description overstated readiness. ProsperoRadio normally opens the general libSceOpusDec decoder first; its production dispatch retries CELT only after a particular general-decoder error and a CELT packet. Main currently lacks the general decoder, proposed separately in #1823. No title log demonstrates reaching the CELT calls on current main, and this patch does not establish radio playback or a significant library-coverage increase. A reopened submission needs a real title's next-stop log on main.

Duplicate recheck: reviewed file lists for all 538 current open PRs, including the complete 1,203-file list of #1128. Only #1823 touches an Opus decoder module; it implements the separate general decoder, not these CELT exports. Its commits are not included here.

Tested

Candidate e3b8ae7511a17ea3c4f4d1e47e60f94ed3e887ae:

  • macOS arm64 / AppleClang / Release standalone build using the actual library CMake target: decoder regression and public-caller harness both pass three repetitions. Longest observed run: 0.80 s.
  • The decoder regression checks nonzero mono/stereo PCM against separately generated libopus reference output, consecutive packets and recreation, independent contexts, invalid lifecycle calls, insufficient capacity, output/state canaries, malformed duration headers, SILK rejection and a 120 ms packet. The reference uses the same codec implementation; it is not a console or independent-codec oracle.
  • AddressSanitizer and UndefinedBehaviorSanitizer: both standalone tests pass.
  • The external public-caller harness explicitly selects CELT and adapts sysmodule load/unload; unused general-decoder calls abort. It verifies caller compatibility, not the full application's production route.
  • Native Linux x86-64 and Windows x86-64: full default builds, all-library packaging, conventions/registration checks and three decoder-test repetitions per OS pass on this exact candidate (isolated validation). Longest decoder run: Linux 0.0026 s; Windows 0.0222 s. Six executions, zero failures or skips. These are relevant-test results, not a complete CTest-suite run. The fork workflow is on 7f1b5e3f and explicitly checks out candidate e3b8ae75; the workflow is not part of the contribution.
  • python3 tools/check_conventions.py --base d70b89989473ba1f6ae13e44e079e67f1f8a44b0 passes.
  • No physical PS5, commercial title or complete ProsperoRadio playback validation.

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; no silent stubs added
  • No notes, investigation .md files or images added to the repository
  • New third-party code is a submodule built from source
  • Generic decoder behavior; unsupported behavior throws
  • Depends on: feat(opus): implement 48 kHz libSceOpusDec #1823 reaching main before the proposed ProsperoRadio runtime demonstration can be attempted; no prerequisite commits included
  • AI-assisted: yes, OpenAI Codex

@kali113
kali113 marked this pull request as ready for review October 8, 2026 21:18
Copilot AI balanced review requested due to automatic review settings October 8, 2026 21:18

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@github-actions

github-actions Bot commented Oct 8, 2026 •

Copy link
Copy Markdown

Progress report (a8b032b → 6e6ee7e)

📈 System libraries: 84.79% (+0.03%, +6 implemented functions)

✅ 6 implemented
Library Name
libSceOpusCeltDec sceOpusCeltDecCreateEx
libSceOpusCeltDec sceOpusCeltDecDecode
libSceOpusCeltDec sceOpusCeltDecDestroy
libSceOpusCeltDec sceOpusCeltDecGetSize
libSceOpusCeltDec sceOpusCeltDecInitialize
libSceOpusCeltDec sceOpusCeltDecTerminate

popcoder565 and others added 4 commits October 9, 2026 06:41
Every 8- and 16-bit BDA store and the unaligned path of every 32-bit store emitted one get_bda_write_pointer lookup and one note_bda_write per byte at the store site, five write lookups per 32-bit store. They now call write_bda_bytes, which loops over the bytes and does, per byte and in order, the same lookup, the store when it is mapped and the write note, so faults are recorded exactly as before. On an RTX 3060 the agc_driver_flat_store binaries shrink from 496,256 to 138,240 bytes (wave32) and from 928,384 to 225,152 bytes (wave64), and the cold run from 19.7 s to 2.2 s.
note_bda_write unrolled its 8 compare-exchange probes, and drivers inline it at every BDA store and atomic. The probes now run in a loop that tries the same slots in the same order and stops at the same slot, so the recorded pages and the overflow flag are unchanged. With the byte store helper, the agc_driver_flat_store binaries on an RTX 3060 go from 138,240 to 75,648 bytes (wave32) and from 225,152 to 130,560 bytes (wave64), and the cold run from 2.2 s to 1.2 s.
… path

The declaration, the state field and the definition of write_bda_bytes now sit next to EmitBdaStore and the other BDA write functions instead of next to the dword read functions, which boykopovar#1267 extends at the same lines. No change to the emitted code.
@github-actions github-actions Bot added shader core/shader agc libSceAgc* labels Oct 9, 2026
@oneandonlydean

Copy link
Copy Markdown
Collaborator

Closing: ProsperoRadio (PPSA99001) stops on the missing libSceOpusDec.prx on main, and no log shows a title stopping at the sceOpusCeltDec* calls. The branch also carries #1265, #1913, #1986 and #1999. Reopen with only the decoder in the branch when it's a title's next stop on main, with the log line.

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.

5 participants