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
40194019 reset_options(&o);
40204020
40214021 av_log_set_flags(AV_LOG_SKIP_REPEATED);
4022+ parse_loglevel(argc, argv, options);
40224023
40234024 avcodec_register_all();
40244025 #if CONFIG_AVDEVICE
avplay.c+1−0
@@ -3050,6 +3050,7 @@ int main(int argc, char **argv) · 3049 unmodified lines
30503050 int flags;
30513051
30523052 av_log_set_flags(AV_LOG_SKIP_REPEATED);
3053+ parse_loglevel(argc, argv, options);
30533054
30543055 /* register all codecs, demux and protocols */
30553056 avcodec_register_all();
avprobe.c+1−0
@@ -399,6 +399,7 @@ int main(int argc, char **argv) · 398 unmodified lines
399399 {
400400 int ret;
401401
402+ parse_loglevel(argc, argv, options);
402403 av_register_all();
403404 init_opts();
404405 #if CONFIG_AVDEVICE
avserver.c+1−0
@@ -4668,6 +4668,7 @@ int main(int argc, char **argv) · 4667 unmodified lines
46684668 {
46694669 struct sigaction sigact;
46704670
4671+ parse_loglevel(argc, argv, options);
46714672 av_register_all();
46724673
46734674 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
304304 }
305305 }
306306
307+/*
308+ * Return index of option opt in argv or 0 if not found.
309+ */
310+static 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+
335+void 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+
307342 #define FLAGS (o->type == FF_OPT_TYPE_FLAGS) ? AV_DICT_APPEND : 0
308343 int opt_default(const char *opt, const char *arg)
309344 {
cmdutils.h+5−0
@@ -174,6 +174,11 @@ void parse_options(void *optctx, int argc, char **argv, const OptionDef *options · 173 unmodified lines
174174 */
175175 int parse_option(void *optctx, const char *opt, const char *arg, const OptionDef *options);
176176
177+/**
178+ * Find the '-loglevel' option in the commandline args and apply it.
179+ */
180+void parse_loglevel(int argc, char **argv, const OptionDef *options);
181+
177182 /**
178183 * Check if the given stream matches a stream specifier.
179184 *
ffmpeg.c+1−0
@@ -4357,6 +4357,7 @@ int main(int argc, char **argv) · 4356 unmodified lines
43574357 int64_t ti;
43584358
43594359 av_log_set_flags(AV_LOG_SKIP_REPEATED);
4360+ parse_loglevel(argc, argv, options);
43604361
43614362 avcodec_register_all();
43624363 #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