Context for the Development of H.264
By the early 2000s, digital video was becoming common partly through MPEG-2, used on DVDs and in early digital television broadcasts. The standard served many applications, but its compression efficiency limited Internet delivery at the bandwidth available at the time. A standard-definition movie on a DVD could occupy several gigabytes, and sending it over a typical DSL connection required a substantial bitrate. The growing number of video services increased the need for more efficient coding.
The response was a collaboration between the ITU-T Video Coding Experts Group and the ISO/IEC Moving Picture Experts Group. The design target was comparable quality at roughly half the MPEG-2 data rate, although the result depends on content and encoder settings. Finalized in 2003, the standard is known as in ITU-T documents and MPEG-4 Part 10, Advanced Video Coding (AVC), in ISO/IEC documents. It has been used for Blu-ray Discs, online services such as YouTube and Netflix, video conferencing, and mobile recording. The paired specifications describe both the coded syntax and the decoding process, which supports interoperability across storage, broadcast, and network applications.
Operating Principle: Spatial and Temporal Prediction
H.264 uses established methods for reducing spatial redundancy within frames and temporal redundancy between frames. It adds flexible block partitions, more precise motion vectors, multiple reference pictures, in-loop filtering, and entropy coding. These tools reduce the residual difference that must be represented after prediction. The decoder follows the order signaled by the stream to reconstruct samples for display and later predictions. Interoperability follows from the shared stream syntax and defined decoding process, which supports storage, transmission and network services.
Intra-frame Prediction: Coding Blocks Within a Frame
Like older codecs, H.264 uses I-frames as reference points coded without other frames. Within a frame, the encoder applies an integer transform related to the DCT together with . It uses already coded neighbors above and to the left to select a mode such as vertical, horizontal, or DC, then codes the difference between the block and its prediction. A smaller residual reduces the number of coefficients that need further coding, including in keyframes. Prediction does not restore details removed later by quantization in lossy coding.
Inter-frame Prediction: Motion Compensation
In P- and B-frames, H.264 uses . The encoder identifies a similar region in a reference picture, transmits a motion vector, and codes the residual difference. Block partitions, interpolation, and reference selection improve the prediction, leaving less data to represent. B-frames can use references in both directions, reducing temporal redundancy at the cost of memory and coding delay. The decoder reconstructs these pictures in the order required for display and reference management, which can differ from transmission order.
H.264 Coding Tools
The often-cited roughly 50% improvement over MPEG-2 is an averaged target or result from selected comparisons, not a fixed guarantee. Efficiency depends on content, resolution, bitrate, profile, level, and encoder settings. The tools below improve prediction accuracy or reduce the number of bits needed to represent the residual. Quality at the same bitrate also depends on quantization and encoder decisions, so practical results require comparing the same scenes and parameters.
1. Variable Block-Size Motion Compensation
Older standards like MPEG-2 were rigid. They divided the image into fixed-size macroblocks, typically pixels, and performed motion compensation for this entire block with a single motion vector. This worked well for large, uniformly moving areas, but it was inefficient for areas with complex motion or fine details.
H.264 allows the partition size to follow the motion. A macroblock can be divided into , , or blocks. Each block can be further partitioned into , , or . Large partitions suit simple backgrounds, while small ones suit object motion and fine texture, allowing the motion vector to describe local change more accurately. The encoder chooses a partition together with motion and signaling costs, so the smallest block is not always the most efficient. Partition signaling itself takes bits, so the decision balances prediction error against syntax overhead.
2. Quarter-Pixel Motion Vector Precision
Another improvement is motion-vector precision. MPEG-2 could reference positions with half-pixel accuracy. H.264 uses precision for luma samples.
These "sub-pixel" positions are calculated by interpolating samples from the reference frame; they are not additional stored pixels. For luma, a filter derives half-pixel positions, while quarter-pixel positions use real and intermediate values. Interpolation lets the encoder match a block shifted by a non-integer number of pixels more closely, reducing prediction error and the residual. The filter coefficients are specified by the standard, so a decoder can reproduce the same samples. Chroma components use their own sampling and precision rules, which is why the quarter-pixel statement is normally qualified for luma.
3. Multiple Reference Frames
Many older codecs mainly used the immediately preceding frame. H.264 allows the encoder to store and select multiple previous reference pictures, and for B-frame prediction, pictures later in display order. Depending on level and buffer parameters, it can keep up to 16 reference frames. More references improve the chance of a match but require memory, search work, and signaling of the selected index.
Multiple references help in several situations:
- Occlusion: When an object is temporarily hidden, the encoder can refer to a picture from before the occlusion and use it as a prediction candidate after the object reappears.
- Repetitive Motion: For oscillating motion such as a waving hand or bouncing ball, an earlier picture with a similar object position can be selected.
- Fading Scenes: During a cross-fade, references from the outgoing and incoming scenes can provide a more accurate prediction.
4. In-Loop Deblocking Filter
A common artifact of block-based compression is "blocking." Independent block processing can produce discontinuities at block edges, especially at low bitrates.
H.264 defines an in-loop . It analyzes samples on both sides of a boundary and can smooth them according to stream parameters. The filtered picture is used as a reference for later prediction, although the syntax allows the filter operation to be controlled. This reduces visible blocks and limits error propagation, affecting both the current picture and later references.
5. Advanced Entropy Coding (CABAC)
After transform and quantization, H.264 uses entropy coding to represent the resulting coefficients without loss at this stage. The standard supports CAVLC and . CABAC availability depends on the profile.
CABAC uses contexts selected for the type of bin being coded and updates their probabilities during the stream. Statistics from neighboring blocks can influence the model for the current block's coefficients. Compared with one fixed model for an entire frame, this better follows local data. For television signals, typical comparisons report savings of about 10 to 20 percent over CAVLC at similar quality, but the result depends on content and settings. CABAC also increases decoding complexity, so the profile must match the device and latency requirements.
Profiles and Levels: Decoder Constraints
H.264 describes decoder capabilities through and limits picture size, throughput, and bitrate through . Together they help determine whether a stream fits a device. Profile and level information is carried in stream parameters, so a player can reject configurations outside its limits.
- Profiles: A profile defines the tool set a decoder must support. A mobile video chat may need fewer features than a high-definition Blu-ray movie. Examples include:
- Baseline Profile: Uses a simpler tool set without B-frames or CABAC. It was intended among other uses for lower-power devices and low-latency connections.
- Main Profile: Adds B-frames and CABAC among other tools compared with Baseline. It was used in digital television and applications requiring more coding efficiency.
- High Profile: Extends Main with tools for high-definition content, including quantization matrices. It is found in Blu-ray material and online services.
- Levels: A level limits parameters including macroblocks per second, maximum picture size, and bitrate. Level 4.1 can support at 30 frames per second under the relevant constraints. material requires a higher level; Level 5.1 allows higher throughput and frame rates than lower levels, but exact support depends on the stream parameters. A decoder must meet the limits of both the selected profile and level, and the resolution label alone does not specify the maximum frame rate or bitrate.