commit ffa2909116d211648f819de2a2b2be3b0b622bb8
parent 17bc20934fb51571b745dad7692c344f88511672
Author: d.levin256@gmail.com <d.levin256@gmail.com>
Date: Thu, 21 Jul 2016 18:11:03 +0300
interpolation functions
Diffstat:
1 file changed, 32 insertions(+), 49 deletions(-)
diff --git a/include/kfr/dsp/interpolation.hpp b/include/kfr/dsp/interpolation.hpp
@@ -28,59 +28,42 @@
namespace kfr
{
-namespace internal
-{
-template <cpu_t c = cpu_t::native, cpu_t cc = c>
-struct in_interpolation : in_sin_cos<cc>, in_select<cc>
-{
-private:
- using in_sin_cos<cc>::fastcos;
- using in_select<cc>::select;
-
-public:
- template <typename T, typename M>
- KFR_SINTRIN T nearest(M mu, T x1, T x2)
- {
- return select(mu < M(0.5), x1, x2);
- }
- template <typename T, typename M>
- KFR_SINTRIN T linear(M mu, T x1, T x2)
- {
- return mix(mu, x1, x2);
- }
+template <typename T, typename M>
+KFR_SINTRIN T nearest(M mu, T x1, T x2)
+{
+ return native::select(mu < M(0.5), x1, x2);
+}
- template <typename T, typename M>
- KFR_SINTRIN T cosine(M mu, T x1, T x2)
- {
- return mix((M(1) - fastcos(mu * c_pi<T>)) * M(0.5), x1, x2);
- }
+template <typename T, typename M>
+KFR_SINTRIN T linear(M mu, T x1, T x2)
+{
+ return mix(mu, x1, x2);
+}
- template <typename T, typename M>
- KFR_SINTRIN T cubic(M mu, T x0, T x1, T x2, T x3)
- {
- const T a0 = x3 - x2 - x0 + x1;
- const T a1 = x0 - x1 - a0;
- const T a2 = x2 - x0;
- const T a3 = x1;
- return horner(mu, a0, a1, a2, a3);
- }
+template <typename T, typename M>
+KFR_SINTRIN T cosine(M mu, T x1, T x2)
+{
+ return mix((M(1) - native::fastcos(mu * c_pi<T>)) * M(0.5), x1, x2);
+}
- template <typename T, typename M>
- KFR_SINTRIN T catmullrom(M mu, T x0, T x1, T x2, T x3)
- {
- const T a0 = T(0.5) * (x3 - x0) - T(1.5) * (x2 - x1);
- const T a1 = x0 - T(2.5) * x1 + T(2) * x2 - T(0.5) * x3;
- const T a2 = T(0.5) * (x2 - x0);
- const T a3 = x1;
- return horner(mu, a0, a1, a2, a3);
- }
+template <typename T, typename M>
+KFR_SINTRIN T cubic(M mu, T x0, T x1, T x2, T x3)
+{
+ const T a0 = x3 - x2 - x0 + x1;
+ const T a1 = x0 - x1 - a0;
+ const T a2 = x2 - x0;
+ const T a3 = x1;
+ return horner(mu, a0, a1, a2, a3);
+}
- KFR_SPEC_FN(in_interpolation, nearest)
- KFR_SPEC_FN(in_interpolation, linear)
- KFR_SPEC_FN(in_interpolation, cosine)
- KFR_SPEC_FN(in_interpolation, cubic)
- KFR_SPEC_FN(in_interpolation, catmullrom)
-};
+template <typename T, typename M>
+KFR_SINTRIN T catmullrom(M mu, T x0, T x1, T x2, T x3)
+{
+ const T a0 = T(0.5) * (x3 - x0) - T(1.5) * (x2 - x1);
+ const T a1 = x0 - T(2.5) * x1 + T(2) * x2 - T(0.5) * x3;
+ const T a2 = T(0.5) * (x2 - x0);
+ const T a3 = x1;
+ return horner(mu, a0, a1, a2, a3);
}
}