encoding.info
You are hereSourcePredictionTransformEntropy codingFiltersFramesDecisionsRate controlPerceptionQualityBitstreamSettingsEncoder map
Page 6 of 6 in Perceptual optimization

Grain: retention versus synthesis

Perceptual optimization · concept · added 2026-11-15

In Brief:
Grain can be expensive to preserve because much of its fine variation is hard to predict. An encoder can try to retain it, remove it, or code a cleaner picture and send parameters so the decoder can synthesize similar grain. Synthesis aims at the appearance, not the original grain sample by sample.

Film grain and sensor noise are often difficult to compress faithfully. Much of their fine variation changes from pixel to pixel and from frame to frame, so prediction helps little with it, though the scene under the grain stays predictable. An encoder can spend the bits to keep the grain, let quantization wipe it away, or take a third road: remove it before encoding and have the decoder put back grain that aims to resemble it without being the same.

Three ways to treat grain

Compare them

The cat has invented grain of the strength you set. This toy experiment knows the clean picture exactly, so its removal step is ideal: it cannot show a denoiser erasing texture by mistake. Coding is intra only, so nothing here measures grain over time. Error is the mean squared error of the output against the grainy source. Sky spread measures variation around each row's mean in the two top corners, where the picture without grain is plain sky. It mixes grain with coding artifacts and says nothing about whether the pattern matches. The Reconstructed panel is the picture rebuilt from what was coded; Output adds synthesized grain to it when the method calls for that. Nonzero levels counts the picture's coefficients only, not grain parameters or other syntax, so the equal counts of Remove and Synthesize do not mean equal streams or equal decoding work.

8
← up to 4 levelsup to 16 levels →
28
← finer quantizercoarser quantizer →
Source
Reconstructed
Output
Error, ×4
MethodNonzero levelsErrorSky spread
Retain
Remove
Synthesize
Sky spread, source
Sky spread, output
Nonzero levels
Simplified demo: the cat and its grain are invented; the grain is the same strength everywhere and independent from pixel to pixel, which real grain is not. The denoiser is perfect: it is handed the cat without grain. The synthesized grain has the right strength by construction and a different random pattern; a real encoder has to estimate the grain's strength and shape, and the cost of sending those parameters is not counted. Coding is intra only, in 4×4 blocks at the nominal H.264 step for the quantization parameter (QP). In the error panel mid-gray is no change. A count of nonzero levels is not a bitrate.

At grain 8 and QP 28:

In the encoders

x264's grain tuning favors retention, and x264 has no grain synthesis for a decoder to run. AV1 has synthesis in the format: libaom's decoder adds the grain to a separate output image, after decoding.

The tuning's values, and libaom's parameters and options
  • What the x264 tuning sets. The tuning sets deblocking −2:−2, smaller dead zones, no decimation of small coefficients, the psychovisual trellis term on, weaker adaptive quantization, --qcomp 0.8 and the I and B ratios at 1.1. What those do depends on the preset, the rate control mode and macroblock-tree, which sets the B ratio to 1 and takes over --qcomp.
  • What libaom's grain parameters hold. They include up to 14 points relating luma brightness to grain strength, filter coefficients that give grain its spatial shape, and a random seed. From libaom's option list only: --denoise-noise-level, present when the build includes the denoiser, sets an amount of noise, with 0 for no denoising, and --film-grain-table supplies parameters from a file.

Trade-offs

Sources

Read 2026-11-15, at the commits linked.