文档章节

FFmpeg结构体彻底分析——AVPacket

zhangyujsj
 zhangyujsj
发布于 2014/12/17 17:11
字数 693
阅读 86
收藏 0

/**
 * This structure stores compressed data. It is typically exported by demuxers
 * and then passed as input to decoders, or received as output from encoders and
 * then passed to muxers.
 *AVPacket就是一个存储压缩之后的数据的结构体。1 由demuxer产生传给decoder;或者2 从encoder接收传给muxer
 * For video, it should typically contain one compressed frame. For audio it may
 * contain several compressed frames.对于视频对应一帧,对于音频对应多帧
 *
 * AVPacket is one of the few structs in FFmpeg, whose size is a part of public
 * ABI. Thus it may be allocated on stack and no new fields can be added to it
 * without libavcodec and libavformat major bump.
 *
 * The semantics of data ownership depends on the buf or destruct (deprecated)
 * fields. If either is set, the packet data is dynamically allocated and is
 * valid indefinitely until av_free_packet() is called (which in turn calls  
 * av_buffer_unref()/the destruct callback to free the data). If neither is set,
 * the packet data is typically backed by some static buffer somewhere and is
 * only valid for a limited time (e.g. until the next read call when demuxing).
 *
 * The side data is always allocated with av_malloc() and is freed in
 * av_free_packet().
 */

packet的数据是动态分配并且直到av_free_packet()被调用之前还有效。

它的旁路数据总是由av_malloc()分配并且用av_free_pakcet()来释放。
typedef struct AVPacket {
    /**
     * A reference to the reference-counted buffer where the packet data is
     * stored.
     * May be NULL, then the packet data is not reference-counted.
     */
    AVBufferRef *buf;
    /**
     * Presentation timestamp in AVStream->time_base units; the time at which
     * the decompressed packet will be presented to the user.
     * Can be AV_NOPTS_VALUE if it is not stored in the file.
     * pts MUST be larger or equal to dts as presentation cannot happen before
     * decompression, unless one wants to view hex dumps. Some formats misuse
     * the terms dts and pts/cts to mean something different. Such timestamps
     * must be converted to true pts/dts before they are stored in AVPacket.
     */
    int64_t pts;//呈现给用户的时间戳
    /**
     * Decompression timestamp in AVStream->time_base units; the time at which
     * the packet is decompressed.
     * Can be AV_NOPTS_VALUE if it is not stored in the file.
     */
    int64_t dts;//解压缩的时间戳
    uint8_t *data;//数据,特别注意在解码的时候每次用av_read_frame()读完一帧到AVPacket之后要用av_free_packet()函数来释放掉数据一次,才去读下一帧
    int   size;//数据的大小
    int   stream_index;//标志流的index

    /**
     * A combination of AV_PKT_FLAG values
     */
    int   flags;
    /**
     * Additional packet data that can be provided by the container.
     * Packet can contain several types of side information.
     */
    AVPacketSideData *side_data;
    int side_data_elems;

    /**
     * Duration of this packet in AVStream->time_base units, 0 if unknown.
     * Equals next_pts - this_pts in presentation order.
     */
    int   duration;
#if FF_API_DESTRUCT_PACKET
    attribute_deprecated
    void  (*destruct)(struct AVPacket *);
    attribute_deprecated
    void  *priv;
#endif
    int64_t pos;                            ///< byte position in stream, -1 if unknown

    /**
     * Time difference in AVStream->time_base units from the pts of this
     * packet to the point at which the output from the decoder has converged
     * independent from the availability of previous frames. That is, the
     * frames are virtually identical no matter if decoding started from
     * the very first frame or from this keyframe.
     * Is AV_NOPTS_VALUE if unknown.
     * This field is not the display duration of the current packet.
     * This field has no meaning if the packet does not have AV_PKT_FLAG_KEY
     * set.
     *
     * The purpose of this field is to allow seeking in streams that have no
     * keyframes in the conventional sense. It corresponds to the
     * recovery point SEI in H.264 and match_time_delta in NUT. It is also
     * essential for some types of subtitle streams to ensure that all
     * subtitles are correctly displayed after seeking.
     */
    int64_t convergence_duration;
} AVPacket;

© 著作权归作者所有

zhangyujsj
粉丝 24
博文 358
码字总数 224241
作品 0
广州
私信 提问
FFmpeg命令行工具学习(五):FFmpeg 编解码 API 分析

在上一篇文章 FFmpeg命令行工具学习(四):FFmpeg API 介绍与通用 API 分析 中,我们简单的讲解了一下FFmpeg 的API基本概念,并分析了一下通用API,本文我们将分析 FFmpeg 在编解码时使用的A...

灰色飘零
2018/07/20
0
0
使用 liavformat 和 libavcodec 实现解码器

使用ffmpeg 的liavformat 解封装,使用libavcodec 解codec,实现一个简单的解码器。 解码的流程,从数据结构上看就是AVFormatContext ->AVCodecContext -> AVPacket -> AVFrame。 生成AVPac...

鼎铭
2018/07/09
0
0
最新FFmpeg音视频核心技术精讲与实战(完整版)

第1章 课程导学与准备工作 全民娱乐时代,需要音视频等多媒体产品层出不穷,但会处理音视频数据的工程师却极度匮乏,进入音视频开发领域正当时,这门课程就是为这样的你而生。来吧!加入我们...

L272339
01/06
0
0
2018FFmpeg音视频核心技术精讲与实战(已完结)目前最新

第1章 课程导学与准备工作 全民娱乐时代,需要音视频等多媒体产品层出不穷,但会处理音视频数据的工程师却极度匮乏,进入音视频开发领域正当时,这门课程就是为这样的你而生。来吧!加入我们...

聂友华
2018/12/18
0
0
FFmpeg音视频核心技术精讲与实战(最新分享)

第1章 课程导学与准备工作 全民娱乐时代,需要音视频等多媒体产品层出不穷,但会处理音视频数据的工程师却极度匮乏,进入音视频开发领域正当时,这门课程就是为这样的你而生。来吧!加入我们...

qq_38704763
2018/12/06
0
0

没有更多内容

加载失败,请刷新页面

加载更多

EasyExcel

<!-- alibaba EasyExcel escel导入导出 --> <dependency> <groupId>com.alibaba</groupId> <artifactId>easyexcel</artifactId> <version>1.0.0-RELEASE</version> </dependency>......

少年已不再年少
12分钟前
0
0
解决:warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]

代码 static int CheckOneReg(uint8_t busNo, char *title, int32_t addr, uint32_t *val, BOOL isPrintfNL, ErrMsg_t const *pMsg)res |= CheckOneReg(busNo,"fwVer:", HALREG_FW_VER, ......

SamXIAO
13分钟前
0
0
jenkins搭建全流程

安装环境   操作系统:linux   软件:jdk 8   软件:tomcat(apache-tomcat-7.0.90) 软件:jenkins 软件:maven 软件:git 1.1安装步骤 1.1.1安装jdk 由于Jenkins是基于Java开发的,安...

shzwork
19分钟前
0
0
Java的战争

本文来自微信公众号: 金捷幡(ID:jin-jiefan) ,作者:金捷幡,封面:拉里·埃里森(东方IC) 2019年5月,彻底撕破脸的特朗普掀起对华为的战争,谷歌被迫吊销了华为的Android授权。开源软...

Java领航员
今天
8
0
超详细的LM3414MRX/NOPB规格参数介绍就在这里

超详细的LM3414MRX/NOPB规格参数介绍就在这里 描述 LM3414和LM3414MRX/NOPB是具有1-A 60 W(1)共阳极功能的恒流降压LED驱动器。它们适用于驱动单串3-W HBLED,效率高达96%。它们可接受4.5...

不能吃肉的仙女
今天
3
0

没有更多内容

加载失败,请刷新页面

加载更多

返回顶部
顶部