Commit a20f64be authored by Carl Eugen Hoyos's avatar Carl Eugen Hoyos

lavf/img2dec: Auto-detect svg images.

parent cc5b7601
...@@ -34,6 +34,7 @@ ...@@ -34,6 +34,7 @@
#include "internal.h" #include "internal.h"
#include "img2.h" #include "img2.h"
#include "libavcodec/mjpeg.h" #include "libavcodec/mjpeg.h"
#include "subtitles.h"
#if HAVE_GLOB #if HAVE_GLOB
/* Locally define as 0 (bitwise-OR no-op) any missing glob options that /* Locally define as 0 (bitwise-OR no-op) any missing glob options that
...@@ -875,8 +876,17 @@ static int sunrast_probe(AVProbeData *p) ...@@ -875,8 +876,17 @@ static int sunrast_probe(AVProbeData *p)
static int svg_probe(AVProbeData *p) static int svg_probe(AVProbeData *p)
{ {
if (av_match_ext(p->filename, "svg") || av_match_ext(p->filename, "svgz")) 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 AVPROBE_SCORE_EXTENSION + 1;
}
return 0; return 0;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment