FFmpeg
avpacket.c
Go to the documentation of this file.
1 /*
2  * AVPacket functions for libavcodec
3  * Copyright (c) 2000, 2001, 2002 Fabrice Bellard
4  *
5  * This file is part of FFmpeg.
6  *
7  * FFmpeg is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * FFmpeg is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with FFmpeg; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20  */
21 
22 #include <string.h>
23 
24 #include "libavutil/avassert.h"
25 #include "libavutil/common.h"
26 #include "libavutil/internal.h"
27 #include "libavutil/mathematics.h"
28 #include "libavutil/mem.h"
29 
30 #include "bytestream.h"
31 #include "internal.h"
32 #include "packet.h"
33 #include "packet_internal.h"
34 
35 #if FF_API_INIT_PACKET
37 {
40  pkt->pos = -1;
41  pkt->duration = 0;
42  pkt->flags = 0;
43  pkt->stream_index = 0;
44  pkt->buf = NULL;
45  pkt->side_data = NULL;
46  pkt->side_data_elems = 0;
47 }
48 #endif
49 
51 {
52  memset(pkt, 0, sizeof(*pkt));
53 
56  pkt->pos = -1;
57 }
58 
60 {
61  AVPacket *pkt = av_malloc(sizeof(AVPacket));
62  if (!pkt)
63  return pkt;
64 
66 
67  return pkt;
68 }
69 
71 {
72  if (!pkt || !*pkt)
73  return;
74 
76  av_freep(pkt);
77 }
78 
79 static int packet_alloc(AVBufferRef **buf, int size)
80 {
81  int ret;
82  if (size < 0 || size >= INT_MAX - AV_INPUT_BUFFER_PADDING_SIZE)
83  return AVERROR(EINVAL);
84 
86  if (ret < 0)
87  return ret;
88 
89  memset((*buf)->data + size, 0, AV_INPUT_BUFFER_PADDING_SIZE);
90 
91  return 0;
92 }
93 
95 {
96  AVBufferRef *buf = NULL;
97  int ret = packet_alloc(&buf, size);
98  if (ret < 0)
99  return ret;
100 
102  pkt->buf = buf;
103  pkt->data = buf->data;
104  pkt->size = size;
105 
106  return 0;
107 }
108 
110 {
111  if (pkt->size <= size)
112  return;
113  pkt->size = size;
114  memset(pkt->data + size, 0, AV_INPUT_BUFFER_PADDING_SIZE);
115 }
116 
117 int av_grow_packet(AVPacket *pkt, int grow_by)
118 {
119  int new_size;
120  av_assert0((unsigned)pkt->size <= INT_MAX - AV_INPUT_BUFFER_PADDING_SIZE);
121  if ((unsigned)grow_by >
122  INT_MAX - (pkt->size + AV_INPUT_BUFFER_PADDING_SIZE))
123  return AVERROR(ENOMEM);
124 
125  new_size = pkt->size + grow_by + AV_INPUT_BUFFER_PADDING_SIZE;
126  if (pkt->buf) {
127  size_t data_offset;
128  uint8_t *old_data = pkt->data;
129  if (pkt->data == NULL) {
130  data_offset = 0;
131  pkt->data = pkt->buf->data;
132  } else {
133  data_offset = pkt->data - pkt->buf->data;
134  if (data_offset > INT_MAX - new_size)
135  return AVERROR(ENOMEM);
136  }
137 
138  if (new_size + data_offset > pkt->buf->size ||
140  int ret = av_buffer_realloc(&pkt->buf, new_size + data_offset);
141  if (ret < 0) {
142  pkt->data = old_data;
143  return ret;
144  }
145  pkt->data = pkt->buf->data + data_offset;
146  }
147  } else {
148  pkt->buf = av_buffer_alloc(new_size);
149  if (!pkt->buf)
150  return AVERROR(ENOMEM);
151  if (pkt->size > 0)
152  memcpy(pkt->buf->data, pkt->data, pkt->size);
153  pkt->data = pkt->buf->data;
154  }
155  pkt->size += grow_by;
156  memset(pkt->data + pkt->size, 0, AV_INPUT_BUFFER_PADDING_SIZE);
157 
158  return 0;
159 }
160 
162 {
163  if (size >= INT_MAX - AV_INPUT_BUFFER_PADDING_SIZE)
164  return AVERROR(EINVAL);
165 
168  if (!pkt->buf)
169  return AVERROR(ENOMEM);
170 
171  pkt->data = data;
172  pkt->size = size;
173 
174  return 0;
175 }
176 
178 {
179  int i;
180  for (i = 0; i < pkt->side_data_elems; i++)
183  pkt->side_data_elems = 0;
184 }
185 
187  uint8_t *data, size_t size)
188 {
190  int i, elems = pkt->side_data_elems;
191 
192  for (i = 0; i < elems; i++) {
193  AVPacketSideData *sd = &pkt->side_data[i];
194 
195  if (sd->type == type) {
196  av_free(sd->data);
197  sd->data = data;
198  sd->size = size;
199  return 0;
200  }
201  }
202 
203  if ((unsigned)elems + 1 > AV_PKT_DATA_NB)
204  return AVERROR(ERANGE);
205 
206  tmp = av_realloc(pkt->side_data, (elems + 1) * sizeof(*tmp));
207  if (!tmp)
208  return AVERROR(ENOMEM);
209 
210  pkt->side_data = tmp;
211  pkt->side_data[elems].data = data;
212  pkt->side_data[elems].size = size;
213  pkt->side_data[elems].type = type;
214  pkt->side_data_elems++;
215 
216  return 0;
217 }
218 
219 
221  size_t size)
222 {
223  int ret;
224  uint8_t *data;
225 
226  if (size > SIZE_MAX - AV_INPUT_BUFFER_PADDING_SIZE)
227  return NULL;
229  if (!data)
230  return NULL;
231 
233  if (ret < 0) {
234  av_freep(&data);
235  return NULL;
236  }
237 
238  return data;
239 }
240 
242  size_t *size)
243 {
244  int i;
245 
246  for (i = 0; i < pkt->side_data_elems; i++) {
247  if (pkt->side_data[i].type == type) {
248  if (size)
249  *size = pkt->side_data[i].size;
250  return pkt->side_data[i].data;
251  }
252  }
253  if (size)
254  *size = 0;
255  return NULL;
256 }
257 
259 {
260  switch(type) {
261  case AV_PKT_DATA_PALETTE: return "Palette";
262  case AV_PKT_DATA_NEW_EXTRADATA: return "New Extradata";
263  case AV_PKT_DATA_PARAM_CHANGE: return "Param Change";
264  case AV_PKT_DATA_H263_MB_INFO: return "H263 MB Info";
265  case AV_PKT_DATA_REPLAYGAIN: return "Replay Gain";
266  case AV_PKT_DATA_DISPLAYMATRIX: return "Display Matrix";
267  case AV_PKT_DATA_STEREO3D: return "Stereo 3D";
268  case AV_PKT_DATA_AUDIO_SERVICE_TYPE: return "Audio Service Type";
269  case AV_PKT_DATA_QUALITY_STATS: return "Quality stats";
270  case AV_PKT_DATA_FALLBACK_TRACK: return "Fallback track";
271  case AV_PKT_DATA_CPB_PROPERTIES: return "CPB properties";
272  case AV_PKT_DATA_SKIP_SAMPLES: return "Skip Samples";
273  case AV_PKT_DATA_JP_DUALMONO: return "JP Dual Mono";
274  case AV_PKT_DATA_STRINGS_METADATA: return "Strings Metadata";
275  case AV_PKT_DATA_SUBTITLE_POSITION: return "Subtitle Position";
276  case AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL: return "Matroska BlockAdditional";
277  case AV_PKT_DATA_WEBVTT_IDENTIFIER: return "WebVTT ID";
278  case AV_PKT_DATA_WEBVTT_SETTINGS: return "WebVTT Settings";
279  case AV_PKT_DATA_METADATA_UPDATE: return "Metadata Update";
280  case AV_PKT_DATA_MPEGTS_STREAM_ID: return "MPEGTS Stream ID";
281  case AV_PKT_DATA_MASTERING_DISPLAY_METADATA: return "Mastering display metadata";
282  case AV_PKT_DATA_CONTENT_LIGHT_LEVEL: return "Content light level metadata";
283  case AV_PKT_DATA_SPHERICAL: return "Spherical Mapping";
284  case AV_PKT_DATA_A53_CC: return "A53 Closed Captions";
285  case AV_PKT_DATA_ENCRYPTION_INIT_INFO: return "Encryption initialization data";
286  case AV_PKT_DATA_ENCRYPTION_INFO: return "Encryption info";
287  case AV_PKT_DATA_AFD: return "Active Format Description data";
288  case AV_PKT_DATA_PRFT: return "Producer Reference Time";
289  case AV_PKT_DATA_ICC_PROFILE: return "ICC Profile";
290  case AV_PKT_DATA_DOVI_CONF: return "DOVI configuration record";
291  case AV_PKT_DATA_S12M_TIMECODE: return "SMPTE ST 12-1:2014 timecode";
292  }
293  return NULL;
294 }
295 
297 {
298  uint8_t *data = NULL;
299  *size = 0;
300 
301  if (!dict)
302  return NULL;
303 
304  for (int pass = 0; pass < 2; pass++) {
305  const AVDictionaryEntry *t = NULL;
306  size_t total_length = 0;
307 
308  while ((t = av_dict_get(dict, "", t, AV_DICT_IGNORE_SUFFIX))) {
309  for (int i = 0; i < 2; i++) {
310  const char *str = i ? t->value : t->key;
311  const size_t len = strlen(str) + 1;
312 
313  if (pass)
314  memcpy(data + total_length, str, len);
315  else if (len > SIZE_MAX - total_length)
316  return NULL;
317  total_length += len;
318  }
319  }
320  if (pass)
321  break;
322  data = av_malloc(total_length);
323  if (!data)
324  return NULL;
325  *size = total_length;
326  }
327 
328  return data;
329 }
330 
331 int av_packet_unpack_dictionary(const uint8_t *data, size_t size,
332  AVDictionary **dict)
333 {
334  const uint8_t *end;
335  int ret;
336 
337  if (!dict || !data || !size)
338  return 0;
339  end = data + size;
340  if (size && end[-1])
341  return AVERROR_INVALIDDATA;
342  while (data < end) {
343  const uint8_t *key = data;
344  const uint8_t *val = data + strlen(key) + 1;
345 
346  if (val >= end || !*key)
347  return AVERROR_INVALIDDATA;
348 
349  ret = av_dict_set(dict, key, val, 0);
350  if (ret < 0)
351  return ret;
352  data = val + strlen(val) + 1;
353  }
354 
355  return 0;
356 }
357 
359  size_t size)
360 {
361  int i;
362 
363  for (i = 0; i < pkt->side_data_elems; i++) {
364  if (pkt->side_data[i].type == type) {
365  if (size > pkt->side_data[i].size)
366  return AVERROR(ENOMEM);
367  pkt->side_data[i].size = size;
368  return 0;
369  }
370  }
371  return AVERROR(ENOENT);
372 }
373 
375 {
376  int i;
377 
378  dst->pts = src->pts;
379  dst->dts = src->dts;
380  dst->pos = src->pos;
381  dst->duration = src->duration;
382  dst->flags = src->flags;
383  dst->stream_index = src->stream_index;
384 
385  dst->side_data = NULL;
386  dst->side_data_elems = 0;
387  for (i = 0; i < src->side_data_elems; i++) {
388  enum AVPacketSideDataType type = src->side_data[i].type;
389  size_t size = src->side_data[i].size;
390  uint8_t *src_data = src->side_data[i].data;
391  uint8_t *dst_data = av_packet_new_side_data(dst, type, size);
392 
393  if (!dst_data) {
395  return AVERROR(ENOMEM);
396  }
397  memcpy(dst_data, src_data, size);
398  }
399 
400  return 0;
401 }
402 
404 {
408 }
409 
411 {
412  int ret;
413 
414  dst->buf = NULL;
415 
416  ret = av_packet_copy_props(dst, src);
417  if (ret < 0)
418  goto fail;
419 
420  if (!src->buf) {
421  ret = packet_alloc(&dst->buf, src->size);
422  if (ret < 0)
423  goto fail;
424  av_assert1(!src->size || src->data);
425  if (src->size)
426  memcpy(dst->buf->data, src->data, src->size);
427 
428  dst->data = dst->buf->data;
429  } else {
430  dst->buf = av_buffer_ref(src->buf);
431  if (!dst->buf) {
432  ret = AVERROR(ENOMEM);
433  goto fail;
434  }
435  dst->data = src->data;
436  }
437 
438  dst->size = src->size;
439 
440  return 0;
441 fail:
442  av_packet_unref(dst);
443  return ret;
444 }
445 
447 {
449 
450  if (!ret)
451  return ret;
452 
453  if (av_packet_ref(ret, src))
455 
456  return ret;
457 }
458 
460 {
461  *dst = *src;
463 }
464 
466 {
467  int ret;
468 
469  if (pkt->buf)
470  return 0;
471 
472  ret = packet_alloc(&pkt->buf, pkt->size);
473  if (ret < 0)
474  return ret;
475  av_assert1(!pkt->size || pkt->data);
476  if (pkt->size)
477  memcpy(pkt->buf->data, pkt->data, pkt->size);
478 
479  pkt->data = pkt->buf->data;
480 
481  return 0;
482 }
483 
485 {
486  AVBufferRef *buf = NULL;
487  int ret;
488 
489  if (pkt->buf && av_buffer_is_writable(pkt->buf))
490  return 0;
491 
492  ret = packet_alloc(&buf, pkt->size);
493  if (ret < 0)
494  return ret;
495  av_assert1(!pkt->size || pkt->data);
496  if (pkt->size)
497  memcpy(buf->data, pkt->data, pkt->size);
498 
500  pkt->buf = buf;
501  pkt->data = buf->data;
502 
503  return 0;
504 }
505 
507 {
508  if (pkt->pts != AV_NOPTS_VALUE)
509  pkt->pts = av_rescale_q(pkt->pts, src_tb, dst_tb);
510  if (pkt->dts != AV_NOPTS_VALUE)
511  pkt->dts = av_rescale_q(pkt->dts, src_tb, dst_tb);
512  if (pkt->duration > 0)
513  pkt->duration = av_rescale_q(pkt->duration, src_tb, dst_tb);
514 }
515 
516 int avpriv_packet_list_put(PacketList **packet_buffer,
517  PacketList **plast_pktl,
518  AVPacket *pkt,
519  int (*copy)(AVPacket *dst, const AVPacket *src),
520  int flags)
521 {
522  PacketList *pktl = av_malloc(sizeof(PacketList));
523  int ret;
524 
525  if (!pktl)
526  return AVERROR(ENOMEM);
527 
528  if (copy) {
529  get_packet_defaults(&pktl->pkt);
530  ret = copy(&pktl->pkt, pkt);
531  if (ret < 0) {
532  av_free(pktl);
533  return ret;
534  }
535  } else {
537  if (ret < 0) {
538  av_free(pktl);
539  return ret;
540  }
541  av_packet_move_ref(&pktl->pkt, pkt);
542  }
543 
544  pktl->next = NULL;
545 
546  if (*packet_buffer)
547  (*plast_pktl)->next = pktl;
548  else
549  *packet_buffer = pktl;
550 
551  /* Add the packet in the buffered packet list. */
552  *plast_pktl = pktl;
553  return 0;
554 }
555 
557  PacketList **pkt_buffer_end,
558  AVPacket *pkt)
559 {
560  PacketList *pktl;
561  if (!*pkt_buffer)
562  return AVERROR(EAGAIN);
563  pktl = *pkt_buffer;
564  *pkt = pktl->pkt;
565  *pkt_buffer = pktl->next;
566  if (!pktl->next)
567  *pkt_buffer_end = NULL;
568  av_freep(&pktl);
569  return 0;
570 }
571 
572 void avpriv_packet_list_free(PacketList **pkt_buf, PacketList **pkt_buf_end)
573 {
574  PacketList *tmp = *pkt_buf;
575 
576  while (tmp) {
577  PacketList *pktl = tmp;
578  tmp = pktl->next;
579  av_packet_unref(&pktl->pkt);
580  av_freep(&pktl);
581  }
582  *pkt_buf = NULL;
583  *pkt_buf_end = NULL;
584 }
585 
586 int ff_side_data_set_encoder_stats(AVPacket *pkt, int quality, int64_t *error, int error_count, int pict_type)
587 {
588  uint8_t *side_data;
589  size_t side_data_size;
590  int i;
591 
592  side_data = av_packet_get_side_data(pkt, AV_PKT_DATA_QUALITY_STATS, &side_data_size);
593  if (!side_data) {
594  side_data_size = 4+4+8*error_count;
596  side_data_size);
597  }
598 
599  if (!side_data || side_data_size < 4+4+8*error_count)
600  return AVERROR(ENOMEM);
601 
602  AV_WL32(side_data , quality );
603  side_data[4] = pict_type;
604  side_data[5] = error_count;
605  for (i = 0; i<error_count; i++)
606  AV_WL64(side_data+8 + 8*i , error[i]);
607 
608  return 0;
609 }
610 
611 int ff_side_data_set_prft(AVPacket *pkt, int64_t timestamp)
612 {
614  uint8_t *side_data;
615  size_t side_data_size;
616 
617  side_data = av_packet_get_side_data(pkt, AV_PKT_DATA_PRFT, &side_data_size);
618  if (!side_data) {
619  side_data_size = sizeof(AVProducerReferenceTime);
620  side_data = av_packet_new_side_data(pkt, AV_PKT_DATA_PRFT, side_data_size);
621  }
622 
623  if (!side_data || side_data_size < sizeof(AVProducerReferenceTime))
624  return AVERROR(ENOMEM);
625 
626  prft = (AVProducerReferenceTime *)side_data;
627  prft->wallclock = timestamp;
628  prft->flags = 0;
629 
630  return 0;
631 }
error
static void error(const char *err)
Definition: target_bsf_fuzzer.c:30
av_packet_unref
void av_packet_unref(AVPacket *pkt)
Wipe the packet.
Definition: avpacket.c:403
AVERROR
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
AV_PKT_DATA_NB
@ AV_PKT_DATA_NB
The number of side data types.
Definition: packet.h:301
AV_WL32
#define AV_WL32(p, v)
Definition: intreadwrite.h:426
AV_PKT_DATA_MPEGTS_STREAM_ID
@ AV_PKT_DATA_MPEGTS_STREAM_ID
MPEGTS stream ID as uint8_t, this is required to pass the stream ID information from the demuxer to t...
Definition: packet.h:215
AV_PKT_DATA_PARAM_CHANGE
@ AV_PKT_DATA_PARAM_CHANGE
An AV_PKT_DATA_PARAM_CHANGE side data packet is laid out as follows:
Definition: packet.h:72
ff_side_data_set_encoder_stats
int ff_side_data_set_encoder_stats(AVPacket *pkt, int quality, int64_t *error, int error_count, int pict_type)
Definition: avpacket.c:586
AVBufferRef::data
uint8_t * data
The data buffer.
Definition: buffer.h:92
av_grow_packet
int av_grow_packet(AVPacket *pkt, int grow_by)
Increase packet size, correctly zeroing padding.
Definition: avpacket.c:117
AV_PKT_DATA_ENCRYPTION_INFO
@ AV_PKT_DATA_ENCRYPTION_INFO
This side data contains encryption info for how to decrypt the packet.
Definition: packet.h:255
tmp
static uint8_t tmp[11]
Definition: aes_ctr.c:27
AVPacketSideData
Definition: packet.h:306
AVProducerReferenceTime::wallclock
int64_t wallclock
A UTC timestamp, in microseconds, since Unix epoch (e.g, av_gettime()).
Definition: avcodec.h:472
internal.h
AVPacket::data
uint8_t * data
Definition: packet.h:365
av_packet_shrink_side_data
int av_packet_shrink_side_data(AVPacket *pkt, enum AVPacketSideDataType type, size_t size)
Shrink the already allocated side data buffer.
Definition: avpacket.c:358
AV_PKT_DATA_PALETTE
@ AV_PKT_DATA_PALETTE
An AV_PKT_DATA_PALETTE side data packet contains exactly AVPALETTE_SIZE bytes worth of palette.
Definition: packet.h:46
PacketList
Definition: packet_internal.h:26
data
const char data[16]
Definition: mxf.c:142
AV_PKT_DATA_ENCRYPTION_INIT_INFO
@ AV_PKT_DATA_ENCRYPTION_INIT_INFO
This side data is encryption initialization data.
Definition: packet.h:249
AV_DICT_IGNORE_SUFFIX
#define AV_DICT_IGNORE_SUFFIX
Return first entry in a dictionary whose first part corresponds to the search key,...
Definition: dict.h:70
AV_PKT_DATA_AFD
@ AV_PKT_DATA_AFD
Active Format Description data consisting of a single byte as specified in ETSI TS 101 154 using AVAc...
Definition: packet.h:261
AVPacket::duration
int64_t duration
Duration of this packet in AVStream->time_base units, 0 if unknown.
Definition: packet.h:383
mathematics.h
AVDictionary
Definition: dict.c:30
AV_PKT_DATA_SPHERICAL
@ AV_PKT_DATA_SPHERICAL
This side data should be associated with a video stream and corresponds to the AVSphericalMapping str...
Definition: packet.h:228
av_packet_free_side_data
void av_packet_free_side_data(AVPacket *pkt)
Convenience function to free all the side data stored.
Definition: avpacket.c:177
packet_alloc
static int packet_alloc(AVBufferRef **buf, int size)
Definition: avpacket.c:79
av_packet_free
void av_packet_free(AVPacket **pkt)
Free the packet, if the packet is reference counted, it will be unreferenced first.
Definition: avpacket.c:70
quality
trying all byte sequences megabyte in length and selecting the best looking sequence will yield cases to try But a word about quality
Definition: rate_distortion.txt:12
av_malloc
#define av_malloc(s)
Definition: tableprint_vlc.h:31
AVPacketSideData::size
size_t size
Definition: packet.h:308
av_packet_add_side_data
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:186
fail
#define fail()
Definition: checkasm.h:134
av_shrink_packet
void av_shrink_packet(AVPacket *pkt, int size)
Reduce packet size, correctly zeroing padding.
Definition: avpacket.c:109
ff_side_data_set_prft
int ff_side_data_set_prft(AVPacket *pkt, int64_t timestamp)
Definition: avpacket.c:611
val
static double val(void *priv, double ch)
Definition: aeval.c:76
type
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf type
Definition: writing_filters.txt:86
AV_PKT_DATA_DISPLAYMATRIX
@ AV_PKT_DATA_DISPLAYMATRIX
This side data contains a 3x3 transformation matrix describing an affine transformation that needs to...
Definition: packet.h:108
AV_PKT_DATA_STRINGS_METADATA
@ AV_PKT_DATA_STRINGS_METADATA
A list of zero terminated key/value strings.
Definition: packet.h:172
AV_PKT_DATA_REPLAYGAIN
@ AV_PKT_DATA_REPLAYGAIN
This side data should be associated with an audio stream and contains ReplayGain information in form ...
Definition: packet.h:99
av_packet_side_data_name
const char * av_packet_side_data_name(enum AVPacketSideDataType type)
Definition: avpacket.c:258
av_init_packet
void av_init_packet(AVPacket *pkt)
Definition: avpacket.c:36
avassert.h
AV_PKT_DATA_WEBVTT_SETTINGS
@ AV_PKT_DATA_WEBVTT_SETTINGS
The optional settings (rendering instructions) that immediately follow the timestamp specifier of a W...
Definition: packet.h:202
pkt
AVPacket * pkt
Definition: movenc.c:59
AV_PKT_DATA_AUDIO_SERVICE_TYPE
@ AV_PKT_DATA_AUDIO_SERVICE_TYPE
This side data should be associated with an audio stream and corresponds to enum AVAudioServiceType.
Definition: packet.h:120
av_dict_get
AVDictionaryEntry * av_dict_get(const AVDictionary *m, const char *key, const AVDictionaryEntry *prev, int flags)
Get a dictionary entry with matching key.
Definition: dict.c:40
av_new_packet
int av_new_packet(AVPacket *pkt, int size)
Allocate the payload of a packet and initialize its fields with default values.
Definition: avpacket.c:94
AV_PKT_DATA_STEREO3D
@ AV_PKT_DATA_STEREO3D
This side data should be associated with a video stream and contains Stereoscopic 3D information in f...
Definition: packet.h:114
AV_PKT_DATA_MASTERING_DISPLAY_METADATA
@ AV_PKT_DATA_MASTERING_DISPLAY_METADATA
Mastering display metadata (based on SMPTE-2086:2014).
Definition: packet.h:222
AVDictionaryEntry::key
char * key
Definition: dict.h:82
av_buffer_default_free
void av_buffer_default_free(void *opaque, uint8_t *data)
Default free callback, which calls av_free() on the buffer data.
Definition: buffer.c:62
av_assert0
#define av_assert0(cond)
assert() equivalent, that is always enabled.
Definition: avassert.h:37
AV_PKT_DATA_ICC_PROFILE
@ AV_PKT_DATA_ICC_PROFILE
ICC profile data consisting of an opaque octet buffer following the format described by ISO 15076-1.
Definition: packet.h:274
AVPacketSideData::data
uint8_t * data
Definition: packet.h:307
av_rescale_q
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
Definition: mathematics.c:142
key
const char * key
Definition: hwcontext_opencl.c:168
AV_PKT_DATA_PRFT
@ AV_PKT_DATA_PRFT
Producer Reference Time data corresponding to the AVProducerReferenceTime struct, usually exported by...
Definition: packet.h:268
pass
#define pass
Definition: fft_template.c:603
AVPacket::buf
AVBufferRef * buf
A reference to the reference-counted buffer where the packet data is stored.
Definition: packet.h:348
NULL
#define NULL
Definition: coverity.c:32
av_buffer_unref
void av_buffer_unref(AVBufferRef **buf)
Free a given reference and automatically free the buffer if there are no more references to it.
Definition: buffer.c:125
AVRational
Rational number (pair of numerator and denominator).
Definition: rational.h:58
AVPacketSideData::type
enum AVPacketSideDataType type
Definition: packet.h:309
src
#define src
Definition: vp8dsp.c:255
PacketList::next
struct PacketList * next
Definition: packet_internal.h:27
AV_PKT_DATA_SUBTITLE_POSITION
@ AV_PKT_DATA_SUBTITLE_POSITION
Subtitle event position.
Definition: packet.h:183
AVProducerReferenceTime
This structure supplies correlation between a packet timestamp and a wall clock production time.
Definition: avcodec.h:468
av_packet_ref
int av_packet_ref(AVPacket *dst, const AVPacket *src)
Setup a new reference to the data described by a given packet.
Definition: avpacket.c:410
av_packet_move_ref
void av_packet_move_ref(AVPacket *dst, AVPacket *src)
Move every field in src to dst and reset src.
Definition: avpacket.c:459
AVProducerReferenceTime::flags
int flags
Definition: avcodec.h:473
av_buffer_create
AVBufferRef * av_buffer_create(uint8_t *data, size_t size, void(*free)(void *opaque, uint8_t *data), void *opaque, int flags)
Create an AVBuffer from an existing array.
Definition: buffer.c:29
av_packet_from_data
int av_packet_from_data(AVPacket *pkt, uint8_t *data, int size)
Initialize a reference-counted packet from av_malloc()ed data.
Definition: avpacket.c:161
AVPacket::size
int size
Definition: packet.h:366
copy
static void copy(const float *p1, float *p2, const int length)
Definition: vf_vaguedenoiser.c:194
get_packet_defaults
static void get_packet_defaults(AVPacket *pkt)
Definition: avpacket.c:50
size
int size
Definition: twinvq_data.h:10344
AV_NOPTS_VALUE
#define AV_NOPTS_VALUE
Undefined timestamp value.
Definition: avutil.h:248
AV_PKT_DATA_H263_MB_INFO
@ AV_PKT_DATA_H263_MB_INFO
An AV_PKT_DATA_H263_MB_INFO side data packet contains a number of structures with info about macroblo...
Definition: packet.h:93
av_packet_unpack_dictionary
int av_packet_unpack_dictionary(const uint8_t *data, size_t size, AVDictionary **dict)
Unpack a dictionary from side_data.
Definition: avpacket.c:331
AVPacket::dts
int64_t dts
Decompression timestamp in AVStream->time_base units; the time at which the packet is decompressed.
Definition: packet.h:364
AV_WL64
#define AV_WL64(p, v)
Definition: intreadwrite.h:440
AVPacketSideDataType
AVPacketSideDataType
Definition: packet.h:40
av_packet_pack_dictionary
uint8_t * av_packet_pack_dictionary(AVDictionary *dict, size_t *size)
Pack a dictionary for use in side_data.
Definition: avpacket.c:296
AV_PKT_DATA_CONTENT_LIGHT_LEVEL
@ AV_PKT_DATA_CONTENT_LIGHT_LEVEL
Content light level (based on CTA-861.3).
Definition: packet.h:235
av_packet_make_refcounted
int av_packet_make_refcounted(AVPacket *pkt)
Ensure the data described by a given packet is reference counted.
Definition: avpacket.c:465
AVPacket::flags
int flags
A combination of AV_PKT_FLAG values.
Definition: packet.h:371
av_packet_alloc
AVPacket * av_packet_alloc(void)
Allocate an AVPacket and set its fields to default values.
Definition: avpacket.c:59
av_buffer_alloc
AVBufferRef * av_buffer_alloc(size_t size)
Allocate an AVBuffer of the given size using av_malloc().
Definition: buffer.c:67
av_packet_rescale_ts
void av_packet_rescale_ts(AVPacket *pkt, AVRational src_tb, AVRational dst_tb)
Convert valid timing fields (timestamps / durations) in a packet from one timebase to another.
Definition: avpacket.c:506
PacketList::pkt
AVPacket pkt
Definition: packet_internal.h:28
AVBufferRef::size
size_t size
Size of data in bytes.
Definition: buffer.h:96
AV_PKT_DATA_METADATA_UPDATE
@ AV_PKT_DATA_METADATA_UPDATE
A list of zero terminated key/value strings.
Definition: packet.h:209
av_realloc
void * av_realloc(void *ptr, size_t size)
Allocate, reallocate, or free a block of memory.
Definition: mem.c:134
AV_PKT_DATA_JP_DUALMONO
@ AV_PKT_DATA_JP_DUALMONO
An AV_PKT_DATA_JP_DUALMONO side data packet indicates that the packet may contain "dual mono" audio s...
Definition: packet.h:166
av_packet_copy_props
int av_packet_copy_props(AVPacket *dst, const AVPacket *src)
Copy only "properties" fields from src to dst.
Definition: avpacket.c:374
i
int i
Definition: input.c:407
AVPacket::pts
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
Definition: packet.h:358
packet.h
av_packet_get_side_data
uint8_t * av_packet_get_side_data(const AVPacket *pkt, enum AVPacketSideDataType type, size_t *size)
Get side information from packet.
Definition: avpacket.c:241
internal.h
common.h
av_assert1
#define av_assert1(cond)
assert() equivalent, that does not lie in speed critical code.
Definition: avassert.h:53
AV_PKT_DATA_A53_CC
@ AV_PKT_DATA_A53_CC
ATSC A53 Part 4 Closed Captions.
Definition: packet.h:242
av_mallocz
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
Definition: mem.c:243
AV_PKT_DATA_CPB_PROPERTIES
@ AV_PKT_DATA_CPB_PROPERTIES
This side data corresponds to the AVCPBProperties struct.
Definition: packet.h:145
AV_PKT_DATA_SKIP_SAMPLES
@ AV_PKT_DATA_SKIP_SAMPLES
Recommmends skipping the specified number of samples.
Definition: packet.h:156
len
int len
Definition: vorbis_enc_data.h:452
av_buffer_is_writable
int av_buffer_is_writable(const AVBufferRef *buf)
Definition: buffer.c:133
ret
ret
Definition: filter_design.txt:187
AV_PKT_DATA_DOVI_CONF
@ AV_PKT_DATA_DOVI_CONF
DOVI configuration ref: dolby-vision-bitstreams-within-the-iso-base-media-file-format-v2....
Definition: packet.h:283
avpriv_packet_list_get
int avpriv_packet_list_get(PacketList **pkt_buffer, PacketList **pkt_buffer_end, AVPacket *pkt)
Remove the oldest AVPacket in the list and return it.
Definition: avpacket.c:556
AVPacket::side_data
AVPacketSideData * side_data
Additional packet data that can be provided by the container.
Definition: packet.h:376
AV_PKT_DATA_S12M_TIMECODE
@ AV_PKT_DATA_S12M_TIMECODE
Timecode which conforms to SMPTE ST 12-1:2014.
Definition: packet.h:291
AV_INPUT_BUFFER_PADDING_SIZE
#define AV_INPUT_BUFFER_PADDING_SIZE
Definition: avcodec.h:192
av_packet_new_side_data
uint8_t * av_packet_new_side_data(AVPacket *pkt, enum AVPacketSideDataType type, size_t size)
Allocate new information of a packet.
Definition: avpacket.c:220
AV_PKT_DATA_NEW_EXTRADATA
@ AV_PKT_DATA_NEW_EXTRADATA
The AV_PKT_DATA_NEW_EXTRADATA is used to notify the codec or the format that the extradata buffer was...
Definition: packet.h:55
av_packet_make_writable
int av_packet_make_writable(AVPacket *pkt)
Create a writable reference for the data described by a given packet, avoiding data copy if possible.
Definition: avpacket.c:484
AVPacket::stream_index
int stream_index
Definition: packet.h:367
av_buffer_ref
AVBufferRef * av_buffer_ref(AVBufferRef *buf)
Create a new reference to an AVBuffer.
Definition: buffer.c:93
av_buffer_realloc
int av_buffer_realloc(AVBufferRef **pbuf, size_t size)
Reallocate a given buffer.
Definition: buffer.c:169
mem.h
AVBufferRef
A reference to a data buffer.
Definition: buffer.h:84
packet_internal.h
AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL
@ AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL
Data found in BlockAdditional element of matroska container.
Definition: packet.h:191
av_free
#define av_free(p)
Definition: tableprint_vlc.h:34
AVDictionaryEntry
Definition: dict.h:81
AVPacket
This structure stores compressed data.
Definition: packet.h:342
av_freep
#define av_freep(p)
Definition: tableprint_vlc.h:35
av_dict_set
int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags)
Set the given entry in *pm, overwriting an existing entry.
Definition: dict.c:70
AVPacket::pos
int64_t pos
byte position in stream, -1 if unknown
Definition: packet.h:385
AV_PKT_DATA_FALLBACK_TRACK
@ AV_PKT_DATA_FALLBACK_TRACK
This side data contains an integer value representing the stream index of a "fallback" track.
Definition: packet.h:140
bytestream.h
convert_header.str
string str
Definition: convert_header.py:20
AV_PKT_DATA_QUALITY_STATS
@ AV_PKT_DATA_QUALITY_STATS
This side data contains quality related information from the encoder.
Definition: packet.h:132
flags
#define flags(name, subs,...)
Definition: cbs_av1.c:561
AVERROR_INVALIDDATA
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
Definition: error.h:59
AV_PKT_DATA_WEBVTT_IDENTIFIER
@ AV_PKT_DATA_WEBVTT_IDENTIFIER
The optional first identifier line of a WebVTT cue.
Definition: packet.h:196
AVDictionaryEntry::value
char * value
Definition: dict.h:83
avpriv_packet_list_put
int avpriv_packet_list_put(PacketList **packet_buffer, PacketList **plast_pktl, AVPacket *pkt, int(*copy)(AVPacket *dst, const AVPacket *src), int flags)
Append an AVPacket to the list.
Definition: avpacket.c:516
avpriv_packet_list_free
void avpriv_packet_list_free(PacketList **pkt_buf, PacketList **pkt_buf_end)
Wipe the list and unref all the packets in it.
Definition: avpacket.c:572
AVPacket::side_data_elems
int side_data_elems
Definition: packet.h:377
av_packet_clone
AVPacket * av_packet_clone(const AVPacket *src)
Create a new packet that references the same data as src.
Definition: avpacket.c:446