diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2017-05-06 13:18:24 +0200 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2017-05-10 11:19:22 +0200 |
commit | 632cd5bf7778cb9062633f8d27ecd6aadcaa5d28 (patch) | |
tree | a23938f3b97ac8d49239b4839eca5ab29959bcaa | |
parent | 36b6a3b606a36147672c5bf3a3615aaec5486d95 (diff) |
filter/accela: punt if running ahead of the input value
-rw-r--r-- | filter-accela/ftnoir_filter_accela.cpp | 7 |
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]; } } |