[FFmpeg-devel] [PATCH 2/3] avutil/film_grain_params: add support for H.274 Film Grain Characteristics
James Almer
jamrial at gmail.com
Thu Jul 22 16:44:54 EEST 2021
Used by codecs like H.264, HEVC, and VVC.
Signed-off-by: James Almer <jamrial at gmail.com>
---
Missing version bump and APIchanges entry.
libavutil/film_grain_params.h | 89 +++++++++++++++++++++++++++++++++++
1 file changed, 89 insertions(+)
diff --git a/libavutil/film_grain_params.h b/libavutil/film_grain_params.h
index 7629e3a041..7350dfc5b8 100644
--- a/libavutil/film_grain_params.h
+++ b/libavutil/film_grain_params.h
@@ -28,6 +28,11 @@ enum AVFilmGrainParamsType {
* The union is valid when interpreted as AVFilmGrainAOMParams (codec.aom)
*/
AV_FILM_GRAIN_PARAMS_AV1,
+
+ /**
+ * The union is valid when interpreted as AVFilmGrainH274Params (codec.h274)
+ */
+ AV_FILM_GRAIN_PARAMS_H274,
};
/**
@@ -117,6 +122,89 @@ typedef struct AVFilmGrainAOMParams {
int limit_output_range;
} AVFilmGrainAOMParams;
+/**
+ * This structure describes how to handle film grain synthesis for codecs using
+ * the ITU-T H.274 Versatile suplemental enhancement information message.
+ *
+ * @note The struct must be allocated as part of AVFilmGrainParams using
+ * av_film_grain_params_alloc(). Its size is not a part of the public ABI.
+ */
+typedef struct AVFilmGrainH274Params {
+ /**
+ * Specifies the film grain simulation mode.
+ * 0 = Frequency filtering, 1 = Auto-regression
+ */
+ int model_id;
+
+ /**
+ * Specifies the bit depth used for the luma component.
+ */
+ int bit_depth_luma;
+
+ /**
+ * Specifies the bit depth used for the chroma components.
+ */
+ int bit_depth_chroma;
+
+ enum AVColorRange color_range;
+ enum AVColorPrimaries color_primaries;
+ enum AVColorTransferCharacteristic color_trc;
+ enum AVColorSpace color_space;
+
+ /**
+ * Specifies the blending mode used to blend the simulated film grain
+ * with the decoded images.
+ *
+ * 0 = Additive, 1 = Multiplicative
+ */
+ int blending_mode_id;
+
+ /**
+ * Specifies a scale factor used in the film grain characterization equations.
+ */
+ int log2_scale_factor;
+
+ /**
+ * Indicates if the modelling of film grain for a given component is present.
+ */
+ int component_model_present[3 /* y, cb, cr */];
+
+ /**
+ * Specifies the number of intensity intervals for which a specific set of
+ * model values has been estimated, with a range of [1, 256].
+ */
+ uint16_t num_intensity_intervals[3 /* y, cb, cr */];
+
+ /**
+ * Specifies the number of model values present for each intensity interval
+ * in which the film grain has been modelled, with a range of [1, 6].
+ */
+ uint8_t num_model_values[3 /* y, cb, cr */];
+
+ /**
+ * Specifies the lower ounds of each intensity interval for whichthe set of
+ * model values applies for the component.
+ */
+ uint8_t intensity_interval_lower_bound[3 /* y, cb, cr */][256 /* intensity interval */];
+
+ /**
+ * Specifies the upper bound of each intensity interval for which the set of
+ * model values applies for the component.
+ */
+ uint8_t intensity_interval_upper_bound[3 /* y, cb, cr */][256 /* intensity interval */];
+
+ /**
+ * Specifies the model values for the component for each intensity interval.
+ * - When model_id == 0, the following applies:
+ * For comp_model_value[y], the range of values is [0, 2^bit_depth_luma - 1]
+ * For comp_model_value[cb..cr], the range of values is [0, 2^bit_depth_chroma - 1]
+ * - Otherwise, the following applies:
+ * For comp_model_value[y], the range of values is [-2^(bit_depth_luma - 1), 2^(bit_depth_luma - 1) - 1]
+ * For comp_model_value[cb..cr], the range of values is [-2^(bit_depth_chroma - 1), 2^(bit_depth_chroma - 1) - 1]
+ */
+ int16_t comp_model_value[3 /* y, cb, cr */][256 /* intensity interval */][6 /* model value */];
+} AVFilmGrainH274Params;
+
/**
* This structure describes how to handle film grain synthesis in video
* for specific codecs. Must be present on every frame where film grain is
@@ -143,6 +231,7 @@ typedef struct AVFilmGrainParams {
*/
union {
AVFilmGrainAOMParams aom;
+ AVFilmGrainH274Params h274;
} codec;
} AVFilmGrainParams;
--
2.32.0
More information about the ffmpeg-devel
mailing list