aboutsummaryrefslogtreecommitdiffstats
path: root/Transceiver52M/arm/scale.c
diff options
context:
space:
mode:
authorThomas Tsou <tom@tsou.cc>2013-10-30 21:18:55 -0400
committerThomas Tsou <tom@tsou.cc>2013-11-15 23:32:35 -0500
commit7e4e536b1bfc9b20df6b30d427de29e3cc5bf5cf (patch)
tree31b73f9d77cc616c57cd9cc61ca9d608533205e9 /Transceiver52M/arm/scale.c
parent204a9f135ac2408dd62b55462ebe4b2d10be4f56 (diff)
Transceiver52M: Add ARM NEON support
Similar to the existing Intel SSE cases, add support for NEON vector floating point SIMD processing. In this case, use ARM assembly directly as the NEON intrinsics do not generate preferential code output. Currently support NEON vectorized convolution and floating point integer conversions. Signed-off-by: Thomas Tsou <tom@tsou.cc>
Diffstat (limited to 'Transceiver52M/arm/scale.c')
-rw-r--r--Transceiver52M/arm/scale.c56
1 files changed, 56 insertions, 0 deletions
diff --git a/Transceiver52M/arm/scale.c b/Transceiver52M/arm/scale.c
new file mode 100644
index 0000000..2de13ff
--- /dev/null
+++ b/Transceiver52M/arm/scale.c
@@ -0,0 +1,56 @@
+/*
+ * NEON scaling
+ * Copyright (C) 2012,2013 Thomas Tsou <tom@tsou.cc>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <malloc.h>
+#include <string.h>
+#include <scale.h>
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+void neon_scale_4n(float *, float *, float *, int);
+
+static void scale_ps(float *out, float *in, float *scale, int len)
+{
+ float ai, aq, bi, bq;
+
+ bi = scale[0];
+ bq = scale[1];
+
+ for (int i = 0; i < len; i++) {
+ ai = in[2 * i + 0];
+ aq = in[2 * i + 1];
+
+ out[2 * i + 0] = ai * bi - aq * bq;
+ out[2 * i + 1] = ai * bq + aq * bi;
+ }
+}
+
+void scale_complex(float *out, float *in, float* scale, int len)
+{
+#ifdef HAVE_NEON
+ if (len % 4)
+ scale_ps(out, in, scale, len);
+ else
+ neon_scale_4n(in, scale, out, len >> 2);
+#else
+ scale_ps(out, in, scale, len);
+#endif
+}