FFmpeg  2.8.17
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules 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;
61  pkt->priv = NULL;
63 #endif
64  pkt->buf = NULL;
65  pkt->side_data = NULL;
66  pkt->side_data_elems = 0;
67 }
68 
69 static int packet_alloc(AVBufferRef **buf, int size)
70 {
71  int ret;
72  if ((unsigned)size >= (unsigned)size + AV_INPUT_BUFFER_PADDING_SIZE)
73  return AVERROR(EINVAL);
74 
76  if (ret < 0)
77  return ret;
78 
79  memset((*buf)->data + size, 0, AV_INPUT_BUFFER_PADDING_SIZE);
80 
81  return 0;
82 }
83 
85 {
86  AVBufferRef *buf = NULL;
87  int ret = packet_alloc(&buf, size);
88  if (ret < 0)
89  return ret;
90 
91  av_init_packet(pkt);
92  pkt->buf = buf;
93  pkt->data = buf->data;
94  pkt->size = size;
95 #if FF_API_DESTRUCT_PACKET
99 #endif
100 
101  return 0;
102 }
103 
105 {
106  if (pkt->size <= size)
107  return;
108  pkt->size = size;
109  memset(pkt->data + size, 0, AV_INPUT_BUFFER_PADDING_SIZE);
110 }
111 
112 int av_grow_packet(AVPacket *pkt, int grow_by)
113 {
114  int new_size;
115  av_assert0((unsigned)pkt->size <= INT_MAX - AV_INPUT_BUFFER_PADDING_SIZE);
116  if (!pkt->size)
117  return av_new_packet(pkt, grow_by);
118  if ((unsigned)grow_by >
119  INT_MAX - (pkt->size + AV_INPUT_BUFFER_PADDING_SIZE))
120  return -1;
121 
122  new_size = pkt->size + grow_by + AV_INPUT_BUFFER_PADDING_SIZE;
123  if (pkt->buf) {
124  int ret = av_buffer_realloc(&pkt->buf, new_size);
125  if (ret < 0)
126  return ret;
127  } else {
128  pkt->buf = av_buffer_alloc(new_size);
129  if (!pkt->buf)
130  return AVERROR(ENOMEM);
131  memcpy(pkt->buf->data, pkt->data, FFMIN(pkt->size, pkt->size + grow_by));
132 #if FF_API_DESTRUCT_PACKET
136 #endif
137  }
138  pkt->data = pkt->buf->data;
139  pkt->size += grow_by;
140  memset(pkt->data + pkt->size, 0, AV_INPUT_BUFFER_PADDING_SIZE);
141 
142  return 0;
143 }
144 
146 {
147  if (size >= INT_MAX - AV_INPUT_BUFFER_PADDING_SIZE)
148  return AVERROR(EINVAL);
149 
152  if (!pkt->buf)
153  return AVERROR(ENOMEM);
154 
155  pkt->data = data;
156  pkt->size = size;
157 #if FF_API_DESTRUCT_PACKET
161 #endif
162 
163  return 0;
164 }
165 
166 #define ALLOC_MALLOC(data, size) data = av_malloc(size)
167 #define ALLOC_BUF(data, size) \
168 do { \
169  av_buffer_realloc(&pkt->buf, size); \
170  data = pkt->buf ? pkt->buf->data : NULL; \
171 } while (0)
172 
173 #define DUP_DATA(dst, src, size, padding, ALLOC) \
174  do { \
175  void *data; \
176  if (padding) { \
177  if ((unsigned)(size) > \
178  (unsigned)(size) + AV_INPUT_BUFFER_PADDING_SIZE) \
179  goto failed_alloc; \
180  ALLOC(data, size + AV_INPUT_BUFFER_PADDING_SIZE); \
181  } else { \
182  ALLOC(data, size); \
183  } \
184  if (!data) \
185  goto failed_alloc; \
186  memcpy(data, src, size); \
187  if (padding) \
188  memset((uint8_t *)data + size, 0, \
189  AV_INPUT_BUFFER_PADDING_SIZE); \
190  dst = data; \
191  } while (0)
192 
193 /* Makes duplicates of data, side_data, but does not copy any other fields */
194 static int copy_packet_data(AVPacket *pkt, const AVPacket *src, int dup)
195 {
196  pkt->data = NULL;
197  pkt->side_data = NULL;
198  pkt->side_data_elems = 0;
199  if (pkt->buf) {
200  AVBufferRef *ref = av_buffer_ref(src->buf);
201  if (!ref)
202  return AVERROR(ENOMEM);
203  pkt->buf = ref;
204  pkt->data = ref->data;
205  } else {
206  DUP_DATA(pkt->data, src->data, pkt->size, 1, ALLOC_BUF);
207  }
208 #if FF_API_DESTRUCT_PACKET
212 #endif
213  if (src->side_data_elems && dup) {
214  pkt->side_data = src->side_data;
215  pkt->side_data_elems = src->side_data_elems;
216  }
217  if (src->side_data_elems && !dup) {
218  return av_copy_packet_side_data(pkt, src);
219  }
220  return 0;
221 
222 failed_alloc:
223  av_free_packet(pkt);
224  return AVERROR(ENOMEM);
225 }
226 
228 {
229  if (src->side_data_elems) {
230  int i;
231  DUP_DATA(pkt->side_data, src->side_data,
232  src->side_data_elems * sizeof(*src->side_data), 0, ALLOC_MALLOC);
233  if (src != pkt) {
234  memset(pkt->side_data, 0,
235  src->side_data_elems * sizeof(*src->side_data));
236  }
237  for (i = 0; i < src->side_data_elems; i++) {
238  DUP_DATA(pkt->side_data[i].data, src->side_data[i].data,
239  src->side_data[i].size, 1, ALLOC_MALLOC);
240  pkt->side_data[i].size = src->side_data[i].size;
241  pkt->side_data[i].type = src->side_data[i].type;
242  }
243  }
244  pkt->side_data_elems = src->side_data_elems;
245  return 0;
246 
247 failed_alloc:
248  av_free_packet(pkt);
249  return AVERROR(ENOMEM);
250 }
251 
253 {
254  AVPacket tmp_pkt;
255 
257  if (!pkt->buf && pkt->data
259  && !pkt->destruct
260 #endif
261  ) {
263  tmp_pkt = *pkt;
264  return copy_packet_data(pkt, &tmp_pkt, 1);
265  }
266  return 0;
267 }
268 
270 {
271  *dst = *src;
272  return copy_packet_data(dst, src, 0);
273 }
274 
276 {
277  int i;
278  for (i = 0; i < pkt->side_data_elems; i++)
279  av_freep(&pkt->side_data[i].data);
280  av_freep(&pkt->side_data);
281  pkt->side_data_elems = 0;
282 }
283 
285 {
286  if (pkt) {
288  if (pkt->buf)
289  av_buffer_unref(&pkt->buf);
290 #if FF_API_DESTRUCT_PACKET
291  else if (pkt->destruct)
292  pkt->destruct(pkt);
293  pkt->destruct = NULL;
294 #endif
296  pkt->data = NULL;
297  pkt->size = 0;
298 
300  }
301 }
302 
304  int size)
305 {
306  int elems = pkt->side_data_elems;
307 
308  if ((unsigned)elems + 1 > AV_PKT_DATA_NB)
309  return NULL;
310  if ((unsigned)size > INT_MAX - AV_INPUT_BUFFER_PADDING_SIZE)
311  return NULL;
312 
313 
314  pkt->side_data = av_realloc(pkt->side_data,
315  (elems + 1) * sizeof(*pkt->side_data));
316  if (!pkt->side_data)
317  return NULL;
318 
320  if (!pkt->side_data[elems].data)
321  return NULL;
322  pkt->side_data[elems].size = size;
323  pkt->side_data[elems].type = type;
324  pkt->side_data_elems++;
325 
326  return pkt->side_data[elems].data;
327 }
328 
330  int *size)
331 {
332  int i;
333 
334  for (i = 0; i < pkt->side_data_elems; i++) {
335  if (pkt->side_data[i].type == type) {
336  if (size)
337  *size = pkt->side_data[i].size;
338  return pkt->side_data[i].data;
339  }
340  }
341  if (size)
342  *size = 0;
343  return NULL;
344 }
345 
347 {
348  switch(type) {
349  case AV_PKT_DATA_PALETTE: return "Palette";
350  case AV_PKT_DATA_NEW_EXTRADATA: return "New Extradata";
351  case AV_PKT_DATA_PARAM_CHANGE: return "Param Change";
352  case AV_PKT_DATA_H263_MB_INFO: return "H263 MB Info";
353  case AV_PKT_DATA_REPLAYGAIN: return "Replay Gain";
354  case AV_PKT_DATA_DISPLAYMATRIX: return "Display Matrix";
355  case AV_PKT_DATA_STEREO3D: return "Stereo 3D";
356  case AV_PKT_DATA_AUDIO_SERVICE_TYPE: return "Audio Service Type";
357  case AV_PKT_DATA_SKIP_SAMPLES: return "Skip Samples";
358  case AV_PKT_DATA_JP_DUALMONO: return "JP Dual Mono";
359  case AV_PKT_DATA_STRINGS_METADATA: return "Strings Metadata";
360  case AV_PKT_DATA_SUBTITLE_POSITION: return "Subtitle Position";
361  case AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL: return "Matroska BlockAdditional";
362  case AV_PKT_DATA_WEBVTT_IDENTIFIER: return "WebVTT ID";
363  case AV_PKT_DATA_WEBVTT_SETTINGS: return "WebVTT Settings";
364  case AV_PKT_DATA_METADATA_UPDATE: return "Metadata Update";
365  }
366  return NULL;
367 }
368 
369 #define FF_MERGE_MARKER 0x8c4d9d108e25e9feULL
370 
372  if(pkt->side_data_elems){
373  AVBufferRef *buf;
374  int i;
375  uint8_t *p;
376  uint64_t size= pkt->size + 8LL + AV_INPUT_BUFFER_PADDING_SIZE;
377  AVPacket old= *pkt;
378  for (i=0; i<old.side_data_elems; i++) {
379  size += old.side_data[i].size + 5LL;
380  }
381  if (size > INT_MAX)
382  return AVERROR(EINVAL);
383  buf = av_buffer_alloc(size);
384  if (!buf)
385  return AVERROR(ENOMEM);
386  pkt->buf = buf;
387  pkt->data = p = buf->data;
388 #if FF_API_DESTRUCT_PACKET
392 #endif
393  pkt->size = size - AV_INPUT_BUFFER_PADDING_SIZE;
394  bytestream_put_buffer(&p, old.data, old.size);
395  for (i=old.side_data_elems-1; i>=0; i--) {
396  bytestream_put_buffer(&p, old.side_data[i].data, old.side_data[i].size);
397  bytestream_put_be32(&p, old.side_data[i].size);
398  *p++ = old.side_data[i].type | ((i==old.side_data_elems-1)*128);
399  }
400  bytestream_put_be64(&p, FF_MERGE_MARKER);
401  av_assert0(p-pkt->data == pkt->size);
402  memset(p, 0, AV_INPUT_BUFFER_PADDING_SIZE);
403  av_free_packet(&old);
404  pkt->side_data_elems = 0;
405  pkt->side_data = NULL;
406  return 1;
407  }
408  return 0;
409 }
410 
412  if (!pkt->side_data_elems && pkt->size >12 && AV_RB64(pkt->data + pkt->size - 8) == FF_MERGE_MARKER){
413  int i;
414  unsigned int size;
415  uint8_t *p;
416 
417  p = pkt->data + pkt->size - 8 - 5;
418  for (i=1; ; i++){
419  size = AV_RB32(p);
420  if (size>INT_MAX - 5 || p - pkt->data < size)
421  return 0;
422  if (p[4]&128)
423  break;
424  if (p - pkt->data < size + 5)
425  return 0;
426  p-= size+5;
427  }
428 
429  if (i > AV_PKT_DATA_NB)
430  return AVERROR(ERANGE);
431 
432  pkt->side_data = av_malloc_array(i, sizeof(*pkt->side_data));
433  if (!pkt->side_data)
434  return AVERROR(ENOMEM);
435 
436  p= pkt->data + pkt->size - 8 - 5;
437  for (i=0; ; i++){
438  size= AV_RB32(p);
441  pkt->side_data[i].size = size;
442  pkt->side_data[i].type = p[4]&127;
443  if (!pkt->side_data[i].data)
444  return AVERROR(ENOMEM);
445  memcpy(pkt->side_data[i].data, p-size, size);
446  pkt->size -= size + 5;
447  if(p[4]&128)
448  break;
449  p-= size+5;
450  }
451  pkt->size -= 8;
452  pkt->side_data_elems = i+1;
453  return 1;
454  }
455  return 0;
456 }
457 
459 {
460  AVDictionaryEntry *t = NULL;
461  uint8_t *data = NULL;
462  *size = 0;
463 
464  if (!dict)
465  return NULL;
466 
467  while ((t = av_dict_get(dict, "", t, AV_DICT_IGNORE_SUFFIX))) {
468  const size_t keylen = strlen(t->key);
469  const size_t valuelen = strlen(t->value);
470  const size_t new_size = *size + keylen + 1 + valuelen + 1;
471  uint8_t *const new_data = av_realloc(data, new_size);
472 
473  if (!new_data)
474  goto fail;
475  data = new_data;
476  if (new_size > INT_MAX)
477  goto fail;
478 
479  memcpy(data + *size, t->key, keylen + 1);
480  memcpy(data + *size + keylen + 1, t->value, valuelen + 1);
481 
482  *size = new_size;
483  }
484 
485  return data;
486 
487 fail:
488  av_freep(&data);
489  *size = 0;
490  return NULL;
491 }
492 
494 {
495  const uint8_t *end = data + size;
496  int ret = 0;
497 
498  if (!dict || !data || !size)
499  return ret;
500  if (size && end[-1])
501  return AVERROR_INVALIDDATA;
502  while (data < end) {
503  const uint8_t *key = data;
504  const uint8_t *val = data + strlen(key) + 1;
505 
506  if (val >= end)
507  return AVERROR_INVALIDDATA;
508 
509  ret = av_dict_set(dict, key, val, 0);
510  if (ret < 0)
511  break;
512  data = val + strlen(val) + 1;
513  }
514 
515  return ret;
516 }
517 
519  int size)
520 {
521  int i;
522 
523  for (i = 0; i < pkt->side_data_elems; i++) {
524  if (pkt->side_data[i].type == type) {
525  if (size > pkt->side_data[i].size)
526  return AVERROR(ENOMEM);
527  pkt->side_data[i].size = size;
528  return 0;
529  }
530  }
531  return AVERROR(ENOENT);
532 }
533 
535 {
536  int i;
537 
538  dst->pts = src->pts;
539  dst->dts = src->dts;
540  dst->pos = src->pos;
541  dst->duration = src->duration;
543  dst->flags = src->flags;
544  dst->stream_index = src->stream_index;
545 
546  for (i = 0; i < src->side_data_elems; i++) {
547  enum AVPacketSideDataType type = src->side_data[i].type;
548  int size = src->side_data[i].size;
549  uint8_t *src_data = src->side_data[i].data;
550  uint8_t *dst_data = av_packet_new_side_data(dst, type, size);
551 
552  if (!dst_data) {
554  return AVERROR(ENOMEM);
555  }
556  memcpy(dst_data, src_data, size);
557  }
558 
559  return 0;
560 }
561 
563 {
565  av_buffer_unref(&pkt->buf);
566  av_init_packet(pkt);
567  pkt->data = NULL;
568  pkt->size = 0;
569 }
570 
572 {
573  int ret;
574 
575  ret = av_packet_copy_props(dst, src);
576  if (ret < 0)
577  return ret;
578 
579  if (!src->buf) {
580  ret = packet_alloc(&dst->buf, src->size);
581  if (ret < 0)
582  goto fail;
583  memcpy(dst->buf->data, src->data, src->size);
584  } else {
585  dst->buf = av_buffer_ref(src->buf);
586  if (!dst->buf) {
587  ret = AVERROR(ENOMEM);
588  goto fail;
589  }
590  }
591 
592  dst->size = src->size;
593  dst->data = dst->buf->data;
594  return 0;
595 fail:
597  return ret;
598 }
599 
601 {
602  *dst = *src;
603  av_init_packet(src);
604 }
605 
607 {
608  if (pkt->pts != AV_NOPTS_VALUE)
609  pkt->pts = av_rescale_q(pkt->pts, src_tb, dst_tb);
610  if (pkt->dts != AV_NOPTS_VALUE)
611  pkt->dts = av_rescale_q(pkt->dts, src_tb, dst_tb);
612  if (pkt->duration > 0)
613  pkt->duration = av_rescale_q(pkt->duration, src_tb, dst_tb);
614  if (pkt->convergence_duration > 0)
615  pkt->convergence_duration = av_rescale_q(pkt->convergence_duration, src_tb, dst_tb);
616 }
617 
618 int ff_side_data_set_encoder_stats(AVPacket *pkt, int quality, int64_t *error, int error_count, int pict_type)
619 {
620  uint8_t *side_data;
621  int side_data_size;
622  int i;
623 
624  side_data = av_packet_get_side_data(pkt, AV_PKT_DATA_QUALITY_STATS, &side_data_size);
625  if (!side_data) {
626  side_data_size = 4+4+8*error_count;
628  side_data_size);
629  }
630 
631  if (!side_data || side_data_size < 4+4+8*error_count)
632  return AVERROR(ENOMEM);
633 
634  AV_WL32(side_data , quality );
635  side_data[4] = pict_type;
636  side_data[5] = error_count;
637  for (i = 0; i<error_count; i++)
638  AV_WL64(side_data+8 + 8*i , error[i]);
639 
640  return 0;
641 }
#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:173
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
Definition: error.h:59
AVPacketSideDataType
Definition: avcodec.h:1224
A list of zero terminated key/value strings.
Definition: avcodec.h:1367
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:284
The optional first identifier line of a WebVTT cue.
Definition: avcodec.h:1354
int ff_side_data_set_encoder_stats(AVPacket *pkt, int quality, int64_t *error, int error_count, int pict_type)
Definition: avpacket.c:618
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:1458
#define AV_RB64
Definition: intreadwrite.h:164
void av_shrink_packet(AVPacket *pkt, int size)
Reduce packet size, correctly zeroing padding.
Definition: avpacket.c:104
Subtitle event position.
Definition: avcodec.h:1341
#define ALLOC_MALLOC(data, size)
Definition: avpacket.c:166
This side data should be associated with a video stream and contains Stereoscopic 3D information in f...
Definition: avcodec.h:1285
int size
Definition: avcodec.h:1434
#define ALLOC_BUF(data, size)
Definition: avpacket.c:167
static AVPacket pkt
int av_dup_packet(AVPacket *pkt)
Definition: avpacket.c:252
An AV_PKT_DATA_H263_MB_INFO side data packet contains a number of structures with info about macroblo...
Definition: avcodec.h:1264
#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:493
attribute_deprecated void(* destruct)(struct AVPacket *)
Definition: avcodec.h:1454
#define AV_RB32
Definition: intreadwrite.h:130
static av_cold int end(AVCodecContext *avctx)
Definition: avrndec.c:90
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:1279
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:145
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:1433
void av_packet_move_ref(AVPacket *dst, AVPacket *src)
Move every field in src to dst and reset src.
Definition: avpacket.c:600
uint8_t * data
Definition: avcodec.h:1383
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:1451
int av_packet_ref(AVPacket *dst, const AVPacket *src)
Setup a new reference to the data described by a given packet.
Definition: avpacket.c:571
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:147
int av_new_packet(AVPacket *pkt, int size)
Allocate the payload of a packet and initialize its fields with default values.
Definition: avpacket.c:84
#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:606
An AV_PKT_DATA_PARAM_CHANGE side data packet is laid out as follows:
Definition: avcodec.h:1243
#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:275
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:1477
AVBufferRef * buf
A reference to the reference-counted buffer where the packet data is stored.
Definition: avcodec.h:1416
simple assert() macros that are a bit more flexible than ISO C assert().
enum AVPacketSideDataType type
Definition: avcodec.h:1385
int side_data_elems
Definition: avcodec.h:1445
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:518
int av_buffer_realloc(AVBufferRef **pbuf, int size)
Reallocate a given buffer.
Definition: buffer.c:168
Libavcodec external API header.
#define fail()
Definition: checkasm.h:57
int flags
A combination of AV_PKT_FLAG values.
Definition: avcodec.h:1439
int av_packet_merge_side_data(AVPacket *pkt)
Definition: avpacket.c:371
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:534
#define FFMIN(a, b)
Definition: common.h:92
This side data contains quality related information from the encoder.
Definition: avcodec.h:1303
static int packet_alloc(AVBufferRef **buf, int size)
Definition: avpacket.c:69
#define FF_API_DESTRUCT_PACKET
Definition: version.h:83
int av_packet_split_side_data(AVPacket *pkt)
Definition: avpacket.c:411
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:1330
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:458
void av_packet_unref(AVPacket *pkt)
Wipe the packet.
Definition: avpacket.c:562
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:269
void * buf
Definition: avisynth_c.h:553
Data found in BlockAdditional element of matroska container.
Definition: avcodec.h:1349
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:1314
attribute_deprecated void * priv
Definition: avcodec.h:1456
static int copy_packet_data(AVPacket *pkt, const AVPacket *src, int dup)
Definition: avpacket.c:194
This side data should be associated with an audio stream and contains ReplayGain information in form ...
Definition: avcodec.h:1270
#define FF_MERGE_MARKER
Definition: avpacket.c:369
A reference to a data buffer.
Definition: buffer.h:81
An AV_PKT_DATA_JP_DUALMONO side data packet indicates that the packet may contain "dual mono" audio s...
Definition: avcodec.h:1324
AVPacketSideData * side_data
Additional packet data that can be provided by the container.
Definition: avcodec.h:1444
#define FF_DISABLE_DEPRECATION_WARNINGS
Definition: internal.h:82
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:112
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:1360
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:636
char * value
Definition: dict.h:88
#define FF_ENABLE_DEPRECATION_WARNINGS
Definition: internal.h:83
int64_t dts
Decompression timestamp in AVStream->time_base units; the time at which the packet is decompressed...
Definition: avcodec.h:1432
const char * av_packet_side_data_name(enum AVPacketSideDataType type)
Definition: avpacket.c:346
#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:329
#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:303
int stream_index
Definition: avcodec.h:1435
int av_copy_packet_side_data(AVPacket *pkt, const AVPacket *src)
Copy packet side data.
Definition: avpacket.c:227
The number of side data elements (in fact a bit more than it).
Definition: avcodec.h:1377
This structure stores compressed data.
Definition: avcodec.h:1410
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:1426
#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:1291