FFMPEG结构体分析:AVCodecContext
FFMPEG有几个最重要的结构体,包含了解协议,解封装,解码操作,此前已经进行过分析:FFMPEG中最关键的结构体之间的关系
在此不再详述,其中AVCodecContext是包含变量较多的结构体(感觉差不多是变量最多的结构体)。本文将会大概分析一下该结构体里每个变量的含义和作用。因为如果每个变量都分析的话,工作量太大,实在来不及。
首先看一下结构体的定义(位于avcodec.h):
/*
*雷霄骅
*leixiaohua1020@126.com
*中国传媒大学/数字电视技术
*/
/**
* main external API structure.
* New fields can be added to the end with minor version bumps.
* Removal, reordering and changes to existing fields require a major
* version bump.
* Please use AVOptions (av_opt* / av_set/get*()) to access these fields from user
* applications.
* sizeof(AVCodecContext) must not be used outside libav*.
*/
typedef struct AVCodecContext {
/**
* information on struct for av_log
* - set by avcodec_alloc_context3
*/
const AVClass *av_class;
int log_level_offset;
enum AVMediaType codec_type; /* see AVMEDIA_TYPE_xxx */
const struct AVCodec *codec;
char codec_name[32];
enum AVCodecID codec_id; /* see AV_CODEC_ID_xxx */
/**
* fourcc (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A').
* This is used to work around some encoder bugs.
* A demuxer should set this to what is stored in the field used to identify the codec.
* If there are multiple such fields in a container then the demuxer should choose the one
* which maximizes the information about the used codec.
* If the codec tag field in a container is larger than 32 bits then the demuxer should
* remap the longer ID to 32 bits with a table or other structure. Alternatively a new
* extra_codec_tag + size could be added but for this a clear advantage must be demonstrated
* first.
* - encoding: Set by user, if not then the default based on codec_id will be used.
* - decoding: Set by user, will be converted to uppercase by libavcodec during init.
*/
unsigned int codec_tag;
/**
* fourcc from the AVI stream header (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A').
* This is used to work around some encoder bugs.
* - encoding: unused
* - decoding: Set by user, will be converted to uppercase by libavcodec during init.
*/
unsigned int stream_codec_tag;
#if FF_API_SUB_ID
/**
* @deprecated this field is unused
*/
attribute_deprecated int sub_id;
#endif
void *priv_data;
/**
* Private context used for internal data.
*
* Unlike priv_data, this is not codec-specific. It is used in general
* libavcodec functions.
*/
struct AVCodecInternal *internal;
/**
* Private data of the user, can be used to carry app specific stuff.
* - encoding: Set by user.
* - decoding: Set by user.
*/
void *opaque;
/**
* the average bitrate
* - encoding: Set by user; unused for constant quantizer encoding.
* - decoding: Set by libavcodec. 0 or some bitrate if this info is available in the stream.
*/
int bit_rate;
/**
* number of bits the bitstream is allowed to diverge from the reference.
* the reference can be CBR (for CBR pass1) or VBR (for pass2)
* - encoding: Set by user; unused for constant quantizer encoding.
* - decoding: unused
*/
int bit_rate_tolerance;
/**
* Global quality for codecs which cannot change it per frame.
* This should be proportional to MPEG-1/2/4 qscale.
* - encoding: Set by user.
* - decoding: unused
*/
int global_quality;
/**
* - encoding: Set by user.
* - decoding: unused
*/
int compression_level;
#define FF_COMPRESSION_DEFAULT -1
/**
* CODEC_FLAG_*.
* - encoding: Set by user.
* - decoding: Set by user.
*/
int flags;
/**
* CODEC_FLAG2_*
* - encoding: Set by user.
* - decoding: Set by user.
*/
int flags2;
/**
* some codecs need / can use extradata like Huffman tables.
* mjpeg: Huffman tables
* rv10: additional flags
* mpeg4: global headers (they can be in the bitstream or here)
* The allocated memory should be FF_INPUT_BUFFER_PADDING_SIZE bytes larger
* than extradata_size to avoid prolems if it is read with the bitstream reader.
* The bytewise contents of extradata must not depend on the architecture or CPU endianness.
* - encoding: Set/allocated/freed by libavcodec.
* - decoding: Set/allocated/freed by user.
*/
uint8_t *extradata;
int extradata_size;
/**
* This is the fundamental unit of time (in seconds) in terms
* of which frame timestamps are represented. For fixed-fps content,
* timebase should be 1/framerate and timestamp increments should be
* identically 1.
* - encoding: MUST be set by user.
* - decoding: Set by libavcodec.
*/
AVRational time_base;
/**
* For some codecs, the time base is closer to the field rate than the frame rate.
* Most notably, H.264 and MPEG-2 specify time_base as half of frame duration
* if no telecine is used ...
*
* Set to time_base ticks per frame. Default 1, e.g., H.264/MPEG-2 set it to 2.
*/
int ticks_per_frame;
/**
* Encoding: Number of frames delay there will be from the encoder input to
* the decoder output. (we assume the decoder matches the spec)
* Decoding: Number of frames delay in addition to what a standard decoder
* as specified in the spec would produce.
*
* Video:
* Number of frames the decoded output will be delayed relative to the
* encoded input.
*
* Audio:
* For encoding, this is the number of "priming" samples added to the
* beginning of the stream. The decoded output will be delayed by this
* many samples relative to the input to the encoder. Note that this
* field is purely informational and does not directly affect the pts
* output by the encoder, which should always be based on the actual
* presentation time, including any delay.
* For decoding, this is the number of samples the decoder needs to
* output before the decoder's output is valid. When seeking, you should
* start decoding this many samples prior to your desired seek point.
*
* - encoding: Set by libavcodec.
* - decoding: Set by libavcodec.
*/
int delay;
/* video only */
/**
* picture width / height.
* - encoding: MUST be set by user.
* - decoding: Set by libavcodec.
* Note: For compatibility it is possible to set this instead of
* coded_width/height before decoding.
*/
int width, height;
/**
* Bitstream width / height, may be different from width/height if lowres enabled.
* - encoding: unused
* - decoding: Set by user before init if known. Codec should override / dynamically change if needed.
*/
int coded_width, coded_height;
#define FF_ASPECT_EXTENDED 15
/**
* the number of pictures in a group of pictures, or 0 for intra_only
* - encoding: Set by user.
* - decoding: unused
*/
int gop_size;
/**
* Pixel format, see AV_PIX_FMT_xxx.
* May be set by the demuxer if known from headers.
* May be overridden by the decoder if it knows better.
* - encoding: Set by user.
* - decoding: Set by user if known, overridden by libavcodec if known
*/
enum AVPixelFormat pix_fmt;
/**
* Motion estimation algorithm used for video coding.
* 1 (zero), 2 (full), 3 (log), 4 (phods), 5 (epzs), 6 (x1), 7 (hex),
* 8 (umh), 9 (ite补充:软件开发 , C++ ,
上一个:单链表的逆置
下一个:hdu 2846 Repository (字典树)
- 更多C/C++疑问解答:
- 关于c++的cout输出的问题。
- 在学校里学过C和C++,不过学的很一般,现在自学C#,会不会很难?
- 全国计算机二级C语言笔试题
- 已知某树有2个2度结点,3个3度结点,4个4度结点,问有几个叶子结点?
- c++数据结构内部排序问题,整数排序
- 2012九月计算机二级C语言全国题库,,急求急求
- 如果assert只有一个字符串作为参数,是什么意思呢?
- C语言中,哪些运算符具有左结合性,哪些具有右结合性,帮忙总结下,谢谢了!
- 为什么用结构体编写的程序输入是,0输不出来啊~~~
- 将IEEE—754的十六进制转化为十进制浮点类型,用C或C++都行,多谢各位大侠啊,非常感谢!
- 为什么这个程序求不出公式?
- 这个链表倒置的算法请大家分析下
- c语言函数库调用
- C语言unsigned int纠错
- C语言快排求解啊