← All articles

H.264 Baseline vs High Profile on an FPGA: what CABAC buys

The same pictures, the same quantizer, two entropy coders. Measured bit rates on a Nexys Video, including a case where Baseline wins.

IronKernel · · Video

H.264 has two entropy coders. Constrained Baseline uses CAVLC and High Profile adds CABAC. Both code the same motion vectors and coefficients, so at a fixed quantizer the decoded picture is the same and only the number of bits changes. We measured that difference on our own encoder: IronH264 for Baseline, and the High Profile extension that plugs into it.

The two coders

CAVLC codes each block of coefficients with variable-length tables, chosen from the neighboring blocks. It is simple, and it works in whole bits: the shortest code is one bit, however likely the symbol.

CABAC turns every syntax element into binary decisions and codes each one with an arithmetic coder. A context model tracks how likely each decision is and adapts as the picture is coded. A very likely decision costs a fraction of a bit. The cost is a serial coding loop and the context memory.

High Profile also allows an 8 × 8 transform for inter-predicted luma. A larger transform packs smooth areas into fewer coefficients and does worse on fine detail, so the extension can fix the choice or select per macroblock.

Board measurements at 1080p30

These are from a Nexys Video with two encoder engines at 90 MHz and constant QP 28. The inputs are identical across the columns.

InputBaseline CAVLCHigh Profile CABACSaving
Motion and noise pattern27.23 Mb/s23.83 Mb/s12.5%
Scrolling bars0.52 Mb/s0.25 Mb/s52%
Ten-minute soak27.54 Mb/s, 18,002 pictures24.02 Mb/s, 18,002 pictures12.8%

The two inputs sit at opposite ends. The scrolling bars are almost all skipped macroblocks and zero residual, which is where one-bit minimum codes hurt CAVLC most, so CABAC halves the rate. The noise band is near-random data that no entropy coder compresses well, and the saving falls to about an eighth. Real camera scenes land between those two.

Where Baseline wins

CABAC is not always smaller. In RTL simulation over two P pictures, a short 1080p sequence of moving objects took 2,640 bits with Baseline and 3,016 with CABAC. CABAC's context models start from fixed states at every slice and adapt as they code, so a slice with very little data gives them little to adapt on. That is the likely cause here. The engines also split the picture into bands with at least one slice each, which shortens the slices further.

Simulation, bits in two P picturesBaselineCABAC 4 × 4CABAC fixed 8 × 8
720p scrolling bars16,7288,5288,368
720p pan9,4647,3207,800
1080p moving objects2,6403,0163,016

The pan shows the transform trade as well: fixed 8 × 8 used more bits than 4 × 4 on that content. These are synthetic scenes, so evaluate with pictures that look like the product's.

What it costs in logic

The CABAC-only netlist in the demo image is 2,719 LUTs and 1,295 flip-flops on the XC7A200T at 90 MHz. The parent encoder keeps its prediction, motion search, picture memory and NAL packing; the extension replaces the entropy stage and, when selected, the inter-luma transform path. Registers, DDR buffers and the bitstream rings are the same, so software written for Baseline runs unchanged and reads the available tools from a status register.

Choosing

Baseline decodes on everything and is the right start for a link with bit rate to spare. High Profile earns its place when the link is the limit: a radio, a shared uplink or recorded storage. Software players such as VLC and ffplay decode High Profile. Check a fixed-function receiver before committing to it.

A change of profile forces an IDR picture, so a receiver decodes through the transition. The timed demo for the Nexys Video shows this: it runs High Profile for 30 minutes, then continues the same stream in Baseline. In the recorded run the change came 1,799.82 seconds after configuration, and the receiver logged 59,404 pictures over 1,980 seconds with none dropped.

Further reading

Choosing an H.264 profile for an FPGA design?

Send the FPGA part, the resolution and frame rate, and the bit rate your link can carry.