How CDEF Improves Visual Quality in AVIF Images

The Constrained Directional Enhancement Filter (CDEF) is a core in-loop filtering technology used in the AVIF image format, inherited from the AV1 video codec. It significantly enhances visual fidelity by targeting and eliminating ringing artifacts and compression noise along high-contrast boundaries without blurring the underlying picture. By analyzing edge directions and applying adaptive, non-linear smoothing parallel to those edges, CDEF ensures that AVIF files retain sharp lines, clean text, and natural textures even at aggressive compression levels.

The Problem CDEF Solves: Ringing Artifacts

Block-based transform coding, which forms the foundation of formats like AVIF, naturally introduces high-frequency noise known as ringing artifacts (or the Gibbs phenomenon). When an image contains strong contrast—such as dark text on a bright background or hard architectural silhouettes—the quantization process discards fine frequency components. This results in visible ripples, halos, or speckled noise around sharp contours. While traditional deblocking filters smooth the seams between block boundaries, they cannot address ringing artifacts situated inside the blocks.

Step 1: Direction Estimation

To address these artifacts without destroying fine details, CDEF first performs a directional search. The encoder divides the image into small blocks (typically 8x8 pixels) and analyzes the gradient vectors to determine the dominant direction of any edges present in that area. It selects one of eight possible directions (ranging from 0 to 157.5 degrees). If an area lacks a distinct edge or is flat, the filter identifies this state to avoid applying directional bias.

Step 2: Adaptive Non-Linear Filtering

Once the dominant direction is established, CDEF applies a non-linear spatial filter tailored to that specific angle:

Placement in the AVIF Pipeline

CDEF operates as an in-loop filter, meaning it processes the image data directly inside the decoding pipeline:

  1. Deblocking Filter: Smooths the grid-like block boundaries.
  2. CDEF: Cleans up ringing and preserves edge directionality.
  3. Loop Restoration: Restores fine textures using Wiener or self-guided filters.

By running immediately after the deblocking stage, CDEF provides clean, noise-free edges for the subsequent restoration step, preventing later algorithms from amplifying compression errors.

Direct Impact on User Experience

By actively reconstructing edge integrity, CDEF allows AVIF to excel where older formats like JPEG struggle: