From 3565f0c8ce7c50076da94b0839ec0ecd41709d76 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Tue, 14 Jan 2020 22:47:30 +0100 Subject: [PATCH] pcm/Dsd2Pcm: move code to TranslateSample() 10% speedup. Strange, huh? --- src/pcm/Dsd2Pcm.cxx | 10 ++++++++-- src/pcm/Dsd2Pcm.hxx | 1 + 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/pcm/Dsd2Pcm.cxx b/src/pcm/Dsd2Pcm.cxx index 8bf4cc1d4..69f0cc764 100644 --- a/src/pcm/Dsd2Pcm.cxx +++ b/src/pcm/Dsd2Pcm.cxx @@ -183,6 +183,13 @@ Dsd2Pcm::CalcOutputSample(size_t ffp) const noexcept return acc; } +inline float +Dsd2Pcm::TranslateSample(size_t ffp, uint8_t src) noexcept +{ + ApplySample(ffp, src); + return CalcOutputSample(ffp); +} + void Dsd2Pcm::Translate(size_t samples, const uint8_t *src, ptrdiff_t src_stride, @@ -194,8 +201,7 @@ Dsd2Pcm::Translate(size_t samples, unsigned bite1 = *src & 0xFFu; src += src_stride; if (lsbf) bite1 = bit_reverse(bite1); - ApplySample(ffp, bite1); - *dst = CalcOutputSample(ffp); + *dst = TranslateSample(ffp, bite1); dst += dst_stride; ffp = (ffp + 1) & FIFOMASK; } diff --git a/src/pcm/Dsd2Pcm.hxx b/src/pcm/Dsd2Pcm.hxx index c274fdf97..3a35cc8d3 100644 --- a/src/pcm/Dsd2Pcm.hxx +++ b/src/pcm/Dsd2Pcm.hxx @@ -78,6 +78,7 @@ public: private: void ApplySample(size_t ffp, uint8_t src) noexcept; float CalcOutputSample(size_t ffp) const noexcept; + float TranslateSample(size_t ffp, uint8_t src) noexcept; }; #endif /* include guard DSD2PCM_H_INCLUDED */