From: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> To: ffmpeg-devel@ffmpeg.org Subject: Re: [FFmpeg-devel] [PATCH 04/10] fftools/cmdutils: split common option handlers into their own file Date: Thu, 17 Mar 2022 16:30:04 +0100 Message-ID: <AS1PR01MB95646DAF0BAE7EE297B41BC98F129@AS1PR01MB9564.eurprd01.prod.exchangelabs.com> (raw) In-Reply-To: <20220315090532.27295-4-anton@khirnov.net> Anton Khirnov: > --- > fftools/Makefile | 2 +- > fftools/cmdutils.c | 1399 +-------------- > fftools/cmdutils.h | 202 --- > fftools/ffmpeg_opt.c | 1 + > fftools/ffplay.c | 1 + > fftools/ffprobe.c | 1 + > fftools/{cmdutils.c => opt_common.c} | 2450 ++++++++------------------ > fftools/opt_common.h | 231 +++ > 8 files changed, 985 insertions(+), 3302 deletions(-) > copy fftools/{cmdutils.c => opt_common.c} (60%) > create mode 100644 fftools/opt_common.h Very weird stats. When I apply this, I get: fftools/Makefile | 2 +- fftools/cmdutils.c | 1399 +------------------------------------------------ fftools/cmdutils.h | 202 ------- fftools/ffmpeg_opt.c | 1 + fftools/ffplay.c | 1 + fftools/ffprobe.c | 1 + fftools/opt_common.c | 1445 +++++++++++++++++++++++++++++++++++++++++++++++++++ fftools/opt_common.h | 231 ++++++++ 8 files changed, 1685 insertions(+), 1597 deletions(-) > +#if CONFIG_AVFILTER > +static void show_help_filter(const char *name) > +{ > +#if CONFIG_AVFILTER > + const AVFilter *f = avfilter_get_by_name(name); > + int i, count; > + > + if (!name) { > + av_log(NULL, AV_LOG_ERROR, "No filter name specified.\n"); > + return; > + } else if (!f) { > + av_log(NULL, AV_LOG_ERROR, "Unknown filter '%s'.\n", name); > + return; > + } > + > + printf("Filter %s\n", f->name); > + if (f->description) > + printf(" %s\n", f->description); > > - printf(" Supported framerates:"); > - while (fps->num) { > - printf(" %d/%d", fps->num, fps->den); > - fps++; > - } > - printf("\n"); > + if (f->flags & AVFILTER_FLAG_SLICE_THREADS) > + printf(" slice threading supported\n"); > + > + printf(" Inputs:\n"); > + count = avfilter_filter_pad_count(f, 0); > + for (i = 0; i < count; i++) { You can use a local loop variable here and in several other places here. > + printf(" #%d: %s (%s)\n", i, avfilter_pad_get_name(f->inputs, i), > + av_get_media_type_string(avfilter_pad_get_type(f->inputs, i))); > } > - PRINT_CODEC_SUPPORTED(c, pix_fmts, enum AVPixelFormat, "pixel formats", > - AV_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 (f->flags & AVFILTER_FLAG_DYNAMIC_INPUTS) > + printf(" dynamic (depending on the options)\n"); > + else if (!count) > + printf(" none (source filter)\n"); > > - if (c->priv_class) { > - show_help_children(c->priv_class, > - AV_OPT_FLAG_ENCODING_PARAM | > - AV_OPT_FLAG_DECODING_PARAM); > + printf(" Outputs:\n"); > + count = avfilter_filter_pad_count(f, 1); > + for (i = 0; i < count; i++) { > + printf(" #%d: %s (%s)\n", i, avfilter_pad_get_name(f->outputs, i), > + av_get_media_type_string(avfilter_pad_get_type(f->outputs, i))); > } > + if (f->flags & AVFILTER_FLAG_DYNAMIC_OUTPUTS) > + printf(" dynamic (depending on the options)\n"); > + else if (!count) > + printf(" none (sink filter)\n"); > + > + if (f->priv_class) > + show_help_children(f->priv_class, AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_FILTERING_PARAM | > + AV_OPT_FLAG_AUDIO_PARAM); > + if (f->flags & AVFILTER_FLAG_SUPPORT_TIMELINE) > + printf("This filter has support for timeline through the 'enable' option.\n"); > +#else > + av_log(NULL, AV_LOG_ERROR, "Build without libavfilter; " > + "can not to satisfy request\n"); > +#endif > } > +#endif > > -static char get_media_type_char(enum AVMediaType type) > +static void show_help_bsf(const char *name) > { > - switch (type) { > - case AVMEDIA_TYPE_VIDEO: return 'V'; > - case AVMEDIA_TYPE_AUDIO: return 'A'; > - case AVMEDIA_TYPE_DATA: return 'D'; > - case AVMEDIA_TYPE_SUBTITLE: return 'S'; > - case AVMEDIA_TYPE_ATTACHMENT:return 'T'; > - default: return '?'; > + const AVBitStreamFilter *bsf = av_bsf_get_by_name(name); > + > + if (!name) { > + av_log(NULL, AV_LOG_ERROR, "No bitstream filter name specified.\n"); > + return; > + } else if (!bsf) { > + av_log(NULL, AV_LOG_ERROR, "Unknown bit stream filter '%s'.\n", name); > + return; > } > + > + printf("Bit stream filter %s\n", bsf->name); > + PRINT_CODEC_SUPPORTED(bsf, codec_ids, enum AVCodecID, "codecs", > + AV_CODEC_ID_NONE, GET_CODEC_NAME); > + if (bsf->priv_class) > + show_help_children(bsf->priv_class, AV_OPT_FLAG_BSF_PARAM); > } > > -static const AVCodec *next_codec_for_id(enum AVCodecID id, void **iter, > - int encoder) > +int show_help(void *optctx, const char *opt, const char *arg) > { > - const AVCodec *c; > - while ((c = av_codec_iterate(iter))) { > - if (c->id == id && > - (encoder ? av_codec_is_encoder(c) : av_codec_is_decoder(c))) > - return c; > + char *topic, *par; > + av_log_set_callback(log_callback_help); > + > + topic = av_strdup(arg ? arg : ""); > + if (!topic) > + return AVERROR(ENOMEM); > + 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 if (!strcmp(topic, "demuxer")) { > + show_help_demuxer(par); > + } else if (!strcmp(topic, "muxer")) { > + show_help_muxer(par); > + } else if (!strcmp(topic, "protocol")) { > + show_help_protocol(par); > +#if CONFIG_AVFILTER > + } else if (!strcmp(topic, "filter")) { > + show_help_filter(par); > +#endif > + } else if (!strcmp(topic, "bsf")) { > + show_help_bsf(par); > + } else { > + show_help_default(topic, par); > } > - return NULL; > + > + av_freep(&topic); > + return 0; > +} > + > +static void print_codecs_for_id(enum AVCodecID id, int encoder) > +{ > + void *iter = NULL; > + const AVCodec *codec; > + > + printf(" (%s: ", encoder ? "encoders" : "decoders"); > + > + while ((codec = next_codec_for_id(id, &iter, encoder))) > + printf("%s ", codec->name); > + > + printf(")"); > } > > static int compare_codec_desc(const void *a, const void *b) > @@ -1534,17 +638,16 @@ static unsigned get_codecs_sorted(const AVCodecDescriptor ***rcodecs) > return nb_codecs; > } > > -static void print_codecs_for_id(enum AVCodecID id, int encoder) > +static char get_media_type_char(enum AVMediaType type) > { > - void *iter = NULL; > - const AVCodec *codec; > - > - printf(" (%s: ", encoder ? "encoders" : "decoders"); > - > - while ((codec = next_codec_for_id(id, &iter, encoder))) > - printf("%s ", codec->name); > - > - printf(")"); > + switch (type) { > + case AVMEDIA_TYPE_VIDEO: return 'V'; > + case AVMEDIA_TYPE_AUDIO: return 'A'; > + case AVMEDIA_TYPE_DATA: return 'D'; > + case AVMEDIA_TYPE_SUBTITLE: return 'S'; > + case AVMEDIA_TYPE_ATTACHMENT:return 'T'; > + default: return '?'; AVMEDIA_TYPE_ATTACHMENT has obviously been added later. You now have an opportunity to fix the formatting. You should use it. > + } > } > > int show_codecs(void *optctx, const char *opt, const char *arg) > @@ -1666,21 +769,6 @@ int show_bsfs(void *optctx, const char *opt, const char *arg) > return 0; > } > > +static int show_formats_devices(void *optctx, const char *opt, const char *arg, int device_only, int muxdemuxers) > +{ > + void *ifmt_opaque = NULL; > + const AVInputFormat *ifmt = NULL; > + void *ofmt_opaque = NULL; > + const AVOutputFormat *ofmt = NULL; > + const char *last_name; > + int is_dev; > + > + printf("%s\n" > + " D. = Demuxing supported\n" > + " .E = Muxing supported\n" > + " --\n", device_only ? "Devices:" : "File formats:"); > + last_name = "000"; > + for (;;) { > + int decode = 0; > + int encode = 0; > + const char *name = NULL; > + const char *long_name = NULL; > + > + if (muxdemuxers !=SHOW_DEMUXERS) { > + ofmt_opaque = NULL; Can use smaller scope; same below. > + while ((ofmt = av_muxer_iterate(&ofmt_opaque))) { > + is_dev = is_device(ofmt->priv_class); > + if (!is_dev && device_only) > + continue; > + if ((!name || strcmp(ofmt->name, name) < 0) && > + strcmp(ofmt->name, last_name) > 0) { > + name = ofmt->name; > + long_name = ofmt->long_name; > + encode = 1; > + } > + } > + } > + if (muxdemuxers != SHOW_MUXERS) { > + ifmt_opaque = NULL; > + while ((ifmt = av_demuxer_iterate(&ifmt_opaque))) { > + is_dev = is_device(ifmt->priv_class); > + if (!is_dev && device_only) > + continue; > + if ((!name || strcmp(ifmt->name, name) < 0) && > + strcmp(ifmt->name, last_name) > 0) { > + name = ifmt->name; > + long_name = ifmt->long_name; > + encode = 0; > + } > + if (name && strcmp(ifmt->name, name) == 0) > + decode = 1; > + } > + } > + if (!name) > + break; > + last_name = name; > + > + printf(" %c%c %-15s %s\n", > + decode ? 'D' : ' ', > + encode ? 'E' : ' ', > + name, > + long_name ? long_name:" "); > + } > + return 0; > +} > + _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
next prev parent reply other threads:[~2022-03-17 15:30 UTC|newest] Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-03-15 9:05 [FFmpeg-devel] [PATCH 01/10] fftools/cmdutils: drop prototypes for nonexistent functions Anton Khirnov 2022-03-15 9:05 ` [FFmpeg-devel] [PATCH 02/10] fftools/cmdutils: drop extern declarations for nonexistent variables Anton Khirnov 2022-03-17 14:21 ` Andreas Rheinhardt 2022-03-15 9:05 ` [FFmpeg-devel] [PATCH 03/10] fftools: drop useless indirection Anton Khirnov 2022-03-17 14:21 ` Andreas Rheinhardt 2022-03-15 9:05 ` [FFmpeg-devel] [PATCH 04/10] fftools/cmdutils: split common option handlers into their own file Anton Khirnov 2022-03-17 15:30 ` Andreas Rheinhardt [this message] 2022-03-20 10:07 ` Anton Khirnov 2022-03-15 9:05 ` [FFmpeg-devel] [PATCH 05/10] fftools: move opt_timelimit from cmdutils to ffmpeg Anton Khirnov 2022-03-17 15:34 ` Andreas Rheinhardt 2022-03-15 9:05 ` [FFmpeg-devel] [PATCH 06/10] fftools/ffmpeg: drop mistakenly added empty line Anton Khirnov 2022-03-17 15:35 ` Andreas Rheinhardt 2022-03-15 9:05 ` [FFmpeg-devel] [PATCH 07/10] fftools/ffplay: drop options deprecated since 2011 Anton Khirnov 2022-03-15 9:05 ` [FFmpeg-devel] [PATCH 08/10] fftools/ffprobe; drop -show_format_entry Anton Khirnov 2022-03-15 9:05 ` [FFmpeg-devel] [PATCH 09/10] fftools: drop the fake "default" option from ffplay/ffprobe Anton Khirnov 2022-03-15 9:05 ` [FFmpeg-devel] [PATCH 10/10] fftools/cmdutils: drop redundant code Anton Khirnov 2022-03-17 14:19 ` [FFmpeg-devel] [PATCH 01/10] fftools/cmdutils: drop prototypes for nonexistent functions Andreas Rheinhardt
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=AS1PR01MB95646DAF0BAE7EE297B41BC98F129@AS1PR01MB9564.eurprd01.prod.exchangelabs.com \ --to=andreas.rheinhardt@outlook.com \ --cc=ffmpeg-devel@ffmpeg.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel This inbox may be cloned and mirrored by anyone: git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \ ffmpegdev@gitmailbox.com public-inbox-index ffmpegdev Example config snippet for mirrors. AGPL code for this site: git clone https://public-inbox.org/public-inbox.git