Path: blob/a-new-beginning/libavutil.xcframework/ios-arm64/libavutil.framework/Headers/film_grain_params.h
2 views
/*1* This file is part of FFmpeg.2*3* FFmpeg is free software; you can redistribute it and/or4* modify it under the terms of the GNU Lesser General Public5* License as published by the Free Software Foundation; either6* version 2.1 of the License, or (at your option) any later version.7*8* FFmpeg is distributed in the hope that it will be useful,9* but WITHOUT ANY WARRANTY; without even the implied warranty of10* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU11* Lesser General Public License for more details.12*13* You should have received a copy of the GNU Lesser General Public14* License along with FFmpeg; if not, write to the Free Software15* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA16*/1718#ifndef AVUTIL_FILM_GRAIN_PARAMS_H19#define AVUTIL_FILM_GRAIN_PARAMS_H2021#include "frame.h"2223enum AVFilmGrainParamsType {24AV_FILM_GRAIN_PARAMS_NONE = 0,2526/**27* The union is valid when interpreted as AVFilmGrainAOMParams (codec.aom)28*/29AV_FILM_GRAIN_PARAMS_AV1,3031/**32* The union is valid when interpreted as AVFilmGrainH274Params (codec.h274)33*/34AV_FILM_GRAIN_PARAMS_H274,35};3637/**38* This structure describes how to handle film grain synthesis for AOM codecs.39*40* @note The struct must be allocated as part of AVFilmGrainParams using41* av_film_grain_params_alloc(). Its size is not a part of the public ABI.42*/43typedef struct AVFilmGrainAOMParams {44/**45* Number of points, and the scale and value for each point of the46* piecewise linear scaling function for the uma plane.47*/48int num_y_points;49uint8_t y_points[14][2 /* value, scaling */];5051/**52* Signals whether to derive the chroma scaling function from the luma.53* Not equivalent to copying the luma values and scales.54*/55int chroma_scaling_from_luma;5657/**58* If chroma_scaling_from_luma is set to 0, signals the chroma scaling59* function parameters.60*/61int num_uv_points[2 /* cb, cr */];62uint8_t uv_points[2 /* cb, cr */][10][2 /* value, scaling */];6364/**65* Specifies the shift applied to the chroma components. For AV1, its within66* [8; 11] and determines the range and quantization of the film grain.67*/68int scaling_shift;6970/**71* Specifies the auto-regression lag.72*/73int ar_coeff_lag;7475/**76* Luma auto-regression coefficients. The number of coefficients is given by77* 2 * ar_coeff_lag * (ar_coeff_lag + 1).78*/79int8_t ar_coeffs_y[24];8081/**82* Chroma auto-regression coefficients. The number of coefficients is given by83* 2 * ar_coeff_lag * (ar_coeff_lag + 1) + !!num_y_points.84*/85int8_t ar_coeffs_uv[2 /* cb, cr */][25];8687/**88* Specifies the range of the auto-regressive coefficients. Values of 6,89* 7, 8 and so on represent a range of [-2, 2), [-1, 1), [-0.5, 0.5) and90* so on. For AV1 must be between 6 and 9.91*/92int ar_coeff_shift;9394/**95* Signals the down shift applied to the generated gaussian numbers during96* synthesis.97*/98int grain_scale_shift;99100/**101* Specifies the luma/chroma multipliers for the index to the component102* scaling function.103*/104int uv_mult[2 /* cb, cr */];105int uv_mult_luma[2 /* cb, cr */];106107/**108* Offset used for component scaling function. For AV1 its a 9-bit value109* with a range [-256, 255]110*/111int uv_offset[2 /* cb, cr */];112113/**114* Signals whether to overlap film grain blocks.115*/116int overlap_flag;117118/**119* Signals to clip to limited color levels after film grain application.120*/121int limit_output_range;122} AVFilmGrainAOMParams;123124/**125* This structure describes how to handle film grain synthesis for codecs using126* the ITU-T H.274 Versatile suplemental enhancement information message.127*128* @note The struct must be allocated as part of AVFilmGrainParams using129* av_film_grain_params_alloc(). Its size is not a part of the public ABI.130*/131typedef struct AVFilmGrainH274Params {132/**133* Specifies the film grain simulation mode.134* 0 = Frequency filtering, 1 = Auto-regression135*/136int model_id;137138/**139* Specifies the bit depth used for the luma component.140*/141int bit_depth_luma;142143/**144* Specifies the bit depth used for the chroma components.145*/146int bit_depth_chroma;147148enum AVColorRange color_range;149enum AVColorPrimaries color_primaries;150enum AVColorTransferCharacteristic color_trc;151enum AVColorSpace color_space;152153/**154* Specifies the blending mode used to blend the simulated film grain155* with the decoded images.156*157* 0 = Additive, 1 = Multiplicative158*/159int blending_mode_id;160161/**162* Specifies a scale factor used in the film grain characterization equations.163*/164int log2_scale_factor;165166/**167* Indicates if the modelling of film grain for a given component is present.168*/169int component_model_present[3 /* y, cb, cr */];170171/**172* Specifies the number of intensity intervals for which a specific set of173* model values has been estimated, with a range of [1, 256].174*/175uint16_t num_intensity_intervals[3 /* y, cb, cr */];176177/**178* Specifies the number of model values present for each intensity interval179* in which the film grain has been modelled, with a range of [1, 6].180*/181uint8_t num_model_values[3 /* y, cb, cr */];182183/**184* Specifies the lower ounds of each intensity interval for whichthe set of185* model values applies for the component.186*/187uint8_t intensity_interval_lower_bound[3 /* y, cb, cr */][256 /* intensity interval */];188189/**190* Specifies the upper bound of each intensity interval for which the set of191* model values applies for the component.192*/193uint8_t intensity_interval_upper_bound[3 /* y, cb, cr */][256 /* intensity interval */];194195/**196* Specifies the model values for the component for each intensity interval.197* - When model_id == 0, the following applies:198* For comp_model_value[y], the range of values is [0, 2^bit_depth_luma - 1]199* For comp_model_value[cb..cr], the range of values is [0, 2^bit_depth_chroma - 1]200* - Otherwise, the following applies:201* For comp_model_value[y], the range of values is [-2^(bit_depth_luma - 1), 2^(bit_depth_luma - 1) - 1]202* For comp_model_value[cb..cr], the range of values is [-2^(bit_depth_chroma - 1), 2^(bit_depth_chroma - 1) - 1]203*/204int16_t comp_model_value[3 /* y, cb, cr */][256 /* intensity interval */][6 /* model value */];205} AVFilmGrainH274Params;206207/**208* This structure describes how to handle film grain synthesis in video209* for specific codecs. Must be present on every frame where film grain is210* meant to be synthesised for correct presentation.211*212* @note The struct must be allocated with av_film_grain_params_alloc() and213* its size is not a part of the public ABI.214*/215typedef struct AVFilmGrainParams {216/**217* Specifies the codec for which this structure is valid.218*/219enum AVFilmGrainParamsType type;220221/**222* Seed to use for the synthesis process, if the codec allows for it.223*224* @note For H.264, this refers to `pic_offset` as defined in225* SMPTE RDD 5-2006.226*/227uint64_t seed;228229/**230* Additional fields may be added both here and in any structure included.231* If a codec's film grain structure differs slightly over another232* codec's, fields within may change meaning depending on the type.233*/234union {235AVFilmGrainAOMParams aom;236AVFilmGrainH274Params h274;237} codec;238} AVFilmGrainParams;239240/**241* Allocate an AVFilmGrainParams structure and set its fields to242* default values. The resulting struct can be freed using av_freep().243* If size is not NULL it will be set to the number of bytes allocated.244*245* @return An AVFilmGrainParams filled with default values or NULL246* on failure.247*/248AVFilmGrainParams *av_film_grain_params_alloc(size_t *size);249250/**251* Allocate a complete AVFilmGrainParams and add it to the frame.252*253* @param frame The frame which side data is added to.254*255* @return The AVFilmGrainParams structure to be filled by caller.256*/257AVFilmGrainParams *av_film_grain_params_create_side_data(AVFrame *frame);258259#endif /* AVUTIL_FILM_GRAIN_PARAMS_H */260261262