Commit 9d3009c6 authored by Anton Khirnov's avatar Anton Khirnov

avconv: print an error on applying options of the wrong type.

I.e. input options to output files or vice versa.
parent e460aa32
This diff is collapsed.
...@@ -351,6 +351,16 @@ int parse_optgroup(void *optctx, OptionGroup *g) ...@@ -351,6 +351,16 @@ int parse_optgroup(void *optctx, OptionGroup *g)
for (i = 0; i < g->nb_opts; i++) { for (i = 0; i < g->nb_opts; i++) {
Option *o = &g->opts[i]; Option *o = &g->opts[i];
if (g->group_def->flags &&
!(g->group_def->flags & o->opt->flags)) {
av_log(NULL, AV_LOG_ERROR, "Option %s (%s) cannot be applied to "
"%s %s -- you are trying to apply an input option to an "
"output file or vice versa. Move this option before the "
"file it belongs to.\n", o->key, o->opt->help,
g->group_def->name, g->arg);
return AVERROR(EINVAL);
}
av_log(NULL, AV_LOG_DEBUG, "Applying option %s (%s) with argument %s.\n", av_log(NULL, AV_LOG_DEBUG, "Applying option %s (%s) with argument %s.\n",
o->key, o->opt->help, o->val); o->key, o->opt->help, o->val);
......
...@@ -144,6 +144,8 @@ typedef struct OptionDef { ...@@ -144,6 +144,8 @@ typedef struct OptionDef {
an int containing element count in the array. */ an int containing element count in the array. */
#define OPT_TIME 0x10000 #define OPT_TIME 0x10000
#define OPT_DOUBLE 0x20000 #define OPT_DOUBLE 0x20000
#define OPT_INPUT 0x40000
#define OPT_OUTPUT 0x80000
union { union {
void *dst_ptr; void *dst_ptr;
int (*func_arg)(void *, const char *, const char *); int (*func_arg)(void *, const char *, const char *);
...@@ -224,6 +226,11 @@ typedef struct OptionGroupDef { ...@@ -224,6 +226,11 @@ typedef struct OptionGroupDef {
* are terminated by a non-option argument (e.g. avconv output files) * are terminated by a non-option argument (e.g. avconv output files)
*/ */
const char *sep; const char *sep;
/**
* Option flags that must be set on each option that is
* applied to this group
*/
int flags;
} OptionGroupDef; } OptionGroupDef;
typedef struct OptionGroup { typedef struct OptionGroup {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment