changeset 2286:5fca908f82ea libavformat

try exact match before case insensitive match in codec_get_id
author michael
date Fri, 27 Jul 2007 11:36:17 +0000
parents a36b77f40ee2
children 8b2ad7bc2e4b
files utils.c
diffstat 1 files changed, 11 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/utils.c	Fri Jul 27 00:29:33 2007 +0000
+++ b/utils.c	Fri Jul 27 11:36:17 2007 +0000
@@ -1671,13 +1671,17 @@
 
 enum CodecID codec_get_id(const AVCodecTag *tags, unsigned int tag)
 {
-    while (tags->id != CODEC_ID_NONE) {
-        if(   toupper((tag >> 0)&0xFF) == toupper((tags->tag >> 0)&0xFF)
-           && toupper((tag >> 8)&0xFF) == toupper((tags->tag >> 8)&0xFF)
-           && toupper((tag >>16)&0xFF) == toupper((tags->tag >>16)&0xFF)
-           && toupper((tag >>24)&0xFF) == toupper((tags->tag >>24)&0xFF))
-            return tags->id;
-        tags++;
+    int i;
+    for(i=0; tags[i].id != CODEC_ID_NONE;i++) {
+        if(tag == tags[i].tag)
+            return tags[i].id;
+    }
+    for(i=0; tags[i].id != CODEC_ID_NONE; i++) {
+        if(   toupper((tag >> 0)&0xFF) == toupper((tags[i].tag >> 0)&0xFF)
+           && toupper((tag >> 8)&0xFF) == toupper((tags[i].tag >> 8)&0xFF)
+           && toupper((tag >>16)&0xFF) == toupper((tags[i].tag >>16)&0xFF)
+           && toupper((tag >>24)&0xFF) == toupper((tags[i].tag >>24)&0xFF))
+            return tags[i].id;
     }
     return CODEC_ID_NONE;
 }