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 #include "libavutil/rational.h"
30 
31 #include "bytestream.h"
32 #include "internal.h"
33 #include "packet.h"
34 #include "packet_internal.h"
35 
36 #if FF_API_INIT_PACKET
38 {
41  pkt->pos = -1;
42  pkt->duration = 0;
43  pkt->flags = 0;
44  pkt->stream_index = 0;
45  pkt->buf = NULL;
46  pkt->side_data = NULL;
47  pkt->side_data_elems = 0;
48  pkt->opaque = NULL;
49  pkt->opaque_ref = NULL;
50  pkt->time_base = av_make_q(0, 1);
51 }
52 #endif
53 
55 {
56  memset(pkt, 0, sizeof(*pkt));
57 
60  pkt->pos = -1;
61  pkt->time_base = av_make_q(0, 1);
62 }
63 
65 {
66  AVPacket *pkt = av_malloc(sizeof(AVPacket));
67  if (!pkt)
68  return pkt;
69 
71 
72  return pkt;
73 }
74 
76 {
77  if (!pkt || !*pkt)
78  return;
79 
81  av_freep(pkt);
82 }
83 
84 static int packet_alloc(AVBufferRef **buf, int size)
85 {
86  int ret;
87  if (size < 0 || size >= INT_MAX - AV_INPUT_BUFFER_PADDING_SIZE)
88  return AVERROR(EINVAL);
89 
91  if (ret < 0)
92  return ret;
93 
94  memset((*buf)->data + size, 0, AV_INPUT_BUFFER_PADDING_SIZE);
95 
96  return 0;
97 }
98 
100 {
101  AVBufferRef *buf = NULL;
102  int ret = packet_alloc(&buf, size);
103  if (ret < 0)
104  return ret;
105 
107  pkt->buf = buf;
108  pkt->data = buf->data;
109  pkt->size = size;
110 
111  return 0;
112 }
113 
115 {
116  if (pkt->size <= size)
117  return;
118  pkt->size = size;
119  memset(pkt->data + size, 0, AV_INPUT_BUFFER_PADDING_SIZE);
120 }
121 
122 int av_grow_packet(AVPacket *pkt, int grow_by)
123 {
124  int new_size;
125  av_assert0((unsigned)pkt->size <= INT_MAX - AV_INPUT_BUFFER_PADDING_SIZE);
126  if ((unsigned)grow_by >
127  INT_MAX - (pkt->size + AV_INPUT_BUFFER_PADDING_SIZE))
128  return AVERROR(ENOMEM);
129 
130  new_size = pkt->size + grow_by + AV_INPUT_BUFFER_PADDING_SIZE;
131  if (pkt->buf) {
132  size_t data_offset;
133  uint8_t *old_data = pkt->data;
134  if (pkt->data == NULL) {
135  data_offset = 0;
136  pkt->data = pkt->buf->data;
137  } else {
138  data_offset = pkt->data - pkt->buf->data;
139  if (data_offset > INT_MAX - new_size)
140  return AVERROR(ENOMEM);
141  }
142 
143  if (new_size + data_offset > pkt->buf->size ||
145  int ret;
146 
147  // allocate slightly more than requested to avoid excessive
148  // reallocations
149  if (new_size + data_offset < INT_MAX - new_size/16)
150  new_size += new_size/16;
151 
152  ret = av_buffer_realloc(&pkt->buf, new_size + data_offset);
153  if (ret < 0) {
154  pkt->data = old_data;
155  return ret;
156  }
157  pkt->data = pkt->buf->data + data_offset;
158  }
159  } else {
160  pkt->buf = av_buffer_alloc(new_size);
161  if (!pkt->buf)
162  return AVERROR(ENOMEM);
163  if (pkt->size > 0)
164  memcpy(pkt->buf->data, pkt->data, pkt->size);
165  pkt->data = pkt->buf->data;
166  }
167  pkt->size += grow_by;
168  memset(pkt->data + pkt->size, 0, AV_INPUT_BUFFER_PADDING_SIZE);
169 
170  return 0;
171 }
172 
174 {
175  if (size >= INT_MAX - AV_INPUT_BUFFER_PADDING_SIZE)
176  return AVERROR(EINVAL);
177 
180  if (!pkt->buf)
181  return AVERROR(ENOMEM);
182 
183  pkt->data = data;
184  pkt->size = size;
185 
186  return 0;
187 }
188 
190 {
191  int i;
192  for (i = 0; i < pkt->side_data_elems; i++)
195  pkt->side_data_elems = 0;
196 }
197 
199  uint8_t *data, size_t size)
200 {
202  int i, elems = pkt->side_data_elems;
203 
204  for (i = 0; i < elems; i++) {
205  AVPacketSideData *sd = &pkt->side_data[i];
206 
207  if (sd->type == type) {
208  av_free(sd->data);
209  sd->data = data;
210  sd->size = size;
211  return 0;
212  }
213  }
214 
215  if ((unsigned)elems + 1 > AV_PKT_DATA_NB)
216  return AVERROR(ERANGE);
217 
218  tmp = av_realloc(pkt->side_data, (elems + 1) * sizeof(*tmp));
219  if (!tmp)
220  return AVERROR(ENOMEM);
221 
222  pkt->side_data = tmp;
223  pkt->side_data[elems].data = data;
224  pkt->side_data[elems].size = size;
225  pkt->side_data[elems].type = type;
226  pkt->side_data_elems++;
227 
228  return 0;
229 }
230 
231 
233  size_t size)
234 {
235  int ret;
236  uint8_t *data;
237 
238  if (size > SIZE_MAX - AV_INPUT_BUFFER_PADDING_SIZE)
239  return NULL;
241  if (!data)
242  return NULL;
243 
245  if (ret < 0) {
246  av_freep(&data);
247  return NULL;
248  }
249 
250  return data;
251 }
252 
254  size_t *size)
255 {
256  int i;
257 
258  for (i = 0; i < pkt->side_data_elems; i++) {
259  if (pkt->side_data[i].type == type) {
260  if (size)
261  *size = pkt->side_data[i].size;
262  return pkt->side_data[i].data;
263  }
264  }
265  if (size)
266  *size = 0;
267  return NULL;
268 }
269 
271 {
272  switch(type) {
273  case AV_PKT_DATA_PALETTE: return "Palette";
274  case AV_PKT_DATA_NEW_EXTRADATA: return "New Extradata";
275  case AV_PKT_DATA_PARAM_CHANGE: return "Param Change";
276  case AV_PKT_DATA_H263_MB_INFO: return "H263 MB Info";
277  case AV_PKT_DATA_REPLAYGAIN: return "Replay Gain";
278  case AV_PKT_DATA_DISPLAYMATRIX: return "Display Matrix";
279  case AV_PKT_DATA_STEREO3D: return "Stereo 3D";
280  case AV_PKT_DATA_AUDIO_SERVICE_TYPE: return "Audio Service Type";
281  case AV_PKT_DATA_QUALITY_STATS: return "Quality stats";
282  case AV_PKT_DATA_FALLBACK_TRACK: return "Fallback track";
283  case AV_PKT_DATA_CPB_PROPERTIES: return "CPB properties";
284  case AV_PKT_DATA_SKIP_SAMPLES: return "Skip Samples";
285  case AV_PKT_DATA_JP_DUALMONO: return "JP Dual Mono";
286  case AV_PKT_DATA_STRINGS_METADATA: return "Strings Metadata";
287  case AV_PKT_DATA_SUBTITLE_POSITION: return "Subtitle Position";
288  case AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL: return "Matroska BlockAdditional";
289  case AV_PKT_DATA_WEBVTT_IDENTIFIER: return "WebVTT ID";
290  case AV_PKT_DATA_WEBVTT_SETTINGS: return "WebVTT Settings";
291  case AV_PKT_DATA_METADATA_UPDATE: return "Metadata Update";
292  case AV_PKT_DATA_MPEGTS_STREAM_ID: return "MPEGTS Stream ID";
293  case AV_PKT_DATA_MASTERING_DISPLAY_METADATA: return "Mastering display metadata";
294  case AV_PKT_DATA_CONTENT_LIGHT_LEVEL: return "Content light level metadata";
295  case AV_PKT_DATA_SPHERICAL: return "Spherical Mapping";
296  case AV_PKT_DATA_A53_CC: return "A53 Closed Captions";
297  case AV_PKT_DATA_ENCRYPTION_INIT_INFO: return "Encryption initialization data";
298  case AV_PKT_DATA_ENCRYPTION_INFO: return "Encryption info";
299  case AV_PKT_DATA_AFD: return "Active Format Description data";
300  case AV_PKT_DATA_PRFT: return "Producer Reference Time";
301  case AV_PKT_DATA_ICC_PROFILE: return "ICC Profile";
302  case AV_PKT_DATA_DOVI_CONF: return "DOVI configuration record";
303  case AV_PKT_DATA_S12M_TIMECODE: return "SMPTE ST 12-1:2014 timecode";
304  case AV_PKT_DATA_DYNAMIC_HDR10_PLUS: return "HDR10+ Dynamic Metadata (SMPTE 2094-40)";
305  }
306  return NULL;
307 }
308 
310 {
311  uint8_t *data = NULL;
312  *size = 0;
313 
314  if (!dict)
315  return NULL;
316 
317  for (int pass = 0; pass < 2; pass++) {
318  const AVDictionaryEntry *t = NULL;
319  size_t total_length = 0;
320 
321  while ((t = av_dict_get(dict, "", t, AV_DICT_IGNORE_SUFFIX))) {
322  for (int i = 0; i < 2; i++) {
323  const char *str = i ? t->value : t->key;
324  const size_t len = strlen(str) + 1;
325 
326  if (pass)
327  memcpy(data + total_length, str, len);
328  else if (len > SIZE_MAX - total_length)
329  return NULL;
330  total_length += len;
331  }
332  }
333  if (pass)
334  break;
335  data = av_malloc(total_length);
336  if (!data)
337  return NULL;
338  *size = total_length;
339  }
340 
341  return data;
342 }
343 
344 int av_packet_unpack_dictionary(const uint8_t *data, size_t size,
345  AVDictionary **dict)
346 {
347  const uint8_t *end;
348  int ret;
349 
350  if (!dict || !data || !size)
351  return 0;
352  end = data + size;
353  if (size && end[-1])
354  return AVERROR_INVALIDDATA;
355  while (data < end) {
356  const uint8_t *key = data;
357  const uint8_t *val = data + strlen(key) + 1;
358 
359  if (val >= end || !*key)
360  return AVERROR_INVALIDDATA;
361 
362  ret = av_dict_set(dict, key, val, 0);
363  if (ret < 0)
364  return ret;
365  data = val + strlen(val) + 1;
366  }
367 
368  return 0;
369 }
370 
372  size_t size)
373 {
374  int i;
375 
376  for (i = 0; i < pkt->side_data_elems; i++) {
377  if (pkt->side_data[i].type == type) {
378  if (size > pkt->side_data[i].size)
379  return AVERROR(ENOMEM);
380  pkt->side_data[i].size = size;
381  return 0;
382  }
383  }
384  return AVERROR(ENOENT);
385 }
386 
388 {
389  int i, ret;
390 
391  dst->pts = src->pts;
392  dst->dts = src->dts;
393  dst->pos = src->pos;
394  dst->duration = src->duration;
395  dst->flags = src->flags;
396  dst->stream_index = src->stream_index;
397  dst->opaque = src->opaque;
398  dst->time_base = src->time_base;
399  dst->opaque_ref = NULL;
400  dst->side_data = NULL;
401  dst->side_data_elems = 0;
402 
403  ret = av_buffer_replace(&dst->opaque_ref, src->opaque_ref);
404  if (ret < 0)
405  return ret;
406 
407  for (i = 0; i < src->side_data_elems; i++) {
408  enum AVPacketSideDataType type = src->side_data[i].type;
409  size_t size = src->side_data[i].size;
410  uint8_t *src_data = src->side_data[i].data;
411  uint8_t *dst_data = av_packet_new_side_data(dst, type, size);
412 
413  if (!dst_data) {
416  return AVERROR(ENOMEM);
417  }
418  memcpy(dst_data, src_data, size);
419  }
420 
421  return 0;
422 }
423 
425 {
430 }
431 
433 {
434  int ret;
435 
436  dst->buf = NULL;
437 
438  ret = av_packet_copy_props(dst, src);
439  if (ret < 0)
440  goto fail;
441 
442  if (!src->buf) {
443  ret = packet_alloc(&dst->buf, src->size);
444  if (ret < 0)
445  goto fail;
446  av_assert1(!src->size || src->data);
447  if (src->size)
448  memcpy(dst->buf->data, src->data, src->size);
449 
450  dst->data = dst->buf->data;
451  } else {
452  dst->buf = av_buffer_ref(src->buf);
453  if (!dst->buf) {
454  ret = AVERROR(ENOMEM);
455  goto fail;
456  }
457  dst->data = src->data;
458  }
459 
460  dst->size = src->size;
461 
462  return 0;
463 fail:
464  av_packet_unref(dst);
465  return ret;
466 }
467 
469 {
471 
472  if (!ret)
473  return ret;
474 
475  if (av_packet_ref(ret, src))
477 
478  return ret;
479 }
480 
482 {
483  *dst = *src;
485 }
486 
488 {
489  int ret;
490 
491  if (pkt->buf)
492  return 0;
493 
494  ret = packet_alloc(&pkt->buf, pkt->size);
495  if (ret < 0)
496  return ret;
497  av_assert1(!pkt->size || pkt->data);
498  if (pkt->size)
499  memcpy(pkt->buf->data, pkt->data, pkt->size);
500 
501  pkt->data = pkt->buf->data;
502 
503  return 0;
504 }
505 
507 {
508  AVBufferRef *buf = NULL;
509  int ret;
510 
511  if (pkt->buf && av_buffer_is_writable(pkt->buf))
512  return 0;
513 
514  ret = packet_alloc(&buf, pkt->size);
515  if (ret < 0)
516  return ret;
517  av_assert1(!pkt->size || pkt->data);
518  if (pkt->size)
519  memcpy(buf->data, pkt->data, pkt->size);
520 
522  pkt->buf = buf;
523  pkt->data = buf->data;
524 
525  return 0;
526 }
527 
529 {
530  if (pkt->pts != AV_NOPTS_VALUE)
531  pkt->pts = av_rescale_q(pkt->pts, src_tb, dst_tb);
532  if (pkt->dts != AV_NOPTS_VALUE)
533  pkt->dts = av_rescale_q(pkt->dts, src_tb, dst_tb);
534  if (pkt->duration > 0)
535  pkt->duration = av_rescale_q(pkt->duration, src_tb, dst_tb);
536 }
537 
539  AVPacket *pkt,
540  int (*copy)(AVPacket *dst, const AVPacket *src),
541  int flags)
542 {
543  PacketListEntry *pktl = av_malloc(sizeof(*pktl));
544  int ret;
545 
546  if (!pktl)
547  return AVERROR(ENOMEM);
548 
549  if (copy) {
550  get_packet_defaults(&pktl->pkt);
551  ret = copy(&pktl->pkt, pkt);
552  if (ret < 0) {
553  av_free(pktl);
554  return ret;
555  }
556  } else {
558  if (ret < 0) {
559  av_free(pktl);
560  return ret;
561  }
562  av_packet_move_ref(&pktl->pkt, pkt);
563  }
564 
565  pktl->next = NULL;
566 
567  if (packet_buffer->head)
568  packet_buffer->tail->next = pktl;
569  else
570  packet_buffer->head = pktl;
571 
572  /* Add the packet in the buffered packet list. */
573  packet_buffer->tail = pktl;
574  return 0;
575 }
576 
578  AVPacket *pkt)
579 {
580  PacketListEntry *pktl = pkt_buffer->head;
581  if (!pktl)
582  return AVERROR(EAGAIN);
583  *pkt = pktl->pkt;
584  pkt_buffer->head = pktl->next;
585  if (!pkt_buffer->head)
586  pkt_buffer->tail = NULL;
587  av_freep(&pktl);
588  return 0;
589 }
590 
592 {
593  PacketListEntry *tmp = pkt_buf->head;
594 
595  while (tmp) {
596  PacketListEntry *pktl = tmp;
597  tmp = pktl->next;
598  av_packet_unref(&pktl->pkt);
599  av_freep(&pktl);
600  }
601  pkt_buf->head = pkt_buf->tail = NULL;
602 }
603 
604 int ff_side_data_set_encoder_stats(AVPacket *pkt, int quality, int64_t *error, int error_count, int pict_type)
605 {
606  uint8_t *side_data;
607  size_t side_data_size;
608  int i;
609 
610  side_data = av_packet_get_side_data(pkt, AV_PKT_DATA_QUALITY_STATS, &side_data_size);
611  if (!side_data) {
612  side_data_size = 4+4+8*error_count;
614  side_data_size);
615  }
616 
617  if (!side_data || side_data_size < 4+4+8*error_count)
618  return AVERROR(ENOMEM);
619 
620  AV_WL32(side_data , quality );
621  side_data[4] = pict_type;
622  side_data[5] = error_count;
623  for (i = 0; i<error_count; i++)
624  AV_WL64(side_data+8 + 8*i , error[i]);
625 
626  return 0;
627 }
628 
629 int ff_side_data_set_prft(AVPacket *pkt, int64_t timestamp)
630 {
632  uint8_t *side_data;
633  size_t side_data_size;
634 
635  side_data = av_packet_get_side_data(pkt, AV_PKT_DATA_PRFT, &side_data_size);
636  if (!side_data) {
637  side_data_size = sizeof(AVProducerReferenceTime);
638  side_data = av_packet_new_side_data(pkt, AV_PKT_DATA_PRFT, side_data_size);
639  }
640 
641  if (!side_data || side_data_size < sizeof(AVProducerReferenceTime))
642  return AVERROR(ENOMEM);
643 
644  prft = (AVProducerReferenceTime *)side_data;
645  prft->wallclock = timestamp;
646  prft->flags = 0;
647 
648  return 0;
649 }
error
static void error(const char *err)
Definition: target_bsf_fuzzer.c:31
av_packet_unref
void av_packet_unref(AVPacket *pkt)
Wipe the packet.
Definition: avpacket.c:424
avpriv_packet_list_put
int avpriv_packet_list_put(PacketList *packet_buffer, AVPacket *pkt, int(*copy)(AVPacket *dst, const AVPacket *src), int flags)
Append an AVPacket to the list.
Definition: avpacket.c:538
PacketList::head
PacketListEntry * head
Definition: packet_internal.h:32
avpriv_packet_list_get
int avpriv_packet_list_get(PacketList *pkt_buffer, AVPacket *pkt)
Remove the oldest AVPacket in the list and return it.
Definition: avpacket.c:577
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:309
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:604
AVBufferRef::data
uint8_t * data
The data buffer.
Definition: buffer.h:90
rational.h
av_grow_packet
int av_grow_packet(AVPacket *pkt, int grow_by)
Increase packet size, correctly zeroing padding.
Definition: avpacket.c:122
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:26
AVPacketSideData
Definition: packet.h:314
AVProducerReferenceTime::wallclock
int64_t wallclock
A UTC timestamp, in microseconds, since Unix epoch (e.g, av_gettime()).
Definition: defs.h:157
internal.h
AVPacket::data
uint8_t * data
Definition: packet.h:373
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:371
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:31
data
const char data[16]
Definition: mxf.c:143
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:68
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:391
mathematics.h
AVDictionary
Definition: dict.c:30
av_buffer_ref
AVBufferRef * av_buffer_ref(const AVBufferRef *buf)
Create a new reference to an AVBuffer.
Definition: buffer.c:103
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:189
packet_alloc
static int packet_alloc(AVBufferRef **buf, int size)
Definition: avpacket.c:84
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:75
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:316
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:198
AVPacket::opaque_ref
AVBufferRef * opaque_ref
AVBufferRef for free use by the API user.
Definition: packet.h:409
fail
#define fail()
Definition: checkasm.h:127
av_shrink_packet
void av_shrink_packet(AVPacket *pkt, int size)
Reduce packet size, correctly zeroing padding.
Definition: avpacket.c:114
ff_side_data_set_prft
int ff_side_data_set_prft(AVPacket *pkt, int64_t timestamp)
Definition: avpacket.c:629
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:270
av_init_packet
void av_init_packet(AVPacket *pkt)
Definition: avpacket.c:37
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:99
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:80
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:72
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:315
AV_PKT_DATA_DYNAMIC_HDR10_PLUS
@ AV_PKT_DATA_DYNAMIC_HDR10_PLUS
HDR10+ dynamic metadata associated with a video frame.
Definition: packet.h:299
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:141
key
const char * key
Definition: hwcontext_opencl.c:168
AVPacket::opaque
void * opaque
for some private data of the user
Definition: packet.h:398
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:601
PacketList::tail
PacketListEntry * tail
Definition: packet_internal.h:32
AVPacket::buf
AVBufferRef * buf
A reference to the reference-counted buffer where the packet data is stored.
Definition: packet.h:356
NULL
#define NULL
Definition: coverity.c:32
av_realloc
void * av_realloc(void *ptr, size_t size)
Allocate, reallocate, or free a block of memory.
Definition: mem.c:152
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:139
AVRational
Rational number (pair of numerator and denominator).
Definition: rational.h:58
AVPacketSideData::type
enum AVPacketSideDataType type
Definition: packet.h:317
src
#define src
Definition: vp8dsp.c:255
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: defs.h:153
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:432
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:481
PacketListEntry::next
struct PacketListEntry * next
Definition: packet_internal.h:27
AVProducerReferenceTime::flags
int flags
Definition: defs.h:158
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:55
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:173
AVPacket::size
int size
Definition: packet.h:374
copy
static void copy(const float *p1, float *p2, const int length)
Definition: vf_vaguedenoiser.c:187
get_packet_defaults
static void get_packet_defaults(AVPacket *pkt)
Definition: avpacket.c:54
avpriv_packet_list_free
void avpriv_packet_list_free(PacketList *pkt_buf)
Wipe the list and unref all the packets in it.
Definition: avpacket.c:591
size
int size
Definition: twinvq_data.h:10344
av_make_q
static AVRational av_make_q(int num, int den)
Create an AVRational.
Definition: rational.h:71
AV_NOPTS_VALUE
#define AV_NOPTS_VALUE
Undefined timestamp value.
Definition: avutil.h:248
PacketListEntry::pkt
AVPacket pkt
Definition: packet_internal.h:28
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:344
AVPacket::dts
int64_t dts
Decompression timestamp in AVStream->time_base units; the time at which the packet is decompressed.
Definition: packet.h:372
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:309
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:487
AVPacket::flags
int flags
A combination of AV_PKT_FLAG values.
Definition: packet.h:379
av_packet_alloc
AVPacket * av_packet_alloc(void)
Allocate an AVPacket and set its fields to default values.
Definition: avpacket.c:64
av_buffer_alloc
AVBufferRef * av_buffer_alloc(size_t size)
Allocate an AVBuffer of the given size using av_malloc().
Definition: buffer.c:77
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:528
AVBufferRef::size
size_t size
Size of data in bytes.
Definition: buffer.h:94
AV_PKT_DATA_METADATA_UPDATE
@ AV_PKT_DATA_METADATA_UPDATE
A list of zero terminated key/value strings.
Definition: packet.h:209
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:387
PacketListEntry
Definition: packet_internal.h:26
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:271
AVPacket::pts
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
Definition: packet.h:366
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:253
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:263
AV_PKT_DATA_CPB_PROPERTIES
@ AV_PKT_DATA_CPB_PROPERTIES
This side data corresponds to the AVCPBProperties struct.
Definition: packet.h:145
av_buffer_replace
int av_buffer_replace(AVBufferRef **pdst, const AVBufferRef *src)
Ensure dst refers to the same data as src.
Definition: buffer.c:233
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:426
av_buffer_is_writable
int av_buffer_is_writable(const AVBufferRef *buf)
Definition: buffer.c:147
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
AVPacket::side_data
AVPacketSideData * side_data
Additional packet data that can be provided by the container.
Definition: packet.h:384
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: defs.h:40
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:232
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:506
AVPacket::stream_index
int stream_index
Definition: packet.h:375
av_buffer_realloc
int av_buffer_realloc(AVBufferRef **pbuf, size_t size)
Reallocate a given buffer.
Definition: buffer.c:183
mem.h
AVBufferRef
A reference to a data buffer.
Definition: buffer.h:82
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:79
AVPacket
This structure stores compressed data.
Definition: packet.h:350
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:393
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:61
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:81
AVPacket::time_base
AVRational time_base
Time base of the packet's timestamps.
Definition: packet.h:417
AVPacket::side_data_elems
int side_data_elems
Definition: packet.h:385
av_packet_clone
AVPacket * av_packet_clone(const AVPacket *src)
Create a new packet that references the same data as src.
Definition: avpacket.c:468