Databases Reference
In-Depth Information
13.6.4 Format __ JFIF
The most common format used for storing JPEG encoded images is the JPEG File Interchange
Format (JFIF). It uses markers to partition the bitstream. The first byte of each marker is FF
and the second byte is constrained to be neither FF nor 0. Markers can be stand-alone or they
can be followed by a payload. Examples of standalone markers are the SOI (start of image)
(FFD8) markers, which initiate all JFIF files, and the EOI (end of image) (FFD9) markers,
which terminate all JFIF files. In the markers which act as headers for a payload, the first two
bytes encode the length of the payload.
The application-specific APP0 marker (FFE0), which immediately follows the SOI marker
has the following format:
Field
Size
Content
Length
2 bytes
Length of the header
Identifier
5 bytes
0x4A 0x46 0x49 0x46 0x00 (JFIF0)
Version
2 bytes
MSB for major revision, LSB for minor revisions
Units
1 byte
0: no units, 1: dots per inch, 2: dots per cm
Xdensity
2 bytes
Horizontal pixel density
Ydensity
2 bytes
Vertical pixel density
Xthumbnail
1 byte
Thumbnail horizontal pixel count
Ythumbnail
1 byte
Thumbnail vertical pixel count
(
) n
RGB
3 n bytes
24-bit RGB values for thumbnail
n =
Xthumbnail
×
Ythumbnail
The structure of the JFIF file is shown in Figure 13.10 in which the representation optional
elements are shown as dashed boxes. Optional elements include table markers such as DHT
(define Huffman table) (FFC4) and DQT (define quantization table) (FFDB). The syntax of the
DHT marker is shown in Figure 13.11 . The first two bytes contain the length of the payload.
The four most significant bits of the next byte indicate whether the Huffman code is for the
DC coefficient or the AC coefficients. The number of Huffman codewords of lengths from 1
bit through 16 bits are stored in the next 16 bytes. This is followed by a variable number of
bytes that describe the Huffman codes in terms of their lengths.
The syntax of the quantization table marker is shown in Figure 13.12 . Again, the first
two bytes contain the payload length. The most significant four bits of the next byte specify
whether the quantization table values are stored in one or two bytes. A value of 0 indicates a
single byte is used for each quantization value while a value of 1 indicates 2 bytes are used
for each quantization value. The next 64 or 128 bytes contain the 64 quantization table values
stored in zigzag order.
Optional table marker segments are followed by the frame header, which indicates the start
of a frame and in turn can be followed by a number of scans. Each new scan begins with a
marker segment, the DNL marker segment (FFDC), which defines the number of lines in the
next scan. This is used to reset the dimension of the image set in the frame header. The scan
can begin with optional tables followed by the scan header. The first two bytes in the scan
header are the start of scan (SOS) marker followed by the length, number of components, and
component parameters. The scan header is followed by the entropy-coded data interleavedwith
restart markers (DRI). These markers provide a degree of robustness to the JPEG datastream.
 
Search WWH ::




Custom Search