How AVIF Preserves Highlights and Shadows in Raw Photos
The AV1 Image File Format (AVIF) preserves fine highlight and shadow details in raw photography by leveraging high bit-depth encoding, advanced compression algorithms, and modern High Dynamic Range (HDR) color spaces. While legacy formats like 8-bit JPEG discard extensive tonal information through aggressive compression and severe dynamic range limits, AVIF supports 10-bit and 12-bit color pipelines. This article explains the technical mechanisms—including tonal resolution, transfer functions, and transform block efficiency—that allow AVIF to maintain the fidelity of high-contrast scenes without introducing banding, clipping, or compression artifacts.
Increased Tonal Granularity via 10-bit and 12-bit Depth
Standard 8-bit formats allocate 256 discrete brightness levels per color channel, totaling approximately 16.7 million colors. This limited scale frequently leads to tonal quantization errors: deep shadows are crushed into pure black, and bright skies clip into flat white.
AVIF expands this allocation significantly:
- 10-bit encoding provides 1,024 values per channel (over 1 billion colors).
- 12-bit encoding provides 4,096 values per channel (over 68 billion colors).
When exporting raw photographs to AVIF, this quadrupling (or 16-fold increase) of tonal steps allows gradual transitions near the exposure extremes to remain smooth. Subtle light roll-offs in bright clouds and soft variations in near-black shadows retain their distinct luminance levels instead of merging into posterized bands.
Support for Modern HDR Transfer Functions
Preserving dynamic range requires not just more bits, but an intelligent distribution of those bits across visible light. AVIF natively integrates modern transfer curves commonly used in cinematic and HDR standards:
- Perceptual Quantizer (PQ / SMPTE ST 2084): Designed around the human visual system's sensitivity to contrast, PQ allocates bit precision non-linearly. It maps luminance up to 10,000 nits, dedicating more precision to midtones and highlights where visual perception is sharpest, thereby preventing blown-out details.
- Hybrid Log-Gamma (HLG): Delivers a logarithmic curve for top-end luminance, maintaining backward compatibility while extending highlight headroom.
Raw camera sensors capture light linearly. When raw data is mapped to AVIF using PQ or HLG alongside wide color gamuts such as DCI-P3 or Rec. 2020, extreme specular highlights and deep shadow tones are preserved accurately rather than clamped to standard dynamic range boundaries.
Advanced AV1 Compression Mechanics
Derived from the open-source AV1 video codec, AVIF employs sophisticated spatial prediction and quantization tools that specifically protect fine details:
- Flexible Partitioning: AV1 uses recursive block partitioning ranging from 128×128 down to 4×4 pixels. In broad highlight areas with gentle gradients (like an overexposed sky), large blocks prevent block boundary artifacts. In textured shadow regions, small blocks preserve high-frequency structural details.
- Chroma Subsampling Flexibility: AVIF supports full YUV 4:4:4 sampling, eliminating color subsampling entirely. This prevents color bleed and edge degradation in high-contrast transitions, such as dark tree branches silhouetted against a bright sunrise.
- Directed Smoothing and In-Loop Filtering: Unlike legacy deblocking filters that smear dark textures to hide noise, AV1 uses Constrained Directional Enhancement Filtering (CDEF). This preserves edge sharpness and micro-contrast in deep shadows without smudging fine, low-light details.
By combining expanded bit-depth with mathematically efficient compression and perceptual color mapping, AVIF bridges the gap between massive, uncompressed raw files and lightweight, distribution-ready web images without sacrificing extreme dynamic range.