avformat/rawdec: Increase probe score when "Content-Type: image/jpeg" is found at...
authorMichael Niedermayer <michaelni@gmx.at>
Tue, 10 Jun 2014 12:23:06 +0000 (14:23 +0200)
committerMichael Niedermayer <michaelni@gmx.at>
Tue, 10 Jun 2014 12:42:19 +0000 (14:42 +0200)
Based-on code by: Carl Eugen Hoyos and Andrey Utkin
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
libavformat/rawdec.c

index 543bb6b..ca9b282 100644 (file)
@@ -185,10 +185,18 @@ static int mjpeg_probe(AVProbeData *p)
         }
     }
 
-    if (nb_invalid == 0 && nb_frames > 2)
-        return AVPROBE_SCORE_EXTENSION / 2;
-    if (nb_invalid*4 + 1 < nb_frames)
+    if (nb_invalid*4 + 1 < nb_frames) {
+        static const char ct_jpeg[] = "\r\nContent-Type: image/jpeg\r\n\r\n";
+        int i;
+
+        for (i=0; i<FFMIN(p->buf_size - sizeof(ct_jpeg), 100); i++)
+            if (!memcmp(p->buf + i, ct_jpeg, sizeof(ct_jpeg) - 1))
+                return AVPROBE_SCORE_EXTENSION;
+
+        if (nb_invalid == 0 && nb_frames > 2)
+            return AVPROBE_SCORE_EXTENSION / 2;
         return AVPROBE_SCORE_EXTENSION / 4;
+    }
 
     return 0;
 }