blob: 251b3c9159e06cd2de3874f95bbe2c2c61cc3c7d [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 *
Pau Espin Pedrol21d03d32019-07-22 12:05:52 +02005 * SPDX-License-Identifier: LGPL-2.1+
6 *
Thomas Tsou0a3dc4c2013-11-09 02:29:55 -05007 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
Thomas Tsou0a3dc4c2013-11-09 02:29:55 -050016 */
17
18#include <malloc.h>
19#include <string.h>
20#include <mult.h>
21
22#ifdef HAVE_CONFIG_H
23#include "config.h"
24#endif
25
26void neon_cmplx_mul_4n(float *, float *, float *, int);
27
28static void cmplx_mul_ps(float *out, float *a, float *b, int len)
29{
30 float ai, aq, bi, bq;
31
32 for (int i = 0; i < len; i++) {
33 ai = a[2 * i + 0];
34 aq = a[2 * i + 1];
35
36 bi = b[2 * i + 0];
37 bq = b[2 * i + 1];
38
39 out[2 * i + 0] = ai * bi - aq * bq;
40 out[2 * i + 1] = ai * bq + aq * bi;
41 }
42}
43
44void mul_complex(float *out, float *a, float *b, int len)
45{
46#ifdef HAVE_NEON
47 if (len % 4)
48 cmplx_mul_ps(out, a, b, len);
49 else
50 neon_cmplx_mul_4n(out, a, b, len >> 2);
51#else
52 cmplx_mul_ps(out, a, b, len);
53#endif
54}