blob: 245be50599c4141c0ae05b03143a68a6945f32cd [file] [log] [blame]
Thomas Tsou0a3dc4c2013-11-09 02:29:55 -05001/*
2 * NEON scaling
3 * Copyright (C) 2012,2013 Thomas Tsou <tom@tsou.cc>
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 */
19
20#include <malloc.h>
21#include <string.h>
22#include <mult.h>
23
24#ifdef HAVE_CONFIG_H
25#include "config.h"
26#endif
27
28void neon_cmplx_mul_4n(float *, float *, float *, int);
29
30static void cmplx_mul_ps(float *out, float *a, float *b, int len)
31{
32 float ai, aq, bi, bq;
33
34 for (int i = 0; i < len; i++) {
35 ai = a[2 * i + 0];
36 aq = a[2 * i + 1];
37
38 bi = b[2 * i + 0];
39 bq = b[2 * i + 1];
40
41 out[2 * i + 0] = ai * bi - aq * bq;
42 out[2 * i + 1] = ai * bq + aq * bi;
43 }
44}
45
46void mul_complex(float *out, float *a, float *b, int len)
47{
48#ifdef HAVE_NEON
49 if (len % 4)
50 cmplx_mul_ps(out, a, b, len);
51 else
52 neon_cmplx_mul_4n(out, a, b, len >> 2);
53#else
54 cmplx_mul_ps(out, a, b, len);
55#endif
56}