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 @@ -36,12 +36,31 @@ GenericPcmInterleave(uint8_t *gcc_restrict dest, } } +template +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 static void PcmInterleaveT(T *gcc_restrict dest, const ConstBuffer 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++;