FFmpeg
Functions
avpacket.c File Reference
#include <string.h>
#include "libavutil/avassert.h"
#include "libavutil/common.h"
#include "libavutil/internal.h"
#include "libavutil/mathematics.h"
#include "libavutil/mem.h"
#include "bytestream.h"
#include "internal.h"
#include "packet.h"
#include "packet_internal.h"

Go to the source code of this file.

Functions

void av_init_packet (AVPacket *pkt)
 
static void get_packet_defaults (AVPacket *pkt)
 
AVPacketav_packet_alloc (void)
 Allocate an AVPacket and set its fields to default values. More...
 
void av_packet_free (AVPacket **pkt)
 Free the packet, if the packet is reference counted, it will be unreferenced first. More...
 
static int packet_alloc (AVBufferRef **buf, int size)
 
int av_new_packet (AVPacket *pkt, int size)
 Allocate the payload of a packet and initialize its fields with default values. More...
 
void av_shrink_packet (AVPacket *pkt, int size)
 Reduce packet size, correctly zeroing padding. More...
 
int av_grow_packet (AVPacket *pkt, int grow_by)
 Increase packet size, correctly zeroing padding. More...
 
int av_packet_from_data (AVPacket *pkt, uint8_t *data, int size)
 Initialize a reference-counted packet from av_malloc()ed data. More...
 
void av_packet_free_side_data (AVPacket *pkt)
 Convenience function to free all the side data stored. More...
 
int av_packet_add_side_data (AVPacket *pkt, enum AVPacketSideDataType type, uint8_t *data, size_t size)
 Wrap an existing array as a packet side data. More...
 
uint8_t * av_packet_new_side_data (AVPacket *pkt, enum AVPacketSideDataType type, size_t size)
 Allocate new information of a packet. More...
 
uint8_t * av_packet_get_side_data (const AVPacket *pkt, enum AVPacketSideDataType type, size_t *size)
 Get side information from packet. More...
 
const char * av_packet_side_data_name (enum AVPacketSideDataType type)
 
uint8_t * av_packet_pack_dictionary (AVDictionary *dict, size_t *size)
 Pack a dictionary for use in side_data. More...
 
int av_packet_unpack_dictionary (const uint8_t *data, size_t size, AVDictionary **dict)
 Unpack a dictionary from side_data. More...
 
int av_packet_shrink_side_data (AVPacket *pkt, enum AVPacketSideDataType type, size_t size)
 Shrink the already allocated side data buffer. More...
 
int av_packet_copy_props (AVPacket *dst, const AVPacket *src)
 Copy only "properties" fields from src to dst. More...
 
void av_packet_unref (AVPacket *pkt)
 Wipe the packet. More...
 
int av_packet_ref (AVPacket *dst, const AVPacket *src)
 Setup a new reference to the data described by a given packet. More...
 
AVPacketav_packet_clone (const AVPacket *src)
 Create a new packet that references the same data as src. More...
 
void av_packet_move_ref (AVPacket *dst, AVPacket *src)
 Move every field in src to dst and reset src. More...
 
int av_packet_make_refcounted (AVPacket *pkt)
 Ensure the data described by a given packet is reference counted. More...
 
int av_packet_make_writable (AVPacket *pkt)
 Create a writable reference for the data described by a given packet, avoiding data copy if possible. More...
 
void av_packet_rescale_ts (AVPacket *pkt, AVRational src_tb, AVRational dst_tb)
 Convert valid timing fields (timestamps / durations) in a packet from one timebase to another. More...
 
int avpriv_packet_list_put (PacketList **packet_buffer, PacketList **plast_pktl, AVPacket *pkt, int(*copy)(AVPacket *dst, const AVPacket *src), int flags)
 Append an AVPacket to the list. More...
 
int avpriv_packet_list_get (PacketList **pkt_buffer, PacketList **pkt_buffer_end, AVPacket *pkt)
 Remove the oldest AVPacket in the list and return it. More...
 
void avpriv_packet_list_free (PacketList **pkt_buf, PacketList **pkt_buf_end)
 Wipe the list and unref all the packets in it. More...
 
int ff_side_data_set_encoder_stats (AVPacket *pkt, int quality, int64_t *error, int error_count, int pict_type)
 
int ff_side_data_set_prft (AVPacket *pkt, int64_t timestamp)
 

Function Documentation

◆ av_init_packet()

void av_init_packet ( AVPacket pkt)

Definition at line 36 of file avpacket.c.

Referenced by av_get_packet(), ff_read_packet(), and ffmmal_decode().

◆ get_packet_defaults()

static void get_packet_defaults ( AVPacket pkt)
static

Definition at line 50 of file avpacket.c.

Referenced by av_new_packet(), av_packet_alloc(), av_packet_move_ref(), and av_packet_unref().

◆ packet_alloc()

static int packet_alloc ( AVBufferRef **  buf,
int  size 
)
static

◆ avpriv_packet_list_put()

int avpriv_packet_list_put ( PacketList **  head,
PacketList **  tail,
AVPacket pkt,
int(*)(AVPacket *dst, const AVPacket *src copy,
int  flags 
)

Append an AVPacket to the list.

Parameters
headList head element
tailList tail element
pktThe packet being appended. The data described in it will be made reference counted if it isn't already.
copyA callback to copy the contents of the packet to the list. May be null, in which case the packet's reference will be moved to the list.
Returns
0 on success, negative AVERROR value on failure. On failure, the packet and the list are unchanged.

Definition at line 516 of file avpacket.c.

Referenced by aiff_write_packet(), av_read_frame(), avformat_find_stream_info(), avformat_queue_attached_pictures(), ff_read_packet(), flac_write_packet(), mp3_write_packet(), parse_packet(), and tta_write_packet().

◆ avpriv_packet_list_get()

int avpriv_packet_list_get ( PacketList **  head,
PacketList **  tail,
AVPacket pkt 
)

Remove the oldest AVPacket in the list and return it.

Note
The pkt will be overwritten completely on success. The caller owns the packet and must unref it by itself.
Parameters
headList head element
tailList tail element
pktPointer to an AVPacket struct
Returns
0 on success, and a packet is returned. AVERROR(EAGAIN) if the list was empty.

Definition at line 553 of file avpacket.c.

Referenced by av_read_frame(), ff_read_packet(), flac_queue_flush(), mp3_queue_flush(), read_frame_internal(), and tta_queue_flush().

◆ avpriv_packet_list_free()

void avpriv_packet_list_free ( PacketList **  head,
PacketList **  tail 
)

Wipe the list and unref all the packets in it.

Parameters
headList head element
tailList tail element

Definition at line 569 of file avpacket.c.

Referenced by aiff_deinit(), flac_deinit(), flush_packet_queue(), matroska_parse_laces(), mp3_deinit(), and tta_deinit().

◆ ff_side_data_set_encoder_stats()

int ff_side_data_set_encoder_stats ( AVPacket pkt,
int  quality,
int64_t *  error,
int  error_count,
int  pict_type 
)

◆ ff_side_data_set_prft()

int ff_side_data_set_prft ( AVPacket pkt,
int64_t  timestamp 
)

Definition at line 608 of file avpacket.c.

Referenced by X264_frame().