How media compression works
Prediction, transforms, quantisation and entropy coding in modern media codecs.
The compression pipeline
Modern codecs differ in details, but many share the same broad pipeline: predict, transform, quantize, and entropy-code the remaining information.
1. Predict what the frame or block should look like
2. Store only the residual difference
3. Transform and quantize that residual
4. Entropy-code the result into a compact bitstream
Video compression concepts
Intra prediction
Instead of coding every pixel directly, codecs often predict a block from nearby pixels in the same frame. Only the prediction error needs to be stored.
Inter prediction
Video frames are usually similar over time. A codec can point to a block in a previous or future frame and store a motion vector plus the remaining difference.
Residuals
Once a prediction is made, the codec stores what is left over. Good prediction means a smaller residual and fewer bits spent.
Common questions
What are the main steps in modern compression?
Many codecs follow a similar broad process: prediction, transform, quantization, and entropy coding. The exact tools differ by codec.
What does quantization do in a codec?
Quantization reduces precision to save bits. Stronger quantization usually creates smaller files but can also create visible or audible artifacts.
Why do codecs use prediction?
Prediction lets the encoder describe what changed instead of storing everything directly. Good prediction leaves a smaller residual, which takes fewer bits to encode.
What is entropy coding?
Entropy coding is the final packing step that stores common patterns with fewer bits and rare patterns with more bits, making the compressed stream smaller.
A conceptual coding pipeline
Lossless codecs omit irreversible quantisation. Audio codecs may instead use prediction, frequency-domain analysis and perceptual bit allocation. Entropy coding is reversible by itself.
Read more: transform coding, Huffman coding, GOPs and keyframes.