libavif Tone-Mapping Operators for SDR Fallback

This article examines how the open-source AV1 Image File Format library, libavif, manages Standard Dynamic Range (SDR) fallback when decoding High Dynamic Range (HDR) content. It breaks down the parametric gain map operators embedded within the library, how standard colorimetry transforms are handled, and how tone mapping responsibilities are delineated between libavif and downstream rendering engines.

Gain Map-Based Tone-Mapping (ISO/IEC 21496-1)

Rather than applying subjective, heuristic-based dynamic tone-mapping operators (such as Reinhard, Hable, or ACES) directly to a standalone HDR signal, libavif implements parametric tone-mapping through gain maps. Standardized under ISO/IEC 21496-1 (incorporating concepts from Adobe Gain Map and Google UltraHDR formats), this mechanism is the primary method used by libavif to generate accurate SDR fallbacks or adapt content across varying display capabilities.

The operator functions through a deterministic parametric model:

\[\text{Output} = (\text{Base} + \text{offset}_1) \times \exp(W \times \log(\text{Gain} + \text{offset}_2)) - \text{offset}_1\]

This operator ensures that when rendering on an SDR display, the decoder can bypass heavy computation and present the author-intended SDR baseline without tone-compression artifacts.

Transfer Function Operations: PQ and HLG Handling

When dealing with native HDR AVIF images that do not contain an auxiliary gain map channel, libavif does not embed an internal, arbitrary tone-mapping algorithm to squash HDR luminance into SDR. Instead, it relies on standardized transfer function transformations:

Delegation to Host Rendering Pipelines

libavif is deliberately architected as an image container parser and codec interface rather than a full color-grading engine. Consequently, advanced non-parametric tone-mapping operations are delegated to consuming frameworks: