Path: blob/master/dep/ffmpeg/include/libavcodec/packet.h
4216 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* Recommmends 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* The number of side data types.349* This is not part of the public API/ABI in the sense that it may350* change when new side data types are added.351* This must stay the last enum value.352* If its value becomes huge, some code using it353* needs to be updated as it assumes it to be smaller than other limits.354*/355AV_PKT_DATA_NB356};357358#if FF_API_QUALITY_FACTOR359#define AV_PKT_DATA_QUALITY_FACTOR AV_PKT_DATA_QUALITY_STATS //DEPRECATED360#endif361362/**363* This structure stores auxiliary information for decoding, presenting, or364* otherwise processing the coded stream. It is typically exported by demuxers365* and encoders and can be fed to decoders and muxers either in a per packet366* basis, or as global side data (applying to the entire coded stream).367*368* Global side data is handled as follows:369* - During demuxing, it may be exported through370* @ref AVStream.codecpar.side_data "AVStream's codec parameters", which can371* then be passed as input to decoders through the372* @ref AVCodecContext.coded_side_data "decoder context's side data", for373* initialization.374* - For muxing, it can be fed through @ref AVStream.codecpar.side_data375* "AVStream's codec parameters", typically the output of encoders through376* the @ref AVCodecContext.coded_side_data "encoder context's side data", for377* initialization.378*379* Packet specific side data is handled as follows:380* - During demuxing, it may be exported through @ref AVPacket.side_data381* "AVPacket's side data", which can then be passed as input to decoders.382* - For muxing, it can be fed through @ref AVPacket.side_data "AVPacket's383* side data", typically the output of encoders.384*385* Different modules may accept or export different types of side data386* depending on media type and codec. Refer to @ref AVPacketSideDataType for a387* list of defined types and where they may be found or used.388*/389typedef struct AVPacketSideData {390uint8_t *data;391size_t size;392enum AVPacketSideDataType type;393} AVPacketSideData;394395/**396* Allocate a new packet side data.397*398* @param sd pointer to an array of side data to which the side data should399* be added. *sd may be NULL, in which case the array will be400* initialized.401* @param nb_sd pointer to an integer containing the number of entries in402* the array. The integer value will be increased by 1 on success.403* @param type side data type404* @param size desired side data size405* @param flags currently unused. Must be zero406*407* @return pointer to freshly allocated side data on success, or NULL otherwise.408*/409AVPacketSideData *av_packet_side_data_new(AVPacketSideData **psd, int *pnb_sd,410enum AVPacketSideDataType type,411size_t size, int flags);412413/**414* Wrap existing data as packet side data.415*416* @param sd pointer to an array of side data to which the side data should417* be added. *sd may be NULL, in which case the array will be418* initialized419* @param nb_sd pointer to an integer containing the number of entries in420* the array. The integer value will be increased by 1 on success.421* @param type side data type422* @param data a data array. It must be allocated with the av_malloc() family423* of functions. The ownership of the data is transferred to the424* side data array on success425* @param size size of the data array426* @param flags currently unused. Must be zero427*428* @return pointer to freshly allocated side data on success, or NULL otherwise429* On failure, the side data array is unchanged and the data remains430* owned by the caller.431*/432AVPacketSideData *av_packet_side_data_add(AVPacketSideData **sd, int *nb_sd,433enum AVPacketSideDataType type,434void *data, size_t size, int flags);435436/**437* Get side information from a side data array.438*439* @param sd the array from which the side data should be fetched440* @param nb_sd value containing the number of entries in the array.441* @param type desired side information type442*443* @return pointer to side data if present or NULL otherwise444*/445const AVPacketSideData *av_packet_side_data_get(const AVPacketSideData *sd,446int nb_sd,447enum AVPacketSideDataType type);448449/**450* Remove side data of the given type from a side data array.451*452* @param sd the array from which the side data should be removed453* @param nb_sd pointer to an integer containing the number of entries in454* the array. Will be reduced by the amount of entries removed455* upon return456* @param type side information type457*/458void av_packet_side_data_remove(AVPacketSideData *sd, int *nb_sd,459enum AVPacketSideDataType type);460461/**462* Convenience function to free all the side data stored in an array, and463* the array itself.464*465* @param sd pointer to array of side data to free. Will be set to NULL466* upon return.467* @param nb_sd pointer to an integer containing the number of entries in468* the array. Will be set to 0 upon return.469*/470void av_packet_side_data_free(AVPacketSideData **sd, int *nb_sd);471472const char *av_packet_side_data_name(enum AVPacketSideDataType type);473474/**475* @}476*/477478/**479* @defgroup lavc_packet AVPacket480*481* Types and functions for working with AVPacket.482* @{483*/484485/**486* This structure stores compressed data. It is typically exported by demuxers487* and then passed as input to decoders, or received as output from encoders and488* then passed to muxers.489*490* For video, it should typically contain one compressed frame. For audio it may491* contain several compressed frames. Encoders are allowed to output empty492* packets, with no compressed data, containing only side data493* (e.g. to update some stream parameters at the end of encoding).494*495* The semantics of data ownership depends on the buf field.496* If it is set, the packet data is dynamically allocated and is497* valid indefinitely until a call to av_packet_unref() reduces the498* reference count to 0.499*500* If the buf field is not set av_packet_ref() would make a copy instead501* of increasing the reference count.502*503* The side data is always allocated with av_malloc(), copied by504* av_packet_ref() and freed by av_packet_unref().505*506* sizeof(AVPacket) being a part of the public ABI is deprecated. once507* av_init_packet() is removed, new packets will only be able to be allocated508* with av_packet_alloc(), and new fields may be added to the end of the struct509* with a minor bump.510*511* @see av_packet_alloc512* @see av_packet_ref513* @see av_packet_unref514*/515typedef struct AVPacket {516/**517* A reference to the reference-counted buffer where the packet data is518* stored.519* May be NULL, then the packet data is not reference-counted.520*/521AVBufferRef *buf;522/**523* Presentation timestamp in AVStream->time_base units; the time at which524* the decompressed packet will be presented to the user.525* Can be AV_NOPTS_VALUE if it is not stored in the file.526* pts MUST be larger or equal to dts as presentation cannot happen before527* decompression, unless one wants to view hex dumps. Some formats misuse528* the terms dts and pts/cts to mean something different. Such timestamps529* must be converted to true pts/dts before they are stored in AVPacket.530*/531int64_t pts;532/**533* Decompression timestamp in AVStream->time_base units; the time at which534* the packet is decompressed.535* Can be AV_NOPTS_VALUE if it is not stored in the file.536*/537int64_t dts;538uint8_t *data;539int size;540int stream_index;541/**542* A combination of AV_PKT_FLAG values543*/544int flags;545/**546* Additional packet data that can be provided by the container.547* Packet can contain several types of side information.548*/549AVPacketSideData *side_data;550int side_data_elems;551552/**553* Duration of this packet in AVStream->time_base units, 0 if unknown.554* Equals next_pts - this_pts in presentation order.555*/556int64_t duration;557558int64_t pos; ///< byte position in stream, -1 if unknown559560/**561* for some private data of the user562*/563void *opaque;564565/**566* AVBufferRef for free use by the API user. FFmpeg will never check the567* contents of the buffer ref. FFmpeg calls av_buffer_unref() on it when568* the packet is unreferenced. av_packet_copy_props() calls create a new569* reference with av_buffer_ref() for the target packet's opaque_ref field.570*571* This is unrelated to the opaque field, although it serves a similar572* purpose.573*/574AVBufferRef *opaque_ref;575576/**577* Time base of the packet's timestamps.578* In the future, this field may be set on packets output by encoders or579* demuxers, but its value will be by default ignored on input to decoders580* or muxers.581*/582AVRational time_base;583} AVPacket;584585#if FF_API_INIT_PACKET586attribute_deprecated587typedef struct AVPacketList {588AVPacket pkt;589struct AVPacketList *next;590} AVPacketList;591#endif592593#define AV_PKT_FLAG_KEY 0x0001 ///< The packet contains a keyframe594#define AV_PKT_FLAG_CORRUPT 0x0002 ///< The packet content is corrupted595/**596* Flag is used to discard packets which are required to maintain valid597* decoder state but are not required for output and should be dropped598* after decoding.599**/600#define AV_PKT_FLAG_DISCARD 0x0004601/**602* The packet comes from a trusted source.603*604* Otherwise-unsafe constructs such as arbitrary pointers to data605* outside the packet may be followed.606*/607#define AV_PKT_FLAG_TRUSTED 0x0008608/**609* Flag is used to indicate packets that contain frames that can610* be discarded by the decoder. I.e. Non-reference frames.611*/612#define AV_PKT_FLAG_DISPOSABLE 0x0010613614enum AVSideDataParamChangeFlags {615AV_SIDE_DATA_PARAM_CHANGE_SAMPLE_RATE = 0x0004,616AV_SIDE_DATA_PARAM_CHANGE_DIMENSIONS = 0x0008,617};618619/**620* Allocate an AVPacket and set its fields to default values. The resulting621* struct must be freed using av_packet_free().622*623* @return An AVPacket filled with default values or NULL on failure.624*625* @note this only allocates the AVPacket itself, not the data buffers. Those626* must be allocated through other means such as av_new_packet.627*628* @see av_new_packet629*/630AVPacket *av_packet_alloc(void);631632/**633* Create a new packet that references the same data as src.634*635* This is a shortcut for av_packet_alloc()+av_packet_ref().636*637* @return newly created AVPacket on success, NULL on error.638*639* @see av_packet_alloc640* @see av_packet_ref641*/642AVPacket *av_packet_clone(const AVPacket *src);643644/**645* Free the packet, if the packet is reference counted, it will be646* unreferenced first.647*648* @param pkt packet to be freed. The pointer will be set to NULL.649* @note passing NULL is a no-op.650*/651void av_packet_free(AVPacket **pkt);652653#if FF_API_INIT_PACKET654/**655* Initialize optional fields of a packet with default values.656*657* Note, this does not touch the data and size members, which have to be658* initialized separately.659*660* @param pkt packet661*662* @see av_packet_alloc663* @see av_packet_unref664*665* @deprecated This function is deprecated. Once it's removed,666sizeof(AVPacket) will not be a part of the ABI anymore.667*/668attribute_deprecated669void av_init_packet(AVPacket *pkt);670#endif671672/**673* Allocate the payload of a packet and initialize its fields with674* default values.675*676* @param pkt packet677* @param size wanted payload size678* @return 0 if OK, AVERROR_xxx otherwise679*/680int av_new_packet(AVPacket *pkt, int size);681682/**683* Reduce packet size, correctly zeroing padding684*685* @param pkt packet686* @param size new size687*/688void av_shrink_packet(AVPacket *pkt, int size);689690/**691* Increase packet size, correctly zeroing padding692*693* @param pkt packet694* @param grow_by number of bytes by which to increase the size of the packet695*/696int av_grow_packet(AVPacket *pkt, int grow_by);697698/**699* Initialize a reference-counted packet from av_malloc()ed data.700*701* @param pkt packet to be initialized. This function will set the data, size,702* and buf fields, all others are left untouched.703* @param data Data allocated by av_malloc() to be used as packet data. If this704* function returns successfully, the data is owned by the underlying AVBuffer.705* The caller may not access the data through other means.706* @param size size of data in bytes, without the padding. I.e. the full buffer707* size is assumed to be size + AV_INPUT_BUFFER_PADDING_SIZE.708*709* @return 0 on success, a negative AVERROR on error710*/711int av_packet_from_data(AVPacket *pkt, uint8_t *data, int size);712713/**714* Allocate new information of a packet.715*716* @param pkt packet717* @param type side information type718* @param size side information size719* @return pointer to fresh allocated data or NULL otherwise720*/721uint8_t* av_packet_new_side_data(AVPacket *pkt, enum AVPacketSideDataType type,722size_t size);723724/**725* Wrap an existing array as a packet side data.726*727* @param pkt packet728* @param type side information type729* @param data the side data array. It must be allocated with the av_malloc()730* family of functions. The ownership of the data is transferred to731* pkt.732* @param size side information size733* @return a non-negative number on success, a negative AVERROR code on734* failure. On failure, the packet is unchanged and the data remains735* owned by the caller.736*/737int av_packet_add_side_data(AVPacket *pkt, enum AVPacketSideDataType type,738uint8_t *data, size_t size);739740/**741* Shrink the already allocated side data buffer742*743* @param pkt packet744* @param type side information type745* @param size new side information size746* @return 0 on success, < 0 on failure747*/748int av_packet_shrink_side_data(AVPacket *pkt, enum AVPacketSideDataType type,749size_t size);750751/**752* Get side information from packet.753*754* @param pkt packet755* @param type desired side information type756* @param size If supplied, *size will be set to the size of the side data757* or to zero if the desired side data is not present.758* @return pointer to data if present or NULL otherwise759*/760uint8_t* av_packet_get_side_data(const AVPacket *pkt, enum AVPacketSideDataType type,761size_t *size);762763/**764* Pack a dictionary for use in side_data.765*766* @param dict The dictionary to pack.767* @param size pointer to store the size of the returned data768* @return pointer to data if successful, NULL otherwise769*/770uint8_t *av_packet_pack_dictionary(AVDictionary *dict, size_t *size);771/**772* Unpack a dictionary from side_data.773*774* @param data data from side_data775* @param size size of the data776* @param dict the metadata storage dictionary777* @return 0 on success, < 0 on failure778*/779int av_packet_unpack_dictionary(const uint8_t *data, size_t size,780AVDictionary **dict);781782/**783* Convenience function to free all the side data stored.784* All the other fields stay untouched.785*786* @param pkt packet787*/788void av_packet_free_side_data(AVPacket *pkt);789790/**791* Setup a new reference to the data described by a given packet792*793* If src is reference-counted, setup dst as a new reference to the794* buffer in src. Otherwise allocate a new buffer in dst and copy the795* data from src into it.796*797* All the other fields are copied from src.798*799* @see av_packet_unref800*801* @param dst Destination packet. Will be completely overwritten.802* @param src Source packet803*804* @return 0 on success, a negative AVERROR on error. On error, dst805* will be blank (as if returned by av_packet_alloc()).806*/807int av_packet_ref(AVPacket *dst, const AVPacket *src);808809/**810* Wipe the packet.811*812* Unreference the buffer referenced by the packet and reset the813* remaining packet fields to their default values.814*815* @param pkt The packet to be unreferenced.816*/817void av_packet_unref(AVPacket *pkt);818819/**820* Move every field in src to dst and reset src.821*822* @see av_packet_unref823*824* @param src Source packet, will be reset825* @param dst Destination packet826*/827void av_packet_move_ref(AVPacket *dst, AVPacket *src);828829/**830* Copy only "properties" fields from src to dst.831*832* Properties for the purpose of this function are all the fields833* beside those related to the packet data (buf, data, size)834*835* @param dst Destination packet836* @param src Source packet837*838* @return 0 on success AVERROR on failure.839*/840int av_packet_copy_props(AVPacket *dst, const AVPacket *src);841842/**843* Ensure the data described by a given packet is reference counted.844*845* @note This function does not ensure that the reference will be writable.846* Use av_packet_make_writable instead for that purpose.847*848* @see av_packet_ref849* @see av_packet_make_writable850*851* @param pkt packet whose data should be made reference counted.852*853* @return 0 on success, a negative AVERROR on error. On failure, the854* packet is unchanged.855*/856int av_packet_make_refcounted(AVPacket *pkt);857858/**859* Create a writable reference for the data described by a given packet,860* avoiding data copy if possible.861*862* @param pkt Packet whose data should be made writable.863*864* @return 0 on success, a negative AVERROR on failure. On failure, the865* packet is unchanged.866*/867int av_packet_make_writable(AVPacket *pkt);868869/**870* Convert valid timing fields (timestamps / durations) in a packet from one871* timebase to another. Timestamps with unknown values (AV_NOPTS_VALUE) will be872* ignored.873*874* @param pkt packet on which the conversion will be performed875* @param tb_src source timebase, in which the timing fields in pkt are876* expressed877* @param tb_dst destination timebase, to which the timing fields will be878* converted879*/880void av_packet_rescale_ts(AVPacket *pkt, AVRational tb_src, AVRational tb_dst);881882/**883* @}884*/885886#endif // AVCODEC_PACKET_H887888889