tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

packet.h (22941B)


      1 /*
      2 * AVPacket public API
      3 *
      4 * This file is part of FFmpeg.
      5 *
      6 * FFmpeg is free software; you can redistribute it and/or
      7 * modify it under the terms of the GNU Lesser General Public
      8 * License as published by the Free Software Foundation; either
      9 * version 2.1 of the License, or (at your option) any later version.
     10 *
     11 * FFmpeg is distributed in the hope that it will be useful,
     12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
     13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
     14 * Lesser General Public License for more details.
     15 *
     16 * You should have received a copy of the GNU Lesser General Public
     17 * License along with FFmpeg; if not, write to the Free Software
     18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
     19 */
     20 
     21 #ifndef AVCODEC_PACKET_H
     22 #define AVCODEC_PACKET_H
     23 
     24 #include <stddef.h>
     25 #include <stdint.h>
     26 
     27 #include "libavutil/attributes.h"
     28 #include "libavutil/buffer.h"
     29 #include "libavutil/dict.h"
     30 #include "libavutil/rational.h"
     31 
     32 #include "libavcodec/version.h"
     33 
     34 /**
     35 * @defgroup lavc_packet AVPacket
     36 *
     37 * Types and functions for working with AVPacket.
     38 * @{
     39 */
     40 enum AVPacketSideDataType {
     41  /**
     42   * An AV_PKT_DATA_PALETTE side data packet contains exactly AVPALETTE_SIZE
     43   * bytes worth of palette. This side data signals that a new palette is
     44   * present.
     45   */
     46  AV_PKT_DATA_PALETTE,
     47 
     48  /**
     49   * The AV_PKT_DATA_NEW_EXTRADATA is used to notify the codec or the format
     50   * that the extradata buffer was changed and the receiving side should
     51   * act upon it appropriately. The new extradata is embedded in the side
     52   * data buffer and should be immediately used for processing the current
     53   * frame or packet.
     54   */
     55  AV_PKT_DATA_NEW_EXTRADATA,
     56 
     57  /**
     58   * An AV_PKT_DATA_PARAM_CHANGE side data packet is laid out as follows:
     59   * @code
     60   * u32le param_flags
     61   * if (param_flags & AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_COUNT)
     62   *     s32le channel_count
     63   * if (param_flags & AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_LAYOUT)
     64   *     u64le channel_layout
     65   * if (param_flags & AV_SIDE_DATA_PARAM_CHANGE_SAMPLE_RATE)
     66   *     s32le sample_rate
     67   * if (param_flags & AV_SIDE_DATA_PARAM_CHANGE_DIMENSIONS)
     68   *     s32le width
     69   *     s32le height
     70   * @endcode
     71   */
     72  AV_PKT_DATA_PARAM_CHANGE,
     73 
     74  /**
     75   * An AV_PKT_DATA_H263_MB_INFO side data packet contains a number of
     76   * structures with info about macroblocks relevant to splitting the
     77   * packet into smaller packets on macroblock edges (e.g. as for RFC 2190).
     78   * That is, it does not necessarily contain info about all macroblocks,
     79   * as long as the distance between macroblocks in the info is smaller
     80   * than the target payload size.
     81   * Each MB info structure is 12 bytes, and is laid out as follows:
     82   * @code
     83   * u32le bit offset from the start of the packet
     84   * u8    current quantizer at the start of the macroblock
     85   * u8    GOB number
     86   * u16le macroblock address within the GOB
     87   * u8    horizontal MV predictor
     88   * u8    vertical MV predictor
     89   * u8    horizontal MV predictor for block number 3
     90   * u8    vertical MV predictor for block number 3
     91   * @endcode
     92   */
     93  AV_PKT_DATA_H263_MB_INFO,
     94 
     95  /**
     96   * This side data should be associated with an audio stream and contains
     97   * ReplayGain information in form of the AVReplayGain struct.
     98   */
     99  AV_PKT_DATA_REPLAYGAIN,
    100 
    101  /**
    102   * This side data contains a 3x3 transformation matrix describing an affine
    103   * transformation that needs to be applied to the decoded video frames for
    104   * correct presentation.
    105   *
    106   * See libavutil/display.h for a detailed description of the data.
    107   */
    108  AV_PKT_DATA_DISPLAYMATRIX,
    109 
    110  /**
    111   * This side data should be associated with a video stream and contains
    112   * Stereoscopic 3D information in form of the AVStereo3D struct.
    113   */
    114  AV_PKT_DATA_STEREO3D,
    115 
    116  /**
    117   * This side data should be associated with an audio stream and corresponds
    118   * to enum AVAudioServiceType.
    119   */
    120  AV_PKT_DATA_AUDIO_SERVICE_TYPE,
    121 
    122  /**
    123   * This side data contains quality related information from the encoder.
    124   * @code
    125   * u32le quality factor of the compressed frame. Allowed range is between 1
    126   * (good) and FF_LAMBDA_MAX (bad). u8    picture type u8    error count u16
    127   * reserved u64le[error count] sum of squared differences between encoder in
    128   * and output
    129   * @endcode
    130   */
    131  AV_PKT_DATA_QUALITY_STATS,
    132 
    133  /**
    134   * This side data contains an integer value representing the stream index
    135   * of a "fallback" track.  A fallback track indicates an alternate
    136   * track to use when the current track can not be decoded for some reason.
    137   * e.g. no decoder available for codec.
    138   */
    139  AV_PKT_DATA_FALLBACK_TRACK,
    140 
    141  /**
    142   * This side data corresponds to the AVCPBProperties struct.
    143   */
    144  AV_PKT_DATA_CPB_PROPERTIES,
    145 
    146  /**
    147   * Recommmends skipping the specified number of samples
    148   * @code
    149   * u32le number of samples to skip from start of this packet
    150   * u32le number of samples to skip from end of this packet
    151   * u8    reason for start skip
    152   * u8    reason for end   skip (0=padding silence, 1=convergence)
    153   * @endcode
    154   */
    155  AV_PKT_DATA_SKIP_SAMPLES,
    156 
    157  /**
    158   * An AV_PKT_DATA_JP_DUALMONO side data packet indicates that
    159   * the packet may contain "dual mono" audio specific to Japanese DTV
    160   * and if it is true, recommends only the selected channel to be used.
    161   * @code
    162   * u8    selected channels (0=mail/left, 1=sub/right, 2=both)
    163   * @endcode
    164   */
    165  AV_PKT_DATA_JP_DUALMONO,
    166 
    167  /**
    168   * A list of zero terminated key/value strings. There is no end marker for
    169   * the list, so it is required to rely on the side data size to stop.
    170   */
    171  AV_PKT_DATA_STRINGS_METADATA,
    172 
    173  /**
    174   * Subtitle event position
    175   * @code
    176   * u32le x1
    177   * u32le y1
    178   * u32le x2
    179   * u32le y2
    180   * @endcode
    181   */
    182  AV_PKT_DATA_SUBTITLE_POSITION,
    183 
    184  /**
    185   * Data found in BlockAdditional element of matroska container. There is
    186   * no end marker for the data, so it is required to rely on the side data
    187   * size to recognize the end. 8 byte id (as found in BlockAddId) followed
    188   * by data.
    189   */
    190  AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL,
    191 
    192  /**
    193   * The optional first identifier line of a WebVTT cue.
    194   */
    195  AV_PKT_DATA_WEBVTT_IDENTIFIER,
    196 
    197  /**
    198   * The optional settings (rendering instructions) that immediately
    199   * follow the timestamp specifier of a WebVTT cue.
    200   */
    201  AV_PKT_DATA_WEBVTT_SETTINGS,
    202 
    203  /**
    204   * A list of zero terminated key/value strings. There is no end marker for
    205   * the list, so it is required to rely on the side data size to stop. This
    206   * side data includes updated metadata which appeared in the stream.
    207   */
    208  AV_PKT_DATA_METADATA_UPDATE,
    209 
    210  /**
    211   * MPEGTS stream ID as uint8_t, this is required to pass the stream ID
    212   * information from the demuxer to the corresponding muxer.
    213   */
    214  AV_PKT_DATA_MPEGTS_STREAM_ID,
    215 
    216  /**
    217   * Mastering display metadata (based on SMPTE-2086:2014). This metadata
    218   * should be associated with a video stream and contains data in the form
    219   * of the AVMasteringDisplayMetadata struct.
    220   */
    221  AV_PKT_DATA_MASTERING_DISPLAY_METADATA,
    222 
    223  /**
    224   * This side data should be associated with a video stream and corresponds
    225   * to the AVSphericalMapping structure.
    226   */
    227  AV_PKT_DATA_SPHERICAL,
    228 
    229  /**
    230   * Content light level (based on CTA-861.3). This metadata should be
    231   * associated with a video stream and contains data in the form of the
    232   * AVContentLightMetadata struct.
    233   */
    234  AV_PKT_DATA_CONTENT_LIGHT_LEVEL,
    235 
    236  /**
    237   * ATSC A53 Part 4 Closed Captions. This metadata should be associated with
    238   * a video stream. A53 CC bitstream is stored as uint8_t in
    239   * AVPacketSideData.data. The number of bytes of CC data is
    240   * AVPacketSideData.size.
    241   */
    242  AV_PKT_DATA_A53_CC,
    243 
    244  /**
    245   * This side data is encryption initialization data.
    246   * The format is not part of ABI, use av_encryption_init_info_* methods to
    247   * access.
    248   */
    249  AV_PKT_DATA_ENCRYPTION_INIT_INFO,
    250 
    251  /**
    252   * This side data contains encryption info for how to decrypt the packet.
    253   * The format is not part of ABI, use av_encryption_info_* methods to access.
    254   */
    255  AV_PKT_DATA_ENCRYPTION_INFO,
    256 
    257  /**
    258   * Active Format Description data consisting of a single byte as specified
    259   * in ETSI TS 101 154 using AVActiveFormatDescription enum.
    260   */
    261  AV_PKT_DATA_AFD,
    262 
    263  /**
    264   * Producer Reference Time data corresponding to the AVProducerReferenceTime
    265   * struct, usually exported by some encoders (on demand through the prft flag
    266   * set in the AVCodecContext export_side_data field).
    267   */
    268  AV_PKT_DATA_PRFT,
    269 
    270  /**
    271   * ICC profile data consisting of an opaque octet buffer following the
    272   * format described by ISO 15076-1.
    273   */
    274  AV_PKT_DATA_ICC_PROFILE,
    275 
    276  /**
    277   * DOVI configuration
    278   * ref:
    279   * dolby-vision-bitstreams-within-the-iso-base-media-file-format-v2.1.2,
    280   * section 2.2
    281   * dolby-vision-bitstreams-in-mpeg-2-transport-stream-multiplex-v1.2,
    282   * section 3.3 Tags are stored in struct AVDOVIDecoderConfigurationRecord.
    283   */
    284  AV_PKT_DATA_DOVI_CONF,
    285 
    286  /**
    287   * Timecode which conforms to SMPTE ST 12-1:2014. The data is an array of 4
    288   * uint32_t where the first uint32_t describes how many (1-3) of the other
    289   * timecodes are used. The timecode format is described in the documentation
    290   * of av_timecode_get_smpte_from_framenum() function in libavutil/timecode.h.
    291   */
    292  AV_PKT_DATA_S12M_TIMECODE,
    293 
    294  /**
    295   * HDR10+ dynamic metadata associated with a video frame. The metadata is in
    296   * the form of the AVDynamicHDRPlus struct and contains
    297   * information for color volume transform - application 4 of
    298   * SMPTE 2094-40:2016 standard.
    299   */
    300  AV_PKT_DATA_DYNAMIC_HDR10_PLUS,
    301 
    302  /**
    303   * The number of side data types.
    304   * This is not part of the public API/ABI in the sense that it may
    305   * change when new side data types are added.
    306   * This must stay the last enum value.
    307   * If its value becomes huge, some code using it
    308   * needs to be updated as it assumes it to be smaller than other limits.
    309   */
    310  AV_PKT_DATA_NB
    311 };
    312 
    313 #define AV_PKT_DATA_QUALITY_FACTOR AV_PKT_DATA_QUALITY_STATS  // DEPRECATED
    314 
    315 typedef struct AVPacketSideData {
    316  uint8_t* data;
    317  size_t size;
    318  enum AVPacketSideDataType type;
    319 } AVPacketSideData;
    320 
    321 /**
    322 * This structure stores compressed data. It is typically exported by demuxers
    323 * and then passed as input to decoders, or received as output from encoders and
    324 * then passed to muxers.
    325 *
    326 * For video, it should typically contain one compressed frame. For audio it may
    327 * contain several compressed frames. Encoders are allowed to output empty
    328 * packets, with no compressed data, containing only side data
    329 * (e.g. to update some stream parameters at the end of encoding).
    330 *
    331 * The semantics of data ownership depends on the buf field.
    332 * If it is set, the packet data is dynamically allocated and is
    333 * valid indefinitely until a call to av_packet_unref() reduces the
    334 * reference count to 0.
    335 *
    336 * If the buf field is not set av_packet_ref() would make a copy instead
    337 * of increasing the reference count.
    338 *
    339 * The side data is always allocated with av_malloc(), copied by
    340 * av_packet_ref() and freed by av_packet_unref().
    341 *
    342 * sizeof(AVPacket) being a part of the public ABI is deprecated. once
    343 * av_init_packet() is removed, new packets will only be able to be allocated
    344 * with av_packet_alloc(), and new fields may be added to the end of the struct
    345 * with a minor bump.
    346 *
    347 * @see av_packet_alloc
    348 * @see av_packet_ref
    349 * @see av_packet_unref
    350 */
    351 typedef struct AVPacket {
    352  /**
    353   * A reference to the reference-counted buffer where the packet data is
    354   * stored.
    355   * May be NULL, then the packet data is not reference-counted.
    356   */
    357  AVBufferRef* buf;
    358  /**
    359   * Presentation timestamp in AVStream->time_base units; the time at which
    360   * the decompressed packet will be presented to the user.
    361   * Can be AV_NOPTS_VALUE if it is not stored in the file.
    362   * pts MUST be larger or equal to dts as presentation cannot happen before
    363   * decompression, unless one wants to view hex dumps. Some formats misuse
    364   * the terms dts and pts/cts to mean something different. Such timestamps
    365   * must be converted to true pts/dts before they are stored in AVPacket.
    366   */
    367  int64_t pts;
    368  /**
    369   * Decompression timestamp in AVStream->time_base units; the time at which
    370   * the packet is decompressed.
    371   * Can be AV_NOPTS_VALUE if it is not stored in the file.
    372   */
    373  int64_t dts;
    374  uint8_t* data;
    375  int size;
    376  int stream_index;
    377  /**
    378   * A combination of AV_PKT_FLAG values
    379   */
    380  int flags;
    381  /**
    382   * Additional packet data that can be provided by the container.
    383   * Packet can contain several types of side information.
    384   */
    385  AVPacketSideData* side_data;
    386  int side_data_elems;
    387 
    388  /**
    389   * Duration of this packet in AVStream->time_base units, 0 if unknown.
    390   * Equals next_pts - this_pts in presentation order.
    391   */
    392  int64_t duration;
    393 
    394  int64_t pos;  ///< byte position in stream, -1 if unknown
    395 
    396  /**
    397   * for some private data of the user
    398   */
    399  void* opaque;
    400 
    401  /**
    402   * AVBufferRef for free use by the API user. FFmpeg will never check the
    403   * contents of the buffer ref. FFmpeg calls av_buffer_unref() on it when
    404   * the packet is unreferenced. av_packet_copy_props() calls create a new
    405   * reference with av_buffer_ref() for the target packet's opaque_ref field.
    406   *
    407   * This is unrelated to the opaque field, although it serves a similar
    408   * purpose.
    409   */
    410  AVBufferRef* opaque_ref;
    411 
    412  /**
    413   * Time base of the packet's timestamps.
    414   * In the future, this field may be set on packets output by encoders or
    415   * demuxers, but its value will be by default ignored on input to decoders
    416   * or muxers.
    417   */
    418  AVRational time_base;
    419 } AVPacket;
    420 
    421 #if FF_API_INIT_PACKET
    422 attribute_deprecated typedef struct AVPacketList {
    423  AVPacket pkt;
    424  struct AVPacketList* next;
    425 } AVPacketList;
    426 #endif
    427 
    428 #define AV_PKT_FLAG_KEY 0x0001      ///< The packet contains a keyframe
    429 #define AV_PKT_FLAG_CORRUPT 0x0002  ///< The packet content is corrupted
    430 /**
    431 * Flag is used to discard packets which are required to maintain valid
    432 * decoder state but are not required for output and should be dropped
    433 * after decoding.
    434 **/
    435 #define AV_PKT_FLAG_DISCARD 0x0004
    436 /**
    437 * The packet comes from a trusted source.
    438 *
    439 * Otherwise-unsafe constructs such as arbitrary pointers to data
    440 * outside the packet may be followed.
    441 */
    442 #define AV_PKT_FLAG_TRUSTED 0x0008
    443 /**
    444 * Flag is used to indicate packets that contain frames that can
    445 * be discarded by the decoder.  I.e. Non-reference frames.
    446 */
    447 #define AV_PKT_FLAG_DISPOSABLE 0x0010
    448 
    449 enum AVSideDataParamChangeFlags {
    450  AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_COUNT = 0x0001,
    451  AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_LAYOUT = 0x0002,
    452  AV_SIDE_DATA_PARAM_CHANGE_SAMPLE_RATE = 0x0004,
    453  AV_SIDE_DATA_PARAM_CHANGE_DIMENSIONS = 0x0008,
    454 };
    455 
    456 /**
    457 * Allocate an AVPacket and set its fields to default values.  The resulting
    458 * struct must be freed using av_packet_free().
    459 *
    460 * @return An AVPacket filled with default values or NULL on failure.
    461 *
    462 * @note this only allocates the AVPacket itself, not the data buffers. Those
    463 * must be allocated through other means such as av_new_packet.
    464 *
    465 * @see av_new_packet
    466 */
    467 AVPacket* av_packet_alloc(void);
    468 
    469 /**
    470 * Create a new packet that references the same data as src.
    471 *
    472 * This is a shortcut for av_packet_alloc()+av_packet_ref().
    473 *
    474 * @return newly created AVPacket on success, NULL on error.
    475 *
    476 * @see av_packet_alloc
    477 * @see av_packet_ref
    478 */
    479 AVPacket* av_packet_clone(const AVPacket* src);
    480 
    481 /**
    482 * Free the packet, if the packet is reference counted, it will be
    483 * unreferenced first.
    484 *
    485 * @param pkt packet to be freed. The pointer will be set to NULL.
    486 * @note passing NULL is a no-op.
    487 */
    488 void av_packet_free(AVPacket** pkt);
    489 
    490 #if FF_API_INIT_PACKET
    491 /**
    492 * Initialize optional fields of a packet with default values.
    493 *
    494 * Note, this does not touch the data and size members, which have to be
    495 * initialized separately.
    496 *
    497 * @param pkt packet
    498 *
    499 * @see av_packet_alloc
    500 * @see av_packet_unref
    501 *
    502 * @deprecated This function is deprecated. Once it's removed,
    503               sizeof(AVPacket) will not be a part of the ABI anymore.
    504 */
    505 attribute_deprecated void av_init_packet(AVPacket* pkt);
    506 #endif
    507 
    508 /**
    509 * Allocate the payload of a packet and initialize its fields with
    510 * default values.
    511 *
    512 * @param pkt packet
    513 * @param size wanted payload size
    514 * @return 0 if OK, AVERROR_xxx otherwise
    515 */
    516 int av_new_packet(AVPacket* pkt, int size);
    517 
    518 /**
    519 * Reduce packet size, correctly zeroing padding
    520 *
    521 * @param pkt packet
    522 * @param size new size
    523 */
    524 void av_shrink_packet(AVPacket* pkt, int size);
    525 
    526 /**
    527 * Increase packet size, correctly zeroing padding
    528 *
    529 * @param pkt packet
    530 * @param grow_by number of bytes by which to increase the size of the packet
    531 */
    532 int av_grow_packet(AVPacket* pkt, int grow_by);
    533 
    534 /**
    535 * Initialize a reference-counted packet from av_malloc()ed data.
    536 *
    537 * @param pkt packet to be initialized. This function will set the data, size,
    538 *        and buf fields, all others are left untouched.
    539 * @param data Data allocated by av_malloc() to be used as packet data. If this
    540 *        function returns successfully, the data is owned by the underlying
    541 * AVBuffer. The caller may not access the data through other means.
    542 * @param size size of data in bytes, without the padding. I.e. the full buffer
    543 *        size is assumed to be size + AV_INPUT_BUFFER_PADDING_SIZE.
    544 *
    545 * @return 0 on success, a negative AVERROR on error
    546 */
    547 int av_packet_from_data(AVPacket* pkt, uint8_t* data, int size);
    548 
    549 /**
    550 * Allocate new information of a packet.
    551 *
    552 * @param pkt packet
    553 * @param type side information type
    554 * @param size side information size
    555 * @return pointer to fresh allocated data or NULL otherwise
    556 */
    557 uint8_t* av_packet_new_side_data(AVPacket* pkt, enum AVPacketSideDataType type,
    558                                 size_t size);
    559 
    560 /**
    561 * Wrap an existing array as a packet side data.
    562 *
    563 * @param pkt packet
    564 * @param type side information type
    565 * @param data the side data array. It must be allocated with the av_malloc()
    566 *             family of functions. The ownership of the data is transferred to
    567 *             pkt.
    568 * @param size side information size
    569 * @return a non-negative number on success, a negative AVERROR code on
    570 *         failure. On failure, the packet is unchanged and the data remains
    571 *         owned by the caller.
    572 */
    573 int av_packet_add_side_data(AVPacket* pkt, enum AVPacketSideDataType type,
    574                            uint8_t* data, size_t size);
    575 
    576 /**
    577 * Shrink the already allocated side data buffer
    578 *
    579 * @param pkt packet
    580 * @param type side information type
    581 * @param size new side information size
    582 * @return 0 on success, < 0 on failure
    583 */
    584 int av_packet_shrink_side_data(AVPacket* pkt, enum AVPacketSideDataType type,
    585                               size_t size);
    586 
    587 /**
    588 * Get side information from packet.
    589 *
    590 * @param pkt packet
    591 * @param type desired side information type
    592 * @param size If supplied, *size will be set to the size of the side data
    593 *             or to zero if the desired side data is not present.
    594 * @return pointer to data if present or NULL otherwise
    595 */
    596 uint8_t* av_packet_get_side_data(const AVPacket* pkt,
    597                                 enum AVPacketSideDataType type, size_t* size);
    598 
    599 const char* av_packet_side_data_name(enum AVPacketSideDataType type);
    600 
    601 /**
    602 * Pack a dictionary for use in side_data.
    603 *
    604 * @param dict The dictionary to pack.
    605 * @param size pointer to store the size of the returned data
    606 * @return pointer to data if successful, NULL otherwise
    607 */
    608 uint8_t* av_packet_pack_dictionary(AVDictionary* dict, size_t* size);
    609 /**
    610 * Unpack a dictionary from side_data.
    611 *
    612 * @param data data from side_data
    613 * @param size size of the data
    614 * @param dict the metadata storage dictionary
    615 * @return 0 on success, < 0 on failure
    616 */
    617 int av_packet_unpack_dictionary(const uint8_t* data, size_t size,
    618                                AVDictionary** dict);
    619 
    620 /**
    621 * Convenience function to free all the side data stored.
    622 * All the other fields stay untouched.
    623 *
    624 * @param pkt packet
    625 */
    626 void av_packet_free_side_data(AVPacket* pkt);
    627 
    628 /**
    629 * Setup a new reference to the data described by a given packet
    630 *
    631 * If src is reference-counted, setup dst as a new reference to the
    632 * buffer in src. Otherwise allocate a new buffer in dst and copy the
    633 * data from src into it.
    634 *
    635 * All the other fields are copied from src.
    636 *
    637 * @see av_packet_unref
    638 *
    639 * @param dst Destination packet. Will be completely overwritten.
    640 * @param src Source packet
    641 *
    642 * @return 0 on success, a negative AVERROR on error. On error, dst
    643 *         will be blank (as if returned by av_packet_alloc()).
    644 */
    645 int av_packet_ref(AVPacket* dst, const AVPacket* src);
    646 
    647 /**
    648 * Wipe the packet.
    649 *
    650 * Unreference the buffer referenced by the packet and reset the
    651 * remaining packet fields to their default values.
    652 *
    653 * @param pkt The packet to be unreferenced.
    654 */
    655 void av_packet_unref(AVPacket* pkt);
    656 
    657 /**
    658 * Move every field in src to dst and reset src.
    659 *
    660 * @see av_packet_unref
    661 *
    662 * @param src Source packet, will be reset
    663 * @param dst Destination packet
    664 */
    665 void av_packet_move_ref(AVPacket* dst, AVPacket* src);
    666 
    667 /**
    668 * Copy only "properties" fields from src to dst.
    669 *
    670 * Properties for the purpose of this function are all the fields
    671 * beside those related to the packet data (buf, data, size)
    672 *
    673 * @param dst Destination packet
    674 * @param src Source packet
    675 *
    676 * @return 0 on success AVERROR on failure.
    677 */
    678 int av_packet_copy_props(AVPacket* dst, const AVPacket* src);
    679 
    680 /**
    681 * Ensure the data described by a given packet is reference counted.
    682 *
    683 * @note This function does not ensure that the reference will be writable.
    684 *       Use av_packet_make_writable instead for that purpose.
    685 *
    686 * @see av_packet_ref
    687 * @see av_packet_make_writable
    688 *
    689 * @param pkt packet whose data should be made reference counted.
    690 *
    691 * @return 0 on success, a negative AVERROR on error. On failure, the
    692 *         packet is unchanged.
    693 */
    694 int av_packet_make_refcounted(AVPacket* pkt);
    695 
    696 /**
    697 * Create a writable reference for the data described by a given packet,
    698 * avoiding data copy if possible.
    699 *
    700 * @param pkt Packet whose data should be made writable.
    701 *
    702 * @return 0 on success, a negative AVERROR on failure. On failure, the
    703 *         packet is unchanged.
    704 */
    705 int av_packet_make_writable(AVPacket* pkt);
    706 
    707 /**
    708 * Convert valid timing fields (timestamps / durations) in a packet from one
    709 * timebase to another. Timestamps with unknown values (AV_NOPTS_VALUE) will be
    710 * ignored.
    711 *
    712 * @param pkt packet on which the conversion will be performed
    713 * @param tb_src source timebase, in which the timing fields in pkt are
    714 *               expressed
    715 * @param tb_dst destination timebase, to which the timing fields will be
    716 *               converted
    717 */
    718 void av_packet_rescale_ts(AVPacket* pkt, AVRational tb_src, AVRational tb_dst);
    719 
    720 /**
    721 * @}
    722 */
    723 
    724 #endif  // AVCODEC_PACKET_H