Supported Bit Depths in libavif Image Encoding
This article provides a clear overview of the color bit depths
supported by libavif, the official reference library for
encoding and decoding AVIF (AV1 Image File Format) images. It explains
the capabilities of 8-bit, 10-bit, and 12-bit color depths, helping
developers and creators choose the right configuration for their imaging
needs.
Supported Bit Depths
The libavif library fully supports three specific bit
depths for image encoding:
- 8-bit
- 10-bit
- 12-bit
These options allow libavif to cater to everything from
standard web graphics to professional-grade high-dynamic-range (HDR)
photography.
8-Bit Encoding
- Shades per Channel: 256 shades per color channel (Red, Green, Blue).
- Total Colors: Approximately 16.7 million colors.
- Best Use Case: Standard Dynamic Range (SDR) images, general web assets, and screenshots.
- Details: This is the most common bit depth for traditional web images (like JPEG and PNG). It offers the smallest file sizes and universal compatibility across older hardware and browsers.
10-Bit Encoding
- Shades per Channel: 1,024 shades per color channel.
- Total Colors: Over 1 billion colors.
- Best Use Case: High Dynamic Range (HDR) images and smooth gradients.
- Details: 10-bit encoding significantly reduces “color banding” artifacts in gradients, such as skies or shadows. It is the industry-standard sweet spot for modern HDR displays, offering a massive leap in color fidelity with only a marginal increase in file size compared to 8-bit.
12-Bit Encoding
- Shades per Channel: 4,096 shades per color channel.
- Total Colors: Over 68 billion colors.
- Best Use Case: Master archiving, professional photography, and high-end print preparation.
- Details: 12-bit provides the highest precision supported by the AV1 codec. It preserves the maximum amount of sensor data from RAW camera files, ensuring that no detail is lost during compression.
Chroma Subsampling and Color Spaces
The supported bit depths (8, 10, and 12-bit) can be paired with
various chroma subsampling configurations and color spaces within
libavif:
- RGB and YUV formats:
libavifsupports encoding in YUV 4:4:4 (full color resolution), YUV 4:2:2, YUV 4:2:0 (most common for web delivery), and monochrome (grayscale). - Lossless Compression: All three bit depths can be encoded losslessly, allowing for perfect pixel reproduction at 8, 10, or 12 bits.