How Does Libaom Handle Color Spaces?

This article provides a technical overview of how libaom, the reference software library for the AV1 video codec, defines and manages color spaces and pixel formats. It explores the internal enumerations used for color primaries, transfer characteristics, and matrix coefficients, alongside the library’s approach to chroma subsampling and bit depth configuration. Understanding these mechanisms is essential for developers looking to ensure accurate color reproduction and efficient video encoding when working with the AV1 ecosystem.

Internal Color Space Representations

Libaom relies on standard specifications defined by the ITU-T H.273 / ISO/IEC 23091-2 standards to manage color representation. It categorizes color properties into three distinct components, typically mapped via the aom_color_primaries, aom_transfer_characteristics, and aom_matrix_coefficients enums in the API.

By separating these properties, libaom ensures full compatibility with a broad spectrum of color spaces, spanning standard definition (SD), high definition (HD), and high dynamic range (HDR) workflows.

Pixel Formats and Chroma Subsampling

To accommodate various compression and fidelity requirements, libaom supports multiple pixel formats. These are primarily defined by their chroma subsampling structures and are handled via the aom_img_fmt enumeration.

The library natively handles the following configurations:

Additionally, libaom accounts for the specific alignment of chroma samples relative to luma samples (colocated versus disparately sampled), which is critical for accurate color decoding and preventing artifacting during playback.

Bit Depth Handling

Libaom is designed for both consumer-grade and professional video pipelines, supporting 8-bit, 10-bit, and 12-bit color depths. The library scales its internal processing pipelines based on the requested configuration:

During initialization, developers pass configuration structures (aom_codec_enc_cfg_t) to explicitly dictate the input and output bit depths, ensuring the encoder allocates the appropriate memory and processing pathways.