The PSP Media Engine and its implementation

The PSP has a separate CPU called the Media Engine. From a game's perspective, it's only accessible through high-level libraries.

The overall architecture looks something like this:

  • Games call into high level libraries that handle media formats and containers. These are sceMpeg, sceAtrac, sceMp3 etc. scePsmfPlayer is a special case that itself is a wrapper around sceMpeg (scePsmf is just a parser).
  • The high level libraries call into the sceVideocodec and sceAudiocodec libraries.
  • sceVideoCodec/sceAudioCodec call into the ME driver libraries.
  • Those communicate somehow with the actual ME CPU, and then deliver the decoded results back up the stack.

Some of these are exclusively shipped with games, like scePsmf/scePsmfPlayer. Others like sceAtrac are also present in the firmware, and games can either ship their own on disc or load the latest version from the firmware directly.

For reverse engineering purposes, psdevwiki has a list of where modules are. To get the prx files, dump them from your own PSP using psardumper.

Emulation

In PPSSPP traditionally we have emulated the high-level libraries directly.

However, I'm now looking into if we should go one or two levels down the stack.

scePsmf/scePsmfPlayer should really not be emulated, instead we should run the implementations that are present on disc, and make sure that our sceMpeg is accurate enough to work with with them.

Additionally, sceAtrac/sceMp4/sceAac/sceMp3 should all be allowed to run when possible, and the underlying sceAudiocodec will take care of the actual decoding.