Distortion measures
A distortion measure scores how far a candidate block is from the source block. Three common ones are the sum of absolute differences (SAD), the sum of absolute transformed differences (SATD) and the sum of squared differences (SSD). Encoders use them at different stages of candidate evaluation.
SAD = Σ |candidate − source| SATD = Σ |H(candidate − source)| / scale H: Hadamard transform SSD = Σ (candidate − source)²
Why three
An encoder compares far more candidates than it can afford to encode. It uses inexpensive prediction scores to reject many of them early. For the candidates that remain it may estimate a fuller coding cost: transform, quantize and reconstruct the residual, then combine distortion with estimated bits. That last stage is expensive because of the reconstruction, not because of the arithmetic of SSD.
How they differ
Below are an 8×8 source block, a candidate, the candidate's error (candidate minus source), and that error after a Hadamard transform. The three error shapes all have the same SAD. Switch between them and watch the other two measures.
sa8d; x264 also builds SATD from 4×4 transforms. Scores use unrounded values; the displayed gray pixels are rounded.- SAD is the same for all three. The model is built that way: SAD adds up error magnitudes and ignores where they sit.
- SATD responds to structure in the error. The Hadamard transform is built from additions and subtractions only. In this model an even offset collapses into one coefficient, so SATD is a quarter of SAD; for the noise and the column it is about twice SAD. That makes it a useful predictor for ranking candidates. It is not a bit count.
- SSD weights large errors more. Squaring makes one error of 8 count as much as sixty-four errors of 1, so the one-column error scores eight times the even offset.
The stages in x264, which depend on settings:
- Integer motion search normally uses SAD. With
--me tesait can use SATD. - Sub-pixel and fast mode comparisons use SATD when
--submeis 2 or more and the encode is not lossless. - Reconstruction-based decisions begin at
--subme 6, or 7 in B slices. Candidates are transformed, quantized and reconstructed, and the distortion against the source is SSD, plus a psychovisual term when that is enabled; see Rate-distortion optimization.
The early stages usually score a prediction before the residual is quantized. That is a property of the stage, not of the measure: any of the three can compare any two blocks.
Trade-offs
- They do not model visual masking. The same error can get the same score over a smooth background and over a textured one, even though its visibility differs.
- SSD fixes the peak signal-to-noise ratio (PSNR). PSNR is computed from mean squared error, which is SSD divided by the sample count. For a given block size and bit depth, lower SSD means higher PSNR.
- SATD is a search metric, not the coding path. It does not reproduce the codec's transform, quantization and entropy coding, so it is used to rank candidates, not to predict final bits or error.
- The units differ. SAD and SATD grow in proportion to the error and SSD with its square, which is why x264 and x265 use differently scaled lambdas with them; see How lambda follows the quantization parameter.
Sources
Read 2026-11-13, at the commits linked.
- x264 at commit c24e06c (GitHub mirror):
mbcmp_init(SAD or SATD by--subme, lossless and--me tesa),x264_pixel_satd_4x4,x264_pixel_sa8d_8x8and its divide by 4, where reconstruction-based mode decision begins,ssd_plane, with the psychovisual term,rd_cost_mb. - Not checked: other encoders. The stages are described as x264 uses them, and the numbers in the demo are computed by the page itself.