FFmpeg 7.1.1
|
Types and functions for working with AVPacket. More...
Data Structures | |
struct | AVPacket |
This structure stores compressed data. More... | |
Macros | |
#define | AV_PKT_FLAG_KEY 0x0001 |
The packet contains a keyframe. | |
#define | AV_PKT_FLAG_CORRUPT 0x0002 |
The packet content is corrupted. | |
#define | AV_PKT_FLAG_DISCARD 0x0004 |
Flag is used to discard packets which are required to maintain valid decoder state but are not required for output and should be dropped after decoding. | |
#define | AV_PKT_FLAG_TRUSTED 0x0008 |
The packet comes from a trusted source. | |
#define | AV_PKT_FLAG_DISPOSABLE 0x0010 |
Flag is used to indicate packets that contain frames that can be discarded by the decoder. | |
Enumerations | |
enum | AVSideDataParamChangeFlags { AV_SIDE_DATA_PARAM_CHANGE_SAMPLE_RATE = 0x0004 , AV_SIDE_DATA_PARAM_CHANGE_DIMENSIONS = 0x0008 } |
Functions | |
AVPacket * | av_packet_alloc (void) |
Allocate an AVPacket and set its fields to default values. | |
AVPacket * | av_packet_clone (const AVPacket *src) |
Create a new packet that references the same data as src. | |
void | av_packet_free (AVPacket **pkt) |
Free the packet, if the packet is reference counted, it will be unreferenced first. | |
int | av_new_packet (AVPacket *pkt, int size) |
Allocate the payload of a packet and initialize its fields with default values. | |
void | av_shrink_packet (AVPacket *pkt, int size) |
Reduce packet size, correctly zeroing padding. | |
int | av_grow_packet (AVPacket *pkt, int grow_by) |
Increase packet size, correctly zeroing padding. | |
int | av_packet_from_data (AVPacket *pkt, uint8_t *data, int size) |
Initialize a reference-counted packet from av_malloc()ed data. | |
uint8_t * | av_packet_new_side_data (AVPacket *pkt, enum AVPacketSideDataType type, size_t size) |
Allocate new information of a packet. | |
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. | |
int | av_packet_shrink_side_data (AVPacket *pkt, enum AVPacketSideDataType type, size_t size) |
Shrink the already allocated side data buffer. | |
uint8_t * | av_packet_get_side_data (const AVPacket *pkt, enum AVPacketSideDataType type, size_t *size) |
Get side information from packet. | |
uint8_t * | av_packet_pack_dictionary (AVDictionary *dict, size_t *size) |
Pack a dictionary for use in side_data. | |
int | av_packet_unpack_dictionary (const uint8_t *data, size_t size, AVDictionary **dict) |
Unpack a dictionary from side_data. | |
void | av_packet_free_side_data (AVPacket *pkt) |
Convenience function to free all the side data stored. | |
int | av_packet_ref (AVPacket *dst, const AVPacket *src) |
Setup a new reference to the data described by a given packet. | |
void | av_packet_unref (AVPacket *pkt) |
Wipe the packet. | |
void | av_packet_move_ref (AVPacket *dst, AVPacket *src) |
Move every field in src to dst and reset src. | |
int | av_packet_copy_props (AVPacket *dst, const AVPacket *src) |
Copy only "properties" fields from src to dst. | |
int | av_packet_make_refcounted (AVPacket *pkt) |
Ensure the data described by a given packet is reference counted. | |
int | av_packet_make_writable (AVPacket *pkt) |
Create a writable reference for the data described by a given packet, avoiding data copy if possible. | |
void | av_packet_rescale_ts (AVPacket *pkt, AVRational tb_src, AVRational tb_dst) |
Convert valid timing fields (timestamps / durations) in a packet from one timebase to another. | |
Types and functions for working with AVPacket.
#define AV_PKT_FLAG_KEY 0x0001 |
#define AV_PKT_FLAG_CORRUPT 0x0002 |
#define AV_PKT_FLAG_DISCARD 0x0004 |
#define AV_PKT_FLAG_TRUSTED 0x0008 |
#define AV_PKT_FLAG_DISPOSABLE 0x0010 |
AVPacket * av_packet_alloc | ( | void | ) |
Allocate an AVPacket and set its fields to default values.
The resulting struct must be freed using av_packet_free().
Referenced by add_stream(), encode_write(), init_filters(), init_packet(), main(), and main().
Create a new packet that references the same data as src.
This is a shortcut for av_packet_alloc()+av_packet_ref().
void av_packet_free | ( | AVPacket ** | pkt | ) |
Free the packet, if the packet is reference counted, it will be unreferenced first.
pkt | packet to be freed. The pointer will be set to NULL. |
Referenced by close_stream(), decode_audio_frame(), encode_audio_frame(), encode_write(), main(), and main().
int av_new_packet | ( | AVPacket * | pkt, |
int | size | ||
) |
Allocate the payload of a packet and initialize its fields with default values.
pkt | packet |
size | wanted payload size |
void av_shrink_packet | ( | AVPacket * | pkt, |
int | size | ||
) |
Reduce packet size, correctly zeroing padding.
pkt | packet |
size | new size |
int av_grow_packet | ( | AVPacket * | pkt, |
int | grow_by | ||
) |
Increase packet size, correctly zeroing padding.
pkt | packet |
grow_by | number of bytes by which to increase the size of the packet |
int av_packet_from_data | ( | AVPacket * | pkt, |
uint8_t * | data, | ||
int | size | ||
) |
Initialize a reference-counted packet from av_malloc()ed data.
pkt | packet to be initialized. This function will set the data, size, and buf fields, all others are left untouched. |
data | Data allocated by av_malloc() to be used as packet data. If this function returns successfully, the data is owned by the underlying AVBuffer. The caller may not access the data through other means. |
size | size of data in bytes, without the padding. I.e. the full buffer size is assumed to be size + AV_INPUT_BUFFER_PADDING_SIZE. |
uint8_t * av_packet_new_side_data | ( | AVPacket * | pkt, |
enum AVPacketSideDataType | type, | ||
size_t | size | ||
) |
Allocate new information of a packet.
pkt | packet |
type | side information type |
size | side information size |
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.
pkt | packet |
type | side information type |
data | the side data array. It must be allocated with the av_malloc() family of functions. The ownership of the data is transferred to pkt. |
size | side information size |
int av_packet_shrink_side_data | ( | AVPacket * | pkt, |
enum AVPacketSideDataType | type, | ||
size_t | size | ||
) |
Shrink the already allocated side data buffer.
pkt | packet |
type | side information type |
size | new side information size |
uint8_t * av_packet_get_side_data | ( | const AVPacket * | pkt, |
enum AVPacketSideDataType | type, | ||
size_t * | size | ||
) |
Get side information from packet.
pkt | packet |
type | desired side information type |
size | If supplied, *size will be set to the size of the side data or to zero if the desired side data is not present. |
uint8_t * av_packet_pack_dictionary | ( | AVDictionary * | dict, |
size_t * | size | ||
) |
Pack a dictionary for use in side_data.
dict | The dictionary to pack. |
size | pointer to store the size of the returned data |
int av_packet_unpack_dictionary | ( | const uint8_t * | data, |
size_t | size, | ||
AVDictionary ** | dict | ||
) |
Unpack a dictionary from side_data.
data | data from side_data |
size | size of the data |
dict | the metadata storage dictionary |
void av_packet_free_side_data | ( | AVPacket * | pkt | ) |
Convenience function to free all the side data stored.
All the other fields stay untouched.
pkt | packet |
Setup a new reference to the data described by a given packet.
If src is reference-counted, setup dst as a new reference to the buffer in src. Otherwise allocate a new buffer in dst and copy the data from src into it.
All the other fields are copied from src.
dst | Destination packet. Will be completely overwritten. |
src | Source packet |
void av_packet_unref | ( | AVPacket * | pkt | ) |
Wipe the packet.
Unreference the buffer referenced by the packet and reset the remaining packet fields to their default values.
pkt | The packet to be unreferenced. |
Referenced by encode(), encode(), encode_write(), encode_write(), encode_write(), encode_write_frame(), main(), and main().
Move every field in src to dst and reset src.
src | Source packet, will be reset |
dst | Destination packet |
Copy only "properties" fields from src to dst.
Properties for the purpose of this function are all the fields beside those related to the packet data (buf, data, size)
dst | Destination packet |
src | Source packet |
int av_packet_make_refcounted | ( | AVPacket * | pkt | ) |
Ensure the data described by a given packet is reference counted.
pkt | packet whose data should be made reference counted. |
int av_packet_make_writable | ( | AVPacket * | pkt | ) |
Create a writable reference for the data described by a given packet, avoiding data copy if possible.
pkt | Packet whose data should be made writable. |
void av_packet_rescale_ts | ( | AVPacket * | pkt, |
AVRational | tb_src, | ||
AVRational | tb_dst | ||
) |
Convert valid timing fields (timestamps / durations) in a packet from one timebase to another.
Timestamps with unknown values (AV_NOPTS_VALUE) will be ignored.
pkt | packet on which the conversion will be performed |
tb_src | source timebase, in which the timing fields in pkt are expressed |
tb_dst | destination timebase, to which the timing fields will be converted |
Referenced by encode_write(), encode_write(), encode_write_frame(), main(), and write_frame().