diff options
Diffstat (limited to 'filter-accela')
-rw-r--r-- | filter-accela/ftnoir_filter_accela.cpp | 5 | ||||
-rw-r--r-- | filter-accela/ftnoir_filter_accela.h | 18 |
2 files changed, 19 insertions, 4 deletions
diff --git a/filter-accela/ftnoir_filter_accela.cpp b/filter-accela/ftnoir_filter_accela.cpp index 439638eb..24287e48 100644 --- a/filter-accela/ftnoir_filter_accela.cpp +++ b/filter-accela/ftnoir_filter_accela.cpp @@ -99,10 +99,7 @@ void FTNoIR_Filter::filter(const double* input, double *output) ? (std::pow(out_/s.max_rot_nl, rot_nl) * s.max_rot_nl) : out_; const double val = m.getValue(float(out)); - const double signum = int(vec < 0) * -2 + 1; - const double result = last_output[i] + signum * dt * val; - - last_output[i] = output[i] = result; + last_output[i] = output[i] = last_output[i] + signum(vec) * dt * val; } } diff --git a/filter-accela/ftnoir_filter_accela.h b/filter-accela/ftnoir_filter_accela.h index b347c30b..da011228 100644 --- a/filter-accela/ftnoir_filter_accela.h +++ b/filter-accela/ftnoir_filter_accela.h @@ -50,6 +50,24 @@ private: double last_output[6]; double smoothed_input[6]; Timer t; + + template <typename T> + static inline int signum(T x, std::false_type) + { + return T(0) < x; + } + + template <typename T> + static inline int signum(T x, std::true_type) + { + return (T(0) < x) - (x < T(0)); + } + + template <typename T> + static inline int signum(T x) + { + return signum(x, std::is_signed<T>()); + } }; class FilterControls: public IFilterDialog |