Skip to content

Latest commit

 

History

History
597 lines (431 loc) · 36.4 KB

07.bitstream.semantics.md

File metadata and controls

597 lines (431 loc) · 36.4 KB

Syntax structures semantics

General

This section specifies the meaning of the syntax elements present in the syntax structures.

Important variables and function calls are also described.

AOMedia ITU-T T.35 metadata semantics

itu_t_t35_country_code is a syntax element that corresponds to the country code in an ITU-T T.35 user registered metadata syntax. itu_t_t35_country_code shall be equal to 0xB5 for bitstreams conforming to this version of the specification.

itu_t_t35_terminal_provider_code is a syntax element that corresponds to a terminal provider code in an ITU-T T.35 user registered metadata syntax. itu_t_t35_terminal_provider_code shall be equal to 0x5890 for bitstreams conforming to this version of the specification.

itu_t_t35_terminal_provider_oriented_code shall be equal to 0x01 for bitstreams conforming to this version of the specification.

Film grain parameter sets semantics

afgs_enable_flag equal to 1 specifies that the film grain synthesis process is applied to the decoded picture associated with the current av1_film_grain_param_sets function. afgs_enable_flag equal to 0 specifies that the film grain synthesis process is not applied to the decoded picture associated with the current av1_film_grain_param_sets function.

reserved_4bits must be set to 0. The value is ignored by a decoder.

num_film_grain_sets_minus1 plus 1 specifies the number of signaled film grain parameter sets in the current av1_film_grain_param_sets function.

select_film_grain_param_set() is a function call that returns the index of the film grain parameter set signaled in the current av1_film_grain_param_sets function that is most appropriate for the current decoder configuration.

Note: It is recommended that the most appropriate film grain parameter set is the film grain parameter set having the largest spatial resolution that is both supported by the film grain synthesis process of the decoder and is less than or equal to the intended display resolution. {:.alert .alert-info }

load_grain_params( idx ) is a function call that specifies that all syntax elements determined in the av1_film_grain_params function and all variables beginning with upper case determined in the av1_film_grain_params function (and its sub-functions) shall be set equal to the values located in the memory location denoted by idx.

Conformance

Conformance to this specification requires that all requirements specified in this section be fulfilled.

For a given decoded picture, there shall not be more than one film grain parameter set for a given combination of luma horizontal and luma vertical resolution.

For a given decoded picture, if film grain parameter sets are associated with this picture, one film grain parameter set shall be provided satisfying the following conditions: (i) apply_horz_resolution equal to the luma horizontal resolution of the decoded picture >> apply_units_resolution_log2, (ii) apply_vert_resolution equal to the luma vertical resolution of the decoded picture >> apply_units_resolution_log2, (iii) subsampling_x equal to the chroma horizontal subsampling of the decoded picture, (iv) subsampling_y equal to the chroma vertical subsampling of the decoded picture, (v) bitdepth equal to the bitdepth of the decoded picture when the bitdepth syntax element is present, (vi) color_primaries equal to the color primaries of the decoded picture when the color_primaries syntax element is present, (vii) transfer_characteristics equal to the transfer characteristics of the decoded picture when the transfer_characteristics syntax element is present, (viii) matrix_coefficients equal to the matrix coefficients of the decoded picture when the matrix_coefficients syntax element is present, and (ix) video_full_range_flag equal to the video full range flag of the decoded picture when the video_full_range_flag syntax element is present.

For a given decoded picture, there shall not be more than one film grain parameter set for a given combination of luma horizontal resolution, luma vertical resolution, and, when present, color primaries, transfer characteristics, matrix coefficients, and video full range values.

When there are more than one film grain parameter set with the same combination of luma horizontal and luma vertical resolution for a given decoded picture, the value of cicp_info_present_flag shall be equal to 1 for these film grain parameter sets.

For a given decoded picture, all film grain parameter sets associated with the picture shall have the same value for afgs1_enable_flag.

Note: The conformance statements above mean that if film grain parameter sets are associated with a decoded picture, there must be one film grain parameter set that corresponds to the decoded picture resolution and other decoded frame characteristics, there shall not be more than one film grain parameter set that correspond to the same resolution and decoded frame characteristics, and film grain parameter sets related to the same decoded picture shall each use a unique of film_grain_param_set_idx. {:.alert .alert-info }

Note: The conformance statements above mean that if multiple distinct decoded pictures could be generated from the same bitstream (for example, when scalable layers are present with operating points which produce different resolutions) and film grain parameter sets are present, then a film grain parameter set must be available matching the parameters of each possible decoded picture. {:.alert .alert-info }

Film grain parameter payload semantics

payload_less_than_4byte_flag equal to 1 specifies that the number of bytes used by the data in the current av1_film_grain_payload is less than four bytes. payload_less_than_4byte_flag equal to 0 specifies that the number of bytes used by the data in the current av1_film_grain_payload may be equal to four or more bytes.

payload_size specifies the number of bytes used by the data in the current av1_film_grain_payload.

Note: The number of bytes used by the data in the current av1_film_grain_payload includes the payload_less_than_4byte_flag and payload_size syntax elements, all syntax elements in the av1_film_grain_params function (and any sub-functions), as well as optional zero padding bytes. The zero padding bytes can be useful for applications that choose to create an av1_film_grain_payload prior to determining the payload contents. {:.alert .alert-info }

Film grain parameters semantics

This metadata provides the post-processing module with a model for parameterized film grain synthesis. The film grain process is applied to pictures output by a video decoder or a video post-processing module. The film grain synthesis should be applied at the resolution specified for the selected film grain parameter set.

Note: An encoder may use this film grain metadata to characterize film grain that was present in the original source video material and was removed by pre-processing filtering techniques. The specified film grain parameters and the post-processing algorithm are equivalent to the AV1 film grain synthesis at the picture level. {:.alert .alert-info }

The film grain parameters signaled in this metadata message are applied to the output video picture that is associated with the coded video picture that is associated with the current metadata message in the encoded video bitstream.

Note: When coding the film grain parameters in this metadata message, the encoder should consider the scalability layering structure of the bitstream. In particular, the metadata associated with lower scalability layers should not refer to the film grain parameters associated with higher scalability layers. {:.alert .alert-info }

film_grain_param_set_idx specifies the index of a film grain parameter set. Up to 8 separate film grain parameter sets can be simultaneously stored by the film grain processing module.

Note: An encoder may use film_grain_param_set_idx to differentiate between up to 8 separate film grain models. {:.alert .alert-info }

apply_grain_flag equal to 1 specifies that the film grain synthesis process is enabled when the film grain parameters specified in the current av1_film_grain_params function are selected. apply_grain_flag equal to 0 specifies that the film grain synthesis process is disabled when the film grain parameters specified in the current av1_film_grain_params function are selected.

process_grain_params( ) is a function call that specifies that all variables beginning with upper case specified in the current section are determined by performing any process specified in the semantics of each parsed syntax elements.

save_grain_params( idx ) is a function call that specifies that all syntax elements determined in the av1_film_grain_params function and all variables beginning with upper case determined in the av1_film_grain_params function (and its sub-functions) shall be stored in the memory location denoted by idx.

grain_seed specifies the starting value for the pseudo-random numbers used during film grain synthesis.

update_grain_flag equal to 1 specifies the presence of a new set of film grain parameters. update_grain_flag equal to 0 specifies that a set of film grain parameters corresponding to the film_grain_param_set_idx value should be used.

It is a requirement of the specification conformance that for every distinct value of film_grain_param_set_idx used in a coded video sequence, the first picture in the decoding order with that value of film_grain_param_set_idx that has apply_grain_flag flag equal to 1 have update_grain_flag equal to 1.

Note: This requirement means that film grain parameters associated with a particular film_grain_param_set_idx value can only be inferred from previously signaled parameters in the picture decoding order with the same value of film_grain_param_set_idx in the current coded video sequence. {:.alert .alert-info }

It is a requirement of the specification conformance that if (i) update_grain_flag is equal to zero, (ii) apply_horz_resolution equal to the luma horizontal resolution of the decoded picture » apply_units_resolution_log2, and (iii) apply_vert_resolution equal to the luma vertical resolution of the decoded picture » apply_units_resolution_log2 then the film_grain_param_set_idx shall reference the film grain parameter set that when the save_grain_params( film_grain_param_set_idx ) function was called, the following conditions were true (i) update_grain_flag was equal to 1, (ii) apply_horz_resolution was equal to the luma horizontal resolution of the decoded picture » apply_units_resolution_log2, and (iii) apply_vert_resolution was equal to the luma vertical resolution of the decoded picture » apply_units_resolution_log2.

Note: This requirement means that film grain parameters associated with the decoded picture resolution can only be inferred from previously signaled parameters that corresponded to the decoded picture resolution. This requirement is intended to make sure that bitstreams that exercise variable decoded picture resolution do not copy the film grain parameters for the decoded picture resolutions from pictures that were not at a decoded picture resolution. This requirement helps decoders that only use (and store) film grain parameter sets that correspond to the decoded picture resolution. {:.alert .alert-info }

tempGrainSeed is a temporary variable that is used to preserve the value of grain_seed when load_grain_params is called.

apply_units_resolution_log2 specifies the units used for indicating apply_horz_resolution and apply_vert_resolution.

apply_vert_resolution specifies the luma vertical resolution corresponding to the film grain synthesis parameters in units of 1 << apply_units_resolution_log2 luma samples.

apply_horz_resolution specifies the luma horizontal resolution corresponding to the film grain synthesis parameters in units of 1 << apply_units_resolution_log2 luma samples.

luma_only_flag equal to 1 specifies that the film grain synthesis parameters in the current set do not include U and V color planes. luma_only_flag equal to 0 specifies that the film grain synthesis parameters in the current set include U and V color planes.

subsampling_x equal to 0 specifies that the horizontal resolution of the chroma component of the film grain synthesis parameters in the current set is the same as the horizontal resolution of the luma component. subsampling_x equal to 1 specifies that the horizontal resolution of the chroma component of the film grain synthesis parameters in the current set is equal to the horizontal resolution of the luma component subsampled by a factor of two.

subsampling_y equal to 0 specifies that the vertical resolution of the chroma component of the film grain synthesis parameters in the current set is the same as the vertical resolution of the luma component. subsampling_y equal to 1 specifies that the vertical resolution of the chroma component of the film grain synthesis parameters in the current set is equal to the vertical resolution of the luma component subsampled by a factor of two.

Note: The table below shows example mappings between common image formats and values for the subsampling_x, subsampling_y, and luma_only_flag syntax elements. {:.alert .alert-info }

subsampling_x subsampling_y luma_only_flag Description
0 0 0 YUV 4:4:4
1 0 0 YUV 4:2:2
1 1 0 YUV 4:2:0
- - 1 Monochrome 4:0:0
{:.table .table-sm .table-bordered }
{:.alert .alert-info }

video_signal_characteristics_flag equal to 1 specifies that bit_depth_minus8, color_primaries, transfer_characteristics, and matrix_coefficients may be present. video_signal_characteristics_flag equal to 0 specifies that bit_depth_minus8, color_primaries, transfer_characteristics, and matrix_coefficients are not present.

bit_depth_minus8 indicates the bitdepth of the decoded video picture associated with the current film grain parameters. When bit_depth_minus8 is not present, the variable BitDepth is derived from the decoded video picture that is associated with the current film grain parameters.

It is a requirement of conformance to this specification that the value of bit_depth_minus8 is less or equal to 4.

Note: The reference decoding process is described with the assumption that the bit depth of the decoded picture does not exceed 12 bits. {:.alert .alert-info }

cicp_info_present_flag equal to 1 specifies that color_primaries, transfer_characteristics, and matrix coefficients are present. cicp_info_present_flag equal to 0 specifies that color_primaries, transfer_characteristics, and matrix coefficients are not present.

color_primaries is an integer that indicates the color primaries of the decoded video picture associated with the current film grain parameters. The integer value is defined by the corresponding color primaries section of ISO/IEC 23091-4 and/or ITU-T H.273. The syntax element is intended to be informative and is not used in the film grain process defined in this specification. When present, color_primaries should match any color primary information of the decoded video picture that is associated with the current film grain parameters. The behavior of the film grain synthesis process in response to this syntax element not matching the decoded picture associated with the current film grain parameters is outside the scope of this specification.

transfer_characteristics is an integer that indicates the transfer characteristics of the decoded picture associated with the current film grain parameters. The integer value is defined by the corresponding transfer characteristics section of ISO/IEC 23091-4 and/or ITU-T H.273. The syntax element is intended to be informative and is not used in the film grain process defined in this specification. When present, transfer_characteristics should match any transform characteristics information of the decoded video picture that is associated with the current film grain parameters. The behavior of the film grain synthesis process in response to this syntax element not matching the decoded picture associated with the current film grain parameters is outside the scope of this specification.

matrix_coefficients is an integer that indicates the matrix coefficients of the decoded picture associated with the current film grain parameters. The integer value is defined by the corresponding matrix coefficients section of ISO/IEC 23091-4 and/or ITU-T H.273. The syntax element is intended to be informative and is not used in the film grain process defined in this specification. When present, matrix_coefficients should match any matrix coefficient information of the decoded video picture that is associated with the current film grain parameters. The behavior of the film grain synthesis process in response to this syntax element not matching the decoded picture associated with the current film grain parameters is outside the scope of this specification.

video_full_range_flag is a flag that indicates the scaling and offset values applied in association with the matrix coefficients of the decoded picture associated with the current film grain parameters. The value is defined by the corresponding matrix coefficients section of ISO/IEC 23091-4 and/or ITU-T H.273. The syntax element is intended to be informative and is not used in the film grain process defined in this specification. When present, video_full_range_flag should match any video full range information of the decoded video picture that is associated with the current film grain parameters.
The behavior of the film grain synthesis process in response to the syntax element not matching the decoded picture associated with the current film grain parameters is outside the scope of this specification.

predict_scaling_flag equal to 0 specifies that scaling functions in the current film grain parameter set are not predicted from scaling functions that belong to other film grain parameter sets. predict_scaling_flag equal to 1 specifies that scaling functions in the current film grain parameter set may be predicted from scaling functions that belong to other film grain parameter sets in the current av1_film_grain_payload( ) function.

It is a requirement of conformance to this specification that the film grain parameter set at the decoded picture resolution for each decoded picture has the predict_scaling_flag flag equal to zero.

filmGrainParamSetIdxForPrediction is a variable equal to the value of film_grain_param_set_idx that is determined in the first call to av1_film_grain_params( ) within the current aom_itu_t_t35_payload( ).

It is a requirement of conformance to this specification that the value of the film grain parameter set with index filmGrainParamSetIdxForPrediction have been initialized with values of the scaling functions that are in the current coded video sequence before use. It is also a requirement of conformance to this specification that the value of filmGrainParamSetIdxForPrediction is different from the value of film_grain_param_set_idx for the current film grain parameter set before use.

Note: This requirement restricts prediction between the film grain parameter sets to be within one aom_itu_t_t35_payload( ). It also restricts the reference for the prediction process to be the film grain parameter set determined in the first av1_film_grain_params( ) call. {:.alert .alert-info }

predict_y_scaling_flag equal to 0 specifies that the luma scaling functions in the current film grain parameter set are not predicted from a different film grain parameter set. predict_y_scaling_flag equal to 1 specifies that the luma scaling functions in the current film grain parameter set are predicted from a different film grain parameter set having an index film_grain_param_set_idx equal to filmGrainParamSetIdxForPrediction.

y_scaling_mult specifies the multiplier used for predicting the luma film grain scaling function.

y_scaling_add specifies the additive offset parameter used for predicting the luma film grain scaling function.

numYPointsInRef is a variable equal to the number of points for the piecewise linear scaling function of the luma component in the film grain parameter set referenced by filmGrainParamSetIdxForPrediction.

bits_per_y_scaling_res specifies the number of bits used for encoding point_y_scaling_res[ i ].

point_y_scaling_res[ i ] specifies the prediction difference of the parameters. The parameter is signaled using bits_per_y_scaling_res bits and is in the [ -(1 << (bits_per_y_scaling_res - 1)) , (1 << (bits_per_y_scaling_res - 1)) - 1 ] range.

y_scaling_res_granularity specifies the granularity with which the difference values for the predicted scaling function are encoded.

num_y_points specifies the number of points for the piece-wise linear scaling function of the luma component.

It is a requirement of conformance to this specification that num_y_points is less than or equal to 14.

point_y_value_increment_bits_minus1 plus 1 specifies the number of bits used for encoding point_y_values_increment[ i ].

point_y_scaling_bits_minus5 plus 5 specifies the number of bits used for encoding point_y_scaling[ i ].

point_y_value_increment[ i ] is the increment of PointYValue[ i ] relative to the PointYValue[ i - 1 ].

point_y_scaling[ i ] represents the scaling (output) value for the i-th point of the piecewise linear scaling function for the luma component.

When predict_y_scaling_flag is equal to 1, the luma scaling function values are derived as follows:

The values of PointYValueRef[ i ] and PointYScalingRef[ i ] for all instances of index i are equal to PointYValue[ i ] and PointYScaling[ i ], respectively, in the film grain parameter set with film_grain_param_set_idx equal to filmGrainParamSetIdxForPrediction.

for ( i = 0; i < numYPointsInRef; i++ ) {
    PointYValue[ i ] = PointYValueRef[ i ]
    PointYScaling[ i ] =
        Clip3(0, 255, ( (PointYScalingRef[ i ] * (y_scaling_mult - 256) + 8) >> 4) + y_scaling_add - 256
        + (point_y_scaling_res[ i ] - ( 1 << (bits_per_y_scaling_res - 1)  ) )* y_scaling_res_granularity )
}

Note: y_scaling_mult represents a value of a multiplier from -16 to +15.9375 with a value granularity of 1/16. y_scaling_add represents an integer value of intercept in the range [ -256, 255]. {:.alert .alert-info }

When predict_y_scaling_flag is equal to 0, the luma scaling function values PointYValue[ i ] and PointYScaling[ i ] are obtained as follows:

for ( i = 0; i < num_y_points; i++ ){
    if ( i )
        PointYValue[ i ] = PointYValue[ i - 1 ] + point_y_value_increment[ i ]
    else
        PointYValue[ 0 ] = point_y_value_increment[ 0 ]
    PointYScaling[ i ] = point_y_scaling[ i ]
}

PointYValue[ i ] represents the x (luma value) coordinate for the i-th point of the piecewise linear scaling function for the luma component. The values are signaled in the scale of 0 to 255. In the case of 10-bit video, these values correspond to luma values divided by 4. In the case of 12-bit video, these values correspond to luma values divided by 16.

chroma_scaling_from_luma_flag equal to 1 specifies that the chroma scaling is inferred from the luma scaling. chroma_scaling_from_luma_flag equal to 0 specifies that the chroma scaling is signaled independently.

predict_cb_scaling_flag equal to 0 specifies that the Cb component scaling functions in the current film grain parameter set are not predicted from a different film grain parameter set. predict_cb_scaling_flag equal to 1 specifies that the Cb component scaling functions in the current film grain parameter set are predicted from a film grain parameter set indicated by filmGrainParamSetIdxForPrediction.

If predict_cb_scaling_flag is equal to 1, the variables CbMult, CbLumaMult, and CbOffset are set equal to the syntax elements cb_mult, cb_luma_mult, and cb_offset, respectively, specified in av1_film_grain_params( ) function, in which
film_grain_param_set_idx value is equal to filmGrainParamSetIdxForPrediction value of the current av1_film_grain_params( ) function.

If predict_cb_scaling_flag is equal to 0, the variables CbMult, CbLumaMult, and CbOffset are set equal to the syntax elements cb_mult, cb_luma_mult, and cb_offset, respectively, of the current av1_film_grain_params( ) function.

cb_scaling_mult specifies the multiplier used for predicting the Cb component film grain scaling function.

cb_scaling_add specifies the additive offset parameter used for predicting the Cb component film grain scaling function.

numCbPointsInRef is a variable equal to the value of num_cb_points of the film grain parameter set referred to by filmGrainParamSetIdxForPrediction

bits_per_cb_scaling_res specifies the number of bits used for encoding the parameters point_cb_scaling_res[ i ] for all possible values of i.

point_cb_scaling_res[ i ] specifies the prediction difference of the Cb parameter for the point with index i. The parameter is signaled using bits_per_cb_scaling_res bits and is in the [ -(1 << (bits_per_cb_scaling_res - 1)), (1 << (bits_per_cb_scaling_res - 1)) - 1 ] range.

cb_scaling_res_granularity specifies the granularity with which the difference values for the predicted scaling function for the Cb component are encoded.

num_cb_points specifies the number of points for the piece-wise linear scaling function of the Cb component.

It is a requirement of conformance to this specification that num_cb_points is less than or equal to 10.

Note: When chroma_scaling_from_luma_flag is equal to 1, it is still allowed for num_y_points to take values up to 14. This means that the chroma scaling also needs to support up to 14 points. {:.alert .alert-info }

point_cb_value_increment_bits_minus1 plus 1 specifies the number of bits used to signal point_cb_values[ i ].

point_cb_scaling_bits_minus5 plus 5 specifies the number of bits used to signal point_cb_scaling[ i ]

cb_scaling_offset specifies the offset applied to obtain point_cb_scaling[ i ] values.

point_cb_value_increment[ i ] specifies the increment of point_cb_value[ i ] relative to the point_cb_value[ i - 1 ].

point_cb_scaling[ i ] represents the scaling (output) value for the i-th point of the piecewise linear scaling function for the Cb component.

When predict_cb_scaling_flag parameters is equal to 1, the Cb scaling function values are obtained as follows:

The values of PointCbValueRef[ i ] and PointCbScalingRef[ i ] for all instances of index i are equal to PointCbValue[ i ] and PointCbScaling[ i ], respectively, in the film grain parameter set with film_grain_param_set_idx equal to filmGrainParamSetIdxForPrediction.

for ( i = 0; i < numCbPointsInRef; i++ ) {
    PointCbValue[ i ] = PointCbValueRef[ i ]
    PointCbScaling[ i ] =
        Clip3(0, 255, ( (PointCbScalingRef[ i ] * (cb_scaling_mult - 256) + 8) >> 4) + cb_scaling_add - 256
        + (point_cb_scaling_res[ i ] - ( 1 << (bits_per_cb_scaling_res-1)  ) ) * cb_scaling_res_granularity)
}

Note: cb_scaling_mult represents a value of a multiplier from -16 to +15.9375 with a value granularity of 1/16. cb_scaling_add represents an integer value of intercept in the range [-256, 255]. {:.alert .alert-info }

When predict_cb_scaling_flag parameters is equal to 0, the Cb scaling function values PointCbValue[ i ] and PointCbScaling[ i ] are derived as follows:

for ( i = 0; i < num_cb_points; i++ ){
    if ( i )
        PointCbValue[ i ] = PointCbValue[ i - 1 ] + point_cb_value_increment[ i ]
    else
        PointCbValue[ 0 ] = point_cb_value_increment[ 0 ]
    PointCbScaling[ i ] = point_cb_scaling[ i ] + cb_scaling_offset
}

PointCbValue[ i ] represents the x coordinate for the i-th point of the piece-wise linear scaling function for the Cb component. The values are signaled on the scale of 0..255.

predict_cr_scaling_flag equal to 0 specifies that the Cr component scaling functions in the current film grain parameter set are not predicted from a different film grain parameter set. predict_cr_scaling_flag equal to 1 specifies that the Cr component scaling functions in the current film grain parameter set are predicted from a film grain parameter set indicated by film_grain_param_set_idx equal to filmGrainParamSetIdxForPrediction.

If predict_cr_scaling_flag is equal to 1, the variables CrMult, CrLumaMult, and CrOffset are set equal to the syntax elements cr_mult, cr_luma_mult, and cr_offset, respectively, specified in av1_film_grain_params( ) function, in which
film_grain_param_set_idx value is equal to filmGrainParamSetIdxForPrediction value of the current av1_film_grain_params( ) function.

If predict_cr_scaling_flag is equal to 0, the variables CrMult, CrLumaMult, and CrOffset are set equal to the syntax elements cr_mult, cr_luma_mult, and cr_offset, respectively, of the current av1_film_grain_params( ) function.

cr_scaling_mult specifies the multiplier used for predicting the Cr component film grain scaling function.

cr_scaling_add specifies the addition parameter used for predicting the Cr component film grain scaling function.

numCrPointsInRef is a variable equal to the value of num_cr_points of the film grain parameter set referred to by filmGrainParamSetIdxForPrediction.

bits_per_cr_scaling_res specifies the number of bits used for encoding point_cr_scaling[ i ].

point_cr_scaling_res[ i ] specifies the prediction difference of the parameters. The parameter is signaled using bits_per_cr_scaling_res bits and is in the [ -(1 << (bits_per_cr_scaling_res - 1)), (1 << (bits_per_cr_scaling_res - 1)) - 1 ] range.

cr_scaling_res_granularity specifies the granularity with which the difference values for the predicted scaling function are encoded.

It is a requirement of conformance to this specification that when filmGrainParamSetIdxForPrediction is present, it shall be equal to the value of film_grain_param_set_idx that is determined in the first call to av1_film_grain_params( ) within the current aom_itu_t_t35_payload( ).

Note: This requirement restricts prediction between the film grain parameter sets to be within one aom_itu_t_t35_payload( ). It also restricts the reference for the prediction process to be the film grain parameter set determined in the first av1_film_grain_params( ) call. {:.alert .alert-info }

num_cr_points specifies the number of points for the piece-wise linear scaling function of the Cr component.

It is a requirement of conformance to this specification that num_cr_points is less than or equal to 10.

If SubX is equal to 1 and SubY is equal to 1 and num_cb_points is equal to 0, it is a requirement of conformance to this specification that num_cr_points is equal to 0.

If SubX is equal to 1 and SubY is equal to 1 and num_cb_points is not equal to 0, it is a requirement of conformance to this specification that num_cr_points is not equal to 0.

Note: These requirements ensure that for 4:2:0 chroma subsampling, film grain noise will be applied to both chroma components, or to neither. There is no restriction for 4:2:2 or 4:4:4 chroma subsampling. {:.alert .alert-info }

point_cr_value_increment_bits_minus1 plus 1 specifies the number of bits used to signal point_cr_value_increment[ i ].

point_cr_scaling_bits_minus5 plus 5 specifies the number of bits used to signal point_cr_scaling[ i ].

cr_scaling_offset specifies the offset applied to obtain point_cr_scaling[ i ] values.

point_cr_value_increment[ i ] specifies the increment of point_cr_value[ i ] relative to the point_cr_value[ i - 1 ].

point_cr_scaling[ i ] represents the scaling (output) value for the i-th point of the piecewise linear scaling function for the Cr component.

When predict_cr_scaling_flag parameters is equal to 1, the Cr scaling function values are derived as follows:

The values of PointCrValueRef[ i ] and PointCrScalingRef[ i ] for all instances of index i are equal to PointCrValue[ i ] and PointCrScaling[ i ], respectively, in the film grain parameter set with film_grain_param_set_idx equal to filmGrainParamSetIdxForPrediction.

for ( i = 0; i < numCrPointsInRef; i++ ) {
    PointCrValue[ i ] = PointCrValueRef[ i ]
    PointCrScaling[ i ] =
        Clip3(0, 255, ( (PointCrScalingRef[ i ] * (cr_scaling_mult - 256) + 8) >> 4) + cr_scaling_add - 256
        + (point_cr_scaling_res[ i ] - ( 1 << (bits_per_cr_scaling_res-1)  )) * cr_scaling_res_granularity)
}

Note: cr_scaling_mult represents a value of a multiplier from -16 to +15.9375 with a value granularity of 1/16. cr_scaling_add represents an integer value of intercept in the range between [ - 256, 255]. {:.alert .alert-info }

When predict_cr_scaling_flag parameters is equal to 0, the Cr scaling function values PointCrValue[ i ] and PointCrScaling[ i ] are obtained as follows:

for ( i = 0; i < num_cr_points; i++ ) {
    if ( i )
        PointCrValue[ i ] = PointCrValue[ i - 1 ] + point_cr_value_increment[ i ]
    else
        PointCrValue[ 0 ] = point_cr_value_increment[ 0 ]
    PointCrScaling[ i ] = point_cr_scaling[ i ] + cr_scaling_offset
}

PointCrValue[ i ] represents the x coordinate for the i-th point of the piece-wise linear scaling function for the Cr component. The values are signaled in the range of 0 to 255.

grain_scaling_minus8 plus 8 specifies the shift applied to the values of the chroma component. The grain_scaling_minus8 can take values of 0 to 3 and determines the range and quantization step of the standard deviation of film grain.

ar_coeff_lag specifies the number of auto-regressive coefficients for luma and chroma.

bits_per_ar_coeff_y_minus5 plus 5 specifies the number of bits used to signal ar_coeffs_y[ i ].

ar_coeffs_y[ i ] specifies the auto-regressive coefficients used for the luma component.

The values of auto-regressive coefficients plus 128 for the luma component ArCoeffsYPlus128[ i ] are derived as follows

for ( i = 0; i < numPosLuma; i++ )
    ArCoeffsYPlus128[ i ] = ar_coeffs_y[ i ] - (1<<(BitsArY - 1)).

bits_per_ar_coeff_cb_minus5 plus 5 specifies the number of bits used to signal ar_coeffs_cb[ i ].

ar_coeffs_cb[ i ] specifies the auto-regressive coefficients used for the Cb plane.

The values of the auto-regressive coefficients plus 128 for the Cb component ArCoeffsCbPlus128[ i ] are derived as follows:

for ( i = 0; i < numPosChroma; i++ )
    ArCoeffsCbPlus128[ i ] = ar_coeffs_cb[ i ] - (1<<(BitsArCb - 1)).

bits_per_ar_coeff_cr_minus5 plus 5 specifies the number of bits used to signal ar_coeffs_cr[ i ].

ar_coeffs_cr[ i ] specifies the auto-regressive coefficients used for the Cr plane.

The values of the auto-regressive coefficients plus 128 for the Cr component ArCoeffsCrPlus128[ i ] are derived as follows:

for ( i = 0; i < numPosChroma; i++ )
        ArCoeffsCrPlus128[ i ] = ar_coeffs_cr[ i ] - (1<<(BitsArCr - 1)).

ar_coeff_shift_minus6 specifies the range of the auto-regressive coefficients. Values of 0, 1, 2, and 3 correspond to the ranges for auto-regressive coefficients of [-2, 2), [-1, 1), [-0.5, 0.5) and [-0.25, 0.25), respectively.

grain_scale_shift specifies how much the Gaussian random numbers should be scaled down during the grain synthesis process.

cb_mult specifies the multiplier for the Cb component used in the derivation of the input index to the Cb component scaling function.

cb_luma_mult specifies the multiplier for the average luma component used in the derivation of the input index to the Cb component scaling function.

cb_offset specifies the offset used in the derivation of the input index to the Cb component scaling function.

cr_mult specifies the multiplier for the Cr component used in the derivation of the input index to the Cr component scaling function.

cr_luma_mult specifies the multiplier for the average luma component used in the derivation of the input index to the Cr component scaling function.

cr_offset specifies the offset used in the derivation of the input index to the Cr component scaling function.

overlap_flag equal to 1 specifies that the overlap between film grain blocks shall be applied. overlap_flag equal to 0 specifies that the overlap between film grain blocks shall not be applied.

clip_to_restricted_range_flag equal to 1 specifies that clipping to the restricted range is applied to the sample values after adding the film grain. clip_to_restricted_range_flag equal to 0 specifies that clipping to the full range shall be applied to the sample values after adding the film grain.

Padding bits semantics

padding_zero_bit shall be equal to 0.