]> git.sesse.net Git - vlc/commitdiff
add exif jpeg detection to the image demuxer
authorSébastien Escudier <sebastien-devel@celeos.eu>
Wed, 15 Feb 2012 10:37:58 +0000 (11:37 +0100)
committerSébastien Escudier <sebastien-devel@celeos.eu>
Thu, 16 Feb 2012 09:32:01 +0000 (10:32 +0100)
modules/demux/image.c

index 892140471a313fbeeb8b0750fd3e3c9dc31a5956..f2fb8ac542ae03557238db1e938e8d3c343b433e 100644 (file)
@@ -404,6 +404,24 @@ static bool IsSpiff(stream_t *s)
     return true;
 }
 
+static bool IsExif(stream_t *s)
+{
+    const uint8_t *header;
+    int size = stream_Peek(s, &header, 256);
+    int position = 0;
+
+    if (FindJpegMarker(&position, header, size) != 0xd8)
+        return false;
+    if (FindJpegMarker(&position, header, size) != 0xe1)
+        return false;
+    position += 2;  /* Skip size */
+    if (position + 5 > size)
+        return false;
+    if (memcmp(&header[position], "Exif\0", 5))
+        return false;
+    return true;
+}
+
 static bool IsTarga(stream_t *s)
 {
     /* The header is not enough to ensure proper detection, we need
@@ -513,6 +531,9 @@ static const image_format_t formats[] = {
     { .codec = VLC_CODEC_JPEG,
       .detect = IsSpiff,
     },
+    { .codec = VLC_CODEC_JPEG,
+      .detect = IsExif,
+    },
     { .codec = VLC_CODEC_TARGA,
       .detect = IsTarga,
     },