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
441f9cc2
Commit
441f9cc2
authored
Sep 24, 2014
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tag/ReplayGain: add VorbisComment parser
Move code from the Vorbis and FLAC decoder plugins.
parent
9f4fc8ad
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
31 additions
and
41 deletions
+31
-41
FlacMetadata.cxx
src/decoder/plugins/FlacMetadata.cxx
+10
-24
VorbisComments.cxx
src/decoder/plugins/VorbisComments.cxx
+2
-17
ReplayGain.cxx
src/tag/ReplayGain.cxx
+16
-0
ReplayGain.hxx
src/tag/ReplayGain.hxx
+3
-0
No files found.
src/decoder/plugins/FlacMetadata.cxx
View file @
441f9cc2
...
...
@@ -26,6 +26,7 @@
#include "tag/TagBuilder.hxx"
#include "tag/Tag.hxx"
#include "tag/VorbisComment.hxx"
#include "tag/ReplayGain.hxx"
#include "ReplayGainInfo.hxx"
#include "util/ASCII.hxx"
#include "util/SplitString.hxx"
...
...
@@ -52,37 +53,22 @@ vorbis_comment_value(const FLAC__StreamMetadata *block,
return
comment
+
name_length
+
1
;
}
static
bool
flac_find_float_comment
(
const
FLAC__StreamMetadata
*
block
,
const
char
*
cmnt
,
float
*
fl
)
{
const
char
*
value
=
vorbis_comment_value
(
block
,
cmnt
);
if
(
value
==
nullptr
)
return
false
;
*
fl
=
(
float
)
atof
(
value
);
return
true
;
}
bool
flac_parse_replay_gain
(
ReplayGainInfo
&
rgi
,
const
FLAC__StreamMetadata
*
block
)
{
const
FLAC__StreamMetadata_VorbisComment
&
vc
=
block
->
data
.
vorbis_comment
;
rgi
.
Clear
();
bool
found
=
false
;
if
(
flac_find_float_comment
(
block
,
"replaygain_album_gain"
,
&
rgi
.
tuples
[
REPLAY_GAIN_ALBUM
].
gain
))
found
=
true
;
if
(
flac_find_float_comment
(
block
,
"replaygain_album_peak"
,
&
rgi
.
tuples
[
REPLAY_GAIN_ALBUM
].
peak
))
found
=
true
;
if
(
flac_find_float_comment
(
block
,
"replaygain_track_gain"
,
&
rgi
.
tuples
[
REPLAY_GAIN_TRACK
].
gain
))
found
=
true
;
if
(
flac_find_float_comment
(
block
,
"replaygain_track_peak"
,
&
rgi
.
tuples
[
REPLAY_GAIN_TRACK
].
peak
))
found
=
true
;
const
auto
*
comments
=
vc
.
comments
;
for
(
FLAC__uint32
i
=
0
,
n
=
vc
.
num_comments
;
i
<
n
;
++
i
)
if
(
ParseReplayGainVorbis
(
rgi
,
(
const
char
*
)
comments
[
i
].
entry
))
found
=
true
;
return
found
;
}
...
...
src/decoder/plugins/VorbisComments.cxx
View file @
441f9cc2
...
...
@@ -24,6 +24,7 @@
#include "tag/TagHandler.hxx"
#include "tag/TagBuilder.hxx"
#include "tag/VorbisComment.hxx"
#include "tag/ReplayGain.hxx"
#include "ReplayGainInfo.hxx"
#include "util/ASCII.hxx"
#include "util/SplitString.hxx"
...
...
@@ -36,27 +37,11 @@ vorbis_comments_to_replay_gain(ReplayGainInfo &rgi, char **comments)
{
rgi
.
Clear
();
const
char
*
temp
;
bool
found
=
false
;
while
(
*
comments
)
{
if
((
temp
=
vorbis_comment_value
(
*
comments
,
"replaygain_track_gain"
)))
{
rgi
.
tuples
[
REPLAY_GAIN_TRACK
].
gain
=
atof
(
temp
);
if
(
ParseReplayGainVorbis
(
rgi
,
*
comments
))
found
=
true
;
}
else
if
((
temp
=
vorbis_comment_value
(
*
comments
,
"replaygain_album_gain"
)))
{
rgi
.
tuples
[
REPLAY_GAIN_ALBUM
].
gain
=
atof
(
temp
);
found
=
true
;
}
else
if
((
temp
=
vorbis_comment_value
(
*
comments
,
"replaygain_track_peak"
)))
{
rgi
.
tuples
[
REPLAY_GAIN_TRACK
].
peak
=
atof
(
temp
);
found
=
true
;
}
else
if
((
temp
=
vorbis_comment_value
(
*
comments
,
"replaygain_album_peak"
)))
{
rgi
.
tuples
[
REPLAY_GAIN_ALBUM
].
peak
=
atof
(
temp
);
found
=
true
;
}
comments
++
;
}
...
...
src/tag/ReplayGain.cxx
View file @
441f9cc2
...
...
@@ -19,6 +19,7 @@
#include "config.h"
#include "ReplayGain.hxx"
#include "VorbisComment.hxx"
#include "ReplayGainInfo.hxx"
#include "util/ASCII.hxx"
...
...
@@ -68,3 +69,18 @@ ParseReplayGainTag(ReplayGainInfo &info, const char *name, const char *value)
return
ParseReplayGainTagTemplate
(
info
,
NameValue
{
name
,
value
});
}
bool
ParseReplayGainVorbis
(
ReplayGainInfo
&
info
,
const
char
*
entry
)
{
struct
VorbisCommentEntry
{
const
char
*
entry
;
gcc_pure
const
char
*
operator
[](
const
char
*
n
)
const
{
return
vorbis_comment_value
(
entry
,
n
);
}
};
return
ParseReplayGainTagTemplate
(
info
,
VorbisCommentEntry
{
entry
});
}
src/tag/ReplayGain.hxx
View file @
441f9cc2
...
...
@@ -27,4 +27,7 @@ struct ReplayGainInfo;
bool
ParseReplayGainTag
(
ReplayGainInfo
&
info
,
const
char
*
name
,
const
char
*
value
);
bool
ParseReplayGainVorbis
(
ReplayGainInfo
&
info
,
const
char
*
entry
);
#endif
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