Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc-2-2
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc-2-2
Commits
55862d2e
Commit
55862d2e
authored
Mar 31, 2014
by
Jean-Paul Saman
Committed by
Jean-Paul Saman
May 12, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
demux/image.c: Detect SVG Scalable Vector Graphics Images
parent
13aa51f8
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
50 additions
and
0 deletions
+50
-0
modules/demux/image.c
modules/demux/image.c
+50
-0
No files found.
modules/demux/image.c
View file @
55862d2e
...
...
@@ -423,6 +423,53 @@ static bool IsExif(stream_t *s)
return
true
;
}
static
bool
FindSVGmarker
(
int
*
position
,
const
uint8_t
*
data
,
const
int
size
,
const
char
*
marker
)
{
for
(
int
i
=
*
position
;
i
<
size
;
i
++
)
{
if
(
memcmp
(
&
data
[
i
],
marker
,
strlen
(
marker
))
==
0
)
{
*
position
=
i
;
return
true
;
}
}
return
false
;
}
static
bool
IsSVG
(
stream_t
*
s
)
{
char
*
ext
=
strstr
(
s
->
psz_path
,
".svg"
);
if
(
!
ext
)
return
false
;
const
uint8_t
*
header
;
int
size
=
stream_Peek
(
s
,
&
header
,
4096
);
int
position
=
0
;
const
char
xml
[]
=
"<?xml version=
\"
"
;
if
(
!
FindSVGmarker
(
&
position
,
header
,
size
,
xml
))
return
false
;
if
(
position
!=
0
)
return
false
;
const
char
endxml
[]
=
">
\0
"
;
if
(
!
FindSVGmarker
(
&
position
,
header
,
size
,
endxml
))
return
false
;
if
(
position
<=
15
)
return
false
;
const
char
svg
[]
=
"<svg"
;
if
(
!
FindSVGmarker
(
&
position
,
header
,
size
,
svg
))
return
false
;
if
(
position
<
19
)
return
false
;
/* SVG Scalable Vector Graphics image */
/* NOTE: some SVG images have the mimetype set in a meta data section
* and some do not */
return
true
;
}
static
bool
IsTarga
(
stream_t
*
s
)
{
/* The header is not enough to ensure proper detection, we need
...
...
@@ -538,6 +585,9 @@ static const image_format_t formats[] = {
{
.
codec
=
VLC_CODEC_JPEG
,
.
detect
=
IsExif
,
},
{
.
codec
=
VLC_CODEC_SVG
,
.
detect
=
IsSVG
,
},
{
.
codec
=
VLC_CODEC_TARGA
,
.
detect
=
IsTarga
,
},
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment