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