How video encoders trade bits for quality: rate-distortion theory, the Lagrangian cost J = D + λR, and why RDO lives in the encoder, not the standard.
At every block, an encoder faces dozens of choices. Which block size? Which prediction mode? Which quantization step? The one piece of math running through all these choices is Rate-Distortion Theory.
Rate is the number of bits spent, and Distortion is the difference from the original. The two always move in opposite directions. Spend more bits and distortion drops; save bits and distortion rises. The encoder's goal is either to 'minimize distortion within a given bit budget' or to 'minimize bits at a given quality.'
The problem is how to combine two different units, 'bits' and 'distortion,' into one number you can compare. The answer is the Lagrange multiplier method.
J = D + λ·R
J : total cost. Pick the choice with the smallest value.
D : distortion (usually SSD, the sum of squared errors against the original)
R : number of bits that choice requires
λ : the weight that balances bits against distortion (Lagrange multiplier)When grocery shopping you have to compare 'price' and 'taste,' which are different units. If you set an exchange rate (λ) like "1 point of taste = $1," you can rank every product by a single number: 'price + λ×(10 - taste score).' When λ is large (bits are expensive), you give up some taste and pick the cheap one; when λ is small (bits are cheap), you put taste first.
λ isn't a fixed value; it changes with the target QP (quantization parameter). The lower you set the quality (the higher the QP), the larger λ gets, and the more aggressively the encoder moves toward saving bits.
An important fact: RDO is not defined in the standard. A standard only says 'these modes exist'; 'which mode to pick' is up to the encoder. The difference in competitiveness among open-source encoders like x264, x265, and SVT-AV1 mostly comes from how sophisticated and fast an RDO they implement. "Full RDO" (actually encoding every candidate and comparing) is the most accurate but overwhelmingly slow, so most practical encoders prune candidates ahead of time with heuristics.
How file size and quality change when the same encoder spends more time searching (a slower preset) can be seen in our x265 preset measurement.
The fundamental trade-off between bit usage (R) and quality loss (D).
The encoder's core formula for combining R and D into one number to compare candidates.
Rate-Distortion Optimization. The encoder algorithm that finds the decision minimizing J.
Quantization Parameter. The value that sets how coarsely to quantize. Directly tied to λ.
In the Lagrangian cost function J = D + λR, how does the encoder behave when λ is set large?
Which statement about 'RDO' is correct?