vlc | branch: master | Tristan Matthews <tma...@videolan.org> | Tue Mar  6 
01:22:34 2018 -0500| [816f1630123b781a74cab3591583e9a05e7a29a3] | committer: 
Tristan Matthews

demux: image: add WebP probing

Refs #19446

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=816f1630123b781a74cab3591583e9a05e7a29a3
---

 modules/demux/image.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/modules/demux/image.c b/modules/demux/image.c
index 038cf5e43f..7b7604156f 100644
--- a/modules/demux/image.c
+++ b/modules/demux/image.c
@@ -416,6 +416,21 @@ static bool IsJfif(stream_t *s)
     return true;
 }
 
+static bool IsWebP(stream_t *s)
+{
+    const uint8_t *header;
+    if (vlc_stream_Peek(s, &header, 20) < 20) /* WebP header size */
+        return false;
+    if (memcmp(&header[0], "RIFF", 4))
+        return false;
+    /* TODO: support other chunk types */
+    if (memcmp(&header[8], "WEBPVP8 ", 8))
+        return false;
+    /* skip headers */
+    vlc_stream_Seek(s, 20);
+    return true;
+}
+
 static bool IsSpiff(stream_t *s)
 {
     const uint8_t *header;
@@ -616,6 +631,9 @@ static const image_format_t formats[] = {
     { .codec = VLC_CODEC_JPEG,
       .detect = IsExif,
     },
+    { .codec = VLC_CODEC_WEBP,
+      .detect = IsWebP,
+    },
     { .codec = VLC_CODEC_BPG,
       .marker_size = 4,
       .marker = { 'B', 'P', 'G', 0xFB },

_______________________________________________
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits

Reply via email to