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
5ddde0aa
Commit
5ddde0aa
authored
Nov 11, 2008
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
replay_gain: converted struct replay_gain_info elements to an array
Having an array instead of individual variables allows the use of the replay_gain_mode enum as an array index.
parent
5e686add
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
47 additions
and
45 deletions
+47
-45
_flac_common.c
src/decoder/_flac_common.c
+4
-4
mp3_plugin.c
src/decoder/mp3_plugin.c
+6
-6
mpc_plugin.c
src/decoder/mpc_plugin.c
+4
-4
oggvorbis_plugin.c
src/decoder/oggvorbis_plugin.c
+4
-4
wavpack_plugin.c
src/decoder/wavpack_plugin.c
+4
-4
replay_gain.c
src/replay_gain.c
+19
-19
replay_gain.h
src/replay_gain.h
+6
-4
No files found.
src/decoder/_flac_common.c
View file @
5ddde0aa
...
...
@@ -75,13 +75,13 @@ static void flacParseReplayGain(const FLAC__StreamMetadata * block,
data
->
replayGainInfo
=
replay_gain_info_new
();
found
|=
flacFindVorbisCommentFloat
(
block
,
"replaygain_album_gain"
,
&
data
->
replayGainInfo
->
album_
gain
);
&
data
->
replayGainInfo
->
tuples
[
REPLAY_GAIN_ALBUM
].
gain
);
found
|=
flacFindVorbisCommentFloat
(
block
,
"replaygain_album_peak"
,
&
data
->
replayGainInfo
->
album_
peak
);
&
data
->
replayGainInfo
->
tuples
[
REPLAY_GAIN_ALBUM
].
peak
);
found
|=
flacFindVorbisCommentFloat
(
block
,
"replaygain_track_gain"
,
&
data
->
replayGainInfo
->
t
rack_
gain
);
&
data
->
replayGainInfo
->
t
uples
[
REPLAY_GAIN_TRACK
].
gain
);
found
|=
flacFindVorbisCommentFloat
(
block
,
"replaygain_track_peak"
,
&
data
->
replayGainInfo
->
t
rack_
peak
);
&
data
->
replayGainInfo
->
t
uples
[
REPLAY_GAIN_TRACK
].
peak
);
if
(
!
found
)
{
replay_gain_info_free
(
data
->
replayGainInfo
);
...
...
src/decoder/mp3_plugin.c
View file @
5ddde0aa
...
...
@@ -228,16 +228,16 @@ parse_id3_replay_gain_info(struct id3_tag *tag)
(
&
frame
->
fields
[
2
]));
if
(
strcasecmp
(
key
,
"replaygain_track_gain"
)
==
0
)
{
replay_gain_info
->
t
rack_
gain
=
atof
(
value
);
replay_gain_info
->
t
uples
[
REPLAY_GAIN_TRACK
].
gain
=
atof
(
value
);
found
=
true
;
}
else
if
(
strcasecmp
(
key
,
"replaygain_album_gain"
)
==
0
)
{
replay_gain_info
->
album_
gain
=
atof
(
value
);
replay_gain_info
->
tuples
[
REPLAY_GAIN_ALBUM
].
gain
=
atof
(
value
);
found
=
true
;
}
else
if
(
strcasecmp
(
key
,
"replaygain_track_peak"
)
==
0
)
{
replay_gain_info
->
t
rack_
peak
=
atof
(
value
);
replay_gain_info
->
t
uples
[
REPLAY_GAIN_TRACK
].
peak
=
atof
(
value
);
found
=
true
;
}
else
if
(
strcasecmp
(
key
,
"replaygain_album_peak"
)
==
0
)
{
replay_gain_info
->
album_
peak
=
atof
(
value
);
replay_gain_info
->
tuples
[
REPLAY_GAIN_ALBUM
].
peak
=
atof
(
value
);
found
=
true
;
}
...
...
@@ -761,8 +761,8 @@ mp3_decode_first_frame(struct mp3_data *data, struct tag **tag,
if
(
replay_gain_info_r
&&
!*
replay_gain_info_r
&&
lame
.
track_gain
)
{
*
replay_gain_info_r
=
replay_gain_info_new
();
(
*
replay_gain_info_r
)
->
t
rack_
gain
=
lame
.
track_gain
;
(
*
replay_gain_info_r
)
->
t
rack_
peak
=
lame
.
peak
;
(
*
replay_gain_info_r
)
->
t
uples
[
REPLAY_GAIN_TRACK
].
gain
=
lame
.
track_gain
;
(
*
replay_gain_info_r
)
->
t
uples
[
REPLAY_GAIN_TRACK
].
peak
=
lame
.
peak
;
}
}
}
...
...
src/decoder/mpc_plugin.c
View file @
5ddde0aa
...
...
@@ -157,10 +157,10 @@ mpc_decode(struct decoder *mpd_decoder, struct input_stream *inStream)
audio_format
.
sample_rate
=
info
.
sample_freq
;
replayGainInfo
=
replay_gain_info_new
();
replayGainInfo
->
album_
gain
=
info
.
gain_album
*
0
.
01
;
replayGainInfo
->
album_
peak
=
info
.
peak_album
/
32767
.
0
;
replayGainInfo
->
t
rack_
gain
=
info
.
gain_title
*
0
.
01
;
replayGainInfo
->
t
rack_
peak
=
info
.
peak_title
/
32767
.
0
;
replayGainInfo
->
tuples
[
REPLAY_GAIN_ALBUM
].
gain
=
info
.
gain_album
*
0
.
01
;
replayGainInfo
->
tuples
[
REPLAY_GAIN_ALBUM
].
peak
=
info
.
peak_album
/
32767
.
0
;
replayGainInfo
->
t
uples
[
REPLAY_GAIN_TRACK
].
gain
=
info
.
gain_title
*
0
.
01
;
replayGainInfo
->
t
uples
[
REPLAY_GAIN_TRACK
].
peak
=
info
.
peak_title
/
32767
.
0
;
decoder_initialized
(
mpd_decoder
,
&
audio_format
,
inStream
->
seekable
,
...
...
src/decoder/oggvorbis_plugin.c
View file @
5ddde0aa
...
...
@@ -105,19 +105,19 @@ ogg_getReplayGainInfo(char **comments)
while
(
*
comments
)
{
if
((
temp
=
ogg_parseComment
(
*
comments
,
"replaygain_track_gain"
)))
{
rgi
->
t
rack_
gain
=
atof
(
temp
);
rgi
->
t
uples
[
REPLAY_GAIN_TRACK
].
gain
=
atof
(
temp
);
found
=
true
;
}
else
if
((
temp
=
ogg_parseComment
(
*
comments
,
"replaygain_album_gain"
)))
{
rgi
->
album_
gain
=
atof
(
temp
);
rgi
->
tuples
[
REPLAY_GAIN_ALBUM
].
gain
=
atof
(
temp
);
found
=
true
;
}
else
if
((
temp
=
ogg_parseComment
(
*
comments
,
"replaygain_track_peak"
)))
{
rgi
->
t
rack_
peak
=
atof
(
temp
);
rgi
->
t
uples
[
REPLAY_GAIN_TRACK
].
peak
=
atof
(
temp
);
found
=
true
;
}
else
if
((
temp
=
ogg_parseComment
(
*
comments
,
"replaygain_album_peak"
)))
{
rgi
->
album_
peak
=
atof
(
temp
);
rgi
->
tuples
[
REPLAY_GAIN_ALBUM
].
peak
=
atof
(
temp
);
found
=
true
;
}
...
...
src/decoder/wavpack_plugin.c
View file @
5ddde0aa
...
...
@@ -240,16 +240,16 @@ wavpack_replaygain(WavpackContext *wpc)
replay_gain_info
=
replay_gain_info_new
();
found
=
wavpack_tag_float
(
wpc
,
"replaygain_track_gain"
,
&
replay_gain_info
->
t
rack_
gain
)
&
replay_gain_info
->
t
uples
[
REPLAY_GAIN_TRACK
].
gain
)
||
wavpack_tag_float
(
wpc
,
"replaygain_track_peak"
,
&
replay_gain_info
->
t
rack_
peak
)
&
replay_gain_info
->
t
uples
[
REPLAY_GAIN_TRACK
].
peak
)
||
wavpack_tag_float
(
wpc
,
"replaygain_album_gain"
,
&
replay_gain_info
->
album_
gain
)
&
replay_gain_info
->
tuples
[
REPLAY_GAIN_ALBUM
].
gain
)
||
wavpack_tag_float
(
wpc
,
"replaygain_album_peak"
,
&
replay_gain_info
->
album_
peak
);
&
replay_gain_info
->
tuples
[
REPLAY_GAIN_ALBUM
].
peak
);
if
(
found
)
{
return
replay_gain_info
;
...
...
src/replay_gain.c
View file @
5ddde0aa
...
...
@@ -25,6 +25,13 @@
#include "audio_format.h"
#include "os_compat.h"
#include <glib.h>
static
const
char
*
const
replay_gain_mode_names
[]
=
{
[
REPLAY_GAIN_ALBUM
]
=
"album"
,
[
REPLAY_GAIN_TRACK
]
=
"track"
,
};
enum
replay_gain_mode
replay_gain_mode
=
REPLAY_GAIN_OFF
;
static
float
replay_gain_preamp
=
1
.
0
;
...
...
@@ -86,11 +93,10 @@ struct replay_gain_info *replay_gain_info_new(void)
{
struct
replay_gain_info
*
ret
=
xmalloc
(
sizeof
(
*
ret
));
ret
->
album_gain
=
0
.
0
;
ret
->
album_peak
=
0
.
0
;
ret
->
track_gain
=
0
.
0
;
ret
->
track_peak
=
0
.
0
;
for
(
unsigned
i
=
0
;
i
<
G_N_ELEMENTS
(
ret
->
tuples
);
++
i
)
{
ret
->
tuples
[
i
].
gain
=
0
.
0
;
ret
->
tuples
[
i
].
peak
=
0
.
0
;
}
/* set to -1 so that we know in replay_gain_apply to compute the scale */
ret
->
scale
=
-
1
.
0
;
...
...
@@ -116,20 +122,14 @@ replay_gain_apply(struct replay_gain_info *info, char *buffer, int size,
return
;
if
(
info
->
scale
<
0
)
{
switch
(
replay_gain_mode
)
{
case
REPLAY_GAIN_TRACK
:
DEBUG
(
"computing ReplayGain track scale with gain %f, "
"peak %f
\n
"
,
info
->
track_gain
,
info
->
track_peak
);
info
->
scale
=
calc_replay_gain_scale
(
info
->
track_gain
,
info
->
track_peak
);
break
;
default:
DEBUG
(
"computing ReplayGain album scale with gain %f, "
"peak %f
\n
"
,
info
->
album_gain
,
info
->
album_peak
);
info
->
scale
=
calc_replay_gain_scale
(
info
->
album_gain
,
info
->
album_peak
);
break
;
}
const
struct
replay_gain_tuple
*
tuple
=
&
info
->
tuples
[
replay_gain_mode
];
DEBUG
(
"computing ReplayGain %s scale with gain %f, peak %f
\n
"
,
replay_gain_mode_names
[
replay_gain_mode
],
tuple
->
gain
,
tuple
->
peak
);
info
->
scale
=
calc_replay_gain_scale
(
tuple
->
gain
,
tuple
->
peak
);
}
if
(
info
->
scale
<=
1
.
01
&&
info
->
scale
>=
0
.
99
)
...
...
src/replay_gain.h
View file @
5ddde0aa
...
...
@@ -30,11 +30,13 @@ struct audio_format;
extern
enum
replay_gain_mode
replay_gain_mode
;
struct
replay_gain_tuple
{
float
gain
;
float
peak
;
};
struct
replay_gain_info
{
float
album_gain
;
float
album_peak
;
float
track_gain
;
float
track_peak
;
struct
replay_gain_tuple
tuples
[
2
];
/* used internally by mpd, to mess with it */
float
scale
;
...
...
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