Ch. 3 · Anatomy of a Hybrid Codec

한국어日本語
7 min

In-Loop Filters Explained: Deblocking, SAO and ALF

Block-based coding leaves visible seams at block edges, so codecs filter each frame before it becomes a reference. See how deblocking, SAO and ALF differ.

When each block is quantized independently, values jump abruptly at the boundary between neighboring blocks. This is called a blocking artifact. The in-loop filter corrects this problem inside the decoder loop (before the picture is used as a reference frame).

Why 'in-loop' matters

The filtered result is used as the reference for predicting the next frames. So a well-designed filter doesn't just improve quality: it raises the accuracy of the reference frames and improves the compression efficiency of the frames that follow, too. This is the decisive difference from a simple post-processing filter — an in-loop filter is part of the standard, and decoders must apply it identically.

Deblocking filter

The oldest and most basic filter. It has existed in every mainstream codec since H.264. It smooths the pixels on both sides of a block edge, adjusting its strength by judging from the amount of pixel-value change (the gradient) whether the edge is a real object contour or a compression artifact.

Before filtering (step at the edge) Block edge After filtering (gentle transition)
Deblocking filter — turning an abrupt step at a block edge into a gentle transition

SAO — Sample Adaptive Offset (HEVC)

A filter newly introduced by HEVC. Where deblocking smooths the 'edge', SAO looks at the overall pattern of pixel values. It has two modes.

  • Band Offset — Adds a correction value to all pixels in a particular brightness range (band), fixing the brightness bias caused by quantization.
  • Edge Offset — Checks whether a pixel locally sticks out from its surroundings (a local extremum) and corrects it, reducing ringing artifacts.

ALF — Adaptive Loop Filter (VVC)

The most powerful and complex in-loop filter. It analyzes the directionality of each block region (whether it has horizontal, vertical, or diagonal texture) and chooses and applies the best of several pre-trained sets of filter coefficients. In effect, a small adaptive signal-processing filter is built into the codec.

FilterCodecsArtifacts targeted
DeblockingAll, from H.264Step artifacts at block edges
SAOHEVC, VVC (optional)Brightness bias, ringing
ALFVVCCompound quantization noise, loss of directional texture
CDEFAV1A directional filter applied after deblocking that takes over SAO's role
Loop RestorationAV1An additional restoration stage based on Wiener and self-guided filters
CCSO / GDFAV2Cross-component correction for chroma / detail-restoration filter (new)
In practice — filter order and compute cost

Several filters are applied in a fixed order (e.g., deblocking → SAO → ALF). Changing the order changes the result, so the standard specifies it strictly. In hardware decoder design, the in-loop filter chain easily becomes a pipeline bottleneck and takes up a large share of a decoder chip's silicon area and power. The steady addition of filters in AV2 likewise shows the compression efficiency ↔ decoder complexity trade-off.

In-loop filterIn-loop filter

A standardized filter applied right after reconstruction, before the picture is used as a reference frame.

Deblocking filterDeblocking filter

The most basic filter, softening step artifacts at block edges.

SAOSample Adaptive Offset

HEVC's filter. Corrects brightness bias and ringing with band/edge offsets.

ALFAdaptive Loop Filter

The filter in VVC. Selects and applies a trained set of filter coefficients based on directionality.

CDEFConstrained Directional Enhancement Filter

AV1's filter. Applied after deblocking, taking over SAO's role.

Loop RestorationLoop Restoration

AV1's additional restoration stage. Uses Wiener and self-guided filters to correct noise left after CDEF.

CCSO / GDFCross-Component Sample Offset / Guided Detail Filter

In-loop filter tools newly added in AV2. CCSO handles cross-correction between chroma components and GDF handles detail restoration (see Chapter 8).

Check yourself

What is the fundamental difference between an in-loop filter and a simple post-processing filter?