From 556c5d14d7fd862e86d428477afcc708b3f4055c Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Tue, 17 May 2022 02:32:10 -0700 Subject: [PATCH] Avoid a virtual function call to set the decoder width --- alc/alu.cpp | 2 +- core/uhjfilter.h | 23 ++++++++--------------- 2 files changed, 9 insertions(+), 16 deletions(-) diff --git a/alc/alu.cpp b/alc/alu.cpp index 487ce4c8..c7fb5f57 100644 --- a/alc/alu.cpp +++ b/alc/alu.cpp @@ -765,7 +765,7 @@ void CalcPanningAndFilters(Voice *voice, const float xpos, const float ypos, con voice->mFlags.reset(VoiceHasHrtf).reset(VoiceHasNfc); if(auto *decoder{voice->mDecoder.get()}) - decoder->setWidth(minf(props->EnhWidth, 0.7f)); + decoder->mWidthControl = minf(props->EnhWidth, 0.7f); if(IsAmbisonic(voice->mFmtChannels)) { diff --git a/core/uhjfilter.h b/core/uhjfilter.h index ab967948..eeabb6d2 100644 --- a/core/uhjfilter.h +++ b/core/uhjfilter.h @@ -12,10 +12,16 @@ struct DecoderBase { virtual ~DecoderBase() = default; - virtual void setWidth(float width) noexcept = 0; - virtual void decode(const al::span samples, const size_t samplesToDo, const size_t forwardSamples) = 0; + + /** + * The width factor for Super Stereo processing. Can be changed in between + * calls to decode, with valid values being between 0...0.7. + */ + float mWidthControl{0.593f}; + + float mCurrentWidth{-1.0f}; }; @@ -62,8 +68,6 @@ struct UhjDecoder : public DecoderBase, public UhjFilterBase { alignas(16) std::array mTemp{}; - void setWidth(float) noexcept override { } - /** * Decodes a 3- or 4-channel UHJ signal into a B-Format signal with FuMa * channel ordering and UHJ scaling. For 3-channel, the 3rd channel may be @@ -79,17 +83,6 @@ struct UhjDecoder : public DecoderBase, public UhjFilterBase { }; struct UhjStereoDecoder : public UhjDecoder { - float mCurrentWidth{-1.0f}; - - /** - * The width factor for Super Stereo processing. Can be changed in between - * calls to decodeStereo, with valid values being between 0...0.7. - */ - float mWidthControl{0.593f}; - - void setWidth(float width) noexcept override - { mWidthControl = width; } - /** * Applies Super Stereo processing on a stereo signal to create a B-Format * signal with FuMa channel ordering and UHJ scaling. The samples span -- 2.11.4.GIT