FFmpeg  2.8.1
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...
 

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_SKIP_SAMPLES =70, 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
}
 
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

attribute_deprecated void av_destruct_packet (AVPacket *pkt)
 Default packet destructor. 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...
 
int av_dup_packet (AVPacket *pkt)
 
int av_copy_packet (AVPacket *dst, const AVPacket *src)
 Copy packet, including contents. More...
 
int av_copy_packet_side_data (AVPacket *dst, const AVPacket *src)
 Copy packet side data. More...
 
void av_free_packet (AVPacket *pkt)
 Free a packet. More...
 
uint8_t * av_packet_new_side_data (AVPacket *pkt, enum AVPacketSideDataType type, int size)
 Allocate new information of a packet. More...
 
int av_packet_shrink_side_data (AVPacket *pkt, enum AVPacketSideDataType type, int size)
 Shrink the already allocated side data buffer. More...
 
uint8_t * av_packet_get_side_data (AVPacket *pkt, enum AVPacketSideDataType type, int *size)
 Get side information from packet. More...
 
int av_packet_merge_side_data (AVPacket *pkt)
 
int av_packet_split_side_data (AVPacket *pkt)
 
const char * av_packet_side_data_name (enum AVPacketSideDataType type)
 
uint8_t * av_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...
 
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

#define AV_PKT_DATA_QUALITY_FACTOR   AV_PKT_DATA_QUALITY_STATS

Definition at line 1370 of file avcodec.h.

#define AV_PKT_FLAG_KEY   0x0001

The packet contains a keyframe.

Examples:
muxing.c.

Definition at line 1469 of file avcodec.h.

Referenced by write_video_frame().

#define AV_PKT_FLAG_CORRUPT   0x0002

The packet content is corrupted.

Definition at line 1470 of file avcodec.h.

Enumeration Type Documentation

Enumerator
AV_PKT_DATA_PALETTE 
AV_PKT_DATA_NEW_EXTRADATA 
AV_PKT_DATA_PARAM_CHANGE 

An AV_PKT_DATA_PARAM_CHANGE side data packet is laid out as follows:

1 u32le param_flags
2 if (param_flags & AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_COUNT)
3  s32le channel_count
4 if (param_flags & AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_LAYOUT)
5  u64le channel_layout
6 if (param_flags & AV_SIDE_DATA_PARAM_CHANGE_SAMPLE_RATE)
7  s32le sample_rate
8 if (param_flags & AV_SIDE_DATA_PARAM_CHANGE_DIMENSIONS)
9  s32le width
10  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:

1 u32le bit offset from the start of the packet
2 u8 current quantizer at the start of the macroblock
3 u8 GOB number
4 u16le macroblock address within the GOB
5 u8 horizontal MV predictor
6 u8 vertical MV predictor
7 u8 horizontal MV predictor for block number 3
8 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.

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

Recommmends skipping the specified number of samples.

1 u32le number of samples to skip from start of this packet
2 u32le number of samples to skip from end of this packet
3 u8 reason for start skip
4 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.

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

1 u32le x1
2 u32le y1
3 u32le x2
4 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.

Definition at line 1224 of file avcodec.h.

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 1472 of file avcodec.h.

Function Documentation

attribute_deprecated void av_destruct_packet ( AVPacket pkt)

Default packet destructor.

Deprecated:
use the AVBuffer API instead
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:
decoding_encoding.c, demuxing_decoding.c, muxing.c, transcode_aac.c, and transcoding.c.

Referenced by audio_decode_example(), audio_encode_example(), encode_write_frame(), init_packet(), main(), video_decode_example(), video_encode_example(), write_audio_frame(), and write_video_frame().

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
void av_shrink_packet ( AVPacket pkt,
int  size 
)

Reduce packet size, correctly zeroing padding.

Parameters
pktpacket
sizenew size
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
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, buf and destruct 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
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.
int av_copy_packet ( AVPacket dst,
const AVPacket src 
)

Copy packet, including contents.

Returns
0 on success, negative AVERROR on fail
int av_copy_packet_side_data ( AVPacket dst,
const AVPacket src 
)

Copy packet side data.

Returns
0 on success, negative AVERROR on fail
void av_free_packet ( AVPacket pkt)
uint8_t* av_packet_new_side_data ( AVPacket pkt,
enum AVPacketSideDataType  type,
int  size 
)

Allocate new information of a packet.

Parameters
pktpacket
typeside information type
sizeside information size
Returns
pointer to fresh allocated data or NULL otherwise
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
uint8_t* av_packet_get_side_data ( AVPacket pkt,
enum AVPacketSideDataType  type,
int *  size 
)

Get side information from packet.

Parameters
pktpacket
typedesired side information type
sizepointer for side information size to store (optional)
Returns
pointer to data if present or NULL otherwise
int av_packet_merge_side_data ( AVPacket pkt)
int av_packet_split_side_data ( AVPacket pkt)
const char* av_packet_side_data_name ( enum AVPacketSideDataType  type)
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
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
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
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.
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.
void av_packet_move_ref ( AVPacket dst,
AVPacket src 
)

Move every field in src to dst and reset src.

See also
av_packet_unref
Parameters
srcSource packet, will be reset
dstDestination packet
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.
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, and transcoding.c.

Referenced by encode_write_frame(), main(), write_frame(), and write_video_frame().