feat(ajm): decode Opus mapping family 255 with several channels #5517

Merged
ps54all merged 2 commits from upstream-pr/5517 into main 2026-10-14 21:48:07 +00:00
ps54all commented 2026-10-13 22:03:38 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by ps54all on 2026-10-13T22:03:38Z.


Depends on #5075: this branch is built on its head 485f638a5; only the last commit belongs to this PR.

What

#5075 accepts Opus mapping family 255 for one channel. Metal Gear Solid 4 initializes its intro movie's decoder with 4, 48000, 255 (12 bytes, nothing after the family), so the stream count and channel mapping that family 255 needs (RFC 7845 §5.1.1) are not in the initialization words.

  • A family 255 instance with more than one channel now opens its decoder on the first packet.
  • That multistream packet's self-delimited streams are counted (RFC 6716 appendix B, codes 0-3 with padding). Each stream's TOC stereo flag marks it as coupled (coupled streams come first in a multistream packet), and the channels map in order. FFmpeg then gets a family 255 OpusHead with that layout.
  • A packet whose streams do not add up to the channel count throws. Other families above 1 still throw.
  • The debt entry records that the layout is inferred, not read from the console.

Tested

Windows 11, RTX 3080, WinLibs GCC 15.2.0 r7, Release.

  • guest_ajm gains TestOpusMultistreamFamily255. #5075's test packets are stereo, so each is turned into a two-stream packet (a self-delimited copy followed by the packet). A 4, 48000, 255 instance must then decode it to four channels, both pairs sample-equal to a 2, 48000, 0 decode of the original, with the full input consumed. #5075's refusal of 2, 48000, 255 is replaced by this; 1, 48000, 2 is still refused. Without the change the test aborts (0xc0000409); with it, it passes.
  • check_conventions.py --base origin/main passes.
  • Metal Gear Solid 4: Guns of the Patriots, Master Collection Version (PPSA18194): its intro movie stopped at sceAjmBatchJobInitialize (Opus mapping family ...) not implemented. With this (plus #5411, #5514, #5515, #5425) it plays with sound, and the game reaches gameplay (about 3 fps).

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; 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
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: #5075
  • Unblocks: PPSA18194
  • GPUs tested: n/a
  • AI-assisted: yes (Claude Code); the runs are on my machine.

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4850060756 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5517). Originally posted by [ps54all](https://github.com/ps54all) on 2026-10-13T22:03:38Z. --- **Depends on #5075**: this branch is built on its head `485f638a5`; only the last commit belongs to this PR. ### What #5075 accepts Opus mapping family 255 for one channel. Metal Gear Solid 4 initializes its intro movie's decoder with `4, 48000, 255` (12 bytes, nothing after the family), so the stream count and channel mapping that family 255 needs ([RFC 7845 §5.1.1](https://datatracker.ietf.org/doc/html/rfc7845#section-5.1.1)) are not in the initialization words. - A family 255 instance with more than one channel now opens its decoder on the first packet. - That multistream packet's self-delimited streams are counted ([RFC 6716 appendix B](https://datatracker.ietf.org/doc/html/rfc6716#appendix-B), codes 0-3 with padding). Each stream's TOC stereo flag marks it as coupled (coupled streams come first in a multistream packet), and the channels map in order. FFmpeg then gets a family 255 `OpusHead` with that layout. - A packet whose streams do not add up to the channel count throws. Other families above 1 still throw. - The debt entry records that the layout is inferred, not read from the console. ### Tested Windows 11, RTX 3080, WinLibs GCC 15.2.0 r7, Release. - `guest_ajm` gains `TestOpusMultistreamFamily255`. #5075's test packets are stereo, so each is turned into a two-stream packet (a self-delimited copy followed by the packet). A `4, 48000, 255` instance must then decode it to four channels, both pairs sample-equal to a `2, 48000, 0` decode of the original, with the full input consumed. #5075's refusal of `2, 48000, 255` is replaced by this; `1, 48000, 2` is still refused. Without the change the test aborts (`0xc0000409`); with it, it passes. - `check_conventions.py --base origin/main` passes. - Metal Gear Solid 4: Guns of the Patriots, Master Collection Version (PPSA18194): its intro movie stopped at `sceAjmBatchJobInitialize (Opus mapping family ...) not implemented`. With this (plus #5411, #5514, #5515, #5425) it plays with sound, and the game reaches gameplay (about 3 fps). ### 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 - [x] Unimplemented paths throw; silent stubs are listed under Silent stubs in their library's technical debt file - [x] No notes, investigation `.md` files or images added to the repository - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: #5075 - [x] Unblocks: PPSA18194 - [x] GPUs tested: n/a - [x] AI-assisted: yes (Claude Code); the runs are on my machine. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
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!5517
No description provided.