Picojpeg - Extremely memory efficient embedded JPEG decompressor

  •        1400

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 . Here's my twitter page.

http://code.google.com/p/picojpeg

Tags
Implementation
License
Platform

   




Related Projects

vim-olive - Vim Mode Line Verifier


Vim Mode Line Verifier

vim-mash - Motion Activated Search Highlighter for Vim


Motion Activated Search Highlighter for Vim

vim-grillz - Flash your wicked grillz!


Flash your wicked grillz!

vim-foist - Complete whole lines from any partial therein


Complete whole lines from any partial therein

vim-efmc - Vim Error Format Compiler


Vim Error Format Compiler


uzbl-utrs - mkng uzbl tlrbl


mkng uzbl tlrbl

toycsv - A toy CSV parser written in ruby + lexr + racc


A toy CSV parser written in ruby + lexr + racc

tiktok - TikTok provides a simple asynchronous timer object for VimL.


TikTok provides a simple asynchronous timer object for VimL.

tabby - Using Vim's Tabs the Right Way


Using Vim's Tabs the Right Way

SohiVila - GNU source-highlight Vim language


GNU source-highlight Vim language

SinTax - A DSL for generating Vim syntax highlighting files


A DSL for generating Vim syntax highlighting files

rkdots - Generate a graphviz visualisation of the given javascript statement.


Generate a graphviz visualisation of the given javascript statement.

RelNumBar - Show relativenumbers alongside normal numbers in Vim


Show relativenumbers alongside normal numbers in Vim

Punisher - Punisher hurts you where it hurts most - your time.


Punisher hurts you where it hurts most - your time.

noisy - Don't chat quietly (weechat channel noises)


Don't chat quietly (weechat channel noises)

newlisp-manual - Asciidoc version of the newLISP manual


Asciidoc version of the newLISP manual

Land-of-newLISP - Selected snippets from Land of Lisp rewritten in newLISP


Selected snippets from Land of Lisp rewritten in newLISP

Fossilise - Poor man's collaborative editing in Vim


Poor man's collaborative editing in Vim

firstly - Convert Between Numeric, Spelt, and Short & Long Ordinal Forms of Numbers


Convert Between Numeric, Spelt, and Short & Long Ordinal Forms of Numbers