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 
33 #if FF_API_DESTRUCT_PACKET
34 
36 {
37  av_freep(&pkt->data);
38  pkt->size = 0;
39 }
40 
41 /* a dummy destruct callback for the callers that assume AVPacket.destruct ==
42  * NULL => static data */
44 {
45  av_assert0(0);
46 }
47 #endif
48 
50 {
51  pkt->pts = AV_NOPTS_VALUE;
52  pkt->dts = AV_NOPTS_VALUE;
53  pkt->pos = -1;
54  pkt->duration = 0;
55  pkt->convergence_duration = 0;
56  pkt->flags = 0;
57  pkt->stream_index = 0;
58 #if FF_API_DESTRUCT_PACKET
60  pkt->destruct = NULL;
62 #endif
63  pkt->buf = NULL;
64  pkt->side_data = NULL;
65  pkt->side_data_elems = 0;
66 }
67 
68 static int packet_alloc(AVBufferRef **buf, int size)
69 {
70  int ret;
71  if ((unsigned)size >= (unsigned)size + FF_INPUT_BUFFER_PADDING_SIZE)
72  return AVERROR(EINVAL);
73 
75  if (ret < 0)
76  return ret;
77 
78  memset((*buf)->data + size, 0, FF_INPUT_BUFFER_PADDING_SIZE);
79 
80  return 0;
81 }
82 
84 {
85  AVBufferRef *buf = NULL;
86  int ret = packet_alloc(&buf, size);
87  if (ret < 0)
88  return ret;
89 
90  av_init_packet(pkt);
91  pkt->buf = buf;
92  pkt->data = buf->data;
93  pkt->size = size;
94 #if FF_API_DESTRUCT_PACKET
98 #endif
99 
100  return 0;
101 }
102 
104 {
105  if (pkt->size <= size)
106  return;
107  pkt->size = size;
108  memset(pkt->data + size, 0, FF_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 - FF_INPUT_BUFFER_PADDING_SIZE);
115  if (!pkt->size)
116  return av_new_packet(pkt, grow_by);
117  if ((unsigned)grow_by >
118  INT_MAX - (pkt->size + FF_INPUT_BUFFER_PADDING_SIZE))
119  return -1;
120 
121  new_size = pkt->size + grow_by + FF_INPUT_BUFFER_PADDING_SIZE;
122  if (pkt->buf) {
123  int ret = av_buffer_realloc(&pkt->buf, new_size);
124  if (ret < 0)
125  return ret;
126  } else {
127  pkt->buf = av_buffer_alloc(new_size);
128  if (!pkt->buf)
129  return AVERROR(ENOMEM);
130  memcpy(pkt->buf->data, pkt->data, FFMIN(pkt->size, pkt->size + grow_by));
131 #if FF_API_DESTRUCT_PACKET
135 #endif
136  }
137  pkt->data = pkt->buf->data;
138  pkt->size += grow_by;
139  memset(pkt->data + pkt->size, 0, FF_INPUT_BUFFER_PADDING_SIZE);
140 
141  return 0;
142 }
143 
145 {
146  if (size >= INT_MAX - FF_INPUT_BUFFER_PADDING_SIZE)
147  return AVERROR(EINVAL);
148 
151  if (!pkt->buf)
152  return AVERROR(ENOMEM);
153 
154  pkt->data = data;
155  pkt->size = size;
156 #if FF_API_DESTRUCT_PACKET
160 #endif
161 
162  return 0;
163 }
164 
165 #define ALLOC_MALLOC(data, size) data = av_malloc(size)
166 #define ALLOC_BUF(data, size) \
167 do { \
168  av_buffer_realloc(&pkt->buf, size); \
169  data = pkt->buf ? pkt->buf->data : NULL; \
170 } while (0)
171 
172 #define DUP_DATA(dst, src, size, padding, ALLOC) \
173  do { \
174  void *data; \
175  if (padding) { \
176  if ((unsigned)(size) > \
177  (unsigned)(size) + FF_INPUT_BUFFER_PADDING_SIZE) \
178  goto failed_alloc; \
179  ALLOC(data, size + FF_INPUT_BUFFER_PADDING_SIZE); \
180  } else { \
181  ALLOC(data, size); \
182  } \
183  if (!data) \
184  goto failed_alloc; \
185  memcpy(data, src, size); \
186  if (padding) \
187  memset((uint8_t *)data + size, 0, \
188  FF_INPUT_BUFFER_PADDING_SIZE); \
189  dst = data; \
190  } while (0)
191 
192 /* Makes duplicates of data, side_data, but does not copy any other fields */
193 static int copy_packet_data(AVPacket *pkt, const AVPacket *src, int dup)
194 {
195  pkt->data = NULL;
196  pkt->side_data = NULL;
197  if (pkt->buf) {
198  AVBufferRef *ref = av_buffer_ref(src->buf);
199  if (!ref)
200  return AVERROR(ENOMEM);
201  pkt->buf = ref;
202  pkt->data = ref->data;
203  } else {
204  DUP_DATA(pkt->data, src->data, pkt->size, 1, ALLOC_BUF);
205  }
206 #if FF_API_DESTRUCT_PACKET
210 #endif
211  if (pkt->side_data_elems && dup)
212  pkt->side_data = src->side_data;
213  if (pkt->side_data_elems && !dup) {
214  return av_copy_packet_side_data(pkt, src);
215  }
216  return 0;
217 
218 failed_alloc:
219  av_free_packet(pkt);
220  return AVERROR(ENOMEM);
221 }
222 
224 {
225  if (src->side_data_elems) {
226  int i;
227  DUP_DATA(pkt->side_data, src->side_data,
228  src->side_data_elems * sizeof(*src->side_data), 0, ALLOC_MALLOC);
229  if (src != pkt) {
230  memset(pkt->side_data, 0,
231  src->side_data_elems * sizeof(*src->side_data));
232  }
233  for (i = 0; i < src->side_data_elems; i++) {
234  DUP_DATA(pkt->side_data[i].data, src->side_data[i].data,
235  src->side_data[i].size, 1, ALLOC_MALLOC);
236  pkt->side_data[i].size = src->side_data[i].size;
237  pkt->side_data[i].type = src->side_data[i].type;
238  }
239  }
240  pkt->side_data_elems = src->side_data_elems;
241  return 0;
242 
243 failed_alloc:
244  av_free_packet(pkt);
245  return AVERROR(ENOMEM);
246 }
247 
249 {
250  AVPacket tmp_pkt;
251 
253  if (!pkt->buf && pkt->data
255  && !pkt->destruct
256 #endif
257  ) {
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 }
270 
272 {
273  int i;
274  for (i = 0; i < pkt->side_data_elems; i++)
275  av_freep(&pkt->side_data[i].data);
276  av_freep(&pkt->side_data);
277  pkt->side_data_elems = 0;
278 }
279 
281 {
282  if (pkt) {
284  if (pkt->buf)
285  av_buffer_unref(&pkt->buf);
286 #if FF_API_DESTRUCT_PACKET
287  else if (pkt->destruct)
288  pkt->destruct(pkt);
289  pkt->destruct = NULL;
290 #endif
292  pkt->data = NULL;
293  pkt->size = 0;
294 
296  }
297 }
298 
300  int size)
301 {
302  int elems = pkt->side_data_elems;
303 
304  if ((unsigned)elems + 1 > INT_MAX / sizeof(*pkt->side_data))
305  return NULL;
306  if ((unsigned)size > INT_MAX - FF_INPUT_BUFFER_PADDING_SIZE)
307  return NULL;
308 
309  pkt->side_data = av_realloc(pkt->side_data,
310  (elems + 1) * sizeof(*pkt->side_data));
311  if (!pkt->side_data)
312  return NULL;
313 
315  if (!pkt->side_data[elems].data)
316  return NULL;
317  pkt->side_data[elems].size = size;
318  pkt->side_data[elems].type = type;
319  pkt->side_data_elems++;
320 
321  return pkt->side_data[elems].data;
322 }
323 
325  int *size)
326 {
327  int i;
328 
329  for (i = 0; i < pkt->side_data_elems; i++) {
330  if (pkt->side_data[i].type == type) {
331  if (size)
332  *size = pkt->side_data[i].size;
333  return pkt->side_data[i].data;
334  }
335  }
336  return NULL;
337 }
338 
340 {
341  switch(type) {
342  case AV_PKT_DATA_PALETTE: return "Palette";
343  case AV_PKT_DATA_NEW_EXTRADATA: return "New Extradata";
344  case AV_PKT_DATA_PARAM_CHANGE: return "Param Change";
345  case AV_PKT_DATA_H263_MB_INFO: return "H263 MB Info";
346  case AV_PKT_DATA_REPLAYGAIN: return "Replay Gain";
347  case AV_PKT_DATA_DISPLAYMATRIX: return "Display Matrix";
348  case AV_PKT_DATA_STEREO3D: return "Stereo 3D";
349  case AV_PKT_DATA_AUDIO_SERVICE_TYPE: return "Audio Service Type";
350  case AV_PKT_DATA_SKIP_SAMPLES: return "Skip Samples";
351  case AV_PKT_DATA_JP_DUALMONO: return "JP Dual Mono";
352  case AV_PKT_DATA_STRINGS_METADATA: return "Strings Metadata";
353  case AV_PKT_DATA_SUBTITLE_POSITION: return "Subtitle Position";
354  case AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL: return "Matroska BlockAdditional";
355  case AV_PKT_DATA_WEBVTT_IDENTIFIER: return "WebVTT ID";
356  case AV_PKT_DATA_WEBVTT_SETTINGS: return "WebVTT Settings";
357  case AV_PKT_DATA_METADATA_UPDATE: return "Metadata Update";
358  }
359  return NULL;
360 }
361 
362 #define FF_MERGE_MARKER 0x8c4d9d108e25e9feULL
363 
365  if(pkt->side_data_elems){
366  AVBufferRef *buf;
367  int i;
368  uint8_t *p;
369  uint64_t size= pkt->size + 8LL + FF_INPUT_BUFFER_PADDING_SIZE;
370  AVPacket old= *pkt;
371  for (i=0; i<old.side_data_elems; i++) {
372  size += old.side_data[i].size + 5LL;
373  }
374  if (size > INT_MAX)
375  return AVERROR(EINVAL);
376  buf = av_buffer_alloc(size);
377  if (!buf)
378  return AVERROR(ENOMEM);
379  pkt->buf = buf;
380  pkt->data = p = buf->data;
381 #if FF_API_DESTRUCT_PACKET
385 #endif
386  pkt->size = size - FF_INPUT_BUFFER_PADDING_SIZE;
387  bytestream_put_buffer(&p, old.data, old.size);
388  for (i=old.side_data_elems-1; i>=0; i--) {
389  bytestream_put_buffer(&p, old.side_data[i].data, old.side_data[i].size);
390  bytestream_put_be32(&p, old.side_data[i].size);
391  *p++ = old.side_data[i].type | ((i==old.side_data_elems-1)*128);
392  }
393  bytestream_put_be64(&p, FF_MERGE_MARKER);
394  av_assert0(p-pkt->data == pkt->size);
395  memset(p, 0, FF_INPUT_BUFFER_PADDING_SIZE);
396  av_free_packet(&old);
397  pkt->side_data_elems = 0;
398  pkt->side_data = NULL;
399  return 1;
400  }
401  return 0;
402 }
403 
405  if (!pkt->side_data_elems && pkt->size >12 && AV_RB64(pkt->data + pkt->size - 8) == FF_MERGE_MARKER){
406  int i;
407  unsigned int size;
408  uint8_t *p;
409 
410  p = pkt->data + pkt->size - 8 - 5;
411  for (i=1; ; i++){
412  size = AV_RB32(p);
413  if (size>INT_MAX || p - pkt->data < size)
414  return 0;
415  if (p[4]&128)
416  break;
417  p-= size+5;
418  }
419 
420  pkt->side_data = av_malloc_array(i, sizeof(*pkt->side_data));
421  if (!pkt->side_data)
422  return AVERROR(ENOMEM);
423 
424  p= pkt->data + pkt->size - 8 - 5;
425  for (i=0; ; i++){
426  size= AV_RB32(p);
429  pkt->side_data[i].size = size;
430  pkt->side_data[i].type = p[4]&127;
431  if (!pkt->side_data[i].data)
432  return AVERROR(ENOMEM);
433  memcpy(pkt->side_data[i].data, p-size, size);
434  pkt->size -= size + 5;
435  if(p[4]&128)
436  break;
437  p-= size+5;
438  }
439  pkt->size -= 8;
440  pkt->side_data_elems = i+1;
441  return 1;
442  }
443  return 0;
444 }
445 
447 {
448  AVDictionaryEntry *t = NULL;
449  uint8_t *data = NULL;
450  *size = 0;
451 
452  if (!dict)
453  return NULL;
454 
455  while ((t = av_dict_get(dict, "", t, AV_DICT_IGNORE_SUFFIX))) {
456  const size_t keylen = strlen(t->key);
457  const size_t valuelen = strlen(t->value);
458  const size_t new_size = *size + keylen + 1 + valuelen + 1;
459  uint8_t *const new_data = av_realloc(data, new_size);
460 
461  if (!new_data)
462  goto fail;
463  data = new_data;
464  if (new_size > INT_MAX)
465  goto fail;
466 
467  memcpy(data + *size, t->key, keylen + 1);
468  memcpy(data + *size + keylen + 1, t->value, valuelen + 1);
469 
470  *size = new_size;
471  }
472 
473  return data;
474 
475 fail:
476  av_freep(&data);
477  *size = 0;
478  return NULL;
479 }
480 
482 {
483  const uint8_t *end = data + size;
484  int ret = 0;
485 
486  if (!dict || !data || !size)
487  return ret;
488  if (size && end[-1])
489  return AVERROR_INVALIDDATA;
490  while (data < end) {
491  const uint8_t *key = data;
492  const uint8_t *val = data + strlen(key) + 1;
493 
494  if (val >= end)
495  return AVERROR_INVALIDDATA;
496 
497  ret = av_dict_set(dict, key, val, 0);
498  if (ret < 0)
499  break;
500  data = val + strlen(val) + 1;
501  }
502 
503  return ret;
504 }
505 
507  int size)
508 {
509  int i;
510 
511  for (i = 0; i < pkt->side_data_elems; i++) {
512  if (pkt->side_data[i].type == type) {
513  if (size > pkt->side_data[i].size)
514  return AVERROR(ENOMEM);
515  pkt->side_data[i].size = size;
516  return 0;
517  }
518  }
519  return AVERROR(ENOENT);
520 }
521 
523 {
524  int i;
525 
526  dst->pts = src->pts;
527  dst->dts = src->dts;
528  dst->pos = src->pos;
529  dst->duration = src->duration;
531  dst->flags = src->flags;
532  dst->stream_index = src->stream_index;
533 
534  for (i = 0; i < src->side_data_elems; i++) {
535  enum AVPacketSideDataType type = src->side_data[i].type;
536  int size = src->side_data[i].size;
537  uint8_t *src_data = src->side_data[i].data;
538  uint8_t *dst_data = av_packet_new_side_data(dst, type, size);
539 
540  if (!dst_data) {
542  return AVERROR(ENOMEM);
543  }
544  memcpy(dst_data, src_data, size);
545  }
546 
547  return 0;
548 }
549 
551 {
553  av_buffer_unref(&pkt->buf);
554  av_init_packet(pkt);
555  pkt->data = NULL;
556  pkt->size = 0;
557 }
558 
560 {
561  int ret;
562 
563  ret = av_packet_copy_props(dst, src);
564  if (ret < 0)
565  return ret;
566 
567  if (!src->buf) {
568  ret = packet_alloc(&dst->buf, src->size);
569  if (ret < 0)
570  goto fail;
571  memcpy(dst->buf->data, src->data, src->size);
572  } else {
573  dst->buf = av_buffer_ref(src->buf);
574  if (!dst->buf) {
575  ret = AVERROR(ENOMEM);
576  goto fail;
577  }
578  }
579 
580  dst->size = src->size;
581  dst->data = dst->buf->data;
582  return 0;
583 fail:
585  return ret;
586 }
587 
589 {
590  *dst = *src;
591  av_init_packet(src);
592 }
593 
595 {
596  if (pkt->pts != AV_NOPTS_VALUE)
597  pkt->pts = av_rescale_q(pkt->pts, src_tb, dst_tb);
598  if (pkt->dts != AV_NOPTS_VALUE)
599  pkt->dts = av_rescale_q(pkt->dts, src_tb, dst_tb);
600  if (pkt->duration > 0)
601  pkt->duration = av_rescale_q(pkt->duration, src_tb, dst_tb);
602  if (pkt->convergence_duration > 0)
603  pkt->convergence_duration = av_rescale_q(pkt->convergence_duration, src_tb, dst_tb);
604 }
#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:172
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
Definition: error.h:59
AVPacketSideDataType
Definition: avcodec.h:977
A list of zero terminated key/value strings.
Definition: avcodec.h:1108
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
void av_free_packet(AVPacket *pkt)
Free a packet.
Definition: avpacket.c:280
The optional first identifier line of a WebVTT cue.
Definition: avcodec.h:1095
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:1187
void av_shrink_packet(AVPacket *pkt, int size)
Reduce packet size, correctly zeroing padding.
Definition: avpacket.c:103
Subtitle event position.
Definition: avcodec.h:1082
#define ALLOC_MALLOC(data, size)
Definition: avpacket.c:165
This side data should be associated with a video stream and contains Stereoscopic 3D information in f...
Definition: avcodec.h:1038
int size
Definition: avcodec.h:1163
#define ALLOC_BUF(data, size)
Definition: avpacket.c:166
static AVPacket pkt
int av_dup_packet(AVPacket *pkt)
Definition: avpacket.c:248
An AV_PKT_DATA_H263_MB_INFO side data packet contains a number of structures with info about macroblo...
Definition: avcodec.h:1017
#define av_assert0(cond)
assert() equivalent, that is always enabled.
Definition: avassert.h:37
uint8_t
int av_packet_unpack_dictionary(const uint8_t *data, int size, AVDictionary **dict)
Unpack a dictionary from side_data.
Definition: avpacket.c:481
attribute_deprecated void(* destruct)(struct AVPacket *)
Definition: avcodec.h:1183
static av_cold int end(AVCodecContext *avctx)
Definition: avrndec.c:67
static void dummy_destruct_packet(AVPacket *pkt)
Definition: avpacket.c:43
This side data contains a 3x3 transformation matrix describing an affine transformation that needs to...
Definition: avcodec.h:1032
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:144
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:85
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:1162
void av_packet_move_ref(AVPacket *dst, AVPacket *src)
Move every field in src to dst and reset src.
Definition: avpacket.c:588
uint8_t * data
Definition: avcodec.h:1112
ptrdiff_t size
Definition: opengl_enc.c:101
int duration
Duration of this packet in AVStream->time_base units, 0 if unknown.
Definition: avcodec.h:1180
int av_packet_ref(AVPacket *dst, const AVPacket *src)
Setup a new reference to the data described by a given packet.
Definition: avpacket.c:559
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
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
Definition: mathematics.c:140
int av_new_packet(AVPacket *pkt, int size)
Allocate the payload of a packet and initialize its fields with default values.
Definition: avpacket.c:83
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:594
An AV_PKT_DATA_PARAM_CHANGE side data packet is laid out as follows:
Definition: avcodec.h:996
#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:271
int64_t convergence_duration
Time difference in AVStream->time_base units from the pts of this packet to the point at which the ou...
Definition: avcodec.h:1206
AVBufferRef * buf
A reference to the reference-counted buffer where the packet data is stored.
Definition: avcodec.h:1145
simple assert() macros that are a bit more flexible than ISO C assert().
enum AVPacketSideDataType type
Definition: avcodec.h:1114
int side_data_elems
Definition: avcodec.h:1174
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:506
int av_buffer_realloc(AVBufferRef **pbuf, int size)
Reallocate a given buffer.
Definition: buffer.c:168
Libavcodec external API header.
int flags
A combination of AV_PKT_FLAG values.
Definition: avcodec.h:1168
int av_packet_merge_side_data(AVPacket *pkt)
Definition: avpacket.c:364
common internal API header
#define FF_INPUT_BUFFER_PADDING_SIZE
Required number of additionally allocated bytes at the end of the input bitstream for decoding...
Definition: avcodec.h:630
int av_packet_copy_props(AVPacket *dst, const AVPacket *src)
Copy only "properties" fields from src to dst.
Definition: avpacket.c:522
#define FFMIN(a, b)
Definition: common.h:66
ret
Definition: avfilter.c:974
static int packet_alloc(AVBufferRef **buf, int size)
Definition: avpacket.c:68
#define FF_API_DESTRUCT_PACKET
Definition: version.h:79
int av_packet_split_side_data(AVPacket *pkt)
Definition: avpacket.c:404
void av_destruct_packet(AVPacket *pkt)
Default packet destructor.
Definition: avpacket.c:35
AVS_Value src
Definition: avisynth_c.h:482
A list of zero terminated key/value strings.
Definition: avcodec.h:1071
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:446
void av_packet_unref(AVPacket *pkt)
Wipe the packet.
Definition: avpacket.c:550
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:265
void * buf
Definition: avisynth_c.h:553
Data found in BlockAdditional element of matroska container.
Definition: avcodec.h:1090
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:1055
static int copy_packet_data(AVPacket *pkt, const AVPacket *src, int dup)
Definition: avpacket.c:193
This side data should be associated with an audio stream and contains ReplayGain information in form ...
Definition: avcodec.h:1023
#define FF_MERGE_MARKER
Definition: avpacket.c:362
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:85
An AV_PKT_DATA_JP_DUALMONO side data packet indicates that the packet may contain "dual mono" audio s...
Definition: avcodec.h:1065
AVPacketSideData * side_data
Additional packet data that can be provided by the container.
Definition: avcodec.h:1173
#define FF_DISABLE_DEPRECATION_WARNINGS
Definition: internal.h:79
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:143
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:111
void av_init_packet(AVPacket *pkt)
Initialize optional fields of a packet with default values.
Definition: avpacket.c:49
char * key
Definition: dict.h:87
The optional settings (rendering instructions) that immediately follow the timestamp specifier of a W...
Definition: avcodec.h:1101
static av_always_inline void bytestream_put_buffer(uint8_t **b, const uint8_t *src, unsigned int size)
Definition: bytestream.h:366
char * value
Definition: dict.h:88
#define FF_ENABLE_DEPRECATION_WARNINGS
Definition: internal.h:80
int64_t dts
Decompression timestamp in AVStream->time_base units; the time at which the packet is decompressed...
Definition: avcodec.h:1161
const char * av_packet_side_data_name(enum AVPacketSideDataType type)
Definition: avpacket.c:339
#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:72
uint8_t * av_packet_get_side_data(AVPacket *pkt, enum AVPacketSideDataType type, int *size)
Get side information from packet.
Definition: avpacket.c:324
#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:1164
int av_copy_packet_side_data(AVPacket *pkt, const AVPacket *src)
Copy packet side data.
Definition: avpacket.c:223
This structure stores compressed data.
Definition: avcodec.h:1139
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:250
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
Definition: avcodec.h:1155
#define AV_NOPTS_VALUE
Undefined timestamp value.
Definition: avutil.h:241
This side data should be associated with an audio stream and corresponds to enum AVAudioServiceType.
Definition: avcodec.h:1044