Sunday, June 2, 2013

JPEG optimization success!

Well, it looks like I've reached my goal earlier than I expected!

By making the change to decode JPEG directly to a GLES2 texture, performance skyrocketed.

Decoding from memory buffer and rendering on screen:
100 FPS (up from 62 FPS) <-- GOAL REACHED

Only decoding JPEG:
140 FPS (up from 103 FPS)


  1. Hi Matt,

    Is your latest JPEG code published anywhere? I've been using your hello_jpeg_v2.tar.gz, and it works really well but I'd be interested in seeing your latest discoveries!

    One thing I never understood with the hello_jpeg example was how to use the resizer - where do you set the size?

    Thanks for your work, I've knocked up a mostly working DSLR photobooth ( I hope to get jpegs resized direct to GL textures soon!

  2. Hi Tom,

    I haven't published my latest JPEG->GLES2 code mainly because it needs some clean-up work and I didn't want to go to the trouble if no one would use it. Sounds like it would be worth my time to release it. :)

    The hello_jpeg readme should show where to set the size for the resizer. The way the code is written is it sets the output width/height to match the input jpeg width/height but it doesn't have to be this way. You can set the output width/height to whatever you want (at least.. I _think_ you can hehe).

  3. Hi Matt,

    thanks for your response!

    The comments in the readme refer to lines that don't seem relevant - perhaps they were line numbers from an earlier version?

    Should it be set in OnDecoderOutputChanged()?

    portdef.format.image.nFrameWidth = uWidth;
    portdef.format.image.nFrameHeight = uHeight;

    thanks again!

  4. Hi Matt,

    Sorry for reviving an old thread, but have you published your JPEG->GLES2 code anywhere?

    I am currently conducting undergraduate research and our group is trying to decode HD(1920x1080) JPEG images(actually an MJPEG stream, but the principle is just multiple JPEG images) in real time so that we can do object tracking.

    One of our approaches is trying to use the Raspberry Pi, but, going off the hello_jpeg, we were able to decode and display using a linux framebuffer at a really low frame-rate. My colleague and I were thinking of switching to GLES2 instead of OpenMAX for the decode and rendering to the screen and we stumbled upon your projects here and were wondering if we would be able to look at it and learn.

    Thank you,


    1. Ok, I published my code and posted about it here:

      Unfortunately, I am not getting much response. If you could respond to this thread to help draw attention to this, I'd appreciate. I think this is something a lot of pi devs would be interested in.

  5. Hi Jonathan,
    I just saw this (blogger doesn't notify me when I have comments awaiting moderation for some reason).

    I never did publish my code but I will try to clean it up and put it up there for people as I can see it would be helpful.