FFmpeg 9.0
Loading...
Searching...
No Matches
codec_par.h
Go to the documentation of this file.
1/*
2 * Codec parameters public API
3 *
4 * This file is part of FFmpeg.
5 *
6 * FFmpeg is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * FFmpeg is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with FFmpeg; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21#ifndef AVCODEC_CODEC_PAR_H
22#define AVCODEC_CODEC_PAR_H
23
24#include <stdint.h>
25
26#include "libavutil/avutil.h"
28#include "libavutil/rational.h"
29#include "libavutil/pixfmt.h"
30
31#include "codec_id.h"
32#include "defs.h"
33#include "packet.h"
34
35/**
36 * @defgroup lavc_codec_params Codec parameters
37 * @ingroup lavc_core
38 * @{
39 */
40
41/**
42 * This struct describes the properties of an encoded stream.
43 *
44 * @note
45 * The `sizeof(AVCodecParameters)` is not a part of the public ABI,
46 * therefore this struct must be allocated with ::avcodec_parameters_alloc()
47 * and freed with ::avcodec_parameters_free().
48 */
49typedef struct AVCodecParameters {
50 /**
51 * General type of the encoded data.
52 */
54 /**
55 * Specific type of the encoded data (the codec used).
56 */
58 /**
59 * Additional information about the codec (corresponds to the AVI FOURCC).
60 */
61 uint32_t codec_tag;
62
63 /**
64 * Extra binary data needed for initializing the decoder, codec-dependent.
65 *
66 * Must be allocated with ::av_malloc() and will be freed by
67 * ::avcodec_parameters_free(). The allocated size of extradata must be at
68 * least #extradata_size + ::AV_INPUT_BUFFER_PADDING_SIZE, with the padding
69 * bytes zeroed.
70 */
71 uint8_t *extradata;
72 /**
73 * Size of the extradata content in bytes.
74 */
76
77 /**
78 * Additional data associated with the entire stream.
79 *
80 * Should be allocated with ::av_packet_side_data_new() or
81 * ::av_packet_side_data_add(), and will be freed by ::avcodec_parameters_free().
82 */
84
85 /**
86 * Amount of entries in #coded_side_data.
87 */
89
90 /**
91 * - Video: the pixel format, the value corresponds to enum ::AVPixelFormat.
92 * - Audio: the sample format, the value corresponds to enum ::AVSampleFormat.
93 */
94 int format;
95
96 /**
97 * The average bitrate of the encoded data (in bits per second).
98 */
99 int64_t bit_rate;
100
101 /**
102 * The number of bits per sample in the codedwords.
103 *
104 * This is basically the bitrate per sample. It is mandatory for a bunch of
105 * formats to actually decode them. It's the number of bits for one sample in
106 * the actual coded bitstream.
107 *
108 * This could be, for example, 4, for ADPCM.
109 * For PCM formats this matches #bits_per_raw_sample.
110 *
111 * Can be 0.
112 */
114
115 /**
116 * The number of valid bits in each output sample.
117 *
118 * If the sample format has more bits, the least significant bits are additional
119 * padding bits, which are always 0. Use right shifts to reduce the sample
120 * to its actual size.
121 *
122 * For example, audio formats with 24-bit samples will have #bits_per_raw_sample
123 * set to 24, and ::format set to ::AV_SAMPLE_FMT_S32. To get the original sample,
124 * use: `(int32_t)sample >> 8`.
125 *
126 * For ADPCM, this might be 12 or 16, or similar.
127 *
128 * Can be 0.
129 */
131
132 /**
133 * Codec-specific bitstream restrictions that the stream conforms to.
134 */
136 int level;
137
138 /**
139 * The width of the video frame in pixels.
140 *
141 * Video only.
142 */
143 int width;
144
145 /**
146 * The height of the video frame in pixels.
147 *
148 * Video only.
149 */
151
152 /**
153 * The aspect ratio (width/height) which a single pixel
154 * should have when displayed.
155 *
156 * When the aspect ratio is unknown or undefined, the numerator should be
157 * set to 0 (the denominator may have any value).
158 *
159 * Video only.
160 */
162
163 /**
164 * Number of frames per second, for streams with constant frame
165 * durations. Should be set to `{ 0, 1 }` when some frames have differing
166 * durations or if the value is not known.
167 *
168 * @note This field corresponds to values that are stored in codec-level
169 * headers and is typically overridden by container/transport-layer
170 * timestamps, when available. It should thus be used only as a last resort,
171 * when no higher-level timing information is available.
172 *
173 * Video only.
174 */
176
177 /**
178 * The order of the fields in interlaced video.
179 *
180 * Video only.
181 */
183
184 /**
185 * Additional colorspace characteristics.
186 *
187 * Video only.
188 */
194
195 /**
196 * Number of delayed frames.
197 *
198 * Video only.
199 */
201
202 /**
203 * The channel layout and number of channels.
204 *
205 * Audio only.
206 */
208 /**
209 * The number of audio samples per second.
210 *
211 * Audio only.
212 */
214 /**
215 * The number of bytes per coded audio frame, required by some formats.
216 *
217 * Audio only.
218 *
219 * Corresponds to nBlockAlign in WAVEFORMATEX.
220 */
222 /**
223 * Audio frame size, if known. Required by some formats to be static.
224 *
225 * Audio only.
226 */
228
229 /**
230 * Number of padding audio samples at the start.
231 *
232 * The amount of padding (in samples) inserted by the encoder at
233 * the beginning of the audio. I.e. this number of leading decoded samples
234 * must be discarded to get the original audio without leading
235 * padding.
236 *
237 * Audio only.
238 */
240 /**
241 * Number of padding audio samples at the end.
242 *
243 * The amount of padding (in samples) appended by the encoder to
244 * the end of the audio. I.e. this number of decoded samples must be
245 * discarded from the end of the stream to get the original
246 * audio without any trailing padding.
247 *
248 * Audio only.
249 */
251 /**
252 * Number of audio samples to skip after a discontinuity.
253 *
254 * Audio only.
255 */
257
258 /**
259 * Video with alpha channel only. Alpha channel handling
260 */
263
264/**
265 * @relates AVCodecParameters
266 * @{
267 */
268
269/**
270 * Allocate a new AVCodecParameters and set its fields to default values
271 * (unknown/invalid/0). The returned struct must be freed with
272 * ::avcodec_parameters_free().
273 */
275
276/**
277 * Free an AVCodecParameters instance and everything associated with it and
278 * write `NULL` to the supplied pointer.
279 */
281
282/**
283 * Copy the contents of \p src to \p dst. Any allocated fields in dst are freed and
284 * replaced with newly allocated duplicates of the corresponding fields in src.
285 *
286 * @return >= 0 on success, a negative AVERROR code on failure.
287 */
289
290/**
291 * This function is the same as ::av_get_audio_frame_duration(), except it works
292 * with ::AVCodecParameters instead of an ::AVCodecContext.
293 */
295
296/** @} */
297
298/**
299 * @}
300 */
301
302#endif // AVCODEC_CODEC_PAR_H
Convenience header that includes libavutil's core.
Public libavutil channel layout APIs header.
Misc types and constants that do not belong anywhere else.
AVFieldOrder
Definition defs.h:211
int av_get_audio_frame_duration2(AVCodecParameters *par, int frame_bytes)
This function is the same as av_get_audio_frame_duration(), except it works with AVCodecParameters in...
AVCodecParameters * avcodec_parameters_alloc(void)
Allocate a new AVCodecParameters and set its fields to default values (unknown/invalid/0).
int avcodec_parameters_copy(AVCodecParameters *dst, const AVCodecParameters *src)
Copy the contents of src to dst.
void avcodec_parameters_free(AVCodecParameters **par)
Free an AVCodecParameters instance and everything associated with it and write NULL to the supplied p...
AVCodecID
Identify the syntax and semantics of the bitstream.
Definition codec_id.h:47
AVMediaType
Definition avutil.h:198
pixel format definitions
AVChromaLocation
Location of chroma samples.
Definition pixfmt.h:796
AVColorRange
Visual content value range.
Definition pixfmt.h:742
AVAlphaMode
Correlation between the alpha channel and color values.
Definition pixfmt.h:810
AVColorPrimaries
Chromaticity coordinates of the source primaries.
Definition pixfmt.h:636
AVColorTransferCharacteristic
Color Transfer Characteristic.
Definition pixfmt.h:666
AVColorSpace
YUV colorspace type.
Definition pixfmt.h:700
Utilities for rational number calculation.
An AVChannelLayout holds information about the channel layout of audio data.
This struct describes the properties of an encoded stream.
Definition codec_par.h:49
enum AVColorSpace color_space
Definition codec_par.h:192
int extradata_size
Size of the extradata content in bytes.
Definition codec_par.h:75
int frame_size
Audio frame size, if known.
Definition codec_par.h:227
enum AVFieldOrder field_order
The order of the fields in interlaced video.
Definition codec_par.h:182
int height
The height of the video frame in pixels.
Definition codec_par.h:150
int nb_coded_side_data
Amount of entries in coded_side_data.
Definition codec_par.h:88
int bits_per_coded_sample
The number of bits per sample in the codedwords.
Definition codec_par.h:113
AVChannelLayout ch_layout
The channel layout and number of channels.
Definition codec_par.h:207
int width
The width of the video frame in pixels.
Definition codec_par.h:143
int64_t bit_rate
The average bitrate of the encoded data (in bits per second).
Definition codec_par.h:99
int seek_preroll
Number of audio samples to skip after a discontinuity.
Definition codec_par.h:256
enum AVMediaType codec_type
General type of the encoded data.
Definition codec_par.h:53
int trailing_padding
Number of padding audio samples at the end.
Definition codec_par.h:250
AVRational framerate
Number of frames per second, for streams with constant frame durations.
Definition codec_par.h:175
int profile
Codec-specific bitstream restrictions that the stream conforms to.
Definition codec_par.h:135
int block_align
The number of bytes per coded audio frame, required by some formats.
Definition codec_par.h:221
int bits_per_raw_sample
The number of valid bits in each output sample.
Definition codec_par.h:130
AVRational sample_aspect_ratio
The aspect ratio (width/height) which a single pixel should have when displayed.
Definition codec_par.h:161
int video_delay
Number of delayed frames.
Definition codec_par.h:200
uint32_t codec_tag
Additional information about the codec (corresponds to the AVI FOURCC).
Definition codec_par.h:61
uint8_t * extradata
Extra binary data needed for initializing the decoder, codec-dependent.
Definition codec_par.h:71
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
Definition codec_par.h:57
enum AVColorPrimaries color_primaries
Definition codec_par.h:190
int sample_rate
The number of audio samples per second.
Definition codec_par.h:213
enum AVColorTransferCharacteristic color_trc
Definition codec_par.h:191
enum AVAlphaMode alpha_mode
Video with alpha channel only.
Definition codec_par.h:261
int initial_padding
Number of padding audio samples at the start.
Definition codec_par.h:239
AVPacketSideData * coded_side_data
Additional data associated with the entire stream.
Definition codec_par.h:83
enum AVChromaLocation chroma_location
Definition codec_par.h:193
enum AVColorRange color_range
Additional colorspace characteristics.
Definition codec_par.h:189
This structure stores auxiliary information for decoding, presenting, or otherwise processing the cod...
Definition packet.h:424
Rational number (pair of numerator and denominator).
Definition rational.h:58