How AVIF Handles Non-Square Pixels
The AV1 Image File Format (AVIF) accommodates non-square pixels by decoupling an image’s stored pixel dimensions from its intended display geometry. Inheriting the container architecture of the ISO Base Media File Format (ISOBMFF), AVIF utilizes standardized metadata boxes to define non-unity Pixel Aspect Ratios (PAR). This allows specialized fields—such as medical diagnostics, archival broadcast, microscopy, and anamorphic cinematography—to preserve raw sensor resolution and spatial fidelity without introducing interpolation artifacts caused by pre-compression resampling.
The Container-Level
Mechanism: The pasp Box
AVIF relies primarily on the ISOBMFF Pixel Aspect Ratio Box
(pasp) to handle non-square pixels. While the underlying
AV1 video compression standard encodes pixel data on a uniform
rectangular grid, the container dictates how a compliant decoder scales
that data for rendering.
The pasp box contains two 32-bit unsigned integers:
hSpacing: The relative horizontal spacing of pixels.vSpacing: The relative vertical spacing of pixels.
When a display engine renders an AVIF image with a pasp
property, it calculates the target display aspect ratio (DAR) using the
formula:
\[\text{Display Aspect Ratio} = \left(\frac{\text{Storage Width}}{\text{Storage Height}}\right) \times \left(\frac{\text{hSpacing}}{\text{vSpacing}}\right)\]
By altering only the metadata ratio, the actual coded byte payload remains unaffected, preserving mathematical precision at the bitstream level.
Interaction with the AV1 Bitstream
Non-square geometry can also be signaled directly within the AV1
sequence header through the render_and_frame_size_different
flag, which defines separate render_width and
render_height values.
However, in an AVIF item, container-level signaling via the
pasp item property takes precedence in standard rendering
pipelines. In strict specialized environments, decoders verify that the
bitstream's internal render size parameters align with the container's
pasp ratios to prevent display mismatch errors.
Use Cases in Specialized Environments
1. Medical Imaging and DICOM
Certain modalities, like legacy ultrasound or specialized computed
tomography (CT) scanners, capture physical cross-sections where the
spatial sampling interval along the X-axis differs from the Y-axis.
Converting these images to square pixels prior to compression requires
spatial resampling (e.g., bicubic or Lanczos filtering), which modifies
pixel intensity values and can obscure diagnostic details. AVIF retains
the raw capture matrix, using pasp to reflect anisotropic
spatial dimensions accurately.
2. Anamorphic Film and Video Archiving
In anamorphic production, lenses optically compress a widescreen field of view horizontally onto a narrower sensor or film stock. Storing these assets in AVIF allows archives to preserve the original 2:1 or 1.33:1 optical squeeze natively. The image data is stored in its squeezed form, maximizing effective resolution, while the metadata instructs the display to stretch the image to the correct widescreen aspect ratio on playback.
3. Remote Sensing and Geospatial Imagery
Satellite and aerial sensors operating in push-broom configurations frequently record data with different along-track and across-track ground sampling distances (GSD). Storing this data in AVIF maintains the true physical detector resolution, while ensuring GIS software correctly scales the raster layer without requiring on-disk reprojection.
Clean Aperture and
Alignment: The clap Box
Specialized imaging often pairs non-square pixels with non-standard
edge artifacts, such as blanking intervals in digitized analog video or
sensor calibration margins. AVIF addresses this by pairing the
pasp box with the Clean Aperture Box
(clap).
The clap box specifies fractional cropping parameters to
define the exact subset of pixels meant for display. Decoders first crop
the raw pixel array according to the clap instructions and
then apply the pasp horizontal and vertical scaling
factors, guaranteeing that geometric measurements remain scientifically
valid.
Decoder and Ecosystem Considerations
While the AVIF specification fully supports non-square pixels, application-level support varies:
- Scientific and Professional Tools: Image viewers
based on
libaviforlibheifgenerally read thepaspbox correctly, passing the display transform matrix to the GPU for real-time, hardware-accelerated scaling. - Web Browsers: Consumer web browsers prioritize
square-pixel web assets. Some current browser implementations decode the
raw AV1 frame correctly but ignore the container-level
paspbox, resulting in visually stretched or compressed output unless forced via CSS aspect-ratio properties.
In specialized production pipelines, systems must validate that the target viewing and processing software actively queries ISOBMFF transformation properties rather than assuming a 1:1 pixel aspect ratio.