History

avtools: parse loglevel before all the other options.

This way it can be applied to cmdutils too -- e.g. showing the banner and printing startup messages.

Anton Khirnov committed 15 years ago

Commit 182cbe41 parent 4ca59d17 files · +45 −0Browse files

Unified · Split

7 files
  1. avconv.c +1 −0
  2. avplay.c +1 −0
  3. avprobe.c +1 −0
  4. avserver.c +1 −0
  5. cmdutils.c +35 −0
  6. cmdutils.h +5 −0
  7. ffmpeg.c +1 −0
avconv.c+1−0
@@ -4019,6 +4019,7 @@ int main(int argc, char **argv) · 4018 unmodified lines
4019 reset_options(&o);4019 reset_options(&o);
4020 4020
4021 av_log_set_flags(AV_LOG_SKIP_REPEATED);4021 av_log_set_flags(AV_LOG_SKIP_REPEATED);
4022 parse_loglevel(argc, argv, options);
4022 4023
4023 avcodec_register_all();4024 avcodec_register_all();
4024#if CONFIG_AVDEVICE4025#if CONFIG_AVDEVICE
avplay.c+1−0
@@ -3050,6 +3050,7 @@ int main(int argc, char **argv) · 3049 unmodified lines
3050 int flags;3050 int flags;
3051 3051
3052 av_log_set_flags(AV_LOG_SKIP_REPEATED);3052 av_log_set_flags(AV_LOG_SKIP_REPEATED);
3053 parse_loglevel(argc, argv, options);
3053 3054
3054 /* register all codecs, demux and protocols */3055 /* register all codecs, demux and protocols */
3055 avcodec_register_all();3056 avcodec_register_all();
avprobe.c+1−0
@@ -399,6 +399,7 @@ int main(int argc, char **argv) · 398 unmodified lines
399{399{
400 int ret;400 int ret;
401 401
402 parse_loglevel(argc, argv, options);
402 av_register_all();403 av_register_all();
403 init_opts();404 init_opts();
404#if CONFIG_AVDEVICE405#if CONFIG_AVDEVICE
avserver.c+1−0
@@ -4668,6 +4668,7 @@ int main(int argc, char **argv) · 4667 unmodified lines
4668{4668{
4669 struct sigaction sigact;4669 struct sigaction sigact;
4670 4670
4671 parse_loglevel(argc, argv, options);
4671 av_register_all();4672 av_register_all();
4672 4673
4673 show_banner();4674 show_banner();
cmdutils.c+35−0
@@ -304,6 +304,41 @@ void parse_options(void *optctx, int argc, char **argv, const OptionDef *options · 303 unmodified lines
304 }304 }
305}305}
306 306
307/*
308 * Return index of option opt in argv or 0 if not found.
309 */
310static int locate_option(int argc, char **argv, const OptionDef *options, const char *optname)
311{
312 const OptionDef *po;
313 int i;
314
315 for (i = 1; i < argc; i++) {
316 const char *cur_opt = argv[i];
317
318 if (*cur_opt++ != '-')
319 continue;
320
321 po = find_option(options, cur_opt);
322 if (!po->name && cur_opt[0] == 'n' && cur_opt[1] == 'o')
323 po = find_option(options, cur_opt + 2);
324
325 if ((!po->name && !strcmp(cur_opt, optname)) ||
326 (po->name && !strcmp(optname, po->name)))
327 return i;
328
329 if (!po || po->flags & HAS_ARG)
330 i++;
331 }
332 return 0;
333}
334
335void parse_loglevel(int argc, char **argv, const OptionDef *options)
336{
337 int idx = locate_option(argc, argv, options, "loglevel");
338 if (idx && argv[idx + 1])
339 opt_loglevel("loglevel", argv[idx + 1]);
340}
341
307#define FLAGS (o->type == FF_OPT_TYPE_FLAGS) ? AV_DICT_APPEND : 0342#define FLAGS (o->type == FF_OPT_TYPE_FLAGS) ? AV_DICT_APPEND : 0
308int opt_default(const char *opt, const char *arg)343int opt_default(const char *opt, const char *arg)
309{344{
cmdutils.h+5−0
@@ -174,6 +174,11 @@ void parse_options(void *optctx, int argc, char **argv, const OptionDef *options · 173 unmodified lines
174 */174 */
175int parse_option(void *optctx, const char *opt, const char *arg, const OptionDef *options);175int parse_option(void *optctx, const char *opt, const char *arg, const OptionDef *options);
176 176
177/**
178 * Find the '-loglevel' option in the commandline args and apply it.
179 */
180void parse_loglevel(int argc, char **argv, const OptionDef *options);
181
177/**182/**
178 * Check if the given stream matches a stream specifier.183 * Check if the given stream matches a stream specifier.
179 *184 *
ffmpeg.c+1−0
@@ -4357,6 +4357,7 @@ int main(int argc, char **argv) · 4356 unmodified lines
4357 int64_t ti;4357 int64_t ti;
4358 4358
4359 av_log_set_flags(AV_LOG_SKIP_REPEATED);4359 av_log_set_flags(AV_LOG_SKIP_REPEATED);
4360 parse_loglevel(argc, argv, options);
4360 4361
4361 avcodec_register_all();4362 avcodec_register_all();
4362#if CONFIG_AVDEVICE4363#if CONFIG_AVDEVICE

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t