| 1 |
/* |
| 2 |
* Copyright (C) 2020 Linux Studio Plugins Project <https://lsp-plug.in/> |
| 3 |
* (C) 2020 Vladimir Sadovnikov <[email protected]> |
| 4 |
* |
| 5 |
* This file is part of lsp-dsp-lib |
| 6 |
* Created on: 31 мар. 2020 г. |
| 7 |
* |
| 8 |
* lsp-dsp-lib is free software: you can redistribute it and/or modify |
| 9 |
* it under the terms of the GNU Lesser General Public License as published by |
| 10 |
* the Free Software Foundation, either version 3 of the License, or |
| 11 |
* any later version. |
| 12 |
* |
| 13 |
* lsp-dsp-lib is distributed in the hope that it will be useful, |
| 14 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 |
* GNU Lesser General Public License for more details. |
| 17 |
* |
| 18 |
* You should have received a copy of the GNU Lesser General Public License |
| 19 |
* along with lsp-dsp-lib. If not, see <https://www.gnu.org/licenses/>. |
| 20 |
*/ |
| 21 |
|
| 22 |
#ifndef PRIVATE_DSP_ARCH_ARM_NEON_D32_FFT_NORMALIZE_H_ |
| 23 |
#define PRIVATE_DSP_ARCH_ARM_NEON_D32_FFT_NORMALIZE_H_ |
| 24 |
|
| 25 |
#ifndef PRIVATE_DSP_ARCH_ARM_NEON_D32_IMPL |
| 26 |
#error "This header should not be included directly" |
| 27 |
#endif /* PRIVATE_DSP_ARCH_ARM_NEON_D32_IMPL */ |
| 28 |
|
| 29 |
namespace lsp |
| 30 |
{ |
| 31 |
namespace neon_d32 |
| 32 |
{ |
| 33 |
void normalize_fft3(float *dre, float *dim, const float *re, const float *im, size_t rank) |
| 34 |
{ |
| 35 |
IF_ARCH_ARM( |
| 36 |
float k = 1.0f/(1 << rank); |
| 37 |
size_t count = 1 << rank; |
| 38 |
); |
| 39 |
ARCH_ARM_ASM( |
| 40 |
// x8 blocks |
| 41 |
__ASM_EMIT("vdup.32 q0, %y[k]") // q0 = k |
| 42 |
__ASM_EMIT("subs %[count], %[count], #8") |
| 43 |
__ASM_EMIT("vmov q1, q0") |
| 44 |
__ASM_EMIT("blt 2f") |
| 45 |
__ASM_EMIT("1:") |
| 46 |
__ASM_EMIT("vldm %[s_re]!, {q4-q5}") |
| 47 |
__ASM_EMIT("vldm %[s_im]!, {q6-q7}") |
| 48 |
__ASM_EMIT("vmul.f32 q4, q4, q0") |
| 49 |
__ASM_EMIT("vmul.f32 q5, q5, q1") |
| 50 |
__ASM_EMIT("vmul.f32 q6, q6, q0") |
| 51 |
__ASM_EMIT("vmul.f32 q7, q7, q1") |
| 52 |
__ASM_EMIT("subs %[count], %[count], #8") |
| 53 |
__ASM_EMIT("vstm %[d_re]!, {q4-q5}") |
| 54 |
__ASM_EMIT("vstm %[d_im]!, {q6-q7}") |
| 55 |
__ASM_EMIT("bhs 1b") |
| 56 |
__ASM_EMIT("2:") |
| 57 |
: [s_re] "+r" (re), [s_im] "+r" (im), |
| 58 |
[d_re] "+r" (dre), [d_im] "+r" (dim), |
| 59 |
[k] "+t" (k), [count] "+r" (count) |
| 60 |
: |
| 61 |
: "cc", "memory", |
| 62 |
"q0", "q1", |
| 63 |
"q4", "q5", "q6", "q7" |
| 64 |
); |
| 65 |
} |
| 66 |
|
| 67 |
void normalize_fft2(float *re, float *im, size_t rank) |
| 68 |
{ |
| 69 |
IF_ARCH_ARM( |
| 70 |
float k = 1.0f/(1 << rank); |
| 71 |
size_t count = 1 << rank; |
| 72 |
); |
| 73 |
ARCH_ARM_ASM( |
| 74 |
// x8 blocks |
| 75 |
__ASM_EMIT("vdup.32 q0, %y[k]") // q0 = k |
| 76 |
__ASM_EMIT("subs %[count], %[count], #8") |
| 77 |
__ASM_EMIT("vmov q1, q0") |
| 78 |
__ASM_EMIT("blt 2f") |
| 79 |
__ASM_EMIT("1:") |
| 80 |
__ASM_EMIT("vldm %[d_re], {q4-q5}") |
| 81 |
__ASM_EMIT("vldm %[d_im], {q6-q7}") |
| 82 |
__ASM_EMIT("vmul.f32 q4, q4, q0") |
| 83 |
__ASM_EMIT("vmul.f32 q5, q5, q1") |
| 84 |
__ASM_EMIT("vmul.f32 q6, q6, q0") |
| 85 |
__ASM_EMIT("vmul.f32 q7, q7, q1") |
| 86 |
__ASM_EMIT("subs %[count], %[count], #8") |
| 87 |
__ASM_EMIT("vstm %[d_re]!, {q4-q5}") |
| 88 |
__ASM_EMIT("vstm %[d_im]!, {q6-q7}") |
| 89 |
__ASM_EMIT("bhs 1b") |
| 90 |
__ASM_EMIT("2:") |
| 91 |
: [d_re] "+r" (re), [d_im] "+r" (im), |
| 92 |
[k] "+t" (k), [count] "+r" (count) |
| 93 |
: |
| 94 |
: "cc", "memory", |
| 95 |
"q0", "q1", |
| 96 |
"q4", "q5", "q6", "q7" |
| 97 |
); |
| 98 |
} |
| 99 |
} |
| 100 |
} |
| 101 |
|
| 102 |
#endif /* PRIVATE_DSP_ARCH_ARM_NEON_D32_FFT_NORMALIZE_H_ */ |