X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=fftools%2Fcmdutils.c;h=88fdbeaf1e48fa15dc899403336bb866f6ca222a;hb=58b6594b01e37ebf3daa2cb66183287a1f1b0a78;hp=9cfbc45c2bfbaa85a0f7f118fa199494c7fccbca;hpb=4f9a8d3fe2f9485ee08848d336ee96f15ec0e7e6;p=ffmpeg diff --git a/fftools/cmdutils.c b/fftools/cmdutils.c index 9cfbc45c2bf..88fdbeaf1e4 100644 --- a/fftools/cmdutils.c +++ b/fftools/cmdutils.c @@ -55,9 +55,6 @@ #include "libavutil/ffversion.h" #include "libavutil/version.h" #include "cmdutils.h" -#if CONFIG_NETWORK -#include "libavformat/network.h" -#endif #if HAVE_SYS_RESOURCE_H #include #include @@ -119,7 +116,7 @@ static void log_callback_report(void *ptr, int level, const char *fmt, va_list v void init_dynload(void) { -#ifdef _WIN32 +#if HAVE_SETDLLDIRECTORY && defined(_WIN32) /* Calling SetDllDirectory with the empty string (but not NULL) removes the * current working directory from the DLL search path as a security pre-caution. */ SetDllDirectory(""); @@ -182,7 +179,7 @@ void show_help_options(const OptionDef *options, const char *msg, int req_flags, first = 1; for (po = options; po->name; po++) { - char buf[64]; + char buf[128]; if (((po->flags & req_flags) != req_flags) || (alt_flags && !(po->flags & alt_flags)) || @@ -205,13 +202,14 @@ void show_help_options(const OptionDef *options, const char *msg, int req_flags, void show_help_children(const AVClass *class, int flags) { - const AVClass *child = NULL; + void *iter = NULL; + const AVClass *child; if (class->option) { av_opt_show2(&class, NULL, flags, 0); printf("\n"); } - while (child = av_opt_child_class_next(class, child)) + while (child = av_opt_child_class_iterate(class, &iter)) show_help_children(child, flags); } @@ -848,8 +846,8 @@ do { \ } if (octx->cur_group.nb_opts || codec_opts || format_opts || resample_opts) - av_log(NULL, AV_LOG_WARNING, "Trailing options were found on the " - "commandline.\n"); + av_log(NULL, AV_LOG_WARNING, "Trailing option(s) found in the " + "command: may be ignored.\n"); av_log(NULL, AV_LOG_DEBUG, "Finished splitting the commandline.\n"); @@ -980,6 +978,7 @@ static int init_report(const char *env) char *filename_template = NULL; char *key, *val; int ret, count = 0; + int prog_loglevel, envlevel = 0; time_t now; struct tm *tm; AVBPrint filename; @@ -1011,6 +1010,7 @@ static int init_report(const char *env) av_log(NULL, AV_LOG_FATAL, "Invalid report file level\n"); exit_program(1); } + envlevel = 1; } else { av_log(NULL, AV_LOG_ERROR, "Unknown key '%s' in FFREPORT\n", key); } @@ -1027,6 +1027,10 @@ static int init_report(const char *env) return AVERROR(ENOMEM); } + prog_loglevel = av_log_get_level(); + if (!envlevel) + report_file_level = FFMAX(report_file_level, prog_loglevel); + report_file = fopen(filename.str, "w"); if (!report_file) { int ret = AVERROR(errno); @@ -1037,16 +1041,17 @@ static int init_report(const char *env) av_log_set_callback(log_callback_report); av_log(NULL, AV_LOG_INFO, "%s started on %04d-%02d-%02d at %02d:%02d:%02d\n" - "Report written to \"%s\"\n", + "Report written to \"%s\"\n" + "Log level: %d\n", program_name, tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec, - filename.str); + filename.str, report_file_level); av_bprint_finalize(&filename, NULL); return 0; } -int opt_report(const char *opt) +int opt_report(void *optctx, const char *opt, const char *arg) { return init_report(NULL); } @@ -1416,10 +1421,6 @@ static void print_codec(const AVCodec *c) printf("threads "); if (c->capabilities & AV_CODEC_CAP_AVOID_PROBING) printf("avoidprobe "); - if (c->capabilities & AV_CODEC_CAP_INTRA_ONLY) - printf("intraonly "); - if (c->capabilities & AV_CODEC_CAP_LOSSLESS) - printf("lossless "); if (c->capabilities & AV_CODEC_CAP_HARDWARE) printf("hardware "); if (c->capabilities & AV_CODEC_CAP_HYBRID) @@ -1493,13 +1494,14 @@ static char get_media_type_char(enum AVMediaType type) } } -static const AVCodec *next_codec_for_id(enum AVCodecID id, const AVCodec *prev, +static const AVCodec *next_codec_for_id(enum AVCodecID id, void **iter, 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; + 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; } return NULL; } @@ -1536,11 +1538,12 @@ static unsigned get_codecs_sorted(const AVCodecDescriptor ***rcodecs) static void print_codecs_for_id(enum AVCodecID id, int encoder) { - const AVCodec *codec = NULL; + void *iter = NULL; + const AVCodec *codec; printf(" (%s: ", encoder ? "encoders" : "decoders"); - while ((codec = next_codec_for_id(id, codec, encoder))) + while ((codec = next_codec_for_id(id, &iter, encoder))) printf("%s ", codec->name); printf(")"); @@ -1563,7 +1566,8 @@ int show_codecs(void *optctx, const char *opt, const char *arg) " -------\n"); for (i = 0; i < nb_codecs; i++) { const AVCodecDescriptor *desc = codecs[i]; - const AVCodec *codec = NULL; + const AVCodec *codec; + void *iter = NULL; if (strstr(desc->name, "_deprecated")) continue; @@ -1581,14 +1585,14 @@ int show_codecs(void *optctx, const char *opt, const char *arg) /* 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))) { + while ((codec = next_codec_for_id(desc->id, &iter, 0))) { if (strcmp(codec->name, desc->name)) { print_codecs_for_id(desc->id, 0); break; } } - codec = NULL; - while ((codec = next_codec_for_id(desc->id, codec, 1))) { + iter = NULL; + while ((codec = next_codec_for_id(desc->id, &iter, 1))) { if (strcmp(codec->name, desc->name)) { print_codecs_for_id(desc->id, 1); break; @@ -1619,9 +1623,10 @@ static void print_codecs(int encoder) encoder ? "Encoders" : "Decoders"); for (i = 0; i < nb_codecs; i++) { const AVCodecDescriptor *desc = codecs[i]; - const AVCodec *codec = NULL; + const AVCodec *codec; + void *iter = NULL; - while ((codec = next_codec_for_id(desc->id, codec, encoder))) { + while ((codec = next_codec_for_id(desc->id, &iter, encoder))) { printf(" %c", get_media_type_char(desc->type)); printf((codec->capabilities & AV_CODEC_CAP_FRAME_THREADS) ? "F" : "."); printf((codec->capabilities & AV_CODEC_CAP_SLICE_THREADS) ? "S" : "."); @@ -1826,9 +1831,10 @@ static void show_help_codec(const char *name, int encoder) if (codec) print_codec(codec); else if ((desc = avcodec_descriptor_get_by_name(name))) { + void *iter = NULL; int printed = 0; - while ((codec = next_codec_for_id(desc->id, codec, encoder))) { + while ((codec = next_codec_for_id(desc->id, &iter, encoder))) { printed = 1; print_codec(codec); } @@ -1863,6 +1869,24 @@ static void show_help_demuxer(const char *name) show_help_children(fmt->priv_class, AV_OPT_FLAG_DECODING_PARAM); } +static void show_help_protocol(const char *name) +{ + const AVClass *proto_class; + + if (!name) { + av_log(NULL, AV_LOG_ERROR, "No protocol name specified.\n"); + return; + } + + proto_class = avio_protocol_get_class(name); + if (!proto_class) { + av_log(NULL, AV_LOG_ERROR, "Unknown protocol '%s'.\n", name); + return; + } + + show_help_children(proto_class, AV_OPT_FLAG_DECODING_PARAM | AV_OPT_FLAG_ENCODING_PARAM); +} + static void show_help_muxer(const char *name) { const AVCodecDescriptor *desc; @@ -1993,6 +2017,8 @@ int show_help(void *optctx, const char *opt, const char *arg) 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); @@ -2032,7 +2058,7 @@ FILE *get_preset_file(char *filename, size_t filename_size, av_strlcpy(filename, preset_name, filename_size); f = fopen(filename, "r"); } else { -#ifdef _WIN32 +#if HAVE_GETMODULEHANDLE && defined(_WIN32) char datadir[MAX_PATH], *ls; base[2] = NULL; @@ -2185,7 +2211,7 @@ double get_rotation(AVStream *st) if (fabs(theta - 90*round(theta/90)) > 2) av_log(NULL, AV_LOG_WARNING, "Odd rotation angle.\n" "If you want to help, upload a sample " - "of this file to ftp://upload.ffmpeg.org/incoming/ " + "of this file to https://streams.videolan.org/upload/ " "and contact the ffmpeg-devel mailing list. (ffmpeg-devel@ffmpeg.org)"); return theta;