Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1459611
  • 博文数量: 181
  • 博客积分: 3308
  • 博客等级: 中校
  • 技术积分: 2227
  • 用 户 组: 普通用户
  • 注册时间: 2010-10-03 12:03
个人简介

我是zoro

文章分类

全部博文(181)

文章存档

2015年(1)

2013年(35)

2012年(39)

2011年(50)

2010年(56)

分类: LINUX

2012-11-01 13:27:45

转自:http://blog.csdn.net/menuconfig/article/details/6613775

调用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, 探测不成功.

阅读(2783) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~