AV1 Film Grain Metadata for Client-Side Synthesis
The AV1 video codec uses Film Grain Synthesis to preserve visual texture at low bitrates by stripping random high-frequency noise during encoding and synthetically regenerating it during playback. Instead of carrying heavy pixel data for grain, the AV1 bitstream transmits a compact set of parametric metadata inside the frame header. This article outlines the specific metadata elements AV1 delivers to the client decoder to mathematically reconstruct film grain, detailing control flags, pseudo-random seeds, piecewise intensity curves, autoregressive coefficients, and color-correlation factors.
Control and Synchronization Parameters
The client decoder first parses general control flags to determine whether and how grain synthesis should be applied to the current frame:
apply_grain: A 1-bit boolean flag indicating whether film grain should be generated and blended onto the decoded frame.update_grain: A flag signaling whether the frame contains a new set of grain parameters or reuses previously transmitted ones.film_grain_params_ref_idx: Ifupdate_grainis false, this integer identifies which reference frame's stored grain parameters must be applied to the current frame.random_seed: A 16-bit unsigned integer that seeds the pseudo-random number generator (PRNG). This ensures that the generated noise pattern is deterministic across all compliant decoders.overlap_flag: A boolean flag indicating whether the 32x32 grain template blocks should overlap during rendering to avoid visible block boundaries.clip_to_restricted_range: Specifies whether the reconstructed pixel values should be clipped to restricted video ranges after grain addition.
Piecewise Intensity-Scaling Functions
Real film grain intensity varies across different brightness levels; highlights and deep shadows often have different grain strengths than midtones. AV1 models this behavior using piecewise linear functions for each color plane (Y, Cb, and Cr):
- Point Counts (
num_y_points,num_cb_points,num_cr_points): Integers indicating how many coordinate points define the scaling curve for the luminance and chrominance planes (up to 14 points for luma, 10 for chroma). - Sample Values (
point_y_value[], etc.): The horizontal coordinates on the intensity scale (x-axis), representing input pixel brightness values. - Scaling Factors (
point_y_scaling[], etc.): The vertical coordinates (y-axis), representing the grain amplitude to apply at the corresponding brightness level. scaling_shift: A bit-shift value that normalizes the interpolated scaling factors back to the correct mathematical scale.
Autoregressive (AR) Filter Coefficients
To simulate the spatial correlation and physical "clumping" of film grain rather than applying flat white noise, AV1 uses a 2D autoregressive filter:
ar_coeff_lag: Specifies the spatial neighborhood size (0 to 3) of the autoregressive process. A lag of 0 represents white noise, while lags of 1, 2, or 3 correspond to 3x3, 5x5, or 7x7 spatial filter kernels.ar_coeffs_y_plus_128[]: An array of signed filter coefficients applied to the luma channel to shape the spatial frequency and texture of the grain.ar_coeffs_cb_plus_128[]andar_coeffs_cr_plus_128[]: Arrays of filter coefficients applied to the Cb and Cr channels.ar_coeff_shift: A bit-shift value used to scale down the accumulated autoregressive values during integer fixed-point reconstruction.
Chroma Correlation and Cross-Component Parameters
Film emulsions often exhibit cross-color coupling, where noise in color channels correlates with luma luminance. AV1 models this relationship through designated cross-component coefficients:
chroma_scaling_from_luma: A flag indicating whether the chrominance grain amplitude should be derived using the luminance intensity curve rather than dedicated chroma curves.cb_mult,cr_mult: Multipliers defining the base intensity of chroma grain.cb_luma_mult,cr_luma_mult: Weighting factors that introduce a proportion of the reconstructed luma grain pattern directly into the chroma grain channels.cb_offset,cr_offset: Baseline offsets applied to the chroma grain values to prevent bias during color-plane synthesis.
Client-side decoders assemble these parameters to generate 32x32 noise blocks via the seeded PRNG, filter them through the autoregressive kernel, scale them according to local pixel luminance, and add the final texture to the output image just before presentation.