summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMax Kellermann <max@musicpd.org>2020-10-16 18:32:30 +0200
committerMax Kellermann <max@musicpd.org>2020-10-16 18:39:29 +0200
commit1db533c8cfe2b76c6914d6ac3d490f5057611b35 (patch)
tree7de1762e6acacdd8ae43589b7121f51b7092b521 /src
parent78ee663660f5e38321f6bb66b4e66e1380888f37 (diff)
decoder/opus: move formula to EbuR128ToReplayGain()
Diffstat (limited to 'src')
-rw-r--r--src/decoder/plugins/OpusDecoderPlugin.cxx19
1 files changed, 12 insertions, 7 deletions
diff --git a/src/decoder/plugins/OpusDecoderPlugin.cxx b/src/decoder/plugins/OpusDecoderPlugin.cxx
index 05200e07a..4257b31e5 100644
--- a/src/decoder/plugins/OpusDecoderPlugin.cxx
+++ b/src/decoder/plugins/OpusDecoderPlugin.cxx
@@ -63,6 +63,17 @@ IsOpusTags(const ogg_packet &packet) noexcept
return packet.bytes >= 8 && memcmp(packet.packet, "OpusTags", 8) == 0;
}
+/**
+ * Convert an EBU R128 value to ReplayGain.
+ */
+constexpr float
+EbuR128ToReplayGain(float ebu_r128) noexcept
+{
+ /* add 5dB to compensate for the different reference levels
+ between ReplayGain (89dB) and EBU R128 (-23 LUFS) */
+ return ebu_r128 + 5;
+}
+
bool
mpd_opus_init([[maybe_unused]] const ConfigBlock &block)
{
@@ -249,13 +260,7 @@ MPDOpusDecoder::HandleTags(const ogg_packet &packet)
{
ReplayGainInfo rgi;
rgi.Clear();
-
- /**
- * Add 5dB to compensate for the different
- * reference levels between ReplayGain (89dB) and EBU R128 (-23 LUFS).
- */
- rgi.track.gain = output_gain + 5;
- rgi.album.gain = output_gain + 5;
+ rgi.track.gain = rgi.album.gain = EbuR128ToReplayGain(output_gain);
TagBuilder tag_builder;
AddTagHandler h(tag_builder);