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
114b3c1e
Commit
114b3c1e
authored
Nov 11, 2008
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
replay_gain: no CamelCase
Renamed functions and variables.
parent
54ad08ab
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
119 additions
and
111 deletions
+119
-111
_flac_common.c
src/decoder/_flac_common.c
+7
-7
_flac_common.h
src/decoder/_flac_common.h
+1
-1
flac_plugin.c
src/decoder/flac_plugin.c
+1
-1
mp3_plugin.c
src/decoder/mp3_plugin.c
+25
-22
mpc_plugin.c
src/decoder/mpc_plugin.c
+7
-7
oggflac_plugin.c
src/decoder/oggflac_plugin.c
+1
-1
oggvorbis_plugin.c
src/decoder/oggvorbis_plugin.c
+12
-10
wavpack_plugin.c
src/decoder/wavpack_plugin.c
+11
-11
decoder_api.c
src/decoder_api.c
+3
-3
decoder_api.h
src/decoder_api.h
+1
-1
main.c
src/main.c
+1
-1
replay_gain.c
src/replay_gain.c
+31
-30
replay_gain.h
src/replay_gain.h
+18
-16
No files found.
src/decoder/_flac_common.c
View file @
114b3c1e
...
...
@@ -70,21 +70,21 @@ static void flacParseReplayGain(const FLAC__StreamMetadata * block,
int
found
=
0
;
if
(
data
->
replayGainInfo
)
freeReplayGainInfo
(
data
->
replayGainInfo
);
replay_gain_info_free
(
data
->
replayGainInfo
);
data
->
replayGainInfo
=
newReplayGainInfo
();
data
->
replayGainInfo
=
replay_gain_info_new
();
found
|=
flacFindVorbisCommentFloat
(
block
,
"replaygain_album_gain"
,
&
data
->
replayGainInfo
->
album
G
ain
);
&
data
->
replayGainInfo
->
album
_g
ain
);
found
|=
flacFindVorbisCommentFloat
(
block
,
"replaygain_album_peak"
,
&
data
->
replayGainInfo
->
album
P
eak
);
&
data
->
replayGainInfo
->
album
_p
eak
);
found
|=
flacFindVorbisCommentFloat
(
block
,
"replaygain_track_gain"
,
&
data
->
replayGainInfo
->
track
G
ain
);
&
data
->
replayGainInfo
->
track
_g
ain
);
found
|=
flacFindVorbisCommentFloat
(
block
,
"replaygain_track_peak"
,
&
data
->
replayGainInfo
->
track
P
eak
);
&
data
->
replayGainInfo
->
track
_p
eak
);
if
(
!
found
)
{
freeReplayGainInfo
(
data
->
replayGainInfo
);
replay_gain_info_free
(
data
->
replayGainInfo
);
data
->
replayGainInfo
=
NULL
;
}
}
...
...
src/decoder/_flac_common.h
View file @
114b3c1e
...
...
@@ -145,7 +145,7 @@ typedef struct {
FLAC__uint64
position
;
struct
decoder
*
decoder
;
struct
input_stream
*
inStream
;
ReplayGainI
nfo
*
replayGainInfo
;
struct
replay_gain_i
nfo
*
replayGainInfo
;
struct
tag
*
tag
;
}
FlacData
;
...
...
src/decoder/flac_plugin.c
View file @
114b3c1e
...
...
@@ -368,7 +368,7 @@ flac_decode_internal(struct decoder * decoder, struct input_stream *inStream,
fail:
if
(
data
.
replayGainInfo
)
freeReplayGainInfo
(
data
.
replayGainInfo
);
replay_gain_info_free
(
data
.
replayGainInfo
);
if
(
flacDec
)
flac_delete
(
flacDec
);
...
...
src/decoder/mp3_plugin.c
View file @
114b3c1e
...
...
@@ -204,16 +204,17 @@ mp3_fill_buffer(struct mp3_data *data)
}
#ifdef HAVE_ID3TAG
static
ReplayGainInfo
*
parse_id3_replay_gain_info
(
struct
id3_tag
*
tag
)
static
struct
replay_gain_info
*
parse_id3_replay_gain_info
(
struct
id3_tag
*
tag
)
{
int
i
;
char
*
key
;
char
*
value
;
struct
id3_frame
*
frame
;
bool
found
=
false
;
ReplayGainI
nfo
*
replay_gain_info
;
struct
replay_gain_i
nfo
*
replay_gain_info
;
replay_gain_info
=
newReplayGainInfo
();
replay_gain_info
=
replay_gain_info_new
();
for
(
i
=
0
;
(
frame
=
id3_tag_findframe
(
tag
,
"TXXX"
,
i
));
i
++
)
{
if
(
frame
->
nfields
<
3
)
...
...
@@ -227,16 +228,16 @@ static ReplayGainInfo *parse_id3_replay_gain_info(struct id3_tag *tag)
(
&
frame
->
fields
[
2
]));
if
(
strcasecmp
(
key
,
"replaygain_track_gain"
)
==
0
)
{
replay_gain_info
->
track
G
ain
=
atof
(
value
);
replay_gain_info
->
track
_g
ain
=
atof
(
value
);
found
=
true
;
}
else
if
(
strcasecmp
(
key
,
"replaygain_album_gain"
)
==
0
)
{
replay_gain_info
->
album
G
ain
=
atof
(
value
);
replay_gain_info
->
album
_g
ain
=
atof
(
value
);
found
=
true
;
}
else
if
(
strcasecmp
(
key
,
"replaygain_track_peak"
)
==
0
)
{
replay_gain_info
->
track
P
eak
=
atof
(
value
);
replay_gain_info
->
track
_p
eak
=
atof
(
value
);
found
=
true
;
}
else
if
(
strcasecmp
(
key
,
"replaygain_album_peak"
)
==
0
)
{
replay_gain_info
->
album
P
eak
=
atof
(
value
);
replay_gain_info
->
album
_p
eak
=
atof
(
value
);
found
=
true
;
}
...
...
@@ -246,7 +247,7 @@ static ReplayGainInfo *parse_id3_replay_gain_info(struct id3_tag *tag)
if
(
found
)
return
replay_gain_info
;
freeReplayGainInfo
(
replay_gain_info
);
replay_gain_info_free
(
replay_gain_info
);
return
NULL
;
}
#endif
...
...
@@ -254,7 +255,7 @@ static ReplayGainInfo *parse_id3_replay_gain_info(struct id3_tag *tag)
#ifdef HAVE_ID3TAG
static
void
mp3_parse_id3
(
struct
mp3_data
*
data
,
size_t
tagsize
,
struct
tag
**
mpd_tag
,
ReplayGainI
nfo
**
replay_gain_info_r
)
struct
replay_gain_i
nfo
**
replay_gain_info_r
)
{
struct
id3_tag
*
id3_tag
=
NULL
;
id3_length_t
count
;
...
...
@@ -307,10 +308,11 @@ static void mp3_parse_id3(struct mp3_data *data, size_t tagsize,
}
if
(
replay_gain_info_r
)
{
ReplayGainInfo
*
tmp_rgi
=
parse_id3_replay_gain_info
(
id3_tag
);
struct
replay_gain_info
*
tmp_rgi
=
parse_id3_replay_gain_info
(
id3_tag
);
if
(
tmp_rgi
!=
NULL
)
{
if
(
*
replay_gain_info_r
)
freeReplayGainInfo
(
*
replay_gain_info_r
);
replay_gain_info_free
(
*
replay_gain_info_r
);
*
replay_gain_info_r
=
tmp_rgi
;
}
}
...
...
@@ -323,7 +325,7 @@ static void mp3_parse_id3(struct mp3_data *data, size_t tagsize,
static
enum
mp3_action
decode_next_frame_header
(
struct
mp3_data
*
data
,
struct
tag
**
tag
,
ReplayGainI
nfo
**
replay_gain_info_r
)
struct
replay_gain_i
nfo
**
replay_gain_info_r
)
{
enum
mad_layer
layer
;
...
...
@@ -698,7 +700,7 @@ mp3_filesize_to_song_length(struct mp3_data *data)
static
bool
mp3_decode_first_frame
(
struct
mp3_data
*
data
,
struct
tag
**
tag
,
ReplayGainI
nfo
**
replay_gain_info_r
)
struct
replay_gain_i
nfo
**
replay_gain_info_r
)
{
struct
decoder
*
decoder
=
data
->
decoder
;
struct
xing
xing
;
...
...
@@ -758,9 +760,9 @@ mp3_decode_first_frame(struct mp3_data *data, struct tag **tag,
* parse_lame() for details. -- jat */
if
(
replay_gain_info_r
&&
!*
replay_gain_info_r
&&
lame
.
track_gain
)
{
*
replay_gain_info_r
=
newReplayGainInfo
();
(
*
replay_gain_info_r
)
->
track
G
ain
=
lame
.
track_gain
;
(
*
replay_gain_info_r
)
->
track
P
eak
=
lame
.
peak
;
*
replay_gain_info_r
=
replay_gain_info_new
();
(
*
replay_gain_info_r
)
->
track
_g
ain
=
lame
.
track_gain
;
(
*
replay_gain_info_r
)
->
track
_p
eak
=
lame
.
peak
;
}
}
}
...
...
@@ -813,7 +815,7 @@ static int mp3_total_file_time(const char *file)
static
bool
mp3_open
(
struct
input_stream
*
is
,
struct
mp3_data
*
data
,
struct
decoder
*
decoder
,
struct
tag
**
tag
,
ReplayGainI
nfo
**
replay_gain_info_r
)
struct
replay_gain_i
nfo
**
replay_gain_info_r
)
{
mp3_data_init
(
data
,
decoder
,
is
);
*
tag
=
NULL
;
...
...
@@ -877,7 +879,7 @@ mp3_update_timer_next_frame(struct mp3_data *data)
*/
static
enum
decoder_command
mp3_send_pcm
(
struct
mp3_data
*
data
,
unsigned
i
,
unsigned
pcm_length
,
ReplayGainI
nfo
*
replay_gain_info
)
struct
replay_gain_i
nfo
*
replay_gain_info
)
{
unsigned
max_samples
;
...
...
@@ -916,7 +918,8 @@ mp3_send_pcm(struct mp3_data *data, unsigned i, unsigned pcm_length,
* Synthesize the current frame and send it via decoder_data().
*/
static
enum
decoder_command
mp3_synth_and_send
(
struct
mp3_data
*
data
,
ReplayGainInfo
*
replay_gain_info
)
mp3_synth_and_send
(
struct
mp3_data
*
data
,
struct
replay_gain_info
*
replay_gain_info
)
{
unsigned
i
,
pcm_length
;
enum
decoder_command
cmd
;
...
...
@@ -971,7 +974,7 @@ mp3_synth_and_send(struct mp3_data *data, ReplayGainInfo *replay_gain_info)
}
static
bool
mp3_read
(
struct
mp3_data
*
data
,
ReplayGainI
nfo
**
replay_gain_info_r
)
mp3_read
(
struct
mp3_data
*
data
,
struct
replay_gain_i
nfo
**
replay_gain_info_r
)
{
struct
decoder
*
decoder
=
data
->
decoder
;
int
ret
;
...
...
@@ -1052,7 +1055,7 @@ mp3_decode(struct decoder *decoder, struct input_stream *input_stream)
{
struct
mp3_data
data
;
struct
tag
*
tag
=
NULL
;
ReplayGainI
nfo
*
replay_gain_info
=
NULL
;
struct
replay_gain_i
nfo
*
replay_gain_info
=
NULL
;
struct
audio_format
audio_format
;
if
(
!
mp3_open
(
input_stream
,
&
data
,
decoder
,
&
tag
,
&
replay_gain_info
))
{
...
...
@@ -1077,7 +1080,7 @@ mp3_decode(struct decoder *decoder, struct input_stream *input_stream)
while
(
mp3_read
(
&
data
,
&
replay_gain_info
))
;
if
(
replay_gain_info
)
freeReplayGainInfo
(
replay_gain_info
);
replay_gain_info_free
(
replay_gain_info
);
if
(
decoder_get_command
(
decoder
)
==
DECODE_COMMAND_SEEK
&&
data
.
mute_frame
==
MUTEFRAME_SEEK
)
...
...
src/decoder/mpc_plugin.c
View file @
114b3c1e
...
...
@@ -120,7 +120,7 @@ mpc_decode(struct decoder *mpd_decoder, struct input_stream *inStream)
mpc_uint32_t
vbrUpdateBits
;
float
total_time
;
int
i
;
ReplayGainI
nfo
*
replayGainInfo
=
NULL
;
struct
replay_gain_i
nfo
*
replayGainInfo
=
NULL
;
data
.
inStream
=
inStream
;
data
.
decoder
=
mpd_decoder
;
...
...
@@ -156,11 +156,11 @@ mpc_decode(struct decoder *mpd_decoder, struct input_stream *inStream)
audio_format
.
channels
=
info
.
channels
;
audio_format
.
sample_rate
=
info
.
sample_freq
;
replayGainInfo
=
newReplayGainInfo
();
replayGainInfo
->
album
G
ain
=
info
.
gain_album
*
0
.
01
;
replayGainInfo
->
album
P
eak
=
info
.
peak_album
/
32767
.
0
;
replayGainInfo
->
track
G
ain
=
info
.
gain_title
*
0
.
01
;
replayGainInfo
->
track
P
eak
=
info
.
peak_title
/
32767
.
0
;
replayGainInfo
=
replay_gain_info_new
();
replayGainInfo
->
album
_g
ain
=
info
.
gain_album
*
0
.
01
;
replayGainInfo
->
album
_p
eak
=
info
.
peak_album
/
32767
.
0
;
replayGainInfo
->
track
_g
ain
=
info
.
gain_title
*
0
.
01
;
replayGainInfo
->
track
_p
eak
=
info
.
peak_title
/
32767
.
0
;
decoder_initialized
(
mpd_decoder
,
&
audio_format
,
inStream
->
seekable
,
...
...
@@ -231,7 +231,7 @@ mpc_decode(struct decoder *mpd_decoder, struct input_stream *inStream)
replayGainInfo
);
}
freeReplayGainInfo
(
replayGainInfo
);
replay_gain_info_free
(
replayGainInfo
);
return
true
;
}
...
...
src/decoder/oggflac_plugin.c
View file @
114b3c1e
...
...
@@ -31,7 +31,7 @@ static void oggflac_cleanup(FlacData * data,
OggFLAC__SeekableStreamDecoder
*
decoder
)
{
if
(
data
->
replayGainInfo
)
freeReplayGainInfo
(
data
->
replayGainInfo
);
replay_gain_info_free
(
data
->
replayGainInfo
);
if
(
decoder
)
OggFLAC__seekable_stream_decoder_delete
(
decoder
);
}
...
...
src/decoder/oggvorbis_plugin.c
View file @
114b3c1e
...
...
@@ -93,31 +93,33 @@ static const char *ogg_parseComment(const char *comment, const char *needle)
return
NULL
;
}
static
void
ogg_getReplayGainInfo
(
char
**
comments
,
ReplayGainInfo
**
infoPtr
)
static
void
ogg_getReplayGainInfo
(
char
**
comments
,
struct
replay_gain_info
**
infoPtr
)
{
const
char
*
temp
;
bool
found
=
false
;
if
(
*
infoPtr
)
freeReplayGainInfo
(
*
infoPtr
);
*
infoPtr
=
newReplayGainInfo
();
replay_gain_info_free
(
*
infoPtr
);
*
infoPtr
=
replay_gain_info_new
();
while
(
*
comments
)
{
if
((
temp
=
ogg_parseComment
(
*
comments
,
"replaygain_track_gain"
)))
{
(
*
infoPtr
)
->
track
G
ain
=
atof
(
temp
);
(
*
infoPtr
)
->
track
_g
ain
=
atof
(
temp
);
found
=
true
;
}
else
if
((
temp
=
ogg_parseComment
(
*
comments
,
"replaygain_album_gain"
)))
{
(
*
infoPtr
)
->
album
G
ain
=
atof
(
temp
);
(
*
infoPtr
)
->
album
_g
ain
=
atof
(
temp
);
found
=
true
;
}
else
if
((
temp
=
ogg_parseComment
(
*
comments
,
"replaygain_track_peak"
)))
{
(
*
infoPtr
)
->
track
P
eak
=
atof
(
temp
);
(
*
infoPtr
)
->
track
_p
eak
=
atof
(
temp
);
found
=
true
;
}
else
if
((
temp
=
ogg_parseComment
(
*
comments
,
"replaygain_album_peak"
)))
{
(
*
infoPtr
)
->
album
P
eak
=
atof
(
temp
);
(
*
infoPtr
)
->
album
_p
eak
=
atof
(
temp
);
found
=
true
;
}
...
...
@@ -125,7 +127,7 @@ static void ogg_getReplayGainInfo(char **comments, ReplayGainInfo ** infoPtr)
}
if
(
!
found
)
{
freeReplayGainInfo
(
*
infoPtr
);
replay_gain_info_free
(
*
infoPtr
);
*
infoPtr
=
NULL
;
}
}
...
...
@@ -209,7 +211,7 @@ oggvorbis_decode(struct decoder *decoder, struct input_stream *inStream)
int
chunkpos
=
0
;
long
bitRate
=
0
;
long
test
;
ReplayGainI
nfo
*
replayGainInfo
=
NULL
;
struct
replay_gain_i
nfo
*
replayGainInfo
=
NULL
;
char
**
comments
;
const
char
*
errorStr
;
bool
initialized
=
false
;
...
...
@@ -324,7 +326,7 @@ oggvorbis_decode(struct decoder *decoder, struct input_stream *inStream)
}
if
(
replayGainInfo
)
freeReplayGainInfo
(
replayGainInfo
);
replay_gain_info_free
(
replayGainInfo
);
ov_clear
(
&
vf
);
return
true
;
...
...
src/decoder/wavpack_plugin.c
View file @
114b3c1e
...
...
@@ -121,7 +121,7 @@ format_samples_float(mpd_unused int bytes_per_sample, void *buffer,
*/
static
void
wavpack_decode
(
struct
decoder
*
decoder
,
WavpackContext
*
wpc
,
bool
canseek
,
ReplayGainI
nfo
*
replayGainInfo
)
struct
replay_gain_i
nfo
*
replayGainInfo
)
{
struct
audio_format
audio_format
;
void
(
*
format_samples
)(
int
bytes_per_sample
,
...
...
@@ -229,43 +229,43 @@ wavpack_tag(WavpackContext *wpc, char *key)
return
value
;
}
static
ReplayGainI
nfo
*
static
struct
replay_gain_i
nfo
*
wavpack_replaygain
(
WavpackContext
*
wpc
)
{
static
char
replaygain_track_gain
[]
=
"replaygain_track_gain"
;
static
char
replaygain_album_gain
[]
=
"replaygain_album_gain"
;
static
char
replaygain_track_peak
[]
=
"replaygain_track_peak"
;
static
char
replaygain_album_peak
[]
=
"replaygain_album_peak"
;
ReplayGainI
nfo
*
replay_gain_info
;
struct
replay_gain_i
nfo
*
replay_gain_info
;
bool
found
=
false
;
char
*
value
;
replay_gain_info
=
newReplayGainInfo
();
replay_gain_info
=
replay_gain_info_new
();
value
=
wavpack_tag
(
wpc
,
replaygain_track_gain
);
if
(
value
)
{
replay_gain_info
->
track
G
ain
=
atof
(
value
);
replay_gain_info
->
track
_g
ain
=
atof
(
value
);
free
(
value
);
found
=
true
;
}
value
=
wavpack_tag
(
wpc
,
replaygain_album_gain
);
if
(
value
)
{
replay_gain_info
->
album
G
ain
=
atof
(
value
);
replay_gain_info
->
album
_g
ain
=
atof
(
value
);
free
(
value
);
found
=
true
;
}
value
=
wavpack_tag
(
wpc
,
replaygain_track_peak
);
if
(
value
)
{
replay_gain_info
->
track
P
eak
=
atof
(
value
);
replay_gain_info
->
track
_p
eak
=
atof
(
value
);
free
(
value
);
found
=
true
;
}
value
=
wavpack_tag
(
wpc
,
replaygain_album_peak
);
if
(
value
)
{
replay_gain_info
->
album
P
eak
=
atof
(
value
);
replay_gain_info
->
album
_p
eak
=
atof
(
value
);
free
(
value
);
found
=
true
;
}
...
...
@@ -275,7 +275,7 @@ wavpack_replaygain(WavpackContext *wpc)
return
replay_gain_info
;
}
freeReplayGainInfo
(
replay_gain_info
);
replay_gain_info_free
(
replay_gain_info
);
return
NULL
;
}
...
...
@@ -537,7 +537,7 @@ wavpack_filedecode(struct decoder *decoder, const char *fname)
{
char
error
[
ERRORLEN
];
WavpackContext
*
wpc
;
ReplayGainI
nfo
*
replay_gain_info
;
struct
replay_gain_i
nfo
*
replay_gain_info
;
wpc
=
WavpackOpenFileInput
(
fname
,
error
,
OPEN_TAGS
|
OPEN_WVC
|
...
...
@@ -553,7 +553,7 @@ wavpack_filedecode(struct decoder *decoder, const char *fname)
wavpack_decode
(
decoder
,
wpc
,
true
,
replay_gain_info
);
if
(
replay_gain_info
)
{
freeReplayGainInfo
(
replay_gain_info
);
replay_gain_info_free
(
replay_gain_info
);
}
WavpackCloseFile
(
wpc
);
...
...
src/decoder_api.c
View file @
114b3c1e
...
...
@@ -175,7 +175,7 @@ decoder_data(struct decoder *decoder,
struct
input_stream
*
is
,
void
*
_data
,
size_t
length
,
float
data_time
,
uint16_t
bitRate
,
ReplayGainI
nfo
*
replay_gain_info
)
struct
replay_gain_i
nfo
*
replay_gain_info
)
{
static
char
*
conv_buffer
;
static
size_t
conv_buffer_size
;
...
...
@@ -234,8 +234,8 @@ decoder_data(struct decoder *decoder,
data
,
&
decoder
->
conv_state
);
}
if
(
replay_gain_info
!=
NULL
&&
(
replay
GainState
!=
REPLAY
GAIN_OFF
))
doReplayGain
(
replay_gain_info
,
data
,
length
,
if
(
replay_gain_info
!=
NULL
&&
(
replay
_gain_mode
!=
REPLAY_
GAIN_OFF
))
replay_gain_apply
(
replay_gain_info
,
data
,
length
,
&
dc
.
out_audio_format
);
else
if
(
normalizationEnabled
)
normalizeData
(
data
,
length
,
&
dc
.
out_audio_format
);
...
...
src/decoder_api.h
View file @
114b3c1e
...
...
@@ -143,7 +143,7 @@ enum decoder_command
decoder_data
(
struct
decoder
*
decoder
,
struct
input_stream
*
inStream
,
void
*
data
,
size_t
datalen
,
float
data_time
,
uint16_t
bitRate
,
ReplayGainInfo
*
replayGainI
nfo
);
struct
replay_gain_info
*
replay_gain_i
nfo
);
/**
* This function is called by the decoder plugin when it has
...
...
src/main.c
View file @
114b3c1e
...
...
@@ -429,7 +429,7 @@ int main(int argc, char *argv[])
initAudioDriver
();
initVolume
();
client_manager_init
();
initReplayGainState
();
replay_gain_global_init
();
initNormalization
();
input_stream_global_init
();
...
...
src/replay_gain.c
View file @
114b3c1e
...
...
@@ -26,11 +26,11 @@
#include "os_compat.h"
/* Added 4/14/2004 by AliasMrJones */
int
replay
GainState
=
REPLAY
GAIN_OFF
;
int
replay
_gain_mode
=
REPLAY_
GAIN_OFF
;
static
float
replay
GainP
reamp
=
1
.
0
;
static
float
replay
_gain_p
reamp
=
1
.
0
;
void
initReplayGainState
(
void
)
void
replay_gain_global_init
(
void
)
{
ConfigParam
*
param
=
getConfigParam
(
CONF_REPLAYGAIN
);
...
...
@@ -38,9 +38,9 @@ void initReplayGainState(void)
return
;
if
(
strcmp
(
param
->
value
,
"track"
)
==
0
)
{
replay
GainState
=
REPLAY
GAIN_TRACK
;
replay
_gain_mode
=
REPLAY_
GAIN_TRACK
;
}
else
if
(
strcmp
(
param
->
value
,
"album"
)
==
0
)
{
replay
GainState
=
REPLAY
GAIN_ALBUM
;
replay
_gain_mode
=
REPLAY_
GAIN_ALBUM
;
}
else
{
FATAL
(
"replaygain value
\"
%s
\"
at line %i is invalid
\n
"
,
param
->
value
,
param
->
line
);
...
...
@@ -62,18 +62,18 @@ void initReplayGainState(void)
"15 at line %i
\n
"
,
param
->
value
,
param
->
line
);
}
replay
GainP
reamp
=
pow
(
10
,
f
/
20
.
0
);
replay
_gain_p
reamp
=
pow
(
10
,
f
/
20
.
0
);
}
}
static
float
c
omputeReplayGainS
cale
(
float
gain
,
float
peak
)
static
float
c
alc_replay_gain_s
cale
(
float
gain
,
float
peak
)
{
float
scale
;
if
(
gain
==
0
.
0
)
return
(
1
);
scale
=
pow
(
10
.
0
,
gain
/
20
.
0
);
scale
*=
replay
GainP
reamp
;
scale
*=
replay
_gain_p
reamp
;
if
(
scale
>
15
.
0
)
scale
=
15
.
0
;
...
...
@@ -83,28 +83,29 @@ static float computeReplayGainScale(float gain, float peak)
return
(
scale
);
}
ReplayGainInfo
*
newReplayGainInfo
(
void
)
struct
replay_gain_info
*
replay_gain_info_new
(
void
)
{
ReplayGainInfo
*
ret
=
xmalloc
(
sizeof
(
ReplayGainInfo
));
struct
replay_gain_info
*
ret
=
xmalloc
(
sizeof
(
*
ret
));
ret
->
album
G
ain
=
0
.
0
;
ret
->
album
P
eak
=
0
.
0
;
ret
->
album
_g
ain
=
0
.
0
;
ret
->
album
_p
eak
=
0
.
0
;
ret
->
track
G
ain
=
0
.
0
;
ret
->
track
P
eak
=
0
.
0
;
ret
->
track
_g
ain
=
0
.
0
;
ret
->
track
_p
eak
=
0
.
0
;
/* set to -1 so that we know in
doReplayGain
to compute the scale */
/* set to -1 so that we know in
replay_gain_apply
to compute the scale */
ret
->
scale
=
-
1
.
0
;
return
ret
;
}
void
freeReplayGainInfo
(
ReplayGainInfo
*
info
)
void
replay_gain_info_free
(
struct
replay_gain_info
*
info
)
{
free
(
info
);
}
void
doReplayGain
(
ReplayGainInfo
*
info
,
char
*
buffer
,
int
bufferSize
,
void
replay_gain_apply
(
struct
replay_gain_info
*
info
,
char
*
buffer
,
int
size
,
const
struct
audio_format
*
format
)
{
int16_t
*
buffer16
;
...
...
@@ -112,22 +113,22 @@ void doReplayGain(ReplayGainInfo * info, char *buffer, int bufferSize,
int32_t
temp32
;
float
scale
;
if
(
replay
GainState
==
REPLAY
GAIN_OFF
||
!
info
)
if
(
replay
_gain_mode
==
REPLAY_
GAIN_OFF
||
!
info
)
return
;
if
(
info
->
scale
<
0
)
{
switch
(
replay
GainStat
e
)
{
case
REPLAYGAIN_TRACK
:
switch
(
replay
_gain_mod
e
)
{
case
REPLAY
_
GAIN_TRACK
:
DEBUG
(
"computing ReplayGain track scale with gain %f, "
"peak %f
\n
"
,
info
->
track
Gain
,
info
->
trackP
eak
);
info
->
scale
=
c
omputeReplayGainScale
(
info
->
trackG
ain
,
info
->
track
P
eak
);
"peak %f
\n
"
,
info
->
track
_gain
,
info
->
track_p
eak
);
info
->
scale
=
c
alc_replay_gain_scale
(
info
->
track_g
ain
,
info
->
track
_p
eak
);
break
;
default:
DEBUG
(
"computing ReplayGain album scale with gain %f, "
"peak %f
\n
"
,
info
->
album
Gain
,
info
->
albumP
eak
);
info
->
scale
=
c
omputeReplayGainScale
(
info
->
albumG
ain
,
info
->
album
P
eak
);
"peak %f
\n
"
,
info
->
album
_gain
,
info
->
album_p
eak
);
info
->
scale
=
c
alc_replay_gain_scale
(
info
->
album_g
ain
,
info
->
album
_p
eak
);
break
;
}
}
...
...
@@ -142,23 +143,23 @@ void doReplayGain(ReplayGainInfo * info, char *buffer, int bufferSize,
switch
(
format
->
bits
)
{
case
16
:
while
(
bufferS
ize
>
0
)
{
while
(
s
ize
>
0
)
{
temp32
=
*
buffer16
;
temp32
*=
scale
;
*
buffer16
=
temp32
>
32767
?
32767
:
(
temp32
<
-
32768
?
-
32768
:
temp32
);
buffer16
++
;
bufferS
ize
-=
2
;
s
ize
-=
2
;
}
break
;
case
8
:
while
(
bufferS
ize
>
0
)
{
while
(
s
ize
>
0
)
{
temp32
=
*
buffer8
;
temp32
*=
scale
;
*
buffer8
=
temp32
>
127
?
127
:
(
temp32
<
-
128
?
-
128
:
temp32
);
buffer8
++
;
bufferS
ize
--
;
s
ize
--
;
}
break
;
default:
...
...
src/replay_gain.h
View file @
114b3c1e
...
...
@@ -17,34 +17,36 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef MPD_REPLAYGAIN_H
#define MPD_REPLAYGAIN_H
#ifndef MPD_REPLAY
_
GAIN_H
#define MPD_REPLAY
_
GAIN_H
#define REPLAYGAIN_OFF 0
#define REPLAYGAIN_TRACK 1
#define REPLAYGAIN_ALBUM 2
#define REPLAY
_
GAIN_OFF 0
#define REPLAY
_
GAIN_TRACK 1
#define REPLAY
_
GAIN_ALBUM 2
struct
audio_format
;
extern
int
replay
GainStat
e
;
extern
int
replay
_gain_mod
e
;
typedef
struct
_ReplayGainI
nfo
{
float
album
G
ain
;
float
album
P
eak
;
float
track
G
ain
;
float
track
P
eak
;
struct
replay_gain_i
nfo
{
float
album
_g
ain
;
float
album
_p
eak
;
float
track
_g
ain
;
float
track
_p
eak
;
/* used internally by mpd, to mess with it */
float
scale
;
}
ReplayGainInfo
;
};
ReplayGainInfo
*
newReplayGainInfo
(
void
);
struct
replay_gain_info
*
replay_gain_info_new
(
void
);
void
freeReplayGainInfo
(
ReplayGainInfo
*
info
);
void
replay_gain_info_free
(
struct
replay_gain_info
*
info
);
void
initReplayGainState
(
void
);
void
replay_gain_global_init
(
void
);
void
doReplayGain
(
ReplayGainInfo
*
info
,
char
*
buffer
,
int
bufferSize
,
void
replay_gain_apply
(
struct
replay_gain_info
*
info
,
char
*
buffer
,
int
bufferSize
,
const
struct
audio_format
*
format
);
#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