FFmpeg
Loading...
Searching...
No Matches
packet.c
Go to the documentation of this file.
1/*
2 * AVPacket functions for libavcodec
3 * Copyright (c) 2000, 2001, 2002 Fabrice Bellard
4 *
5 * This file is part of FFmpeg.
6 *
7 * FFmpeg is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * FFmpeg is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with FFmpeg; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21
22#include <string.h>
23
24#include "libavutil/avassert.h"
25#include "libavutil/avutil.h"
28#include "libavutil/mem.h"
29#include "libavutil/rational.h"
30
31#include "defs.h"
32#include "packet.h"
33#include "packet_internal.h"
34
35#if FF_API_INIT_PACKET
36void av_init_packet(AVPacket *pkt)
37{
38 pkt->pts = AV_NOPTS_VALUE;
39 pkt->dts = AV_NOPTS_VALUE;
40 pkt->pos = -1;
41 pkt->duration = 0;
42 pkt->flags = 0;
43 pkt->stream_index = 0;
44 pkt->buf = NULL;
45 pkt->side_data = NULL;
46 pkt->side_data_elems = 0;
47 pkt->opaque = NULL;
48 pkt->opaque_ref = NULL;
49 pkt->time_base = av_make_q(0, 1);
50}
51#endif
52
54{
55 memset(pkt, 0, sizeof(*pkt));
56
57 pkt->pts = AV_NOPTS_VALUE;
58 pkt->dts = AV_NOPTS_VALUE;
59 pkt->pos = -1;
60 pkt->time_base = av_make_q(0, 1);
61}
62
64{
65 AVPacket *pkt = av_malloc(sizeof(AVPacket));
66 if (!pkt)
67 return pkt;
68
70
71 return pkt;
72}
73
75{
76 if (!pkt || !*pkt)
77 return;
78
81}
82
83static int packet_alloc(AVBufferRef **buf, int size)
84{
85 int ret;
87 return AVERROR(EINVAL);
88
90 if (ret < 0)
91 return ret;
92
93 memset((*buf)->data + size, 0, AV_INPUT_BUFFER_PADDING_SIZE);
94
95 return 0;
96}
97
99{
100 AVBufferRef *buf = NULL;
101 int ret = packet_alloc(&buf, size);
102 if (ret < 0)
103 return ret;
104
106 pkt->buf = buf;
107 pkt->data = buf->data;
108 pkt->size = size;
109
110 return 0;
111}
112
114{
115 if (pkt->size <= size)
116 return;
117 pkt->size = size;
118 memset(pkt->data + size, 0, AV_INPUT_BUFFER_PADDING_SIZE);
119}
120
121int av_grow_packet(AVPacket *pkt, int grow_by)
122{
123 int new_size;
124 av_assert0((unsigned)pkt->size <= INT_MAX - AV_INPUT_BUFFER_PADDING_SIZE);
125 if ((unsigned)grow_by >
126 INT_MAX - (pkt->size + AV_INPUT_BUFFER_PADDING_SIZE))
127 return AVERROR(ENOMEM);
128
129 new_size = pkt->size + grow_by + AV_INPUT_BUFFER_PADDING_SIZE;
130 if (pkt->buf) {
131 size_t data_offset;
132 uint8_t *old_data = pkt->data;
133 if (pkt->data == NULL) {
134 data_offset = 0;
135 pkt->data = pkt->buf->data;
136 } else {
137 data_offset = pkt->data - pkt->buf->data;
138 if (data_offset > INT_MAX - new_size)
139 return AVERROR(ENOMEM);
140 }
141
142 if (new_size + data_offset > pkt->buf->size ||
143 !av_buffer_is_writable(pkt->buf)) {
144 int ret;
145
146 // allocate slightly more than requested to avoid excessive
147 // reallocations
148 if (new_size + data_offset < INT_MAX - new_size/16)
149 new_size += new_size/16;
150
151 ret = av_buffer_realloc(&pkt->buf, new_size + data_offset);
152 if (ret < 0) {
153 pkt->data = old_data;
154 return ret;
155 }
156 pkt->data = pkt->buf->data + data_offset;
157 }
158 } else {
159 pkt->buf = av_buffer_alloc(new_size);
160 if (!pkt->buf)
161 return AVERROR(ENOMEM);
162 if (pkt->size > 0)
163 memcpy(pkt->buf->data, pkt->data, pkt->size);
164 pkt->data = pkt->buf->data;
165 }
166 pkt->size += grow_by;
167 memset(pkt->data + pkt->size, 0, AV_INPUT_BUFFER_PADDING_SIZE);
168
169 return 0;
170}
171
173{
174 if (size >= INT_MAX - AV_INPUT_BUFFER_PADDING_SIZE)
175 return AVERROR(EINVAL);
176
179 if (!pkt->buf)
180 return AVERROR(ENOMEM);
181
182 pkt->data = data;
183 pkt->size = size;
184
185 return 0;
186}
187
189{
190 int i;
191 for (i = 0; i < pkt->side_data_elems; i++)
192 av_freep(&pkt->side_data[i].data);
193 av_freep(&pkt->side_data);
194 pkt->side_data_elems = 0;
195}
196
198 uint8_t *data, size_t size)
199{
201 int i, elems = pkt->side_data_elems;
202
203 for (i = 0; i < elems; i++) {
204 AVPacketSideData *sd = &pkt->side_data[i];
205
206 if (sd->type == type) {
207 av_free(sd->data);
208 sd->data = data;
209 sd->size = size;
210 return 0;
211 }
212 }
213
214 if ((unsigned)elems + 1 > AV_PKT_DATA_NB)
215 return AVERROR(ERANGE);
216
217 tmp = av_realloc(pkt->side_data, (elems + 1) * sizeof(*tmp));
218 if (!tmp)
219 return AVERROR(ENOMEM);
220
221 pkt->side_data = tmp;
222 pkt->side_data[elems].data = data;
223 pkt->side_data[elems].size = size;
224 pkt->side_data[elems].type = type;
225 pkt->side_data_elems++;
226
227 return 0;
228}
229
230
232 size_t size)
233{
234 int ret;
235 uint8_t *data;
236
237 if (size > SIZE_MAX - AV_INPUT_BUFFER_PADDING_SIZE)
238 return NULL;
240 if (!data)
241 return NULL;
242
244 if (ret < 0) {
245 av_freep(&data);
246 return NULL;
247 }
248
249 return data;
250}
251
253 size_t *size)
254{
255 int i;
256
257 for (i = 0; i < pkt->side_data_elems; i++) {
258 if (pkt->side_data[i].type == type) {
259 if (size)
260 *size = pkt->side_data[i].size;
261 return pkt->side_data[i].data;
262 }
263 }
264 if (size)
265 *size = 0;
266 return NULL;
267}
268
270{
271 switch(type) {
272 case AV_PKT_DATA_PALETTE: return "Palette";
273 case AV_PKT_DATA_NEW_EXTRADATA: return "New Extradata";
274 case AV_PKT_DATA_PARAM_CHANGE: return "Param Change";
275 case AV_PKT_DATA_H263_MB_INFO: return "H263 MB Info";
276 case AV_PKT_DATA_REPLAYGAIN: return "Replay Gain";
277 case AV_PKT_DATA_DISPLAYMATRIX: return "Display Matrix";
278 case AV_PKT_DATA_STEREO3D: return "Stereo 3D";
279 case AV_PKT_DATA_AUDIO_SERVICE_TYPE: return "Audio Service Type";
280 case AV_PKT_DATA_QUALITY_STATS: return "Quality stats";
281 case AV_PKT_DATA_FALLBACK_TRACK: return "Fallback track";
282 case AV_PKT_DATA_CPB_PROPERTIES: return "CPB properties";
283 case AV_PKT_DATA_SKIP_SAMPLES: return "Skip Samples";
284 case AV_PKT_DATA_JP_DUALMONO: return "JP Dual Mono";
285 case AV_PKT_DATA_STRINGS_METADATA: return "Strings Metadata";
286 case AV_PKT_DATA_SUBTITLE_POSITION: return "Subtitle Position";
287 case AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL: return "Matroska BlockAdditional";
288 case AV_PKT_DATA_WEBVTT_IDENTIFIER: return "WebVTT ID";
289 case AV_PKT_DATA_WEBVTT_SETTINGS: return "WebVTT Settings";
290 case AV_PKT_DATA_METADATA_UPDATE: return "Metadata Update";
291 case AV_PKT_DATA_MPEGTS_STREAM_ID: return "MPEGTS Stream ID";
292 case AV_PKT_DATA_MASTERING_DISPLAY_METADATA: return "Mastering display metadata";
293 case AV_PKT_DATA_CONTENT_LIGHT_LEVEL: return "Content light level metadata";
294 case AV_PKT_DATA_SPHERICAL: return "Spherical Mapping";
295 case AV_PKT_DATA_A53_CC: return "A53 Closed Captions";
296 case AV_PKT_DATA_ENCRYPTION_INIT_INFO: return "Encryption initialization data";
297 case AV_PKT_DATA_ENCRYPTION_INFO: return "Encryption info";
298 case AV_PKT_DATA_AFD: return "Active Format Description data";
299 case AV_PKT_DATA_PRFT: return "Producer Reference Time";
300 case AV_PKT_DATA_ICC_PROFILE: return "ICC Profile";
301 case AV_PKT_DATA_DOVI_CONF: return "DOVI configuration record";
302 case AV_PKT_DATA_S12M_TIMECODE: return "SMPTE ST 12-1:2014 timecode";
303 case AV_PKT_DATA_DYNAMIC_HDR10_PLUS: return "HDR10+ Dynamic Metadata (SMPTE 2094-40)";
304 case AV_PKT_DATA_DYNAMIC_HDR_SMPTE_2094_APP5:return "HDR Dynamic Metadata (SMPTE 2094-50)";
305 case AV_PKT_DATA_AMBIENT_VIEWING_ENVIRONMENT:return "Ambient viewing environment";
306 case AV_PKT_DATA_IAMF_MIX_GAIN_PARAM: return "IAMF Mix Gain Parameter Data";
307 case AV_PKT_DATA_IAMF_DEMIXING_INFO_PARAM: return "IAMF Demixing Info Parameter Data";
308 case AV_PKT_DATA_IAMF_RECON_GAIN_INFO_PARAM: return "IAMF Recon Gain Info Parameter Data";
309 case AV_PKT_DATA_FRAME_CROPPING: return "Frame Cropping";
310 case AV_PKT_DATA_LCEVC: return "LCEVC NAL data";
311 case AV_PKT_DATA_3D_REFERENCE_DISPLAYS: return "3D Reference Displays Info";
312 case AV_PKT_DATA_RTCP_SR: return "RTCP Sender Report";
313 case AV_PKT_DATA_EXIF: return "EXIF metadata";
314 case AV_PKT_DATA_HEVC_CONF: return "HEVC enhancement-layer decoder configuration";
315 }
316 return NULL;
317}
318
319uint8_t *av_packet_pack_dictionary(const AVDictionary *dict, size_t *size)
320{
321 uint8_t *data = NULL;
322 *size = 0;
323
324 if (!dict)
325 return NULL;
326
327 for (int pass = 0; pass < 2; pass++) {
328 const AVDictionaryEntry *t = NULL;
329 size_t total_length = 0;
330
331 while ((t = av_dict_iterate(dict, t))) {
332 for (int i = 0; i < 2; i++) {
333 const char *str = i ? t->value : t->key;
334 const size_t len = strlen(str) + 1;
335
336 if (pass)
337 memcpy(data + total_length, str, len);
338 else if (len > SIZE_MAX - total_length)
339 return NULL;
340 total_length += len;
341 }
342 }
343 if (pass)
344 break;
345 data = av_malloc(total_length);
346 if (!data)
347 return NULL;
348 *size = total_length;
349 }
350
351 return data;
352}
353
354int av_packet_unpack_dictionary(const uint8_t *data, size_t size,
355 AVDictionary **dict)
356{
357 const uint8_t *end;
358 int ret;
359
360 if (!dict || !data || !size)
361 return 0;
362 end = data + size;
363 if (end[-1])
364 return AVERROR_INVALIDDATA;
365 while (data < end) {
366 const uint8_t *key = data;
367 const uint8_t *val = data + strlen(key) + 1;
368
369 if (val >= end || !*key)
370 return AVERROR_INVALIDDATA;
371
372 ret = av_dict_set(dict, key, val, 0);
373 if (ret < 0)
374 return ret;
375 data = val + strlen(val) + 1;
376 }
377
378 return 0;
379}
380
382 size_t size)
383{
384 int i;
385
386 for (i = 0; i < pkt->side_data_elems; i++) {
387 if (pkt->side_data[i].type == type) {
388 if (size > pkt->side_data[i].size)
389 return AVERROR(ENOMEM);
390 pkt->side_data[i].size = size;
391 return 0;
392 }
393 }
394 return AVERROR(ENOENT);
395}
396
398{
399 int i, ret;
400
401 dst->pts = src->pts;
402 dst->dts = src->dts;
403 dst->pos = src->pos;
404 dst->duration = src->duration;
405 dst->flags = src->flags;
406 dst->stream_index = src->stream_index;
407 dst->opaque = src->opaque;
408 dst->time_base = src->time_base;
409 dst->opaque_ref = NULL;
410 dst->side_data = NULL;
411 dst->side_data_elems = 0;
412
413 ret = av_buffer_replace(&dst->opaque_ref, src->opaque_ref);
414 if (ret < 0)
415 return ret;
416
417 for (i = 0; i < src->side_data_elems; i++) {
418 enum AVPacketSideDataType type = src->side_data[i].type;
419 size_t size = src->side_data[i].size;
420 uint8_t *src_data = src->side_data[i].data;
421 uint8_t *dst_data = av_packet_new_side_data(dst, type, size);
422
423 if (!dst_data) {
424 av_buffer_unref(&dst->opaque_ref);
426 return AVERROR(ENOMEM);
427 }
428 memcpy(dst_data, src_data, size);
429 }
430
431 return 0;
432}
433
441
443{
444 int ret;
445
446 dst->buf = NULL;
447
449 if (ret < 0)
450 goto fail;
451
452 if (!src->buf) {
453 ret = packet_alloc(&dst->buf, src->size);
454 if (ret < 0)
455 goto fail;
456 av_assert1(!src->size || src->data);
457 if (src->size)
458 memcpy(dst->buf->data, src->data, src->size);
459
460 dst->data = dst->buf->data;
461 } else {
462 dst->buf = av_buffer_ref(src->buf);
463 if (!dst->buf) {
464 ret = AVERROR(ENOMEM);
465 goto fail;
466 }
467 dst->data = src->data;
468 }
469
470 dst->size = src->size;
471
472 return 0;
473fail:
475 return ret;
476}
477
479{
480 AVPacket *ret = av_packet_alloc();
481
482 if (!ret)
483 return ret;
484
485 if (av_packet_ref(ret, src))
486 av_packet_free(&ret);
487
488 return ret;
489}
490
496
498{
499 int ret;
500
501 if (pkt->buf)
502 return 0;
503
504 ret = packet_alloc(&pkt->buf, pkt->size);
505 if (ret < 0)
506 return ret;
507 av_assert1(!pkt->size || pkt->data);
508 if (pkt->size)
509 memcpy(pkt->buf->data, pkt->data, pkt->size);
510
511 pkt->data = pkt->buf->data;
512
513 return 0;
514}
515
517{
518 AVBufferRef *buf = NULL;
519 int ret;
520
521 if (pkt->buf && av_buffer_is_writable(pkt->buf))
522 return 0;
523
524 ret = packet_alloc(&buf, pkt->size);
525 if (ret < 0)
526 return ret;
527 av_assert1(!pkt->size || pkt->data);
528 if (pkt->size)
529 memcpy(buf->data, pkt->data, pkt->size);
530
531 av_buffer_unref(&pkt->buf);
532 pkt->buf = buf;
533 pkt->data = buf->data;
534
535 return 0;
536}
537
539{
540 if (pkt->pts != AV_NOPTS_VALUE)
541 pkt->pts = av_rescale_q(pkt->pts, src_tb, dst_tb);
542 if (pkt->dts != AV_NOPTS_VALUE)
543 pkt->dts = av_rescale_q(pkt->dts, src_tb, dst_tb);
544 if (pkt->duration > 0)
545 pkt->duration = av_rescale_q(pkt->duration, src_tb, dst_tb);
546}
547
549{
551 uint8_t *side_data;
552 size_t side_data_size;
553
554 side_data = av_packet_get_side_data(pkt, AV_PKT_DATA_PRFT, &side_data_size);
555 if (!side_data) {
556 side_data_size = sizeof(AVProducerReferenceTime);
557 side_data = av_packet_new_side_data(pkt, AV_PKT_DATA_PRFT, side_data_size);
558 }
559
560 if (!side_data || side_data_size < sizeof(AVProducerReferenceTime))
561 return AVERROR(ENOMEM);
562
563 prft = (AVProducerReferenceTime *)side_data;
564 prft->wallclock = timestamp;
565 prft->flags = 0;
566
567 return 0;
568}
569
572{
573 for (int i = 0; i < nb_sd; i++)
574 if (sd[i].type == type)
575 return &sd[i];
576
577 return NULL;
578}
579
582 void *data, size_t size)
583{
584 AVPacketSideData *sd = *psd, *tmp;
585 int nb_sd = *pnb_sd;
586
587 for (int i = 0; i < nb_sd; i++) {
588 if (sd[i].type != type)
589 continue;
590
591 av_free(sd[i].data);
592 sd[i].data = data;
593 sd[i].size = size;
594 return &sd[i];
595 }
596
597 if (nb_sd == INT_MAX)
598 return NULL;
599
600 tmp = av_realloc_array(sd, nb_sd + 1, sizeof(*tmp));
601 if (!tmp)
602 return NULL;
603
604 *psd = sd = tmp;
605 sd[nb_sd].type = type;
606 sd[nb_sd].data = data;
607 sd[nb_sd].size = size;
608 *pnb_sd = nb_sd + 1;
609
610 return &sd[nb_sd];
611}
612
615 void *data, size_t size, int flags)
616{
617 return packet_side_data_add(psd, pnb_sd, type, data, size);
618}
619
622 size_t size, int flags)
623{
625 uint8_t *data;
626
627 if (size > SIZE_MAX - AV_INPUT_BUFFER_PADDING_SIZE)
628 return NULL;
629
631 if (!data)
632 return NULL;
634
635 sd = packet_side_data_add(psd, pnb_sd, type, data, size);
636 if (!sd)
637 av_freep(&data);
638
639 return sd;
640}
641
644{
645 int nb_sd = *pnb_sd;
646
647 for (int i = nb_sd - 1; i >= 0; i--) {
648 if (sd[i].type != type)
649 continue;
650 av_free(sd[i].data);
651 sd[i] = sd[--nb_sd];
652 break;
653 }
654
655 *pnb_sd = nb_sd;
656}
657
659{
660 AVPacketSideData *sd = *psd;
661 int nb_sd = *pnb_sd;
662
663 for (int i = 0; i < nb_sd; i++)
664 av_free(sd[i].data);
665
666 av_freep(psd);
667 *pnb_sd = 0;
668}
669
670static void *container_packet_alloc(void *opaque)
671{
672 return av_packet_alloc();
673}
674
675static void container_packet_reset(void *opaque, void *obj)
676{
677 av_packet_unref(obj);
678}
679
680static void container_packet_free(void *opaque, void *obj)
681{
682 AVPacket *pkt = obj;
684}
685
686static int container_packet_transfer(void *opaque, void *dst, void *src, unsigned flags)
687{
689 return av_packet_ref(dst, src);
690
692 return 0;
693}
694
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
Definition dsp.h:87
static double val(void *priv, double ch)
Definition aeval.c:77
simple assert() macros that are a bit more flexible than ISO C assert().
#define av_assert1(cond)
assert() equivalent, that does not lie in speed critical code.
Definition avassert.h:58
#define av_assert0(cond)
assert() equivalent, that is always enabled.
Definition avassert.h:42
Convenience header that includes libavutil's core.
#define flags(name, subs,...)
Definition cbs_h264.c:74
#define i(width, name, range_min, range_max)
Definition cbs_h264.c:63
AVContainerFifo * av_container_fifo_alloc(void *opaque, void *(*container_alloc)(void *opaque), void(*container_reset)(void *opaque, void *obj), void(*container_free)(void *opaque, void *obj), int(*fifo_transfer)(void *opaque, void *dst, void *src, unsigned flags), unsigned flags)
Allocate a new AVContainerFifo for the container type defined by provided callbacks.
@ AV_CONTAINER_FIFO_FLAG_REF
Signal to av_container_fifo_write() that it should make a new reference to data in src rather than co...
#define NULL
Definition coverity.c:32
long long int64_t
Definition coverity.c:34
Misc types and constants that do not belong anywhere else.
static AVPacket * pkt
const char * key
#define fail
Definition test.h:479
#define AV_INPUT_BUFFER_PADDING_SIZE
Required number of additionally allocated bytes at the end of the input bitstream for decoding.
Definition defs.h:40
void av_packet_side_data_free(AVPacketSideData **psd, int *pnb_sd)
Convenience function to free all the side data stored in an array, and the array itself.
Definition packet.c:658
AVPacketSideData * av_packet_side_data_new(AVPacketSideData **psd, int *pnb_sd, enum AVPacketSideDataType type, size_t size, int flags)
Allocate a new packet side data.
Definition packet.c:620
const char * av_packet_side_data_name(enum AVPacketSideDataType type)
Definition packet.c:269
void av_packet_side_data_remove(AVPacketSideData *sd, int *pnb_sd, enum AVPacketSideDataType type)
Remove side data of the given type from a side data array.
Definition packet.c:642
AVPacketSideData * av_packet_side_data_add(AVPacketSideData **psd, int *pnb_sd, enum AVPacketSideDataType type, void *data, size_t size, int flags)
Wrap existing data as packet side data.
Definition packet.c:613
AVPacketSideDataType
Definition packet.h:41
const AVPacketSideData * av_packet_side_data_get(const AVPacketSideData *sd, int nb_sd, enum AVPacketSideDataType type)
Get side information from a side data array.
Definition packet.c:570
@ AV_PKT_DATA_JP_DUALMONO
An AV_PKT_DATA_JP_DUALMONO side data packet indicates that the packet may contain "dual mono" audio s...
Definition packet.h:163
@ AV_PKT_DATA_HEVC_CONF
Dolby Vision enhancement-layer HEVC decoder configuration.
Definition packet.h:384
@ AV_PKT_DATA_STRINGS_METADATA
A list of zero terminated key/value strings.
Definition packet.h:169
@ AV_PKT_DATA_S12M_TIMECODE
Timecode which conforms to SMPTE ST 12-1:2014.
Definition packet.h:288
@ AV_PKT_DATA_AMBIENT_VIEWING_ENVIRONMENT
Ambient viewing environment metadata, as defined by H.274.
Definition packet.h:327
@ AV_PKT_DATA_SKIP_SAMPLES
Recommends skipping the specified number of samples.
Definition packet.h:153
@ AV_PKT_DATA_IAMF_RECON_GAIN_INFO_PARAM
IAMF Recon Gain Info Parameter Data associated with the audio frame.
Definition packet.h:320
@ AV_PKT_DATA_MPEGTS_STREAM_ID
MPEGTS stream ID as uint8_t, this is required to pass the stream ID information from the demuxer to t...
Definition packet.h:212
@ AV_PKT_DATA_DYNAMIC_HDR10_PLUS
HDR10+ dynamic metadata associated with a video frame.
Definition packet.h:296
@ AV_PKT_DATA_PRFT
Producer Reference Time data corresponding to the AVProducerReferenceTime struct, usually exported by...
Definition packet.h:265
@ AV_PKT_DATA_H263_MB_INFO
An AV_PKT_DATA_H263_MB_INFO side data packet contains a number of structures with info about macroblo...
Definition packet.h:90
@ AV_PKT_DATA_3D_REFERENCE_DISPLAYS
This side data contains information about the reference display width(s) and reference viewing distan...
Definition packet.h:357
@ AV_PKT_DATA_ICC_PROFILE
ICC profile data consisting of an opaque octet buffer following the format described by ISO 15076-1.
Definition packet.h:271
@ AV_PKT_DATA_MASTERING_DISPLAY_METADATA
Mastering display metadata (based on SMPTE-2086:2014).
Definition packet.h:219
@ AV_PKT_DATA_RTCP_SR
Contains the last received RTCP SR (Sender Report) information in the form of the AVRTCPSenderReport ...
Definition packet.h:363
@ AV_PKT_DATA_AUDIO_SERVICE_TYPE
This side data should be associated with an audio stream and corresponds to enum AVAudioServiceType.
Definition packet.h:117
@ AV_PKT_DATA_IAMF_DEMIXING_INFO_PARAM
IAMF Demixing Info Parameter Data associated with the audio frame.
Definition packet.h:312
@ AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL
Data found in BlockAdditional element of matroska container.
Definition packet.h:188
@ AV_PKT_DATA_A53_CC
ATSC A53 Part 4 Closed Captions.
Definition packet.h:239
@ AV_PKT_DATA_SPHERICAL
This side data should be associated with a video stream and corresponds to the AVSphericalMapping str...
Definition packet.h:225
@ AV_PKT_DATA_QUALITY_STATS
This side data contains quality related information from the encoder.
Definition packet.h:129
@ AV_PKT_DATA_WEBVTT_SETTINGS
The optional settings (rendering instructions) that immediately follow the timestamp specifier of a W...
Definition packet.h:199
@ AV_PKT_DATA_METADATA_UPDATE
A list of zero terminated key/value strings.
Definition packet.h:206
@ AV_PKT_DATA_SUBTITLE_POSITION
Subtitle event position.
Definition packet.h:180
@ AV_PKT_DATA_PALETTE
An AV_PKT_DATA_PALETTE side data packet contains exactly AVPALETTE_SIZE bytes worth of palette.
Definition packet.h:47
@ AV_PKT_DATA_ENCRYPTION_INFO
This side data contains encryption info for how to decrypt the packet.
Definition packet.h:252
@ AV_PKT_DATA_DISPLAYMATRIX
This side data contains a 3x3 transformation matrix describing an affine transformation that needs to...
Definition packet.h:105
@ AV_PKT_DATA_DYNAMIC_HDR_SMPTE_2094_APP5
HDR dynamic metadata associated with a video frame.
Definition packet.h:376
@ AV_PKT_DATA_AFD
Active Format Description data consisting of a single byte as specified in ETSI TS 101 154 using AVAc...
Definition packet.h:258
@ AV_PKT_DATA_EXIF
Extensible image file format metadata.
Definition packet.h:369
@ AV_PKT_DATA_ENCRYPTION_INIT_INFO
This side data is encryption initialization data.
Definition packet.h:246
@ AV_PKT_DATA_CPB_PROPERTIES
This side data corresponds to the AVCPBProperties struct.
Definition packet.h:142
@ AV_PKT_DATA_NEW_EXTRADATA
The AV_PKT_DATA_NEW_EXTRADATA is used to notify the codec or the format that the extradata buffer was...
Definition packet.h:56
@ AV_PKT_DATA_NB
The number of side data types.
Definition packet.h:394
@ AV_PKT_DATA_PARAM_CHANGE
An AV_PKT_DATA_PARAM_CHANGE side data packet is laid out as follows:
Definition packet.h:69
@ AV_PKT_DATA_STEREO3D
This side data should be associated with a video stream and contains Stereoscopic 3D information in f...
Definition packet.h:111
@ AV_PKT_DATA_WEBVTT_IDENTIFIER
The optional first identifier line of a WebVTT cue.
Definition packet.h:193
@ AV_PKT_DATA_FRAME_CROPPING
The number of pixels to discard from the top/bottom/left/right border of the decoded frame to obtain ...
Definition packet.h:340
@ AV_PKT_DATA_CONTENT_LIGHT_LEVEL
Content light level (based on CTA-861.3).
Definition packet.h:232
@ AV_PKT_DATA_FALLBACK_TRACK
This side data contains an integer value representing the stream index of a "fallback" track.
Definition packet.h:137
@ AV_PKT_DATA_LCEVC
Raw LCEVC payload data, as a uint8_t array, with NAL emulation bytes intact.
Definition packet.h:346
@ AV_PKT_DATA_IAMF_MIX_GAIN_PARAM
IAMF Mix Gain Parameter Data associated with the audio frame.
Definition packet.h:304
@ AV_PKT_DATA_REPLAYGAIN
This side data should be associated with an audio stream and contains ReplayGain information in form ...
Definition packet.h:96
@ AV_PKT_DATA_DOVI_CONF
DOVI configuration ref: dolby-vision-bitstreams-within-the-iso-base-media-file-format-v2....
Definition packet.h:280
void av_packet_free(AVPacket **pkt)
Free the packet, if the packet is reference counted, it will be unreferenced first.
Definition packet.c:74
int av_packet_shrink_side_data(AVPacket *pkt, enum AVPacketSideDataType type, size_t size)
Shrink the already allocated side data buffer.
Definition packet.c:381
void av_packet_free_side_data(AVPacket *pkt)
Convenience function to free all the side data stored.
Definition packet.c:188
void av_packet_unref(AVPacket *pkt)
Wipe the packet.
Definition packet.c:434
uint8_t * av_packet_new_side_data(AVPacket *pkt, enum AVPacketSideDataType type, size_t size)
Allocate new information of a packet.
Definition packet.c:231
int av_grow_packet(AVPacket *pkt, int grow_by)
Increase packet size, correctly zeroing padding.
Definition packet.c:121
int av_packet_from_data(AVPacket *pkt, uint8_t *data, int size)
Initialize a reference-counted packet from av_malloc()ed data.
Definition packet.c:172
AVPacket * av_packet_clone(const AVPacket *src)
Create a new packet that references the same data as src.
Definition packet.c:478
uint8_t * av_packet_pack_dictionary(const AVDictionary *dict, size_t *size)
Pack a dictionary for use in side_data.
Definition packet.c:319
int av_packet_make_refcounted(AVPacket *pkt)
Ensure the data described by a given packet is reference counted.
Definition packet.c:497
int av_packet_add_side_data(AVPacket *pkt, enum AVPacketSideDataType type, uint8_t *data, size_t size)
Wrap an existing array as a packet side data.
Definition packet.c:197
void av_packet_move_ref(AVPacket *dst, AVPacket *src)
Move every field in src to dst and reset src.
Definition packet.c:491
AVContainerFifo * av_container_fifo_alloc_avpacket(unsigned flags)
Allocate an AVContainerFifo instance for AVPacket.
Definition packet.c:695
int av_packet_make_writable(AVPacket *pkt)
Create a writable reference for the data described by a given packet, avoiding data copy if possible.
Definition packet.c:516
int av_packet_unpack_dictionary(const uint8_t *data, size_t size, AVDictionary **dict)
Unpack a dictionary from side_data.
Definition packet.c:354
uint8_t * av_packet_get_side_data(const AVPacket *pkt, enum AVPacketSideDataType type, size_t *size)
Get side information from packet.
Definition packet.c:252
void av_shrink_packet(AVPacket *pkt, int size)
Reduce packet size, correctly zeroing padding.
Definition packet.c:113
AVPacket * av_packet_alloc(void)
Allocate an AVPacket and set its fields to default values.
Definition packet.c:63
int av_packet_ref(AVPacket *dst, const AVPacket *src)
Setup a new reference to the data described by a given packet.
Definition packet.c:442
int av_packet_copy_props(AVPacket *dst, const AVPacket *src)
Copy only "properties" fields from src to dst.
Definition packet.c:397
int av_new_packet(AVPacket *pkt, int size)
Allocate the payload of a packet and initialize its fields with default values.
Definition packet.c:98
void av_packet_rescale_ts(AVPacket *pkt, AVRational src_tb, AVRational dst_tb)
Convert valid timing fields (timestamps / durations) in a packet from one timebase to another.
Definition packet.c:538
int av_buffer_is_writable(const AVBufferRef *buf)
Definition buffer.c:147
void av_buffer_unref(AVBufferRef **buf)
Free a given reference and automatically free the buffer if there are no more references to it.
Definition buffer.c:139
int av_buffer_realloc(AVBufferRef **pbuf, size_t size)
Reallocate a given buffer.
Definition buffer.c:183
void av_buffer_default_free(void *opaque, uint8_t *data)
Default free callback, which calls av_free() on the buffer data.
Definition buffer.c:72
int av_buffer_replace(AVBufferRef **pdst, const AVBufferRef *src)
Ensure dst refers to the same data as src.
Definition buffer.c:233
AVBufferRef * av_buffer_ref(const AVBufferRef *buf)
Create a new reference to an AVBuffer.
Definition buffer.c:103
AVBufferRef * av_buffer_alloc(size_t size)
Allocate an AVBuffer of the given size using av_malloc().
Definition buffer.c:77
AVBufferRef * av_buffer_create(uint8_t *data, size_t size, void(*free)(void *opaque, uint8_t *data), void *opaque, int flags)
Create an AVBuffer from an existing array.
Definition buffer.c:55
const AVDictionaryEntry * av_dict_iterate(const AVDictionary *m, const AVDictionaryEntry *prev)
Iterate over a dictionary.
Definition dict.c:42
int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags)
Set the given entry in *pm, overwriting an existing entry.
Definition dict.c:86
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
Definition error.h:61
#define AVERROR(e)
Definition error.h:45
static AVRational av_make_q(int num, int den)
Create an AVRational.
Definition rational.h:71
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
void * av_realloc_array(void *ptr, size_t nmemb, size_t size)
Definition mem.c:217
#define AV_NOPTS_VALUE
Undefined timestamp value.
Definition avutil.h:247
cl_device_type type
Memory handling functions.
const char data[16]
Definition mxf.c:149
#define av_realloc(p, s)
Definition ops_static.c:54
#define av_malloc(s)
Definition ops_static.c:52
static void container_packet_reset(void *opaque, void *obj)
Definition packet.c:675
static void container_packet_free(void *opaque, void *obj)
Definition packet.c:680
static int packet_alloc(AVBufferRef **buf, int size)
Definition packet.c:83
static void get_packet_defaults(AVPacket *pkt)
Definition packet.c:53
int ff_side_data_set_prft(AVPacket *pkt, int64_t timestamp)
Definition packet.c:548
static void * container_packet_alloc(void *opaque)
Definition packet.c:670
static AVPacketSideData * packet_side_data_add(AVPacketSideData **psd, int *pnb_sd, enum AVPacketSideDataType type, void *data, size_t size)
Definition packet.c:580
static int container_packet_transfer(void *opaque, void *dst, void *src, unsigned flags)
Definition packet.c:686
Utilities for rational number calculation.
A reference to a data buffer.
Definition buffer.h:82
uint8_t * data
The data buffer.
Definition buffer.h:90
AVContainerFifo is a FIFO for "containers" - dynamically allocated reusable structs (e....
char * key
Definition dict.h:91
char * value
Definition dict.h:92
This structure stores auxiliary information for decoding, presenting, or otherwise processing the cod...
Definition packet.h:424
uint8_t * data
Definition packet.h:425
enum AVPacketSideDataType type
Definition packet.h:427
This structure stores compressed data.
Definition packet.h:580
This structure supplies correlation between a packet timestamp and a wall clock production time.
Definition defs.h:331
int64_t wallclock
A UTC timestamp, in microseconds, since Unix epoch (e.g, av_gettime()).
Definition defs.h:335
Rational number (pair of numerator and denominator).
Definition rational.h:58
#define av_free(p)
#define av_mallocz(s)
#define av_freep(p)
static uint8_t tmp[40]
Definition aes_ctr.c:52
#define src
Definition vp8dsp.c:248
int size
int len