Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
VLC
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Monitor
Service Desk
Analyze
Contributor analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Mohamed Emad
VLC
Commits
98bc0e32
Commit
98bc0e32
authored
13 years ago
by
Jean-Baptiste Kempf
Browse files
Options
Downloads
Patches
Plain Diff
Split FLAC picture parsing from flac.c
parent
88d6c465
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
modules/demux/flac.c
+5
-40
5 additions, 40 deletions
modules/demux/flac.c
modules/demux/vorbis.h
+46
-1
46 additions, 1 deletion
modules/demux/vorbis.h
with
51 additions
and
41 deletions
modules/demux/flac.c
+
5
−
40
View file @
98bc0e32
...
...
@@ -572,7 +572,6 @@ static void ParseSeekTable( demux_t *p_demux, const uint8_t *p_data, int i_data,
/* TODO sort it by size and remove wrong seek entry (time not increasing) */
}
#define RM(x) do { i_data -= (x); p_data += (x); } while(0)
static
void
ParseComment
(
demux_t
*
p_demux
,
const
uint8_t
*
p_data
,
int
i_data
)
{
demux_sys_t
*
p_sys
=
p_demux
->
p_sys
;
...
...
@@ -600,43 +599,13 @@ static void ParsePicture( demux_t *p_demux, const uint8_t *p_data, int i_data )
};
demux_sys_t
*
p_sys
=
p_demux
->
p_sys
;
int
i_type
;
int
i_len
;
char
*
psz_mime
=
NULL
;
char
*
psz_description
=
NULL
;
input_attachment_t
*
p_attachment
;
char
psz_name
[
128
];
if
(
i_data
<
4
+
3
*
4
)
i_data
-=
4
;
p_data
+=
4
;
input_attachment_t
*
p_attachment
=
ParseFlacPicture
(
p_data
,
i_data
,
p_sys
->
i_attachments
,
&
i_type
);
if
(
p_attachment
==
NULL
)
return
;
#define RM(x) do { i_data -= (x); p_data += (x); } while(0)
RM
(
4
);
i_type
=
GetDWBE
(
p_data
);
RM
(
4
);
i_len
=
GetDWBE
(
p_data
);
RM
(
4
);
if
(
i_len
<
0
||
i_data
<
i_len
+
4
)
goto
error
;
psz_mime
=
strndup
(
(
const
char
*
)
p_data
,
i_len
);
RM
(
i_len
);
i_len
=
GetDWBE
(
p_data
);
RM
(
4
);
if
(
i_len
<
0
||
i_data
<
i_len
+
4
*
4
+
4
)
goto
error
;
psz_description
=
strndup
(
(
const
char
*
)
p_data
,
i_len
);
RM
(
i_len
);
EnsureUTF8
(
psz_description
);
RM
(
4
*
4
);
i_len
=
GetDWBE
(
p_data
);
RM
(
4
);
if
(
i_len
<
0
||
i_len
>
i_data
)
goto
error
;
msg_Dbg
(
p_demux
,
"Picture type=%d mime=%s description='%s' file length=%d"
,
i_type
,
psz_mime
,
psz_description
,
i_len
);
snprintf
(
psz_name
,
sizeof
(
psz_name
),
"picture%d"
,
p_sys
->
i_attachments
);
if
(
!
strcasecmp
(
psz_mime
,
"image/jpeg"
)
)
strcat
(
psz_name
,
".jpg"
);
else
if
(
!
strcasecmp
(
psz_mime
,
"image/png"
)
)
strcat
(
psz_name
,
".png"
);
p_attachment
=
vlc_input_attachment_New
(
psz_name
,
psz_mime
,
psz_description
,
p_data
,
i_data
);
TAB_APPEND
(
p_sys
->
i_attachments
,
p_sys
->
attachments
,
p_attachment
);
if
(
i_type
>=
0
&&
(
unsigned
int
)
i_type
<
sizeof
(
pi_cover_score
)
/
sizeof
(
pi_cover_score
[
0
])
&&
...
...
@@ -645,9 +614,5 @@ static void ParsePicture( demux_t *p_demux, const uint8_t *p_data, int i_data )
p_sys
->
i_cover_idx
=
p_sys
->
i_attachments
-
1
;
p_sys
->
i_cover_score
=
pi_cover_score
[
i_type
];
}
error:
free
(
psz_mime
);
free
(
psz_description
);
}
#undef RM
This diff is collapsed.
Click to expand it.
modules/demux/vorbis.h
+
46
−
1
View file @
98bc0e32
...
...
@@ -23,6 +23,52 @@
#include
<vlc_charset.h>
static
input_attachment_t
*
ParseFlacPicture
(
const
uint8_t
*
p_data
,
int
i_data
,
int
i_attachments
,
int
*
i_type
)
{
int
i_len
;
char
*
psz_mime
=
NULL
;
char
psz_name
[
128
];
char
*
psz_description
=
NULL
;
input_attachment_t
*
p_attachment
=
NULL
;
if
(
i_data
<
4
+
3
*
4
)
return
NULL
;
#define RM(x) do { i_data -= (x); p_data += (x); } while(0)
*
i_type
=
GetDWBE
(
p_data
);
RM
(
4
);
i_len
=
GetDWBE
(
p_data
);
RM
(
4
);
if
(
i_len
<
0
||
i_data
<
i_len
+
4
)
goto
error
;
psz_mime
=
strndup
(
(
const
char
*
)
p_data
,
i_len
);
RM
(
i_len
);
i_len
=
GetDWBE
(
p_data
);
RM
(
4
);
if
(
i_len
<
0
||
i_data
<
i_len
+
4
*
4
+
4
)
goto
error
;
psz_description
=
strndup
(
(
const
char
*
)
p_data
,
i_len
);
RM
(
i_len
);
EnsureUTF8
(
psz_description
);
RM
(
4
*
4
);
i_len
=
GetDWBE
(
p_data
);
RM
(
4
);
if
(
i_len
<
0
||
i_len
>
i_data
)
goto
error
;
/* printf( "Picture type=%d mime=%s description='%s' file length=%d\n",
*i_type, psz_mime, psz_description, i_len ); */
snprintf
(
psz_name
,
sizeof
(
psz_name
),
"picture%d"
,
i_attachments
);
if
(
!
strcasecmp
(
psz_mime
,
"image/jpeg"
)
)
strcat
(
psz_name
,
".jpg"
);
else
if
(
!
strcasecmp
(
psz_mime
,
"image/png"
)
)
strcat
(
psz_name
,
".png"
);
p_attachment
=
vlc_input_attachment_New
(
psz_name
,
psz_mime
,
psz_description
,
p_data
,
i_data
);
error:
free
(
psz_mime
);
free
(
psz_description
);
return
p_attachment
;
}
static
inline
void
vorbis_ParseComment
(
vlc_meta_t
**
pp_meta
,
const
uint8_t
*
p_data
,
int
i_data
)
{
int
n
;
...
...
@@ -30,7 +76,6 @@ static inline void vorbis_ParseComment( vlc_meta_t **pp_meta, const uint8_t *p_d
if
(
i_data
<
8
)
return
;
#define RM(x) do { i_data -= (x); p_data += (x); } while(0)
n
=
GetDWLE
(
p_data
);
RM
(
4
);
if
(
n
<
0
||
n
>
i_data
)
return
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment