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