Pixel Aspect Ratio Boxes in AVIF Explained

Pixel aspect ratio boxes within an AVIF container are metadata elements designed to define the intended shape of individual pixels for proper image rendering. This article covers what the pixel aspect ratio box is, why it is used in the AV1 Image File Format, how it bridges the gap between non-square source content and modern square-pixel displays, and the technical advantages of handling non-square geometry at the container level.

Understanding the Pixel Aspect Ratio Box

In the AVIF specification—which inherits its container structure from the ISO Base Media File Format (ISOBMFF) and HEIF—the pixel aspect ratio box is represented by the four-character code pasp. Modern digital displays uniformly use square pixels, meaning each pixel has a 1:1 width-to-height ratio. However, certain image and video sources use non-square pixels, where individual pixels are wider or taller than they are high.

The pasp box explicitly declares this ratio by storing two unsigned 32-bit integers:

Together, these values establish the ratio hSpacing:vSpacing, instructing the image viewer or browser to scale the rendered output horizontally or vertically to match the author's intended geometry.

Primary Uses of the pasp Box in AVIF

1. Preserving Anamorphic and Legacy Content

A primary use of the pasp box is to store frames captured with anamorphic lenses or digitized from legacy analog video standards (such as NTSC or PAL). Anamorphic cinematography intentionally squeezes a wide field of view onto a narrower sensor area. In broadcast, formats like standard-definition DVD or D-1 store 720x480 pixels meant to be displayed at a 16:9 or 4:3 aspect ratio. Embedding a pasp box ensures that an AVIF file extracted from or encoded for these mediums displays at the correct geometry without geometric distortion.

2. Lossless Display Correction

Without the pasp box, displaying non-square content correctly on a modern screen requires physically resampling the pixels to a square grid before encoding. Resampling introduces interpolation artifacts, alters high-frequency image details, and can inflate file sizes. By using the pasp box, the underlying AV1 compressed bitstream remains untouched and true to the source data. The rendering engine handles the scaling dynamically at display time, preserving the original pixel fidelity.

3. Storage and Bandwidth Optimization

In certain specialized rendering or compression pipelines, non-square pixel subsampling is deliberately used to reduce horizontal or vertical resolution where human visual perception is less sensitive. By pairing an asymmetric pixel grid with a pasp box, developers can lower the total pixel count encoded by the AV1 codec—yielding smaller file sizes and faster transmission—while ensuring the viewer inflates the image to its intended proportions during playback.

Decoder and Rendering Behavior

When an AVIF-compliant parser reads an image file:

  1. It locates the image item within the file's meta box.
  2. It checks the associated item properties for a pasp box.
  3. If present, the decoder calculates the intended display width by multiplying the coded pixel width by (hSpacing / vSpacing).
  4. If absent, the renderer assumes a standard 1:1 ratio, displaying the raw coded dimensions directly.

By providing explicit dimensional instructions, the pasp box guarantees visual consistency across web browsers, operating systems, and professional image editing software without modifying the core image stream.