What Is the AV1 Constrained Directional Enhancement Filter?
The Constrained Directional Enhancement Filter (CDEF) is a key in-loop filtering tool in the AV1 video codec designed to eliminate ringing artifacts and edge noise while preserving sharp visual details. Positioned directly after the deblocking filter and before loop restoration in the decoding pipeline, CDEF detects the primary direction of edges within small pixel blocks and applies a non-linear low-pass filter along those edges. By smoothing along edge contours rather than across them and clamping changes to prevent detail loss, CDEF significantly improves visual quality and coding efficiency without introducing heavy computational overhead.
Role in the AV1 Decoding Pipeline
Video compression often introduces high-frequency noise near sharp edges—an artifact known as "ringing"—due to coarse quantization in the frequency domain. Traditional deblocking filters smooth out block boundary discontinuities but do not resolve ringing occurring inside block interiors.
To resolve this, AV1 places CDEF as the second stage in its three-step in-loop restoration pipeline:
- Deblocking Filter: Smoothes unnatural boundaries formed between transform and prediction blocks.
- CDEF: Targets and suppresses ringing artifacts around complex edges.
- Loop Restoration Filter: Applies Wiener or self-guided restoration filters to recover fine textures and reduce overall distortion compared to the original frame.
How CDEF Works
CDEF combines the principles of two earlier experimental filters: the Directional Deringing Filter from the Daala project and the Constrained Low-Pass Filter (CLPF) from the Thor project. The filter processes frames in two primary phases: direction search and constrained directional filtering.
1. Direction Search
The filter divides a frame into small blocks, typically 8x8 pixels. For each block, CDEF tests eight possible directions (spanning angles from 0 to 180 degrees) by calculating the variance of pixels along each line. The direction that minimizes the variance along its path is selected as the dominant edge direction for that block. Because this search relies on reconstructed pixel values, both the encoder and decoder can determine the direction independently without spending bitstream overhead to signal it.
2. Directional Filtering
Once the primary direction is established, CDEF applies a one-dimensional filter aligned with that specific angle. A primary filter acts along the detected edge, followed by a secondary cross-filter aligned at a 45-degree angle to the primary axis to capture residual noise. Because the smoothing is oriented along the edge rather than across it, the edge retains its sharpness and high contrast.
3. Constrained Clamping
To prevent the filter from accidentally blurring genuine image details, CDEF uses a non-linear constraint function. The difference between the original pixel value and the filtered value is strictly clamped based on adjustable threshold parameters (primary and secondary strengths). If a surrounding pixel differs drastically from the target pixel, its influence is capped or ignored entirely, ensuring that only small ringing artifacts are removed while true textures remain intact.
Key Benefits of CDEF
- Artifact Reduction: Effectively eliminates halo and mosquito noise around high-contrast edges, such as text overlays, subtitles, and sharp outlines.
- Detail Preservation: Edge-aware filtering and threshold clamping prevent the muddy or over-softened appearance typical of standard low-pass filters.
- Bitstream Efficiency: By cleaning reference frames during the encoding loop, subsequent frames require fewer bits to predict, boosting overall compression efficiency (BD-rate).
- Low Complexity: The mathematical operations used in CDEF are simple additions, subtractions, and bit shifts, making it highly suitable for hardware implementation and SIMD parallelization in software decoders.