How to Skip Film Grain Decoding in libaom?
This article provides a technical guide on how to configure the
libaom AV1 reference decoder to disable film grain
synthesis during the decoding process. We will look at the specific
library flags, command-line arguments, and code-level configurations
required to bypass this feature, which is often done to reduce CPU
overhead or for video debugging purposes.
Understanding AV1 Film Grain Synthesis
The AV1 video codec uses an advanced tool called Film Grain Synthesis. Instead of compressing and encoding the actual random noise (grain) present in a video—which is highly inefficient and consumes massive amounts of bitrate—the encoder analyzes the grain, removes it, and sends the grain parameters as metadata in the bitstream. The decoder is then responsible for regenerating and applying this grain back onto the decoded frames.
While this saves significant bandwidth, the process of synthesizing film grain can be computationally expensive during playback, especially on lower-end hardware.
Disabling Film Grain in
the aomdec CLI
If you are using the compiled aomdec command-line tool
to decode AV1 streams, you can explicitly instruct the decoder to ignore
the film grain metadata.
By default, libaom applies film grain if it is present
in the sequence headers. To skip it, you must use the
--skip-film-grain flag.
aomdec input.ivf --skip-film-grain -o output.y4mWhen this flag is passed, the decoder entirely bypasses the grain synthesis stage, outputting the “clean” or smoothed underlying video frames.
Disabling Film Grain in Code (C/C++ API)
If you are integrating libaom directly into a media
player, transcoder, or custom application, you must use the
aom_codec_control API to pass the configuration to the
decoding context.
The control ID responsible for toggling film grain application is
AOMD_SET_SKIP_FILM_GRAIN.
Implementation Steps
- Initialize the decoder context as you normally
would using
aom_codec_dec_init. - Call the codec control function, passing the
decoder context, the control ID, and an integer value of
1to enable the skip functionality.
Here is a brief C code example:
#include <aom/aom_decoder.h>
#include <aom/aomdx.h>
// Assuming 'codec' is your initialized aom_codec_ctx_t
int skip_grain = 1;
aom_codec_err_t res = aom_codec_control(&codec, AOMD_SET_SKIP_FILM_GRAIN, skip_grain);
if (res != AOM_CODEC_OK) {
// Handle error: the control could not be set
printf("Failed to disable film grain synthesis: %s\n", aom_codec_error_detail(&codec));
}Setting skip_grain to 1 forces the decoder
to skip the application process. Setting it back to 0 (the
default behavior) allows the decoder to apply film grain whenever the
bitstream demands it.
Performance Implications
Bypassing film grain application significantly alters both the performance profile and the visual output of the decode pipeline:
- CPU Utilization: On architectures without hardware-accelerated AV1 film grain handling, disabling this feature can reduce decoding CPU cycles by 10% to 30%, depending on the video resolution and grain density.
- Visual Fidelity: The resulting video will look noticeably smoother or “cleaner” than intended by the content creator, as the simulated cinematic texture will be entirely missing.