FFmpeg  4.4.9
cmdutils.c
Go to the documentation of this file.
1 /*
2  * Various utilities for command line tools
3  * Copyright (c) 2000-2003 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 #include <stdint.h>
24 #include <stdlib.h>
25 #include <errno.h>
26 #include <math.h>
27 
28 /* Include only the enabled headers since some compilers (namely, Sun
29  Studio) will not omit unused inline functions and create undefined
30  references to libraries that are not being built. */
31 
32 #include "config.h"
33 #include "compat/va_copy.h"
34 #include "libavformat/avformat.h"
35 #include "libavfilter/avfilter.h"
36 #include "libavdevice/avdevice.h"
38 #include "libswscale/swscale.h"
41 #include "libavutil/attributes.h"
42 #include "libavutil/avassert.h"
43 #include "libavutil/avstring.h"
44 #include "libavutil/bprint.h"
45 #include "libavutil/display.h"
46 #include "libavutil/mathematics.h"
47 #include "libavutil/imgutils.h"
48 #include "libavutil/libm.h"
49 #include "libavutil/parseutils.h"
50 #include "libavutil/pixdesc.h"
51 #include "libavutil/eval.h"
52 #include "libavutil/dict.h"
53 #include "libavutil/opt.h"
54 #include "libavutil/cpu.h"
55 #include "libavutil/ffversion.h"
56 #include "libavutil/version.h"
57 #include "cmdutils.h"
58 #if HAVE_SYS_RESOURCE_H
59 #include <sys/time.h>
60 #include <sys/resource.h>
61 #endif
62 #ifdef _WIN32
63 #include <windows.h>
64 #endif
65 
66 static int init_report(const char *env);
67 
71 
72 static FILE *report_file;
74 int hide_banner = 0;
75 
80 };
81 
82 void init_opts(void)
83 {
84  av_dict_set(&sws_dict, "flags", "bicubic", 0);
85 }
86 
87 void uninit_opts(void)
88 {
94 }
95 
96 void log_callback_help(void *ptr, int level, const char *fmt, va_list vl)
97 {
98  vfprintf(stdout, fmt, vl);
99 }
100 
101 static void log_callback_report(void *ptr, int level, const char *fmt, va_list vl)
102 {
103  va_list vl2;
104  char line[1024];
105  static int print_prefix = 1;
106 
107  va_copy(vl2, vl);
108  av_log_default_callback(ptr, level, fmt, vl);
109  av_log_format_line(ptr, level, fmt, vl2, line, sizeof(line), &print_prefix);
110  va_end(vl2);
111  if (report_file_level >= level) {
112  fputs(line, report_file);
113  fflush(report_file);
114  }
115 }
116 
117 void init_dynload(void)
118 {
119 #if HAVE_SETDLLDIRECTORY && defined(_WIN32)
120  /* Calling SetDllDirectory with the empty string (but not NULL) removes the
121  * current working directory from the DLL search path as a security pre-caution. */
122  SetDllDirectory("");
123 #endif
124 }
125 
126 static void (*program_exit)(int ret);
127 
128 void register_exit(void (*cb)(int ret))
129 {
130  program_exit = cb;
131 }
132 
133 void report_and_exit(int ret)
134 {
135  av_log(NULL, AV_LOG_FATAL, "%s\n", av_err2str(ret));
136  exit_program(AVUNERROR(ret));
137 }
138 
139 void exit_program(int ret)
140 {
141  if (program_exit)
142  program_exit(ret);
143 
144  exit(ret);
145 }
146 
147 double parse_number_or_die(const char *context, const char *numstr, int type,
148  double min, double max)
149 {
150  char *tail;
151  const char *error;
152  double d = av_strtod(numstr, &tail);
153  if (*tail)
154  error = "Expected number for %s but found: %s\n";
155  else if (d < min || d > max)
156  error = "The value for %s was %s which is not within %f - %f\n";
157  else if (type == OPT_INT64 && (int64_t)d != d)
158  error = "Expected int64 for %s but found %s\n";
159  else if (type == OPT_INT && (int)d != d)
160  error = "Expected int for %s but found %s\n";
161  else
162  return d;
163  av_log(NULL, AV_LOG_FATAL, error, context, numstr, min, max);
164  exit_program(1);
165  return 0;
166 }
167 
168 int64_t parse_time_or_die(const char *context, const char *timestr,
169  int is_duration)
170 {
171  int64_t us;
172  if (av_parse_time(&us, timestr, is_duration) < 0) {
173  av_log(NULL, AV_LOG_FATAL, "Invalid %s specification for %s: %s\n",
174  is_duration ? "duration" : "date", context, timestr);
175  exit_program(1);
176  }
177  return us;
178 }
179 
180 void show_help_options(const OptionDef *options, const char *msg, int req_flags,
181  int rej_flags, int alt_flags)
182 {
183  const OptionDef *po;
184  int first;
185 
186  first = 1;
187  for (po = options; po->name; po++) {
188  char buf[128];
189 
190  if (((po->flags & req_flags) != req_flags) ||
191  (alt_flags && !(po->flags & alt_flags)) ||
192  (po->flags & rej_flags))
193  continue;
194 
195  if (first) {
196  printf("%s\n", msg);
197  first = 0;
198  }
199  av_strlcpy(buf, po->name, sizeof(buf));
200  if (po->argname) {
201  av_strlcat(buf, " ", sizeof(buf));
202  av_strlcat(buf, po->argname, sizeof(buf));
203  }
204  printf("-%-17s %s\n", buf, po->help);
205  }
206  printf("\n");
207 }
208 
209 void show_help_children(const AVClass *class, int flags)
210 {
211  void *iter = NULL;
212  const AVClass *child;
213  if (class->option) {
214  av_opt_show2(&class, NULL, flags, 0);
215  printf("\n");
216  }
217 
218  while (child = av_opt_child_class_iterate(class, &iter))
219  show_help_children(child, flags);
220 }
221 
222 static const OptionDef *find_option(const OptionDef *po, const char *name)
223 {
224  while (po->name) {
225  const char *end;
226  if (av_strstart(name, po->name, &end) && (!*end || *end == ':'))
227  break;
228  po++;
229  }
230  return po;
231 }
232 
233 /* _WIN32 means using the windows libc - cygwin doesn't define that
234  * by default. HAVE_COMMANDLINETOARGVW is true on cygwin, while
235  * it doesn't provide the actual command line via GetCommandLineW(). */
236 #if HAVE_COMMANDLINETOARGVW && defined(_WIN32)
237 #include <shellapi.h>
238 /* Will be leaked on exit */
239 static char** win32_argv_utf8 = NULL;
240 static int win32_argc = 0;
241 
242 /**
243  * Prepare command line arguments for executable.
244  * For Windows - perform wide-char to UTF-8 conversion.
245  * Input arguments should be main() function arguments.
246  * @param argc_ptr Arguments number (including executable)
247  * @param argv_ptr Arguments list.
248  */
249 static void prepare_app_arguments(int *argc_ptr, char ***argv_ptr)
250 {
251  char *argstr_flat;
252  wchar_t **argv_w;
253  int i, buffsize = 0, offset = 0;
254 
255  if (win32_argv_utf8) {
256  *argc_ptr = win32_argc;
257  *argv_ptr = win32_argv_utf8;
258  return;
259  }
260 
261  win32_argc = 0;
262  argv_w = CommandLineToArgvW(GetCommandLineW(), &win32_argc);
263  if (win32_argc <= 0 || !argv_w)
264  return;
265 
266  /* determine the UTF-8 buffer size (including NULL-termination symbols) */
267  for (i = 0; i < win32_argc; i++)
268  buffsize += WideCharToMultiByte(CP_UTF8, 0, argv_w[i], -1,
269  NULL, 0, NULL, NULL);
270 
271  win32_argv_utf8 = av_mallocz(sizeof(char *) * (win32_argc + 1) + buffsize);
272  argstr_flat = (char *)win32_argv_utf8 + sizeof(char *) * (win32_argc + 1);
273  if (!win32_argv_utf8) {
274  LocalFree(argv_w);
275  return;
276  }
277 
278  for (i = 0; i < win32_argc; i++) {
279  win32_argv_utf8[i] = &argstr_flat[offset];
280  offset += WideCharToMultiByte(CP_UTF8, 0, argv_w[i], -1,
281  &argstr_flat[offset],
282  buffsize - offset, NULL, NULL);
283  }
284  win32_argv_utf8[i] = NULL;
285  LocalFree(argv_w);
286 
287  *argc_ptr = win32_argc;
288  *argv_ptr = win32_argv_utf8;
289 }
290 #else
291 static inline void prepare_app_arguments(int *argc_ptr, char ***argv_ptr)
292 {
293  /* nothing to do */
294 }
295 #endif /* HAVE_COMMANDLINETOARGVW */
296 
297 static int write_option(void *optctx, const OptionDef *po, const char *opt,
298  const char *arg)
299 {
300  /* new-style options contain an offset into optctx, old-style address of
301  * a global var*/
302  void *dst = po->flags & (OPT_OFFSET | OPT_SPEC) ?
303  (uint8_t *)optctx + po->u.off : po->u.dst_ptr;
304  int *dstcount;
305 
306  if (po->flags & OPT_SPEC) {
307  SpecifierOpt **so = dst;
308  char *p = strchr(opt, ':');
309  char *str;
310 
311  dstcount = (int *)(so + 1);
312  *so = grow_array(*so, sizeof(**so), dstcount, *dstcount + 1);
313  str = av_strdup(p ? p + 1 : "");
314  if (!str)
315  return AVERROR(ENOMEM);
316  (*so)[*dstcount - 1].specifier = str;
317  dst = &(*so)[*dstcount - 1].u;
318  }
319 
320  if (po->flags & OPT_STRING) {
321  char *str;
322  str = av_strdup(arg);
323  av_freep(dst);
324  if (!str)
325  return AVERROR(ENOMEM);
326  *(char **)dst = str;
327  } else if (po->flags & OPT_BOOL || po->flags & OPT_INT) {
328  *(int *)dst = parse_number_or_die(opt, arg, OPT_INT64, INT_MIN, INT_MAX);
329  } else if (po->flags & OPT_INT64) {
330  *(int64_t *)dst = parse_number_or_die(opt, arg, OPT_INT64, INT64_MIN, INT64_MAX);
331  } else if (po->flags & OPT_TIME) {
332  *(int64_t *)dst = parse_time_or_die(opt, arg, 1);
333  } else if (po->flags & OPT_FLOAT) {
334  *(float *)dst = parse_number_or_die(opt, arg, OPT_FLOAT, -INFINITY, INFINITY);
335  } else if (po->flags & OPT_DOUBLE) {
336  *(double *)dst = parse_number_or_die(opt, arg, OPT_DOUBLE, -INFINITY, INFINITY);
337  } else if (po->u.func_arg) {
338  int ret = po->u.func_arg(optctx, opt, arg);
339  if (ret < 0) {
341  "Failed to set value '%s' for option '%s': %s\n",
342  arg, opt, av_err2str(ret));
343  return ret;
344  }
345  }
346  if (po->flags & OPT_EXIT)
347  exit_program(0);
348 
349  return 0;
350 }
351 
352 int parse_option(void *optctx, const char *opt, const char *arg,
353  const OptionDef *options)
354 {
355  const OptionDef *po;
356  int ret;
357 
358  po = find_option(options, opt);
359  if (!po->name && opt[0] == 'n' && opt[1] == 'o') {
360  /* handle 'no' bool option */
361  po = find_option(options, opt + 2);
362  if ((po->name && (po->flags & OPT_BOOL)))
363  arg = "0";
364  } else if (po->flags & OPT_BOOL)
365  arg = "1";
366 
367  if (!po->name)
368  po = find_option(options, "default");
369  if (!po->name) {
370  av_log(NULL, AV_LOG_ERROR, "Unrecognized option '%s'\n", opt);
371  return AVERROR(EINVAL);
372  }
373  if (po->flags & HAS_ARG && !arg) {
374  av_log(NULL, AV_LOG_ERROR, "Missing argument for option '%s'\n", opt);
375  return AVERROR(EINVAL);
376  }
377 
378  ret = write_option(optctx, po, opt, arg);
379  if (ret < 0)
380  return ret;
381 
382  return !!(po->flags & HAS_ARG);
383 }
384 
385 void parse_options(void *optctx, int argc, char **argv, const OptionDef *options,
386  void (*parse_arg_function)(void *, const char*))
387 {
388  const char *opt;
389  int optindex, handleoptions = 1, ret;
390 
391  /* perform system-dependent conversions for arguments list */
392  prepare_app_arguments(&argc, &argv);
393 
394  /* parse options */
395  optindex = 1;
396  while (optindex < argc) {
397  opt = argv[optindex++];
398 
399  if (handleoptions && opt[0] == '-' && opt[1] != '\0') {
400  if (opt[1] == '-' && opt[2] == '\0') {
401  handleoptions = 0;
402  continue;
403  }
404  opt++;
405 
406  if ((ret = parse_option(optctx, opt, argv[optindex], options)) < 0)
407  exit_program(1);
408  optindex += ret;
409  } else {
410  if (parse_arg_function)
411  parse_arg_function(optctx, opt);
412  }
413  }
414 }
415 
416 int parse_optgroup(void *optctx, OptionGroup *g)
417 {
418  int i, ret;
419 
420  av_log(NULL, AV_LOG_DEBUG, "Parsing a group of options: %s %s.\n",
421  g->group_def->name, g->arg);
422 
423  for (i = 0; i < g->nb_opts; i++) {
424  Option *o = &g->opts[i];
425 
426  if (g->group_def->flags &&
427  !(g->group_def->flags & o->opt->flags)) {
428  av_log(NULL, AV_LOG_ERROR, "Option %s (%s) cannot be applied to "
429  "%s %s -- you are trying to apply an input option to an "
430  "output file or vice versa. Move this option before the "
431  "file it belongs to.\n", o->key, o->opt->help,
432  g->group_def->name, g->arg);
433  return AVERROR(EINVAL);
434  }
435 
436  av_log(NULL, AV_LOG_DEBUG, "Applying option %s (%s) with argument %s.\n",
437  o->key, o->opt->help, o->val);
438 
439  ret = write_option(optctx, o->opt, o->key, o->val);
440  if (ret < 0)
441  return ret;
442  }
443 
444  av_log(NULL, AV_LOG_DEBUG, "Successfully parsed a group of options.\n");
445 
446  return 0;
447 }
448 
449 int locate_option(int argc, char **argv, const OptionDef *options,
450  const char *optname)
451 {
452  const OptionDef *po;
453  int i;
454 
455  for (i = 1; i < argc; i++) {
456  const char *cur_opt = argv[i];
457 
458  if (*cur_opt++ != '-')
459  continue;
460 
461  po = find_option(options, cur_opt);
462  if (!po->name && cur_opt[0] == 'n' && cur_opt[1] == 'o')
463  po = find_option(options, cur_opt + 2);
464 
465  if ((!po->name && !strcmp(cur_opt, optname)) ||
466  (po->name && !strcmp(optname, po->name)))
467  return i;
468 
469  if (!po->name || po->flags & HAS_ARG)
470  i++;
471  }
472  return 0;
473 }
474 
475 static void dump_argument(const char *a)
476 {
477  const unsigned char *p;
478 
479  for (p = a; *p; p++)
480  if (!((*p >= '+' && *p <= ':') || (*p >= '@' && *p <= 'Z') ||
481  *p == '_' || (*p >= 'a' && *p <= 'z')))
482  break;
483  if (!*p) {
484  fputs(a, report_file);
485  return;
486  }
487  fputc('"', report_file);
488  for (p = a; *p; p++) {
489  if (*p == '\\' || *p == '"' || *p == '$' || *p == '`')
490  fprintf(report_file, "\\%c", *p);
491  else if (*p < ' ' || *p > '~')
492  fprintf(report_file, "\\x%02x", *p);
493  else
494  fputc(*p, report_file);
495  }
496  fputc('"', report_file);
497 }
498 
499 static void check_options(const OptionDef *po)
500 {
501  while (po->name) {
502  if (po->flags & OPT_PERFILE)
504  po++;
505  }
506 }
507 
508 void parse_loglevel(int argc, char **argv, const OptionDef *options)
509 {
510  int idx = locate_option(argc, argv, options, "loglevel");
511  const char *env;
512 
514 
515  if (!idx)
516  idx = locate_option(argc, argv, options, "v");
517  if (idx && argv[idx + 1])
518  opt_loglevel(NULL, "loglevel", argv[idx + 1]);
519  idx = locate_option(argc, argv, options, "report");
520  if ((env = getenv("FFREPORT")) || idx) {
521  init_report(env);
522  if (report_file) {
523  int i;
524  fprintf(report_file, "Command line:\n");
525  for (i = 0; i < argc; i++) {
526  dump_argument(argv[i]);
527  fputc(i < argc - 1 ? ' ' : '\n', report_file);
528  }
529  fflush(report_file);
530  }
531  }
532  idx = locate_option(argc, argv, options, "hide_banner");
533  if (idx)
534  hide_banner = 1;
535 }
536 
537 static const AVOption *opt_find(void *obj, const char *name, const char *unit,
538  int opt_flags, int search_flags)
539 {
540  const AVOption *o = av_opt_find(obj, name, unit, opt_flags, search_flags);
541  if(o && !o->flags)
542  return NULL;
543  return o;
544 }
545 
546 #define FLAGS ((o->type == AV_OPT_TYPE_FLAGS && (arg[0]=='-' || arg[0]=='+')) ? AV_DICT_APPEND : 0)
547 int opt_default(void *optctx, const char *opt, const char *arg)
548 {
549  const AVOption *o;
550  int consumed = 0;
551  char opt_stripped[128];
552  const char *p;
553  const AVClass *cc = avcodec_get_class(), *fc = avformat_get_class();
554 #if CONFIG_AVRESAMPLE
555  const AVClass *rc = avresample_get_class();
556 #endif
557 #if CONFIG_SWSCALE
558  const AVClass *sc = sws_get_class();
559 #endif
560 #if CONFIG_SWRESAMPLE
561  const AVClass *swr_class = swr_get_class();
562 #endif
563 
564  if (!strcmp(opt, "debug") || !strcmp(opt, "fdebug"))
566 
567  if (!(p = strchr(opt, ':')))
568  p = opt + strlen(opt);
569  av_strlcpy(opt_stripped, opt, FFMIN(sizeof(opt_stripped), p - opt + 1));
570 
571  if ((o = opt_find(&cc, opt_stripped, NULL, 0,
573  ((opt[0] == 'v' || opt[0] == 'a' || opt[0] == 's') &&
574  (o = opt_find(&cc, opt + 1, NULL, 0, AV_OPT_SEARCH_FAKE_OBJ)))) {
575  av_dict_set(&codec_opts, opt, arg, FLAGS);
576  consumed = 1;
577  }
578  if ((o = opt_find(&fc, opt, NULL, 0,
580  av_dict_set(&format_opts, opt, arg, FLAGS);
581  if (consumed)
582  av_log(NULL, AV_LOG_VERBOSE, "Routing option %s to both codec and muxer layer\n", opt);
583  consumed = 1;
584  }
585 #if CONFIG_SWSCALE
586  if (!consumed && (o = opt_find(&sc, opt, NULL, 0,
588  struct SwsContext *sws = sws_alloc_context();
589  int ret = av_opt_set(sws, opt, arg, 0);
590  sws_freeContext(sws);
591  if (!strcmp(opt, "srcw") || !strcmp(opt, "srch") ||
592  !strcmp(opt, "dstw") || !strcmp(opt, "dsth") ||
593  !strcmp(opt, "src_format") || !strcmp(opt, "dst_format")) {
594  av_log(NULL, AV_LOG_ERROR, "Directly using swscale dimensions/format options is not supported, please use the -s or -pix_fmt options\n");
595  return AVERROR(EINVAL);
596  }
597  if (ret < 0) {
598  av_log(NULL, AV_LOG_ERROR, "Error setting option %s.\n", opt);
599  return ret;
600  }
601 
602  av_dict_set(&sws_dict, opt, arg, FLAGS);
603 
604  consumed = 1;
605  }
606 #else
607  if (!consumed && !strcmp(opt, "sws_flags")) {
608  av_log(NULL, AV_LOG_WARNING, "Ignoring %s %s, due to disabled swscale\n", opt, arg);
609  consumed = 1;
610  }
611 #endif
612 #if CONFIG_SWRESAMPLE
613  if (!consumed && (o=opt_find(&swr_class, opt, NULL, 0,
615  struct SwrContext *swr = swr_alloc();
616  int ret = av_opt_set(swr, opt, arg, 0);
617  swr_free(&swr);
618  if (ret < 0) {
619  av_log(NULL, AV_LOG_ERROR, "Error setting option %s.\n", opt);
620  return ret;
621  }
622  av_dict_set(&swr_opts, opt, arg, FLAGS);
623  consumed = 1;
624  }
625 #endif
626 #if CONFIG_AVRESAMPLE
627  if ((o=opt_find(&rc, opt, NULL, 0,
630  consumed = 1;
631  }
632 #endif
633 
634  if (consumed)
635  return 0;
637 }
638 
639 /*
640  * Check whether given option is a group separator.
641  *
642  * @return index of the group definition that matched or -1 if none
643  */
644 static int match_group_separator(const OptionGroupDef *groups, int nb_groups,
645  const char *opt)
646 {
647  int i;
648 
649  for (i = 0; i < nb_groups; i++) {
650  const OptionGroupDef *p = &groups[i];
651  if (p->sep && !strcmp(p->sep, opt))
652  return i;
653  }
654 
655  return -1;
656 }
657 
658 /*
659  * Finish parsing an option group.
660  *
661  * @param group_idx which group definition should this group belong to
662  * @param arg argument of the group delimiting option
663  */
664 static void finish_group(OptionParseContext *octx, int group_idx,
665  const char *arg)
666 {
667  OptionGroupList *l = &octx->groups[group_idx];
668  OptionGroup *g;
669 
670  GROW_ARRAY(l->groups, l->nb_groups);
671  g = &l->groups[l->nb_groups - 1];
672 
673  *g = octx->cur_group;
674  g->arg = arg;
675  g->group_def = l->group_def;
676  g->sws_dict = sws_dict;
677  g->swr_opts = swr_opts;
678  g->codec_opts = codec_opts;
679  g->format_opts = format_opts;
680  g->resample_opts = resample_opts;
681 
682  codec_opts = NULL;
683  format_opts = NULL;
685  sws_dict = NULL;
686  swr_opts = NULL;
687  init_opts();
688 
689  memset(&octx->cur_group, 0, sizeof(octx->cur_group));
690 }
691 
692 /*
693  * Add an option instance to currently parsed group.
694  */
695 static void add_opt(OptionParseContext *octx, const OptionDef *opt,
696  const char *key, const char *val)
697 {
698  int global = !(opt->flags & (OPT_PERFILE | OPT_SPEC | OPT_OFFSET));
699  OptionGroup *g = global ? &octx->global_opts : &octx->cur_group;
700 
701  GROW_ARRAY(g->opts, g->nb_opts);
702  g->opts[g->nb_opts - 1].opt = opt;
703  g->opts[g->nb_opts - 1].key = key;
704  g->opts[g->nb_opts - 1].val = val;
705 }
706 
708  const OptionGroupDef *groups, int nb_groups)
709 {
710  static const OptionGroupDef global_group = { "global" };
711  int i;
712 
713  memset(octx, 0, sizeof(*octx));
714 
715  octx->nb_groups = nb_groups;
716  octx->groups = av_mallocz_array(octx->nb_groups, sizeof(*octx->groups));
717  if (!octx->groups)
718  exit_program(1);
719 
720  for (i = 0; i < octx->nb_groups; i++)
721  octx->groups[i].group_def = &groups[i];
722 
723  octx->global_opts.group_def = &global_group;
724  octx->global_opts.arg = "";
725 
726  init_opts();
727 }
728 
730 {
731  int i, j;
732 
733  for (i = 0; i < octx->nb_groups; i++) {
734  OptionGroupList *l = &octx->groups[i];
735 
736  for (j = 0; j < l->nb_groups; j++) {
737  av_freep(&l->groups[j].opts);
741 
742  av_dict_free(&l->groups[j].sws_dict);
743  av_dict_free(&l->groups[j].swr_opts);
744  }
745  av_freep(&l->groups);
746  }
747  av_freep(&octx->groups);
748 
749  av_freep(&octx->cur_group.opts);
750  av_freep(&octx->global_opts.opts);
751 
752  uninit_opts();
753 }
754 
755 int split_commandline(OptionParseContext *octx, int argc, char *argv[],
756  const OptionDef *options,
757  const OptionGroupDef *groups, int nb_groups)
758 {
759  int optindex = 1;
760  int dashdash = -2;
761 
762  /* perform system-dependent conversions for arguments list */
763  prepare_app_arguments(&argc, &argv);
764 
765  init_parse_context(octx, groups, nb_groups);
766  av_log(NULL, AV_LOG_DEBUG, "Splitting the commandline.\n");
767 
768  while (optindex < argc) {
769  const char *opt = argv[optindex++], *arg;
770  const OptionDef *po;
771  int ret;
772 
773  av_log(NULL, AV_LOG_DEBUG, "Reading option '%s' ...", opt);
774 
775  if (opt[0] == '-' && opt[1] == '-' && !opt[2]) {
776  dashdash = optindex;
777  continue;
778  }
779  /* unnamed group separators, e.g. output filename */
780  if (opt[0] != '-' || !opt[1] || dashdash+1 == optindex) {
781  finish_group(octx, 0, opt);
782  av_log(NULL, AV_LOG_DEBUG, " matched as %s.\n", groups[0].name);
783  continue;
784  }
785  opt++;
786 
787 #define GET_ARG(arg) \
788 do { \
789  arg = argv[optindex++]; \
790  if (!arg) { \
791  av_log(NULL, AV_LOG_ERROR, "Missing argument for option '%s'.\n", opt);\
792  return AVERROR(EINVAL); \
793  } \
794 } while (0)
795 
796  /* named group separators, e.g. -i */
797  if ((ret = match_group_separator(groups, nb_groups, opt)) >= 0) {
798  GET_ARG(arg);
799  finish_group(octx, ret, arg);
800  av_log(NULL, AV_LOG_DEBUG, " matched as %s with argument '%s'.\n",
801  groups[ret].name, arg);
802  continue;
803  }
804 
805  /* normal options */
806  po = find_option(options, opt);
807  if (po->name) {
808  if (po->flags & OPT_EXIT) {
809  /* optional argument, e.g. -h */
810  arg = argv[optindex++];
811  } else if (po->flags & HAS_ARG) {
812  GET_ARG(arg);
813  } else {
814  arg = "1";
815  }
816 
817  add_opt(octx, po, opt, arg);
818  av_log(NULL, AV_LOG_DEBUG, " matched as option '%s' (%s) with "
819  "argument '%s'.\n", po->name, po->help, arg);
820  continue;
821  }
822 
823  /* AVOptions */
824  if (argv[optindex]) {
825  ret = opt_default(NULL, opt, argv[optindex]);
826  if (ret >= 0) {
827  av_log(NULL, AV_LOG_DEBUG, " matched as AVOption '%s' with "
828  "argument '%s'.\n", opt, argv[optindex]);
829  optindex++;
830  continue;
831  } else if (ret != AVERROR_OPTION_NOT_FOUND) {
832  av_log(NULL, AV_LOG_ERROR, "Error parsing option '%s' "
833  "with argument '%s'.\n", opt, argv[optindex]);
834  return ret;
835  }
836  }
837 
838  /* boolean -nofoo options */
839  if (opt[0] == 'n' && opt[1] == 'o' &&
840  (po = find_option(options, opt + 2)) &&
841  po->name && po->flags & OPT_BOOL) {
842  add_opt(octx, po, opt, "0");
843  av_log(NULL, AV_LOG_DEBUG, " matched as option '%s' (%s) with "
844  "argument 0.\n", po->name, po->help);
845  continue;
846  }
847 
848  av_log(NULL, AV_LOG_ERROR, "Unrecognized option '%s'.\n", opt);
850  }
851 
853  av_log(NULL, AV_LOG_WARNING, "Trailing option(s) found in the "
854  "command: may be ignored.\n");
855 
856  av_log(NULL, AV_LOG_DEBUG, "Finished splitting the commandline.\n");
857 
858  return 0;
859 }
860 
861 int opt_cpuflags(void *optctx, const char *opt, const char *arg)
862 {
863  int ret;
864  unsigned flags = av_get_cpu_flags();
865 
866  if ((ret = av_parse_cpu_caps(&flags, arg)) < 0)
867  return ret;
868 
870  return 0;
871 }
872 
873 int opt_loglevel(void *optctx, const char *opt, const char *arg)
874 {
875  const struct { const char *name; int level; } log_levels[] = {
876  { "quiet" , AV_LOG_QUIET },
877  { "panic" , AV_LOG_PANIC },
878  { "fatal" , AV_LOG_FATAL },
879  { "error" , AV_LOG_ERROR },
880  { "warning", AV_LOG_WARNING },
881  { "info" , AV_LOG_INFO },
882  { "verbose", AV_LOG_VERBOSE },
883  { "debug" , AV_LOG_DEBUG },
884  { "trace" , AV_LOG_TRACE },
885  };
886  const char *token;
887  char *tail;
888  int flags = av_log_get_flags();
889  int level = av_log_get_level();
890  int cmd, i = 0;
891 
892  av_assert0(arg);
893  while (*arg) {
894  token = arg;
895  if (*token == '+' || *token == '-') {
896  cmd = *token++;
897  } else {
898  cmd = 0;
899  }
900  if (!i && !cmd) {
901  flags = 0; /* missing relative prefix, build absolute value */
902  }
903  if (!strncmp(token, "repeat", 6)) {
904  if (cmd == '-') {
906  } else {
908  }
909  arg = token + 6;
910  } else if (!strncmp(token, "level", 5)) {
911  if (cmd == '-') {
913  } else {
915  }
916  arg = token + 5;
917  } else {
918  break;
919  }
920  i++;
921  }
922  if (!*arg) {
923  goto end;
924  } else if (*arg == '+') {
925  arg++;
926  } else if (!i) {
927  flags = av_log_get_flags(); /* level value without prefix, reset flags */
928  }
929 
930  for (i = 0; i < FF_ARRAY_ELEMS(log_levels); i++) {
931  if (!strcmp(log_levels[i].name, arg)) {
932  level = log_levels[i].level;
933  goto end;
934  }
935  }
936 
937  level = strtol(arg, &tail, 10);
938  if (*tail) {
939  av_log(NULL, AV_LOG_FATAL, "Invalid loglevel \"%s\". "
940  "Possible levels are numbers or:\n", arg);
941  for (i = 0; i < FF_ARRAY_ELEMS(log_levels); i++)
942  av_log(NULL, AV_LOG_FATAL, "\"%s\"\n", log_levels[i].name);
943  exit_program(1);
944  }
945 
946 end:
949  return 0;
950 }
951 
952 static void expand_filename_template(AVBPrint *bp, const char *template,
953  struct tm *tm)
954 {
955  int c;
956 
957  while ((c = *(template++))) {
958  if (c == '%') {
959  if (!(c = *(template++)))
960  break;
961  switch (c) {
962  case 'p':
963  av_bprintf(bp, "%s", program_name);
964  break;
965  case 't':
966  av_bprintf(bp, "%04d%02d%02d-%02d%02d%02d",
967  tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday,
968  tm->tm_hour, tm->tm_min, tm->tm_sec);
969  break;
970  case '%':
971  av_bprint_chars(bp, c, 1);
972  break;
973  }
974  } else {
975  av_bprint_chars(bp, c, 1);
976  }
977  }
978 }
979 
980 static int init_report(const char *env)
981 {
982  char *filename_template = NULL;
983  char *key, *val;
984  int ret, count = 0;
985  int prog_loglevel, envlevel = 0;
986  time_t now;
987  struct tm *tm;
988  AVBPrint filename;
989 
990  if (report_file) /* already opened */
991  return 0;
992  time(&now);
993  tm = localtime(&now);
994 
995  while (env && *env) {
996  if ((ret = av_opt_get_key_value(&env, "=", ":", 0, &key, &val)) < 0) {
997  if (count)
999  "Failed to parse FFREPORT environment variable: %s\n",
1000  av_err2str(ret));
1001  break;
1002  }
1003  if (*env)
1004  env++;
1005  count++;
1006  if (!strcmp(key, "file")) {
1007  av_free(filename_template);
1008  filename_template = val;
1009  val = NULL;
1010  } else if (!strcmp(key, "level")) {
1011  char *tail;
1012  report_file_level = strtol(val, &tail, 10);
1013  if (*tail) {
1014  av_log(NULL, AV_LOG_FATAL, "Invalid report file level\n");
1015  exit_program(1);
1016  }
1017  envlevel = 1;
1018  } else {
1019  av_log(NULL, AV_LOG_ERROR, "Unknown key '%s' in FFREPORT\n", key);
1020  }
1021  av_free(val);
1022  av_free(key);
1023  }
1024 
1026  expand_filename_template(&filename,
1027  av_x_if_null(filename_template, "%p-%t.log"), tm);
1028  av_free(filename_template);
1029  if (!av_bprint_is_complete(&filename)) {
1030  av_log(NULL, AV_LOG_ERROR, "Out of memory building report file name\n");
1031  return AVERROR(ENOMEM);
1032  }
1033 
1034  prog_loglevel = av_log_get_level();
1035  if (!envlevel)
1036  report_file_level = FFMAX(report_file_level, prog_loglevel);
1037 
1038  report_file = fopen(filename.str, "w");
1039  if (!report_file) {
1040  int ret = AVERROR(errno);
1041  av_log(NULL, AV_LOG_ERROR, "Failed to open report \"%s\": %s\n",
1042  filename.str, strerror(errno));
1043  return ret;
1044  }
1047  "%s started on %04d-%02d-%02d at %02d:%02d:%02d\n"
1048  "Report written to \"%s\"\n"
1049  "Log level: %d\n",
1050  program_name,
1051  tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday,
1052  tm->tm_hour, tm->tm_min, tm->tm_sec,
1053  filename.str, report_file_level);
1054  av_bprint_finalize(&filename, NULL);
1055  return 0;
1056 }
1057 
1058 int opt_report(void *optctx, const char *opt, const char *arg)
1059 {
1060  return init_report(NULL);
1061 }
1062 
1063 int opt_max_alloc(void *optctx, const char *opt, const char *arg)
1064 {
1065  char *tail;
1066  size_t max;
1067 
1068  max = strtol(arg, &tail, 10);
1069  if (*tail) {
1070  av_log(NULL, AV_LOG_FATAL, "Invalid max_alloc \"%s\".\n", arg);
1071  exit_program(1);
1072  }
1073  av_max_alloc(max);
1074  return 0;
1075 }
1076 
1077 int opt_timelimit(void *optctx, const char *opt, const char *arg)
1078 {
1079 #if HAVE_SETRLIMIT
1080  int lim = parse_number_or_die(opt, arg, OPT_INT64, 0, INT_MAX);
1081  struct rlimit rl = { lim, lim + 1 };
1082  if (setrlimit(RLIMIT_CPU, &rl))
1083  perror("setrlimit");
1084 #else
1085  av_log(NULL, AV_LOG_WARNING, "-%s not implemented on this OS\n", opt);
1086 #endif
1087  return 0;
1088 }
1089 
1090 void print_error(const char *filename, int err)
1091 {
1092  char errbuf[128];
1093  const char *errbuf_ptr = errbuf;
1094 
1095  if (av_strerror(err, errbuf, sizeof(errbuf)) < 0)
1096  errbuf_ptr = strerror(AVUNERROR(err));
1097  av_log(NULL, AV_LOG_ERROR, "%s: %s\n", filename, errbuf_ptr);
1098 }
1099 
1100 static int warned_cfg = 0;
1101 
1102 #define INDENT 1
1103 #define SHOW_VERSION 2
1104 #define SHOW_CONFIG 0
1105 #define SHOW_COPYRIGHT 8
1106 
1107 #define PRINT_LIB_INFO(libname, LIBNAME, flags, level) \
1108  if (CONFIG_##LIBNAME) { \
1109  const char *indent = flags & INDENT? " " : ""; \
1110  if (flags & SHOW_VERSION) { \
1111  unsigned int version = libname##_version(); \
1112  av_log(NULL, level, \
1113  "%slib%-11s %2d.%3d.%3d / %2d.%3d.%3d\n", \
1114  indent, #libname, \
1115  LIB##LIBNAME##_VERSION_MAJOR, \
1116  LIB##LIBNAME##_VERSION_MINOR, \
1117  LIB##LIBNAME##_VERSION_MICRO, \
1118  AV_VERSION_MAJOR(version), AV_VERSION_MINOR(version),\
1119  AV_VERSION_MICRO(version)); \
1120  } \
1121  if (flags & SHOW_CONFIG) { \
1122  const char *cfg = libname##_configuration(); \
1123  if (strcmp(FFMPEG_CONFIGURATION, cfg)) { \
1124  if (!warned_cfg) { \
1125  av_log(NULL, level, \
1126  "%sWARNING: library configuration mismatch\n", \
1127  indent); \
1128  warned_cfg = 1; \
1129  } \
1130  av_log(NULL, level, "%s%-11s configuration: %s\n", \
1131  indent, #libname, cfg); \
1132  } \
1133  } \
1134  } \
1135 
1136 static void print_all_libs_info(int flags, int level)
1137 {
1138  PRINT_LIB_INFO(avutil, AVUTIL, flags, level);
1139  PRINT_LIB_INFO(avcodec, AVCODEC, flags, level);
1140  PRINT_LIB_INFO(avformat, AVFORMAT, flags, level);
1141  PRINT_LIB_INFO(avdevice, AVDEVICE, flags, level);
1142  PRINT_LIB_INFO(avfilter, AVFILTER, flags, level);
1143  PRINT_LIB_INFO(avresample, AVRESAMPLE, flags, level);
1144  PRINT_LIB_INFO(swscale, SWSCALE, flags, level);
1145  PRINT_LIB_INFO(swresample, SWRESAMPLE, flags, level);
1146  PRINT_LIB_INFO(postproc, POSTPROC, flags, level);
1147 }
1148 
1149 static void print_program_info(int flags, int level)
1150 {
1151  const char *indent = flags & INDENT? " " : "";
1152 
1153  av_log(NULL, level, "%s version %s", program_name, FFMPEG_VERSION);
1154  if (flags & SHOW_COPYRIGHT)
1155  av_log(NULL, level, " Copyright (c) %d-%d the FFmpeg developers",
1157  av_log(NULL, level, "\n");
1158  av_log(NULL, level, "%sbuilt with %s\n", indent, CC_IDENT);
1159 
1160  av_log(NULL, level, "%sconfiguration: %s\n", indent, FFMPEG_CONFIGURATION);
1161 }
1162 
1163 static void print_buildconf(int flags, int level)
1164 {
1165  const char *indent = flags & INDENT ? " " : "";
1166  char str[] = { FFMPEG_CONFIGURATION };
1167  char *conflist, *remove_tilde, *splitconf;
1168 
1169  // Change all the ' --' strings to '~--' so that
1170  // they can be identified as tokens.
1171  while ((conflist = strstr(str, " --")) != NULL) {
1172  conflist[0] = '~';
1173  }
1174 
1175  // Compensate for the weirdness this would cause
1176  // when passing 'pkg-config --static'.
1177  while ((remove_tilde = strstr(str, "pkg-config~")) != NULL) {
1178  remove_tilde[sizeof("pkg-config~") - 2] = ' ';
1179  }
1180 
1181  splitconf = strtok(str, "~");
1182  av_log(NULL, level, "\n%sconfiguration:\n", indent);
1183  while (splitconf != NULL) {
1184  av_log(NULL, level, "%s%s%s\n", indent, indent, splitconf);
1185  splitconf = strtok(NULL, "~");
1186  }
1187 }
1188 
1189 void show_banner(int argc, char **argv, const OptionDef *options)
1190 {
1191  int idx = locate_option(argc, argv, options, "version");
1192  if (hide_banner || idx)
1193  return;
1194 
1198 }
1199 
1200 int show_version(void *optctx, const char *opt, const char *arg)
1201 {
1205 
1206  return 0;
1207 }
1208 
1209 int show_buildconf(void *optctx, const char *opt, const char *arg)
1210 {
1213 
1214  return 0;
1215 }
1216 
1217 int show_license(void *optctx, const char *opt, const char *arg)
1218 {
1219 #if CONFIG_NONFREE
1220  printf(
1221  "This version of %s has nonfree parts compiled in.\n"
1222  "Therefore it is not legally redistributable.\n",
1223  program_name );
1224 #elif CONFIG_GPLV3
1225  printf(
1226  "%s is free software; you can redistribute it and/or modify\n"
1227  "it under the terms of the GNU General Public License as published by\n"
1228  "the Free Software Foundation; either version 3 of the License, or\n"
1229  "(at your option) any later version.\n"
1230  "\n"
1231  "%s is distributed in the hope that it will be useful,\n"
1232  "but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
1233  "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n"
1234  "GNU General Public License for more details.\n"
1235  "\n"
1236  "You should have received a copy of the GNU General Public License\n"
1237  "along with %s. If not, see <http://www.gnu.org/licenses/>.\n",
1239 #elif CONFIG_GPL
1240  printf(
1241  "%s is free software; you can redistribute it and/or modify\n"
1242  "it under the terms of the GNU General Public License as published by\n"
1243  "the Free Software Foundation; either version 2 of the License, or\n"
1244  "(at your option) any later version.\n"
1245  "\n"
1246  "%s is distributed in the hope that it will be useful,\n"
1247  "but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
1248  "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n"
1249  "GNU General Public License for more details.\n"
1250  "\n"
1251  "You should have received a copy of the GNU General Public License\n"
1252  "along with %s; if not, write to the Free Software\n"
1253  "Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA\n",
1255 #elif CONFIG_LGPLV3
1256  printf(
1257  "%s is free software; you can redistribute it and/or modify\n"
1258  "it under the terms of the GNU Lesser General Public License as published by\n"
1259  "the Free Software Foundation; either version 3 of the License, or\n"
1260  "(at your option) any later version.\n"
1261  "\n"
1262  "%s is distributed in the hope that it will be useful,\n"
1263  "but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
1264  "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n"
1265  "GNU Lesser General Public License for more details.\n"
1266  "\n"
1267  "You should have received a copy of the GNU Lesser General Public License\n"
1268  "along with %s. If not, see <http://www.gnu.org/licenses/>.\n",
1270 #else
1271  printf(
1272  "%s is free software; you can redistribute it and/or\n"
1273  "modify it under the terms of the GNU Lesser General Public\n"
1274  "License as published by the Free Software Foundation; either\n"
1275  "version 2.1 of the License, or (at your option) any later version.\n"
1276  "\n"
1277  "%s is distributed in the hope that it will be useful,\n"
1278  "but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
1279  "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n"
1280  "Lesser General Public License for more details.\n"
1281  "\n"
1282  "You should have received a copy of the GNU Lesser General Public\n"
1283  "License along with %s; if not, write to the Free Software\n"
1284  "Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA\n",
1286 #endif
1287 
1288  return 0;
1289 }
1290 
1291 static int is_device(const AVClass *avclass)
1292 {
1293  if (!avclass)
1294  return 0;
1295  return AV_IS_INPUT_DEVICE(avclass->category) || AV_IS_OUTPUT_DEVICE(avclass->category);
1296 }
1297 
1298 static int show_formats_devices(void *optctx, const char *opt, const char *arg, int device_only, int muxdemuxers)
1299 {
1300  void *ifmt_opaque = NULL;
1301  const AVInputFormat *ifmt = NULL;
1302  void *ofmt_opaque = NULL;
1303  const AVOutputFormat *ofmt = NULL;
1304  const char *last_name;
1305  int is_dev;
1306 
1307  printf("%s\n"
1308  " D. = Demuxing supported\n"
1309  " .E = Muxing supported\n"
1310  " --\n", device_only ? "Devices:" : "File formats:");
1311  last_name = "000";
1312  for (;;) {
1313  int decode = 0;
1314  int encode = 0;
1315  const char *name = NULL;
1316  const char *long_name = NULL;
1317 
1318  if (muxdemuxers !=SHOW_DEMUXERS) {
1319  ofmt_opaque = NULL;
1320  while ((ofmt = av_muxer_iterate(&ofmt_opaque))) {
1321  is_dev = is_device(ofmt->priv_class);
1322  if (!is_dev && device_only)
1323  continue;
1324  if ((!name || strcmp(ofmt->name, name) < 0) &&
1325  strcmp(ofmt->name, last_name) > 0) {
1326  name = ofmt->name;
1327  long_name = ofmt->long_name;
1328  encode = 1;
1329  }
1330  }
1331  }
1332  if (muxdemuxers != SHOW_MUXERS) {
1333  ifmt_opaque = NULL;
1334  while ((ifmt = av_demuxer_iterate(&ifmt_opaque))) {
1335  is_dev = is_device(ifmt->priv_class);
1336  if (!is_dev && device_only)
1337  continue;
1338  if ((!name || strcmp(ifmt->name, name) < 0) &&
1339  strcmp(ifmt->name, last_name) > 0) {
1340  name = ifmt->name;
1341  long_name = ifmt->long_name;
1342  encode = 0;
1343  }
1344  if (name && strcmp(ifmt->name, name) == 0)
1345  decode = 1;
1346  }
1347  }
1348  if (!name)
1349  break;
1350  last_name = name;
1351 
1352  printf(" %s%s %-15s %s\n",
1353  decode ? "D" : " ",
1354  encode ? "E" : " ",
1355  name,
1356  long_name ? long_name:" ");
1357  }
1358  return 0;
1359 }
1360 
1361 int show_formats(void *optctx, const char *opt, const char *arg)
1362 {
1363  return show_formats_devices(optctx, opt, arg, 0, SHOW_DEFAULT);
1364 }
1365 
1366 int show_muxers(void *optctx, const char *opt, const char *arg)
1367 {
1368  return show_formats_devices(optctx, opt, arg, 0, SHOW_MUXERS);
1369 }
1370 
1371 int show_demuxers(void *optctx, const char *opt, const char *arg)
1372 {
1373  return show_formats_devices(optctx, opt, arg, 0, SHOW_DEMUXERS);
1374 }
1375 
1376 int show_devices(void *optctx, const char *opt, const char *arg)
1377 {
1378  return show_formats_devices(optctx, opt, arg, 1, SHOW_DEFAULT);
1379 }
1380 
1381 #define PRINT_CODEC_SUPPORTED(codec, field, type, list_name, term, get_name) \
1382  if (codec->field) { \
1383  const type *p = codec->field; \
1384  \
1385  printf(" Supported " list_name ":"); \
1386  while (*p != term) { \
1387  get_name(*p); \
1388  printf(" %s", name); \
1389  p++; \
1390  } \
1391  printf("\n"); \
1392  } \
1393 
1394 static void print_codec(const AVCodec *c)
1395 {
1396  int encoder = av_codec_is_encoder(c);
1397 
1398  printf("%s %s [%s]:\n", encoder ? "Encoder" : "Decoder", c->name,
1399  c->long_name ? c->long_name : "");
1400 
1401  printf(" General capabilities: ");
1402  if (c->capabilities & AV_CODEC_CAP_DRAW_HORIZ_BAND)
1403  printf("horizband ");
1404  if (c->capabilities & AV_CODEC_CAP_DR1)
1405  printf("dr1 ");
1406  if (c->capabilities & AV_CODEC_CAP_TRUNCATED)
1407  printf("trunc ");
1408  if (c->capabilities & AV_CODEC_CAP_DELAY)
1409  printf("delay ");
1410  if (c->capabilities & AV_CODEC_CAP_SMALL_LAST_FRAME)
1411  printf("small ");
1412  if (c->capabilities & AV_CODEC_CAP_SUBFRAMES)
1413  printf("subframes ");
1414  if (c->capabilities & AV_CODEC_CAP_EXPERIMENTAL)
1415  printf("exp ");
1416  if (c->capabilities & AV_CODEC_CAP_CHANNEL_CONF)
1417  printf("chconf ");
1418  if (c->capabilities & AV_CODEC_CAP_PARAM_CHANGE)
1419  printf("paramchange ");
1420  if (c->capabilities & AV_CODEC_CAP_VARIABLE_FRAME_SIZE)
1421  printf("variable ");
1422  if (c->capabilities & (AV_CODEC_CAP_FRAME_THREADS |
1425  printf("threads ");
1426  if (c->capabilities & AV_CODEC_CAP_AVOID_PROBING)
1427  printf("avoidprobe ");
1428  if (c->capabilities & AV_CODEC_CAP_HARDWARE)
1429  printf("hardware ");
1430  if (c->capabilities & AV_CODEC_CAP_HYBRID)
1431  printf("hybrid ");
1432  if (!c->capabilities)
1433  printf("none");
1434  printf("\n");
1435 
1436  if (c->type == AVMEDIA_TYPE_VIDEO ||
1437  c->type == AVMEDIA_TYPE_AUDIO) {
1438  printf(" Threading capabilities: ");
1439  switch (c->capabilities & (AV_CODEC_CAP_FRAME_THREADS |
1443  AV_CODEC_CAP_SLICE_THREADS: printf("frame and slice"); break;
1444  case AV_CODEC_CAP_FRAME_THREADS: printf("frame"); break;
1445  case AV_CODEC_CAP_SLICE_THREADS: printf("slice"); break;
1446  case AV_CODEC_CAP_OTHER_THREADS: printf("other"); break;
1447  default: printf("none"); break;
1448  }
1449  printf("\n");
1450  }
1451 
1452  if (avcodec_get_hw_config(c, 0)) {
1453  printf(" Supported hardware devices: ");
1454  for (int i = 0;; i++) {
1455  const AVCodecHWConfig *config = avcodec_get_hw_config(c, i);
1456  if (!config)
1457  break;
1458  printf("%s ", av_hwdevice_get_type_name(config->device_type));
1459  }
1460  printf("\n");
1461  }
1462 
1463  if (c->supported_framerates) {
1464  const AVRational *fps = c->supported_framerates;
1465 
1466  printf(" Supported framerates:");
1467  while (fps->num) {
1468  printf(" %d/%d", fps->num, fps->den);
1469  fps++;
1470  }
1471  printf("\n");
1472  }
1473  PRINT_CODEC_SUPPORTED(c, pix_fmts, enum AVPixelFormat, "pixel formats",
1475  PRINT_CODEC_SUPPORTED(c, supported_samplerates, int, "sample rates", 0,
1477  PRINT_CODEC_SUPPORTED(c, sample_fmts, enum AVSampleFormat, "sample formats",
1479  PRINT_CODEC_SUPPORTED(c, channel_layouts, uint64_t, "channel layouts",
1480  0, GET_CH_LAYOUT_DESC);
1481 
1482  if (c->priv_class) {
1483  show_help_children(c->priv_class,
1486  }
1487 }
1488 
1490 {
1491  switch (type) {
1492  case AVMEDIA_TYPE_VIDEO: return 'V';
1493  case AVMEDIA_TYPE_AUDIO: return 'A';
1494  case AVMEDIA_TYPE_DATA: return 'D';
1495  case AVMEDIA_TYPE_SUBTITLE: return 'S';
1496  case AVMEDIA_TYPE_ATTACHMENT:return 'T';
1497  default: return '?';
1498  }
1499 }
1500 
1501 static const AVCodec *next_codec_for_id(enum AVCodecID id, void **iter,
1502  int encoder)
1503 {
1504  const AVCodec *c;
1505  while ((c = av_codec_iterate(iter))) {
1506  if (c->id == id &&
1507  (encoder ? av_codec_is_encoder(c) : av_codec_is_decoder(c)))
1508  return c;
1509  }
1510  return NULL;
1511 }
1512 
1513 static int compare_codec_desc(const void *a, const void *b)
1514 {
1515  const AVCodecDescriptor * const *da = a;
1516  const AVCodecDescriptor * const *db = b;
1517 
1518  return (*da)->type != (*db)->type ? FFDIFFSIGN((*da)->type, (*db)->type) :
1519  strcmp((*da)->name, (*db)->name);
1520 }
1521 
1522 static unsigned get_codecs_sorted(const AVCodecDescriptor ***rcodecs)
1523 {
1524  const AVCodecDescriptor *desc = NULL;
1525  const AVCodecDescriptor **codecs;
1526  unsigned nb_codecs = 0, i = 0;
1527 
1528  while ((desc = avcodec_descriptor_next(desc)))
1529  nb_codecs++;
1530  if (!(codecs = av_calloc(nb_codecs, sizeof(*codecs)))) {
1531  av_log(NULL, AV_LOG_ERROR, "Out of memory\n");
1532  exit_program(1);
1533  }
1534  desc = NULL;
1535  while ((desc = avcodec_descriptor_next(desc)))
1536  codecs[i++] = desc;
1537  av_assert0(i == nb_codecs);
1538  qsort(codecs, nb_codecs, sizeof(*codecs), compare_codec_desc);
1539  *rcodecs = codecs;
1540  return nb_codecs;
1541 }
1542 
1543 static void print_codecs_for_id(enum AVCodecID id, int encoder)
1544 {
1545  void *iter = NULL;
1546  const AVCodec *codec;
1547 
1548  printf(" (%s: ", encoder ? "encoders" : "decoders");
1549 
1550  while ((codec = next_codec_for_id(id, &iter, encoder)))
1551  printf("%s ", codec->name);
1552 
1553  printf(")");
1554 }
1555 
1556 int show_codecs(void *optctx, const char *opt, const char *arg)
1557 {
1558  const AVCodecDescriptor **codecs;
1559  unsigned i, nb_codecs = get_codecs_sorted(&codecs);
1560 
1561  printf("Codecs:\n"
1562  " D..... = Decoding supported\n"
1563  " .E.... = Encoding supported\n"
1564  " ..V... = Video codec\n"
1565  " ..A... = Audio codec\n"
1566  " ..S... = Subtitle codec\n"
1567  " ...I.. = Intra frame-only codec\n"
1568  " ....L. = Lossy compression\n"
1569  " .....S = Lossless compression\n"
1570  " -------\n");
1571  for (i = 0; i < nb_codecs; i++) {
1572  const AVCodecDescriptor *desc = codecs[i];
1573  const AVCodec *codec;
1574  void *iter = NULL;
1575 
1576  if (strstr(desc->name, "_deprecated"))
1577  continue;
1578 
1579  printf(" ");
1580  printf(avcodec_find_decoder(desc->id) ? "D" : ".");
1581  printf(avcodec_find_encoder(desc->id) ? "E" : ".");
1582 
1583  printf("%c", get_media_type_char(desc->type));
1584  printf((desc->props & AV_CODEC_PROP_INTRA_ONLY) ? "I" : ".");
1585  printf((desc->props & AV_CODEC_PROP_LOSSY) ? "L" : ".");
1586  printf((desc->props & AV_CODEC_PROP_LOSSLESS) ? "S" : ".");
1587 
1588  printf(" %-20s %s", desc->name, desc->long_name ? desc->long_name : "");
1589 
1590  /* print decoders/encoders when there's more than one or their
1591  * names are different from codec name */
1592  while ((codec = next_codec_for_id(desc->id, &iter, 0))) {
1593  if (strcmp(codec->name, desc->name)) {
1594  print_codecs_for_id(desc->id, 0);
1595  break;
1596  }
1597  }
1598  iter = NULL;
1599  while ((codec = next_codec_for_id(desc->id, &iter, 1))) {
1600  if (strcmp(codec->name, desc->name)) {
1601  print_codecs_for_id(desc->id, 1);
1602  break;
1603  }
1604  }
1605 
1606  printf("\n");
1607  }
1608  av_free(codecs);
1609  return 0;
1610 }
1611 
1612 static void print_codecs(int encoder)
1613 {
1614  const AVCodecDescriptor **codecs;
1615  unsigned i, nb_codecs = get_codecs_sorted(&codecs);
1616 
1617  printf("%s:\n"
1618  " V..... = Video\n"
1619  " A..... = Audio\n"
1620  " S..... = Subtitle\n"
1621  " .F.... = Frame-level multithreading\n"
1622  " ..S... = Slice-level multithreading\n"
1623  " ...X.. = Codec is experimental\n"
1624  " ....B. = Supports draw_horiz_band\n"
1625  " .....D = Supports direct rendering method 1\n"
1626  " ------\n",
1627  encoder ? "Encoders" : "Decoders");
1628  for (i = 0; i < nb_codecs; i++) {
1629  const AVCodecDescriptor *desc = codecs[i];
1630  const AVCodec *codec;
1631  void *iter = NULL;
1632 
1633  while ((codec = next_codec_for_id(desc->id, &iter, encoder))) {
1634  printf(" %c", get_media_type_char(desc->type));
1635  printf((codec->capabilities & AV_CODEC_CAP_FRAME_THREADS) ? "F" : ".");
1636  printf((codec->capabilities & AV_CODEC_CAP_SLICE_THREADS) ? "S" : ".");
1637  printf((codec->capabilities & AV_CODEC_CAP_EXPERIMENTAL) ? "X" : ".");
1638  printf((codec->capabilities & AV_CODEC_CAP_DRAW_HORIZ_BAND)?"B" : ".");
1639  printf((codec->capabilities & AV_CODEC_CAP_DR1) ? "D" : ".");
1640 
1641  printf(" %-20s %s", codec->name, codec->long_name ? codec->long_name : "");
1642  if (strcmp(codec->name, desc->name))
1643  printf(" (codec %s)", desc->name);
1644 
1645  printf("\n");
1646  }
1647  }
1648  av_free(codecs);
1649 }
1650 
1651 int show_decoders(void *optctx, const char *opt, const char *arg)
1652 {
1653  print_codecs(0);
1654  return 0;
1655 }
1656 
1657 int show_encoders(void *optctx, const char *opt, const char *arg)
1658 {
1659  print_codecs(1);
1660  return 0;
1661 }
1662 
1663 int show_bsfs(void *optctx, const char *opt, const char *arg)
1664 {
1665  const AVBitStreamFilter *bsf = NULL;
1666  void *opaque = NULL;
1667 
1668  printf("Bitstream filters:\n");
1669  while ((bsf = av_bsf_iterate(&opaque)))
1670  printf("%s\n", bsf->name);
1671  printf("\n");
1672  return 0;
1673 }
1674 
1675 int show_protocols(void *optctx, const char *opt, const char *arg)
1676 {
1677  void *opaque = NULL;
1678  const char *name;
1679 
1680  printf("Supported file protocols:\n"
1681  "Input:\n");
1682  while ((name = avio_enum_protocols(&opaque, 0)))
1683  printf(" %s\n", name);
1684  printf("Output:\n");
1685  while ((name = avio_enum_protocols(&opaque, 1)))
1686  printf(" %s\n", name);
1687  return 0;
1688 }
1689 
1690 int show_filters(void *optctx, const char *opt, const char *arg)
1691 {
1692 #if CONFIG_AVFILTER
1693  const AVFilter *filter = NULL;
1694  char descr[64], *descr_cur;
1695  void *opaque = NULL;
1696  int i, j;
1697  const AVFilterPad *pad;
1698 
1699  printf("Filters:\n"
1700  " T.. = Timeline support\n"
1701  " .S. = Slice threading\n"
1702  " ..C = Command support\n"
1703  " A = Audio input/output\n"
1704  " V = Video input/output\n"
1705  " N = Dynamic number and/or type of input/output\n"
1706  " | = Source or sink filter\n");
1707  while ((filter = av_filter_iterate(&opaque))) {
1708  descr_cur = descr;
1709  for (i = 0; i < 2; i++) {
1710  if (i) {
1711  *(descr_cur++) = '-';
1712  *(descr_cur++) = '>';
1713  }
1714  pad = i ? filter->outputs : filter->inputs;
1715  for (j = 0; pad && avfilter_pad_get_name(pad, j); j++) {
1716  if (descr_cur >= descr + sizeof(descr) - 4)
1717  break;
1718  *(descr_cur++) = get_media_type_char(avfilter_pad_get_type(pad, j));
1719  }
1720  if (!j)
1721  *(descr_cur++) = ((!i && (filter->flags & AVFILTER_FLAG_DYNAMIC_INPUTS)) ||
1722  ( i && (filter->flags & AVFILTER_FLAG_DYNAMIC_OUTPUTS))) ? 'N' : '|';
1723  }
1724  *descr_cur = 0;
1725  printf(" %c%c%c %-17s %-10s %s\n",
1726  filter->flags & AVFILTER_FLAG_SUPPORT_TIMELINE ? 'T' : '.',
1727  filter->flags & AVFILTER_FLAG_SLICE_THREADS ? 'S' : '.',
1728  filter->process_command ? 'C' : '.',
1729  filter->name, descr, filter->description);
1730  }
1731 #else
1732  printf("No filters available: libavfilter disabled\n");
1733 #endif
1734  return 0;
1735 }
1736 
1737 int show_colors(void *optctx, const char *opt, const char *arg)
1738 {
1739  const char *name;
1740  const uint8_t *rgb;
1741  int i;
1742 
1743  printf("%-32s #RRGGBB\n", "name");
1744 
1745  for (i = 0; name = av_get_known_color_name(i, &rgb); i++)
1746  printf("%-32s #%02x%02x%02x\n", name, rgb[0], rgb[1], rgb[2]);
1747 
1748  return 0;
1749 }
1750 
1751 int show_pix_fmts(void *optctx, const char *opt, const char *arg)
1752 {
1753  const AVPixFmtDescriptor *pix_desc = NULL;
1754 
1755  printf("Pixel formats:\n"
1756  "I.... = Supported Input format for conversion\n"
1757  ".O... = Supported Output format for conversion\n"
1758  "..H.. = Hardware accelerated format\n"
1759  "...P. = Paletted format\n"
1760  "....B = Bitstream format\n"
1761  "FLAGS NAME NB_COMPONENTS BITS_PER_PIXEL\n"
1762  "-----\n");
1763 
1764 #if !CONFIG_SWSCALE
1765 # define sws_isSupportedInput(x) 0
1766 # define sws_isSupportedOutput(x) 0
1767 #endif
1768 
1769  while ((pix_desc = av_pix_fmt_desc_next(pix_desc))) {
1771  printf("%c%c%c%c%c %-16s %d %2d\n",
1772  sws_isSupportedInput (pix_fmt) ? 'I' : '.',
1773  sws_isSupportedOutput(pix_fmt) ? 'O' : '.',
1774  pix_desc->flags & AV_PIX_FMT_FLAG_HWACCEL ? 'H' : '.',
1775  pix_desc->flags & AV_PIX_FMT_FLAG_PAL ? 'P' : '.',
1776  pix_desc->flags & AV_PIX_FMT_FLAG_BITSTREAM ? 'B' : '.',
1777  pix_desc->name,
1778  pix_desc->nb_components,
1779  av_get_bits_per_pixel(pix_desc));
1780  }
1781  return 0;
1782 }
1783 
1784 int show_layouts(void *optctx, const char *opt, const char *arg)
1785 {
1786  int i = 0;
1787  uint64_t layout, j;
1788  const char *name, *descr;
1789 
1790  printf("Individual channels:\n"
1791  "NAME DESCRIPTION\n");
1792  for (i = 0; i < 63; i++) {
1793  name = av_get_channel_name((uint64_t)1 << i);
1794  if (!name)
1795  continue;
1796  descr = av_get_channel_description((uint64_t)1 << i);
1797  printf("%-14s %s\n", name, descr);
1798  }
1799  printf("\nStandard channel layouts:\n"
1800  "NAME DECOMPOSITION\n");
1801  for (i = 0; !av_get_standard_channel_layout(i, &layout, &name); i++) {
1802  if (name) {
1803  printf("%-14s ", name);
1804  for (j = 1; j; j <<= 1)
1805  if ((layout & j))
1806  printf("%s%s", (layout & (j - 1)) ? "+" : "", av_get_channel_name(j));
1807  printf("\n");
1808  }
1809  }
1810  return 0;
1811 }
1812 
1813 int show_sample_fmts(void *optctx, const char *opt, const char *arg)
1814 {
1815  int i;
1816  char fmt_str[128];
1817  for (i = -1; i < AV_SAMPLE_FMT_NB; i++)
1818  printf("%s\n", av_get_sample_fmt_string(fmt_str, sizeof(fmt_str), i));
1819  return 0;
1820 }
1821 
1822 static void show_help_codec(const char *name, int encoder)
1823 {
1824  const AVCodecDescriptor *desc;
1825  const AVCodec *codec;
1826 
1827  if (!name) {
1828  av_log(NULL, AV_LOG_ERROR, "No codec name specified.\n");
1829  return;
1830  }
1831 
1832  codec = encoder ? avcodec_find_encoder_by_name(name) :
1834 
1835  if (codec)
1836  print_codec(codec);
1837  else if ((desc = avcodec_descriptor_get_by_name(name))) {
1838  void *iter = NULL;
1839  int printed = 0;
1840 
1841  while ((codec = next_codec_for_id(desc->id, &iter, encoder))) {
1842  printed = 1;
1843  print_codec(codec);
1844  }
1845 
1846  if (!printed) {
1847  av_log(NULL, AV_LOG_ERROR, "Codec '%s' is known to FFmpeg, "
1848  "but no %s for it are available. FFmpeg might need to be "
1849  "recompiled with additional external libraries.\n",
1850  name, encoder ? "encoders" : "decoders");
1851  }
1852  } else {
1853  av_log(NULL, AV_LOG_ERROR, "Codec '%s' is not recognized by FFmpeg.\n",
1854  name);
1855  }
1856 }
1857 
1858 static void show_help_demuxer(const char *name)
1859 {
1860  const AVInputFormat *fmt = av_find_input_format(name);
1861 
1862  if (!fmt) {
1863  av_log(NULL, AV_LOG_ERROR, "Unknown format '%s'.\n", name);
1864  return;
1865  }
1866 
1867  printf("Demuxer %s [%s]:\n", fmt->name, fmt->long_name);
1868 
1869  if (fmt->extensions)
1870  printf(" Common extensions: %s.\n", fmt->extensions);
1871 
1872  if (fmt->priv_class)
1874 }
1875 
1876 static void show_help_protocol(const char *name)
1877 {
1878  const AVClass *proto_class;
1879 
1880  if (!name) {
1881  av_log(NULL, AV_LOG_ERROR, "No protocol name specified.\n");
1882  return;
1883  }
1884 
1885  proto_class = avio_protocol_get_class(name);
1886  if (!proto_class) {
1887  av_log(NULL, AV_LOG_ERROR, "Unknown protocol '%s'.\n", name);
1888  return;
1889  }
1890 
1892 }
1893 
1894 static void show_help_muxer(const char *name)
1895 {
1896  const AVCodecDescriptor *desc;
1897  const AVOutputFormat *fmt = av_guess_format(name, NULL, NULL);
1898 
1899  if (!fmt) {
1900  av_log(NULL, AV_LOG_ERROR, "Unknown format '%s'.\n", name);
1901  return;
1902  }
1903 
1904  printf("Muxer %s [%s]:\n", fmt->name, fmt->long_name);
1905 
1906  if (fmt->extensions)
1907  printf(" Common extensions: %s.\n", fmt->extensions);
1908  if (fmt->mime_type)
1909  printf(" Mime type: %s.\n", fmt->mime_type);
1910  if (fmt->video_codec != AV_CODEC_ID_NONE &&
1912  printf(" Default video codec: %s.\n", desc->name);
1913  }
1914  if (fmt->audio_codec != AV_CODEC_ID_NONE &&
1916  printf(" Default audio codec: %s.\n", desc->name);
1917  }
1918  if (fmt->subtitle_codec != AV_CODEC_ID_NONE &&
1920  printf(" Default subtitle codec: %s.\n", desc->name);
1921  }
1922 
1923  if (fmt->priv_class)
1925 }
1926 
1927 #if CONFIG_AVFILTER
1928 static void show_help_filter(const char *name)
1929 {
1930 #if CONFIG_AVFILTER
1931  const AVFilter *f = avfilter_get_by_name(name);
1932  int i, count;
1933 
1934  if (!name) {
1935  av_log(NULL, AV_LOG_ERROR, "No filter name specified.\n");
1936  return;
1937  } else if (!f) {
1938  av_log(NULL, AV_LOG_ERROR, "Unknown filter '%s'.\n", name);
1939  return;
1940  }
1941 
1942  printf("Filter %s\n", f->name);
1943  if (f->description)
1944  printf(" %s\n", f->description);
1945 
1946  if (f->flags & AVFILTER_FLAG_SLICE_THREADS)
1947  printf(" slice threading supported\n");
1948 
1949  printf(" Inputs:\n");
1950  count = avfilter_pad_count(f->inputs);
1951  for (i = 0; i < count; i++) {
1952  printf(" #%d: %s (%s)\n", i, avfilter_pad_get_name(f->inputs, i),
1954  }
1955  if (f->flags & AVFILTER_FLAG_DYNAMIC_INPUTS)
1956  printf(" dynamic (depending on the options)\n");
1957  else if (!count)
1958  printf(" none (source filter)\n");
1959 
1960  printf(" Outputs:\n");
1961  count = avfilter_pad_count(f->outputs);
1962  for (i = 0; i < count; i++) {
1963  printf(" #%d: %s (%s)\n", i, avfilter_pad_get_name(f->outputs, i),
1965  }
1966  if (f->flags & AVFILTER_FLAG_DYNAMIC_OUTPUTS)
1967  printf(" dynamic (depending on the options)\n");
1968  else if (!count)
1969  printf(" none (sink filter)\n");
1970 
1971  if (f->priv_class)
1974  if (f->flags & AVFILTER_FLAG_SUPPORT_TIMELINE)
1975  printf("This filter has support for timeline through the 'enable' option.\n");
1976 #else
1977  av_log(NULL, AV_LOG_ERROR, "Build without libavfilter; "
1978  "can not to satisfy request\n");
1979 #endif
1980 }
1981 #endif
1982 
1983 static void show_help_bsf(const char *name)
1984 {
1986 
1987  if (!name) {
1988  av_log(NULL, AV_LOG_ERROR, "No bitstream filter name specified.\n");
1989  return;
1990  } else if (!bsf) {
1991  av_log(NULL, AV_LOG_ERROR, "Unknown bit stream filter '%s'.\n", name);
1992  return;
1993  }
1994 
1995  printf("Bit stream filter %s\n", bsf->name);
1996  PRINT_CODEC_SUPPORTED(bsf, codec_ids, enum AVCodecID, "codecs",
1998  if (bsf->priv_class)
2000 }
2001 
2002 int show_help(void *optctx, const char *opt, const char *arg)
2003 {
2004  char *topic, *par;
2006 
2007  topic = av_strdup(arg ? arg : "");
2008  if (!topic)
2009  return AVERROR(ENOMEM);
2010  par = strchr(topic, '=');
2011  if (par)
2012  *par++ = 0;
2013 
2014  if (!*topic) {
2015  show_help_default(topic, par);
2016  } else if (!strcmp(topic, "decoder")) {
2017  show_help_codec(par, 0);
2018  } else if (!strcmp(topic, "encoder")) {
2019  show_help_codec(par, 1);
2020  } else if (!strcmp(topic, "demuxer")) {
2021  show_help_demuxer(par);
2022  } else if (!strcmp(topic, "muxer")) {
2023  show_help_muxer(par);
2024  } else if (!strcmp(topic, "protocol")) {
2025  show_help_protocol(par);
2026 #if CONFIG_AVFILTER
2027  } else if (!strcmp(topic, "filter")) {
2028  show_help_filter(par);
2029 #endif
2030  } else if (!strcmp(topic, "bsf")) {
2031  show_help_bsf(par);
2032  } else {
2033  show_help_default(topic, par);
2034  }
2035 
2036  av_freep(&topic);
2037  return 0;
2038 }
2039 
2040 int read_yesno(void)
2041 {
2042  int c = getchar();
2043  int yesno = (av_toupper(c) == 'Y');
2044 
2045  while (c != '\n' && c != EOF)
2046  c = getchar();
2047 
2048  return yesno;
2049 }
2050 
2051 FILE *get_preset_file(char *filename, size_t filename_size,
2052  const char *preset_name, int is_path,
2053  const char *codec_name)
2054 {
2055  FILE *f = NULL;
2056  int i;
2057  const char *base[3] = { getenv("FFMPEG_DATADIR"),
2058  getenv("HOME"),
2059  FFMPEG_DATADIR, };
2060 
2061  if (is_path) {
2062  av_strlcpy(filename, preset_name, filename_size);
2063  f = fopen(filename, "r");
2064  } else {
2065 #if HAVE_GETMODULEHANDLE && defined(_WIN32)
2066  char datadir[MAX_PATH], *ls;
2067  base[2] = NULL;
2068 
2069  if (GetModuleFileNameA(GetModuleHandleA(NULL), datadir, sizeof(datadir) - 1))
2070  {
2071  for (ls = datadir; ls < datadir + strlen(datadir); ls++)
2072  if (*ls == '\\') *ls = '/';
2073 
2074  if (ls = strrchr(datadir, '/'))
2075  {
2076  *ls = 0;
2077  strncat(datadir, "/ffpresets", sizeof(datadir) - 1 - strlen(datadir));
2078  base[2] = datadir;
2079  }
2080  }
2081 #endif
2082  for (i = 0; i < 3 && !f; i++) {
2083  if (!base[i])
2084  continue;
2085  snprintf(filename, filename_size, "%s%s/%s.ffpreset", base[i],
2086  i != 1 ? "" : "/.ffmpeg", preset_name);
2087  f = fopen(filename, "r");
2088  if (!f && codec_name) {
2089  snprintf(filename, filename_size,
2090  "%s%s/%s-%s.ffpreset",
2091  base[i], i != 1 ? "" : "/.ffmpeg", codec_name,
2092  preset_name);
2093  f = fopen(filename, "r");
2094  }
2095  }
2096  }
2097 
2098  return f;
2099 }
2100 
2101 int check_stream_specifier(AVFormatContext *s, AVStream *st, const char *spec)
2102 {
2103  int ret = avformat_match_stream_specifier(s, st, spec);
2104  if (ret < 0)
2105  av_log(s, AV_LOG_ERROR, "Invalid stream specifier: %s.\n", spec);
2106  return ret;
2107 }
2108 
2110  AVFormatContext *s, AVStream *st, const AVCodec *codec)
2111 {
2112  AVDictionary *ret = NULL;
2113  AVDictionaryEntry *t = NULL;
2114  int flags = s->oformat ? AV_OPT_FLAG_ENCODING_PARAM
2116  char prefix = 0;
2117  const AVClass *cc = avcodec_get_class();
2118 
2119  if (!codec)
2120  codec = s->oformat ? avcodec_find_encoder(codec_id)
2122 
2123  switch (st->codecpar->codec_type) {
2124  case AVMEDIA_TYPE_VIDEO:
2125  prefix = 'v';
2127  break;
2128  case AVMEDIA_TYPE_AUDIO:
2129  prefix = 'a';
2131  break;
2132  case AVMEDIA_TYPE_SUBTITLE:
2133  prefix = 's';
2135  break;
2136  }
2137 
2138  while (t = av_dict_get(opts, "", t, AV_DICT_IGNORE_SUFFIX)) {
2139  const AVClass *priv_class;
2140  char *p = strchr(t->key, ':');
2141 
2142  /* check stream specification in opt name */
2143  if (p)
2144  switch (check_stream_specifier(s, st, p + 1)) {
2145  case 1: *p = 0; break;
2146  case 0: continue;
2147  default: exit_program(1);
2148  }
2149 
2150  if (av_opt_find(&cc, t->key, NULL, flags, AV_OPT_SEARCH_FAKE_OBJ) ||
2151  !codec ||
2152  ((priv_class = codec->priv_class) &&
2153  av_opt_find(&priv_class, t->key, NULL, flags,
2155  av_dict_set(&ret, t->key, t->value, 0);
2156  else if (t->key[0] == prefix &&
2157  av_opt_find(&cc, t->key + 1, NULL, flags,
2159  av_dict_set(&ret, t->key + 1, t->value, 0);
2160 
2161  if (p)
2162  *p = ':';
2163  }
2164  return ret;
2165 }
2166 
2169 {
2170  int i;
2171  AVDictionary **opts;
2172 
2173  if (!s->nb_streams)
2174  return NULL;
2175  opts = av_mallocz_array(s->nb_streams, sizeof(*opts));
2176  if (!opts) {
2178  "Could not alloc memory for stream options.\n");
2179  exit_program(1);
2180  }
2181  for (i = 0; i < s->nb_streams; i++)
2182  opts[i] = filter_codec_opts(codec_opts, s->streams[i]->codecpar->codec_id,
2183  s, s->streams[i], NULL);
2184  return opts;
2185 }
2186 
2187 void *grow_array(void *array, int elem_size, int *size, int new_size)
2188 {
2189  if (new_size >= INT_MAX / elem_size) {
2190  av_log(NULL, AV_LOG_ERROR, "Array too big.\n");
2191  exit_program(1);
2192  }
2193  if (*size < new_size) {
2194  uint8_t *tmp = av_realloc_array(array, new_size, elem_size);
2195  if (!tmp) {
2196  av_log(NULL, AV_LOG_ERROR, "Could not alloc buffer.\n");
2197  exit_program(1);
2198  }
2199  memset(tmp + *size*elem_size, 0, (new_size-*size) * elem_size);
2200  *size = new_size;
2201  return tmp;
2202  }
2203  return array;
2204 }
2205 
2207 {
2208  uint8_t* displaymatrix = av_stream_get_side_data(st,
2210  double theta = 0;
2211  if (displaymatrix)
2212  theta = -av_display_rotation_get((int32_t*) displaymatrix);
2213 
2214  theta -= 360*floor(theta/360 + 0.9/360);
2215 
2216  if (fabs(theta - 90*round(theta/90)) > 2)
2217  av_log(NULL, AV_LOG_WARNING, "Odd rotation angle.\n"
2218  "If you want to help, upload a sample "
2219  "of this file to https://streams.videolan.org/upload/ "
2220  "and contact the ffmpeg-devel mailing list. (ffmpeg-devel@ffmpeg.org)");
2221 
2222  return theta;
2223 }
2224 
2225 #if CONFIG_AVDEVICE
2226 static int print_device_sources(AVInputFormat *fmt, AVDictionary *opts)
2227 {
2228  int ret, i;
2229  AVDeviceInfoList *device_list = NULL;
2230 
2231  if (!fmt || !fmt->priv_class || !AV_IS_INPUT_DEVICE(fmt->priv_class->category))
2232  return AVERROR(EINVAL);
2233 
2234  printf("Auto-detected sources for %s:\n", fmt->name);
2235  if (!fmt->get_device_list) {
2236  ret = AVERROR(ENOSYS);
2237  printf("Cannot list sources. Not implemented.\n");
2238  goto fail;
2239  }
2240 
2241  if ((ret = avdevice_list_input_sources(fmt, NULL, opts, &device_list)) < 0) {
2242  printf("Cannot list sources.\n");
2243  goto fail;
2244  }
2245 
2246  for (i = 0; i < device_list->nb_devices; i++) {
2247  printf("%s %s [%s]\n", device_list->default_device == i ? "*" : " ",
2248  device_list->devices[i]->device_name, device_list->devices[i]->device_description);
2249  }
2250 
2251  fail:
2252  avdevice_free_list_devices(&device_list);
2253  return ret;
2254 }
2255 
2256 static int print_device_sinks(AVOutputFormat *fmt, AVDictionary *opts)
2257 {
2258  int ret, i;
2259  AVDeviceInfoList *device_list = NULL;
2260 
2261  if (!fmt || !fmt->priv_class || !AV_IS_OUTPUT_DEVICE(fmt->priv_class->category))
2262  return AVERROR(EINVAL);
2263 
2264  printf("Auto-detected sinks for %s:\n", fmt->name);
2265  if (!fmt->get_device_list) {
2266  ret = AVERROR(ENOSYS);
2267  printf("Cannot list sinks. Not implemented.\n");
2268  goto fail;
2269  }
2270 
2271  if ((ret = avdevice_list_output_sinks(fmt, NULL, opts, &device_list)) < 0) {
2272  printf("Cannot list sinks.\n");
2273  goto fail;
2274  }
2275 
2276  for (i = 0; i < device_list->nb_devices; i++) {
2277  printf("%s %s [%s]\n", device_list->default_device == i ? "*" : " ",
2278  device_list->devices[i]->device_name, device_list->devices[i]->device_description);
2279  }
2280 
2281  fail:
2282  avdevice_free_list_devices(&device_list);
2283  return ret;
2284 }
2285 
2286 static int show_sinks_sources_parse_arg(const char *arg, char **dev, AVDictionary **opts)
2287 {
2288  int ret;
2289  if (arg) {
2290  char *opts_str = NULL;
2291  av_assert0(dev && opts);
2292  *dev = av_strdup(arg);
2293  if (!*dev)
2294  return AVERROR(ENOMEM);
2295  if ((opts_str = strchr(*dev, ','))) {
2296  *(opts_str++) = '\0';
2297  if (opts_str[0] && ((ret = av_dict_parse_string(opts, opts_str, "=", ":", 0)) < 0)) {
2298  av_freep(dev);
2299  return ret;
2300  }
2301  }
2302  } else
2303  printf("\nDevice name is not provided.\n"
2304  "You can pass devicename[,opt1=val1[,opt2=val2...]] as an argument.\n\n");
2305  return 0;
2306 }
2307 
2308 int show_sources(void *optctx, const char *opt, const char *arg)
2309 {
2310  AVInputFormat *fmt = NULL;
2311  char *dev = NULL;
2312  AVDictionary *opts = NULL;
2313  int ret = 0;
2314  int error_level = av_log_get_level();
2315 
2317 
2318  if ((ret = show_sinks_sources_parse_arg(arg, &dev, &opts)) < 0)
2319  goto fail;
2320 
2321  do {
2322  fmt = av_input_audio_device_next(fmt);
2323  if (fmt) {
2324  if (!strcmp(fmt->name, "lavfi"))
2325  continue; //it's pointless to probe lavfi
2326  if (dev && !av_match_name(dev, fmt->name))
2327  continue;
2328  print_device_sources(fmt, opts);
2329  }
2330  } while (fmt);
2331  do {
2332  fmt = av_input_video_device_next(fmt);
2333  if (fmt) {
2334  if (dev && !av_match_name(dev, fmt->name))
2335  continue;
2336  print_device_sources(fmt, opts);
2337  }
2338  } while (fmt);
2339  fail:
2340  av_dict_free(&opts);
2341  av_free(dev);
2342  av_log_set_level(error_level);
2343  return ret;
2344 }
2345 
2346 int show_sinks(void *optctx, const char *opt, const char *arg)
2347 {
2348  AVOutputFormat *fmt = NULL;
2349  char *dev = NULL;
2350  AVDictionary *opts = NULL;
2351  int ret = 0;
2352  int error_level = av_log_get_level();
2353 
2355 
2356  if ((ret = show_sinks_sources_parse_arg(arg, &dev, &opts)) < 0)
2357  goto fail;
2358 
2359  do {
2360  fmt = av_output_audio_device_next(fmt);
2361  if (fmt) {
2362  if (dev && !av_match_name(dev, fmt->name))
2363  continue;
2364  print_device_sinks(fmt, opts);
2365  }
2366  } while (fmt);
2367  do {
2368  fmt = av_output_video_device_next(fmt);
2369  if (fmt) {
2370  if (dev && !av_match_name(dev, fmt->name))
2371  continue;
2372  print_device_sinks(fmt, opts);
2373  }
2374  } while (fmt);
2375  fail:
2376  av_dict_free(&opts);
2377  av_free(dev);
2378  av_log_set_level(error_level);
2379  return ret;
2380 }
2381 
2382 #endif
static enum AVCodecID codec_ids[]
static enum AVSampleFormat sample_fmts[]
Definition: adpcmenc.c:925
static double val(void *priv, double ch)
Definition: aeval.c:76
Macro definitions for various function/variable attributes.
#define av_unused
Definition: attributes.h:131
uint8_t
int32_t
simple assert() macros that are a bit more flexible than ISO C assert().
#define av_assert0(cond)
assert() equivalent, that is always enabled.
Definition: avassert.h:37
Main libavdevice API header.
Main libavfilter public API header.
Main libavformat public API header.
const char * avio_enum_protocols(void **opaque, int output)
Iterate through names of available protocols.
Definition: protocols.c:114
const AVClass * avio_protocol_get_class(const char *name)
Get AVClass by names of available protocols.
Definition: protocols.c:129
external API header
void av_bprintf(AVBPrint *buf, const char *fmt,...)
Definition: bprint.c:94
void av_bprint_init(AVBPrint *buf, unsigned size_init, unsigned size_max)
Definition: bprint.c:69
int av_bprint_finalize(AVBPrint *buf, char **ret_str)
Finalize a print buffer.
Definition: bprint.c:245
void av_bprint_chars(AVBPrint *buf, char c, unsigned n)
Append char c n times to a print buffer.
Definition: bprint.c:140
static int av_bprint_is_complete(const AVBPrint *buf)
Test if the print buffer is complete (not truncated).
Definition: bprint.h:185
#define AV_BPRINT_SIZE_AUTOMATIC
#define flags(name, subs,...)
Definition: cbs_av1.c:572
#define fc(width, name, range_min, range_max)
Definition: cbs_av1.c:562
#define us(width, name, range_min, range_max, subs,...)
Definition: cbs_h2645.c:288
#define s(width, name)
Definition: cbs_vp9.c:257
#define f(width, name)
Definition: cbs_vp9.c:255
static av_always_inline void filter(int16_t *output, ptrdiff_t out_stride, const int16_t *low, ptrdiff_t low_stride, const int16_t *high, ptrdiff_t high_stride, int len, int clip)
Definition: cfhddsp.c:27
uint64_t layout
#define fail()
Definition: checkasm.h:133
void exit_program(int ret)
Wraps exit with a program-specific cleanup routine.
Definition: cmdutils.c:139
static int match_group_separator(const OptionGroupDef *groups, int nb_groups, const char *opt)
Definition: cmdutils.c:644
int show_decoders(void *optctx, const char *opt, const char *arg)
Print a listing containing all the decoders supported by the program.
Definition: cmdutils.c:1651
int hide_banner
Definition: cmdutils.c:74
int opt_loglevel(void *optctx, const char *opt, const char *arg)
Set the libav* libraries log level.
Definition: cmdutils.c:873
AVDictionary * resample_opts
Definition: cmdutils.c:70
void show_help_children(const AVClass *class, int flags)
Show help for all options with given flags in class and all its children.
Definition: cmdutils.c:209
int opt_cpuflags(void *optctx, const char *opt, const char *arg)
Override the cpuflags.
Definition: cmdutils.c:861
static void prepare_app_arguments(int *argc_ptr, char ***argv_ptr)
Definition: cmdutils.c:291
void init_dynload(void)
Initialize dynamic library loading.
Definition: cmdutils.c:117
int parse_option(void *optctx, const char *opt, const char *arg, const OptionDef *options)
Parse one given option.
Definition: cmdutils.c:352
int show_help(void *optctx, const char *opt, const char *arg)
Generic -h handler common to all fftools.
Definition: cmdutils.c:2002
void show_help_options(const OptionDef *options, const char *msg, int req_flags, int rej_flags, int alt_flags)
Print help for all options matching specified flags.
Definition: cmdutils.c:180
static const OptionDef * find_option(const OptionDef *po, const char *name)
Definition: cmdutils.c:222
static void log_callback_report(void *ptr, int level, const char *fmt, va_list vl)
Definition: cmdutils.c:101
static void show_help_bsf(const char *name)
Definition: cmdutils.c:1983
int opt_default(void *optctx, const char *opt, const char *arg)
Fallback for options that are not explicitly handled, these will be parsed through AVOptions.
Definition: cmdutils.c:547
void print_error(const char *filename, int err)
Print an error message to stderr, indicating filename and a human readable description of the error c...
Definition: cmdutils.c:1090
static void show_help_codec(const char *name, int encoder)
Definition: cmdutils.c:1822
int show_filters(void *optctx, const char *opt, const char *arg)
Print a listing containing all the filters supported by the program.
Definition: cmdutils.c:1690
static void show_help_demuxer(const char *name)
Definition: cmdutils.c:1858
int show_sample_fmts(void *optctx, const char *opt, const char *arg)
Print a listing containing all the sample formats supported by the program.
Definition: cmdutils.c:1813
#define SHOW_CONFIG
Definition: cmdutils.c:1104
void report_and_exit(int ret)
Reports an error corresponding to the provided AVERROR code and calls exit_program() with the corresp...
Definition: cmdutils.c:133
AVDictionary * swr_opts
Definition: cmdutils.c:69
int read_yesno(void)
Return a positive value if a line read from standard input starts with [yY], otherwise return 0.
Definition: cmdutils.c:2040
static int report_file_level
Definition: cmdutils.c:73
static void print_codecs(int encoder)
Definition: cmdutils.c:1612
show_muxdemuxers
Definition: cmdutils.c:76
@ SHOW_DEFAULT
Definition: cmdutils.c:77
@ SHOW_DEMUXERS
Definition: cmdutils.c:78
@ SHOW_MUXERS
Definition: cmdutils.c:79
#define SHOW_VERSION
Definition: cmdutils.c:1103
FILE * get_preset_file(char *filename, size_t filename_size, const char *preset_name, int is_path, const char *codec_name)
Get a file corresponding to a preset file.
Definition: cmdutils.c:2051
int show_muxers(void *optctx, const char *opt, const char *arg)
Print a listing containing all the muxers supported by the program (including devices).
Definition: cmdutils.c:1366
int locate_option(int argc, char **argv, const OptionDef *options, const char *optname)
Return index of option opt in argv or 0 if not found.
Definition: cmdutils.c:449
#define INDENT
Definition: cmdutils.c:1102
static int compare_codec_desc(const void *a, const void *b)
Definition: cmdutils.c:1513
int show_bsfs(void *optctx, const char *opt, const char *arg)
Print a listing containing all the bit stream filters supported by the program.
Definition: cmdutils.c:1663
static FILE * report_file
Definition: cmdutils.c:72
void * grow_array(void *array, int elem_size, int *size, int new_size)
Realloc array to hold new_size elements of elem_size.
Definition: cmdutils.c:2187
static int write_option(void *optctx, const OptionDef *po, const char *opt, const char *arg)
Definition: cmdutils.c:297
static void print_all_libs_info(int flags, int level)
Definition: cmdutils.c:1136
AVDictionary ** setup_find_stream_info_opts(AVFormatContext *s, AVDictionary *codec_opts)
Setup AVCodecContext options for avformat_find_stream_info().
Definition: cmdutils.c:2167
int check_stream_specifier(AVFormatContext *s, AVStream *st, const char *spec)
Check if the given stream matches a stream specifier.
Definition: cmdutils.c:2101
static void(* program_exit)(int ret)
Definition: cmdutils.c:126
static void init_parse_context(OptionParseContext *octx, const OptionGroupDef *groups, int nb_groups)
Definition: cmdutils.c:707
static void add_opt(OptionParseContext *octx, const OptionDef *opt, const char *key, const char *val)
Definition: cmdutils.c:695
#define FLAGS
Definition: cmdutils.c:546
static void print_buildconf(int flags, int level)
Definition: cmdutils.c:1163
#define PRINT_LIB_INFO(libname, LIBNAME, flags, level)
Definition: cmdutils.c:1107
AVDictionary * filter_codec_opts(AVDictionary *opts, enum AVCodecID codec_id, AVFormatContext *s, AVStream *st, const AVCodec *codec)
Filter out options for given codec.
Definition: cmdutils.c:2109
int show_layouts(void *optctx, const char *opt, const char *arg)
Print a listing containing all the standard channel layouts supported by the program.
Definition: cmdutils.c:1784
static void dump_argument(const char *a)
Definition: cmdutils.c:475
int show_encoders(void *optctx, const char *opt, const char *arg)
Print a listing containing all the encoders supported by the program.
Definition: cmdutils.c:1657
#define GET_ARG(arg)
static void finish_group(OptionParseContext *octx, int group_idx, const char *arg)
Definition: cmdutils.c:664
int show_version(void *optctx, const char *opt, const char *arg)
Print the version of the program to stdout.
Definition: cmdutils.c:1200
static void expand_filename_template(AVBPrint *bp, const char *template, struct tm *tm)
Definition: cmdutils.c:952
void parse_loglevel(int argc, char **argv, const OptionDef *options)
Find the '-loglevel' option in the command line args and apply it.
Definition: cmdutils.c:508
static void show_help_protocol(const char *name)
Definition: cmdutils.c:1876
static const AVCodec * next_codec_for_id(enum AVCodecID id, void **iter, int encoder)
Definition: cmdutils.c:1501
void parse_options(void *optctx, int argc, char **argv, const OptionDef *options, void(*parse_arg_function)(void *, const char *))
Definition: cmdutils.c:385
static char get_media_type_char(enum AVMediaType type)
Definition: cmdutils.c:1489
void uninit_parse_context(OptionParseContext *octx)
Free all allocated memory in an OptionParseContext.
Definition: cmdutils.c:729
int split_commandline(OptionParseContext *octx, int argc, char *argv[], const OptionDef *options, const OptionGroupDef *groups, int nb_groups)
Split the commandline into an intermediate form convenient for further processing.
Definition: cmdutils.c:755
double get_rotation(AVStream *st)
Definition: cmdutils.c:2206
void log_callback_help(void *ptr, int level, const char *fmt, va_list vl)
Trivial log callback.
Definition: cmdutils.c:96
AVDictionary * format_opts
Definition: cmdutils.c:70
void show_banner(int argc, char **argv, const OptionDef *options)
Print the program banner to stderr.
Definition: cmdutils.c:1189
static void show_help_muxer(const char *name)
Definition: cmdutils.c:1894
int opt_timelimit(void *optctx, const char *opt, const char *arg)
Limit the execution time.
Definition: cmdutils.c:1077
int show_license(void *optctx, const char *opt, const char *arg)
Print the license of the program to stdout.
Definition: cmdutils.c:1217
static int warned_cfg
Definition: cmdutils.c:1100
int show_codecs(void *optctx, const char *opt, const char *arg)
Print a listing containing all the codecs supported by the program.
Definition: cmdutils.c:1556
int show_buildconf(void *optctx, const char *opt, const char *arg)
Print the build configuration of the program to stdout.
Definition: cmdutils.c:1209
int64_t parse_time_or_die(const char *context, const char *timestr, int is_duration)
Parse a string specifying a time and return its corresponding value as a number of microseconds.
Definition: cmdutils.c:168
void register_exit(void(*cb)(int ret))
Register a program-specific cleanup routine.
Definition: cmdutils.c:128
static int show_formats_devices(void *optctx, const char *opt, const char *arg, int device_only, int muxdemuxers)
Definition: cmdutils.c:1298
AVDictionary * codec_opts
Definition: cmdutils.c:70
int show_devices(void *optctx, const char *opt, const char *arg)
Print a listing containing all the devices supported by the program.
Definition: cmdutils.c:1376
static void print_program_info(int flags, int level)
Definition: cmdutils.c:1149
static unsigned get_codecs_sorted(const AVCodecDescriptor ***rcodecs)
Definition: cmdutils.c:1522
#define SHOW_COPYRIGHT
Definition: cmdutils.c:1105
void uninit_opts(void)
Uninitialize the cmdutils option system, in particular free the *_opts contexts and their contents.
Definition: cmdutils.c:87
static void print_codec(const AVCodec *c)
Definition: cmdutils.c:1394
int show_formats(void *optctx, const char *opt, const char *arg)
Print a listing containing all the formats supported by the program (including devices).
Definition: cmdutils.c:1361
#define sws_isSupportedOutput(x)
static int is_device(const AVClass *avclass)
Definition: cmdutils.c:1291
int show_protocols(void *optctx, const char *opt, const char *arg)
Print a listing containing all the protocols supported by the program.
Definition: cmdutils.c:1675
int parse_optgroup(void *optctx, OptionGroup *g)
Parse an options group and write results into optctx.
Definition: cmdutils.c:416
static const AVOption * opt_find(void *obj, const char *name, const char *unit, int opt_flags, int search_flags)
Definition: cmdutils.c:537
int opt_max_alloc(void *optctx, const char *opt, const char *arg)
Definition: cmdutils.c:1063
static void check_options(const OptionDef *po)
Definition: cmdutils.c:499
int opt_report(void *optctx, const char *opt, const char *arg)
Definition: cmdutils.c:1058
void init_opts(void)
Initialize the cmdutils option system, in particular allocate the *_opts contexts.
Definition: cmdutils.c:82
int show_colors(void *optctx, const char *opt, const char *arg)
Print a listing containing all the color names and values recognized by the program.
Definition: cmdutils.c:1737
double parse_number_or_die(const char *context, const char *numstr, int type, double min, double max)
Parse a string and return its corresponding value as a double.
Definition: cmdutils.c:147
static int init_report(const char *env)
Definition: cmdutils.c:980
#define PRINT_CODEC_SUPPORTED(codec, field, type, list_name, term, get_name)
Definition: cmdutils.c:1381
int show_pix_fmts(void *optctx, const char *opt, const char *arg)
Print a listing containing all the pixel formats supported by the program.
Definition: cmdutils.c:1751
int show_demuxers(void *optctx, const char *opt, const char *arg)
Print a listing containing all the demuxer supported by the program (including devices).
Definition: cmdutils.c:1371
#define sws_isSupportedInput(x)
AVDictionary * sws_dict
Definition: cmdutils.c:68
static void print_codecs_for_id(enum AVCodecID id, int encoder)
Definition: cmdutils.c:1543
const char program_name[]
program name, defined by the program for show_version().
Definition: ffmpeg.c:109
#define GET_SAMPLE_RATE_NAME(rate)
Definition: cmdutils.h:642
#define OPT_SPEC
Definition: cmdutils.h:186
#define OPT_BOOL
Definition: cmdutils.h:173
#define media_type_string
Definition: cmdutils.h:628
#define OPT_INT64
Definition: cmdutils.h:181
#define OPT_PERFILE
Definition: cmdutils.h:184
#define GET_CODEC_NAME(id)
Definition: cmdutils.h:636
#define OPT_INT
Definition: cmdutils.h:178
#define OPT_FLOAT
Definition: cmdutils.h:179
#define OPT_INPUT
Definition: cmdutils.h:189
#define GET_PIX_FMT_NAME(pix_fmt)
Definition: cmdutils.h:633
#define OPT_DOUBLE
Definition: cmdutils.h:188
void show_help_default(const char *opt, const char *arg)
Per-fftool specific help handler.
Definition: ffmpeg_opt.c:3311
#define OPT_STRING
Definition: cmdutils.h:175
#define GET_CH_LAYOUT_DESC(ch_layout)
Definition: cmdutils.h:650
#define GROW_ARRAY(array, nb_elems)
Definition: cmdutils.h:630
#define GET_SAMPLE_FMT_NAME(sample_fmt)
Definition: cmdutils.h:639
#define OPT_EXIT
Definition: cmdutils.h:182
#define OPT_OUTPUT
Definition: cmdutils.h:190
#define OPT_TIME
Definition: cmdutils.h:187
const int program_birth_year
program birth year, defined by the program for show_banner()
Definition: ffmpeg.c:110
#define OPT_OFFSET
Definition: cmdutils.h:185
#define HAS_ARG
Definition: cmdutils.h:172
#define FFMIN(a, b)
Definition: common.h:105
#define FFMAX(a, b)
Definition: common.h:103
#define FFDIFFSIGN(x, y)
Comparator.
Definition: common.h:101
#define FFMPEG_CONFIGURATION
Definition: config.h:4
#define CONFIG_THIS_YEAR
Definition: config.h:6
#define FFMPEG_DATADIR
Definition: config.h:7
#define CC_IDENT
Definition: config.h:9
#define NULL
Definition: coverity.c:32
long long int64_t
Definition: coverity.c:34
void av_force_cpu_flags(int arg)
Disables cpu detection and forces the specified flags.
Definition: cpu.c:67
int av_parse_cpu_caps(unsigned *flags, const char *s)
Parse CPU caps from a string and update the given AV_CPU_* flags based on that.
Definition: cpu.c:196
int av_get_cpu_flags(void)
Return the flags which specify extensions supported by the CPU.
Definition: cpu.c:95
static __device__ float fabs(float a)
Definition: cuda_runtime.h:182
static __device__ float floor(float a)
Definition: cuda_runtime.h:173
#define max(a, b)
Definition: cuda_runtime.h:33
static struct codec_string codecs[]
static const uint16_t channel_layouts[7]
Definition: dca_lbr.c:114
static void decode(AVCodecContext *dec_ctx, AVPacket *pkt, AVFrame *frame, FILE *outfile)
Definition: decode_audio.c:71
static enum AVPixelFormat pix_fmt
Public dictionary API.
Display matrix.
static void encode(AVCodecContext *ctx, AVFrame *frame, AVPacket *pkt, FILE *output)
Definition: encode_audio.c:95
double av_strtod(const char *numstr, char **tail)
Parse the string in numstr and return its value as a double.
Definition: eval.c:108
simple arithmetic expression evaluator
const OptionDef options[]
#define FFMPEG_VERSION
Definition: ffversion.h:4
int av_opt_get_key_value(const char **ropts, const char *key_val_sep, const char *pairs_sep, unsigned flags, char **rkey, char **rval)
Extract a key-value pair from the beginning of a string.
Definition: opt.c:1547
#define AV_OPT_SEARCH_CHILDREN
Search in possible children of the given object first.
Definition: opt.h:560
#define AV_OPT_SEARCH_FAKE_OBJ
The obj passed to av_opt_find() is fake – only a double pointer to AVClass instead of a required poin...
Definition: opt.h:568
const AVOption * av_opt_find(void *obj, const char *name, const char *unit, int opt_flags, int search_flags)
Look for an option in an object.
Definition: opt.c:1671
FF_ENABLE_DEPRECATION_WARNINGS const AVClass * av_opt_child_class_iterate(const AVClass *parent, void **iter)
Iterate over potential AVOptions-enabled children of parent.
Definition: opt.c:1741
int av_opt_show2(void *obj, void *av_log_obj, int req_flags, int rej_flags)
Show the obj options.
Definition: opt.c:1356
int av_get_standard_channel_layout(unsigned index, uint64_t *layout, const char **name)
Get the value and name of a standard channel layout.
const char * av_get_channel_description(uint64_t channel)
Get the description of a given channel.
const char * av_get_channel_name(uint64_t channel)
Get the name of a given channel.
#define AV_CODEC_CAP_DRAW_HORIZ_BAND
Decoder can use draw_horiz_band callback.
Definition: codec.h:44
#define AV_CODEC_PROP_LOSSY
Codec supports lossy compression.
Definition: codec_desc.h:78
const AVCodecDescriptor * avcodec_descriptor_get_by_name(const char *name)
Definition: codec_desc.c:3516
AVCodec * avcodec_find_decoder(enum AVCodecID id)
Find a registered decoder with a matching codec ID.
Definition: allcodecs.c:946
#define AV_CODEC_CAP_TRUNCATED
Definition: codec.h:53
int av_codec_is_encoder(const AVCodec *codec)
Definition: utils.c:74
#define AV_CODEC_CAP_OTHER_THREADS
Codec supports multithreading through a method other than slice- or frame-level multithreading.
Definition: codec.h:122
#define AV_CODEC_CAP_AVOID_PROBING
Decoder is not a preferred choice for probing.
Definition: codec.h:139
#define AV_CODEC_CAP_VARIABLE_FRAME_SIZE
Audio encoder supports receiving a different number of samples in each call.
Definition: codec.h:129
#define AV_CODEC_CAP_DELAY
Encoder or decoder requires flushing with NULL input at the end in order to give the complete and cor...
Definition: codec.h:77
const AVCodecHWConfig * avcodec_get_hw_config(const AVCodec *codec, int index)
Retrieve supported hardware configurations for a codec.
Definition: utils.c:930
#define AV_CODEC_PROP_LOSSLESS
Codec supports lossless compression.
Definition: codec_desc.h:82
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
Definition: codec.h:52
#define AV_CODEC_CAP_SUBFRAMES
Codec can output multiple frames per AVPacket Normally demuxers return one frame at a time,...
Definition: codec.h:95
int av_codec_is_decoder(const AVCodec *codec)
Definition: utils.c:79
#define AV_CODEC_PROP_INTRA_ONLY
Codec uses only intra compression.
Definition: codec_desc.h:72
AVCodec * avcodec_find_decoder_by_name(const char *name)
Find a registered decoder with the specified name.
Definition: allcodecs.c:974
#define AV_CODEC_CAP_SLICE_THREADS
Codec supports slice-based (or partition-based) multithreading.
Definition: codec.h:112
const AVCodec * av_codec_iterate(void **opaque)
Iterate over all registered codecs.
Definition: allcodecs.c:859
const AVCodecDescriptor * avcodec_descriptor_next(const AVCodecDescriptor *prev)
Iterate over all codec descriptors known to libavcodec.
Definition: codec_desc.c:3507
AVCodec * avcodec_find_encoder(enum AVCodecID id)
Find a registered encoder with a matching codec ID.
Definition: allcodecs.c:941
AVCodec * avcodec_find_encoder_by_name(const char *name)
Find a registered encoder with the specified name.
Definition: allcodecs.c:969
AVCodecID
Identify the syntax and semantics of the bitstream.
Definition: codec_id.h:46
const AVCodecDescriptor * avcodec_descriptor_get(enum AVCodecID id)
Definition: codec_desc.c:3501
#define AV_CODEC_CAP_CHANNEL_CONF
Codec should fill in channel configuration and samplerate instead of container.
Definition: codec.h:104
#define AV_CODEC_CAP_PARAM_CHANGE
Codec supports changed parameters at any point.
Definition: codec.h:116
#define AV_CODEC_CAP_HARDWARE
Codec is backed by a hardware implementation.
Definition: codec.h:157
#define AV_CODEC_CAP_SMALL_LAST_FRAME
Codec can be fed a final frame with a smaller size.
Definition: codec.h:82
#define AV_CODEC_CAP_FRAME_THREADS
Codec supports frame-level multithreading.
Definition: codec.h:108
const AVBitStreamFilter * av_bsf_get_by_name(const char *name)
const AVClass * avcodec_get_class(void)
Get the AVClass for AVCodecContext.
Definition: options.c:312
#define AV_CODEC_CAP_HYBRID
Codec is potentially backed by a hardware implementation, but not necessarily.
Definition: codec.h:164
#define AV_CODEC_CAP_EXPERIMENTAL
Codec is experimental and is thus avoided in favor of non experimental encoders.
Definition: codec.h:100
const AVBitStreamFilter * av_bsf_iterate(void **opaque)
Iterate over all registered bitstream filters.
@ AV_CODEC_ID_NONE
Definition: codec_id.h:47
@ AV_PKT_DATA_DISPLAYMATRIX
This side data contains a 3x3 transformation matrix describing an affine transformation that needs to...
Definition: packet.h:108
int avdevice_list_input_sources(AVInputFormat *device, const char *device_name, AVDictionary *device_options, AVDeviceInfoList **device_list)
List devices.
Definition: avdevice.c:125
int avdevice_list_output_sinks(AVOutputFormat *device, const char *device_name, AVDictionary *device_options, AVDeviceInfoList **device_list)
Definition: avdevice.c:136
AVInputFormat * av_input_video_device_next(AVInputFormat *d)
Video input devices iterator.
Definition: alldevices.c:128
AVInputFormat * av_input_audio_device_next(AVInputFormat *d)
Audio input devices iterator.
Definition: alldevices.c:123
void avdevice_free_list_devices(AVDeviceInfoList **device_list)
Convenient function to free result of avdevice_list_devices().
Definition: avdevice.c:147
AVOutputFormat * av_output_video_device_next(AVOutputFormat *d)
Video output devices iterator.
Definition: alldevices.c:138
AVOutputFormat * av_output_audio_device_next(AVOutputFormat *d)
Audio output devices iterator.
Definition: alldevices.c:133
const AVOutputFormat * av_muxer_iterate(void **opaque)
Iterate over all registered muxers.
Definition: allformats.c:541
uint8_t * av_stream_get_side_data(const AVStream *stream, enum AVPacketSideDataType type, size_t *size)
Get side information from stream.
const AVClass * avformat_get_class(void)
Get the AVClass for AVFormatContext.
Definition: options.c:246
const AVInputFormat * av_demuxer_iterate(void **opaque)
Iterate over all registered demuxers.
Definition: allformats.c:558
ff_const59 AVInputFormat * av_find_input_format(const char *short_name)
Find AVInputFormat based on the short name of the input format.
Definition: format.c:143
ff_const59 AVOutputFormat * av_guess_format(const char *short_name, const char *filename, const char *mime_type)
Return the output format in the list of registered output formats which best matches the provided par...
Definition: format.c:76
int avformat_match_stream_specifier(AVFormatContext *s, AVStream *st, const char *spec)
Check if the stream st contained in s is matched by the stream specifier spec.
Definition: utils.c:5325
const AVFilter * av_filter_iterate(void **opaque)
Iterate over all registered filters.
Definition: allfilters.c:534
#define AVFILTER_FLAG_DYNAMIC_OUTPUTS
The number of the filter outputs is not determined just by AVFilter.outputs.
Definition: avfilter.h:112
enum AVMediaType avfilter_pad_get_type(const AVFilterPad *pads, int pad_idx)
Get the type of an AVFilterPad.
Definition: avfilter.c:1058
const char * avfilter_pad_get_name(const AVFilterPad *pads, int pad_idx)
Get the name of an AVFilterPad.
Definition: avfilter.c:1053
#define AVFILTER_FLAG_SUPPORT_TIMELINE
Handy mask to test whether the filter supports or no the timeline feature (internally or generically)...
Definition: avfilter.h:139
#define AVFILTER_FLAG_SLICE_THREADS
The filter supports multithreading by splitting frames into multiple parts and processing them concur...
Definition: avfilter.h:117
const AVFilter * avfilter_get_by_name(const char *name)
Get a filter definition matching the given name.
Definition: allfilters.c:545
int avfilter_pad_count(const AVFilterPad *pads)
Get the number of elements in a NULL-terminated array of AVFilterPads (e.g.
Definition: avfilter.c:564
#define AVFILTER_FLAG_DYNAMIC_INPUTS
The number of the filter inputs is not determined just by AVFilter.inputs.
Definition: avfilter.h:106
attribute_deprecated const AVClass * avresample_get_class(void)
Definition: options.c:110
void av_dict_free(AVDictionary **pm)
Free all the memory allocated for an AVDictionary struct and all keys and values.
Definition: dict.c:199
#define AV_DICT_IGNORE_SUFFIX
Return first entry in a dictionary whose first part corresponds to the search key,...
Definition: dict.h:70
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
int av_dict_parse_string(AVDictionary **pm, const char *str, const char *key_val_sep, const char *pairs_sep, int flags)
Parse the key/value pairs list and add the parsed entries to a dictionary.
Definition: dict.c:176
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
#define AVUNERROR(e)
Definition: error.h:44
int av_strerror(int errnum, char *errbuf, size_t errbuf_size)
Put a description of the AVERROR code errnum in errbuf.
Definition: error.c:105
#define av_err2str(errnum)
Convenience macro, the return value should be used only directly in function arguments but never stan...
Definition: error.h:119
#define AVERROR(e)
Definition: error.h:43
#define AVERROR_OPTION_NOT_FOUND
Option not found.
Definition: error.h:61
#define AV_LOG_TRACE
Extremely verbose debugging, useful for libav* development.
Definition: log.h:220
#define AV_LOG_PANIC
Something went really wrong and we will crash now.
Definition: log.h:181
#define AV_LOG_QUIET
Print no output.
Definition: log.h:176
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
Definition: log.h:215
#define AV_LOG_WARNING
Something somehow does not look correct.
Definition: log.h:200
#define AV_LOG_FATAL
Something went wrong and recovery is not possible.
Definition: log.h:188
#define AV_LOG_VERBOSE
Detailed information.
Definition: log.h:210
#define AV_LOG_INFO
Standard information.
Definition: log.h:205
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:194
void av_log_set_callback(void(*callback)(void *, int, const char *, va_list))
Set the logging callback.
Definition: log.c:455
void av_log_set_level(int level)
Set the log level.
Definition: log.c:440
void av_log_default_callback(void *ptr, int level, const char *fmt, va_list vl)
Default logging callback.
Definition: log.c:346
#define AV_LOG_SKIP_REPEATED
Skip repeated messages, this requires the user app to use av_log() instead of (f)printf as the 2 woul...
Definition: log.h:384
int av_log_get_flags(void)
Definition: log.c:450
#define AV_LOG_PRINT_LEVEL
Include the log severity in messages originating from codecs.
Definition: log.h:392
int av_log_get_level(void)
Get the current log level.
Definition: log.c:435
void av_log_format_line(void *ptr, int level, const char *fmt, va_list vl, char *line, int line_size, int *print_prefix)
Format a line of log the same way as the default callback.
Definition: log.c:328
void av_log_set_flags(int arg)
Definition: log.c:445
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
Definition: mem.c:237
char * av_strdup(const char *s)
Duplicate a string.
Definition: mem.c:253
void * av_realloc_array(void *ptr, size_t nmemb, size_t size)
Allocate, reallocate, or free an array.
Definition: mem.c:198
void * av_calloc(size_t nmemb, size_t size)
Non-inlined equivalent of av_mallocz_array().
Definition: mem.c:245
void * av_mallocz_array(size_t nmemb, size_t size)
Allocate a memory block for an array with av_mallocz().
Definition: mem.c:190
void av_max_alloc(size_t max)
Set the maximum size that may be allocated in one block.
Definition: mem.c:73
static void * av_x_if_null(const void *p, const void *x)
Return x default pointer in case p is NULL.
Definition: avutil.h:308
AVMediaType
Definition: avutil.h:199
@ AVMEDIA_TYPE_ATTACHMENT
Opaque data information usually sparse.
Definition: avutil.h:205
@ AVMEDIA_TYPE_AUDIO
Definition: avutil.h:202
@ AVMEDIA_TYPE_SUBTITLE
Definition: avutil.h:204
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
@ AVMEDIA_TYPE_DATA
Opaque data information usually continuous.
Definition: avutil.h:203
char * av_get_sample_fmt_string(char *buf, int buf_size, enum AVSampleFormat sample_fmt)
Generate a string corresponding to the sample format with sample_fmt, or a header if sample_fmt is ne...
Definition: samplefmt.c:93
AVSampleFormat
Audio sample formats.
Definition: samplefmt.h:58
@ AV_SAMPLE_FMT_NB
Number of sample formats. DO NOT USE if linking dynamically.
Definition: samplefmt.h:74
@ AV_SAMPLE_FMT_NONE
Definition: samplefmt.h:59
size_t av_strlcat(char *dst, const char *src, size_t size)
Append the string src to the string dst, but to a total length of no more than size - 1 bytes,...
Definition: avstring.c:93
int av_match_name(const char *name, const char *names)
Match instances of a name in a comma-separated list of names.
Definition: avstring.c:356
int av_strstart(const char *str, const char *pfx, const char **ptr)
Return non-zero if pfx is a prefix of str.
Definition: avstring.c:34
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:83
static av_const int av_toupper(int c)
Locale-independent conversion of ASCII characters to uppercase.
Definition: avstring.h:236
double av_display_rotation_get(const int32_t matrix[9])
Extract the rotation component of the transformation matrix.
Definition: display.c:34
const AVClass * sws_get_class(void)
Get the AVClass for swsContext.
Definition: options.c:95
struct SwsContext * sws_alloc_context(void)
Allocate an empty SwsContext.
Definition: utils.c:1103
void sws_freeContext(struct SwsContext *swsContext)
Free the swscaler context swsContext.
Definition: utils.c:2373
const AVClass * swr_get_class(void)
Get the AVClass for SwrContext.
Definition: options.c:144
av_cold void swr_free(SwrContext **ss)
Free the given SwrContext and set the pointer to NULL.
Definition: swresample.c:137
av_cold struct SwrContext * swr_alloc(void)
Allocate SwrContext.
Definition: options.c:149
int av_opt_set(void *obj, const char *name, const char *val, int search_flags)
Definition: opt.c:475
const char * av_hwdevice_get_type_name(enum AVHWDeviceType type)
Get the string name of an AVHWDeviceType.
Definition: hwcontext.c:92
cl_device_type type
const char * key
misc image utilities
int i
Definition: input.c:407
const char * arg
Definition: jacosubdec.c:67
Libavutil version macros.
static enum AVPixelFormat pix_fmts[]
Definition: libkvazaar.c:309
Replacements for frequently missing libm functions.
static av_always_inline av_const double round(double x)
Definition: libm.h:444
const char * desc
Definition: libsvtav1.c:83
#define AV_IS_OUTPUT_DEVICE(category)
Definition: log.h:55
#define AV_IS_INPUT_DEVICE(category)
Definition: log.h:50
#define INFINITY
Definition: mathematics.h:67
AVOptions.
#define AV_OPT_FLAG_FILTERING_PARAM
a generic parameter which can be set by the user for filtering
Definition: opt.h:294
#define AV_OPT_FLAG_BSF_PARAM
a generic parameter which can be set by the user for bit stream filtering
Definition: opt.h:292
#define AV_OPT_FLAG_AUDIO_PARAM
Definition: opt.h:280
#define AV_OPT_FLAG_DECODING_PARAM
a generic parameter which can be set by the user for demuxing or decoding
Definition: opt.h:279
#define AV_OPT_FLAG_VIDEO_PARAM
Definition: opt.h:281
#define AV_OPT_FLAG_ENCODING_PARAM
a generic parameter which can be set by the user for muxing or encoding
Definition: opt.h:278
#define AV_OPT_FLAG_SUBTITLE_PARAM
Definition: opt.h:282
const char * av_get_known_color_name(int color_idx, const uint8_t **rgbp)
Get the name of a color from the internal table of hard-coded named colors.
Definition: parseutils.c:434
int av_parse_time(int64_t *timeval, const char *timestr, int duration)
Parse timestr and return in *time a corresponding number of microseconds.
Definition: parseutils.c:587
misc parsing utilities
enum AVPixelFormat av_pix_fmt_desc_get_id(const AVPixFmtDescriptor *desc)
Definition: pixdesc.c:2592
const AVPixFmtDescriptor * av_pix_fmt_desc_next(const AVPixFmtDescriptor *prev)
Iterate over all pixel format descriptors known to libavutil.
Definition: pixdesc.c:2580
int av_get_bits_per_pixel(const AVPixFmtDescriptor *pixdesc)
Return the number of bits per pixel used by the pixel format described by pixdesc.
Definition: pixdesc.c:2525
#define AV_PIX_FMT_FLAG_BITSTREAM
All values of a component are bit-wise packed end to end.
Definition: pixdesc.h:136
#define AV_PIX_FMT_FLAG_HWACCEL
Pixel format is an HW accelerated format.
Definition: pixdesc.h:140
#define AV_PIX_FMT_FLAG_PAL
Pixel format has a palette in data[1], values are indexes in this palette.
Definition: pixdesc.h:132
const char * class
Definition: pixdesc_query.c:27
AVPixelFormat
Pixel format.
Definition: pixfmt.h:64
@ AV_PIX_FMT_NONE
Definition: pixfmt.h:65
external API header
const char * name
Definition: qsvenc.c:46
typedef void(RENAME(mix_any_func_type))
static const SheerTable rgb[2]
#define FF_ARRAY_ELEMS(a)
#define snprintf
Definition: snprintf.h:34
const AVClass * priv_class
A class for the private data, used to declare bitstream filter private AVOptions.
Definition: bsf.h:117
const char * name
Definition: bsf.h:99
Describe the class of an AVClass context structure.
Definition: log.h:67
AVClassCategory category
Category used for visualization (like color) This is only set if the category is equal for all object...
Definition: log.h:133
This struct describes the properties of a single codec described by an AVCodecID.
Definition: codec_desc.h:38
enum AVHWDeviceType device_type
The device type associated with the configuration.
Definition: codec.h:464
enum AVMediaType codec_type
General type of the encoded data.
Definition: codec_par.h:56
AVCodec.
Definition: codec.h:197
const AVClass * priv_class
AVClass for the private context.
Definition: codec.h:223
const char * long_name
Descriptive name for the codec, meant to be more human readable than name.
Definition: codec.h:209
const char * name
Name of the codec implementation.
Definition: codec.h:204
int capabilities
Codec capabilities.
Definition: codec.h:216
List of devices.
Definition: avdevice.h:465
int nb_devices
number of autodetected devices
Definition: avdevice.h:467
int default_device
index of default device or -1 if no default
Definition: avdevice.h:468
AVDeviceInfo ** devices
list of autodetected devices
Definition: avdevice.h:466
char * device_description
human friendly name
Definition: avdevice.h:459
char * device_name
device name, format depends on device
Definition: avdevice.h:458
char * key
Definition: dict.h:82
char * value
Definition: dict.h:83
A filter pad used for either input or output.
Definition: internal.h:54
Filter definition.
Definition: avfilter.h:145
Format I/O context.
Definition: avformat.h:1232
const char * long_name
Descriptive name for the format, meant to be more human-readable than name.
Definition: avformat.h:652
const char * name
A comma separated list of short names for the format.
Definition: avformat.h:645
int(* get_device_list)(struct AVFormatContext *s, struct AVDeviceInfoList *device_list)
Returns device list with it properties.
Definition: avformat.h:772
const char * extensions
If extensions are defined, then no probe is done.
Definition: avformat.h:666
const AVClass * priv_class
AVClass for the private context.
Definition: avformat.h:670
AVOption.
Definition: opt.h:248
int flags
Definition: opt.h:277
const char * extensions
comma-separated filename extensions
Definition: avformat.h:499
enum AVCodecID video_codec
default video codec
Definition: avformat.h:502
enum AVCodecID audio_codec
default audio codec
Definition: avformat.h:501
const char * long_name
Descriptive name for the format, meant to be more human-readable than name.
Definition: avformat.h:497
const char * name
Definition: avformat.h:491
const char * mime_type
Definition: avformat.h:498
int(* get_device_list)(struct AVFormatContext *s, struct AVDeviceInfoList *device_list)
Returns device list with it properties.
Definition: avformat.h:592
enum AVCodecID subtitle_codec
default subtitle codec
Definition: avformat.h:503
const AVClass * priv_class
AVClass for the private context.
Definition: avformat.h:519
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
Definition: pixdesc.h:81
const char * name
Definition: pixdesc.h:82
uint64_t flags
Combination of AV_PIX_FMT_FLAG_...
Definition: pixdesc.h:106
uint8_t nb_components
The number of components each pixel has, (1-4)
Definition: pixdesc.h:83
Rational number (pair of numerator and denominator).
Definition: rational.h:58
int num
Numerator.
Definition: rational.h:59
int den
Denominator.
Definition: rational.h:60
Stream structure.
Definition: avformat.h:873
AVCodecParameters * codecpar
Codec parameters associated with this stream.
Definition: avformat.h:1038
union OptionDef::@1 u
int flags
Definition: cmdutils.h:171
size_t off
Definition: cmdutils.h:194
const char * name
Definition: cmdutils.h:170
const char * argname
Definition: cmdutils.h:197
void * dst_ptr
Definition: cmdutils.h:192
const char * help
Definition: cmdutils.h:196
int(* func_arg)(void *, const char *, const char *)
Definition: cmdutils.h:193
const char * sep
Option to be used as group separator.
Definition: cmdutils.h:311
A list of option groups that all have the same group type (e.g.
Definition: cmdutils.h:337
OptionGroup * groups
Definition: cmdutils.h:340
const OptionGroupDef * group_def
Definition: cmdutils.h:338
int nb_opts
Definition: cmdutils.h:324
const OptionGroupDef * group_def
Definition: cmdutils.h:320
AVDictionary * codec_opts
Definition: cmdutils.h:326
AVDictionary * swr_opts
Definition: cmdutils.h:330
Option * opts
Definition: cmdutils.h:323
AVDictionary * sws_dict
Definition: cmdutils.h:329
const char * arg
Definition: cmdutils.h:321
AVDictionary * format_opts
Definition: cmdutils.h:327
AVDictionary * resample_opts
Definition: cmdutils.h:328
OptionGroup global_opts
Definition: cmdutils.h:345
OptionGroupList * groups
Definition: cmdutils.h:347
OptionGroup cur_group
Definition: cmdutils.h:351
An option extracted from the commandline.
Definition: cmdutils.h:298
const char * key
Definition: cmdutils.h:300
const OptionDef * opt
Definition: cmdutils.h:299
const char * val
Definition: cmdutils.h:301
The libswresample context.
Definition: graph2dot.c:48
Definition: rpzaenc.c:58
uint8_t level
Definition: svq3.c:206
libswresample public header
static int swscale(SwsContext *c, const uint8_t *src[], int srcStride[], int srcSliceY, int srcSliceH, uint8_t *dst[], int dstStride[])
Definition: swscale.c:238
external API header
#define av_free(p)
#define av_freep(p)
#define av_log(a,...)
static void error(const char *err)
static uint8_t tmp[11]
Definition: aes_ctr.c:27
static int array[MAX_W *MAX_W]
Definition: jpeg2000dwt.c:106
AVDictionary * opts
Definition: movenc.c:50
int size
#define va_copy(dst, src)
Definition: va_copy.h:31
enum AVCodecID codec_id
Definition: vaapi_decode.c:374
const char * b
Definition: vf_curves.c:119
const char * g
Definition: vf_curves.c:118
static double cb(void *priv, double x, double y)
Definition: vf_geq.c:220
static const uint8_t offset[127][2]
Definition: vf_spp.c:107
float min
uint8_t base
Definition: vp3data.h:141
static double c[64]