How AVIF Prevents Blocking Artifacts in Compression
AVIF (AV1 Image File Format) maintains impressive visual clarity at extremely low bitrates where legacy formats like JPEG degrade into severe pixelation. Traditional formats typically suffer from harsh, grid-like "checkerboard" blocking artifacts when heavily compressed. AVIF circumvents this problem by employing technologies derived from the AV1 video codec, primarily multi-stage in-loop filtering, flexible recursive block partitioning, and advanced transform kernels that adapt to image content dynamically.
Flexible Block Partitioning
Legacy image formats like JPEG divide an image into rigid 8x8 pixel blocks, quantizing each block independently regardless of content complexity. When quantization is aggressive, the sharp differences between adjacent blocks create visible seams.
AVIF replaces rigid grids with dynamic superblocks up to 128x128 pixels. These superblocks can be recursively split using a tree structure into sizes as small as 4x4 pixels, supporting square, rectangular, and asymmetrical splits (such as 1:2, 2:1, 1:4, and 4:1). Flat regions, like a clear sky or smooth background, are encoded using large continuous blocks, eliminating internal block boundaries altogether. Smaller blocks are reserved solely for high-detail areas, drastically reducing the total number of artificial seams in an image.
Multi-Stage In-Loop Filtering
The primary defense against edge discontinuities in AVIF is its sequential in-loop filtering pipeline. Because these filters run inside the encoding and decoding loop, future predictions rely on the filtered image, preventing artifacts from compounding.
Deblocking Filter: The first stage targets the grid lines directly. It analyzes the boundaries between transform blocks and applies adaptive smoothing based on the quantization level and edge sharpness. If a boundary matches the mathematical footprint of a compression artifact rather than a real object edge, the filter blurs the seam across the boundary to restore continuity.
Constrained Directional Enhancement Filter (CDEF): After deblocking, CDEF addresses ringing and remaining block edges. It determines the primary direction of edges within each 8x8 block and applies an adaptive 1D filter along that specific direction. By filtering parallel to detected edges rather than across them, CDEF smooths out boundary noise without dulling sharp lines or structural contrast.
Loop Restoration: The final stage applies either a separable Wiener filter or a Self-Guided Restoration filter. These mathematical algorithms compare the filtered result against the original uncompressed source, reconstructing high-frequency details and fine textures that may have been over-smoothed during earlier filtering stages.
Diverse Transform Types
JPEG relies exclusively on the Discrete Cosine Transform (DCT), which assumes symmetrical boundary conditions that often fail at high compression levels, producing prominent edge steps.
AVIF utilizes an extensive library of transforms, including standard DCT, Asymmetric Discrete Sine Transforms (ADST), flipped ADST, and Identity transforms. By allowing horizontal and vertical passes to use different transform types, the encoder can model directional gradients, shadows, and sharp cutoffs accurately. This mathematical flexibility ensures that the reconstructed pixels align naturally with neighboring blocks, preventing the frequency mismatch that causes visible blocking.