FFMpeg分析2:AVInputFormat和AVOutputFormat

来源:互联网 发布:网络联合电视台 编辑:程序博客网 时间:2024/05/18 00:01

  我们先看一下音视频播放器的大概结构(个人想法,不保证正确):1、数据源输入(Input)->2、文件格式解析器(Demux)->3、音视频解码(Decoder)->4、颜色空间转换(仅视频)->5、渲染输出(Render Output)。前一篇介绍的几个struct是数据源输入模块里的内容,哪么这一帖所讲的就是第二个模块即文件格式解析器里用到的内容。

      AVInputFormat、AVOutputFormat与URLProtocol类似,每一种文件类型都有一个AVInputFormat和AVOutputFormat静态对像并通过av_register_input_format和av_register_output_format函数链成一个表,其表头在utils.c:

 

/** head of registered input format linked list */

AVInputFormat *first_iformat = NULL;

/** head of registered output format linked list */

AVOutputFormat *first_oformat = NULL;

 

AVInputFormat和AVOutputFormat的定义分别在avformat.h,代码很长,不贴出来浪费空间了。

当程序运行时,AVInputFormat对像的

 

int av_open_input_file(AVFormatContext **ic_ptr, const char *filename,

                       AVInputFormat *fmt,

                       int buf_size,

                       AVFormatParameters *ap)

{

 

     fmt = av_probe_input_format(pd, 0);//返回该文件的AVInputFormat类型

}

至于AVOutputFormat嘛,下次再说吧,晚安!

原创粉丝点击