av_find_stream_info还没有理解透彻?
来源:互联网 发布:教师资格证网络课程 编辑:程序博客网 时间:2024/06/02 13:52
int av_find_stream_info(AVFormatContext *ic){//1.初始化parserfor(i=0;i<ic->nb_streams;i++) {st = ic->streams[i];if (!st->parser) {st->parser = av_parser_init(st->codec->codec_id);if(st->need_parsing == AVSTREAM_PARSE_HEADERS && st->parser){st->parser->flags |= PARSER_FLAG_COMPLETE_FRAMES;}}}for(;;) {for(i=0;i<ic->nb_streams;i++) {st = ic->streams[i];if (!has_codec_parameters(st->codec))break;}if (i == ic->nb_streams) {/* if we found the info for all the codecs, we can stop */break;}//2.如果codec参数还存在无效的,则读取一个Packetret = av_read_frame_internal(ic, &pkt1);if(st->parser && st->parser->parser->split && !st->codec->extradata){int i= st->parser->parser->split(st->codec, pkt->data, pkt->size);if(i){st->codec->extradata_size= i;st->codec->extradata= av_malloc(st->codec->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE);memcpy(st->codec->extradata, pkt->data, st->codec->extradata_size);memset(st->codec->extradata + i, 0, FF_INPUT_BUFFER_PADDING_SIZE);}}if (!has_codec_parameters(st->codec) /)//3.如果codec参数还存在无效的,则通过解码来获取信息try_decode_frame(st, pkt->data, pkt->size);if (st->time_base.den > 0 && av_rescale_q(codec_info_duration[st->index], st->time_base, AV_TIME_BASE_Q) >= ic-ax_analyze_duration) break;count++;}return ret;}
视频解码为H264时的跟踪:
1. for(;;)中count执行了206次才退出
2. 第206次退出的地方:
if (st->time_base.den > 0 && av_rescale_q(codec_info_duration[st->index], st->time_base, AV_TIME_BASE_Q) >= ic->max_analyze_duration)
break;
满足了av_rescale_q(codec_info_duration[st->index], st->time_base, AV_TIME_BASE_Q) >= ic->max_analyze_duration导致退出
av_rescale_q(codec_info_duration[st->index], st->time_base, AV_TIME_BASE_Q) >= ic->max_analyze_duration还得研究?
3. 设置数据断点发现st->codec->pix_fmt设置为PIX_FMT_YUV420P的地方:
函数堆栈try_decode_frame()->avcodec_open()->avctx->codec->init()->H264.c中的decode_init()下的
avctx->pix_fmt= avctx->get_format(avctx, avctx->codec->pix_fmts);
4.当前流退出av_find_stream_info的判断不仅是has_codec_parameters:
if (!has_codec_parameters(st->codec))
break;
if( tb_unreliable(st->codec)
&& duration_count[i]<20 && st->codec->codec_type == CODEC_TYPE_VIDEO)
break;
if(st->parser && st->parser->parser->split && !st->codec->extradata)
break;
if(st->first_dts == AV_NOPTS_VALUE)
break;
- av_find_stream_info还没有理解透彻?
- av_find_stream_info还没有理解透彻?
- av_find_stream_info
- av_find_stream_info
- 命名空间还没有理解
- 电路交换 透彻理解
- 报文交换 透彻理解
- 分组交换 透彻理解
- 透彻理解IOC
- 透彻理解迪杰斯特拉算法
- 透彻理解指针
- 透彻理解迪杰斯特拉算法
- 透彻理解迪杰斯特拉算法
- 透彻理解KMP算法
- 透彻理解匿名函数
- KMP透彻理解
- av_find_stream_info || av_estimate_timings
- 透彻理解红黑树之四
- 突破,Objective-C开发速学手册
- LCD12864
- Linux下修改PATH的方法
- 杨辉三角
- copy_to_user、copy_from_user 分析
- av_find_stream_info还没有理解透彻?
- Pomelo杂记(一)
- 23种PHP开发工具集合
- java测试题---1
- 第十五周项目5--中英词典
- 程序员面试题精选100题(13)-第一个只出现一次的字符[算法]
- CCS实现的级联菜单
- 比较2个日期区间重合的天数
- 【二维数组】15周项目四(带名字)。多科成绩单