How Darktable Integrates AVIF for Raw Export

This article examines how the open-source photography workflow application Darktable implements open-source AVIF libraries to compress and export non-destructive raw photographic edits. It details the underlying software architecture, the handoff between Darktable’s 32-bit floating-point pixel pipeline and encoders like libavif, and how high bit-depth color management is maintained throughout the export process to maximize image fidelity while reducing storage footprints.

The Core Integration: libavif and Encoder Backends

Darktable does not natively construct AVIF containers or encode AV1 streams using custom, internal code. Instead, its export architecture relies on libavif, a widely adopted open-source C library developed by the Alliance for Open Media (AOMedia). During compilation via CMake, Darktable detects the presence of libavif on the host system. If present, Darktable builds its AVIF image-input/output (imageio) module, exposing AVIF as an export target in the lighttable view.

libavif functions as a wrapper and multiplexer, handling the ISO Base Media File Format (ISOBMFF) container creation. For the actual frame compression, libavif links to an underlying AV1 encoder installed on the system, most commonly:

Darktable passes user-defined configuration parameters directly to libavif, which instructs the active underlying codec on how to handle the raster data.

From 32-Bit Float to AVIF Encoding

Darktable’s non-destructive processing pipeline computes pixel transformations in a 32-bit floating-point linear color space. When a user triggers an export, the software translates these raw processing adjustments into a finalized raster image through a defined sequence:

  1. Pipeline Processing: Raw demosaicing, lens corrections, exposure compensation, and color grading modules are calculated sequentially in memory.
  2. Color Space Conversion and Gamut Mapping: Darktable utilizes LittleCMS (LCMS2) to transform the internal working profile (typically linear Rec. 2020) into the user's selected export profile (such as standard sRGB, Display P3, or wider gamut spaces).
  3. Quantization: libavif supports 8-bit, 10-bit, and 12-bit color depths. Darktable quantizes its 32-bit floating-point pixel buffers into 8-bit or 10-bit/12-bit integer formats depending on the export quality and bit-depth settings chosen by the user. Retaining 10-bit or 12-bit precision prevents banding and tonal posterization in high-dynamic-range scenes.
  4. Metadata and ICC Embedding: Darktable writes EXIF, XMP, and the exported ICC profile directly into the AVIF file structure via libavif's metadata packaging hooks, preserving edit attribution and hardware color-matching instructions.

Export Controls and Encoder Parameters

Within the export module, Darktable translates UI parameters into low-level instructions passed to libavif:

By leveraging libavif and modular AV1 backends, Darktable bridges high-end raw photo processing with modern container formats, providing photographers with HDR-capable, small-footprint image files that retain the fidelity of their raw edits.