FFmpeg
Data Structures | Macros | Enumerations | Functions

Types and functions for working with AVPacket. More...

Data Structures

struct  AVPacketSideData
 
struct  AVPacket
 This structure stores compressed data. More...
 

Macros

#define AV_PKT_DATA_QUALITY_FACTOR   AV_PKT_DATA_QUALITY_STATS
 
#define AV_PKT_FLAG_KEY   0x0001
 The packet contains a keyframe. More...
 
#define AV_PKT_FLAG_CORRUPT   0x0002
 The packet content is corrupted. More...
 
#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. More...
 
#define AV_PKT_FLAG_TRUSTED   0x0008
 The packet comes from a trusted source. More...
 
#define AV_PKT_FLAG_DISPOSABLE   0x0010
 Flag is used to indicate packets that contain frames that can be discarded by the decoder. More...
 

Enumerations

enum  AVPacketSideDataType {
  AV_PKT_DATA_PALETTE, AV_PKT_DATA_NEW_EXTRADATA, AV_PKT_DATA_PARAM_CHANGE, AV_PKT_DATA_H263_MB_INFO,
  AV_PKT_DATA_REPLAYGAIN, AV_PKT_DATA_DISPLAYMATRIX, AV_PKT_DATA_STEREO3D, AV_PKT_DATA_AUDIO_SERVICE_TYPE,
  AV_PKT_DATA_QUALITY_STATS, AV_PKT_DATA_FALLBACK_TRACK, AV_PKT_DATA_CPB_PROPERTIES, AV_PKT_DATA_SKIP_SAMPLES,
  AV_PKT_DATA_JP_DUALMONO, AV_PKT_DATA_STRINGS_METADATA, AV_PKT_DATA_SUBTITLE_POSITION, AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL,
  AV_PKT_DATA_WEBVTT_IDENTIFIER, AV_PKT_DATA_WEBVTT_SETTINGS, AV_PKT_DATA_METADATA_UPDATE, AV_PKT_DATA_MPEGTS_STREAM_ID,
  AV_PKT_DATA_MASTERING_DISPLAY_METADATA, AV_PKT_DATA_SPHERICAL, AV_PKT_DATA_CONTENT_LIGHT_LEVEL, AV_PKT_DATA_A53_CC,
  AV_PKT_DATA_ENCRYPTION_INIT_INFO, AV_PKT_DATA_ENCRYPTION_INFO, AV_PKT_DATA_AFD, AV_PKT_DATA_NB
}
 
enum  AVSideDataParamChangeFlags { AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_COUNT = 0x0001, AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_LAYOUT = 0x0002, AV_SIDE_DATA_PARAM_CHANGE_SAMPLE_RATE = 0x0004, AV_SIDE_DATA_PARAM_CHANGE_DIMENSIONS = 0x0008 }
 

Functions

AVPacketav_packet_alloc (void)
 Allocate an AVPacket and set its fields to default values. More...
 
AVPacketav_packet_clone (const AVPacket *src)
 Create a new packet that references the same data as src. More...
 
void av_packet_free (AVPacket **pkt)
 Free the packet, if the packet is reference counted, it will be unreferenced first. More...
 
void av_init_packet (AVPacket *pkt)
 Initialize optional fields of a packet with default values. More...
 
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...
 
attribute_deprecated int av_dup_packet (AVPacket *pkt)
 
attribute_deprecated int av_copy_packet (AVPacket *dst, const AVPacket *src)
 Copy packet, including contents. More...
 
attribute_deprecated int av_copy_packet_side_data (AVPacket *dst, const AVPacket *src)
 Copy packet side data. More...
 
attribute_deprecated void av_free_packet (AVPacket *pkt)
 Free a packet. More...
 
uint8_tav_packet_new_side_data (AVPacket *pkt, enum AVPacketSideDataType type, int size)
 Allocate new information of a packet. 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...
 
int av_packet_shrink_side_data (AVPacket *pkt, enum AVPacketSideDataType type, int size)
 Shrink the already allocated side data buffer. More...
 
uint8_tav_packet_get_side_data (const AVPacket *pkt, enum AVPacketSideDataType type, int *size)
 Get side information from packet. More...
 
attribute_deprecated int av_packet_merge_side_data (AVPacket *pkt)
 
attribute_deprecated int av_packet_split_side_data (AVPacket *pkt)
 
const char * av_packet_side_data_name (enum AVPacketSideDataType type)
 
uint8_tav_packet_pack_dictionary (AVDictionary *dict, int *size)
 Pack a dictionary for use in side_data. More...
 
int av_packet_unpack_dictionary (const uint8_t *data, int size, AVDictionary **dict)
 Unpack a dictionary from side_data. More...
 
void av_packet_free_side_data (AVPacket *pkt)
 Convenience function to free all the side data stored. More...
 
int av_packet_ref (AVPacket *dst, const AVPacket *src)
 Setup a new reference to the data described by a given packet. More...
 
void av_packet_unref (AVPacket *pkt)
 Wipe the packet. More...
 
void av_packet_move_ref (AVPacket *dst, AVPacket *src)
 Move every field in src to dst and reset src. More...
 
int av_packet_copy_props (AVPacket *dst, const AVPacket *src)
 Copy only "properties" fields from src to dst. 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 tb_src, AVRational tb_dst)
 Convert valid timing fields (timestamps / durations) in a packet from one timebase to another. More...
 

Detailed Description

Types and functions for working with AVPacket.

Macro Definition Documentation

◆ AV_PKT_DATA_QUALITY_FACTOR

#define AV_PKT_DATA_QUALITY_FACTOR   AV_PKT_DATA_QUALITY_STATS

Definition at line 1418 of file avcodec.h.

◆ AV_PKT_FLAG_KEY

#define AV_PKT_FLAG_KEY   0x0001

The packet contains a keyframe.

Definition at line 1509 of file avcodec.h.

◆ AV_PKT_FLAG_CORRUPT

#define AV_PKT_FLAG_CORRUPT   0x0002

The packet content is corrupted.

Definition at line 1510 of file avcodec.h.

◆ AV_PKT_FLAG_DISCARD

#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.

Definition at line 1516 of file avcodec.h.

◆ AV_PKT_FLAG_TRUSTED

#define AV_PKT_FLAG_TRUSTED   0x0008

The packet comes from a trusted source.

Otherwise-unsafe constructs such as arbitrary pointers to data outside the packet may be followed.

Definition at line 1523 of file avcodec.h.

◆ AV_PKT_FLAG_DISPOSABLE

#define AV_PKT_FLAG_DISPOSABLE   0x0010

Flag is used to indicate packets that contain frames that can be discarded by the decoder.

I.e. Non-reference frames.

Definition at line 1528 of file avcodec.h.

Enumeration Type Documentation

◆ AVPacketSideDataType

Enumerator
AV_PKT_DATA_PALETTE 

An AV_PKT_DATA_PALETTE side data packet contains exactly AVPALETTE_SIZE bytes worth of palette.

This side data signals that a new palette is present.

AV_PKT_DATA_NEW_EXTRADATA 

The AV_PKT_DATA_NEW_EXTRADATA is used to notify the codec or the format that the extradata buffer was changed and the receiving side should act upon it appropriately.

The new extradata is embedded in the side data buffer and should be immediately used for processing the current frame or packet.

AV_PKT_DATA_PARAM_CHANGE 

An AV_PKT_DATA_PARAM_CHANGE side data packet is laid out as follows:

u32le param_flags
if (param_flags & AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_COUNT)
s32le channel_count
if (param_flags & AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_LAYOUT)
u64le channel_layout
if (param_flags & AV_SIDE_DATA_PARAM_CHANGE_SAMPLE_RATE)
s32le sample_rate
if (param_flags & AV_SIDE_DATA_PARAM_CHANGE_DIMENSIONS)
s32le width
s32le height
AV_PKT_DATA_H263_MB_INFO 

An AV_PKT_DATA_H263_MB_INFO side data packet contains a number of structures with info about macroblocks relevant to splitting the packet into smaller packets on macroblock edges (e.g.

as for RFC 2190). That is, it does not necessarily contain info about all macroblocks, as long as the distance between macroblocks in the info is smaller than the target payload size. Each MB info structure is 12 bytes, and is laid out as follows:

u32le bit offset from the start of the packet
u8 current quantizer at the start of the macroblock
u8 GOB number
u16le macroblock address within the GOB
u8 horizontal MV predictor
u8 vertical MV predictor
u8 horizontal MV predictor for block number 3
u8 vertical MV predictor for block number 3
AV_PKT_DATA_REPLAYGAIN 

This side data should be associated with an audio stream and contains ReplayGain information in form of the AVReplayGain struct.

AV_PKT_DATA_DISPLAYMATRIX 

This side data contains a 3x3 transformation matrix describing an affine transformation that needs to be applied to the decoded video frames for correct presentation.

See libavutil/display.h for a detailed description of the data.

AV_PKT_DATA_STEREO3D 

This side data should be associated with a video stream and contains Stereoscopic 3D information in form of the AVStereo3D struct.

AV_PKT_DATA_AUDIO_SERVICE_TYPE 

This side data should be associated with an audio stream and corresponds to enum AVAudioServiceType.

AV_PKT_DATA_QUALITY_STATS 

This side data contains quality related information from the encoder.

u32le quality factor of the compressed frame. Allowed range is between 1 (good) and FF_LAMBDA_MAX (bad).
u8 picture type
u8 error count
u16 reserved
u64le[error count] sum of squared differences between encoder in and output
AV_PKT_DATA_FALLBACK_TRACK 

This side data contains an integer value representing the stream index of a "fallback" track.

A fallback track indicates an alternate track to use when the current track can not be decoded for some reason. e.g. no decoder available for codec.

AV_PKT_DATA_CPB_PROPERTIES 

This side data corresponds to the AVCPBProperties struct.

AV_PKT_DATA_SKIP_SAMPLES 

Recommmends skipping the specified number of samples.

u32le number of samples to skip from start of this packet
u32le number of samples to skip from end of this packet
u8 reason for start skip
u8 reason for end skip (0=padding silence, 1=convergence)
AV_PKT_DATA_JP_DUALMONO 

An AV_PKT_DATA_JP_DUALMONO side data packet indicates that the packet may contain "dual mono" audio specific to Japanese DTV and if it is true, recommends only the selected channel to be used.

u8 selected channels (0=mail/left, 1=sub/right, 2=both)
AV_PKT_DATA_STRINGS_METADATA 

A list of zero terminated key/value strings.

There is no end marker for the list, so it is required to rely on the side data size to stop.

AV_PKT_DATA_SUBTITLE_POSITION 

Subtitle event position.

u32le x1
u32le y1
u32le x2
u32le y2
AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL 

Data found in BlockAdditional element of matroska container.

There is no end marker for the data, so it is required to rely on the side data size to recognize the end. 8 byte id (as found in BlockAddId) followed by data.

AV_PKT_DATA_WEBVTT_IDENTIFIER 

The optional first identifier line of a WebVTT cue.

AV_PKT_DATA_WEBVTT_SETTINGS 

The optional settings (rendering instructions) that immediately follow the timestamp specifier of a WebVTT cue.

AV_PKT_DATA_METADATA_UPDATE 

A list of zero terminated key/value strings.

There is no end marker for the list, so it is required to rely on the side data size to stop. This side data includes updated metadata which appeared in the stream.

AV_PKT_DATA_MPEGTS_STREAM_ID 

MPEGTS stream ID as uint8_t, this is required to pass the stream ID information from the demuxer to the corresponding muxer.

AV_PKT_DATA_MASTERING_DISPLAY_METADATA 

Mastering display metadata (based on SMPTE-2086:2014).

This metadata should be associated with a video stream and contains data in the form of the AVMasteringDisplayMetadata struct.

AV_PKT_DATA_SPHERICAL 

This side data should be associated with a video stream and corresponds to the AVSphericalMapping structure.

AV_PKT_DATA_CONTENT_LIGHT_LEVEL 

Content light level (based on CTA-861.3).

This metadata should be associated with a video stream and contains data in the form of the AVContentLightMetadata struct.

AV_PKT_DATA_A53_CC 

ATSC A53 Part 4 Closed Captions.

This metadata should be associated with a video stream. A53 CC bitstream is stored as uint8_t in AVPacketSideData.data. The number of bytes of CC data is AVPacketSideData.size.

AV_PKT_DATA_ENCRYPTION_INIT_INFO 

This side data is encryption initialization data.

The format is not part of ABI, use av_encryption_init_info_* methods to access.

AV_PKT_DATA_ENCRYPTION_INFO 

This side data contains encryption info for how to decrypt the packet.

The format is not part of ABI, use av_encryption_info_* methods to access.

AV_PKT_DATA_AFD 

Active Format Description data consisting of a single byte as specified in ETSI TS 101 154 using AVActiveFormatDescription enum.

AV_PKT_DATA_NB 

The number of side data types.

This is not part of the public API/ABI in the sense that it may change when new side data types are added. This must stay the last enum value. If its value becomes huge, some code using it needs to be updated as it assumes it to be smaller than other limits.

Definition at line 1184 of file avcodec.h.

◆ AVSideDataParamChangeFlags

Enumerator
AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_COUNT 
AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_LAYOUT 
AV_SIDE_DATA_PARAM_CHANGE_SAMPLE_RATE 
AV_SIDE_DATA_PARAM_CHANGE_DIMENSIONS 

Definition at line 1531 of file avcodec.h.

Function Documentation

◆ av_packet_alloc()

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().

Returns
An AVPacket filled with default values or NULL on failure.
Note
this only allocates the AVPacket itself, not the data buffers. Those must be allocated through other means such as av_new_packet.
See also
av_new_packet
Examples
decode_audio.c, decode_video.c, encode_audio.c, and encode_video.c.

Definition at line 51 of file avpacket.c.

Referenced by apng_write_packet(), av1_frame_split_init(), av_bsf_alloc(), av_packet_clone(), avcodec_open2(), decode_init(), extract_extradata_init(), ff_bsf_get_packet(), ff_reshuffle_raw_rgb(), gif_write_packet(), main(), mpeg4_unpack_bframes_init(), vp9_superframe_init(), vp9_superframe_split_init(), and worker().

◆ av_packet_clone()

AVPacket* av_packet_clone ( const AVPacket src)

Create a new packet that references the same data as src.

This is a shortcut for av_packet_alloc()+av_packet_ref().

Returns
newly created AVPacket on success, NULL on error.
See also
av_packet_alloc
av_packet_ref

Definition at line 642 of file avpacket.c.

Referenced by decklink_write_video_packet(), flac_write_packet(), and main().

◆ av_packet_free()

void av_packet_free ( AVPacket **  pkt)

◆ av_init_packet()

void av_init_packet ( AVPacket pkt)

Initialize optional fields of a packet with default values.

Note, this does not touch the data and size members, which have to be initialized separately.

Parameters
pktpacket
Examples
demuxing_decoding.c, muxing.c, transcode_aac.c, transcoding.c, vaapi_encode.c, and vaapi_transcode.c.

Definition at line 33 of file avpacket.c.

Referenced by asf_read_stream_properties(), asf_read_timestamp(), av_get_packet(), av_interleaved_write_frame(), av_new_packet(), av_packet_move_ref(), av_packet_unref(), av_write_uncoded_frame_internal(), avformat_find_stream_info(), avpriv_dv_produce_packet(), compute_crc_of_packets(), do_audio_out(), do_streamcopy(), do_subtitle_out(), do_video_out(), dv_extract_audio_info(), encode_frame(), encode_write(), encode_write_frame(), FDBPrepare(), ff_alloc_packet2(), ff_flac_parse_picture(), ff_id3v2_parse_apic(), ff_interleave_packet_per_dts(), ff_load_image(), ff_mov_add_hinted_packet(), ff_read_packet(), ff_rtp_finalize_packet(), ffmmal_decode(), fifo_basic_test(), fifo_overflow_drop_test(), fifo_write_packet(), filter(), filter_frame(), find_video_stream_info(), flac_read_timestamp(), flush_encoders(), hnm_read_header(), init_packet(), initializations(), lavfi_read_packet(), LLVMFuzzerTestOneInput(), main(), mkv_write_header(), mov_write_subtitle_end_packet(), movie_push_frame(), mpegts_get_dts(), mpegts_write_packet_internal(), mpjpeg_read_packet(), mux_frames(), mxf_interleave_get_packet(), new_data_packet(), new_pes_packet(), packet_queue_put_nullpacket(), parse_packet(), process_input_packet(), qt_rtp_parse_packet(), read_frame_internal(), read_interval_packets(), reset_packet(), reset_packet_state(), rtp_mpegts_write_packet(), run_test(), signal_init_ts(), sp5x_decode_frame(), tdsc_decode_jpeg_tile(), video_decode(), video_decode_example(), decklink_input_callback::VideoInputFrameArrived(), vp8_lossy_decode_frame(), wc3_read_header(), worker(), write_audio_frame(), write_skip_frames(), write_video_frame(), and xvid_encode_init().

◆ av_new_packet()

int av_new_packet ( AVPacket pkt,
int  size 
)

Allocate the payload of a packet and initialize its fields with default values.

Parameters
pktpacket
sizewanted payload size
Returns
0 if OK, AVERROR_xxx otherwise

Definition at line 86 of file avpacket.c.

Referenced by aa_read_packet(), aac_parse_packet(), ac3_handle_packet(), amf_copy_buffer(), amr_handle_packet(), amr_read_packet(), ape_read_packet(), asf_deinterleave(), asf_parse_packet(), asf_read_replicated_data(), asf_read_single_payload(), audio_read_packet(), avf_read_packet(), avisynth_read_packet_audio(), avisynth_read_packet_video(), avs_read_video_packet(), bmv_read_packet(), callback(), cdxl_read_packet(), cin_read_packet(), create_subcc_packet(), decode_frame(), demux_audio(), demux_video(), dsf_read_packet(), dss_723_1_read_packet(), dss_sp_read_packet(), dump_extradata(), dxa_read_packet(), encode_frame(), fbdev_read_packet(), ff_alloc_packet2(), ff_h263_handle_packet(), ff_h264_handle_aggregated_packet(), ff_h264_handle_frag_packet(), ff_img_read_packet(), ff_raw_read_partial_packet(), ff_reshuffle_raw_rgb(), ff_rm_retrieve_cache(), ff_spdif_read_packet(), ff_subtitles_queue_insert(), fits_read_packet(), fourxm_read_packet(), fsb_read_packet(), g723_1_read_packet(), gdigrab_read_packet(), genh_read_packet(), grab_read_packet(), h264_handle_packet(), hevc_handle_packet(), ilbc_read_packet(), image_available(), imx_dump_header(), interleave_new_audio_packet(), latm_parse_packet(), lavfi_read_packet(), load_ipmovie_packet(), lxf_read_packet(), main(), merge_superframe(), mjpeg2jpeg_filter(), mjpega_dump_header(), mmap_read_frame(), modplug_read_packet(), mp3_header_decompress(), mpa_robust_parse_packet(), mpc_read_packet(), mpeg_parse_packet(), mpegts_raw_read_packet(), mxg_read_packet(), nuv_packet(), ogg_read_packet(), process_output_surface(), pulse_read_packet(), qdm2_restore_block(), qt_rtp_parse_packet(), read_frame(), read_packet(), read_packet_gme(), read_packet_openmpt(), recode_subtitle(), return_stored_frame(), rm_assemble_video_frame(), rm_read_audio_stream_info(), roq_read_packet(), rsd_read_packet(), rtp_parse_packet_internal(), s337m_read_packet(), sbg_read_packet(), sdr2_read_packet(), sds_read_packet(), seq_read_packet(), siff_read_packet(), smacker_read_packet(), store_packet(), str_read_packet(), supply_new_packets(), swf_read_packet(), text2movsub(), vaapi_encode_output(), vc2hq_handle_sequence_header(), vc2hq_mark_end_of_sequence(), videostream_cb(), vmd_read_packet(), vp9_raw_reorder_make_output(), vpk_read_packet(), vqf_read_packet(), wsaud_read_packet(), wv_read_packet(), xavs2_encode_frame(), xcbgrab_frame(), xiph_handle_packet(), and yop_read_packet().

◆ av_shrink_packet()

void av_shrink_packet ( AVPacket pkt,
int  size 
)

◆ av_grow_packet()

int av_grow_packet ( AVPacket pkt,
int  grow_by 
)

Increase packet size, correctly zeroing padding.

Parameters
pktpacket
grow_bynumber of bytes by which to increase the size of the packet

Definition at line 109 of file avpacket.c.

Referenced by alloc_and_copy(), append_packet_chunked(), encode_callback(), encode_frame(), ff_subtitles_queue_insert(), hevc_mp4toannexb_filter(), main(), stream_seek(), stream_skip(), stream_write(), and wv_read_packet().

◆ av_packet_from_data()

int av_packet_from_data ( AVPacket pkt,
uint8_t data,
int  size 
)

Initialize a reference-counted packet from av_malloc()ed data.

Parameters
pktpacket to be initialized. This function will set the data, size, and buf fields, all others are left untouched.
dataData 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.
sizesize of data in bytes, without the padding. I.e. the full buffer size is assumed to be size + AV_INPUT_BUFFER_PADDING_SIZE.
Returns
0 on success, a negative AVERROR on error

Definition at line 152 of file avpacket.c.

Referenced by ff_rtp_finalize_packet(), iec61883_parse_queue_dv(), main(), omx_encode_frame(), prepare_packet(), qt_rtp_parse_packet(), and rfc4175_finalize_packet().

◆ av_dup_packet()

attribute_deprecated int av_dup_packet ( AVPacket pkt)
Warning
This is a hack - the packet memory allocation stuff is broken. The packet is allocated if it was not really allocated.
Deprecated:
Use av_packet_ref or av_packet_make_refcounted

Definition at line 251 of file avpacket.c.

◆ av_copy_packet()

attribute_deprecated int av_copy_packet ( AVPacket dst,
const AVPacket src 
)

Copy packet, including contents.

Returns
0 on success, negative AVERROR on fail
Deprecated:
Use av_packet_ref

Definition at line 262 of file avpacket.c.

◆ av_copy_packet_side_data()

attribute_deprecated int av_copy_packet_side_data ( AVPacket dst,
const AVPacket src 
)

Copy packet side data.

Returns
0 on success, negative AVERROR on fail
Deprecated:
Use av_packet_copy_props

Definition at line 226 of file avpacket.c.

Referenced by copy_packet_data(), and do_streamcopy().

◆ av_free_packet()

attribute_deprecated void av_free_packet ( AVPacket pkt)

Free a packet.

Deprecated:
Use av_packet_unref
Parameters
pktpacket to free

Definition at line 281 of file avpacket.c.

◆ av_packet_new_side_data()

uint8_t* av_packet_new_side_data ( AVPacket pkt,
enum AVPacketSideDataType  type,
int  size 
)

◆ av_packet_add_side_data()

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.

Parameters
pktpacket
typeside information type
datathe side data array. It must be allocated with the av_malloc() family of functions. The ownership of the data is transferred to pkt.
sizeside information size
Returns
a non-negative number on success, a negative AVERROR code on failure. On failure, the packet is unchanged and the data remains owned by the caller.

Definition at line 295 of file avpacket.c.

Referenced by av_packet_new_side_data(), cenc_filter(), extract_extradata_filter(), ff_mpv_encode_picture(), get_metadata(), h264_metadata_filter(), setup_side_data_entry(), and decklink_input_callback::VideoInputFrameArrived().

◆ av_packet_shrink_side_data()

int av_packet_shrink_side_data ( AVPacket pkt,
enum AVPacketSideDataType  type,
int  size 
)

Shrink the already allocated side data buffer.

Parameters
pktpacket
typeside information type
sizenew side information size
Returns
0 on success, < 0 on failure

Definition at line 549 of file avpacket.c.

Referenced by ff_mpv_encode_picture().

◆ av_packet_get_side_data()

uint8_t* av_packet_get_side_data ( const AVPacket pkt,
enum AVPacketSideDataType  type,
int size 
)

◆ av_packet_merge_side_data()

attribute_deprecated int av_packet_merge_side_data ( AVPacket pkt)

Definition at line 405 of file avpacket.c.

◆ av_packet_split_side_data()

attribute_deprecated int av_packet_split_side_data ( AVPacket pkt)

Definition at line 440 of file avpacket.c.

◆ av_packet_side_data_name()

const char* av_packet_side_data_name ( enum AVPacketSideDataType  type)

Definition at line 367 of file avpacket.c.

Referenced by print_pkt_side_data(), and setup_side_data_entry().

◆ av_packet_pack_dictionary()

uint8_t* av_packet_pack_dictionary ( AVDictionary dict,
int size 
)

Pack a dictionary for use in side_data.

Parameters
dictThe dictionary to pack.
sizepointer to store the size of the returned data
Returns
pointer to data if successful, NULL otherwise

Definition at line 488 of file avpacket.c.

Referenced by concat_read_packet(), decklink_input_callback::VideoInputFrameArrived(), and vorbis_update_metadata().

◆ av_packet_unpack_dictionary()

int av_packet_unpack_dictionary ( const uint8_t data,
int  size,
AVDictionary **  dict 
)

Unpack a dictionary from side_data.

Parameters
datadata from side_data
sizesize of the data
dictthe metadata storage dictionary
Returns
0 on success, < 0 on failure

Definition at line 523 of file avpacket.c.

Referenced by add_metadata_from_side_data(), ff_decklink_read_packet(), and show_packet().

◆ av_packet_free_side_data()

void av_packet_free_side_data ( AVPacket pkt)

Convenience function to free all the side data stored.

All the other fields stay untouched.

Parameters
pktpacket

Definition at line 270 of file avpacket.c.

Referenced by av_free_packet(), av_packet_copy_props(), av_packet_ref(), and av_packet_unref().

◆ av_packet_ref()

int av_packet_ref ( AVPacket dst,
const AVPacket src 
)

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.

See also
av_packet_unref
Parameters
dstDestination packet
srcSource packet
Returns
0 on success, a negative AVERROR on error.

Definition at line 608 of file avpacket.c.

Referenced by aiff_write_packet(), apng_write_packet(), av1_frame_split_filter(), av_packet_clone(), avcodec_send_packet(), extract_extradata(), ff_interleave_add_packet(), ff_packet_list_put(), ff_subtitles_queue_read_packet(), ffat_decode(), fifo_write_packet(), flush_packet(), gif_write_packet(), mkv_write_packet(), mov_write_packet(), mpeg4_unpack_bframes_filter(), qsv_decode_frame(), read_thread(), submit_packet(), tee_write_packet(), vp9_superframe_split_filter(), webp_write_packet(), and write_packet().

◆ av_packet_unref()

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.

Parameters
pktThe packet to be unreferenced.
Examples
demuxing_decoding.c, encode_audio.c, encode_video.c, filtering_audio.c, filtering_video.c, hw_decode.c, qsvdec.c, remuxing.c, transcode_aac.c, transcoding.c, vaapi_encode.c, and vaapi_transcode.c.

Definition at line 599 of file avpacket.c.

Referenced by aac_adtstoasc_filter(), adp_read_packet(), adts_aac_read_packet(), adx_read_packet(), aiff_write_trailer(), amr_read_packet(), android_camera_read_close(), ape_read_packet(), append_packet_chunked(), asf_deinterleave(), asf_parse_packet(), asf_read_close(), asf_read_header(), asf_read_picture(), asf_read_pts(), asf_read_timestamp(), asf_reset_header(), asfrtp_parse_packet(), audio_read_packet(), av1_frame_split_filter(), av1_frame_split_flush(), av1_metadata_filter(), av_bitstream_filter_filter(), av_bsf_flush(), av_copy_packet_side_data(), av_interleaved_write_frame(), av_packet_alloc(), av_packet_free(), av_packet_merge_side_data(), av_read_frame(), av_write_trailer(), avcodec_decode_subtitle2(), avcodec_encode_audio2(), avcodec_encode_video2(), avcodec_flush_buffers(), avcodec_receive_packet(), avcodec_send_packet(), avformat_find_stream_info(), avi_read_close(), avi_read_packet(), avisynth_read_packet_audio(), avisynth_read_packet_video(), avpacket_queue_flush(), avpacket_queue_put(), avs_read_video_packet(), binkaudio_receive_frame(), bsf_list_filter(), bsfs_poll(), cdxl_read_packet(), cin_read_packet(), compute_crc_of_packets(), concat_read_packet(), copy_packet_data(), crystalhd_decode_packet(), crystalhd_receive_frame(), cuvid_output_frame(), decode_audio_frame(), decode_frame(), decode_simple_internal(), decoder_decode_frame(), decoder_destroy(), demux_audio(), dfa_read_packet(), do_encode(), drop_dups(), dshow_read_close(), dss_723_1_read_packet(), dss_sp_read_packet(), dump_extradata(), dxa_read_packet(), ea_read_packet(), eac3_core_filter(), encode(), encode_audio_frame(), encode_frame(), encode_picture_ls(), encode_write(), estimate_timings_from_pts(), extract_extradata(), extract_extradata_filter(), extract_packet_props(), failing_write_packet(), ff_decode_get_packet(), ff_frame_thread_free(), ff_img_read_packet(), ff_interleave_add_packet(), ff_interleave_packet_per_dts(), ff_load_image(), ff_packet_list_free(), ff_qsv_enc_close(), ff_qsv_encode(), ff_raw_read_partial_packet(), ff_read_packet(), ff_rm_free_rmstream(), ff_spdif_read_packet(), ff_subtitles_queue_clean(), ff_v4l2_buffer_buf_to_avpkt(), ffat_close_decoder(), ffat_decode(), ffat_decode_callback(), ffat_decode_flush(), ffmpeg_cleanup(), fifo_basic_test(), fifo_overflow_drop_test(), fifo_thread_recover(), fifo_thread_write_packet(), fifo_write_packet(), filter_packet(), filter_units_filter(), find_video_stream_info(), fits_read_packet(), flac_finish_header(), flac_queue_flush(), flac_read_timestamp(), flush(), flush_encoders(), flush_packet(), flv_read_packet(), fourxm_read_packet(), free_message(), free_pkt_fifo(), free_playlist_list(), free_stream(), g723_1_read_packet(), gdv_read_packet(), gif_write_packet(), gsm_read_packet(), h264_metadata_filter(), h264_mp4toannexb_filter(), h264_redundant_pps_filter(), h265_metadata_filter(), handle_id3(), hapqa_extract(), hevc_mp4toannexb_filter(), hls_read_packet(), hls_read_seek(), hnm_read_close(), idcin_read_packet(), iec61883_parse_queue_dv(), ilbc_read_packet(), image_available(), imx_dump_header(), interleave_packet(), lavfi_read_packet(), libdav1d_receive_frame(), libopus_encode(), LLVMFuzzerTestOneInput(), load_ipmovie_packet(), lxf_read_packet(), main(), mediacodec_decode_close(), mediacodec_decode_flush(), mediacodec_receive_frame(), mjpeg2jpeg_filter(), mjpega_dump_header(), mkv_write_packet(), mkv_write_trailer(), mmap_read_frame(), modplug_read_packet(), mov2textsub(), mov_free(), mov_read_packet(), mov_write_subtitle_end_packet(), movie_push_frame(), mp3_header_decompress(), mp3_queue_flush(), mp3lame_encode_frame(), mpa_robust_parse_packet(), mpc_read_packet(), mpc_read_seek(), mpeg2_metadata_filter(), mpeg4_unpack_bframes_filter(), mpeg4_unpack_bframes_flush(), mpegts_get_dts(), mpegts_raw_read_packet(), mpegts_read_packet(), mpjpeg_read_packet(), mxf_interleave_get_packet(), nc_read_packet(), noise(), nsv_read_close(), nuv_packet(), ogg_read_packet(), packet_queue_flush(), packet_queue_put(), parse_packet(), process_input(), prores_metadata(), qsv_clear_buffers(), qsv_decode_frame(), qt_rtp_parse_packet(), read_frame_internal(), read_gab2_sub(), read_interval_packets(), read_packet(), read_thread(), recode_subtitle(), redspark_read_packet(), reset_packet(), reset_packet_state(), rl2_read_packet(), rm_assemble_video_frame(), rm_read_packet(), roq_read_packet(), rpl_read_packet(), run_test(), s337m_read_packet(), sap_fetch_packet(), decklink_output_callback::ScheduledFrameCompleted(), sdr2_read_packet(), seek_frame_generic(), seek_subtitle(), siff_read_packet(), storeframe(), str_read_close(), str_read_packet(), submit_packet(), swf_read_packet(), text2movsub(), thp_read_packet(), trace_headers(), truehd_core_filter(), tta_encode_frame(), tta_queue_flush(), v4l2_receive_frame(), vfw_read_close(), video_decode(), video_decode_example(), vivo_read_packet(), vmd_read_packet(), vp9_metadata_filter(), vp9_superframe_filter(), vp9_superframe_flush(), vp9_superframe_split_filter(), vp9_superframe_split_flush(), vpk_read_packet(), vqf_read_packet(), vtenc_frame(), wc3_read_close(), write_packet(), write_trailer(), wv_read_packet(), xiph_handle_packet(), xvid_encode_frame(), xvid_encode_init(), yop_read_close(), yop_read_packet(), yop_read_seek(), and yuv4_read_packet().

◆ av_packet_move_ref()

void av_packet_move_ref ( AVPacket dst,
AVPacket src 
)

◆ av_packet_copy_props()

int av_packet_copy_props ( AVPacket dst,
const AVPacket src 
)

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)

Parameters
dstDestination packet
srcSource packet
Returns
0 on success AVERROR on failure.

Definition at line 565 of file avpacket.c.

Referenced by av_packet_ref(), dump_extradata(), extract_packet_props(), ff_qsv_encode(), ff_reshuffle_raw_rgb(), h264_mp4toannexb_filter(), hevc_mp4toannexb_filter(), imx_dump_header(), mjpeg2jpeg_filter(), mjpega_dump_header(), mp3_header_decompress(), mpeg4_unpack_bframes_filter(), text2movsub(), and vp9_superframe_filter().

◆ av_packet_make_refcounted()

int av_packet_make_refcounted ( AVPacket pkt)

Ensure the data described by a given packet is reference counted.

Note
This function does not ensure that the reference will be writable. Use av_packet_make_writable instead for that purpose.
See also
av_packet_ref
av_packet_make_writable
Parameters
pktpacket whose data should be made reference counted.
Returns
0 on success, a negative AVERROR on error. On failure, the packet is unchanged.

Definition at line 663 of file avpacket.c.

Referenced by av_bsf_send_packet(), avcodec_encode_audio2(), avcodec_encode_video2(), avpacket_queue_put(), ff_read_packet(), parse_packet(), worker(), and write_packet().

◆ av_packet_make_writable()

int av_packet_make_writable ( AVPacket pkt)

Create a writable reference for the data described by a given packet, avoiding data copy if possible.

Parameters
pktPacket whose data should be made writable.
Returns
0 on success, a negative AVERROR on failure. On failure, the packet is unchanged.

Definition at line 682 of file avpacket.c.

Referenced by mpeg4_unpack_bframes_filter(), noise(), prores_metadata(), and truehd_core_filter().

◆ av_packet_rescale_ts()

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.

Parameters
pktpacket on which the conversion will be performed
tb_srcsource timebase, in which the timing fields in pkt are expressed
tb_dstdestination timebase, to which the timing fields will be converted
Examples
muxing.c, transcoding.c, and vaapi_transcode.c.

Definition at line 704 of file avpacket.c.

Referenced by do_audio_out(), do_video_out(), encode_write(), encode_write_frame(), fifo_thread_write_packet(), flush_encoders(), main(), tee_write_packet(), write_frame(), and write_packet().