feat(ajm): implement sceAjmBatchJobSetResampleParameters and sceAjmBatchJobGetResampleInfo #1018

Merged
Raghav314 merged 2 commits from upstream-pr/1018 into main 2026-10-07 01:47:50 +00:00
Raghav314 commented 2026-10-07 00:07:03 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Raghav314 on 2026-10-07T00:07:03Z.


What

  • SetResampleParameters and GetResampleInfo are batch jobs, run in order with the decodes.
  • The ratio is used as decoded samples per output sample. In Hades II, FMOD sets it to
    frequency / output rate (observed 42763 / 48000 = 0.8909) and clamps it to [0.125, 4].
  • Decoded PCM for AT9, MP3 and Opus goes through a 4-point Catmull-Rom resampler.
    Each job fills its output from held samples first and decodes more only when needed.
    At ratio 1.0 the resampler is bypassed and output is unchanged.
  • GetResampleInfo writes 48 bytes to its result pointer: the 8-byte job result, then
    float ratio, int32 num_samples and 32 zero bytes. num_samples is the number of decoded
    samples the resampler still holds. FMOD treats num_samples <= 2 as the end of a voice;
    the resampler keeps two look-ahead samples, which matches that.
  • The flags argument is ignored, as in shadPS4 and Kyty (neither uses it).
  • ClearContext and Initialize drop held samples. Non-finite or non-positive ratios
    return SCE_AJM_ERROR_INVALID_PARAMETER.

Tested

Linux (CachyOS), x86-64, GCC, 7800X3D / RTX 4090.

  • guest_ajm: ratio 1.0 output is unchanged; 2.0 and 0.5 give exact samples at whole positions;
    midpoints match the interpolator; each job fills its output; the drain ends with <= 2 held;
    ClearContext restarts the stream; invalid ratios are refused. Covers Opus, MP3 and AT9
    (the AT9 case uses a silent superframe built by testing against LibAtrac9).
  • Full ctest suite passes.
  • Hades II (PPSA36082) gets past the sceAjmBatchJobSetResampleParameters abort on main.

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 in TechnicalDebt
  • 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
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4766069464 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1018). Originally posted by [Raghav314](https://github.com/Raghav314) on 2026-10-07T00:07:03Z. --- ### What - SetResampleParameters and GetResampleInfo are batch jobs, run in order with the decodes. - The ratio is used as decoded samples per output sample. In Hades II, FMOD sets it to frequency / output rate (observed 42763 / 48000 = 0.8909) and clamps it to [0.125, 4]. - Decoded PCM for AT9, MP3 and Opus goes through a 4-point Catmull-Rom resampler. Each job fills its output from held samples first and decodes more only when needed. At ratio 1.0 the resampler is bypassed and output is unchanged. - GetResampleInfo writes 48 bytes to its result pointer: the 8-byte job result, then float ratio, int32 num_samples and 32 zero bytes. num_samples is the number of decoded samples the resampler still holds. FMOD treats num_samples <= 2 as the end of a voice; the resampler keeps two look-ahead samples, which matches that. - The flags argument is ignored, as in shadPS4 and Kyty (neither uses it). - ClearContext and Initialize drop held samples. Non-finite or non-positive ratios return SCE_AJM_ERROR_INVALID_PARAMETER. ### Tested Linux (CachyOS), x86-64, GCC, 7800X3D / RTX 4090. - guest_ajm: ratio 1.0 output is unchanged; 2.0 and 0.5 give exact samples at whole positions; midpoints match the interpolator; each job fills its output; the drain ends with <= 2 held; ClearContext restarts the stream; invalid ratios are refused. Covers Opus, MP3 and AT9 (the AT9 case uses a silent superframe built by testing against LibAtrac9). - Full ctest suite passes. - Hades II (PPSA36082) gets past the sceAjmBatchJobSetResampleParameters abort on main. ### Checklist - [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 in [TechnicalDebt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/TechnicalDebt.md#silent-stubs) - [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 - [x] AI-assisted: yes
github-actions[bot] commented 2026-10-07 00:07:26 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-07T00:07:26Z.


Progress report (ee391a5 → 60e1653)

📈 System libraries: 86.69% (+0.07%, +2 implemented functions)

✅ 2 implemented
Library Name
libSceAjm.native sceAjmBatchJobGetResampleInfo
libSceAjm.native sceAjmBatchJobSetResampleParameters
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6027852672 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1018#issuecomment-6027852672). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-07T00:07:26Z. --- <!-- progress-report --> ### Progress report (ee391a5 → 60e1653) 📈 **System libraries**: 86.69% (+0.07%, +2 implemented functions) <details> <summary>✅ 2 implemented</summary> | Library | Name | | - | - | | libSceAjm.native | `sceAjmBatchJobGetResampleInfo` | | libSceAjm.native | `sceAjmBatchJobSetResampleParameters` | </details>
github-actions[bot] commented 2026-10-07 00:13:01 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-07T00:13:01Z.


Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.

Pull request Conflicting files (lines on main) Same exports Same new files
#946 docs/dev/TechnicalDebt.md L163
#1021 docs/dev/TechnicalDebt.md L163
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6027917759 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1018#issuecomment-6027917759). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-07T00:13:01Z. --- <!-- pr-overlap --> Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in **Depends on**. | Pull request | Conflicting files (lines on `main`) | Same exports | Same new files | |---|---|---|---| | #946 | `docs/dev/TechnicalDebt.md` [L163](https://github.com/boykopovar/AnyPS5/blob/ee391a5614246338aec9cb7a3a3dd4f479aec9f3/docs/dev/TechnicalDebt.md#L163) | | | | #1021 | `docs/dev/TechnicalDebt.md` [L163](https://github.com/boykopovar/AnyPS5/blob/ee391a5614246338aec9cb7a3a3dd4f479aec9f3/docs/dev/TechnicalDebt.md#L163) | | |
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!1018
No description provided.