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