FFmpeg
film_grain_params.h
Go to the documentation of this file.
1 /*
2  * This file is part of FFmpeg.
3  *
4  * FFmpeg is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * FFmpeg is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with FFmpeg; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17  */
18 
19 #ifndef AVUTIL_FILM_GRAIN_PARAMS_H
20 #define AVUTIL_FILM_GRAIN_PARAMS_H
21 
22 #include "frame.h"
23 
26 
27  /**
28  * The union is valid when interpreted as AVFilmGrainAOMParams (codec.aom)
29  */
31 };
32 
33 /**
34  * This structure describes how to handle film grain synthesis for AOM codecs.
35  *
36  * @note The struct must be allocated as part of AVFilmGrainParams using
37  * av_film_grain_params_alloc(). Its size is not a part of the public ABI.
38  */
39 typedef struct AVFilmGrainAOMParams {
40  /**
41  * Number of points, and the scale and value for each point of the
42  * piecewise linear scaling function for the uma plane.
43  */
45  uint8_t y_points[14][2 /* value, scaling */];
46 
47  /**
48  * Signals whether to derive the chroma scaling function from the luma.
49  * Not equivalent to copying the luma values and scales.
50  */
52 
53  /**
54  * If chroma_scaling_from_luma is set to 0, signals the chroma scaling
55  * function parameters.
56  */
57  int num_uv_points[2 /* cb, cr */];
58  uint8_t uv_points[2 /* cb, cr */][10][2 /* value, scaling */];
59 
60  /**
61  * Specifies the shift applied to the chroma components. For AV1, its within
62  * [8; 11] and determines the range and quantization of the film grain.
63  */
65 
66  /**
67  * Specifies the auto-regression lag.
68  */
70 
71  /**
72  * Luma auto-regression coefficients. The number of coefficients is given by
73  * 2 * ar_coeff_lag * (ar_coeff_lag + 1).
74  */
75  int8_t ar_coeffs_y[24];
76 
77  /**
78  * Chroma auto-regression coefficients. The number of coefficients is given by
79  * 2 * ar_coeff_lag * (ar_coeff_lag + 1) + !!num_y_points.
80  */
81  int8_t ar_coeffs_uv[2 /* cb, cr */][25];
82 
83  /**
84  * Specifies the range of the auto-regressive coefficients. Values of 6,
85  * 7, 8 and so on represent a range of [-2, 2), [-1, 1), [-0.5, 0.5) and
86  * so on. For AV1 must be between 6 and 9.
87  */
89 
90  /**
91  * Signals the down shift applied to the generated gaussian numbers during
92  * synthesis.
93  */
95 
96  /**
97  * Specifies the luma/chroma multipliers for the index to the component
98  * scaling function.
99  */
100  int uv_mult[2 /* cb, cr */];
101  int uv_mult_luma[2 /* cb, cr */];
102 
103  /**
104  * Offset used for component scaling function. For AV1 its a 9-bit value
105  * with a range [-256, 255]
106  */
107  int uv_offset[2 /* cb, cr */];
108 
109  /**
110  * Signals whether to overlap film grain blocks.
111  */
113 
114  /**
115  * Signals to clip to limited color levels after film grain application.
116  */
119 
120 /**
121  * This structure describes how to handle film grain synthesis in video
122  * for specific codecs. Must be present on every frame where film grain is
123  * meant to be synthesised for correct presentation.
124  *
125  * @note The struct must be allocated with av_film_grain_params_alloc() and
126  * its size is not a part of the public ABI.
127  */
128 typedef struct AVFilmGrainParams {
129  /**
130  * Specifies the codec for which this structure is valid.
131  */
133 
134  /**
135  * Seed to use for the synthesis process, if the codec allows for it.
136  */
137  uint64_t seed;
138 
139  /**
140  * Additional fields may be added both here and in any structure included.
141  * If a codec's film grain structure differs slightly over another
142  * codec's, fields within may change meaning depending on the type.
143  */
144  union {
146  } codec;
148 
149 /**
150  * Allocate an AVFilmGrainParams structure and set its fields to
151  * default values. The resulting struct can be freed using av_freep().
152  * If size is not NULL it will be set to the number of bytes allocated.
153  *
154  * @return An AVFilmGrainParams filled with default values or NULL
155  * on failure.
156  */
158 
159 /**
160  * Allocate a complete AVFilmGrainParams and add it to the frame.
161  *
162  * @param frame The frame which side data is added to.
163  *
164  * @return The AVFilmGrainParams structure to be filled by caller.
165  */
167 
168 #endif /* AVUTIL_FILM_GRAIN_PARAMS_H */
AVFilmGrainAOMParams::uv_points
uint8_t uv_points[2][10][2]
Definition: film_grain_params.h:58
AVFilmGrainParams::aom
AVFilmGrainAOMParams aom
Definition: film_grain_params.h:145
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:318
av_film_grain_params_alloc
AVFilmGrainParams * av_film_grain_params_alloc(size_t *size)
Allocate an AVFilmGrainParams structure and set its fields to default values.
Definition: film_grain_params.c:21
AVFilmGrainParams::seed
uint64_t seed
Seed to use for the synthesis process, if the codec allows for it.
Definition: film_grain_params.h:137
AVFilmGrainAOMParams::grain_scale_shift
int grain_scale_shift
Signals the down shift applied to the generated gaussian numbers during synthesis.
Definition: film_grain_params.h:94
AVFilmGrainAOMParams::limit_output_range
int limit_output_range
Signals to clip to limited color levels after film grain application.
Definition: film_grain_params.h:117
AVFilmGrainAOMParams::num_y_points
int num_y_points
Number of points, and the scale and value for each point of the piecewise linear scaling function for...
Definition: film_grain_params.h:44
AVFilmGrainAOMParams
This structure describes how to handle film grain synthesis for AOM codecs.
Definition: film_grain_params.h:39
av_film_grain_params_create_side_data
AVFilmGrainParams * av_film_grain_params_create_side_data(AVFrame *frame)
Allocate a complete AVFilmGrainParams and add it to the frame.
Definition: film_grain_params.c:31
AV_FILM_GRAIN_PARAMS_NONE
@ AV_FILM_GRAIN_PARAMS_NONE
Definition: film_grain_params.h:25
AVFilmGrainAOMParams::uv_mult_luma
int uv_mult_luma[2]
Definition: film_grain_params.h:101
AVFilmGrainAOMParams::num_uv_points
int num_uv_points[2]
If chroma_scaling_from_luma is set to 0, signals the chroma scaling function parameters.
Definition: film_grain_params.h:57
size
int size
Definition: twinvq_data.h:10344
AVFilmGrainParams
This structure describes how to handle film grain synthesis in video for specific codecs.
Definition: film_grain_params.h:128
frame.h
AVFilmGrainAOMParams::ar_coeffs_y
int8_t ar_coeffs_y[24]
Luma auto-regression coefficients.
Definition: film_grain_params.h:75
AVFilmGrainParamsType
AVFilmGrainParamsType
Definition: film_grain_params.h:24
uint8_t
uint8_t
Definition: audio_convert.c:194
AVFilmGrainAOMParams::scaling_shift
int scaling_shift
Specifies the shift applied to the chroma components.
Definition: film_grain_params.h:64
frame
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several the filter must be ready for frames arriving randomly on any input any filter with several inputs will most likely require some kind of queuing mechanism It is perfectly acceptable to have a limited queue and to drop frames when the inputs are too unbalanced request_frame For filters that do not use the this method is called when a frame is wanted on an output For a it should directly call filter_frame on the corresponding output For a if there are queued frames already one of these frames should be pushed If the filter should request a frame on one of its repeatedly until at least one frame has been pushed Return or at least make progress towards producing a frame
Definition: filter_design.txt:264
AVFilmGrainAOMParams::ar_coeff_lag
int ar_coeff_lag
Specifies the auto-regression lag.
Definition: film_grain_params.h:69
AVFilmGrainAOMParams::y_points
uint8_t y_points[14][2]
Definition: film_grain_params.h:45
AVFilmGrainAOMParams::uv_offset
int uv_offset[2]
Offset used for component scaling function.
Definition: film_grain_params.h:107
AVFilmGrainAOMParams::uv_mult
int uv_mult[2]
Specifies the luma/chroma multipliers for the index to the component scaling function.
Definition: film_grain_params.h:100
AVFilmGrainAOMParams::overlap_flag
int overlap_flag
Signals whether to overlap film grain blocks.
Definition: film_grain_params.h:112
AVFilmGrainParams::codec
union AVFilmGrainParams::@294 codec
Additional fields may be added both here and in any structure included.
AVFilmGrainAOMParams::chroma_scaling_from_luma
int chroma_scaling_from_luma
Signals whether to derive the chroma scaling function from the luma.
Definition: film_grain_params.h:51
AV_FILM_GRAIN_PARAMS_AV1
@ AV_FILM_GRAIN_PARAMS_AV1
The union is valid when interpreted as AVFilmGrainAOMParams (codec.aom)
Definition: film_grain_params.h:30
AVFilmGrainParams::type
enum AVFilmGrainParamsType type
Specifies the codec for which this structure is valid.
Definition: film_grain_params.h:132
AVFilmGrainAOMParams::ar_coeff_shift
int ar_coeff_shift
Specifies the range of the auto-regressive coefficients.
Definition: film_grain_params.h:88
AVFilmGrainAOMParams::ar_coeffs_uv
int8_t ar_coeffs_uv[2][25]
Chroma auto-regression coefficients.
Definition: film_grain_params.h:81