随笔 - 171  文章 - 257  trackbacks - 0
<2012年12月>
2526272829301
2345678
9101112131415
16171819202122
23242526272829
303112345

常用链接

留言簿(33)

随笔分类(225)

随笔档案(171)

相册

技术

友情链接

最新随笔

搜索

  •  

积分与排名

  • 积分 - 441600
  • 排名 - 48

最新随笔

最新评论

阅读排行榜

评论排行榜

调用av_open_input_file(&pFormatCtx, is->filename, NULL, 0, NULL)函数打开输入的文件.


1. 分析一下函数原型:
int av_open_input_file(AVFormatContext **ic_ptr, // 输出参数: 格式上下文
    const char *filename, // 文件名
    AVInputFormat *fmt, // 输入的格式, 为NULL, 即未知
    int buf_size, // 缓冲的大小, 为0
    AVFormatParameters *ap); // 格式的参数, 为NULL



2. 初始化探测数据:
AVProbeData probe_data, *pd = &probe_data;
pd->filename = "";
if (filename)
  pd->filename = filename;
pd->buf = NULL;
pd->buf_size = 0;



3. 探测输入的格式:
if (!fmt) { // fmt == NULL, 成立
    fmt = av_probe_input_format(pd, 0);
}



进入av_probe_input_format函数:
AVInputFormat *av_probe_input_format(AVProbeData *pd, int is_opened) {
    int score=0;
    return av_probe_input_format2(pd, is_opened, &score);
}



进入av_probe_input_format2函数:
AVInputFormat *av_probe_input_format2(AVProbeData *pd, int is_opened, int *score_max)
{
    AVInputFormat *fmt1, *fmt;
    int score;
    fmt = NULL;
    for(fmt1 = first_iformat; fmt1 != NULL; fmt1 = fmt1->next) {
        if (!is_opened == !(fmt1->flags & AVFMT_NOFILE)) // is_opened == 0, fmt1->flags 没有设置 AVFMT_NOFILE 标志时成立
            continue; 
        /* 省略部分代码 */
    }




见libavformat/raw.c文件:
AVInputFormat h264_demuxer = {
  "h264",
  NULL_IF_CONFIG_SMALL("raw H.264 video format"),
  0,
  h264_probe,
  video_read_header,
  ff_raw_read_partial_packet,
  .flags= AVFMT_GENERIC_INDEX,
  .extensions = "h26l,h264,264", //FIXME remove after writing mpeg4_probe
  .value = CODEC_ID_H264,
};


由于 h264_demuxer.flags == AVFMT_GENERIC_INDEX, 所以上面成立, continue, 返回的 AVInputFormat 指针为 NULL, 探测不成功.
posted on 2012-12-14 01:32 Khan 阅读(1555) 评论(0)  编辑 收藏 引用 所属分类: GCC/G++跨平台开发周边技术

只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理