Path: blob/master/dep/ffmpeg/include/libavcodec/packet.h
7547 views
/*1* AVPacket public API2*3* This file is part of FFmpeg.4*5* FFmpeg is free software; you can redistribute it and/or6* modify it under the terms of the GNU Lesser General Public7* License as published by the Free Software Foundation; either8* version 2.1 of the License, or (at your option) any later version.9*10* FFmpeg is distributed in the hope that it will be useful,11* but WITHOUT ANY WARRANTY; without even the implied warranty of12* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU13* Lesser General Public License for more details.14*15* You should have received a copy of the GNU Lesser General Public16* License along with FFmpeg; if not, write to the Free Software17* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA18*/1920#ifndef AVCODEC_PACKET_H21#define AVCODEC_PACKET_H2223#include <stddef.h>24#include <stdint.h>2526#include "libavutil/attributes.h"27#include "libavutil/buffer.h"28#include "libavutil/dict.h"29#include "libavutil/rational.h"30#include "libavutil/version.h"3132#include "libavcodec/version_major.h"3334/**35* @defgroup lavc_packet_side_data AVPacketSideData36*37* Types and functions for working with AVPacketSideData.38* @{39*/40enum AVPacketSideDataType {41/**42* An AV_PKT_DATA_PALETTE side data packet contains exactly AVPALETTE_SIZE43* bytes worth of palette. This side data signals that a new palette is44* present.45*/46AV_PKT_DATA_PALETTE,4748/**49* The AV_PKT_DATA_NEW_EXTRADATA is used to notify the codec or the format50* that the extradata buffer was changed and the receiving side should51* act upon it appropriately. The new extradata is embedded in the side52* data buffer and should be immediately used for processing the current53* frame or packet.54*/55AV_PKT_DATA_NEW_EXTRADATA,5657/**58* An AV_PKT_DATA_PARAM_CHANGE side data packet is laid out as follows:59* @code60* u32le param_flags61* if (param_flags & AV_SIDE_DATA_PARAM_CHANGE_SAMPLE_RATE)62* s32le sample_rate63* if (param_flags & AV_SIDE_DATA_PARAM_CHANGE_DIMENSIONS)64* s32le width65* s32le height66* @endcode67*/68AV_PKT_DATA_PARAM_CHANGE,6970/**71* An AV_PKT_DATA_H263_MB_INFO side data packet contains a number of72* structures with info about macroblocks relevant to splitting the73* packet into smaller packets on macroblock edges (e.g. as for RFC 2190).74* That is, it does not necessarily contain info about all macroblocks,75* as long as the distance between macroblocks in the info is smaller76* than the target payload size.77* Each MB info structure is 12 bytes, and is laid out as follows:78* @code79* u32le bit offset from the start of the packet80* u8 current quantizer at the start of the macroblock81* u8 GOB number82* u16le macroblock address within the GOB83* u8 horizontal MV predictor84* u8 vertical MV predictor85* u8 horizontal MV predictor for block number 386* u8 vertical MV predictor for block number 387* @endcode88*/89AV_PKT_DATA_H263_MB_INFO,9091/**92* This side data should be associated with an audio stream and contains93* ReplayGain information in form of the AVReplayGain struct.94*/95AV_PKT_DATA_REPLAYGAIN,9697/**98* This side data contains a 3x3 transformation matrix describing an affine99* transformation that needs to be applied to the decoded video frames for100* correct presentation.101*102* See libavutil/display.h for a detailed description of the data.103*/104AV_PKT_DATA_DISPLAYMATRIX,105106/**107* This side data should be associated with a video stream and contains108* Stereoscopic 3D information in form of the AVStereo3D struct.109*/110AV_PKT_DATA_STEREO3D,111112/**113* This side data should be associated with an audio stream and corresponds114* to enum AVAudioServiceType.115*/116AV_PKT_DATA_AUDIO_SERVICE_TYPE,117118/**119* This side data contains quality related information from the encoder.120* @code121* u32le quality factor of the compressed frame. Allowed range is between 1 (good) and FF_LAMBDA_MAX (bad).122* u8 picture type123* u8 error count124* u16 reserved125* u64le[error count] sum of squared differences between encoder in and output126* @endcode127*/128AV_PKT_DATA_QUALITY_STATS,129130/**131* This side data contains an integer value representing the stream index132* of a "fallback" track. A fallback track indicates an alternate133* track to use when the current track can not be decoded for some reason.134* e.g. no decoder available for codec.135*/136AV_PKT_DATA_FALLBACK_TRACK,137138/**139* This side data corresponds to the AVCPBProperties struct.140*/141AV_PKT_DATA_CPB_PROPERTIES,142143/**144* Recommends skipping the specified number of samples145* @code146* u32le number of samples to skip from start of this packet147* u32le number of samples to skip from end of this packet148* u8 reason for start skip149* u8 reason for end skip (0=padding silence, 1=convergence)150* @endcode151*/152AV_PKT_DATA_SKIP_SAMPLES,153154/**155* An AV_PKT_DATA_JP_DUALMONO side data packet indicates that156* the packet may contain "dual mono" audio specific to Japanese DTV157* and if it is true, recommends only the selected channel to be used.158* @code159* u8 selected channels (0=main/left, 1=sub/right, 2=both)160* @endcode161*/162AV_PKT_DATA_JP_DUALMONO,163164/**165* A list of zero terminated key/value strings. There is no end marker for166* the list, so it is required to rely on the side data size to stop.167*/168AV_PKT_DATA_STRINGS_METADATA,169170/**171* Subtitle event position172* @code173* u32le x1174* u32le y1175* u32le x2176* u32le y2177* @endcode178*/179AV_PKT_DATA_SUBTITLE_POSITION,180181/**182* Data found in BlockAdditional element of matroska container. There is183* no end marker for the data, so it is required to rely on the side data184* size to recognize the end. 8 byte id (as found in BlockAddId) followed185* by data.186*/187AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL,188189/**190* The optional first identifier line of a WebVTT cue.191*/192AV_PKT_DATA_WEBVTT_IDENTIFIER,193194/**195* The optional settings (rendering instructions) that immediately196* follow the timestamp specifier of a WebVTT cue.197*/198AV_PKT_DATA_WEBVTT_SETTINGS,199200/**201* A list of zero terminated key/value strings. There is no end marker for202* the list, so it is required to rely on the side data size to stop. This203* side data includes updated metadata which appeared in the stream.204*/205AV_PKT_DATA_METADATA_UPDATE,206207/**208* MPEGTS stream ID as uint8_t, this is required to pass the stream ID209* information from the demuxer to the corresponding muxer.210*/211AV_PKT_DATA_MPEGTS_STREAM_ID,212213/**214* Mastering display metadata (based on SMPTE-2086:2014). This metadata215* should be associated with a video stream and contains data in the form216* of the AVMasteringDisplayMetadata struct.217*/218AV_PKT_DATA_MASTERING_DISPLAY_METADATA,219220/**221* This side data should be associated with a video stream and corresponds222* to the AVSphericalMapping structure.223*/224AV_PKT_DATA_SPHERICAL,225226/**227* Content light level (based on CTA-861.3). This metadata should be228* associated with a video stream and contains data in the form of the229* AVContentLightMetadata struct.230*/231AV_PKT_DATA_CONTENT_LIGHT_LEVEL,232233/**234* ATSC A53 Part 4 Closed Captions. This metadata should be associated with235* a video stream. A53 CC bitstream is stored as uint8_t in AVPacketSideData.data.236* The number of bytes of CC data is AVPacketSideData.size.237*/238AV_PKT_DATA_A53_CC,239240/**241* This side data is encryption initialization data.242* The format is not part of ABI, use av_encryption_init_info_* methods to243* access.244*/245AV_PKT_DATA_ENCRYPTION_INIT_INFO,246247/**248* This side data contains encryption info for how to decrypt the packet.249* The format is not part of ABI, use av_encryption_info_* methods to access.250*/251AV_PKT_DATA_ENCRYPTION_INFO,252253/**254* Active Format Description data consisting of a single byte as specified255* in ETSI TS 101 154 using AVActiveFormatDescription enum.256*/257AV_PKT_DATA_AFD,258259/**260* Producer Reference Time data corresponding to the AVProducerReferenceTime struct,261* usually exported by some encoders (on demand through the prft flag set in the262* AVCodecContext export_side_data field).263*/264AV_PKT_DATA_PRFT,265266/**267* ICC profile data consisting of an opaque octet buffer following the268* format described by ISO 15076-1.269*/270AV_PKT_DATA_ICC_PROFILE,271272/**273* DOVI configuration274* ref:275* dolby-vision-bitstreams-within-the-iso-base-media-file-format-v2.1.2, section 2.2276* dolby-vision-bitstreams-in-mpeg-2-transport-stream-multiplex-v1.2, section 3.3277* Tags are stored in struct AVDOVIDecoderConfigurationRecord.278*/279AV_PKT_DATA_DOVI_CONF,280281/**282* Timecode which conforms to SMPTE ST 12-1:2014. The data is an array of 4 uint32_t283* where the first uint32_t describes how many (1-3) of the other timecodes are used.284* The timecode format is described in the documentation of av_timecode_get_smpte_from_framenum()285* function in libavutil/timecode.h.286*/287AV_PKT_DATA_S12M_TIMECODE,288289/**290* HDR10+ dynamic metadata associated with a video frame. The metadata is in291* the form of the AVDynamicHDRPlus struct and contains292* information for color volume transform - application 4 of293* SMPTE 2094-40:2016 standard.294*/295AV_PKT_DATA_DYNAMIC_HDR10_PLUS,296297/**298* IAMF Mix Gain Parameter Data associated with the audio frame. This metadata299* is in the form of the AVIAMFParamDefinition struct and contains information300* defined in sections 3.6.1 and 3.8.1 of the Immersive Audio Model and301* Formats standard.302*/303AV_PKT_DATA_IAMF_MIX_GAIN_PARAM,304305/**306* IAMF Demixing Info Parameter Data associated with the audio frame. This307* metadata is in the form of the AVIAMFParamDefinition struct and contains308* information defined in sections 3.6.1 and 3.8.2 of the Immersive Audio Model309* and Formats standard.310*/311AV_PKT_DATA_IAMF_DEMIXING_INFO_PARAM,312313/**314* IAMF Recon Gain Info Parameter Data associated with the audio frame. This315* metadata is in the form of the AVIAMFParamDefinition struct and contains316* information defined in sections 3.6.1 and 3.8.3 of the Immersive Audio Model317* and Formats standard.318*/319AV_PKT_DATA_IAMF_RECON_GAIN_INFO_PARAM,320321/**322* Ambient viewing environment metadata, as defined by H.274. This metadata323* should be associated with a video stream and contains data in the form324* of the AVAmbientViewingEnvironment struct.325*/326AV_PKT_DATA_AMBIENT_VIEWING_ENVIRONMENT,327328/**329* The number of pixels to discard from the top/bottom/left/right border of the330* decoded frame to obtain the sub-rectangle intended for presentation.331*332* @code333* u32le crop_top334* u32le crop_bottom335* u32le crop_left336* u32le crop_right337* @endcode338*/339AV_PKT_DATA_FRAME_CROPPING,340341/**342* Raw LCEVC payload data, as a uint8_t array, with NAL emulation343* bytes intact.344*/345AV_PKT_DATA_LCEVC,346347/**348* This side data contains information about the reference display width(s)349* and reference viewing distance(s) as well as information about the350* corresponding reference stereo pair(s), i.e., the pair(s) of views to be351* displayed for the viewer's left and right eyes on the reference display352* at the reference viewing distance.353* The payload is the AV3DReferenceDisplaysInfo struct defined in354* libavutil/tdrdi.h.355*/356AV_PKT_DATA_3D_REFERENCE_DISPLAYS,357358/**359* Contains the last received RTCP SR (Sender Report) information360* in the form of the AVRTCPSenderReport struct.361*/362AV_PKT_DATA_RTCP_SR,363364/**365* The number of side data types.366* This is not part of the public API/ABI in the sense that it may367* change when new side data types are added.368* This must stay the last enum value.369* If its value becomes huge, some code using it370* needs to be updated as it assumes it to be smaller than other limits.371*/372AV_PKT_DATA_NB373};374375/**376* This structure stores auxiliary information for decoding, presenting, or377* otherwise processing the coded stream. It is typically exported by demuxers378* and encoders and can be fed to decoders and muxers either in a per packet379* basis, or as global side data (applying to the entire coded stream).380*381* Global side data is handled as follows:382* - During demuxing, it may be exported through383* @ref AVCodecParameters.coded_side_data "AVStream's codec parameters", which can384* then be passed as input to decoders through the385* @ref AVCodecContext.coded_side_data "decoder context's side data", for386* initialization.387* - For muxing, it can be fed through @ref AVCodecParameters.coded_side_data388* "AVStream's codec parameters", typically the output of encoders through389* the @ref AVCodecContext.coded_side_data "encoder context's side data", for390* initialization.391*392* Packet specific side data is handled as follows:393* - During demuxing, it may be exported through @ref AVPacket.side_data394* "AVPacket's side data", which can then be passed as input to decoders.395* - For muxing, it can be fed through @ref AVPacket.side_data "AVPacket's396* side data", typically the output of encoders.397*398* Different modules may accept or export different types of side data399* depending on media type and codec. Refer to @ref AVPacketSideDataType for a400* list of defined types and where they may be found or used.401*/402typedef struct AVPacketSideData {403uint8_t *data;404size_t size;405enum AVPacketSideDataType type;406} AVPacketSideData;407408/**409* Allocate a new packet side data.410*411* @param sd pointer to an array of side data to which the side data should412* be added. *sd may be NULL, in which case the array will be413* initialized.414* @param nb_sd pointer to an integer containing the number of entries in415* the array. The integer value will be increased by 1 on success.416* @param type side data type417* @param size desired side data size418* @param flags currently unused. Must be zero419*420* @return pointer to freshly allocated side data on success, or NULL otherwise.421*/422AVPacketSideData *av_packet_side_data_new(AVPacketSideData **psd, int *pnb_sd,423enum AVPacketSideDataType type,424size_t size, int flags);425426/**427* Wrap existing data as packet side data.428*429* @param sd pointer to an array of side data to which the side data should430* be added. *sd may be NULL, in which case the array will be431* initialized432* @param nb_sd pointer to an integer containing the number of entries in433* the array. The integer value will be increased by 1 on success.434* @param type side data type435* @param data a data array. It must be allocated with the av_malloc() family436* of functions. The ownership of the data is transferred to the437* side data array on success438* @param size size of the data array439* @param flags currently unused. Must be zero440*441* @return pointer to freshly allocated side data on success, or NULL otherwise442* On failure, the side data array is unchanged and the data remains443* owned by the caller.444*/445AVPacketSideData *av_packet_side_data_add(AVPacketSideData **sd, int *nb_sd,446enum AVPacketSideDataType type,447void *data, size_t size, int flags);448449/**450* Get side information from a side data array.451*452* @param sd the array from which the side data should be fetched453* @param nb_sd value containing the number of entries in the array.454* @param type desired side information type455*456* @return pointer to side data if present or NULL otherwise457*/458const AVPacketSideData *av_packet_side_data_get(const AVPacketSideData *sd,459int nb_sd,460enum AVPacketSideDataType type);461462/**463* Remove side data of the given type from a side data array.464*465* @param sd the array from which the side data should be removed466* @param nb_sd pointer to an integer containing the number of entries in467* the array. Will be reduced by the amount of entries removed468* upon return469* @param type side information type470*/471void av_packet_side_data_remove(AVPacketSideData *sd, int *nb_sd,472enum AVPacketSideDataType type);473474/**475* Convenience function to free all the side data stored in an array, and476* the array itself.477*478* @param sd pointer to array of side data to free. Will be set to NULL479* upon return.480* @param nb_sd pointer to an integer containing the number of entries in481* the array. Will be set to 0 upon return.482*/483void av_packet_side_data_free(AVPacketSideData **sd, int *nb_sd);484485const char *av_packet_side_data_name(enum AVPacketSideDataType type);486487/**488* @}489*/490491/**492* @defgroup lavc_packet AVPacket493*494* Types and functions for working with AVPacket.495* @{496*/497498/**499* This structure stores compressed data. It is typically exported by demuxers500* and then passed as input to decoders, or received as output from encoders and501* then passed to muxers.502*503* For video, it should typically contain one compressed frame. For audio it may504* contain several compressed frames. Encoders are allowed to output empty505* packets, with no compressed data, containing only side data506* (e.g. to update some stream parameters at the end of encoding).507*508* The semantics of data ownership depends on the buf field.509* If it is set, the packet data is dynamically allocated and is510* valid indefinitely until a call to av_packet_unref() reduces the511* reference count to 0.512*513* If the buf field is not set av_packet_ref() would make a copy instead514* of increasing the reference count.515*516* The side data is always allocated with av_malloc(), copied by517* av_packet_ref() and freed by av_packet_unref().518*519* sizeof(AVPacket) being a part of the public ABI is deprecated. once520* av_init_packet() is removed, new packets will only be able to be allocated521* with av_packet_alloc(), and new fields may be added to the end of the struct522* with a minor bump.523*524* @see av_packet_alloc525* @see av_packet_ref526* @see av_packet_unref527*/528typedef struct AVPacket {529/**530* A reference to the reference-counted buffer where the packet data is531* stored.532* May be NULL, then the packet data is not reference-counted.533*/534AVBufferRef *buf;535/**536* Presentation timestamp in AVStream->time_base units; the time at which537* the decompressed packet will be presented to the user.538* Can be AV_NOPTS_VALUE if it is not stored in the file.539* pts MUST be larger or equal to dts as presentation cannot happen before540* decompression, unless one wants to view hex dumps. Some formats misuse541* the terms dts and pts/cts to mean something different. Such timestamps542* must be converted to true pts/dts before they are stored in AVPacket.543*/544int64_t pts;545/**546* Decompression timestamp in AVStream->time_base units; the time at which547* the packet is decompressed.548* Can be AV_NOPTS_VALUE if it is not stored in the file.549*/550int64_t dts;551uint8_t *data;552int size;553int stream_index;554/**555* A combination of AV_PKT_FLAG values556*/557int flags;558/**559* Additional packet data that can be provided by the container.560* Packet can contain several types of side information.561*/562AVPacketSideData *side_data;563int side_data_elems;564565/**566* Duration of this packet in AVStream->time_base units, 0 if unknown.567* Equals next_pts - this_pts in presentation order.568*/569int64_t duration;570571int64_t pos; ///< byte position in stream, -1 if unknown572573/**574* for some private data of the user575*/576void *opaque;577578/**579* AVBufferRef for free use by the API user. FFmpeg will never check the580* contents of the buffer ref. FFmpeg calls av_buffer_unref() on it when581* the packet is unreferenced. av_packet_copy_props() calls create a new582* reference with av_buffer_ref() for the target packet's opaque_ref field.583*584* This is unrelated to the opaque field, although it serves a similar585* purpose.586*/587AVBufferRef *opaque_ref;588589/**590* Time base of the packet's timestamps.591* In the future, this field may be set on packets output by encoders or592* demuxers, but its value will be by default ignored on input to decoders593* or muxers.594*/595AVRational time_base;596} AVPacket;597598#if FF_API_INIT_PACKET599attribute_deprecated600typedef struct AVPacketList {601AVPacket pkt;602struct AVPacketList *next;603} AVPacketList;604#endif605606#define AV_PKT_FLAG_KEY 0x0001 ///< The packet contains a keyframe607#define AV_PKT_FLAG_CORRUPT 0x0002 ///< The packet content is corrupted608/**609* Flag is used to discard packets which are required to maintain valid610* decoder state but are not required for output and should be dropped611* after decoding.612**/613#define AV_PKT_FLAG_DISCARD 0x0004614/**615* The packet comes from a trusted source.616*617* Otherwise-unsafe constructs such as arbitrary pointers to data618* outside the packet may be followed.619*/620#define AV_PKT_FLAG_TRUSTED 0x0008621/**622* Flag is used to indicate packets that contain frames that can623* be discarded by the decoder. I.e. Non-reference frames.624*/625#define AV_PKT_FLAG_DISPOSABLE 0x0010626627enum AVSideDataParamChangeFlags {628AV_SIDE_DATA_PARAM_CHANGE_SAMPLE_RATE = 0x0004,629AV_SIDE_DATA_PARAM_CHANGE_DIMENSIONS = 0x0008,630};631632/**633* Allocate an AVPacket and set its fields to default values. The resulting634* struct must be freed using av_packet_free().635*636* @return An AVPacket filled with default values or NULL on failure.637*638* @note this only allocates the AVPacket itself, not the data buffers. Those639* must be allocated through other means such as av_new_packet.640*641* @see av_new_packet642*/643AVPacket *av_packet_alloc(void);644645/**646* Create a new packet that references the same data as src.647*648* This is a shortcut for av_packet_alloc()+av_packet_ref().649*650* @return newly created AVPacket on success, NULL on error.651*652* @see av_packet_alloc653* @see av_packet_ref654*/655AVPacket *av_packet_clone(const AVPacket *src);656657/**658* Free the packet, if the packet is reference counted, it will be659* unreferenced first.660*661* @param pkt packet to be freed. The pointer will be set to NULL.662* @note passing NULL is a no-op.663*/664void av_packet_free(AVPacket **pkt);665666#if FF_API_INIT_PACKET667/**668* Initialize optional fields of a packet with default values.669*670* Note, this does not touch the data and size members, which have to be671* initialized separately.672*673* @param pkt packet674*675* @see av_packet_alloc676* @see av_packet_unref677*678* @deprecated This function is deprecated. Once it's removed,679sizeof(AVPacket) will not be a part of the ABI anymore.680*/681attribute_deprecated682void av_init_packet(AVPacket *pkt);683#endif684685/**686* Allocate the payload of a packet and initialize its fields with687* default values.688*689* @param pkt packet690* @param size wanted payload size691* @return 0 if OK, AVERROR_xxx otherwise692*/693int av_new_packet(AVPacket *pkt, int size);694695/**696* Reduce packet size, correctly zeroing padding697*698* @param pkt packet699* @param size new size700*/701void av_shrink_packet(AVPacket *pkt, int size);702703/**704* Increase packet size, correctly zeroing padding705*706* @param pkt packet707* @param grow_by number of bytes by which to increase the size of the packet708*/709int av_grow_packet(AVPacket *pkt, int grow_by);710711/**712* Initialize a reference-counted packet from av_malloc()ed data.713*714* @param pkt packet to be initialized. This function will set the data, size,715* and buf fields, all others are left untouched.716* @param data Data allocated by av_malloc() to be used as packet data. If this717* function returns successfully, the data is owned by the underlying AVBuffer.718* The caller may not access the data through other means.719* @param size size of data in bytes, without the padding. I.e. the full buffer720* size is assumed to be size + AV_INPUT_BUFFER_PADDING_SIZE.721*722* @return 0 on success, a negative AVERROR on error723*/724int av_packet_from_data(AVPacket *pkt, uint8_t *data, int size);725726/**727* Allocate new information of a packet.728*729* @param pkt packet730* @param type side information type731* @param size side information size732* @return pointer to fresh allocated data or NULL otherwise733*/734uint8_t* av_packet_new_side_data(AVPacket *pkt, enum AVPacketSideDataType type,735size_t size);736737/**738* Wrap an existing array as a packet side data.739*740* @param pkt packet741* @param type side information type742* @param data the side data array. It must be allocated with the av_malloc()743* family of functions. The ownership of the data is transferred to744* pkt.745* @param size side information size746* @return a non-negative number on success, a negative AVERROR code on747* failure. On failure, the packet is unchanged and the data remains748* owned by the caller.749*/750int av_packet_add_side_data(AVPacket *pkt, enum AVPacketSideDataType type,751uint8_t *data, size_t size);752753/**754* Shrink the already allocated side data buffer755*756* @param pkt packet757* @param type side information type758* @param size new side information size759* @return 0 on success, < 0 on failure760*/761int av_packet_shrink_side_data(AVPacket *pkt, enum AVPacketSideDataType type,762size_t size);763764/**765* Get side information from packet.766*767* @param pkt packet768* @param type desired side information type769* @param size If supplied, *size will be set to the size of the side data770* or to zero if the desired side data is not present.771* @return pointer to data if present or NULL otherwise772*/773uint8_t* av_packet_get_side_data(const AVPacket *pkt, enum AVPacketSideDataType type,774size_t *size);775776/**777* Pack a dictionary for use in side_data.778*779* @param dict The dictionary to pack.780* @param size pointer to store the size of the returned data781* @return pointer to data if successful, NULL otherwise782*/783uint8_t *av_packet_pack_dictionary(AVDictionary *dict, size_t *size);784/**785* Unpack a dictionary from side_data.786*787* @param data data from side_data788* @param size size of the data789* @param dict the metadata storage dictionary790* @return 0 on success, < 0 on failure791*/792int av_packet_unpack_dictionary(const uint8_t *data, size_t size,793AVDictionary **dict);794795/**796* Convenience function to free all the side data stored.797* All the other fields stay untouched.798*799* @param pkt packet800*/801void av_packet_free_side_data(AVPacket *pkt);802803/**804* Setup a new reference to the data described by a given packet805*806* If src is reference-counted, setup dst as a new reference to the807* buffer in src. Otherwise allocate a new buffer in dst and copy the808* data from src into it.809*810* All the other fields are copied from src.811*812* @see av_packet_unref813*814* @param dst Destination packet. Will be completely overwritten.815* @param src Source packet816*817* @return 0 on success, a negative AVERROR on error. On error, dst818* will be blank (as if returned by av_packet_alloc()).819*/820int av_packet_ref(AVPacket *dst, const AVPacket *src);821822/**823* Wipe the packet.824*825* Unreference the buffer referenced by the packet and reset the826* remaining packet fields to their default values.827*828* @param pkt The packet to be unreferenced.829*/830void av_packet_unref(AVPacket *pkt);831832/**833* Move every field in src to dst and reset src.834*835* @see av_packet_unref836*837* @param src Source packet, will be reset838* @param dst Destination packet839*/840void av_packet_move_ref(AVPacket *dst, AVPacket *src);841842/**843* Copy only "properties" fields from src to dst.844*845* Properties for the purpose of this function are all the fields846* beside those related to the packet data (buf, data, size)847*848* @param dst Destination packet849* @param src Source packet850*851* @return 0 on success AVERROR on failure.852*/853int av_packet_copy_props(AVPacket *dst, const AVPacket *src);854855/**856* Ensure the data described by a given packet is reference counted.857*858* @note This function does not ensure that the reference will be writable.859* Use av_packet_make_writable instead for that purpose.860*861* @see av_packet_ref862* @see av_packet_make_writable863*864* @param pkt packet whose data should be made reference counted.865*866* @return 0 on success, a negative AVERROR on error. On failure, the867* packet is unchanged.868*/869int av_packet_make_refcounted(AVPacket *pkt);870871/**872* Create a writable reference for the data described by a given packet,873* avoiding data copy if possible.874*875* @param pkt Packet whose data should be made writable.876*877* @return 0 on success, a negative AVERROR on failure. On failure, the878* packet is unchanged.879*/880int av_packet_make_writable(AVPacket *pkt);881882/**883* Convert valid timing fields (timestamps / durations) in a packet from one884* timebase to another. Timestamps with unknown values (AV_NOPTS_VALUE) will be885* ignored.886*887* @param pkt packet on which the conversion will be performed888* @param tb_src source timebase, in which the timing fields in pkt are889* expressed890* @param tb_dst destination timebase, to which the timing fields will be891* converted892*/893void av_packet_rescale_ts(AVPacket *pkt, AVRational tb_src, AVRational tb_dst);894895/**896* Allocate an AVContainerFifo instance for AVPacket.897*898* @param flags currently unused899*/900struct AVContainerFifo *av_container_fifo_alloc_avpacket(unsigned flags);901902/**903* @}904*/905906#endif // AVCODEC_PACKET_H907908909