博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
ffmpeg常用数据结构一
阅读量:6983 次
发布时间:2019-06-27

本文共 3884 字,大约阅读时间需要 12 分钟。

整体结构图:

 

 附:

聚合(Aggregation) : 表示has-a的关系,是一种不稳定的包含关系。较强于一般关联,整体与局部的关系,并且没有了整体,局部也可单独存在。如公司和员工的关系,公司包含员工,但如果公司倒闭,员工依然可以换公司。在类图使用空心的菱形表示,菱形从局部指向整体

 

依赖(Dependency):对象之间最弱的一种关联方式,是临时性的关联。代码中一般指由局部变量、函数参数、返回值建立的对于其他对象的调用关系。一个类调用被依赖类中的某些方法而得以完成这个类的一些职责。在类图使用带箭头的虚线表示,箭头从使用类指向被依赖的类

 

AVCodecContext

这是一个描述编解码器上下文的数据结构,包含了众多编解码器需要的参数信息,如下列出了部分比较重要的域:

typedef  struct  AVCodecContext {

 

    ......

 

    /**

     * 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;

intextradata_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.

     */

AVRationaltime_base;

 

    /* 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;

 

    ......

 

    /* audio only */

intsample_rate; ///< samples per second

int channels;    ///< number of audio channels

 

    /**

     * audio sample format

     * - encoding: Set by user.

     * - decoding: Set by libavcodec.

     */

enumSampleFormatsample_fmt;  ///< sample format

 

    /* The following data should not be initialized. */

    /**

     * Samples per packet, initialized when calling 'init'.

     */

intframe_size;

intframe_number;   ///< audio or video frame number

 

    ......

 

    char codec_name[32];

enumAVMediaTypecodec_type; /* see AVMEDIA_TYPE_xxx */

enumCodecIDcodec_id; /* see 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 then 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 intcodec_tag;           

 

    ......

 

    /**

     * Size of the frame reordering buffer in the decoder.

     * For MPEG-2 it is 1 IPB or 0 low delay IP.

     * - encoding: Set by libavcodec.

     * - decoding: Set by libavcodec.

     */

inthas_b_frames;

 

    /**

     * number of bytes per packet if constant and known or 0

     * Used by some WAV based audio codecs.

     */

intblock_align;

 

    ......

 

    /**

     * bits per sample/pixel from the demuxer (needed for huffyuv).

     * - encoding: Set by libavcodec.

     * - decoding: Set by user.

     */

intbits_per_coded_sample; 

 

     ......

 

} AVCodecContext;

如果是单纯使用libavcodec,这部分信息需要调用者进行初始化;如果是使用整个FFMPEG库,这部分信息在调用 avformat_open_input和avformat_find_stream_info的过程中根据文件的头信息及媒体流内的头部信息完成初始化。其中几个主要域的释义如下:

1.   extradata/extradata_size:这个buffer中存放了解码器可能会用到的额外信息在av_read_frame中填充。一般来说,首先,某种具体格式的demuxer在读取格式头信息的时候会填充extradata,其次,如果demuxer没有做这个事情,比如可能在头部压根儿就没有相关的编解码信息,则相应的parser会继续从已经解复用出来的媒体流中继续寻找。在没有找到任何额外信息的情况下,这个buffer指针为空。

2.   time_base

3.   width/height:视频的宽和高。

4.   sample_rate/channels:音频的采样率和信道数目。

5.   sample_fmt: 音频的原始采样格式。

6.   codec_name/codec_type/codec_id/codec_tag编解码器的信息

 

 

转载地址:http://apvpl.baihongyu.com/

你可能感兴趣的文章
Socket网络编程--聊天程序(8)
查看>>
jQuery添加/改变/移除CSS类
查看>>
不可重复读和幻读的区别
查看>>
LeetCode_Path Sum II
查看>>
CF 439C(251C题)Devu and Partitioning of the Array
查看>>
【云计算】docker的小知识,帮你更深入理解容器技术
查看>>
IE6/IE7下:inline-block解决方案
查看>>
NuGet在Push的时候提示“远程服务器返回错误:(403)已禁用”问题解决
查看>>
FindBugs插件
查看>>
深入理解Javascript闭包(closure)
查看>>
URAL 1029
查看>>
[Leetcode] Sqrt(x)
查看>>
多线程相互排斥--mutex(二)
查看>>
/dev/null &
查看>>
11个让你吃惊的Linux终端命令
查看>>
Windows 编程
查看>>
PHP 代码规范
查看>>
双数组 实现 Trie
查看>>
android使用Activity
查看>>
【星辰傀儡线·命运环·卷二 尘埃】 5 困惑
查看>>