Loading...
Searching...
No Matches
codec_par.h
Go to the documentation of this file.
/*
* Codec parameters public API
*
* This file is part of FFmpeg.
*
* FFmpeg is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* FFmpeg is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef AVCODEC_CODEC_PAR_H
#define AVCODEC_CODEC_PAR_H
#include <stdint.h>
#include "libavutil/avutil.h"
#include "libavutil/channel_layout.h"
#include "libavutil/rational.h"
#include "libavutil/pixfmt.h"
#include "codec_id.h"
#include "defs.h"
#include "packet.h"
/**
* @addtogroup lavc_core
* @{
*/
/**
* This struct describes the properties of an encoded stream.
*
* sizeof(AVCodecParameters) is not a part of the public ABI, this struct must
* be allocated with avcodec_parameters_alloc() and freed with
* avcodec_parameters_free().
*/
typedef struct AVCodecParameters {
/**
* General type of the encoded data.
*/
enum AVMediaType codec_type;
/**
* Specific type of the encoded data (the codec used).
*/
enum AVCodecID codec_id;
/**
* Additional information about the codec (corresponds to the AVI FOURCC).
*/
uint32_t codec_tag;
/**
* Extra binary data needed for initializing the decoder, codec-dependent.
*
* Must be allocated with av_malloc() and will be freed by
* avcodec_parameters_free(). The allocated size of extradata must be at
* least extradata_size + AV_INPUT_BUFFER_PADDING_SIZE, with the padding
* bytes zeroed.
*/
uint8_t *extradata;
/**
* Size of the extradata content in bytes.
*/
int extradata_size;
/**
* Additional data associated with the entire stream.
*
* Should be allocated with av_packet_side_data_new() or
* av_packet_side_data_add(), and will be freed by avcodec_parameters_free().
*/
AVPacketSideData *coded_side_data;
/**
* Amount of entries in @ref coded_side_data.
*/
int nb_coded_side_data;
/**
* - video: the pixel format, the value corresponds to enum AVPixelFormat.
* - audio: the sample format, the value corresponds to enum AVSampleFormat.
*/
int format;
/**
* The average bitrate of the encoded data (in bits per second).
*/
int64_t bit_rate;
/**
* The number of bits per sample in the codedwords.
*
* This is basically the bitrate per sample. It is mandatory for a bunch of
* formats to actually decode them. It's the number of bits for one sample in
* the actual coded bitstream.
*
* This could be for example 4 for ADPCM
* For PCM formats this matches bits_per_raw_sample
* Can be 0
*/
int bits_per_coded_sample;
/**
* This is the number of valid bits in each output sample. If the
* sample format has more bits, the least significant bits are additional
* padding bits, which are always 0. Use right shifts to reduce the sample
* to its actual size. For example, audio formats with 24 bit samples will
* have bits_per_raw_sample set to 24, and format set to AV_SAMPLE_FMT_S32.
* To get the original sample use "(int32_t)sample >> 8"."
*
* For ADPCM this might be 12 or 16 or similar
* Can be 0
*/
int bits_per_raw_sample;
/**
* Codec-specific bitstream restrictions that the stream conforms to.
*/
int profile;
int level;
/**
* Video only. The dimensions of the video frame in pixels.
*/
int width;
int height;
/**
* Video only. The aspect ratio (width / height) which a single pixel
* should have when displayed.
*
* When the aspect ratio is unknown / undefined, the numerator should be
* set to 0 (the denominator may have any value).
*/
AVRational sample_aspect_ratio;
/**
* Video only. Number of frames per second, for streams with constant frame
* durations. Should be set to { 0, 1 } when some frames have differing
* durations or if the value is not known.
*
* @note This field corresponds to values that are stored in codec-level
* headers and is typically overridden by container/transport-layer
* timestamps, when available. It should thus be used only as a last resort,
* when no higher-level timing information is available.
*/
AVRational framerate;
/**
* Video only. The order of the fields in interlaced video.
*/
enum AVFieldOrder field_order;
/**
* Video only. Additional colorspace characteristics.
*/
enum AVColorRange color_range;
enum AVColorPrimaries color_primaries;
enum AVColorTransferCharacteristic color_trc;
enum AVColorSpace color_space;
enum AVChromaLocation chroma_location;
/**
* Video only. Number of delayed frames.
*/
int video_delay;
/**
* Audio only. The channel layout and number of channels.
*/
AVChannelLayout ch_layout;
/**
* Audio only. The number of audio samples per second.
*/
int sample_rate;
/**
* Audio only. The number of bytes per coded audio frame, required by some
* formats.
*
* Corresponds to nBlockAlign in WAVEFORMATEX.
*/
int block_align;
/**
* Audio only. Audio frame size, if known. Required by some formats to be static.
*/
int frame_size;
/**
* Audio only. The amount of padding (in samples) inserted by the encoder at
* the beginning of the audio. I.e. this number of leading decoded samples
* must be discarded by the caller to get the original audio without leading
* padding.
*/
int initial_padding;
/**
* Audio only. The amount of padding (in samples) appended by the encoder to
* the end of the audio. I.e. this number of decoded samples must be
* discarded by the caller from the end of the stream to get the original
* audio without any trailing padding.
*/
int trailing_padding;
/**
* Audio only. Number of samples to skip after a discontinuity.
*/
int seek_preroll;
/**
* Video with alpha channel only. Alpha channel handling
*/
enum AVAlphaMode alpha_mode;
} AVCodecParameters;
/**
* Allocate a new AVCodecParameters and set its fields to default values
* (unknown/invalid/0). The returned struct must be freed with
* avcodec_parameters_free().
*/
AVCodecParameters *avcodec_parameters_alloc(void);
/**
* Free an AVCodecParameters instance and everything associated with it and
* write NULL to the supplied pointer.
*/
void avcodec_parameters_free(AVCodecParameters **par);
/**
* Copy the contents of src to dst. Any allocated fields in dst are freed and
* replaced with newly allocated duplicates of the corresponding fields in src.
*
* @return >= 0 on success, a negative AVERROR code on failure.
*/
int avcodec_parameters_copy(AVCodecParameters *dst, const AVCodecParameters *src);
/**
* This function is the same as av_get_audio_frame_duration(), except it works
* with AVCodecParameters instead of an AVCodecContext.
*/
int av_get_audio_frame_duration2(AVCodecParameters *par, int frame_bytes);
/**
* @}
*/
#endif // AVCODEC_CODEC_PAR_H
avutil.h
Convenience header that includes libavutil's core.
channel_layout.h
Public libavutil channel layout APIs header.
codec_id.h
defs.h
Misc types and constants that do not belong anywhere else.
AVFieldOrder
AVFieldOrder
Definition defs.h:211
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...
avcodec_parameters_alloc
AVCodecParameters * avcodec_parameters_alloc(void)
Allocate a new AVCodecParameters and set its fields to default values (unknown/invalid/0).
avcodec_parameters_copy
int avcodec_parameters_copy(AVCodecParameters *dst, const AVCodecParameters *src)
Copy the contents of src to dst.
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...
AVCodecID
AVCodecID
Identify the syntax and semantics of the bitstream.
Definition codec_id.h:49
AVMediaType
AVMediaType
Definition avutil.h:198
packet.h
pixfmt.h
pixel format definitions
AVChromaLocation
AVChromaLocation
Location of chroma samples.
Definition pixfmt.h:796
AVColorRange
AVColorRange
Visual content value range.
Definition pixfmt.h:742
AVAlphaMode
AVAlphaMode
Correlation between the alpha channel and color values.
Definition pixfmt.h:810
AVColorPrimaries
AVColorPrimaries
Chromaticity coordinates of the source primaries.
Definition pixfmt.h:636
AVColorTransferCharacteristic
AVColorTransferCharacteristic
Color Transfer Characteristic.
Definition pixfmt.h:666
AVColorSpace
AVColorSpace
YUV colorspace type.
Definition pixfmt.h:700
rational.h
Utilities for rational number calculation.
AVChannelLayout
An AVChannelLayout holds information about the channel layout of audio data.
Definition channel_layout.h:319
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:169
AVCodecParameters::extradata_size
int extradata_size
Size of the extradata content in bytes.
Definition codec_par.h:73
AVCodecParameters::frame_size
int frame_size
Audio only.
Definition codec_par.h:195
AVCodecParameters::field_order
enum AVFieldOrder field_order
Video only.
Definition codec_par.h:161
AVCodecParameters::height
int height
Definition codec_par.h:135
AVCodecParameters::level
int level
Definition codec_par.h:129
AVCodecParameters::nb_coded_side_data
int nb_coded_side_data
Amount of entries in coded_side_data.
Definition codec_par.h:86
AVCodecParameters::bits_per_coded_sample
int bits_per_coded_sample
The number of bits per sample in the codedwords.
Definition codec_par.h:110
AVCodecParameters::ch_layout
AVChannelLayout ch_layout
Audio only.
Definition codec_par.h:180
AVCodecParameters::width
int width
Video only.
Definition codec_par.h:134
AVCodecParameters::bit_rate
int64_t bit_rate
The average bitrate of the encoded data (in bits per second).
Definition codec_par.h:97
AVCodecParameters::seek_preroll
int seek_preroll
Audio only.
Definition codec_par.h:214
AVCodecParameters::codec_type
enum AVMediaType codec_type
General type of the encoded data.
Definition codec_par.h:51
AVCodecParameters::trailing_padding
int trailing_padding
Audio only.
Definition codec_par.h:210
AVCodecParameters::framerate
AVRational framerate
Video only.
Definition codec_par.h:156
AVCodecParameters::profile
int profile
Codec-specific bitstream restrictions that the stream conforms to.
Definition codec_par.h:128
AVCodecParameters::block_align
int block_align
Audio only.
Definition codec_par.h:191
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:123
AVCodecParameters::sample_aspect_ratio
AVRational sample_aspect_ratio
Video only.
Definition codec_par.h:144
AVCodecParameters::video_delay
int video_delay
Video only.
Definition codec_par.h:175
AVCodecParameters::codec_tag
uint32_t codec_tag
Additional information about the codec (corresponds to the AVI FOURCC).
Definition codec_par.h:59
AVCodecParameters::extradata
uint8_t * extradata
Extra binary data needed for initializing the decoder, codec-dependent.
Definition codec_par.h:69
AVCodecParameters::codec_id
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
Definition codec_par.h:55
AVCodecParameters::color_primaries
enum AVColorPrimaries color_primaries
Definition codec_par.h:167
AVCodecParameters::format
int format
Definition codec_par.h:92
AVCodecParameters::sample_rate
int sample_rate
Audio only.
Definition codec_par.h:184
AVCodecParameters::color_trc
enum AVColorTransferCharacteristic color_trc
Definition codec_par.h:168
AVCodecParameters::alpha_mode
enum AVAlphaMode alpha_mode
Video with alpha channel only.
Definition codec_par.h:219
AVCodecParameters::initial_padding
int initial_padding
Audio only.
Definition codec_par.h:203
AVCodecParameters::coded_side_data
AVPacketSideData * coded_side_data
Additional data associated with the entire stream.
Definition codec_par.h:81
AVCodecParameters::chroma_location
enum AVChromaLocation chroma_location
Definition codec_par.h:170
AVCodecParameters::color_range
enum AVColorRange color_range
Video only.
Definition codec_par.h:166
AVPacketSideData
This structure stores auxiliary information for decoding, presenting, or otherwise processing the cod...
Definition packet.h:409
AVRational
Rational number (pair of numerator and denominator).
Definition rational.h:58