Commit Graph
15 Commits
Author SHA1 Message Date
Henrik RydgårdandClaude Opus 5.5 cc0604ab54 sceAudiocodec: Atrac3 mono output from InitMono, and 0x183 for joint stereo
On hardware InitMono only takes the mono Atrac3 parameters (0x0E, 0x0F),
and the stereo ones fail with 0x807f00ff. Init fills in the context: 44100
at 0x2c, the frame size at 0x30, and the output channels at 0x34, which
InitMono sets to 1. The ME reads that at every decode, and writes a mono
layout as stereo only when it's 2. We accepted every parameter, wrote
nothing there, and always wrote stereo.

A bad frame's ctx.err is 0x183 when a joint stereo frame's second part
lacks its marker, and 0x182 for any other bad sound unit. The decoder now
reports which, and we give 0x183 where we gave 0x182
(pspautotests audio/audiocodec/at3errors).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-19 14:13:44 +02:00
Henrik RydgårdandClaude Opus 5.5 c162eb3d74 sceAudiocodec: Match hardware setup, framing, errors and timing; fix Atrac3 polarity
Checked against pspautotests audio/audiocodec, recorded on a PSP.

- Atrac3+: at3Related selects headered (mpeg.prx) or raw (libatrac3plus)
  frames, instead of sniffing for the sync word. The header's size field
  is 10 bits, as the context's. Header errors 0x211/0x213, bad frames
  0x20a, all returning SCE_AVCODEC_ERROR_INVALID_DATA with nothing read.
- The first successfully decoded Atrac3+ frame, and the first two AAC
  frames, produce no output. Checked sample-for-sample against hardware.
- Atrac3: the parameter at 0x28 selects the frame layout, as
  libatrac3plus.prx's table maps it. We used to read its low bit as a
  joint-stereo flag, which decoded mono (0x0F) streams as stereo garbage.
  AtracCtx2 had the table's fields swapped the same way.
- at3_standalone's Atrac3 output was inverted relative to the PSP's
  (sceAtrac too). Negate the IMDCT scale.
- CheckNeedMem sizes (AAC is 0x658c), codec 0x1004/0x1005, Init
  validation (AAC sample rate, Atrac3 parameter, Atrac3+ channels), and
  ReleaseEDRAM clearing edramAddr.
- Every call that reaches the ME now blocks for its measured time, and
  decode time is modelled per codec and frame size.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-28 16:57:41 -06:00
Henrik Rydgård d04074a542 Atrac3 (not +): Keep decoding even on broken frames.
Fixes some music in some unofficial game mods, whose music got broken
in 1.18. Was reported through e-mail by Miguel.
2025-01-04 01:11:26 +01:00
Henrik Rydgård 083543cc14 Unrelated logging improvement 2025-01-03 21:14:22 +01:00
Henrik Rydgård 090d1f8d0e atrac3: Add a cross platform restrict modifier, use it for the vector math functions
Also remove redundant parameters.

There are a bunch of other places where we could use this, so just
experimenting here.

This enables autovectorization to work here.
2024-05-02 16:57:15 +02:00
Henrik Rydgård 7b6b7ebe3c Add some SSE code for an atrac hotspot just for fun, remove function pointers 2024-04-13 10:37:35 +02:00
Henrik Rydgård 68c192b892 Fix some symbol clashes apparently affecting the docker build 2024-04-13 01:06:18 +02:00
Henrik Rydgård 3409db9b90 Remove line endings from atrac3+ log strings 2024-04-12 13:53:20 +02:00
Henrik Rydgård 39b884cfb3 Atrac3/3+: Improve error handling 2024-04-12 11:18:26 +02:00
Henrik Rydgård 45936e8826 Atrac: Add "flush_buffers" api. The ffmpeg atrac decoder was missing this. 2024-04-11 16:35:27 +02:00
Henrik Rydgård 58cb2ba804 Fix playback of atrac3+ when block align not specified 2024-04-11 16:10:31 +02:00
Henrik Rydgård b35b351802 Finally remove the AVCodecContext 2024-04-11 14:50:29 +02:00
Henrik Rydgård 843119411f Stop passing around the AVCodecContext pointer so much 2024-04-11 14:39:59 +02:00
Henrik Rydgård 0d30728832 Remove context parameter from av_log 2024-04-11 14:39:59 +02:00
Henrik Rydgård e10b90b718 Switch at3_standalone to C++ to avoid namespace clashes 2024-04-11 14:39:59 +02:00