Ch. 5 · AVC / H.264

한국어日本語
6 min

H.264 Macroblocks and NAL Units Explained: SPS, PPS and Slices

How H.264 splits video into 16×16 macroblocks and packages it in NAL units (SPS, PPS, slices, SEI), and why a missing SPS/PPS breaks playback.

In Chapter 3 we previewed the variable block partitioning of modern codecs. H.264 uses the original form of that idea, the macroblock: a fixed 16×16 pixel unit that can be subdivided further, down to 8×8 and 4×4, for prediction and transform.

16×16 16×8 / 8×16 8×8 × 4 down to 4×4
Macroblock sub-partitioning — start at 16×16 and split smaller when needed
Connection to Chapter 3

The macroblock's fixed 16×16 starting point and its limited sub-partitioning (down to 4×4) are the forerunner of the HEVC recursive quadtree from Chapter 3 (from 64×64 down to arbitrary depth). H.264's structure was comparatively simple, able to split only one more level at a time, and that limitation was the direct motivation for HEVC's CTUs and quadtree.

NAL units — putting the bitstream in envelopes

An H.264 bitstream is a sequence of pieces called NAL (Network Abstraction Layer) units. Each NAL unit carries either compressed video data or configuration information, like an envelope that may hold a letter (video data) or a contract (configuration).

NAL unit typeWhat it carries
SPS (Sequence Parameter Set)Sequence-wide settings such as resolution, profile/level, and frame rate (includes the VUI — the three CICP values from Chapter 1 live here)
PPS (Picture Parameter Set)Picture-level settings such as the entropy coding method and quantization parameters
IDR / non-IDR sliceThe actual compressed video data
SEI (Supplementary Enhancement Information)Auxiliary information such as static HDR metadata (MaxCLL/MaxFALL, mastering display info) and caption timing
In practice — no SPS/PPS, no playback

Most problems like "the video plays but the first second is garbled" or "it won't play when I splice in from the middle of a stream" come from missing or mismatched SPS/PPS. In live streaming, the standard practice is to repeat the SPS/PPS at every keyframe, so a decoder can start playback whenever it joins (a midstream join). This matters especially for adaptive streaming such as HLS/DASH (Chapter 10).

MacroblockMacroblock

H.264's basic processing unit. Starts at 16×16 pixels and can be subdivided.

NAL unitNAL unit

The transport unit that makes up an H.264/HEVC bitstream. Carries either video data or configuration information.

SPS / PPSSPS / PPS

Sequence-level and picture-level configuration. Required to initialize the decoder. The VUI (the three CICP values) lives inside the SPS.

SEISEI message

Auxiliary information that has no bearing on compression but is needed for playback, such as static HDR metadata like MaxCLL/MaxFALL.

Check yourself

Why are the SPS/PPS repeated at every keyframe in live streaming?