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/common.h"
26 #include "libavutil/internal.h"
27 #include "libavutil/mathematics.h"
28 #include "libavutil/mem.h"
29 
30 #include "bytestream.h"
31 #include "internal.h"
32 #include "packet.h"
33 #include "packet_internal.h"
34 
36 {
39  pkt->pos = -1;
40  pkt->duration = 0;
41 #if FF_API_CONVERGENCE_DURATION
43  pkt->convergence_duration = 0;
45 #endif
46  pkt->flags = 0;
47  pkt->stream_index = 0;
48  pkt->buf = NULL;
49  pkt->side_data = NULL;
50  pkt->side_data_elems = 0;
51 }
52 
54 {
55  AVPacket *pkt = av_mallocz(sizeof(AVPacket));
56  if (!pkt)
57  return pkt;
58 
60 
61  return pkt;
62 }
63 
65 {
66  if (!pkt || !*pkt)
67  return;
68 
70  av_freep(pkt);
71 }
72 
73 static int packet_alloc(AVBufferRef **buf, int size)
74 {
75  int ret;
76  if (size < 0 || size >= INT_MAX - AV_INPUT_BUFFER_PADDING_SIZE)
77  return AVERROR(EINVAL);
78 
80  if (ret < 0)
81  return ret;
82 
83  memset((*buf)->data + size, 0, AV_INPUT_BUFFER_PADDING_SIZE);
84 
85  return 0;
86 }
87 
89 {
90  AVBufferRef *buf = NULL;
91  int ret = packet_alloc(&buf, size);
92  if (ret < 0)
93  return ret;
94 
96  pkt->buf = buf;
97  pkt->data = buf->data;
98  pkt->size = size;
99 
100  return 0;
101 }
102 
104 {
105  if (pkt->size <= size)
106  return;
107  pkt->size = size;
108  memset(pkt->data + size, 0, AV_INPUT_BUFFER_PADDING_SIZE);
109 }
110 
111 int av_grow_packet(AVPacket *pkt, int grow_by)
112 {
113  int new_size;
114  av_assert0((unsigned)pkt->size <= INT_MAX - AV_INPUT_BUFFER_PADDING_SIZE);
115  if ((unsigned)grow_by >
116  INT_MAX - (pkt->size + AV_INPUT_BUFFER_PADDING_SIZE))
117  return AVERROR(ENOMEM);
118 
119  new_size = pkt->size + grow_by + AV_INPUT_BUFFER_PADDING_SIZE;
120  if (pkt->buf) {
121  size_t data_offset;
122  uint8_t *old_data = pkt->data;
123  if (pkt->data == NULL) {
124  data_offset = 0;
125  pkt->data = pkt->buf->data;
126  } else {
127  data_offset = pkt->data - pkt->buf->data;
128  if (data_offset > INT_MAX - new_size)
129  return AVERROR(ENOMEM);
130  }
131 
132  if (new_size + data_offset > pkt->buf->size ||
134  int ret = av_buffer_realloc(&pkt->buf, new_size + data_offset);
135  if (ret < 0) {
136  pkt->data = old_data;
137  return ret;
138  }
139  pkt->data = pkt->buf->data + data_offset;
140  }
141  } else {
142  pkt->buf = av_buffer_alloc(new_size);
143  if (!pkt->buf)
144  return AVERROR(ENOMEM);
145  if (pkt->size > 0)
146  memcpy(pkt->buf->data, pkt->data, pkt->size);
147  pkt->data = pkt->buf->data;
148  }
149  pkt->size += grow_by;
150  memset(pkt->data + pkt->size, 0, AV_INPUT_BUFFER_PADDING_SIZE);
151 
152  return 0;
153 }
154 
156 {
157  if (size >= INT_MAX - AV_INPUT_BUFFER_PADDING_SIZE)
158  return AVERROR(EINVAL);
159 
162  if (!pkt->buf)
163  return AVERROR(ENOMEM);
164 
165  pkt->data = data;
166  pkt->size = size;
167 
168  return 0;
169 }
170 
171 #if FF_API_AVPACKET_OLD_API
173 #define ALLOC_MALLOC(data, size) data = av_malloc(size)
174 #define ALLOC_BUF(data, size) \
175 do { \
176  av_buffer_realloc(&pkt->buf, size); \
177  data = pkt->buf ? pkt->buf->data : NULL; \
178 } while (0)
179 
180 #define DUP_DATA(dst, src, size, padding, ALLOC) \
181  do { \
182  void *data; \
183  if (padding) { \
184  if ((unsigned)(size) > \
185  (unsigned)(size) + AV_INPUT_BUFFER_PADDING_SIZE) \
186  goto failed_alloc; \
187  ALLOC(data, size + AV_INPUT_BUFFER_PADDING_SIZE); \
188  } else { \
189  ALLOC(data, size); \
190  } \
191  if (!data) \
192  goto failed_alloc; \
193  memcpy(data, src, size); \
194  if (padding) \
195  memset((uint8_t *)data + size, 0, \
196  AV_INPUT_BUFFER_PADDING_SIZE); \
197  dst = data; \
198  } while (0)
199 
200 /* Makes duplicates of data, side_data, but does not copy any other fields */
201 static int copy_packet_data(AVPacket *pkt, const AVPacket *src, int dup)
202 {
203  pkt->data = NULL;
204  pkt->side_data = NULL;
205  pkt->side_data_elems = 0;
206  if (pkt->buf) {
207  AVBufferRef *ref = av_buffer_ref(src->buf);
208  if (!ref)
209  return AVERROR(ENOMEM);
210  pkt->buf = ref;
211  pkt->data = ref->data;
212  } else {
213  DUP_DATA(pkt->data, src->data, pkt->size, 1, ALLOC_BUF);
214  }
215  if (src->side_data_elems && dup) {
216  pkt->side_data = src->side_data;
217  pkt->side_data_elems = src->side_data_elems;
218  }
219  if (src->side_data_elems && !dup) {
221  }
222  return 0;
223 
224 failed_alloc:
226  return AVERROR(ENOMEM);
227 }
228 
230 {
231  if (src->side_data_elems) {
232  int i;
233  DUP_DATA(pkt->side_data, src->side_data,
234  src->side_data_elems * sizeof(*src->side_data), 0, ALLOC_MALLOC);
235  if (src != pkt) {
236  memset(pkt->side_data, 0,
237  src->side_data_elems * sizeof(*src->side_data));
238  }
239  for (i = 0; i < src->side_data_elems; i++) {
240  DUP_DATA(pkt->side_data[i].data, src->side_data[i].data,
241  src->side_data[i].size, 1, ALLOC_MALLOC);
242  pkt->side_data[i].size = src->side_data[i].size;
243  pkt->side_data[i].type = src->side_data[i].type;
244  }
245  }
246  pkt->side_data_elems = src->side_data_elems;
247  return 0;
248 
249 failed_alloc:
251  return AVERROR(ENOMEM);
252 }
253 
255 {
256  AVPacket tmp_pkt;
257 
258  if (!pkt->buf && pkt->data) {
259  tmp_pkt = *pkt;
260  return copy_packet_data(pkt, &tmp_pkt, 1);
261  }
262  return 0;
263 }
264 
266 {
267  *dst = *src;
268  return copy_packet_data(dst, src, 0);
269 }
271 #endif
272 
274 {
275  int i;
276  for (i = 0; i < pkt->side_data_elems; i++)
279  pkt->side_data_elems = 0;
280 }
281 
282 #if FF_API_AVPACKET_OLD_API
285 {
286  if (pkt) {
287  if (pkt->buf)
289  pkt->data = NULL;
290  pkt->size = 0;
291 
293  }
294 }
296 #endif
297 
299  uint8_t *data, size_t size)
300 {
302  int i, elems = pkt->side_data_elems;
303 
304  for (i = 0; i < elems; i++) {
305  AVPacketSideData *sd = &pkt->side_data[i];
306 
307  if (sd->type == type) {
308  av_free(sd->data);
309  sd->data = data;
310  sd->size = size;
311  return 0;
312  }
313  }
314 
315  if ((unsigned)elems + 1 > AV_PKT_DATA_NB)
316  return AVERROR(ERANGE);
317 
318  tmp = av_realloc(pkt->side_data, (elems + 1) * sizeof(*tmp));
319  if (!tmp)
320  return AVERROR(ENOMEM);
321 
322  pkt->side_data = tmp;
323  pkt->side_data[elems].data = data;
324  pkt->side_data[elems].size = size;
325  pkt->side_data[elems].type = type;
326  pkt->side_data_elems++;
327 
328  return 0;
329 }
330 
331 
333  int size)
334 {
335  int ret;
336  uint8_t *data;
337 
338  if ((unsigned)size > INT_MAX - AV_INPUT_BUFFER_PADDING_SIZE)
339  return NULL;
341  if (!data)
342  return NULL;
343 
345  if (ret < 0) {
346  av_freep(&data);
347  return NULL;
348  }
349 
350  return data;
351 }
352 
354  int *size)
355 {
356  int i;
357 
358  for (i = 0; i < pkt->side_data_elems; i++) {
359  if (pkt->side_data[i].type == type) {
360  if (size)
361  *size = pkt->side_data[i].size;
362  return pkt->side_data[i].data;
363  }
364  }
365  if (size)
366  *size = 0;
367  return NULL;
368 }
369 
371 {
372  switch(type) {
373  case AV_PKT_DATA_PALETTE: return "Palette";
374  case AV_PKT_DATA_NEW_EXTRADATA: return "New Extradata";
375  case AV_PKT_DATA_PARAM_CHANGE: return "Param Change";
376  case AV_PKT_DATA_H263_MB_INFO: return "H263 MB Info";
377  case AV_PKT_DATA_REPLAYGAIN: return "Replay Gain";
378  case AV_PKT_DATA_DISPLAYMATRIX: return "Display Matrix";
379  case AV_PKT_DATA_STEREO3D: return "Stereo 3D";
380  case AV_PKT_DATA_AUDIO_SERVICE_TYPE: return "Audio Service Type";
381  case AV_PKT_DATA_QUALITY_STATS: return "Quality stats";
382  case AV_PKT_DATA_FALLBACK_TRACK: return "Fallback track";
383  case AV_PKT_DATA_CPB_PROPERTIES: return "CPB properties";
384  case AV_PKT_DATA_SKIP_SAMPLES: return "Skip Samples";
385  case AV_PKT_DATA_JP_DUALMONO: return "JP Dual Mono";
386  case AV_PKT_DATA_STRINGS_METADATA: return "Strings Metadata";
387  case AV_PKT_DATA_SUBTITLE_POSITION: return "Subtitle Position";
388  case AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL: return "Matroska BlockAdditional";
389  case AV_PKT_DATA_WEBVTT_IDENTIFIER: return "WebVTT ID";
390  case AV_PKT_DATA_WEBVTT_SETTINGS: return "WebVTT Settings";
391  case AV_PKT_DATA_METADATA_UPDATE: return "Metadata Update";
392  case AV_PKT_DATA_MPEGTS_STREAM_ID: return "MPEGTS Stream ID";
393  case AV_PKT_DATA_MASTERING_DISPLAY_METADATA: return "Mastering display metadata";
394  case AV_PKT_DATA_CONTENT_LIGHT_LEVEL: return "Content light level metadata";
395  case AV_PKT_DATA_SPHERICAL: return "Spherical Mapping";
396  case AV_PKT_DATA_A53_CC: return "A53 Closed Captions";
397  case AV_PKT_DATA_ENCRYPTION_INIT_INFO: return "Encryption initialization data";
398  case AV_PKT_DATA_ENCRYPTION_INFO: return "Encryption info";
399  case AV_PKT_DATA_AFD: return "Active Format Description data";
400  case AV_PKT_DATA_PRFT: return "Producer Reference Time";
401  case AV_PKT_DATA_ICC_PROFILE: return "ICC Profile";
402  case AV_PKT_DATA_DOVI_CONF: return "DOVI configuration record";
403  }
404  return NULL;
405 }
406 
407 #if FF_API_MERGE_SD_API
408 
409 #define FF_MERGE_MARKER 0x8c4d9d108e25e9feULL
410 
412  if(pkt->side_data_elems){
413  AVBufferRef *buf;
414  int i;
415  uint8_t *p;
416  uint64_t size= pkt->size + 8LL + AV_INPUT_BUFFER_PADDING_SIZE;
417  AVPacket old= *pkt;
418  for (i=0; i<old.side_data_elems; i++) {
419  size += old.side_data[i].size + 5LL;
420  }
421  if (size > INT_MAX)
422  return AVERROR(EINVAL);
423  buf = av_buffer_alloc(size);
424  if (!buf)
425  return AVERROR(ENOMEM);
426  pkt->buf = buf;
427  pkt->data = p = buf->data;
429  bytestream_put_buffer(&p, old.data, old.size);
430  for (i=old.side_data_elems-1; i>=0; i--) {
432  bytestream_put_be32(&p, old.side_data[i].size);
433  *p++ = old.side_data[i].type | ((i==old.side_data_elems-1)*128);
434  }
435  bytestream_put_be64(&p, FF_MERGE_MARKER);
436  av_assert0(p-pkt->data == pkt->size);
437  memset(p, 0, AV_INPUT_BUFFER_PADDING_SIZE);
438  av_packet_unref(&old);
439  pkt->side_data_elems = 0;
440  pkt->side_data = NULL;
441  return 1;
442  }
443  return 0;
444 }
445 
447  if (!pkt->side_data_elems && pkt->size >12 && AV_RB64(pkt->data + pkt->size - 8) == FF_MERGE_MARKER){
448  int i;
449  unsigned int size;
450  uint8_t *p;
451 
452  p = pkt->data + pkt->size - 8 - 5;
453  for (i=1; ; i++){
454  size = AV_RB32(p);
455  if (size>INT_MAX - 5 || p - pkt->data < size)
456  return 0;
457  if (p[4]&128)
458  break;
459  if (p - pkt->data < size + 5)
460  return 0;
461  p-= size+5;
462  }
463 
464  if (i > AV_PKT_DATA_NB)
465  return AVERROR(ERANGE);
466 
467  pkt->side_data = av_malloc_array(i, sizeof(*pkt->side_data));
468  if (!pkt->side_data)
469  return AVERROR(ENOMEM);
470 
471  p= pkt->data + pkt->size - 8 - 5;
472  for (i=0; ; i++){
473  size= AV_RB32(p);
474  av_assert0(size<=INT_MAX - 5 && p - pkt->data >= size);
476  pkt->side_data[i].size = size;
477  pkt->side_data[i].type = p[4]&127;
478  if (!pkt->side_data[i].data)
479  return AVERROR(ENOMEM);
480  memcpy(pkt->side_data[i].data, p-size, size);
481  pkt->size -= size + 5;
482  if(p[4]&128)
483  break;
484  p-= size+5;
485  }
486  pkt->size -= 8;
487  pkt->side_data_elems = i+1;
488  return 1;
489  }
490  return 0;
491 }
492 #endif
493 
495 {
496  AVDictionaryEntry *t = NULL;
497  uint8_t *data = NULL;
498  *size = 0;
499 
500  if (!dict)
501  return NULL;
502 
503  while ((t = av_dict_get(dict, "", t, AV_DICT_IGNORE_SUFFIX))) {
504  const size_t keylen = strlen(t->key);
505  const size_t valuelen = strlen(t->value);
506  const size_t new_size = *size + keylen + 1 + valuelen + 1;
507  uint8_t *const new_data = av_realloc(data, new_size);
508 
509  if (!new_data)
510  goto fail;
511  data = new_data;
512  if (new_size > INT_MAX)
513  goto fail;
514 
515  memcpy(data + *size, t->key, keylen + 1);
516  memcpy(data + *size + keylen + 1, t->value, valuelen + 1);
517 
518  *size = new_size;
519  }
520 
521  return data;
522 
523 fail:
524  av_freep(&data);
525  *size = 0;
526  return NULL;
527 }
528 
530 {
531  const uint8_t *end;
532  int ret;
533 
534  if (!dict || !data || !size)
535  return 0;
536  end = data + size;
537  if (size && end[-1])
538  return AVERROR_INVALIDDATA;
539  while (data < end) {
540  const uint8_t *key = data;
541  const uint8_t *val = data + strlen(key) + 1;
542 
543  if (val >= end || !*key)
544  return AVERROR_INVALIDDATA;
545 
546  ret = av_dict_set(dict, key, val, 0);
547  if (ret < 0)
548  return ret;
549  data = val + strlen(val) + 1;
550  }
551 
552  return 0;
553 }
554 
556  int size)
557 {
558  int i;
559 
560  for (i = 0; i < pkt->side_data_elems; i++) {
561  if (pkt->side_data[i].type == type) {
562  if (size > pkt->side_data[i].size)
563  return AVERROR(ENOMEM);
564  pkt->side_data[i].size = size;
565  return 0;
566  }
567  }
568  return AVERROR(ENOENT);
569 }
570 
572 {
573  int i;
574 
575  dst->pts = src->pts;
576  dst->dts = src->dts;
577  dst->pos = src->pos;
578  dst->duration = src->duration;
579 #if FF_API_CONVERGENCE_DURATION
581  dst->convergence_duration = src->convergence_duration;
583 #endif
584  dst->flags = src->flags;
585  dst->stream_index = src->stream_index;
586 
587  dst->side_data = NULL;
588  dst->side_data_elems = 0;
589  for (i = 0; i < src->side_data_elems; i++) {
590  enum AVPacketSideDataType type = src->side_data[i].type;
591  int size = src->side_data[i].size;
592  uint8_t *src_data = src->side_data[i].data;
593  uint8_t *dst_data = av_packet_new_side_data(dst, type, size);
594 
595  if (!dst_data) {
597  return AVERROR(ENOMEM);
598  }
599  memcpy(dst_data, src_data, size);
600  }
601 
602  return 0;
603 }
604 
606 {
610  pkt->data = NULL;
611  pkt->size = 0;
612 }
613 
615 {
616  int ret;
617 
618  dst->buf = NULL;
619 
620  ret = av_packet_copy_props(dst, src);
621  if (ret < 0)
622  goto fail;
623 
624  if (!src->buf) {
625  ret = packet_alloc(&dst->buf, src->size);
626  if (ret < 0)
627  goto fail;
628  av_assert1(!src->size || src->data);
629  if (src->size)
630  memcpy(dst->buf->data, src->data, src->size);
631 
632  dst->data = dst->buf->data;
633  } else {
634  dst->buf = av_buffer_ref(src->buf);
635  if (!dst->buf) {
636  ret = AVERROR(ENOMEM);
637  goto fail;
638  }
639  dst->data = src->data;
640  }
641 
642  dst->size = src->size;
643 
644  return 0;
645 fail:
646  av_packet_unref(dst);
647  return ret;
648 }
649 
651 {
653 
654  if (!ret)
655  return ret;
656 
657  if (av_packet_ref(ret, src))
659 
660  return ret;
661 }
662 
664 {
665  *dst = *src;
667  src->data = NULL;
668  src->size = 0;
669 }
670 
672 {
673  int ret;
674 
675  if (pkt->buf)
676  return 0;
677 
678  ret = packet_alloc(&pkt->buf, pkt->size);
679  if (ret < 0)
680  return ret;
681  av_assert1(!pkt->size || pkt->data);
682  if (pkt->size)
683  memcpy(pkt->buf->data, pkt->data, pkt->size);
684 
685  pkt->data = pkt->buf->data;
686 
687  return 0;
688 }
689 
691 {
692  AVBufferRef *buf = NULL;
693  int ret;
694 
695  if (pkt->buf && av_buffer_is_writable(pkt->buf))
696  return 0;
697 
698  ret = packet_alloc(&buf, pkt->size);
699  if (ret < 0)
700  return ret;
701  av_assert1(!pkt->size || pkt->data);
702  if (pkt->size)
703  memcpy(buf->data, pkt->data, pkt->size);
704 
706  pkt->buf = buf;
707  pkt->data = buf->data;
708 
709  return 0;
710 }
711 
713 {
714  if (pkt->pts != AV_NOPTS_VALUE)
715  pkt->pts = av_rescale_q(pkt->pts, src_tb, dst_tb);
716  if (pkt->dts != AV_NOPTS_VALUE)
717  pkt->dts = av_rescale_q(pkt->dts, src_tb, dst_tb);
718  if (pkt->duration > 0)
719  pkt->duration = av_rescale_q(pkt->duration, src_tb, dst_tb);
720 #if FF_API_CONVERGENCE_DURATION
722  if (pkt->convergence_duration > 0)
723  pkt->convergence_duration = av_rescale_q(pkt->convergence_duration, src_tb, dst_tb);
725 #endif
726 }
727 
728 int ff_side_data_set_encoder_stats(AVPacket *pkt, int quality, int64_t *error, int error_count, int pict_type)
729 {
730  uint8_t *side_data;
731  int side_data_size;
732  int i;
733 
734  side_data = av_packet_get_side_data(pkt, AV_PKT_DATA_QUALITY_STATS, &side_data_size);
735  if (!side_data) {
736  side_data_size = 4+4+8*error_count;
738  side_data_size);
739  }
740 
741  if (!side_data || side_data_size < 4+4+8*error_count)
742  return AVERROR(ENOMEM);
743 
744  AV_WL32(side_data , quality );
745  side_data[4] = pict_type;
746  side_data[5] = error_count;
747  for (i = 0; i<error_count; i++)
748  AV_WL64(side_data+8 + 8*i , error[i]);
749 
750  return 0;
751 }
752 
753 int ff_side_data_set_prft(AVPacket *pkt, int64_t timestamp)
754 {
756  uint8_t *side_data;
757  int side_data_size;
758 
759  side_data = av_packet_get_side_data(pkt, AV_PKT_DATA_PRFT, &side_data_size);
760  if (!side_data) {
761  side_data_size = sizeof(AVProducerReferenceTime);
762  side_data = av_packet_new_side_data(pkt, AV_PKT_DATA_PRFT, side_data_size);
763  }
764 
765  if (!side_data || side_data_size < sizeof(AVProducerReferenceTime))
766  return AVERROR(ENOMEM);
767 
768  prft = (AVProducerReferenceTime *)side_data;
769  prft->wallclock = timestamp;
770  prft->flags = 0;
771 
772  return 0;
773 }
error
static void error(const char *err)
Definition: target_bsf_fuzzer.c:29
av_packet_unref
void av_packet_unref(AVPacket *pkt)
Wipe the packet.
Definition: avpacket.c:605
FF_ENABLE_DEPRECATION_WARNINGS
#define FF_ENABLE_DEPRECATION_WARNINGS
Definition: internal.h:85
av_buffer_alloc
AVBufferRef * av_buffer_alloc(int size)
Allocate an AVBuffer of the given size using av_malloc().
Definition: buffer.c:67
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_PKT_DATA_NB
@ AV_PKT_DATA_NB
The number of side data types.
Definition: packet.h:293
av_buffer_realloc
int av_buffer_realloc(AVBufferRef **pbuf, int size)
Reallocate a given buffer.
Definition: buffer.c:169
AV_WL32
#define AV_WL32(p, v)
Definition: intreadwrite.h:426
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:215
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:72
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:728
AVBufferRef::data
uint8_t * data
The data buffer.
Definition: buffer.h:89
av_grow_packet
int av_grow_packet(AVPacket *pkt, int grow_by)
Increase packet size, correctly zeroing padding.
Definition: avpacket.c:111
end
static av_cold int end(AVCodecContext *avctx)
Definition: avrndec.c:92
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:255
tmp
static uint8_t tmp[11]
Definition: aes_ctr.c:26
AVPacketSideData
Definition: packet.h:298
AVProducerReferenceTime::wallclock
int64_t wallclock
A UTC timestamp, in microseconds, since Unix epoch (e.g, av_gettime()).
Definition: avcodec.h:502
internal.h
AVPacket::data
uint8_t * data
Definition: packet.h:355
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:46
data
const char data[16]
Definition: mxf.c:91
AV_PKT_DATA_ENCRYPTION_INIT_INFO
@ AV_PKT_DATA_ENCRYPTION_INIT_INFO
This side data is encryption initialization data.
Definition: packet.h:249
AV_DICT_IGNORE_SUFFIX
#define AV_DICT_IGNORE_SUFFIX
Return first entry in a dictionary whose first part corresponds to the search key,...
Definition: dict.h:70
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:261
av_buffer_create
AVBufferRef * av_buffer_create(uint8_t *data, int size, void(*free)(void *opaque, uint8_t *data), void *opaque, int flags)
Create an AVBuffer from an existing array.
Definition: buffer.c:29
AVPacket::duration
int64_t duration
Duration of this packet in AVStream->time_base units, 0 if unknown.
Definition: packet.h:373
mathematics.h
AVDictionary
Definition: dict.c:30
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:228
av_packet_free_side_data
FF_ENABLE_DEPRECATION_WARNINGS void av_packet_free_side_data(AVPacket *pkt)
Convenience function to free all the side data stored.
Definition: avpacket.c:273
packet_alloc
static int packet_alloc(AVBufferRef **buf, int size)
Definition: avpacket.c:73
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:64
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
AVBufferRef::size
int size
Size of data in bytes.
Definition: buffer.h:93
av_packet_add_side_data
FF_ENABLE_DEPRECATION_WARNINGS 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:298
fail
#define fail()
Definition: checkasm.h:123
av_packet_pack_dictionary
uint8_t * av_packet_pack_dictionary(AVDictionary *dict, int *size)
Pack a dictionary for use in side_data.
Definition: avpacket.c:494
av_shrink_packet
void av_shrink_packet(AVPacket *pkt, int size)
Reduce packet size, correctly zeroing padding.
Definition: avpacket.c:103
ff_side_data_set_prft
int ff_side_data_set_prft(AVPacket *pkt, int64_t timestamp)
Definition: avpacket.c:753
av_packet_shrink_side_data
int av_packet_shrink_side_data(AVPacket *pkt, enum AVPacketSideDataType type, int size)
Shrink the already allocated side data buffer.
Definition: avpacket.c:555
val
static double val(void *priv, double ch)
Definition: aeval.c:76
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
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:108
AV_PKT_DATA_STRINGS_METADATA
@ AV_PKT_DATA_STRINGS_METADATA
A list of zero terminated key/value strings.
Definition: packet.h:172
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:99
av_packet_side_data_name
const char * av_packet_side_data_name(enum AVPacketSideDataType type)
Definition: avpacket.c:370
avassert.h
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:202
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:120
av_dict_get
AVDictionaryEntry * av_dict_get(const AVDictionary *m, const char *key, const AVDictionaryEntry *prev, int flags)
Get a dictionary entry with matching key.
Definition: dict.c:40
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:88
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:114
AV_PKT_DATA_MASTERING_DISPLAY_METADATA
@ AV_PKT_DATA_MASTERING_DISPLAY_METADATA
Mastering display metadata (based on SMPTE-2086:2014).
Definition: packet.h:222
AVDictionaryEntry::key
char * key
Definition: dict.h:82
copy_packet_data
static int copy_packet_data(AVPacket *pkt, const AVPacket *src, int dup)
Definition: avpacket.c:201
av_packet_split_side_data
int av_packet_split_side_data(AVPacket *pkt)
Definition: avpacket.c:446
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:62
av_assert0
#define av_assert0(cond)
assert() equivalent, that is always enabled.
Definition: avassert.h:37
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:274
FF_MERGE_MARKER
#define FF_MERGE_MARKER
Definition: avpacket.c:409
AVPacketSideData::data
uint8_t * data
Definition: packet.h:299
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_copy_packet_side_data
int av_copy_packet_side_data(AVPacket *pkt, const AVPacket *src)
Definition: avpacket.c:229
key
const char * key
Definition: hwcontext_opencl.c:168
AV_PKT_DATA_PRFT
@ AV_PKT_DATA_PRFT
Producer Reference Time data corresponding to the AVProducerReferenceTime struct, usually exported by...
Definition: packet.h:268
av_packet_new_side_data
uint8_t * av_packet_new_side_data(AVPacket *pkt, enum AVPacketSideDataType type, int size)
Allocate new information of a packet.
Definition: avpacket.c:332
ALLOC_MALLOC
#define ALLOC_MALLOC(data, size)
Definition: avpacket.c:173
av_packet_get_side_data
uint8_t * av_packet_get_side_data(const AVPacket *pkt, enum AVPacketSideDataType type, int *size)
Get side information from packet.
Definition: avpacket.c:353
AVPacket::buf
AVBufferRef * buf
A reference to the reference-counted buffer where the packet data is stored.
Definition: packet.h:338
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:125
AVRational
Rational number (pair of numerator and denominator).
Definition: rational.h:58
AVPacketSideData::type
enum AVPacketSideDataType type
Definition: packet.h:301
src
#define src
Definition: vp8dsp.c:254
av_dup_packet
int av_dup_packet(AVPacket *pkt)
Definition: avpacket.c:254
AV_PKT_DATA_SUBTITLE_POSITION
@ AV_PKT_DATA_SUBTITLE_POSITION
Subtitle event position.
Definition: packet.h:183
AVProducerReferenceTime
This structure supplies correlation between a packet timestamp and a wall clock production time.
Definition: avcodec.h:498
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:614
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:663
AVProducerReferenceTime::flags
int flags
Definition: avcodec.h:503
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:155
AVPacket::size
int size
Definition: packet.h:356
size
int size
Definition: twinvq_data.h:11134
AV_NOPTS_VALUE
#define AV_NOPTS_VALUE
Undefined timestamp value.
Definition: avutil.h:248
AV_RB32
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_WL16 uint64_t_TMPL AV_WB64 unsigned int_TMPL AV_RB32
Definition: bytestream.h:92
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:93
AVPacket::dts
int64_t dts
Decompression timestamp in AVStream->time_base units; the time at which the packet is decompressed.
Definition: packet.h:354
AV_WL64
#define AV_WL64(p, v)
Definition: intreadwrite.h:440
AVPacketSideData::size
int size
Definition: packet.h:300
AVPacketSideDataType
AVPacketSideDataType
Definition: packet.h:40
AV_PKT_DATA_CONTENT_LIGHT_LEVEL
@ AV_PKT_DATA_CONTENT_LIGHT_LEVEL
Content light level (based on CTA-861.3).
Definition: packet.h:235
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:671
AVPacket::flags
int flags
A combination of AV_PKT_FLAG values.
Definition: packet.h:361
av_packet_alloc
AVPacket * av_packet_alloc(void)
Allocate an AVPacket and set its fields to default values.
Definition: avpacket.c:53
av_packet_unpack_dictionary
int av_packet_unpack_dictionary(const uint8_t *data, int size, AVDictionary **dict)
Unpack a dictionary from side_data.
Definition: avpacket.c:529
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:712
AV_PKT_DATA_METADATA_UPDATE
@ AV_PKT_DATA_METADATA_UPDATE
A list of zero terminated key/value strings.
Definition: packet.h:209
av_realloc
void * av_realloc(void *ptr, size_t size)
Allocate, reallocate, or free a block of memory.
Definition: mem.c:134
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:166
bytestream_put_buffer
static av_always_inline void bytestream_put_buffer(uint8_t **b, const uint8_t *src, unsigned int size)
Definition: bytestream.h:368
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:571
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:269
AVPacket::pts
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
Definition: packet.h:348
packet.h
DUP_DATA
#define DUP_DATA(dst, src, size, padding, ALLOC)
Definition: avpacket.c:180
internal.h
av_malloc_array
#define av_malloc_array(a, b)
Definition: tableprint_vlc.h:32
common.h
av_assert1
#define av_assert1(cond)
assert() equivalent, that does not lie in speed critical code.
Definition: avassert.h:53
AV_PKT_DATA_A53_CC
@ AV_PKT_DATA_A53_CC
ATSC A53 Part 4 Closed Captions.
Definition: packet.h:242
uint8_t
uint8_t
Definition: audio_convert.c:194
av_packet_merge_side_data
int av_packet_merge_side_data(AVPacket *pkt)
Definition: avpacket.c:411
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:237
AV_PKT_DATA_CPB_PROPERTIES
@ AV_PKT_DATA_CPB_PROPERTIES
This side data corresponds to the AVCPBProperties struct.
Definition: packet.h:145
AV_PKT_DATA_SKIP_SAMPLES
@ AV_PKT_DATA_SKIP_SAMPLES
Recommmends skipping the specified number of samples.
Definition: packet.h:156
av_copy_packet
int av_copy_packet(AVPacket *dst, const AVPacket *src)
Definition: avpacket.c:265
av_buffer_is_writable
int av_buffer_is_writable(const AVBufferRef *buf)
Definition: buffer.c:133
av_free_packet
FF_DISABLE_DEPRECATION_WARNINGS void av_free_packet(AVPacket *pkt)
Definition: avpacket.c:284
ALLOC_BUF
#define ALLOC_BUF(data, size)
Definition: avpacket.c:174
ret
ret
Definition: filter_design.txt:187
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:283
AVPacket::side_data
AVPacketSideData * side_data
Additional packet data that can be provided by the container.
Definition: packet.h:366
AV_INPUT_BUFFER_PADDING_SIZE
#define AV_INPUT_BUFFER_PADDING_SIZE
Definition: avcodec.h:215
pkt
static AVPacket pkt
Definition: demuxing_decoding.c:54
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:55
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:690
ref
static int ref[MAX_W *MAX_W]
Definition: jpeg2000dwt.c:107
AVPacket::stream_index
int stream_index
Definition: packet.h:357
av_buffer_ref
AVBufferRef * av_buffer_ref(AVBufferRef *buf)
Create a new reference to an AVBuffer.
Definition: buffer.c:93
FF_DISABLE_DEPRECATION_WARNINGS
#define FF_DISABLE_DEPRECATION_WARNINGS
Definition: internal.h:84
mem.h
AVBufferRef
A reference to a data buffer.
Definition: buffer.h:81
packet_internal.h
AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL
@ AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL
Data found in BlockAdditional element of matroska container.
Definition: packet.h:191
av_free
#define av_free(p)
Definition: tableprint_vlc.h:34
AVDictionaryEntry
Definition: dict.h:81
AVPacket
This structure stores compressed data.
Definition: packet.h:332
av_freep
#define av_freep(p)
Definition: tableprint_vlc.h:35
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:70
AVPacket::pos
int64_t pos
byte position in stream, -1 if unknown
Definition: packet.h:375
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:140
bytestream.h
AV_PKT_DATA_QUALITY_STATS
@ AV_PKT_DATA_QUALITY_STATS
This side data contains quality related information from the encoder.
Definition: packet.h:132
AVERROR_INVALIDDATA
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
Definition: error.h:59
AV_PKT_DATA_WEBVTT_IDENTIFIER
@ AV_PKT_DATA_WEBVTT_IDENTIFIER
The optional first identifier line of a WebVTT cue.
Definition: packet.h:196
AVDictionaryEntry::value
char * value
Definition: dict.h:83
AV_RB64
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_WL16 uint64_t_TMPL AV_RB64
Definition: bytestream.h:91
AVPacket::side_data_elems
int side_data_elems
Definition: packet.h:367
av_packet_clone
AVPacket * av_packet_clone(const AVPacket *src)
Create a new packet that references the same data as src.
Definition: avpacket.c:650
av_init_packet
void av_init_packet(AVPacket *pkt)
Initialize optional fields of a packet with default values.
Definition: avpacket.c:35