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