Integrated JPEG CODEC
cients. The encoding methods used for DC and AC coefficients
differ in their details, and this requires two Huffman tables to be
specified, one for DC and one for AC. And since the statistics of
the luminance and chrominance components are generally quite
different, separate Huffman tables are required for luminance
and chrominance, for a total of four tables, two DC and two AC.
The ZR36060 supports this configuration.
In all three of the formats, the tables and the parameters required
for decoding the image and/or the tables are contained inmarker
segments, which are sequences of bytes that start with special
two-byte codes called markers or marker codes. The two bytes
that follow the marker specify the length of the marker segment
in bytes, including the two length bytes but not including the
marker code itself. There are two special stand-alone markers
that are not associated with marker segments, to mark the start-
of-image (SOI) and end-of-image (EOI). The code values are
0xFFD8 for SOI, and 0xFFD9 for EOI.
Baseline decompression essentially consists of the inverses of
each of the stages used in compression, in reverse order:
Huffman decoding, dequantization, inverse DCT, and conver-
sion of the blocks back to raster order.
The first byte of every marker is 0xFF. A marker may be prefixed
by an arbitrary number of 0xFF bytes which are discarded by the
decoder. The second byte of a marker has defined values,
except for 0x00, which is used as follows. In order to permit a
decoder to identify the restart markers, if they exist, and the EOI
marker, the encoder stuffs a 0x00 byte after every 0xFF byte that
results from the Huffman encoding. Note that this “byte stuffing”
is an essential part of the JPEG standard, and there is no defini-
tion in the standard of a bitstream that does not include the byte
stuffing. The ZR36060 always produces image bitstreams with
byte stuffing, and requires the byte stuffing to be present in order
to decode a JPEG bitstream.
1.2.1.1 The Minimum Coded Unit
If the compressed image data is interleaved, as is the case in the
ZR36060, the compression is performed in units of a Minimum
Coded Unit, or MCU, which contains one or more blocks of each
color components. For the 4:2:2 pixel format used by the
ZR36060, where the chrominance (U and V) components are
decimated by 2:1 horizontally relative to the luminance (Y), the
MCU consists of 2 blocks of Y followed by one block each of U
and V.
1.2.1.2 Restart Intervals
The JPEG standard also does not define any sort of “markerless”
bitstream data format. Certain markers and marker segments
are defined in the standard to be “required”, and others, such as
the restart markers and the table marker segments, are optional.
The ZR36060 always includes the required markers when it
produces a compressed bitstream, and can be programmed to
include certain optional markers. To be decompressed by the
ZR36060, an image bitstream must include the required
markers. All markers included in the bitstream, required and
optional, are handled automatically, without host intervention, by
the ZR36060 in decompression.
The ZR36060 supports compression and decompression of
JPEG data that includes restart intervals. A restart interval is
defined as an integral number of MCUs, which are processed as
an “independent sequence”, meaning that it is possible to
identify and decode a restart interval within a JPEG data
sequence, without the need to decode whatever data precedes
it. In the context of baseline compression, this has significance
because the DC coefficients of the DCT are differentially
encoded. Note that the use of restarts is optional; it is acceptable
(and very common) to use no restart markers and encode the
whole image as a single sequence.
1.2.2.1 Required markers and marker segments
1.2.2 JPEG markers
The required markers for baseline JPEG are:
JPEG defines three data formats for the compressed bitstream,
all of which are supported by the ZR36060:
• Start-of-image, SOI (0xFFD8). This is the first marker in a
JPEG image bitstream.
• The interchange format, which contains the specifications of
all the tables required to decode the image.
• Start-of-frame marker segment, SOF0 (0xFFC0), followed
by a variable number of bytes depending on the number of
color components. For the ZR36060, there are always three
components and the segment has a length of 17 bytes. The
SOF segment is used to specify which quantization table to
use for each color component, and the number of blocks of
each color component in the MCU.
• the abbreviated format for compressed data, which can con-
tain some or none of the tables, under the assumption that
the remaining tables are known to the decoder and are al-
ready loaded in the decoder or can be loaded. This is
commonly used for motion video, in order to save the time
otherwise required to decode the tables from their
specifications.
• Start-of-scan marker segment, SOS (0xFFDA), followed by a
variable number of bytes depending on the number of color
components. The Huffman coded data follows immediately
after the last byte of the SOS segment. In the case of the
ZR36060, the length of the SOS segment is always 12 bytes.
The SOS segment is used to specify which Huffman table to
use for each color component.
• the abbreviated tables-only format, which contains no com-
pressed data but only tables. It is one means by which it is
possible to load tables into the decoder; in the ZR36060 the
other means is by specifying the tables to the device and is-
suing an explicit Load command.
4