博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
FFmpeg结构体彻底分析——AVPacket
阅读量:7048 次
发布时间:2019-06-28

本文共 3765 字,大约阅读时间需要 12 分钟。

hot3.png

/**

 * 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;

转载于:https://my.oschina.net/u/1024767/blog/357285

你可能感兴趣的文章
MySQL单机多实例安装并配置主从复制
查看>>
awk调用shell命令的两种方法:system与print
查看>>
网络对抗技术 20164320 王浩 Exp 9 Web安全基础
查看>>
谷歌开源第二代机器学习系统 TensorFlow
查看>>
juqery模板 Templates
查看>>
eclipse 自动创建web.xml
查看>>
python 基础回顾2
查看>>
Servlet 示例
查看>>
十一.单表更新及多表更新
查看>>
poj 2773 Happy 2006
查看>>
设计模式(三)——结构型模式
查看>>
黑客与画家
查看>>
ThreadPoolExecutor详解
查看>>
Jenkins权限配置失误后导致登录失败的解决办法
查看>>
eclipse设置酷炫的代码颜色风格
查看>>
stm32 低功耗模式 学习总结
查看>>
太空飞行计划问题
查看>>
TAT
查看>>
863D - Yet Another Array Queries Problem(思维)
查看>>
(基本不使用这种)springMVC注解
查看>>