How librav1e Handles HDR Metadata

This article explains how the Rust-based AV1 encoder, librav1e, processes High Dynamic Range (HDR) metadata. It covers how the encoder signals color properties, handles static HDR10 metadata like Mastering Display Color Volume (MDCV) and Content Light Level (CLL), and manages dynamic HDR metadata within the AV1 ecosystem.

To properly encode HDR video, an encoder must write specific metadata into the video bitstream. This metadata informs playback devices how to map the colors and brightness of the content to the capabilities of the viewer’s screen. librav1e handles this through specific color-description signaling and metadata injection.

1. Signaling Color Properties

HDR video requires precise color space configuration. librav1e allows users to define these properties using command-line interface (CLI) parameters or the library’s programming API. For standard HDR10 content, the following parameters are used:

Specifying these flags ensures the output bitstream is flagged correctly so decoders interpret the color values properly.

2. Static HDR Metadata (HDR10)

Static HDR metadata describes the brightness limits of the mastering display and the content itself. librav1e handles this via two main inputs:

In the Rust API, these correspond to the MasteringDisplay and ContentLightLevel structs, which are passed to the encoder configuration before the encoding session begins.

3. Dynamic HDR Metadata

Unlike static metadata, which applies to the entire video, dynamic metadata changes scene-by-scene or frame-by-frame to optimize playback.