changeset 4245:a2a190f1bb9d libavformat

match format in names list separated by commas
author bcoudurier
date Sat, 17 Jan 2009 21:40:27 +0000
parents f7c35963d089
children e7d360560ada
files utils.c
diffstat 1 files changed, 19 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/utils.c	Sat Jan 17 20:08:43 2009 +0000
+++ b/utils.c	Sat Jan 17 21:40:27 2009 +0000
@@ -153,6 +153,24 @@
     return 0;
 }
 
+static int match_format(const char *name, const char *names)
+{
+    const char *p;
+    int len, namelen;
+
+    if (!name || !names)
+        return 0;
+
+    namelen = strlen(name);
+    while ((p = strchr(names, ','))) {
+        len = FFMAX(p - names, namelen);
+        if (!strncasecmp(name, names, len))
+            return 1;
+        names = p+1;
+    }
+    return !strcasecmp(name, names);
+}
+
 AVOutputFormat *guess_format(const char *short_name, const char *filename,
                              const char *mime_type)
 {
@@ -232,7 +250,7 @@
 {
     AVInputFormat *fmt;
     for(fmt = first_iformat; fmt != NULL; fmt = fmt->next) {
-        if (!strcmp(fmt->name, short_name))
+        if (match_format(short_name, fmt->name))
             return fmt;
     }
     return NULL;