aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2022-03-07 17:32:13 -0800
committerChris Robinson <[email protected]>2022-03-07 17:32:13 -0800
commit90db129d60a8a3ec0ca0591f789d09ba777142ea (patch)
tree44ceb0164501c9184795095c10f75cd72cd883b9 /core
parent1369a081a03e51add9a98fc084822cc0d5fd2461 (diff)
Avoid a divide-by-zero in UhjDecoder::decodeStereo
Diffstat (limited to 'core')
-rw-r--r--core/uhjfilter.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/core/uhjfilter.cpp b/core/uhjfilter.cpp
index a56e25bf..7a68f1b1 100644
--- a/core/uhjfilter.cpp
+++ b/core/uhjfilter.cpp
@@ -191,14 +191,14 @@ void UhjDecoder::decodeStereo(const al::span<float*> samples, const size_t sampl
*/
const float wtarget{mWidthControl};
const float wcurrent{unlikely(mCurrentWidth < 0.0f) ? wtarget : mCurrentWidth};
- const float wstep{(wtarget - wcurrent) / static_cast<float>(forwardSamples)};
- if(likely(wstep < 0.00001f))
+ if(likely(wtarget == wcurrent) || unlikely(forwardSamples == 0))
{
for(size_t i{0};i < samplesToDo+sFilterDelay;++i)
- mD[i] = (left[i] - right[i]) * wtarget;
+ mD[i] = (left[i] - right[i]) * wcurrent;
}
else
{
+ const float wstep{(wtarget - wcurrent) / static_cast<float>(forwardSamples)};
float fi{0.0f};
size_t i{0};
for(;i < forwardSamples;++i)
@@ -208,8 +208,8 @@ void UhjDecoder::decodeStereo(const al::span<float*> samples, const size_t sampl
}
for(;i < samplesToDo+sFilterDelay;++i)
mD[i] = (left[i] - right[i]) * wtarget;
+ mCurrentWidth = wtarget;
}
- mCurrentWidth = wtarget;
}
float *RESTRICT woutput{al::assume_aligned<16>(samples[0])};