blob: d44ffc83b31af640bee8c3027de7a1ceb04a9153 [file] [log] [blame]
Thomas Tsou7e4e5362013-10-30 21:18:55 -04001/*
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 Tsou7e4e5362013-10-30 21:18:55 -04007 * 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 Tsou7e4e5362013-10-30 21:18:55 -040016 */
17
18#include <malloc.h>
19#include <string.h>
20#include <scale.h>
21
22#ifdef HAVE_CONFIG_H
23#include "config.h"
24#endif
25
26void neon_scale_4n(float *, float *, float *, int);
27
28static void scale_ps(float *out, float *in, float *scale, int len)
29{
30 float ai, aq, bi, bq;
31
32 bi = scale[0];
33 bq = scale[1];
34
35 for (int i = 0; i < len; i++) {
36 ai = in[2 * i + 0];
37 aq = in[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 scale_complex(float *out, float *in, float* scale, int len)
45{
46#ifdef HAVE_NEON
47 if (len % 4)
48 scale_ps(out, in, scale, len);
49 else
50 neon_scale_4n(in, scale, out, len >> 2);
51#else
52 scale_ps(out, in, scale, len);
53#endif
54}