FFmpeg解码流程核心结构体
| 层级 | 结构体 | 所属头文件 | 功能描述 | 关联关系 |
|---|---|---|---|---|
| 协议层 | URLProtocol | libavformat/url.h | 描述协议类型(如HTTP/RTMP),每个协议对应一个实例(如ff_librtmp_protocol) | 被URLContext调用,通过AVIOContext与解封装层交互 |
URLContext | libavformat/url.h | 存储协议操作的上下文(如网络连接状态、超时设置) | 关联具体的URLProtocol | |
AVIOContext | libavformat/avio.h | 提供读写接口(如avio_read),封装协议层数据流 | 作为AVFormatContext的成员(pb字段) | |
| 解封装层 | AVInputFormat、AVInputFormat | libavformat/avformat.h | 描述输入、输出容器格式(如MP4对应ff_mp4_demuxer) | 被AVFormatContext引用(iformat字段) |
AVFormatContext | libavformat/avformat.h | 全局管家,存储封装格式、流信息、协议上下文等 | 包含AVStream数组、AVIOContext、AVInputFormat等 | |
AVStream | libavformat/avformat.h | 存储单路流的元信息(如时间基、帧率) | 关联AVCodecContext(通过codecpar字段) | |
| 解码层 | AVCodecContext | libavcodec/avcodec.h | 配置编解码参数(如视频分辨率、音频采样率) | 关联AVCodec(解码器实现)和AVStream(流信息) |
AVCodec | libavcodec/avcodec.h | 描述编解码器(如H.264解码器avcodec_find_decoder(AV_CODEC_ID_H264)) | 作为AVCodecContext的成员(codec字段) | |
| 数据存储 | AVPacket | libavcodec/packet.h | 存储压缩数据包(视频通常1帧/包,音频可能多帧/包) | 由解封装层生成(av_read_frame),输入解码器(avcodec_send_packet) |
AVFrame | libavutil/frame.h | 存储原始数据帧(视频为YUV/RGB,音频为PCM) | 由解码器输出(avcodec_receive_frame),供渲染或后处理使用 |

被折叠的 条评论
为什么被折叠?



