FFmpeg
Loading...
Searching...
No Matches
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"
34#include "libswscale/swscale.h"
36#include "libavutil/avassert.h"
37#include "libavutil/avstring.h"
38#include "libavutil/bprint.h"
39#include "libavutil/display.h"
41#include "libavutil/mem.h"
43#include "libavutil/eval.h"
44#include "libavutil/dict.h"
45#include "libavutil/opt.h"
46#include "cmdutils.h"
47#include "fopen_utf8.h"
48#include "opt_common.h"
49#ifdef _WIN32
50#include <windows.h>
51#include "compat/w32dlfcn.h"
52#endif
53
57
59
67
68void log_callback_help(void *ptr, int level, const char *fmt, va_list vl)
69{
70 vfprintf(stdout, fmt, vl);
71}
72
73void init_dynload(void)
74{
75#if HAVE_SETDLLDIRECTORY && defined(_WIN32)
76 /* Calling SetDllDirectory with the empty string (but not NULL) removes the
77 * current working directory from the DLL search path as a security pre-caution. */
78 SetDllDirectory("");
79#endif
80}
81
82int parse_number(const char *context, const char *numstr, enum OptionType type,
83 double min, double max, double *dst)
84{
85 char *tail;
86 const char *error;
87 double d = av_strtod(numstr, &tail);
88 if (*tail)
89 error = "Expected number for %s but found: %s\n";
90 else if (d < min || d > max)
91 error = "The value for %s was %s which is not within %f - %f\n";
92 else if (type == OPT_TYPE_INT64 && (int64_t)d != d)
93 error = "Expected int64 for %s but found %s\n";
94 else if (type == OPT_TYPE_INT && (int)d != d)
95 error = "Expected int for %s but found %s\n";
96 else {
97 *dst = d;
98 return 0;
99 }
100
101 av_log(NULL, AV_LOG_FATAL, error, context, numstr, min, max);
102 return AVERROR(EINVAL);
103}
104
105void show_help_options(const OptionDef *options, const char *msg, int req_flags,
106 int rej_flags)
107{
108 const OptionDef *po;
109 int first;
110
111 first = 1;
112 for (po = options; po->name; po++) {
113 char buf[128];
114
115 if (((po->flags & req_flags) != req_flags) ||
116 (po->flags & rej_flags))
117 continue;
118
119 if (first) {
120 printf("%s\n", msg);
121 first = 0;
122 }
123 av_strlcpy(buf, po->name, sizeof(buf));
124
125 if (po->flags & OPT_FLAG_PERSTREAM)
126 av_strlcat(buf, "[:<stream_spec>]", sizeof(buf));
127 else if (po->flags & OPT_FLAG_SPEC)
128 av_strlcat(buf, "[:<spec>]", sizeof(buf));
129
130 if (po->argname)
131 av_strlcatf(buf, sizeof(buf), " <%s>", po->argname);
132
133 printf("-%-17s %s\n", buf, po->help);
134 }
135 printf("\n");
136}
137
138void show_help_children(const AVClass *class, int flags)
139{
140 void *iter = NULL;
141 const AVClass *child;
142 if (class->option) {
143 av_opt_show2(&class, NULL, flags, 0);
144 printf("\n");
145 }
146
147 while (child = av_opt_child_class_iterate(class, &iter))
149}
150
151static const OptionDef *find_option(const OptionDef *po, const char *name)
152{
153 if (*name == '/')
154 name++;
155
156 while (po->name) {
157 const char *end;
158 if (av_strstart(name, po->name, &end) && (!*end || *end == ':'))
159 break;
160 po++;
161 }
162 return po;
163}
164
165/* _WIN32 means using the windows libc - cygwin doesn't define that
166 * by default. HAVE_COMMANDLINETOARGVW is true on cygwin, while
167 * it doesn't provide the actual command line via GetCommandLineW(). */
168#if HAVE_COMMANDLINETOARGVW && defined(_WIN32)
169#include <shellapi.h>
170/* Will be leaked on exit */
171static char** win32_argv_utf8 = NULL;
172static int win32_argc = 0;
173
174/**
175 * Prepare command line arguments for executable.
176 * For Windows - perform wide-char to UTF-8 conversion.
177 * Input arguments should be main() function arguments.
178 * @param argc_ptr Arguments number (including executable)
179 * @param argv_ptr Arguments list.
180 */
181static void prepare_app_arguments(int *argc_ptr, char ***argv_ptr)
182{
183 char *argstr_flat;
184 wchar_t **argv_w;
185 int i, buffsize = 0, offset = 0;
186
187 if (win32_argv_utf8) {
188 *argc_ptr = win32_argc;
189 *argv_ptr = win32_argv_utf8;
190 return;
191 }
192
193 win32_argc = 0;
194 argv_w = CommandLineToArgvW(GetCommandLineW(), &win32_argc);
195 if (win32_argc <= 0 || !argv_w)
196 return;
197
198 /* determine the UTF-8 buffer size (including NULL-termination symbols) */
199 for (i = 0; i < win32_argc; i++)
200 buffsize += WideCharToMultiByte(CP_UTF8, 0, argv_w[i], -1,
201 NULL, 0, NULL, NULL);
202
203 win32_argv_utf8 = av_mallocz(sizeof(char *) * (win32_argc + 1) + buffsize);
204 argstr_flat = (char *)win32_argv_utf8 + sizeof(char *) * (win32_argc + 1);
205 if (!win32_argv_utf8) {
206 LocalFree(argv_w);
207 return;
208 }
209
210 for (i = 0; i < win32_argc; i++) {
211 win32_argv_utf8[i] = &argstr_flat[offset];
212 offset += WideCharToMultiByte(CP_UTF8, 0, argv_w[i], -1,
213 &argstr_flat[offset],
214 buffsize - offset, NULL, NULL);
215 }
216 win32_argv_utf8[i] = NULL;
217 LocalFree(argv_w);
218
219 *argc_ptr = win32_argc;
220 *argv_ptr = win32_argv_utf8;
221}
222#else
223static inline void prepare_app_arguments(int *argc_ptr, char ***argv_ptr)
224{
225 /* nothing to do */
226}
227#endif /* HAVE_COMMANDLINETOARGVW */
228
229static int opt_has_arg(const OptionDef *o)
230{
231 if (o->type == OPT_TYPE_BOOL)
232 return 0;
233 if (o->type == OPT_TYPE_FUNC)
234 return !!(o->flags & OPT_FUNC_ARG);
235 return 1;
236}
237
238static int write_option(void *optctx, const OptionDef *po, const char *opt,
239 const char *arg, const OptionDef *defs)
240{
241 /* new-style options contain an offset into optctx, old-style address of
242 * a global var*/
243 void *dst = po->flags & OPT_FLAG_OFFSET ?
244 (uint8_t *)optctx + po->u.off : po->u.dst_ptr;
245 char *arg_allocated = NULL;
246
247 enum OptionType so_type = po->type;
248
249 SpecifierOptList *sol = NULL;
250 double num;
251 int ret = 0;
252
253 if (*opt == '/') {
254 opt++;
255
256 if (!opt_has_arg(po)) {
258 "Requested to load an argument from file for an option '%s'"
259 " which does not take an argument\n",
260 po->name);
261 return AVERROR(EINVAL);
262 }
263
264 arg_allocated = read_file_to_string(arg);
265 if (!arg_allocated) {
267 "Error reading the value for option '%s' from file: %s\n",
268 opt, arg);
269 return AVERROR(EINVAL);
270 }
271
272 arg = arg_allocated;
273 }
274
275 if (po->flags & OPT_FLAG_SPEC) {
276 const char *p = strchr(opt, ':');
277 char *str;
278
279 sol = dst;
280 ret = GROW_ARRAY(sol->opt, sol->nb_opt);
281 if (ret < 0)
282 goto finish;
283
284 str = av_strdup(p ? p + 1 : "");
285 if (!str) {
286 ret = AVERROR(ENOMEM);
287 goto finish;
288 }
289 sol->opt[sol->nb_opt - 1].specifier = str;
290
291 if (po->flags & OPT_FLAG_PERSTREAM) {
292 ret = stream_specifier_parse(&sol->opt[sol->nb_opt - 1].stream_spec,
293 str, 0, NULL);
294 if (ret < 0)
295 goto finish;
296 }
297
298 dst = &sol->opt[sol->nb_opt - 1].u;
299 }
300
301 if (po->type == OPT_TYPE_STRING) {
302 char *str;
303 if (arg_allocated) {
304 str = arg_allocated;
305 arg_allocated = NULL;
306 } else
307 str = av_strdup(arg);
308 av_freep(dst);
309
310 if (!str) {
311 ret = AVERROR(ENOMEM);
312 goto finish;
313 }
314
315 *(char **)dst = str;
316 } else if (po->type == OPT_TYPE_BOOL || po->type == OPT_TYPE_INT) {
317 ret = parse_number(opt, arg, OPT_TYPE_INT64, INT_MIN, INT_MAX, &num);
318 if (ret < 0)
319 goto finish;
320
321 *(int *)dst = num;
322 so_type = OPT_TYPE_INT;
323 } else if (po->type == OPT_TYPE_INT64) {
324 ret = parse_number(opt, arg, OPT_TYPE_INT64, INT64_MIN, (double)INT64_MAX, &num);
325 if (ret < 0)
326 goto finish;
327
328 *(int64_t *)dst = num;
329 } else if (po->type == OPT_TYPE_TIME) {
330 ret = av_parse_time(dst, arg, 1);
331 if (ret < 0) {
332 av_log(NULL, AV_LOG_ERROR, "Invalid duration for option %s: %s\n",
333 opt, arg);
334 goto finish;
335 }
336 so_type = OPT_TYPE_INT64;
337 } else if (po->type == OPT_TYPE_FLOAT) {
338 ret = parse_number(opt, arg, OPT_TYPE_FLOAT, -INFINITY, INFINITY, &num);
339 if (ret < 0)
340 goto finish;
341
342 *(float *)dst = num;
343 } else if (po->type == OPT_TYPE_DOUBLE) {
344 ret = parse_number(opt, arg, OPT_TYPE_DOUBLE, -INFINITY, INFINITY, &num);
345 if (ret < 0)
346 goto finish;
347
348 *(double *)dst = num;
349 } else {
350 av_assert0(po->type == OPT_TYPE_FUNC && po->u.func_arg);
351
352 ret = po->u.func_arg(optctx, opt, arg);
353 if (ret < 0) {
354 if ((strcmp(opt, "init_hw_device") != 0) || (strcmp(arg, "list") != 0)) {
356 "Failed to set value '%s' for option '%s': %s\n",
357 arg, opt, av_err2str(ret));
358 }
359 goto finish;
360 }
361 }
362 if (po->flags & OPT_EXIT) {
363 ret = AVERROR_EXIT;
364 goto finish;
365 }
366
367 if (sol) {
368 sol->type = so_type;
369 sol->opt_canon = (po->flags & OPT_HAS_CANON) ?
370 find_option(defs, po->u1.name_canon) : po;
371 }
372
373finish:
374 av_freep(&arg_allocated);
375 return ret;
376}
377
378int parse_option(void *optctx, const char *opt, const char *arg,
379 const OptionDef *options)
380{
381 static const OptionDef opt_avoptions = {
382 .name = "AVOption passthrough",
383 .type = OPT_TYPE_FUNC,
384 .flags = OPT_FUNC_ARG,
385 .u.func_arg = opt_default,
386 };
387
388 const OptionDef *po;
389 int ret;
390
391 po = find_option(options, opt);
392 if (!po->name && opt[0] == 'n' && opt[1] == 'o') {
393 /* handle 'no' bool option */
394 po = find_option(options, opt + 2);
395 if ((po->name && po->type == OPT_TYPE_BOOL))
396 arg = "0";
397 } else if (po->type == OPT_TYPE_BOOL)
398 arg = "1";
399
400 if (!po->name)
401 po = &opt_avoptions;
402 if (!po->name) {
403 av_log(NULL, AV_LOG_ERROR, "Unrecognized option '%s'\n", opt);
404 return AVERROR(EINVAL);
405 }
406 if (opt_has_arg(po) && !arg) {
407 av_log(NULL, AV_LOG_ERROR, "Missing argument for option '%s'\n", opt);
408 return AVERROR(EINVAL);
409 }
410
411 ret = write_option(optctx, po, opt, arg, options);
412 if (ret < 0)
413 return ret;
414
415 return opt_has_arg(po);
416}
417
418int parse_options(void *optctx, int argc, char **argv, const OptionDef *options,
419 int (*parse_arg_function)(void *, const char*))
420{
421 const char *opt;
422 int optindex, handleoptions = 1, ret;
423
424 /* perform system-dependent conversions for arguments list */
425 prepare_app_arguments(&argc, &argv);
426
427 /* parse options */
428 optindex = 1;
429 while (optindex < argc) {
430 opt = argv[optindex++];
431
432 if (handleoptions && opt[0] == '-' && opt[1] != '\0') {
433 if (opt[1] == '-' && opt[2] == '\0') {
434 handleoptions = 0;
435 continue;
436 }
437 opt++;
438
439 if ((ret = parse_option(optctx, opt, argv[optindex], options)) < 0)
440 return ret;
441 optindex += ret;
442 } else {
443 if (parse_arg_function) {
444 ret = parse_arg_function(optctx, opt);
445 if (ret < 0)
446 return ret;
447 }
448 }
449 }
450
451 return 0;
452}
453
454int parse_optgroup(void *optctx, OptionGroup *g, const OptionDef *defs)
455{
456 int i, ret;
457
458 av_log(NULL, AV_LOG_DEBUG, "Parsing a group of options: %s %s.\n",
459 g->group_def->name, g->arg);
460
461 for (i = 0; i < g->nb_opts; i++) {
462 Option *o = &g->opts[i];
463
464 if (g->group_def->flags &&
465 !(g->group_def->flags & o->opt->flags)) {
466 av_log(NULL, AV_LOG_ERROR, "Option %s (%s) cannot be applied to "
467 "%s %s -- you are trying to apply an input option to an "
468 "output file or vice versa. Move this option before the "
469 "file it belongs to.\n", o->key, o->opt->help,
470 g->group_def->name, g->arg);
471 return AVERROR(EINVAL);
472 }
473
474 av_log(NULL, AV_LOG_DEBUG, "Applying option %s (%s) with argument %s.\n",
475 o->key, o->opt->help, o->val);
476
477 ret = write_option(optctx, o->opt, o->key, o->val, defs);
478 if (ret < 0)
479 return ret;
480 }
481
482 av_log(NULL, AV_LOG_DEBUG, "Successfully parsed a group of options.\n");
483
484 return 0;
485}
486
487int locate_option(int argc, char **argv, const OptionDef *options,
488 const char *optname)
489{
490 const OptionDef *po;
491 int i;
492
493 for (i = 1; i < argc; i++) {
494 const char *cur_opt = argv[i];
495
496 if (!(cur_opt[0] == '-' && cur_opt[1]))
497 continue;
498 cur_opt++;
499
500 po = find_option(options, cur_opt);
501 if (!po->name && cur_opt[0] == 'n' && cur_opt[1] == 'o')
502 po = find_option(options, cur_opt + 2);
503
504 if ((!po->name && !strcmp(cur_opt, optname)) ||
505 (po->name && !strcmp(optname, po->name)))
506 return i;
507
508 if (!po->name || opt_has_arg(po))
509 i++;
510 }
511 return 0;
512}
513
514static void dump_argument(FILE *report_file, const char *a)
515{
516 const unsigned char *p;
517
518 for (p = a; *p; p++)
519 if (!((*p >= '+' && *p <= ':') || (*p >= '@' && *p <= 'Z') ||
520 *p == '_' || (*p >= 'a' && *p <= 'z')))
521 break;
522 if (!*p) {
523 fputs(a, report_file);
524 return;
525 }
526 fputc('"', report_file);
527 for (p = a; *p; p++) {
528 if (*p == '\\' || *p == '"' || *p == '$' || *p == '`')
529 fprintf(report_file, "\\%c", *p);
530 else if (*p < ' ' || *p > '~')
531 fprintf(report_file, "\\x%02x", *p);
532 else
533 fputc(*p, report_file);
534 }
535 fputc('"', report_file);
536}
537
538static void check_options(const OptionDef *po)
539{
540 while (po->name) {
541 if (po->flags & OPT_PERFILE)
543
544 if (po->type == OPT_TYPE_FUNC)
546
547 // OPT_FUNC_ARG can only be ser for OPT_TYPE_FUNC
548 av_assert0((po->type == OPT_TYPE_FUNC) || !(po->flags & OPT_FUNC_ARG));
549
550 po++;
551 }
552}
553
554void parse_loglevel(int argc, char **argv, const OptionDef *options)
555{
556 int idx;
557 char *env;
558
560
561 idx = locate_option(argc, argv, options, "loglevel");
562 if (!idx)
563 idx = locate_option(argc, argv, options, "v");
564 if (idx && argv[idx + 1])
565 opt_loglevel(NULL, "loglevel", argv[idx + 1]);
566 idx = locate_option(argc, argv, options, "report");
567 env = getenv_utf8("FFREPORT");
568 if (env || idx) {
569 FILE *report_file = NULL;
571 if (report_file) {
572 int i;
573 fprintf(report_file, "Command line:\n");
574 for (i = 0; i < argc; i++) {
576 fputc(i < argc - 1 ? ' ' : '\n', report_file);
577 }
578 fflush(report_file);
579 }
580 }
581 freeenv_utf8(env);
582 idx = locate_option(argc, argv, options, "hide_banner");
583 if (idx)
584 hide_banner = 1;
585}
586
587static const AVOption *opt_find(void *obj, const char *name, const char *unit,
588 int opt_flags, int search_flags)
589{
590 const AVOption *o = av_opt_find(obj, name, unit, opt_flags, search_flags);
591 if(o && !o->flags)
592 return NULL;
593 return o;
594}
595
596#define FLAGS ((o->type == AV_OPT_TYPE_FLAGS && (arg[0]=='-' || arg[0]=='+')) ? AV_DICT_APPEND : 0)
597int opt_default(void *optctx, const char *opt, const char *arg)
598{
599 const AVOption *o;
600 int consumed = 0;
601 char opt_stripped[128];
602 const char *p;
604#if CONFIG_SWSCALE
605 const AVClass *sc = sws_get_class();
606#endif
607#if CONFIG_SWRESAMPLE
608 const AVClass *swr_class = swr_get_class();
609#endif
610
611 if (!strcmp(opt, "debug") || !strcmp(opt, "fdebug"))
613
614 if (!(p = strchr(opt, ':')))
615 p = opt + strlen(opt);
616 av_strlcpy(opt_stripped, opt, FFMIN(sizeof(opt_stripped), p - opt + 1));
617
618 if ((o = opt_find(&cc, opt_stripped, NULL, 0,
620 ((opt[0] == 'v' || opt[0] == 'a' || opt[0] == 's') &&
621 (o = opt_find(&cc, opt + 1, NULL, 0, AV_OPT_SEARCH_FAKE_OBJ)))) {
623 consumed = 1;
624 }
625 if ((o = opt_find(&fc, opt, NULL, 0,
628 if (consumed)
629 av_log(NULL, AV_LOG_VERBOSE, "Routing option %s to both codec and muxer layer\n", opt);
630 consumed = 1;
631 }
632#if CONFIG_SWSCALE
633 if (!consumed && (o = opt_find(&sc, opt, NULL, 0,
635 if (!strcmp(opt, "srcw") || !strcmp(opt, "srch") ||
636 !strcmp(opt, "dstw") || !strcmp(opt, "dsth") ||
637 !strcmp(opt, "src_format") || !strcmp(opt, "dst_format")) {
638 av_log(NULL, AV_LOG_ERROR, "Directly using swscale dimensions/format options is not supported, please use the -s or -pix_fmt options\n");
639 return AVERROR(EINVAL);
640 }
641 av_dict_set(&sws_dict, opt, arg, FLAGS);
642
643 consumed = 1;
644 }
645#else
646 if (!consumed && !strcmp(opt, "sws_flags")) {
647 av_log(NULL, AV_LOG_WARNING, "Ignoring %s %s, due to disabled swscale\n", opt, arg);
648 consumed = 1;
649 }
650#endif
651#if CONFIG_SWRESAMPLE
652 if (!consumed && (o=opt_find(&swr_class, opt, NULL, 0,
654 av_dict_set(&swr_opts, opt, arg, FLAGS);
655 consumed = 1;
656 }
657#endif
658
659 if (consumed)
660 return 0;
662}
663
664/*
665 * Check whether given option is a group separator.
666 *
667 * @return index of the group definition that matched or -1 if none
668 */
669static int match_group_separator(const OptionGroupDef *groups, int nb_groups,
670 const char *opt)
671{
672 int i;
673
674 for (i = 0; i < nb_groups; i++) {
675 const OptionGroupDef *p = &groups[i];
676 if (p->sep && !strcmp(p->sep, opt))
677 return i;
678 }
679
680 return -1;
681}
682
683/*
684 * Finish parsing an option group.
685 *
686 * @param group_idx which group definition should this group belong to
687 * @param arg argument of the group delimiting option
688 */
689static int finish_group(OptionParseContext *octx, int group_idx,
690 const char *arg)
691{
692 OptionGroupList *l = &octx->groups[group_idx];
693 OptionGroup *g;
694 int ret;
695
696 ret = GROW_ARRAY(l->groups, l->nb_groups);
697 if (ret < 0)
698 return ret;
699
700 g = &l->groups[l->nb_groups - 1];
701
702 *g = octx->cur_group;
703 g->arg = arg;
704 g->group_def = l->group_def;
705 g->sws_dict = sws_dict;
706 g->swr_opts = swr_opts;
707 g->codec_opts = codec_opts;
708 g->format_opts = format_opts;
709
712 sws_dict = NULL;
713 swr_opts = NULL;
714
715 memset(&octx->cur_group, 0, sizeof(octx->cur_group));
716
717 return ret;
718}
719
720/*
721 * Add an option instance to currently parsed group.
722 */
723static int add_opt(OptionParseContext *octx, const OptionDef *opt,
724 const char *key, const char *val)
725{
726 int global = !(opt->flags & OPT_PERFILE);
727 OptionGroup *g = global ? &octx->global_opts : &octx->cur_group;
728 int ret;
729
730 ret = GROW_ARRAY(g->opts, g->nb_opts);
731 if (ret < 0)
732 return ret;
733
734 g->opts[g->nb_opts - 1].opt = opt;
735 g->opts[g->nb_opts - 1].key = key;
736 g->opts[g->nb_opts - 1].val = val;
737
738 return 0;
739}
740
742 const OptionGroupDef *groups, int nb_groups)
743{
744 static const OptionGroupDef global_group = { "global" };
745 int i;
746
747 memset(octx, 0, sizeof(*octx));
748
749 octx->groups = av_calloc(nb_groups, sizeof(*octx->groups));
750 if (!octx->groups)
751 return AVERROR(ENOMEM);
752 octx->nb_groups = nb_groups;
753
754 for (i = 0; i < octx->nb_groups; i++)
755 octx->groups[i].group_def = &groups[i];
756
757 octx->global_opts.group_def = &global_group;
758 octx->global_opts.arg = "";
759
760 return 0;
761}
762
764{
765 int i, j;
766
767 for (i = 0; i < octx->nb_groups; i++) {
768 OptionGroupList *l = &octx->groups[i];
769
770 for (j = 0; j < l->nb_groups; j++) {
771 av_freep(&l->groups[j].opts);
774
777 }
778 av_freep(&l->groups);
779 }
780 av_freep(&octx->groups);
781
782 av_freep(&octx->cur_group.opts);
783 av_freep(&octx->global_opts.opts);
784
785 uninit_opts();
786}
787
788int split_commandline(OptionParseContext *octx, int argc, char *argv[],
789 const OptionDef *options,
790 const OptionGroupDef *groups, int nb_groups)
791{
792 int ret;
793 int optindex = 1;
794 int dashdash = -2;
795
796 /* perform system-dependent conversions for arguments list */
797 prepare_app_arguments(&argc, &argv);
798
799 ret = init_parse_context(octx, groups, nb_groups);
800 if (ret < 0)
801 return ret;
802
803 av_log(NULL, AV_LOG_DEBUG, "Splitting the commandline.\n");
804
805 while (optindex < argc) {
806 const char *opt = argv[optindex++], *arg;
807 const OptionDef *po;
808 int group_idx;
809
810 av_log(NULL, AV_LOG_DEBUG, "Reading option '%s' ...", opt);
811
812 if (opt[0] == '-' && opt[1] == '-' && !opt[2]) {
813 dashdash = optindex;
814 continue;
815 }
816 /* unnamed group separators, e.g. output filename */
817 if (opt[0] != '-' || !opt[1] || dashdash+1 == optindex) {
818 ret = finish_group(octx, 0, opt);
819 if (ret < 0)
820 return ret;
821
822 av_log(NULL, AV_LOG_DEBUG, " matched as %s.\n", groups[0].name);
823 continue;
824 }
825 opt++;
826
827#define GET_ARG(arg) \
828do { \
829 arg = argv[optindex++]; \
830 if (!arg) { \
831 av_log(NULL, AV_LOG_ERROR, "Missing argument for option '%s'.\n", opt);\
832 return AVERROR(EINVAL); \
833 } \
834} while (0)
835
836 /* named group separators, e.g. -i */
837 group_idx = match_group_separator(groups, nb_groups, opt);
838 if (group_idx >= 0) {
839 GET_ARG(arg);
840 ret = finish_group(octx, group_idx, arg);
841 if (ret < 0)
842 return ret;
843
844 av_log(NULL, AV_LOG_DEBUG, " matched as %s with argument '%s'.\n",
845 groups[group_idx].name, arg);
846 continue;
847 }
848
849 /* normal options */
850 po = find_option(options, opt);
851 if (po->name) {
852 if (po->flags & OPT_EXIT) {
853 /* optional argument, e.g. -h */
854 arg = argv[optindex++];
855 } else if (opt_has_arg(po)) {
856 GET_ARG(arg);
857 } else {
858 arg = "1";
859 }
860
861 ret = add_opt(octx, po, opt, arg);
862 if (ret < 0)
863 return ret;
864
865 av_log(NULL, AV_LOG_DEBUG, " matched as option '%s' (%s) with "
866 "argument '%s'.\n", po->name, po->help, arg);
867 continue;
868 }
869
870 /* AVOptions */
871 if (argv[optindex]) {
872 ret = opt_default(NULL, opt, argv[optindex]);
873 if (ret >= 0) {
874 av_log(NULL, AV_LOG_DEBUG, " matched as AVOption '%s' with "
875 "argument '%s'.\n", opt, argv[optindex]);
876 optindex++;
877 continue;
878 } else if (ret != AVERROR_OPTION_NOT_FOUND) {
879 av_log(NULL, AV_LOG_ERROR, "Error parsing option '%s' "
880 "with argument '%s'.\n", opt, argv[optindex]);
881 return ret;
882 }
883 }
884
885 /* boolean -nofoo options */
886 if (opt[0] == 'n' && opt[1] == 'o' &&
887 (po = find_option(options, opt + 2)) &&
888 po->name && po->type == OPT_TYPE_BOOL) {
889 ret = add_opt(octx, po, opt, "0");
890 if (ret < 0)
891 return ret;
892
893 av_log(NULL, AV_LOG_DEBUG, " matched as option '%s' (%s) with "
894 "argument 0.\n", po->name, po->help);
895 continue;
896 }
897
898 av_log(NULL, AV_LOG_ERROR, "Unrecognized option '%s'.\n", opt);
900 }
901
902 if (octx->cur_group.nb_opts || codec_opts || format_opts)
903 av_log(NULL, AV_LOG_WARNING, "Trailing option(s) found in the "
904 "command: may be ignored.\n");
905
906 av_log(NULL, AV_LOG_DEBUG, "Finished splitting the commandline.\n");
907
908 return 0;
909}
910
911int read_yesno(void)
912{
913 int c = getchar();
914 int yesno = (av_toupper(c) == 'Y');
915
916 while (c != '\n' && c != EOF)
917 c = getchar();
918
919 return yesno;
920}
921
922FILE *get_preset_file(char *filename, size_t filename_size,
923 const char *preset_name, int is_path,
924 const char *codec_name)
925{
926 FILE *f = NULL;
927 int i;
928#if HAVE_GETMODULEHANDLE && defined(_WIN32)
929 char *datadir = NULL;
930#endif
931 char *env_home = getenv_utf8("HOME");
932 char *env_ffmpeg_datadir = getenv_utf8("FFMPEG_DATADIR");
933 const char *base[3] = { env_ffmpeg_datadir,
934 env_home, /* index=1(HOME) is special: search in a .ffmpeg subfolder */
935 FFMPEG_DATADIR, };
936
937 if (is_path) {
938 av_strlcpy(filename, preset_name, filename_size);
939 f = fopen_utf8(filename, "r");
940 } else {
941#if HAVE_GETMODULEHANDLE && defined(_WIN32)
942 wchar_t *datadir_w = get_module_filename(NULL);
943 base[2] = NULL;
944
945 if (wchartoutf8(datadir_w, &datadir))
946 datadir = NULL;
947 av_free(datadir_w);
948
949 if (datadir)
950 {
951 char *ls;
952 for (ls = datadir; *ls; ls++)
953 if (*ls == '\\') *ls = '/';
954
955 if (ls = strrchr(datadir, '/'))
956 {
957 ptrdiff_t datadir_len = ls - datadir;
958 size_t desired_size = datadir_len + strlen("/ffpresets") + 1;
959 char *new_datadir = av_realloc_array(
960 datadir, desired_size, sizeof *datadir);
961 if (new_datadir) {
962 datadir = new_datadir;
963 strcpy(datadir + datadir_len, "/ffpresets");
964 base[2] = datadir;
965 }
966 }
967 }
968#endif
969 for (i = 0; i < 3 && !f; i++) {
970 if (!base[i])
971 continue;
972 snprintf(filename, filename_size, "%s%s/%s.ffpreset", base[i],
973 i != 1 ? "" : "/.ffmpeg", preset_name);
974 f = fopen_utf8(filename, "r");
975 if (!f && codec_name) {
976 snprintf(filename, filename_size,
977 "%s%s/%s-%s.ffpreset",
978 base[i], i != 1 ? "" : "/.ffmpeg", codec_name,
979 preset_name);
980 f = fopen_utf8(filename, "r");
981 }
982 }
983 }
984
985#if HAVE_GETMODULEHANDLE && defined(_WIN32)
986 av_free(datadir);
987#endif
988 freeenv_utf8(env_ffmpeg_datadir);
989 freeenv_utf8(env_home);
990 return f;
991}
992
994{
995 return (c >= '0' && c <= '9') ||
996 (c >= 'A' && c <= 'Z') ||
997 (c >= 'a' && c <= 'z');
998}
999
1001{
1002 av_freep(&ss->meta_key);
1003 av_freep(&ss->meta_val);
1004 av_freep(&ss->remainder);
1005
1006 memset(ss, 0, sizeof(*ss));
1007}
1008
1010 int allow_remainder, void *logctx)
1011{
1012 char *endptr;
1013 int ret;
1014
1015 memset(ss, 0, sizeof(*ss));
1016
1017 ss->idx = -1;
1018 ss->media_type = AVMEDIA_TYPE_UNKNOWN;
1019 ss->stream_list = STREAM_LIST_ALL;
1020
1021 av_log(logctx, AV_LOG_TRACE, "Parsing stream specifier: %s\n", spec);
1022
1023 while (*spec) {
1024 if (*spec <= '9' && *spec >= '0') { /* opt:index */
1025 ss->idx = strtol(spec, &endptr, 0);
1026
1027 av_assert0(endptr > spec);
1028 spec = endptr;
1029
1030 av_log(logctx, AV_LOG_TRACE,
1031 "Parsed index: %d; remainder: %s\n", ss->idx, spec);
1032
1033 // this terminates the specifier
1034 break;
1035 } else if ((*spec == 'v' || *spec == 'a' || *spec == 's' ||
1036 *spec == 'd' || *spec == 't' || *spec == 'V') &&
1037 !cmdutils_isalnum(*(spec + 1))) { /* opt:[vasdtV] */
1038 if (ss->media_type != AVMEDIA_TYPE_UNKNOWN) {
1039 av_log(logctx, AV_LOG_ERROR, "Stream type specified multiple times\n");
1040 ret = AVERROR(EINVAL);
1041 goto fail;
1042 }
1043
1044 switch (*spec++) {
1045 case 'v': ss->media_type = AVMEDIA_TYPE_VIDEO; break;
1046 case 'a': ss->media_type = AVMEDIA_TYPE_AUDIO; break;
1047 case 's': ss->media_type = AVMEDIA_TYPE_SUBTITLE; break;
1048 case 'd': ss->media_type = AVMEDIA_TYPE_DATA; break;
1049 case 't': ss->media_type = AVMEDIA_TYPE_ATTACHMENT; break;
1050 case 'V': ss->media_type = AVMEDIA_TYPE_VIDEO;
1051 ss->no_apic = 1; break;
1052 default: av_assert0(0);
1053 }
1054
1055 av_log(logctx, AV_LOG_TRACE, "Parsed media type: %s; remainder: %s\n",
1056 av_get_media_type_string(ss->media_type), spec);
1057 } else if (*spec == 'g' && *(spec + 1) == ':') {
1058 if (ss->stream_list != STREAM_LIST_ALL)
1059 goto multiple_stream_lists;
1060
1061 spec += 2;
1062 if (*spec == '#' || (*spec == 'i' && *(spec + 1) == ':')) {
1063 ss->stream_list = STREAM_LIST_GROUP_ID;
1064
1065 spec += 1 + (*spec == 'i');
1066 } else
1067 ss->stream_list = STREAM_LIST_GROUP_IDX;
1068
1069 ss->list_id = strtol(spec, &endptr, 0);
1070 if (spec == endptr) {
1071 av_log(logctx, AV_LOG_ERROR, "Expected stream group idx/ID, got: %s\n", spec);
1072 ret = AVERROR(EINVAL);
1073 goto fail;
1074 }
1075 spec = endptr;
1076
1077 av_log(logctx, AV_LOG_TRACE, "Parsed stream group %s: %"PRId64"; remainder: %s\n",
1078 ss->stream_list == STREAM_LIST_GROUP_ID ? "ID" : "index", ss->list_id, spec);
1079 } else if (*spec == 'p' && *(spec + 1) == ':') {
1080 if (ss->stream_list != STREAM_LIST_ALL)
1081 goto multiple_stream_lists;
1082
1083 ss->stream_list = STREAM_LIST_PROGRAM;
1084
1085 spec += 2;
1086 ss->list_id = strtol(spec, &endptr, 0);
1087 if (spec == endptr) {
1088 av_log(logctx, AV_LOG_ERROR, "Expected program ID, got: %s\n", spec);
1089 ret = AVERROR(EINVAL);
1090 goto fail;
1091 }
1092 spec = endptr;
1093
1094 av_log(logctx, AV_LOG_TRACE,
1095 "Parsed program ID: %"PRId64"; remainder: %s\n", ss->list_id, spec);
1096 } else if (!strncmp(spec, "disp:", 5)) {
1097 const AVClass *st_class = av_stream_get_class();
1098 const AVOption *o = av_opt_find(&st_class, "disposition", NULL, 0, AV_OPT_SEARCH_FAKE_OBJ);
1099 char *disp = NULL;
1100 size_t len;
1101
1102 av_assert0(o);
1103
1104 if (ss->disposition) {
1105 av_log(logctx, AV_LOG_ERROR, "Multiple disposition specifiers\n");
1106 ret = AVERROR(EINVAL);
1107 goto fail;
1108 }
1109
1110 spec += 5;
1111
1112 for (len = 0; cmdutils_isalnum(spec[len]) ||
1113 spec[len] == '_' || spec[len] == '+'; len++)
1114 continue;
1115
1116 disp = av_strndup(spec, len);
1117 if (!disp) {
1118 ret = AVERROR(ENOMEM);
1119 goto fail;
1120 }
1121
1122 ret = av_opt_eval_flags(&st_class, o, disp, &ss->disposition);
1123 av_freep(&disp);
1124 if (ret < 0) {
1125 av_log(logctx, AV_LOG_ERROR, "Invalid disposition specifier\n");
1126 goto fail;
1127 }
1128
1129 spec += len;
1130
1131 av_log(logctx, AV_LOG_TRACE,
1132 "Parsed disposition: 0x%x; remainder: %s\n", ss->disposition, spec);
1133 } else if (*spec == '#' ||
1134 (*spec == 'i' && *(spec + 1) == ':')) {
1135 if (ss->stream_list != STREAM_LIST_ALL)
1136 goto multiple_stream_lists;
1137
1138 ss->stream_list = STREAM_LIST_STREAM_ID;
1139
1140 spec += 1 + (*spec == 'i');
1141 ss->list_id = strtol(spec, &endptr, 0);
1142 if (spec == endptr) {
1143 av_log(logctx, AV_LOG_ERROR, "Expected stream ID, got: %s\n", spec);
1144 ret = AVERROR(EINVAL);
1145 goto fail;
1146 }
1147 spec = endptr;
1148
1149 av_log(logctx, AV_LOG_TRACE,
1150 "Parsed stream ID: %"PRId64"; remainder: %s\n", ss->list_id, spec);
1151
1152 // this terminates the specifier
1153 break;
1154 } else if (*spec == 'm' && *(spec + 1) == ':') {
1155 av_assert0(!ss->meta_key && !ss->meta_val);
1156
1157 spec += 2;
1158 ss->meta_key = av_get_token(&spec, ":");
1159 if (!ss->meta_key) {
1160 ret = AVERROR(ENOMEM);
1161 goto fail;
1162 }
1163 if (*spec == ':') {
1164 spec++;
1165 ss->meta_val = av_get_token(&spec, ":");
1166 if (!ss->meta_val) {
1167 ret = AVERROR(ENOMEM);
1168 goto fail;
1169 }
1170 }
1171
1172 av_log(logctx, AV_LOG_TRACE,
1173 "Parsed metadata: %s:%s; remainder: %s", ss->meta_key,
1174 ss->meta_val ? ss->meta_val : "<any value>", spec);
1175
1176 // this terminates the specifier
1177 break;
1178 } else if (*spec == 'u' && (*(spec + 1) == '\0' || *(spec + 1) == ':')) {
1179 ss->usable_only = 1;
1180 spec++;
1181 av_log(logctx, AV_LOG_ERROR, "Parsed 'usable only'\n");
1182
1183 // this terminates the specifier
1184 break;
1185 } else
1186 break;
1187
1188 if (*spec == ':')
1189 spec++;
1190 }
1191
1192 if (*spec) {
1193 if (!allow_remainder) {
1194 av_log(logctx, AV_LOG_ERROR,
1195 "Trailing garbage at the end of a stream specifier: %s\n",
1196 spec);
1197 ret = AVERROR(EINVAL);
1198 goto fail;
1199 }
1200
1201 if (*spec == ':')
1202 spec++;
1203
1204 ss->remainder = av_strdup(spec);
1205 if (!ss->remainder) {
1206 ret = AVERROR(EINVAL);
1207 goto fail;
1208 }
1209 }
1210
1211 return 0;
1212
1213multiple_stream_lists:
1214 av_log(logctx, AV_LOG_ERROR,
1215 "Cannot combine multiple program/group designators in a "
1216 "single stream specifier");
1217 ret = AVERROR(EINVAL);
1218
1219fail:
1221 return ret;
1222}
1223
1225 const AVFormatContext *s, const AVStream *st,
1226 void *logctx)
1227{
1228 const AVStreamGroup *g = NULL;
1229 const AVProgram *p = NULL;
1230 int start_stream = 0, nb_streams;
1231 int nb_matched = 0;
1232
1233 switch (ss->stream_list) {
1235 // <n-th> stream with given ID makes no sense and should be impossible to request
1236 av_assert0(ss->idx < 0);
1237 // return early if we know for sure the stream does not match
1238 if (st->id != ss->list_id)
1239 return 0;
1240 start_stream = st->index;
1241 nb_streams = st->index + 1;
1242 break;
1243 case STREAM_LIST_ALL:
1244 start_stream = ss->idx >= 0 ? 0 : st->index;
1245 nb_streams = st->index + 1;
1246 break;
1248 for (unsigned i = 0; i < s->nb_programs; i++) {
1249 if (s->programs[i]->id == ss->list_id) {
1250 p = s->programs[i];
1251 break;
1252 }
1253 }
1254 if (!p) {
1255 av_log(logctx, AV_LOG_WARNING, "No program with ID %"PRId64" exists,"
1256 " stream specifier can never match\n", ss->list_id);
1257 return 0;
1258 }
1259 nb_streams = p->nb_stream_indexes;
1260 break;
1262 for (unsigned i = 0; i < s->nb_stream_groups; i++) {
1263 if (ss->list_id == s->stream_groups[i]->id) {
1264 g = s->stream_groups[i];
1265 break;
1266 }
1267 }
1270 if (ss->stream_list == STREAM_LIST_GROUP_IDX &&
1271 ss->list_id >= 0 && ss->list_id < s->nb_stream_groups)
1272 g = s->stream_groups[ss->list_id];
1273
1274 if (!g) {
1275 av_log(logctx, AV_LOG_WARNING, "No stream group with group %s %"
1276 PRId64" exists, stream specifier can never match\n",
1277 ss->stream_list == STREAM_LIST_GROUP_ID ? "ID" : "index",
1278 ss->list_id);
1279 return 0;
1280 }
1281 nb_streams = g->nb_streams;
1282 break;
1283 default: av_assert0(0);
1284 }
1285
1286 for (int i = start_stream; i < nb_streams; i++) {
1287 const AVStream *candidate = s->streams[g ? g->streams[i]->index :
1288 p ? p->stream_index[i] : i];
1289
1290 if (ss->media_type != AVMEDIA_TYPE_UNKNOWN &&
1291 (ss->media_type != candidate->codecpar->codec_type ||
1292 (ss->no_apic && (candidate->disposition & AV_DISPOSITION_ATTACHED_PIC))))
1293 continue;
1294
1295 if (ss->meta_key) {
1296 const AVDictionaryEntry *tag = av_dict_get(candidate->metadata,
1297 ss->meta_key, NULL, 0);
1298
1299 if (!tag)
1300 continue;
1301 if (ss->meta_val && strcmp(tag->value, ss->meta_val))
1302 continue;
1303 }
1304
1305 if (ss->usable_only) {
1306 const AVCodecParameters *par = candidate->codecpar;
1307
1308 switch (par->codec_type) {
1309 case AVMEDIA_TYPE_AUDIO:
1310 if (!par->sample_rate || !par->ch_layout.nb_channels ||
1311 par->format == AV_SAMPLE_FMT_NONE)
1312 continue;
1313 break;
1314 case AVMEDIA_TYPE_VIDEO:
1315 if (!par->width || !par->height || par->format == AV_PIX_FMT_NONE)
1316 continue;
1317 break;
1319 continue;
1320 }
1321 }
1322
1323 if (ss->disposition &&
1324 (candidate->disposition & ss->disposition) != ss->disposition)
1325 continue;
1326
1327 if (st == candidate)
1328 return ss->idx < 0 || ss->idx == nb_matched;
1329
1330 nb_matched++;
1331 }
1332
1333 return 0;
1334}
1335
1337{
1339 int ret;
1340
1341 ret = stream_specifier_parse(&ss, spec, 0, NULL);
1342 if (ret < 0)
1343 return ret;
1344
1345 ret = stream_specifier_match(&ss, s, st, NULL);
1347 return ret;
1348}
1349
1351 const AVFormatContext *s, const AVStreamGroup *stg,
1352 void *logctx)
1353{
1354 int start_stream_group = 0, nb_stream_groups;
1355 int nb_matched = 0;
1356
1357 if (ss->idx >= 0)
1358 return 0;
1359
1360 switch (ss->stream_list) {
1362 case STREAM_LIST_ALL:
1364 return 0;
1366 // <n-th> stream with given ID makes no sense and should be impossible to request
1367 av_assert0(ss->idx < 0);
1368 // return early if we know for sure the stream does not match
1369 if (stg->id != ss->list_id)
1370 return 0;
1371 start_stream_group = stg->index;
1372 nb_stream_groups = stg->index + 1;
1373 break;
1375 start_stream_group = ss->list_id >= 0 ? 0 : stg->index;
1376 nb_stream_groups = stg->index + 1;
1377 break;
1378 default: av_assert0(0);
1379 }
1380
1381 for (int i = start_stream_group; i < nb_stream_groups; i++) {
1382 const AVStreamGroup *candidate = s->stream_groups[i];
1383
1384 if (ss->meta_key) {
1385 const AVDictionaryEntry *tag = av_dict_get(candidate->metadata,
1386 ss->meta_key, NULL, 0);
1387
1388 if (!tag)
1389 continue;
1390 if (ss->meta_val && strcmp(tag->value, ss->meta_val))
1391 continue;
1392 }
1393
1394 if (ss->usable_only) {
1395 switch (candidate->type) {
1397 const AVStreamGroupTileGrid *tg = candidate->params.tile_grid;
1398 if (!tg->coded_width || !tg->coded_height || !tg->nb_tiles ||
1399 !tg->width || !tg->height || !tg->offsets)
1400 continue;
1401 break;
1402 }
1403 default:
1404 continue;
1405 }
1406 }
1407
1408 if (ss->disposition &&
1409 (candidate->disposition & ss->disposition) != ss->disposition)
1410 continue;
1411
1412 if (stg == candidate)
1413 return ss->list_id < 0 || ss->list_id == nb_matched;
1414
1415 nb_matched++;
1416 }
1417
1418 return 0;
1419}
1420
1422 AVFormatContext *s, AVStream *st, const AVCodec *codec,
1423 AVDictionary **dst, AVDictionary **opts_used)
1424{
1425 AVDictionary *ret = NULL;
1426 const AVDictionaryEntry *t = NULL;
1427 int flags = s->oformat ? AV_OPT_FLAG_ENCODING_PARAM
1429 char prefix = 0;
1430 const AVClass *cc = avcodec_get_class();
1431
1432 switch (st->codecpar->codec_type) {
1433 case AVMEDIA_TYPE_VIDEO:
1434 prefix = 'v';
1436 break;
1437 case AVMEDIA_TYPE_AUDIO:
1438 prefix = 'a';
1440 break;
1442 prefix = 's';
1444 break;
1445 }
1446
1447 while (t = av_dict_iterate(opts, t)) {
1448 const AVClass *priv_class;
1449 char *p = strchr(t->key, ':');
1450 int used = 0;
1451
1452 /* check stream specification in opt name */
1453 if (p) {
1454 int err = check_stream_specifier(s, st, p + 1);
1455 if (err < 0) {
1456 av_dict_free(&ret);
1457 return err;
1458 } else if (!err)
1459 continue;
1460
1461 *p = 0;
1462 }
1463
1465 !codec ||
1466 ((priv_class = codec->priv_class) &&
1467 av_opt_find(&priv_class, t->key, NULL, flags,
1469 av_dict_set(&ret, t->key, t->value, 0);
1470 used = 1;
1471 } else if (t->key[0] == prefix &&
1472 av_opt_find(&cc, t->key + 1, NULL, flags,
1474 av_dict_set(&ret, t->key + 1, t->value, 0);
1475 used = 1;
1476 }
1477
1478 if (p)
1479 *p = ':';
1480
1481 if (used && opts_used)
1482 av_dict_set(opts_used, t->key, "", 0);
1483 }
1484
1485 *dst = ret;
1486 return 0;
1487}
1488
1490 AVDictionary *local_codec_opts,
1491 AVDictionary ***dst)
1492{
1493 int ret;
1495
1496 *dst = NULL;
1497
1498 if (!s->nb_streams)
1499 return 0;
1500
1501 opts = av_calloc(s->nb_streams, sizeof(*opts));
1502 if (!opts)
1503 return AVERROR(ENOMEM);
1504
1505 for (int i = 0; i < s->nb_streams; i++) {
1506 ret = filter_codec_opts(local_codec_opts, s->streams[i]->codecpar->codec_id,
1507 s, s->streams[i], NULL, &opts[i], NULL);
1508 if (ret < 0)
1509 goto fail;
1510 }
1511 *dst = opts;
1512 return 0;
1513fail:
1514 for (int i = 0; i < s->nb_streams; i++)
1515 av_dict_free(&opts[i]);
1516 av_freep(&opts);
1517 return ret;
1518}
1519
1520int grow_array(void **array, int elem_size, int *size, int new_size)
1521{
1522 if (new_size >= INT_MAX / elem_size) {
1523 av_log(NULL, AV_LOG_ERROR, "Array too big.\n");
1524 return AVERROR(ERANGE);
1525 }
1526 if (*size < new_size) {
1527 uint8_t *tmp = av_realloc_array(*array, new_size, elem_size);
1528 if (!tmp)
1529 return AVERROR(ENOMEM);
1530 memset(tmp + *size*elem_size, 0, (new_size-*size) * elem_size);
1531 *size = new_size;
1532 *array = tmp;
1533 return 0;
1534 }
1535 return 0;
1536}
1537
1538void *allocate_array_elem(void *ptr, size_t elem_size, int *nb_elems)
1539{
1540 void *new_elem;
1541
1542 new_elem = av_mallocz(elem_size);
1543 if (!new_elem)
1544 return NULL;
1545 if (av_dynarray_add_nofree(ptr, nb_elems, new_elem) < 0)
1546 av_freep(&new_elem);
1547
1548 return new_elem;
1549}
1550
1551double get_rotation(const int32_t *displaymatrix)
1552{
1553 double theta = 0;
1554 if (displaymatrix)
1555 theta = -round(av_display_rotation_get(displaymatrix));
1556
1557 theta -= 360*floor(theta/360 + 0.9/360);
1558
1559 if (fabs(theta - 90*round(theta/90)) > 2)
1560 av_log(NULL, AV_LOG_WARNING, "Odd rotation angle.\n"
1561 "If you want to help, upload a sample "
1562 "of this file to https://streams.videolan.org/upload/ "
1563 "and contact the ffmpeg-devel mailing list. (ffmpeg-devel@ffmpeg.org)");
1564
1565 return theta;
1566}
1567
1568/* read file contents into a string */
1569char *read_file_to_string(const char *filename)
1570{
1571 AVIOContext *pb = NULL;
1572 int ret = avio_open(&pb, filename, AVIO_FLAG_READ);
1573 AVBPrint bprint;
1574 char *str;
1575
1576 if (ret < 0) {
1577 av_log(NULL, AV_LOG_ERROR, "Error opening file %s.\n", filename);
1578 return NULL;
1579 }
1580
1582 ret = avio_read_to_bprint(pb, &bprint, SIZE_MAX);
1583 avio_closep(&pb);
1584 if (ret < 0) {
1585 av_bprint_finalize(&bprint, NULL);
1586 return NULL;
1587 }
1588 ret = av_bprint_finalize(&bprint, &str);
1589 if (ret < 0)
1590 return NULL;
1591 return str;
1592}
1593
1595{
1596 const AVDictionaryEntry *t = NULL;
1597
1598 while ((t = av_dict_iterate(b, t))) {
1600 }
1601}
1602
1604{
1605 const AVDictionaryEntry *t = av_dict_iterate(m, NULL);
1606 if (t) {
1607 av_log(NULL, AV_LOG_FATAL, "Option %s not found.\n", t->key);
1609 }
1610
1611 return 0;
1612}
1613
1614void dump_dictionary(void *ctx, const AVDictionary *m,
1615 const char *name, const char *indent,
1616 int log_level)
1617{
1618 const AVDictionaryEntry *tag = NULL;
1619
1620 if (!m)
1621 return;
1622
1623 av_log(ctx, log_level, "%s%s:\n", indent, name);
1624 while ((tag = av_dict_iterate(m, tag))) {
1625 const char *p = tag->value;
1626 av_log(ctx, log_level, "%s %-16s: ", indent, tag->key);
1627 while (*p) {
1628 size_t len = strcspn(p, "\x8\xa\xb\xc\xd");
1629 av_log(ctx, log_level, "%.*s", (int)(FFMIN(255, len)), p);
1630 p += len;
1631 if (*p == 0xd) av_log(ctx, log_level, " ");
1632 if (*p == 0xa) av_log(ctx, log_level, "\n%s %-16s: ", indent, "");
1633 if (*p) p++;
1634 }
1635 av_log(ctx, log_level, "\n");
1636 }
1637}
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
Definition dsp.h:87
static double val(void *priv, double ch)
Definition aeval.c:77
#define class
Definition math.h:25
static AVFormatContext * ctx
static void finish(void)
static AVDictionary * opts
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:42
Main libavformat public API header.
@ AV_STREAM_GROUP_PARAMS_TILE_GRID
Definition avformat.h:1152
#define AV_DISPOSITION_ATTACHED_PIC
The stream is stored in the file as an attached picture/"cover art" (e.g.
Definition avformat.h:694
int avio_open(AVIOContext **s, const char *filename, int flags)
Create and initialize a AVIOContext for accessing the resource indicated by url.
Definition avio.c:565
int avio_closep(AVIOContext **s)
Close the resource accessed by the AVIOContext *s, free it and set the pointer pointing to it to NULL...
Definition avio.c:717
#define AVIO_FLAG_READ
read-only
Definition avio.h:617
int avio_read_to_bprint(AVIOContext *h, struct AVBPrint *pb, size_t max_size)
Read contents of h into print buffer, up to max_size bytes, or up to EOF.
Definition aviobuf.c:1254
size_t av_strlcatf(char *dst, size_t size, const char *fmt,...)
Definition avstring.c:103
void av_bprint_init(AVBPrint *buf, unsigned size_init, unsigned size_max)
Definition bprint.c:68
AVBPrint public header.
#define AV_BPRINT_SIZE_UNLIMITED
#define flags(name, subs,...)
Definition cbs_h264.c:74
#define i(width, name, range_min, range_max)
Definition cbs_h264.c:63
#define f(width, name)
Definition cbs_vp8.c:236
#define ss(width, name, subs,...)
Definition cbs_vp9.c:202
#define s(width, name)
Definition cbs_vp9.c:198
unsigned stream_group_specifier_match(const StreamSpecifier *ss, const AVFormatContext *s, const AVStreamGroup *stg, void *logctx)
Definition cmdutils.c:1350
static int match_group_separator(const OptionGroupDef *groups, int nb_groups, const char *opt)
Definition cmdutils.c:669
int parse_optgroup(void *optctx, OptionGroup *g, const OptionDef *defs)
Parse an options group and write results into optctx.
Definition cmdutils.c:454
static int opt_has_arg(const OptionDef *o)
Definition cmdutils.c:229
int hide_banner
Definition cmdutils.c:58
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:138
static void prepare_app_arguments(int *argc_ptr, char ***argv_ptr)
Definition cmdutils.c:223
void init_dynload(void)
Initialize dynamic library loading.
Definition cmdutils.c:73
int parse_option(void *optctx, const char *opt, const char *arg, const OptionDef *options)
Parse one given option.
Definition cmdutils.c:378
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:597
int check_avoptions(AVDictionary *m)
Definition cmdutils.c:1603
void dump_dictionary(void *ctx, const AVDictionary *m, const char *name, const char *indent, int log_level)
This does the same as libavformat/dump.c corresponding function and should probably be kept in sync w...
Definition cmdutils.c:1614
AVDictionary * swr_opts
Definition cmdutils.c:55
int read_yesno(void)
Return a positive value if a line read from standard input starts with [yY], otherwise return 0.
Definition cmdutils.c:911
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:487
static void dump_argument(FILE *report_file, const char *a)
Definition cmdutils.c:514
static const AVOption * opt_find(void *obj, const char *name, const char *unit, int opt_flags, int search_flags)
Definition cmdutils.c:587
int cmdutils_isalnum(char c)
Definition cmdutils.c:993
int stream_specifier_parse(StreamSpecifier *ss, const char *spec, int allow_remainder, void *logctx)
Parse a stream specifier string into a form suitable for matching.
Definition cmdutils.c:1009
int check_stream_specifier(AVFormatContext *s, AVStream *st, const char *spec)
Check if the given stream matches a stream specifier.
Definition cmdutils.c:1336
#define FLAGS
Definition cmdutils.c:596
#define GET_ARG(arg)
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:554
static int add_opt(OptionParseContext *octx, const OptionDef *opt, const char *key, const char *val)
Definition cmdutils.c:723
void show_help_options(const OptionDef *options, const char *msg, int req_flags, int rej_flags)
Print help for all options matching specified flags.
Definition cmdutils.c:105
void uninit_parse_context(OptionParseContext *octx)
Free all allocated memory in an OptionParseContext.
Definition cmdutils.c:763
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:788
void log_callback_help(void *ptr, int level, const char *fmt, va_list vl)
Trivial log callback.
Definition cmdutils.c:68
void * allocate_array_elem(void *ptr, size_t elem_size, int *nb_elems)
Atomically add a new element to an array of pointers, i.e.
Definition cmdutils.c:1538
AVDictionary * format_opts
Definition cmdutils.c:56
int parse_options(void *optctx, int argc, char **argv, const OptionDef *options, int(*parse_arg_function)(void *, const char *))
Parse the command line arguments.
Definition cmdutils.c:418
int filter_codec_opts(const AVDictionary *opts, enum AVCodecID codec_id, AVFormatContext *s, AVStream *st, const AVCodec *codec, AVDictionary **dst, AVDictionary **opts_used)
Filter out options for given codec.
Definition cmdutils.c:1421
char * read_file_to_string(const char *filename)
Definition cmdutils.c:1569
void remove_avoptions(AVDictionary **a, AVDictionary *b)
Definition cmdutils.c:1594
AVDictionary * codec_opts
Definition cmdutils.c:56
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:922
static int finish_group(OptionParseContext *octx, int group_idx, const char *arg)
Definition cmdutils.c:689
unsigned stream_specifier_match(const StreamSpecifier *ss, const AVFormatContext *s, const AVStream *st, void *logctx)
Definition cmdutils.c:1224
void uninit_opts(void)
Uninitialize the cmdutils option system, in particular free the *_opts contexts and their contents.
Definition cmdutils.c:60
double get_rotation(const int32_t *displaymatrix)
Definition cmdutils.c:1551
int setup_find_stream_info_opts(AVFormatContext *s, AVDictionary *local_codec_opts, AVDictionary ***dst)
Setup AVCodecContext options for avformat_find_stream_info().
Definition cmdutils.c:1489
static const OptionDef * find_option(const OptionDef *po, const char *name)
Definition cmdutils.c:151
int 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:1520
static int write_option(void *optctx, const OptionDef *po, const char *opt, const char *arg, const OptionDef *defs)
Definition cmdutils.c:238
int parse_number(const char *context, const char *numstr, enum OptionType type, double min, double max, double *dst)
Parse a string and return its corresponding value as a double.
Definition cmdutils.c:82
void stream_specifier_uninit(StreamSpecifier *ss)
Definition cmdutils.c:1000
static void check_options(const OptionDef *po)
Definition cmdutils.c:538
static int init_parse_context(OptionParseContext *octx, const OptionGroupDef *groups, int nb_groups)
Definition cmdutils.c:741
AVDictionary * sws_dict
Definition cmdutils.c:54
#define OPT_FUNC_ARG
Definition cmdutils.h:205
#define OPT_FLAG_SPEC
Definition cmdutils.h:228
#define OPT_PERFILE
Definition cmdutils.h:219
#define OPT_FLAG_OFFSET
Definition cmdutils.h:223
#define OPT_INPUT
Definition cmdutils.h:237
OptionType
Definition cmdutils.h:80
@ OPT_TYPE_BOOL
Definition cmdutils.h:82
@ OPT_TYPE_STRING
Definition cmdutils.h:83
@ OPT_TYPE_INT64
Definition cmdutils.h:85
@ OPT_TYPE_INT
Definition cmdutils.h:84
@ OPT_TYPE_DOUBLE
Definition cmdutils.h:87
@ OPT_TYPE_TIME
Definition cmdutils.h:88
@ OPT_TYPE_FUNC
Definition cmdutils.h:81
@ OPT_TYPE_FLOAT
Definition cmdutils.h:86
#define GROW_ARRAY(array, nb_elems)
Definition cmdutils.h:536
#define OPT_FLAG_PERSTREAM
Definition cmdutils.h:232
@ STREAM_LIST_ALL
Definition cmdutils.h:106
@ STREAM_LIST_PROGRAM
Definition cmdutils.h:108
@ STREAM_LIST_GROUP_IDX
Definition cmdutils.h:110
@ STREAM_LIST_STREAM_ID
Definition cmdutils.h:107
@ STREAM_LIST_GROUP_ID
Definition cmdutils.h:109
#define OPT_EXIT
Definition cmdutils.h:207
#define OPT_OUTPUT
Definition cmdutils.h:238
#define OPT_HAS_CANON
Definition cmdutils.h:245
#define OPT_DECODER
Definition cmdutils.h:248
#define NULL
Definition coverity.c:32
long long int64_t
Definition coverity.c:34
__device__ int printf(const char *,...)
static __device__ float fabs(float a)
static __device__ float floor(float a)
#define min(a, b)
#define max(a, b)
static const uint16_t fc[]
Definition dcaenc.h:43
Public dictionary API.
Display matrix.
double av_strtod(const char *numstr, char **tail)
Parse the string in numstr and return its value as a double.
Definition eval.c:110
simple arithmetic expression evaluator
const char * key
static const OptionGroupDef groups[]
static unsigned int nb_streams
Definition ffprobe.c:352
static FILE * fopen_utf8(const char *path, const char *mode)
Definition fopen_utf8.h:66
static char * getenv_utf8(const char *varname)
Definition getenv_utf8.h:67
static void freeenv_utf8(char *var)
Definition getenv_utf8.h:72
#define fail
Definition test.h:479
#define AV_OPT_FLAG_AUDIO_PARAM
Definition opt.h:356
#define AV_OPT_FLAG_DECODING_PARAM
A generic parameter which can be set by the user for demuxing or decoding.
Definition opt.h:355
#define AV_OPT_FLAG_VIDEO_PARAM
Definition opt.h:357
#define AV_OPT_FLAG_ENCODING_PARAM
A generic parameter which can be set by the user for muxing or encoding.
Definition opt.h:351
#define AV_OPT_FLAG_SUBTITLE_PARAM
Definition opt.h:358
const AVClass * avcodec_get_class(void)
Get the AVClass for AVCodecContext.
Definition options.c:184
AVCodecID
Identify the syntax and semantics of the bitstream.
Definition codec_id.h:47
const AVClass * av_stream_get_class(void)
Get the AVClass for AVStream.
Definition options.c:242
const AVClass * avformat_get_class(void)
Get the AVClass for AVFormatContext.
Definition options.c:193
int av_bprint_finalize(AVBPrint *buf, char **ret_str)
Finalize a print buffer.
Definition bprint.c:234
void av_dict_free(AVDictionary **pm)
Free all the memory allocated for an AVDictionary struct and all keys and values.
Definition dict.c:233
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:60
const AVDictionaryEntry * av_dict_iterate(const AVDictionary *m, const AVDictionaryEntry *prev)
Iterate over a dictionary.
Definition dict.c:42
int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags)
Set the given entry in *pm, overwriting an existing entry.
Definition dict.c:86
#define AV_DICT_MATCH_CASE
Only get an entry with exact-case key match.
Definition dict.h:74
#define AVERROR_EXIT
Immediate exit was requested; the called function should not be restarted.
Definition error.h:58
#define av_err2str(errnum)
Convenience macro, the return value should be used only directly in function arguments but never stan...
Definition error.h:122
#define AVERROR(e)
Definition error.h:45
#define AVERROR_OPTION_NOT_FOUND
Option not found.
Definition error.h:63
#define AV_LOG_TRACE
Extremely verbose debugging, useful for libav* development.
Definition log.h:236
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
Definition log.h:231
#define AV_LOG_WARNING
Something somehow does not look correct.
Definition log.h:216
#define AV_LOG_FATAL
Something went wrong and recovery is not possible.
Definition log.h:204
#define AV_LOG_VERBOSE
Detailed information.
Definition log.h:226
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition log.h:210
void av_log_set_level(int level)
Set the log level.
Definition log.c:476
int av_dynarray_add_nofree(void *tab_ptr, int *nb_ptr, void *elem)
Add an element to a dynamic array.
Definition mem.c:313
char * av_strndup(const char *s, size_t len)
Duplicate a substring of a string.
Definition mem.c:284
void * av_realloc_array(void *ptr, size_t nmemb, size_t size)
Definition mem.c:217
const char * av_get_media_type_string(enum AVMediaType media_type)
Return a string describing the media_type enum, NULL if media_type is unknown.
Definition utils.c:28
@ AVMEDIA_TYPE_ATTACHMENT
Opaque data information usually sparse.
Definition avutil.h:204
@ AVMEDIA_TYPE_AUDIO
Definition avutil.h:201
@ AVMEDIA_TYPE_SUBTITLE
Definition avutil.h:203
@ AVMEDIA_TYPE_VIDEO
Definition avutil.h:200
@ AVMEDIA_TYPE_DATA
Opaque data information usually continuous.
Definition avutil.h:202
@ AVMEDIA_TYPE_UNKNOWN
Usually treated as AVMEDIA_TYPE_DATA.
Definition avutil.h:199
@ AV_SAMPLE_FMT_NONE
Definition samplefmt.h:56
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:95
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:36
size_t av_strlcpy(char *dst, const char *src, size_t size)
Copy the string src to dst, but no more than size - 1 bytes, and null-terminate dst.
Definition avstring.c:85
char * av_get_token(const char **buf, const char *term)
Unescape the given string until a non escaped terminating char, and return the token corresponding to...
Definition avstring.c:143
static av_const int av_toupper(int c)
Locale-independent conversion of ASCII characters to uppercase.
Definition avstring.h:227
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:133
const AVClass * swr_get_class(void)
Get the AVClass for SwrContext.
Definition options.c:143
int av_opt_eval_flags(void *obj, const AVOption *o, const char *val, int *flags_out)
const AVClass * av_opt_child_class_iterate(const AVClass *parent, void **iter)
Iterate over potential AVOptions-enabled children of parent.
Definition opt.c:2130
#define AV_OPT_SEARCH_CHILDREN
Search in possible children of the given object first.
Definition opt.h:604
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:2071
#define AV_OPT_SEARCH_FAKE_OBJ
The obj passed to av_opt_find() or av_opt_set() is fake – only a double pointer to AVClass instead of...
Definition opt.h:612
int av_opt_show2(void *obj, void *av_log_obj, int req_flags, int rej_flags)
Show the obj options.
Definition opt.c:1746
int a
cl_device_type type
#define b
Definition input.c:43
unsigned offset
Definition libaomenc.c:763
const char * arg
Definition jacosubdec.c:65
#define av_fallthrough
Definition attributes.h:67
#define FFMIN(a, b)
Definition macros.h:49
#define INFINITY
void * av_calloc(size_t nmemb, size_t size)
Definition mem.c:264
Memory handling functions.
uint32_t tag
Definition movenc.c:2087
#define av_strdup(s)
Definition ops_static.c:55
AVOptions.
int opt_loglevel(void *optctx, const char *opt, const char *arg)
Set the libav* libraries log level.
static FILE * report_file
Definition opt_common.c:76
int init_report(const char *env, FILE **file)
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:592
misc parsing utilities
@ AV_PIX_FMT_NONE
Definition pixfmt.h:72
const char * name
Definition qsvenc.c:142
int nb_channels
Number of channels in this layout.
Describe the class of an AVClass context structure.
Definition log.h:76
This struct describes the properties of an encoded stream.
Definition codec_par.h:49
int height
The height of the video frame in pixels.
Definition codec_par.h:150
AVChannelLayout ch_layout
The channel layout and number of channels.
Definition codec_par.h:207
int width
The width of the video frame in pixels.
Definition codec_par.h:143
enum AVMediaType codec_type
General type of the encoded data.
Definition codec_par.h:53
int sample_rate
The number of audio samples per second.
Definition codec_par.h:213
AVCodec.
Definition codec.h:175
const AVClass * priv_class
AVClass for the private context.
Definition codec.h:197
char * key
Definition dict.h:91
char * value
Definition dict.h:92
Format I/O context.
Definition avformat.h:1335
Bytestream IO Context.
Definition avio.h:160
AVOption.
Definition opt.h:428
int flags
A combination of AV_OPT_FLAG_*.
Definition opt.h:471
New fields can be added to the end with minor version bumps.
Definition avformat.h:1259
AVStreamGroupTileGrid holds information on how to combine several independent images on a single canv...
Definition avformat.h:975
int width
Width of the final image for presentation.
Definition avformat.h:1060
int height
Height of the final image for presentation.
Definition avformat.h:1070
int coded_width
Width of the canvas.
Definition avformat.h:990
struct AVStreamGroupTileGrid::@036353327352337314037001273105074056331305251354 * offsets
An nb_tiles sized array of offsets in pixels from the topleft edge of the canvas, indicating where ea...
unsigned int nb_tiles
Amount of tiles in the grid.
Definition avformat.h:983
int coded_height
Width of the canvas.
Definition avformat.h:996
union AVStreamGroup::@166361102046003066253145020066347265153020354020 params
Group type-specific parameters.
enum AVStreamGroupParamsType type
Group type.
Definition avformat.h:1188
struct AVStreamGroupTileGrid * tile_grid
Definition avformat.h:1196
AVDictionary * metadata
Metadata that applies to the whole group.
Definition avformat.h:1216
unsigned int index
Group index in AVFormatContext.
Definition avformat.h:1172
int disposition
Stream group disposition - a combination of AV_DISPOSITION_* flags.
Definition avformat.h:1246
int64_t id
Group type-specific group ID.
Definition avformat.h:1180
Stream structure.
Definition avformat.h:768
AVCodecParameters * codecpar
Codec parameters associated with this stream.
Definition avformat.h:791
AVDictionary * metadata
Definition avformat.h:848
int id
Format-specific stream ID.
Definition avformat.h:780
int index
stream index in AVFormatContext
Definition avformat.h:774
int disposition
Stream disposition - a combination of AV_DISPOSITION_* flags.
Definition avformat.h:837
int flags
Definition cmdutils.h:198
size_t off
Definition cmdutils.h:253
const char * name
Definition cmdutils.h:196
union OptionDef::@124325020351351046145113015057017340133060321367 u
const char * name_canon
Definition cmdutils.h:261
const char * argname
Definition cmdutils.h:256
void * dst_ptr
Definition cmdutils.h:251
const char * help
Definition cmdutils.h:255
enum OptionType type
Definition cmdutils.h:197
union OptionDef::@302341376237271032103161277113207234376351006005 u1
int(* func_arg)(void *, const char *, const char *)
Definition cmdutils.h:252
A list of option groups that all have the same group type (e.g.
Definition cmdutils.h:357
OptionGroup * groups
Definition cmdutils.h:360
const OptionGroupDef * group_def
Definition cmdutils.h:358
const OptionGroupDef * group_def
Definition cmdutils.h:341
AVDictionary * codec_opts
Definition cmdutils.h:347
AVDictionary * swr_opts
Definition cmdutils.h:350
Option * opts
Definition cmdutils.h:344
AVDictionary * sws_dict
Definition cmdutils.h:349
const char * arg
Definition cmdutils.h:342
AVDictionary * format_opts
Definition cmdutils.h:348
OptionGroup global_opts
Definition cmdutils.h:365
OptionGroupList * groups
Definition cmdutils.h:367
OptionGroup cur_group
Definition cmdutils.h:371
An option extracted from the commandline.
Definition cmdutils.h:319
const char * key
Definition cmdutils.h:321
const OptionDef * opt
Definition cmdutils.h:320
const char * val
Definition cmdutils.h:322
enum OptionType type
Definition cmdutils.h:192
SpecifierOpt * opt
Definition cmdutils.h:184
const struct OptionDef * opt_canon
Definition cmdutils.h:188
StreamSpecifier stream_spec
Definition cmdutils.h:171
union SpecifierOpt::@356325016025214271156003270003007057215065005026 u
char * specifier
Definition cmdutils.h:169
uint8_t level
Definition svq3.c:208
libswresample public header
external API header
#define av_free(p)
#define av_mallocz(s)
#define av_freep(p)
#define av_log(a,...)
static void error(const char *err)
static uint8_t tmp[40]
Definition aes_ctr.c:52
static int array[MAX_W *MAX_W]
int size
char prefix[8]
enum AVCodecID codec_id
const char * g
Definition vf_curves.c:128
int len
uint8_t base
Definition vp3data.h:128
static double c[64]