FFmpeg之AVPacket

/*该结构存储压缩数据。它通常由分路器导出
 *然后作为输入传递给解码器,或作为编码器和输出接收
 *然后传递给muxers。
 *
 *对于视频,它通常应包含一个压缩帧。对于音频它可能
 *包含几个压缩帧。
 *
 * AVPacket是FFmpeg中为数不多的结构之一,其大小是公众的一部分
 * ABI。因此,它可以在堆栈上分配,并且不能向其添加新字段
 *没有libavcodec和libavformat主要的颠簸。
 *
 *数据所有权的语义取决于buf或destruct(不建议使用)
 *字段。如果设置了任何一个,则分组数据是动态分配的
 *无限期有效,直到调用av_free_packet()(然后调用
 * av_buffer_unref()/解析回调以释放数据)。如果两者都没有,
 *数据包数据通常由某个静态缓冲区支持
 *仅在有限时间内有效(例如,在解复用时进行下一次读取呼叫)。
 *
 *副数据总是用av_malloc()分配并被释放
 * av_free_packet()。
*/
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;
    int   size;
    int   stream_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;


 

猜你喜欢

转载自blog.csdn.net/xiaomucgwlmx/article/details/82908961