A transform packs a residual block's energy into a few frequency coefficients. Learn why codecs use the DCT, why standards use integer versions, and what MTS adds.
After prediction, what remains is the residual block. You could quantize and entropy-code it right away, but one more step comes first — the transform. It converts the spatial domain (pixel values) into the frequency domain (coefficients).
The residual of a natural image is usually a slowly varying signal. Decompose such a signal into frequencies and the energy gathers in a few low-frequency coefficients (overall brightness and tone changes), while the high-frequency (fine detail) coefficients are mostly close to 0. Once scattered information is 'concentrated' into a few large numbers, the quantization and entropy coding that follow work far more efficiently.
The transform codecs use overwhelmingly often is the DCT-II. In theory, for natural signals (approximated as a first-order Markov process), the DCT comes very close to the KLT (Karhunen-Loève Transform, the statistically optimal transform). The KLT has to be recomputed for each set of data, so it isn't practical, but the DCT achieves almost the same effect with a fixed set of basis functions.
It's like transcribing a chord into sheet music. Instead of recording the complex air vibration coming out of a speaker (the spatial domain) as-is, you write it down as 'a chord mixing C, E, and G' (frequency components), and you can reproduce the same sound with much less information. In most music, a few main notes (low-frequency coefficients) hold most of the energy.
Real codec standards don't use the pure DCT (real-number arithmetic). The encoder and decoder must produce bit-for-bit identical results (conformance, see Chapter 1), but floating-point arithmetic can have slightly different rounding errors across platforms and compilers. So the standards from H.264 onward define an integer transform that approximates the DCT. H.264 was the first to establish this approach, and every codec since has followed it.
Early codecs used only fixed 4×4/8×8 DCTs, but recent codecs use a range of transform sizes from 4×4 up to 64×64 (or 32×32) to match the CU size, and even let the encoder choose the best of several transform kernels, such as the DST (Discrete Sine Transform) in addition to the DCT. VVC's MTS (Multiple Transform Selection) is the representative example. Some sharply directional edges suit the DST better, while smooth areas suit the DCT better.
A transform that decomposes a spatial signal into frequency components. A core tool of video codecs.
The statistically optimal transform. The DCT is a practical approximation of it.
A standard transform that approximates the real-valued DCT with integer arithmetic, for conformance.
A VVC tool for choosing among several transform kernels such as DCT/DST.
Why do codec standards use integer transforms instead of the pure real-valued DCT?