[FFmpeg-cvslog] lavf/img2dec: Auto-detect svg images.

Carl Eugen Hoyos git at videolan.org
Sat Oct 7 04:43:03 EEST 2017


ffmpeg | branch: master | Carl Eugen Hoyos <ceffmpeg at gmail.com> | Mon Oct  2 11:38:34 2017 +0200| [a20f64bee235042f6e35c8e7ae65ccfddbf7343b] | committer: Carl Eugen Hoyos

lavf/img2dec: Auto-detect svg images.

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

 libavformat/img2dec.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/libavformat/img2dec.c b/libavformat/img2dec.c
index 19cae87fdb..ecf64eaffa 100644
--- a/libavformat/img2dec.c
+++ b/libavformat/img2dec.c
@@ -34,6 +34,7 @@
 #include "internal.h"
 #include "img2.h"
 #include "libavcodec/mjpeg.h"
+#include "subtitles.h"
 
 #if HAVE_GLOB
 /* Locally define as 0 (bitwise-OR no-op) any missing glob options that
@@ -875,8 +876,17 @@ static int sunrast_probe(AVProbeData *p)
 
 static int svg_probe(AVProbeData *p)
 {
-    if (av_match_ext(p->filename, "svg") || av_match_ext(p->filename, "svgz"))
-        return AVPROBE_SCORE_EXTENSION + 1;
+    const uint8_t *b = p->buf;
+    const uint8_t *end = p->buf + p->buf_size;
+    if (memcmp(p->buf, "<?xml", 5))
+        return 0;
+    while (b < end) {
+        b += ff_subtitles_next_line(b);
+        if (b >= end - 4)
+            return 0;
+        if (!memcmp(b, "<svg", 4))
+            return AVPROBE_SCORE_EXTENSION + 1;
+    }
     return 0;
 }
 



More information about the ffmpeg-cvslog mailing list