Library To Decode Mjpeg?


PhonicUK

Member
Joined
Mar 27, 2009
Messages
148
Age
37
Website
www.phonicuk.com
Hey all,

I'm looking at porting the client-side of PSPDisp (Kinda like StreamMyGame for the PSP, works extremely well!) to the Pandora. It's all pretty simple and straightforward, side for one minor detail...

The PSP has an integrated MJPEG (Motion JPEG) decoding module/library.

What would an equivalent lib be under *nix? LibMPEG2 and similar can't do it, and there is some debate over whether AVLib can.

Any thoughts?
 
PhonicUK said:
Hey all,

I'm looking at porting the client-side of PSPDisp (Kinda like StreamMyGame for the PSP, works extremely well!) to the Pandora. It's all pretty simple and straightforward, side for one minor detail...

The PSP has an integrated MJPEG (Motion JPEG) decoding module/library.

What would an equivalent lib be under *nix? LibMPEG2 and similar can't do it, and there is some debate over whether AVLib can.

Any thoughts?
ffmpeg or mplayer would be the first place I'd look.
 
Last edited by a moderator:
One of your problems may be that MJPEG isn't exactly a well defined format. I doubt PSP really has "MJPEG hardware", but DCT macroblock decoding hardware, like PS1. This hardware can be used to accelerate JPEG, MJPEG, MPEG1, etc.

Do you think you could identify more specifically what kind of support you need? IE, what's happening on the PSP software exactly? Since it's streaming data w/o motion compensation it seems strange that it'd be dealing with a movie file. I would expect instead that it's just streaming individual JPEG files. To decode those you can use libjpeg, which can be built from the download here: http://www.ijg.org/files/jpegsrc.v8a.tar.gz

If it really is dealing with MJPEG files then doing your own wrapper code to pull out the JPEG files wouldn't be difficult, and IMO probably not worth going through the trouble of installing a library for. But you still need to know the exact container format being used.
 
Here's the ffmpeg encode line, it should provide clues as to how the PSP is encoding the stream. The mjpeg format wasn't introduced until firmware 2.80 - Why PSPDisp chose to use it is an oddity. I guess so they could get 480x272 cleanly. It really is less efficient than other formats.

Code:
ffmpeg -y -i “filename.ext” -title “name for file” -vcodec mjpeg -coder 1 -bufsize 128 -s 480x272 -r 30 -b 3582 -acodec pcm_s16le -ac 2 -ar 22050 -ab 705 “output_filename.avi”
 
Mrm, generating AVIs can't be a good way to handle streaming video. There'd be at least some overhead involved going to and from files, even with disk caching.

Anyway, if ffmpeg encoded it then libavcodec/libavfile should work fine in decoding it.
 
I'm not suggesting that he covert the stream to AVI and then display it. But the PSP is very picky about the input stream for mjpeg - indeed any video you intend to play on it. mjepg is the pickiest of them all. The ffmpeg encode line supplied is just a clue to what to expect the steam to look like coming from the PSPDisp encoder, since it will most likely be using this... encoding.
 
The lines in the PSP client basically consist of:

Code:
  if (LoadStartModule("flash0:/kd/avcodec.prx") == 0)
  {
    if (sceJpegInitMJpeg() == 0) 
    {
      if (sceJpegCreateMJpeg(480, 272) == 0)

To get it started. And...

Code:
sceJpegDeleteMJpeg();
sceJpegCreateMJpeg(480, 272);
sceJpegDecodeMJpeg(dataBuffer, dataSize, pixels, 0);

With some extra logic to take the image part of the stream out from the other status data sent.

I'm probably going to have to have a look at the server source.

Since its destroying and re-creating the MJpeg instance each frame, I'm inclined to think its actually just plain JPEG...

Edit: For those not familiar with the PSP, a PRX is kinda like a dll/so library - its stored as part of the PSPs internal flash. You can have 3rd party PRX's (Playstation Relocatable Executable) for extra functionality if needed.

Edit2: Balls, the server is written in Delphi! Maybe I'll just rewrite the server too...
 
Back
Top