FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
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 {
35  pkt->pts = AV_NOPTS_VALUE;
36  pkt->dts = AV_NOPTS_VALUE;
37  pkt->pos = -1;
38  pkt->duration = 0;
39 #if FF_API_CONVERGENCE_DURATION
41  pkt->convergence_duration = 0;
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 
57  av_packet_unref(pkt);
58 
59  return pkt;
60 }
61 
63 {
64  if (!pkt || !*pkt)
65  return;
66 
67  av_packet_unref(*pkt);
68  av_freep(pkt);
69 }
70 
71 static int packet_alloc(AVBufferRef **buf, int size)
72 {
73  int ret;
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 
93  av_init_packet(pkt);
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 (!pkt->size)
114  return av_new_packet(pkt, grow_by);
115  if ((unsigned)grow_by >
116  INT_MAX - (pkt->size + AV_INPUT_BUFFER_PADDING_SIZE))
117  return -1;
118 
119  new_size = pkt->size + grow_by + AV_INPUT_BUFFER_PADDING_SIZE;
120  if (pkt->buf) {
121  int ret = av_buffer_realloc(&pkt->buf, new_size);
122  if (ret < 0)
123  return ret;
124  } else {
125  pkt->buf = av_buffer_alloc(new_size);
126  if (!pkt->buf)
127  return AVERROR(ENOMEM);
128  memcpy(pkt->buf->data, pkt->data, FFMIN(pkt->size, pkt->size + grow_by));
129  }
130  pkt->data = pkt->buf->data;
131  pkt->size += grow_by;
132  memset(pkt->data + pkt->size, 0, AV_INPUT_BUFFER_PADDING_SIZE);
133 
134  return 0;
135 }
136 
138 {
139  if (size >= INT_MAX - AV_INPUT_BUFFER_PADDING_SIZE)
140  return AVERROR(EINVAL);
141 
144  if (!pkt->buf)
145  return AVERROR(ENOMEM);
146 
147  pkt->data = data;
148  pkt->size = size;
149 
150  return 0;
151 }
152 
153 #if FF_API_AVPACKET_OLD_API
155 #define ALLOC_MALLOC(data, size) data = av_malloc(size)
156 #define ALLOC_BUF(data, size) \
157 do { \
158  av_buffer_realloc(&pkt->buf, size); \
159  data = pkt->buf ? pkt->buf->data : NULL; \
160 } while (0)
161 
162 #define DUP_DATA(dst, src, size, padding, ALLOC) \
163  do { \
164  void *data; \
165  if (padding) { \
166  if ((unsigned)(size) > \
167  (unsigned)(size) + AV_INPUT_BUFFER_PADDING_SIZE) \
168  goto failed_alloc; \
169  ALLOC(data, size + AV_INPUT_BUFFER_PADDING_SIZE); \
170  } else { \
171  ALLOC(data, size); \
172  } \
173  if (!data) \
174  goto failed_alloc; \
175  memcpy(data, src, size); \
176  if (padding) \
177  memset((uint8_t *)data + size, 0, \
178  AV_INPUT_BUFFER_PADDING_SIZE); \
179  dst = data; \
180  } while (0)
181 
182 /* Makes duplicates of data, side_data, but does not copy any other fields */
183 static int copy_packet_data(AVPacket *pkt, const AVPacket *src, int dup)
184 {
185  pkt->data = NULL;
186  pkt->side_data = NULL;
187  if (pkt->buf) {
188  AVBufferRef *ref = av_buffer_ref(src->buf);
189  if (!ref)
190  return AVERROR(ENOMEM);
191  pkt->buf = ref;
192  pkt->data = ref->data;
193  } else {
194  DUP_DATA(pkt->data, src->data, pkt->size, 1, ALLOC_BUF);
195  }
196  if (pkt->side_data_elems && dup)
197  pkt->side_data = src->side_data;
198  if (pkt->side_data_elems && !dup) {
199  return av_copy_packet_side_data(pkt, src);
200  }
201  return 0;
202 
203 failed_alloc:
204  av_packet_unref(pkt);
205  return AVERROR(ENOMEM);
206 }
207 
209 {
210  if (src->side_data_elems) {
211  int i;
212  DUP_DATA(pkt->side_data, src->side_data,
213  src->side_data_elems * sizeof(*src->side_data), 0, ALLOC_MALLOC);
214  if (src != pkt) {
215  memset(pkt->side_data, 0,
216  src->side_data_elems * sizeof(*src->side_data));
217  }
218  for (i = 0; i < src->side_data_elems; i++) {
219  DUP_DATA(pkt->side_data[i].data, src->side_data[i].data,
220  src->side_data[i].size, 1, ALLOC_MALLOC);
221  pkt->side_data[i].size = src->side_data[i].size;
222  pkt->side_data[i].type = src->side_data[i].type;
223  }
224  }
225  pkt->side_data_elems = src->side_data_elems;
226  return 0;
227 
228 failed_alloc:
229  av_packet_unref(pkt);
230  return AVERROR(ENOMEM);
231 }
233 #endif
234 
236 {
237  AVPacket tmp_pkt;
238 
239  if (!pkt->buf && pkt->data) {
240  tmp_pkt = *pkt;
241  return copy_packet_data(pkt, &tmp_pkt, 1);
242  }
243  return 0;
244 }
245 
247 {
248  *dst = *src;
249  return copy_packet_data(dst, src, 0);
250 }
251 
253 {
254  int i;
255  for (i = 0; i < pkt->side_data_elems; i++)
256  av_freep(&pkt->side_data[i].data);
257  av_freep(&pkt->side_data);
258  pkt->side_data_elems = 0;
259 }
260 
261 #if FF_API_AVPACKET_OLD_API
264 {
265  if (pkt) {
266  if (pkt->buf)
267  av_buffer_unref(&pkt->buf);
268  pkt->data = NULL;
269  pkt->size = 0;
270 
272  }
273 }
275 #endif
276 
278  uint8_t *data, size_t size)
279 {
280  int elems = pkt->side_data_elems;
281 
282  if ((unsigned)elems + 1 > INT_MAX / sizeof(*pkt->side_data))
283  return AVERROR(ERANGE);
284 
285  pkt->side_data = av_realloc(pkt->side_data,
286  (elems + 1) * sizeof(*pkt->side_data));
287  if (!pkt->side_data)
288  return AVERROR(ENOMEM);
289 
290  pkt->side_data[elems].data = data;
291  pkt->side_data[elems].size = size;
292  pkt->side_data[elems].type = type;
293  pkt->side_data_elems++;
294 
295  return 0;
296 }
297 
298 
300  int size)
301 {
302  int ret;
303  uint8_t *data;
304 
305  if ((unsigned)size > INT_MAX - AV_INPUT_BUFFER_PADDING_SIZE)
306  return NULL;
308  if (!data)
309  return NULL;
310 
311  ret = av_packet_add_side_data(pkt, type, data, size);
312  if (ret < 0) {
313  av_freep(&data);
314  return NULL;
315  }
316 
317  return data;
318 }
319 
321  int *size)
322 {
323  int i;
324 
325  for (i = 0; i < pkt->side_data_elems; i++) {
326  if (pkt->side_data[i].type == type) {
327  if (size)
328  *size = pkt->side_data[i].size;
329  return pkt->side_data[i].data;
330  }
331  }
332  return NULL;
333 }
334 
336 {
337  switch(type) {
338  case AV_PKT_DATA_PALETTE: return "Palette";
339  case AV_PKT_DATA_NEW_EXTRADATA: return "New Extradata";
340  case AV_PKT_DATA_PARAM_CHANGE: return "Param Change";
341  case AV_PKT_DATA_H263_MB_INFO: return "H263 MB Info";
342  case AV_PKT_DATA_REPLAYGAIN: return "Replay Gain";
343  case AV_PKT_DATA_DISPLAYMATRIX: return "Display Matrix";
344  case AV_PKT_DATA_STEREO3D: return "Stereo 3D";
345  case AV_PKT_DATA_AUDIO_SERVICE_TYPE: return "Audio Service Type";
346  case AV_PKT_DATA_SKIP_SAMPLES: return "Skip Samples";
347  case AV_PKT_DATA_JP_DUALMONO: return "JP Dual Mono";
348  case AV_PKT_DATA_STRINGS_METADATA: return "Strings Metadata";
349  case AV_PKT_DATA_SUBTITLE_POSITION: return "Subtitle Position";
350  case AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL: return "Matroska BlockAdditional";
351  case AV_PKT_DATA_WEBVTT_IDENTIFIER: return "WebVTT ID";
352  case AV_PKT_DATA_WEBVTT_SETTINGS: return "WebVTT Settings";
353  case AV_PKT_DATA_METADATA_UPDATE: return "Metadata Update";
354  case AV_PKT_DATA_MPEGTS_STREAM_ID: return "MPEGTS Stream ID";
355  case AV_PKT_DATA_MASTERING_DISPLAY_METADATA: return "Mastering display metadata";
356  }
357  return NULL;
358 }
359 
360 #define FF_MERGE_MARKER 0x8c4d9d108e25e9feULL
361 
363  if(pkt->side_data_elems){
364  AVBufferRef *buf;
365  int i;
366  uint8_t *p;
367  uint64_t size= pkt->size + 8LL + AV_INPUT_BUFFER_PADDING_SIZE;
368  AVPacket old= *pkt;
369  for (i=0; i<old.side_data_elems; i++) {
370  size += old.side_data[i].size + 5LL;
371  }
372  if (size > INT_MAX)
373  return AVERROR(EINVAL);
374  buf = av_buffer_alloc(size);
375  if (!buf)
376  return AVERROR(ENOMEM);
377  pkt->buf = buf;
378  pkt->data = p = buf->data;
379  pkt->size = size - AV_INPUT_BUFFER_PADDING_SIZE;
380  bytestream_put_buffer(&p, old.data, old.size);
381  for (i=old.side_data_elems-1; i>=0; i--) {
382  bytestream_put_buffer(&p, old.side_data[i].data, old.side_data[i].size);
383  bytestream_put_be32(&p, old.side_data[i].size);
384  *p++ = old.side_data[i].type | ((i==old.side_data_elems-1)*128);
385  }
386  bytestream_put_be64(&p, FF_MERGE_MARKER);
387  av_assert0(p-pkt->data == pkt->size);
388  memset(p, 0, AV_INPUT_BUFFER_PADDING_SIZE);
389  av_packet_unref(&old);
390  pkt->side_data_elems = 0;
391  pkt->side_data = NULL;
392  return 1;
393  }
394  return 0;
395 }
396 
398  if (!pkt->side_data_elems && pkt->size >12 && AV_RB64(pkt->data + pkt->size - 8) == FF_MERGE_MARKER){
399  int i;
400  unsigned int size;
401  uint8_t *p;
402 
403  p = pkt->data + pkt->size - 8 - 5;
404  for (i=1; ; i++){
405  size = AV_RB32(p);
406  if (size>INT_MAX - 5 || p - pkt->data < size)
407  return 0;
408  if (p[4]&128)
409  break;
410  if (p - pkt->data < size + 5)
411  return 0;
412  p-= size+5;
413  }
414 
415  pkt->side_data = av_malloc_array(i, sizeof(*pkt->side_data));
416  if (!pkt->side_data)
417  return AVERROR(ENOMEM);
418 
419  p= pkt->data + pkt->size - 8 - 5;
420  for (i=0; ; i++){
421  size= AV_RB32(p);
424  pkt->side_data[i].size = size;
425  pkt->side_data[i].type = p[4]&127;
426  if (!pkt->side_data[i].data)
427  return AVERROR(ENOMEM);
428  memcpy(pkt->side_data[i].data, p-size, size);
429  pkt->size -= size + 5;
430  if(p[4]&128)
431  break;
432  p-= size+5;
433  }
434  pkt->size -= 8;
435  pkt->side_data_elems = i+1;
436  return 1;
437  }
438  return 0;
439 }
440 
442 {
443  AVDictionaryEntry *t = NULL;
444  uint8_t *data = NULL;
445  *size = 0;
446 
447  if (!dict)
448  return NULL;
449 
450  while ((t = av_dict_get(dict, "", t, AV_DICT_IGNORE_SUFFIX))) {
451  const size_t keylen = strlen(t->key);
452  const size_t valuelen = strlen(t->value);
453  const size_t new_size = *size + keylen + 1 + valuelen + 1;
454  uint8_t *const new_data = av_realloc(data, new_size);
455 
456  if (!new_data)
457  goto fail;
458  data = new_data;
459  if (new_size > INT_MAX)
460  goto fail;
461 
462  memcpy(data + *size, t->key, keylen + 1);
463  memcpy(data + *size + keylen + 1, t->value, valuelen + 1);
464 
465  *size = new_size;
466  }
467 
468  return data;
469 
470 fail:
471  av_freep(&data);
472  *size = 0;
473  return NULL;
474 }
475 
477 {
478  const uint8_t *end = data + size;
479  int ret = 0;
480 
481  if (!dict || !data || !size)
482  return ret;
483  if (size && end[-1])
484  return AVERROR_INVALIDDATA;
485  while (data < end) {
486  const uint8_t *key = data;
487  const uint8_t *val = data + strlen(key) + 1;
488 
489  if (val >= end)
490  return AVERROR_INVALIDDATA;
491 
492  ret = av_dict_set(dict, key, val, 0);
493  if (ret < 0)
494  break;
495  data = val + strlen(val) + 1;
496  }
497 
498  return ret;
499 }
500 
502  int size)
503 {
504  int i;
505 
506  for (i = 0; i < pkt->side_data_elems; i++) {
507  if (pkt->side_data[i].type == type) {
508  if (size > pkt->side_data[i].size)
509  return AVERROR(ENOMEM);
510  pkt->side_data[i].size = size;
511  return 0;
512  }
513  }
514  return AVERROR(ENOENT);
515 }
516 
518 {
519  int i;
520 
521  dst->pts = src->pts;
522  dst->dts = src->dts;
523  dst->pos = src->pos;
524  dst->duration = src->duration;
525 #if FF_API_CONVERGENCE_DURATION
529 #endif
530  dst->flags = src->flags;
531  dst->stream_index = src->stream_index;
532 
533  for (i = 0; i < src->side_data_elems; i++) {
534  enum AVPacketSideDataType type = src->side_data[i].type;
535  int size = src->side_data[i].size;
536  uint8_t *src_data = src->side_data[i].data;
537  uint8_t *dst_data = av_packet_new_side_data(dst, type, size);
538 
539  if (!dst_data) {
541  return AVERROR(ENOMEM);
542  }
543  memcpy(dst_data, src_data, size);
544  }
545 
546  return 0;
547 }
548 
550 {
552  av_buffer_unref(&pkt->buf);
553  av_init_packet(pkt);
554  pkt->data = NULL;
555  pkt->size = 0;
556 }
557 
559 {
560  int ret;
561 
562  ret = av_packet_copy_props(dst, src);
563  if (ret < 0)
564  return ret;
565 
566  if (!src->buf) {
567  ret = packet_alloc(&dst->buf, src->size);
568  if (ret < 0)
569  goto fail;
570  memcpy(dst->buf->data, src->data, src->size);
571  dst->data = dst->buf->data;
572  } else {
573  dst->buf = av_buffer_ref(src->buf);
574  if (!dst->buf) {
575  ret = AVERROR(ENOMEM);
576  goto fail;
577  }
578  dst->data = src->data;
579  }
580 
581  dst->size = src->size;
582 
583  return 0;
584 fail:
586  return ret;
587 }
588 
590 {
591  AVPacket *ret = av_packet_alloc();
592 
593  if (!ret)
594  return ret;
595 
596  if (av_packet_ref(ret, src))
597  av_packet_free(&ret);
598 
599  return ret;
600 }
601 
603 {
604  *dst = *src;
605  av_init_packet(src);
606  src->data = NULL;
607  src->size = 0;
608 }
609 
611 {
612  if (pkt->pts != AV_NOPTS_VALUE)
613  pkt->pts = av_rescale_q(pkt->pts, src_tb, dst_tb);
614  if (pkt->dts != AV_NOPTS_VALUE)
615  pkt->dts = av_rescale_q(pkt->dts, src_tb, dst_tb);
616  if (pkt->duration > 0)
617  pkt->duration = av_rescale_q(pkt->duration, src_tb, dst_tb);
618 #if FF_API_CONVERGENCE_DURATION
620  if (pkt->convergence_duration > 0)
621  pkt->convergence_duration = av_rescale_q(pkt->convergence_duration, src_tb, dst_tb);
623 #endif
624 }
625 
626 int ff_side_data_set_encoder_stats(AVPacket *pkt, int quality, int64_t *error, int error_count, int pict_type)
627 {
628  uint8_t *side_data;
629  int side_data_size;
630  int i;
631 
632  side_data = av_packet_get_side_data(pkt, AV_PKT_DATA_QUALITY_STATS, &side_data_size);
633  if (!side_data) {
634  side_data_size = 4+4+8*error_count;
636  side_data_size);
637  }
638 
639  if (!side_data || side_data_size < 4+4+8*error_count)
640  return AVERROR(ENOMEM);
641 
642  AV_WL32(side_data , quality );
643  side_data[4] = pict_type;
644  side_data[5] = error_count;
645  for (i = 0; i<error_count; i++)
646  AV_WL64(side_data+8 + 8*i , error[i]);
647 
648  return 0;
649 }
#define NULL
Definition: coverity.c:32
const char const char void * val
Definition: avisynth_c.h:634
#define DUP_DATA(dst, src, size, padding, ALLOC)
Definition: avpacket.c:162
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
Definition: error.h:59
AVPacketSideDataType
Definition: avcodec.h:1346
A list of zero terminated key/value strings.
Definition: avcodec.h:1502
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:124
The optional first identifier line of a WebVTT cue.
Definition: avcodec.h:1489
int ff_side_data_set_encoder_stats(AVPacket *pkt, int quality, int64_t *error, int error_count, int pict_type)
Definition: avpacket.c:626
ptrdiff_t const GLvoid * data
Definition: opengl_enc.c:101
memory handling functions
int64_t pos
byte position in stream, -1 if unknown
Definition: avcodec.h:1597
void av_shrink_packet(AVPacket *pkt, int size)
Reduce packet size, correctly zeroing padding.
Definition: avpacket.c:101
Subtitle event position.
Definition: avcodec.h:1476
#define ALLOC_MALLOC(data, size)
Definition: avpacket.c:155
This side data should be associated with a video stream and contains Stereoscopic 3D information in f...
Definition: avcodec.h:1407
int size
Definition: avcodec.h:1578
#define ALLOC_BUF(data, size)
Definition: avpacket.c:156
static AVPacket pkt
An AV_PKT_DATA_H263_MB_INFO side data packet contains a number of structures with info about macroblo...
Definition: avcodec.h:1386
Mastering display metadata (based on SMPTE-2086:2014).
Definition: avcodec.h:1515
#define av_assert0(cond)
assert() equivalent, that is always enabled.
Definition: avassert.h:37
void av_packet_free(AVPacket **pkt)
Free the packet, if the packet is reference counted, it will be unreferenced first.
Definition: avpacket.c:62
uint8_t
int av_packet_unpack_dictionary(const uint8_t *data, int size, AVDictionary **dict)
Unpack a dictionary from side_data.
Definition: avpacket.c:476
static av_cold int end(AVCodecContext *avctx)
Definition: avrndec.c:90
int64_t duration
Duration of this packet in AVStream->time_base units, 0 if unknown.
Definition: avcodec.h:1595
This side data contains a 3x3 transformation matrix describing an affine transformation that needs to...
Definition: avcodec.h:1401
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:137
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:87
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:39
uint8_t * data
Definition: avcodec.h:1577
void av_packet_move_ref(AVPacket *dst, AVPacket *src)
Move every field in src to dst and reset src.
Definition: avpacket.c:602
uint8_t * data
Definition: avcodec.h:1521
ptrdiff_t size
Definition: opengl_enc.c:101
static int ref[MAX_W *MAX_W]
int av_packet_ref(AVPacket *dst, const AVPacket *src)
Setup a new reference to the data described by a given packet.
Definition: avpacket.c:558
void av_buffer_default_free(void *opaque, uint8_t *data)
Default free callback, which calls av_free() on the buffer data.
Definition: buffer.c:61
MPEGTS stream ID, this is required to pass the stream ID information from the demuxer to the correspo...
Definition: avcodec.h:1508
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
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
#define AV_WL64(p, v)
Definition: intreadwrite.h:440
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:610
An AV_PKT_DATA_PARAM_CHANGE side data packet is laid out as follows:
Definition: avcodec.h:1365
#define AVERROR(e)
Definition: error.h:43
void av_packet_free_side_data(AVPacket *pkt)
Convenience function to free all the side data stored.
Definition: avpacket.c:252
FF_ENABLE_DEPRECATION_WARNINGS int av_dup_packet(AVPacket *pkt)
Definition: avpacket.c:235
AVBufferRef * buf
A reference to the reference-counted buffer where the packet data is stored.
Definition: avcodec.h:1560
simple assert() macros that are a bit more flexible than ISO C assert().
enum AVPacketSideDataType type
Definition: avcodec.h:1523
int side_data_elems
Definition: avcodec.h:1589
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
int av_packet_shrink_side_data(AVPacket *pkt, enum AVPacketSideDataType type, int size)
Shrink the already allocated side data buffer.
Definition: avpacket.c:501
int av_buffer_realloc(AVBufferRef **pbuf, int size)
Reallocate a given buffer.
Definition: buffer.c:168
#define fail()
Definition: checkasm.h:81
int flags
A combination of AV_PKT_FLAG values.
Definition: avcodec.h:1583
int av_packet_merge_side_data(AVPacket *pkt)
Definition: avpacket.c:362
common internal API header
int av_packet_copy_props(AVPacket *dst, const AVPacket *src)
Copy only "properties" fields from src to dst.
Definition: avpacket.c:517
#define FFMIN(a, b)
Definition: common.h:96
This side data contains quality related information from the encoder.
Definition: avcodec.h:1425
static int packet_alloc(AVBufferRef **buf, int size)
Definition: avpacket.c:71
#define src
Definition: vp9dsp.c:530
int av_packet_split_side_data(AVPacket *pkt)
Definition: avpacket.c:397
AVPacket * av_packet_clone(AVPacket *src)
Create a new packet that references the same data as src.
Definition: avpacket.c:589
Libavcodec external API header.
A list of zero terminated key/value strings.
Definition: avcodec.h:1465
AVBufferRef * av_buffer_alloc(int size)
Allocate an AVBuffer of the given size using av_malloc().
Definition: buffer.c:66
uint8_t * av_packet_pack_dictionary(AVDictionary *dict, int *size)
Pack a dictionary for use in side_data.
Definition: avpacket.c:441
void av_packet_unref(AVPacket *pkt)
Wipe the packet.
Definition: avpacket.c:549
uint8_t * data
The data buffer.
Definition: buffer.h:89
int av_copy_packet(AVPacket *dst, const AVPacket *src)
Copy packet, including contents.
Definition: avpacket.c:246
void * buf
Definition: avisynth_c.h:553
Data found in BlockAdditional element of matroska container.
Definition: avcodec.h:1484
GLint GLenum type
Definition: opengl_enc.c:105
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:69
rational number numerator/denominator
Definition: rational.h:43
Recommmends skipping the specified number of samples.
Definition: avcodec.h:1449
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:277
static int copy_packet_data(AVPacket *pkt, const AVPacket *src, int dup)
Definition: avpacket.c:183
This side data should be associated with an audio stream and contains ReplayGain information in form ...
Definition: avcodec.h:1392
#define FF_MERGE_MARKER
Definition: avpacket.c:360
A reference to a data buffer.
Definition: buffer.h:81
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:87
An AV_PKT_DATA_JP_DUALMONO side data packet indicates that the packet may contain "dual mono" audio s...
Definition: avcodec.h:1459
AVPacketSideData * side_data
Additional packet data that can be provided by the container.
Definition: avcodec.h:1588
attribute_deprecated int64_t convergence_duration
Definition: avcodec.h:1606
#define FF_DISABLE_DEPRECATION_WARNINGS
Definition: internal.h:80
common internal api header.
common internal and external API header
void * av_realloc(void *ptr, size_t size)
Allocate or reallocate a block of memory.
Definition: mem.c:145
AVBufferRef * av_buffer_ref(AVBufferRef *buf)
Create a new reference to an AVBuffer.
Definition: buffer.c:92
int av_grow_packet(AVPacket *pkt, int grow_by)
Increase packet size, correctly zeroing padding.
Definition: avpacket.c:109
void av_init_packet(AVPacket *pkt)
Initialize optional fields of a packet with default values.
Definition: avpacket.c:33
char * key
Definition: dict.h:86
The optional settings (rendering instructions) that immediately follow the timestamp specifier of a W...
Definition: avcodec.h:1495
static av_always_inline void bytestream_put_buffer(uint8_t **b, const uint8_t *src, unsigned int size)
Definition: bytestream.h:368
#define AV_INPUT_BUFFER_PADDING_SIZE
Required number of additionally allocated bytes at the end of the input bitstream for decoding...
Definition: avcodec.h:728
char * value
Definition: dict.h:87
#define FF_ENABLE_DEPRECATION_WARNINGS
Definition: internal.h:81
AVPacket * av_packet_alloc(void)
Allocate an AVPacket and set its fields to default values.
Definition: avpacket.c:51
int64_t dts
Decompression timestamp in AVStream->time_base units; the time at which the packet is decompressed...
Definition: avcodec.h:1576
const char * av_packet_side_data_name(enum AVPacketSideDataType type)
Definition: avpacket.c:335
FF_DISABLE_DEPRECATION_WARNINGS void av_free_packet(AVPacket *pkt)
Free a packet.
Definition: avpacket.c:263
#define av_freep(p)
#define AV_DICT_IGNORE_SUFFIX
Return first entry in a dictionary whose first part corresponds to the search key, ignoring the suffix of the found key string.
Definition: dict.h:70
uint8_t * av_packet_get_side_data(AVPacket *pkt, enum AVPacketSideDataType type, int *size)
Get side information from packet.
Definition: avpacket.c:320
#define av_malloc_array(a, b)
uint8_t * av_packet_new_side_data(AVPacket *pkt, enum AVPacketSideDataType type, int size)
Allocate new information of a packet.
Definition: avpacket.c:299
int stream_index
Definition: avcodec.h:1579
int av_copy_packet_side_data(AVPacket *pkt, const AVPacket *src)
Copy packet side data.
Definition: avpacket.c:208
This structure stores compressed data.
Definition: avcodec.h:1554
void * av_mallocz(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
Definition: mem.c:252
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
Definition: avcodec.h:1570
#define AV_NOPTS_VALUE
Undefined timestamp value.
Definition: avutil.h:240
#define AV_WL32(p, v)
Definition: intreadwrite.h:426
This side data should be associated with an audio stream and corresponds to enum AVAudioServiceType.
Definition: avcodec.h:1413