Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
82975639
Commit
82975639
authored
Dec 14, 2013
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
decoder/flac: simplify the comment parsers
parent
1da05260
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
30 deletions
+26
-30
FlacMetadata.cxx
src/decoder/FlacMetadata.cxx
+26
-30
No files found.
src/decoder/FlacMetadata.cxx
View file @
82975639
...
...
@@ -30,27 +30,35 @@
#include <string.h>
static
const
char
*
vorbis_comment_value
(
const
FLAC__StreamMetadata
*
block
,
const
char
*
name
)
{
int
offset
=
FLAC__metadata_object_vorbiscomment_find_entry_from
(
block
,
0
,
name
);
if
(
offset
<
0
)
return
nullptr
;
size_t
name_length
=
strlen
(
name
);
const
FLAC__StreamMetadata_VorbisComment_Entry
&
vc
=
block
->
data
.
vorbis_comment
.
comments
[
offset
];
const
char
*
comment
=
(
const
char
*
)
vc
.
entry
;
/* 1 is for '=' */
return
comment
+
name_length
+
1
;
}
static
bool
flac_find_float_comment
(
const
FLAC__StreamMetadata
*
block
,
const
char
*
cmnt
,
float
*
fl
)
{
int
offset
;
size_t
pos
;
int
len
;
unsigned
char
*
p
;
offset
=
FLAC__metadata_object_vorbiscomment_find_entry_from
(
block
,
0
,
cmnt
);
if
(
offset
<
0
)
return
false
;
pos
=
strlen
(
cmnt
)
+
1
;
/* 1 is for '=' */
len
=
block
->
data
.
vorbis_comment
.
comments
[
offset
].
length
-
pos
;
if
(
len
<=
0
)
const
char
*
value
=
vorbis_comment_value
(
block
,
cmnt
);
if
(
value
==
nullptr
)
return
false
;
p
=
&
block
->
data
.
vorbis_comment
.
comments
[
offset
].
entry
[
pos
];
*
fl
=
(
float
)
atof
((
char
*
)
p
);
*
fl
=
(
float
)
atof
(
value
);
return
true
;
}
...
...
@@ -81,23 +89,11 @@ gcc_pure
static
std
::
string
flac_find_string_comment
(
const
FLAC__StreamMetadata
*
block
,
const
char
*
cmnt
)
{
int
offset
;
size_t
pos
;
int
len
;
const
unsigned
char
*
p
;
offset
=
FLAC__metadata_object_vorbiscomment_find_entry_from
(
block
,
0
,
cmnt
);
if
(
offset
<
0
)
return
std
::
string
();
pos
=
strlen
(
cmnt
)
+
1
;
/* 1 is for '=' */
len
=
block
->
data
.
vorbis_comment
.
comments
[
offset
].
length
-
pos
;
if
(
len
<=
0
)
const
char
*
value
=
vorbis_comment_value
(
block
,
cmnt
);
if
(
value
==
nullptr
)
return
std
::
string
();
p
=
&
block
->
data
.
vorbis_comment
.
comments
[
offset
].
entry
[
pos
];
return
std
::
string
((
const
char
*
)
p
,
len
);
return
std
::
string
(
value
);
}
MixRampInfo
...
...
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