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 
24 #include "config.h"
25 
26 #include "libavutil/avstring.h"
27 #include "libavutil/bprint.h"
28 #include "libavutil/internal.h"
29 #include "libavutil/thread.h"
30 #include "libavutil/time.h"
31 
32 #include "libavcodec/internal.h"
33 
34 #include "avformat.h"
35 #include "avio_internal.h"
36 #include "internal.h"
37 #if CONFIG_NETWORK
38 #include "network.h"
39 #endif
40 #include "os_support.h"
41 
43 
44 /**
45  * @file
46  * various utility functions for use within FFmpeg
47  */
48 
50 {
51  return ff_mutex_lock(&avformat_mutex) ? -1 : 0;
52 }
53 
55 {
56  return ff_mutex_unlock(&avformat_mutex) ? -1 : 0;
57 }
58 
59 /* an arbitrarily chosen "sane" max packet size -- 50M */
60 #define SANE_CHUNK_SIZE (50000000)
61 
62 /* Read the data in sane-sized chunks and append to pkt.
63  * Return the number of bytes read or an error. */
65 {
66  int orig_size = pkt->size;
67  int ret;
68 
69  do {
70  int prev_size = pkt->size;
71  int read_size;
72 
73  /* When the caller requests a lot of data, limit it to the amount
74  * left in file or SANE_CHUNK_SIZE when it is not known. */
75  read_size = size;
76  if (read_size > SANE_CHUNK_SIZE/10) {
77  read_size = ffio_limit(s, read_size);
78  // If filesize/maxsize is unknown, limit to SANE_CHUNK_SIZE
79  if (ffiocontext(s)->maxsize < 0)
80  read_size = FFMIN(read_size, SANE_CHUNK_SIZE);
81  }
82 
83  ret = av_grow_packet(pkt, read_size);
84  if (ret < 0)
85  break;
86 
87  ret = avio_read(s, pkt->data + prev_size, read_size);
88  if (ret != read_size) {
89  av_shrink_packet(pkt, prev_size + FFMAX(ret, 0));
90  break;
91  }
92 
93  size -= read_size;
94  } while (size > 0);
95  if (size > 0)
97 
98  if (!pkt->size)
100  return pkt->size > orig_size ? pkt->size - orig_size : ret;
101 }
102 
104 {
105 #if FF_API_INIT_PACKET
107  av_init_packet(pkt);
108  pkt->data = NULL;
109  pkt->size = 0;
111 #else
113 #endif
114  pkt->pos = avio_tell(s);
115 
116  return append_packet_chunked(s, pkt, size);
117 }
118 
120 {
121  if (!pkt->size)
122  return av_get_packet(s, pkt, size);
123  return append_packet_chunked(s, pkt, size);
124 }
125 
126 int av_filename_number_test(const char *filename)
127 {
128  char buf[1024];
129  return filename &&
130  (av_get_frame_filename(buf, sizeof(buf), filename, 1) >= 0);
131 }
132 
133 /**********************************************************/
134 
135 unsigned int ff_codec_get_tag(const AVCodecTag *tags, enum AVCodecID id)
136 {
137  while (tags->id != AV_CODEC_ID_NONE) {
138  if (tags->id == id)
139  return tags->tag;
140  tags++;
141  }
142  return 0;
143 }
144 
145 enum AVCodecID ff_codec_get_id(const AVCodecTag *tags, unsigned int tag)
146 {
147  for (int i = 0; tags[i].id != AV_CODEC_ID_NONE; i++)
148  if (tag == tags[i].tag)
149  return tags[i].id;
150  for (int i = 0; tags[i].id != AV_CODEC_ID_NONE; i++)
151  if (ff_toupper4(tag) == ff_toupper4(tags[i].tag))
152  return tags[i].id;
153  return AV_CODEC_ID_NONE;
154 }
155 
156 enum AVCodecID ff_get_pcm_codec_id(int bps, int flt, int be, int sflags)
157 {
158  if (bps <= 0 || bps > 64)
159  return AV_CODEC_ID_NONE;
160 
161  if (flt) {
162  switch (bps) {
163  case 32:
165  case 64:
167  default:
168  return AV_CODEC_ID_NONE;
169  }
170  } else {
171  bps += 7;
172  bps >>= 3;
173  if (sflags & (1 << (bps - 1))) {
174  switch (bps) {
175  case 1:
176  return AV_CODEC_ID_PCM_S8;
177  case 2:
179  case 3:
181  case 4:
183  case 8:
185  default:
186  return AV_CODEC_ID_NONE;
187  }
188  } else {
189  switch (bps) {
190  case 1:
191  return AV_CODEC_ID_PCM_U8;
192  case 2:
194  case 3:
196  case 4:
198  default:
199  return AV_CODEC_ID_NONE;
200  }
201  }
202  }
203 }
204 
205 unsigned int av_codec_get_tag(const AVCodecTag *const *tags, enum AVCodecID id)
206 {
207  unsigned int tag;
208  if (!av_codec_get_tag2(tags, id, &tag))
209  return 0;
210  return tag;
211 }
212 
213 int av_codec_get_tag2(const AVCodecTag * const *tags, enum AVCodecID id,
214  unsigned int *tag)
215 {
216  for (int i = 0; tags && tags[i]; i++) {
217  const AVCodecTag *codec_tags = tags[i];
218  while (codec_tags->id != AV_CODEC_ID_NONE) {
219  if (codec_tags->id == id) {
220  *tag = codec_tags->tag;
221  return 1;
222  }
223  codec_tags++;
224  }
225  }
226  return 0;
227 }
228 
229 enum AVCodecID av_codec_get_id(const AVCodecTag *const *tags, unsigned int tag)
230 {
231  for (int i = 0; tags && tags[i]; i++) {
232  enum AVCodecID id = ff_codec_get_id(tags[i], tag);
233  if (id != AV_CODEC_ID_NONE)
234  return id;
235  }
236  return AV_CODEC_ID_NONE;
237 }
238 
240 {
241  av_freep(&par->extradata);
242  par->extradata_size = 0;
243 
244  if (size < 0 || size >= INT32_MAX - AV_INPUT_BUFFER_PADDING_SIZE)
245  return AVERROR(EINVAL);
246 
248  if (!par->extradata)
249  return AVERROR(ENOMEM);
250 
251  memset(par->extradata + size, 0, AV_INPUT_BUFFER_PADDING_SIZE);
252  par->extradata_size = size;
253 
254  return 0;
255 }
256 
257 /*******************************************************/
258 
259 uint64_t ff_ntp_time(void)
260 {
261  return (av_gettime() / 1000) * 1000 + NTP_OFFSET_US;
262 }
263 
264 uint64_t ff_get_formatted_ntp_time(uint64_t ntp_time_us)
265 {
266  uint64_t ntp_ts, frac_part, sec;
267  uint32_t usec;
268 
269  //current ntp time in seconds and micro seconds
270  sec = ntp_time_us / 1000000;
271  usec = ntp_time_us % 1000000;
272 
273  //encoding in ntp timestamp format
274  frac_part = usec * 0xFFFFFFFFULL;
275  frac_part /= 1000000;
276 
277  if (sec > 0xFFFFFFFFULL)
278  av_log(NULL, AV_LOG_WARNING, "NTP time format roll over detected\n");
279 
280  ntp_ts = sec << 32;
281  ntp_ts |= frac_part;
282 
283  return ntp_ts;
284 }
285 
286 uint64_t ff_parse_ntp_time(uint64_t ntp_ts)
287 {
288  uint64_t sec = ntp_ts >> 32;
289  uint64_t frac_part = ntp_ts & 0xFFFFFFFFULL;
290  uint64_t usec = (frac_part * 1000000) / 0xFFFFFFFFULL;
291 
292  return (sec * 1000000) + usec;
293 }
294 
295 int av_get_frame_filename2(char *buf, int buf_size, const char *path, int number, int flags)
296 {
297  const char *p;
298  char *q, buf1[20], c;
299  int nd, len, percentd_found;
300 
301  q = buf;
302  p = path;
303  percentd_found = 0;
304  for (;;) {
305  c = *p++;
306  if (c == '\0')
307  break;
308  if (c == '%') {
309  do {
310  nd = 0;
311  while (av_isdigit(*p)) {
312  if (nd >= INT_MAX / 10 - 255)
313  goto fail;
314  nd = nd * 10 + *p++ - '0';
315  }
316  c = *p++;
317  } while (av_isdigit(c));
318 
319  switch (c) {
320  case '%':
321  goto addchar;
322  case 'd':
323  if (!(flags & AV_FRAME_FILENAME_FLAGS_MULTIPLE) && percentd_found)
324  goto fail;
325  percentd_found = 1;
326  if (number < 0)
327  nd += 1;
328  snprintf(buf1, sizeof(buf1), "%0*d", nd, number);
329  len = strlen(buf1);
330  if ((q - buf + len) > buf_size - 1)
331  goto fail;
332  memcpy(q, buf1, len);
333  q += len;
334  break;
335  default:
336  goto fail;
337  }
338  } else {
339 addchar:
340  if ((q - buf) < buf_size - 1)
341  *q++ = c;
342  }
343  }
344  if (!percentd_found)
345  goto fail;
346  *q = '\0';
347  return 0;
348 fail:
349  *q = '\0';
350  return -1;
351 }
352 
353 int av_get_frame_filename(char *buf, int buf_size, const char *path, int number)
354 {
355  return av_get_frame_filename2(buf, buf_size, path, number, 0);
356 }
357 
358 void av_url_split(char *proto, int proto_size,
359  char *authorization, int authorization_size,
360  char *hostname, int hostname_size,
361  int *port_ptr, char *path, int path_size, const char *url)
362 {
363  const char *p, *ls, *at, *at2, *col, *brk;
364 
365  if (port_ptr)
366  *port_ptr = -1;
367  if (proto_size > 0)
368  proto[0] = 0;
369  if (authorization_size > 0)
370  authorization[0] = 0;
371  if (hostname_size > 0)
372  hostname[0] = 0;
373  if (path_size > 0)
374  path[0] = 0;
375 
376  /* parse protocol */
377  if ((p = strchr(url, ':'))) {
378  av_strlcpy(proto, url, FFMIN(proto_size, p + 1 - url));
379  p++; /* skip ':' */
380  if (*p == '/')
381  p++;
382  if (*p == '/')
383  p++;
384  } else {
385  /* no protocol means plain filename */
386  av_strlcpy(path, url, path_size);
387  return;
388  }
389 
390  /* separate path from hostname */
391  ls = p + strcspn(p, "/?#");
392  av_strlcpy(path, ls, path_size);
393 
394  /* the rest is hostname, use that to parse auth/port */
395  if (ls != p) {
396  /* authorization (user[:pass]@hostname) */
397  at2 = p;
398  while ((at = strchr(p, '@')) && at < ls) {
399  av_strlcpy(authorization, at2,
400  FFMIN(authorization_size, at + 1 - at2));
401  p = at + 1; /* skip '@' */
402  }
403 
404  if (*p == '[' && (brk = strchr(p, ']')) && brk < ls) {
405  /* [host]:port */
406  av_strlcpy(hostname, p + 1,
407  FFMIN(hostname_size, brk - p));
408  if (brk[1] == ':' && port_ptr)
409  *port_ptr = atoi(brk + 2);
410  } else if ((col = strchr(p, ':')) && col < ls) {
411  av_strlcpy(hostname, p,
412  FFMIN(col + 1 - p, hostname_size));
413  if (port_ptr)
414  *port_ptr = atoi(col + 1);
415  } else
416  av_strlcpy(hostname, p,
417  FFMIN(ls + 1 - p, hostname_size));
418  }
419 }
420 
421 int ff_mkdir_p(const char *path)
422 {
423  int ret = 0;
424  char *temp = av_strdup(path);
425  char *pos = temp;
426  char tmp_ch = '\0';
427 
428  if (!path || !temp) {
429  return -1;
430  }
431 
432  if (!av_strncasecmp(temp, "/", 1) || !av_strncasecmp(temp, "\\", 1)) {
433  pos++;
434  } else if (!av_strncasecmp(temp, "./", 2) || !av_strncasecmp(temp, ".\\", 2)) {
435  pos += 2;
436  }
437 
438  for ( ; *pos != '\0'; ++pos) {
439  if (*pos == '/' || *pos == '\\') {
440  tmp_ch = *pos;
441  *pos = '\0';
442  ret = mkdir(temp, 0755);
443  *pos = tmp_ch;
444  }
445  }
446 
447  if ((*(pos - 1) != '/') && (*(pos - 1) != '\\')) {
448  ret = mkdir(temp, 0755);
449  }
450 
451  av_free(temp);
452  return ret;
453 }
454 
455 char *ff_data_to_hex(char *buff, const uint8_t *src, int s, int lowercase)
456 {
457  static const char hex_table_uc[16] = { '0', '1', '2', '3',
458  '4', '5', '6', '7',
459  '8', '9', 'A', 'B',
460  'C', 'D', 'E', 'F' };
461  static const char hex_table_lc[16] = { '0', '1', '2', '3',
462  '4', '5', '6', '7',
463  '8', '9', 'a', 'b',
464  'c', 'd', 'e', 'f' };
465  const char *hex_table = lowercase ? hex_table_lc : hex_table_uc;
466 
467  for (int i = 0; i < s; i++) {
468  buff[i * 2] = hex_table[src[i] >> 4];
469  buff[i * 2 + 1] = hex_table[src[i] & 0xF];
470  }
471  buff[2 * s] = '\0';
472 
473  return buff;
474 }
475 
476 int ff_hex_to_data(uint8_t *data, const char *p)
477 {
478  int c, len, v;
479 
480  len = 0;
481  v = 1;
482  for (;;) {
483  p += strspn(p, SPACE_CHARS);
484  if (*p == '\0')
485  break;
486  c = av_toupper((unsigned char) *p++);
487  if (c >= '0' && c <= '9')
488  c = c - '0';
489  else if (c >= 'A' && c <= 'F')
490  c = c - 'A' + 10;
491  else
492  break;
493  v = (v << 4) | c;
494  if (v & 0x100) {
495  if (data)
496  data[len] = v;
497  len++;
498  v = 1;
499  }
500  }
501  return len;
502 }
503 
504 void ff_parse_key_value(const char *str, ff_parse_key_val_cb callback_get_buf,
505  void *context)
506 {
507  const char *ptr = str;
508 
509  /* Parse key=value pairs. */
510  for (;;) {
511  const char *key;
512  char *dest = NULL, *dest_end;
513  int key_len, dest_len = 0;
514 
515  /* Skip whitespace and potential commas. */
516  while (*ptr && (av_isspace(*ptr) || *ptr == ','))
517  ptr++;
518  if (!*ptr)
519  break;
520 
521  key = ptr;
522 
523  if (!(ptr = strchr(key, '=')))
524  break;
525  ptr++;
526  key_len = ptr - key;
527 
528  callback_get_buf(context, key, key_len, &dest, &dest_len);
529  dest_end = dest ? dest + dest_len - 1 : NULL;
530 
531  if (*ptr == '\"') {
532  ptr++;
533  while (*ptr && *ptr != '\"') {
534  if (*ptr == '\\') {
535  if (!ptr[1])
536  break;
537  if (dest && dest < dest_end)
538  *dest++ = ptr[1];
539  ptr += 2;
540  } else {
541  if (dest && dest < dest_end)
542  *dest++ = *ptr;
543  ptr++;
544  }
545  }
546  if (*ptr == '\"')
547  ptr++;
548  } else {
549  for (; *ptr && !(av_isspace(*ptr) || *ptr == ','); ptr++)
550  if (dest && dest < dest_end)
551  *dest++ = *ptr;
552  }
553  if (dest)
554  *dest = 0;
555  }
556 }
557 
559 {
560 #if CONFIG_NETWORK
561  int ret;
562  if ((ret = ff_network_init()) < 0)
563  return ret;
564  if ((ret = ff_tls_init()) < 0)
565  return ret;
566 #endif
567  return 0;
568 }
569 
571 {
572 #if CONFIG_NETWORK
574  ff_tls_deinit();
575 #endif
576  return 0;
577 }
578 
579 int ff_is_http_proto(const char *filename) {
580  const char *proto = avio_find_protocol_name(filename);
581  return proto ? (!av_strcasecmp(proto, "http") || !av_strcasecmp(proto, "https")) : 0;
582 }
583 
584 int ff_bprint_to_codecpar_extradata(AVCodecParameters *par, struct AVBPrint *buf)
585 {
586  int ret;
587  char *str;
588 
589  ret = av_bprint_finalize(buf, &str);
590  if (ret < 0)
591  return ret;
592  if (!av_bprint_is_complete(buf)) {
593  av_free(str);
594  return AVERROR(ENOMEM);
595  }
596 
597  par->extradata = str;
598  /* Note: the string is NUL terminated (so extradata can be read as a
599  * string), but the ending character is not accounted in the size (in
600  * binary formats you are likely not supposed to mux that character). When
601  * extradata is copied, it is also padded with AV_INPUT_BUFFER_PADDING_SIZE
602  * zeros. */
603  par->extradata_size = buf->len;
604  return 0;
605 }
AV_CODEC_ID_PCM_S16LE
@ AV_CODEC_ID_PCM_S16LE
Definition: codec_id.h:331
av_packet_unref
void av_packet_unref(AVPacket *pkt)
Wipe the packet.
Definition: avpacket.c:427
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:145
AV_LOG_WARNING
#define AV_LOG_WARNING
Something somehow does not look correct.
Definition: log.h:186
AV_CODEC_ID_PCM_F32BE
@ AV_CODEC_ID_PCM_F32BE
Definition: codec_id.h:351
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:455
AVCodecParameters::extradata
uint8_t * extradata
Extra binary data needed for initializing the decoder, codec-dependent.
Definition: codec_par.h:69
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
ff_lock_avformat
int ff_lock_avformat(void)
Definition: utils.c:49
av_codec_get_tag2
int av_codec_get_tag2(const AVCodecTag *const *tags, enum AVCodecID id, unsigned int *tag)
Definition: utils.c:213
ff_mkdir_p
int ff_mkdir_p(const char *path)
Automatically create sub-directories.
Definition: utils.c:421
ff_ntp_time
uint64_t ff_ntp_time(void)
Get the current time since NTP epoch in microseconds.
Definition: utils.c:259
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
thread.h
AVCodecTag::id
enum AVCodecID id
Definition: internal.h:49
av_grow_packet
int av_grow_packet(AVPacket *pkt, int grow_by)
Increase packet size, correctly zeroing padding.
Definition: avpacket.c:121
av_strcasecmp
int av_strcasecmp(const char *a, const char *b)
Locale-independent case-insensitive compare.
Definition: avstring.c:207
av_isspace
static av_const int av_isspace(int c)
Locale-independent conversion of ASCII isspace.
Definition: avstring.h:218
internal.h
AVPacket::data
uint8_t * data
Definition: packet.h:522
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:295
data
const char data[16]
Definition: mxf.c:148
AV_CODEC_ID_PCM_U24LE
@ AV_CODEC_ID_PCM_U24LE
Definition: codec_id.h:345
ff_toupper4
unsigned int ff_toupper4(unsigned int x)
Definition: to_upper4.h:29
FFMAX
#define FFMAX(a, b)
Definition: macros.h:47
ff_network_close
void ff_network_close(void)
Definition: network.c:116
av_get_frame_filename
int av_get_frame_filename(char *buf, int buf_size, const char *path, int number)
Definition: utils.c:353
os_support.h
ff_network_init
int ff_network_init(void)
Definition: network.c:58
ff_tls_init
int ff_tls_init(void)
Definition: network.c:31
av_malloc
#define av_malloc(s)
Definition: tableprint_vlc.h:30
av_filename_number_test
int av_filename_number_test(const char *filename)
Check whether filename actually is a numbered sequence generator.
Definition: utils.c:126
AV_CODEC_ID_PCM_S64LE
@ AV_CODEC_ID_PCM_S64LE
Definition: codec_id.h:362
ff_mutex_unlock
static int ff_mutex_unlock(AVMutex *mutex)
Definition: thread.h:189
AV_CODEC_ID_PCM_S16BE
@ AV_CODEC_ID_PCM_S16BE
Definition: codec_id.h:332
fail
#define fail()
Definition: checkasm.h:179
av_shrink_packet
void av_shrink_packet(AVPacket *pkt, int size)
Reduce packet size, correctly zeroing padding.
Definition: avpacket.c:113
avio_tell
static av_always_inline int64_t avio_tell(AVIOContext *s)
ftell() equivalent for AVIOContext.
Definition: avio.h:513
avformat_network_init
int avformat_network_init(void)
Do global initialization of network libraries.
Definition: utils.c:558
SPACE_CHARS
#define SPACE_CHARS
Definition: dnn_backend_tf.c:369
AV_CODEC_ID_PCM_S8
@ AV_CODEC_ID_PCM_S8
Definition: codec_id.h:335
av_codec_get_tag
unsigned int av_codec_get_tag(const AVCodecTag *const *tags, enum AVCodecID id)
Definition: utils.c:205
pkt
AVPacket * pkt
Definition: movenc.c:59
AV_PKT_FLAG_CORRUPT
#define AV_PKT_FLAG_CORRUPT
The packet content is corrupted.
Definition: packet.h:578
AVCodecTag
Definition: internal.h:48
AVMutex
#define AVMutex
Definition: thread.h:184
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:119
AV_CODEC_ID_PCM_U16BE
@ AV_CODEC_ID_PCM_U16BE
Definition: codec_id.h:334
key
const char * key
Definition: hwcontext_opencl.c:179
ff_hex_to_data
int ff_hex_to_data(uint8_t *data, const char *p)
Parse a string of hexadecimal strings.
Definition: utils.c:476
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:346
AV_CODEC_ID_PCM_U32BE
@ AV_CODEC_ID_PCM_U32BE
Definition: codec_id.h:342
AV_CODEC_ID_PCM_S64BE
@ AV_CODEC_ID_PCM_S64BE
Definition: codec_id.h:363
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:504
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:264
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:217
AVIOContext
Bytestream IO Context.
Definition: avio.h:166
AV_CODEC_ID_PCM_S24LE
@ AV_CODEC_ID_PCM_S24LE
Definition: codec_id.h:343
AVPacket::size
int size
Definition: packet.h:523
av_bprint_finalize
int av_bprint_finalize(AVBPrint *buf, char **ret_str)
Finalize a print buffer.
Definition: bprint.c:240
bps
unsigned bps
Definition: movenc.c:1787
AV_MUTEX_INITIALIZER
#define AV_MUTEX_INITIALIZER
Definition: thread.h:185
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:156
size
int size
Definition: twinvq_data.h:10344
NTP_OFFSET_US
#define NTP_OFFSET_US
Definition: internal.h:503
ff_unlock_avformat
int ff_unlock_avformat(void)
Definition: utils.c:54
av_isdigit
static av_const int av_isdigit(int c)
Locale-independent conversion of ASCII isdigit.
Definition: avstring.h:202
ff_mutex_lock
static int ff_mutex_lock(AVMutex *mutex)
Definition: thread.h:188
AVPacket::flags
int flags
A combination of AV_PKT_FLAG values.
Definition: packet.h:528
AV_FRAME_FILENAME_FLAGS_MULTIPLE
#define AV_FRAME_FILENAME_FLAGS_MULTIPLE
Allow multiple d.
Definition: avformat.h:2994
SANE_CHUNK_SIZE
#define SANE_CHUNK_SIZE
Definition: utils.c:60
ffio_limit
int ffio_limit(AVIOContext *s, int size)
Definition: aviobuf.c:1173
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:255
avio_internal.h
internal.h
avformat_mutex
static AVMutex avformat_mutex
Definition: utils.c:42
AV_CODEC_ID_PCM_F64BE
@ AV_CODEC_ID_PCM_F64BE
Definition: codec_id.h:353
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:358
FFMIN
#define FFMIN(a, b)
Definition: macros.h:49
AV_CODEC_ID_PCM_S32BE
@ AV_CODEC_ID_PCM_S32BE
Definition: codec_id.h:340
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:103
ff_tls_deinit
void ff_tls_deinit(void)
Definition: network.c:46
tag
uint32_t tag
Definition: movenc.c:1786
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:579
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:584
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:413
avformat.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:364
avformat_network_deinit
int avformat_network_deinit(void)
Undo the initialization done by avformat_network_init.
Definition: utils.c:570
avio_read
int avio_read(AVIOContext *s, unsigned char *buf, int size)
Read size bytes from AVIOContext into buf.
Definition: aviobuf.c:659
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:582
AV_CODEC_ID_PCM_U32LE
@ AV_CODEC_ID_PCM_U32LE
Definition: codec_id.h:341
temp
else temp
Definition: vf_mcdeint.c:263
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:270
AV_CODEC_ID_PCM_S32LE
@ AV_CODEC_ID_PCM_S32LE
Definition: codec_id.h:339
ff_codec_get_tag
unsigned int ff_codec_get_tag(const AVCodecTag *tags, enum AVCodecID id)
Definition: utils.c:135
AV_CODEC_ID_PCM_U8
@ AV_CODEC_ID_PCM_U8
Definition: codec_id.h:336
AV_CODEC_ID_PCM_F64LE
@ AV_CODEC_ID_PCM_F64LE
Definition: codec_id.h:354
av_free
#define av_free(p)
Definition: tableprint_vlc.h:33
AVPacket
This structure stores compressed data.
Definition: packet.h:499
av_freep
#define av_freep(p)
Definition: tableprint_vlc.h:34
src
INIT_CLIP pixel * src
Definition: h264pred_template.c:418
AVPacket::pos
int64_t pos
byte position in stream, -1 if unknown
Definition: packet.h:542
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:468
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:286
AV_CODEC_ID_PCM_U16LE
@ AV_CODEC_ID_PCM_U16LE
Definition: codec_id.h:333
flags
#define flags(name, subs,...)
Definition: cbs_av1.c:474
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:352
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:27
avstring.h
av_codec_get_id
enum AVCodecID av_codec_get_id(const AVCodecTag *const *tags, unsigned int tag)
Definition: utils.c:229
AVCodecTag::tag
unsigned int tag
Definition: internal.h:50
snprintf
#define snprintf
Definition: snprintf.h:34
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:239
AV_CODEC_ID_PCM_S24BE
@ AV_CODEC_ID_PCM_S24BE
Definition: codec_id.h:344
append_packet_chunked
static int append_packet_chunked(AVIOContext *s, AVPacket *pkt, int size)
Definition: utils.c:64