diff options
author | Chris Robinson <[email protected]> | 2022-10-28 20:07:45 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2022-10-28 20:07:45 -0700 |
commit | bb88035a96e6794e4dd1085c2c11b046b7f5c8c7 (patch) | |
tree | 487716d54051d88b1bc85b648efa51b7a0308a9f | |
parent | f1f3672f0b8c45b87fcf3b3b99868c274569eaf4 (diff) |
Rename some variables to more clearly indicate their meaning
-rw-r--r-- | core/device.h | 2 | ||||
-rw-r--r-- | core/uhjfilter.cpp | 28 | ||||
-rw-r--r-- | core/uhjfilter.h | 36 | ||||
-rw-r--r-- | core/voice.cpp | 12 | ||||
-rw-r--r-- | core/voice.h | 2 |
5 files changed, 40 insertions, 40 deletions
diff --git a/core/device.h b/core/device.h index 31a88ee4..292c1730 100644 --- a/core/device.h +++ b/core/device.h @@ -189,7 +189,7 @@ struct DeviceBase { /* Temp storage used for mixer processing. */ static constexpr size_t MixerLineSize{BufferLineSize + MaxResamplerPadding + - DecoderBase::sMaxDelay}; + DecoderBase::sMaxPadding}; static constexpr size_t MixerChannelsMax{16}; using MixerBufferLine = std::array<float,MixerLineSize>; alignas(16) std::array<MixerBufferLine,MixerChannelsMax> mSampleData; diff --git a/core/uhjfilter.cpp b/core/uhjfilter.cpp index 1a4e1630..5fb529ae 100644 --- a/core/uhjfilter.cpp +++ b/core/uhjfilter.cpp @@ -245,7 +245,7 @@ template<size_t N> void UhjDecoder<N>::decode(const al::span<float*> samples, const size_t samplesToDo, const size_t forwardSamples) { - static_assert(sFilterDelay <= sMaxDelay, "Filter delay is too large"); + static_assert(sInputPadding <= sMaxPadding, "Filter padding is too large"); const auto &PShift = GetPhaseShifter<N>::Get(); @@ -257,15 +257,15 @@ void UhjDecoder<N>::decode(const al::span<float*> samples, const size_t samplesT const float *RESTRICT t{al::assume_aligned<16>(samples[2])}; /* S = Left + Right */ - for(size_t i{0};i < samplesToDo+sFilterDelay;++i) + for(size_t i{0};i < samplesToDo+sInputPadding;++i) mS[i] = left[i] + right[i]; /* D = Left - Right */ - for(size_t i{0};i < samplesToDo+sFilterDelay;++i) + for(size_t i{0};i < samplesToDo+sInputPadding;++i) mD[i] = left[i] - right[i]; /* T */ - for(size_t i{0};i < samplesToDo+sFilterDelay;++i) + for(size_t i{0};i < samplesToDo+sInputPadding;++i) mT[i] = t[i]; } @@ -275,7 +275,7 @@ void UhjDecoder<N>::decode(const al::span<float*> samples, const size_t samplesT /* Precompute j(0.828331*D + 0.767820*T) and store in xoutput. */ auto tmpiter = std::copy(mDTHistory.cbegin(), mDTHistory.cend(), mTemp.begin()); - std::transform(mD.cbegin(), mD.cbegin()+samplesToDo+sFilterDelay, mT.cbegin(), tmpiter, + std::transform(mD.cbegin(), mD.cbegin()+samplesToDo+sInputPadding, mT.cbegin(), tmpiter, [](const float d, const float t) noexcept { return 0.828331f*d + 0.767820f*t; }); std::copy_n(mTemp.cbegin()+forwardSamples, mDTHistory.size(), mDTHistory.begin()); PShift.process({xoutput, samplesToDo}, mTemp.data()); @@ -289,7 +289,7 @@ void UhjDecoder<N>::decode(const al::span<float*> samples, const size_t samplesT /* Precompute j*S and store in youtput. */ tmpiter = std::copy(mSHistory.cbegin(), mSHistory.cend(), mTemp.begin()); - std::copy_n(mS.cbegin(), samplesToDo+sFilterDelay, tmpiter); + std::copy_n(mS.cbegin(), samplesToDo+sInputPadding, tmpiter); std::copy_n(mTemp.cbegin()+forwardSamples, mSHistory.size(), mSHistory.begin()); PShift.process({youtput, samplesToDo}, mTemp.data()); @@ -309,7 +309,7 @@ void UhjDecoder<N>::decode(const al::span<float*> samples, const size_t samplesT void UhjDecoderIIR::decode(const al::span<float*> samples, const size_t samplesToDo, const size_t forwardSamples) { - static_assert(sFilterDelay <= sMaxDelay, "Filter delay is too large"); + static_assert(sInputPadding <= sMaxPadding, "Filter padding is too large"); ASSUME(samplesToDo > 0); @@ -392,7 +392,7 @@ template<size_t N> void UhjStereoDecoder<N>::decode(const al::span<float*> samples, const size_t samplesToDo, const size_t forwardSamples) { - static_assert(sFilterDelay <= sMaxDelay, "Filter delay is too large"); + static_assert(sInputPadding <= sMaxPadding, "Filter padding is too large"); const auto &PShift = GetPhaseShifter<N>::Get(); @@ -402,7 +402,7 @@ void UhjStereoDecoder<N>::decode(const al::span<float*> samples, const size_t sa const float *RESTRICT left{al::assume_aligned<16>(samples[0])}; const float *RESTRICT right{al::assume_aligned<16>(samples[1])}; - for(size_t i{0};i < samplesToDo+sFilterDelay;++i) + for(size_t i{0};i < samplesToDo+sInputPadding;++i) mS[i] = left[i] + right[i]; /* Pre-apply the width factor to the difference signal D. Smoothly @@ -412,7 +412,7 @@ void UhjStereoDecoder<N>::decode(const al::span<float*> samples, const size_t sa const float wcurrent{unlikely(mCurrentWidth < 0.0f) ? wtarget : mCurrentWidth}; if(likely(wtarget == wcurrent) || unlikely(forwardSamples == 0)) { - for(size_t i{0};i < samplesToDo+sFilterDelay;++i) + for(size_t i{0};i < samplesToDo+sInputPadding;++i) mD[i] = (left[i] - right[i]) * wcurrent; mCurrentWidth = wcurrent; } @@ -426,7 +426,7 @@ void UhjStereoDecoder<N>::decode(const al::span<float*> samples, const size_t sa mD[i] = (left[i] - right[i]) * (wcurrent + wstep*fi); fi += 1.0f; } - for(;i < samplesToDo+sFilterDelay;++i) + for(;i < samplesToDo+sInputPadding;++i) mD[i] = (left[i] - right[i]) * wtarget; mCurrentWidth = wtarget; } @@ -438,7 +438,7 @@ void UhjStereoDecoder<N>::decode(const al::span<float*> samples, const size_t sa /* Precompute j*D and store in xoutput. */ auto tmpiter = std::copy(mDTHistory.cbegin(), mDTHistory.cend(), mTemp.begin()); - std::copy_n(mD.cbegin(), samplesToDo+sFilterDelay, tmpiter); + std::copy_n(mD.cbegin(), samplesToDo+sInputPadding, tmpiter); std::copy_n(mTemp.cbegin()+forwardSamples, mDTHistory.size(), mDTHistory.begin()); PShift.process({xoutput, samplesToDo}, mTemp.data()); @@ -451,7 +451,7 @@ void UhjStereoDecoder<N>::decode(const al::span<float*> samples, const size_t sa /* Precompute j*S and store in youtput. */ tmpiter = std::copy(mSHistory.cbegin(), mSHistory.cend(), mTemp.begin()); - std::copy_n(mS.cbegin(), samplesToDo+sFilterDelay, tmpiter); + std::copy_n(mS.cbegin(), samplesToDo+sInputPadding, tmpiter); std::copy_n(mTemp.cbegin()+forwardSamples, mSHistory.size(), mSHistory.begin()); PShift.process({youtput, samplesToDo}, mTemp.data()); @@ -463,7 +463,7 @@ void UhjStereoDecoder<N>::decode(const al::span<float*> samples, const size_t sa void UhjStereoDecoderIIR::decode(const al::span<float*> samples, const size_t samplesToDo, const size_t forwardSamples) { - static_assert(sFilterDelay <= sMaxDelay, "Filter delay is too large"); + static_assert(sInputPadding <= sMaxPadding, "Filter padding is too large"); ASSUME(samplesToDo > 0); diff --git a/core/uhjfilter.h b/core/uhjfilter.h index c4e2000f..48c379dd 100644 --- a/core/uhjfilter.h +++ b/core/uhjfilter.h @@ -114,7 +114,7 @@ struct UhjEncoderIIR final : public UhjEncoderBase { struct DecoderBase { - static constexpr size_t sMaxDelay{256}; + static constexpr size_t sMaxPadding{256}; /* For 2-channel UHJ, shelf filters should use these LF responses. */ static constexpr float sWLFScale{0.661f}; @@ -134,17 +134,17 @@ struct DecoderBase { template<size_t N> struct UhjDecoder final : public DecoderBase { - /* This isn't a true delay, just the number of extra input samples needed. */ - static constexpr size_t sFilterDelay{N/2}; + /* The number of extra sample frames needed for input. */ + static constexpr size_t sInputPadding{N/2}; - alignas(16) std::array<float,BufferLineSize+MaxResamplerEdge+sFilterDelay> mS{}; - alignas(16) std::array<float,BufferLineSize+MaxResamplerEdge+sFilterDelay> mD{}; - alignas(16) std::array<float,BufferLineSize+MaxResamplerEdge+sFilterDelay> mT{}; + alignas(16) std::array<float,BufferLineSize+MaxResamplerEdge+sInputPadding> mS{}; + alignas(16) std::array<float,BufferLineSize+MaxResamplerEdge+sInputPadding> mD{}; + alignas(16) std::array<float,BufferLineSize+MaxResamplerEdge+sInputPadding> mT{}; - alignas(16) std::array<float,sFilterDelay-1> mDTHistory{}; - alignas(16) std::array<float,sFilterDelay-1> mSHistory{}; + alignas(16) std::array<float,sInputPadding-1> mDTHistory{}; + alignas(16) std::array<float,sInputPadding-1> mSHistory{}; - alignas(16) std::array<float,BufferLineSize+MaxResamplerEdge + sFilterDelay*2> mTemp{}; + alignas(16) std::array<float,BufferLineSize+MaxResamplerEdge + sInputPadding*2> mTemp{}; /** * Decodes a 3- or 4-channel UHJ signal into a B-Format signal with FuMa @@ -163,10 +163,10 @@ struct UhjDecoder final : public DecoderBase { struct UhjDecoderIIR final : public DecoderBase { /* FIXME: These IIR decoder filters actually have a 1-sample delay on the * non-filtered components, which is not reflected in the source latency - * value. sFilterDelay is 0, however, because it doesn't need any extra + * value. sInputPadding is 0, however, because it doesn't need any extra * input samples as long as 'forwardSamples' is less than 'samplesToDo'. */ - static constexpr size_t sFilterDelay{0}; + static constexpr size_t sInputPadding{0}; alignas(16) std::array<float,BufferLineSize+MaxResamplerEdge> mS{}; alignas(16) std::array<float,BufferLineSize+MaxResamplerEdge> mD{}; @@ -187,17 +187,17 @@ struct UhjDecoderIIR final : public DecoderBase { template<size_t N> struct UhjStereoDecoder final : public DecoderBase { - static constexpr size_t sFilterDelay{N/2}; + static constexpr size_t sInputPadding{N/2}; float mCurrentWidth{-1.0f}; - alignas(16) std::array<float,BufferLineSize+MaxResamplerEdge+sFilterDelay> mS{}; - alignas(16) std::array<float,BufferLineSize+MaxResamplerEdge+sFilterDelay> mD{}; + alignas(16) std::array<float,BufferLineSize+MaxResamplerEdge+sInputPadding> mS{}; + alignas(16) std::array<float,BufferLineSize+MaxResamplerEdge+sInputPadding> mD{}; - alignas(16) std::array<float,sFilterDelay-1> mDTHistory{}; - alignas(16) std::array<float,sFilterDelay-1> mSHistory{}; + alignas(16) std::array<float,sInputPadding-1> mDTHistory{}; + alignas(16) std::array<float,sInputPadding-1> mSHistory{}; - alignas(16) std::array<float,BufferLineSize+MaxResamplerEdge + sFilterDelay*2> mTemp{}; + alignas(16) std::array<float,BufferLineSize+MaxResamplerEdge + sInputPadding*2> mTemp{}; /** * Applies Super Stereo processing on a stereo signal to create a B-Format @@ -212,7 +212,7 @@ struct UhjStereoDecoder final : public DecoderBase { }; struct UhjStereoDecoderIIR final : public DecoderBase { - static constexpr size_t sFilterDelay{0}; + static constexpr size_t sInputPadding{0}; float mCurrentWidth{-1.0f}; diff --git a/core/voice.cpp b/core/voice.cpp index 942c1e87..fbf3ea4d 100644 --- a/core/voice.cpp +++ b/core/voice.cpp @@ -860,15 +860,15 @@ void Voice::prepare(DeviceBase *device) { case UhjQualityType::IIR: mDecoder = std::make_unique<UhjStereoDecoderIIR>(); - mDecoderPadding = UhjStereoDecoderIIR::sFilterDelay; + mDecoderPadding = UhjStereoDecoderIIR::sInputPadding; break; case UhjQualityType::FIR256: mDecoder = std::make_unique<UhjStereoDecoder<UhjLength256>>(); - mDecoderPadding = UhjStereoDecoder<UhjLength256>::sFilterDelay; + mDecoderPadding = UhjStereoDecoder<UhjLength256>::sInputPadding; break; case UhjQualityType::FIR512: mDecoder = std::make_unique<UhjStereoDecoder<UhjLength512>>(); - mDecoderPadding = UhjStereoDecoder<UhjLength512>::sFilterDelay; + mDecoderPadding = UhjStereoDecoder<UhjLength512>::sInputPadding; break; } } @@ -878,15 +878,15 @@ void Voice::prepare(DeviceBase *device) { case UhjQualityType::IIR: mDecoder = std::make_unique<UhjDecoderIIR>(); - mDecoderPadding = UhjDecoderIIR::sFilterDelay; + mDecoderPadding = UhjDecoderIIR::sInputPadding; break; case UhjQualityType::FIR256: mDecoder = std::make_unique<UhjDecoder<UhjLength256>>(); - mDecoderPadding = UhjDecoder<UhjLength256>::sFilterDelay; + mDecoderPadding = UhjDecoder<UhjLength256>::sInputPadding; break; case UhjQualityType::FIR512: mDecoder = std::make_unique<UhjDecoder<UhjLength512>>(); - mDecoderPadding = UhjDecoder<UhjLength512>::sFilterDelay; + mDecoderPadding = UhjDecoder<UhjLength512>::sInputPadding; break; } } diff --git a/core/voice.h b/core/voice.h index 9dd642b4..fab551da 100644 --- a/core/voice.h +++ b/core/voice.h @@ -51,7 +51,7 @@ enum class DirectMode : unsigned char { /* Maximum number of extra source samples that may need to be loaded, for * resampling or conversion purposes. */ -constexpr uint MaxPostVoiceLoad{MaxResamplerEdge + DecoderBase::sMaxDelay}; +constexpr uint MaxPostVoiceLoad{MaxResamplerEdge + DecoderBase::sMaxPadding}; enum { |