diff --git a/src/pcm/Dsd2Pcm.cxx b/src/pcm/Dsd2Pcm.cxx index 0b99cc5e4..6ce9ff9bb 100644 --- a/src/pcm/Dsd2Pcm.cxx +++ b/src/pcm/Dsd2Pcm.cxx @@ -34,6 +34,7 @@ or implied, of Sebastian Gesemann. #include "util/bit_reverse.h" #include "util/GenerateArray.hxx" +#include #include #include @@ -205,3 +206,16 @@ Dsd2Pcm::Translate(size_t samples, } fifopos = ffp; } + +void +MultiDsd2Pcm::Translate(unsigned channels, size_t n_frames, + const uint8_t *src, float *dest) noexcept +{ + assert(channels <= per_channel.max_size()); + + for (unsigned i = 0; i < channels; ++i) { + per_channel[i].Translate(n_frames, + src++, channels, + dest++, channels); + } +} diff --git a/src/pcm/Dsd2Pcm.hxx b/src/pcm/Dsd2Pcm.hxx index b36c7007e..561a428e4 100644 --- a/src/pcm/Dsd2Pcm.hxx +++ b/src/pcm/Dsd2Pcm.hxx @@ -31,6 +31,10 @@ or implied, of Sebastian Gesemann. #ifndef DSD2PCM_H_INCLUDED #define DSD2PCM_H_INCLUDED +#include "ChannelDefs.hxx" + +#include + #include #include @@ -79,5 +83,18 @@ private: float TranslateSample(size_t ffp, uint8_t src) noexcept; }; +class MultiDsd2Pcm { + std::array per_channel; + +public: + void Reset() noexcept { + for (auto &i : per_channel) + i.Reset(); + } + + void Translate(unsigned channels, size_t n_frames, + const uint8_t *src, float *dest) noexcept; +}; + #endif /* include guard DSD2PCM_H_INCLUDED */ diff --git a/src/pcm/PcmDsd.cxx b/src/pcm/PcmDsd.cxx index 5dabdf7f6..b7d76dc1f 100644 --- a/src/pcm/PcmDsd.cxx +++ b/src/pcm/PcmDsd.cxx @@ -23,31 +23,18 @@ #include -void -PcmDsd::Reset() noexcept -{ - for (auto &i : dsd2pcm) - i.Reset(); -} - ConstBuffer PcmDsd::ToFloat(unsigned channels, ConstBuffer src) noexcept { assert(!src.IsNull()); assert(!src.empty()); assert(src.size % channels == 0); - assert(channels <= dsd2pcm.max_size()); const size_t num_samples = src.size; const size_t num_frames = src.size / channels; float *dest = buffer.GetT(num_samples); - for (unsigned c = 0; c < channels; ++c) { - dsd2pcm[c].Translate(num_frames, - src.data + c, channels, - dest + c, channels); - } - + dsd2pcm.Translate(channels, num_frames, src.data, dest); return { dest, num_samples }; } diff --git a/src/pcm/PcmDsd.hxx b/src/pcm/PcmDsd.hxx index 6b36944b1..11b0efa97 100644 --- a/src/pcm/PcmDsd.hxx +++ b/src/pcm/PcmDsd.hxx @@ -21,11 +21,8 @@ #define MPD_PCM_DSD_HXX #include "Buffer.hxx" -#include "ChannelDefs.hxx" #include "Dsd2Pcm.hxx" -#include - #include template struct ConstBuffer; @@ -36,10 +33,12 @@ template struct ConstBuffer; class PcmDsd { PcmBuffer buffer; - std::array dsd2pcm; + MultiDsd2Pcm dsd2pcm; public: - void Reset() noexcept; + void Reset() noexcept { + dsd2pcm.Reset(); + } ConstBuffer ToFloat(unsigned channels, ConstBuffer src) noexcept;