Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
libopusenc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
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
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
Show 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
...
@@ -290,6 +290,12 @@ static unsigned char *_ope_read_picture_file(const char *filename, const char *d
return
buf
;
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.
/*Parse a picture SPECIFICATION as given on the command-line.
spec: The specification.
spec: The specification.
error_message: Returns an error message on error.
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
...
@@ -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.
have already been added, to ensure only one is allowed.
Return: A Base64-encoded string suitable for use in a METADATA_BLOCK_PICTURE
Return: A Base64-encoded string suitable for use in a METADATA_BLOCK_PICTURE
tag.*/
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
){
int
*
error
,
int
*
seen_file_icons
){
opus_uint32
width
;
opus_uint32
width
;
opus_uint32
height
;
opus_uint32
height
;
opus_uint32
depth
;
opus_uint32
depth
;
opus_uint32
colors
;
opus_uint32
colors
;
unsigned
char
*
buf
;
const
char
*
mime_type
;
const
char
*
mime_type
;
char
*
out
;
char
*
out
;
size_t
nbuf
;
size_t
data_offset
;
size_t
data_length
;
size_t
data_length
;
size_t
b64_length
;
size_t
b64_length
;
int
has_palette
;
int
has_palette
;
*
error
=
OPE_OK
;
*
error
=
OPE_OK
;
if
(
picture_type
<
0
)
picture_type
=
3
;
if
(
picture_type
<
0
)
picture_type
=
3
;
if
(
picture_type
>
20
)
{
if
(
!
validate_picture_type
(
picture_type
,
*
seen_file_icons
))
{
*
error
=
OPE_INVALID_PICTURE
;
*
error
=
OPE_INVALID_PICTURE
;
return
NULL
;
}
if
(
picture_type
>=
1
&&
picture_type
<=
2
&&
(
*
seen_file_icons
&
picture_type
)){
*
error
=
OPE_INVALID_PICTURE
;
return
NULL
;
return
NULL
;
}
}
buf
=
_ope_read_picture_file
(
filename
,
description
,
error
,
&
nbuf
,
&
data_offset
);
if
(
buf
==
NULL
)
return
NULL
;
if
(
buf
==
NULL
)
return
NULL
;
data_length
=
nbuf
-
data_offset
;
data_length
=
nbuf
-
data_offset
;
/*Try to extract the image dimensions/color information from the file.*/
/*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
...
@@ -395,3 +393,17 @@ char *_ope_parse_picture_specification(const char *filename, int picture_type, c
free
(
buf
);
free
(
buf
);
return
out
;
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