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 = av_buffer_realloc(&pkt->buf, new_size + data_offset);
146  if (ret < 0) {
147  pkt->data = old_data;
148  return ret;
149  }
150  pkt->data = pkt->buf->data + data_offset;
151  }
152  } else {
153  pkt->buf = av_buffer_alloc(new_size);
154  if (!pkt->buf)
155  return AVERROR(ENOMEM);
156  if (pkt->size > 0)
157  memcpy(pkt->buf->data, pkt->data, pkt->size);
158  pkt->data = pkt->buf->data;
159  }
160  pkt->size += grow_by;
161  memset(pkt->data + pkt->size, 0, AV_INPUT_BUFFER_PADDING_SIZE);
162 
163  return 0;
164 }
165 
167 {
168  if (size >= INT_MAX - AV_INPUT_BUFFER_PADDING_SIZE)
169  return AVERROR(EINVAL);
170 
173  if (!pkt->buf)
174  return AVERROR(ENOMEM);
175 
176  pkt->data = data;
177  pkt->size = size;
178 
179  return 0;
180 }
181 
183 {
184  int i;
185  for (i = 0; i < pkt->side_data_elems; i++)
188  pkt->side_data_elems = 0;
189 }
190 
192  uint8_t *data, size_t size)
193 {
195  int i, elems = pkt->side_data_elems;
196 
197  for (i = 0; i < elems; i++) {
198  AVPacketSideData *sd = &pkt->side_data[i];
199 
200  if (sd->type == type) {
201  av_free(sd->data);
202  sd->data = data;
203  sd->size = size;
204  return 0;
205  }
206  }
207 
208  if ((unsigned)elems + 1 > AV_PKT_DATA_NB)
209  return AVERROR(ERANGE);
210 
211  tmp = av_realloc(pkt->side_data, (elems + 1) * sizeof(*tmp));
212  if (!tmp)
213  return AVERROR(ENOMEM);
214 
215  pkt->side_data = tmp;
216  pkt->side_data[elems].data = data;
217  pkt->side_data[elems].size = size;
218  pkt->side_data[elems].type = type;
219  pkt->side_data_elems++;
220 
221  return 0;
222 }
223 
224 
226  size_t size)
227 {
228  int ret;
229  uint8_t *data;
230 
231  if (size > SIZE_MAX - AV_INPUT_BUFFER_PADDING_SIZE)
232  return NULL;
234  if (!data)
235  return NULL;
236 
238  if (ret < 0) {
239  av_freep(&data);
240  return NULL;
241  }
242 
243  return data;
244 }
245 
247  size_t *size)
248 {
249  int i;
250 
251  for (i = 0; i < pkt->side_data_elems; i++) {
252  if (pkt->side_data[i].type == type) {
253  if (size)
254  *size = pkt->side_data[i].size;
255  return pkt->side_data[i].data;
256  }
257  }
258  if (size)
259  *size = 0;
260  return NULL;
261 }
262 
264 {
265  switch(type) {
266  case AV_PKT_DATA_PALETTE: return "Palette";
267  case AV_PKT_DATA_NEW_EXTRADATA: return "New Extradata";
268  case AV_PKT_DATA_PARAM_CHANGE: return "Param Change";
269  case AV_PKT_DATA_H263_MB_INFO: return "H263 MB Info";
270  case AV_PKT_DATA_REPLAYGAIN: return "Replay Gain";
271  case AV_PKT_DATA_DISPLAYMATRIX: return "Display Matrix";
272  case AV_PKT_DATA_STEREO3D: return "Stereo 3D";
273  case AV_PKT_DATA_AUDIO_SERVICE_TYPE: return "Audio Service Type";
274  case AV_PKT_DATA_QUALITY_STATS: return "Quality stats";
275  case AV_PKT_DATA_FALLBACK_TRACK: return "Fallback track";
276  case AV_PKT_DATA_CPB_PROPERTIES: return "CPB properties";
277  case AV_PKT_DATA_SKIP_SAMPLES: return "Skip Samples";
278  case AV_PKT_DATA_JP_DUALMONO: return "JP Dual Mono";
279  case AV_PKT_DATA_STRINGS_METADATA: return "Strings Metadata";
280  case AV_PKT_DATA_SUBTITLE_POSITION: return "Subtitle Position";
281  case AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL: return "Matroska BlockAdditional";
282  case AV_PKT_DATA_WEBVTT_IDENTIFIER: return "WebVTT ID";
283  case AV_PKT_DATA_WEBVTT_SETTINGS: return "WebVTT Settings";
284  case AV_PKT_DATA_METADATA_UPDATE: return "Metadata Update";
285  case AV_PKT_DATA_MPEGTS_STREAM_ID: return "MPEGTS Stream ID";
286  case AV_PKT_DATA_MASTERING_DISPLAY_METADATA: return "Mastering display metadata";
287  case AV_PKT_DATA_CONTENT_LIGHT_LEVEL: return "Content light level metadata";
288  case AV_PKT_DATA_SPHERICAL: return "Spherical Mapping";
289  case AV_PKT_DATA_A53_CC: return "A53 Closed Captions";
290  case AV_PKT_DATA_ENCRYPTION_INIT_INFO: return "Encryption initialization data";
291  case AV_PKT_DATA_ENCRYPTION_INFO: return "Encryption info";
292  case AV_PKT_DATA_AFD: return "Active Format Description data";
293  case AV_PKT_DATA_PRFT: return "Producer Reference Time";
294  case AV_PKT_DATA_ICC_PROFILE: return "ICC Profile";
295  case AV_PKT_DATA_DOVI_CONF: return "DOVI configuration record";
296  case AV_PKT_DATA_S12M_TIMECODE: return "SMPTE ST 12-1:2014 timecode";
297  case AV_PKT_DATA_DYNAMIC_HDR10_PLUS: return "HDR10+ Dynamic Metadata (SMPTE 2094-40)";
298  }
299  return NULL;
300 }
301 
303 {
304  uint8_t *data = NULL;
305  *size = 0;
306 
307  if (!dict)
308  return NULL;
309 
310  for (int pass = 0; pass < 2; pass++) {
311  const AVDictionaryEntry *t = NULL;
312  size_t total_length = 0;
313 
314  while ((t = av_dict_get(dict, "", t, AV_DICT_IGNORE_SUFFIX))) {
315  for (int i = 0; i < 2; i++) {
316  const char *str = i ? t->value : t->key;
317  const size_t len = strlen(str) + 1;
318 
319  if (pass)
320  memcpy(data + total_length, str, len);
321  else if (len > SIZE_MAX - total_length)
322  return NULL;
323  total_length += len;
324  }
325  }
326  if (pass)
327  break;
328  data = av_malloc(total_length);
329  if (!data)
330  return NULL;
331  *size = total_length;
332  }
333 
334  return data;
335 }
336 
337 int av_packet_unpack_dictionary(const uint8_t *data, size_t size,
338  AVDictionary **dict)
339 {
340  const uint8_t *end;
341  int ret;
342 
343  if (!dict || !data || !size)
344  return 0;
345  end = data + size;
346  if (size && end[-1])
347  return AVERROR_INVALIDDATA;
348  while (data < end) {
349  const uint8_t *key = data;
350  const uint8_t *val = data + strlen(key) + 1;
351 
352  if (val >= end || !*key)
353  return AVERROR_INVALIDDATA;
354 
355  ret = av_dict_set(dict, key, val, 0);
356  if (ret < 0)
357  return ret;
358  data = val + strlen(val) + 1;
359  }
360 
361  return 0;
362 }
363 
365  size_t size)
366 {
367  int i;
368 
369  for (i = 0; i < pkt->side_data_elems; i++) {
370  if (pkt->side_data[i].type == type) {
371  if (size > pkt->side_data[i].size)
372  return AVERROR(ENOMEM);
373  pkt->side_data[i].size = size;
374  return 0;
375  }
376  }
377  return AVERROR(ENOENT);
378 }
379 
381 {
382  int i, ret;
383 
384  dst->pts = src->pts;
385  dst->dts = src->dts;
386  dst->pos = src->pos;
387  dst->duration = src->duration;
388  dst->flags = src->flags;
389  dst->stream_index = src->stream_index;
390  dst->opaque = src->opaque;
391  dst->time_base = src->time_base;
392  dst->opaque_ref = NULL;
393  dst->side_data = NULL;
394  dst->side_data_elems = 0;
395 
396  ret = av_buffer_replace(&dst->opaque_ref, src->opaque_ref);
397  if (ret < 0)
398  return ret;
399 
400  for (i = 0; i < src->side_data_elems; i++) {
401  enum AVPacketSideDataType type = src->side_data[i].type;
402  size_t size = src->side_data[i].size;
403  uint8_t *src_data = src->side_data[i].data;
404  uint8_t *dst_data = av_packet_new_side_data(dst, type, size);
405 
406  if (!dst_data) {
409  return AVERROR(ENOMEM);
410  }
411  memcpy(dst_data, src_data, size);
412  }
413 
414  return 0;
415 }
416 
418 {
423 }
424 
426 {
427  int ret;
428 
429  dst->buf = NULL;
430 
431  ret = av_packet_copy_props(dst, src);
432  if (ret < 0)
433  goto fail;
434 
435  if (!src->buf) {
436  ret = packet_alloc(&dst->buf, src->size);
437  if (ret < 0)
438  goto fail;
439  av_assert1(!src->size || src->data);
440  if (src->size)
441  memcpy(dst->buf->data, src->data, src->size);
442 
443  dst->data = dst->buf->data;
444  } else {
445  dst->buf = av_buffer_ref(src->buf);
446  if (!dst->buf) {
447  ret = AVERROR(ENOMEM);
448  goto fail;
449  }
450  dst->data = src->data;
451  }
452 
453  dst->size = src->size;
454 
455  return 0;
456 fail:
457  av_packet_unref(dst);
458  return ret;
459 }
460 
462 {
464 
465  if (!ret)
466  return ret;
467 
468  if (av_packet_ref(ret, src))
470 
471  return ret;
472 }
473 
475 {
476  *dst = *src;
478 }
479 
481 {
482  int ret;
483 
484  if (pkt->buf)
485  return 0;
486 
487  ret = packet_alloc(&pkt->buf, pkt->size);
488  if (ret < 0)
489  return ret;
490  av_assert1(!pkt->size || pkt->data);
491  if (pkt->size)
492  memcpy(pkt->buf->data, pkt->data, pkt->size);
493 
494  pkt->data = pkt->buf->data;
495 
496  return 0;
497 }
498 
500 {
501  AVBufferRef *buf = NULL;
502  int ret;
503 
504  if (pkt->buf && av_buffer_is_writable(pkt->buf))
505  return 0;
506 
507  ret = packet_alloc(&buf, pkt->size);
508  if (ret < 0)
509  return ret;
510  av_assert1(!pkt->size || pkt->data);
511  if (pkt->size)
512  memcpy(buf->data, pkt->data, pkt->size);
513 
515  pkt->buf = buf;
516  pkt->data = buf->data;
517 
518  return 0;
519 }
520 
522 {
523  if (pkt->pts != AV_NOPTS_VALUE)
524  pkt->pts = av_rescale_q(pkt->pts, src_tb, dst_tb);
525  if (pkt->dts != AV_NOPTS_VALUE)
526  pkt->dts = av_rescale_q(pkt->dts, src_tb, dst_tb);
527  if (pkt->duration > 0)
528  pkt->duration = av_rescale_q(pkt->duration, src_tb, dst_tb);
529 }
530 
531 int avpriv_packet_list_put(PacketList **packet_buffer,
532  PacketList **plast_pktl,
533  AVPacket *pkt,
534  int (*copy)(AVPacket *dst, const AVPacket *src),
535  int flags)
536 {
537  PacketList *pktl = av_malloc(sizeof(PacketList));
538  int ret;
539 
540  if (!pktl)
541  return AVERROR(ENOMEM);
542 
543  if (copy) {
544  get_packet_defaults(&pktl->pkt);
545  ret = copy(&pktl->pkt, pkt);
546  if (ret < 0) {
547  av_free(pktl);
548  return ret;
549  }
550  } else {
552  if (ret < 0) {
553  av_free(pktl);
554  return ret;
555  }
556  av_packet_move_ref(&pktl->pkt, pkt);
557  }
558 
559  pktl->next = NULL;
560 
561  if (*packet_buffer)
562  (*plast_pktl)->next = pktl;
563  else
564  *packet_buffer = pktl;
565 
566  /* Add the packet in the buffered packet list. */
567  *plast_pktl = pktl;
568  return 0;
569 }
570 
572  PacketList **pkt_buffer_end,
573  AVPacket *pkt)
574 {
575  PacketList *pktl;
576  if (!*pkt_buffer)
577  return AVERROR(EAGAIN);
578  pktl = *pkt_buffer;
579  *pkt = pktl->pkt;
580  *pkt_buffer = pktl->next;
581  if (!pktl->next)
582  *pkt_buffer_end = NULL;
583  av_freep(&pktl);
584  return 0;
585 }
586 
587 void avpriv_packet_list_free(PacketList **pkt_buf, PacketList **pkt_buf_end)
588 {
589  PacketList *tmp = *pkt_buf;
590 
591  while (tmp) {
592  PacketList *pktl = tmp;
593  tmp = pktl->next;
594  av_packet_unref(&pktl->pkt);
595  av_freep(&pktl);
596  }
597  *pkt_buf = NULL;
598  *pkt_buf_end = NULL;
599 }
600 
601 int ff_side_data_set_encoder_stats(AVPacket *pkt, int quality, int64_t *error, int error_count, int pict_type)
602 {
603  uint8_t *side_data;
604  size_t side_data_size;
605  int i;
606 
607  side_data = av_packet_get_side_data(pkt, AV_PKT_DATA_QUALITY_STATS, &side_data_size);
608  if (!side_data) {
609  side_data_size = 4+4+8*error_count;
611  side_data_size);
612  }
613 
614  if (!side_data || side_data_size < 4+4+8*error_count)
615  return AVERROR(ENOMEM);
616 
617  AV_WL32(side_data , quality );
618  side_data[4] = pict_type;
619  side_data[5] = error_count;
620  for (i = 0; i<error_count; i++)
621  AV_WL64(side_data+8 + 8*i , error[i]);
622 
623  return 0;
624 }
625 
626 int ff_side_data_set_prft(AVPacket *pkt, int64_t timestamp)
627 {
629  uint8_t *side_data;
630  size_t side_data_size;
631 
632  side_data = av_packet_get_side_data(pkt, AV_PKT_DATA_PRFT, &side_data_size);
633  if (!side_data) {
634  side_data_size = sizeof(AVProducerReferenceTime);
635  side_data = av_packet_new_side_data(pkt, AV_PKT_DATA_PRFT, side_data_size);
636  }
637 
638  if (!side_data || side_data_size < sizeof(AVProducerReferenceTime))
639  return AVERROR(ENOMEM);
640 
641  prft = (AVProducerReferenceTime *)side_data;
642  prft->wallclock = timestamp;
643  prft->flags = 0;
644 
645  return 0;
646 }
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:417
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:601
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:364
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: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:182
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:191
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:626
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:263
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
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
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: 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:425
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:474
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:166
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
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
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:337
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:302
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:480
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:521
PacketList::pkt
AVPacket pkt
Definition: packet_internal.h:28
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:380
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:246
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
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:571
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:225
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:499
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
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:531
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:587
AVPacket::time_base
AVRational time_base
Time base of the packet's timestamps.
Definition: packet.h:414
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:461