From 3b3ea34655db02d9cd9ea1a4122e920a7fdec602 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Mon, 3 Oct 2011 21:10:06 +0200 Subject: Remove all uses of deprecated AVOptions API. --- avconv.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'avconv.c') diff --git a/avconv.c b/avconv.c index 03c419dcb2..d82e1df4da 100644 --- a/avconv.c +++ b/avconv.c @@ -224,7 +224,7 @@ typedef struct OutputStream { AVFilterGraph *graph; #endif - int sws_flags; + int64_t sws_flags; AVDictionary *opts; int is_past_recording_time; } OutputStream; @@ -421,7 +421,7 @@ static int configure_video_filters(InputStream *ist, OutputStream *ost) snprintf(args, 255, "%d:%d:flags=0x%X", codec->width, codec->height, - ost->sws_flags); + (unsigned)ost->sws_flags); if ((ret = avfilter_graph_create_filter(&filter, avfilter_get_by_name("scale"), NULL, args, NULL, ost->graph)) < 0) return ret; @@ -430,7 +430,7 @@ static int configure_video_filters(InputStream *ist, OutputStream *ost) last_filter = filter; } - snprintf(args, sizeof(args), "flags=0x%X", ost->sws_flags); + snprintf(args, sizeof(args), "flags=0x%X", (unsigned)ost->sws_flags); ost->graph->scale_sws_opts = av_strdup(args); if (ost->avfilter) { @@ -3033,7 +3033,7 @@ static OutputStream *new_output_stream(OptionsContext *o, AVFormatContext *oc, e if (oc->oformat->flags & AVFMT_GLOBALHEADER) st->codec->flags |= CODEC_FLAG_GLOBAL_HEADER; - ost->sws_flags = av_get_int(sws_opts, "sws_flags", NULL); + av_opt_get_int(sws_opts, "sws_flags", 0, &ost->sws_flags); return ost; } -- cgit v1.2.3 From 7a6cd9957de27cbc8a69510f3d11dffea31f7ad8 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Tue, 4 Oct 2011 14:50:00 +0200 Subject: cmdutils/avtools: simplify show_help() by using av_opt_child_class_next() --- avconv.c | 44 ++++---------------------------------------- avplay.c | 15 +++------------ avprobe.c | 4 +--- cmdutils.c | 10 ++++++++++ cmdutils.h | 6 ++++++ 5 files changed, 24 insertions(+), 55 deletions(-) (limited to 'avconv.c') diff --git a/avconv.c b/avconv.c index d82e1df4da..44bc59f0cb 100644 --- a/avconv.c +++ b/avconv.c @@ -3676,11 +3676,7 @@ static void show_usage(void) static void show_help(void) { - AVCodec *c; - AVOutputFormat *oformat = NULL; - AVInputFormat *iformat = NULL; - const AVClass *class; - + 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", @@ -3707,41 +3703,9 @@ static void show_help(void) OPT_GRAB, OPT_GRAB); printf("\n"); - class = avcodec_get_class(); - av_opt_show2(&class, NULL, AV_OPT_FLAG_ENCODING_PARAM|AV_OPT_FLAG_DECODING_PARAM, 0); - printf("\n"); - - /* individual codec options */ - c = NULL; - while ((c = av_codec_next(c))) { - if (c->priv_class) { - av_opt_show2(&c->priv_class, NULL, AV_OPT_FLAG_ENCODING_PARAM|AV_OPT_FLAG_DECODING_PARAM, 0); - printf("\n"); - } - } - - class = avformat_get_class(); - av_opt_show2(&class, NULL, AV_OPT_FLAG_ENCODING_PARAM|AV_OPT_FLAG_DECODING_PARAM, 0); - printf("\n"); - - /* individual muxer options */ - while ((oformat = av_oformat_next(oformat))) { - if (oformat->priv_class) { - av_opt_show2(&oformat->priv_class, NULL, AV_OPT_FLAG_ENCODING_PARAM, 0); - printf("\n"); - } - } - - /* individual demuxer options */ - while ((iformat = av_iformat_next(iformat))) { - if (iformat->priv_class) { - av_opt_show2(&iformat->priv_class, NULL, AV_OPT_FLAG_DECODING_PARAM, 0); - printf("\n"); - } - } - - class = sws_get_class(); - av_opt_show2(&class, NULL, AV_OPT_FLAG_ENCODING_PARAM|AV_OPT_FLAG_DECODING_PARAM, 0); + show_help_children(avcodec_get_class(), flags); + show_help_children(avformat_get_class(), flags); + show_help_children(sws_get_class(), flags); } static int opt_target(OptionsContext *o, const char *opt, const char *arg) diff --git a/avplay.c b/avplay.c index 2eea5d72fd..8da50eb7bd 100644 --- a/avplay.c +++ b/avplay.c @@ -2996,7 +2996,6 @@ static void show_usage(void) static void show_help(void) { - const AVClass *class; av_log_set_callback(log_callback_help); show_usage(); show_help_options(options, "Main options:\n", @@ -3004,18 +3003,10 @@ static void show_help(void) show_help_options(options, "\nAdvanced options:\n", OPT_EXPERT, OPT_EXPERT); printf("\n"); - class = avcodec_get_class(); - av_opt_show2(&class, NULL, - AV_OPT_FLAG_DECODING_PARAM, 0); - printf("\n"); - class = avformat_get_class(); - av_opt_show2(&class, NULL, - AV_OPT_FLAG_DECODING_PARAM, 0); + show_help_children(avcodec_get_class(), AV_OPT_FLAG_DECODING_PARAM); + show_help_children(avformat_get_class(), AV_OPT_FLAG_DECODING_PARAM); #if !CONFIG_AVFILTER - printf("\n"); - class = sws_get_class(); - av_opt_show2(&class, NULL, - AV_OPT_FLAG_ENCODING_PARAM, 0); + show_help_children(sws_get_class(), AV_OPT_FLAG_ENCODING_PARAM); #endif printf("\nWhile playing:\n" "q, ESC quit\n" diff --git a/avprobe.c b/avprobe.c index ae22dac648..99ec1aa08e 100644 --- a/avprobe.c +++ b/avprobe.c @@ -360,13 +360,11 @@ static void opt_input_file(void *optctx, const char *arg) static void show_help(void) { - const AVClass *class = avformat_get_class(); av_log_set_callback(log_callback_help); show_usage(); show_help_options(options, "Main options:\n", 0, 0); printf("\n"); - av_opt_show2(&class, NULL, - AV_OPT_FLAG_DECODING_PARAM, 0); + show_help_children(avformat_get_class(), AV_OPT_FLAG_DECODING_PARAM); } static void opt_pretty(void) diff --git a/cmdutils.c b/cmdutils.c index afe47cb864..ade3f10ce2 100644 --- a/cmdutils.c +++ b/cmdutils.c @@ -130,6 +130,16 @@ void show_help_options(const OptionDef *options, const char *msg, int mask, int } } +void show_help_children(const AVClass *class, int flags) +{ + const AVClass *child = NULL; + av_opt_show2(&class, NULL, flags, 0); + printf("\n"); + + while (child = av_opt_child_class_next(class, child)) + show_help_children(child, flags); +} + static const OptionDef* find_option(const OptionDef *po, const char *name){ const char *p = strchr(name, ':'); int len = p ? p - name : strlen(name); diff --git a/cmdutils.h b/cmdutils.h index 1c17433bc5..80b20b8e06 100644 --- a/cmdutils.h +++ b/cmdutils.h @@ -154,6 +154,12 @@ typedef struct { void show_help_options(const OptionDef *options, const char *msg, int mask, int value); +/** + * Show help for all options with given flags in class and all its + * children. + */ +void show_help_children(const AVClass *class, int flags); + /** * Parse the command line arguments. * -- cgit v1.2.3