From ba7bf86e73bd33b60ff306db2a84ceae31d87d65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Thu, 17 Sep 2026 10:45:16 -0600 Subject: [PATCH] sceAudiocodec: don't return a zero Atrac3+ frame size for odd bitrates CalculateInputBytesAndChannelsAt3Plus only set the frame size for the four bitrates it had a table entry for and left it at 0 otherwise, which fails the decode - the same shape of bug the AAC path just had. formatByte2 * 8 + 8 is the size for all four known bitrates, so use it for the rest too; the firmware never returns 0 here. The common PSMF path is unaffected: it takes the size from the frame's own header before reaching this. Co-Authored-By: Claude Opus 5 (1M context) --- Core/HLE/sceAudiocodec.cpp | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-) diff --git a/Core/HLE/sceAudiocodec.cpp b/Core/HLE/sceAudiocodec.cpp index 1e7809f4e3..1950e09821 100644 --- a/Core/HLE/sceAudiocodec.cpp +++ b/Core/HLE/sceAudiocodec.cpp @@ -139,24 +139,12 @@ void CalculateInputBytesAndChannelsAt3Plus(const SceAudiocodecCodec *ctx, int *i return; } - int size = formatByte2 * 8 + 8; - // No idea if this is accurate, this is just a guess... - if (formatByte1 & 8) { - *channels = 2; - } else { - *channels = 1; - } - switch (size) { - case 0x118: - case 0x178: - case 0x230: - case 0x2E8: - // These have been seen before, let's return it. - *inputBytes = size; - return; - default: - break; - } + // bit 3 of the first byte is the channel count. This is a guess, but it fits the data we have. + *channels = (formatByte1 & 8) ? 2 : 1; + // formatByte2 * 8 + 8 gives the frame size for every bitrate we have data for (0x118, 0x178, + // 0x230, 0x2E8), so use it for any other value as well rather than leaving inputBytes at 0, + // which the firmware never does and which would fail the decode outright. + *inputBytes = formatByte2 * 8 + 8; } // Atrac3 (0x1001). Unlike Atrac3+, the context doesn't carry a frame size - libatrac3plus.prx