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.
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.
Jean-Luc started CNX Software in 2010 as a part-time endeavor, before quitting his job as a software engineering manager, and starting to write daily news, and reviews full time later in 2011.