How does libaom implement AV1 film grain synthesis?

Libaom, the reference encoder implementation for the AV1 video format, implements film grain synthesis by separating film grain from the underlying video content at the encoder side and transmitting mathematical modeling parameters instead of the raw noise. This process consists of a denoising step, followed by film grain parameter estimation using an autoregressive model. The generated metadata parameters are written directly into the uncompressed frame header container as part of the AV1 Open Bitstream Unit (OBU). At the decoder side, the video is reconstructed in its clean form, and the film grain is synthetically re-applied using a deterministic pseudo-random number generator and frequency-shaping algorithms. This workflow preserves the artistic intent of film grain while achieving massive savings in bitrate efficiency.

Denoising and Parameter Estimation at the Encoder

The libaom implementation initiates the process by analyzing the incoming source video frames. Because true high-frequency film grain is incredibly expensive to compress using standard block-based motion compensation, libaom actively strips this noise out before standard intra and inter-prediction loops take place.

Parameter Signaling in the AV1 Bitstream

Rather than encoding the noise visually, libaom structures the extracted grain properties into metadata compliant with the AV1 specification. This data is written into the frame header via standard signaling functions. The primary parameters exported by libaom’s encoder include:

Grain Synthesis at the Decoder

When a decoder reads an AV1 bitstream produced by libaom, it first handles the standard decoding pipeline to output a clean video frame. If the apply_grain flag is active in the frame header, the decoder starts the synthesis engine using the parsed metadata.

[Parsed Bitstream] ──> [Reconstruct Clean Frame] ──┐
                                                   └──> [Combine Samples] ──> [Final Video Output]
[Grain Parameters] ──> [Generate 64x64 Templates] ─┘

The hardware or software decoder establishes a deterministic, 16-bit Linear-Feedback Shift Register (LFSR) seeded by the random_seed. Libaom’s decoding mechanics pre-compute a \(64 \times 64\) luma grain template and two \(32 \times 32\) chroma templates. The decoder reads across the image in a raster scan pattern, applying pseudo-random offsets to pull unique sections from the template block. These noise samples are scaled via Look-Up Tables (LUTs) initialized by the scaling points, combined with the underlying clean video pixels, and finally clipped to the appropriate bit-depth boundaries to deliver the final artifact-free video.