Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Xiph.Org
libopusenc
Commits
ecdd28cd
Unverified
Commit
ecdd28cd
authored
Feb 05, 2018
by
Jean-Marc Valin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
More refactoring of the picture handling code
parent
81b3f156
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
11 deletions
+23
-11
src/picture.c
src/picture.c
+23
-11
No files found.
src/picture.c
View file @
ecdd28cd
...
...
@@ -290,6 +290,12 @@ static unsigned char *_ope_read_picture_file(const char *filename, const char *d
return
buf
;
}
static
int
validate_picture_type
(
int
picture_type
,
int
seen_file_icons
)
{
if
(
picture_type
>
20
)
return
0
;
if
(
picture_type
>=
1
&&
picture_type
<=
2
&&
(
seen_file_icons
&
picture_type
))
return
0
;
return
1
;
}
/*Parse a picture SPECIFICATION as given on the command-line.
spec: The specification.
error_message: Returns an error message on error.
...
...
@@ -297,31 +303,23 @@ static unsigned char *_ope_read_picture_file(const char *filename, const char *d
have already been added, to ensure only one is allowed.
Return: A Base64-encoded string suitable for use in a METADATA_BLOCK_PICTURE
tag.*/
char
*
_ope_parse_picture_specification
(
const
char
*
filename
,
int
picture_type
,
const
char
*
description
,
static
char
*
_ope_parse_picture_specification
_impl
(
unsigned
char
*
buf
,
size_t
nbuf
,
size_t
data_offset
,
int
picture_type
,
const
char
*
description
,
int
*
error
,
int
*
seen_file_icons
){
opus_uint32
width
;
opus_uint32
height
;
opus_uint32
depth
;
opus_uint32
colors
;
unsigned
char
*
buf
;
const
char
*
mime_type
;
char
*
out
;
size_t
nbuf
;
size_t
data_offset
;
size_t
data_length
;
size_t
b64_length
;
int
has_palette
;
*
error
=
OPE_OK
;
if
(
picture_type
<
0
)
picture_type
=
3
;
if
(
picture_type
>
20
)
{
*
error
=
OPE_INVALID_PICTURE
;
return
NULL
;
}
if
(
picture_type
>=
1
&&
picture_type
<=
2
&&
(
*
seen_file_icons
&
picture_type
)){
*
error
=
OPE_INVALID_PICTURE
;
if
(
!
validate_picture_type
(
picture_type
,
*
seen_file_icons
))
{
*
error
=
OPE_INVALID_PICTURE
;
return
NULL
;
}
buf
=
_ope_read_picture_file
(
filename
,
description
,
error
,
&
nbuf
,
&
data_offset
);
if
(
buf
==
NULL
)
return
NULL
;
data_length
=
nbuf
-
data_offset
;
/*Try to extract the image dimensions/color information from the file.*/
...
...
@@ -395,3 +393,17 @@ char *_ope_parse_picture_specification(const char *filename, int picture_type, c
free
(
buf
);
return
out
;
}
char
*
_ope_parse_picture_specification
(
const
char
*
filename
,
int
picture_type
,
const
char
*
description
,
int
*
error
,
int
*
seen_file_icons
){
size_t
nbuf
;
size_t
data_offset
;
unsigned
char
*
buf
;
if
(
picture_type
<
0
)
picture_type
=
3
;
if
(
!
validate_picture_type
(
picture_type
,
*
seen_file_icons
))
{
*
error
=
OPE_INVALID_PICTURE
;
return
NULL
;
}
buf
=
_ope_read_picture_file
(
filename
,
description
,
error
,
&
nbuf
,
&
data_offset
);
return
_ope_parse_picture_specification_impl
(
buf
,
nbuf
,
data_offset
,
picture_type
,
description
,
error
,
seen_file_icons
);
}
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