JPEGDEC is a Faster JPEG Arduino Library Designed for 32-bit MCUs

In order to ensure software compatibility, Arduino libraries are supposed to work on various types of hardware from 8-bit microcontrollers with a limited amount of memory to more powerful 32-bit chips like STM32 Arm Cortex-M MCU or ESP32 dual-core Tensilica WiSoC that can access a larger amount of RAM.

This is all good, but in some cases, this may affect performance. Larry Bank noticed this when looking for a JPEG viewers for Arduino and only found ones which sacrificed speed to work on MCUs with very little RAM. So he started to work on JPEDDEC JPEG Arduino library optimized for speed and compatible with any MCU with at least 20K of RAM.

Optimizations go beyond just loading more data into memory, as Larry explains in a blog post, the library also performs the removal of stuffed bytes, optimize the Huffman decode and DCT parts, and more.

Some of the key features of the library include:

  • Support for any MCU with at least 20K of RAM
  • JPEG image data can come from memory (FLASH/RAM), SD Card or other media storage
  • Simple class and callback design allows you to easily add JPEG support to any application.
  • The C code doing the heavy lifting is portable and has no external dependencies.
  • Fast downscaling options (1/2, 1/4, 1/8).
  • Option to detect and decode the embedded Exif thumbnail
  • Support for Baseline Huffman images (grayscale or YCbCr)

You’ll find the JPEGDEC Arduino library on Github. Larry also developed a benchmarking sketch (jpeg_perf_test.ino), and ran it on popular microcontrollers including ESP8266, ESP32, and various Arm Cortex-M0+/M4F/M7 microcontrollers using a 640×480 images.

The full decode speed ranges from 1.3 seconds on a Cortex-M0+ @ 48 MHz to just 29.6 ms on NXP i.MT 1062 Cortex-M7 crossover processor @ 600 MHz found in Teensy 4.0 board. Paul Stoffregen, the maker of Teensy board, took JPEGDEC Arduino library on the board in the video below where you can appreciate the performance using his own sketch reading the photos from a MicroSD card, decoding them with JPEGDEC, and push the result to an SPI display. Just wait until he presses the button to experience the real speed.

You may think it’s not a representative demo since the NXP processor is so fast it’s just like a standard application processor. Larry uploaded his own video demo using Adafruit PyPortal powered by a Microchip SAMD51 Cortex-M4F MCU @ 120 MHz.

Via Hackaday

Support CNX Software - Donate via PayPal, become a Patron on Patreon, or buy review samples
Subscribe
Notify of
guest
1 Comment
oldest
newest most voted
David Willmore
David Willmore
1 month ago

I love Paul’s reaction to pressing the button. He’s clearly so happy with how fast it is. Hats off to both Larry for the code and Paul for the great platform!

Advertisements