diff options
author | Max Kellermann <max@musicpd.org> | 2019-09-13 19:45:26 +0200 |
---|---|---|
committer | Max Kellermann <max@musicpd.org> | 2019-09-13 19:50:43 +0200 |
commit | b6243a99450fcef7cd3a1bdea628a93719c1fc5f (patch) | |
tree | 273b730b2d38d540eec66f8bc55c8d647412cbf8 /src | |
parent | 496f88653d9166338d37fb94cc10cffd6af196d5 (diff) |
decoder/mpcdec: merge duplicate code
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); |