DCT Sequential Encoding

Overview
The DCT sequential mode of operation consists of the FDCT and Quantization steps, and the multiple-componont control. In addition to the Baseline sequential codec, other DCT sequential codec are defined to accommodate the two different sample precisions (8 and 12 bits) and the two different types of entropy coding methods (Huffman and arithmetic).

Baseline sequential coding is for images with 8-bit samples and uses Huffman coding only. It also differs from the other sequential DCT codecs in that its decoder can store only two sets of Huffman tables (one AC table and DC table per set). This restriction means that, for images with three or four interleaved components, at least one set of Huffman tables must be shared by two components. This restriction poses no limitation at all for noninterleaved components; a new set of tables can be loaded into the decoder before decoompression of a noninterleaved component begins.

For many applications which do need to inerleave three color components, this restriction is hardly a limitation at all. Color spaces (YUV, CIELUV, CIELAB, and others) which represent the chromatic ("color") information in two components and the achromatic ("grayscale") information ina third are more efficient for compression than spaces like RGB. One Hufman table set can be used for the achromatic component and aone for the chrominance components. DCT coefficient statistics are similar for the chrominance components of most images, and one set of Huffman tables can encode both almost as optimally as two.

In this part, Baseline sequential coding will be shown and one example will be introduced. Other DCT sequential coding will be noted briefly.
 

Baseline Sequential Coding
The DCT, Quantization, DC differencing and zig-zag ordering processing steps for the Baseline sequential codec proceed just as described before. Prior to entropy coding, there usually are few nonzero and many zero-valued coefficients. The task of entropy coding is to encode these few coefficients efficiently. The description of Baseline sequential entropy coding is given in two steps : conversion of the quantized DCT coefficients into an intermediate sequence of symbols and assignment of variable-length codes to the symbols.

 
Intermediate Entropy Coding Representations

 
AC intermediate entropy coding representations
 
In the intermediate symbol sequence, each nonzero AC coefficient is represented in combination with the "runlength" (consecutive number) of zero-values AC coefficients which precede it in the zig-zag sequence.  Each such runlength/nonzero-coefficient combinatin is represented by a pair of symbols :

 
<(RUNLENGTH, SIZE), AMPLITUDE>
 
The first symbol represents RUNLENGTH and SIZE and the second represents the AMPLITUDE of the nonzero AC coefficient.

RUNLENGTH
 

RUNLENGTH is the number of consecutive zero-valued AC coefficients in the zig-zag sequence preceding the nonzero AC coefficient being represnted. It represents zero runs of length 0 to 15. But actual zero-runs in the zig-zag sequence can be greater than 15, so the first symbol (15, 0) is interpreted as the runlength = 16. There can be up to 3 consecutive (15, 0) before the teminating the first symbol whose RUNLENGTH value completes the actual runlength. So the symbol (0,0) means EOB (end of block), and can be viewed as an "escape" symbol which terminates the8x8 sample block.

SIZE
 

SIZE is the number of bits used to encode AMPLITUDE. The possible range of quantized AC coefficients determines the range of values which the AMPLITUDE and the SIZE must represent. If the 64-point (8x8 block) input signal contains N-bit integers, then the DCT coefficients can grow by at most 3 bits. Baseline sequential has 8-bit integer source samples in the range [-127, 127], so quantized AC coefficient amplitudes are covered by integers in the range [-1024, 1023]. The signed-integer encoding uses AMPLITUDE codes of 1 to 10 bits in length, so SIZE represents value from 1 to 10, and RUNLENGTH represents values from 0 to 15.

DC intermediate entropy coding representations
 

The intermediate representation for an 8x8 sample block's differential DC coefficient is structured similarly. The first symbol, however, represents only SIZE; the second symbol represents AMPLITUDE as before :

 
< SIZE, AMPLITUDE>
 
Because the DC coefficient is differentially encoded, it is covered by twice as many integer values [-2048, 2047], so one additional level must be added to the bottom of Table for DC coefficients. The first symbol for DC coefficients thus represents a value from 1 to 11.

 
Variable-Length Entropy Coding
 
After all coefficients are represented by the intermediate symbols, variable-length codes are assigned. For each 8x8 block, the DC coefficient's intermediate symbol is coded and output first.

For both DC and AC coefficients, each first symbol is encoded with a variable-length code (VLC) from the Huffman table set assigned to the 8x8 block's image component. The second symbol is encoded with a variable-length integer (VLI) code in Table. Note that VLIs are not Huffman codes. The length of a VLC (Huffman code) is not known until it is decoded, but the length ofa VLI is stored in its preceding VLC.

Huffman codes (VLCs) must be specified externally as an input to JPEG encoders. The JPEG proposal includes an example set of Huffman tables in its information annes, but because they are application-specific, it specifies none for required use. However, the VLI codes are "hardwired" into the proposal, because they are far more numerous, can be computed rather than stored, and have not been shown to be appreciably more efficient when implemented as Huffman codes..

 
 
Others

 
The structure of the 12-bit DCT sequential codec with Huffman coding is a straightforward extension of the entropy coding method described previously. Quantized DCT coefficients can be 4 bits alrger, so the SIZE and AMPLITUDE extend accoringly.

JPEG Introduction