tag_rva2: support separate album/track replay gain

This commit is contained in:
Jonathan Dieter 2012-04-23 22:15:23 +02:00 committed by Max Kellermann
parent ad83c7f704
commit 7c6d1896a4
2 changed files with 13 additions and 4 deletions

2
NEWS
View File

@ -11,6 +11,8 @@ ver 0.17 (2011/??/??)
- curl: enable CURLOPT_NETRC - curl: enable CURLOPT_NETRC
- curl: non-blocking I/O - curl: non-blocking I/O
- soup: new input plugin based on libsoup - soup: new input plugin based on libsoup
* tags:
- RVA2: support separate album/track replay gain
* decoder: * decoder:
- mpg123: implement seeking - mpg123: implement seeking
- ffmpeg: drop support for pre-0.5 ffmpeg - ffmpeg: drop support for pre-0.5 ffmpeg

View File

@ -22,6 +22,7 @@
#include "replay_gain_info.h" #include "replay_gain_info.h"
#include <stdint.h> #include <stdint.h>
#include <string.h>
#include <glib.h> #include <glib.h>
#include <id3tag.h> #include <id3tag.h>
@ -73,15 +74,21 @@ rva2_float_volume_adjustment(const struct rva2_data *data)
static inline bool static inline bool
rva2_apply_data(struct replay_gain_info *replay_gain_info, rva2_apply_data(struct replay_gain_info *replay_gain_info,
const struct rva2_data *data) const struct rva2_data *data, const id3_latin1_t *id)
{ {
if (data->type != CHANNEL_MASTER_VOLUME) if (data->type != CHANNEL_MASTER_VOLUME)
return false; return false;
float volume_adjustment = rva2_float_volume_adjustment(data); float volume_adjustment = rva2_float_volume_adjustment(data);
replay_gain_info->tuples[REPLAY_GAIN_TRACK].gain = volume_adjustment; if (strcmp((const char *)id, "album") == 0) {
replay_gain_info->tuples[REPLAY_GAIN_ALBUM].gain = volume_adjustment; replay_gain_info->tuples[REPLAY_GAIN_ALBUM].gain = volume_adjustment;
} else if (strcmp((const char *)id, "track") == 0) {
replay_gain_info->tuples[REPLAY_GAIN_TRACK].gain = volume_adjustment;
} else {
replay_gain_info->tuples[REPLAY_GAIN_ALBUM].gain = volume_adjustment;
replay_gain_info->tuples[REPLAY_GAIN_TRACK].gain = volume_adjustment;
}
return true; return true;
} }
@ -115,7 +122,7 @@ rva2_apply_frame(struct replay_gain_info *replay_gain_info,
if (4 + peak_bytes > length) if (4 + peak_bytes > length)
break; break;
if (rva2_apply_data(replay_gain_info, d)) if (rva2_apply_data(replay_gain_info, d, id))
return true; return true;
data += 4 + peak_bytes; data += 4 + peak_bytes;