Thomas Tsou | 7e4e536 | 2013-10-30 21:18:55 -0400 | [diff] [blame] | 1 | /* |
| 2 | * NEON scaling |
| 3 | * Copyright (C) 2012,2013 Thomas Tsou <tom@tsou.cc> |
| 4 | * |
Pau Espin Pedrol | 21d03d3 | 2019-07-22 12:05:52 +0200 | [diff] [blame] | 5 | * SPDX-License-Identifier: LGPL-2.1+ |
| 6 | * |
Thomas Tsou | 7e4e536 | 2013-10-30 21:18:55 -0400 | [diff] [blame] | 7 | * 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 Tsou | 7e4e536 | 2013-10-30 21:18:55 -0400 | [diff] [blame] | 16 | */ |
| 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 | |
| 26 | void neon_scale_4n(float *, float *, float *, int); |
| 27 | |
| 28 | static 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 | |
| 44 | void 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 | } |