feat(libSceAudiodecCpu): implement DVD LPCM decode and HE-VAG lifecycle #27277

Open
gurtgg wants to merge 3 commits from upstream-pr/27277 into main
gurtgg commented 2026-11-25 18:34:38 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by gurtgg on 2026-11-25T18:34:38Z.


What

  • Implemented firmware 13.60 stereo DVD LPCM (0x1004, 16/20/24-bit at 48/96 kHz with 150-tick PTS continuation and parameter validation) in libSceAudiodecCpu (core/libs/prx/libSceAudiodecCpu/Export.cpp).
  • Implemented firmware 13.60 HE-VAG (0x1008) QueryMemSize (0x1b0), InitDecoder parameter/memory validation and state initialization, ClearContext history clearing, and Decode pre-validation gates.
  • Added negative-control guest-memory regression tests in GuestAudiodecCpuQueryGuest.cpp covering HE-VAG lifecycle/validation and DVD LPCM 16/20/24-bit decode, error codes, and rollback on unwritable guest outputs.
  • Added a technical debt change fragment under docs/dev/debt/changes/feat-audiodeccpu-1360-codecs.md.

Tested

  • Verified all staged outputs against firmware 13.60 libSceAudiodecCpu.sprx, libSceAudiodecCpuLpcm.sprx, and libSceAudiodecCpuHevag.sprx disassembly and validated encoding/conventions checks.

Checklist

  • Changes follow upstream tools/check_conventions.py rules (no C++ comments, UTF-8 no-BOM, LF only)
  • Regression tests added in core/libs/tests/GuestAudiodecCpuQueryGuest.cpp
  • AI-assisted: yes
  • Depends on: none
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5496989146 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/27277). Originally posted by [gurtgg](https://github.com/gurtgg) on 2026-11-25T18:34:38Z. --- ### What - Implemented firmware 13.60 stereo DVD LPCM (`0x1004`, 16/20/24-bit at 48/96 kHz with 150-tick PTS continuation and parameter validation) in `libSceAudiodecCpu` (`core/libs/prx/libSceAudiodecCpu/Export.cpp`). - Implemented firmware 13.60 HE-VAG (`0x1008`) `QueryMemSize` (`0x1b0`), `InitDecoder` parameter/memory validation and state initialization, `ClearContext` history clearing, and `Decode` pre-validation gates. - Added negative-control guest-memory regression tests in `GuestAudiodecCpuQueryGuest.cpp` covering HE-VAG lifecycle/validation and DVD LPCM 16/20/24-bit decode, error codes, and rollback on unwritable guest outputs. - Added a technical debt change fragment under `docs/dev/debt/changes/feat-audiodeccpu-1360-codecs.md`. ### Tested - Verified all staged outputs against firmware 13.60 `libSceAudiodecCpu.sprx`, `libSceAudiodecCpuLpcm.sprx`, and `libSceAudiodecCpuHevag.sprx` disassembly and validated encoding/conventions checks. ### Checklist - [x] Changes follow upstream `tools/check_conventions.py` rules (no C++ comments, UTF-8 no-BOM, LF only) - [x] Regression tests added in `core/libs/tests/GuestAudiodecCpuQueryGuest.cpp` - AI-assisted: yes - Depends on: none
MarcZX10 commented 2026-11-25 19:01:46 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-25T19:01:46Z.

Review: COMMENTED


Reviewed — no blocking findings

Nothing blocks merging; optional notes are listed below.

What I ran

Reviewed head 744ea71ceef8277ded52933058061b2d2d7b4ebd. Read the prepared description, commits, diff, manifest, and all three changed files. No tests or build commands were run.

Results

Check Result Note
Diff and source review passed Three changed files read
Automated checks not run No test or build execution

Findings

Blocking

None.

Non-blocking

  • core/libs/prx/libSceAudiodecCpu/Export.cpp:175 accepts channels == 0 although the description says InitDecoder validates channel parameters. Consider returning ErrorHevagChannels for zero channels if firmware rejects that value.
  • The HE-VAG tests cover a rate below the minimum but do not exercise the upper bound or zero channels (core/libs/tests/GuestAudiodecCpuQueryGuest.cpp:155).

Not verified

Tests, build, convention checks, and comparison against firmware disassembly were not run by this review. The prepared files.json was not available through the reader; the listing confirms the three changed files were included, and all three were read.

To get this to a good state

Nothing is required. Optional: verify the HE-VAG channel lower bound against firmware and add boundary tests if needed.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6063335828 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/27277#pullrequestreview-6063335828). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-25T19:01:46Z. **Review:** COMMENTED --- # Reviewed — no blocking findings Nothing blocks merging; optional notes are listed below. ## What I ran Reviewed head `744ea71ceef8277ded52933058061b2d2d7b4ebd`. Read the prepared description, commits, diff, manifest, and all three changed files. No tests or build commands were run. ## Results | Check | Result | Note | |---|---|---| | Diff and source review | passed | Three changed files read | | Automated checks | not run | No test or build execution | ## Findings ### Blocking None. ### Non-blocking - `core/libs/prx/libSceAudiodecCpu/Export.cpp:175` accepts `channels == 0` although the description says InitDecoder validates channel parameters. Consider returning `ErrorHevagChannels` for zero channels if firmware rejects that value. - The HE-VAG tests cover a rate below the minimum but do not exercise the upper bound or zero channels (`core/libs/tests/GuestAudiodecCpuQueryGuest.cpp:155`). ## Not verified Tests, build, convention checks, and comparison against firmware disassembly were not run by this review. The prepared `files.json` was not available through the reader; the listing confirms the three changed files were included, and all three were read. ## To get this to a good state Nothing is required. Optional: verify the HE-VAG channel lower bound against firmware and add boundary tests if needed.
MarcZX10 commented 2026-11-25 23:39:03 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-25T23:39:03Z.

Review: CHANGES_REQUESTED


Reviewed — changes requested

Changes are required before merge: fix DVD LPCM decoding for valid frame counts that are not multiples of the packing group, and ensure PCM output is bounded by the supplied output capacity.

What I ran

Reviewed head 5834eb2e5e4eec2ff695f9bcff94e31e08b0b1f0 using repo_read.py and the prepared diff. No tests or build commands were run.

Results

Check Result Note
Source review failed DVD LPCM output has concrete edge case defects
Tests/build not run No commands run

Findings

Blocking

  • DVD LPCM sample loops drop valid trailing samples for odd 16-bit sample counts and for 20/24-bit counts not divisible by four. The input byte calculation also rounds down to complete packing groups, while output is sized for all samples; this can leave decoded samples unset or read an undersized input buffer. This affects supported frame counts when the frame count is not a packing-group multiple. Handle partial groups or reject those frame counts explicitly. core/libs/prx/libSceAudiodecCpu/Export.cpp:343
  • samples is computed from the full AU while input is capped at LpcmOutputSamples, but output is allocated for the full sample count and copied using samples * 4. A sufficiently large valid frame therefore writes past the module’s declared PCM output capacity (0x43800 bytes). Reject oversized decoded frames or process them in bounded chunks. core/libs/prx/libSceAudiodecCpu/Export.cpp:341

Non-blocking

None.

Not verified

The full text of all three changed files was read: core/libs/prx/libSceAudiodecCpu/Export.cpp, core/libs/tests/GuestAudiodecCpuQueryGuest.cpp, and docs/dev/debt/changes/feat-audiodeccpu-1360-codecs.md. No changed files were excluded. Tests, build, firmware behavior, and console hardware behavior were not run or independently confirmed. The description’s disassembly verification is author-reported.

To get this to a good state

Fix the partial-group input/output handling and bound the PCM write by the provided output capacity; then rerun the guest regression tests and build.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6066516489 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/27277#pullrequestreview-6066516489). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-25T23:39:03Z. **Review:** CHANGES_REQUESTED --- # Reviewed — changes requested Changes are required before merge: fix DVD LPCM decoding for valid frame counts that are not multiples of the packing group, and ensure PCM output is bounded by the supplied output capacity. ## What I ran Reviewed head `5834eb2e5e4eec2ff695f9bcff94e31e08b0b1f0` using `repo_read.py` and the prepared diff. No tests or build commands were run. ## Results | Check | Result | Note | |---|---|---| | Source review | failed | DVD LPCM output has concrete edge case defects | | Tests/build | not run | No commands run | ## Findings ### Blocking - DVD LPCM sample loops drop valid trailing samples for odd 16-bit sample counts and for 20/24-bit counts not divisible by four. The input byte calculation also rounds down to complete packing groups, while `output` is sized for all samples; this can leave decoded samples unset or read an undersized input buffer. This affects supported frame counts when the frame count is not a packing-group multiple. Handle partial groups or reject those frame counts explicitly. `core/libs/prx/libSceAudiodecCpu/Export.cpp:343` - `samples` is computed from the full AU while input is capped at `LpcmOutputSamples`, but output is allocated for the full sample count and copied using `samples * 4`. A sufficiently large valid frame therefore writes past the module’s declared PCM output capacity (`0x43800` bytes). Reject oversized decoded frames or process them in bounded chunks. `core/libs/prx/libSceAudiodecCpu/Export.cpp:341` ### Non-blocking None. ## Not verified The full text of all three changed files was read: `core/libs/prx/libSceAudiodecCpu/Export.cpp`, `core/libs/tests/GuestAudiodecCpuQueryGuest.cpp`, and `docs/dev/debt/changes/feat-audiodeccpu-1360-codecs.md`. No changed files were excluded. Tests, build, firmware behavior, and console hardware behavior were not run or independently confirmed. The description’s disassembly verification is author-reported. ## To get this to a good state Fix the partial-group input/output handling and bound the PCM write by the provided output capacity; then rerun the guest regression tests and build.
MarcZX10 commented 2026-11-26 00:41:59 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-26T00:41:59Z.

Review: COMMENTED


Reviewed — no blocking findings

The inspected changes show no verified blocking defect, but I did not run the regression tests, so a formal approval is not justified.

What I ran

Reviewed head edc35d68f503739b6bbb9cd616e572118f379c1b. No commands or tests were run; I inspected the prepared diff and targeted source ranges through repo_read.py.

Results

Check Result Note
Diff and changed-file inspection passed Three changed files inspected
Regression tests not run No execution environment used

Findings

Blocking

None verified in the inspected code.

Non-blocking

  • Run the new guest regression tests on this head before merge; they cover DVD LPCM decoding and HE-VAG lifecycle validation.

Sources

  • core/libs/prx/libSceAudiodecCpu/Export.cpp — inspected the HE-VAG lifecycle, DVD LPCM decode, and codec dispatch paths.
  • core/libs/tests/GuestAudiodecCpuQueryGuest.cpp — inspected the added lifecycle and decode test cases.
  • docs/dev/debt/changes/feat-audiodeccpu-1360-codecs.md — read the full change fragment.

Not verified

Tests, build and firmware behavior were not run or confirmed. The full text of Export.cpp and GuestAudiodecCpuQueryGuest.cpp was not read; targeted ranges and changed hunks were inspected. The prepared bundle lists all three changed files as included; all three were inspected, with the two C++ files only partially read.

To get this to a good state

Nothing is required. Optional: run the new guest regression tests on this head.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6067004049 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/27277#pullrequestreview-6067004049). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-26T00:41:59Z. **Review:** COMMENTED --- # Reviewed — no blocking findings The inspected changes show no verified blocking defect, but I did not run the regression tests, so a formal approval is not justified. ## What I ran Reviewed head `edc35d68f503739b6bbb9cd616e572118f379c1b`. No commands or tests were run; I inspected the prepared diff and targeted source ranges through `repo_read.py`. ## Results | Check | Result | Note | |---|---|---| | Diff and changed-file inspection | passed | Three changed files inspected | | Regression tests | not run | No execution environment used | ## Findings ### Blocking None verified in the inspected code. ### Non-blocking - Run the new guest regression tests on this head before merge; they cover DVD LPCM decoding and HE-VAG lifecycle validation. ## Sources - `core/libs/prx/libSceAudiodecCpu/Export.cpp` — inspected the HE-VAG lifecycle, DVD LPCM decode, and codec dispatch paths. - `core/libs/tests/GuestAudiodecCpuQueryGuest.cpp` — inspected the added lifecycle and decode test cases. - `docs/dev/debt/changes/feat-audiodeccpu-1360-codecs.md` — read the full change fragment. ## Not verified Tests, build and firmware behavior were not run or confirmed. The full text of `Export.cpp` and `GuestAudiodecCpuQueryGuest.cpp` was not read; targeted ranges and changed hunks were inspected. The prepared bundle lists all three changed files as included; all three were inspected, with the two C++ files only partially read. ## To get this to a good state Nothing is required. Optional: run the new guest regression tests on this head.
ligmaSec commented 2026-12-03 10:25:00 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by ligmaSec on 2026-12-03T10:25:00Z.

Review: COMMENTED


The GuestAudiodecCpuQueryGuest fixture passed on Linux with the exact implementation from this head. The fixture covers the LPCM and HE-VAG paths, including the DVD PCM output capacity boundary and preservation of output on rejection.

AI-assisted: yes.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6167884662 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/27277#pullrequestreview-6167884662). Originally posted by [ligmaSec](https://github.com/ligmaSec) on 2026-12-03T10:25:00Z. **Review:** COMMENTED --- The GuestAudiodecCpuQueryGuest fixture passed on Linux with the exact implementation from this head. The fixture covers the LPCM and HE-VAG paths, including the DVD PCM output capacity boundary and preservation of output on rejection. AI-assisted: yes.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/27277:upstream-pr/27277'
git switch 'upstream-pr/27277'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/27277'
git switch 'upstream-pr/27277'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/27277'
git switch 'upstream-pr/27277'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/27277'
git switch 'main'
git merge --squash 'upstream-pr/27277'
git switch 'main'
git merge --ff-only 'upstream-pr/27277'
git switch 'main'
git merge 'upstream-pr/27277'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!27277
No description provided.