What Is the End-of-Block Marker in JPEG Encoding?

This article explains the purpose and function of the End-of-Block (EOB) marker within JPEG entropy encoding. It covers how an image block is transformed and ordered, why the EOB marker is necessary, and how it drastically optimizes file compression by signaling the termination of non-zero frequency data.

The Context: Transform, Quantization, and the Zig-Zag Scan

To understand the EOB marker, it is necessary to look at how a standard JPEG processes image data:

  1. Discrete Cosine Transform (DCT): The image is divided into 8×8 pixel blocks. The DCT converts spatial pixel data into 64 frequency coefficients: one DC coefficient (the average block brightness) and 63 AC coefficients (representing details from low to high frequencies).
  2. Quantization: The coefficients are divided by values in a quantization matrix and rounded to integers. Because human vision is less sensitive to high-frequency details, high-frequency coefficients are heavily quantized and often become zero.
  3. Zig-Zag Ordering: The 8×8 matrix is reordered linearly using a zig-zag pattern. This places the low-frequency coefficients first and groups the long runs of zero-value high-frequency coefficients toward the end of the sequence.

What the End-of-Block (EOB) Marker Signifies

The End-of-Block (EOB) marker is a special symbol used during the entropy encoding phase (typically Huffman coding) to indicate that all remaining AC coefficients in the current 8×8 block are zero.

Instead of writing out repeated run-length codes for every remaining zero up to the 64th coefficient, the encoder emits a single EOB code word immediately following the last non-zero coefficient.

How the EOB Marker Works in Practice

During run-length encoding (RLE), non-zero coefficients are encoded as a pair: (run of preceding zeros, coefficient value).

Significance to Compression Efficiency

The EOB marker is critical to JPEG compression efficiency: