]> git.sesse.net Git - ffmpeg/blobdiff - cmdutils.c
Merge remote-tracking branch 'qatar/master'
[ffmpeg] / cmdutils.c
index 36e472a705415b0a49ff628eb045536dad0778fa..5731a11f4cf957bb20d8ba08bf9443eb5359e16b 100644 (file)
@@ -34,7 +34,9 @@
 #include "libavdevice/avdevice.h"
 #include "libswscale/swscale.h"
 #include "libswresample/swresample.h"
+#if CONFIG_POSTPROC
 #include "libpostproc/postprocess.h"
+#endif
 #include "libavutil/avstring.h"
 #include "libavutil/mathematics.h"
 #include "libavutil/parseutils.h"
@@ -248,14 +250,12 @@ int parse_option(void *optctx, const char *opt, const char *arg,
     if (!po->name && opt[0] == 'n' && opt[1] == 'o') {
         /* handle 'no' bool option */
         po = find_option(options, opt + 2);
-        if (!(po->name && (po->flags & OPT_BOOL)))
-            goto unknown_opt;
-        bool_val = 0;
+        if ((po->name && (po->flags & OPT_BOOL)))
+            bool_val = 0;
     }
     if (!po->name)
         po = find_option(options, "default");
     if (!po->name) {
-unknown_opt:
         av_log(NULL, AV_LOG_ERROR, "Unrecognized option '%s'\n", opt);
         return AVERROR(EINVAL);
     }
@@ -607,7 +607,9 @@ static void print_all_libs_info(int flags, int level)
     PRINT_LIB_INFO(avfilter, AVFILTER, flags, level);
     PRINT_LIB_INFO(swscale,  SWSCALE,  flags, level);
     PRINT_LIB_INFO(swresample,SWRESAMPLE,  flags, level);
+#if CONFIG_POSTPROC
     PRINT_LIB_INFO(postproc, POSTPROC, flags, level);
+#endif
 }
 
 static void print_program_info(int flags, int level)
@@ -760,6 +762,18 @@ int opt_formats(const char *opt, const char *arg)
     return 0;
 }
 
+static char get_media_type_char(enum AVMediaType type)
+{
+    static const char map[AVMEDIA_TYPE_NB] = {
+        [AVMEDIA_TYPE_VIDEO]      = 'V',
+        [AVMEDIA_TYPE_AUDIO]      = 'A',
+        [AVMEDIA_TYPE_DATA]       = 'D',
+        [AVMEDIA_TYPE_SUBTITLE]   = 'S',
+        [AVMEDIA_TYPE_ATTACHMENT] = 'T',
+    };
+    return type >= 0 && type < AVMEDIA_TYPE_NB && map[type] ? map[type] : '?';
+}
+
 int opt_codecs(const char *opt, const char *arg)
 {
     AVCodec *p = NULL, *p2;
@@ -779,7 +793,6 @@ int opt_codecs(const char *opt, const char *arg)
         int decode = 0;
         int encode = 0;
         int cap    = 0;
-        const char *type_str;
 
         p2 = NULL;
         while ((p = av_codec_next(p))) {
@@ -800,24 +813,10 @@ int opt_codecs(const char *opt, const char *arg)
             break;
         last_name = p2->name;
 
-        switch (p2->type) {
-        case AVMEDIA_TYPE_VIDEO:
-            type_str = "V";
-            break;
-        case AVMEDIA_TYPE_AUDIO:
-            type_str = "A";
-            break;
-        case AVMEDIA_TYPE_SUBTITLE:
-            type_str = "S";
-            break;
-        default:
-            type_str = "?";
-            break;
-        }
-        printf(" %s%s%s%s%s%s %-15s %s",
+        printf(" %s%s%c%s%s%s %-15s %s",
                decode ? "D" : (/* p2->decoder ? "d" : */ " "),
                encode ? "E" : " ",
-               type_str,
+               get_media_type_char(p2->type),
                cap & CODEC_CAP_DRAW_HORIZ_BAND ? "S" : " ",
                cap & CODEC_CAP_DR1 ? "D" : " ",
                cap & CODEC_CAP_TRUNCATED ? "T" : " ",
@@ -851,31 +850,46 @@ int opt_bsfs(const char *opt, const char *arg)
 
 int opt_protocols(const char *opt, const char *arg)
 {
-    URLProtocol *up=NULL;
+    void *opaque = NULL;
+    const char *name;
 
     printf("Supported file protocols:\n"
-           "I.. = Input  supported\n"
-           ".O. = Output supported\n"
-           "..S = Seek   supported\n"
-           "FLAGS NAME\n"
-           "----- \n");
-    while((up = av_protocol_next(up)))
-        printf("%c%c%c   %s\n",
-               up->url_read  ? 'I' : '.',
-               up->url_write ? 'O' : '.',
-               up->url_seek  ? 'S' : '.',
-               up->name);
-    return 0;
+           "Input:\n");
+    while ((name = avio_enum_protocols(&opaque, 0)))
+        printf("%s\n", name);
+    printf("Output:\n");
+    while ((name = avio_enum_protocols(&opaque, 1)))
+        printf("%s\n", name);
 }
 
 int opt_filters(const char *opt, const char *arg)
 {
     AVFilter av_unused(**filter) = NULL;
+    char descr[64], *descr_cur;
+    int i, j;
+    const AVFilterPad *pad;
 
     printf("Filters:\n");
 #if CONFIG_AVFILTER
-    while ((filter = av_filter_next(filter)) && *filter)
-        printf("%-16s %s\n", (*filter)->name, (*filter)->description);
+    while ((filter = av_filter_next(filter)) && *filter) {
+        descr_cur = descr;
+        for (i = 0; i < 2; i++) {
+            if (i) {
+                *(descr_cur++) = '-';
+                *(descr_cur++) = '>';
+            }
+            pad = i ? (*filter)->outputs : (*filter)->inputs;
+            for (j = 0; pad[j].name; j++) {
+                if (descr_cur >= descr + sizeof(descr) - 4)
+                    break;
+                *(descr_cur++) = get_media_type_char(pad[j].type);
+            }
+            if (!j)
+                *(descr_cur++) = '|';
+        }
+        *descr_cur = 0;
+        printf("%-16s %-10s %s\n", (*filter)->name, descr, (*filter)->description);
+    }
 #endif
     return 0;
 }