FFmpeg
avpacket.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"
26 #include "libavutil/intreadwrite.h"
27 #include "libavutil/mathematics.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
36 void av_init_packet(AVPacket *pkt)
37 {
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 
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 
80  av_freep(pkt);
81 }
82 
83 static int packet_alloc(AVBufferRef **buf, int size)
84 {
85  int ret;
86  if (size < 0 || size >= INT_MAX - AV_INPUT_BUFFER_PADDING_SIZE)
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 
121 int 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 ||
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++)
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  }
305  return NULL;
306 }
307 
309 {
310  uint8_t *data = NULL;
311  *size = 0;
312 
313  if (!dict)
314  return NULL;
315 
316  for (int pass = 0; pass < 2; pass++) {
317  const AVDictionaryEntry *t = NULL;
318  size_t total_length = 0;
319 
320  while ((t = av_dict_iterate(dict, t))) {
321  for (int i = 0; i < 2; i++) {
322  const char *str = i ? t->value : t->key;
323  const size_t len = strlen(str) + 1;
324 
325  if (pass)
326  memcpy(data + total_length, str, len);
327  else if (len > SIZE_MAX - total_length)
328  return NULL;
329  total_length += len;
330  }
331  }
332  if (pass)
333  break;
334  data = av_malloc(total_length);
335  if (!data)
336  return NULL;
337  *size = total_length;
338  }
339 
340  return data;
341 }
342 
343 int av_packet_unpack_dictionary(const uint8_t *data, size_t size,
344  AVDictionary **dict)
345 {
346  const uint8_t *end;
347  int ret;
348 
349  if (!dict || !data || !size)
350  return 0;
351  end = data + size;
352  if (size && end[-1])
353  return AVERROR_INVALIDDATA;
354  while (data < end) {
355  const uint8_t *key = data;
356  const uint8_t *val = data + strlen(key) + 1;
357 
358  if (val >= end || !*key)
359  return AVERROR_INVALIDDATA;
360 
361  ret = av_dict_set(dict, key, val, 0);
362  if (ret < 0)
363  return ret;
364  data = val + strlen(val) + 1;
365  }
366 
367  return 0;
368 }
369 
371  size_t size)
372 {
373  int i;
374 
375  for (i = 0; i < pkt->side_data_elems; i++) {
376  if (pkt->side_data[i].type == type) {
377  if (size > pkt->side_data[i].size)
378  return AVERROR(ENOMEM);
379  pkt->side_data[i].size = size;
380  return 0;
381  }
382  }
383  return AVERROR(ENOENT);
384 }
385 
387 {
388  int i, ret;
389 
390  dst->pts = src->pts;
391  dst->dts = src->dts;
392  dst->pos = src->pos;
393  dst->duration = src->duration;
394  dst->flags = src->flags;
395  dst->stream_index = src->stream_index;
396  dst->opaque = src->opaque;
397  dst->time_base = src->time_base;
398  dst->opaque_ref = NULL;
399  dst->side_data = NULL;
400  dst->side_data_elems = 0;
401 
402  ret = av_buffer_replace(&dst->opaque_ref, src->opaque_ref);
403  if (ret < 0)
404  return ret;
405 
406  for (i = 0; i < src->side_data_elems; i++) {
407  enum AVPacketSideDataType type = src->side_data[i].type;
408  size_t size = src->side_data[i].size;
409  uint8_t *src_data = src->side_data[i].data;
410  uint8_t *dst_data = av_packet_new_side_data(dst, type, size);
411 
412  if (!dst_data) {
415  return AVERROR(ENOMEM);
416  }
417  memcpy(dst_data, src_data, size);
418  }
419 
420  return 0;
421 }
422 
424 {
429 }
430 
432 {
433  int ret;
434 
435  dst->buf = NULL;
436 
437  ret = av_packet_copy_props(dst, src);
438  if (ret < 0)
439  goto fail;
440 
441  if (!src->buf) {
442  ret = packet_alloc(&dst->buf, src->size);
443  if (ret < 0)
444  goto fail;
445  av_assert1(!src->size || src->data);
446  if (src->size)
447  memcpy(dst->buf->data, src->data, src->size);
448 
449  dst->data = dst->buf->data;
450  } else {
451  dst->buf = av_buffer_ref(src->buf);
452  if (!dst->buf) {
453  ret = AVERROR(ENOMEM);
454  goto fail;
455  }
456  dst->data = src->data;
457  }
458 
459  dst->size = src->size;
460 
461  return 0;
462 fail:
463  av_packet_unref(dst);
464  return ret;
465 }
466 
468 {
470 
471  if (!ret)
472  return ret;
473 
474  if (av_packet_ref(ret, src))
476 
477  return ret;
478 }
479 
481 {
482  *dst = *src;
484 }
485 
487 {
488  int ret;
489 
490  if (pkt->buf)
491  return 0;
492 
493  ret = packet_alloc(&pkt->buf, pkt->size);
494  if (ret < 0)
495  return ret;
496  av_assert1(!pkt->size || pkt->data);
497  if (pkt->size)
498  memcpy(pkt->buf->data, pkt->data, pkt->size);
499 
500  pkt->data = pkt->buf->data;
501 
502  return 0;
503 }
504 
506 {
507  AVBufferRef *buf = NULL;
508  int ret;
509 
510  if (pkt->buf && av_buffer_is_writable(pkt->buf))
511  return 0;
512 
513  ret = packet_alloc(&buf, pkt->size);
514  if (ret < 0)
515  return ret;
516  av_assert1(!pkt->size || pkt->data);
517  if (pkt->size)
518  memcpy(buf->data, pkt->data, pkt->size);
519 
521  pkt->buf = buf;
522  pkt->data = buf->data;
523 
524  return 0;
525 }
526 
528 {
529  if (pkt->pts != AV_NOPTS_VALUE)
530  pkt->pts = av_rescale_q(pkt->pts, src_tb, dst_tb);
531  if (pkt->dts != AV_NOPTS_VALUE)
532  pkt->dts = av_rescale_q(pkt->dts, src_tb, dst_tb);
533  if (pkt->duration > 0)
534  pkt->duration = av_rescale_q(pkt->duration, src_tb, dst_tb);
535 }
536 
538  AVPacket *pkt,
539  int (*copy)(AVPacket *dst, const AVPacket *src),
540  int flags)
541 {
542  PacketListEntry *pktl = av_malloc(sizeof(*pktl));
543  int ret;
544 
545  if (!pktl)
546  return AVERROR(ENOMEM);
547 
548  if (copy) {
549  get_packet_defaults(&pktl->pkt);
550  ret = copy(&pktl->pkt, pkt);
551  if (ret < 0) {
552  av_free(pktl);
553  return ret;
554  }
555  } else {
557  if (ret < 0) {
558  av_free(pktl);
559  return ret;
560  }
561  av_packet_move_ref(&pktl->pkt, pkt);
562  }
563 
564  pktl->next = NULL;
565 
566  if (packet_buffer->head)
567  packet_buffer->tail->next = pktl;
568  else
569  packet_buffer->head = pktl;
570 
571  /* Add the packet in the buffered packet list. */
572  packet_buffer->tail = pktl;
573  return 0;
574 }
575 
577  AVPacket *pkt)
578 {
579  PacketListEntry *pktl = pkt_buffer->head;
580  if (!pktl)
581  return AVERROR(EAGAIN);
582  *pkt = pktl->pkt;
583  pkt_buffer->head = pktl->next;
584  if (!pkt_buffer->head)
585  pkt_buffer->tail = NULL;
586  av_freep(&pktl);
587  return 0;
588 }
589 
591 {
592  PacketListEntry *tmp = pkt_buf->head;
593 
594  while (tmp) {
595  PacketListEntry *pktl = tmp;
596  tmp = pktl->next;
597  av_packet_unref(&pktl->pkt);
598  av_freep(&pktl);
599  }
600  pkt_buf->head = pkt_buf->tail = NULL;
601 }
602 
603 int ff_side_data_set_encoder_stats(AVPacket *pkt, int quality, int64_t *error, int error_count, int pict_type)
604 {
605  uint8_t *side_data;
606  size_t side_data_size;
607  int i;
608 
609  side_data = av_packet_get_side_data(pkt, AV_PKT_DATA_QUALITY_STATS, &side_data_size);
610  if (!side_data) {
611  side_data_size = 4+4+8*error_count;
613  side_data_size);
614  }
615 
616  if (!side_data || side_data_size < 4+4+8*error_count)
617  return AVERROR(ENOMEM);
618 
619  AV_WL32(side_data , quality );
620  side_data[4] = pict_type;
621  side_data[5] = error_count;
622  for (i = 0; i<error_count; i++)
623  AV_WL64(side_data+8 + 8*i , error[i]);
624 
625  return 0;
626 }
627 
628 int ff_side_data_set_prft(AVPacket *pkt, int64_t timestamp)
629 {
631  uint8_t *side_data;
632  size_t side_data_size;
633 
634  side_data = av_packet_get_side_data(pkt, AV_PKT_DATA_PRFT, &side_data_size);
635  if (!side_data) {
636  side_data_size = sizeof(AVProducerReferenceTime);
637  side_data = av_packet_new_side_data(pkt, AV_PKT_DATA_PRFT, side_data_size);
638  }
639 
640  if (!side_data || side_data_size < sizeof(AVProducerReferenceTime))
641  return AVERROR(ENOMEM);
642 
643  prft = (AVProducerReferenceTime *)side_data;
644  prft->wallclock = timestamp;
645  prft->flags = 0;
646 
647  return 0;
648 }
649 
652 {
653  for (int i = 0; i < nb_sd; i++)
654  if (sd[i].type == type)
655  return &sd[i];
656 
657  return NULL;
658 }
659 
662  void *data, size_t size)
663 {
664  AVPacketSideData *sd = *psd, *tmp;
665  int nb_sd = *pnb_sd;
666 
667  for (int i = 0; i < nb_sd; i++) {
668  if (sd[i].type != type)
669  continue;
670 
671  av_free(sd[i].data);
672  sd[i].data = data;
673  sd[i].size = size;
674  return &sd[i];
675  }
676 
677  if (nb_sd == INT_MAX)
678  return NULL;
679 
680  tmp = av_realloc_array(sd, nb_sd + 1, sizeof(*tmp));
681  if (!tmp)
682  return NULL;
683 
684  *psd = sd = tmp;
685  sd[nb_sd].type = type;
686  sd[nb_sd].data = data;
687  sd[nb_sd].size = size;
688  *pnb_sd = nb_sd + 1;
689 
690  return &sd[nb_sd];
691 }
692 
695  void *data, size_t size, int flags)
696 {
697  return packet_side_data_add(psd, pnb_sd, type, data, size);
698 }
699 
702  size_t size, int flags)
703 {
704  AVPacketSideData *sd = NULL;
705  uint8_t *data;
706 
707  if (size > SIZE_MAX - AV_INPUT_BUFFER_PADDING_SIZE)
708  return NULL;
709 
711  if (!data)
712  return NULL;
713  memset(data + size, 0, AV_INPUT_BUFFER_PADDING_SIZE);
714 
715  sd = packet_side_data_add(psd, pnb_sd, type, data, size);
716  if (!sd)
717  av_freep(&data);
718 
719  return sd;
720 }
721 
724 {
725  int nb_sd = *pnb_sd;
726 
727  for (int i = nb_sd - 1; i >= 0; i--) {
728  if (sd[i].type != type)
729  continue;
730  av_free(sd[i].data);
731  sd[i] = sd[--nb_sd];
732  break;
733  }
734 
735  *pnb_sd = nb_sd;
736 }
737 
739 {
740  AVPacketSideData *sd = *psd;
741  int nb_sd = *pnb_sd;
742 
743  for (int i = 0; i < nb_sd; i++)
744  av_free(sd[i].data);
745 
746  av_freep(psd);
747  *pnb_sd = 0;
748 }
error
static void error(const char *err)
Definition: target_bsf_fuzzer.c:31
AV_PKT_DATA_DISPLAYMATRIX
@ AV_PKT_DATA_DISPLAYMATRIX
This side data contains a 3x3 transformation matrix describing an affine transformation that needs to...
Definition: packet.h:109
av_packet_unref
void av_packet_unref(AVPacket *pkt)
Wipe the packet.
Definition: avpacket.c:423
avpriv_packet_list_put
int avpriv_packet_list_put(PacketList *packet_buffer, AVPacket *pkt, int(*copy)(AVPacket *dst, const AVPacket *src), int flags)
Append an AVPacket to the list.
Definition: avpacket.c:537
PacketList::head
PacketListEntry * head
Definition: packet_internal.h:34
avpriv_packet_list_get
int avpriv_packet_list_get(PacketList *pkt_buffer, AVPacket *pkt)
Remove the oldest AVPacket in the list and return it.
Definition: avpacket.c:576
AVERROR
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
AV_WL32
#define AV_WL32(p, v)
Definition: intreadwrite.h:424
AV_PKT_DATA_QUALITY_STATS
@ AV_PKT_DATA_QUALITY_STATS
This side data contains quality related information from the encoder.
Definition: packet.h:133
AV_PKT_DATA_NEW_EXTRADATA
@ 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
ff_side_data_set_encoder_stats
int ff_side_data_set_encoder_stats(AVPacket *pkt, int quality, int64_t *error, int error_count, int pict_type)
Definition: avpacket.c:603
AVBufferRef::data
uint8_t * data
The data buffer.
Definition: buffer.h:90
AV_PKT_DATA_MASTERING_DISPLAY_METADATA
@ AV_PKT_DATA_MASTERING_DISPLAY_METADATA
Mastering display metadata (based on SMPTE-2086:2014).
Definition: packet.h:223
rational.h
av_grow_packet
int av_grow_packet(AVPacket *pkt, int grow_by)
Increase packet size, correctly zeroing padding.
Definition: avpacket.c:121
tmp
static uint8_t tmp[11]
Definition: aes_ctr.c:28
AVPacketSideData
This structure stores auxiliary information for decoding, presenting, or otherwise processing the cod...
Definition: packet.h:342
AVProducerReferenceTime::wallclock
int64_t wallclock
A UTC timestamp, in microseconds, since Unix epoch (e.g, av_gettime()).
Definition: defs.h:322
AVPacket::data
uint8_t * data
Definition: packet.h:491
AV_PKT_DATA_ENCRYPTION_INIT_INFO
@ AV_PKT_DATA_ENCRYPTION_INIT_INFO
This side data is encryption initialization data.
Definition: packet.h:250
av_packet_shrink_side_data
int av_packet_shrink_side_data(AVPacket *pkt, enum AVPacketSideDataType type, size_t size)
Shrink the already allocated side data buffer.
Definition: avpacket.c:370
AV_PKT_DATA_FALLBACK_TRACK
@ AV_PKT_DATA_FALLBACK_TRACK
This side data contains an integer value representing the stream index of a "fallback" track.
Definition: packet.h:141
PacketList
Definition: packet_internal.h:33
data
const char data[16]
Definition: mxf.c:148
av_packet_side_data_remove
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: avpacket.c:722
AV_PKT_DATA_S12M_TIMECODE
@ AV_PKT_DATA_S12M_TIMECODE
Timecode which conforms to SMPTE ST 12-1:2014.
Definition: packet.h:292
AVPacket::duration
int64_t duration
Duration of this packet in AVStream->time_base units, 0 if unknown.
Definition: packet.h:509
mathematics.h
AVDictionary
Definition: dict.c:34
av_buffer_ref
AVBufferRef * av_buffer_ref(const AVBufferRef *buf)
Create a new reference to an AVBuffer.
Definition: buffer.c:103
av_packet_free_side_data
void av_packet_free_side_data(AVPacket *pkt)
Convenience function to free all the side data stored.
Definition: avpacket.c:188
packet_alloc
static int packet_alloc(AVBufferRef **buf, int size)
Definition: avpacket.c:83
av_packet_free
void av_packet_free(AVPacket **pkt)
Free the packet, if the packet is reference counted, it will be unreferenced first.
Definition: avpacket.c:74
quality
trying all byte sequences megabyte in length and selecting the best looking sequence will yield cases to try But a word about quality
Definition: rate_distortion.txt:12
av_malloc
#define av_malloc(s)
Definition: tableprint_vlc.h:30
AV_PKT_DATA_DOVI_CONF
@ AV_PKT_DATA_DOVI_CONF
DOVI configuration ref: dolby-vision-bitstreams-within-the-iso-base-media-file-format-v2....
Definition: packet.h:284
AVPacketSideData::size
size_t size
Definition: packet.h:344
AV_PKT_DATA_REPLAYGAIN
@ AV_PKT_DATA_REPLAYGAIN
This side data should be associated with an audio stream and contains ReplayGain information in form ...
Definition: packet.h:100
av_packet_add_side_data
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: avpacket.c:197
AV_PKT_DATA_PALETTE
@ AV_PKT_DATA_PALETTE
An AV_PKT_DATA_PALETTE side data packet contains exactly AVPALETTE_SIZE bytes worth of palette.
Definition: packet.h:47
AVPacket::opaque_ref
AVBufferRef * opaque_ref
AVBufferRef for free use by the API user.
Definition: packet.h:527
fail
#define fail()
Definition: checkasm.h:138
av_shrink_packet
void av_shrink_packet(AVPacket *pkt, int size)
Reduce packet size, correctly zeroing padding.
Definition: avpacket.c:113
ff_side_data_set_prft
int ff_side_data_set_prft(AVPacket *pkt, int64_t timestamp)
Definition: avpacket.c:628
val
static double val(void *priv, double ch)
Definition: aeval.c:78
type
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf type
Definition: writing_filters.txt:86
packet_side_data_add
static AVPacketSideData * packet_side_data_add(AVPacketSideData **psd, int *pnb_sd, enum AVPacketSideDataType type, void *data, size_t size)
Definition: avpacket.c:660
AV_PKT_DATA_WEBVTT_SETTINGS
@ AV_PKT_DATA_WEBVTT_SETTINGS
The optional settings (rendering instructions) that immediately follow the timestamp specifier of a W...
Definition: packet.h:203
avassert.h
AV_PKT_DATA_PARAM_CHANGE
@ AV_PKT_DATA_PARAM_CHANGE
An AV_PKT_DATA_PARAM_CHANGE side data packet is laid out as follows:
Definition: packet.h:73
pkt
AVPacket * pkt
Definition: movenc.c:59
av_packet_side_data_name
const char * av_packet_side_data_name(enum AVPacketSideDataType type)
Definition: avpacket.c:269
intreadwrite.h
av_new_packet
int av_new_packet(AVPacket *pkt, int size)
Allocate the payload of a packet and initialize its fields with default values.
Definition: avpacket.c:98
av_realloc_array
void * av_realloc_array(void *ptr, size_t nmemb, size_t size)
Definition: mem.c:215
AVDictionaryEntry::key
char * key
Definition: dict.h:90
av_buffer_default_free
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
av_assert0
#define av_assert0(cond)
assert() equivalent, that is always enabled.
Definition: avassert.h:40
AVPacketSideData::data
uint8_t * data
Definition: packet.h:343
AV_PKT_DATA_STEREO3D
@ AV_PKT_DATA_STEREO3D
This side data should be associated with a video stream and contains Stereoscopic 3D information in f...
Definition: packet.h:115
av_rescale_q
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
Definition: mathematics.c:142
AV_PKT_DATA_SUBTITLE_POSITION
@ AV_PKT_DATA_SUBTITLE_POSITION
Subtitle event position.
Definition: packet.h:184
key
const char * key
Definition: hwcontext_opencl.c:174
AVPacket::opaque
void * opaque
for some private data of the user
Definition: packet.h:516
av_packet_side_data_free
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: avpacket.c:738
PacketList::tail
PacketListEntry * tail
Definition: packet_internal.h:34
AVPacket::buf
AVBufferRef * buf
A reference to the reference-counted buffer where the packet data is stored.
Definition: packet.h:474
NULL
#define NULL
Definition: coverity.c:32
av_buffer_unref
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
AVRational
Rational number (pair of numerator and denominator).
Definition: rational.h:58
AVPacketSideData::type
enum AVPacketSideDataType type
Definition: packet.h:345
AVProducerReferenceTime
This structure supplies correlation between a packet timestamp and a wall clock production time.
Definition: defs.h:318
av_packet_ref
int av_packet_ref(AVPacket *dst, const AVPacket *src)
Setup a new reference to the data described by a given packet.
Definition: avpacket.c:431
av_packet_move_ref
void av_packet_move_ref(AVPacket *dst, AVPacket *src)
Move every field in src to dst and reset src.
Definition: avpacket.c:480
PacketListEntry::next
struct PacketListEntry * next
Definition: packet_internal.h:29
AVProducerReferenceTime::flags
int flags
Definition: defs.h:323
AV_PKT_DATA_CONTENT_LIGHT_LEVEL
@ AV_PKT_DATA_CONTENT_LIGHT_LEVEL
Content light level (based on CTA-861.3).
Definition: packet.h:236
av_buffer_create
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
AV_PKT_DATA_NB
@ AV_PKT_DATA_NB
The number of side data types.
Definition: packet.h:310
av_packet_side_data_get
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: avpacket.c:650
AV_PKT_DATA_SPHERICAL
@ AV_PKT_DATA_SPHERICAL
This side data should be associated with a video stream and corresponds to the AVSphericalMapping str...
Definition: packet.h:229
av_packet_from_data
int av_packet_from_data(AVPacket *pkt, uint8_t *data, int size)
Initialize a reference-counted packet from av_malloc()ed data.
Definition: avpacket.c:172
AVPacket::size
int size
Definition: packet.h:492
copy
static void copy(const float *p1, float *p2, const int length)
Definition: vf_vaguedenoiser.c:185
get_packet_defaults
static void get_packet_defaults(AVPacket *pkt)
Definition: avpacket.c:53
avpriv_packet_list_free
void avpriv_packet_list_free(PacketList *pkt_buf)
Wipe the list and unref all the packets in it.
Definition: avpacket.c:590
AV_PKT_DATA_DYNAMIC_HDR10_PLUS
@ AV_PKT_DATA_DYNAMIC_HDR10_PLUS
HDR10+ dynamic metadata associated with a video frame.
Definition: packet.h:300
size
int size
Definition: twinvq_data.h:10344
av_make_q
static AVRational av_make_q(int num, int den)
Create an AVRational.
Definition: rational.h:71
AV_PKT_DATA_METADATA_UPDATE
@ AV_PKT_DATA_METADATA_UPDATE
A list of zero terminated key/value strings.
Definition: packet.h:210
AV_NOPTS_VALUE
#define AV_NOPTS_VALUE
Undefined timestamp value.
Definition: avutil.h:248
PacketListEntry::pkt
AVPacket pkt
Definition: packet_internal.h:30
av_packet_unpack_dictionary
int av_packet_unpack_dictionary(const uint8_t *data, size_t size, AVDictionary **dict)
Unpack a dictionary from side_data.
Definition: avpacket.c:343
AVPacket::dts
int64_t dts
Decompression timestamp in AVStream->time_base units; the time at which the packet is decompressed.
Definition: packet.h:490
AV_WL64
#define AV_WL64(p, v)
Definition: intreadwrite.h:438
av_packet_side_data_add
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: avpacket.c:693
AV_PKT_DATA_PRFT
@ AV_PKT_DATA_PRFT
Producer Reference Time data corresponding to the AVProducerReferenceTime struct, usually exported by...
Definition: packet.h:269
av_packet_pack_dictionary
uint8_t * av_packet_pack_dictionary(AVDictionary *dict, size_t *size)
Pack a dictionary for use in side_data.
Definition: avpacket.c:308
av_packet_make_refcounted
int av_packet_make_refcounted(AVPacket *pkt)
Ensure the data described by a given packet is reference counted.
Definition: avpacket.c:486
AVPacket::flags
int flags
A combination of AV_PKT_FLAG values.
Definition: packet.h:497
av_packet_alloc
AVPacket * av_packet_alloc(void)
Allocate an AVPacket and set its fields to default values.
Definition: avpacket.c:63
av_buffer_alloc
AVBufferRef * av_buffer_alloc(size_t size)
Allocate an AVBuffer of the given size using av_malloc().
Definition: buffer.c:77
av_packet_rescale_ts
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: avpacket.c:527
AVBufferRef::size
size_t size
Size of data in bytes.
Definition: buffer.h:94
AV_PKT_DATA_STRINGS_METADATA
@ AV_PKT_DATA_STRINGS_METADATA
A list of zero terminated key/value strings.
Definition: packet.h:173
av_packet_copy_props
int av_packet_copy_props(AVPacket *dst, const AVPacket *src)
Copy only "properties" fields from src to dst.
Definition: avpacket.c:386
AV_PKT_DATA_CPB_PROPERTIES
@ AV_PKT_DATA_CPB_PROPERTIES
This side data corresponds to the AVCPBProperties struct.
Definition: packet.h:146
AV_PKT_DATA_H263_MB_INFO
@ 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:94
PacketListEntry
Definition: packet_internal.h:28
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:255
AVPacket::pts
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
Definition: packet.h:484
packet.h
av_packet_get_side_data
uint8_t * av_packet_get_side_data(const AVPacket *pkt, enum AVPacketSideDataType type, size_t *size)
Get side information from packet.
Definition: avpacket.c:252
AV_PKT_DATA_ICC_PROFILE
@ 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:275
av_assert1
#define av_assert1(cond)
assert() equivalent, that does not lie in speed critical code.
Definition: avassert.h:56
av_mallocz
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
Definition: mem.c:254
AV_PKT_DATA_MPEGTS_STREAM_ID
@ 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:216
av_buffer_replace
int av_buffer_replace(AVBufferRef **pdst, const AVBufferRef *src)
Ensure dst refers to the same data as src.
Definition: buffer.c:233
len
int len
Definition: vorbis_enc_data.h:426
av_buffer_is_writable
int av_buffer_is_writable(const AVBufferRef *buf)
Definition: buffer.c:147
AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL
@ AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL
Data found in BlockAdditional element of matroska container.
Definition: packet.h:192
ret
ret
Definition: filter_design.txt:187
AV_PKT_DATA_JP_DUALMONO
@ 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:167
av_packet_side_data_new
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: avpacket.c:700
AVPacket::side_data
AVPacketSideData * side_data
Additional packet data that can be provided by the container.
Definition: packet.h:502
AV_INPUT_BUFFER_PADDING_SIZE
#define AV_INPUT_BUFFER_PADDING_SIZE
Definition: defs.h:40
AV_PKT_DATA_WEBVTT_IDENTIFIER
@ AV_PKT_DATA_WEBVTT_IDENTIFIER
The optional first identifier line of a WebVTT cue.
Definition: packet.h:197
av_packet_new_side_data
uint8_t * av_packet_new_side_data(AVPacket *pkt, enum AVPacketSideDataType type, size_t size)
Allocate new information of a packet.
Definition: avpacket.c:231
defs.h
av_packet_make_writable
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: avpacket.c:505
AV_PKT_DATA_AFD
@ 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:262
AV_PKT_DATA_SKIP_SAMPLES
@ AV_PKT_DATA_SKIP_SAMPLES
Recommmends skipping the specified number of samples.
Definition: packet.h:157
AVPacketSideDataType
AVPacketSideDataType
Definition: packet.h:41
AVPacket::stream_index
int stream_index
Definition: packet.h:493
av_buffer_realloc
int av_buffer_realloc(AVBufferRef **pbuf, size_t size)
Reallocate a given buffer.
Definition: buffer.c:183
AV_PKT_DATA_ENCRYPTION_INFO
@ AV_PKT_DATA_ENCRYPTION_INFO
This side data contains encryption info for how to decrypt the packet.
Definition: packet.h:256
AV_PKT_DATA_AUDIO_SERVICE_TYPE
@ AV_PKT_DATA_AUDIO_SERVICE_TYPE
This side data should be associated with an audio stream and corresponds to enum AVAudioServiceType.
Definition: packet.h:121
avutil.h
AV_PKT_DATA_A53_CC
@ AV_PKT_DATA_A53_CC
ATSC A53 Part 4 Closed Captions.
Definition: packet.h:243
mem.h
AVBufferRef
A reference to a data buffer.
Definition: buffer.h:82
packet_internal.h
av_free
#define av_free(p)
Definition: tableprint_vlc.h:33
AVDictionaryEntry
Definition: dict.h:89
AVPacket
This structure stores compressed data.
Definition: packet.h:468
av_freep
#define av_freep(p)
Definition: tableprint_vlc.h:34
av_dict_set
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:88
src
INIT_CLIP pixel * src
Definition: h264pred_template.c:418
AVPacket::pos
int64_t pos
byte position in stream, -1 if unknown
Definition: packet.h:511
flags
#define flags(name, subs,...)
Definition: cbs_av1.c:474
AVERROR_INVALIDDATA
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
Definition: error.h:61
AVDictionaryEntry::value
char * value
Definition: dict.h:91
av_dict_iterate
const AVDictionaryEntry * av_dict_iterate(const AVDictionary *m, const AVDictionaryEntry *prev)
Iterate over a dictionary.
Definition: dict.c:44
AVPacket::time_base
AVRational time_base
Time base of the packet's timestamps.
Definition: packet.h:535
AVPacket::side_data_elems
int side_data_elems
Definition: packet.h:503
av_realloc
void * av_realloc(void *ptr, size_t size)
Allocate, reallocate, or free a block of memory.
Definition: mem.c:153
av_packet_clone
AVPacket * av_packet_clone(const AVPacket *src)
Create a new packet that references the same data as src.
Definition: avpacket.c:467