audio: let the AJM Opus decoder write part of a packet #1914

Manually merged
github merged 1 commit from gh-pr/1914/head into gh-pr/1914/base 2026-11-26 10:08:45 +00:00
Owner

@⁠Cosmo on GitHub · 2026-10-26 07:45 UTC · original
Cosmo:fix/ajm-opus-small-output → main · +621 −18 · 5 files · 1 commits · merged 2026-10-28 20:31 UTC

A game using FMOD had no in-game sound. It decodes Opus into 1024-byte outputs, but each packet decodes to 1920 bytes. The decoder only wrote whole packets, so every call returned NOT_ENOUGH_ROOM and nothing was decoded.

Now the decoder writes as much of a packet as fits and keeps the rest for the next call. With it, the game has sound. ajm_opus_tests covers this.

What I don't know is whether the PS5 reports NOT_ENOUGH_ROOM when it has to keep part of a packet for the next call. This change reports OK.

AI use

Research, implementation and tests were done with Claude Code at my direction.
I reviewed the code, and tested it as described above.

**@⁠Cosmo** on GitHub · 2026-10-26 07:45 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1914) `Cosmo:fix/ajm-opus-small-output` → `main` · +621 −18 · 5 files · 1 commits · merged 2026-10-28 20:31 UTC A game using FMOD had no in-game sound. It decodes Opus into 1024-byte outputs, but each packet decodes to 1920 bytes. The decoder only wrote whole packets, so every call returned NOT_ENOUGH_ROOM and nothing was decoded. Now the decoder writes as much of a packet as fits and keeps the rest for the next call. With it, the game has sound. `ajm_opus_tests` covers this. What I don't know is whether the PS5 reports NOT_ENOUGH_ROOM when it has to keep part of a packet for the next call. This change reports OK. ## AI use Research, implementation and tests were done with Claude Code at my direction. I reviewed the code, and tested it as described above.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 10:08:43 +00:00
github manually merged commit edc97ec0ea into gh-pr/1914/base 2026-11-26 10:08:45 +00:00
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-26 07:50 UTC · original · edited 2026-10-28 20:24 UTC

Review in Change Stack →

Walkthrough

The PR adds an AjmResampler for Opus decoding, connects its parameter controls and resampling information to AJM results, and adds a test executable with CTest registration. The tests cover chunked output, resampling ratios, retained PCM, format changes, and loop behavior.

Suggested reviewers: nmzik

Priority: Normal

Change: Feature

Merge Risk: Low · up to edc97

Resampled audio can report a false drained state or carry old audio into a new stream. These bounded issues warrant fixes or explicit acceptance before merging.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 4.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly identifies the main decoder change: allowing the AJM Opus decoder to write part of a packet. This matches the pull request objectives and related test changes.
Description check Passed The description explains the partial-packet decoding problem, the retained output behavior, the reported status change, and the associated testing. It is related to the changeset.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 4.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 25 functions across 4 files. (1 skipped: 1 unsupported.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

**@⁠coderabbitai[bot]** on GitHub · 2026-10-26 07:50 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1914#issuecomment-6410927608) · edited 2026-10-28 20:24 UTC <!-- coderabbit-ai-generated:v1 --> <!-- This is an auto-generated comment: summarize by coderabbit.ai --> <!-- review_stack_entry_start --> <a href="https://app.coderabbit.ai/change-stack/KytyPS5/KytyPS5/pull/1914?scope=ghh_OusAJGA4HG8ljoOV0wJvVx8NmnZIjc2DdjmxOu0xZWA&amp;cs_source=review_comment"><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui-dark.svg?v=3"><source media="(prefers-color-scheme: light)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg?v=3"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg?v=3" alt="Review in Change Stack →" height="32"></picture></a> <!-- review_stack_entry_end --> <!-- walkthrough_start --> <details> <summary><strong>Walkthrough</strong></summary> <dl> <dd> The PR adds an `AjmResampler` for Opus decoding, connects its parameter controls and resampling information to AJM results, and adds a test executable with CTest registration. The tests cover chunked output, resampling ratios, retained PCM, format changes, and loop behavior. **Suggested reviewers:** `nmzik` </dd> </dl> </details> <!-- walkthrough_end --> <!-- change_assessment_start --> <strong>Priority: <picture><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/priority-normal-16.svg" width="16" height="16" align="absmiddle" alt=""></picture> Normal</strong> <!-- change_assessment_commit:"edc97ec0ea227d55c9799ffd4bea8b3559b11e30" --> **Change:** Feature <!-- change_assessment_end --> <details> <summary><strong>Merge Risk:</strong> <strong><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/risk-low-16.svg" width="16" height="16" align="absmiddle" alt=""></picture> Low</strong> · up to <code>edc97</code></summary> <dl> <dd> <!-- final_review_risk_start --> <!-- final_review_risk_label **Merge Risk:** **🔵 Low** · up to `edc97` --> <!-- final_review_risk_coverage:{"sourceCommitId":"edc97ec0ea227d55c9799ffd4bea8b3559b11e30","coveredCommitId":"edc97ec0ea227d55c9799ffd4bea8b3559b11e30","kind":"reviewed"} --> Resampled audio can report a false drained state or carry old audio into a new stream. These bounded issues warrant fixes or explicit acceptance before merging. <!-- final_review_risk_end --> </dd> </dl> </details> <!-- pre_merge_checks_walkthrough_start --> <details> <summary><strong>Pre-merge checks: <sup><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-counter-passed-14-v2.svg" width="14" height="14" align="middle" alt="Passed" title="Passed"></picture></sup> 4 · <sup><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-counter-failed-14-v2.svg" width="14" height="14" align="middle" alt="Failed" title="Failed"></picture></sup> 1</strong></summary> <dl> <dd> <strong><sup><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-counter-failed-14-v2.svg" width="14" height="14" align="middle" alt="Failed" title="Failed"></picture></sup> Failed checks: 1 warning</strong> | Check name | Status | Explanation | Resolution | | :---------------- | :----------------------------------------------------------------------------------------------: | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :--------------------------------------------------------------------------------- | | Docstring Coverage | ![Warning](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-warning.svg) | Docstring coverage is 4.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat… | Write docstrings for the functions missing them to satisfy the coverage threshold. | <details> <summary><strong><sup><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-counter-passed-14-v2.svg" width="14" height="14" align="middle" alt="Passed" title="Passed"></picture></sup> Passed checks: 4 passed</strong></summary> <dl> <dd> | Check name | Status | Explanation | | :------------------------ | :--------------------------------------------------------------------------------------------: | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | Title check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | The title clearly identifies the main decoder change: allowing the AJM Opus decoder to write part of a packet. This matches the pull request objectives and related test changes. | | Description check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | The description explains the partial-packet decoding problem, the retained output behavior, the reported status change, and the associated testing. It is related to the changeset. | | Linked Issues check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | Check skipped because no linked issues were found for this pull request. | | Out of Scope Changes check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | Check skipped because no linked issues were found for this pull request. | </dd> </dl> </details> <details> <summary><strong>Full details: Docstring Coverage</strong></summary> <dl> <dd> **Explanation** Docstring coverage is 4.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 25 functions across 4 files. (1 skipped: 1 unsupported.) **Resolution** Write docstrings for the functions missing them to satisfy the coverage threshold. </dd> </dl> </details> </dd> </dl> </details> <!-- pre_merge_checks_walkthrough_end --> <!-- autopilot:start --> - [ ] <!-- {"checkboxId":"2708ad07-9f24-4260-9c11-7dc76a49f2e3"} --> <strong title="Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts">Autofix</strong> · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts <!-- autopilot:end --> <!-- tips_start --> Thanks for using [CodeRabbit](https://coderabbit.ai?utm_source=oss&utm_medium=github&utm_campaign=KytyPS5/KytyPS5&utm_content=1914)! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. <details> <summary><strong>❤️ Share</strong></summary> <dl> <dd> - [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai) - [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai) - [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai) - [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code) </dd> </dl> </details> <sub>Comment `@coderabbitai help` to get the list of available commands.</sub> <!-- tips_end -->
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-26 07:50 UTC · original
On src/libs/ajm/opus_decoder.h line 85 (outdated):

@@ -79,6 +81,13 @@ class AjmOpusDecoder final: public AjmDecoder {
 			result.result = AJM_RESULT_NOT_INITIALIZED;
 			return result;
 		}
+		WritePcm(output, output_size, gapless, &result);
+		if (!m_pcm_buffer.empty()) {

Minor · Functional Correctness · Quick win

🔎 Supported by static analysis

Script executed:

sed -n '55,250p' src/libs/ajm/opus_decoder.h
rg -n 'multiple_frames|\.Decode\(' src/libs/ajm.cpp src/libs/ajm
sed -n '51,160p' tests/AjmOpusTests.cpp

Repository: KytyPS5/KytyPS5

Length of output: 13904


Script executed:

sed -n '100,155p' src/libs/ajm/decoder.h
sed -n '270,325p' src/libs/ajm.cpp
sed -n '400,470p' src/libs/ajm.cpp
sed -n '1,120p' src/libs/ajm.cpp
rg -n -F -- 'multiple_frames' src/libs/ajm src/libs/ajm.cpp tests

Repository: KytyPS5/KytyPS5

Length of output: 12861


Script executed:

rg -n -F -e 'AjmDecodeInstance(' -e 'AJM_FLAG_RUN_MULTIPLE_FRAMES' -e 'AjmDecodeSplitInstance(' src/libs/ajm.cpp
sed -n '500,680p' src/libs/ajm.cpp
sed -n '680,860p' src/libs/ajm.cpp

Repository: KytyPS5/KytyPS5

Length of output: 14000


Web query:

Sony PlayStation AJM sceAjmBatchJobDecodeSingle multiple frames contract

Result:

<source_evidence>
<source kind="search">
<title>音频与 3D 音频(NGS2、ajm、audio3d) - shadps4-emu/shadPS4</title>
<location>https://opendeep.wiki/shadps4-emu/shadPS4/7-system-libraries/audio</location>
<excerpt>citeturn0search2 [wordlim: 200] Crawled: yesterday; `ajm` 是 shadPS4 中 PS4 Audio Job Manager 子系统的实现,源码位于 `src/core/libraries/ajm/`,由调度器 `AjmContext` 与若干个 `AjmInstance` 组成;每个实例内部进一步拆出 batch job 与 codec-specific 状态。 ... `1 AjmJobFlags flags{}; 2 flags.version = 1; 3 flags.codec = static_cast&lt;u64&gt;(AjmCodecType::At9Dec); 4 flags.run_flags = AjmJobRunFlags::MultipleFrames; 5 flags.control_flags = AjmJobControlFlags::Initialize; 6 flags.sideband_flags = AjmJobSidebandFlags::GaplessDecode; 7 8// flags.raw 作为 `sceAjmBatchSubmit` 入口的 flags 参数`
### 模块组成

  * `ajm.cpp` / `ajm.h`:注册符号和模块入口;`AjmContext` 维护 instance 表与统计信息。
  * `ajm_context.cpp`:全局状态、操作句柄(`sceAjmCreateContext` / `sceAjmDestroyContext`)。
  * `ajm_instance.cpp`:单个 ajm 实例生命周期、module 控制。
  * `ajm_batch.cpp`:批作业模式(multiple frames、reset、resample)调度逻辑,是 hot path。
  * `ajm_mp3.cpp` / `ajm_mp3.h`:MP3 解码器适配,基于 FFmpeg `libavcodec` / `libavcodec` 解析器 + `libswresample` 实现;通过 `AjmMp3Decoder` 类(继承 `AjmCodec`)把 MP3 流解析为 PCM 帧,支持 `S16` / `S32` / `Float` 三种输出格式,自动完成 `mp3 → target_format` 的重采样;同时支持 gapless(通过 `AjmInstanceGapless` 跟踪总样本/encoder delay)。关键类型:
    * `AjmDecMp3OflType`:MPEG 帧边信息(Lame/Vbri/Fgh)枚举。
    * `AjmMp3CodecFlags`:`IgnoreOfl` / `VlcRewind` 等 codec 控制位。
    * `AjmDecMp3ParseFrame`:解析单帧后回填的元数据(采样率、位率、通道、样本数、OFL 类型等)。
    * `AjmSidebandDecMp3CodecInfo`:sideband 通道中回写的 MP3 codec 信息(CRC / 通道模式 / 模式扩展 / copyright / original / emphasis)。
    * `ParseMp3Header(...)` / `ParseMp3Frame(...)`:解析单帧 MP3 流,填写 BB 级标记。
    * `AjmCodec::GetFormat() / GetMinimumInputSize() / GetNextFrameSize() / ProcessData() / Reset()`:与 `ajm_codec.h` 的接口保持一致,由 `AjmMp3Decoder` 各自实现。
  * `ajm_at9.cpp`:ATRAC9 解码器适配;与 MP3 路径实现一致的解码回调签名。
  * `ajm_aac.cpp`:M4AAC 解码;其配置数据 (`ORBIS_AT9_CONFIG_DATA_SIZE = 4`) 用于把 ASC 参数注入解码器。
  * `ajm_instance_statistics.cpp`:统计查询接口 (`AJM_INSTANCE_STATISTICS = 0x80000`)。

### 控制与执行流程

游戏往 ajm 提交 job 时遵循以下顺序:

  1. 创建 context(`sceAjmCreateContext`),得到一个 process-wide 的 handle。
  2. 在该 context 下创建 instance(`sceAjmModuleCreate` / `AjmInstance::Create`),并选取 codec(`AjmCodecType`)。
  3. 提交 batch(`sceAjmBatchSubmit` / `AjmBatch::Submit`):把若干 job + 输入 buffer 链接成链表。
  4. 引擎迭代调用 `_ajm_instance_run` 一类入口推进 batch,运行时按需触发 `Reset`/`Initialize`/`Resample` 控制标志位对应的内部状态机。
  5. 解码完成后把 PCM 写回作业输出 buffer,并把 sideband 元数据(`AjmSidebandFormat`、`AjmSidebandMFrame`、`AjmSidebandStream`)回写到游戏侧指针。

&gt; ajm 本身不直接控制音频输出——它的产物只是 PCM,与 `audioout` 协作由调用方负责。

### MP3 解码器细节(`AjmMp3Decoder`)

`ajm_mp3.cpp/h` 中以 `AjmMp3Decoder` 实现 MP3 路径,关键流程为:

  1. 构造与资源:构造期调用 `avcodec_find_decoder(AV_CODEC_ID_MP3)` 拿到 FFmpeg MP3 解码器,并用 `avcodec_alloc_context3` / `avcodec_open2` 初始化上下文;用 `av_parser_init` 创建解析器上下文;`libswresample` 的 `SwrContext` 在需要时懒分配。
## Usage Examples

### 1. audio3d 的 per-port 参数初始化

cpp

`1// 获取默认 open parameters 2 OrbisAudio3dOpenParameters params{}; 3 sceAudio3dGetDefaultOpenParameters(&amp;params); 4 params.granularity = 512; // 48kHz 下约 10.7ms 5 params.max_objects = 32; 6 params.queue_depth = 4; 7 params.buffer_mode = OrbisAudio3dBufferMode::ORBIS_AUDIO3D_BUFFER_ADVANCE_AND_PUSH; 8 9// 创建 port 10 OrbisAudio3dPortId port_id; 11 sceAudio3dPortOpen(user_id, &amp;params, &amp;port_id);`

&gt; Source: audio3d.h (结构体与符号定义参考)

### 2. ajm codec 槽位组装 flags

cpp

`1 AjmJobFlags flags{}; 2 flags.version = 1; 3 flags.codec = static_cast&lt;u64&gt;(AjmCodecType::At9Dec); 4 flags.run_flags = AjmJobRunFlags::MultipleFrames; 5 flags.control_flags = AjmJobControlFlags::Initialize; 6 flags.sideband_flags = AjmJobSidebandFlags::GaplessDecode; 7 8// flags.raw 作为 `sceAjmBatchSubmit` 入口的 flags 参数`

&gt; Source: ajm.h

### 3. ajm 格式编码枚举选择

cpp
  * `s32 sceAjmBatchSubmit(...)`:提交一批解码作业。
  * `s32 sceAjmBatchRun(...)`:推进一个或多个 job。
  * `s32 sceAjmBatchGetResult(...)`:读取解码后的 PCM 与 sideband。
  * `s32 sceAjmDecMp3ParseFrame(const u8* buf, u32 stream_size, int parse_ofl, AjmDecMp3ParseFrame* frame)`:在不创建 instance 的前提下解析一段 MP3 流,返回 `frame_size` / `num_channels` / `samples_per_channel` / `bitrate` / `sample_rate` / `encoder…[truncated]</excerpt>
</source>
<source kind="search">
<title>[Game tracker] BALAN WONDERWORLD (PPSA02058) · Issue #2882 · mattias800/prosper · GitHub</title>
<location>GitHub issue 2882 in mattias800/prosper (link omitted to avoid creating a cross-reference)</location>
<excerpt>citeturn1search0 [wordlim: 200] Published: 2 months ago; Crawled: last month; background, the game&#39;s own typeface, all 24 language buttons with English highlighted, and the ...   * Boots, links and runs guest code in 232 ms. ... `sceNetResolverCreate`, `sceVoiceQoSInit`, `sceAjmBatchJobDecodeSingle`, `pthread_setschedparam`.

# [Game tracker] BALAN WONDERWORLD (PPSA02058) #2882

New issue

Copy link

New issue

Copy link

Open

Open

[Game tracker] BALAN WONDERWORLD (PPSA02058)#2882

Copy link

Labels

game:balan-wonderworldBALAN WONDERWORLD (PPSA02058)BALAN WONDERWORLD (PPSA02058)tracker:gameLong-lived per-game compatibility milestone and evidence index; not a bugLong-lived per-game compatibility milestone and evidence index; not a bug

## Description

mattias800

opened on Aug 21, 2026

Issue body actions

## Current milestone

&gt; Updated 2026-08-22 — a pad route now gets past this screen. Read the comment thread
&gt; for the measurement; the paragraph below records where a default, no-input boot stops,
&gt; which is still accurate and is the control the routed result is measured against.
&gt; Route: `prosper/scripts/balan-PPSA02058/reach-title-and-prologue.pad`.
&gt; The rung is unchanged — the routed run reaches a map load, not a rendered world.

Rung 2 — the game&#39;s own 4K language-select menu renders, and waits for Cross. First booted
2026-08-22 by the never-booted survey (`prosper/docs/NEVER_BOOTED_SURVEY_2026_08.md`).

Boot is clean and fast: `[bootphase] BOOT_COMPLETE +232ms`, `[agc] register defaults requested for SDK version 7`. The title then composites its language-select screen at 3840x2160 — the theatre
background, the game&#39;s own typeface, all 24 language buttons with English highlighted, and the
`○ ✕ △ □ Change Language` / `Select Language` prompt bar. 17.9 fps while producing frames, 97% of a
137 s run active, guest alive at the end.

This is the game&#39;s first-boot flow, not its title screen. It is placed at rung 2 on
`COMPATIBILITY.md`&#39;s own bucket (&quot;title screen or menu reached&quot;), and the menu&#39;s own prompt bar
names the button it is waiting for.

Direct unmodified 4K capture: `assets/screenshots/balan-wonderworld-language-select.png`.

 | 
--- | ---
Title  | BALAN WONDERWORLD
Title ID  | `PPSA02058`
Content ID  | `EP0082-PPSA02058_00-BALANWW5E0000001`
Required system software  | `0x0250000000000000`
Application size  | 31 GB

### Engine: Unreal Engine 4

Derived from layout, not from the publisher: an `engine/` directory beside a project directory,
a `ue4commandline.txt`, and a `.pak` archive — the standard UE4 packaged-build shape.

No `.utoc`/`.ucas`, so this is a `.pak` build rather than IoStore. That matters for where to
start: `docs/UE4_APR_IOSTORE_BRINGUP.md` covers the IoStore path, which this title does not use.

The engine version is not present in the eboot strings, so none is recorded here rather than
guessing one.

Unreal is the largest cohort in this project and none of its titles has reached gameplay yet
(see `COMPATIBILITY.md` § Where the titles accumulate). Shared UE4 findings live in
`docs/CROSS_ENGINE_UE4.md`; check it before forming a hypothesis, and add to it if this title
teaches something general.

Project directory: `happiness/`.

## What works

  * Boots, links and runs guest code in 232 ms.
  * Composites at 3840x2160 through the live renderer at 17.9 fps while producing frames.
  * Renders the language-select menu completely: background art, typeface, all button labels
including CJK, Thai, Greek, Cyrillic and Arabic, and the PlayStation glyph prompt bar.
  * Survives a 140 s run with no guest fault.

## Current blockers

  * #2932 — only ~18% of frames carry the
menu; the rest are a flat white 4K clear. Measured on a 1 s grid over 110 samples: content at
t = 16, 18, 32, 33, 36, 45, 49, 50, 54, 56, 60, 69, 72, 73, 77, 82, 86, 98, 103, 105 s, with no
cadence. Coarser 7 s and 5 s grids reported &quot;3 of 20&quot; and &quot;3 of 24&quot;…[truncated]</excerpt>
</source>
<source kind="search">
<title>[Game tracker] BALAN WONDERWORLD (PPSA02058) · Issue #2882 · mattias800/prosper · GitHub</title>
<location>GitHub issue 2882 in mattias800/prosper (link omitted to avoid creating a cross-reference)</location>
<excerpt>citeturn2search2 [wordlim: 200] Published: 2 months ago; Crawled: last month; `sceNetResolverCreate`, `sceVoiceQoSInit`, `sceAjmBatchJobDecodeSingle`, `pthread_setschedparam`.
`sceNetResolverCreate`, `sceVoiceQoSInit`, `sceAjmBatchJobDecodeSingle`, `pthread_setschedparam`.

## Reproduction route

Frontend `tools/screenshot`, default route, no pad input, on master `bffa40d4`,
Linux / AMD Radeon 8060S (RADV STRIX_HALO):
    
    PROSPER_RENDER=1 PROSPER_GUEST_ARGS=-force-gfx-direct PROSPER_BOOTPHASE=1 \
    SDL_VIDEODRIVER=offscreen \
    timeout -k 10 260 ./prosper/build-linux/screenshot &lt;DUMP_ROOT&gt;/PPSA02058-app0 \
        --seconds 7 --count 20 --timeout 170 --out &lt;OUT_DIR&gt; \
        --allow-guest-fault --no-stop-after-guest-fault

The outer bound and `--timeout` are deliberately different values: `--timeout` cannot bound a
boot (instrument trap 214), so a run that produces neither `[shot] done:` nor `[shot] timeout` was
killed from outside and its silence is not evidence.

To measure the content duty cycle rather than a grid artefact, use `--seconds 1 --count 110`.

## Ruled out

  * #1588 / `PROSPER_CB_EFC_NO_COLOR` is not
the mechanism here. The `[gpu] resolve_pipeline_state` diagnostic reports MODE=0 (DISABLE)
</excerpt>
</source>
<source kind="search">
<title>音频与 3D 音频(NGS2、ajm、audio3d) - shadps4-emu/shadPS4</title>
<location>https://opendeep.wiki/shadps4-emu/shadPS4/7-system-libraries/audio</location>
<excerpt>citeturn2search8 [wordlim: 200] Crawled: yesterday; `1 struct OrbisMusicPlayerPlayStatusExtension { 2 u64 size; // +0x00 (0x48) 3 u32 error_code; // +0x08 (0: ok, non-zero: error) 4 u32 play_state; // +0x0c (0: playing, 1: paused, 2: stopped) 5 u64 total_duration_s; // +0x10 6 u64 current_time_s; // +0x18 7 u32 tracklist_id; // +0x20 8 u32 track_index; // +0x24 9 u32 play_index; // +0x28 10 u32 total_track_count; // +0x2c 11 u32 volume; // +0x30 (0 - 25) 12 u32 repeat_mode; // +0x34 (0: off, 1: all, 2: one) 13 u32 shuffle_mode; // +0x38 14 u32 can_skip_next; // +0x3c 15 u32 can_skip_previous; // +0x40 16 u32 is_loading; // +0x44 17}; 18 static_assert(sizeof(OrbisMusicPlayerPlayStatusExtension) == 0x48); 19 20 struct SceMusicPlayerServicePlayStatus { 21 u32 result; // +0x00 (0: ok) 22 u32 play_status; // +0x04 (0: stopped, 1: playing, 2: paused) 23 u32 track_index; // +0x08 24 u32 tracklist_id; // +0x0c 25 u64 playback_time; // +0x10 26 u32 shuffle; // +0x18 27 u32 repeat; // +0x1c (0: off, 1: all, 2: one) 28}; 29 static_assert(sizeof(SceMusicPlayerServicePlayStatus) == 0x20);`
</excerpt>
</source>
<source kind="search">
<title>Ghost of Yōtei (PPSA26344) · boykopovar AnyPS5 · Discussion #675 · GitHub</title>
<location>GitHub discussion 675 in boykopovar/AnyPS5 (link omitted to avoid creating a cross-reference)</location>
<excerpt>citeturn0search0 [wordlim: 200] Crawled: today;   * Next non-GPU stop: `sceAjmBatchJobControl`, when the menu music starts. ... It does not overlap feat(ajm): implement sceAjmBatchJobDecodeSplit #867, which adds `sceAjmBatchJobDecodeSplit` and touches the same files.
## Update 2026-10-06 (7): the boot screen renders

Same host and testing branch as the previous update, with the same local diagnostic that skips only the six empty-table `GetBufferResource` dispatches.

  * The &quot;black&quot; frames were a fade-in. In the previous update every captured frame was black. A frame dump shows brightness rising frame by frame to the &quot;Sony Interactive Entertainment presents&quot; card and its copyright line, rendered by the title (capture at 960x540).
  * Still slow. It runs at about 1 frame per second. Finding out where the ~100 ms per frame goes is in progress.
  * Next non-GPU stop: `sceAjmBatchJobControl`, when the menu music starts. A pull request is in progress. It does not overlap feat(ajm): implement sceAjmBatchJobDecodeSplit #867, which adds `sceAjmBatchJobDecodeSplit` and touches the same files.
  * What this needs from upstream:
    * the six skipped dispatches need runtime-indexed buffer descriptors (see the notes on perf(agc): baseline shader recompilation on registration #639);

  * Correction to update 7:
    * The boot screen there was read from the title&#39;s own render target. In a normal run the window stays black: the title draws the &quot;Sony Interactive Entertainment presents&quot; card every frame, but the driver presents the clear colour (cause below).
    * At about 1 fps a frame takes about 1 s, not ~100 ms.
  * Why the window is black.
    * Every frame, the title&#39;s own retile compute shader copies its colour target&#39;s DCC keys into the display buffer&#39;s keys.
    * The driver writes &quot;uncompressed&quot; keys for that target only at write-back, which happens after the retile. So the display keys still hold the 0x00 clear code, and the presenter shows the clear colour.
    * Storing the keys when the target is first written makes the card visible in a local probe. A pull request is in progress.
  * Menu music: feat(ajm): implement sceAjmBatchJobControl #884 implements `sceAjmBatchJobControl`. With it, the title:
    * creates two ATRAC9 voices, runs five control jobs and about 950 decodes;
    * writes its savedata, and moves on to new, larger frames.
  * Next stop, about 10 minutes in: `AGC driver: null or misaligned address`. The arguments match the 0x60-byte, 8-byte-aligned check on a shader header that the title registers at a 4-byte-aligned address (0x801e374cc4). Being checked.
  * Where the ~1 s per frame goes:
    * GPU: one compute shader (0x800036e100, light culling, 240x135 groups of 16x16) takes 600-650 ms per frame. Its light loops run zero times, so the cost is in the translation. Profiling is in progress.
    * CPU: recording takes about 400 ms per frame, at about 3.7 ms per dispatch and 4.1 ms per draw; most draw recipe lookups miss.

Celegans12 Oct 6, 2026

</excerpt>
</source>
<omitted_sources count="29">Additional source records were omitted from this bounded result.</omitted_sources>
</source_evidence>

Citations:

- 1: GitHub issue 2882 in mattias800/prosper (link omitted to avoid creating a cross-reference)
- 2: https://opendeep.wiki/shadps4-emu/shadPS4/7-system-libraries/audio?utm_source=openai

Stop a single-frame call after draining pending PCM.

AjmBatchJobDecodeSingle passes false for multiple_frames. When WritePcm empties m_pcm_buffer, the pending-PCM path continues into the input loop without checking that flag. A single-frame call can therefore write the remainder of one packet, consume the next packet, and write part of it.

Return after draining pending PCM when multiple_frames is false. Preserve the existing multi-frame behavior.

Suggested fix
+		const bool had_pending_pcm = !m_pcm_buffer.empty();
		WritePcm(output, output_size, gapless, &result);
-		if (!m_pcm_buffer.empty()) {
+		if (!m_pcm_buffer.empty() || (had_pending_pcm && !multiple_frames)) {
			if (result.output_written == 0) {
				result.result = AJM_RESULT_NOT_ENOUGH_ROOM;
			}
			return result;
		}
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

		const bool had_pending_pcm = !m_pcm_buffer.empty();
		WritePcm(output, output_size, gapless, &result);
		if (!m_pcm_buffer.empty() || (had_pending_pcm && !multiple_frames)) {
**@⁠coderabbitai[bot]** on GitHub · 2026-10-26 07:50 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1914#discussion_r4374980916) On `src/libs/ajm/opus_decoder.h` line 85 (outdated): ```diff @@ -79,6 +81,13 @@ class AjmOpusDecoder final: public AjmDecoder { result.result = AJM_RESULT_NOT_INITIALIZED; return result; } + WritePcm(output, output_size, gapless, &result); + if (!m_pcm_buffer.empty()) { ``` <!-- coderabbit-ai-generated:v1 --> **<picture><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/amber-16.svg" width="16" height="16" align="absmiddle" alt=""></picture> Minor** · **Functional Correctness** · **Quick win** <details> <summary>🔎 Supported by static analysis</summary> <dl> <dd> Script executed: ```bash sed -n '55,250p' src/libs/ajm/opus_decoder.h rg -n 'multiple_frames|\.Decode\(' src/libs/ajm.cpp src/libs/ajm sed -n '51,160p' tests/AjmOpusTests.cpp ``` Repository: KytyPS5/KytyPS5 Length of output: 13904 --- Script executed: ```bash sed -n '100,155p' src/libs/ajm/decoder.h sed -n '270,325p' src/libs/ajm.cpp sed -n '400,470p' src/libs/ajm.cpp sed -n '1,120p' src/libs/ajm.cpp rg -n -F -- 'multiple_frames' src/libs/ajm src/libs/ajm.cpp tests ``` Repository: KytyPS5/KytyPS5 Length of output: 12861 --- Script executed: ```bash rg -n -F -e 'AjmDecodeInstance(' -e 'AJM_FLAG_RUN_MULTIPLE_FRAMES' -e 'AjmDecodeSplitInstance(' src/libs/ajm.cpp sed -n '500,680p' src/libs/ajm.cpp sed -n '680,860p' src/libs/ajm.cpp ``` Repository: KytyPS5/KytyPS5 Length of output: 14000 --- Web query: `Sony PlayStation AJM sceAjmBatchJobDecodeSingle multiple frames contract` Result: ``` <source_evidence> <source kind="search"> <title>音频与 3D 音频(NGS2、ajm、audio3d) - shadps4-emu/shadPS4</title> <location>https://opendeep.wiki/shadps4-emu/shadPS4/7-system-libraries/audio</location> <excerpt>citeturn0search2 [wordlim: 200] Crawled: yesterday; `ajm` 是 shadPS4 中 PS4 Audio Job Manager 子系统的实现,源码位于 `src/core/libraries/ajm/`,由调度器 `AjmContext` 与若干个 `AjmInstance` 组成;每个实例内部进一步拆出 batch job 与 codec-specific 状态。 ... `1 AjmJobFlags flags{}; 2 flags.version = 1; 3 flags.codec = static_cast&lt;u64&gt;(AjmCodecType::At9Dec); 4 flags.run_flags = AjmJobRunFlags::MultipleFrames; 5 flags.control_flags = AjmJobControlFlags::Initialize; 6 flags.sideband_flags = AjmJobSidebandFlags::GaplessDecode; 7 8// flags.raw 作为 `sceAjmBatchSubmit` 入口的 flags 参数` ### 模块组成 * `ajm.cpp` / `ajm.h`:注册符号和模块入口;`AjmContext` 维护 instance 表与统计信息。 * `ajm_context.cpp`:全局状态、操作句柄(`sceAjmCreateContext` / `sceAjmDestroyContext`)。 * `ajm_instance.cpp`:单个 ajm 实例生命周期、module 控制。 * `ajm_batch.cpp`:批作业模式(multiple frames、reset、resample)调度逻辑,是 hot path。 * `ajm_mp3.cpp` / `ajm_mp3.h`:MP3 解码器适配,基于 FFmpeg `libavcodec` / `libavcodec` 解析器 + `libswresample` 实现;通过 `AjmMp3Decoder` 类(继承 `AjmCodec`)把 MP3 流解析为 PCM 帧,支持 `S16` / `S32` / `Float` 三种输出格式,自动完成 `mp3 → target_format` 的重采样;同时支持 gapless(通过 `AjmInstanceGapless` 跟踪总样本/encoder delay)。关键类型: * `AjmDecMp3OflType`:MPEG 帧边信息(Lame/Vbri/Fgh)枚举。 * `AjmMp3CodecFlags`:`IgnoreOfl` / `VlcRewind` 等 codec 控制位。 * `AjmDecMp3ParseFrame`:解析单帧后回填的元数据(采样率、位率、通道、样本数、OFL 类型等)。 * `AjmSidebandDecMp3CodecInfo`:sideband 通道中回写的 MP3 codec 信息(CRC / 通道模式 / 模式扩展 / copyright / original / emphasis)。 * `ParseMp3Header(...)` / `ParseMp3Frame(...)`:解析单帧 MP3 流,填写 BB 级标记。 * `AjmCodec::GetFormat() / GetMinimumInputSize() / GetNextFrameSize() / ProcessData() / Reset()`:与 `ajm_codec.h` 的接口保持一致,由 `AjmMp3Decoder` 各自实现。 * `ajm_at9.cpp`:ATRAC9 解码器适配;与 MP3 路径实现一致的解码回调签名。 * `ajm_aac.cpp`:M4AAC 解码;其配置数据 (`ORBIS_AT9_CONFIG_DATA_SIZE = 4`) 用于把 ASC 参数注入解码器。 * `ajm_instance_statistics.cpp`:统计查询接口 (`AJM_INSTANCE_STATISTICS = 0x80000`)。 ### 控制与执行流程 游戏往 ajm 提交 job 时遵循以下顺序: 1. 创建 context(`sceAjmCreateContext`),得到一个 process-wide 的 handle。 2. 在该 context 下创建 instance(`sceAjmModuleCreate` / `AjmInstance::Create`),并选取 codec(`AjmCodecType`)。 3. 提交 batch(`sceAjmBatchSubmit` / `AjmBatch::Submit`):把若干 job + 输入 buffer 链接成链表。 4. 引擎迭代调用 `_ajm_instance_run` 一类入口推进 batch,运行时按需触发 `Reset`/`Initialize`/`Resample` 控制标志位对应的内部状态机。 5. 解码完成后把 PCM 写回作业输出 buffer,并把 sideband 元数据(`AjmSidebandFormat`、`AjmSidebandMFrame`、`AjmSidebandStream`)回写到游戏侧指针。 &gt; ajm 本身不直接控制音频输出——它的产物只是 PCM,与 `audioout` 协作由调用方负责。 ### MP3 解码器细节(`AjmMp3Decoder`) `ajm_mp3.cpp/h` 中以 `AjmMp3Decoder` 实现 MP3 路径,关键流程为: 1. 构造与资源:构造期调用 `avcodec_find_decoder(AV_CODEC_ID_MP3)` 拿到 FFmpeg MP3 解码器,并用 `avcodec_alloc_context3` / `avcodec_open2` 初始化上下文;用 `av_parser_init` 创建解析器上下文;`libswresample` 的 `SwrContext` 在需要时懒分配。 ## Usage Examples ### 1. audio3d 的 per-port 参数初始化 cpp `1// 获取默认 open parameters 2 OrbisAudio3dOpenParameters params{}; 3 sceAudio3dGetDefaultOpenParameters(&amp;params); 4 params.granularity = 512; // 48kHz 下约 10.7ms 5 params.max_objects = 32; 6 params.queue_depth = 4; 7 params.buffer_mode = OrbisAudio3dBufferMode::ORBIS_AUDIO3D_BUFFER_ADVANCE_AND_PUSH; 8 9// 创建 port 10 OrbisAudio3dPortId port_id; 11 sceAudio3dPortOpen(user_id, &amp;params, &amp;port_id);` &gt; Source: audio3d.h (结构体与符号定义参考) ### 2. ajm codec 槽位组装 flags cpp `1 AjmJobFlags flags{}; 2 flags.version = 1; 3 flags.codec = static_cast&lt;u64&gt;(AjmCodecType::At9Dec); 4 flags.run_flags = AjmJobRunFlags::MultipleFrames; 5 flags.control_flags = AjmJobControlFlags::Initialize; 6 flags.sideband_flags = AjmJobSidebandFlags::GaplessDecode; 7 8// flags.raw 作为 `sceAjmBatchSubmit` 入口的 flags 参数` &gt; Source: ajm.h ### 3. ajm 格式编码枚举选择 cpp * `s32 sceAjmBatchSubmit(...)`:提交一批解码作业。 * `s32 sceAjmBatchRun(...)`:推进一个或多个 job。 * `s32 sceAjmBatchGetResult(...)`:读取解码后的 PCM 与 sideband。 * `s32 sceAjmDecMp3ParseFrame(const u8* buf, u32 stream_size, int parse_ofl, AjmDecMp3ParseFrame* frame)`:在不创建 instance 的前提下解析一段 MP3 流,返回 `frame_size` / `num_channels` / `samples_per_channel` / `bitrate` / `sample_rate` / `encoder…[truncated]</excerpt> </source> <source kind="search"> <title>[Game tracker] BALAN WONDERWORLD (PPSA02058) · Issue #2882 · mattias800/prosper · GitHub</title> <location>GitHub issue 2882 in mattias800/prosper (link omitted to avoid creating a cross-reference)</location> <excerpt>citeturn1search0 [wordlim: 200] Published: 2 months ago; Crawled: last month; background, the game&#39;s own typeface, all 24 language buttons with English highlighted, and the ... * Boots, links and runs guest code in 232 ms. ... `sceNetResolverCreate`, `sceVoiceQoSInit`, `sceAjmBatchJobDecodeSingle`, `pthread_setschedparam`. # [Game tracker] BALAN WONDERWORLD (PPSA02058) #2882 New issue Copy link New issue Copy link Open Open [Game tracker] BALAN WONDERWORLD (PPSA02058)#2882 Copy link Labels game:balan-wonderworldBALAN WONDERWORLD (PPSA02058)BALAN WONDERWORLD (PPSA02058)tracker:gameLong-lived per-game compatibility milestone and evidence index; not a bugLong-lived per-game compatibility milestone and evidence index; not a bug ## Description mattias800 opened on Aug 21, 2026 Issue body actions ## Current milestone &gt; Updated 2026-08-22 — a pad route now gets past this screen. Read the comment thread &gt; for the measurement; the paragraph below records where a default, no-input boot stops, &gt; which is still accurate and is the control the routed result is measured against. &gt; Route: `prosper/scripts/balan-PPSA02058/reach-title-and-prologue.pad`. &gt; The rung is unchanged — the routed run reaches a map load, not a rendered world. Rung 2 — the game&#39;s own 4K language-select menu renders, and waits for Cross. First booted 2026-08-22 by the never-booted survey (`prosper/docs/NEVER_BOOTED_SURVEY_2026_08.md`). Boot is clean and fast: `[bootphase] BOOT_COMPLETE +232ms`, `[agc] register defaults requested for SDK version 7`. The title then composites its language-select screen at 3840x2160 — the theatre background, the game&#39;s own typeface, all 24 language buttons with English highlighted, and the `○ ✕ △ □ Change Language` / `Select Language` prompt bar. 17.9 fps while producing frames, 97% of a 137 s run active, guest alive at the end. This is the game&#39;s first-boot flow, not its title screen. It is placed at rung 2 on `COMPATIBILITY.md`&#39;s own bucket (&quot;title screen or menu reached&quot;), and the menu&#39;s own prompt bar names the button it is waiting for. Direct unmodified 4K capture: `assets/screenshots/balan-wonderworld-language-select.png`. | --- | --- Title | BALAN WONDERWORLD Title ID | `PPSA02058` Content ID | `EP0082-PPSA02058_00-BALANWW5E0000001` Required system software | `0x0250000000000000` Application size | 31 GB ### Engine: Unreal Engine 4 Derived from layout, not from the publisher: an `engine/` directory beside a project directory, a `ue4commandline.txt`, and a `.pak` archive — the standard UE4 packaged-build shape. No `.utoc`/`.ucas`, so this is a `.pak` build rather than IoStore. That matters for where to start: `docs/UE4_APR_IOSTORE_BRINGUP.md` covers the IoStore path, which this title does not use. The engine version is not present in the eboot strings, so none is recorded here rather than guessing one. Unreal is the largest cohort in this project and none of its titles has reached gameplay yet (see `COMPATIBILITY.md` § Where the titles accumulate). Shared UE4 findings live in `docs/CROSS_ENGINE_UE4.md`; check it before forming a hypothesis, and add to it if this title teaches something general. Project directory: `happiness/`. ## What works * Boots, links and runs guest code in 232 ms. * Composites at 3840x2160 through the live renderer at 17.9 fps while producing frames. * Renders the language-select menu completely: background art, typeface, all button labels including CJK, Thai, Greek, Cyrillic and Arabic, and the PlayStation glyph prompt bar. * Survives a 140 s run with no guest fault. ## Current blockers * #2932 — only ~18% of frames carry the menu; the rest are a flat white 4K clear. Measured on a 1 s grid over 110 samples: content at t = 16, 18, 32, 33, 36, 45, 49, 50, 54, 56, 60, 69, 72, 73, 77, 82, 86, 98, 103, 105 s, with no cadence. Coarser 7 s and 5 s grids reported &quot;3 of 20&quot; and &quot;3 of 24&quot;…[truncated]</excerpt> </source> <source kind="search"> <title>[Game tracker] BALAN WONDERWORLD (PPSA02058) · Issue #2882 · mattias800/prosper · GitHub</title> <location>GitHub issue 2882 in mattias800/prosper (link omitted to avoid creating a cross-reference)</location> <excerpt>citeturn2search2 [wordlim: 200] Published: 2 months ago; Crawled: last month; `sceNetResolverCreate`, `sceVoiceQoSInit`, `sceAjmBatchJobDecodeSingle`, `pthread_setschedparam`. `sceNetResolverCreate`, `sceVoiceQoSInit`, `sceAjmBatchJobDecodeSingle`, `pthread_setschedparam`. ## Reproduction route Frontend `tools/screenshot`, default route, no pad input, on master `bffa40d4`, Linux / AMD Radeon 8060S (RADV STRIX_HALO): PROSPER_RENDER=1 PROSPER_GUEST_ARGS=-force-gfx-direct PROSPER_BOOTPHASE=1 \ SDL_VIDEODRIVER=offscreen \ timeout -k 10 260 ./prosper/build-linux/screenshot &lt;DUMP_ROOT&gt;/PPSA02058-app0 \ --seconds 7 --count 20 --timeout 170 --out &lt;OUT_DIR&gt; \ --allow-guest-fault --no-stop-after-guest-fault The outer bound and `--timeout` are deliberately different values: `--timeout` cannot bound a boot (instrument trap 214), so a run that produces neither `[shot] done:` nor `[shot] timeout` was killed from outside and its silence is not evidence. To measure the content duty cycle rather than a grid artefact, use `--seconds 1 --count 110`. ## Ruled out * #1588 / `PROSPER_CB_EFC_NO_COLOR` is not the mechanism here. The `[gpu] resolve_pipeline_state` diagnostic reports MODE=0 (DISABLE) </excerpt> </source> <source kind="search"> <title>音频与 3D 音频(NGS2、ajm、audio3d) - shadps4-emu/shadPS4</title> <location>https://opendeep.wiki/shadps4-emu/shadPS4/7-system-libraries/audio</location> <excerpt>citeturn2search8 [wordlim: 200] Crawled: yesterday; `1 struct OrbisMusicPlayerPlayStatusExtension { 2 u64 size; // +0x00 (0x48) 3 u32 error_code; // +0x08 (0: ok, non-zero: error) 4 u32 play_state; // +0x0c (0: playing, 1: paused, 2: stopped) 5 u64 total_duration_s; // +0x10 6 u64 current_time_s; // +0x18 7 u32 tracklist_id; // +0x20 8 u32 track_index; // +0x24 9 u32 play_index; // +0x28 10 u32 total_track_count; // +0x2c 11 u32 volume; // +0x30 (0 - 25) 12 u32 repeat_mode; // +0x34 (0: off, 1: all, 2: one) 13 u32 shuffle_mode; // +0x38 14 u32 can_skip_next; // +0x3c 15 u32 can_skip_previous; // +0x40 16 u32 is_loading; // +0x44 17}; 18 static_assert(sizeof(OrbisMusicPlayerPlayStatusExtension) == 0x48); 19 20 struct SceMusicPlayerServicePlayStatus { 21 u32 result; // +0x00 (0: ok) 22 u32 play_status; // +0x04 (0: stopped, 1: playing, 2: paused) 23 u32 track_index; // +0x08 24 u32 tracklist_id; // +0x0c 25 u64 playback_time; // +0x10 26 u32 shuffle; // +0x18 27 u32 repeat; // +0x1c (0: off, 1: all, 2: one) 28}; 29 static_assert(sizeof(SceMusicPlayerServicePlayStatus) == 0x20);` </excerpt> </source> <source kind="search"> <title>Ghost of Yōtei (PPSA26344) · boykopovar AnyPS5 · Discussion #675 · GitHub</title> <location>GitHub discussion 675 in boykopovar/AnyPS5 (link omitted to avoid creating a cross-reference)</location> <excerpt>citeturn0search0 [wordlim: 200] Crawled: today; * Next non-GPU stop: `sceAjmBatchJobControl`, when the menu music starts. ... It does not overlap feat(ajm): implement sceAjmBatchJobDecodeSplit #867, which adds `sceAjmBatchJobDecodeSplit` and touches the same files. ## Update 2026-10-06 (7): the boot screen renders Same host and testing branch as the previous update, with the same local diagnostic that skips only the six empty-table `GetBufferResource` dispatches. * The &quot;black&quot; frames were a fade-in. In the previous update every captured frame was black. A frame dump shows brightness rising frame by frame to the &quot;Sony Interactive Entertainment presents&quot; card and its copyright line, rendered by the title (capture at 960x540). * Still slow. It runs at about 1 frame per second. Finding out where the ~100 ms per frame goes is in progress. * Next non-GPU stop: `sceAjmBatchJobControl`, when the menu music starts. A pull request is in progress. It does not overlap feat(ajm): implement sceAjmBatchJobDecodeSplit #867, which adds `sceAjmBatchJobDecodeSplit` and touches the same files. * What this needs from upstream: * the six skipped dispatches need runtime-indexed buffer descriptors (see the notes on perf(agc): baseline shader recompilation on registration #639); * Correction to update 7: * The boot screen there was read from the title&#39;s own render target. In a normal run the window stays black: the title draws the &quot;Sony Interactive Entertainment presents&quot; card every frame, but the driver presents the clear colour (cause below). * At about 1 fps a frame takes about 1 s, not ~100 ms. * Why the window is black. * Every frame, the title&#39;s own retile compute shader copies its colour target&#39;s DCC keys into the display buffer&#39;s keys. * The driver writes &quot;uncompressed&quot; keys for that target only at write-back, which happens after the retile. So the display keys still hold the 0x00 clear code, and the presenter shows the clear colour. * Storing the keys when the target is first written makes the card visible in a local probe. A pull request is in progress. * Menu music: feat(ajm): implement sceAjmBatchJobControl #884 implements `sceAjmBatchJobControl`. With it, the title: * creates two ATRAC9 voices, runs five control jobs and about 950 decodes; * writes its savedata, and moves on to new, larger frames. * Next stop, about 10 minutes in: `AGC driver: null or misaligned address`. The arguments match the 0x60-byte, 8-byte-aligned check on a shader header that the title registers at a 4-byte-aligned address (0x801e374cc4). Being checked. * Where the ~1 s per frame goes: * GPU: one compute shader (0x800036e100, light culling, 240x135 groups of 16x16) takes 600-650 ms per frame. Its light loops run zero times, so the cost is in the translation. Profiling is in progress. * CPU: recording takes about 400 ms per frame, at about 3.7 ms per dispatch and 4.1 ms per draw; most draw recipe lookups miss. Celegans12 Oct 6, 2026 </excerpt> </source> <omitted_sources count="29">Additional source records were omitted from this bounded result.</omitted_sources> </source_evidence> Citations: - 1: GitHub issue 2882 in mattias800/prosper (link omitted to avoid creating a cross-reference) - 2: https://opendeep.wiki/shadps4-emu/shadPS4/7-system-libraries/audio?utm_source=openai ``` --- </dd> </dl> </details> **Stop a single-frame call after draining pending PCM.** `AjmBatchJobDecodeSingle` passes `false` for `multiple_frames`. When `WritePcm` empties `m_pcm_buffer`, the pending-PCM path continues into the input loop without checking that flag. A single-frame call can therefore write the remainder of one packet, consume the next packet, and write part of it. Return after draining pending PCM when `multiple_frames` is `false`. Preserve the existing multi-frame behavior. <details> <summary>Suggested fix</summary> <dl> <dd> ```diff + const bool had_pending_pcm = !m_pcm_buffer.empty(); WritePcm(output, output_size, gapless, &result); - if (!m_pcm_buffer.empty()) { + if (!m_pcm_buffer.empty() || (had_pending_pcm && !multiple_frames)) { if (result.output_written == 0) { result.result = AJM_RESULT_NOT_ENOUGH_ROOM; } return result; } ``` </dd> </dl> </details> <!-- suggestion_start --> <details> <summary>Committable suggestion</summary> <dl> <dd> > ‼️ **IMPORTANT** > Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements. ```suggestion const bool had_pending_pcm = !m_pcm_buffer.empty(); WritePcm(output, output_size, gapless, &result); if (!m_pcm_buffer.empty() || (had_pending_pcm && !multiple_frames)) { ``` </dd> </dl> </details> <!-- suggestion_end --> <!-- fingerprinting:phantom:medusa:wombat --> <!-- cr-indicator-types:potential_issue --> <!-- cr-comment:v1:7d524017ddfac8500164e0e4 --> <!-- This is an auto-generated comment by CodeRabbit -->
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-26 07:50 UTC · original · reviewed

Actionable comments posted: 1


Review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between f90a8b1589 and e0508eebc9cf4e870907d157bbe6caa5a8f206c3.

Files selected for processing: 3
  • CMakeLists.txt
  • src/libs/ajm/opus_decoder.h
  • tests/AjmOpusTests.cpp

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.

**@⁠coderabbitai[bot]** on GitHub · 2026-10-26 07:50 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1914#pullrequestreview-5648852363) · **reviewed** <!-- coderabbit-ai-generated:v1 --> **Actionable comments posted: 1** --- <details> <summary><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/info.svg" width="16" height="16" align="absmiddle" alt=""></picture> Review info</summary> <dl> <dd> <details> <summary><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/cog-dark.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/cog.svg" width="16" height="16" align="absmiddle" alt=""></picture> Run configuration</summary> <dl> <dd> - **Source mode**: Auto - **Repository**: [KytyPS5/KytyPS5](<https://github.com/KytyPS5/KytyPS5>) - **Branch**: [main](<https://github.com/KytyPS5/KytyPS5/tree/main>) - **File**: [.coderabbit.yaml](<https://github.com/KytyPS5/KytyPS5/blob/f90a8b1589d08ef48d933bd472d4ba864addaefb/.coderabbit.yaml>) - **Commit**: [f90a8b1](<https://github.com/KytyPS5/KytyPS5/commit/f90a8b1589d08ef48d933bd472d4ba864addaefb>) - **Layers**: Repository YAML - **Review profile**: CHILL - **Plan**: Advanced - **Run ID**: `d3239bd1-d648-4be5-bca7-e003515a4478` </dd> </dl> </details> <details> <summary><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/git-commit-horizontal-dark.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/git-commit-horizontal.svg" width="16" height="16" align="absmiddle" alt=""></picture> Commits</summary> <dl> <dd> Reviewing files that changed from the base of the PR and between f90a8b1589d08ef48d933bd472d4ba864addaefb and e0508eebc9cf4e870907d157bbe6caa5a8f206c3. </dd> </dl> </details> <details> <summary><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/file-plus-corner-dark.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/file-plus-corner.svg" width="16" height="16" align="absmiddle" alt=""></picture> Files selected for processing: 3</summary> <dl> <dd> * `CMakeLists.txt` * `src/libs/ajm/opus_decoder.h` * `tests/AjmOpusTests.cpp` </dd> </dl> </details> **Included review availability:** This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review. </dd> </dl> </details> <!-- This is an auto-generated comment by CodeRabbit for review status --> <!-- coderabbit-review-publication v1 publication=9fc149f3-4329-4330-a4e1-9ecace095211 attempt=20594ec0-c147-4467-8cbd-77c31c86a384 batch=1/1 -->
Author
Owner

@⁠Nmzik on GitHub · 2026-10-28 18:45 UTC · original

@⁠Cosmo PPSA game code?

**@⁠Nmzik** on GitHub · 2026-10-28 18:45 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1914#issuecomment-6477605944) @⁠Cosmo PPSA game code?
Author
Owner

@⁠Cosmo on GitHub · 2026-10-28 18:50 UTC · original

@⁠Cosmo PPSA game code?

PPSA33626 works best to demonstrate.
In-game there was basically no sound

**@⁠Cosmo** on GitHub · 2026-10-28 18:50 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1914#issuecomment-6477721037) > @⁠Cosmo PPSA game code? PPSA33626 works best to demonstrate. In-game there was basically no sound
@ -0,0 +41,4 @@
info.ratio = static_cast<float>(m_ratio);
info.num_samples = m_end && m_position >= Samples()
? -1
: static_cast<int32_t>(std::ceil(Samples() - m_position));
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-28 20:24 UTC · original

Minor · Functional Correctness · Quick win

Clamp num_samples to 0 unless the stream has ended.

GetInfo() can report a negative num_samples before END is set. m_position can exceed Samples() after the last buffered sample is consumed. Compact() removes only Samples() from the position, so the remainder stays and Samples() - m_position becomes negative.

Example: a stream has 959 source samples (960 with skip 1) and the ratio is 2. The last write moves m_position to 960, and Compact() leaves 1. GetInfo() then returns ceil(0 - 1) = -1. This is the same value as the end-of-stream marker.

tests/AjmResampleTests.cpp treats num_samples < 0 as "stream drained". A caller can therefore see a false end-of-stream.

Proposed fix
--- "a/src/libs/ajm/resampler.h"
+++ "b/src/libs/ajm/resampler.h"
@@ -39,9 +39,10 @@
 	[[nodiscard]] AjmSidebandResampleInfo GetInfo() const {
 		AjmSidebandResampleInfo info;
 		info.ratio       = static_cast<float>(m_ratio);
-		info.num_samples = m_end && m_position >= Samples()
-		                       ? -1
-		                       : static_cast<int32_t>(std::ceil(Samples() - m_position));
+		info.num_samples =
+		    m_end && m_position >= Samples()
+		        ? -1
+		        : static_cast<int32_t>(std::max(0.0, std::ceil(Samples() - m_position)));
 		return info;
 	}
 
Committable suggestion

IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

		info.num_samples =
		    m_end && m_position >= Samples()
		        ? -1
		        : static_cast<int32_t>(std::max(0.0, std::ceil(Samples() - m_position)));
**@⁠coderabbitai[bot]** on GitHub · 2026-10-28 20:24 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1914#discussion_r4405687835) <!-- coderabbit-ai-generated:v1 --> **<picture><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/amber-16.svg" width="16" height="16" align="absmiddle" alt=""></picture> Minor** · **Functional Correctness** · **Quick win** **Clamp `num_samples` to 0 unless the stream has ended.** `GetInfo()` can report a negative `num_samples` before END is set. `m_position` can exceed `Samples()` after the last buffered sample is consumed. `Compact()` removes only `Samples()` from the position, so the remainder stays and `Samples() - m_position` becomes negative. Example: a stream has 959 source samples (960 with `skip` 1) and the ratio is 2. The last write moves `m_position` to 960, and `Compact()` leaves 1. `GetInfo()` then returns `ceil(0 - 1) = -1`. This is the same value as the end-of-stream marker. `tests/AjmResampleTests.cpp` treats `num_samples < 0` as "stream drained". A caller can therefore see a false end-of-stream. <details> <summary>Proposed fix</summary> <dl> <dd> ```diff --- "a/src/libs/ajm/resampler.h" +++ "b/src/libs/ajm/resampler.h" @@ -39,9 +39,10 @@ [[nodiscard]] AjmSidebandResampleInfo GetInfo() const { AjmSidebandResampleInfo info; info.ratio = static_cast<float>(m_ratio); - info.num_samples = m_end && m_position >= Samples() - ? -1 - : static_cast<int32_t>(std::ceil(Samples() - m_position)); + info.num_samples = + m_end && m_position >= Samples() + ? -1 + : static_cast<int32_t>(std::max(0.0, std::ceil(Samples() - m_position))); return info; } ``` </dd> </dl> </details> <!-- suggestion_start --> <details> <summary>Committable suggestion</summary> <dl> <dd> > <picture><img src="https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-warning.svg" width="20" height="20" align="absmiddle" alt=""></picture> **IMPORTANT** > Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements. ```suggestion info.num_samples = m_end && m_position >= Samples() ? -1 : static_cast<int32_t>(std::max(0.0, std::ceil(Samples() - m_position))); ``` </dd> </dl> </details> <!-- suggestion_end --> <!-- fingerprinting:phantom:medusa:beignet55 --> <!-- cr-indicator-types:potential_issue --> <!-- cr-comment:v1:a7b808daf0a1770644186ef4 --> <!-- This is an auto-generated comment by CodeRabbit -->
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-28 20:24 UTC · original · reviewed

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to GitHub limitations.

⚠️ Outside diff range comments (1)

Minor · Reset the resampler with the decoder on AJM_FLAG_CONTROL_RESET. · ajm.cpp:547-551

src/libs/ajm.cpp:547-551
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Reset the resampler with the decoder on AJM_FLAG_CONTROL_RESET.

AjmBatchJobClearContext reaches this branch. The branch resets the decoder but not the per-instance AjmResampler. Buffered PCM can be emitted before the new stream, and m_end can prevent new input from being decoded.

Proposed fix
 	if ((flags & AJM_FLAG_CONTROL_RESET) != 0) {
 		state->gapless.Reset();
 		decoder->Reset();
+		(void)state->resampler.SetParameters(
+		    0, 0, AJM_RESAMPLE_FLAG_RESET | AJM_RESAMPLE_FLAG_IGNORE_RATIO_PARAMETER);
 		result = decoder->MakeResult();
 	}

Source: Learnings


Review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between e0508eebc9cf4e870907d157bbe6caa5a8f206c3 and edc97ec0ea.

Files selected for processing: 5
  • CMakeLists.txt
  • src/libs/ajm.cpp
  • src/libs/ajm/decoder.h
  • src/libs/ajm/resampler.h
  • tests/AjmResampleTests.cpp

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

**@⁠coderabbitai[bot]** on GitHub · 2026-10-28 20:24 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1914#pullrequestreview-5689197503) · **reviewed** <!-- coderabbit-ai-generated:v1 --> **Actionable comments posted: 1** > [!CAUTION] > Some comments are outside the diff and can’t be posted inline due to GitHub limitations. > > **⚠️ Outside diff range comments (1)** > > <details> > <summary><strong><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/amber-16.svg" width="16" height="16" align="absmiddle" alt=""></picture> Minor</strong> · Reset the resampler with the decoder on <code>AJM_FLAG_CONTROL_RESET</code>. · <code>ajm.cpp:547-551</code></summary><blockquote> > <dl> > <dd> > > `src/libs/ajm.cpp:547-551` > **🎯 Functional Correctness** | **🟡 Minor** | **⚡ Quick win** > > **Reset the resampler with the decoder on `AJM_FLAG_CONTROL_RESET`.** > > `AjmBatchJobClearContext` reaches this branch. The branch resets the decoder but not the per-instance `AjmResampler`. Buffered PCM can be emitted before the new stream, and `m_end` can prevent new input from being decoded. > > <details> > <summary>Proposed fix</summary> > <dl> > <dd> > > ```diff > if ((flags & AJM_FLAG_CONTROL_RESET) != 0) { > state->gapless.Reset(); > decoder->Reset(); > + (void)state->resampler.SetParameters( > + 0, 0, AJM_RESAMPLE_FLAG_RESET | AJM_RESAMPLE_FLAG_IGNORE_RATIO_PARAMETER); > result = decoder->MakeResult(); > } > ``` > > </dd> > </dl> > </details> > > <!-- cr-comment:v1:46f3a9273fe1b89c9c19cc1e --> > > _Source: Learnings_ > > </dd> > </dl> > </blockquote></details> --- <details> <summary><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/info.svg" width="16" height="16" align="absmiddle" alt=""></picture> Review info</summary> <dl> <dd> <details> <summary><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/cog-dark.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/cog.svg" width="16" height="16" align="absmiddle" alt=""></picture> Run configuration</summary> <dl> <dd> - **Source mode**: Auto - **Repository**: [KytyPS5/KytyPS5](<https://github.com/KytyPS5/KytyPS5>) - **Branch**: [main](<https://github.com/KytyPS5/KytyPS5/tree/main>) - **File**: [.coderabbit.yaml](<https://github.com/KytyPS5/KytyPS5/blob/c67352d5d6dc6fc3fd375deed5c1a89b3e33974e/.coderabbit.yaml>) - **Commit**: [c67352d](<https://github.com/KytyPS5/KytyPS5/commit/c67352d5d6dc6fc3fd375deed5c1a89b3e33974e>) - **Layers**: Repository YAML - **Review profile**: CHILL - **Plan**: Advanced - **Run ID**: `10fadde3-95d4-44d4-88b1-6134ebcd9ada` </dd> </dl> </details> <details> <summary><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/git-commit-horizontal-dark.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/git-commit-horizontal.svg" width="16" height="16" align="absmiddle" alt=""></picture> Commits</summary> <dl> <dd> Reviewing files that changed from the base of the PR and between e0508eebc9cf4e870907d157bbe6caa5a8f206c3 and edc97ec0ea227d55c9799ffd4bea8b3559b11e30. </dd> </dl> </details> <details> <summary><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/file-plus-corner-dark.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/file-plus-corner.svg" width="16" height="16" align="absmiddle" alt=""></picture> Files selected for processing: 5</summary> <dl> <dd> * `CMakeLists.txt` * `src/libs/ajm.cpp` * `src/libs/ajm/decoder.h` * `src/libs/ajm/resampler.h` * `tests/AjmResampleTests.cpp` </dd> </dl> </details> **Included review availability:** This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review. </dd> </dl> </details> <!-- This is an auto-generated comment by CodeRabbit for review status --> <!-- coderabbit-review-publication v1 publication=679a2177-9137-431d-b151-5abb9388550a attempt=5f1219d2-5ec0-4d81-949c-777813fce6e1 batch=1/1 -->
This discussion has been locked. Commenting is limited to contributors.
No description provided.