How AVIF Manages Variable Block Sizes

The AVIF image format achieves superior compression efficiency by utilizing the AV1 codec’s flexible partitioning system, which dynamically divides an image into blocks ranging from 128x128 down to 4x4 pixels. This article explains the mechanics behind AVIF's recursive block partitioning, the multi-way split structure used to handle different visual textures, and how Rate-Distortion Optimization (RDO) determines the optimal block layout to balance visual fidelity with minimal file size.

Superblocks as the Structural Foundation

AVIF processes an image by first organizing it into a grid of base units known as superblocks. In the AV1 architecture underpinning AVIF, a superblock defaults to a size of 128x128 pixels (though it can also be configured to 64x64 pixels). Rather than forcing uniform processing across the entire grid, these superblocks act as the root level of a nested hierarchical tree, allowing the encoder to adaptively analyze and subdivide local image content.

Recursive 10-Way Partition Tree

To break a superblock down to smaller components, AVIF uses a recursive partitioning tree that supports 10 distinct split modes. While older standards like JPEG use fixed 8x8 blocks and basic VP9 implementations rely on 4-way quadtrees, AVIF allows blocks to be split into both square and non-square configurations:

This recursive process continues downward through intermediate block sizes—such as 64x64, 32x32, 16x16, and 8x8—until reaching the smallest supported limit of 4x4 pixels.

Rate-Distortion Optimization (RDO)

AVIF decides whether to keep a large block or subdivide it down to 4x4 using Rate-Distortion Optimization (RDO). During encoding, the system calculates a cost function balancing two factors: "rate" (the number of bits required to encode the block structure, prediction vectors, and residual data) and "distortion" (the mathematical error or visual variance introduced by compression).

The encoder evaluates several partition configurations for a given area. If a smooth patch can be represented accurately using a single 128x128 or 64x64 block with very few bits, the encoder preserves the larger size. If a region contains sharp edges or fine details, RDO determines that spending more bits on multiple smaller blocks down to 4x4 results in a significant reduction in visual distortion, justifying the increased data cost.

Dynamic Allocation in Practice

Variable block sizing allows AVIF to distribute bits where the human eye needs them most:

Transform Block Integration

Once the spatial partition tree is established, AVIF applies transform coding to compress the remaining image data. The size of the transform block typically matches the partition block size, though larger partitions can also host multiple smaller transforms (down to 4x4). AVIF pairs variable transform sizes with flexible transform types—such as Discrete Cosine Transform (DCT) and Asymmetric Discrete Sine Transform (ADST)—ensuring that the mathematical representation of frequencies perfectly matches the geometric boundaries selected during partitioning.