24 #include "libavutil/avassert.h"
25 #include "libavutil/common.h"
27 #include "libavutil/mem.h"
32 #if FF_API_DESTRUCT_PACKET
58 #if FF_API_DESTRUCT_PACKET
94 #if FF_API_DESTRUCT_PACKET
96 pkt->
destruct = dummy_destruct_packet;
105 if (pkt->
size <= size)
117 if ((
unsigned)grow_by >
131 #if FF_API_DESTRUCT_PACKET
133 pkt->
destruct = dummy_destruct_packet;
138 pkt->
size += grow_by;
139 memset(pkt->
data + pkt->
size, 0, FF_INPUT_BUFFER_PADDING_SIZE);
156 #if FF_API_DESTRUCT_PACKET
158 pkt->
destruct = dummy_destruct_packet;
165 #define ALLOC_MALLOC(data, size) data = av_malloc(size)
166 #define ALLOC_BUF(data, size) \
168 av_buffer_realloc(&pkt->buf, size); \
169 data = pkt->buf ? pkt->buf->data : NULL; \
172 #define DUP_DATA(dst, src, size, padding, ALLOC) \
176 if ((unsigned)(size) > \
177 (unsigned)(size) + FF_INPUT_BUFFER_PADDING_SIZE) \
179 ALLOC(data, size + FF_INPUT_BUFFER_PADDING_SIZE); \
185 memcpy(data, src, size); \
187 memset((uint8_t *)data + size, 0, \
188 FF_INPUT_BUFFER_PADDING_SIZE); \
206 #if FF_API_DESTRUCT_PACKET
208 pkt->
destruct = dummy_destruct_packet;
285 #if FF_API_DESTRUCT_PACKET
303 if ((
unsigned)elems + 1 > INT_MAX /
sizeof(*pkt->
side_data))
338 #define FF_MERGE_MARKER 0x8c4d9d108e25e9feULL
357 #if FF_API_DESTRUCT_PACKET
359 pkt->
destruct = dummy_destruct_packet;
371 memset(p, 0, FF_INPUT_BUFFER_PADDING_SIZE);
383 unsigned int size, orig_pktsize = pkt->
size;
389 if (size>INT_MAX || p - pkt->
data < size)
410 pkt->
size -= size + 5;
468 memcpy(dst_data, src_data, size);
#define DUP_DATA(dst, src, size, padding, ALLOC)
void av_buffer_unref(AVBufferRef **buf)
Free a given reference and automatically free the buffer if there are no more references to it...
void av_free_packet(AVPacket *pkt)
Free a packet.
int64_t pos
byte position in stream, -1 if unknown
void av_shrink_packet(AVPacket *pkt, int size)
Reduce packet size, correctly zeroing padding.
#define ALLOC_MALLOC(data, size)
int av_copy_packet(AVPacket *dst, AVPacket *src)
Copy packet, including contents.
#define ALLOC_BUF(data, size)
int av_dup_packet(AVPacket *pkt)
AVBufferRef * buf
A reference to the reference-counted buffer where the packet data is stored.
void av_freep(void *ptr)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc() and set the pointer ...
attribute_deprecated void(* destruct)(struct AVPacket *)
int av_packet_from_data(AVPacket *pkt, uint8_t *data, int size)
Initialize a reference-counted packet from av_malloc()ed data.
AVBufferRef * av_buffer_create(uint8_t *data, int size, void(*free)(void *opaque, uint8_t *data), void *opaque, int flags)
Create an AVBuffer from an existing array.
void av_packet_move_ref(AVPacket *dst, AVPacket *src)
Move every field in src to dst and reset src.
struct AVPacket::@25 * side_data
Additional packet data that can be provided by the container.
int duration
Duration of this packet in AVStream->time_base units, 0 if unknown.
void av_buffer_default_free(void *opaque, uint8_t *data)
Default free callback, which calls av_free() on the buffer data.
int av_new_packet(AVPacket *pkt, int size)
Allocate the payload of a packet and initialize its fields with default values.
int av_copy_packet_side_data(AVPacket *dst, AVPacket *src)
Copy packet side data.
void av_free(void *ptr)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc(). ...
void av_packet_free_side_data(AVPacket *pkt)
Convenience function to free all the side data stored.
int64_t convergence_duration
Time difference in AVStream->time_base units from the pts of this packet to the point at which the ou...
static int copy_packet_data(AVPacket *pkt, AVPacket *src, int dup)
int av_packet_shrink_side_data(AVPacket *pkt, enum AVPacketSideDataType type, int size)
Shrink the already allocated side data buffer.
int av_buffer_realloc(AVBufferRef **buf, int size)
Reallocate a given buffer.
Libavcodec external API header.
uint8_t * av_packet_new_side_data(AVPacket *pkt, enum AVPacketSideDataType type, int size)
Allocate new information of a packet.
int flags
A combination of AV_PKT_FLAG values.
int av_packet_merge_side_data(AVPacket *pkt)
common internal API header
#define FF_INPUT_BUFFER_PADDING_SIZE
Required number of additionally allocated bytes at the end of the input bitstream for decoding...
int av_packet_copy_props(AVPacket *dst, const AVPacket *src)
Copy only "properties" fields from src to dst.
uint8_t * data
The data buffer.
void * av_realloc(void *ptr, size_t size) 1(2)
Allocate or reallocate a block of memory.
uint8_t * av_packet_get_side_data(AVPacket *pkt, enum AVPacketSideDataType type, int *size)
Get side information from packet.
static int packet_alloc(AVBufferRef **buf, int size)
void * av_malloc(size_t size) av_malloc_attrib 1(1)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
int av_packet_split_side_data(AVPacket *pkt)
attribute_deprecated void av_destruct_packet(AVPacket *pkt)
Default packet destructor.
#define FF_API_DESTRUCT_PACKET
AVBufferRef * av_buffer_alloc(int size)
Allocate an AVBuffer of the given size using av_malloc().
void av_packet_unref(AVPacket *pkt)
Wipe the packet.
A reference to a data buffer.
#define FF_DISABLE_DEPRECATION_WARNINGS
common internal api header.
int av_grow_packet(AVPacket *pkt, int grow_by)
Increase packet size, correctly zeroing padding.
void av_init_packet(AVPacket *pkt)
Initialize optional fields of a packet with default values.
static av_always_inline void bytestream_put_buffer(uint8_t **b, const uint8_t *src, unsigned int size)
int av_packet_ref(AVPacket *dst, AVPacket *src)
Setup a new reference to the data described by a given packet.
AVBufferRef * av_buffer_ref(AVBufferRef *buf)
Create a new reference to an AVBuffer.
#define FF_ENABLE_DEPRECATION_WARNINGS
int64_t dts
Decompression timestamp in AVStream->time_base units; the time at which the packet is decompressed...
enum AVPacketSideDataType type
#define av_assert0(cond)
assert() equivalent, that is always enabled.
This structure stores compressed data.
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
#define AV_NOPTS_VALUE
Undefined timestamp value.
void * av_mallocz(size_t size) av_malloc_attrib 1(1)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...