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 ((unsigned)grow_by >
114  INT_MAX - (pkt->size + AV_INPUT_BUFFER_PADDING_SIZE))
115  return -1;
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 -1;
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  memcpy(pkt->buf->data, pkt->data, pkt->size);
143  pkt->data = pkt->buf->data;
144  }
145  pkt->size += grow_by;
146  memset(pkt->data + pkt->size, 0, AV_INPUT_BUFFER_PADDING_SIZE);
147 
148  return 0;
149 }
150 
152 {
153  if (size >= INT_MAX - AV_INPUT_BUFFER_PADDING_SIZE)
154  return AVERROR(EINVAL);
155 
158  if (!pkt->buf)
159  return AVERROR(ENOMEM);
160 
161  pkt->data = data;
162  pkt->size = size;
163 
164  return 0;
165 }
166 
167 #if FF_API_AVPACKET_OLD_API
169 #define ALLOC_MALLOC(data, size) data = av_malloc(size)
170 #define ALLOC_BUF(data, size) \
171 do { \
172  av_buffer_realloc(&pkt->buf, size); \
173  data = pkt->buf ? pkt->buf->data : NULL; \
174 } while (0)
175 
176 #define DUP_DATA(dst, src, size, padding, ALLOC) \
177  do { \
178  void *data; \
179  if (padding) { \
180  if ((unsigned)(size) > \
181  (unsigned)(size) + AV_INPUT_BUFFER_PADDING_SIZE) \
182  goto failed_alloc; \
183  ALLOC(data, size + AV_INPUT_BUFFER_PADDING_SIZE); \
184  } else { \
185  ALLOC(data, size); \
186  } \
187  if (!data) \
188  goto failed_alloc; \
189  memcpy(data, src, size); \
190  if (padding) \
191  memset((uint8_t *)data + size, 0, \
192  AV_INPUT_BUFFER_PADDING_SIZE); \
193  dst = data; \
194  } while (0)
195 
196 /* Makes duplicates of data, side_data, but does not copy any other fields */
197 static int copy_packet_data(AVPacket *pkt, const AVPacket *src, int dup)
198 {
199  pkt->data = NULL;
200  pkt->side_data = NULL;
201  if (pkt->buf) {
202  AVBufferRef *ref = av_buffer_ref(src->buf);
203  if (!ref)
204  return AVERROR(ENOMEM);
205  pkt->buf = ref;
206  pkt->data = ref->data;
207  } else {
208  DUP_DATA(pkt->data, src->data, pkt->size, 1, ALLOC_BUF);
209  }
210  if (pkt->side_data_elems && dup)
211  pkt->side_data = src->side_data;
212  if (pkt->side_data_elems && !dup) {
213  return av_copy_packet_side_data(pkt, src);
214  }
215  return 0;
216 
217 failed_alloc:
218  av_packet_unref(pkt);
219  return AVERROR(ENOMEM);
220 }
221 
223 {
224  if (src->side_data_elems) {
225  int i;
226  DUP_DATA(pkt->side_data, src->side_data,
227  src->side_data_elems * sizeof(*src->side_data), 0, ALLOC_MALLOC);
228  if (src != pkt) {
229  memset(pkt->side_data, 0,
230  src->side_data_elems * sizeof(*src->side_data));
231  }
232  for (i = 0; i < src->side_data_elems; i++) {
233  DUP_DATA(pkt->side_data[i].data, src->side_data[i].data,
234  src->side_data[i].size, 1, ALLOC_MALLOC);
235  pkt->side_data[i].size = src->side_data[i].size;
236  pkt->side_data[i].type = src->side_data[i].type;
237  }
238  }
239  pkt->side_data_elems = src->side_data_elems;
240  return 0;
241 
242 failed_alloc:
243  av_packet_unref(pkt);
244  return AVERROR(ENOMEM);
245 }
247 #endif
248 
250 {
251  AVPacket tmp_pkt;
252 
253  if (!pkt->buf && pkt->data) {
254  tmp_pkt = *pkt;
255  return copy_packet_data(pkt, &tmp_pkt, 1);
256  }
257  return 0;
258 }
259 
261 {
262  *dst = *src;
263  return copy_packet_data(dst, src, 0);
264 }
265 
267 {
268  int i;
269  for (i = 0; i < pkt->side_data_elems; i++)
270  av_freep(&pkt->side_data[i].data);
271  av_freep(&pkt->side_data);
272  pkt->side_data_elems = 0;
273 }
274 
275 #if FF_API_AVPACKET_OLD_API
278 {
279  if (pkt) {
280  if (pkt->buf)
281  av_buffer_unref(&pkt->buf);
282  pkt->data = NULL;
283  pkt->size = 0;
284 
286  }
287 }
289 #endif
290 
292  uint8_t *data, size_t size)
293 {
294  int elems = pkt->side_data_elems;
295 
296  if ((unsigned)elems + 1 > INT_MAX / sizeof(*pkt->side_data))
297  return AVERROR(ERANGE);
298 
299  pkt->side_data = av_realloc(pkt->side_data,
300  (elems + 1) * sizeof(*pkt->side_data));
301  if (!pkt->side_data)
302  return AVERROR(ENOMEM);
303 
304  pkt->side_data[elems].data = data;
305  pkt->side_data[elems].size = size;
306  pkt->side_data[elems].type = type;
307  pkt->side_data_elems++;
308 
309  return 0;
310 }
311 
312 
314  int size)
315 {
316  int ret;
317  uint8_t *data;
318 
319  if ((unsigned)size > INT_MAX - AV_INPUT_BUFFER_PADDING_SIZE)
320  return NULL;
322  if (!data)
323  return NULL;
324 
325  ret = av_packet_add_side_data(pkt, type, data, size);
326  if (ret < 0) {
327  av_freep(&data);
328  return NULL;
329  }
330 
331  return data;
332 }
333 
335  int *size)
336 {
337  int i;
338 
339  for (i = 0; i < pkt->side_data_elems; i++) {
340  if (pkt->side_data[i].type == type) {
341  if (size)
342  *size = pkt->side_data[i].size;
343  return pkt->side_data[i].data;
344  }
345  }
346  return NULL;
347 }
348 
350 {
351  switch(type) {
352  case AV_PKT_DATA_PALETTE: return "Palette";
353  case AV_PKT_DATA_NEW_EXTRADATA: return "New Extradata";
354  case AV_PKT_DATA_PARAM_CHANGE: return "Param Change";
355  case AV_PKT_DATA_H263_MB_INFO: return "H263 MB Info";
356  case AV_PKT_DATA_REPLAYGAIN: return "Replay Gain";
357  case AV_PKT_DATA_DISPLAYMATRIX: return "Display Matrix";
358  case AV_PKT_DATA_STEREO3D: return "Stereo 3D";
359  case AV_PKT_DATA_AUDIO_SERVICE_TYPE: return "Audio Service Type";
360  case AV_PKT_DATA_SKIP_SAMPLES: return "Skip Samples";
361  case AV_PKT_DATA_JP_DUALMONO: return "JP Dual Mono";
362  case AV_PKT_DATA_STRINGS_METADATA: return "Strings Metadata";
363  case AV_PKT_DATA_SUBTITLE_POSITION: return "Subtitle Position";
364  case AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL: return "Matroska BlockAdditional";
365  case AV_PKT_DATA_WEBVTT_IDENTIFIER: return "WebVTT ID";
366  case AV_PKT_DATA_WEBVTT_SETTINGS: return "WebVTT Settings";
367  case AV_PKT_DATA_METADATA_UPDATE: return "Metadata Update";
368  case AV_PKT_DATA_MPEGTS_STREAM_ID: return "MPEGTS Stream ID";
369  case AV_PKT_DATA_MASTERING_DISPLAY_METADATA: return "Mastering display metadata";
370  }
371  return NULL;
372 }
373 
374 #define FF_MERGE_MARKER 0x8c4d9d108e25e9feULL
375 
377  if(pkt->side_data_elems){
378  AVBufferRef *buf;
379  int i;
380  uint8_t *p;
381  uint64_t size= pkt->size + 8LL + AV_INPUT_BUFFER_PADDING_SIZE;
382  AVPacket old= *pkt;
383  for (i=0; i<old.side_data_elems; i++) {
384  size += old.side_data[i].size + 5LL;
385  }
386  if (size > INT_MAX)
387  return AVERROR(EINVAL);
388  buf = av_buffer_alloc(size);
389  if (!buf)
390  return AVERROR(ENOMEM);
391  pkt->buf = buf;
392  pkt->data = p = buf->data;
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_packet_unref(&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  pkt->side_data = av_malloc_array(i, sizeof(*pkt->side_data));
430  if (!pkt->side_data)
431  return AVERROR(ENOMEM);
432 
433  p= pkt->data + pkt->size - 8 - 5;
434  for (i=0; ; i++){
435  size= AV_RB32(p);
438  pkt->side_data[i].size = size;
439  pkt->side_data[i].type = p[4]&127;
440  if (!pkt->side_data[i].data)
441  return AVERROR(ENOMEM);
442  memcpy(pkt->side_data[i].data, p-size, size);
443  pkt->size -= size + 5;
444  if(p[4]&128)
445  break;
446  p-= size+5;
447  }
448  pkt->size -= 8;
449  pkt->side_data_elems = i+1;
450  return 1;
451  }
452  return 0;
453 }
454 
456 {
457  AVDictionaryEntry *t = NULL;
458  uint8_t *data = NULL;
459  *size = 0;
460 
461  if (!dict)
462  return NULL;
463 
464  while ((t = av_dict_get(dict, "", t, AV_DICT_IGNORE_SUFFIX))) {
465  const size_t keylen = strlen(t->key);
466  const size_t valuelen = strlen(t->value);
467  const size_t new_size = *size + keylen + 1 + valuelen + 1;
468  uint8_t *const new_data = av_realloc(data, new_size);
469 
470  if (!new_data)
471  goto fail;
472  data = new_data;
473  if (new_size > INT_MAX)
474  goto fail;
475 
476  memcpy(data + *size, t->key, keylen + 1);
477  memcpy(data + *size + keylen + 1, t->value, valuelen + 1);
478 
479  *size = new_size;
480  }
481 
482  return data;
483 
484 fail:
485  av_freep(&data);
486  *size = 0;
487  return NULL;
488 }
489 
491 {
492  const uint8_t *end = data + size;
493  int ret = 0;
494 
495  if (!dict || !data || !size)
496  return ret;
497  if (size && end[-1])
498  return AVERROR_INVALIDDATA;
499  while (data < end) {
500  const uint8_t *key = data;
501  const uint8_t *val = data + strlen(key) + 1;
502 
503  if (val >= end)
504  return AVERROR_INVALIDDATA;
505 
506  ret = av_dict_set(dict, key, val, 0);
507  if (ret < 0)
508  break;
509  data = val + strlen(val) + 1;
510  }
511 
512  return ret;
513 }
514 
516  int size)
517 {
518  int i;
519 
520  for (i = 0; i < pkt->side_data_elems; i++) {
521  if (pkt->side_data[i].type == type) {
522  if (size > pkt->side_data[i].size)
523  return AVERROR(ENOMEM);
524  pkt->side_data[i].size = size;
525  return 0;
526  }
527  }
528  return AVERROR(ENOENT);
529 }
530 
532 {
533  int i;
534 
535  dst->pts = src->pts;
536  dst->dts = src->dts;
537  dst->pos = src->pos;
538  dst->duration = src->duration;
539 #if FF_API_CONVERGENCE_DURATION
543 #endif
544  dst->flags = src->flags;
545  dst->stream_index = src->stream_index;
546 
547  for (i = 0; i < src->side_data_elems; i++) {
548  enum AVPacketSideDataType type = src->side_data[i].type;
549  int size = src->side_data[i].size;
550  uint8_t *src_data = src->side_data[i].data;
551  uint8_t *dst_data = av_packet_new_side_data(dst, type, size);
552 
553  if (!dst_data) {
555  return AVERROR(ENOMEM);
556  }
557  memcpy(dst_data, src_data, size);
558  }
559 
560  return 0;
561 }
562 
564 {
566  av_buffer_unref(&pkt->buf);
567  av_init_packet(pkt);
568  pkt->data = NULL;
569  pkt->size = 0;
570 }
571 
573 {
574  int ret;
575 
576  ret = av_packet_copy_props(dst, src);
577  if (ret < 0)
578  return ret;
579 
580  if (!src->buf) {
581  ret = packet_alloc(&dst->buf, src->size);
582  if (ret < 0)
583  goto fail;
584  memcpy(dst->buf->data, src->data, src->size);
585 
586  dst->data = dst->buf->data;
587  } else {
588  dst->buf = av_buffer_ref(src->buf);
589  if (!dst->buf) {
590  ret = AVERROR(ENOMEM);
591  goto fail;
592  }
593  dst->data = src->data;
594  }
595 
596  dst->size = src->size;
597 
598  return 0;
599 fail:
601  return ret;
602 }
603 
605 {
606  AVPacket *ret = av_packet_alloc();
607 
608  if (!ret)
609  return ret;
610 
611  if (av_packet_ref(ret, src))
612  av_packet_free(&ret);
613 
614  return ret;
615 }
616 
618 {
619  *dst = *src;
620  av_init_packet(src);
621  src->data = NULL;
622  src->size = 0;
623 }
624 
626 {
627  if (pkt->pts != AV_NOPTS_VALUE)
628  pkt->pts = av_rescale_q(pkt->pts, src_tb, dst_tb);
629  if (pkt->dts != AV_NOPTS_VALUE)
630  pkt->dts = av_rescale_q(pkt->dts, src_tb, dst_tb);
631  if (pkt->duration > 0)
632  pkt->duration = av_rescale_q(pkt->duration, src_tb, dst_tb);
633 #if FF_API_CONVERGENCE_DURATION
635  if (pkt->convergence_duration > 0)
636  pkt->convergence_duration = av_rescale_q(pkt->convergence_duration, src_tb, dst_tb);
638 #endif
639 }
640 
641 int ff_side_data_set_encoder_stats(AVPacket *pkt, int quality, int64_t *error, int error_count, int pict_type)
642 {
643  uint8_t *side_data;
644  int side_data_size;
645  int i;
646 
647  side_data = av_packet_get_side_data(pkt, AV_PKT_DATA_QUALITY_STATS, &side_data_size);
648  if (!side_data) {
649  side_data_size = 4+4+8*error_count;
651  side_data_size);
652  }
653 
654  if (!side_data || side_data_size < 4+4+8*error_count)
655  return AVERROR(ENOMEM);
656 
657  AV_WL32(side_data , quality );
658  side_data[4] = pict_type;
659  side_data[5] = error_count;
660  for (i = 0; i<error_count; i++)
661  AV_WL64(side_data+8 + 8*i , error[i]);
662 
663  return 0;
664 }
#define NULL
Definition: coverity.c:32
const char const char void * val
Definition: avisynth_c.h:771
#define DUP_DATA(dst, src, size, padding, ALLOC)
Definition: avpacket.c:176
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
Definition: error.h:59
AVPacketSideDataType
Definition: avcodec.h:1351
A list of zero terminated key/value strings.
Definition: avcodec.h:1515
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:1502
void * av_realloc(void *ptr, size_t size)
Allocate, reallocate, or free a block of memory.
Definition: mem.c:145
int ff_side_data_set_encoder_stats(AVPacket *pkt, int quality, int64_t *error, int error_count, int pict_type)
Definition: avpacket.c:641
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:1610
void av_shrink_packet(AVPacket *pkt, int size)
Reduce packet size, correctly zeroing padding.
Definition: avpacket.c:101
Subtitle event position.
Definition: avcodec.h:1489
#define ALLOC_MALLOC(data, size)
Definition: avpacket.c:169
This side data should be associated with a video stream and contains Stereoscopic 3D information in f...
Definition: avcodec.h:1420
int size
Definition: avcodec.h:1591
#define ALLOC_BUF(data, size)
Definition: avpacket.c:170
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
Definition: mem.c:252
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:1399
Mastering display metadata (based on SMPTE-2086:2014).
Definition: avcodec.h:1528
#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:490
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:1608
This side data contains a 3x3 transformation matrix describing an affine transformation that needs to...
Definition: avcodec.h:1414
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:151
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:40
uint8_t * data
Definition: avcodec.h:1590
void av_packet_move_ref(AVPacket *dst, AVPacket *src)
Move every field in src to dst and reset src.
Definition: avpacket.c:617
uint8_t * data
Definition: avcodec.h:1534
ptrdiff_t size
Definition: opengl_enc.c:101
int av_packet_ref(AVPacket *dst, const AVPacket *src)
Setup a new reference to the data described by a given packet.
Definition: avpacket.c:572
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:1521
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:625
An AV_PKT_DATA_PARAM_CHANGE side data packet is laid out as follows:
Definition: avcodec.h:1378
#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:266
FF_ENABLE_DEPRECATION_WARNINGS int av_dup_packet(AVPacket *pkt)
Definition: avpacket.c:249
AVBufferRef * buf
A reference to the reference-counted buffer where the packet data is stored.
Definition: avcodec.h:1573
simple assert() macros that are a bit more flexible than ISO C assert().
enum AVPacketSideDataType type
Definition: avcodec.h:1536
int side_data_elems
Definition: avcodec.h:1602
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:515
int av_buffer_realloc(AVBufferRef **pbuf, int size)
Reallocate a given buffer.
Definition: buffer.c:168
#define fail()
Definition: checkasm.h:82
int flags
A combination of AV_PKT_FLAG values.
Definition: avcodec.h:1596
int av_packet_merge_side_data(AVPacket *pkt)
Definition: avpacket.c:376
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:531
This side data contains quality related information from the encoder.
Definition: avcodec.h:1438
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:411
AVPacket * av_packet_clone(AVPacket *src)
Create a new packet that references the same data as src.
Definition: avpacket.c:604
The AV_PKT_DATA_NEW_EXTRADATA is used to notify the codec or the format that the extradata buffer was...
Definition: avcodec.h:1361
Libavcodec external API header.
A list of zero terminated key/value strings.
Definition: avcodec.h:1478
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:455
void av_packet_unref(AVPacket *pkt)
Wipe the packet.
Definition: avpacket.c:563
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:260
void * buf
Definition: avisynth_c.h:690
Data found in BlockAdditional element of matroska container.
Definition: avcodec.h:1497
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:70
Rational number (pair of numerator and denominator).
Definition: rational.h:58
Recommmends skipping the specified number of samples.
Definition: avcodec.h:1462
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:291
static int copy_packet_data(AVPacket *pkt, const AVPacket *src, int dup)
Definition: avpacket.c:197
int size
Size of data in bytes.
Definition: buffer.h:93
This side data should be associated with an audio stream and contains ReplayGain information in form ...
Definition: avcodec.h:1405
#define FF_MERGE_MARKER
Definition: avpacket.c:374
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:1472
AVPacketSideData * side_data
Additional packet data that can be provided by the container.
Definition: avcodec.h:1601
attribute_deprecated int64_t convergence_duration
Definition: avcodec.h:1619
#define FF_DISABLE_DEPRECATION_WARNINGS
Definition: internal.h:80
common internal api header.
common internal and external API header
static int ref[MAX_W *MAX_W]
Definition: jpeg2000dwt.c:107
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:1508
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:733
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:1589
const char * av_packet_side_data_name(enum AVPacketSideDataType type)
Definition: avpacket.c:349
FF_DISABLE_DEPRECATION_WARNINGS void av_free_packet(AVPacket *pkt)
Free a packet.
Definition: avpacket.c:277
#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:334
#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:313
int stream_index
Definition: avcodec.h:1592
int av_copy_packet_side_data(AVPacket *pkt, const AVPacket *src)
Copy packet side data.
Definition: avpacket.c:222
This structure stores compressed data.
Definition: avcodec.h:1567
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
Definition: avcodec.h:1583
#define AV_NOPTS_VALUE
Undefined timestamp value.
Definition: avutil.h:242
#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:1426