AVIF Gain Maps: Adaptive SDR and HDR Display
AVIF supports adaptive display across Standard Dynamic Range (SDR) and High Dynamic Range (HDR) monitors by utilizing gain maps—secondary image channels paired with specific metadata that instruct a display engine how to scale luminance. This technology enables a single AVIF file to serve a baseline SDR image to standard screens while dynamically reconstructing an HDR image tailored to the precise brightness capabilities of an HDR display. By adopting standard gain map specifications, AVIF bridges the gap between hardware generations without requiring duplicate assets or sacrificing backward compatibility.
The Architecture of an AVIF Gain Map
AVIF (AV1 Image File Format) is built upon the ISO Base Media File Format (ISOBMFF). This container structure allows an AVIF file to store multiple image items, auxiliary items, and metadata tracks within a single payload.
When an AVIF file includes a gain map, it typically stores:
- A Base Image: Usually an SDR-rendered version of the photo (encoded via the AV1 codec), ensuring full backward compatibility with legacy decoders and standard displays.
- An Auxiliary Image (The Gain Map): A secondary, often lower-resolution AV1-encoded grayscale or color image that represents the quotient (difference) between the SDR image and the HDR rendition.
- Gain Map Metadata: Standardized metadata (such as ISO 21496-1) detailing parameters like minimum and maximum gain values, gamma, exposure offsets, and the target display's intended peak luminance.
How Adaptive Rendering Works
When an image viewer or web browser opens an AVIF file with a gain map, the display engine executes a multi-step calculation:
- Hardware Interrogation: The application queries the operating system to determine the peak luminance and dynamic range capabilities of the connected monitor.
- Weight Calculation: The engine compares the monitor’s peak brightness with the target brightness specified in the gain map metadata. It computes an interpolation factor (a weight between 0.0 and 1.0).
- Map Scaling: The gain map values are decoded, scaled by the calculated weight, and upscaled to match the resolution of the base image if necessary.
- Pixel Synthesis: The base image pixels are multiplied by the adjusted gain map values to produce final pixel luminance values that match the display's exact peak capability.
If the monitor is purely SDR, the engine ignores the auxiliary gain map entirely and renders the base image, avoiding any performance penalty or visual degradation. If the display is capable of 1,000 nits, the engine applies the gain map to boost highlights up to 1,000 nits. If the display only supports 600 nits, the gain map scales proportionally, preventing clipped highlights or washed-out midtones.
Benefits Over Traditional HDR Formats
Direct HDR images encoded using transfer functions like PQ (Perceptual Quantizer) or HLG (Hybrid Log-Gamma) look incorrect or dull when shown on an SDR screen without dynamic tone mapping. Conversely, hard-clipping an HDR image down to SDR ruins highlights.
AVIF gain maps solve this by:
- Ensuring Universal Compatibility: Older software and non-HDR displays simply render the SDR base item without error.
- Eliminating Static Tone Mapping: Instead of relying on a monitor's unpredictable internal tone-mapping algorithm, the creator's metadata dictates exactly how the image adapts across different brightness thresholds.
- Optimizing Bandwidth: Because gain maps mostly contain low-frequency luminance data, they can be downsampled and compressed aggressively with AV1, typically adding only 10% to 20% to the total file size compared to a standalone SDR image.