Commit 11d957fb authored by Anton Khirnov's avatar Anton Khirnov

avtools: remove the distinction between func_arg and func2_arg.

func2_arg is the same as func_arg, except it has one additional
parameter. Change all func_arg callbacks to take that parameter (and
ignore it).
parent bbcedade
...@@ -2398,7 +2398,7 @@ static void parse_cpuflags(int argc, char **argv, const OptionDef *options) ...@@ -2398,7 +2398,7 @@ static void parse_cpuflags(int argc, char **argv, const OptionDef *options)
{ {
int idx = locate_option(argc, argv, options, "cpuflags"); int idx = locate_option(argc, argv, options, "cpuflags");
if (idx && argv[idx + 1]) if (idx && argv[idx + 1])
opt_cpuflags("cpuflags", argv[idx + 1]); opt_cpuflags(NULL, "cpuflags", argv[idx + 1]);
} }
int main(int argc, char **argv) int main(int argc, char **argv)
......
...@@ -352,7 +352,7 @@ extern const OptionDef options[]; ...@@ -352,7 +352,7 @@ extern const OptionDef options[];
void reset_options(OptionsContext *o); void reset_options(OptionsContext *o);
void show_usage(void); void show_usage(void);
int opt_cpuflags(const char *opt, const char *arg); int opt_cpuflags(void *optctx, const char *opt, const char *arg);
void opt_output_file(void *optctx, const char *filename); void opt_output_file(void *optctx, const char *filename);
......
This diff is collapsed.
...@@ -794,7 +794,7 @@ static void show_usage(void) ...@@ -794,7 +794,7 @@ static void show_usage(void)
printf("\n"); printf("\n");
} }
static int opt_format(const char *opt, const char *arg) static int opt_format(void *optctx, const char *opt, const char *arg)
{ {
iformat = av_find_input_format(arg); iformat = av_find_input_format(arg);
if (!iformat) { if (!iformat) {
...@@ -804,7 +804,7 @@ static int opt_format(const char *opt, const char *arg) ...@@ -804,7 +804,7 @@ static int opt_format(const char *opt, const char *arg)
return 0; return 0;
} }
static int opt_output_format(const char *opt, const char *arg) static int opt_output_format(void *optctx, const char *opt, const char *arg)
{ {
if (!strcmp(arg, "json")) { if (!strcmp(arg, "json")) {
...@@ -838,7 +838,7 @@ static int opt_output_format(const char *opt, const char *arg) ...@@ -838,7 +838,7 @@ static int opt_output_format(const char *opt, const char *arg)
return 0; return 0;
} }
static int opt_show_format_entry(const char *opt, const char *arg) static int opt_show_format_entry(void *optctx, const char *opt, const char *arg)
{ {
do_show_format = 1; do_show_format = 1;
nb_fmt_entries_to_show++; nb_fmt_entries_to_show++;
...@@ -877,7 +877,7 @@ void show_help_default(const char *opt, const char *arg) ...@@ -877,7 +877,7 @@ void show_help_default(const char *opt, const char *arg)
show_help_children(avformat_get_class(), AV_OPT_FLAG_DECODING_PARAM); show_help_children(avformat_get_class(), AV_OPT_FLAG_DECODING_PARAM);
} }
static int opt_pretty(const char *opt, const char *arg) static int opt_pretty(void *optctx, const char *opt, const char *arg)
{ {
show_value_unit = 1; show_value_unit = 1;
use_value_prefix = 1; use_value_prefix = 1;
......
...@@ -286,8 +286,7 @@ int parse_option(void *optctx, const char *opt, const char *arg, ...@@ -286,8 +286,7 @@ int parse_option(void *optctx, const char *opt, const char *arg,
} else if (po->flags & OPT_DOUBLE) { } else if (po->flags & OPT_DOUBLE) {
*(double *)dst = parse_number_or_die(opt, arg, OPT_DOUBLE, -INFINITY, INFINITY); *(double *)dst = parse_number_or_die(opt, arg, OPT_DOUBLE, -INFINITY, INFINITY);
} else if (po->u.func_arg) { } else if (po->u.func_arg) {
int ret = po->flags & OPT_FUNC2 ? po->u.func2_arg(optctx, opt, arg) int ret = po->u.func_arg(optctx, opt, arg);
: po->u.func_arg(opt, arg);
if (ret < 0) { if (ret < 0) {
av_log(NULL, AV_LOG_ERROR, av_log(NULL, AV_LOG_ERROR,
"Failed to set value '%s' for option '%s'\n", arg, opt); "Failed to set value '%s' for option '%s'\n", arg, opt);
...@@ -362,11 +361,11 @@ void parse_loglevel(int argc, char **argv, const OptionDef *options) ...@@ -362,11 +361,11 @@ void parse_loglevel(int argc, char **argv, const OptionDef *options)
if (!idx) if (!idx)
idx = locate_option(argc, argv, options, "v"); idx = locate_option(argc, argv, options, "v");
if (idx && argv[idx + 1]) if (idx && argv[idx + 1])
opt_loglevel("loglevel", argv[idx + 1]); opt_loglevel(NULL, "loglevel", argv[idx + 1]);
} }
#define FLAGS (o->type == AV_OPT_TYPE_FLAGS) ? AV_DICT_APPEND : 0 #define FLAGS (o->type == AV_OPT_TYPE_FLAGS) ? AV_DICT_APPEND : 0
int opt_default(const char *opt, const char *arg) int opt_default(void *optctx, const char *opt, const char *arg)
{ {
const AVOption *o; const AVOption *o;
char opt_stripped[128]; char opt_stripped[128];
...@@ -401,7 +400,7 @@ int opt_default(const char *opt, const char *arg) ...@@ -401,7 +400,7 @@ int opt_default(const char *opt, const char *arg)
return AVERROR_OPTION_NOT_FOUND; return AVERROR_OPTION_NOT_FOUND;
} }
int opt_loglevel(const char *opt, const char *arg) int opt_loglevel(void *optctx, const char *opt, const char *arg)
{ {
const struct { const char *name; int level; } log_levels[] = { const struct { const char *name; int level; } log_levels[] = {
{ "quiet" , AV_LOG_QUIET }, { "quiet" , AV_LOG_QUIET },
...@@ -436,7 +435,7 @@ int opt_loglevel(const char *opt, const char *arg) ...@@ -436,7 +435,7 @@ int opt_loglevel(const char *opt, const char *arg)
return 0; return 0;
} }
int opt_timelimit(const char *opt, const char *arg) int opt_timelimit(void *optctx, const char *opt, const char *arg)
{ {
#if HAVE_SETRLIMIT #if HAVE_SETRLIMIT
int lim = parse_number_or_die(opt, arg, OPT_INT64, 0, INT_MAX); int lim = parse_number_or_die(opt, arg, OPT_INT64, 0, INT_MAX);
...@@ -516,7 +515,7 @@ void show_banner(void) ...@@ -516,7 +515,7 @@ void show_banner(void)
print_all_libs_info(INDENT|SHOW_VERSION, AV_LOG_VERBOSE); print_all_libs_info(INDENT|SHOW_VERSION, AV_LOG_VERBOSE);
} }
int show_version(const char *opt, const char *arg) int show_version(void *optctx, const char *opt, const char *arg)
{ {
av_log_set_callback(log_callback_help); av_log_set_callback(log_callback_help);
printf("%s " LIBAV_VERSION "\n", program_name); printf("%s " LIBAV_VERSION "\n", program_name);
...@@ -525,7 +524,7 @@ int show_version(const char *opt, const char *arg) ...@@ -525,7 +524,7 @@ int show_version(const char *opt, const char *arg)
return 0; return 0;
} }
int show_license(const char *opt, const char *arg) int show_license(void *optctx, const char *opt, const char *arg)
{ {
printf( printf(
#if CONFIG_NONFREE #if CONFIG_NONFREE
...@@ -596,7 +595,7 @@ int show_license(const char *opt, const char *arg) ...@@ -596,7 +595,7 @@ int show_license(const char *opt, const char *arg)
return 0; return 0;
} }
int show_formats(const char *opt, const char *arg) int show_formats(void *optctx, const char *opt, const char *arg)
{ {
AVInputFormat *ifmt = NULL; AVInputFormat *ifmt = NULL;
AVOutputFormat *ofmt = NULL; AVOutputFormat *ofmt = NULL;
...@@ -736,7 +735,7 @@ static void print_codecs_for_id(enum AVCodecID id, int encoder) ...@@ -736,7 +735,7 @@ static void print_codecs_for_id(enum AVCodecID id, int encoder)
printf(")"); printf(")");
} }
int show_codecs(const char *opt, const char *arg) int show_codecs(void *optctx, const char *opt, const char *arg)
{ {
const AVCodecDescriptor *desc = NULL; const AVCodecDescriptor *desc = NULL;
...@@ -815,19 +814,19 @@ static void print_codecs(int encoder) ...@@ -815,19 +814,19 @@ static void print_codecs(int encoder)
} }
} }
int show_decoders(const char *opt, const char *arg) int show_decoders(void *optctx, const char *opt, const char *arg)
{ {
print_codecs(0); print_codecs(0);
return 0; return 0;
} }
int show_encoders(const char *opt, const char *arg) int show_encoders(void *optctx, const char *opt, const char *arg)
{ {
print_codecs(1); print_codecs(1);
return 0; return 0;
} }
int show_bsfs(const char *opt, const char *arg) int show_bsfs(void *optctx, const char *opt, const char *arg)
{ {
AVBitStreamFilter *bsf = NULL; AVBitStreamFilter *bsf = NULL;
...@@ -838,7 +837,7 @@ int show_bsfs(const char *opt, const char *arg) ...@@ -838,7 +837,7 @@ int show_bsfs(const char *opt, const char *arg)
return 0; return 0;
} }
int show_protocols(const char *opt, const char *arg) int show_protocols(void *optctx, const char *opt, const char *arg)
{ {
void *opaque = NULL; void *opaque = NULL;
const char *name; const char *name;
...@@ -853,7 +852,7 @@ int show_protocols(const char *opt, const char *arg) ...@@ -853,7 +852,7 @@ int show_protocols(const char *opt, const char *arg)
return 0; return 0;
} }
int show_filters(const char *opt, const char *arg) int show_filters(void *optctx, const char *opt, const char *arg)
{ {
AVFilter av_unused(**filter) = NULL; AVFilter av_unused(**filter) = NULL;
...@@ -865,7 +864,7 @@ int show_filters(const char *opt, const char *arg) ...@@ -865,7 +864,7 @@ int show_filters(const char *opt, const char *arg)
return 0; return 0;
} }
int show_pix_fmts(const char *opt, const char *arg) int show_pix_fmts(void *optctx, const char *opt, const char *arg)
{ {
enum PixelFormat pix_fmt; enum PixelFormat pix_fmt;
...@@ -898,7 +897,7 @@ int show_pix_fmts(const char *opt, const char *arg) ...@@ -898,7 +897,7 @@ int show_pix_fmts(const char *opt, const char *arg)
return 0; return 0;
} }
int show_sample_fmts(const char *opt, const char *arg) int show_sample_fmts(void *optctx, const char *opt, const char *arg)
{ {
int i; int i;
char fmt_str[128]; char fmt_str[128];
...@@ -993,7 +992,7 @@ static void show_help_muxer(const char *name) ...@@ -993,7 +992,7 @@ static void show_help_muxer(const char *name)
show_help_children(fmt->priv_class, AV_OPT_FLAG_ENCODING_PARAM); show_help_children(fmt->priv_class, AV_OPT_FLAG_ENCODING_PARAM);
} }
int show_help(const char *opt, const char *arg) int show_help(void *optctx, const char *opt, const char *arg)
{ {
char *topic, *par; char *topic, *par;
av_log_set_callback(log_callback_help); av_log_set_callback(log_callback_help);
......
...@@ -65,17 +65,17 @@ void log_callback_help(void* ptr, int level, const char* fmt, va_list vl); ...@@ -65,17 +65,17 @@ void log_callback_help(void* ptr, int level, const char* fmt, va_list vl);
* Fallback for options that are not explicitly handled, these will be * Fallback for options that are not explicitly handled, these will be
* parsed through AVOptions. * parsed through AVOptions.
*/ */
int opt_default(const char *opt, const char *arg); int opt_default(void *optctx, const char *opt, const char *arg);
/** /**
* Set the libav* libraries log level. * Set the libav* libraries log level.
*/ */
int opt_loglevel(const char *opt, const char *arg); int opt_loglevel(void *optctx, const char *opt, const char *arg);
/** /**
* Limit the execution time. * Limit the execution time.
*/ */
int opt_timelimit(const char *opt, const char *arg); int opt_timelimit(void *optctx, const char *opt, const char *arg);
/** /**
* Parse a string and return its corresponding value as a double. * Parse a string and return its corresponding value as a double.
...@@ -136,7 +136,8 @@ typedef struct { ...@@ -136,7 +136,8 @@ typedef struct {
#define OPT_INT64 0x0400 #define OPT_INT64 0x0400
#define OPT_EXIT 0x0800 #define OPT_EXIT 0x0800
#define OPT_DATA 0x1000 #define OPT_DATA 0x1000
#define OPT_FUNC2 0x2000 #define OPT_PERFILE 0x2000 /* the option is per-file (currently avconv-only).
implied by OPT_OFFSET or OPT_SPEC */
#define OPT_OFFSET 0x4000 /* option is specified as an offset in a passed optctx */ #define OPT_OFFSET 0x4000 /* option is specified as an offset in a passed optctx */
#define OPT_SPEC 0x8000 /* option is to be stored in an array of SpecifierOpt. #define OPT_SPEC 0x8000 /* option is to be stored in an array of SpecifierOpt.
Implies OPT_OFFSET. Next element after the offset is Implies OPT_OFFSET. Next element after the offset is
...@@ -145,8 +146,7 @@ typedef struct { ...@@ -145,8 +146,7 @@ typedef struct {
#define OPT_DOUBLE 0x20000 #define OPT_DOUBLE 0x20000
union { union {
void *dst_ptr; void *dst_ptr;
int (*func_arg)(const char *, const char *); int (*func_arg)(void *, const char *, const char *);
int (*func2_arg)(void *, const char *, const char *);
size_t off; size_t off;
} u; } u;
const char *help; const char *help;
...@@ -180,7 +180,7 @@ void show_help_default(const char *opt, const char *arg); ...@@ -180,7 +180,7 @@ void show_help_default(const char *opt, const char *arg);
/** /**
* Generic -h handler common to all avtools. * Generic -h handler common to all avtools.
*/ */
int show_help(const char *opt, const char *arg); int show_help(void *optctx, const char *opt, const char *arg);
/** /**
* Parse the command line arguments. * Parse the command line arguments.
...@@ -277,67 +277,67 @@ void show_banner(void); ...@@ -277,67 +277,67 @@ void show_banner(void);
* depends on the current versions of the repository and of the libav* * depends on the current versions of the repository and of the libav*
* libraries. * libraries.
*/ */
int show_version(const char *opt, const char *arg); int show_version(void *optctx, const char *opt, const char *arg);
/** /**
* Print the license of the program to stdout. The license depends on * Print the license of the program to stdout. The license depends on
* the license of the libraries compiled into the program. * the license of the libraries compiled into the program.
*/ */
int show_license(const char *opt, const char *arg); int show_license(void *optctx, const char *opt, const char *arg);
/** /**
* Print a listing containing all the formats supported by the * Print a listing containing all the formats supported by the
* program. * program.
*/ */
int show_formats(const char *opt, const char *arg); int show_formats(void *optctx, const char *opt, const char *arg);
/** /**
* Print a listing containing all the codecs supported by the * Print a listing containing all the codecs supported by the
* program. * program.
*/ */
int show_codecs(const char *opt, const char *arg); int show_codecs(void *optctx, const char *opt, const char *arg);
/** /**
* Print a listing containing all the decoders supported by the * Print a listing containing all the decoders supported by the
* program. * program.
*/ */
int show_decoders(const char *opt, const char *arg); int show_decoders(void *optctx, const char *opt, const char *arg);
/** /**
* Print a listing containing all the encoders supported by the * Print a listing containing all the encoders supported by the
* program. * program.
*/ */
int show_encoders(const char *opt, const char *arg); int show_encoders(void *optctx, const char *opt, const char *arg);
/** /**
* Print a listing containing all the filters supported by the * Print a listing containing all the filters supported by the
* program. * program.
*/ */
int show_filters(const char *opt, const char *arg); int show_filters(void *optctx, const char *opt, const char *arg);
/** /**
* Print a listing containing all the bit stream filters supported by the * Print a listing containing all the bit stream filters supported by the
* program. * program.
*/ */
int show_bsfs(const char *opt, const char *arg); int show_bsfs(void *optctx, const char *opt, const char *arg);
/** /**
* Print a listing containing all the protocols supported by the * Print a listing containing all the protocols supported by the
* program. * program.
*/ */
int show_protocols(const char *opt, const char *arg); int show_protocols(void *optctx, const char *opt, const char *arg);
/** /**
* Print a listing containing all the pixel formats supported by the * Print a listing containing all the pixel formats supported by the
* program. * program.
*/ */
int show_pix_fmts(const char *opt, const char *arg); int show_pix_fmts(void *optctx, const char *opt, const char *arg);
/** /**
* Print a listing containing all the sample formats supported by the * Print a listing containing all the sample formats supported by the
* program. * program.
*/ */
int show_sample_fmts(const char *opt, const char *arg); int show_sample_fmts(void *optctx, const char *opt, const char *arg);
/** /**
* Return a positive value if a line read from standard input * Return a positive value if a line read from standard input
......
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