summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--filter-accela/ftnoir_filter_accela.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/filter-accela/ftnoir_filter_accela.cpp b/filter-accela/ftnoir_filter_accela.cpp
index 3f78c7a6..b8a0ac77 100644
--- a/filter-accela/ftnoir_filter_accela.cpp
+++ b/filter-accela/ftnoir_filter_accela.cpp
@@ -32,6 +32,7 @@ static inline constexpr T signum(T x)
}
template<int N = 3, typename F>
+OTR_NEVER_INLINE
static void do_deltas(const double* deltas, double* output, double alpha, double& smoothed, F&& fun)
{
double norm[N];
@@ -152,6 +153,12 @@ void accela::filter(const double* input, double *output)
{
output[k] *= dt;
output[k] += last_output[k];
+
+ if (signum(last_output[k] - output[k]) < 0)
+ output[k] = std::fmax(input[k], output[k]);
+ else
+ output[k] = std::fmin(input[k], output[k]);
+
last_output[k] = output[k];
}
}