Discussion:
[PATCH 02/17] lavc: add avcodec_descriptor_get_by_name().
(too old to reply)
Anton Khirnov
2012-08-15 08:37:15 UTC
Permalink
---
libavcodec/avcodec.h | 2 ++
libavcodec/codec_desc.c | 13 +++++++++++++
2 files changed, 15 insertions(+)

diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index b6917a0..e544071 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -4548,6 +4548,8 @@ const AVCodecDescriptor *avcodec_descriptor_get(enum AVCodecID id);
*/
const AVCodecDescriptor *avcodec_descriptor_next(const AVCodecDescriptor *prev);

+const AVCodecDescriptor *avcodec_descriptor_get_by_name(const char *name);
+
/**
* @}
*/
diff --git a/libavcodec/codec_desc.c b/libavcodec/codec_desc.c
index a0c1fd2..c181baa 100644
--- a/libavcodec/codec_desc.c
+++ b/libavcodec/codec_desc.c
@@ -16,6 +16,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/

+#include <string.h>
+
#include "avcodec.h"

#include "libavutil/internal.h"
@@ -1938,3 +1940,14 @@ const AVCodecDescriptor *avcodec_descriptor_next(const AVCodecDescriptor *prev)
return prev + 1;
return NULL;
}
+
+const AVCodecDescriptor *avcodec_descriptor_get_by_name(const char *name)
+{
+ const AVCodecDescriptor *desc = NULL;
+
+ while ((desc = avcodec_descriptor_next(desc))) {
+ if (!strcmp(desc->name, name))
+ return desc;
+ }
+ return NULL;
+}
--
1.7.10.4
Anton Khirnov
2012-08-15 08:37:16 UTC
Permalink
---
Changelog | 1 +
avconv.c | 15 ++++++++-------
avconv.h | 4 +++-
avconv_opt.c | 3 ++-
doc/avconv.texi | 2 +-
5 files changed, 15 insertions(+), 10 deletions(-)

diff --git a/Changelog b/Changelog
index 64c23d3..4d0a9f5 100644
--- a/Changelog
+++ b/Changelog
@@ -42,6 +42,7 @@ version <next>:
- RTMPE protocol support
- RTMPTE protocol support
- Canopus Lossless Codec decoder
+- avconv -shortest option is now per-output file


version 0.8:
diff --git a/avconv.c b/avconv.c
index 2bc9d82..d3501ab 100644
--- a/avconv.c
+++ b/avconv.c
@@ -719,7 +719,7 @@ static int poll_filter(OutputStream *ost)
*/
static int poll_filters(void)
{
- int i, ret = 0;
+ int i, j, ret = 0;

while (ret >= 0 && !received_sigterm) {
OutputStream *ost = NULL;
@@ -746,10 +746,14 @@ static int poll_filters(void)
ret = poll_filter(ost);

if (ret == AVERROR_EOF) {
+ OutputFile *of = output_files[ost->file_index];
+
ost->finished = 1;

- if (opt_shortest)
- return ret;
+ if (of->shortest) {
+ for (j = 0; j < of->ctx->nb_streams; j++)
+ output_streams[of->ost_index + j]->finished = 1;
+ }

ret = 0;
} else if (ret == AVERROR(EAGAIN))
@@ -2170,10 +2174,7 @@ static int process_input(void)
}
}

- if (opt_shortest)
- return AVERROR_EOF;
- else
- return AVERROR(EAGAIN);
+ return AVERROR(EAGAIN);
}

reset_eagain();
diff --git a/avconv.h b/avconv.h
index 756d197..94b3f67 100644
--- a/avconv.h
+++ b/avconv.h
@@ -113,6 +113,7 @@ typedef struct OptionsContext {
uint64_t limit_filesize;
float mux_preload;
float mux_max_delay;
+ int shortest;

int video_disable;
int audio_disable;
@@ -303,6 +304,8 @@ typedef struct OutputFile {
int64_t recording_time; /* desired length of the resulting file in microseconds */
int64_t start_time; /* start time in microseconds */
uint64_t limit_filesize;
+
+ int shortest;
} OutputFile;

extern InputStream **input_streams;
@@ -333,7 +336,6 @@ extern int do_hex_dump;
extern int do_pkt_dump;
extern int copy_ts;
extern int copy_tb;
-extern int opt_shortest;
extern int exit_on_error;
extern int print_stats;
extern int qp_hist;
diff --git a/avconv_opt.c b/avconv_opt.c
index 7b86d76..dc44986 100644
--- a/avconv_opt.c
+++ b/avconv_opt.c
@@ -1352,6 +1352,7 @@ loop_end:
oc->duration = o->recording_time;
output_files[nb_output_files - 1]->start_time = o->start_time;
output_files[nb_output_files - 1]->limit_filesize = o->limit_filesize;
+ output_files[nb_output_files - 1]->shortest = o->shortest;
av_dict_copy(&output_files[nb_output_files - 1]->opts, format_opts, 0);

/* check filename in case of an image number is expected */
@@ -1836,7 +1837,7 @@ const OptionDef options[] = {
{ "adrift_threshold", HAS_ARG | OPT_FLOAT | OPT_EXPERT, {(void*)&audio_drift_threshold}, "audio drift threshold", "threshold" },
{ "copyts", OPT_BOOL | OPT_EXPERT, {(void*)&copy_ts}, "copy timestamps" },
{ "copytb", OPT_BOOL | OPT_EXPERT, {(void*)&copy_tb}, "copy input stream time base when stream copying" },
- { "shortest", OPT_BOOL | OPT_EXPERT, {(void*)&opt_shortest}, "finish encoding within shortest input" }, //
+ { "shortest", OPT_BOOL | OPT_EXPERT | OPT_OFFSET, {.off = OFFSET(shortest)}, "finish encoding within shortest input" },
{ "dts_delta_threshold", HAS_ARG | OPT_FLOAT | OPT_EXPERT, {(void*)&dts_delta_threshold}, "timestamp discontinuity delta threshold", "threshold" },
{ "xerror", OPT_BOOL, {(void*)&exit_on_error}, "exit on error", "error" },
{ "copyinkf", OPT_BOOL | OPT_EXPERT | OPT_SPEC, {.off = OFFSET(copy_initial_nonkeyframes)}, "copy initial non-keyframes" },
diff --git a/doc/avconv.texi b/doc/avconv.texi
index ff5bb52..fc64028 100644
--- a/doc/avconv.texi
+++ b/doc/avconv.texi
@@ -752,7 +752,7 @@ This option has been deprecated. Use the @code{asyncts} audio filter instead.
Copy timestamps from input to output.
@item -copytb
Copy input stream time base from input to output when stream copying.
-@item -shortest
+@item -shortest (@emph{output})
Finish encoding when the shortest input stream ends.
@item -dts_delta_threshold
Timestamp discontinuity delta threshold.
--
1.7.10.4
Luca Barbato
2012-08-15 21:49:08 UTC
Permalink
Post by Anton Khirnov
---
Changelog | 1 +
avconv.c | 15 ++++++++-------
avconv.h | 4 +++-
avconv_opt.c | 3 ++-
doc/avconv.texi | 2 +-
5 files changed, 15 insertions(+), 10 deletions(-)
Looks fine but might be enjoy better documentation.

lu
Anton Khirnov
2012-08-15 08:37:17 UTC
Permalink
Make it print a list of AVCodecDescriptors.

Add new -decoders and -encoders options that print lists of decoders and
encoders respectively.
---
cmdutils.c | 174 ++++++++++++++++++++++++++----------------
cmdutils.h | 12 +++
cmdutils_common_opts.h | 2 +
doc/avtools-common-opts.texi | 25 +++---
4 files changed, 131 insertions(+), 82 deletions(-)

diff --git a/cmdutils.c b/cmdutils.c
index ae59f79..b017490 100644
--- a/cmdutils.c
+++ b/cmdutils.c
@@ -632,81 +632,123 @@ void show_formats(void)
}
}

+static char get_media_type_char(enum AVMediaType type)
+{
+ switch (type) {
+ case AVMEDIA_TYPE_VIDEO: return 'V';
+ case AVMEDIA_TYPE_AUDIO: return 'A';
+ case AVMEDIA_TYPE_SUBTITLE: return 'S';
+ default: return '?';
+ }
+}
+
+static const AVCodec *next_codec_for_id(enum AVCodecID id, const AVCodec *prev,
+ int encoder)
+{
+ while ((prev = av_codec_next(prev))) {
+ if (prev->id == id &&
+ (encoder ? av_codec_is_encoder(prev) : av_codec_is_decoder(prev)))
+ return prev;
+ }
+ return NULL;
+}
+
+static void print_codecs_for_id(enum AVCodecID id, int encoder)
+{
+ const AVCodec *codec = NULL;
+
+ printf(" (%s: ", encoder ? "encoders" : "decoders");
+
+ while ((codec = next_codec_for_id(id, codec, encoder)))
+ printf("%s ", codec->name);
+
+ printf(")");
+}
+
void show_codecs(void)
{
- AVCodec *p = NULL, *p2;
- const char *last_name;
+ const AVCodecDescriptor *desc = NULL;
+
printf("Codecs:\n"
- " D..... = Decoding supported\n"
- " .E.... = Encoding supported\n"
- " ..V... = Video codec\n"
- " ..A... = Audio codec\n"
- " ..S... = Subtitle codec\n"
- " ...S.. = Supports draw_horiz_band\n"
- " ....D. = Supports direct rendering method 1\n"
- " .....T = Supports weird frame truncation\n"
- " ------\n");
- last_name= "000";
- for (;;) {
- int decode = 0;
- int encode = 0;
- int cap = 0;
- const char *type_str;
-
- p2 = NULL;
- while ((p = av_codec_next(p))) {
- if ((p2 == NULL || strcmp(p->name, p2->name) < 0) &&
- strcmp(p->name, last_name) > 0) {
- p2 = p;
- decode = encode = cap = 0;
+ " D... = Decoding supported\n"
+ " .E.. = Encoding supported\n"
+ " ..V. = Video codec\n"
+ " ..A. = Audio codec\n"
+ " ..S. = Subtitle codec\n"
+ " ...I = Intra frame-only codec\n"
+ " -----\n");
+ while ((desc = avcodec_descriptor_next(desc))) {
+ const AVCodec *codec = NULL;
+
+ printf(avcodec_find_decoder(desc->id) ? "D" : ".");
+ printf(avcodec_find_encoder(desc->id) ? "E" : ".");
+
+ printf("%c", get_media_type_char(desc->type));
+ printf((desc->props & AV_CODEC_PROP_INTRA_ONLY) ? "I" : ".");
+
+ printf(" %-20s %s", desc->name, desc->long_name ? desc->long_name : "");
+
+ /* print decoders/encoders when there's more than one or their
+ * names are different from codec name */
+ while ((codec = next_codec_for_id(desc->id, codec, 0))) {
+ if (strcmp(codec->name, desc->name)) {
+ print_codecs_for_id(desc->id, 0);
+ break;
}
- if (p2 && strcmp(p->name, p2->name) == 0) {
- if (av_codec_is_decoder(p))
- decode = 1;
- if (av_codec_is_encoder(p))
- encode = 1;
- cap |= p->capabilities;
+ }
+ codec = NULL;
+ while ((codec = next_codec_for_id(desc->id, codec, 1))) {
+ if (strcmp(codec->name, desc->name)) {
+ print_codecs_for_id(desc->id, 1);
+ break;
}
}
- if (p2 == NULL)
- break;
- last_name = p2->name;

- switch (p2->type) {
- case AVMEDIA_TYPE_VIDEO:
- type_str = "V";
- break;
- case AVMEDIA_TYPE_AUDIO:
- type_str = "A";
- break;
- case AVMEDIA_TYPE_SUBTITLE:
- type_str = "S";
- break;
- default:
- type_str = "?";
- break;
- }
- printf(" %s%s%s%s%s%s %-15s %s",
- decode ? "D" : (/* p2->decoder ? "d" : */ " "),
- encode ? "E" : " ",
- type_str,
- cap & CODEC_CAP_DRAW_HORIZ_BAND ? "S" : " ",
- cap & CODEC_CAP_DR1 ? "D" : " ",
- cap & CODEC_CAP_TRUNCATED ? "T" : " ",
- p2->name,
- p2->long_name ? p2->long_name : "");
-#if 0
- if (p2->decoder && decode == 0)
- printf(" use %s for decoding", p2->decoder->name);
-#endif
printf("\n");
}
- printf("\n");
- printf("Note, the names of encoders and decoders do not always match, so there are\n"
- "several cases where the above table shows encoder only or decoder only entries\n"
- "even though both encoding and decoding are supported. For example, the h263\n"
- "decoder corresponds to the h263 and h263p encoders, for file formats it is even\n"
- "worse.\n");
+}
+
+static void print_codecs(int encoder)
+{
+ const AVCodecDescriptor *desc = NULL;
+
+ printf("%s:\n"
+ " V... = Video\n"
+ " A... = Audio\n"
+ " S... = Subtitle\n"
+ " .F.. = Frame-level multithreading\n"
+ " ..S. = Slice-level multithreading\n"
+ " ...X = Codec is experimental\n"
+ " ---\n",
+ encoder ? "Encoders" : "Decoders");
+ while ((desc = avcodec_descriptor_next(desc))) {
+ const AVCodec *codec = NULL;
+
+ while ((codec = next_codec_for_id(desc->id, codec, encoder))) {
+ printf("%c", get_media_type_char(desc->type));
+ printf((codec->capabilities & CODEC_CAP_FRAME_THREADS) ? "F" : ".");
+ printf((codec->capabilities & CODEC_CAP_SLICE_THREADS) ? "S" : ".");
+ printf((codec->capabilities & CODEC_CAP_EXPERIMENTAL) ? "X" : ".");
+
+ printf(" %-20s %s", codec->name, codec->long_name ? codec->long_name : "");
+ if (strcmp(codec->name, desc->name))
+ printf(" (codec %s)", desc->name);
+
+ printf("\n");
+ }
+ }
+}
+
+int show_decoders(const char *opt, const char *arg)
+{
+ print_codecs(0);
+ return 0;
+}
+
+int show_encoders(const char *opt, const char *arg)
+{
+ print_codecs(1);
+ return 0;
}

void show_bsfs(void)
diff --git a/cmdutils.h b/cmdutils.h
index f013c2a..d787496 100644
--- a/cmdutils.h
+++ b/cmdutils.h
@@ -279,6 +279,18 @@ void show_formats(void);
void show_codecs(void);

/**
+ * Print a listing containing all the decoders supported by the
+ * program.
+ */
+int show_decoders(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);
+
+/**
* Print a listing containing all the filters supported by the
* program.
*/
diff --git a/cmdutils_common_opts.h b/cmdutils_common_opts.h
index 1158afa..d9a09c0 100644
--- a/cmdutils_common_opts.h
+++ b/cmdutils_common_opts.h
@@ -6,6 +6,8 @@
{ "version", OPT_EXIT, {(void*)show_version}, "show version" },
{ "formats" , OPT_EXIT, {(void*)show_formats }, "show available formats" },
{ "codecs" , OPT_EXIT, {(void*)show_codecs }, "show available codecs" },
+ { "decoders" , OPT_EXIT, {(void*)show_decoders }, "show available decoders" },
+ { "encoders" , OPT_EXIT, {(void*)show_encoders }, "show available encoders" },
{ "bsfs" , OPT_EXIT, {(void*)show_bsfs }, "show available bit stream filters" },
{ "protocols", OPT_EXIT, {(void*)show_protocols}, "show available protocols" },
{ "filters", OPT_EXIT, {(void*)show_filters }, "show available filters" },
diff --git a/doc/avtools-common-opts.texi b/doc/avtools-common-opts.texi
index 0be9cf0..375e4b0 100644
--- a/doc/avtools-common-opts.texi
+++ b/doc/avtools-common-opts.texi
@@ -69,23 +69,16 @@ Encoding available
@end table

@item -codecs
-Show available codecs.
+Show all codecs known to libavcodec.

-The fields preceding the codec names have the following meanings:
-@table @samp
-@item D
-Decoding available
-@item E
-Encoding available
-@item V/A/S
-Video/audio/subtitle codec
-@item S
-Codec supports slices
-@item D
-Codec supports direct rendering
-@item T
-Codec can handle input truncated at random locations instead of only at frame boundaries
-@end table
+Note that the term 'codec' is used throughout this documentation as a shortcut
+for what is more correctly called a media bitstream format.
+
+@item -decoders
+Show available decoders.
+
+@item -encoders
+Show all available encoders.

@item -bsfs
Show available bitstream filters.
--
1.7.10.4
Diego Biurrun
2012-08-15 09:22:08 UTC
Permalink
Post by Anton Khirnov
Make it print a list of AVCodecDescriptors.
Add new -decoders and -encoders options that print lists of decoders and
encoders respectively.
I'd suggest you make this -list-<component>, similar to what configure
does. But no, I don't have a strong opinion.

Diego
Anton Khirnov
2012-08-15 10:14:58 UTC
Permalink
Post by Diego Biurrun
Post by Anton Khirnov
Make it print a list of AVCodecDescriptors.
Add new -decoders and -encoders options that print lists of decoders and
encoders respectively.
I'd suggest you make this -list-<component>, similar to what configure
does. But no, I don't have a strong opinion.
We already have:
-formats
-codecs
-bsfs
-protocols
-filters
-pix_fmts
-sample_fmts

-list-decoders is inconsistent with those. (and longer to write)
--
Anton Khirnov
Diego Biurrun
2012-08-15 10:33:09 UTC
Permalink
Post by Anton Khirnov
Post by Diego Biurrun
Post by Anton Khirnov
Make it print a list of AVCodecDescriptors.
Add new -decoders and -encoders options that print lists of decoders and
encoders respectively.
I'd suggest you make this -list-<component>, similar to what configure
does. But no, I don't have a strong opinion.
-formats
-codecs
-bsfs
-protocols
-filters
-pix_fmts
-sample_fmts
-list-decoders is inconsistent with those. (and longer to write)
I retract my suggestion (which was just a suggestion, not something I
really wanted you to do). Go right ahead.

Diego
Anton Khirnov
2012-08-15 08:37:19 UTC
Permalink
This allows e.g. -c:v h264 to select the libx264 encoder.
---
avconv_opt.c | 10 ++++++++++
1 file changed, 10 insertions(+)

diff --git a/avconv_opt.c b/avconv_opt.c
index 97ae0a4..5c6fc87 100644
--- a/avconv_opt.c
+++ b/avconv_opt.c
@@ -381,12 +381,22 @@ static int copy_metadata(char *outspec, char *inspec, AVFormatContext *oc, AVFor

static AVCodec *find_codec_or_die(const char *name, enum AVMediaType type, int encoder)
{
+ const AVCodecDescriptor *desc;
const char *codec_string = encoder ? "encoder" : "decoder";
AVCodec *codec;

codec = encoder ?
avcodec_find_encoder_by_name(name) :
avcodec_find_decoder_by_name(name);
+
+ if (!codec && (desc = avcodec_descriptor_get_by_name(name))) {
+ codec = encoder ? avcodec_find_encoder(desc->id) :
+ avcodec_find_decoder(desc->id);
+ if (codec)
+ av_log(NULL, AV_LOG_VERBOSE, "Matched %s '%s' for codec '%s'.\n",
+ codec_string, codec->name, desc->name);
+ }
+
if (!codec) {
av_log(NULL, AV_LOG_FATAL, "Unknown %s '%s'\n", codec_string, name);
exit_program(1);
--
1.7.10.4
Diego Biurrun
2012-08-15 09:19:52 UTC
Permalink
Post by Anton Khirnov
This allows e.g. -c:v h264 to select the libx264 encoder.
---
avconv_opt.c | 10 ++++++++++
1 file changed, 10 insertions(+)
try _to_ match
Post by Anton Khirnov
--- a/avconv_opt.c
+++ b/avconv_opt.c
@@ -381,12 +381,22 @@ static int copy_metadata(char *outspec, char *inspec, AVFormatContext *oc, AVFor
+
+ if (!codec && (desc = avcodec_descriptor_get_by_name(name))) {
+ avcodec_find_decoder(desc->id);
This would be more readable with the ':' below the '?'.

I have no opinion on the patch itself.

Diego
Måns Rullgård
2012-08-15 09:36:39 UTC
Permalink
Post by Diego Biurrun
Post by Anton Khirnov
This allows e.g. -c:v h264 to select the libx264 encoder.
---
avconv_opt.c | 10 ++++++++++
1 file changed, 10 insertions(+)
try _to_ match
Post by Anton Khirnov
--- a/avconv_opt.c
+++ b/avconv_opt.c
@@ -381,12 +381,22 @@ static int copy_metadata(char *outspec, char *inspec, AVFormatContext *oc, AVFor
+
+ if (!codec && (desc = avcodec_descriptor_get_by_name(name))) {
+ avcodec_find_decoder(desc->id);
This would be more readable with the ':' below the '?'.
I disagree.
--
Måns Rullgård
***@mansr.com
Kostya Shishkov
2012-08-15 09:41:07 UTC
Permalink
Post by Måns Rullgård
Post by Diego Biurrun
Post by Anton Khirnov
This allows e.g. -c:v h264 to select the libx264 encoder.
---
avconv_opt.c | 10 ++++++++++
1 file changed, 10 insertions(+)
try _to_ match
Post by Anton Khirnov
--- a/avconv_opt.c
+++ b/avconv_opt.c
@@ -381,12 +381,22 @@ static int copy_metadata(char *outspec, char *inspec, AVFormatContext *oc, AVFor
+
+ if (!codec && (desc = avcodec_descriptor_get_by_name(name))) {
+ avcodec_find_decoder(desc->id);
This would be more readable with the ':' below the '?'.
I disagree.
I also find

a = cond ? X
: Y;

much nicer and easier to understand.
Måns Rullgård
2012-08-15 09:48:50 UTC
Permalink
Post by Kostya Shishkov
Post by Måns Rullgård
Post by Diego Biurrun
Post by Anton Khirnov
This allows e.g. -c:v h264 to select the libx264 encoder.
---
avconv_opt.c | 10 ++++++++++
1 file changed, 10 insertions(+)
try _to_ match
Post by Anton Khirnov
--- a/avconv_opt.c
+++ b/avconv_opt.c
@@ -381,12 +381,22 @@ static int copy_metadata(char *outspec, char *inspec, AVFormatContext *oc, AVFor
+
+ if (!codec && (desc = avcodec_descriptor_get_by_name(name))) {
+ avcodec_find_decoder(desc->id);
This would be more readable with the ':' below the '?'.
I disagree.
I also find
a = cond ? X
: Y;
much nicer and easier to understand.
Non-unary operators at the start of a line are ugly and against God's will.
--
Måns Rullgård
***@mansr.com
Kostya Shishkov
2012-08-15 09:54:33 UTC
Permalink
Post by Måns Rullgård
Post by Kostya Shishkov
Post by Måns Rullgård
Post by Diego Biurrun
Post by Anton Khirnov
This allows e.g. -c:v h264 to select the libx264 encoder.
---
avconv_opt.c | 10 ++++++++++
1 file changed, 10 insertions(+)
try _to_ match
Post by Anton Khirnov
--- a/avconv_opt.c
+++ b/avconv_opt.c
@@ -381,12 +381,22 @@ static int copy_metadata(char *outspec, char *inspec, AVFormatContext *oc, AVFor
+
+ if (!codec && (desc = avcodec_descriptor_get_by_name(name))) {
+ avcodec_find_decoder(desc->id);
This would be more readable with the ':' below the '?'.
I disagree.
I also find
a = cond ? X
: Y;
much nicer and easier to understand.
Non-unary operators at the start of a line are ugly and against God's will.
My religion has an amendment: s/non-unary/binary/
Because it's viewed as if-else construct.
Let's see if I can bikeshed about it, say, next Thursday.
Luca Barbato
2012-08-19 09:33:57 UTC
Permalink
Post by Anton Khirnov
This allows e.g. -c:v h264 to select the libx264 encoder.
---
avconv_opt.c | 10 ++++++++++
1 file changed, 10 insertions(+)
Fine for me.
Anton Khirnov
2012-08-19 09:35:49 UTC
Permalink
ping
--
Anton Khirnov
Anton Khirnov
2012-08-15 08:37:18 UTC
Permalink
show_foo() functions are declared as void show_foo(void), but called as
int show_foo(const char*, const char*).
---
avconv_opt.c | 3 ++-
avplay.c | 6 ++++--
avprobe.c | 3 ++-
cmdutils.c | 27 +++++++++++++++++++--------
cmdutils.h | 16 ++++++++--------
cmdutils_common_opts.h | 32 ++++++++++++++++----------------
6 files changed, 51 insertions(+), 36 deletions(-)

diff --git a/avconv_opt.c b/avconv_opt.c
index dc44986..97ae0a4 100644
--- a/avconv_opt.c
+++ b/avconv_opt.c
@@ -1760,7 +1760,7 @@ static int opt_filter_complex(const char *opt, const char *arg)
return 0;
}

-static void show_help(void)
+static int show_help(const char *opt, const char *arg)
{
int flags = AV_OPT_FLAG_DECODING_PARAM | AV_OPT_FLAG_ENCODING_PARAM;
av_log_set_callback(log_callback_help);
@@ -1792,6 +1792,7 @@ static void show_help(void)
show_help_children(avcodec_get_class(), flags);
show_help_children(avformat_get_class(), flags);
show_help_children(sws_get_class(), flags);
+ return 0;
}

void show_usage(void)
diff --git a/avplay.c b/avplay.c
index 3f2c425..593b38a 100644
--- a/avplay.c
+++ b/avplay.c
@@ -224,7 +224,7 @@ typedef struct VideoState {
int refresh;
} VideoState;

-static void show_help(void);
+static int show_help(const char *opt, const char *arg);

/* options specified by the user */
static AVInputFormat *file_iformat;
@@ -2922,7 +2922,7 @@ static void show_usage(void)
printf("\n");
}

-static void show_help(void)
+static int show_help(const char *opt, const char *arg)
{
av_log_set_callback(log_callback_help);
show_usage();
@@ -2949,6 +2949,8 @@ static void show_help(void)
"down/up seek backward/forward 1 minute\n"
"mouse click seek to percentage in file corresponding to fraction of width\n"
);
+
+ return 0;
}

static void opt_input_file(void *optctx, const char *filename)
diff --git a/avprobe.c b/avprobe.c
index 28746bf..e14b5f6 100644
--- a/avprobe.c
+++ b/avprobe.c
@@ -867,13 +867,14 @@ static void opt_input_file(void *optctx, const char *arg)
input_filename = arg;
}

-static void show_help(void)
+static int show_help(const char *opt, const char *arg)
{
av_log_set_callback(log_callback_help);
show_usage();
show_help_options(options, "Main options:\n", 0, 0);
printf("\n");
show_help_children(avformat_get_class(), AV_OPT_FLAG_DECODING_PARAM);
+ return 0;
}

static void opt_pretty(void)
diff --git a/cmdutils.c b/cmdutils.c
index b017490..3b8ab3f 100644
--- a/cmdutils.c
+++ b/cmdutils.c
@@ -510,13 +510,16 @@ void show_banner(void)
print_all_libs_info(INDENT|SHOW_VERSION, AV_LOG_VERBOSE);
}

-void show_version(void) {
+int show_version(const char *opt, const char *arg)
+{
av_log_set_callback(log_callback_help);
printf("%s " LIBAV_VERSION "\n", program_name);
print_all_libs_info(SHOW_VERSION, AV_LOG_INFO);
+
+ return 0;
}

-void show_license(void)
+int show_license(const char *opt, const char *arg)
{
printf(
#if CONFIG_NONFREE
@@ -583,9 +586,11 @@ void show_license(void)
program_name, program_name, program_name
#endif
);
+
+ return 0;
}

-void show_formats(void)
+int show_formats(const char *opt, const char *arg)
{
AVInputFormat *ifmt = NULL;
AVOutputFormat *ofmt = NULL;
@@ -630,6 +635,7 @@ void show_formats(void)
name,
long_name ? long_name:" ");
}
+ return 0;
}

static char get_media_type_char(enum AVMediaType type)
@@ -665,7 +671,7 @@ static void print_codecs_for_id(enum AVCodecID id, int encoder)
printf(")");
}

-void show_codecs(void)
+int show_codecs(const char *opt, const char *arg)
{
const AVCodecDescriptor *desc = NULL;

@@ -706,6 +712,7 @@ void show_codecs(void)

printf("\n");
}
+ return 0;
}

static void print_codecs(int encoder)
@@ -751,7 +758,7 @@ int show_encoders(const char *opt, const char *arg)
return 0;
}

-void show_bsfs(void)
+int show_bsfs(const char *opt, const char *arg)
{
AVBitStreamFilter *bsf = NULL;

@@ -759,9 +766,10 @@ void show_bsfs(void)
while ((bsf = av_bitstream_filter_next(bsf)))
printf("%s\n", bsf->name);
printf("\n");
+ return 0;
}

-void show_protocols(void)
+int show_protocols(const char *opt, const char *arg)
{
void *opaque = NULL;
const char *name;
@@ -773,9 +781,10 @@ void show_protocols(void)
printf("Output:\n");
while ((name = avio_enum_protocols(&opaque, 1)))
printf("%s\n", name);
+ return 0;
}

-void show_filters(void)
+int show_filters(const char *opt, const char *arg)
{
AVFilter av_unused(**filter) = NULL;

@@ -784,9 +793,10 @@ void show_filters(void)
while ((filter = av_filter_next(filter)) && *filter)
printf("%-16s %s\n", (*filter)->name, (*filter)->description);
#endif
+ return 0;
}

-void show_pix_fmts(void)
+int show_pix_fmts(const char *opt, const char *arg)
{
enum PixelFormat pix_fmt;

@@ -816,6 +826,7 @@ void show_pix_fmts(void)
pix_desc->nb_components,
av_get_bits_per_pixel(pix_desc));
}
+ return 0;
}

int show_sample_fmts(const char *opt, const char *arg)
diff --git a/cmdutils.h b/cmdutils.h
index d787496..a02d19d 100644
--- a/cmdutils.h
+++ b/cmdutils.h
@@ -258,25 +258,25 @@ void show_banner(void);
* depends on the current versions of the repository and of the libav*
* libraries.
*/
-void show_version(void);
+int show_version(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.
*/
-void show_license(void);
+int show_license(const char *opt, const char *arg);

/**
* Print a listing containing all the formats supported by the
* program.
*/
-void show_formats(void);
+int show_formats(const char *opt, const char *arg);

/**
* Print a listing containing all the codecs supported by the
* program.
*/
-void show_codecs(void);
+int show_codecs(const char *opt, const char *arg);

/**
* Print a listing containing all the decoders supported by the
@@ -294,25 +294,25 @@ int show_encoders(const char *opt, const char *arg);
* Print a listing containing all the filters supported by the
* program.
*/
-void show_filters(void);
+int show_filters(const char *opt, const char *arg);

/**
* Print a listing containing all the bit stream filters supported by the
* program.
*/
-void show_bsfs(void);
+int show_bsfs(const char *opt, const char *arg);

/**
* Print a listing containing all the protocols supported by the
* program.
*/
-void show_protocols(void);
+int show_protocols(const char *opt, const char *arg);

/**
* Print a listing containing all the pixel formats supported by the
* program.
*/
-void show_pix_fmts(void);
+int show_pix_fmts(const char *opt, const char *arg);

/**
* Print a listing containing all the sample formats supported by the
diff --git a/cmdutils_common_opts.h b/cmdutils_common_opts.h
index d9a09c0..d66a82e 100644
--- a/cmdutils_common_opts.h
+++ b/cmdutils_common_opts.h
@@ -1,17 +1,17 @@
- { "L", OPT_EXIT, {(void*)show_license}, "show license" },
- { "h", OPT_EXIT, {(void*)show_help}, "show help" },
- { "?", OPT_EXIT, {(void*)show_help}, "show help" },
- { "help", OPT_EXIT, {(void*)show_help}, "show help" },
- { "-help", OPT_EXIT, {(void*)show_help}, "show help" },
- { "version", OPT_EXIT, {(void*)show_version}, "show version" },
- { "formats" , OPT_EXIT, {(void*)show_formats }, "show available formats" },
- { "codecs" , OPT_EXIT, {(void*)show_codecs }, "show available codecs" },
- { "decoders" , OPT_EXIT, {(void*)show_decoders }, "show available decoders" },
- { "encoders" , OPT_EXIT, {(void*)show_encoders }, "show available encoders" },
- { "bsfs" , OPT_EXIT, {(void*)show_bsfs }, "show available bit stream filters" },
- { "protocols", OPT_EXIT, {(void*)show_protocols}, "show available protocols" },
- { "filters", OPT_EXIT, {(void*)show_filters }, "show available filters" },
- { "pix_fmts" , OPT_EXIT, {(void*)show_pix_fmts }, "show available pixel formats" },
+ { "L" , OPT_EXIT, {.func_arg = show_license}, "show license" },
+ { "h" , OPT_EXIT, {.func_arg = show_help}, "show help" },
+ { "?" , OPT_EXIT, {.func_arg = show_help}, "show help" },
+ { "help" , OPT_EXIT, {.func_arg = show_help}, "show help" },
+ { "-help" , OPT_EXIT, {.func_arg = show_help}, "show help" },
+ { "version" , OPT_EXIT, {.func_arg = show_version}, "show version" },
+ { "formats" , OPT_EXIT, {.func_arg = show_formats }, "show available formats" },
+ { "codecs" , OPT_EXIT, {.func_arg = show_codecs }, "show available codecs" },
+ { "decoders" , OPT_EXIT, {.func_arg = show_decoders }, "show available decoders" },
+ { "encoders" , OPT_EXIT, {.func_arg = show_encoders }, "show available encoders" },
+ { "bsfs" , OPT_EXIT, {.func_arg = show_bsfs }, "show available bit stream filters" },
+ { "protocols" , OPT_EXIT, {.func_arg = show_protocols}, "show available protocols" },
+ { "filters" , OPT_EXIT, {.func_arg = show_filters }, "show available filters" },
+ { "pix_fmts" , OPT_EXIT, {.func_arg = show_pix_fmts }, "show available pixel formats" },
{ "sample_fmts", OPT_EXIT, {.func_arg = show_sample_fmts }, "show available audio sample formats" },
- { "loglevel", HAS_ARG, {(void*)opt_loglevel}, "set libav* logging level", "loglevel" },
- { "v", HAS_ARG, {(void*)opt_loglevel}, "set libav* logging level", "loglevel" },
+ { "loglevel" , HAS_ARG, {.func_arg = opt_loglevel}, "set libav* logging level", "loglevel" },
+ { "v", HAS_ARG, {.func_arg = opt_loglevel}, "set libav* logging level", "loglevel" },
--
1.7.10.4
Anton Khirnov
2012-08-17 15:49:19 UTC
Permalink
ping on 5, 6 and 13
--
Anton Khirnov
Diego Biurrun
2012-08-17 15:59:08 UTC
Permalink
Post by Anton Khirnov
show_foo() functions are declared as void show_foo(void), but called as
int show_foo(const char*, const char*).
---
avconv_opt.c | 3 ++-
avplay.c | 6 ++++--
avprobe.c | 3 ++-
cmdutils.c | 27 +++++++++++++++++++--------
cmdutils.h | 16 ++++++++--------
cmdutils_common_opts.h | 32 ++++++++++++++++----------------
6 files changed, 51 insertions(+), 36 deletions(-)
Adding unused parameters just to match the function pointer signature
feels wrong. Why don't you add another function pointer with matching
signature to the union in cmdutils.h?

Diego
Anton Khirnov
2012-08-17 17:53:46 UTC
Permalink
Post by Diego Biurrun
Post by Anton Khirnov
show_foo() functions are declared as void show_foo(void), but called as
int show_foo(const char*, const char*).
---
avconv_opt.c | 3 ++-
avplay.c | 6 ++++--
avprobe.c | 3 ++-
cmdutils.c | 27 +++++++++++++++++++--------
cmdutils.h | 16 ++++++++--------
cmdutils_common_opts.h | 32 ++++++++++++++++----------------
6 files changed, 51 insertions(+), 36 deletions(-)
Adding unused parameters just to match the function pointer signature
feels wrong. Why don't you add another function pointer with matching
signature to the union in cmdutils.h?
What exactly feels wrong about it? It looks very right to me.

Your suggestion is more code with no benefit.
--
Anton Khirnov
Diego Biurrun
2012-08-18 10:58:08 UTC
Permalink
Post by Anton Khirnov
Post by Diego Biurrun
Post by Anton Khirnov
show_foo() functions are declared as void show_foo(void), but called as
int show_foo(const char*, const char*).
---
avconv_opt.c | 3 ++-
avplay.c | 6 ++++--
avprobe.c | 3 ++-
cmdutils.c | 27 +++++++++++++++++++--------
cmdutils.h | 16 ++++++++--------
cmdutils_common_opts.h | 32 ++++++++++++++++----------------
6 files changed, 51 insertions(+), 36 deletions(-)
Adding unused parameters just to match the function pointer signature
feels wrong. Why don't you add another function pointer with matching
signature to the union in cmdutils.h?
What exactly feels wrong about it? It looks very right to me.
Your suggestion is more code with no benefit.
$attached does not look like more code to me.

Diego
Uoti Urpala
2012-08-18 11:06:09 UTC
Permalink
Post by Diego Biurrun
Post by Anton Khirnov
Post by Diego Biurrun
Adding unused parameters just to match the function pointer signature
feels wrong. Why don't you add another function pointer with matching
signature to the union in cmdutils.h?
What exactly feels wrong about it? It looks very right to me.
Your suggestion is more code with no benefit.
$attached does not look like more code to me.
But your version does not fix the issue. The functions are still
_called_ through the func_arg field. You'd need to change the calling
code to pick the correct field. As is, your patch only adds the new
issue of setting one field in the union (.show) but reading the value
through another (.func_arg).
Måns Rullgård
2012-08-18 12:00:19 UTC
Permalink
Post by Uoti Urpala
Post by Diego Biurrun
Post by Anton Khirnov
Post by Diego Biurrun
Adding unused parameters just to match the function pointer signature
feels wrong. Why don't you add another function pointer with matching
signature to the union in cmdutils.h?
What exactly feels wrong about it? It looks very right to me.
Your suggestion is more code with no benefit.
$attached does not look like more code to me.
It adds code whereas Anton's patch does not.
Post by Uoti Urpala
But your version does not fix the issue. The functions are still
_called_ through the func_arg field. You'd need to change the calling
code to pick the correct field. As is, your patch only adds the new
issue of setting one field in the union (.show) but reading the value
through another (.func_arg).
This is not just a cosmetic issue. Calling a function with arguments
not matching the definition has undefined behaviour.

I think all the functions should be changed to take 3 arguments. That
would actually simplify things.
--
Måns Rullgård
***@mansr.com
Luca Barbato
2012-08-19 09:32:51 UTC
Permalink
Post by Anton Khirnov
show_foo() functions are declared as void show_foo(void), but called as
int show_foo(const char*, const char*).
Seems ok, what about using unused though?

lu
Anton Khirnov
2012-08-19 12:36:33 UTC
Permalink
Post by Luca Barbato
Post by Anton Khirnov
show_foo() functions are declared as void show_foo(void), but called as
int show_foo(const char*, const char*).
Seems ok, what about using unused though?
??
--
Anton Khirnov
Anton Khirnov
2012-08-15 08:37:20 UTC
Permalink
---
avconv_opt.c | 147 +++++++++++++++++++++++++++++++++-------------------------
1 file changed, 83 insertions(+), 64 deletions(-)

diff --git a/avconv_opt.c b/avconv_opt.c
index 5c6fc87..1243861 100644
--- a/avconv_opt.c
+++ b/avconv_opt.c
@@ -148,28 +148,33 @@ static double parse_frame_aspect_ratio(const char *arg)
return ar;
}

-static int opt_audio_codec(OptionsContext *o, const char *opt, const char *arg)
+static int opt_audio_codec(void *optctx, const char *opt, const char *arg)
{
+ OptionsContext *o = optctx;
return parse_option(o, "codec:a", arg, options);
}

-static int opt_video_codec(OptionsContext *o, const char *opt, const char *arg)
+static int opt_video_codec(void *optctx, const char *opt, const char *arg)
{
+ OptionsContext *o = optctx;
return parse_option(o, "codec:v", arg, options);
}

-static int opt_subtitle_codec(OptionsContext *o, const char *opt, const char *arg)
+static int opt_subtitle_codec(void *optctx, const char *opt, const char *arg)
{
+ OptionsContext *o = optctx;
return parse_option(o, "codec:s", arg, options);
}

-static int opt_data_codec(OptionsContext *o, const char *opt, const char *arg)
+static int opt_data_codec(void *optctx, const char *opt, const char *arg)
{
+ OptionsContext *o = optctx;
return parse_option(o, "codec:d", arg, options);
}

-static int opt_map(OptionsContext *o, const char *opt, const char *arg)
+static int opt_map(void *optctx, const char *opt, const char *arg)
{
+ OptionsContext *o = optctx;
StreamMap *m = NULL;
int i, negative = 0, file_idx;
int sync_file_idx = -1, sync_stream_idx;
@@ -264,8 +269,9 @@ static int opt_map(OptionsContext *o, const char *opt, const char *arg)
return 0;
}

-static int opt_attach(OptionsContext *o, const char *opt, const char *arg)
+static int opt_attach(void *optctx, const char *opt, const char *arg)
{
+ OptionsContext *o = optctx;
o->attachments = grow_array(o->attachments, sizeof(*o->attachments),
&o->nb_attachments, o->nb_attachments + 1);
o->attachments[o->nb_attachments - 1] = arg;
@@ -541,8 +547,9 @@ static void dump_attachment(AVStream *st, const char *filename)
avio_close(out);
}

-static int opt_input_file(OptionsContext *o, const char *opt, const char *filename)
+static int opt_input_file(void *optctx, const char *opt, const char *filename)
{
+ OptionsContext *o = optctx;
AVFormatContext *ic;
AVInputFormat *file_iformat = NULL;
int err, i, ret;
@@ -1048,8 +1055,9 @@ static OutputStream *new_subtitle_stream(OptionsContext *o, AVFormatContext *oc)
}

/* arg format is "output-stream-index:streamid-value". */
-static int opt_streamid(OptionsContext *o, const char *opt, const char *arg)
+static int opt_streamid(void *optctx, const char *opt, const char *arg)
{
+ OptionsContext *o = optctx;
int idx;
char *p;
char idx_str[16];
@@ -1496,8 +1504,9 @@ static int opt_pass(const char *opt, const char *arg)
}


-static int opt_target(OptionsContext *o, const char *opt, const char *arg)
+static int opt_target(void *optctx, const char *opt, const char *arg)
{
+ OptionsContext *o = optctx;
enum { PAL, NTSC, FILM, UNKNOWN } norm = UNKNOWN;
static const char *const frame_rates[] = { "25", "30000/1001", "24000/1001" };

@@ -1650,43 +1659,51 @@ static int opt_vstats(const char *opt, const char *arg)
return opt_vstats_file(opt, filename);
}

-static int opt_video_frames(OptionsContext *o, const char *opt, const char *arg)
+static int opt_video_frames(void *optctx, const char *opt, const char *arg)
{
+ OptionsContext *o = optctx;
return parse_option(o, "frames:v", arg, options);
}

-static int opt_audio_frames(OptionsContext *o, const char *opt, const char *arg)
+static int opt_audio_frames(void *optctx, const char *opt, const char *arg)
{
+ OptionsContext *o = optctx;
return parse_option(o, "frames:a", arg, options);
}

-static int opt_data_frames(OptionsContext *o, const char *opt, const char *arg)
+static int opt_data_frames(void *optctx, const char *opt, const char *arg)
{
+ OptionsContext *o = optctx;
return parse_option(o, "frames:d", arg, options);
}

-static int opt_video_tag(OptionsContext *o, const char *opt, const char *arg)
+static int opt_video_tag(void *optctx, const char *opt, const char *arg)
{
+ OptionsContext *o = optctx;
return parse_option(o, "tag:v", arg, options);
}

-static int opt_audio_tag(OptionsContext *o, const char *opt, const char *arg)
+static int opt_audio_tag(void *optctx, const char *opt, const char *arg)
{
+ OptionsContext *o = optctx;
return parse_option(o, "tag:a", arg, options);
}

-static int opt_subtitle_tag(OptionsContext *o, const char *opt, const char *arg)
+static int opt_subtitle_tag(void *optctx, const char *opt, const char *arg)
{
+ OptionsContext *o = optctx;
return parse_option(o, "tag:s", arg, options);
}

-static int opt_video_filters(OptionsContext *o, const char *opt, const char *arg)
+static int opt_video_filters(void *optctx, const char *opt, const char *arg)
{
+ OptionsContext *o = optctx;
return parse_option(o, "filter:v", arg, options);
}

-static int opt_audio_filters(OptionsContext *o, const char *opt, const char *arg)
+static int opt_audio_filters(void *optctx, const char *opt, const char *arg)
{
+ OptionsContext *o = optctx;
return parse_option(o, "filter:a", arg, options);
}

@@ -1719,8 +1736,9 @@ int opt_cpuflags(const char *opt, const char *arg)
return 0;
}

-static int opt_channel_layout(OptionsContext *o, const char *opt, const char *arg)
+static int opt_channel_layout(void *optctx, const char *opt, const char *arg)
{
+ OptionsContext *o = optctx;
char layout_str[32];
char *stream_str;
char *ac_str;
@@ -1754,8 +1772,9 @@ static int opt_channel_layout(OptionsContext *o, const char *opt, const char *ar
return ret;
}

-static int opt_audio_qscale(OptionsContext *o, const char *opt, const char *arg)
+static int opt_audio_qscale(void *optctx, const char *opt, const char *arg)
{
+ OptionsContext *o = optctx;
return parse_option(o, "q:a", arg, options);
}

@@ -1818,12 +1837,12 @@ const OptionDef options[] = {
/* main options */
#include "cmdutils_common_opts.h"
{ "f", HAS_ARG | OPT_STRING | OPT_OFFSET, {.off = OFFSET(format)}, "force format", "fmt" },
- { "i", HAS_ARG | OPT_FUNC2, {(void*)opt_input_file}, "input file name", "filename" },
- { "y", OPT_BOOL, {(void*)&file_overwrite}, "overwrite output files" },
+ { "i", HAS_ARG | OPT_FUNC2, {.func2_arg = opt_input_file}, "input file name", "filename" },
+ { "y", OPT_BOOL, {&file_overwrite}, "overwrite output files" },
{ "c", HAS_ARG | OPT_STRING | OPT_SPEC, {.off = OFFSET(codec_names)}, "codec name", "codec" },
{ "codec", HAS_ARG | OPT_STRING | OPT_SPEC, {.off = OFFSET(codec_names)}, "codec name", "codec" },
{ "pre", HAS_ARG | OPT_STRING | OPT_SPEC, {.off = OFFSET(presets)}, "preset name", "preset" },
- { "map", HAS_ARG | OPT_EXPERT | OPT_FUNC2, {(void*)opt_map}, "set input stream mapping", "[-]input_file_id[:stream_specifier][,sync_file_id[:stream_specifier]]" },
+ { "map", HAS_ARG | OPT_EXPERT | OPT_FUNC2, {.func2_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 metadata information of outfile from infile",
"outfile[,metadata]:infile[,metadata]" },
{ "map_chapters", OPT_INT | HAS_ARG | OPT_EXPERT | OPT_OFFSET, {.off = OFFSET(chapters_input_file)}, "set chapters mapping", "input_file_index" },
@@ -1833,85 +1852,85 @@ const OptionDef options[] = {
{ "itsoffset", HAS_ARG | OPT_TIME | OPT_OFFSET, {.off = OFFSET(input_ts_offset)}, "set the input ts offset", "time_off" },
{ "itsscale", HAS_ARG | OPT_DOUBLE | OPT_SPEC, {.off = OFFSET(ts_scale)}, "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, {(void*)opt_data_frames}, "set the number of data frames to record", "number" },
- { "benchmark", OPT_BOOL | OPT_EXPERT, {(void*)&do_benchmark},
+ { "dframes", HAS_ARG | OPT_FUNC2, {.func2_arg = opt_data_frames}, "set the number of data frames to record", "number" },
+ { "benchmark", OPT_BOOL | OPT_EXPERT, {&do_benchmark},
"add timings for benchmarking" },
- { "timelimit", HAS_ARG, {(void*)opt_timelimit}, "set max runtime in seconds", "limit" },
- { "dump", OPT_BOOL | OPT_EXPERT, {(void*)&do_pkt_dump},
+ { "timelimit", HAS_ARG, {.func_arg = opt_timelimit}, "set max runtime in seconds", "limit" },
+ { "dump", OPT_BOOL | OPT_EXPERT, {&do_pkt_dump},
"dump each input packet" },
- { "hex", OPT_BOOL | OPT_EXPERT, {(void*)&do_hex_dump},
+ { "hex", OPT_BOOL | OPT_EXPERT, {&do_hex_dump},
"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, {(void*)opt_target}, "specify target file type (\"vcd\", \"svcd\", \"dvd\", \"dv\", \"dv50\", \"pal-vcd\", \"ntsc-svcd\", ...)", "type" },
- { "vsync", HAS_ARG | OPT_EXPERT, {(void*)opt_vsync}, "video sync method", "" },
- { "async", HAS_ARG | OPT_INT | OPT_EXPERT, {(void*)&audio_sync_method}, "audio sync method", "" },
- { "adrift_threshold", HAS_ARG | OPT_FLOAT | OPT_EXPERT, {(void*)&audio_drift_threshold}, "audio drift threshold", "threshold" },
- { "copyts", OPT_BOOL | OPT_EXPERT, {(void*)&copy_ts}, "copy timestamps" },
- { "copytb", OPT_BOOL | OPT_EXPERT, {(void*)&copy_tb}, "copy input stream time base when stream copying" },
+ { "target", HAS_ARG | OPT_FUNC2, {.func2_arg = opt_target}, "specify target file type (\"vcd\", \"svcd\", \"dvd\", \"dv\", \"dv50\", \"pal-vcd\", \"ntsc-svcd\", ...)", "type" },
+ { "vsync", HAS_ARG | OPT_EXPERT, {opt_vsync}, "video sync method", "" },
+ { "async", HAS_ARG | OPT_INT | OPT_EXPERT, {&audio_sync_method}, "audio sync method", "" },
+ { "adrift_threshold", HAS_ARG | OPT_FLOAT | OPT_EXPERT, {&audio_drift_threshold}, "audio drift threshold", "threshold" },
+ { "copyts", OPT_BOOL | OPT_EXPERT, {&copy_ts}, "copy timestamps" },
+ { "copytb", OPT_BOOL | OPT_EXPERT, {&copy_tb}, "copy input stream time base when stream copying" },
{ "shortest", OPT_BOOL | OPT_EXPERT | OPT_OFFSET, {.off = OFFSET(shortest)}, "finish encoding within shortest input" },
- { "dts_delta_threshold", HAS_ARG | OPT_FLOAT | OPT_EXPERT, {(void*)&dts_delta_threshold}, "timestamp discontinuity delta threshold", "threshold" },
- { "xerror", OPT_BOOL, {(void*)&exit_on_error}, "exit on error", "error" },
+ { "dts_delta_threshold", HAS_ARG | OPT_FLOAT | OPT_EXPERT, {&dts_delta_threshold}, "timestamp discontinuity delta threshold", "threshold" },
+ { "xerror", OPT_BOOL, {&exit_on_error}, "exit on error", "error" },
{ "copyinkf", OPT_BOOL | OPT_EXPERT | OPT_SPEC, {.off = OFFSET(copy_initial_nonkeyframes)}, "copy initial non-keyframes" },
{ "frames", OPT_INT64 | HAS_ARG | OPT_SPEC, {.off = OFFSET(max_frames)}, "set the number of frames to record", "number" },
{ "tag", OPT_STRING | HAS_ARG | OPT_SPEC, {.off = OFFSET(codec_tags)}, "force codec tag/fourcc", "fourcc/tag" },
{ "q", HAS_ARG | OPT_EXPERT | OPT_DOUBLE | OPT_SPEC, {.off = OFFSET(qscale)}, "use fixed quality scale (VBR)", "q" },
{ "qscale", HAS_ARG | OPT_EXPERT | OPT_DOUBLE | OPT_SPEC, {.off = OFFSET(qscale)}, "use fixed quality scale (VBR)", "q" },
{ "filter", HAS_ARG | OPT_STRING | OPT_SPEC, {.off = OFFSET(filters)}, "set stream filterchain", "filter_list" },
- { "filter_complex", HAS_ARG | OPT_EXPERT, {(void*)opt_filter_complex}, "create a complex filtergraph", "graph_description" },
+ { "filter_complex", HAS_ARG | OPT_EXPERT, {.func_arg = opt_filter_complex}, "create a complex filtergraph", "graph_description" },
{ "stats", OPT_BOOL, {&print_stats}, "print progress report during encoding", },
- { "attach", HAS_ARG | OPT_FUNC2, {(void*)opt_attach}, "add an attachment to the output file", "filename" },
+ { "attach", HAS_ARG | OPT_FUNC2, {.func2_arg = opt_attach}, "add an attachment to the output file", "filename" },
{ "dump_attachment", HAS_ARG | OPT_STRING | OPT_SPEC, {.off = OFFSET(dump_attachment)}, "extract an attachment into a file", "filename" },
- { "cpuflags", HAS_ARG | OPT_EXPERT, {(void*)opt_cpuflags}, "set CPU flags mask", "mask" },
+ { "cpuflags", HAS_ARG | OPT_EXPERT, {.func_arg = opt_cpuflags}, "set CPU flags mask", "mask" },

/* video options */
- { "vframes", HAS_ARG | OPT_VIDEO | OPT_FUNC2, {(void*)opt_video_frames}, "set the number of video frames to record", "number" },
+ { "vframes", HAS_ARG | OPT_VIDEO | OPT_FUNC2, {.func2_arg = opt_video_frames}, "set the number of video frames to record", "number" },
{ "r", HAS_ARG | OPT_VIDEO | OPT_STRING | OPT_SPEC, {.off = OFFSET(frame_rates)}, "set frame rate (Hz value, fraction or abbreviation)", "rate" },
{ "s", HAS_ARG | OPT_VIDEO | OPT_STRING | OPT_SPEC, {.off = OFFSET(frame_sizes)}, "set frame size (WxH or abbreviation)", "size" },
{ "aspect", HAS_ARG | OPT_VIDEO | OPT_STRING | OPT_SPEC, {.off = OFFSET(frame_aspect_ratios)}, "set aspect ratio (4:3, 16:9 or 1.3333, 1.7777)", "aspect" },
{ "pix_fmt", HAS_ARG | OPT_EXPERT | OPT_VIDEO | OPT_STRING | OPT_SPEC, {.off = OFFSET(frame_pix_fmts)}, "set pixel format", "format" },
{ "vn", OPT_BOOL | OPT_VIDEO | OPT_OFFSET, {.off = OFFSET(video_disable)}, "disable video" },
- { "vdt", OPT_INT | HAS_ARG | OPT_EXPERT | OPT_VIDEO, {(void*)&video_discard}, "discard threshold", "n" },
+ { "vdt", OPT_INT | HAS_ARG | OPT_EXPERT | OPT_VIDEO, {&video_discard}, "discard threshold", "n" },
{ "rc_override", HAS_ARG | OPT_EXPERT | OPT_VIDEO | OPT_STRING | OPT_SPEC, {.off = OFFSET(rc_overrides)}, "rate control override for specific intervals", "override" },
- { "vcodec", HAS_ARG | OPT_VIDEO | OPT_FUNC2, {(void*)opt_video_codec}, "force video codec ('copy' to copy stream)", "codec" },
- { "same_quant", OPT_BOOL | OPT_VIDEO, {(void*)&same_quant},
+ { "vcodec", HAS_ARG | OPT_VIDEO | OPT_FUNC2, {.func2_arg = opt_video_codec}, "force video codec ('copy' to copy stream)", "codec" },
+ { "same_quant", OPT_BOOL | OPT_VIDEO, {&same_quant},
"use same quantizer as source (implies VBR)" },
- { "pass", HAS_ARG | OPT_VIDEO, {(void*)opt_pass}, "select the pass number (1 or 2)", "n" },
- { "passlogfile", HAS_ARG | OPT_STRING | OPT_VIDEO, {(void*)&pass_logfilename_prefix}, "select two pass log file name prefix", "prefix" },
- { "deinterlace", OPT_EXPERT | OPT_VIDEO, {(void*)opt_deinterlace},
+ { "pass", HAS_ARG | OPT_VIDEO, {opt_pass}, "select the pass number (1 or 2)", "n" },
+ { "passlogfile", HAS_ARG | OPT_STRING | OPT_VIDEO, {&pass_logfilename_prefix}, "select two pass log file name prefix", "prefix" },
+ { "deinterlace", OPT_EXPERT | OPT_VIDEO, {opt_deinterlace},
"this option is deprecated, use the yadif filter instead" },
- { "vstats", OPT_EXPERT | OPT_VIDEO, {(void*)&opt_vstats}, "dump video coding statistics to file" },
- { "vstats_file", HAS_ARG | OPT_EXPERT | OPT_VIDEO, {(void*)opt_vstats_file}, "dump video coding statistics to file", "file" },
- { "vf", HAS_ARG | OPT_VIDEO | OPT_FUNC2, {(void*)opt_video_filters}, "video filters", "filter list" },
+ { "vstats", OPT_EXPERT | OPT_VIDEO, {&opt_vstats}, "dump video coding statistics to file" },
+ { "vstats_file", HAS_ARG | OPT_EXPERT | OPT_VIDEO, {opt_vstats_file}, "dump video coding statistics to file", "file" },
+ { "vf", HAS_ARG | OPT_VIDEO | OPT_FUNC2, {.func2_arg = opt_video_filters}, "video filters", "filter list" },
{ "intra_matrix", HAS_ARG | OPT_EXPERT | OPT_VIDEO | OPT_STRING | OPT_SPEC, {.off = OFFSET(intra_matrices)}, "specify intra matrix coeffs", "matrix" },
{ "inter_matrix", HAS_ARG | OPT_EXPERT | OPT_VIDEO | OPT_STRING | OPT_SPEC, {.off = OFFSET(inter_matrices)}, "specify inter matrix coeffs", "matrix" },
{ "top", HAS_ARG | OPT_EXPERT | OPT_VIDEO | OPT_INT| OPT_SPEC, {.off = OFFSET(top_field_first)}, "top=1/bottom=0/auto=-1 field first", "" },
- { "dc", OPT_INT | HAS_ARG | OPT_EXPERT | OPT_VIDEO, {(void*)&intra_dc_precision}, "intra_dc_precision", "precision" },
- { "vtag", HAS_ARG | OPT_EXPERT | OPT_VIDEO | OPT_FUNC2, {(void*)opt_video_tag}, "force video tag/fourcc", "fourcc/tag" },
- { "qphist", OPT_BOOL | OPT_EXPERT | OPT_VIDEO, { (void *)&qp_hist }, "show QP histogram" },
+ { "dc", OPT_INT | HAS_ARG | OPT_EXPERT | OPT_VIDEO, {&intra_dc_precision}, "intra_dc_precision", "precision" },
+ { "vtag", HAS_ARG | OPT_EXPERT | OPT_VIDEO | OPT_FUNC2, {.func2_arg = opt_video_tag}, "force video tag/fourcc", "fourcc/tag" },
+ { "qphist", OPT_BOOL | OPT_EXPERT | OPT_VIDEO, {&qp_hist }, "show QP histogram" },
{ "force_fps", OPT_BOOL | OPT_EXPERT | OPT_VIDEO | OPT_SPEC, {.off = OFFSET(force_fps)}, "force the selected framerate, disable the best supported framerate selection" },
- { "streamid", HAS_ARG | OPT_EXPERT | OPT_FUNC2, {(void*)opt_streamid}, "set the value of an outfile streamid", "streamIndex:value" },
+ { "streamid", HAS_ARG | OPT_EXPERT | OPT_FUNC2, {.func2_arg = opt_streamid}, "set the value of an outfile streamid", "streamIndex:value" },
{ "force_key_frames", OPT_STRING | HAS_ARG | OPT_EXPERT | OPT_VIDEO | OPT_SPEC, {.off = OFFSET(forced_key_frames)}, "force key frames at specified timestamps", "timestamps" },

/* audio options */
- { "aframes", HAS_ARG | OPT_AUDIO | OPT_FUNC2, {(void*)opt_audio_frames}, "set the number of audio frames to record", "number" },
- { "aq", HAS_ARG | OPT_AUDIO | OPT_FUNC2, {(void*)opt_audio_qscale}, "set audio quality (codec-specific)", "quality", },
+ { "aframes", HAS_ARG | OPT_AUDIO | OPT_FUNC2, {.func2_arg = opt_audio_frames}, "set the number of audio frames to record", "number" },
+ { "aq", HAS_ARG | OPT_AUDIO | OPT_FUNC2, {.func2_arg = opt_audio_qscale}, "set audio quality (codec-specific)", "quality", },
{ "ar", HAS_ARG | OPT_AUDIO | OPT_INT | OPT_SPEC, {.off = OFFSET(audio_sample_rate)}, "set audio sampling rate (in Hz)", "rate" },
{ "ac", HAS_ARG | OPT_AUDIO | OPT_INT | OPT_SPEC, {.off = OFFSET(audio_channels)}, "set number of audio channels", "channels" },
{ "an", OPT_BOOL | OPT_AUDIO | OPT_OFFSET, {.off = OFFSET(audio_disable)}, "disable audio" },
- { "acodec", HAS_ARG | OPT_AUDIO | OPT_FUNC2, {(void*)opt_audio_codec}, "force audio codec ('copy' to copy stream)", "codec" },
- { "atag", HAS_ARG | OPT_EXPERT | OPT_AUDIO | OPT_FUNC2, {(void*)opt_audio_tag}, "force audio tag/fourcc", "fourcc/tag" },
- { "vol", OPT_INT | HAS_ARG | OPT_AUDIO, {(void*)&audio_volume}, "change audio volume (256=normal)" , "volume" }, //
+ { "acodec", HAS_ARG | OPT_AUDIO | OPT_FUNC2, {.func2_arg = opt_audio_codec}, "force audio codec ('copy' to copy stream)", "codec" },
+ { "atag", HAS_ARG | OPT_EXPERT | OPT_AUDIO | OPT_FUNC2, {.func2_arg = opt_audio_tag}, "force audio tag/fourcc", "fourcc/tag" },
+ { "vol", OPT_INT | HAS_ARG | OPT_AUDIO, {&audio_volume}, "change audio volume (256=normal)" , "volume" }, //
{ "sample_fmt", HAS_ARG | OPT_EXPERT | OPT_AUDIO | OPT_SPEC | OPT_STRING, {.off = OFFSET(sample_fmts)}, "set sample format", "format" },
- { "channel_layout", HAS_ARG | OPT_EXPERT | OPT_AUDIO | OPT_FUNC2, {(void*)opt_channel_layout}, "set channel layout", "layout" },
- { "af", HAS_ARG | OPT_AUDIO | OPT_FUNC2, {(void*)opt_audio_filters}, "audio filters", "filter list" },
+ { "channel_layout", HAS_ARG | OPT_EXPERT | OPT_AUDIO | OPT_FUNC2, {.func2_arg = opt_channel_layout}, "set channel layout", "layout" },
+ { "af", HAS_ARG | OPT_AUDIO | OPT_FUNC2, {.func2_arg = opt_audio_filters}, "audio filters", "filter list" },

/* subtitle options */
{ "sn", OPT_BOOL | OPT_SUBTITLE | OPT_OFFSET, {.off = OFFSET(subtitle_disable)}, "disable subtitle" },
- { "scodec", HAS_ARG | OPT_SUBTITLE | OPT_FUNC2, {(void*)opt_subtitle_codec}, "force subtitle codec ('copy' to copy stream)", "codec" },
- { "stag", HAS_ARG | OPT_EXPERT | OPT_SUBTITLE | OPT_FUNC2, {(void*)opt_subtitle_tag}, "force subtitle tag/fourcc", "fourcc/tag" },
+ { "scodec", HAS_ARG | OPT_SUBTITLE | OPT_FUNC2, {.func2_arg = opt_subtitle_codec}, "force subtitle codec ('copy' to copy stream)", "codec" },
+ { "stag", HAS_ARG | OPT_EXPERT | OPT_SUBTITLE | OPT_FUNC2, {.func2_arg = opt_subtitle_tag}, "force subtitle tag/fourcc", "fourcc/tag" },

/* grab options */
- { "isync", OPT_BOOL | OPT_EXPERT | OPT_GRAB, {(void*)&input_sync}, "sync read on input", "" },
+ { "isync", OPT_BOOL | OPT_EXPERT | OPT_GRAB, {&input_sync}, "sync read on input", "" },

/* muxer options */
{ "muxdelay", OPT_FLOAT | HAS_ARG | OPT_EXPERT | OPT_OFFSET, {.off = OFFSET(mux_max_delay)}, "set the maximum demux-decode delay", "seconds" },
@@ -1920,8 +1939,8 @@ const OptionDef options[] = {
{ "bsf", HAS_ARG | OPT_STRING | OPT_SPEC, {.off = OFFSET(bitstream_filters)}, "A comma-separated list of bitstream filters", "bitstream_filters" },

/* data codec support */
- { "dcodec", HAS_ARG | OPT_DATA | OPT_FUNC2, {(void*)opt_data_codec}, "force data codec ('copy' to copy stream)", "codec" },
+ { "dcodec", HAS_ARG | OPT_DATA | OPT_FUNC2, {.func2_arg = opt_data_codec}, "force data codec ('copy' to copy stream)", "codec" },

- { "default", HAS_ARG | OPT_AUDIO | OPT_VIDEO | OPT_EXPERT, {(void*)opt_default}, "generic catch all option", "" },
+ { "default", HAS_ARG | OPT_AUDIO | OPT_VIDEO | OPT_EXPERT, {.func_arg = opt_default}, "generic catch all option", "" },
{ NULL, },
};
--
1.7.10.4
Luca Barbato
2012-08-16 17:08:39 UTC
Permalink
Post by Anton Khirnov
---
avconv_opt.c | 147 +++++++++++++++++++++++++++++++++-------------------------
1 file changed, 83 insertions(+), 64 deletions(-)
Ok.
Diego Biurrun
2012-08-16 17:51:39 UTC
Permalink
Post by Anton Khirnov
---
avconv_opt.c | 147 +++++++++++++++++++++++++++++++++-------------------------
1 file changed, 83 insertions(+), 64 deletions(-)
--- a/avconv_opt.c
+++ b/avconv_opt.c
@@ -148,28 +148,33 @@ static double parse_frame_aspect_ratio(const char *arg)
-static int opt_audio_codec(OptionsContext *o, const char *opt, const char *arg)
+static int opt_audio_codec(void *optctx, const char *opt, const char *arg)
{
+ OptionsContext *o = optctx;
return parse_option(o, "codec:a", arg, options);
}
What about changing the function pointer signature instead?

Diego
Anton Khirnov
2012-08-16 18:42:14 UTC
Permalink
Post by Diego Biurrun
Post by Anton Khirnov
---
avconv_opt.c | 147 +++++++++++++++++++++++++++++++++-------------------------
1 file changed, 83 insertions(+), 64 deletions(-)
--- a/avconv_opt.c
+++ b/avconv_opt.c
@@ -148,28 +148,33 @@ static double parse_frame_aspect_ratio(const char *arg)
-static int opt_audio_codec(OptionsContext *o, const char *opt, const char *arg)
+static int opt_audio_codec(void *optctx, const char *opt, const char *arg)
{
+ OptionsContext *o = optctx;
return parse_option(o, "codec:a", arg, options);
}
What about changing the function pointer signature instead?
I cannot do that. OptionsContext is avconv-specific.
It is called from the code that is shared between all avtools.
--
Anton Khirnov
Anton Khirnov
2012-08-15 08:37:21 UTC
Permalink
---
avconv_opt.c | 265 ++++++++++++++++++++++++++++++++++++++--------------------
1 file changed, 174 insertions(+), 91 deletions(-)

diff --git a/avconv_opt.c b/avconv_opt.c
index 1243861..132ac1b 100644
--- a/avconv_opt.c
+++ b/avconv_opt.c
@@ -1836,111 +1836,194 @@ void show_usage(void)
const OptionDef options[] = {
/* main options */
#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}, "input file name", "filename" },
- { "y", OPT_BOOL, {&file_overwrite}, "overwrite output files" },
- { "c", HAS_ARG | OPT_STRING | OPT_SPEC, {.off = OFFSET(codec_names)}, "codec name", "codec" },
- { "codec", HAS_ARG | OPT_STRING | OPT_SPEC, {.off = OFFSET(codec_names)}, "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}, "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 metadata information of outfile from infile",
- "outfile[,metadata]:infile[,metadata]" },
- { "map_chapters", OPT_INT | HAS_ARG | OPT_EXPERT | OPT_OFFSET, {.off = OFFSET(chapters_input_file)}, "set chapters mapping", "input_file_index" },
- { "t", HAS_ARG | OPT_TIME | OPT_OFFSET, {.off = OFFSET(recording_time)}, "record or transcode \"duration\" seconds of audio/video", "duration" },
- { "fs", HAS_ARG | OPT_INT64 | OPT_OFFSET, {.off = OFFSET(limit_filesize)}, "set the limit file size in bytes", "limit_size" }, //
- { "ss", HAS_ARG | OPT_TIME | OPT_OFFSET, {.off = OFFSET(start_time)}, "set the start time offset", "time_off" },
- { "itsoffset", HAS_ARG | OPT_TIME | OPT_OFFSET, {.off = OFFSET(input_ts_offset)}, "set the input ts offset", "time_off" },
- { "itsscale", HAS_ARG | OPT_DOUBLE | OPT_SPEC, {.off = OFFSET(ts_scale)}, "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, {.func2_arg = opt_data_frames}, "set the number of data frames to record", "number" },
- { "benchmark", OPT_BOOL | OPT_EXPERT, {&do_benchmark},
- "add timings for benchmarking" },
- { "timelimit", HAS_ARG, {.func_arg = opt_timelimit}, "set max runtime in seconds", "limit" },
- { "dump", OPT_BOOL | OPT_EXPERT, {&do_pkt_dump},
- "dump each input packet" },
- { "hex", OPT_BOOL | OPT_EXPERT, {&do_hex_dump},
- "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}, "specify target file type (\"vcd\", \"svcd\", \"dvd\", \"dv\", \"dv50\", \"pal-vcd\", \"ntsc-svcd\", ...)", "type" },
- { "vsync", HAS_ARG | OPT_EXPERT, {opt_vsync}, "video sync method", "" },
- { "async", HAS_ARG | OPT_INT | OPT_EXPERT, {&audio_sync_method}, "audio sync method", "" },
- { "adrift_threshold", HAS_ARG | OPT_FLOAT | OPT_EXPERT, {&audio_drift_threshold}, "audio drift threshold", "threshold" },
- { "copyts", OPT_BOOL | OPT_EXPERT, {&copy_ts}, "copy timestamps" },
- { "copytb", OPT_BOOL | OPT_EXPERT, {&copy_tb}, "copy input stream time base when stream copying" },
- { "shortest", OPT_BOOL | OPT_EXPERT | OPT_OFFSET, {.off = OFFSET(shortest)}, "finish encoding within shortest input" },
- { "dts_delta_threshold", HAS_ARG | OPT_FLOAT | OPT_EXPERT, {&dts_delta_threshold}, "timestamp discontinuity delta threshold", "threshold" },
- { "xerror", OPT_BOOL, {&exit_on_error}, "exit on error", "error" },
- { "copyinkf", OPT_BOOL | OPT_EXPERT | OPT_SPEC, {.off = OFFSET(copy_initial_nonkeyframes)}, "copy initial non-keyframes" },
- { "frames", OPT_INT64 | HAS_ARG | OPT_SPEC, {.off = OFFSET(max_frames)}, "set the number of frames to record", "number" },
- { "tag", OPT_STRING | HAS_ARG | OPT_SPEC, {.off = OFFSET(codec_tags)}, "force codec tag/fourcc", "fourcc/tag" },
- { "q", HAS_ARG | OPT_EXPERT | OPT_DOUBLE | OPT_SPEC, {.off = OFFSET(qscale)}, "use fixed quality scale (VBR)", "q" },
- { "qscale", HAS_ARG | OPT_EXPERT | OPT_DOUBLE | OPT_SPEC, {.off = OFFSET(qscale)}, "use fixed quality scale (VBR)", "q" },
- { "filter", HAS_ARG | OPT_STRING | OPT_SPEC, {.off = OFFSET(filters)}, "set stream filterchain", "filter_list" },
- { "filter_complex", HAS_ARG | OPT_EXPERT, {.func_arg = opt_filter_complex}, "create a complex filtergraph", "graph_description" },
- { "stats", OPT_BOOL, {&print_stats}, "print progress report during encoding", },
- { "attach", HAS_ARG | OPT_FUNC2, {.func2_arg = opt_attach}, "add an attachment to the output file", "filename" },
- { "dump_attachment", HAS_ARG | OPT_STRING | OPT_SPEC, {.off = OFFSET(dump_attachment)}, "extract an attachment into a file", "filename" },
- { "cpuflags", HAS_ARG | OPT_EXPERT, {.func_arg = opt_cpuflags}, "set CPU flags mask", "mask" },
+ { "f", HAS_ARG | OPT_STRING | OPT_OFFSET, {.off = OFFSET(format)},
+ "force format", "fmt" },
+ { "i", HAS_ARG | OPT_FUNC2, {.func2_arg = opt_input_file},
+ "input file name", "filename" },
+ { "y", OPT_BOOL, { &file_overwrite},
+ "overwrite output files" },
+ { "c", HAS_ARG | OPT_STRING | OPT_SPEC, {.off = OFFSET(codec_names)},
+ "codec name", "codec" },
+ { "codec", HAS_ARG | OPT_STRING | OPT_SPEC, {.off = OFFSET(codec_names)},
+ "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},
+ "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 metadata information of outfile from infile",
+ "outfile[,metadata]:infile[,metadata]" },
+ { "map_chapters", HAS_ARG | OPT_INT | OPT_EXPERT | OPT_OFFSET, {.off = OFFSET(chapters_input_file)},
+ "set chapters mapping", "input_file_index" },
+ { "t", HAS_ARG | OPT_TIME | OPT_OFFSET, {.off = OFFSET(recording_time)},
+ "record or transcode \"duration\" seconds of audio/video",
+ "duration" },
+ { "fs", HAS_ARG | OPT_INT64 | OPT_OFFSET, {.off = OFFSET(limit_filesize)},
+ "set the limit file size in bytes", "limit_size" },
+ { "ss", HAS_ARG | OPT_TIME | OPT_OFFSET, {.off = OFFSET(start_time)},
+ "set the start time offset", "time_off" },
+ { "itsoffset", HAS_ARG | OPT_TIME | OPT_OFFSET, {.off = OFFSET(input_ts_offset)},
+ "set the input ts offset", "time_off" },
+ { "itsscale", HAS_ARG | OPT_DOUBLE | OPT_SPEC, {.off = OFFSET(ts_scale)},
+ "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, {.func2_arg = opt_data_frames},
+ "set the number of data frames to record", "number" },
+ { "benchmark", OPT_BOOL | OPT_EXPERT, {&do_benchmark},
+ "add timings for benchmarking" },
+ { "timelimit", HAS_ARG, {.func_arg = opt_timelimit},
+ "set max runtime in seconds", "limit" },
+ { "dump", OPT_BOOL | OPT_EXPERT, {&do_pkt_dump},
+ "dump each input packet" },
+ { "hex", OPT_BOOL | OPT_EXPERT, {&do_hex_dump},
+ "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},
+ "specify target file type (\"vcd\", \"svcd\", \"dvd\","
+ " \"dv\", \"dv50\", \"pal-vcd\", \"ntsc-svcd\", ...)", "type" },
+ { "vsync", HAS_ARG | OPT_EXPERT, {opt_vsync},
+ "video sync method", "" },
+ { "async", HAS_ARG | OPT_INT | OPT_EXPERT, {&audio_sync_method},
+ "audio sync method", "" },
+ { "adrift_threshold", HAS_ARG | OPT_FLOAT | OPT_EXPERT, {&audio_drift_threshold},
+ "audio drift threshold", "threshold" },
+ { "copyts", OPT_BOOL | OPT_EXPERT, {&copy_ts},
+ "copy timestamps" },
+ { "copytb", OPT_BOOL | OPT_EXPERT, {&copy_tb},
+ "copy input stream time base when stream copying" },
+ { "shortest", OPT_BOOL | OPT_EXPERT | OPT_OFFSET, {.off = OFFSET(shortest)},
+ "finish encoding within shortest input" },
+ { "dts_delta_threshold", HAS_ARG | OPT_FLOAT | OPT_EXPERT, {&dts_delta_threshold},
+ "timestamp discontinuity delta threshold", "threshold" },
+ { "xerror", OPT_BOOL, {&exit_on_error},
+ "exit on error", "error" },
+ { "copyinkf", OPT_BOOL | OPT_EXPERT | OPT_SPEC, {.off = OFFSET(copy_initial_nonkeyframes)},
+ "copy initial non-keyframes" },
+ { "frames", OPT_INT64 | HAS_ARG | OPT_SPEC, {.off = OFFSET(max_frames)},
+ "set the number of frames to record", "number" },
+ { "tag", OPT_STRING | HAS_ARG | OPT_SPEC, {.off = OFFSET(codec_tags)},
+ "force codec tag/fourcc", "fourcc/tag" },
+ { "q", HAS_ARG | OPT_EXPERT | OPT_DOUBLE | OPT_SPEC,{.off = OFFSET(qscale)},
+ "use fixed quality scale (VBR)", "q" },
+ { "qscale", HAS_ARG | OPT_EXPERT | OPT_DOUBLE | OPT_SPEC,{.off = OFFSET(qscale)},
+ "use fixed quality scale (VBR)", "q" },
+ { "filter", HAS_ARG | OPT_STRING | OPT_SPEC, {.off = OFFSET(filters)},
+ "set stream filterchain", "filter_list" },
+ { "filter_complex", HAS_ARG | OPT_EXPERT, {.func_arg = opt_filter_complex},
+ "create a complex filtergraph", "graph_description" },
+ { "stats", OPT_BOOL, {&print_stats},
+ "print progress report during encoding", },
+ { "attach", HAS_ARG | OPT_FUNC2, {.func2_arg = opt_attach},
+ "add an attachment to the output file", "filename" },
+ { "dump_attachment", HAS_ARG | OPT_STRING | OPT_SPEC, {.off = OFFSET(dump_attachment)},
+ "extract an attachment into a file", "filename" },
+ { "cpuflags", HAS_ARG | OPT_EXPERT, {.func_arg = opt_cpuflags},
+ "set CPU flags mask", "mask" },

/* video options */
- { "vframes", HAS_ARG | OPT_VIDEO | OPT_FUNC2, {.func2_arg = opt_video_frames}, "set the number of video frames to record", "number" },
- { "r", HAS_ARG | OPT_VIDEO | OPT_STRING | OPT_SPEC, {.off = OFFSET(frame_rates)}, "set frame rate (Hz value, fraction or abbreviation)", "rate" },
- { "s", HAS_ARG | OPT_VIDEO | OPT_STRING | OPT_SPEC, {.off = OFFSET(frame_sizes)}, "set frame size (WxH or abbreviation)", "size" },
- { "aspect", HAS_ARG | OPT_VIDEO | OPT_STRING | OPT_SPEC, {.off = OFFSET(frame_aspect_ratios)}, "set aspect ratio (4:3, 16:9 or 1.3333, 1.7777)", "aspect" },
- { "pix_fmt", HAS_ARG | OPT_EXPERT | OPT_VIDEO | OPT_STRING | OPT_SPEC, {.off = OFFSET(frame_pix_fmts)}, "set pixel format", "format" },
- { "vn", OPT_BOOL | OPT_VIDEO | OPT_OFFSET, {.off = OFFSET(video_disable)}, "disable video" },
- { "vdt", OPT_INT | HAS_ARG | OPT_EXPERT | OPT_VIDEO, {&video_discard}, "discard threshold", "n" },
- { "rc_override", HAS_ARG | OPT_EXPERT | OPT_VIDEO | OPT_STRING | OPT_SPEC, {.off = OFFSET(rc_overrides)}, "rate control override for specific intervals", "override" },
- { "vcodec", HAS_ARG | OPT_VIDEO | OPT_FUNC2, {.func2_arg = opt_video_codec}, "force video codec ('copy' to copy stream)", "codec" },
- { "same_quant", OPT_BOOL | OPT_VIDEO, {&same_quant},
- "use same quantizer as source (implies VBR)" },
- { "pass", HAS_ARG | OPT_VIDEO, {opt_pass}, "select the pass number (1 or 2)", "n" },
- { "passlogfile", HAS_ARG | OPT_STRING | OPT_VIDEO, {&pass_logfilename_prefix}, "select two pass log file name prefix", "prefix" },
- { "deinterlace", OPT_EXPERT | OPT_VIDEO, {opt_deinterlace},
- "this option is deprecated, use the yadif filter instead" },
- { "vstats", OPT_EXPERT | OPT_VIDEO, {&opt_vstats}, "dump video coding statistics to file" },
- { "vstats_file", HAS_ARG | OPT_EXPERT | OPT_VIDEO, {opt_vstats_file}, "dump video coding statistics to file", "file" },
- { "vf", HAS_ARG | OPT_VIDEO | OPT_FUNC2, {.func2_arg = opt_video_filters}, "video filters", "filter list" },
- { "intra_matrix", HAS_ARG | OPT_EXPERT | OPT_VIDEO | OPT_STRING | OPT_SPEC, {.off = OFFSET(intra_matrices)}, "specify intra matrix coeffs", "matrix" },
- { "inter_matrix", HAS_ARG | OPT_EXPERT | OPT_VIDEO | OPT_STRING | OPT_SPEC, {.off = OFFSET(inter_matrices)}, "specify inter matrix coeffs", "matrix" },
- { "top", HAS_ARG | OPT_EXPERT | OPT_VIDEO | OPT_INT| OPT_SPEC, {.off = OFFSET(top_field_first)}, "top=1/bottom=0/auto=-1 field first", "" },
- { "dc", OPT_INT | HAS_ARG | OPT_EXPERT | OPT_VIDEO, {&intra_dc_precision}, "intra_dc_precision", "precision" },
- { "vtag", HAS_ARG | OPT_EXPERT | OPT_VIDEO | OPT_FUNC2, {.func2_arg = opt_video_tag}, "force video tag/fourcc", "fourcc/tag" },
- { "qphist", OPT_BOOL | OPT_EXPERT | OPT_VIDEO, {&qp_hist }, "show QP histogram" },
- { "force_fps", OPT_BOOL | OPT_EXPERT | OPT_VIDEO | OPT_SPEC, {.off = OFFSET(force_fps)}, "force the selected framerate, disable the best supported framerate selection" },
- { "streamid", HAS_ARG | OPT_EXPERT | OPT_FUNC2, {.func2_arg = opt_streamid}, "set the value of an outfile streamid", "streamIndex:value" },
- { "force_key_frames", OPT_STRING | HAS_ARG | OPT_EXPERT | OPT_VIDEO | OPT_SPEC, {.off = OFFSET(forced_key_frames)}, "force key frames at specified timestamps", "timestamps" },
+ { "vframes", OPT_VIDEO | HAS_ARG | OPT_FUNC2, {.func2_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" },
+ { "s", OPT_VIDEO | HAS_ARG | OPT_STRING | OPT_SPEC, {.off = OFFSET(frame_sizes)},
+ "set frame size (WxH or abbreviation)", "size" },
+ { "aspect", OPT_VIDEO | HAS_ARG | OPT_STRING | OPT_SPEC, {.off = OFFSET(frame_aspect_ratios)},
+ "set aspect ratio (4:3, 16:9 or 1.3333, 1.7777)", "aspect" },
+ { "pix_fmt", OPT_VIDEO | HAS_ARG | OPT_EXPERT | OPT_STRING | OPT_SPEC, {.off = OFFSET(frame_pix_fmts)},
+ "set pixel format", "format" },
+ { "vn", OPT_VIDEO | OPT_BOOL | OPT_OFFSET, {.off = OFFSET(video_disable)},
+ "disable video" },
+ { "vdt", OPT_VIDEO | OPT_INT | HAS_ARG | OPT_EXPERT , {&video_discard},
+ "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},
+ "force video codec ('copy' to copy stream)", "codec" },
+ { "same_quant", OPT_VIDEO | OPT_BOOL , {&same_quant},
+ "use same quantizer as source (implies VBR)" },
+ { "pass", OPT_VIDEO | HAS_ARG , {opt_pass},
+ "select the pass number (1 or 2)", "n" },
+ { "passlogfile", OPT_VIDEO | HAS_ARG | OPT_STRING , {&pass_logfilename_prefix},
+ "select two pass log file name prefix", "prefix" },
+ { "deinterlace", OPT_VIDEO | OPT_EXPERT , {.func_arg = opt_deinterlace},
+ "this option is deprecated, use the yadif filter instead" },
+ { "vstats", OPT_VIDEO | OPT_EXPERT , {&opt_vstats},
+ "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},
+ "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" },
+ { "inter_matrix", OPT_VIDEO | HAS_ARG | OPT_EXPERT | OPT_STRING | OPT_SPEC, {.off = OFFSET(inter_matrices)},
+ "specify inter matrix coeffs", "matrix" },
+ { "top", OPT_VIDEO | HAS_ARG | OPT_EXPERT | OPT_INT| OPT_SPEC, {.off = OFFSET(top_field_first)},
+ "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},
+ "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},
+ "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", HAS_ARG | OPT_AUDIO | OPT_FUNC2, {.func2_arg = opt_audio_frames}, "set the number of audio frames to record", "number" },
- { "aq", HAS_ARG | OPT_AUDIO | OPT_FUNC2, {.func2_arg = opt_audio_qscale}, "set audio quality (codec-specific)", "quality", },
- { "ar", HAS_ARG | OPT_AUDIO | OPT_INT | OPT_SPEC, {.off = OFFSET(audio_sample_rate)}, "set audio sampling rate (in Hz)", "rate" },
- { "ac", HAS_ARG | OPT_AUDIO | OPT_INT | OPT_SPEC, {.off = OFFSET(audio_channels)}, "set number of audio channels", "channels" },
- { "an", OPT_BOOL | OPT_AUDIO | OPT_OFFSET, {.off = OFFSET(audio_disable)}, "disable audio" },
- { "acodec", HAS_ARG | OPT_AUDIO | OPT_FUNC2, {.func2_arg = opt_audio_codec}, "force audio codec ('copy' to copy stream)", "codec" },
- { "atag", HAS_ARG | OPT_EXPERT | OPT_AUDIO | OPT_FUNC2, {.func2_arg = opt_audio_tag}, "force audio tag/fourcc", "fourcc/tag" },
- { "vol", OPT_INT | HAS_ARG | OPT_AUDIO, {&audio_volume}, "change audio volume (256=normal)" , "volume" }, //
- { "sample_fmt", HAS_ARG | OPT_EXPERT | OPT_AUDIO | OPT_SPEC | OPT_STRING, {.off = OFFSET(sample_fmts)}, "set sample format", "format" },
- { "channel_layout", HAS_ARG | OPT_EXPERT | OPT_AUDIO | OPT_FUNC2, {.func2_arg = opt_channel_layout}, "set channel layout", "layout" },
- { "af", HAS_ARG | OPT_AUDIO | OPT_FUNC2, {.func2_arg = opt_audio_filters}, "audio filters", "filter list" },
+ { "aframes", OPT_AUDIO | HAS_ARG | OPT_FUNC2, {.func2_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},
+ "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" },
+ { "ac", OPT_AUDIO | HAS_ARG | OPT_INT | OPT_SPEC, {.off = OFFSET(audio_channels)},
+ "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},
+ "force audio codec ('copy' to copy stream)", "codec" },
+ { "atag", OPT_AUDIO | HAS_ARG | OPT_EXPERT | OPT_FUNC2, {.func2_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},
+ "set channel layout", "layout" },
+ { "af", OPT_AUDIO | HAS_ARG | OPT_FUNC2, {.func2_arg = opt_audio_filters},
+ "audio filters", "filter list" },

/* subtitle options */
- { "sn", OPT_BOOL | OPT_SUBTITLE | OPT_OFFSET, {.off = OFFSET(subtitle_disable)}, "disable subtitle" },
- { "scodec", HAS_ARG | OPT_SUBTITLE | OPT_FUNC2, {.func2_arg = opt_subtitle_codec}, "force subtitle codec ('copy' to copy stream)", "codec" },
- { "stag", HAS_ARG | OPT_EXPERT | OPT_SUBTITLE | OPT_FUNC2, {.func2_arg = opt_subtitle_tag}, "force subtitle tag/fourcc", "fourcc/tag" },
+ { "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},
+ "force subtitle codec ('copy' to copy stream)", "codec" },
+ { "stag", OPT_SUBTITLE | HAS_ARG | OPT_EXPERT | OPT_FUNC2, {.func2_arg = opt_subtitle_tag}
+ , "force subtitle tag/fourcc", "fourcc/tag" },

/* grab options */
{ "isync", OPT_BOOL | OPT_EXPERT | OPT_GRAB, {&input_sync}, "sync read on input", "" },

/* muxer options */
- { "muxdelay", OPT_FLOAT | HAS_ARG | OPT_EXPERT | OPT_OFFSET, {.off = OFFSET(mux_max_delay)}, "set the maximum demux-decode delay", "seconds" },
- { "muxpreload", OPT_FLOAT | HAS_ARG | OPT_EXPERT | OPT_OFFSET, {.off = OFFSET(mux_preload)}, "set the initial demux-decode delay", "seconds" },
+ { "muxdelay", OPT_FLOAT | HAS_ARG | OPT_EXPERT | OPT_OFFSET, {.off = OFFSET(mux_max_delay)},
+ "set the maximum demux-decode delay", "seconds" },
+ { "muxpreload", OPT_FLOAT | HAS_ARG | OPT_EXPERT | OPT_OFFSET, {.off = OFFSET(mux_preload)},
+ "set the initial demux-decode delay", "seconds" },

- { "bsf", HAS_ARG | OPT_STRING | OPT_SPEC, {.off = OFFSET(bitstream_filters)}, "A comma-separated list of bitstream filters", "bitstream_filters" },
+ { "bsf", HAS_ARG | OPT_STRING | OPT_SPEC, {.off = OFFSET(bitstream_filters)},
+ "A comma-separated list of bitstream filters", "bitstream_filters" },

/* data codec support */
- { "dcodec", HAS_ARG | OPT_DATA | OPT_FUNC2, {.func2_arg = opt_data_codec}, "force data codec ('copy' to copy stream)", "codec" },
+ { "dcodec", HAS_ARG | OPT_DATA | OPT_FUNC2, {.func2_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}, "generic catch all option", "" },
+ { "default", HAS_ARG | OPT_AUDIO | OPT_VIDEO | OPT_EXPERT, {.func_arg = opt_default},
+ "generic catch all option", "" },
{ NULL, },
};
--
1.7.10.4
Diego Biurrun
2012-08-15 15:50:46 UTC
Permalink
Post by Anton Khirnov
--- a/avconv_opt.c
+++ b/avconv_opt.c
@@ -1836,111 +1836,194 @@ void show_usage(void)
+ { "f", HAS_ARG | OPT_STRING | OPT_OFFSET, {.off = OFFSET(format)},
+ "force format", "fmt" },
+ { "i", HAS_ARG | OPT_FUNC2, {.func2_arg = opt_input_file},
+ "input file name", "filename" },
Please add spaces inside {}.

Diego
Anton Khirnov
2012-08-15 08:37:22 UTC
Permalink
This option does not do anything.

Also remove OPT_GRAB, since -isync is the last option using it.
---
avconv_opt.c | 20 ++++++++------------
cmdutils.h | 1 -
doc/avconv.texi | 7 -------
3 files changed, 8 insertions(+), 20 deletions(-)

diff --git a/avconv_opt.c b/avconv_opt.c
index 132ac1b..dd221fa 100644
--- a/avconv_opt.c
+++ b/avconv_opt.c
@@ -1795,28 +1795,24 @@ static int show_help(const char *opt, const char *arg)
av_log_set_callback(log_callback_help);
show_usage();
show_help_options(options, "Main options:\n",
- OPT_EXPERT | OPT_AUDIO | OPT_VIDEO | OPT_SUBTITLE | OPT_GRAB, 0);
+ OPT_EXPERT | OPT_AUDIO | OPT_VIDEO | OPT_SUBTITLE, 0);
show_help_options(options, "\nAdvanced options:\n",
- OPT_EXPERT | OPT_AUDIO | OPT_VIDEO | OPT_SUBTITLE | OPT_GRAB,
+ OPT_EXPERT | OPT_AUDIO | OPT_VIDEO | OPT_SUBTITLE,
OPT_EXPERT);
show_help_options(options, "\nVideo options:\n",
- OPT_EXPERT | OPT_AUDIO | OPT_VIDEO | OPT_GRAB,
+ OPT_EXPERT | OPT_AUDIO | OPT_VIDEO,
OPT_VIDEO);
show_help_options(options, "\nAdvanced Video options:\n",
- OPT_EXPERT | OPT_AUDIO | OPT_VIDEO | OPT_GRAB,
+ OPT_EXPERT | OPT_AUDIO | OPT_VIDEO,
OPT_VIDEO | OPT_EXPERT);
show_help_options(options, "\nAudio options:\n",
- OPT_EXPERT | OPT_AUDIO | OPT_VIDEO | OPT_GRAB,
+ OPT_EXPERT | OPT_AUDIO | OPT_VIDEO,
OPT_AUDIO);
show_help_options(options, "\nAdvanced Audio options:\n",
- OPT_EXPERT | OPT_AUDIO | OPT_VIDEO | OPT_GRAB,
+ OPT_EXPERT | OPT_AUDIO | OPT_VIDEO,
OPT_AUDIO | OPT_EXPERT);
show_help_options(options, "\nSubtitle options:\n",
- OPT_SUBTITLE | OPT_GRAB,
- OPT_SUBTITLE);
- show_help_options(options, "\nAudio/Video grab options:\n",
- OPT_GRAB,
- OPT_GRAB);
+ OPT_SUBTITLE, OPT_SUBTITLE);
printf("\n");
show_help_children(avcodec_get_class(), flags);
show_help_children(avformat_get_class(), flags);
@@ -2008,7 +2004,7 @@ const OptionDef options[] = {
, "force subtitle tag/fourcc", "fourcc/tag" },

/* grab options */
- { "isync", OPT_BOOL | OPT_EXPERT | OPT_GRAB, {&input_sync}, "sync read on input", "" },
+ { "isync", OPT_BOOL | OPT_EXPERT, {&input_sync}, "this option is deprecated and does nothing", "" },

/* muxer options */
{ "muxdelay", OPT_FLOAT | HAS_ARG | OPT_EXPERT | OPT_OFFSET, {.off = OFFSET(mux_max_delay)},
diff --git a/cmdutils.h b/cmdutils.h
index a02d19d..6fb5a35 100644
--- a/cmdutils.h
+++ b/cmdutils.h
@@ -130,7 +130,6 @@ typedef struct {
#define OPT_STRING 0x0008
#define OPT_VIDEO 0x0010
#define OPT_AUDIO 0x0020
-#define OPT_GRAB 0x0040
#define OPT_INT 0x0080
#define OPT_FLOAT 0x0100
#define OPT_SUBTITLE 0x0200
diff --git a/doc/avconv.texi b/doc/avconv.texi
index fc64028..9f06ddf 100644
--- a/doc/avconv.texi
+++ b/doc/avconv.texi
@@ -595,13 +595,6 @@ Set the subtitle codec. This is an alias for @code{-codec:s}.
Disable subtitle recording.
@end table

-@section Audio/Video grab options
-
-@table @option
-@item -isync (@emph{global})
-Synchronize read on input.
-@end table
-
@section Advanced options

@table @option
--
1.7.10.4
Luca Barbato
2012-08-15 22:28:21 UTC
Permalink
Post by Anton Khirnov
This option does not do anything.
Also remove OPT_GRAB, since -isync is the last option using it.
---
avconv_opt.c | 20 ++++++++------------
cmdutils.h | 1 -
doc/avconv.texi | 7 -------
3 files changed, 8 insertions(+), 20 deletions(-)
Ok.
Anton Khirnov
2012-08-15 08:37:24 UTC
Permalink
Currently it takes a mask and value, such that options for which
(flags & mask) == value.

Change it to take required flags and forbidden flags instead. This is
shorter and simpler to understand.
---
avconv_opt.c | 19 +++++++------------
avplay.c | 6 ++----
cmdutils.c | 29 ++++++++++++++++-------------
cmdutils.h | 12 ++++++++++--
4 files changed, 35 insertions(+), 31 deletions(-)

diff --git a/avconv_opt.c b/avconv_opt.c
index f1942cf..8a90b9c 100644
--- a/avconv_opt.c
+++ b/avconv_opt.c
@@ -1795,24 +1795,19 @@ static int show_help(const char *opt, const char *arg)
av_log_set_callback(log_callback_help);
show_usage();
show_help_options(options, "Main options:",
- OPT_EXPERT | OPT_AUDIO | OPT_VIDEO | OPT_SUBTITLE, 0);
+ 0, OPT_EXPERT | OPT_AUDIO | OPT_VIDEO | OPT_SUBTITLE);
show_help_options(options, "Advanced options:",
- OPT_EXPERT | OPT_AUDIO | OPT_VIDEO | OPT_SUBTITLE,
- OPT_EXPERT);
+ OPT_EXPERT, OPT_AUDIO | OPT_VIDEO | OPT_SUBTITLE);
show_help_options(options, "Video options:",
- OPT_EXPERT | OPT_AUDIO | OPT_VIDEO,
- OPT_VIDEO);
+ OPT_VIDEO, OPT_EXPERT | OPT_AUDIO);
show_help_options(options, "Advanced Video options:",
- OPT_EXPERT | OPT_AUDIO | OPT_VIDEO,
- OPT_VIDEO | OPT_EXPERT);
+ OPT_EXPERT | OPT_VIDEO, OPT_AUDIO);
show_help_options(options, "Audio options:",
- OPT_EXPERT | OPT_AUDIO | OPT_VIDEO,
- OPT_AUDIO);
+ OPT_AUDIO, OPT_EXPERT | OPT_VIDEO);
show_help_options(options, "Advanced Audio options:",
- OPT_EXPERT | OPT_AUDIO | OPT_VIDEO,
- OPT_AUDIO | OPT_EXPERT);
+ OPT_EXPERT | OPT_AUDIO, OPT_VIDEO);
show_help_options(options, "Subtitle options:",
- OPT_SUBTITLE, OPT_SUBTITLE);
+ OPT_SUBTITLE, 0);
printf("\n");
show_help_children(avcodec_get_class(), flags);
show_help_children(avformat_get_class(), flags);
diff --git a/avplay.c b/avplay.c
index bb10810..64d7b3d 100644
--- a/avplay.c
+++ b/avplay.c
@@ -2926,10 +2926,8 @@ static int show_help(const char *opt, const char *arg)
{
av_log_set_callback(log_callback_help);
show_usage();
- show_help_options(options, "Main options:",
- OPT_EXPERT, 0);
- show_help_options(options, "Advanced options:",
- OPT_EXPERT, OPT_EXPERT);
+ show_help_options(options, "Main options:", 0, OPT_EXPERT);
+ show_help_options(options, "Advanced options:", OPT_EXPERT, 0);
printf("\n");
show_help_children(avcodec_get_class(), AV_OPT_FLAG_DECODING_PARAM);
show_help_children(avformat_get_class(), AV_OPT_FLAG_DECODING_PARAM);
diff --git a/cmdutils.c b/cmdutils.c
index 5107744..bc5cb8a 100644
--- a/cmdutils.c
+++ b/cmdutils.c
@@ -113,8 +113,8 @@ int64_t parse_time_or_die(const char *context, const char *timestr,
return us;
}

-void show_help_options(const OptionDef *options, const char *msg, int mask,
- int value)
+void show_help_options(const OptionDef *options, const char *msg, int req_flags,
+ int rej_flags)
{
const OptionDef *po;
int first;
@@ -122,18 +122,21 @@ void show_help_options(const OptionDef *options, const char *msg, int mask,
first = 1;
for (po = options; po->name != NULL; po++) {
char buf[64];
- if ((po->flags & mask) == value) {
- if (first) {
- printf("%s\n", msg);
- first = 0;
- }
- av_strlcpy(buf, po->name, sizeof(buf));
- if (po->flags & HAS_ARG) {
- av_strlcat(buf, " ", sizeof(buf));
- av_strlcat(buf, po->argname, sizeof(buf));
- }
- printf("-%-17s %s\n", buf, po->help);
+
+ if (((po->flags & req_flags) != req_flags) ||
+ (po->flags & rej_flags))
+ continue;
+
+ if (first) {
+ printf("%s\n", msg);
+ first = 0;
+ }
+ av_strlcpy(buf, po->name, sizeof(buf));
+ if (po->flags & HAS_ARG) {
+ av_strlcat(buf, " ", sizeof(buf));
+ av_strlcat(buf, po->argname, sizeof(buf));
}
+ printf("-%-17s %s\n", buf, po->help);
}
printf("\n");
}
diff --git a/cmdutils.h b/cmdutils.h
index 6fb5a35..eb8a22a 100644
--- a/cmdutils.h
+++ b/cmdutils.h
@@ -153,8 +153,16 @@ typedef struct {
const char *argname;
} OptionDef;

-void show_help_options(const OptionDef *options, const char *msg, int mask,
- int value);
+/**
+ * Print help for all options matching specified flags.
+ *
+ * @param options a list of options
+ * @param msg title of this group. Only printed if at least one option matches.
+ * @param req_flags print only options which have all those flags set.
+ * @param rej_flags don't print options which have any of those flags set.
+ */
+void show_help_options(const OptionDef *options, const char *msg, int req_flags,
+ int rej_flags);

/**
* Show help for all options with given flags in class and all its
--
1.7.10.4
Luca Barbato
2012-08-16 11:45:27 UTC
Permalink
Post by Anton Khirnov
Currently it takes a mask and value, such that options for which
(flags & mask) == value.
Change it to take required flags and forbidden flags instead. This is
shorter and simpler to understand.
---
Ok.
Anton Khirnov
2012-08-15 08:37:26 UTC
Permalink
---
cmdutils.c | 55 ++++++++++++++++++++++++++++++++++++++++++
doc/avtools-common-opts.texi | 9 +++++++
2 files changed, 64 insertions(+)

diff --git a/cmdutils.c b/cmdutils.c
index 55cf3f0..50076c2 100644
--- a/cmdutils.c
+++ b/cmdutils.c
@@ -936,6 +936,57 @@ static void show_help_codec(const char *name, int encoder)
}
}

+static void show_help_demuxer(const char *name)
+{
+ const AVInputFormat *fmt = av_find_input_format(name);
+
+ if (!fmt) {
+ av_log(NULL, AV_LOG_ERROR, "Unknown format '%s'.\n", name);
+ return;
+ }
+
+ printf("Demuxer %s [%s]:\n", fmt->name, fmt->long_name);
+
+ if (fmt->extensions)
+ printf(" Common extensions: %s.\n", fmt->extensions);
+
+ if (fmt->priv_class)
+ show_help_children(fmt->priv_class, AV_OPT_FLAG_DECODING_PARAM);
+}
+
+static void show_help_muxer(const char *name)
+{
+ const AVCodecDescriptor *desc;
+ const AVOutputFormat *fmt = av_guess_format(name, NULL, NULL);
+
+ if (!fmt) {
+ av_log(NULL, AV_LOG_ERROR, "Unknown format '%s'.\n", name);
+ return;
+ }
+
+ printf("Muxer %s [%s]:\n", fmt->name, fmt->long_name);
+
+ if (fmt->extensions)
+ printf(" Common extensions: %s.\n", fmt->extensions);
+ if (fmt->mime_type)
+ printf(" Mime type: %s.\n", fmt->mime_type);
+ if (fmt->video_codec != AV_CODEC_ID_NONE &&
+ (desc = avcodec_descriptor_get(fmt->video_codec))) {
+ printf(" Default video codec: %s.\n", desc->name);
+ }
+ if (fmt->audio_codec != AV_CODEC_ID_NONE &&
+ (desc = avcodec_descriptor_get(fmt->audio_codec))) {
+ printf(" Default audio codec: %s.\n", desc->name);
+ }
+ if (fmt->subtitle_codec != AV_CODEC_ID_NONE &&
+ (desc = avcodec_descriptor_get(fmt->subtitle_codec))) {
+ printf(" Default subtitle codec: %s.\n", desc->name);
+ }
+
+ if (fmt->priv_class)
+ show_help_children(fmt->priv_class, AV_OPT_FLAG_ENCODING_PARAM);
+}
+
int show_help(const char *opt, const char *arg)
{
char *topic, *par;
@@ -952,6 +1003,10 @@ int show_help(const char *opt, const char *arg)
show_help_codec(par, 0);
} else if (!strcmp(topic, "encoder")) {
show_help_codec(par, 1);
+ } else if (!strcmp(topic, "demuxer")) {
+ show_help_demuxer(par);
+ } else if (!strcmp(topic, "muxer")) {
+ show_help_muxer(par);
} else {
show_help_default(topic, par);
}
diff --git a/doc/avtools-common-opts.texi b/doc/avtools-common-opts.texi
index eefb37b..d07505d 100644
--- a/doc/avtools-common-opts.texi
+++ b/doc/avtools-common-opts.texi
@@ -64,6 +64,15 @@ Print detailed information about the decoder named @var{decoder_name}. Use the
@item encoder=@var{encoder_name}
Print detailed information about the encoder named @var{encoder_name}. Use the
@option{-encoders} option to get a list of all encoders.
+
+@item demuxer=@var{demuxer_name}
+Print detailed information about the demuxer named @var{demuxer_name}. Use the
+@option{-formats} option to get a list of all demuxers and muxers.
+
+@item muxer=@var{muxer_name}
+Print detailed information about the muxer named @var{muxer_name}. Use the
+@option{-formats} option to get a list of all muxers and demuxers.
+
@end table

@item -version
--
1.7.10.4
Luca Barbato
2012-08-19 09:35:20 UTC
Permalink
Post by Anton Khirnov
---
cmdutils.c | 55 ++++++++++++++++++++++++++++++++++++++++++
doc/avtools-common-opts.texi | 9 +++++++
2 files changed, 64 insertions(+)
Looks ok.
Anton Khirnov
2012-08-19 09:35:59 UTC
Permalink
ping
--
Anton Khirnov
Anton Khirnov
2012-08-15 08:37:27 UTC
Permalink
---
avconv_opt.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/avconv_opt.c b/avconv_opt.c
index 5febae1..16d3175 100644
--- a/avconv_opt.c
+++ b/avconv_opt.c
@@ -1794,8 +1794,11 @@ void show_help_default(const char *opt, const char *arg)
int flags = AV_OPT_FLAG_DECODING_PARAM | AV_OPT_FLAG_ENCODING_PARAM;

show_usage();
+ show_help_options(options, "Print help / information / capabilities:",
+ OPT_EXIT, 0);
show_help_options(options, "Main options:",
- 0, OPT_EXPERT | OPT_AUDIO | OPT_VIDEO | OPT_SUBTITLE);
+ 0, OPT_EXPERT | OPT_AUDIO | OPT_VIDEO | OPT_SUBTITLE |
+ OPT_EXIT);
show_help_options(options, "Advanced options:",
OPT_EXPERT, OPT_AUDIO | OPT_VIDEO | OPT_SUBTITLE);
show_help_options(options, "Video options:",
--
1.7.10.4
Luca Barbato
2012-08-16 16:52:52 UTC
Permalink
Post by Anton Khirnov
---
avconv_opt.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
Ok
Anton Khirnov
2012-08-15 08:37:25 UTC
Permalink
---
avconv_filter.c | 14 -----
avconv_opt.c | 5 +-
avplay.c | 6 +--
avprobe.c | 3 +-
avserver.c | 2 +-
cmdutils.c | 120 +++++++++++++++++++++++++++++++++++++++++-
cmdutils.h | 30 +++++++++++
cmdutils_common_opts.h | 8 +--
doc/avtools-common-opts.texi | 16 +++++-
9 files changed, 172 insertions(+), 32 deletions(-)

diff --git a/avconv_filter.c b/avconv_filter.c
index d0ab4dc..4e5c1ec 100644
--- a/avconv_filter.c
+++ b/avconv_filter.c
@@ -59,29 +59,15 @@ static char *choose_ ## var ## s(OutputStream *ost) \
return NULL; \
}

-#define GET_PIX_FMT_NAME(pix_fmt)\
- const char *name = av_get_pix_fmt_name(pix_fmt);
-
DEF_CHOOSE_FORMAT(enum PixelFormat, pix_fmt, pix_fmts, PIX_FMT_NONE,
GET_PIX_FMT_NAME, ":")

-#define GET_SAMPLE_FMT_NAME(sample_fmt)\
- const char *name = av_get_sample_fmt_name(sample_fmt)
-
DEF_CHOOSE_FORMAT(enum AVSampleFormat, sample_fmt, sample_fmts,
AV_SAMPLE_FMT_NONE, GET_SAMPLE_FMT_NAME, ",")

-#define GET_SAMPLE_RATE_NAME(rate)\
- char name[16];\
- snprintf(name, sizeof(name), "%d", rate);
-
DEF_CHOOSE_FORMAT(int, sample_rate, supported_samplerates, 0,
GET_SAMPLE_RATE_NAME, ",")

-#define GET_CH_LAYOUT_NAME(ch_layout)\
- char name[16];\
- snprintf(name, sizeof(name), "0x%"PRIx64, ch_layout);
-
DEF_CHOOSE_FORMAT(uint64_t, channel_layout, channel_layouts, 0,
GET_CH_LAYOUT_NAME, ",")

diff --git a/avconv_opt.c b/avconv_opt.c
index 8a90b9c..5febae1 100644
--- a/avconv_opt.c
+++ b/avconv_opt.c
@@ -1789,10 +1789,10 @@ static int opt_filter_complex(const char *opt, const char *arg)
return 0;
}

-static int show_help(const char *opt, const char *arg)
+void show_help_default(const char *opt, const char *arg)
{
int flags = AV_OPT_FLAG_DECODING_PARAM | AV_OPT_FLAG_ENCODING_PARAM;
- av_log_set_callback(log_callback_help);
+
show_usage();
show_help_options(options, "Main options:",
0, OPT_EXPERT | OPT_AUDIO | OPT_VIDEO | OPT_SUBTITLE);
@@ -1812,7 +1812,6 @@ static int show_help(const char *opt, const char *arg)
show_help_children(avcodec_get_class(), flags);
show_help_children(avformat_get_class(), flags);
show_help_children(sws_get_class(), flags);
- return 0;
}

void show_usage(void)
diff --git a/avplay.c b/avplay.c
index 64d7b3d..4322802 100644
--- a/avplay.c
+++ b/avplay.c
@@ -224,8 +224,6 @@ typedef struct VideoState {
int refresh;
} VideoState;

-static int show_help(const char *opt, const char *arg);
-
/* options specified by the user */
static AVInputFormat *file_iformat;
static const char *input_filename;
@@ -2922,7 +2920,7 @@ static void show_usage(void)
printf("\n");
}

-static int show_help(const char *opt, const char *arg)
+void show_help_default(const char *opt, const char *arg)
{
av_log_set_callback(log_callback_help);
show_usage();
@@ -2947,8 +2945,6 @@ static int show_help(const char *opt, const char *arg)
"down/up seek backward/forward 1 minute\n"
"mouse click seek to percentage in file corresponding to fraction of width\n"
);
-
- return 0;
}

static void opt_input_file(void *optctx, const char *filename)
diff --git a/avprobe.c b/avprobe.c
index 70a9910..475c6a6 100644
--- a/avprobe.c
+++ b/avprobe.c
@@ -867,14 +867,13 @@ static void opt_input_file(void *optctx, const char *arg)
input_filename = arg;
}

-static int show_help(const char *opt, const char *arg)
+void show_help_default(const char *opt, const char *arg)
{
av_log_set_callback(log_callback_help);
show_usage();
show_help_options(options, "Main options:", 0, 0);
printf("\n");
show_help_children(avformat_get_class(), AV_OPT_FLAG_DECODING_PARAM);
- return 0;
}

static void opt_pretty(void)
diff --git a/avserver.c b/avserver.c
index de050a6..c3e8f2e 100644
--- a/avserver.c
+++ b/avserver.c
@@ -4629,7 +4629,7 @@ static void opt_debug(void)
logfilename[0] = '-';
}

-static void show_help(void)
+void show_help_default(void)
{
printf("usage: avserver [options]\n"
"Hyper fast multi format Audio/Video streaming server\n");
diff --git a/cmdutils.c b/cmdutils.c
index bc5cb8a..55cf3f0 100644
--- a/cmdutils.c
+++ b/cmdutils.c
@@ -132,7 +132,7 @@ void show_help_options(const OptionDef *options, const char *msg, int req_flags,
first = 0;
}
av_strlcpy(buf, po->name, sizeof(buf));
- if (po->flags & HAS_ARG) {
+ if (po->argname) {
av_strlcat(buf, " ", sizeof(buf));
av_strlcat(buf, po->argname, sizeof(buf));
}
@@ -642,6 +642,65 @@ int show_formats(const char *opt, const char *arg)
return 0;
}

+#define PRINT_CODEC_SUPPORTED(codec, field, type, list_name, term, get_name) \
+ if (codec->field) { \
+ const type *p = c->field; \
+ \
+ printf(" Supported " list_name ":"); \
+ while (*p != term) { \
+ get_name(*p); \
+ printf(" %s", name); \
+ p++; \
+ } \
+ printf("\n"); \
+ } \
+
+static void print_codec(const AVCodec *c)
+{
+ int encoder = av_codec_is_encoder(c);
+
+ printf("%s %s [%s]:\n", encoder ? "Encoder" : "Decoder", c->name,
+ c->long_name ? c->long_name : "");
+
+ if (c->type == AVMEDIA_TYPE_VIDEO) {
+ printf(" Threading capabilities: ");
+ switch (c->capabilities & (CODEC_CAP_FRAME_THREADS |
+ CODEC_CAP_SLICE_THREADS)) {
+ case CODEC_CAP_FRAME_THREADS |
+ CODEC_CAP_SLICE_THREADS: printf("frame and slice"); break;
+ case CODEC_CAP_FRAME_THREADS: printf("frame"); break;
+ case CODEC_CAP_SLICE_THREADS: printf("slice"); break;
+ default: printf("no"); break;
+ }
+ printf("\n");
+ }
+
+ if (c->supported_framerates) {
+ const AVRational *fps = c->supported_framerates;
+
+ printf(" Supported framerates:");
+ while (fps->num) {
+ printf(" %d/%d", fps->num, fps->den);
+ fps++;
+ }
+ printf("\n");
+ }
+ PRINT_CODEC_SUPPORTED(c, pix_fmts, enum PixelFormat, "pixel formats",
+ PIX_FMT_NONE, GET_PIX_FMT_NAME);
+ PRINT_CODEC_SUPPORTED(c, supported_samplerates, int, "sample rates", 0,
+ GET_SAMPLE_RATE_NAME);
+ PRINT_CODEC_SUPPORTED(c, sample_fmts, enum AVSampleFormat, "sample formats",
+ AV_SAMPLE_FMT_NONE, GET_SAMPLE_FMT_NAME);
+ PRINT_CODEC_SUPPORTED(c, channel_layouts, uint64_t, "channel layouts",
+ 0, GET_CH_LAYOUT_DESC);
+
+ if (c->priv_class) {
+ show_help_children(c->priv_class,
+ AV_OPT_FLAG_ENCODING_PARAM |
+ AV_OPT_FLAG_DECODING_PARAM);
+ }
+}
+
static char get_media_type_char(enum AVMediaType type)
{
switch (type) {
@@ -842,6 +901,65 @@ int show_sample_fmts(const char *opt, const char *arg)
return 0;
}

+static void show_help_codec(const char *name, int encoder)
+{
+ const AVCodecDescriptor *desc;
+ const AVCodec *codec;
+
+ if (!name) {
+ av_log(NULL, AV_LOG_ERROR, "No codec name specified.\n");
+ return;
+ }
+
+ codec = encoder ? avcodec_find_encoder_by_name(name) :
+ avcodec_find_decoder_by_name(name);
+
+ if (codec)
+ print_codec(codec);
+ else if ((desc = avcodec_descriptor_get_by_name(name))) {
+ int printed = 0;
+
+ while ((codec = next_codec_for_id(desc->id, codec, encoder))) {
+ printed = 1;
+ print_codec(codec);
+ }
+
+ if (!printed) {
+ av_log(NULL, AV_LOG_ERROR, "Codec '%s' is known to Libav, "
+ "but no %s for it are available. Libav might need to be "
+ "recompiled with additional external libraries.\n",
+ name, encoder ? "encoders" : "decoders");
+ }
+ } else {
+ av_log(NULL, AV_LOG_ERROR, "Codec '%s' is not recognized by Libav.\n",
+ name);
+ }
+}
+
+int show_help(const char *opt, const char *arg)
+{
+ char *topic, *par;
+ av_log_set_callback(log_callback_help);
+
+ topic = av_strdup(arg ? arg : "");
+ par = strchr(topic, '=');
+ if (par)
+ *par++ = 0;
+
+ if (!*topic) {
+ show_help_default(topic, par);
+ } else if (!strcmp(topic, "decoder")) {
+ show_help_codec(par, 0);
+ } else if (!strcmp(topic, "encoder")) {
+ show_help_codec(par, 1);
+ } else {
+ show_help_default(topic, par);
+ }
+
+ av_freep(&topic);
+ return 0;
+}
+
int read_yesno(void)
{
int c = getchar();
diff --git a/cmdutils.h b/cmdutils.h
index eb8a22a..39125ce 100644
--- a/cmdutils.h
+++ b/cmdutils.h
@@ -171,6 +171,17 @@ void show_help_options(const OptionDef *options, const char *msg, int req_flags,
void show_help_children(const AVClass *class, int flags);

/**
+ * Per-avtool specific help handler. Implemented in each
+ * avtool, called by show_help().
+ */
+void show_help_default(const char *opt, const char *arg);
+
+/**
+ * Generic -h handler common to all avtools.
+ */
+int show_help(const char *opt, const char *arg);
+
+/**
* Parse the command line arguments.
*
* @param optctx an opaque options context
@@ -446,4 +457,23 @@ void filter_release_buffer(AVFilterBuffer *fb);
* buffers have been released.
*/
void free_buffer_pool(FrameBuffer **pool);
+
+#define GET_PIX_FMT_NAME(pix_fmt)\
+ const char *name = av_get_pix_fmt_name(pix_fmt);
+
+#define GET_SAMPLE_FMT_NAME(sample_fmt)\
+ const char *name = av_get_sample_fmt_name(sample_fmt)
+
+#define GET_SAMPLE_RATE_NAME(rate)\
+ char name[16];\
+ snprintf(name, sizeof(name), "%d", rate);
+
+#define GET_CH_LAYOUT_NAME(ch_layout)\
+ char name[16];\
+ snprintf(name, sizeof(name), "0x%"PRIx64, ch_layout);
+
+#define GET_CH_LAYOUT_DESC(ch_layout)\
+ char name[128];\
+ av_get_channel_layout_string(name, sizeof(name), 0, ch_layout);
+
#endif /* LIBAV_CMDUTILS_H */
diff --git a/cmdutils_common_opts.h b/cmdutils_common_opts.h
index d66a82e..619cd89 100644
--- a/cmdutils_common_opts.h
+++ b/cmdutils_common_opts.h
@@ -1,8 +1,8 @@
{ "L" , OPT_EXIT, {.func_arg = show_license}, "show license" },
- { "h" , OPT_EXIT, {.func_arg = show_help}, "show help" },
- { "?" , OPT_EXIT, {.func_arg = show_help}, "show help" },
- { "help" , OPT_EXIT, {.func_arg = show_help}, "show help" },
- { "-help" , OPT_EXIT, {.func_arg = show_help}, "show help" },
+ { "h" , OPT_EXIT, {.func_arg = show_help}, "show help", "topic" },
+ { "?" , OPT_EXIT, {.func_arg = show_help}, "show help", "topic" },
+ { "help" , OPT_EXIT, {.func_arg = show_help}, "show help", "topic" },
+ { "-help" , OPT_EXIT, {.func_arg = show_help}, "show help", "topic" },
{ "version" , OPT_EXIT, {.func_arg = show_version}, "show version" },
{ "formats" , OPT_EXIT, {.func_arg = show_formats }, "show available formats" },
{ "codecs" , OPT_EXIT, {.func_arg = show_codecs }, "show available codecs" },
diff --git a/doc/avtools-common-opts.texi b/doc/avtools-common-opts.texi
index 375e4b0..eefb37b 100644
--- a/doc/avtools-common-opts.texi
+++ b/doc/avtools-common-opts.texi
@@ -51,8 +51,20 @@ These options are shared amongst the av* tools.
@item -L
Show license.

-@item -h, -?, -help, --help
-Show help.
+@item -h, -?, -help, --help [@var{arg}]
+Show help. An optional parameter may be specified to print help about a specific
+item.
+
+Possible values of @var{arg} are:
+@table @option
+@item decoder=@var{decoder_name}
+Print detailed information about the decoder named @var{decoder_name}. Use the
+@option{-decoders} option to get a list of all decoders.
+
+@item encoder=@var{encoder_name}
+Print detailed information about the encoder named @var{encoder_name}. Use the
+@option{-encoders} option to get a list of all encoders.
+@end table

@item -version
Show version.
--
1.7.10.4
Luca Barbato
2012-08-16 11:46:34 UTC
Permalink
Post by Anton Khirnov
---
avconv_filter.c | 14 -----
avconv_opt.c | 5 +-
avplay.c | 6 +--
avprobe.c | 3 +-
avserver.c | 2 +-
cmdutils.c | 120 +++++++++++++++++++++++++++++++++++++++++-
cmdutils.h | 30 +++++++++++
cmdutils_common_opts.h | 8 +--
doc/avtools-common-opts.texi | 16 +++++-
9 files changed, 172 insertions(+), 32 deletions(-)
Ok.
Anton Khirnov
2012-08-15 08:37:28 UTC
Permalink
By default don't dump every single option on the user, but print only
the basic options.

Add -h long/full to print more options.
---
avconv_opt.c | 46 ++++++++++++++++++++++++++++++++++++----------
1 file changed, 36 insertions(+), 10 deletions(-)

diff --git a/avconv_opt.c b/avconv_opt.c
index 16d3175..e451933 100644
--- a/avconv_opt.c
+++ b/avconv_opt.c
@@ -1791,30 +1791,56 @@ static int opt_filter_complex(const char *opt, const char *arg)

void show_help_default(const char *opt, const char *arg)
{
- int flags = AV_OPT_FLAG_DECODING_PARAM | AV_OPT_FLAG_ENCODING_PARAM;
+ int show_advanced = 0, show_avoptions = 0;
+
+ if (opt) {
+ if (!strcmp(opt, "long"))
+ show_advanced = 1;
+ else if (!strcmp(opt, "full"))
+ show_advanced = show_avoptions = 1;
+ else
+ av_log(NULL, AV_LOG_ERROR, "Unknown help option '%s'.\n", opt);
+ }

show_usage();
+
+ printf("Getting help:\n"
+ " -h -- print basic options\n"
+ " -h long -- print more options\n"
+ " -h full -- print all options (including all format and codec specific options, very long)\n"
+ " See man %s for detailed description of the options.\n"
+ "\n", program_name);
+
show_help_options(options, "Print help / information / capabilities:",
OPT_EXIT, 0);
show_help_options(options, "Main options:",
0, OPT_EXPERT | OPT_AUDIO | OPT_VIDEO | OPT_SUBTITLE |
OPT_EXIT);
- show_help_options(options, "Advanced options:",
- OPT_EXPERT, OPT_AUDIO | OPT_VIDEO | OPT_SUBTITLE);
+ if (show_advanced)
+ show_help_options(options, "Advanced options:",
+ OPT_EXPERT, OPT_AUDIO | OPT_VIDEO | OPT_SUBTITLE);
+
show_help_options(options, "Video options:",
OPT_VIDEO, OPT_EXPERT | OPT_AUDIO);
- show_help_options(options, "Advanced Video options:",
- OPT_EXPERT | OPT_VIDEO, OPT_AUDIO);
+ if (show_advanced)
+ show_help_options(options, "Advanced Video options:",
+ OPT_EXPERT | OPT_VIDEO, OPT_AUDIO);
+
show_help_options(options, "Audio options:",
OPT_AUDIO, OPT_EXPERT | OPT_VIDEO);
- show_help_options(options, "Advanced Audio options:",
- OPT_EXPERT | OPT_AUDIO, OPT_VIDEO);
+ if (show_advanced)
+ show_help_options(options, "Advanced Audio options:",
+ OPT_EXPERT | OPT_AUDIO, OPT_VIDEO);
show_help_options(options, "Subtitle options:",
OPT_SUBTITLE, 0);
printf("\n");
- show_help_children(avcodec_get_class(), flags);
- show_help_children(avformat_get_class(), flags);
- show_help_children(sws_get_class(), flags);
+
+ if (show_avoptions) {
+ int flags = AV_OPT_FLAG_DECODING_PARAM | AV_OPT_FLAG_ENCODING_PARAM;
+ show_help_children(avcodec_get_class(), flags);
+ show_help_children(avformat_get_class(), flags);
+ show_help_children(sws_get_class(), flags);
+ }
}

void show_usage(void)
--
1.7.10.4
Luca Barbato
2012-08-16 17:07:59 UTC
Permalink
Post by Anton Khirnov
By default don't dump every single option on the user, but print only
the basic options.
Add -h long/full to print more options.
ok.
Anton Khirnov
2012-08-15 08:37:29 UTC
Permalink
---
avconv_opt.c | 32 +++++++++++++++++++++-----------
avplay.c | 4 ++--
avprobe.c | 2 +-
avserver.c | 2 +-
cmdutils.c | 3 ++-
cmdutils.h | 3 ++-
6 files changed, 29 insertions(+), 17 deletions(-)

diff --git a/avconv_opt.c b/avconv_opt.c
index e451933..fc1c1d4 100644
--- a/avconv_opt.c
+++ b/avconv_opt.c
@@ -1791,6 +1791,8 @@ static int opt_filter_complex(const char *opt, const char *arg)

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;
int show_advanced = 0, show_avoptions = 0;

if (opt) {
@@ -1812,27 +1814,35 @@ void show_help_default(const char *opt, const char *arg)
"\n", program_name);

show_help_options(options, "Print help / information / capabilities:",
- OPT_EXIT, 0);
- show_help_options(options, "Main options:",
- 0, OPT_EXPERT | OPT_AUDIO | OPT_VIDEO | OPT_SUBTITLE |
- OPT_EXIT);
+ OPT_EXIT, 0, 0);
+
+ show_help_options(options, "Global options (affect whole program "
+ "instead of just one file:",
+ 0, per_file | OPT_EXIT | OPT_EXPERT, 0);
+ if (show_advanced)
+ show_help_options(options, "Advanced global options:", OPT_EXPERT,
+ per_file | OPT_EXIT, 0);
+
+ show_help_options(options, "Per-file main options:", 0,
+ OPT_EXPERT | OPT_AUDIO | OPT_VIDEO | OPT_SUBTITLE |
+ OPT_EXIT, per_file);
if (show_advanced)
- show_help_options(options, "Advanced options:",
- OPT_EXPERT, OPT_AUDIO | OPT_VIDEO | OPT_SUBTITLE);
+ show_help_options(options, "Advanced per-file options:",
+ OPT_EXPERT, OPT_AUDIO | OPT_VIDEO | OPT_SUBTITLE, per_file);

show_help_options(options, "Video options:",
- OPT_VIDEO, OPT_EXPERT | OPT_AUDIO);
+ OPT_VIDEO, OPT_EXPERT | OPT_AUDIO, 0);
if (show_advanced)
show_help_options(options, "Advanced Video options:",
- OPT_EXPERT | OPT_VIDEO, OPT_AUDIO);
+ OPT_EXPERT | OPT_VIDEO, OPT_AUDIO, 0);

show_help_options(options, "Audio options:",
- OPT_AUDIO, OPT_EXPERT | OPT_VIDEO);
+ OPT_AUDIO, OPT_EXPERT | OPT_VIDEO, 0);
if (show_advanced)
show_help_options(options, "Advanced Audio options:",
- OPT_EXPERT | OPT_AUDIO, OPT_VIDEO);
+ OPT_EXPERT | OPT_AUDIO, OPT_VIDEO, 0);
show_help_options(options, "Subtitle options:",
- OPT_SUBTITLE, 0);
+ OPT_SUBTITLE, 0, 0);
printf("\n");

if (show_avoptions) {
diff --git a/avplay.c b/avplay.c
index 4322802..0c642e0 100644
--- a/avplay.c
+++ b/avplay.c
@@ -2924,8 +2924,8 @@ void show_help_default(const char *opt, const char *arg)
{
av_log_set_callback(log_callback_help);
show_usage();
- show_help_options(options, "Main options:", 0, OPT_EXPERT);
- show_help_options(options, "Advanced options:", OPT_EXPERT, 0);
+ show_help_options(options, "Main options:", 0, OPT_EXPERT, 0);
+ show_help_options(options, "Advanced options:", OPT_EXPERT, 0, 0);
printf("\n");
show_help_children(avcodec_get_class(), AV_OPT_FLAG_DECODING_PARAM);
show_help_children(avformat_get_class(), AV_OPT_FLAG_DECODING_PARAM);
diff --git a/avprobe.c b/avprobe.c
index 475c6a6..2246574 100644
--- a/avprobe.c
+++ b/avprobe.c
@@ -871,7 +871,7 @@ void show_help_default(const char *opt, const char *arg)
{
av_log_set_callback(log_callback_help);
show_usage();
- show_help_options(options, "Main options:", 0, 0);
+ show_help_options(options, "Main options:", 0, 0, 0);
printf("\n");
show_help_children(avformat_get_class(), AV_OPT_FLAG_DECODING_PARAM);
}
diff --git a/avserver.c b/avserver.c
index c3e8f2e..834253e 100644
--- a/avserver.c
+++ b/avserver.c
@@ -4634,7 +4634,7 @@ void show_help_default(void)
printf("usage: avserver [options]\n"
"Hyper fast multi format Audio/Video streaming server\n");
printf("\n");
- show_help_options(options, "Main options:", 0, 0);
+ show_help_options(options, "Main options:", 0, 0, 0);
}

static const OptionDef options[] = {
diff --git a/cmdutils.c b/cmdutils.c
index 50076c2..6576eba 100644
--- a/cmdutils.c
+++ b/cmdutils.c
@@ -114,7 +114,7 @@ int64_t parse_time_or_die(const char *context, const char *timestr,
}

void show_help_options(const OptionDef *options, const char *msg, int req_flags,
- int rej_flags)
+ int rej_flags, int alt_flags)
{
const OptionDef *po;
int first;
@@ -124,6 +124,7 @@ void show_help_options(const OptionDef *options, const char *msg, int req_flags,
char buf[64];

if (((po->flags & req_flags) != req_flags) ||
+ (alt_flags && !(po->flags & alt_flags)) ||
(po->flags & rej_flags))
continue;

diff --git a/cmdutils.h b/cmdutils.h
index 39125ce..212aa71 100644
--- a/cmdutils.h
+++ b/cmdutils.h
@@ -160,9 +160,10 @@ typedef struct {
* @param msg title of this group. Only printed if at least one option matches.
* @param req_flags print only options which have all those flags set.
* @param rej_flags don't print options which have any of those flags set.
+ * @param alt_flags print only options that have at least one of those flags set
*/
void show_help_options(const OptionDef *options, const char *msg, int req_flags,
- int rej_flags);
+ int rej_flags, int alt_flags);

/**
* Show help for all options with given flags in class and all its
--
1.7.10.4
Luca Barbato
2012-08-16 13:47:38 UTC
Permalink
Post by Anton Khirnov
---
avconv_opt.c | 32 +++++++++++++++++++++-----------
avplay.c | 4 ++--
avprobe.c | 2 +-
avserver.c | 2 +-
cmdutils.c | 3 ++-
cmdutils.h | 3 ++-
6 files changed, 29 insertions(+), 17 deletions(-)
Seems fine
Anton Khirnov
2012-08-15 08:37:30 UTC
Permalink
---
avconv_opt.c | 24 ++++++++++++------------
1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/avconv_opt.c b/avconv_opt.c
index fc1c1d4..5ad4928 100644
--- a/avconv_opt.c
+++ b/avconv_opt.c
@@ -1892,17 +1892,17 @@ const OptionDef options[] = {
"set the limit file size in bytes", "limit_size" },
{ "ss", HAS_ARG | OPT_TIME | OPT_OFFSET, {.off = OFFSET(start_time)},
"set the start time offset", "time_off" },
- { "itsoffset", HAS_ARG | OPT_TIME | OPT_OFFSET, {.off = OFFSET(input_ts_offset)},
+ { "itsoffset", HAS_ARG | OPT_TIME | OPT_OFFSET | OPT_EXPERT,{.off = OFFSET(input_ts_offset)},
"set the input ts offset", "time_off" },
- { "itsscale", HAS_ARG | OPT_DOUBLE | OPT_SPEC, {.off = OFFSET(ts_scale)},
+ { "itsscale", HAS_ARG | OPT_DOUBLE | OPT_SPEC | OPT_EXPERT,{.off = OFFSET(ts_scale)},
"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, {.func2_arg = opt_data_frames},
+ { "dframes", HAS_ARG | OPT_FUNC2 | OPT_EXPERT, {.func2_arg = opt_data_frames},
"set the number of data frames to record", "number" },
{ "benchmark", OPT_BOOL | OPT_EXPERT, {&do_benchmark},
"add timings for benchmarking" },
- { "timelimit", HAS_ARG, {.func_arg = opt_timelimit},
+ { "timelimit", HAS_ARG | OPT_EXPERT, {.func_arg = opt_timelimit},
"set max runtime in seconds", "limit" },
{ "dump", OPT_BOOL | OPT_EXPERT, {&do_pkt_dump},
"dump each input packet" },
@@ -1927,13 +1927,13 @@ const OptionDef options[] = {
"finish encoding within shortest input" },
{ "dts_delta_threshold", HAS_ARG | OPT_FLOAT | OPT_EXPERT, {&dts_delta_threshold},
"timestamp discontinuity delta threshold", "threshold" },
- { "xerror", OPT_BOOL, {&exit_on_error},
+ { "xerror", OPT_BOOL | OPT_EXPERT, {&exit_on_error},
"exit on error", "error" },
{ "copyinkf", OPT_BOOL | OPT_EXPERT | OPT_SPEC, {.off = OFFSET(copy_initial_nonkeyframes)},
"copy initial non-keyframes" },
{ "frames", OPT_INT64 | HAS_ARG | OPT_SPEC, {.off = OFFSET(max_frames)},
"set the number of frames to record", "number" },
- { "tag", OPT_STRING | HAS_ARG | OPT_SPEC, {.off = OFFSET(codec_tags)},
+ { "tag", OPT_STRING | HAS_ARG | OPT_SPEC | OPT_EXPERT,{.off = OFFSET(codec_tags)},
"force codec tag/fourcc", "fourcc/tag" },
{ "q", HAS_ARG | OPT_EXPERT | OPT_DOUBLE | OPT_SPEC,{.off = OFFSET(qscale)},
"use fixed quality scale (VBR)", "q" },
@@ -1945,9 +1945,9 @@ const OptionDef options[] = {
"create a complex filtergraph", "graph_description" },
{ "stats", OPT_BOOL, {&print_stats},
"print progress report during encoding", },
- { "attach", HAS_ARG | OPT_FUNC2, {.func2_arg = opt_attach},
+ { "attach", HAS_ARG | OPT_FUNC2 | OPT_EXPERT, {.func2_arg = opt_attach},
"add an attachment to the output file", "filename" },
- { "dump_attachment", HAS_ARG | OPT_STRING | OPT_SPEC, {.off = OFFSET(dump_attachment)},
+ { "dump_attachment", HAS_ARG | OPT_STRING | OPT_SPEC |OPT_EXPERT,{.off = OFFSET(dump_attachment)},
"extract an attachment into a file", "filename" },
{ "cpuflags", HAS_ARG | OPT_EXPERT, {.func_arg = opt_cpuflags},
"set CPU flags mask", "mask" },
@@ -1971,11 +1971,11 @@ const OptionDef options[] = {
"rate control override for specific intervals", "override" },
{ "vcodec", OPT_VIDEO | HAS_ARG | OPT_FUNC2, {.func2_arg = opt_video_codec},
"force video codec ('copy' to copy stream)", "codec" },
- { "same_quant", OPT_VIDEO | OPT_BOOL , {&same_quant},
+ { "same_quant", OPT_VIDEO | OPT_BOOL | OPT_EXPERT, {&same_quant},
"use same quantizer as source (implies VBR)" },
{ "pass", OPT_VIDEO | HAS_ARG , {opt_pass},
"select the pass number (1 or 2)", "n" },
- { "passlogfile", OPT_VIDEO | HAS_ARG | OPT_STRING , {&pass_logfilename_prefix},
+ { "passlogfile", OPT_VIDEO | HAS_ARG | OPT_STRING | OPT_EXPERT, {&pass_logfilename_prefix},
"select two pass log file name prefix", "prefix" },
{ "deinterlace", OPT_VIDEO | OPT_EXPERT , {.func_arg = opt_deinterlace},
"this option is deprecated, use the yadif filter instead" },
@@ -2045,11 +2045,11 @@ const OptionDef options[] = {
{ "muxpreload", OPT_FLOAT | HAS_ARG | OPT_EXPERT | OPT_OFFSET, {.off = OFFSET(mux_preload)},
"set the initial demux-decode delay", "seconds" },

- { "bsf", HAS_ARG | OPT_STRING | OPT_SPEC, {.off = OFFSET(bitstream_filters)},
+ { "bsf", HAS_ARG | OPT_STRING | OPT_SPEC | OPT_EXPERT, {.off = OFFSET(bitstream_filters)},
"A comma-separated list of bitstream filters", "bitstream_filters" },

/* data codec support */
- { "dcodec", HAS_ARG | OPT_DATA | OPT_FUNC2, {.func2_arg = opt_data_codec},
+ { "dcodec", HAS_ARG | OPT_DATA | OPT_FUNC2 | OPT_EXPERT, {.func2_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},
--
1.7.10.4
Luca Barbato
2012-08-16 12:25:38 UTC
Permalink
Post by Anton Khirnov
---
avconv_opt.c | 24 ++++++++++++------------
1 file changed, 12 insertions(+), 12 deletions(-)
Ok.
Anton Khirnov
2012-08-15 08:37:23 UTC
Permalink
Don't require every caller to supply them.
---
avconv_opt.c | 14 +++++++-------
avplay.c | 4 ++--
avprobe.c | 2 +-
avserver.c | 2 +-
cmdutils.c | 3 ++-
5 files changed, 13 insertions(+), 12 deletions(-)

diff --git a/avconv_opt.c b/avconv_opt.c
index dd221fa..f1942cf 100644
--- a/avconv_opt.c
+++ b/avconv_opt.c
@@ -1794,24 +1794,24 @@ static int show_help(const char *opt, const char *arg)
int flags = AV_OPT_FLAG_DECODING_PARAM | AV_OPT_FLAG_ENCODING_PARAM;
av_log_set_callback(log_callback_help);
show_usage();
- show_help_options(options, "Main options:\n",
+ show_help_options(options, "Main options:",
OPT_EXPERT | OPT_AUDIO | OPT_VIDEO | OPT_SUBTITLE, 0);
- show_help_options(options, "\nAdvanced options:\n",
+ show_help_options(options, "Advanced options:",
OPT_EXPERT | OPT_AUDIO | OPT_VIDEO | OPT_SUBTITLE,
OPT_EXPERT);
- show_help_options(options, "\nVideo options:\n",
+ show_help_options(options, "Video options:",
OPT_EXPERT | OPT_AUDIO | OPT_VIDEO,
OPT_VIDEO);
- show_help_options(options, "\nAdvanced Video options:\n",
+ show_help_options(options, "Advanced Video options:",
OPT_EXPERT | OPT_AUDIO | OPT_VIDEO,
OPT_VIDEO | OPT_EXPERT);
- show_help_options(options, "\nAudio options:\n",
+ show_help_options(options, "Audio options:",
OPT_EXPERT | OPT_AUDIO | OPT_VIDEO,
OPT_AUDIO);
- show_help_options(options, "\nAdvanced Audio options:\n",
+ show_help_options(options, "Advanced Audio options:",
OPT_EXPERT | OPT_AUDIO | OPT_VIDEO,
OPT_AUDIO | OPT_EXPERT);
- show_help_options(options, "\nSubtitle options:\n",
+ show_help_options(options, "Subtitle options:",
OPT_SUBTITLE, OPT_SUBTITLE);
printf("\n");
show_help_children(avcodec_get_class(), flags);
diff --git a/avplay.c b/avplay.c
index 593b38a..bb10810 100644
--- a/avplay.c
+++ b/avplay.c
@@ -2926,9 +2926,9 @@ static int show_help(const char *opt, const char *arg)
{
av_log_set_callback(log_callback_help);
show_usage();
- show_help_options(options, "Main options:\n",
+ show_help_options(options, "Main options:",
OPT_EXPERT, 0);
- show_help_options(options, "\nAdvanced options:\n",
+ show_help_options(options, "Advanced options:",
OPT_EXPERT, OPT_EXPERT);
printf("\n");
show_help_children(avcodec_get_class(), AV_OPT_FLAG_DECODING_PARAM);
diff --git a/avprobe.c b/avprobe.c
index e14b5f6..70a9910 100644
--- a/avprobe.c
+++ b/avprobe.c
@@ -871,7 +871,7 @@ static int show_help(const char *opt, const char *arg)
{
av_log_set_callback(log_callback_help);
show_usage();
- show_help_options(options, "Main options:\n", 0, 0);
+ show_help_options(options, "Main options:", 0, 0);
printf("\n");
show_help_children(avformat_get_class(), AV_OPT_FLAG_DECODING_PARAM);
return 0;
diff --git a/avserver.c b/avserver.c
index fabdd32..de050a6 100644
--- a/avserver.c
+++ b/avserver.c
@@ -4634,7 +4634,7 @@ static void show_help(void)
printf("usage: avserver [options]\n"
"Hyper fast multi format Audio/Video streaming server\n");
printf("\n");
- show_help_options(options, "Main options:\n", 0, 0);
+ show_help_options(options, "Main options:", 0, 0);
}

static const OptionDef options[] = {
diff --git a/cmdutils.c b/cmdutils.c
index 3b8ab3f..5107744 100644
--- a/cmdutils.c
+++ b/cmdutils.c
@@ -124,7 +124,7 @@ void show_help_options(const OptionDef *options, const char *msg, int mask,
char buf[64];
if ((po->flags & mask) == value) {
if (first) {
- printf("%s", msg);
+ printf("%s\n", msg);
first = 0;
}
av_strlcpy(buf, po->name, sizeof(buf));
@@ -135,6 +135,7 @@ void show_help_options(const OptionDef *options, const char *msg, int mask,
printf("-%-17s %s\n", buf, po->help);
}
}
+ printf("\n");
}

void show_help_children(const AVClass *class, int flags)
--
1.7.10.4
Luca Barbato
2012-08-16 11:43:55 UTC
Permalink
Post by Anton Khirnov
Don't require every caller to supply them.
---
avconv_opt.c | 14 +++++++-------
avplay.c | 4 ++--
avprobe.c | 2 +-
avserver.c | 2 +-
cmdutils.c | 3 ++-
5 files changed, 13 insertions(+), 12 deletions(-)
Ok.
Luca Barbato
2012-08-15 21:48:21 UTC
Permalink
Post by Anton Khirnov
---
libavcodec/avcodec.h | 2 ++
libavcodec/codec_desc.c | 13 +++++++++++++
2 files changed, 15 insertions(+)
Ok.
Loading...