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