[FFmpeg-devel] [PATCH] cmdutils: include type in filter list.

Nicolas George nicolas.george at normalesup.org
Thu Jan 19 13:38:48 CET 2012


Signed-off-by: Nicolas George <nicolas.george at normalesup.org>
---

ffmpeg -filters will look like that:

aconvert         A->A       Convert the input audio to sample_fmt:channel_layout:packed_fmt.
amerge           AA->A      Merge two audio streams into a single multi-channel stream.
abuffer          |->A       Buffer audio frames, and make them accessible to the filterchain.
abuffersink      A->|       Buffer audio frames, and make them available to the end of the filter graph.
anullsink        A->|       Do absolutely nothing with the input audio.
deshake          V->V       Stabilize shaky video.
overlay          VV->V      Overlay a video source on top of the input.
split            V->VV      Pass on the input to two outputs.
cellauto         |->V       Create pattern generated by an elementary cellular automaton.
buffersink       V->|       Buffer video frames, and make them available to the end of the filter graph.


 cmdutils.c |   55 ++++++++++++++++++++++++++++++++++++-------------------
 1 files changed, 36 insertions(+), 19 deletions(-)

diff --git a/cmdutils.c b/cmdutils.c
index 344e506..7e43d69 100644
--- a/cmdutils.c
+++ b/cmdutils.c
@@ -764,6 +764,18 @@ int opt_formats(const char *opt, const char *arg)
     return 0;
 }
 
+static char get_media_type_letter(enum AVMediaType type)
+{
+    char map[AVMEDIA_TYPE_NB] = {
+        [AVMEDIA_TYPE_VIDEO]      = 'V',
+        [AVMEDIA_TYPE_AUDIO]      = 'A',
+        [AVMEDIA_TYPE_DATA]       = 'D',
+        [AVMEDIA_TYPE_SUBTITLE]   = 'S',
+        [AVMEDIA_TYPE_ATTACHMENT] = 'J',
+    };
+    return type >= 0 && type < AVMEDIA_TYPE_NB && map[type] ? map[type] : '?';
+}
+
 int opt_codecs(const char *opt, const char *arg)
 {
     AVCodec *p = NULL, *p2;
@@ -783,7 +795,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))) {
@@ -804,24 +815,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_letter(p2->type),
                cap & CODEC_CAP_DRAW_HORIZ_BAND ? "S" : " ",
                cap & CODEC_CAP_DR1 ? "D" : " ",
                cap & CODEC_CAP_TRUNCATED ? "T" : " ",
@@ -875,11 +872,31 @@ int opt_protocols(const char *opt, const char *arg)
 int opt_filters(const char *opt, const char *arg)
 {
     AVFilter av_unused(**filter) = NULL;
+    char descr[64], *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) {
+        cur = descr;
+        for (i = 0; i < 2; i++) {
+            if (i) {
+                *(cur++) = '-';
+                *(cur++) = '>';
+            }
+            pad = i ? (*filter)->outputs : (*filter)->inputs;
+            for (j = 0; pad[j].name; j++) {
+                if (cur >= descr + sizeof(descr) - 4)
+                    break;
+                *(cur++) = get_media_type_letter(pad[j].type);
+            }
+            if (!j)
+                *(cur++) = '|';
+        }
+        *cur = 0;
+        printf("%-16s %-10s %s\n", (*filter)->name, descr, (*filter)->description);
+    }
 #endif
     return 0;
 }
-- 
1.7.8.3



More information about the ffmpeg-devel mailing list