Ch. 5 · AVC / H.264

한국어日本語
6 min

CABAC vs CAVLC: How H.264 Entropy Coding Works

How CABAC turns syntax values into bins, picks from about 460 contexts, and saves 9–14% bitrate over CAVLC, and why it is hard to parallelize.

In Chapter 2 we learned the principle of CABAC (Context-Adaptive Binary Arithmetic Coding). H.264 was the first standard video codec to adopt it, and it brought an average bitrate saving of 9–14% over CAVLC, H.264's own Huffman-family alternative — the pure gain from swapping only the entropy coder while keeping every other tool the same.

The three steps of CABAC

  1. 1Binarization — converts every syntax value (modes, motion vectors, coefficients, etc.) into a string of binary symbols (bins). Different binarization schemes, such as unary codes and Exp-Golomb, are used depending on the kind of value.
  2. 2Context model selection — as in Chapter 2, it looks at the state of neighboring blocks to choose the probability (the context) that this bin will be 0 or 1. H.264 defines about 460 contexts.
  3. 3Arithmetic coding + probability update — performs arithmetic coding with the selected probability, then updates that context's probability for next time based on the value that actually occurred.
Syntax value Binarization→ bin string Context selectdetermine prob. P Arithmeticcoding Update probability with the result
The CABAC encoding flow — Chapter 2's 'context modeling' concept as a real pipeline
Why wasn't CABAC used everywhere at first?

CABAC's probability update has to happen sequentially, bin by bin, which makes it extremely hard to parallelize (the 'serial entropy coder' problem mentioned in Chapter 3). Mobile SoCs in the early 2000s lacked the compute to run it in real time, so Baseline Profile supported only the simpler, easier-to-parallelize CAVLC. As hardware improved, CABAC became effectively the only choice, and from HEVC on, CAVLC disappeared altogether.

In practice

CABAC's sequential nature is still a bottleneck in hardware decoder design. To decode 4K/8K at high frame rates in real time, CABAC throughput becomes a key performance metric. Attempts to ease this problem (tiles, WPP) are covered in Chapter 6 on HEVC.

BinarizationBinarization

The process of turning a syntax value into a binary string (bins) that can be arithmetic-coded.

CABACCABAC

Context-adaptive binary arithmetic coding, introduced by H.264. The practical implementation of Chapter 2's arithmetic coding.

CAVLCCAVLC

Context-Adaptive Variable-Length Coding. H.264's Huffman-family alternative: lighter than CABAC but with lower compression.

Exp-GolombExp-Golomb code

A variable-length binarization scheme that assigns fewer bits to smaller values. Often used in CABAC's binarization step.

Check yourself

Why did the low-end Baseline Profile use CAVLC instead of CABAC in the early days of H.264?