Saturday, February 21, 2009

JPEG File Interchange Format V1.02 - III

JFIF Extension APP0 Marker Segment
Immediately following the JFIF APP0 marker segment may be a JFIF extension APP0marker. This JFIF extension APP0 marker segment may only be present for JFIF versions1.02 and above. The syntax of the JFIF extension APP0 marker segment is:

X’FF’, APP0, length, identifier, extension_code, extension_data

length (2 bytes) Total APP0 field byte count, including the bytecount value (2 bytes), but excluding the APP0marker itself

identifier (5 bytes) = X'4A', X'46', X'58', X'58', X'00'This zero terminated string (“JFXX”) uniquelyidentifies this APP0 marker.

extension_code (1 byte) = Code which identifies the extension. In thisversion, the following extensions are defined:
= X'10' Thumbnail coded using JPEG
= X'11' Thumbnail stored using 1 byte/pixel
= X'13' Thumbnail stored using 3 bytes/pixel
extension_data (variable) = The specification of the remainder of the JFIFextension APP0 marker segment varies with theextension. See below for a specification ofextension_data for each extension.

JFIF Extension:
Thumbnail coded using JPEGThis extension supports thumbnails compressed using JPEG. The compressed thumbnailimmediately follows the extension_code (X'10') in the extension_data field and the lengthof the compressed data must be included in the JFIF extension APP0 marker length field.

The syntax of the extension_data field conforms to the syntax for interchange formatdefined in Annex B of ISO DIS 10918-1. However, no “JFIF” or “JFXX” markersegments shall be present. As in the full resolution image of the JFIF file, the syntax ofextension_data constrains parameters in the frame header as defined below:

X’FF’, SOI



X’FF’, SOFn, length, frame parameters

Number of components Nf = 1 or 31st
component C1 = 1 = Y component
2nd component C2 = 2 = Cb component
3rd component C3 = 3 = Cr component



X’FF’, EOI

JFIF Extension: Thumbnail stored using one byte per pixel

This extension supports thumbnails stored using one byte per pixel and a color palette inthe extension_data field. The syntax of extension_data is:

Xthumbnail (1 byte) Thumbnail horizontal pixel count
Ythumbnail (1 byte) Thumbnail vertical pixel count
palette (768 bytes) 24-bit RGB pixel values for the color palette. The RGB values define the colors represented byeach value of an 8-bit binary encoding (0 - 255).
(pixel)n (n bytes) 8-bit values for the thumbnail pixelsn = Xthumbnail * Ythumbnail.

JFIF Extension: Thumbnail stored using three bytes per pixel

This extension supports thumbnails stored using three bytes per pixel in the extension_datafield. The syntax of extension_data is:

Xthumbnail (1 byte) Thumbnail horizontal pixel count
Ythumbnail (1 byte) Thumbnail vertical pixel count
(RGB)n (3n bytes) Packed (24-bit) RGB values for the thumbnailpixels, n = Xthumbnail * Ythumbnail

Useful tips
• you can identify a JFIF file by looking for the following sequence: X'FF', SOI, X'FF',APP0, <2>, "JFIF", X'00'.

• if you use APP0 elsewhere, be sure not to have the strings "JFIF" or "JFXX" right afterthe APP0 marker.

• if you do not want to include a thumbnail, just program Xthumbnail = Ythumbnail = 0.
• be sure to check the version number in the special APP0 field. In general, if the majorversion number of the JFIF file matches that supported by the decoder, the file will bedecodable.

• if you only want to specify a pixel aspect ratio, put 0 for the units field in the specialAPP0 field. Xdensity and Ydensity can then be programmed for the desired aspect ratio.Xdensity = 1, Ydensity = 1 will program a 1:1 aspect ratio. Xdensity and Ydensity shouldalways be non-zero.

No comments:

Post a Comment