Zig-zag scan is the specific path the encoder uses to read out the coefficients of a transformed block — starting at the top-left corner and zig-zagging diagonally to the bottom-right. The point: after the DCT, the top-left coefficient holds the most important information (the average brightness of the block), the values near it hold the next-most-important (broad shapes), and the bottom-right values hold the least important (the finest detail). Zig-zag scan turns the 2D block into a 1D sequence that puts important values first and unimportant values last.

This ordering is crucial for compression efficiency. After quantization, most of the high-frequency coefficients in the bottom-right round to zero. By scanning zig-zag, those zeros all end up at the end of the sequence, forming a long run that run-length coding compresses to almost nothing. If you scanned the block in row-major order instead, the zeros would be scattered through the sequence and run-length coding wouldn't have anything to compress. The simple geometric trick of changing the reading order is what makes the rest of the pipeline efficient.

For a product team, zig-zag scan is invisible plumbing inherited from JPEG. There's nothing to configure. Modern codecs (HEVC, AV1, VVC) actually use more sophisticated scan patterns — vertical-first or horizontal-first or even adaptive based on the dominant edge direction in the block — but the underlying idea is the same: arrange the coefficients so that the runs of zeros are as long as possible at the end. It's a small piece of the encoder pipeline, but a piece that everything downstream depends on.