[FFmpeg-cvslog] avformat/rawdec: Increase probe score when "Content-Type: image/jpeg" is found at the file start

Michael Niedermayer git at videolan.org
Tue Jun 10 14:50:18 CEST 2014


ffmpeg | branch: master | Michael Niedermayer <michaelni at gmx.at> | Tue Jun 10 14:23:06 2014 +0200| [0f0f6260484eddd5fcd569b692a8a928cd12fd80] | committer: Michael Niedermayer

avformat/rawdec: Increase probe score when "Content-Type: image/jpeg" is found at the file start

Based-on code by: Carl Eugen Hoyos and Andrey Utkin
Signed-off-by: Michael Niedermayer <michaelni at gmx.at>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=0f0f6260484eddd5fcd569b692a8a928cd12fd80
---

 libavformat/rawdec.c |   14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/libavformat/rawdec.c b/libavformat/rawdec.c
index 543bb6b..ca9b282 100644
--- a/libavformat/rawdec.c
+++ b/libavformat/rawdec.c
@@ -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;
 }



More information about the ffmpeg-cvslog mailing list