Browse code

avconv: split printing "main options" into global and per-file.

Anton Khirnov authored on 2012/08/15 17:31:46
Showing 6 changed files
... ...
@@ -1791,6 +1791,8 @@ static int opt_filter_complex(const char *opt, const char *arg)
1791 1791
 
1792 1792
 void show_help_default(const char *opt, const char *arg)
1793 1793
 {
1794
+    /* per-file options have at least one of those set */
1795
+    const int per_file = OPT_SPEC | OPT_OFFSET | OPT_FUNC2;
1794 1796
     int show_advanced = 0, show_avoptions = 0;
1795 1797
 
1796 1798
     if (opt) {
... ...
@@ -1812,27 +1814,35 @@ void show_help_default(const char *opt, const char *arg)
1812 1812
            "\n", program_name);
1813 1813
 
1814 1814
     show_help_options(options, "Print help / information / capabilities:",
1815
-                      OPT_EXIT, 0);
1816
-    show_help_options(options, "Main options:",
1817
-                      0, OPT_EXPERT | OPT_AUDIO | OPT_VIDEO | OPT_SUBTITLE |
1818
-                      OPT_EXIT);
1815
+                      OPT_EXIT, 0, 0);
1816
+
1817
+    show_help_options(options, "Global options (affect whole program "
1818
+                      "instead of just one file:",
1819
+                      0, per_file | OPT_EXIT | OPT_EXPERT, 0);
1820
+    if (show_advanced)
1821
+        show_help_options(options, "Advanced global options:", OPT_EXPERT,
1822
+                          per_file | OPT_EXIT, 0);
1823
+
1824
+    show_help_options(options, "Per-file main options:", 0,
1825
+                      OPT_EXPERT | OPT_AUDIO | OPT_VIDEO | OPT_SUBTITLE |
1826
+                      OPT_EXIT, per_file);
1819 1827
     if (show_advanced)
1820
-        show_help_options(options, "Advanced options:",
1821
-                          OPT_EXPERT, OPT_AUDIO | OPT_VIDEO | OPT_SUBTITLE);
1828
+        show_help_options(options, "Advanced per-file options:",
1829
+                          OPT_EXPERT, OPT_AUDIO | OPT_VIDEO | OPT_SUBTITLE, per_file);
1822 1830
 
1823 1831
     show_help_options(options, "Video options:",
1824
-                      OPT_VIDEO, OPT_EXPERT | OPT_AUDIO);
1832
+                      OPT_VIDEO, OPT_EXPERT | OPT_AUDIO, 0);
1825 1833
     if (show_advanced)
1826 1834
         show_help_options(options, "Advanced Video options:",
1827
-                          OPT_EXPERT | OPT_VIDEO, OPT_AUDIO);
1835
+                          OPT_EXPERT | OPT_VIDEO, OPT_AUDIO, 0);
1828 1836
 
1829 1837
     show_help_options(options, "Audio options:",
1830
-                      OPT_AUDIO, OPT_EXPERT | OPT_VIDEO);
1838
+                      OPT_AUDIO, OPT_EXPERT | OPT_VIDEO, 0);
1831 1839
     if (show_advanced)
1832 1840
         show_help_options(options, "Advanced Audio options:",
1833
-                          OPT_EXPERT | OPT_AUDIO, OPT_VIDEO);
1841
+                          OPT_EXPERT | OPT_AUDIO, OPT_VIDEO, 0);
1834 1842
     show_help_options(options, "Subtitle options:",
1835
-                      OPT_SUBTITLE, 0);
1843
+                      OPT_SUBTITLE, 0, 0);
1836 1844
     printf("\n");
1837 1845
 
1838 1846
     if (show_avoptions) {
... ...
@@ -2924,8 +2924,8 @@ void show_help_default(const char *opt, const char *arg)
2924 2924
 {
2925 2925
     av_log_set_callback(log_callback_help);
2926 2926
     show_usage();
2927
-    show_help_options(options, "Main options:", 0, OPT_EXPERT);
2928
-    show_help_options(options, "Advanced options:", OPT_EXPERT, 0);
2927
+    show_help_options(options, "Main options:", 0, OPT_EXPERT, 0);
2928
+    show_help_options(options, "Advanced options:", OPT_EXPERT, 0, 0);
2929 2929
     printf("\n");
2930 2930
     show_help_children(avcodec_get_class(), AV_OPT_FLAG_DECODING_PARAM);
2931 2931
     show_help_children(avformat_get_class(), AV_OPT_FLAG_DECODING_PARAM);
... ...
@@ -872,7 +872,7 @@ void show_help_default(const char *opt, const char *arg)
872 872
 {
873 873
     av_log_set_callback(log_callback_help);
874 874
     show_usage();
875
-    show_help_options(options, "Main options:", 0, 0);
875
+    show_help_options(options, "Main options:", 0, 0, 0);
876 876
     printf("\n");
877 877
     show_help_children(avformat_get_class(), AV_OPT_FLAG_DECODING_PARAM);
878 878
 }
... ...
@@ -4634,7 +4634,7 @@ void show_help_default(const char *opt, const char *arg)
4634 4634
     printf("usage: avserver [options]\n"
4635 4635
            "Hyper fast multi format Audio/Video streaming server\n");
4636 4636
     printf("\n");
4637
-    show_help_options(options, "Main options:", 0, 0);
4637
+    show_help_options(options, "Main options:", 0, 0, 0);
4638 4638
 }
4639 4639
 
4640 4640
 static const OptionDef options[] = {
... ...
@@ -114,7 +114,7 @@ int64_t parse_time_or_die(const char *context, const char *timestr,
114 114
 }
115 115
 
116 116
 void show_help_options(const OptionDef *options, const char *msg, int req_flags,
117
-                       int rej_flags)
117
+                       int rej_flags, int alt_flags)
118 118
 {
119 119
     const OptionDef *po;
120 120
     int first;
... ...
@@ -124,6 +124,7 @@ void show_help_options(const OptionDef *options, const char *msg, int req_flags,
124 124
         char buf[64];
125 125
 
126 126
         if (((po->flags & req_flags) != req_flags) ||
127
+            (alt_flags && !(po->flags & alt_flags)) ||
127 128
             (po->flags & rej_flags))
128 129
             continue;
129 130
 
... ...
@@ -160,9 +160,10 @@ typedef struct {
160 160
  * @param msg title of this group. Only printed if at least one option matches.
161 161
  * @param req_flags print only options which have all those flags set.
162 162
  * @param rej_flags don't print options which have any of those flags set.
163
+ * @param alt_flags print only options that have at least one of those flags set
163 164
  */
164 165
 void show_help_options(const OptionDef *options, const char *msg, int req_flags,
165
-                       int rej_flags);
166
+                       int rej_flags, int alt_flags);
166 167
 
167 168
 /**
168 169
  * Show help for all options with given flags in class and all its