What Is an AVIF Grid Image and How It Works
An AVIF grid image is a specialized construct within the AV1 Image File Format that combines multiple smaller, independently encoded image tiles into a single visual canvas. This article explains the technical foundation of AVIF grid images, examines the role of the underlying High Efficiency Image File Format (HEIF) structure, and details the step-by-step process decoders use to assemble individual image items into a complete, high-resolution picture.
What Is an AVIF Grid Image?
An AVIF grid image is a derived image item that allows a large image to be segmented into a matrix of smaller rectangular tiles. AVIF leverages the container specifications of ISO/IEC 23008-12 (HEIF). Under this specification, an image does not have to be stored as a single, monolithic compressed bitstream. Instead, an image can be represented as a collection of separate items referenced by a primary "grid" descriptor.
This tiling approach serves two main technical purposes:
- Overcoming Decoder Hardware Limits: Many hardware AV1 decoders have maximum resolution limitations, such as 4K (3840×2160) or 8K. By dividing an ultra-high-resolution image into tiles smaller than the hardware threshold, devices can decode massive images using hardware acceleration rather than relying on slower software fallbacks.
- Parallel Encoding and Decoding: Multiple CPU or GPU cores can encode or decode individual tiles simultaneously, significantly reducing processing latency.
Key Components of a Grid Image
In an AVIF file, image data and structural metadata are stored within
the meta box (fourcc: 'meta'). A grid image
relies on three main components inside this container:
- Input Image Items: The raw individual tiles,
encoded as standard AV1 intra-frames (Item type:
av01). - The Grid Item: A derived image item (Item type:
grid) that contains no pixel data itself, but rather configuration parameters describing the layout. - Item Reference Box (
iref): The structural link that connects the grid item to the individual input tiles.
How the Grid Image Is Assembled
The assembly of an AVIF grid image follows a precise sequence defined by the HEIF and AVIF specifications.
1. Defining the Grid Configuration
The grid item contains a small payload of configuration
bytes that define the structure of the output canvas. This payload
specifies:
- Flags and Field Sizes: Indicates whether 8-bit or 16-bit integers are used for coordinates.
- Rows and Columns: The count of horizontal and vertical tiles (e.g., 2 rows by 2 columns).
- Output Width and Height: The exact pixel dimensions of the final canvas after reconstruction.
2. Referencing the Tile Items
To connect the configuration to the actual image data, the file
includes an Item Reference Box (iref). Inside this box, an
entry with the reference type dimg (derived image)
designates the grid item as the parent and lists the
identifiers of the input tiles as children.
The order of the tile references inside the dimg entry
is critical. The HEIF specification dictates that tiles must be listed
in row-major order: from left to right, top to bottom. For a 2×2 grid,
the items must appear in the reference list as:
- Top-left tile
- Top-right tile
- Bottom-left tile
- Bottom-right tile
3. Decoding and Canvas Placement
When an AVIF decoder processes a grid image, it executes the following steps:
- Parse Metadata: The decoder identifies the primary
item as a
gridtype and reads the row count, column count, and target canvas dimensions. - Initialize Canvas: A blank canvas is allocated matching the specified output width and height.
- Decode Tiles: The decoder retrieves the bitstream
for each referenced
av01item and decodes the pixels. This can occur sequentially or in parallel. - Positioning: Tiles are placed onto the canvas according to their position in the reference list. All tiles in a row must share the same height, and all tiles in a column must share the same width, ensuring clean alignment along shared boundaries.
- Cropping and Final Output: Because individual tiles are often encoded in fixed block dimensions (such as multiples of 64 or 128 pixels), the combined size of the tiles may slightly exceed the intended image dimensions. The decoder crops any excess pixels extending beyond the defined output width and height, presenting the user with the final, seamless image.