JPEGDEC is a Faster JPEG Arduino Library Designed for 32-bit MCUs
For most firmware developers and hobbyists, who have had to write firmware for projects that involve displaying JPEGs on an LCD with an Arduino, one thing that quickly comes to mind is the bulkiness of the libraries and the slow speed at which the images are displayed. While the speed is usually due to the low memory and processing speed of the microcontrollers in use (8-bits microcontrollers), the bulkiness is usually as a result of the schemes and tricks that were adopted to get the low performing MCUs to perform better with jpeg display.
While things have improved in recent times, with 32-bits high performing MCUs with increased RAM and processing speed now available, there has been little or no change to the efficiency/performance of Jpeg libraries. To ensure change and growth is also experienced with the libraries, Software Optimization Specialist, Larry Bank, recently decided to give the libraries the necessary facelift via the release of his new library: the JPEGDEC library.
The new library which targets the Cortex-M0+ processors or any chip with a minimum of 20Kb of RAM is designed to make the display of JPEGs faster on boards based on the Cortex-M0+, or any chip with a minimum of 20K of RAM (bare minimum requirements), without sacrificing the memory of the boards for speed.
Acknowledging the prior existence of different JPEG Libraries for the Arduino, including the ones written by him, Larry, while sharing the rationale behind the new library in a recent blogpost, mentioned the existence of more processing power on MCUs as a motivating factor for the development. He said, While it’s possible to decode JPEGs piece by piece with some intelligent code under the conditions presented by 8-bit systems, it’s possible to go much faster when you’ve got a little more headroom, and this new library was merely doing that, from eliminating unnecessary marker checks to ignoring unneeded data for scaled-down outputs, all coming together to give a faster result.
Highlight features of the new library as noted by Larry includes:
- Supports any MCU with at least 20K of RAM (Cortex-M0+ is the simplest I’ve tested)
- Optimized for speed; the main limitation will be how fast you can copy the pixels to the display. You can use DMA assisted SPI to help.
- JPEG image data can come from memory (FLASH/RAM), SDCard or any media you provide.
- Simple class and callback design allow you to easily add JPEG support to any application.
- The C code doing the heavy lifting is completely portable and has no external dependencies.
- Includes fast downscaling options (1/2, 1/4, 1/8).
- Includes option to detect and decode the embedded Exif thumbnail
- Supports Baseline Huffman images (grayscale or YCbCr)
- Includes optional Floyd-Steinberg dithering to 1, 2 or 4-bpp grayscale output; useful for e-paper displays
The library has already been taken for a spin by several notable community contributors like Paul Stoffregen who made a Youtube Video to demonstrate the performance of the library. Larry himself also developed a benchmark test sketch which shows the library’s performance across different development platforms.
More information on the library and its performance are available on the project’s Github page.