History

lavf/img2dec: Auto-detect svg images.

Carl Eugen Hoyos committed 9 years ago

Commit a20f64b1 parent cc5b7601 file · +12 −2Browse files

Unified · Split

libavformat/img2dec.c+12−2
@@ -34,6 +34,7 @@ · 33 unmodified lines
3434 #include "internal.h"
3535 #include "img2.h"
3636 #include "libavcodec/mjpeg.h"
37+#include "subtitles.h"
3738
3839 #if HAVE_GLOB
3940 /* Locally define as 0 (bitwise-OR no-op) any missing glob options that
@@ -875,8 +876,17 @@ static int sunrast_probe(AVProbeData *p) · 835 unmodified lines
875876
876877 static int svg_probe(AVProbeData *p)
877878 {
878− if (av_match_ext(p->filename, "svg") || av_match_ext(p->filename, "svgz"))
879− return AVPROBE_SCORE_EXTENSION + 1;
879+ const uint8_t *b = p->buf;
880+ const uint8_t *end = p->buf + p->buf_size;
881+ if (memcmp(p->buf, "<?xml", 5))
882+ return 0;
883+ while (b < end) {
884+ b += ff_subtitles_next_line(b);
885+ if (b >= end - 4)
886+ return 0;
887+ if (!memcmp(b, "<svg", 4))
888+ return AVPROBE_SCORE_EXTENSION + 1;
889+ }
880890 return 0;
881891 }
882892

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t