parse_option(o, "s", norm == PAL ? "352x288" : "352x240", options);
parse_option(o, "r", frame_rates[norm], options);
- opt_default("g", norm == PAL ? "15" : "18");
+ opt_default(NULL, "g", norm == PAL ? "15" : "18");
- opt_default("b", "1150000");
- opt_default("maxrate", "1150000");
- opt_default("minrate", "1150000");
- opt_default("bufsize", "327680"); // 40*1024*8;
+ opt_default(NULL, "b", "1150000");
+ opt_default(NULL, "maxrate", "1150000");
+ opt_default(NULL, "minrate", "1150000");
+ opt_default(NULL, "bufsize", "327680"); // 40*1024*8;
- opt_default("b:a", "224000");
+ opt_default(NULL, "b:a", "224000");
parse_option(o, "ar", "44100", options);
parse_option(o, "ac", "2", options);
- opt_default("packetsize", "2324");
- opt_default("muxrate", "1411200"); // 2352 * 75 * 8;
+ opt_default(NULL, "packetsize", "2324");
+ opt_default(NULL, "muxrate", "1411200"); // 2352 * 75 * 8;
/* We have to offset the PTS, so that it is consistent with the SCR.
SCR starts at 36000, but the first two packs contain only padding
parse_option(o, "s", norm == PAL ? "480x576" : "480x480", options);
parse_option(o, "r", frame_rates[norm], options);
- opt_default("g", norm == PAL ? "15" : "18");
+ opt_default(NULL, "g", norm == PAL ? "15" : "18");
- opt_default("b", "2040000");
- opt_default("maxrate", "2516000");
- opt_default("minrate", "0"); // 1145000;
- opt_default("bufsize", "1835008"); // 224*1024*8;
- opt_default("flags", "+scan_offset");
+ opt_default(NULL, "b", "2040000");
+ opt_default(NULL, "maxrate", "2516000");
+ opt_default(NULL, "minrate", "0"); // 1145000;
+ opt_default(NULL, "bufsize", "1835008"); // 224*1024*8;
+ opt_default(NULL, "flags", "+scan_offset");
- opt_default("b:a", "224000");
+ opt_default(NULL, "b:a", "224000");
parse_option(o, "ar", "44100", options);
- opt_default("packetsize", "2324");
+ opt_default(NULL, "packetsize", "2324");
} else if (!strcmp(arg, "dvd")) {
parse_option(o, "s", norm == PAL ? "720x576" : "720x480", options);
parse_option(o, "r", frame_rates[norm], options);
- opt_default("g", norm == PAL ? "15" : "18");
+ opt_default(NULL, "g", norm == PAL ? "15" : "18");
- opt_default("b", "6000000");
- opt_default("maxrate", "9000000");
- opt_default("minrate", "0"); // 1500000;
- opt_default("bufsize", "1835008"); // 224*1024*8;
+ opt_default(NULL, "b", "6000000");
+ opt_default(NULL, "maxrate", "9000000");
+ opt_default(NULL, "minrate", "0"); // 1500000;
+ opt_default(NULL, "bufsize", "1835008"); // 224*1024*8;
- opt_default("packetsize", "2048"); // from www.mpucoder.com: DVD sectors contain 2048 bytes of data, this is also the size of one pack.
- opt_default("muxrate", "10080000"); // from mplex project: data_rate = 1260000. mux_rate = data_rate * 8
+ opt_default(NULL, "packetsize", "2048"); // from www.mpucoder.com: DVD sectors contain 2048 bytes of data, this is also the size of one pack.
+ opt_default(NULL, "muxrate", "10080000"); // from mplex project: data_rate = 1260000. mux_rate = data_rate * 8
- opt_default("b:a", "448000");
+ opt_default(NULL, "b:a", "448000");
parse_option(o, "ar", "48000", options);
} else if (!strncmp(arg, "dv", 2)) {
return 0;
}
-static int opt_vstats_file(const char *opt, const char *arg)
+static int opt_vstats_file(void *optctx, const char *opt, const char *arg)
{
av_free (vstats_filename);
vstats_filename = av_strdup (arg);
return 0;
}
-static int opt_vstats(const char *opt, const char *arg)
+static int opt_vstats(void *optctx, const char *opt, const char *arg)
{
char filename[40];
time_t today2 = time(NULL);
snprintf(filename, sizeof(filename), "vstats_%02d%02d%02d.log", today->tm_hour, today->tm_min,
today->tm_sec);
- return opt_vstats_file(opt, filename);
+ return opt_vstats_file(NULL, opt, filename);
}
static int opt_video_frames(void *optctx, const char *opt, const char *arg)
return parse_option(o, "filter:a", arg, options);
}
-static int opt_vsync(const char *opt, const char *arg)
+static int opt_vsync(void *optctx, const char *opt, const char *arg)
{
if (!av_strcasecmp(arg, "cfr")) video_sync_method = VSYNC_CFR;
else if (!av_strcasecmp(arg, "vfr")) video_sync_method = VSYNC_VFR;
return 0;
}
-static int opt_deinterlace(const char *opt, const char *arg)
+static int opt_deinterlace(void *optctx, const char *opt, const char *arg)
{
av_log(NULL, AV_LOG_WARNING, "-%s is deprecated, use -filter:v yadif instead\n", opt);
do_deinterlace = 1;
return 0;
}
-int opt_cpuflags(const char *opt, const char *arg)
+int opt_cpuflags(void *optctx, const char *opt, const char *arg)
{
int flags = av_parse_cpu_flags(arg);
return AVERROR(EINVAL);
}
snprintf(layout_str, sizeof(layout_str), "%"PRIu64, layout);
- ret = opt_default(opt, layout_str);
+ ret = opt_default(NULL, opt, layout_str);
if (ret < 0)
return ret;
return parse_option(o, "q:a", arg, options);
}
-static int opt_filter_complex(const char *opt, const char *arg)
+static int opt_filter_complex(void *optctx, const char *opt, const char *arg)
{
filtergraphs = grow_array(filtergraphs, sizeof(*filtergraphs),
&nb_filtergraphs, nb_filtergraphs + 1);
void show_help_default(const char *opt, const char *arg)
{
/* per-file options have at least one of those set */
- const int per_file = OPT_SPEC | OPT_OFFSET | OPT_FUNC2;
+ const int per_file = OPT_SPEC | OPT_OFFSET | OPT_PERFILE;
int show_advanced = 0, show_avoptions = 0;
if (opt) {
#include "cmdutils_common_opts.h"
{ "f", HAS_ARG | OPT_STRING | OPT_OFFSET, { .off = OFFSET(format) },
"force format", "fmt" },
- { "i", HAS_ARG | OPT_FUNC2, { .func2_arg = opt_input_file },
+ { "i", HAS_ARG | OPT_PERFILE, { .func_arg = opt_input_file },
"input file name", "filename" },
{ "y", OPT_BOOL, { &file_overwrite },
"overwrite output files" },
"codec name", "codec" },
{ "pre", HAS_ARG | OPT_STRING | OPT_SPEC, { .off = OFFSET(presets) },
"preset name", "preset" },
- { "map", HAS_ARG | OPT_EXPERT | OPT_FUNC2, { .func2_arg = opt_map },
+ { "map", HAS_ARG | OPT_EXPERT | OPT_PERFILE, { .func_arg = opt_map },
"set input stream mapping",
"[-]input_file_id[:stream_specifier][,sync_file_id[:stream_specifier]]" },
{ "map_metadata", HAS_ARG | OPT_STRING | OPT_SPEC, { .off = OFFSET(metadata_map) },
"set the input ts scale", "scale" },
{ "metadata", HAS_ARG | OPT_STRING | OPT_SPEC, { .off = OFFSET(metadata) },
"add metadata", "string=string" },
- { "dframes", HAS_ARG | OPT_FUNC2 | OPT_EXPERT, { .func2_arg = opt_data_frames },
+ { "dframes", HAS_ARG | OPT_PERFILE | OPT_EXPERT, { .func_arg = opt_data_frames },
"set the number of data frames to record", "number" },
{ "benchmark", OPT_BOOL | OPT_EXPERT, { &do_benchmark },
"add timings for benchmarking" },
"when dumping packets, also dump the payload" },
{ "re", OPT_BOOL | OPT_EXPERT | OPT_OFFSET, { .off = OFFSET(rate_emu) },
"read input at native frame rate", "" },
- { "target", HAS_ARG | OPT_FUNC2, { .func2_arg = opt_target },
+ { "target", HAS_ARG | OPT_PERFILE, { .func_arg = opt_target },
"specify target file type (\"vcd\", \"svcd\", \"dvd\","
" \"dv\", \"dv50\", \"pal-vcd\", \"ntsc-svcd\", ...)", "type" },
{ "vsync", HAS_ARG | OPT_EXPERT, { opt_vsync },
"create a complex filtergraph", "graph_description" },
{ "stats", OPT_BOOL, { &print_stats },
"print progress report during encoding", },
- { "attach", HAS_ARG | OPT_FUNC2 | OPT_EXPERT, { .func2_arg = opt_attach },
+ { "attach", HAS_ARG | OPT_PERFILE | OPT_EXPERT, { .func_arg = opt_attach },
"add an attachment to the output file", "filename" },
{ "dump_attachment", HAS_ARG | OPT_STRING | OPT_SPEC |OPT_EXPERT,{ .off = OFFSET(dump_attachment) },
"extract an attachment into a file", "filename" },
"set CPU flags mask", "mask" },
/* video options */
- { "vframes", OPT_VIDEO | HAS_ARG | OPT_FUNC2, { .func2_arg = opt_video_frames },
+ { "vframes", OPT_VIDEO | HAS_ARG | OPT_PERFILE, { .func_arg = opt_video_frames },
"set the number of video frames to record", "number" },
{ "r", OPT_VIDEO | HAS_ARG | OPT_STRING | OPT_SPEC, { .off = OFFSET(frame_rates) },
"set frame rate (Hz value, fraction or abbreviation)", "rate" },
"discard threshold", "n" },
{ "rc_override", OPT_VIDEO | HAS_ARG | OPT_EXPERT | OPT_STRING | OPT_SPEC, { .off = OFFSET(rc_overrides) },
"rate control override for specific intervals", "override" },
- { "vcodec", OPT_VIDEO | HAS_ARG | OPT_FUNC2, { .func2_arg = opt_video_codec },
+ { "vcodec", OPT_VIDEO | HAS_ARG | OPT_PERFILE, { .func_arg = opt_video_codec },
"force video codec ('copy' to copy stream)", "codec" },
{ "same_quant", OPT_VIDEO | OPT_BOOL | OPT_EXPERT, { &same_quant },
"use same quantizer as source (implies VBR)" },
"dump video coding statistics to file" },
{ "vstats_file", OPT_VIDEO | HAS_ARG | OPT_EXPERT , { opt_vstats_file },
"dump video coding statistics to file", "file" },
- { "vf", OPT_VIDEO | HAS_ARG | OPT_FUNC2, { .func2_arg = opt_video_filters },
+ { "vf", OPT_VIDEO | HAS_ARG | OPT_PERFILE, { .func_arg = opt_video_filters },
"video filters", "filter list" },
{ "intra_matrix", OPT_VIDEO | HAS_ARG | OPT_EXPERT | OPT_STRING | OPT_SPEC, { .off = OFFSET(intra_matrices) },
"specify intra matrix coeffs", "matrix" },
"top=1/bottom=0/auto=-1 field first", "" },
{ "dc", OPT_VIDEO | OPT_INT | HAS_ARG | OPT_EXPERT , { &intra_dc_precision },
"intra_dc_precision", "precision" },
- { "vtag", OPT_VIDEO | HAS_ARG | OPT_EXPERT | OPT_FUNC2, { .func2_arg = opt_video_tag },
+ { "vtag", OPT_VIDEO | HAS_ARG | OPT_EXPERT | OPT_PERFILE, { .func_arg = opt_video_tag },
"force video tag/fourcc", "fourcc/tag" },
{ "qphist", OPT_VIDEO | OPT_BOOL | OPT_EXPERT , { &qp_hist },
"show QP histogram" },
{ "force_fps", OPT_VIDEO | OPT_BOOL | OPT_EXPERT | OPT_SPEC, { .off = OFFSET(force_fps) },
"force the selected framerate, disable the best supported framerate selection" },
- { "streamid", OPT_VIDEO | HAS_ARG | OPT_EXPERT | OPT_FUNC2, { .func2_arg = opt_streamid },
+ { "streamid", OPT_VIDEO | HAS_ARG | OPT_EXPERT | OPT_PERFILE, { .func_arg = opt_streamid },
"set the value of an outfile streamid", "streamIndex:value" },
{ "force_key_frames", OPT_VIDEO | OPT_STRING | HAS_ARG | OPT_EXPERT | OPT_SPEC,
{ .off = OFFSET(forced_key_frames) }, "force key frames at specified timestamps", "timestamps" },
/* audio options */
- { "aframes", OPT_AUDIO | HAS_ARG | OPT_FUNC2, { .func2_arg = opt_audio_frames },
+ { "aframes", OPT_AUDIO | HAS_ARG | OPT_PERFILE, { .func_arg = opt_audio_frames },
"set the number of audio frames to record", "number" },
- { "aq", OPT_AUDIO | HAS_ARG | OPT_FUNC2, { .func2_arg = opt_audio_qscale },
+ { "aq", OPT_AUDIO | HAS_ARG | OPT_PERFILE, { .func_arg = opt_audio_qscale },
"set audio quality (codec-specific)", "quality", },
{ "ar", OPT_AUDIO | HAS_ARG | OPT_INT | OPT_SPEC, { .off = OFFSET(audio_sample_rate) },
"set audio sampling rate (in Hz)", "rate" },
"set number of audio channels", "channels" },
{ "an", OPT_AUDIO | OPT_BOOL | OPT_OFFSET, { .off = OFFSET(audio_disable) },
"disable audio" },
- { "acodec", OPT_AUDIO | HAS_ARG | OPT_FUNC2, { .func2_arg = opt_audio_codec },
+ { "acodec", OPT_AUDIO | HAS_ARG | OPT_PERFILE, { .func_arg = opt_audio_codec },
"force audio codec ('copy' to copy stream)", "codec" },
- { "atag", OPT_AUDIO | HAS_ARG | OPT_EXPERT | OPT_FUNC2, { .func2_arg = opt_audio_tag },
+ { "atag", OPT_AUDIO | HAS_ARG | OPT_EXPERT | OPT_PERFILE, { .func_arg = opt_audio_tag },
"force audio tag/fourcc", "fourcc/tag" },
{ "vol", OPT_AUDIO | HAS_ARG | OPT_INT, { &audio_volume },
"change audio volume (256=normal)" , "volume" },
{ "sample_fmt", OPT_AUDIO | HAS_ARG | OPT_EXPERT | OPT_SPEC | OPT_STRING, { .off = OFFSET(sample_fmts) },
"set sample format", "format" },
- { "channel_layout", OPT_AUDIO | HAS_ARG | OPT_EXPERT | OPT_FUNC2, { .func2_arg = opt_channel_layout },
+ { "channel_layout", OPT_AUDIO | HAS_ARG | OPT_EXPERT | OPT_PERFILE, { .func_arg = opt_channel_layout },
"set channel layout", "layout" },
- { "af", OPT_AUDIO | HAS_ARG | OPT_FUNC2, { .func2_arg = opt_audio_filters },
+ { "af", OPT_AUDIO | HAS_ARG | OPT_PERFILE, { .func_arg = opt_audio_filters },
"audio filters", "filter list" },
/* subtitle options */
{ "sn", OPT_SUBTITLE | OPT_BOOL | OPT_OFFSET, { .off = OFFSET(subtitle_disable) },
"disable subtitle" },
- { "scodec", OPT_SUBTITLE | HAS_ARG | OPT_FUNC2, { .func2_arg = opt_subtitle_codec },
+ { "scodec", OPT_SUBTITLE | HAS_ARG | OPT_PERFILE, { .func_arg = opt_subtitle_codec },
"force subtitle codec ('copy' to copy stream)", "codec" },
- { "stag", OPT_SUBTITLE | HAS_ARG | OPT_EXPERT | OPT_FUNC2, { .func2_arg = opt_subtitle_tag }
+ { "stag", OPT_SUBTITLE | HAS_ARG | OPT_EXPERT | OPT_PERFILE, { .func_arg = opt_subtitle_tag }
, "force subtitle tag/fourcc", "fourcc/tag" },
/* grab options */
"A comma-separated list of bitstream filters", "bitstream_filters" },
/* data codec support */
- { "dcodec", HAS_ARG | OPT_DATA | OPT_FUNC2 | OPT_EXPERT, { .func2_arg = opt_data_codec },
+ { "dcodec", HAS_ARG | OPT_DATA | OPT_PERFILE | OPT_EXPERT, { .func_arg = opt_data_codec },
"force data codec ('copy' to copy stream)", "codec" },
{ "default", HAS_ARG | OPT_AUDIO | OPT_VIDEO | OPT_EXPERT, { .func_arg = opt_default },
} else if (po->flags & OPT_DOUBLE) {
*(double *)dst = parse_number_or_die(opt, arg, OPT_DOUBLE, -INFINITY, INFINITY);
} else if (po->u.func_arg) {
- int ret = po->flags & OPT_FUNC2 ? po->u.func2_arg(optctx, opt, arg)
- : po->u.func_arg(opt, arg);
+ int ret = po->u.func_arg(optctx, opt, arg);
if (ret < 0) {
av_log(NULL, AV_LOG_ERROR,
"Failed to set value '%s' for option '%s'\n", arg, opt);
if (!idx)
idx = locate_option(argc, argv, options, "v");
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
-int opt_default(const char *opt, const char *arg)
+int opt_default(void *optctx, const char *opt, const char *arg)
{
const AVOption *o;
char opt_stripped[128];
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[] = {
{ "quiet" , AV_LOG_QUIET },
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
int lim = parse_number_or_die(opt, arg, OPT_INT64, 0, INT_MAX);
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);
printf("%s " LIBAV_VERSION "\n", program_name);
return 0;
}
-int show_license(const char *opt, const char *arg)
+int show_license(void *optctx, const char *opt, const char *arg)
{
printf(
#if CONFIG_NONFREE
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;
AVOutputFormat *ofmt = NULL;
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;
}
}
-int show_decoders(const char *opt, const char *arg)
+int show_decoders(void *optctx, const char *opt, const char *arg)
{
print_codecs(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);
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;
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;
const char *name;
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;
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;
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;
char fmt_str[128];
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;
av_log_set_callback(log_callback_help);
* Fallback for options that are not explicitly handled, these will be
* 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.
*/
-int opt_loglevel(const char *opt, const char *arg);
+int opt_loglevel(void *optctx, const char *opt, const char *arg);
/**
* 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.
#define OPT_INT64 0x0400
#define OPT_EXIT 0x0800
#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_SPEC 0x8000 /* option is to be stored in an array of SpecifierOpt.
Implies OPT_OFFSET. Next element after the offset is
#define OPT_DOUBLE 0x20000
union {
void *dst_ptr;
- int (*func_arg)(const char *, const char *);
- int (*func2_arg)(void *, const char *, const char *);
+ int (*func_arg)(void *, const char *, const char *);
size_t off;
} u;
const char *help;
/**
* 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.
* depends on the current versions of the repository and of the libav*
* 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
* 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
* 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
* 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
* 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
* 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
* 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
* 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
* 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
* 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
* 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