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 #include "avcodec.h"
30 #include "bytestream.h"
31 #include "internal.h"
32 
34 {
37  pkt->pos = -1;
38  pkt->duration = 0;
39 #if FF_API_CONVERGENCE_DURATION
43 #endif
44  pkt->flags = 0;
45  pkt->stream_index = 0;
46  pkt->buf = NULL;
47  pkt->side_data = NULL;
48  pkt->side_data_elems = 0;
49 }
50 
52 {
53  AVPacket *pkt = av_mallocz(sizeof(AVPacket));
54  if (!pkt)
55  return pkt;
56 
58 
59  return pkt;
60 }
61 
63 {
64  if (!pkt || !*pkt)
65  return;
66 
68  av_freep(pkt);
69 }
70 
71 static int packet_alloc(AVBufferRef **buf, int size)
72 {
73  int ret;
74  if (size < 0 || size >= INT_MAX - AV_INPUT_BUFFER_PADDING_SIZE)
75  return AVERROR(EINVAL);
76 
78  if (ret < 0)
79  return ret;
80 
81  memset((*buf)->data + size, 0, AV_INPUT_BUFFER_PADDING_SIZE);
82 
83  return 0;
84 }
85 
87 {
88  AVBufferRef *buf = NULL;
89  int ret = packet_alloc(&buf, size);
90  if (ret < 0)
91  return ret;
92 
94  pkt->buf = buf;
95  pkt->data = buf->data;
96  pkt->size = size;
97 
98  return 0;
99 }
100 
102 {
103  if (pkt->size <= size)
104  return;
105  pkt->size = size;
106  memset(pkt->data + size, 0, AV_INPUT_BUFFER_PADDING_SIZE);
107 }
108 
109 int av_grow_packet(AVPacket *pkt, int grow_by)
110 {
111  int new_size;
112  av_assert0((unsigned)pkt->size <= INT_MAX - AV_INPUT_BUFFER_PADDING_SIZE);
113  if ((unsigned)grow_by >
114  INT_MAX - (pkt->size + AV_INPUT_BUFFER_PADDING_SIZE))
115  return AVERROR(ENOMEM);
116 
117  new_size = pkt->size + grow_by + AV_INPUT_BUFFER_PADDING_SIZE;
118  if (pkt->buf) {
119  size_t data_offset;
120  uint8_t *old_data = pkt->data;
121  if (pkt->data == NULL) {
122  data_offset = 0;
123  pkt->data = pkt->buf->data;
124  } else {
125  data_offset = pkt->data - pkt->buf->data;
126  if (data_offset > INT_MAX - new_size)
127  return AVERROR(ENOMEM);
128  }
129 
130  if (new_size + data_offset > pkt->buf->size) {
131  int ret = av_buffer_realloc(&pkt->buf, new_size + data_offset);
132  if (ret < 0) {
133  pkt->data = old_data;
134  return ret;
135  }
136  pkt->data = pkt->buf->data + data_offset;
137  }
138  } else {
139  pkt->buf = av_buffer_alloc(new_size);
140  if (!pkt->buf)
141  return AVERROR(ENOMEM);
142  if (pkt->size > 0)
143  memcpy(pkt->buf->data, pkt->data, pkt->size);
144  pkt->data = pkt->buf->data;
145  }
146  pkt->size += grow_by;
147  memset(pkt->data + pkt->size, 0, AV_INPUT_BUFFER_PADDING_SIZE);
148 
149  return 0;
150 }
151 
153 {
154  if (size >= INT_MAX - AV_INPUT_BUFFER_PADDING_SIZE)
155  return AVERROR(EINVAL);
156 
159  if (!pkt->buf)
160  return AVERROR(ENOMEM);
161 
162  pkt->data = data;
163  pkt->size = size;
164 
165  return 0;
166 }
167 
168 #if FF_API_AVPACKET_OLD_API
170 #define ALLOC_MALLOC(data, size) data = av_malloc(size)
171 #define ALLOC_BUF(data, size) \
172 do { \
173  av_buffer_realloc(&pkt->buf, size); \
174  data = pkt->buf ? pkt->buf->data : NULL; \
175 } while (0)
176 
177 #define DUP_DATA(dst, src, size, padding, ALLOC) \
178  do { \
179  void *data; \
180  if (padding) { \
181  if ((unsigned)(size) > \
182  (unsigned)(size) + AV_INPUT_BUFFER_PADDING_SIZE) \
183  goto failed_alloc; \
184  ALLOC(data, size + AV_INPUT_BUFFER_PADDING_SIZE); \
185  } else { \
186  ALLOC(data, size); \
187  } \
188  if (!data) \
189  goto failed_alloc; \
190  memcpy(data, src, size); \
191  if (padding) \
192  memset((uint8_t *)data + size, 0, \
193  AV_INPUT_BUFFER_PADDING_SIZE); \
194  dst = data; \
195  } while (0)
196 
197 /* Makes duplicates of data, side_data, but does not copy any other fields */
198 static int copy_packet_data(AVPacket *pkt, const AVPacket *src, int dup)
199 {
200  pkt->data = NULL;
201  pkt->side_data = NULL;
202  pkt->side_data_elems = 0;
203  if (pkt->buf) {
204  AVBufferRef *ref = av_buffer_ref(src->buf);
205  if (!ref)
206  return AVERROR(ENOMEM);
207  pkt->buf = ref;
208  pkt->data = ref->data;
209  } else {
210  DUP_DATA(pkt->data, src->data, pkt->size, 1, ALLOC_BUF);
211  }
212  if (src->side_data_elems && dup) {
213  pkt->side_data = src->side_data;
214  pkt->side_data_elems = src->side_data_elems;
215  }
216  if (src->side_data_elems && !dup) {
218  }
219  return 0;
220 
221 failed_alloc:
223  return AVERROR(ENOMEM);
224 }
225 
227 {
228  if (src->side_data_elems) {
229  int i;
230  DUP_DATA(pkt->side_data, src->side_data,
231  src->side_data_elems * sizeof(*src->side_data), 0, ALLOC_MALLOC);
232  if (src != pkt) {
233  memset(pkt->side_data, 0,
234  src->side_data_elems * sizeof(*src->side_data));
235  }
236  for (i = 0; i < src->side_data_elems; i++) {
237  DUP_DATA(pkt->side_data[i].data, src->side_data[i].data,
238  src->side_data[i].size, 1, ALLOC_MALLOC);
239  pkt->side_data[i].size = src->side_data[i].size;
240  pkt->side_data[i].type = src->side_data[i].type;
241  }
242  }
243  pkt->side_data_elems = src->side_data_elems;
244  return 0;
245 
246 failed_alloc:
248  return AVERROR(ENOMEM);
249 }
250 
252 {
253  AVPacket tmp_pkt;
254 
255  if (!pkt->buf && pkt->data) {
256  tmp_pkt = *pkt;
257  return copy_packet_data(pkt, &tmp_pkt, 1);
258  }
259  return 0;
260 }
261 
263 {
264  *dst = *src;
265  return copy_packet_data(dst, src, 0);
266 }
268 #endif
269 
271 {
272  int i;
273  for (i = 0; i < pkt->side_data_elems; i++)
276  pkt->side_data_elems = 0;
277 }
278 
279 #if FF_API_AVPACKET_OLD_API
282 {
283  if (pkt) {
284  if (pkt->buf)
286  pkt->data = NULL;
287  pkt->size = 0;
288 
290  }
291 }
293 #endif
294 
296  uint8_t *data, size_t size)
297 {
299  int i, elems = pkt->side_data_elems;
300 
301  for (i = 0; i < elems; i++) {
302  AVPacketSideData *sd = &pkt->side_data[i];
303 
304  if (sd->type == type) {
305  av_free(sd->data);
306  sd->data = data;
307  sd->size = size;
308  return 0;
309  }
310  }
311 
312  if ((unsigned)elems + 1 > AV_PKT_DATA_NB)
313  return AVERROR(ERANGE);
314 
315  tmp = av_realloc(pkt->side_data, (elems + 1) * sizeof(*tmp));
316  if (!tmp)
317  return AVERROR(ENOMEM);
318 
319  pkt->side_data = tmp;
320  pkt->side_data[elems].data = data;
321  pkt->side_data[elems].size = size;
322  pkt->side_data[elems].type = type;
323  pkt->side_data_elems++;
324 
325  return 0;
326 }
327 
328 
330  int size)
331 {
332  int ret;
333  uint8_t *data;
334 
335  if ((unsigned)size > INT_MAX - AV_INPUT_BUFFER_PADDING_SIZE)
336  return NULL;
338  if (!data)
339  return NULL;
340 
342  if (ret < 0) {
343  av_freep(&data);
344  return NULL;
345  }
346 
347  return data;
348 }
349 
351  int *size)
352 {
353  int i;
354 
355  for (i = 0; i < pkt->side_data_elems; i++) {
356  if (pkt->side_data[i].type == type) {
357  if (size)
358  *size = pkt->side_data[i].size;
359  return pkt->side_data[i].data;
360  }
361  }
362  if (size)
363  *size = 0;
364  return NULL;
365 }
366 
368 {
369  switch(type) {
370  case AV_PKT_DATA_PALETTE: return "Palette";
371  case AV_PKT_DATA_NEW_EXTRADATA: return "New Extradata";
372  case AV_PKT_DATA_PARAM_CHANGE: return "Param Change";
373  case AV_PKT_DATA_H263_MB_INFO: return "H263 MB Info";
374  case AV_PKT_DATA_REPLAYGAIN: return "Replay Gain";
375  case AV_PKT_DATA_DISPLAYMATRIX: return "Display Matrix";
376  case AV_PKT_DATA_STEREO3D: return "Stereo 3D";
377  case AV_PKT_DATA_AUDIO_SERVICE_TYPE: return "Audio Service Type";
378  case AV_PKT_DATA_QUALITY_STATS: return "Quality stats";
379  case AV_PKT_DATA_FALLBACK_TRACK: return "Fallback track";
380  case AV_PKT_DATA_CPB_PROPERTIES: return "CPB properties";
381  case AV_PKT_DATA_SKIP_SAMPLES: return "Skip Samples";
382  case AV_PKT_DATA_JP_DUALMONO: return "JP Dual Mono";
383  case AV_PKT_DATA_STRINGS_METADATA: return "Strings Metadata";
384  case AV_PKT_DATA_SUBTITLE_POSITION: return "Subtitle Position";
385  case AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL: return "Matroska BlockAdditional";
386  case AV_PKT_DATA_WEBVTT_IDENTIFIER: return "WebVTT ID";
387  case AV_PKT_DATA_WEBVTT_SETTINGS: return "WebVTT Settings";
388  case AV_PKT_DATA_METADATA_UPDATE: return "Metadata Update";
389  case AV_PKT_DATA_MPEGTS_STREAM_ID: return "MPEGTS Stream ID";
390  case AV_PKT_DATA_MASTERING_DISPLAY_METADATA: return "Mastering display metadata";
391  case AV_PKT_DATA_CONTENT_LIGHT_LEVEL: return "Content light level metadata";
392  case AV_PKT_DATA_SPHERICAL: return "Spherical Mapping";
393  case AV_PKT_DATA_A53_CC: return "A53 Closed Captions";
394  case AV_PKT_DATA_ENCRYPTION_INIT_INFO: return "Encryption initialization data";
395  case AV_PKT_DATA_ENCRYPTION_INFO: return "Encryption info";
396  case AV_PKT_DATA_AFD: return "Active Format Description data";
397  }
398  return NULL;
399 }
400 
401 #if FF_API_MERGE_SD_API
402 
403 #define FF_MERGE_MARKER 0x8c4d9d108e25e9feULL
404 
406  if(pkt->side_data_elems){
407  AVBufferRef *buf;
408  int i;
409  uint8_t *p;
410  uint64_t size= pkt->size + 8LL + AV_INPUT_BUFFER_PADDING_SIZE;
411  AVPacket old= *pkt;
412  for (i=0; i<old.side_data_elems; i++) {
413  size += old.side_data[i].size + 5LL;
414  }
415  if (size > INT_MAX)
416  return AVERROR(EINVAL);
418  if (!buf)
419  return AVERROR(ENOMEM);
420  pkt->buf = buf;
421  pkt->data = p = buf->data;
423  bytestream_put_buffer(&p, old.data, old.size);
424  for (i=old.side_data_elems-1; i>=0; i--) {
426  bytestream_put_be32(&p, old.side_data[i].size);
427  *p++ = old.side_data[i].type | ((i==old.side_data_elems-1)*128);
428  }
429  bytestream_put_be64(&p, FF_MERGE_MARKER);
430  av_assert0(p-pkt->data == pkt->size);
431  memset(p, 0, AV_INPUT_BUFFER_PADDING_SIZE);
432  av_packet_unref(&old);
433  pkt->side_data_elems = 0;
434  pkt->side_data = NULL;
435  return 1;
436  }
437  return 0;
438 }
439 
441  if (!pkt->side_data_elems && pkt->size >12 && AV_RB64(pkt->data + pkt->size - 8) == FF_MERGE_MARKER){
442  int i;
443  unsigned int size;
444  uint8_t *p;
445 
446  p = pkt->data + pkt->size - 8 - 5;
447  for (i=1; ; i++){
448  size = AV_RB32(p);
449  if (size>INT_MAX - 5 || p - pkt->data < size)
450  return 0;
451  if (p[4]&128)
452  break;
453  if (p - pkt->data < size + 5)
454  return 0;
455  p-= size+5;
456  }
457 
458  if (i > AV_PKT_DATA_NB)
459  return AVERROR(ERANGE);
460 
461  pkt->side_data = av_malloc_array(i, sizeof(*pkt->side_data));
462  if (!pkt->side_data)
463  return AVERROR(ENOMEM);
464 
465  p= pkt->data + pkt->size - 8 - 5;
466  for (i=0; ; i++){
467  size= AV_RB32(p);
468  av_assert0(size<=INT_MAX - 5 && p - pkt->data >= size);
470  pkt->side_data[i].size = size;
471  pkt->side_data[i].type = p[4]&127;
472  if (!pkt->side_data[i].data)
473  return AVERROR(ENOMEM);
474  memcpy(pkt->side_data[i].data, p-size, size);
475  pkt->size -= size + 5;
476  if(p[4]&128)
477  break;
478  p-= size+5;
479  }
480  pkt->size -= 8;
481  pkt->side_data_elems = i+1;
482  return 1;
483  }
484  return 0;
485 }
486 #endif
487 
489 {
490  AVDictionaryEntry *t = NULL;
491  uint8_t *data = NULL;
492  *size = 0;
493 
494  if (!dict)
495  return NULL;
496 
497  while ((t = av_dict_get(dict, "", t, AV_DICT_IGNORE_SUFFIX))) {
498  const size_t keylen = strlen(t->key);
499  const size_t valuelen = strlen(t->value);
500  const size_t new_size = *size + keylen + 1 + valuelen + 1;
501  uint8_t *const new_data = av_realloc(data, new_size);
502 
503  if (!new_data)
504  goto fail;
505  data = new_data;
506  if (new_size > INT_MAX)
507  goto fail;
508 
509  memcpy(data + *size, t->key, keylen + 1);
510  memcpy(data + *size + keylen + 1, t->value, valuelen + 1);
511 
512  *size = new_size;
513  }
514 
515  return data;
516 
517 fail:
518  av_freep(&data);
519  *size = 0;
520  return NULL;
521 }
522 
524 {
525  const uint8_t *end;
526  int ret = 0;
527 
528  if (!dict || !data || !size)
529  return ret;
530  end = data + size;
531  if (size && end[-1])
532  return AVERROR_INVALIDDATA;
533  while (data < end) {
534  const uint8_t *key = data;
535  const uint8_t *val = data + strlen(key) + 1;
536 
537  if (val >= end || !*key)
538  return AVERROR_INVALIDDATA;
539 
540  ret = av_dict_set(dict, key, val, 0);
541  if (ret < 0)
542  break;
543  data = val + strlen(val) + 1;
544  }
545 
546  return ret;
547 }
548 
550  int size)
551 {
552  int i;
553 
554  for (i = 0; i < pkt->side_data_elems; i++) {
555  if (pkt->side_data[i].type == type) {
556  if (size > pkt->side_data[i].size)
557  return AVERROR(ENOMEM);
558  pkt->side_data[i].size = size;
559  return 0;
560  }
561  }
562  return AVERROR(ENOENT);
563 }
564 
566 {
567  int i;
568 
569  dst->pts = src->pts;
570  dst->dts = src->dts;
571  dst->pos = src->pos;
572  dst->duration = src->duration;
573 #if FF_API_CONVERGENCE_DURATION
575  dst->convergence_duration = src->convergence_duration;
577 #endif
578  dst->flags = src->flags;
579  dst->stream_index = src->stream_index;
580 
581  dst->side_data = NULL;
582  dst->side_data_elems = 0;
583  for (i = 0; i < src->side_data_elems; i++) {
584  enum AVPacketSideDataType type = src->side_data[i].type;
585  int size = src->side_data[i].size;
586  uint8_t *src_data = src->side_data[i].data;
587  uint8_t *dst_data = av_packet_new_side_data(dst, type, size);
588 
589  if (!dst_data) {
591  return AVERROR(ENOMEM);
592  }
593  memcpy(dst_data, src_data, size);
594  }
595 
596  return 0;
597 }
598 
600 {
604  pkt->data = NULL;
605  pkt->size = 0;
606 }
607 
609 {
610  int ret;
611 
612  ret = av_packet_copy_props(dst, src);
613  if (ret < 0)
614  return ret;
615 
616  if (!src->buf) {
617  ret = packet_alloc(&dst->buf, src->size);
618  if (ret < 0)
619  goto fail;
620  av_assert1(!src->size || src->data);
621  if (src->size)
622  memcpy(dst->buf->data, src->data, src->size);
623 
624  dst->data = dst->buf->data;
625  } else {
626  dst->buf = av_buffer_ref(src->buf);
627  if (!dst->buf) {
628  ret = AVERROR(ENOMEM);
629  goto fail;
630  }
631  dst->data = src->data;
632  }
633 
634  dst->size = src->size;
635 
636  return 0;
637 fail:
639  return ret;
640 }
641 
643 {
645 
646  if (!ret)
647  return ret;
648 
649  if (av_packet_ref(ret, src))
651 
652  return ret;
653 }
654 
656 {
657  *dst = *src;
659  src->data = NULL;
660  src->size = 0;
661 }
662 
664 {
665  int ret;
666 
667  if (pkt->buf)
668  return 0;
669 
670  ret = packet_alloc(&pkt->buf, pkt->size);
671  if (ret < 0)
672  return ret;
673  av_assert1(!pkt->size || pkt->data);
674  if (pkt->size)
675  memcpy(pkt->buf->data, pkt->data, pkt->size);
676 
677  pkt->data = pkt->buf->data;
678 
679  return 0;
680 }
681 
683 {
684  AVBufferRef *buf = NULL;
685  int ret;
686 
687  if (pkt->buf && av_buffer_is_writable(pkt->buf))
688  return 0;
689 
690  ret = packet_alloc(&buf, pkt->size);
691  if (ret < 0)
692  return ret;
693  av_assert1(!pkt->size || pkt->data);
694  if (pkt->size)
695  memcpy(buf->data, pkt->data, pkt->size);
696 
698  pkt->buf = buf;
699  pkt->data = buf->data;
700 
701  return 0;
702 }
703 
705 {
706  if (pkt->pts != AV_NOPTS_VALUE)
707  pkt->pts = av_rescale_q(pkt->pts, src_tb, dst_tb);
708  if (pkt->dts != AV_NOPTS_VALUE)
709  pkt->dts = av_rescale_q(pkt->dts, src_tb, dst_tb);
710  if (pkt->duration > 0)
711  pkt->duration = av_rescale_q(pkt->duration, src_tb, dst_tb);
712 #if FF_API_CONVERGENCE_DURATION
714  if (pkt->convergence_duration > 0)
717 #endif
718 }
719 
720 int ff_side_data_set_encoder_stats(AVPacket *pkt, int quality, int64_t *error, int error_count, int pict_type)
721 {
722  uint8_t *side_data;
723  int side_data_size;
724  int i;
725 
726  side_data = av_packet_get_side_data(pkt, AV_PKT_DATA_QUALITY_STATS, &side_data_size);
727  if (!side_data) {
728  side_data_size = 4+4+8*error_count;
730  side_data_size);
731  }
732 
733  if (!side_data || side_data_size < 4+4+8*error_count)
734  return AVERROR(ENOMEM);
735 
736  AV_WL32(side_data , quality );
737  side_data[4] = pict_type;
738  side_data[5] = error_count;
739  for (i = 0; i<error_count; i++)
740  AV_WL64(side_data+8 + 8*i , error[i]);
741 
742  return 0;
743 }
av_packet_unref
void av_packet_unref(AVPacket *pkt)
Wipe the packet.
Definition: avpacket.c:599
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: avcodec.h:1415
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: avcodec.h:1359
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: avcodec.h:1216
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:720
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:109
av_free_packet
FF_DISABLE_DEPRECATION_WARNINGS void av_free_packet(AVPacket *pkt)
Free a packet.
Definition: avpacket.c:281
end
static av_cold int end(AVCodecContext *avctx)
Definition: avrndec.c:90
AV_PKT_DATA_ENCRYPTION_INFO
@ AV_PKT_DATA_ENCRYPTION_INFO
This side data contains encryption info for how to decrypt the packet.
Definition: avcodec.h:1399
tmp
static uint8_t tmp[11]
Definition: aes_ctr.c:26
AVPacketSideData
Definition: avcodec.h:1420
internal.h
AVPacket::data
uint8_t * data
Definition: avcodec.h:1477
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: avcodec.h:1190
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: avcodec.h:1393
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: avcodec.h:1405
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:28
AVPacket::duration
int64_t duration
Duration of this packet in AVStream->time_base units, 0 if unknown.
Definition: avcodec.h:1495
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: avcodec.h:1372
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:270
packet_alloc
static int packet_alloc(AVBufferRef **buf, int size)
Definition: avpacket.c:71
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:62
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_split_side_data
int av_packet_split_side_data(AVPacket *pkt)
Definition: avpacket.c:440
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:295
fail
#define fail()
Definition: checkasm.h:120
AVPacket::convergence_duration
attribute_deprecated int64_t convergence_duration
Definition: avcodec.h:1506
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:488
av_shrink_packet
void av_shrink_packet(AVPacket *pkt, int size)
Reduce packet size, correctly zeroing padding.
Definition: avpacket.c:101
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:549
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: avcodec.h:1252
src
#define src
Definition: vp8dsp.c:254
AV_PKT_DATA_STRINGS_METADATA
@ AV_PKT_DATA_STRINGS_METADATA
A list of zero terminated key/value strings.
Definition: avcodec.h:1316
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: avcodec.h:1243
av_packet_side_data_name
const char * av_packet_side_data_name(enum AVPacketSideDataType type)
Definition: avpacket.c:367
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: avcodec.h:1346
buf
void * buf
Definition: avisynth_c.h:766
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: avcodec.h:1264
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:86
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: avcodec.h:1258
AV_PKT_DATA_MASTERING_DISPLAY_METADATA
@ AV_PKT_DATA_MASTERING_DISPLAY_METADATA
Mastering display metadata (based on SMPTE-2086:2014).
Definition: avcodec.h:1366
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:198
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_dup_packet
int av_dup_packet(AVPacket *pkt)
Definition: avpacket.c:251
av_assert0
#define av_assert0(cond)
assert() equivalent, that is always enabled.
Definition: avassert.h:37
FF_MERGE_MARKER
#define FF_MERGE_MARKER
Definition: avpacket.c:403
AVPacketSideData::data
uint8_t * data
Definition: avcodec.h:1421
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
key
const char * key
Definition: hwcontext_opencl.c:168
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:329
ALLOC_MALLOC
#define ALLOC_MALLOC(data, size)
Definition: avpacket.c:170
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:350
AVPacket::buf
AVBufferRef * buf
A reference to the reference-counted buffer where the packet data is stored.
Definition: avcodec.h:1460
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: avcodec.h:1423
AV_PKT_DATA_SUBTITLE_POSITION
@ AV_PKT_DATA_SUBTITLE_POSITION
Subtitle event position.
Definition: avcodec.h:1327
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:608
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:655
error
static void error(const char *err)
Definition: target_dec_fuzzer.c:61
av_packet_merge_side_data
int av_packet_merge_side_data(AVPacket *pkt)
Definition: avpacket.c:405
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:152
AVPacket::size
int size
Definition: avcodec.h:1478
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: avcodec.h:1237
val
const char const char void * val
Definition: avisynth_c.h:863
AVPacket::dts
int64_t dts
Decompression timestamp in AVStream->time_base units; the time at which the packet is decompressed.
Definition: avcodec.h:1476
AV_WL64
#define AV_WL64(p, v)
Definition: intreadwrite.h:440
AVPacketSideData::size
int size
Definition: avcodec.h:1422
AVPacketSideDataType
AVPacketSideDataType
Definition: avcodec.h:1184
AV_PKT_DATA_CONTENT_LIGHT_LEVEL
@ AV_PKT_DATA_CONTENT_LIGHT_LEVEL
Content light level (based on CTA-861.3).
Definition: avcodec.h:1379
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:663
AVPacket::flags
int flags
A combination of AV_PKT_FLAG values.
Definition: avcodec.h:1483
av_packet_alloc
AVPacket * av_packet_alloc(void)
Allocate an AVPacket and set its fields to default values.
Definition: avpacket.c:51
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:523
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:704
AV_PKT_DATA_METADATA_UPDATE
@ AV_PKT_DATA_METADATA_UPDATE
A list of zero terminated key/value strings.
Definition: avcodec.h:1353
av_realloc
void * av_realloc(void *ptr, size_t size)
Allocate, reallocate, or free a block of memory.
Definition: mem.c:135
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: avcodec.h:1310
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:565
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:259
AVPacket::pts
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
Definition: avcodec.h:1470
DUP_DATA
#define DUP_DATA(dst, src, size, padding, ALLOC)
Definition: avpacket.c:177
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: avcodec.h:1386
uint8_t
uint8_t
Definition: audio_convert.c:194
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:236
AV_PKT_DATA_CPB_PROPERTIES
@ AV_PKT_DATA_CPB_PROPERTIES
This side data corresponds to the AVCPBProperties struct.
Definition: avcodec.h:1289
AV_PKT_DATA_SKIP_SAMPLES
@ AV_PKT_DATA_SKIP_SAMPLES
Recommmends skipping the specified number of samples.
Definition: avcodec.h:1300
av_buffer_is_writable
int av_buffer_is_writable(const AVBufferRef *buf)
Definition: buffer.c:133
avcodec.h
ALLOC_BUF
#define ALLOC_BUF(data, size)
Definition: avpacket.c:171
ret
ret
Definition: filter_design.txt:187
AVPacket::side_data
AVPacketSideData * side_data
Additional packet data that can be provided by the container.
Definition: avcodec.h:1488
AV_INPUT_BUFFER_PADDING_SIZE
#define AV_INPUT_BUFFER_PADDING_SIZE
Definition: avcodec.h:790
av_copy_packet
int av_copy_packet(AVPacket *dst, const AVPacket *src)
Copy packet, including contents.
Definition: avpacket.c:262
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: avcodec.h:1199
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:682
ref
static int ref[MAX_W *MAX_W]
Definition: jpeg2000dwt.c:107
AVPacket::stream_index
int stream_index
Definition: avcodec.h:1479
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
AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL
@ AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL
Data found in BlockAdditional element of matroska container.
Definition: avcodec.h:1335
av_free
#define av_free(p)
Definition: tableprint_vlc.h:34
AVDictionaryEntry
Definition: dict.h:81
AVPacket
This structure stores compressed data.
Definition: avcodec.h:1454
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: avcodec.h:1497
av_copy_packet_side_data
int av_copy_packet_side_data(AVPacket *pkt, const AVPacket *src)
Copy packet side data.
Definition: avpacket.c:226
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: avcodec.h:1284
bytestream.h
AV_PKT_DATA_QUALITY_STATS
@ AV_PKT_DATA_QUALITY_STATS
This side data contains quality related information from the encoder.
Definition: avcodec.h:1276
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: avcodec.h:1340
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: avcodec.h:1489
av_packet_clone
AVPacket * av_packet_clone(const AVPacket *src)
Create a new packet that references the same data as src.
Definition: avpacket.c:642
av_init_packet
void av_init_packet(AVPacket *pkt)
Initialize optional fields of a packet with default values.
Definition: avpacket.c:33