diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/decoder/plugins/MpcdecDecoderPlugin.cxx | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/src/decoder/plugins/MpcdecDecoderPlugin.cxx b/src/decoder/plugins/MpcdecDecoderPlugin.cxx index 76c71a1ed..b7be3fd8e 100644 --- a/src/decoder/plugins/MpcdecDecoderPlugin.cxx +++ b/src/decoder/plugins/MpcdecDecoderPlugin.cxx @@ -137,6 +137,15 @@ mpc_to_mpd_buffer(MpcdecSampleTraits::pointer_type dest, *dest++ = mpc_to_mpd_sample(*src++); } +static constexpr ReplayGainTuple +ImportMpcdecReplayGain(mpc_uint16_t gain, mpc_uint16_t peak) noexcept +{ + auto t = ReplayGainTuple::Undefined(); + t.gain = MPC_OLD_GAIN_REF - (gain / 256.); + t.peak = pow(10, peak / 256. / 20) / 32767; + return t; +} + static void mpcdec_decode(DecoderClient &client, InputStream &is) { @@ -169,10 +178,8 @@ mpcdec_decode(DecoderClient &client, InputStream &is) ReplayGainInfo rgi; rgi.Clear(); - rgi.album.gain = MPC_OLD_GAIN_REF - (info.gain_album / 256.); - rgi.album.peak = pow(10, info.peak_album / 256. / 20) / 32767; - rgi.track.gain = MPC_OLD_GAIN_REF - (info.gain_title / 256.); - rgi.track.peak = pow(10, info.peak_title / 256. / 20) / 32767; + rgi.album = ImportMpcdecReplayGain(info.gain_album, info.peak_album); + rgi.track = ImportMpcdecReplayGain(info.gain_title, info.peak_title); client.SubmitReplayGain(&rgi); |