ffmpeg 源代码简单分析 : avcodec_decode_video2()
来源:互联网 发布:网络发票怎么查询 编辑:程序博客网 时间:2024/05/17 07:42
此前写了好几篇ffmpeg源代码分析文章,列表如下:
图解FFMPEG打开媒体的函数avformat_open_inputffmpeg 源代码简单分析 : av_register_all()
ffmpeg 源代码简单分析 : avcodec_register_all()
ffmpeg 源代码简单分析 : av_read_frame()
ffmpeg 源代码简单分析 : avcodec_decode_video2()
============================
ffmpeg中的avcodec_decode_video2()的作用是解码一帧视频数据。输入一个压缩编码的结构体AVPacket,输出一个解码后的结构体AVFrame。
查看源代码之后发现,这个函数竟然十分的简单,源代码如下:
- int avcodec_decode_video2(AVCodecContext *avctx, AVFrame *picture,
- int *got_picture_ptr,
- const AVPacket *avpkt)
- {
- int ret;
- // copy to ensure we do not change avpkt
- AVPacket tmp = *avpkt;
- *got_picture_ptr= 0;
- if((avctx->coded_width||avctx->coded_height) && av_image_check_size(avctx->coded_width, avctx->coded_height, 0, avctx))
- return -1;
- if((avctx->codec->capabilities & CODEC_CAP_DELAY) || avpkt->size || (avctx->active_thread_type&FF_THREAD_FRAME)){
- int did_split = av_packet_split_side_data(&tmp);
- apply_param_change(avctx, &tmp);
- avctx->pkt = &tmp;
- if (HAVE_THREADS && avctx->active_thread_type&FF_THREAD_FRAME)
- ret = ff_thread_decode_frame(avctx, picture, got_picture_ptr,
- &tmp);
- else {
- ret = avctx->codec->decode(avctx, picture, got_picture_ptr,
- &tmp);
- picture->pkt_dts= avpkt->dts;
- if(!avctx->has_b_frames){
- picture->pkt_pos= avpkt->pos;
- }
- //FIXME these should be under if(!avctx->has_b_frames)
- if (!picture->sample_aspect_ratio.num)
- picture->sample_aspect_ratio = avctx->sample_aspect_ratio;
- if (!picture->width)
- picture->width = avctx->width;
- if (!picture->height)
- picture->height = avctx->height;
- if (picture->format == PIX_FMT_NONE)
- picture->format = avctx->pix_fmt;
- }
- emms_c(); //needed to avoid an emms_c() call before every return;
- avctx->pkt = NULL;
- if (did_split)
- ff_packet_free_side_data(&tmp);
- if (*got_picture_ptr){
- avctx->frame_number++;
- picture->best_effort_timestamp = guess_correct_pts(avctx,
- picture->pkt_pts,
- picture->pkt_dts);
- }
- }else
- ret= 0;
- return ret;
- }
从代码中可以看出,通过ret = avctx->codec->decode(avctx, picture, got_picture_ptr,&tmp)这句代码,调用了相应解码器的decode()函数,完成了解码操作。
0 0
- ffmpeg 源代码简单分析 : avcodec_decode_video2()
- ffmpeg源代码简单分析 :avcodec_decode_video2()
- ffmpeg 源代码简单分析 : avcodec_decode_video2()
- ffmpeg 源代码简单分析 : avcodec_decode_video2()
- ffmpeg 源代码简单分析 : avcodec_decode_video2()
- ffmpeg 源代码简单分析 : avcodec_decode_video2( )
- ffmpeg 函数简单分析 : avcodec_decode_video2()
- FFMPeg代码分析:avcodec_decode_video2函数
- FFMPeg代码分析:avcodec_decode_video2函数
- ffmpeg 源代码简单分析 : av_register_all()
- ffmpeg 源代码简单分析 : avcodec_register_all()
- ffmpeg 源代码简单分析 : av_read_frame()
- ffmpeg 源代码简单分析 : av_register_all()
- ffmpeg 源代码简单分析 : avcodec_register_all()
- ffmpeg 源代码简单分析 :av_read_frame()
- ffmpeg 源代码简单分析 : av_register_all()
- ffmpeg 源代码简单分析 : avcodec_register_all()
- ffmpeg 源代码简单分析 : av_read_frame()
- Linux下错误的捕获:errno和strerror的使用
- Myeclipse8.5的SVN插件的安装及查看是否成功和使用
- jvm对象的创建过程
- 分享劳动成果PostgreSQL 9.2.8 chm
- 地图入门_坐标系统
- ffmpeg 源代码简单分析 : avcodec_decode_video2()
- c++编程IOCP中的socket错误和资源释放处理方法
- 绕过WAF、安全狗知识整理
- 我的幼稚病
- 简述JQuery,Extjs,YUI,Prototype,Dojo 等JS框架的区别和应用场景
- Hadoop 2.3.0编译
- 总结C#获取当前路径的7种方法
- 了解iPhone应用程序中App目录结构
- 读取目标文件的指令集,架构