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