fix(ngs2): decode ATRAC9 across streamed waveform blocks #1300

Merged
TibixDev merged 2 commits from upstream-pr/1300 into main 2026-10-09 23:25:02 +00:00
TibixDev commented 2026-10-07 22:44:53 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by TibixDev on 2026-10-07T22:44:53Z.


What

Decode ATRAC9 waveforms across partial input buffers. Preserve sample and skip counts, assemble split superframes, and let callbacks refill, pause, or reset the stream. Closed ATRAC9 streams with missing samples throw.

Integrated with merged #1038 on 66b8abd8. Both codecs use APPEND (0x2) through the same dispatch. PCM keeps its existing append validation, starvation, and early-close behavior. ATRAC9 appends compressed bytes without replacing the waveform metadata. No duplicate ONLY_DATA flag remains.

Tested

Fedora 44 Release: all seven NGS2 tests pass. Tests cover PCM streaming and ATRAC9 partitions, pitch, skip, repeats, refill callbacks, pause, reset, starvation, and truncation. All 255 byte splits of a superframe match complete decoding, with sample counts, byte counts, and final input pointers checked. An append without waveform metadata is rejected.

MinGW compiles the changed decoder/render/control sources and the ATRAC9 and PCM stream tests. Windows runtime CI is pending. Public source references and unverified console behavior remain in TechnicalDebt.md.

Checklist

  • Current main; merged #1038 integrated.
  • One topic.
  • No new code comments.
  • Unsupported paths still throw; UI stubs are documented.
  • No notes, logs, or images in the repository.
  • No new third-party code.
  • General behavior.
  • Depends on: none.
  • AI-assisted: yes.
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4779385002 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1300). Originally posted by [TibixDev](https://github.com/TibixDev) on 2026-10-07T22:44:53Z. --- ### What Decode ATRAC9 waveforms across partial input buffers. Preserve sample and skip counts, assemble split superframes, and let callbacks refill, pause, or reset the stream. Closed ATRAC9 streams with missing samples throw. Integrated with merged #1038 on `66b8abd8`. Both codecs use `APPEND` (`0x2`) through the same dispatch. PCM keeps its existing append validation, starvation, and early-close behavior. ATRAC9 appends compressed bytes without replacing the waveform metadata. No duplicate `ONLY_DATA` flag remains. ### Tested Fedora 44 Release: all seven NGS2 tests pass. Tests cover PCM streaming and ATRAC9 partitions, pitch, skip, repeats, refill callbacks, pause, reset, starvation, and truncation. All 255 byte splits of a superframe match complete decoding, with sample counts, byte counts, and final input pointers checked. An append without waveform metadata is rejected. MinGW compiles the changed decoder/render/control sources and the ATRAC9 and PCM stream tests. Windows runtime CI is pending. Public source references and unverified console behavior remain in `TechnicalDebt.md`. ### Checklist - [x] Current `main`; merged #1038 integrated. - [x] One topic. - [x] No new code comments. - [x] Unsupported paths still throw; UI stubs are documented. - [x] No notes, logs, or images in the repository. - [x] No new third-party code. - [x] General behavior. - [x] Depends on: none. - [x] AI-assisted: yes.
oneandonlydean commented 2026-10-08 03:26:11 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-08T03:26:11Z.


#1038 also defines flag 0x2: it calls it APPEND and streams PCM through it, while this calls it ONLY_DATA for ATRAC9 and throws for PCM. The two conflict in Ngs2Types.hpp, Ngs2Internal.hpp, Render.cpp and Voice.cpp. Once #1038 lands, please rebase onto it and make the two readings one path.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6051543883 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1300#issuecomment-6051543883). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-08T03:26:11Z. --- #1038 also defines flag `0x2`: it calls it `APPEND` and streams PCM through it, while this calls it `ONLY_DATA` for ATRAC9 and throws for PCM. The two conflict in `Ngs2Types.hpp`, `Ngs2Internal.hpp`, `Render.cpp` and `Voice.cpp`. Once #1038 lands, please rebase onto it and make the two readings one path.
TibixDev commented 2026-10-08 06:45:51 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by TibixDev on 2026-10-08T06:45:51Z.


Integrated with merged #1038 and rebased on 66b8abd8.

Both codecs now use the upstream APPEND (0x2) flag and the same append dispatch. PCM keeps #1038's validation and early-close behavior. ATRAC9 appends compressed bytes while keeping the original waveform duration and skip count. The duplicate ONLY_DATA constant is gone.

All seven Linux Release NGS2 tests pass, including the PCM stream tests. The ATRAC9 tests also check all 255 byte splits of a superframe, ignored continuation metadata, counters, final pointers, and rejection of an append without a waveform. Existing pitch, refill, pause, reset, starvation, truncation, and repeat checks pass. MinGW compiles the changed sources and both codec tests; Windows runtime CI is pending.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6054149854 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1300#issuecomment-6054149854). Originally posted by [TibixDev](https://github.com/TibixDev) on 2026-10-08T06:45:51Z. --- Integrated with merged #1038 and rebased on `66b8abd8`. Both codecs now use the upstream `APPEND` (`0x2`) flag and the same append dispatch. PCM keeps #1038's validation and early-close behavior. ATRAC9 appends compressed bytes while keeping the original waveform duration and skip count. The duplicate `ONLY_DATA` constant is gone. All seven Linux Release NGS2 tests pass, including the PCM stream tests. The ATRAC9 tests also check all 255 byte splits of a superframe, ignored continuation metadata, counters, final pointers, and rejection of an append without a waveform. Existing pitch, refill, pause, reset, starvation, truncation, and repeat checks pass. MinGW compiles the changed sources and both codec tests; Windows runtime CI is pending.
adriadam10 commented 2026-10-09 22:56:26 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-09T22:56:26Z.


Rebased onto current main (only conflict: the NGS2 lines in docs/dev/TechnicalDebt.md, kept both sides). Built and ran the full ctest on the rebased head: all NGS2 tests pass, including ngs2_atrac9, and the new tests fail without the change. Merging once CI is green on the new head.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6090666558 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1300#issuecomment-6090666558). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-09T22:56:26Z. --- Rebased onto current `main` (only conflict: the NGS2 lines in `docs/dev/TechnicalDebt.md`, kept both sides). Built and ran the full ctest on the rebased head: all NGS2 tests pass, including `ngs2_atrac9`, and the new tests fail without the change. Merging once CI is green on the new head.
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!1300
No description provided.