fix(libSceNgs2.native): return 0x804A8432 for waveform formats the module does not parse #9324

Merged
MarrasFederico merged 4 commits from upstream-pr/9324 into main 2026-10-27 08:35:04 +00:00
MarrasFederico commented 2026-10-21 18:27:35 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarrasFederico on 2026-10-21T18:27:35Z.


What

sceNgs2ParseWaveformData and sceNgs2ParseWaveformFile threw "parsing waveform format tag … is not implemented" for any format they did not parse. In prosper's reading of libSceNgs2.native.sprx, the module's route selection answers most of them with 0x804A8432 (UNKNOWN_WAVEFORM_FORMAT). The parser now does the same:

  • Tags: a tag other than 1 (PCM), 3 (float) or 0xFFFE (extensible) returns 0x804A8432.
  • Extensible:
    • an fmt chunk under 0x28 bytes returns 0x804A8432;
    • the PCM GUID and the ATRAC9 GUID keep their parsers, checked in the module's order (PCM first);
    • any other GUID returns 0x804A8432.
  • Two cases still throw, recorded in a new debt entry:
    • an fmt chunk of exactly 0x34 bytes with any other GUID, which the module parses as ATRAC9 without checking the config, unlike the ATRAC9 parser here;
    • the GUID of waveform type 0x43, a codec AnyPS5 does not decode.

This builds on #9148, which adds the float route and the PCM GUID. #9148 is merged and this branch is merged with current main, so the diff holds only this PR's commits.

Tested

Ubuntu 26.04.1, kernel 7.0.0-38, GCC 15.2.0, Release, full build with BUILD_TESTING=ON. Windows was not compiled. No title was run.

  • ngs2_parse, new TestParseUnknownFormats:
    • tags 0, 2, 0x11, 0x55, 0x165 and 0xFFFF return 0x804A8432;
    • extensible fmt chunks of 0x10, 0x18 and 0x26 bytes return 0x804A8432;
    • an unknown GUID with fmt chunks of 0x28, 0x30 and 0x36 bytes returns 0x804A8432;
    • the PCM GUID with a 0x34-byte chunk still parses as PCM;
    • sceNgs2ParseWaveformFile returns 0x804A8432 for tag 0x55.
  • The test fails on this branch's base (#9148), where the first unknown tag throws. Throwing again for unknown tags or returning INVALID_WAVEFORM_FORMAT for a short extensible chunk makes it fail. The test does not exercise the two cases that still throw (the type 0x43 GUID and an unknown GUID with 0x34 bytes), so it does not pin them as unimplemented.
  • All 16 ngs2 tests pass on current main.
  • After merging current main (#9148 included), the full build succeeds and the 16 ngs2 tests pass. This PR and #9149 each add tests at the same place in Ngs2Parse.cpp, so whichever lands second needs a rebase that keeps both.
  • tools/check_conventions.py --base origin/main passes. tools/pr_overlap.py reports my #9149 on Atrac9.cpp L18, where both branches carry #9148's new constants. It could not compare #5797; it does not change the route selection.

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
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4956417140 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9324). Originally posted by [MarrasFederico](https://github.com/MarrasFederico) on 2026-10-21T18:27:35Z. --- ### What `sceNgs2ParseWaveformData` and `sceNgs2ParseWaveformFile` threw "parsing waveform format tag … is not implemented" for any format they did not parse. In prosper's reading of `libSceNgs2.native.sprx`, [the module's route selection](https://github.com/mattias800/prosper/blob/8dcb5dfdb9997ede7c76783995010d6abd1222f8/prosper/src/hle/audio/ngs2_waveform.cpp#L190-L208) answers most of them with `0x804A8432` (`UNKNOWN_WAVEFORM_FORMAT`). The parser now does the same: - **Tags:** a tag other than 1 (PCM), 3 (float) or 0xFFFE (extensible) returns `0x804A8432`. - **Extensible:** - an fmt chunk under 0x28 bytes returns `0x804A8432`; - the PCM GUID and the ATRAC9 GUID keep their parsers, checked in the module's order (PCM first); - any other GUID returns `0x804A8432`. - **Two cases still throw**, recorded in a new debt entry: - an fmt chunk of exactly 0x34 bytes with any other GUID, which the module parses as ATRAC9 without checking the config, unlike the ATRAC9 parser here; - the GUID of waveform type 0x43, a codec AnyPS5 does not decode. This builds on #9148, which adds the float route and the PCM GUID. #9148 is merged and this branch is merged with current `main`, so the diff holds only this PR's commits. ### Tested <!-- OS, title or homebrew, what was checked. "Not tested" is a valid answer. A performance change: the summary lines of main and of this PR from the same machine and scene, with the traces attached, captured as the Performance report issue form describes. --> Ubuntu 26.04.1, kernel 7.0.0-38, GCC 15.2.0, Release, full build with `BUILD_TESTING=ON`. Windows was not compiled. No title was run. - `ngs2_parse`, new `TestParseUnknownFormats`: - tags 0, 2, 0x11, 0x55, 0x165 and 0xFFFF return `0x804A8432`; - extensible fmt chunks of 0x10, 0x18 and 0x26 bytes return `0x804A8432`; - an unknown GUID with fmt chunks of 0x28, 0x30 and 0x36 bytes returns `0x804A8432`; - the PCM GUID with a 0x34-byte chunk still parses as PCM; - `sceNgs2ParseWaveformFile` returns `0x804A8432` for tag 0x55. - The test fails on this branch's base (#9148), where the first unknown tag throws. Throwing again for unknown tags or returning `INVALID_WAVEFORM_FORMAT` for a short extensible chunk makes it fail. The test does not exercise the two cases that still throw (the type 0x43 GUID and an unknown GUID with 0x34 bytes), so it does not pin them as unimplemented. - All 16 `ngs2` tests pass on current `main`. - After merging current `main` (#9148 included), the full build succeeds and the 16 `ngs2` tests pass. This PR and #9149 each add tests at the same place in `Ngs2Parse.cpp`, so whichever lands second needs a rebase that keeps both. - `tools/check_conventions.py --base origin/main` passes. `tools/pr_overlap.py` reports my #9149 on `Atrac9.cpp` L18, where both branches carry #9148's new constants. It could not compare #5797; it does not change the route selection. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none <!-- #PR, or none --> - [x] Fixes: none <!-- issue it closes as Fixes #N, or none --> - [x] Unblocks: none <!-- title ID and Game bring-up discussion, e.g. PPSA01325 #3232, or none --> - [x] GPUs tested: n/a <!-- for AGC, shader recompiler or VideoOut changes: vendor, model, driver and OS of each GPU the GPU tests ran on; otherwise n/a --> - [x] AI-assisted: yes <!-- yes / no -->
ycbuzi commented 2026-10-21 20:48:54 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by ycbuzi on 2026-10-21T20:48:54Z.


Windows run of 0f4a7216ef merged onto main 0c6a5bd593 (229b80cc3f, clean), the platform the description lists as not tested. Windows 11 Home 10.0.26200, MinGW-w64 GCC 15.2.0 (ucrt-posix-seh r7), Release, BUILD_TESTING=ON.

Built libSceNgs2.native and ngs2_parse_tests with no errors or warnings. ctest --repeat until-fail:2 on ngs2_parse: passes on both repeats. The head carries the PRs below it in its stack (#9148) too. Not run: a title.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6326229855 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9324#issuecomment-6326229855). Originally posted by [ycbuzi](https://github.com/ycbuzi) on 2026-10-21T20:48:54Z. --- Windows run of 0f4a7216ef merged onto `main` 0c6a5bd593 (229b80cc3f, clean), the platform the description lists as not tested. Windows 11 Home 10.0.26200, MinGW-w64 GCC 15.2.0 (ucrt-posix-seh r7), Release, `BUILD_TESTING=ON`. Built `libSceNgs2.native` and `ngs2_parse_tests` with no errors or warnings. `ctest --repeat until-fail:2` on `ngs2_parse`: passes on both repeats. The head carries the PRs below it in its stack (#9148) too. Not run: a title.
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!9324
No description provided.