FFmpeg 6.0.1
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
33/**
34 * @addtogroup lavc_core
35 * @{
36 */
37
41 AV_FIELD_TT, ///< Top coded_first, top displayed first
42 AV_FIELD_BB, ///< Bottom coded first, bottom displayed first
43 AV_FIELD_TB, ///< Top coded first, bottom displayed first
44 AV_FIELD_BT, ///< Bottom coded first, top displayed first
45};
46
47/**
48 * This struct describes the properties of an encoded stream.
49 *
50 * sizeof(AVCodecParameters) is not a part of the public ABI, this struct must
51 * be allocated with avcodec_parameters_alloc() and freed with
52 * avcodec_parameters_free().
53 */
54typedef struct AVCodecParameters {
55 /**
56 * General type of the encoded data.
57 */
59 /**
60 * Specific type of the encoded data (the codec used).
61 */
63 /**
64 * Additional information about the codec (corresponds to the AVI FOURCC).
65 */
66 uint32_t codec_tag;
67
68 /**
69 * Extra binary data needed for initializing the decoder, codec-dependent.
70 *
71 * Must be allocated with av_malloc() and will be freed by
72 * avcodec_parameters_free(). The allocated size of extradata must be at
73 * least extradata_size + AV_INPUT_BUFFER_PADDING_SIZE, with the padding
74 * bytes zeroed.
75 */
76 uint8_t *extradata;
77 /**
78 * Size of the extradata content in bytes.
79 */
81
82 /**
83 * - video: the pixel format, the value corresponds to enum AVPixelFormat.
84 * - audio: the sample format, the value corresponds to enum AVSampleFormat.
85 */
86 int format;
87
88 /**
89 * The average bitrate of the encoded data (in bits per second).
90 */
91 int64_t bit_rate;
92
93 /**
94 * The number of bits per sample in the codedwords.
95 *
96 * This is basically the bitrate per sample. It is mandatory for a bunch of
97 * formats to actually decode them. It's the number of bits for one sample in
98 * the actual coded bitstream.
99 *
100 * This could be for example 4 for ADPCM
101 * For PCM formats this matches bits_per_raw_sample
102 * Can be 0
103 */
105
106 /**
107 * This is the number of valid bits in each output sample. If the
108 * sample format has more bits, the least significant bits are additional
109 * padding bits, which are always 0. Use right shifts to reduce the sample
110 * to its actual size. For example, audio formats with 24 bit samples will
111 * have bits_per_raw_sample set to 24, and format set to AV_SAMPLE_FMT_S32.
112 * To get the original sample use "(int32_t)sample >> 8"."
113 *
114 * For ADPCM this might be 12 or 16 or similar
115 * Can be 0
116 */
118
119 /**
120 * Codec-specific bitstream restrictions that the stream conforms to.
121 */
123 int level;
124
125 /**
126 * Video only. The dimensions of the video frame in pixels.
127 */
128 int width;
130
131 /**
132 * Video only. The aspect ratio (width / height) which a single pixel
133 * should have when displayed.
134 *
135 * When the aspect ratio is unknown / undefined, the numerator should be
136 * set to 0 (the denominator may have any value).
137 */
139
140 /**
141 * Video only. The order of the fields in interlaced video.
142 */
144
145 /**
146 * Video only. Additional colorspace characteristics.
147 */
153
154 /**
155 * Video only. Number of delayed frames.
156 */
158
159#if FF_API_OLD_CHANNEL_LAYOUT
160 /**
161 * Audio only. The channel layout bitmask. May be 0 if the channel layout is
162 * unknown or unspecified, otherwise the number of bits set must be equal to
163 * the channels field.
164 * @deprecated use ch_layout
165 */
167 uint64_t channel_layout;
168 /**
169 * Audio only. The number of audio channels.
170 * @deprecated use ch_layout.nb_channels
171 */
173 int channels;
174#endif
175 /**
176 * Audio only. The number of audio samples per second.
177 */
179 /**
180 * Audio only. The number of bytes per coded audio frame, required by some
181 * formats.
182 *
183 * Corresponds to nBlockAlign in WAVEFORMATEX.
184 */
186 /**
187 * Audio only. Audio frame size, if known. Required by some formats to be static.
188 */
190
191 /**
192 * Audio only. The amount of padding (in samples) inserted by the encoder at
193 * the beginning of the audio. I.e. this number of leading decoded samples
194 * must be discarded by the caller to get the original audio without leading
195 * padding.
196 */
198 /**
199 * Audio only. The amount of padding (in samples) appended by the encoder to
200 * the end of the audio. I.e. this number of decoded samples must be
201 * discarded by the caller from the end of the stream to get the original
202 * audio without any trailing padding.
203 */
205 /**
206 * Audio only. Number of samples to skip after a discontinuity.
207 */
209
210 /**
211 * Audio only. The channel layout and number of channels.
212 */
215
216/**
217 * Allocate a new AVCodecParameters and set its fields to default values
218 * (unknown/invalid/0). The returned struct must be freed with
219 * avcodec_parameters_free().
220 */
222
223/**
224 * Free an AVCodecParameters instance and everything associated with it and
225 * write NULL to the supplied pointer.
226 */
228
229/**
230 * Copy the contents of src to dst. Any allocated fields in dst are freed and
231 * replaced with newly allocated duplicates of the corresponding fields in src.
232 *
233 * @return >= 0 on success, a negative AVERROR code on failure.
234 */
236
237/**
238 * This function is the same as av_get_audio_frame_duration(), except it works
239 * with AVCodecParameters instead of an AVCodecContext.
240 */
242
243/**
244 * @}
245 */
246
247#endif // AVCODEC_CODEC_PAR_H
#define attribute_deprecated
Definition: attributes.h:100
Convenience header that includes libavutil's core.
Public libavutil channel layout APIs header.
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...
AVFieldOrder
Definition: codec_par.h:38
AVCodecID
Identify the syntax and semantics of the bitstream.
Definition: codec_id.h:49
@ AV_FIELD_TT
Top coded_first, top displayed first.
Definition: codec_par.h:41
@ AV_FIELD_BB
Bottom coded first, bottom displayed first.
Definition: codec_par.h:42
@ AV_FIELD_UNKNOWN
Definition: codec_par.h:39
@ AV_FIELD_PROGRESSIVE
Definition: codec_par.h:40
@ AV_FIELD_BT
Bottom coded first, top displayed first.
Definition: codec_par.h:44
@ AV_FIELD_TB
Top coded first, bottom displayed first.
Definition: codec_par.h:43
AVMediaType
Definition: avutil.h:199
pixel format definitions
AVChromaLocation
Location of chroma samples.
Definition: pixfmt.h:680
AVColorRange
Visual content value range.
Definition: pixfmt.h:626
AVColorPrimaries
Chromaticity coordinates of the source primaries.
Definition: pixfmt.h:533
AVColorTransferCharacteristic
Color Transfer Characteristic.
Definition: pixfmt.h:558
AVColorSpace
YUV colorspace type.
Definition: pixfmt.h:587
Utilties 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:54
enum AVColorSpace color_space
Definition: codec_par.h:151
int extradata_size
Size of the extradata content in bytes.
Definition: codec_par.h:80
int frame_size
Audio only.
Definition: codec_par.h:189
enum AVFieldOrder field_order
Video only.
Definition: codec_par.h:143
int bits_per_coded_sample
The number of bits per sample in the codedwords.
Definition: codec_par.h:104
AVChannelLayout ch_layout
Audio only.
Definition: codec_par.h:213
int width
Video only.
Definition: codec_par.h:128
int64_t bit_rate
The average bitrate of the encoded data (in bits per second).
Definition: codec_par.h:91
int seek_preroll
Audio only.
Definition: codec_par.h:208
enum AVMediaType codec_type
General type of the encoded data.
Definition: codec_par.h:58
int trailing_padding
Audio only.
Definition: codec_par.h:204
int profile
Codec-specific bitstream restrictions that the stream conforms to.
Definition: codec_par.h:122
int block_align
Audio only.
Definition: codec_par.h:185
int bits_per_raw_sample
This is the number of valid bits in each output sample.
Definition: codec_par.h:117
AVRational sample_aspect_ratio
Video only.
Definition: codec_par.h:138
int video_delay
Video only.
Definition: codec_par.h:157
uint32_t codec_tag
Additional information about the codec (corresponds to the AVI FOURCC).
Definition: codec_par.h:66
uint8_t * extradata
Extra binary data needed for initializing the decoder, codec-dependent.
Definition: codec_par.h:76
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
Definition: codec_par.h:62
enum AVColorPrimaries color_primaries
Definition: codec_par.h:149
int sample_rate
Audio only.
Definition: codec_par.h:178
enum AVColorTransferCharacteristic color_trc
Definition: codec_par.h:150
int initial_padding
Audio only.
Definition: codec_par.h:197
enum AVChromaLocation chroma_location
Definition: codec_par.h:152
enum AVColorRange color_range
Video only.
Definition: codec_par.h:148
Rational number (pair of numerator and denominator).
Definition: rational.h:58