Small JPEG Decoder Library
Copyright © 1994-2000 Rich Geldreich (firstname.lastname@example.org)
The Small JPEG Decoder Library is a C++ library that can decode the most common types of JPEG images. It's not the most full-featured JPEG library available, but it's relatively fast, completely free with full source code (LGPL license), uses little memory, and should be easy to understand and further optimize. The very common Huffman DCT-based sequential and progressive modes of operation are supported.
This library only handles JPEG decompression, upsampling, and colorspace conversion. It does not handle pixel format conversion, quantization, dithering, etc.
If your application's input set is limited in some way (say, you're making a game or some other app that has prepared resources), this library may suite your needs. This library may also prove useful to those that want to read JPEG images on very small 32-bit platforms or embedded devices.
v0.93b (Dec. 28, 2001) may be downloaded below. The file "readme.txt" contains more information about the library, its history, etc.
Relatively simple (very little code compared to other implementations)
Free (LGPL license)
A lot of MMX instruction set specific optimizations -- decoder is 30%-40% faster when MMX is enabled
Supports the most common (widely used) file types:
YCbCr colorspace: H1V1, H1V2, H2V1, or H2V2 sampling factors
Decodes images up to 8192x8192 (this limit can be easily increased)
Includes Visual C++ 6.0 project, with a small sample application (jpg2tga, a simple JPEG to TGA converter)
The chrominance channels are upsampled using what's effectively a simple box filter. This can lead to some artifacts depending on the image.
Only 8-bit component precision streams are supported.
No arithmetic coding support.
Does not support CMYK image types.
Less forgiving than other implementations: if the input stream is bad or corrupted, this decoder may exit with an error condition a little earlier than other decoders. (Restart markers are properly parsed but not currently used to recover if the data stream goes south.)
The MMX specific code in h2v2.cpp does not round and, in general, is not as precise as it should be. The output G component suffers the worst. I might rewrite this code again-- there's way too much unpacking/packing/shifting going on anyway.
jpgd093b.zip (79k) Tweaked YCbCr to RGB lookup tables to improve grayscale pixel conversion quality.
readme.txt (8k) Readme file from archive.
jpgd093a.zip (79k) Fixed a dumb bug in the decode_next_row functions that could allow non-zero coefficients from leaking through in rare cases.
jpgd093.zip (298k) MMX state saved/restored around calls to the decoder stream's read() method, added some defines to ease porting to non-x86 platforms.
jpgd092.zip (323k) Much faster. Still needs a lot of testing because there's a lot more assembler and MMX specific code.
jpgd091.zip (290k) Added warning about the MMX IDCT bug, added free(Pbuf); to jpg2tga.cpp, fixed workspace so the lib header files can be found, changed comments a bit.