You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

732 lines
23KB

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