fix(ajm): decode an ATRAC9 run's whole input and follow gapless segments #2052

Merged
esatturan merged 1 commit from upstream-pr/2052 into main 2026-10-10 05:36:10 +00:00
esatturan commented 2026-10-09 06:00:10 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by esatturan on 2026-10-09T06:00:10Z.


What

  • An ATRAC9 run job stops after the gapless total of output samples, counted from the start of the current segment, and leaves the rest of its input unconsumed. The next run starts the next segment with the decoder as it is, without a second skip. A reset (SetGaplessDecode with the reset flag, ClearContext, initialization) starts a new segment.
  • An ATRAC9 run job decodes its whole input with or without RUN_MULTIPLE_FRAMES: FMOD in PPSA29141 puts two run jobs in one batch, with the second's input right after the whole of the first's. MP3 and Opus run jobs are unchanged.
  • FMOD sets a gapless total shorter than a sound's frames and reads the frames after it on later runs. With the output held at the total, its stream reader waited forever and the last buffer looped.
  • Both are recorded in TechnicalDebt.

Tested

Windows 11, i7-13650HX, RTX 4070 Laptop, MinGW-w64 GCC 15.2.

  • guest_ajm: TestAt9GaplessSegments (a total of 512 samples over a 1024-sample superframe: the first run stops after two frames with input left, the second gets the two after it) and TestAt9RunDecodesWholeInput. Both fail on main.
  • Full ctest on current main (c6e3aa76) merged with this branch, the other LEGO Party! PRs and #1482: 547/547 pass. On Windows, main's libs step currently fails with duplicate patched export name: LibwuIonIBw: #1714 added APS5_EXPORTs for sceVideoOutAddVrrActiveStatusEvent and sceVideoOutAddVrrStatusFlagsPrivilege, whose names the NID table already maps. Those two lines were removed locally for the run.
  • PPSA29141: 148 s of the mixed output from intro to menus with no repeated audio (before: music and voice lines looped). Title runs were on the base these PRs had before review. PPSA29141 was converted with #846's --module-dir for its plugins, and #846 no longer merges with today's main, so the title was not converted and run again on it.

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 (Claude Code)
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4796624270 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2052). Originally posted by [esatturan](https://github.com/esatturan) on 2026-10-09T06:00:10Z. --- ### What - An ATRAC9 run job stops after the gapless total of output samples, counted from the start of the current segment, and leaves the rest of its input unconsumed. The next run starts the next segment with the decoder as it is, without a second skip. A reset (`SetGaplessDecode` with the reset flag, `ClearContext`, initialization) starts a new segment. - An ATRAC9 run job decodes its whole input with or without `RUN_MULTIPLE_FRAMES`: FMOD in PPSA29141 puts two run jobs in one batch, with the second's input right after the whole of the first's. MP3 and Opus run jobs are unchanged. - FMOD sets a gapless total shorter than a sound's frames and reads the frames after it on later runs. With the output held at the total, its stream reader waited forever and the last buffer looped. - Both are recorded in TechnicalDebt. ### Tested Windows 11, i7-13650HX, RTX 4070 Laptop, MinGW-w64 GCC 15.2. - `guest_ajm`: `TestAt9GaplessSegments` (a total of 512 samples over a 1024-sample superframe: the first run stops after two frames with input left, the second gets the two after it) and `TestAt9RunDecodesWholeInput`. Both fail on `main`. - Full `ctest` on current `main` (`c6e3aa76`) merged with this branch, the other LEGO Party! PRs and #1482: 547/547 pass. On Windows, `main`'s `libs` step currently fails with `duplicate patched export name: LibwuIonIBw`: #1714 added `APS5_EXPORT`s for `sceVideoOutAddVrrActiveStatusEvent` and `sceVideoOutAddVrrStatusFlagsPrivilege`, whose names the NID table already maps. Those two lines were removed locally for the run. - PPSA29141: 148 s of the mixed output from intro to menus with no repeated audio (before: music and voice lines looped). Title runs were on the base these PRs had before review. PPSA29141 was converted with #846's `--module-dir` for its plugins, and #846 no longer merges with today's `main`, so the title was not converted and run again on it. ### 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 (Claude Code)
oneandonlydean commented 2026-10-09 09:22:58 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-09T09:22:58Z.


Three things before this can go in:

  • Drop the code comments in Ajm.cpp (the segmentSamples and RunAt9 blocks) and in AudioOut2Context.cpp.
  • Drop the APS5_DUMP_AUDIO dump and the new batch traces; they're a separate change.
  • Add a guest_ajm case that fails on main: a gapless total shorter than the frames, then a second run that gets the frames after it.

It conflicts with main in TechnicalDebt now, so please rebase when you push.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6078130959 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2052#issuecomment-6078130959). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-09T09:22:58Z. --- Three things before this can go in: - Drop the code comments in `Ajm.cpp` (the `segmentSamples` and `RunAt9` blocks) and in `AudioOut2Context.cpp`. - Drop the `APS5_DUMP_AUDIO` dump and the new batch traces; they're a separate change. - Add a `guest_ajm` case that fails on main: a gapless total shorter than the frames, then a second run that gets the frames after it. It conflicts with main in TechnicalDebt now, so please rebase when you push.
github-actions[bot] commented 2026-10-09 23:31:18 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-09T23:31:18Z.


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
#1491 docs/dev/TechnicalDebt.md L361
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6091033004 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2052#issuecomment-6091033004). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-09T23:31:18Z. --- <!-- 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 | |---|---|---|---| | #1491 | `docs/dev/TechnicalDebt.md` [L361](https://github.com/boykopovar/AnyPS5/blob/b7bb2684ecb8e165557f67fbcce1f81e911d69a4/docs/dev/TechnicalDebt.md#L361) | | |
esatturan commented 2026-10-09 23:35:32 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by esatturan on 2026-10-09T23:35:32Z.


Done, rebased on current main:

  • Removed the code comments in Ajm.cpp, and dropped the AudioOut2Context.cpp change (APS5_DUMP_AUDIO) and the new batch traces.
  • Added TestAt9GaplessSegments to guest_ajm. The gapless total is 512 samples over a 1024-sample superframe. The first run stops after two frames and leaves input; the second run gets the two frames after the total. On main the first run consumes the whole superframe, so the test fails.
  • Added TestAt9RunDecodesWholeInput for the other half of the change: a run without RUN_MULTIPLE_FRAMES decodes the whole superframe. It also fails on main. The description now states this half, and TechnicalDebt records it, since the console's behaviour there is not verified.
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6091084165 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2052#issuecomment-6091084165). Originally posted by [esatturan](https://github.com/esatturan) on 2026-10-09T23:35:32Z. --- Done, rebased on current `main`: - Removed the code comments in `Ajm.cpp`, and dropped the `AudioOut2Context.cpp` change (`APS5_DUMP_AUDIO`) and the new batch traces. - Added `TestAt9GaplessSegments` to `guest_ajm`. The gapless total is 512 samples over a 1024-sample superframe. The first run stops after two frames and leaves input; the second run gets the two frames after the total. On `main` the first run consumes the whole superframe, so the test fails. - Added `TestAt9RunDecodesWholeInput` for the other half of the change: a run without `RUN_MULTIPLE_FRAMES` decodes the whole superframe. It also fails on `main`. The description now states this half, and TechnicalDebt records it, since the console's behaviour there is not verified.
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!2052
No description provided.