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
34#include "internal.h"34#include "internal.h"
35#include "img2.h"35#include "img2.h"
36#include "libavcodec/mjpeg.h"36#include "libavcodec/mjpeg.h"
37#include "subtitles.h"
37 38
38#if HAVE_GLOB39#if HAVE_GLOB
39/* Locally define as 0 (bitwise-OR no-op) any missing glob options that40/* 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
875 876
876static int svg_probe(AVProbeData *p)877static int svg_probe(AVProbeData *p)
877{878{
878 if (av_match_ext(p->filename, "svg") || av_match_ext(p->filename, "svgz"))879 const uint8_t *b = p->buf;
879 return AVPROBE_SCORE_EXTENSION + 1;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 }
880 return 0;890 return 0;
881}891}
882 892

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