Published March 5, 2024.
In January 2024, the Alliance for Open Media (AOMedia) published the AOMedia Film Grain Synthesis 1 (AFGS1) specification. AFGS1 is a standalone film grain synthesis specification that can be used with a number of video codecs. Film grain is widely present in professional video content, such as movies and TV shows, and is notoriously difficult to compress using traditional video compression approaches. To overcome this problem, AFGS1 can be used to facilitate the following approach for compressing video with film grain (see Fig. 1), which is similar to the AV1 film grain synthesis technology.
When the grain is detected, the source video is denoised. The encoder efficiently compresses the denoised video. The denoised video is also analyzed to find flat regions. These flat regions are used to estimate film grain model parameters from the difference between the noisy and denoised versions of the video. The compressed video is sent to the decoder along with the film grain parameters. In the decoder, the compressed denoised video is decoded, and the grain is synthesized from the received grain parameters and added to the pictures before they are displayed. You can find more information on the importance of film grain preservation and difficulties encoding the film grain titles in my post on the AV1 film grain synthesis.
The AFGS1 specification establishes a standalone film grain synthesis technology that can be used with a variety of video codecs. When applied to a decoded picture, this technology is equivalent to the film grain synthesis used in AV1. This means that when applied to a frame, AFGS1 uses exactly the same film grain parameters and the low-level reference algorithm as the AV1 film grain synthesis, which results in essentially the same output. As described in the blog post on AV1 film grain synthesis, an auto-regressive (AR) process is used to create film grain templates for three color components (or one component in the case of monochrome video). The grain strength is signaled using so-called scaling functions that map a decoded sample's luma value or a linear combination of chroma and luma components' values to the grain strength. After the grain templates have been generated, the grain is applied to the decoded picture in a raster scan order in 32x32 blocks. The reader can find more details on the film grain synthesis reference process in AV1 and AFSG1 in the blog post on AV1 film grain. Except for the reference process, which is exactly the same in both specifications, AFGS1 has some differences with the AV1 film grain synthesis, described in the following.
AFGS1 specifies the format for transmission of the film grain model parameters that uses the ITU-T T.35 registered user data mechanism. Many modern video codecs use ITU-T T.35 to define registered user data SEI or metadata messages, which allows defining SEI message syntax outside of the main video codec specification while also providing means to uniquely identify the SEI message for the decoder that supports it. Decoders that do not support this SEI message would simply ignore it. Another example of technology that uses the ITU-T T.35 SEI/metadata messages is HDR10+.
Using ITU-T T.35 allows AFGS1 parameters to be signaled in most video codec bitstreams, including AVC/H.264, HEVC/H.265, VVC/H.266, and AV1 without the need to modify any of these specifications. The relevant ITU-T T.35 syntax in AFGS1 is shown in Fig. 2. The syntax elements that identify the AFGS1 payload are itu_t_t35_country_code that shall be equal to 0xB5 (USA), itu_t_t35_terminal_provider_code equal to 0x5890 (AOMedia), and itu_t_t35_terminal_provider_oriented_code equal to 0x01 (AFGS1 metadata). If a video decoding device supports the AFGS1 specification, it will be able to parse the film grain parameters and apply the film grain synthesis process to the decoded video according to the transmitted parameters.
In AV1, a film grain model parameter set is sent for the decoded frame, which has certain characteristics, such as the resolution, color space (typically YCbCr) etc. The AV1 reference implementation applies the film grain synthesis process at the decoded frame resolution, as shown in Fig. 3. If the video needs to be upscaled for display, it happens after applying the grain. Other possible blocks in the display pipeline are omitted for simplicity.
An AFGS1 parameter set includes the frame (or picture) resolution and other parameters, such as CICP color space information. Including this information serves two purposes. First, this allows the decoder to check that a correct set of the film grain parameters has been sent with the bitstream, for example, when transcoding has been applied to the bistream at a certain point. In addition, AFGS1 allows sending several sets of the film grain parameters for each decoded frame, where these parameter sets correspond to unique combinations of resolution, color space, chroma components subsampling, bit depth, and video range flag. Up to 8 film grain parameter sets can be sent for one frame. Also, when the encoder is sending an AFGS1 SEI message with multiple parameter sets, it must send a set of film grain parameters that corresponds to the decoded picture format and characteristics.
In other words, the encoder is expected to send a set of film grain parameters that corresponds to the decoded picture resolution and may also choose to send additional parameter sets that correspond to other (usually higher) picture resolutions [ 2 ]. If a decoder supports this optional feature, it may choose the set of film grain parameters that corresponds to its display resolution (or other higher resolution) and apply the film grain synthesis after upscaling the decoded picture (see Fig. 4). This approach may be helpful when sending video at low resolutions, where the film grain may not be preserved because of the downscaling.
The mandatory set of parameters for the decoded picture resolution serves several purposes. First, some encoders may choose to add film grain at the decoded picture resolution when the video is shown in a smaller window on the display. Second, some decoders may output video with added film grain for further transcoding. A device may also decide to add the grain at the decoded resolution in a lower energy mode. Finally, the mandatory set of film grain parameters for the decoded picture resolution and format provides compatibility with AV1 film grain synthesis implementations. This use case is shown in Fig. 5, where the AFGS1 film grain pipeline is similar to the one used in the AV1 film grain synthesis.
The film grain parameters are not necessarily expected to change with every frame. In some video sequences, a set of film grain parameters may represent the film grain sufficiently well for a whole scene. In this case, it is more efficient to reuse a previously signaled set of parameters rather than sending it again. To support this scenario, AV1 allows copying of film grain parameters that belong to previously decoded frames. In particular, AV1 can use the reference frame index to select a set of film grain parameters associated with a frame in the decoded frame buffer.
Likewise, AFGS1 allows using a previously sent film grain parameter set. In particular, the film grain parameters are associated with a film_grain_param_set_idx that can take values from 0 to 7. As shown in Fig. 6, when update_grain_flag is equal to 1, a new set of film grain parameters is parsed and written to the memory associated with the value of film_grain_param_set_idx signaled for this parameter set.