encoding.info
You are hereSourcePredictionTransformEntropy codingFiltersFramesDecisionsRate controlPerceptionQualityBitstreamSettingsEncoder map
Page 1 of 7 in Decisions

Distortion measures

Decisions · concept · added 2026-11-13

In Brief:
A distortion measure scores how far a candidate block is from the source block. Three are common, they respond differently to the same error, and encoders use them at different stages of choosing a candidate.

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.

SAD SATD SSD Integer motion search every candidate position Sub-pixel and mode pruning the promising ones Rate-distortion decision reconstructed and rate-estimated
Conceptual illustration of stages x264 can use, depending on settings. Box height stands for the number of candidates scored, which this page does not measure; work per candidate rises from left to right.

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.

4
← barely offbadly off →
Source
Candidate
Error
Transformed
positive negative. Colors show relative size within the pattern, so they do not change with error size. The transform's top-left square is the constant component (DC), which carries the average error.
SAD
SATD
SSD
Simplified demo: the block and the three error patterns are invented, and "error size" is the mean absolute error per pixel. The SATD shown is a single 8×8 Hadamard transform with the absolute sum divided by 4, the scale of the variant x264 calls sa8d; x264 also builds SATD from 4×4 transforms. Scores use unrounded values; the displayed gray pixels are rounded.

The stages in x264, which depend on settings:

  1. Integer motion search normally uses SAD. With --me tesa it can use SATD.
  2. Sub-pixel and fast mode comparisons use SATD when --subme is 2 or more and the encode is not lossless.
  3. 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

Sources

Read 2026-11-13, at the commits linked.