From f2491c88c86707cc35c7dfc30a1b5a0a29886540 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Thu, 31 Jan 2013 22:43:28 +0100 Subject: PcmDither: convert struct to a class --- src/PcmDither.hxx | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) (limited to 'src/PcmDither.hxx') diff --git a/src/PcmDither.hxx b/src/PcmDither.hxx index 59affa088..106382307 100644 --- a/src/PcmDither.hxx +++ b/src/PcmDither.hxx @@ -22,24 +22,23 @@ #include -struct pcm_dither { +class PcmDither { int32_t error[3]; int32_t random; -}; -static inline void -pcm_dither_24_init(struct pcm_dither *dither) -{ - dither->error[0] = dither->error[1] = dither->error[2] = 0; - dither->random = 0; -} +public: + constexpr PcmDither() + :error{0, 0, 0}, random(0) {} + + void Dither24To16(int16_t *dest, const int32_t *src, + const int32_t *src_end); -void -pcm_dither_24_to_16(struct pcm_dither *dither, - int16_t *dest, const int32_t *src, const int32_t *src_end); + void Dither32To16(int16_t *dest, const int32_t *src, + const int32_t *src_end); -void -pcm_dither_32_to_16(struct pcm_dither *dither, - int16_t *dest, const int32_t *src, const int32_t *src_end); +private: + int16_t Dither24To16(int_fast32_t sample); + int16_t Dither32To16(int_fast32_t sample); +}; #endif -- cgit v1.2.3