diff options
author | Max Kellermann <max@duempel.org> | 2013-12-22 21:58:18 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2013-12-22 22:18:06 +0100 |
commit | 1543e529f1e52ec135a644bd3faf7496f92b0a38 (patch) | |
tree | c839589dd8c79fb07b1365446f5f57758ce8fb59 /src/pcm/PcmDither.hxx | |
parent | 4043f320fe6f9d2128e1a7be52ab89b380e208cc (diff) | |
download | mpd-1543e529f1e52ec135a644bd3faf7496f92b0a38.tar.gz mpd-1543e529f1e52ec135a644bd3faf7496f92b0a38.tar.xz mpd-1543e529f1e52ec135a644bd3faf7496f92b0a38.zip |
pcm/Dither: convert remaining methods to templates
Use the SampleTraits template and let the compiler generate a special
case for S32 instead of reusing S24_P32.
Diffstat (limited to '')
-rw-r--r-- | src/pcm/PcmDither.hxx | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/src/pcm/PcmDither.hxx b/src/pcm/PcmDither.hxx index f3213a6e6..2b75cdaeb 100644 --- a/src/pcm/PcmDither.hxx +++ b/src/pcm/PcmDither.hxx @@ -22,6 +22,8 @@ #include <stdint.h> +enum class SampleFormat : uint8_t; + class PcmDither { int32_t error[3]; int32_t random; @@ -30,9 +32,6 @@ public: constexpr PcmDither() :error{0, 0, 0}, random(0) {} - template<typename T, T MIN, T MAX, unsigned scale_bits> - T Dither(T sample); - void Dither24To16(int16_t *dest, const int32_t *src, const int32_t *src_end); @@ -40,8 +39,16 @@ public: const int32_t *src_end); private: - int16_t Dither24To16(int_fast32_t sample); - int16_t Dither32To16(int_fast32_t sample); + template<typename T, T MIN, T MAX, unsigned scale_bits> + T Dither(T sample); + + template<typename ST, typename DT> + typename DT::value_type DitherShift(typename ST::value_type sample); + + template<typename ST, typename DT> + void DitherShift(typename DT::pointer_type dest, + typename ST::const_pointer_type src, + typename ST::const_pointer_type src_end); }; #endif |