FFmpeg
utils.c
Go to the documentation of this file.
1 /*
2  * various utility functions for use within FFmpeg
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 <stdint.h>
23 #include <time.h>
24 
25 #include "config.h"
26 
27 #include "libavutil/avstring.h"
28 #include "libavutil/bprint.h"
29 #include "libavutil/dict.h"
30 #include "libavutil/internal.h"
31 #include "libavutil/mem.h"
32 #include "libavutil/time.h"
34 
35 #include "libavcodec/internal.h"
36 
37 #include "avformat.h"
38 #include "avio_internal.h"
39 #include "internal.h"
40 #if CONFIG_NETWORK
41 #include "network.h"
42 #endif
43 #include "os_support.h"
44 
45 /**
46  * @file
47  * various utility functions for use within FFmpeg
48  */
49 
50 /* an arbitrarily chosen "sane" max packet size -- 50M */
51 #define SANE_CHUNK_SIZE (50000000)
52 
53 /* Read the data in sane-sized chunks and append to pkt.
54  * Return the number of bytes read or an error. */
56 {
57  int orig_size = pkt->size;
58  int ret;
59 
60  do {
61  int prev_size = pkt->size;
62  int read_size;
63 
64  /* When the caller requests a lot of data, limit it to the amount
65  * left in file or SANE_CHUNK_SIZE when it is not known. */
66  read_size = size;
67  if (read_size > SANE_CHUNK_SIZE/10) {
68  read_size = ffio_limit(s, read_size);
69  // If filesize/maxsize is unknown, limit to SANE_CHUNK_SIZE
70  if (ffiocontext(s)->maxsize < 0)
71  read_size = FFMIN(read_size, SANE_CHUNK_SIZE);
72  }
73 
74  ret = av_grow_packet(pkt, read_size);
75  if (ret < 0)
76  break;
77 
78  ret = avio_read(s, pkt->data + prev_size, read_size);
79  if (ret != read_size) {
80  av_shrink_packet(pkt, prev_size + FFMAX(ret, 0));
81  break;
82  }
83 
84  size -= read_size;
85  } while (size > 0);
86  if (size > 0)
88 
89  if (!pkt->size)
91  return pkt->size > orig_size ? pkt->size - orig_size : ret;
92 }
93 
95 {
96 #if FF_API_INIT_PACKET
98  av_init_packet(pkt);
99  pkt->data = NULL;
100  pkt->size = 0;
102 #else
104 #endif
105  pkt->pos = avio_tell(s);
106 
107  return append_packet_chunked(s, pkt, size);
108 }
109 
111 {
112  if (!pkt->size)
113  return av_get_packet(s, pkt, size);
114  return append_packet_chunked(s, pkt, size);
115 }
116 
117 int av_filename_number_test(const char *filename)
118 {
119  AVBPrint bp;
120 
121  if (!filename)
122  return 0;
125 }
126 
127 /**********************************************************/
128 
129 unsigned int ff_codec_get_tag(const AVCodecTag *tags, enum AVCodecID id)
130 {
131  while (tags->id != AV_CODEC_ID_NONE) {
132  if (tags->id == id)
133  return tags->tag;
134  tags++;
135  }
136  return 0;
137 }
138 
139 enum AVCodecID ff_codec_get_id(const AVCodecTag *tags, unsigned int tag)
140 {
141  for (int i = 0; tags[i].id != AV_CODEC_ID_NONE; i++)
142  if (tag == tags[i].tag)
143  return tags[i].id;
144  for (int i = 0; tags[i].id != AV_CODEC_ID_NONE; i++)
145  if (ff_toupper4(tag) == ff_toupper4(tags[i].tag))
146  return tags[i].id;
147  return AV_CODEC_ID_NONE;
148 }
149 
150 enum AVCodecID ff_get_pcm_codec_id(int bps, int flt, int be, int sflags)
151 {
152  if (bps <= 0 || bps > 64)
153  return AV_CODEC_ID_NONE;
154 
155  if (flt) {
156  switch (bps) {
157  case 32:
159  case 64:
161  default:
162  return AV_CODEC_ID_NONE;
163  }
164  } else {
165  bps += 7;
166  bps >>= 3;
167  if (sflags & (1 << (bps - 1))) {
168  switch (bps) {
169  case 1:
170  return AV_CODEC_ID_PCM_S8;
171  case 2:
173  case 3:
175  case 4:
177  case 8:
179  default:
180  return AV_CODEC_ID_NONE;
181  }
182  } else {
183  switch (bps) {
184  case 1:
185  return AV_CODEC_ID_PCM_U8;
186  case 2:
188  case 3:
190  case 4:
192  default:
193  return AV_CODEC_ID_NONE;
194  }
195  }
196  }
197 }
198 
199 unsigned int av_codec_get_tag(const AVCodecTag *const *tags, enum AVCodecID id)
200 {
201  unsigned int tag;
202  if (!av_codec_get_tag2(tags, id, &tag))
203  return 0;
204  return tag;
205 }
206 
207 int av_codec_get_tag2(const AVCodecTag * const *tags, enum AVCodecID id,
208  unsigned int *tag)
209 {
210  for (int i = 0; tags && tags[i]; i++) {
211  const AVCodecTag *codec_tags = tags[i];
212  while (codec_tags->id != AV_CODEC_ID_NONE) {
213  if (codec_tags->id == id) {
214  *tag = codec_tags->tag;
215  return 1;
216  }
217  codec_tags++;
218  }
219  }
220  return 0;
221 }
222 
223 enum AVCodecID av_codec_get_id(const AVCodecTag *const *tags, unsigned int tag)
224 {
225  for (int i = 0; tags && tags[i]; i++) {
226  enum AVCodecID id = ff_codec_get_id(tags[i], tag);
227  if (id != AV_CODEC_ID_NONE)
228  return id;
229  }
230  return AV_CODEC_ID_NONE;
231 }
232 
234 {
235  av_freep(&par->extradata);
236  par->extradata_size = 0;
237 
238  if (size < 0 || size >= INT32_MAX - AV_INPUT_BUFFER_PADDING_SIZE)
239  return AVERROR(EINVAL);
240 
242  if (!par->extradata)
243  return AVERROR(ENOMEM);
244 
245  memset(par->extradata + size, 0, AV_INPUT_BUFFER_PADDING_SIZE);
246  par->extradata_size = size;
247 
248  return 0;
249 }
250 
251 /*******************************************************/
252 
253 uint64_t ff_ntp_time(void)
254 {
255  return (av_gettime() / 1000) * 1000 + NTP_OFFSET_US;
256 }
257 
258 uint64_t ff_get_formatted_ntp_time(uint64_t ntp_time_us)
259 {
260  uint64_t ntp_ts, frac_part, sec;
261  uint32_t usec;
262 
263  //current ntp time in seconds and micro seconds
264  sec = ntp_time_us / 1000000;
265  usec = ntp_time_us % 1000000;
266 
267  //encoding in ntp timestamp format
268  frac_part = usec * 0xFFFFFFFFULL;
269  frac_part /= 1000000;
270 
271  if (sec > 0xFFFFFFFFULL)
272  av_log(NULL, AV_LOG_WARNING, "NTP time format roll over detected\n");
273 
274  ntp_ts = sec << 32;
275  ntp_ts |= frac_part;
276 
277  return ntp_ts;
278 }
279 
280 uint64_t ff_parse_ntp_time(uint64_t ntp_ts)
281 {
282  uint64_t sec = ntp_ts >> 32;
283  uint64_t frac_part = ntp_ts & 0xFFFFFFFFULL;
284  uint64_t usec = (frac_part * 1000000) / 0xFFFFFFFFULL;
285 
286  return (sec * 1000000) + usec;
287 }
288 
289 int ff_bprint_get_frame_filename(struct AVBPrint *buf, const char *path, int64_t number, int flags)
290 {
291  const char *p;
292  char c;
293  int nd, percentd_found;
294 
295  p = path;
296  percentd_found = 0;
297  for (;;) {
298  c = *p++;
299  if (c == '\0')
300  break;
301  if (c == '%') {
302  do {
303  nd = 0;
304  while (av_isdigit(*p)) {
305  if (nd >= INT_MAX / 10 - 255)
306  goto fail;
307  nd = nd * 10 + *p++ - '0';
308  }
309  c = *p++;
310  } while (av_isdigit(c));
311 
312  switch (c) {
313  case '%':
314  goto addchar;
315  case 'd':
316  if (!(flags & AV_FRAME_FILENAME_FLAGS_MULTIPLE) && percentd_found)
317  goto fail;
318  percentd_found = 1;
319  if (number < 0)
320  nd += 1;
321  av_bprintf(buf, "%0*" PRId64, nd, number);
322  break;
323  default:
324  goto fail;
325  }
326  } else {
327 addchar:
328  av_bprint_chars(buf, c, 1);
329  }
330  }
331  if (!percentd_found)
332  goto fail;
334  return AVERROR(ENOMEM);
335  return 0;
336 fail:
337  return AVERROR(EINVAL);
338 }
339 
340 static int get_frame_filename(char *buf, int buf_size, const char *path, int64_t number, int flags)
341 {
342  AVBPrint bp;
343  av_bprint_init_for_buffer(&bp, buf, buf_size);
344  return ff_bprint_get_frame_filename(&bp, path, number, flags) < 0 ? -1 : 0;
345 }
346 
347 int av_get_frame_filename2(char *buf, int buf_size, const char *path, int number, int flags)
348 {
349  return get_frame_filename(buf, buf_size, path, number, flags);
350 }
351 
352 int av_get_frame_filename(char *buf, int buf_size, const char *path, int number)
353 {
354  return get_frame_filename(buf, buf_size, path, number, 0);
355 }
356 
357 void av_url_split(char *proto, int proto_size,
358  char *authorization, int authorization_size,
359  char *hostname, int hostname_size,
360  int *port_ptr, char *path, int path_size, const char *url)
361 {
362  const char *p, *ls, *at, *at2, *col, *brk;
363 
364  if (port_ptr)
365  *port_ptr = -1;
366  if (proto_size > 0)
367  proto[0] = 0;
368  if (authorization_size > 0)
369  authorization[0] = 0;
370  if (hostname_size > 0)
371  hostname[0] = 0;
372  if (path_size > 0)
373  path[0] = 0;
374 
375  /* parse protocol */
376  if ((p = strchr(url, ':'))) {
377  av_strlcpy(proto, url, FFMIN(proto_size, p + 1 - url));
378  p++; /* skip ':' */
379  if (*p == '/')
380  p++;
381  if (*p == '/')
382  p++;
383  } else {
384  /* no protocol means plain filename */
385  av_strlcpy(path, url, path_size);
386  return;
387  }
388 
389  /* separate path from hostname */
390  ls = p + strcspn(p, "/?#");
391  av_strlcpy(path, ls, path_size);
392 
393  /* the rest is hostname, use that to parse auth/port */
394  if (ls != p) {
395  /* authorization (user[:pass]@hostname) */
396  at2 = p;
397  while ((at = strchr(p, '@')) && at < ls) {
398  av_strlcpy(authorization, at2,
399  FFMIN(authorization_size, at + 1 - at2));
400  p = at + 1; /* skip '@' */
401  }
402 
403  if (*p == '[' && (brk = strchr(p, ']')) && brk < ls) {
404  /* [host]:port */
405  av_strlcpy(hostname, p + 1,
406  FFMIN(hostname_size, brk - p));
407  if (brk[1] == ':' && port_ptr)
408  *port_ptr = atoi(brk + 2);
409  } else if ((col = strchr(p, ':')) && col < ls) {
410  av_strlcpy(hostname, p,
411  FFMIN(col + 1 - p, hostname_size));
412  if (port_ptr)
413  *port_ptr = atoi(col + 1);
414  } else
415  av_strlcpy(hostname, p,
416  FFMIN(ls + 1 - p, hostname_size));
417  }
418 }
419 
420 int ff_mkdir_p(const char *path)
421 {
422  int ret = 0;
423  char *temp = av_strdup(path);
424  char *pos = temp;
425  char tmp_ch = '\0';
426 
427  if (!path || !temp) {
428  return -1;
429  }
430 
431  if (!av_strncasecmp(temp, "/", 1) || !av_strncasecmp(temp, "\\", 1)) {
432  pos++;
433  } else if (!av_strncasecmp(temp, "./", 2) || !av_strncasecmp(temp, ".\\", 2)) {
434  pos += 2;
435  }
436 
437  for ( ; *pos != '\0'; ++pos) {
438  if (*pos == '/' || *pos == '\\') {
439  tmp_ch = *pos;
440  *pos = '\0';
441  ret = mkdir(temp, 0755);
442  *pos = tmp_ch;
443  }
444  }
445 
446  if ((*(pos - 1) != '/') && (*(pos - 1) != '\\')) {
447  ret = mkdir(temp, 0755);
448  }
449 
450  av_free(temp);
451  return ret;
452 }
453 
454 char *ff_data_to_hex(char *buff, const uint8_t *src, int s, int lowercase)
455 {
456  static const char hex_table_uc[16] = { '0', '1', '2', '3',
457  '4', '5', '6', '7',
458  '8', '9', 'A', 'B',
459  'C', 'D', 'E', 'F' };
460  static const char hex_table_lc[16] = { '0', '1', '2', '3',
461  '4', '5', '6', '7',
462  '8', '9', 'a', 'b',
463  'c', 'd', 'e', 'f' };
464  const char *hex_table = lowercase ? hex_table_lc : hex_table_uc;
465 
466  for (int i = 0; i < s; i++) {
467  buff[i * 2] = hex_table[src[i] >> 4];
468  buff[i * 2 + 1] = hex_table[src[i] & 0xF];
469  }
470  buff[2 * s] = '\0';
471 
472  return buff;
473 }
474 
475 int ff_hex_to_data(uint8_t *data, const char *p)
476 {
477  int c, len, v;
478 
479  len = 0;
480  v = 1;
481  for (;;) {
482  p += strspn(p, SPACE_CHARS);
483  if (*p == '\0')
484  break;
485  c = av_toupper((unsigned char) *p++);
486  if (c >= '0' && c <= '9')
487  c = c - '0';
488  else if (c >= 'A' && c <= 'F')
489  c = c - 'A' + 10;
490  else
491  break;
492  v = (v << 4) | c;
493  if (v & 0x100) {
494  if (data)
495  data[len] = v;
496  len++;
497  v = 1;
498  }
499  }
500  return len;
501 }
502 
503 void ff_parse_key_value(const char *str, ff_parse_key_val_cb callback_get_buf,
504  void *context)
505 {
506  const char *ptr = str;
507 
508  /* Parse key=value pairs. */
509  for (;;) {
510  const char *key;
511  char *dest = NULL, *dest_end;
512  int key_len, dest_len = 0;
513 
514  /* Skip whitespace and potential commas. */
515  while (*ptr && (av_isspace(*ptr) || *ptr == ','))
516  ptr++;
517  if (!*ptr)
518  break;
519 
520  key = ptr;
521 
522  if (!(ptr = strchr(key, '=')))
523  break;
524  ptr++;
525  key_len = ptr - key;
526 
527  callback_get_buf(context, key, key_len, &dest, &dest_len);
528  dest_end = dest ? dest + dest_len - 1 : NULL;
529 
530  if (*ptr == '\"') {
531  ptr++;
532  while (*ptr && *ptr != '\"') {
533  if (*ptr == '\\') {
534  if (!ptr[1])
535  break;
536  if (dest && dest < dest_end)
537  *dest++ = ptr[1];
538  ptr += 2;
539  } else {
540  if (dest && dest < dest_end)
541  *dest++ = *ptr;
542  ptr++;
543  }
544  }
545  if (*ptr == '\"')
546  ptr++;
547  } else {
548  for (; *ptr && !(av_isspace(*ptr) || *ptr == ','); ptr++)
549  if (dest && dest < dest_end)
550  *dest++ = *ptr;
551  }
552  if (dest)
553  *dest = 0;
554  }
555 }
556 
558 {
559 #if CONFIG_NETWORK
560  int ret;
561  if ((ret = ff_network_init()) < 0)
562  return ret;
563  if ((ret = ff_tls_init()) < 0)
564  return ret;
565 #endif
566  return 0;
567 }
568 
570 {
571 #if CONFIG_NETWORK
573  ff_tls_deinit();
574 #endif
575  return 0;
576 }
577 
578 int ff_is_http_proto(const char *filename) {
579  const char *proto = avio_find_protocol_name(filename);
580  return proto ? (!av_strcasecmp(proto, "http") || !av_strcasecmp(proto, "https")) : 0;
581 }
582 
583 int ff_bprint_to_codecpar_extradata(AVCodecParameters *par, struct AVBPrint *buf)
584 {
585  int ret;
586  char *str;
587 
588  ret = av_bprint_finalize(buf, &str);
589  if (ret < 0)
590  return ret;
591  if (!av_bprint_is_complete(buf)) {
592  av_free(str);
593  return AVERROR(ENOMEM);
594  }
595 
596  par->extradata = str;
597  /* Note: the string is NUL terminated (so extradata can be read as a
598  * string), but the ending character is not accounted in the size (in
599  * binary formats you are likely not supposed to mux that character). When
600  * extradata is copied, it is also padded with AV_INPUT_BUFFER_PADDING_SIZE
601  * zeros. */
602  par->extradata_size = buf->len;
603  return 0;
604 }
605 
606 int ff_dict_set_timestamp(AVDictionary **dict, const char *key, int64_t timestamp)
607 {
608  time_t seconds = timestamp / 1000000;
609  struct tm *ptm, tmbuf;
610  ptm = gmtime_r(&seconds, &tmbuf);
611  if (ptm) {
612  char buf[32];
613  if (!strftime(buf, sizeof(buf), "%Y-%m-%dT%H:%M:%S", ptm))
614  return AVERROR_EXTERNAL;
615  av_strlcatf(buf, sizeof(buf), ".%06dZ", (int)(timestamp % 1000000));
616  return av_dict_set(dict, key, buf, 0);
617  } else {
618  return AVERROR_EXTERNAL;
619  }
620 }
AV_CODEC_ID_PCM_S16LE
@ AV_CODEC_ID_PCM_S16LE
Definition: codec_id.h:337
flags
const SwsFlags flags[]
Definition: swscale.c:61
ff_dict_set_timestamp
int ff_dict_set_timestamp(AVDictionary **dict, const char *key, int64_t timestamp)
Set a dictionary value to an ISO-8601 compliant timestamp string.
Definition: utils.c:606
av_packet_unref
void av_packet_unref(AVPacket *pkt)
Wipe the packet.
Definition: packet.c:433
be
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 be(in the first position) for now. Options ------- Then comes the options array. This is what will define the user accessible options. For example
FF_ENABLE_DEPRECATION_WARNINGS
#define FF_ENABLE_DEPRECATION_WARNINGS
Definition: internal.h:73
ff_codec_get_id
enum AVCodecID ff_codec_get_id(const AVCodecTag *tags, unsigned int tag)
Definition: utils.c:139
AV_LOG_WARNING
#define AV_LOG_WARNING
Something somehow does not look correct.
Definition: log.h:216
AV_CODEC_ID_PCM_F32BE
@ AV_CODEC_ID_PCM_F32BE
Definition: codec_id.h:357
get_frame_filename
static int get_frame_filename(char *buf, int buf_size, const char *path, int64_t number, int flags)
Definition: utils.c:340
ff_data_to_hex
char * ff_data_to_hex(char *buff, const uint8_t *src, int s, int lowercase)
Write hexadecimal string corresponding to given binary data.
Definition: utils.c:454
AVCodecParameters::extradata
uint8_t * extradata
Extra binary data needed for initializing the decoder, codec-dependent.
Definition: codec_par.h:69
ff_bprint_get_frame_filename
int ff_bprint_get_frame_filename(struct AVBPrint *buf, const char *path, int64_t number, int flags)
Return in 'buf' the path with 'd' replaced by a number.
Definition: utils.c:289
av_bprint_is_complete
static int av_bprint_is_complete(const AVBPrint *buf)
Test if the print buffer is complete (not truncated).
Definition: bprint.h:218
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_codec_get_tag2
int av_codec_get_tag2(const AVCodecTag *const *tags, enum AVCodecID id, unsigned int *tag)
Definition: utils.c:207
ff_mkdir_p
int ff_mkdir_p(const char *path)
Automatically create sub-directories.
Definition: utils.c:420
av_bprint_init
void av_bprint_init(AVBPrint *buf, unsigned size_init, unsigned size_max)
Definition: bprint.c:69
ff_ntp_time
uint64_t ff_ntp_time(void)
Get the current time since NTP epoch in microseconds.
Definition: utils.c:253
AVCodecParameters
This struct describes the properties of an encoded stream.
Definition: codec_par.h:47
ffiocontext
static av_always_inline FFIOContext * ffiocontext(AVIOContext *ctx)
Definition: avio_internal.h:81
AVCodecTag::id
enum AVCodecID id
Definition: internal.h:43
int64_t
long long int64_t
Definition: coverity.c:34
av_grow_packet
int av_grow_packet(AVPacket *pkt, int grow_by)
Increase packet size, correctly zeroing padding.
Definition: packet.c:122
av_strcasecmp
int av_strcasecmp(const char *a, const char *b)
Locale-independent case-insensitive compare.
Definition: avstring.c:208
av_isspace
static av_const int av_isspace(int c)
Locale-independent conversion of ASCII isspace.
Definition: avstring.h:218
AV_FRAME_FILENAME_FLAGS_IGNORE_TRUNCATION
#define AV_FRAME_FILENAME_FLAGS_IGNORE_TRUNCATION
Ignore truncated output instead of returning an error.
Definition: avformat.h:2821
internal.h
AVPacket::data
uint8_t * data
Definition: packet.h:558
av_get_frame_filename2
int av_get_frame_filename2(char *buf, int buf_size, const char *path, int number, int flags)
Return in 'buf' the path with 'd' replaced by a number.
Definition: utils.c:347
data
const char data[16]
Definition: mxf.c:149
AV_CODEC_ID_PCM_U24LE
@ AV_CODEC_ID_PCM_U24LE
Definition: codec_id.h:351
ff_toupper4
unsigned int ff_toupper4(unsigned int x)
Definition: to_upper4.h:29
AVDictionary
Definition: dict.c:32
FFMAX
#define FFMAX(a, b)
Definition: macros.h:47
ff_network_close
void ff_network_close(void)
Definition: network.c:113
av_get_frame_filename
int av_get_frame_filename(char *buf, int buf_size, const char *path, int number)
Definition: utils.c:352
av_strlcatf
size_t av_strlcatf(char *dst, size_t size, const char *fmt,...)
Definition: avstring.c:103
os_support.h
ff_network_init
int ff_network_init(void)
Definition: network.c:55
ff_tls_init
int ff_tls_init(void)
Definition: network.c:36
av_malloc
#define av_malloc(s)
Definition: tableprint_vlc.h:31
av_filename_number_test
int av_filename_number_test(const char *filename)
Check whether filename actually is a numbered sequence generator.
Definition: utils.c:117
AV_CODEC_ID_PCM_S64LE
@ AV_CODEC_ID_PCM_S64LE
Definition: codec_id.h:368
av_bprint_init_for_buffer
void av_bprint_init_for_buffer(AVBPrint *buf, char *buffer, unsigned size)
Init a print buffer using a pre-existing buffer.
Definition: bprint.c:85
AV_CODEC_ID_PCM_S16BE
@ AV_CODEC_ID_PCM_S16BE
Definition: codec_id.h:338
AV_BPRINT_SIZE_COUNT_ONLY
#define AV_BPRINT_SIZE_COUNT_ONLY
fail
#define fail()
Definition: checkasm.h:200
av_shrink_packet
void av_shrink_packet(AVPacket *pkt, int size)
Reduce packet size, correctly zeroing padding.
Definition: packet.c:114
gmtime_r
#define gmtime_r
Definition: time_internal.h:34
avio_tell
static av_always_inline int64_t avio_tell(AVIOContext *s)
ftell() equivalent for AVIOContext.
Definition: avio.h:494
avformat_network_init
int avformat_network_init(void)
Do global initialization of network libraries.
Definition: utils.c:557
SPACE_CHARS
#define SPACE_CHARS
Definition: dnn_backend_tf.c:356
AV_CODEC_ID_PCM_S8
@ AV_CODEC_ID_PCM_S8
Definition: codec_id.h:341
av_codec_get_tag
unsigned int av_codec_get_tag(const AVCodecTag *const *tags, enum AVCodecID id)
Definition: utils.c:199
pkt
AVPacket * pkt
Definition: movenc.c:60
AV_PKT_FLAG_CORRUPT
#define AV_PKT_FLAG_CORRUPT
The packet content is corrupted.
Definition: packet.h:614
AVCodecTag
Definition: internal.h:42
s
#define s(width, name)
Definition: cbs_vp9.c:198
av_append_packet
int av_append_packet(AVIOContext *s, AVPacket *pkt, int size)
Read data and append it to the current content of the AVPacket.
Definition: utils.c:110
AV_CODEC_ID_PCM_U16BE
@ AV_CODEC_ID_PCM_U16BE
Definition: codec_id.h:340
key
const char * key
Definition: hwcontext_opencl.c:189
ff_hex_to_data
int ff_hex_to_data(uint8_t *data, const char *p)
Parse a string of hexadecimal strings.
Definition: utils.c:475
time_internal.h
context
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 default minimum maximum flags name is the option keep it simple and lowercase description are in without and describe what they for example set the foo of the bar offset is the offset of the field in your context
Definition: writing_filters.txt:91
NULL
#define NULL
Definition: coverity.c:32
AV_CODEC_ID_PCM_U24BE
@ AV_CODEC_ID_PCM_U24BE
Definition: codec_id.h:352
AV_CODEC_ID_PCM_U32BE
@ AV_CODEC_ID_PCM_U32BE
Definition: codec_id.h:348
AV_CODEC_ID_PCM_S64BE
@ AV_CODEC_ID_PCM_S64BE
Definition: codec_id.h:369
ff_parse_key_value
void ff_parse_key_value(const char *str, ff_parse_key_val_cb callback_get_buf, void *context)
Parse a string with comma-separated key=value pairs.
Definition: utils.c:503
time.h
ff_get_formatted_ntp_time
uint64_t ff_get_formatted_ntp_time(uint64_t ntp_time_us)
Get the NTP time stamp formatted as per the RFC-5905.
Definition: utils.c:258
c
Undefined Behavior In the C some operations are like signed integer dereferencing freed accessing outside allocated Undefined Behavior must not occur in a C it is not safe even if the output of undefined operations is unused The unsafety may seem nit picking but Optimizing compilers have in fact optimized code on the assumption that no undefined Behavior occurs Optimizing code based on wrong assumptions can and has in some cases lead to effects beyond the output of computations The signed integer overflow problem in speed critical code Code which is highly optimized and works with signed integers sometimes has the problem that often the output of the computation does not c
Definition: undefined.txt:32
AVCodecID
AVCodecID
Identify the syntax and semantics of the bitstream.
Definition: codec_id.h:49
AVCodecParameters::extradata_size
int extradata_size
Size of the extradata content in bytes.
Definition: codec_par.h:73
av_strncasecmp
int av_strncasecmp(const char *a, const char *b, size_t n)
Locale-independent case-insensitive compare.
Definition: avstring.c:218
AVIOContext
Bytestream IO Context.
Definition: avio.h:160
AV_CODEC_ID_PCM_S24LE
@ AV_CODEC_ID_PCM_S24LE
Definition: codec_id.h:349
AVPacket::size
int size
Definition: packet.h:559
av_bprint_finalize
int av_bprint_finalize(AVBPrint *buf, char **ret_str)
Finalize a print buffer.
Definition: bprint.c:235
bps
unsigned bps
Definition: movenc.c:1958
ff_get_pcm_codec_id
enum AVCodecID ff_get_pcm_codec_id(int bps, int flt, int be, int sflags)
Select a PCM codec based on the given parameters.
Definition: utils.c:150
size
int size
Definition: twinvq_data.h:10344
NTP_OFFSET_US
#define NTP_OFFSET_US
Definition: internal.h:404
av_isdigit
static av_const int av_isdigit(int c)
Locale-independent conversion of ASCII isdigit.
Definition: avstring.h:202
AVERROR_EXTERNAL
#define AVERROR_EXTERNAL
Generic error in an external library.
Definition: error.h:59
AVPacket::flags
int flags
A combination of AV_PKT_FLAG values.
Definition: packet.h:564
AV_FRAME_FILENAME_FLAGS_MULTIPLE
#define AV_FRAME_FILENAME_FLAGS_MULTIPLE
Allow multiple d.
Definition: avformat.h:2820
SANE_CHUNK_SIZE
#define SANE_CHUNK_SIZE
Definition: utils.c:51
ffio_limit
int ffio_limit(AVIOContext *s, int size)
Definition: aviobuf.c:1064
bprint.h
AV_CODEC_ID_NONE
@ AV_CODEC_ID_NONE
Definition: codec_id.h:50
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:256
avio_internal.h
internal.h
AV_CODEC_ID_PCM_F64BE
@ AV_CODEC_ID_PCM_F64BE
Definition: codec_id.h:359
av_toupper
static av_const int av_toupper(int c)
Locale-independent conversion of ASCII characters to uppercase.
Definition: avstring.h:227
av_url_split
void av_url_split(char *proto, int proto_size, char *authorization, int authorization_size, char *hostname, int hostname_size, int *port_ptr, char *path, int path_size, const char *url)
Split a URL string into components.
Definition: utils.c:357
FFMIN
#define FFMIN(a, b)
Definition: macros.h:49
AV_CODEC_ID_PCM_S32BE
@ AV_CODEC_ID_PCM_S32BE
Definition: codec_id.h:346
len
int len
Definition: vorbis_enc_data.h:426
av_get_packet
int av_get_packet(AVIOContext *s, AVPacket *pkt, int size)
Allocate and read the payload of a packet and initialize its fields with default values.
Definition: utils.c:94
ff_tls_deinit
void ff_tls_deinit(void)
Definition: network.c:46
tag
uint32_t tag
Definition: movenc.c:1957
ret
ret
Definition: filter_design.txt:187
ff_is_http_proto
int ff_is_http_proto(const char *filename)
Utility function to check if the file uses http or https protocol.
Definition: utils.c:578
ff_bprint_to_codecpar_extradata
int ff_bprint_to_codecpar_extradata(AVCodecParameters *par, struct AVBPrint *buf)
Finalize buf into extradata and set its size appropriately.
Definition: utils.c:583
lowercase
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 default minimum maximum flags name is the option keep it simple and lowercase description are in lowercase
Definition: writing_filters.txt:89
pos
unsigned int pos
Definition: spdifenc.c:414
avformat.h
av_bprintf
void av_bprintf(AVBPrint *buf, const char *fmt,...)
Definition: bprint.c:122
dict.h
network.h
AV_INPUT_BUFFER_PADDING_SIZE
#define AV_INPUT_BUFFER_PADDING_SIZE
Definition: defs.h:40
id
enum AVCodecID id
Definition: dts2pts.c:367
avformat_network_deinit
int avformat_network_deinit(void)
Undo the initialization done by avformat_network_init.
Definition: utils.c:569
avio_read
int avio_read(AVIOContext *s, unsigned char *buf, int size)
Read size bytes from AVIOContext into buf.
Definition: aviobuf.c:615
ff_parse_key_val_cb
void(* ff_parse_key_val_cb)(void *context, const char *key, int key_len, char **dest, int *dest_len)
Callback function type for ff_parse_key_value.
Definition: internal.h:483
AV_CODEC_ID_PCM_U32LE
@ AV_CODEC_ID_PCM_U32LE
Definition: codec_id.h:347
temp
else temp
Definition: vf_mcdeint.c:271
av_gettime
int64_t av_gettime(void)
Get the current time in microseconds.
Definition: time.c:39
FF_DISABLE_DEPRECATION_WARNINGS
#define FF_DISABLE_DEPRECATION_WARNINGS
Definition: internal.h:72
av_strdup
char * av_strdup(const char *s)
Duplicate a string.
Definition: mem.c:272
AV_CODEC_ID_PCM_S32LE
@ AV_CODEC_ID_PCM_S32LE
Definition: codec_id.h:345
mem.h
ff_codec_get_tag
unsigned int ff_codec_get_tag(const AVCodecTag *tags, enum AVCodecID id)
Definition: utils.c:129
AV_CODEC_ID_PCM_U8
@ AV_CODEC_ID_PCM_U8
Definition: codec_id.h:342
AV_CODEC_ID_PCM_F64LE
@ AV_CODEC_ID_PCM_F64LE
Definition: codec_id.h:360
av_free
#define av_free(p)
Definition: tableprint_vlc.h:34
AVPacket
This structure stores compressed data.
Definition: packet.h:535
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:86
AVPacket::pos
int64_t pos
byte position in stream, -1 if unknown
Definition: packet.h:578
avio_find_protocol_name
const char * avio_find_protocol_name(const char *url)
Return the name of the protocol that will handle the passed URL.
Definition: avio.c:658
ff_parse_ntp_time
uint64_t ff_parse_ntp_time(uint64_t ntp_ts)
Parse the NTP time in micro seconds (since NTP epoch).
Definition: utils.c:280
AV_CODEC_ID_PCM_U16LE
@ AV_CODEC_ID_PCM_U16LE
Definition: codec_id.h:339
av_strlcpy
size_t av_strlcpy(char *dst, const char *src, size_t size)
Copy the string src to dst, but no more than size - 1 bytes, and null-terminate dst.
Definition: avstring.c:85
AV_CODEC_ID_PCM_F32LE
@ AV_CODEC_ID_PCM_F32LE
Definition: codec_id.h:358
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:27
av_bprint_chars
void av_bprint_chars(AVBPrint *buf, char c, unsigned n)
Append char c n times to a print buffer.
Definition: bprint.c:130
avstring.h
av_codec_get_id
enum AVCodecID av_codec_get_id(const AVCodecTag *const *tags, unsigned int tag)
Definition: utils.c:223
AVCodecTag::tag
unsigned int tag
Definition: internal.h:44
ff_alloc_extradata
int ff_alloc_extradata(AVCodecParameters *par, int size)
Allocate extradata with additional AV_INPUT_BUFFER_PADDING_SIZE at end which is always set to 0.
Definition: utils.c:233
AV_CODEC_ID_PCM_S24BE
@ AV_CODEC_ID_PCM_S24BE
Definition: codec_id.h:350
src
#define src
Definition: vp8dsp.c:248
append_packet_chunked
static int append_packet_chunked(AVIOContext *s, AVPacket *pkt, int size)
Definition: utils.c:55