aboutsummaryrefslogtreecommitdiffstats
path: root/src/pcm
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2015-06-22 17:27:29 +0200
committerMax Kellermann <max@duempel.org>2015-06-22 17:27:29 +0200
commitb4fc2e38ab344b80bd3b1b6d613774b5caf560f6 (patch)
tree95e076cf5983cc30abbe131e799fd12a0992e7da /src/pcm
parent16639f9d71a11f2d63df84c7ec660f2a9bd5f526 (diff)
downloadmpd-b4fc2e38ab344b80bd3b1b6d613774b5caf560f6.tar.gz
mpd-b4fc2e38ab344b80bd3b1b6d613774b5caf560f6.tar.xz
mpd-b4fc2e38ab344b80bd3b1b6d613774b5caf560f6.zip
pcm/Interleave: add stereo optimization
Diffstat (limited to 'src/pcm')
-rw-r--r--src/pcm/Interleave.cxx19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/pcm/Interleave.cxx b/src/pcm/Interleave.cxx
index 1152a7070..ed9fc125d 100644
--- a/src/pcm/Interleave.cxx
+++ b/src/pcm/Interleave.cxx
@@ -38,10 +38,29 @@ GenericPcmInterleave(uint8_t *gcc_restrict dest,
template<typename T>
static void
+PcmInterleaveStereo(T *gcc_restrict dest,
+ const T *gcc_restrict src1,
+ const T *gcc_restrict src2,
+ size_t n_frames)
+{
+ for (size_t i = 0; i != n_frames; ++i) {
+ *dest++ = *src1++;
+ *dest++ = *src2++;
+ }
+}
+
+template<typename T>
+static void
PcmInterleaveT(T *gcc_restrict dest,
const ConstBuffer<const T *> src,
size_t n_frames)
{
+ switch (src.size) {
+ case 2:
+ PcmInterleaveStereo(dest, src[0], src[1], n_frames);
+ return;
+ }
+
for (const auto *s : src) {
auto *d = dest++;