Invalid offset calculation in sceMp3ResetPlayPositionByFrame
Game or games this happens in
Homebrew
What area of the game / PPSSPP
I am writing a piece of homebrew using libpspmp3/pspmp3.h from pspsdk. As I understand it, libpspmp3 just maps to the mp3 module. One of the exposed functions from said module is sceMp3ResetPlayPositionByFrame. It is supposed to set the play position of the mp3 to a given mp3 frame. ppsspp's HLE implementation of the mp3 module seems to incorrectly calculate what offset the given frame corresponds to and, as a result, jumps to the wrong part of the mp3.
I have modified pspsdk's mp3 example to showcase the bug. Pressing square calls sceMp3ResetPlayPositionByFrame to make the play position jump to what's meant to be 30 seconds into the mp3. On ppsspp it will instead jump roughly 8 seconds into the mp3 (when the bass synth kicks in). Please ignore the on-screen playtime, I've left the rest of the example untouched so it's incorrect. You have to go by ear, sorry. Here's the modified source with a prebuilt binary and test mp3.
What should happen
The play position should be set to the correct mp3 frame, so 30 seconds into the mp3 file. This is roughly a second before you can hear a bell chime in the back.
I have tested this on real hardware (psp-1000 on 6.60, ARK-4) and it behaves as expected, you can hear the bell.
https://github.com/user-attachments/assets/6c98213f-4c84-4800-a221-c812087054ba
Logs
No response
Platform
Windows
Mobile device model or graphics card (GPU)
NVIDIA GTX 1660TI Mobile
PPSSPP version affected
v1.20.2
Last working version
No response
Graphics backend (3D API)
Vulkan
Checklist
- Test in the latest git build in case it's already fixed.
- Search for other reports of the same issue.
- Try resetting settings or older versions and include if the issue is related.
- Try without any cheats and without loading any save states.
- Include logs or screenshots of issue.
Source: hrydgard/ppsspp