From 9647b2cb0123f0e41163ac237b469926824951db Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Tue, 14 Jan 2020 22:43:11 +0100 Subject: [PATCH] pcm/Dsd2Pcm: move code to ApplySample() For some reason, this speeds up the library by 2%. --- src/pcm/Dsd2Pcm.cxx | 13 ++++++++++--- src/pcm/Dsd2Pcm.hxx | 1 + 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/pcm/Dsd2Pcm.cxx b/src/pcm/Dsd2Pcm.cxx index db1da9159..8bf4cc1d4 100644 --- a/src/pcm/Dsd2Pcm.cxx +++ b/src/pcm/Dsd2Pcm.cxx @@ -163,6 +163,14 @@ Dsd2Pcm::Reset() noexcept */ } +inline void +Dsd2Pcm::ApplySample(size_t ffp, uint8_t src) noexcept +{ + fifo[ffp] = src; + uint8_t *p = fifo + ((ffp-CTABLES) & FIFOMASK); + *p = bit_reverse(*p); +} + inline float Dsd2Pcm::CalcOutputSample(size_t ffp) const noexcept { @@ -184,10 +192,9 @@ Dsd2Pcm::Translate(size_t samples, size_t ffp = fifopos; while (samples-- > 0) { unsigned bite1 = *src & 0xFFu; + src += src_stride; if (lsbf) bite1 = bit_reverse(bite1); - fifo[ffp] = bite1; src += src_stride; - uint8_t *p = fifo + ((ffp-CTABLES) & FIFOMASK); - *p = bit_reverse(*p); + ApplySample(ffp, bite1); *dst = CalcOutputSample(ffp); dst += dst_stride; ffp = (ffp + 1) & FIFOMASK; diff --git a/src/pcm/Dsd2Pcm.hxx b/src/pcm/Dsd2Pcm.hxx index 55d027e38..c274fdf97 100644 --- a/src/pcm/Dsd2Pcm.hxx +++ b/src/pcm/Dsd2Pcm.hxx @@ -76,6 +76,7 @@ public: float *dst, ptrdiff_t dst_stride) noexcept; private: + void ApplySample(size_t ffp, uint8_t src) noexcept; float CalcOutputSample(size_t ffp) const noexcept; };