diff options
author | Max Kellermann <max@duempel.org> | 2013-10-25 19:05:49 +0200 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2013-10-25 19:12:46 +0200 |
commit | d6e28c42e5c2bdab73d3553b21a09fa28dabd037 (patch) | |
tree | 6b7e43d0b777b3be149c86e853debef3cbd49826 /src/ReplayGainInfo.hxx | |
parent | 6d475c40de567d778fa6f96c379687a8bf83f82b (diff) |
ReplayGainInfo: refactor to a class
Diffstat (limited to 'src/ReplayGainInfo.hxx')
-rw-r--r-- | src/ReplayGainInfo.hxx | 54 |
1 files changed, 25 insertions, 29 deletions
diff --git a/src/ReplayGainInfo.hxx b/src/ReplayGainInfo.hxx index 2b2d3d3db..8846a6ed3 100644 --- a/src/ReplayGainInfo.hxx +++ b/src/ReplayGainInfo.hxx @@ -21,6 +21,7 @@ #define MPD_REPLAY_GAIN_INFO_HXX #include "check.h" +#include "Compiler.h" #include <cmath> @@ -34,40 +35,35 @@ enum ReplayGainMode { struct ReplayGainTuple { float gain; float peak; -}; -struct ReplayGainInfo { - ReplayGainTuple tuples[2]; -}; + void Clear() { + gain = INFINITY; + peak = 0.0; + } -static inline void -replay_gain_tuple_init(ReplayGainTuple *tuple) -{ - tuple->gain = INFINITY; - tuple->peak = 0.0; -} + gcc_pure + bool IsDefined() const { + return !std::isinf(gain); + } -static inline void -replay_gain_info_init(struct ReplayGainInfo *info) -{ - replay_gain_tuple_init(&info->tuples[REPLAY_GAIN_ALBUM]); - replay_gain_tuple_init(&info->tuples[REPLAY_GAIN_TRACK]); -} + gcc_pure + float CalculateScale(float preamp, float missing_preamp, + bool peak_limit) const; +}; -static inline bool -replay_gain_tuple_defined(const ReplayGainTuple *tuple) -{ - return !std::isinf(tuple->gain); -} +struct ReplayGainInfo { + ReplayGainTuple tuples[2]; -float -replay_gain_tuple_scale(const ReplayGainTuple *tuple, float preamp, float missing_preamp, bool peak_limit); + void Clear() { + tuples[REPLAY_GAIN_ALBUM].Clear(); + tuples[REPLAY_GAIN_TRACK].Clear(); + } -/** - * Attempt to auto-complete missing data. In particular, if album - * information is missing, track gain is used. - */ -void -replay_gain_info_complete(ReplayGainInfo &info); + /** + * Attempt to auto-complete missing data. In particular, if + * album information is missing, track gain is used. + */ + void Complete(); +}; #endif |