fix(avplayer): read the PS5 SceAvPlayerInitDataEx layout #2159

Merged
Angel21PC merged 1 commit from upstream-pr/2159 into main 2026-10-09 21:43:32 +00:00
Angel21PC commented 2026-10-09 10:16:17 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Angel21PC on 2026-10-09T10:16:17Z.


What

PS5 titles pass a 0x230-byte SceAvPlayerInitDataEx to sceAvPlayerInitEx (this_size 0x230). It matches the PS4 layout (AvPlayerInitDataEx) up to debug_level; then come:

  • auto start, a byte at 0x74;
  • nine 0x30-byte thread parameter blocks (priority, stack size, affinity) at 0x78-0x228;
  • the output video frame buffer count at 0x228.

sceAvPlayerInitEx read auto start and the buffer count at their PS4 offsets, 0xa8 and 0xa4. In the PS5 layout, 0xa8 is the video decoder thread priority and 0xa4 lies in the audio decoder block. A title that sets thread priorities therefore had its video started on its own, and its buffer count was ignored.

With this_size 0x230 or more, both fields are now read at the PS5 offsets. Smaller structures are read as before, and the thread parameters are still ignored.

Where the layout comes from:

  • KytyPS5, prosper, SharpProspero and sharpemu agree on it.
  • Poppy Playtime: Chapter 4 (PPSA25063) fills it the same way. It clears the structure, sets this_size 0x230, writes auto start 0 as a byte at 0x74, the nine thread blocks with priority 700 and its buffer count at 0x228, and starts playback itself with sceAvPlayerStart.
  • No title seen sets auto start, so the layout is recorded in TechnicalDebt.

Tested

Windows 11 Pro, Intel Core i7-12700K, NVIDIA GeForce RTX 4070, 32 GB, MinGW-w64 GCC 15.2.0.

  • guest_avplayer (core/libs/tests/GuestAvPlayer.cpp, TestPs5ExtendedInitLayout) builds a 0x230-byte structure with 3 video frame buffers at 0x228 and checks two cases:

    • auto start 0 at 0x74 and nonzero bytes from 0x78 on, which covers the PS4 offsets: the player reports ready and does not start until sceAvPlayerStart;
    • auto start 1 at 0x74 and zeroes elsewhere: it starts by itself.

    Both cases check that 3 + 4 decode-ahead video buffers are allocated. The test fails on main ("ready event missing", because a thread parameter was read as auto start) and passes with this change.

  • tools/check_conventions.py --base origin/main passes.

  • Poppy Playtime: Chapter 4: the Mob Entertainment intro video plays instead of starting on its own and stopping at once.

  • Not tested: Linux.

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:4799068623 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2159). Originally posted by [Angel21PC](https://github.com/Angel21PC) on 2026-10-09T10:16:17Z. --- ### What PS5 titles pass a 0x230-byte `SceAvPlayerInitDataEx` to `sceAvPlayerInitEx` (`this_size` 0x230). It matches the PS4 layout (`AvPlayerInitDataEx`) up to `debug_level`; then come: - auto start, a byte at 0x74; - nine 0x30-byte thread parameter blocks (priority, stack size, affinity) at 0x78-0x228; - the output video frame buffer count at 0x228. `sceAvPlayerInitEx` read auto start and the buffer count at their PS4 offsets, 0xa8 and 0xa4. In the PS5 layout, 0xa8 is the video decoder thread priority and 0xa4 lies in the audio decoder block. A title that sets thread priorities therefore had its video started on its own, and its buffer count was ignored. With `this_size` 0x230 or more, both fields are now read at the PS5 offsets. Smaller structures are read as before, and the thread parameters are still ignored. Where the layout comes from: - [KytyPS5](https://github.com/KytyPS5/KytyPS5/blob/7b9997baea0d385e9e8fc2bd3abeb02110bc4148/src/libs/avPlayer.cpp#L156-L176), [prosper](https://github.com/mattias800/prosper/blob/eec8d766b495c48f9838ada887b77cb235d37d89/prosper/src/hle/video/avplayer.cpp#L171-L180), [SharpProspero](https://github.com/SvenGDK/SharpProspero/blob/5dfdb4b0b166e83dc9ae275001afb695f12c7174/src/SharpProspero/Interop/Media/AvPlayer.cs#L618-L677) and [sharpemu](https://github.com/sharpemu/sharpemu/blob/47d4c07a8d3035a269ce404b74ffdc71c962b019/src/SharpEmu.Libs/AvPlayer/AvPlayerExports.cs#L2689-L2699) agree on it. - Poppy Playtime: Chapter 4 (PPSA25063) fills it the same way. It clears the structure, sets `this_size` 0x230, writes auto start 0 as a byte at 0x74, the nine thread blocks with priority 700 and its buffer count at 0x228, and starts playback itself with `sceAvPlayerStart`. - No title seen sets auto start, so the layout is recorded in [TechnicalDebt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/TechnicalDebt.md#unknown-function-info). ### Tested Windows 11 Pro, Intel Core i7-12700K, NVIDIA GeForce RTX 4070, 32 GB, MinGW-w64 GCC 15.2.0. - `guest_avplayer` (`core/libs/tests/GuestAvPlayer.cpp`, `TestPs5ExtendedInitLayout`) builds a 0x230-byte structure with 3 video frame buffers at 0x228 and checks two cases: - auto start 0 at 0x74 and nonzero bytes from 0x78 on, which covers the PS4 offsets: the player reports ready and does not start until `sceAvPlayerStart`; - auto start 1 at 0x74 and zeroes elsewhere: it starts by itself. Both cases check that 3 + 4 decode-ahead video buffers are allocated. The test fails on `main` ("ready event missing", because a thread parameter was read as auto start) and passes with this change. - `tools/check_conventions.py --base origin/main` passes. - Poppy Playtime: Chapter 4: the Mob Entertainment intro video plays instead of starting on its own and stopping at once. - Not tested: Linux. ### 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
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!2159
No description provided.