Path: blob/master/dep/ffmpeg/include/libavcodec/codec_par.h
4216 views
/*1* Codec parameters public API2*3* This file is part of FFmpeg.4*5* FFmpeg is free software; you can redistribute it and/or6* modify it under the terms of the GNU Lesser General Public7* License as published by the Free Software Foundation; either8* version 2.1 of the License, or (at your option) any later version.9*10* FFmpeg is distributed in the hope that it will be useful,11* but WITHOUT ANY WARRANTY; without even the implied warranty of12* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU13* Lesser General Public License for more details.14*15* You should have received a copy of the GNU Lesser General Public16* License along with FFmpeg; if not, write to the Free Software17* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA18*/1920#ifndef AVCODEC_CODEC_PAR_H21#define AVCODEC_CODEC_PAR_H2223#include <stdint.h>2425#include "libavutil/avutil.h"26#include "libavutil/channel_layout.h"27#include "libavutil/rational.h"28#include "libavutil/pixfmt.h"2930#include "codec_id.h"31#include "defs.h"32#include "packet.h"3334/**35* @addtogroup lavc_core36* @{37*/3839/**40* This struct describes the properties of an encoded stream.41*42* sizeof(AVCodecParameters) is not a part of the public ABI, this struct must43* be allocated with avcodec_parameters_alloc() and freed with44* avcodec_parameters_free().45*/46typedef struct AVCodecParameters {47/**48* General type of the encoded data.49*/50enum AVMediaType codec_type;51/**52* Specific type of the encoded data (the codec used).53*/54enum AVCodecID codec_id;55/**56* Additional information about the codec (corresponds to the AVI FOURCC).57*/58uint32_t codec_tag;5960/**61* Extra binary data needed for initializing the decoder, codec-dependent.62*63* Must be allocated with av_malloc() and will be freed by64* avcodec_parameters_free(). The allocated size of extradata must be at65* least extradata_size + AV_INPUT_BUFFER_PADDING_SIZE, with the padding66* bytes zeroed.67*/68uint8_t *extradata;69/**70* Size of the extradata content in bytes.71*/72int extradata_size;7374/**75* Additional data associated with the entire stream.76*77* Should be allocated with av_packet_side_data_new() or78* av_packet_side_data_add(), and will be freed by avcodec_parameters_free().79*/80AVPacketSideData *coded_side_data;8182/**83* Amount of entries in @ref coded_side_data.84*/85int nb_coded_side_data;8687/**88* - video: the pixel format, the value corresponds to enum AVPixelFormat.89* - audio: the sample format, the value corresponds to enum AVSampleFormat.90*/91int format;9293/**94* The average bitrate of the encoded data (in bits per second).95*/96int64_t bit_rate;9798/**99* The number of bits per sample in the codedwords.100*101* This is basically the bitrate per sample. It is mandatory for a bunch of102* formats to actually decode them. It's the number of bits for one sample in103* the actual coded bitstream.104*105* This could be for example 4 for ADPCM106* For PCM formats this matches bits_per_raw_sample107* Can be 0108*/109int bits_per_coded_sample;110111/**112* This is the number of valid bits in each output sample. If the113* sample format has more bits, the least significant bits are additional114* padding bits, which are always 0. Use right shifts to reduce the sample115* to its actual size. For example, audio formats with 24 bit samples will116* have bits_per_raw_sample set to 24, and format set to AV_SAMPLE_FMT_S32.117* To get the original sample use "(int32_t)sample >> 8"."118*119* For ADPCM this might be 12 or 16 or similar120* Can be 0121*/122int bits_per_raw_sample;123124/**125* Codec-specific bitstream restrictions that the stream conforms to.126*/127int profile;128int level;129130/**131* Video only. The dimensions of the video frame in pixels.132*/133int width;134int height;135136/**137* Video only. The aspect ratio (width / height) which a single pixel138* should have when displayed.139*140* When the aspect ratio is unknown / undefined, the numerator should be141* set to 0 (the denominator may have any value).142*/143AVRational sample_aspect_ratio;144145/**146* Video only. Number of frames per second, for streams with constant frame147* durations. Should be set to { 0, 1 } when some frames have differing148* durations or if the value is not known.149*150* @note This field correponds to values that are stored in codec-level151* headers and is typically overridden by container/transport-layer152* timestamps, when available. It should thus be used only as a last resort,153* when no higher-level timing information is available.154*/155AVRational framerate;156157/**158* Video only. The order of the fields in interlaced video.159*/160enum AVFieldOrder field_order;161162/**163* Video only. Additional colorspace characteristics.164*/165enum AVColorRange color_range;166enum AVColorPrimaries color_primaries;167enum AVColorTransferCharacteristic color_trc;168enum AVColorSpace color_space;169enum AVChromaLocation chroma_location;170171/**172* Video only. Number of delayed frames.173*/174int video_delay;175176/**177* Audio only. The channel layout and number of channels.178*/179AVChannelLayout ch_layout;180/**181* Audio only. The number of audio samples per second.182*/183int sample_rate;184/**185* Audio only. The number of bytes per coded audio frame, required by some186* formats.187*188* Corresponds to nBlockAlign in WAVEFORMATEX.189*/190int block_align;191/**192* Audio only. Audio frame size, if known. Required by some formats to be static.193*/194int frame_size;195196/**197* Audio only. The amount of padding (in samples) inserted by the encoder at198* the beginning of the audio. I.e. this number of leading decoded samples199* must be discarded by the caller to get the original audio without leading200* padding.201*/202int initial_padding;203/**204* Audio only. The amount of padding (in samples) appended by the encoder to205* the end of the audio. I.e. this number of decoded samples must be206* discarded by the caller from the end of the stream to get the original207* audio without any trailing padding.208*/209int trailing_padding;210/**211* Audio only. Number of samples to skip after a discontinuity.212*/213int seek_preroll;214} AVCodecParameters;215216/**217* Allocate a new AVCodecParameters and set its fields to default values218* (unknown/invalid/0). The returned struct must be freed with219* avcodec_parameters_free().220*/221AVCodecParameters *avcodec_parameters_alloc(void);222223/**224* Free an AVCodecParameters instance and everything associated with it and225* write NULL to the supplied pointer.226*/227void avcodec_parameters_free(AVCodecParameters **par);228229/**230* Copy the contents of src to dst. Any allocated fields in dst are freed and231* replaced with newly allocated duplicates of the corresponding fields in src.232*233* @return >= 0 on success, a negative AVERROR code on failure.234*/235int avcodec_parameters_copy(AVCodecParameters *dst, const AVCodecParameters *src);236237/**238* This function is the same as av_get_audio_frame_duration(), except it works239* with AVCodecParameters instead of an AVCodecContext.240*/241int av_get_audio_frame_duration2(AVCodecParameters *par, int frame_bytes);242243/**244* @}245*/246247#endif // AVCODEC_CODEC_PAR_H248249250