JPEG Overview

The Independent JPEG Group (IJG) libjpeg is an optional library that enables encoding and decoding of JPEG images.

License

If your application links 'jpeg.a' the libjpeg library, you must include the following disclosure in the user instruction manual:

"This software is based in part on the work of the Independent JPEG Group."

The full license agreement can be found here.

You must agree to the terms of this license to use the libjpeg library.

Note that this license agreement differs from that distributed by the IJG in that obligations related to ansi2knr.c are deleted, because it is not used in this implementation of libjpeg.

Overview

This library conforms to ISO JPEG specifications, with the following limitations:

JPEG Encoding

JPEG Decoding

Precautions on Handling Exif Metadata

This library cannot retrieve Exif metadata from JPEG binary, and cannot save Exif metadata in JPEG binary. Consequently, you must take the following precautions:

Differences from the JPEG Codec Library for Wii

The following features implemented under the JPEG Codec Library for Wii are not provided by this middleware.

Size of the Output Buffer Given to the JPEG Encoder

The size of JPEG binary output by the JPEG encoder varies depending on the content of the texture data and the value specified for the picture quality. However, this middleware does not include a feature for determining the size of output data before encoding. You must allocate a large enough buffer before using the JPEG encoder.

The following table indicates the buffer size required to carry out JPEG encoding for various texture data sizes and picture quality specifications. Use these values as a guide when determining the buffer size to use. However, the sizes given in this table are not guarantees of the upper and lower bounds actually needed.

Texture Size and Size of Data After JPEG Encoding
Texture Size Image Quality JPEG Size in Bytes
1920x1080 1 34349
25 45222
50 56609
75 79512
100 752339
1280x720 1 15694
25 22178
50 30963
75 42266
100 356881
640x480 1 7814
25 26302
50 41160
75 51058
100 173993
320x240 1 2995
25 9917
50 15703
75 20516
100 62312

Size of the Work Buffer

For the JPEG Encoder

The size of work buffer for the JPEG encoder is derived from dimension of given surface image, i.e. image width and height. To predict maximum size of work buffer in an application, the size can be obtained by specifying the application's maximum possible size of surface to be encoded.

For the JPEG Decoder

The size of work buffer for the JPEG encoder is derived from dimension of given surface image and encoding parameter of given JPEG image. For most of common JPEG images, to predict maximum size of work buffer, the size can be retrieved by decoding JPEG image which has maximum dimension for the application and specific encoding parameters.

The size of work buffer for the JPEG decoder differs substantially between JPEG images encoded with "baseline mode" and "progressive mode". If an application will handle only "baseline mode" encoded JPEG image, maximum size of work buffer can be predicted by pre-decoding JPEG image which is encoded with parameters below:

JPEG Specification to Obtain Maximum Work Buffer Size ("baseline" case)
Parameter Value
Color Space YCbCr
Scanning Method Baseline
Sampling Ratio 4:2:0
Number of Huffman Tables 4
Number of Quantization Tables 4

If an application will also handle "progressive mode" encoded JPEG image, maximum size of work buffer can be predicted by pre-decoding JPEG image which is encoded with parameters below:

JPEG Specification to Obtain Maximum Work Buffer Size ("progressive" case)
Parameter Value
Color Space YCbCr
Scanning Method Progressive
Sampling Ratio 4:4:4
Number of Huffman Tables 8
Number of Quantization Tables 4

In both "baseline" and "progressive" case, note that you may need to add some margin for memory allocation offsets and allocator's management regions. Also, this is just a rough standard because there should be a large amount of combinations of JPEG encoding parameters in the field.

Display According to the IJG libjpeg License

IJG libjpeg is used for the back end of this JPEG library.
"This software is based in part on the work of the Independent JPEG Group."

Revision History

2013/12/26 Added "Size of the Work Buffer" section.
2013/05/08 Automated cleanup pass.
2013/02/19 Replaced words 'texture' with 'surface'.
2012/08/20 Added "Using an IJG libjpeg".
2012/07/24 Added "Precautions when Handling Exif Metadata."
2012/02/02 Added support for decoding the progressive JPEG format.
2011/08/08 Initial version.


CONFIDENTIAL