|
Project Information
Featured
Links
|
picojpeg is a public domain JPEG decompressor written in plain C in a single source file picojpeg.c and a single header picojpeg.h. It has several fairly unique properties that make it useful on small 8/16-bit embedded devices or in very memory constrained environments: - Optimized for minimal memory consumption: Uses only ~2.3KB of work memory.
- Written assuming ROM code memory is more abundant than available RAM, which is the case on many microcontrollers.
- All work arrays are limited to less than or equal to 256 bytes in size.
- No reliance on the C run-time library (it includes no headers other than picojpeg.h), and does not use dynamic memory allocation.
- Majority of expressions use only 8-bit integer operations. 16-bit operations are only used when necessary.
- Uses a Winograd IDCT to minimize the number of multiplies.
- Whenever possible, multiplies are limited to 8x8 or 16x8 bits, and are done against compile-time constants.
picojpeg has several disadantages and known issues compared to other implementations: - Quality is traded off for minimal RAM memory consumption and decent performance on small microcontrollers. For example, the H2V2 chroma upsampler uses only box filtering, 8x8 multiplies, and minimal 16-bit operations so it's not as precise as it could be.
- 1D IDCT is not yet optimized to exploit runs of 0's in the row loop.
- Only supports baseline sequential greyscale, or YCbCr H1V1 and H2V2 sampling factors. Other sampling factors could easily be added, but I ran out of time.
- The Huffman decoder currently only reads a bit at a time to minimize RAM usage, so it's pretty slow. (I'm planning on improving this.)
- All work arrays (approx. 2.3KB) are globals, because this resulted in the best code generation with the embedded compiler I was using during development. I'm assuming either this is not an issue, or the user is using a compiler that allows them to overlap these variables with other unrelated things. picojpeg is not thread safe because of this.
- Not exhaustively tested. Also, the decompressor doesn't check if the need_bytes callback returns an error code - it just soldiers on until decompression fails for other reasons or until all MCU's (Minimum Coded Units) are output. I'll be fixing this in the next version.
A close variant of picojpeg has been successfully compiled and executed on Microchip's PIC18F4610 microcontroller using SourceBoost Technologies BoostC embedded compiler. The source distribution includes a sample VS2005 project and precompiled Win32/Win64 command line executables that convert JPG to TGA files using picojpeg for decompression. Sean Barrett's public domain stb_image.c module is used to write TGA files. picojpeg was originally based off my jpgd decompressor C++ class, which is faster and more capable than picojpeg but uses a lot more memory. For any questions or problems with this module please contact Rich Geldreich at <richgel99 at gmail.com>. Here's my twitter page.
|