diff --git a/signal/micro/kernels/hexagon/hexagon_square_root.S b/signal/micro/kernels/hexagon/hexagon_square_root.S new file mode 100644 index 00000000000..5ec1d4f8c3c --- /dev/null +++ b/signal/micro/kernels/hexagon/hexagon_square_root.S @@ -0,0 +1,110 @@ +/* Copyright 2021 The TensorFlow Authors. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +==============================================================================*/ + +.section .note.GNU-stack,"",@progbits + +// SignalHexagonSqrt32 +// input: R0 unsigned 32-bit +// output: R0 unsigned 32-bit +// +// The assembly routine below implements the following: +// +// uint16_t Sqrt32(uint32_t num) { +// uint32_t res = 0; +// uint32_t bit = ((int32_t)1) << 30U; +// while (bit > num) +// bit >>= 2; +// while (bit != 0) { +// if (num >= res + bit) { +// num -= res + bit; +// res = (res >> 1U) + bit; +// } else { +// res >>= 1U; +// } +// bit >>= 2U; +// } +// // Do rounding +// if (num > res && num != 0xFFFF) +// ++res; +// return res; +// } + +.text +.p2align 2 +.p2align 4,,15 +.globl SignalHexagonSqrt32 +.type SignalHexagonSqrt32, @function + + // Register mnemonics +#define num R0 // input - as in loop above +#define res R1 // as in loop aboe +#define bit R2 // as in loop above +#define temp R3 // the quantity bit + res +#define zcount R4 // leading zeroes +#define res_shift R5 // the quantity res >> 1 +#define bit_shift R6 // the quantity bit >> 2 + +SignalHexagonSqrt32: + // Set bit to the largest even-power of two + // that is less than or equal to the input + { + res = #0 // return value + bit = ##1073741824 // 2^30 + zcount = cl0(num) // count leading zeroes + } + zcount = clrbit(zcount, #0) // even power of 2 + { + bit = lsr(bit, zcount) // 2^30 right shifted + if (cmp.eq(bit.new, #0)) jump:nt .done // return if bit == 0 + } +.falign +.loop: + { + // Calculate quantities to be used in the conditional below + temp = add(bit, res) + res_shift = lsr(res, #1) + bit_shift = lsr(bit, #2) + } + { + // Conditionally assign to num and res + p0 = cmp.ltu(temp, num) + if (p0.new) num = sub(num, temp) + if (p0.new) res = add(res_shift, bit) + if (!p0.new) res = res_shift + } + { + // Advance bit >> 2 and exit loop if done + bit = bit_shift + if (cmp.gt(bit.new, #0)) jump:t .loop + } +.falign +.done: + // if (num > res && res != 0xffff) { + // ++res + // } + // return res in num (R0) + { + temp = ##65535 + } + { + p0 = cmp.gt(num, res) + p0 = !cmp.eq(res, temp) + if (p0.new) num = add(res, #1) + if (!p0.new) num = res + } + { + jumpr r31 + } +.size SignalHexagonSqrt32, .-SignalHexagonSqrt32 diff --git a/signal/micro/kernels/hexagon/rfft_int16.cc b/signal/micro/kernels/hexagon/rfft_int16.cc new file mode 100644 index 00000000000..0cabfc0f107 --- /dev/null +++ b/signal/micro/kernels/hexagon/rfft_int16.cc @@ -0,0 +1,188 @@ +/* Copyright 2021 The TensorFlow Authors. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +==============================================================================*/ +#include +#include +#include + +#include "signal/src/msb.h" +#include "signal/src/rfft.h" + +// Do not reorder these headers. "typedef.h" must appear before rfft.h +#include "typedef.h" +extern "C" { +#include "rfft.h" +} + +namespace tflm_signal { + +// TODO(b/467010877) The twiddle tables should come from the tflite file +// This array includes the first 3*512/4=384 elements in the twiddle table in: +// HEXAGON_Tools//Examples/libcore/SigProc/cxFFT_IFFT/include +const uint16_t twiddles[] __attribute__((aligned(8))) = { + 0x7fff, 0x0000, 0x0000, 0x8000, 0x0000, 0x8000, 0x0000, 0x8000, 0xa57e, + 0xa57e, 0xa57e, 0x5a82, 0x5a82, 0xa57e, 0xcf05, 0x89bf, 0x89bf, 0xcf05, + 0xa57e, 0xa57e, 0x89bf, 0xcf05, 0x30fc, 0x7642, 0x7642, 0xcf05, 0xe708, + 0x8276, 0xb8e4, 0x9593, 0xcf05, 0x89bf, 0x9593, 0xb8e4, 0xe708, 0x7d8a, + 0x30fc, 0x89bf, 0xb8e4, 0x9593, 0x8276, 0x18f9, 0x89bf, 0xcf05, 0x8276, + 0xe708, 0x6a6e, 0x471d, 0x7d8a, 0xe708, 0xf375, 0x809e, 0xdad8, 0x8583, + 0xe708, 0x8276, 0x9d0e, 0xaecd, 0xc3aa, 0x70e3, 0x471d, 0x9593, 0xc3aa, + 0x8f1e, 0x809e, 0xf375, 0x9593, 0xb8e4, 0x8583, 0xdad8, 0x5134, 0x62f2, + 0x6a6e, 0xb8e4, 0xdad8, 0x8583, 0x9d0e, 0xaecd, 0xb8e4, 0x9593, 0x8f1e, + 0xc3aa, 0x0c8c, 0x7f62, 0x18f9, 0x8276, 0xaecd, 0x9d0e, 0x8f1e, 0x3c57, + 0x8276, 0xe708, 0x809e, 0xf375, 0x7a7d, 0x2528, 0x7f62, 0xf375, 0xf9b9, + 0x8028, 0xed38, 0x8163, 0xf375, 0x809e, 0xa129, 0xaa0b, 0xb3c1, 0x66d0, + 0x5134, 0x9d0e, 0xc946, 0x8c4b, 0x83d7, 0xe0e7, 0x9d0e, 0xaecd, 0x877c, + 0xd4e1, 0x41ce, 0x6dca, 0x70e3, 0xc3aa, 0xe0e7, 0x83d7, 0xaa0b, 0xa129, + 0xc3aa, 0x8f1e, 0x9236, 0xbe32, 0xf9b9, 0x7fd9, 0x2528, 0x8583, 0xb3c1, + 0x9931, 0x877c, 0x2b1f, 0x8583, 0xdad8, 0x8163, 0xed38, 0x73b6, 0x36ba, + 0x7a7d, 0xdad8, 0xed38, 0x8163, 0xc946, 0x8c4b, 0xdad8, 0x8583, 0x9931, + 0xb3c1, 0xd4e1, 0x7885, 0x3c57, 0x8f1e, 0xbe32, 0x9236, 0x8028, 0x0648, + 0x8f1e, 0xc3aa, 0x83d7, 0xe0e7, 0x5ed7, 0x55f6, 0x62f2, 0xaecd, 0xd4e1, + 0x877c, 0x9236, 0xbe32, 0xaecd, 0x9d0e, 0x8c4b, 0xc946, 0x1f1a, 0x7c2a, + 0x0c8c, 0x809e, 0xaa0b, 0xa129, 0x9931, 0x4c40, 0x809e, 0xf375, 0x8028, + 0xf9b9, 0x7e9d, 0x12c8, 0x7fd9, 0xf9b9, 0xfcdc, 0x800a, 0xf696, 0x8059, + 0xf9b9, 0x8028, 0xa34c, 0xa7be, 0xac65, 0x60ec, 0x55f6, 0xa129, 0xcc22, + 0x8afc, 0x8676, 0xd7da, 0xa129, 0xaa0b, 0x8894, 0xd1ef, 0x398d, 0x7255, + 0x73b6, 0xc946, 0xe3f5, 0x831d, 0xb141, 0x9b18, 0xc946, 0x8c4b, 0x93dc, + 0xbb86, 0xf055, 0x7f0a, 0x2b1f, 0x877c, 0xb64c, 0x975a, 0x84a3, 0x2224, + 0x877c, 0xd4e1, 0x81e3, 0xea1e, 0x6f5f, 0x3f17, 0x7c2a, 0xe0e7, 0xf055, + 0x80f7, 0xd1ef, 0x8894, 0xe0e7, 0x83d7, 0x9b18, 0xb141, 0xcc22, 0x7505, + 0x41ce, 0x9236, 0xc0e9, 0x90a1, 0x800a, 0xfcdc, 0x9236, 0xbe32, 0x84a3, + 0xdddd, 0x5843, 0x5cb4, 0x66d0, 0xb3c1, 0xd7da, 0x8676, 0x975a, 0xb64c, + 0xb3c1, 0x9931, 0x8dab, 0xc674, 0x15e2, 0x7e1e, 0x12c8, 0x8163, 0xac65, + 0x9f14, 0x93dc, 0x447b, 0x8163, 0xed38, 0x8059, 0xf696, 0x7ce4, 0x1c0c, + 0x7e9d, 0xed38, 0xf696, 0x8059, 0xe3f5, 0x831d, 0xed38, 0x8163, 0x9f14, + 0xac65, 0xbb86, 0x6c24, 0x4c40, 0x9931, 0xc674, 0x8dab, 0x81e3, 0xea1e, + 0x9931, 0xb3c1, 0x8676, 0xd7da, 0x49b4, 0x68a7, 0x6dca, 0xbe32, 0xdddd, + 0x84a3, 0xa34c, 0xa7be, 0xbe32, 0x9236, 0x90a1, 0xc0e9, 0x0324, 0x7ff6, + 0x1f1a, 0x83d7, 0xb141, 0x9b18, 0x8afc, 0x33df, 0x83d7, 0xe0e7, 0x80f7, + 0xf055, 0x776c, 0x2e11, 0x7885, 0xd4e1, 0xea1e, 0x81e3, 0xc0e9, 0x90a1, + 0xd4e1, 0x877c, 0x975a, 0xb64c, 0xdddd, 0x7b5d, 0x36ba, 0x8c4b, 0xbb86, + 0x93dc, 0x80f7, 0x0fab, 0x8c4b, 0xc946, 0x831d, 0xe3f5, 0x64e9, 0x4ec0, + 0x5ed7, 0xaa0b, 0xd1ef, 0x8894, 0x8dab, 0xc674, 0xaa0b, 0xa129, 0x8afc, + 0xcc22, 0x2827, 0x798a, 0x0648, 0x8028, 0xa7be, 0xa34c, 0x9f14, 0x539b, + 0x8028, 0xf9b9, 0x800a, 0xfcdc, 0x7fa7, 0x096b, 0x7ff6, 0xfcdc, 0xfe6e, + 0x8003, 0xfb4a, 0x8017, 0xfcdc, 0x800a, 0xa463, 0xa69c, 0xa8e3, 0x5dc8, + 0x5843, 0xa34c, 0xcd92, 0x8a5b, 0x8806, 0xd368, 0xa34c, 0xa7be, 0x8927, + 0xd079, 0x354e, 0x7460, 0x7505, 0xcc22, 0xe57e, 0x82c7, 0xb505, 0x9843, + 0xcc22, 0x8afc, 0x94b6, 0xba33, 0xebab, 0x7e60, 0x2e11, 0x8894, 0xb797, + 0x9674, 0x8377, 0x1d93, 0x8894, 0xd1ef, 0x822a, 0xe893, 0x6cf9, 0x4326, + 0x7ce4, 0xe3f5, 0xf1e5, 0x80c8, 0xd65d, 0x86f7, 0xe3f5, 0x831d, 0x9c11, + 0xb005, 0xc7dc, 0x7308, 0x447b, 0x93dc, 0xc248, 0x8fdd, 0x803e, 0xf827, + 0x93dc, 0xbb86, 0x8511, 0xdc5a, 0x54ca, 0x5fe4, 0x68a7, 0xb64c, 0xd958, + 0x85fb, 0x9a23, 0xb27f, 0xb64c, 0x975a, 0x8e62, 0xc50e, 0x113a, 0x7ed6, + 0x15e2, 0x81e3, 0xad97, 0x9e0f, 0x916a, 0x4074, 0x81e3, 0xea1e, 0x8079, + 0xf505, 0x7bc6, 0x209f, 0x7f0a, 0xf055, 0xf827, 0x803e, 0xe893, 0x822a, + 0xf055, 0x80f7, 0xa01d, 0xab36, 0xb797, 0x698c, 0x4ec0, 0x9b18, 0xc7dc, + 0x8cf9, 0x82c7, 0xe57e, 0x9b18, 0xb141, 0x86f7, 0xd65d, 0x45cd, 0x6b4b, + 0x6f5f, 0xc0e9, 0xdf61, 0x843b, 0xa69c, 0xa463, 0xc0e9, 0x90a1, 0x916a, + 0xbf8d, 0xfe6e, 0x7ffe, 0x2224, 0x84a3, 0xb27f, 0x9a23, 0x8927, 0x2f87, + 0x84a3, 0xdddd, 0x812b, 0xeec7, 0x75a6, 0x326e, 0x798a, 0xd7da, 0xebab, + 0x81a1, 0xc50e, 0x8e62, 0xd7da, 0x8676, 0x9843, 0xb505, 0xd958, 0x7a06, + 0x398d, 0x8dab, 0xbcdb, 0x9307, 0x8079, 0x0afb, 0x8dab, 0xc674, 0x8377, + 0xe26d, 0x61f1, 0x5269, 0x60ec, 0xac65, 0xd368, 0x8806, 0x8fdd, 0xc248, + 0xac65, 0x9f14, 0x8ba1, 0xcab3, 0x23a7, 0x7aef, 0x096b, 0x8059, 0xa8e3, + 0xa239, 0x9c11, 0x4ffb, 0x8059, 0xf696, 0x8017, 0xfb4a, 0x7f38, 0x0e1c, + 0x7fa7, 0xf696, 0xfb4a, 0x8017, 0xf1e5, 0x80c8, 0xf696, 0x8059, 0xa239, + 0xa8e3, 0xb005, 0x63ef, 0x539b, 0x9f14, 0xcab3, 0x8ba1, 0x8511, 0xdc5a, + 0x9f14, 0xac65, 0x8806, 0xd368, 0x3db8, 0x7023, 0x7255, 0xc674, 0xe26d, + 0x8377, 0xad97, 0x9e0f, 0xc674, 0x8dab, 0x9307, 0xbcdb, 0xf505, 0x7f87, + 0x2827, 0x8676, 0xb505, 0x9843, 0x85fb, 0x26a8, 0x8676, 0xd7da, 0x81a1, + 0xebab, 0x719e, 0x3af3, 0x7b5d, 0xdddd, 0xeec7, 0x812b, 0xcd92, 0x8a5b, + 0xdddd, 0x84a3, 0x9a23, 0xb27f, 0xd079, 0x76d9, 0x3f17, 0x90a1, 0xbf8d, + 0x916a, 0x8003, 0x0192, 0x90a1, 0xc0e9, 0x843b, 0xdf61, 0x5b9d, 0x5964, + 0x64e9, 0xb141, 0xd65d, 0x86f7, 0x94b6, 0xba33, 0xb141, 0x9b18, 0x8cf9, + 0xc7dc, 0x1a83, 0x7d3a, 0x0fab, 0x80f7, 0xab36, 0xa01d, 0x9674, 0x486a, + 0x80f7, 0xf055, 0x803e, 0xf827, 0x7dd6, 0x176e, 0x7e1e, 0xea1e, 0xf505, + 0x8079, 0xdf61, 0x843b, 0xea1e, 0x81e3, 0x9e0f, 0xad97, 0xbf8d, 0x6e97, + 0x49b4, 0x975a, 0xc50e, 0x8e62, 0x812b, 0xeec7, 0x975a, 0xb64c, 0x85fb, + 0xd958, 0x4d81, 0x65de, 0x6c24, 0xbb86, 0xdc5a, 0x8511, 0xa01d, 0xab36, + 0xbb86, 0x93dc, 0x8fdd, 0xc248, 0x07d9, 0x7fc2, 0x1c0c, 0x831d, 0xb005, + 0x9c11, 0x8cf9, 0x3825, 0x831d, 0xe3f5, 0x80c8, 0xf1e5, 0x790a, 0x29a4, + 0x776c, 0xd1ef, 0xe893, 0x822a, 0xbcdb, 0x9307, 0xd1ef, 0x8894, 0x9674, + 0xb797, 0xe26d, 0x7c89, 0x33df, 0x8afc, 0xba33, 0x94b6, 0x81a1, 0x1455, + 0x8afc, 0xcc22, 0x82c7, 0xe57e, 0x67bd, 0x4afb, 0x5cb4, 0xa7be, 0xd079, + 0x8927, 0x8ba1, 0xcab3, 0xa7be, 0xa34c, 0x8a5b, 0xcd92, 0x2c99, 0x77fb, + 0x0324, 0x800a, 0xa69c, 0xa463, 0xa239, 0x571e, 0x800a, 0xfcdc, 0x8003, + 0xfe6e, 0x7fea, 0x04b6}; + +// Twiddle factors used for the last stage of N-point real FFT +// generated as j*W^k, k=1, 2, ... N/4 +// That's 128 complex int16_t elements +// Or 256 real int16_t elements +const uint16_t rtwiddles[] __attribute__((aligned(8))) = { + 0x0192, 0x7ffe, 0x0324, 0x7ff6, 0x04b6, 0x7fea, 0x0648, 0x7fd9, 0x07d9, + 0x7fc2, 0x096b, 0x7fa7, 0x0afb, 0x7f87, 0x0c8c, 0x7f62, 0x0e1c, 0x7f38, + 0x0fab, 0x7f0a, 0x113a, 0x7ed6, 0x12c8, 0x7e9d, 0x1455, 0x7e60, 0x15e2, + 0x7e1e, 0x176e, 0x7dd6, 0x18f9, 0x7d8a, 0x1a83, 0x7d3a, 0x1c0c, 0x7ce4, + 0x1d93, 0x7c89, 0x1f1a, 0x7c2a, 0x209f, 0x7bc6, 0x2224, 0x7b5d, 0x23a7, + 0x7aef, 0x2528, 0x7a7d, 0x26a8, 0x7a06, 0x2827, 0x798a, 0x29a4, 0x790a, + 0x2b1f, 0x7885, 0x2c99, 0x77fb, 0x2e11, 0x776c, 0x2f87, 0x76d9, 0x30fc, + 0x7642, 0x326e, 0x75a6, 0x33df, 0x7505, 0x354e, 0x7460, 0x36ba, 0x73b6, + 0x3825, 0x7308, 0x398d, 0x7255, 0x3af3, 0x719e, 0x3c57, 0x70e3, 0x3db8, + 0x7023, 0x3f17, 0x6f5f, 0x4074, 0x6e97, 0x41ce, 0x6dca, 0x4326, 0x6cf9, + 0x447b, 0x6c24, 0x45cd, 0x6b4b, 0x471d, 0x6a6e, 0x486a, 0x698c, 0x49b4, + 0x68a7, 0x4afb, 0x67bd, 0x4c40, 0x66d0, 0x4d81, 0x65de, 0x4ec0, 0x64e9, + 0x4ffb, 0x63ef, 0x5134, 0x62f2, 0x5269, 0x61f1, 0x539b, 0x60ec, 0x54ca, + 0x5fe4, 0x55f6, 0x5ed7, 0x571e, 0x5dc8, 0x5843, 0x5cb4, 0x5964, 0x5b9d, + 0x5a82, 0x5a82, 0x5b9d, 0x5964, 0x5cb4, 0x5843, 0x5dc8, 0x571e, 0x5ed7, + 0x55f6, 0x5fe4, 0x54ca, 0x60ec, 0x539b, 0x61f1, 0x5269, 0x62f2, 0x5134, + 0x63ef, 0x4ffb, 0x64e9, 0x4ec0, 0x65de, 0x4d81, 0x66d0, 0x4c40, 0x67bd, + 0x4afb, 0x68a7, 0x49b4, 0x698c, 0x486a, 0x6a6e, 0x471d, 0x6b4b, 0x45cd, + 0x6c24, 0x447b, 0x6cf9, 0x4326, 0x6dca, 0x41ce, 0x6e97, 0x4074, 0x6f5f, + 0x3f17, 0x7023, 0x3db8, 0x70e3, 0x3c57, 0x719e, 0x3af3, 0x7255, 0x398d, + 0x7308, 0x3825, 0x73b6, 0x36ba, 0x7460, 0x354e, 0x7505, 0x33df, 0x75a6, + 0x326e, 0x7642, 0x30fc, 0x76d9, 0x2f87, 0x776c, 0x2e11, 0x77fb, 0x2c99, + 0x7885, 0x2b1f, 0x790a, 0x29a4, 0x798a, 0x2827, 0x7a06, 0x26a8, 0x7a7d, + 0x2528, 0x7aef, 0x23a7, 0x7b5d, 0x2224, 0x7bc6, 0x209f, 0x7c2a, 0x1f1a, + 0x7c89, 0x1d93, 0x7ce4, 0x1c0c, 0x7d3a, 0x1a83, 0x7d8a, 0x18f9, 0x7dd6, + 0x176e, 0x7e1e, 0x15e2, 0x7e60, 0x1455, 0x7e9d, 0x12c8, 0x7ed6, 0x113a, + 0x7f0a, 0x0fab, 0x7f38, 0x0e1c, 0x7f62, 0x0c8c, 0x7f87, 0x0afb, 0x7fa7, + 0x096b, 0x7fc2, 0x07d9, 0x7fd9, 0x0648, 0x7fea, 0x04b6, 0x7ff6, 0x0324, + 0x7ffe, 0x0192, 0x7fff, 0x0000}; + +struct RfftState { + int16_t* aligned_input; + int32_t fft_length; +}; + +size_t RfftInt16GetNeededMemory(int32_t fft_length) { + return sizeof(RfftState) + 2 * sizeof(int16_t) * fft_length; +} + +void* RfftInt16Init(int32_t fft_length, void* state, size_t state_size) { + RfftState* rfft_state = (RfftState*)state; + int16_t* unaligned_buffer = (int16_t*)(rfft_state + 1); + rfft_state->aligned_input = + (int16_t*)((uint32_t)(unaligned_buffer + fft_length) & + ~((1 << tflite::tflm_signal::MostSignificantBit32( + fft_length)) - + 1)); + rfft_state->fft_length = fft_length; + return state; +} + +void RfftInt16Apply(void* state, const int16_t* input, + Complex* output) { + RfftState* rfft_state = (RfftState*)state; + memcpy(rfft_state->aligned_input, input, + rfft_state->fft_length * sizeof(int16_t)); + rfft(rfft_state->aligned_input, rfft_state->fft_length, (CWord2x16*)twiddles, + (CWord2x16*)rtwiddles, (CWord2x16*)output); + return; +} + +} // namespace tflm_signal + diff --git a/signal/micro/kernels/hexagon/square_root_32.cc b/signal/micro/kernels/hexagon/square_root_32.cc new file mode 100644 index 00000000000..ff89a836ba2 --- /dev/null +++ b/signal/micro/kernels/hexagon/square_root_32.cc @@ -0,0 +1,28 @@ +/* Copyright 2021 The TensorFlow Authors. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +==============================================================================*/ +#include "signal/src/square_root.h" + +extern "C" uint16_t SignalHexagonSqrt32(uint32_t num); + +namespace tflite { +namespace tflm_signal { + +// SignalHexagonSqrt32() is defined in assembly. This C wrapper is only +// necessary to force TFLM's source specialization to pick up the optimized +// Hexagon implementation instead of the portable one. +uint16_t Sqrt32(uint32_t num) { return SignalHexagonSqrt32(num); } + +} // namespace tflm_signal +} // namespace tflite diff --git a/signal/micro/kernels/xtensa/rfft_int16.cc b/signal/micro/kernels/xtensa/rfft_int16.cc new file mode 100644 index 00000000000..cf563971382 --- /dev/null +++ b/signal/micro/kernels/xtensa/rfft_int16.cc @@ -0,0 +1,910 @@ +/* Copyright 2023 The TensorFlow Authors. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +==============================================================================*/ + +#include +#include +#include + +#if XCHAL_HAVE_HIFI3 || XCHAL_HAVE_HIFI4 || XCHAL_HAVE_HIFI5 +#include +#elif XCHAL_HAVE_HIFI_MINI || XCHAL_HAVE_HIFI2 || XCHAL_HAVE_HIFI_EP +#include + +#include "hifi2_fft/fft_core.h" +#else +#include "signal/src/kiss_fft_wrappers/kiss_fft_int16.h" +#endif +#include "signal/src/complex.h" +#include "signal/src/rfft.h" + +namespace tflm_signal { + +#if !defined MIN_RFFT_LEN +#define MIN_RFFT_LEN 32 +#endif +#if !defined MAX_RFFT_LEN +#define MAX_RFFT_LEN 8192 +#endif + +#if XCHAL_HAVE_HIFI3 || XCHAL_HAVE_HIFI4 || XCHAL_HAVE_HIFI5 +struct RfftState { +#if defined XTENSA_NDSP_FFT_MEM_OPTIMIZED + int32_t fft_length; + int32_t fft_length_log2; + int32_t output_length; +#endif + fft_handle_t handle; +}; +#elif XCHAL_HAVE_HIFI_MINI || XCHAL_HAVE_HIFI2 || XCHAL_HAVE_HIFI_EP +struct RfftState { + int32_t* scratch; + int32_t fft_length; +}; +#else +// Using KissFFT. No need for state. +#endif + +#if XTENSA_NDSP_FFT_MEM_OPTIMIZED + +// The Nature DSP library has a memory optimized implementation if FFT that +// uses ~18KB less code than the fully-featured FFT implementation. However, it +// is limited to FFT of sizes 256, 512, 1024 and only supports dynamic scaling +// with right shifts. It also take a twiddle table as an input. +// The twiddle tables are in a highly unusual format, which isn't documented. +// Instead of trying to figure out the close form for the table, the actual +// arrays were copied from the library's test vectors: +// fft_cplx32x16_ie_twd_256.bin +// fft_cplx32x16_ie_twd_512.bin +// fft_cplx32x16_ie_twd_1024.bin +// located under NDSP_HiFi3_v410/testdriver/vectors_sanity/fft_twd +// The vectors were converted from fp64 to int16 by multiplying each element +// by 32767 and limiting the value to [-32768,32767]. This is the same +// conversion done in Nature DSP's test engine. + +#if MIN_RFFT_LEN <= 256 && MAX_RFFT_LEN >= 256 +const complex_fract16 twiddles_256[] = { + {.s = {.re = 0, .im = 32767}}, {.s = {.re = -804, .im = 32757}}, + {.s = {.re = -1608, .im = 32728}}, {.s = {.re = -2410, .im = 32678}}, + {.s = {.re = -3212, .im = 32609}}, {.s = {.re = -4011, .im = 32521}}, + {.s = {.re = -4808, .im = 32412}}, {.s = {.re = -5602, .im = 32285}}, + {.s = {.re = -6393, .im = 32137}}, {.s = {.re = -7179, .im = 31971}}, + {.s = {.re = -7962, .im = 31785}}, {.s = {.re = -8739, .im = 31580}}, + {.s = {.re = -9512, .im = 31356}}, {.s = {.re = -10278, .im = 31113}}, + {.s = {.re = -11039, .im = 30852}}, {.s = {.re = -11793, .im = 30571}}, + {.s = {.re = -12539, .im = 30273}}, {.s = {.re = -13279, .im = 29956}}, + {.s = {.re = -14010, .im = 29621}}, {.s = {.re = -14732, .im = 29268}}, + {.s = {.re = -15446, .im = 28898}}, {.s = {.re = -16151, .im = 28510}}, + {.s = {.re = -16846, .im = 28105}}, {.s = {.re = -17530, .im = 27683}}, + {.s = {.re = -18204, .im = 27245}}, {.s = {.re = -18868, .im = 26790}}, + {.s = {.re = -19519, .im = 26319}}, {.s = {.re = -20159, .im = 25832}}, + {.s = {.re = -20787, .im = 25329}}, {.s = {.re = -21403, .im = 24811}}, + {.s = {.re = -22005, .im = 24279}}, {.s = {.re = -22594, .im = 23731}}, + {.s = {.re = -23170, .im = 23170}}, {.s = {.re = -23731, .im = 22594}}, + {.s = {.re = -24279, .im = 22005}}, {.s = {.re = -24811, .im = 21403}}, + {.s = {.re = -25329, .im = 20787}}, {.s = {.re = -25832, .im = 20159}}, + {.s = {.re = -26319, .im = 19519}}, {.s = {.re = -26790, .im = 18868}}, + {.s = {.re = -27245, .im = 18204}}, {.s = {.re = -27683, .im = 17530}}, + {.s = {.re = -28105, .im = 16846}}, {.s = {.re = -28510, .im = 16151}}, + {.s = {.re = -28898, .im = 15446}}, {.s = {.re = -29268, .im = 14732}}, + {.s = {.re = -29621, .im = 14010}}, {.s = {.re = -29956, .im = 13279}}, + {.s = {.re = -30273, .im = 12539}}, {.s = {.re = -30571, .im = 11793}}, + {.s = {.re = -30852, .im = 11039}}, {.s = {.re = -31113, .im = 10278}}, + {.s = {.re = -31356, .im = 9512}}, {.s = {.re = -31580, .im = 8739}}, + {.s = {.re = -31785, .im = 7962}}, {.s = {.re = -31971, .im = 7179}}, + {.s = {.re = -32137, .im = 6393}}, {.s = {.re = -32285, .im = 5602}}, + {.s = {.re = -32412, .im = 4808}}, {.s = {.re = -32521, .im = 4011}}, + {.s = {.re = -32609, .im = 3212}}, {.s = {.re = -32678, .im = 2410}}, + {.s = {.re = -32728, .im = 1608}}, {.s = {.re = -32757, .im = 804}}, + {.s = {.re = 0, .im = 32767}}, {.s = {.re = -1608, .im = 32728}}, + {.s = {.re = -3212, .im = 32609}}, {.s = {.re = -4808, .im = 32412}}, + {.s = {.re = -6393, .im = 32137}}, {.s = {.re = -7962, .im = 31785}}, + {.s = {.re = -9512, .im = 31356}}, {.s = {.re = -11039, .im = 30852}}, + {.s = {.re = -12539, .im = 30273}}, {.s = {.re = -14010, .im = 29621}}, + {.s = {.re = -15446, .im = 28898}}, {.s = {.re = -16846, .im = 28105}}, + {.s = {.re = -18204, .im = 27245}}, {.s = {.re = -19519, .im = 26319}}, + {.s = {.re = -20787, .im = 25329}}, {.s = {.re = -22005, .im = 24279}}, + {.s = {.re = -23170, .im = 23170}}, {.s = {.re = -24279, .im = 22005}}, + {.s = {.re = -25329, .im = 20787}}, {.s = {.re = -26319, .im = 19519}}, + {.s = {.re = -27245, .im = 18204}}, {.s = {.re = -28105, .im = 16846}}, + {.s = {.re = -28898, .im = 15446}}, {.s = {.re = -29621, .im = 14010}}, + {.s = {.re = -30273, .im = 12539}}, {.s = {.re = -30852, .im = 11039}}, + {.s = {.re = -31356, .im = 9512}}, {.s = {.re = -31785, .im = 7962}}, + {.s = {.re = -32137, .im = 6393}}, {.s = {.re = -32412, .im = 4808}}, + {.s = {.re = -32609, .im = 3212}}, {.s = {.re = -32728, .im = 1608}}, + {.s = {.re = -32767, .im = 0}}, {.s = {.re = -32728, .im = -1608}}, + {.s = {.re = -32609, .im = -3212}}, {.s = {.re = -32412, .im = -4808}}, + {.s = {.re = -32137, .im = -6393}}, {.s = {.re = -31785, .im = -7962}}, + {.s = {.re = -31356, .im = -9512}}, {.s = {.re = -30852, .im = -11039}}, + {.s = {.re = -30273, .im = -12539}}, {.s = {.re = -29621, .im = -14010}}, + {.s = {.re = -28898, .im = -15446}}, {.s = {.re = -28105, .im = -16846}}, + {.s = {.re = -27245, .im = -18204}}, {.s = {.re = -26319, .im = -19519}}, + {.s = {.re = -25329, .im = -20787}}, {.s = {.re = -24279, .im = -22005}}, + {.s = {.re = -23170, .im = -23170}}, {.s = {.re = -22005, .im = -24279}}, + {.s = {.re = -20787, .im = -25329}}, {.s = {.re = -19519, .im = -26319}}, + {.s = {.re = -18204, .im = -27245}}, {.s = {.re = -16846, .im = -28105}}, + {.s = {.re = -15446, .im = -28898}}, {.s = {.re = -14010, .im = -29621}}, + {.s = {.re = -12539, .im = -30273}}, {.s = {.re = -11039, .im = -30852}}, + {.s = {.re = -9512, .im = -31356}}, {.s = {.re = -7962, .im = -31785}}, + {.s = {.re = -6393, .im = -32137}}, {.s = {.re = -4808, .im = -32412}}, + {.s = {.re = -3212, .im = -32609}}, {.s = {.re = -1608, .im = -32728}}, + {.s = {.re = 0, .im = 32767}}, {.s = {.re = -2410, .im = 32678}}, + {.s = {.re = -4808, .im = 32412}}, {.s = {.re = -7179, .im = 31971}}, + {.s = {.re = -9512, .im = 31356}}, {.s = {.re = -11793, .im = 30571}}, + {.s = {.re = -14010, .im = 29621}}, {.s = {.re = -16151, .im = 28510}}, + {.s = {.re = -18204, .im = 27245}}, {.s = {.re = -20159, .im = 25832}}, + {.s = {.re = -22005, .im = 24279}}, {.s = {.re = -23731, .im = 22594}}, + {.s = {.re = -25329, .im = 20787}}, {.s = {.re = -26790, .im = 18868}}, + {.s = {.re = -28105, .im = 16846}}, {.s = {.re = -29268, .im = 14732}}, + {.s = {.re = -30273, .im = 12539}}, {.s = {.re = -31113, .im = 10278}}, + {.s = {.re = -31785, .im = 7962}}, {.s = {.re = -32285, .im = 5602}}, + {.s = {.re = -32609, .im = 3212}}, {.s = {.re = -32757, .im = 804}}, + {.s = {.re = -32728, .im = -1608}}, {.s = {.re = -32521, .im = -4011}}, + {.s = {.re = -32137, .im = -6393}}, {.s = {.re = -31580, .im = -8739}}, + {.s = {.re = -30852, .im = -11039}}, {.s = {.re = -29956, .im = -13279}}, + {.s = {.re = -28898, .im = -15446}}, {.s = {.re = -27683, .im = -17530}}, + {.s = {.re = -26319, .im = -19519}}, {.s = {.re = -24811, .im = -21403}}, + {.s = {.re = -23170, .im = -23170}}, {.s = {.re = -21403, .im = -24811}}, + {.s = {.re = -19519, .im = -26319}}, {.s = {.re = -17530, .im = -27683}}, + {.s = {.re = -15446, .im = -28898}}, {.s = {.re = -13279, .im = -29956}}, + {.s = {.re = -11039, .im = -30852}}, {.s = {.re = -8739, .im = -31580}}, + {.s = {.re = -6393, .im = -32137}}, {.s = {.re = -4011, .im = -32521}}, + {.s = {.re = -1608, .im = -32728}}, {.s = {.re = 804, .im = -32757}}, + {.s = {.re = 3212, .im = -32609}}, {.s = {.re = 5602, .im = -32285}}, + {.s = {.re = 7962, .im = -31785}}, {.s = {.re = 10278, .im = -31113}}, + {.s = {.re = 12539, .im = -30273}}, {.s = {.re = 14732, .im = -29268}}, + {.s = {.re = 16846, .im = -28105}}, {.s = {.re = 18868, .im = -26790}}, + {.s = {.re = 20787, .im = -25329}}, {.s = {.re = 22594, .im = -23731}}, + {.s = {.re = 24279, .im = -22005}}, {.s = {.re = 25832, .im = -20159}}, + {.s = {.re = 27245, .im = -18204}}, {.s = {.re = 28510, .im = -16151}}, + {.s = {.re = 29621, .im = -14010}}, {.s = {.re = 30571, .im = -11793}}, + {.s = {.re = 31356, .im = -9512}}, {.s = {.re = 31971, .im = -7179}}, + {.s = {.re = 32412, .im = -4808}}, {.s = {.re = 32678, .im = -2410}}, +}; +#endif + +#if MIN_RFFT_LEN <= 512 && MAX_RFFT_LEN >= 512 +const complex_fract16 twiddles_512[] = { + {.s = {.re = 0, .im = 32767}}, {.s = {.re = -402, .im = 32765}}, + {.s = {.re = -804, .im = 32757}}, {.s = {.re = -1206, .im = 32745}}, + {.s = {.re = -1608, .im = 32728}}, {.s = {.re = -2009, .im = 32705}}, + {.s = {.re = -2410, .im = 32678}}, {.s = {.re = -2811, .im = 32646}}, + {.s = {.re = -3212, .im = 32609}}, {.s = {.re = -3612, .im = 32567}}, + {.s = {.re = -4011, .im = 32521}}, {.s = {.re = -4410, .im = 32469}}, + {.s = {.re = -4808, .im = 32412}}, {.s = {.re = -5205, .im = 32351}}, + {.s = {.re = -5602, .im = 32285}}, {.s = {.re = -5998, .im = 32213}}, + {.s = {.re = -6393, .im = 32137}}, {.s = {.re = -6786, .im = 32057}}, + {.s = {.re = -7179, .im = 31971}}, {.s = {.re = -7571, .im = 31880}}, + {.s = {.re = -7962, .im = 31785}}, {.s = {.re = -8351, .im = 31685}}, + {.s = {.re = -8739, .im = 31580}}, {.s = {.re = -9126, .im = 31470}}, + {.s = {.re = -9512, .im = 31356}}, {.s = {.re = -9896, .im = 31237}}, + {.s = {.re = -10278, .im = 31113}}, {.s = {.re = -10659, .im = 30985}}, + {.s = {.re = -11039, .im = 30852}}, {.s = {.re = -11417, .im = 30714}}, + {.s = {.re = -11793, .im = 30571}}, {.s = {.re = -12167, .im = 30424}}, + {.s = {.re = -12539, .im = 30273}}, {.s = {.re = -12910, .im = 30117}}, + {.s = {.re = -13279, .im = 29956}}, {.s = {.re = -13645, .im = 29791}}, + {.s = {.re = -14010, .im = 29621}}, {.s = {.re = -14372, .im = 29447}}, + {.s = {.re = -14732, .im = 29268}}, {.s = {.re = -15090, .im = 29085}}, + {.s = {.re = -15446, .im = 28898}}, {.s = {.re = -15800, .im = 28706}}, + {.s = {.re = -16151, .im = 28510}}, {.s = {.re = -16499, .im = 28310}}, + {.s = {.re = -16846, .im = 28105}}, {.s = {.re = -17189, .im = 27896}}, + {.s = {.re = -17530, .im = 27683}}, {.s = {.re = -17869, .im = 27466}}, + {.s = {.re = -18204, .im = 27245}}, {.s = {.re = -18537, .im = 27019}}, + {.s = {.re = -18868, .im = 26790}}, {.s = {.re = -19195, .im = 26556}}, + {.s = {.re = -19519, .im = 26319}}, {.s = {.re = -19841, .im = 26077}}, + {.s = {.re = -20159, .im = 25832}}, {.s = {.re = -20475, .im = 25582}}, + {.s = {.re = -20787, .im = 25329}}, {.s = {.re = -21096, .im = 25072}}, + {.s = {.re = -21403, .im = 24811}}, {.s = {.re = -21705, .im = 24547}}, + {.s = {.re = -22005, .im = 24279}}, {.s = {.re = -22301, .im = 24007}}, + {.s = {.re = -22594, .im = 23731}}, {.s = {.re = -22884, .im = 23452}}, + {.s = {.re = -23170, .im = 23170}}, {.s = {.re = -23452, .im = 22884}}, + {.s = {.re = -23731, .im = 22594}}, {.s = {.re = -24007, .im = 22301}}, + {.s = {.re = -24279, .im = 22005}}, {.s = {.re = -24547, .im = 21705}}, + {.s = {.re = -24811, .im = 21403}}, {.s = {.re = -25072, .im = 21096}}, + {.s = {.re = -25329, .im = 20787}}, {.s = {.re = -25582, .im = 20475}}, + {.s = {.re = -25832, .im = 20159}}, {.s = {.re = -26077, .im = 19841}}, + {.s = {.re = -26319, .im = 19519}}, {.s = {.re = -26556, .im = 19195}}, + {.s = {.re = -26790, .im = 18868}}, {.s = {.re = -27019, .im = 18537}}, + {.s = {.re = -27245, .im = 18204}}, {.s = {.re = -27466, .im = 17869}}, + {.s = {.re = -27683, .im = 17530}}, {.s = {.re = -27896, .im = 17189}}, + {.s = {.re = -28105, .im = 16846}}, {.s = {.re = -28310, .im = 16499}}, + {.s = {.re = -28510, .im = 16151}}, {.s = {.re = -28706, .im = 15800}}, + {.s = {.re = -28898, .im = 15446}}, {.s = {.re = -29085, .im = 15090}}, + {.s = {.re = -29268, .im = 14732}}, {.s = {.re = -29447, .im = 14372}}, + {.s = {.re = -29621, .im = 14010}}, {.s = {.re = -29791, .im = 13645}}, + {.s = {.re = -29956, .im = 13279}}, {.s = {.re = -30117, .im = 12910}}, + {.s = {.re = -30273, .im = 12539}}, {.s = {.re = -30424, .im = 12167}}, + {.s = {.re = -30571, .im = 11793}}, {.s = {.re = -30714, .im = 11417}}, + {.s = {.re = -30852, .im = 11039}}, {.s = {.re = -30985, .im = 10659}}, + {.s = {.re = -31113, .im = 10278}}, {.s = {.re = -31237, .im = 9896}}, + {.s = {.re = -31356, .im = 9512}}, {.s = {.re = -31470, .im = 9126}}, + {.s = {.re = -31580, .im = 8739}}, {.s = {.re = -31685, .im = 8351}}, + {.s = {.re = -31785, .im = 7962}}, {.s = {.re = -31880, .im = 7571}}, + {.s = {.re = -31971, .im = 7179}}, {.s = {.re = -32057, .im = 6786}}, + {.s = {.re = -32137, .im = 6393}}, {.s = {.re = -32213, .im = 5998}}, + {.s = {.re = -32285, .im = 5602}}, {.s = {.re = -32351, .im = 5205}}, + {.s = {.re = -32412, .im = 4808}}, {.s = {.re = -32469, .im = 4410}}, + {.s = {.re = -32521, .im = 4011}}, {.s = {.re = -32567, .im = 3612}}, + {.s = {.re = -32609, .im = 3212}}, {.s = {.re = -32646, .im = 2811}}, + {.s = {.re = -32678, .im = 2410}}, {.s = {.re = -32705, .im = 2009}}, + {.s = {.re = -32728, .im = 1608}}, {.s = {.re = -32745, .im = 1206}}, + {.s = {.re = -32757, .im = 804}}, {.s = {.re = -32765, .im = 402}}, + {.s = {.re = 0, .im = 32767}}, {.s = {.re = -804, .im = 32757}}, + {.s = {.re = -1608, .im = 32728}}, {.s = {.re = -2410, .im = 32678}}, + {.s = {.re = -3212, .im = 32609}}, {.s = {.re = -4011, .im = 32521}}, + {.s = {.re = -4808, .im = 32412}}, {.s = {.re = -5602, .im = 32285}}, + {.s = {.re = -6393, .im = 32137}}, {.s = {.re = -7179, .im = 31971}}, + {.s = {.re = -7962, .im = 31785}}, {.s = {.re = -8739, .im = 31580}}, + {.s = {.re = -9512, .im = 31356}}, {.s = {.re = -10278, .im = 31113}}, + {.s = {.re = -11039, .im = 30852}}, {.s = {.re = -11793, .im = 30571}}, + {.s = {.re = -12539, .im = 30273}}, {.s = {.re = -13279, .im = 29956}}, + {.s = {.re = -14010, .im = 29621}}, {.s = {.re = -14732, .im = 29268}}, + {.s = {.re = -15446, .im = 28898}}, {.s = {.re = -16151, .im = 28510}}, + {.s = {.re = -16846, .im = 28105}}, {.s = {.re = -17530, .im = 27683}}, + {.s = {.re = -18204, .im = 27245}}, {.s = {.re = -18868, .im = 26790}}, + {.s = {.re = -19519, .im = 26319}}, {.s = {.re = -20159, .im = 25832}}, + {.s = {.re = -20787, .im = 25329}}, {.s = {.re = -21403, .im = 24811}}, + {.s = {.re = -22005, .im = 24279}}, {.s = {.re = -22594, .im = 23731}}, + {.s = {.re = -23170, .im = 23170}}, {.s = {.re = -23731, .im = 22594}}, + {.s = {.re = -24279, .im = 22005}}, {.s = {.re = -24811, .im = 21403}}, + {.s = {.re = -25329, .im = 20787}}, {.s = {.re = -25832, .im = 20159}}, + {.s = {.re = -26319, .im = 19519}}, {.s = {.re = -26790, .im = 18868}}, + {.s = {.re = -27245, .im = 18204}}, {.s = {.re = -27683, .im = 17530}}, + {.s = {.re = -28105, .im = 16846}}, {.s = {.re = -28510, .im = 16151}}, + {.s = {.re = -28898, .im = 15446}}, {.s = {.re = -29268, .im = 14732}}, + {.s = {.re = -29621, .im = 14010}}, {.s = {.re = -29956, .im = 13279}}, + {.s = {.re = -30273, .im = 12539}}, {.s = {.re = -30571, .im = 11793}}, + {.s = {.re = -30852, .im = 11039}}, {.s = {.re = -31113, .im = 10278}}, + {.s = {.re = -31356, .im = 9512}}, {.s = {.re = -31580, .im = 8739}}, + {.s = {.re = -31785, .im = 7962}}, {.s = {.re = -31971, .im = 7179}}, + {.s = {.re = -32137, .im = 6393}}, {.s = {.re = -32285, .im = 5602}}, + {.s = {.re = -32412, .im = 4808}}, {.s = {.re = -32521, .im = 4011}}, + {.s = {.re = -32609, .im = 3212}}, {.s = {.re = -32678, .im = 2410}}, + {.s = {.re = -32728, .im = 1608}}, {.s = {.re = -32757, .im = 804}}, + {.s = {.re = -32767, .im = 0}}, {.s = {.re = -32757, .im = -804}}, + {.s = {.re = -32728, .im = -1608}}, {.s = {.re = -32678, .im = -2410}}, + {.s = {.re = -32609, .im = -3212}}, {.s = {.re = -32521, .im = -4011}}, + {.s = {.re = -32412, .im = -4808}}, {.s = {.re = -32285, .im = -5602}}, + {.s = {.re = -32137, .im = -6393}}, {.s = {.re = -31971, .im = -7179}}, + {.s = {.re = -31785, .im = -7962}}, {.s = {.re = -31580, .im = -8739}}, + {.s = {.re = -31356, .im = -9512}}, {.s = {.re = -31113, .im = -10278}}, + {.s = {.re = -30852, .im = -11039}}, {.s = {.re = -30571, .im = -11793}}, + {.s = {.re = -30273, .im = -12539}}, {.s = {.re = -29956, .im = -13279}}, + {.s = {.re = -29621, .im = -14010}}, {.s = {.re = -29268, .im = -14732}}, + {.s = {.re = -28898, .im = -15446}}, {.s = {.re = -28510, .im = -16151}}, + {.s = {.re = -28105, .im = -16846}}, {.s = {.re = -27683, .im = -17530}}, + {.s = {.re = -27245, .im = -18204}}, {.s = {.re = -26790, .im = -18868}}, + {.s = {.re = -26319, .im = -19519}}, {.s = {.re = -25832, .im = -20159}}, + {.s = {.re = -25329, .im = -20787}}, {.s = {.re = -24811, .im = -21403}}, + {.s = {.re = -24279, .im = -22005}}, {.s = {.re = -23731, .im = -22594}}, + {.s = {.re = -23170, .im = -23170}}, {.s = {.re = -22594, .im = -23731}}, + {.s = {.re = -22005, .im = -24279}}, {.s = {.re = -21403, .im = -24811}}, + {.s = {.re = -20787, .im = -25329}}, {.s = {.re = -20159, .im = -25832}}, + {.s = {.re = -19519, .im = -26319}}, {.s = {.re = -18868, .im = -26790}}, + {.s = {.re = -18204, .im = -27245}}, {.s = {.re = -17530, .im = -27683}}, + {.s = {.re = -16846, .im = -28105}}, {.s = {.re = -16151, .im = -28510}}, + {.s = {.re = -15446, .im = -28898}}, {.s = {.re = -14732, .im = -29268}}, + {.s = {.re = -14010, .im = -29621}}, {.s = {.re = -13279, .im = -29956}}, + {.s = {.re = -12539, .im = -30273}}, {.s = {.re = -11793, .im = -30571}}, + {.s = {.re = -11039, .im = -30852}}, {.s = {.re = -10278, .im = -31113}}, + {.s = {.re = -9512, .im = -31356}}, {.s = {.re = -8739, .im = -31580}}, + {.s = {.re = -7962, .im = -31785}}, {.s = {.re = -7179, .im = -31971}}, + {.s = {.re = -6393, .im = -32137}}, {.s = {.re = -5602, .im = -32285}}, + {.s = {.re = -4808, .im = -32412}}, {.s = {.re = -4011, .im = -32521}}, + {.s = {.re = -3212, .im = -32609}}, {.s = {.re = -2410, .im = -32678}}, + {.s = {.re = -1608, .im = -32728}}, {.s = {.re = -804, .im = -32757}}, + {.s = {.re = 0, .im = 32767}}, {.s = {.re = -1206, .im = 32745}}, + {.s = {.re = -2410, .im = 32678}}, {.s = {.re = -3612, .im = 32567}}, + {.s = {.re = -4808, .im = 32412}}, {.s = {.re = -5998, .im = 32213}}, + {.s = {.re = -7179, .im = 31971}}, {.s = {.re = -8351, .im = 31685}}, + {.s = {.re = -9512, .im = 31356}}, {.s = {.re = -10659, .im = 30985}}, + {.s = {.re = -11793, .im = 30571}}, {.s = {.re = -12910, .im = 30117}}, + {.s = {.re = -14010, .im = 29621}}, {.s = {.re = -15090, .im = 29085}}, + {.s = {.re = -16151, .im = 28510}}, {.s = {.re = -17189, .im = 27896}}, + {.s = {.re = -18204, .im = 27245}}, {.s = {.re = -19195, .im = 26556}}, + {.s = {.re = -20159, .im = 25832}}, {.s = {.re = -21096, .im = 25072}}, + {.s = {.re = -22005, .im = 24279}}, {.s = {.re = -22884, .im = 23452}}, + {.s = {.re = -23731, .im = 22594}}, {.s = {.re = -24547, .im = 21705}}, + {.s = {.re = -25329, .im = 20787}}, {.s = {.re = -26077, .im = 19841}}, + {.s = {.re = -26790, .im = 18868}}, {.s = {.re = -27466, .im = 17869}}, + {.s = {.re = -28105, .im = 16846}}, {.s = {.re = -28706, .im = 15800}}, + {.s = {.re = -29268, .im = 14732}}, {.s = {.re = -29791, .im = 13645}}, + {.s = {.re = -30273, .im = 12539}}, {.s = {.re = -30714, .im = 11417}}, + {.s = {.re = -31113, .im = 10278}}, {.s = {.re = -31470, .im = 9126}}, + {.s = {.re = -31785, .im = 7962}}, {.s = {.re = -32057, .im = 6786}}, + {.s = {.re = -32285, .im = 5602}}, {.s = {.re = -32469, .im = 4410}}, + {.s = {.re = -32609, .im = 3212}}, {.s = {.re = -32705, .im = 2009}}, + {.s = {.re = -32757, .im = 804}}, {.s = {.re = -32765, .im = -402}}, + {.s = {.re = -32728, .im = -1608}}, {.s = {.re = -32646, .im = -2811}}, + {.s = {.re = -32521, .im = -4011}}, {.s = {.re = -32351, .im = -5205}}, + {.s = {.re = -32137, .im = -6393}}, {.s = {.re = -31880, .im = -7571}}, + {.s = {.re = -31580, .im = -8739}}, {.s = {.re = -31237, .im = -9896}}, + {.s = {.re = -30852, .im = -11039}}, {.s = {.re = -30424, .im = -12167}}, + {.s = {.re = -29956, .im = -13279}}, {.s = {.re = -29447, .im = -14372}}, + {.s = {.re = -28898, .im = -15446}}, {.s = {.re = -28310, .im = -16499}}, + {.s = {.re = -27683, .im = -17530}}, {.s = {.re = -27019, .im = -18537}}, + {.s = {.re = -26319, .im = -19519}}, {.s = {.re = -25582, .im = -20475}}, + {.s = {.re = -24811, .im = -21403}}, {.s = {.re = -24007, .im = -22301}}, + {.s = {.re = -23170, .im = -23170}}, {.s = {.re = -22301, .im = -24007}}, + {.s = {.re = -21403, .im = -24811}}, {.s = {.re = -20475, .im = -25582}}, + {.s = {.re = -19519, .im = -26319}}, {.s = {.re = -18537, .im = -27019}}, + {.s = {.re = -17530, .im = -27683}}, {.s = {.re = -16499, .im = -28310}}, + {.s = {.re = -15446, .im = -28898}}, {.s = {.re = -14372, .im = -29447}}, + {.s = {.re = -13279, .im = -29956}}, {.s = {.re = -12167, .im = -30424}}, + {.s = {.re = -11039, .im = -30852}}, {.s = {.re = -9896, .im = -31237}}, + {.s = {.re = -8739, .im = -31580}}, {.s = {.re = -7571, .im = -31880}}, + {.s = {.re = -6393, .im = -32137}}, {.s = {.re = -5205, .im = -32351}}, + {.s = {.re = -4011, .im = -32521}}, {.s = {.re = -2811, .im = -32646}}, + {.s = {.re = -1608, .im = -32728}}, {.s = {.re = -402, .im = -32765}}, + {.s = {.re = 804, .im = -32757}}, {.s = {.re = 2009, .im = -32705}}, + {.s = {.re = 3212, .im = -32609}}, {.s = {.re = 4410, .im = -32469}}, + {.s = {.re = 5602, .im = -32285}}, {.s = {.re = 6786, .im = -32057}}, + {.s = {.re = 7962, .im = -31785}}, {.s = {.re = 9126, .im = -31470}}, + {.s = {.re = 10278, .im = -31113}}, {.s = {.re = 11417, .im = -30714}}, + {.s = {.re = 12539, .im = -30273}}, {.s = {.re = 13645, .im = -29791}}, + {.s = {.re = 14732, .im = -29268}}, {.s = {.re = 15800, .im = -28706}}, + {.s = {.re = 16846, .im = -28105}}, {.s = {.re = 17869, .im = -27466}}, + {.s = {.re = 18868, .im = -26790}}, {.s = {.re = 19841, .im = -26077}}, + {.s = {.re = 20787, .im = -25329}}, {.s = {.re = 21705, .im = -24547}}, + {.s = {.re = 22594, .im = -23731}}, {.s = {.re = 23452, .im = -22884}}, + {.s = {.re = 24279, .im = -22005}}, {.s = {.re = 25072, .im = -21096}}, + {.s = {.re = 25832, .im = -20159}}, {.s = {.re = 26556, .im = -19195}}, + {.s = {.re = 27245, .im = -18204}}, {.s = {.re = 27896, .im = -17189}}, + {.s = {.re = 28510, .im = -16151}}, {.s = {.re = 29085, .im = -15090}}, + {.s = {.re = 29621, .im = -14010}}, {.s = {.re = 30117, .im = -12910}}, + {.s = {.re = 30571, .im = -11793}}, {.s = {.re = 30985, .im = -10659}}, + {.s = {.re = 31356, .im = -9512}}, {.s = {.re = 31685, .im = -8351}}, + {.s = {.re = 31971, .im = -7179}}, {.s = {.re = 32213, .im = -5998}}, + {.s = {.re = 32412, .im = -4808}}, {.s = {.re = 32567, .im = -3612}}, + {.s = {.re = 32678, .im = -2410}}, {.s = {.re = 32745, .im = -1206}}, +}; +#endif + +#if MIN_RFFT_LEN <= 1024 && MAX_RFFT_LEN >= 1024 +const complex_fract16 twiddles_1024[] = { + {.s = {.re = 0, .im = 32767}}, {.s = {.re = -201, .im = 32766}}, + {.s = {.re = -402, .im = 32765}}, {.s = {.re = -603, .im = 32761}}, + {.s = {.re = -804, .im = 32757}}, {.s = {.re = -1005, .im = 32752}}, + {.s = {.re = -1206, .im = 32745}}, {.s = {.re = -1407, .im = 32737}}, + {.s = {.re = -1608, .im = 32728}}, {.s = {.re = -1809, .im = 32717}}, + {.s = {.re = -2009, .im = 32705}}, {.s = {.re = -2210, .im = 32692}}, + {.s = {.re = -2410, .im = 32678}}, {.s = {.re = -2611, .im = 32663}}, + {.s = {.re = -2811, .im = 32646}}, {.s = {.re = -3012, .im = 32628}}, + {.s = {.re = -3212, .im = 32609}}, {.s = {.re = -3412, .im = 32589}}, + {.s = {.re = -3612, .im = 32567}}, {.s = {.re = -3811, .im = 32545}}, + {.s = {.re = -4011, .im = 32521}}, {.s = {.re = -4210, .im = 32495}}, + {.s = {.re = -4410, .im = 32469}}, {.s = {.re = -4609, .im = 32441}}, + {.s = {.re = -4808, .im = 32412}}, {.s = {.re = -5007, .im = 32382}}, + {.s = {.re = -5205, .im = 32351}}, {.s = {.re = -5404, .im = 32318}}, + {.s = {.re = -5602, .im = 32285}}, {.s = {.re = -5800, .im = 32250}}, + {.s = {.re = -5998, .im = 32213}}, {.s = {.re = -6195, .im = 32176}}, + {.s = {.re = -6393, .im = 32137}}, {.s = {.re = -6590, .im = 32098}}, + {.s = {.re = -6786, .im = 32057}}, {.s = {.re = -6983, .im = 32014}}, + {.s = {.re = -7179, .im = 31971}}, {.s = {.re = -7375, .im = 31926}}, + {.s = {.re = -7571, .im = 31880}}, {.s = {.re = -7767, .im = 31833}}, + {.s = {.re = -7962, .im = 31785}}, {.s = {.re = -8157, .im = 31736}}, + {.s = {.re = -8351, .im = 31685}}, {.s = {.re = -8545, .im = 31633}}, + {.s = {.re = -8739, .im = 31580}}, {.s = {.re = -8933, .im = 31526}}, + {.s = {.re = -9126, .im = 31470}}, {.s = {.re = -9319, .im = 31414}}, + {.s = {.re = -9512, .im = 31356}}, {.s = {.re = -9704, .im = 31297}}, + {.s = {.re = -9896, .im = 31237}}, {.s = {.re = -10087, .im = 31176}}, + {.s = {.re = -10278, .im = 31113}}, {.s = {.re = -10469, .im = 31050}}, + {.s = {.re = -10659, .im = 30985}}, {.s = {.re = -10849, .im = 30919}}, + {.s = {.re = -11039, .im = 30852}}, {.s = {.re = -11228, .im = 30783}}, + {.s = {.re = -11417, .im = 30714}}, {.s = {.re = -11605, .im = 30643}}, + {.s = {.re = -11793, .im = 30571}}, {.s = {.re = -11980, .im = 30498}}, + {.s = {.re = -12167, .im = 30424}}, {.s = {.re = -12353, .im = 30349}}, + {.s = {.re = -12539, .im = 30273}}, {.s = {.re = -12725, .im = 30195}}, + {.s = {.re = -12910, .im = 30117}}, {.s = {.re = -13094, .im = 30037}}, + {.s = {.re = -13279, .im = 29956}}, {.s = {.re = -13462, .im = 29874}}, + {.s = {.re = -13645, .im = 29791}}, {.s = {.re = -13828, .im = 29706}}, + {.s = {.re = -14010, .im = 29621}}, {.s = {.re = -14191, .im = 29534}}, + {.s = {.re = -14372, .im = 29447}}, {.s = {.re = -14553, .im = 29358}}, + {.s = {.re = -14732, .im = 29268}}, {.s = {.re = -14912, .im = 29177}}, + {.s = {.re = -15090, .im = 29085}}, {.s = {.re = -15269, .im = 28992}}, + {.s = {.re = -15446, .im = 28898}}, {.s = {.re = -15623, .im = 28803}}, + {.s = {.re = -15800, .im = 28706}}, {.s = {.re = -15976, .im = 28609}}, + {.s = {.re = -16151, .im = 28510}}, {.s = {.re = -16325, .im = 28411}}, + {.s = {.re = -16499, .im = 28310}}, {.s = {.re = -16673, .im = 28208}}, + {.s = {.re = -16846, .im = 28105}}, {.s = {.re = -17018, .im = 28001}}, + {.s = {.re = -17189, .im = 27896}}, {.s = {.re = -17360, .im = 27790}}, + {.s = {.re = -17530, .im = 27683}}, {.s = {.re = -17700, .im = 27575}}, + {.s = {.re = -17869, .im = 27466}}, {.s = {.re = -18037, .im = 27356}}, + {.s = {.re = -18204, .im = 27245}}, {.s = {.re = -18371, .im = 27133}}, + {.s = {.re = -18537, .im = 27019}}, {.s = {.re = -18703, .im = 26905}}, + {.s = {.re = -18868, .im = 26790}}, {.s = {.re = -19032, .im = 26674}}, + {.s = {.re = -19195, .im = 26556}}, {.s = {.re = -19357, .im = 26438}}, + {.s = {.re = -19519, .im = 26319}}, {.s = {.re = -19680, .im = 26198}}, + {.s = {.re = -19841, .im = 26077}}, {.s = {.re = -20000, .im = 25955}}, + {.s = {.re = -20159, .im = 25832}}, {.s = {.re = -20317, .im = 25708}}, + {.s = {.re = -20475, .im = 25582}}, {.s = {.re = -20631, .im = 25456}}, + {.s = {.re = -20787, .im = 25329}}, {.s = {.re = -20942, .im = 25201}}, + {.s = {.re = -21096, .im = 25072}}, {.s = {.re = -21250, .im = 24942}}, + {.s = {.re = -21403, .im = 24811}}, {.s = {.re = -21554, .im = 24680}}, + {.s = {.re = -21705, .im = 24547}}, {.s = {.re = -21856, .im = 24413}}, + {.s = {.re = -22005, .im = 24279}}, {.s = {.re = -22154, .im = 24143}}, + {.s = {.re = -22301, .im = 24007}}, {.s = {.re = -22448, .im = 23870}}, + {.s = {.re = -22594, .im = 23731}}, {.s = {.re = -22739, .im = 23592}}, + {.s = {.re = -22884, .im = 23452}}, {.s = {.re = -23027, .im = 23311}}, + {.s = {.re = -23170, .im = 23170}}, {.s = {.re = -23311, .im = 23027}}, + {.s = {.re = -23452, .im = 22884}}, {.s = {.re = -23592, .im = 22739}}, + {.s = {.re = -23731, .im = 22594}}, {.s = {.re = -23870, .im = 22448}}, + {.s = {.re = -24007, .im = 22301}}, {.s = {.re = -24143, .im = 22154}}, + {.s = {.re = -24279, .im = 22005}}, {.s = {.re = -24413, .im = 21856}}, + {.s = {.re = -24547, .im = 21705}}, {.s = {.re = -24680, .im = 21554}}, + {.s = {.re = -24811, .im = 21403}}, {.s = {.re = -24942, .im = 21250}}, + {.s = {.re = -25072, .im = 21096}}, {.s = {.re = -25201, .im = 20942}}, + {.s = {.re = -25329, .im = 20787}}, {.s = {.re = -25456, .im = 20631}}, + {.s = {.re = -25582, .im = 20475}}, {.s = {.re = -25708, .im = 20317}}, + {.s = {.re = -25832, .im = 20159}}, {.s = {.re = -25955, .im = 20000}}, + {.s = {.re = -26077, .im = 19841}}, {.s = {.re = -26198, .im = 19680}}, + {.s = {.re = -26319, .im = 19519}}, {.s = {.re = -26438, .im = 19357}}, + {.s = {.re = -26556, .im = 19195}}, {.s = {.re = -26674, .im = 19032}}, + {.s = {.re = -26790, .im = 18868}}, {.s = {.re = -26905, .im = 18703}}, + {.s = {.re = -27019, .im = 18537}}, {.s = {.re = -27133, .im = 18371}}, + {.s = {.re = -27245, .im = 18204}}, {.s = {.re = -27356, .im = 18037}}, + {.s = {.re = -27466, .im = 17869}}, {.s = {.re = -27575, .im = 17700}}, + {.s = {.re = -27683, .im = 17530}}, {.s = {.re = -27790, .im = 17360}}, + {.s = {.re = -27896, .im = 17189}}, {.s = {.re = -28001, .im = 17018}}, + {.s = {.re = -28105, .im = 16846}}, {.s = {.re = -28208, .im = 16673}}, + {.s = {.re = -28310, .im = 16499}}, {.s = {.re = -28411, .im = 16325}}, + {.s = {.re = -28510, .im = 16151}}, {.s = {.re = -28609, .im = 15976}}, + {.s = {.re = -28706, .im = 15800}}, {.s = {.re = -28803, .im = 15623}}, + {.s = {.re = -28898, .im = 15446}}, {.s = {.re = -28992, .im = 15269}}, + {.s = {.re = -29085, .im = 15090}}, {.s = {.re = -29177, .im = 14912}}, + {.s = {.re = -29268, .im = 14732}}, {.s = {.re = -29358, .im = 14553}}, + {.s = {.re = -29447, .im = 14372}}, {.s = {.re = -29534, .im = 14191}}, + {.s = {.re = -29621, .im = 14010}}, {.s = {.re = -29706, .im = 13828}}, + {.s = {.re = -29791, .im = 13645}}, {.s = {.re = -29874, .im = 13462}}, + {.s = {.re = -29956, .im = 13279}}, {.s = {.re = -30037, .im = 13094}}, + {.s = {.re = -30117, .im = 12910}}, {.s = {.re = -30195, .im = 12725}}, + {.s = {.re = -30273, .im = 12539}}, {.s = {.re = -30349, .im = 12353}}, + {.s = {.re = -30424, .im = 12167}}, {.s = {.re = -30498, .im = 11980}}, + {.s = {.re = -30571, .im = 11793}}, {.s = {.re = -30643, .im = 11605}}, + {.s = {.re = -30714, .im = 11417}}, {.s = {.re = -30783, .im = 11228}}, + {.s = {.re = -30852, .im = 11039}}, {.s = {.re = -30919, .im = 10849}}, + {.s = {.re = -30985, .im = 10659}}, {.s = {.re = -31050, .im = 10469}}, + {.s = {.re = -31113, .im = 10278}}, {.s = {.re = -31176, .im = 10087}}, + {.s = {.re = -31237, .im = 9896}}, {.s = {.re = -31297, .im = 9704}}, + {.s = {.re = -31356, .im = 9512}}, {.s = {.re = -31414, .im = 9319}}, + {.s = {.re = -31470, .im = 9126}}, {.s = {.re = -31526, .im = 8933}}, + {.s = {.re = -31580, .im = 8739}}, {.s = {.re = -31633, .im = 8545}}, + {.s = {.re = -31685, .im = 8351}}, {.s = {.re = -31736, .im = 8157}}, + {.s = {.re = -31785, .im = 7962}}, {.s = {.re = -31833, .im = 7767}}, + {.s = {.re = -31880, .im = 7571}}, {.s = {.re = -31926, .im = 7375}}, + {.s = {.re = -31971, .im = 7179}}, {.s = {.re = -32014, .im = 6983}}, + {.s = {.re = -32057, .im = 6786}}, {.s = {.re = -32098, .im = 6590}}, + {.s = {.re = -32137, .im = 6393}}, {.s = {.re = -32176, .im = 6195}}, + {.s = {.re = -32213, .im = 5998}}, {.s = {.re = -32250, .im = 5800}}, + {.s = {.re = -32285, .im = 5602}}, {.s = {.re = -32318, .im = 5404}}, + {.s = {.re = -32351, .im = 5205}}, {.s = {.re = -32382, .im = 5007}}, + {.s = {.re = -32412, .im = 4808}}, {.s = {.re = -32441, .im = 4609}}, + {.s = {.re = -32469, .im = 4410}}, {.s = {.re = -32495, .im = 4210}}, + {.s = {.re = -32521, .im = 4011}}, {.s = {.re = -32545, .im = 3811}}, + {.s = {.re = -32567, .im = 3612}}, {.s = {.re = -32589, .im = 3412}}, + {.s = {.re = -32609, .im = 3212}}, {.s = {.re = -32628, .im = 3012}}, + {.s = {.re = -32646, .im = 2811}}, {.s = {.re = -32663, .im = 2611}}, + {.s = {.re = -32678, .im = 2410}}, {.s = {.re = -32692, .im = 2210}}, + {.s = {.re = -32705, .im = 2009}}, {.s = {.re = -32717, .im = 1809}}, + {.s = {.re = -32728, .im = 1608}}, {.s = {.re = -32737, .im = 1407}}, + {.s = {.re = -32745, .im = 1206}}, {.s = {.re = -32752, .im = 1005}}, + {.s = {.re = -32757, .im = 804}}, {.s = {.re = -32761, .im = 603}}, + {.s = {.re = -32765, .im = 402}}, {.s = {.re = -32766, .im = 201}}, + {.s = {.re = 0, .im = 32767}}, {.s = {.re = -402, .im = 32765}}, + {.s = {.re = -804, .im = 32757}}, {.s = {.re = -1206, .im = 32745}}, + {.s = {.re = -1608, .im = 32728}}, {.s = {.re = -2009, .im = 32705}}, + {.s = {.re = -2410, .im = 32678}}, {.s = {.re = -2811, .im = 32646}}, + {.s = {.re = -3212, .im = 32609}}, {.s = {.re = -3612, .im = 32567}}, + {.s = {.re = -4011, .im = 32521}}, {.s = {.re = -4410, .im = 32469}}, + {.s = {.re = -4808, .im = 32412}}, {.s = {.re = -5205, .im = 32351}}, + {.s = {.re = -5602, .im = 32285}}, {.s = {.re = -5998, .im = 32213}}, + {.s = {.re = -6393, .im = 32137}}, {.s = {.re = -6786, .im = 32057}}, + {.s = {.re = -7179, .im = 31971}}, {.s = {.re = -7571, .im = 31880}}, + {.s = {.re = -7962, .im = 31785}}, {.s = {.re = -8351, .im = 31685}}, + {.s = {.re = -8739, .im = 31580}}, {.s = {.re = -9126, .im = 31470}}, + {.s = {.re = -9512, .im = 31356}}, {.s = {.re = -9896, .im = 31237}}, + {.s = {.re = -10278, .im = 31113}}, {.s = {.re = -10659, .im = 30985}}, + {.s = {.re = -11039, .im = 30852}}, {.s = {.re = -11417, .im = 30714}}, + {.s = {.re = -11793, .im = 30571}}, {.s = {.re = -12167, .im = 30424}}, + {.s = {.re = -12539, .im = 30273}}, {.s = {.re = -12910, .im = 30117}}, + {.s = {.re = -13279, .im = 29956}}, {.s = {.re = -13645, .im = 29791}}, + {.s = {.re = -14010, .im = 29621}}, {.s = {.re = -14372, .im = 29447}}, + {.s = {.re = -14732, .im = 29268}}, {.s = {.re = -15090, .im = 29085}}, + {.s = {.re = -15446, .im = 28898}}, {.s = {.re = -15800, .im = 28706}}, + {.s = {.re = -16151, .im = 28510}}, {.s = {.re = -16499, .im = 28310}}, + {.s = {.re = -16846, .im = 28105}}, {.s = {.re = -17189, .im = 27896}}, + {.s = {.re = -17530, .im = 27683}}, {.s = {.re = -17869, .im = 27466}}, + {.s = {.re = -18204, .im = 27245}}, {.s = {.re = -18537, .im = 27019}}, + {.s = {.re = -18868, .im = 26790}}, {.s = {.re = -19195, .im = 26556}}, + {.s = {.re = -19519, .im = 26319}}, {.s = {.re = -19841, .im = 26077}}, + {.s = {.re = -20159, .im = 25832}}, {.s = {.re = -20475, .im = 25582}}, + {.s = {.re = -20787, .im = 25329}}, {.s = {.re = -21096, .im = 25072}}, + {.s = {.re = -21403, .im = 24811}}, {.s = {.re = -21705, .im = 24547}}, + {.s = {.re = -22005, .im = 24279}}, {.s = {.re = -22301, .im = 24007}}, + {.s = {.re = -22594, .im = 23731}}, {.s = {.re = -22884, .im = 23452}}, + {.s = {.re = -23170, .im = 23170}}, {.s = {.re = -23452, .im = 22884}}, + {.s = {.re = -23731, .im = 22594}}, {.s = {.re = -24007, .im = 22301}}, + {.s = {.re = -24279, .im = 22005}}, {.s = {.re = -24547, .im = 21705}}, + {.s = {.re = -24811, .im = 21403}}, {.s = {.re = -25072, .im = 21096}}, + {.s = {.re = -25329, .im = 20787}}, {.s = {.re = -25582, .im = 20475}}, + {.s = {.re = -25832, .im = 20159}}, {.s = {.re = -26077, .im = 19841}}, + {.s = {.re = -26319, .im = 19519}}, {.s = {.re = -26556, .im = 19195}}, + {.s = {.re = -26790, .im = 18868}}, {.s = {.re = -27019, .im = 18537}}, + {.s = {.re = -27245, .im = 18204}}, {.s = {.re = -27466, .im = 17869}}, + {.s = {.re = -27683, .im = 17530}}, {.s = {.re = -27896, .im = 17189}}, + {.s = {.re = -28105, .im = 16846}}, {.s = {.re = -28310, .im = 16499}}, + {.s = {.re = -28510, .im = 16151}}, {.s = {.re = -28706, .im = 15800}}, + {.s = {.re = -28898, .im = 15446}}, {.s = {.re = -29085, .im = 15090}}, + {.s = {.re = -29268, .im = 14732}}, {.s = {.re = -29447, .im = 14372}}, + {.s = {.re = -29621, .im = 14010}}, {.s = {.re = -29791, .im = 13645}}, + {.s = {.re = -29956, .im = 13279}}, {.s = {.re = -30117, .im = 12910}}, + {.s = {.re = -30273, .im = 12539}}, {.s = {.re = -30424, .im = 12167}}, + {.s = {.re = -30571, .im = 11793}}, {.s = {.re = -30714, .im = 11417}}, + {.s = {.re = -30852, .im = 11039}}, {.s = {.re = -30985, .im = 10659}}, + {.s = {.re = -31113, .im = 10278}}, {.s = {.re = -31237, .im = 9896}}, + {.s = {.re = -31356, .im = 9512}}, {.s = {.re = -31470, .im = 9126}}, + {.s = {.re = -31580, .im = 8739}}, {.s = {.re = -31685, .im = 8351}}, + {.s = {.re = -31785, .im = 7962}}, {.s = {.re = -31880, .im = 7571}}, + {.s = {.re = -31971, .im = 7179}}, {.s = {.re = -32057, .im = 6786}}, + {.s = {.re = -32137, .im = 6393}}, {.s = {.re = -32213, .im = 5998}}, + {.s = {.re = -32285, .im = 5602}}, {.s = {.re = -32351, .im = 5205}}, + {.s = {.re = -32412, .im = 4808}}, {.s = {.re = -32469, .im = 4410}}, + {.s = {.re = -32521, .im = 4011}}, {.s = {.re = -32567, .im = 3612}}, + {.s = {.re = -32609, .im = 3212}}, {.s = {.re = -32646, .im = 2811}}, + {.s = {.re = -32678, .im = 2410}}, {.s = {.re = -32705, .im = 2009}}, + {.s = {.re = -32728, .im = 1608}}, {.s = {.re = -32745, .im = 1206}}, + {.s = {.re = -32757, .im = 804}}, {.s = {.re = -32765, .im = 402}}, + {.s = {.re = -32767, .im = 0}}, {.s = {.re = -32765, .im = -402}}, + {.s = {.re = -32757, .im = -804}}, {.s = {.re = -32745, .im = -1206}}, + {.s = {.re = -32728, .im = -1608}}, {.s = {.re = -32705, .im = -2009}}, + {.s = {.re = -32678, .im = -2410}}, {.s = {.re = -32646, .im = -2811}}, + {.s = {.re = -32609, .im = -3212}}, {.s = {.re = -32567, .im = -3612}}, + {.s = {.re = -32521, .im = -4011}}, {.s = {.re = -32469, .im = -4410}}, + {.s = {.re = -32412, .im = -4808}}, {.s = {.re = -32351, .im = -5205}}, + {.s = {.re = -32285, .im = -5602}}, {.s = {.re = -32213, .im = -5998}}, + {.s = {.re = -32137, .im = -6393}}, {.s = {.re = -32057, .im = -6786}}, + {.s = {.re = -31971, .im = -7179}}, {.s = {.re = -31880, .im = -7571}}, + {.s = {.re = -31785, .im = -7962}}, {.s = {.re = -31685, .im = -8351}}, + {.s = {.re = -31580, .im = -8739}}, {.s = {.re = -31470, .im = -9126}}, + {.s = {.re = -31356, .im = -9512}}, {.s = {.re = -31237, .im = -9896}}, + {.s = {.re = -31113, .im = -10278}}, {.s = {.re = -30985, .im = -10659}}, + {.s = {.re = -30852, .im = -11039}}, {.s = {.re = -30714, .im = -11417}}, + {.s = {.re = -30571, .im = -11793}}, {.s = {.re = -30424, .im = -12167}}, + {.s = {.re = -30273, .im = -12539}}, {.s = {.re = -30117, .im = -12910}}, + {.s = {.re = -29956, .im = -13279}}, {.s = {.re = -29791, .im = -13645}}, + {.s = {.re = -29621, .im = -14010}}, {.s = {.re = -29447, .im = -14372}}, + {.s = {.re = -29268, .im = -14732}}, {.s = {.re = -29085, .im = -15090}}, + {.s = {.re = -28898, .im = -15446}}, {.s = {.re = -28706, .im = -15800}}, + {.s = {.re = -28510, .im = -16151}}, {.s = {.re = -28310, .im = -16499}}, + {.s = {.re = -28105, .im = -16846}}, {.s = {.re = -27896, .im = -17189}}, + {.s = {.re = -27683, .im = -17530}}, {.s = {.re = -27466, .im = -17869}}, + {.s = {.re = -27245, .im = -18204}}, {.s = {.re = -27019, .im = -18537}}, + {.s = {.re = -26790, .im = -18868}}, {.s = {.re = -26556, .im = -19195}}, + {.s = {.re = -26319, .im = -19519}}, {.s = {.re = -26077, .im = -19841}}, + {.s = {.re = -25832, .im = -20159}}, {.s = {.re = -25582, .im = -20475}}, + {.s = {.re = -25329, .im = -20787}}, {.s = {.re = -25072, .im = -21096}}, + {.s = {.re = -24811, .im = -21403}}, {.s = {.re = -24547, .im = -21705}}, + {.s = {.re = -24279, .im = -22005}}, {.s = {.re = -24007, .im = -22301}}, + {.s = {.re = -23731, .im = -22594}}, {.s = {.re = -23452, .im = -22884}}, + {.s = {.re = -23170, .im = -23170}}, {.s = {.re = -22884, .im = -23452}}, + {.s = {.re = -22594, .im = -23731}}, {.s = {.re = -22301, .im = -24007}}, + {.s = {.re = -22005, .im = -24279}}, {.s = {.re = -21705, .im = -24547}}, + {.s = {.re = -21403, .im = -24811}}, {.s = {.re = -21096, .im = -25072}}, + {.s = {.re = -20787, .im = -25329}}, {.s = {.re = -20475, .im = -25582}}, + {.s = {.re = -20159, .im = -25832}}, {.s = {.re = -19841, .im = -26077}}, + {.s = {.re = -19519, .im = -26319}}, {.s = {.re = -19195, .im = -26556}}, + {.s = {.re = -18868, .im = -26790}}, {.s = {.re = -18537, .im = -27019}}, + {.s = {.re = -18204, .im = -27245}}, {.s = {.re = -17869, .im = -27466}}, + {.s = {.re = -17530, .im = -27683}}, {.s = {.re = -17189, .im = -27896}}, + {.s = {.re = -16846, .im = -28105}}, {.s = {.re = -16499, .im = -28310}}, + {.s = {.re = -16151, .im = -28510}}, {.s = {.re = -15800, .im = -28706}}, + {.s = {.re = -15446, .im = -28898}}, {.s = {.re = -15090, .im = -29085}}, + {.s = {.re = -14732, .im = -29268}}, {.s = {.re = -14372, .im = -29447}}, + {.s = {.re = -14010, .im = -29621}}, {.s = {.re = -13645, .im = -29791}}, + {.s = {.re = -13279, .im = -29956}}, {.s = {.re = -12910, .im = -30117}}, + {.s = {.re = -12539, .im = -30273}}, {.s = {.re = -12167, .im = -30424}}, + {.s = {.re = -11793, .im = -30571}}, {.s = {.re = -11417, .im = -30714}}, + {.s = {.re = -11039, .im = -30852}}, {.s = {.re = -10659, .im = -30985}}, + {.s = {.re = -10278, .im = -31113}}, {.s = {.re = -9896, .im = -31237}}, + {.s = {.re = -9512, .im = -31356}}, {.s = {.re = -9126, .im = -31470}}, + {.s = {.re = -8739, .im = -31580}}, {.s = {.re = -8351, .im = -31685}}, + {.s = {.re = -7962, .im = -31785}}, {.s = {.re = -7571, .im = -31880}}, + {.s = {.re = -7179, .im = -31971}}, {.s = {.re = -6786, .im = -32057}}, + {.s = {.re = -6393, .im = -32137}}, {.s = {.re = -5998, .im = -32213}}, + {.s = {.re = -5602, .im = -32285}}, {.s = {.re = -5205, .im = -32351}}, + {.s = {.re = -4808, .im = -32412}}, {.s = {.re = -4410, .im = -32469}}, + {.s = {.re = -4011, .im = -32521}}, {.s = {.re = -3612, .im = -32567}}, + {.s = {.re = -3212, .im = -32609}}, {.s = {.re = -2811, .im = -32646}}, + {.s = {.re = -2410, .im = -32678}}, {.s = {.re = -2009, .im = -32705}}, + {.s = {.re = -1608, .im = -32728}}, {.s = {.re = -1206, .im = -32745}}, + {.s = {.re = -804, .im = -32757}}, {.s = {.re = -402, .im = -32765}}, + {.s = {.re = 0, .im = 32767}}, {.s = {.re = -603, .im = 32761}}, + {.s = {.re = -1206, .im = 32745}}, {.s = {.re = -1809, .im = 32717}}, + {.s = {.re = -2410, .im = 32678}}, {.s = {.re = -3012, .im = 32628}}, + {.s = {.re = -3612, .im = 32567}}, {.s = {.re = -4210, .im = 32495}}, + {.s = {.re = -4808, .im = 32412}}, {.s = {.re = -5404, .im = 32318}}, + {.s = {.re = -5998, .im = 32213}}, {.s = {.re = -6590, .im = 32098}}, + {.s = {.re = -7179, .im = 31971}}, {.s = {.re = -7767, .im = 31833}}, + {.s = {.re = -8351, .im = 31685}}, {.s = {.re = -8933, .im = 31526}}, + {.s = {.re = -9512, .im = 31356}}, {.s = {.re = -10087, .im = 31176}}, + {.s = {.re = -10659, .im = 30985}}, {.s = {.re = -11228, .im = 30783}}, + {.s = {.re = -11793, .im = 30571}}, {.s = {.re = -12353, .im = 30349}}, + {.s = {.re = -12910, .im = 30117}}, {.s = {.re = -13462, .im = 29874}}, + {.s = {.re = -14010, .im = 29621}}, {.s = {.re = -14553, .im = 29358}}, + {.s = {.re = -15090, .im = 29085}}, {.s = {.re = -15623, .im = 28803}}, + {.s = {.re = -16151, .im = 28510}}, {.s = {.re = -16673, .im = 28208}}, + {.s = {.re = -17189, .im = 27896}}, {.s = {.re = -17700, .im = 27575}}, + {.s = {.re = -18204, .im = 27245}}, {.s = {.re = -18703, .im = 26905}}, + {.s = {.re = -19195, .im = 26556}}, {.s = {.re = -19680, .im = 26198}}, + {.s = {.re = -20159, .im = 25832}}, {.s = {.re = -20631, .im = 25456}}, + {.s = {.re = -21096, .im = 25072}}, {.s = {.re = -21554, .im = 24680}}, + {.s = {.re = -22005, .im = 24279}}, {.s = {.re = -22448, .im = 23870}}, + {.s = {.re = -22884, .im = 23452}}, {.s = {.re = -23311, .im = 23027}}, + {.s = {.re = -23731, .im = 22594}}, {.s = {.re = -24143, .im = 22154}}, + {.s = {.re = -24547, .im = 21705}}, {.s = {.re = -24942, .im = 21250}}, + {.s = {.re = -25329, .im = 20787}}, {.s = {.re = -25708, .im = 20317}}, + {.s = {.re = -26077, .im = 19841}}, {.s = {.re = -26438, .im = 19357}}, + {.s = {.re = -26790, .im = 18868}}, {.s = {.re = -27133, .im = 18371}}, + {.s = {.re = -27466, .im = 17869}}, {.s = {.re = -27790, .im = 17360}}, + {.s = {.re = -28105, .im = 16846}}, {.s = {.re = -28411, .im = 16325}}, + {.s = {.re = -28706, .im = 15800}}, {.s = {.re = -28992, .im = 15269}}, + {.s = {.re = -29268, .im = 14732}}, {.s = {.re = -29534, .im = 14191}}, + {.s = {.re = -29791, .im = 13645}}, {.s = {.re = -30037, .im = 13094}}, + {.s = {.re = -30273, .im = 12539}}, {.s = {.re = -30498, .im = 11980}}, + {.s = {.re = -30714, .im = 11417}}, {.s = {.re = -30919, .im = 10849}}, + {.s = {.re = -31113, .im = 10278}}, {.s = {.re = -31297, .im = 9704}}, + {.s = {.re = -31470, .im = 9126}}, {.s = {.re = -31633, .im = 8545}}, + {.s = {.re = -31785, .im = 7962}}, {.s = {.re = -31926, .im = 7375}}, + {.s = {.re = -32057, .im = 6786}}, {.s = {.re = -32176, .im = 6195}}, + {.s = {.re = -32285, .im = 5602}}, {.s = {.re = -32382, .im = 5007}}, + {.s = {.re = -32469, .im = 4410}}, {.s = {.re = -32545, .im = 3811}}, + {.s = {.re = -32609, .im = 3212}}, {.s = {.re = -32663, .im = 2611}}, + {.s = {.re = -32705, .im = 2009}}, {.s = {.re = -32737, .im = 1407}}, + {.s = {.re = -32757, .im = 804}}, {.s = {.re = -32766, .im = 201}}, + {.s = {.re = -32765, .im = -402}}, {.s = {.re = -32752, .im = -1005}}, + {.s = {.re = -32728, .im = -1608}}, {.s = {.re = -32692, .im = -2210}}, + {.s = {.re = -32646, .im = -2811}}, {.s = {.re = -32589, .im = -3412}}, + {.s = {.re = -32521, .im = -4011}}, {.s = {.re = -32441, .im = -4609}}, + {.s = {.re = -32351, .im = -5205}}, {.s = {.re = -32250, .im = -5800}}, + {.s = {.re = -32137, .im = -6393}}, {.s = {.re = -32014, .im = -6983}}, + {.s = {.re = -31880, .im = -7571}}, {.s = {.re = -31736, .im = -8157}}, + {.s = {.re = -31580, .im = -8739}}, {.s = {.re = -31414, .im = -9319}}, + {.s = {.re = -31237, .im = -9896}}, {.s = {.re = -31050, .im = -10469}}, + {.s = {.re = -30852, .im = -11039}}, {.s = {.re = -30643, .im = -11605}}, + {.s = {.re = -30424, .im = -12167}}, {.s = {.re = -30195, .im = -12725}}, + {.s = {.re = -29956, .im = -13279}}, {.s = {.re = -29706, .im = -13828}}, + {.s = {.re = -29447, .im = -14372}}, {.s = {.re = -29177, .im = -14912}}, + {.s = {.re = -28898, .im = -15446}}, {.s = {.re = -28609, .im = -15976}}, + {.s = {.re = -28310, .im = -16499}}, {.s = {.re = -28001, .im = -17018}}, + {.s = {.re = -27683, .im = -17530}}, {.s = {.re = -27356, .im = -18037}}, + {.s = {.re = -27019, .im = -18537}}, {.s = {.re = -26674, .im = -19032}}, + {.s = {.re = -26319, .im = -19519}}, {.s = {.re = -25955, .im = -20000}}, + {.s = {.re = -25582, .im = -20475}}, {.s = {.re = -25201, .im = -20942}}, + {.s = {.re = -24811, .im = -21403}}, {.s = {.re = -24413, .im = -21856}}, + {.s = {.re = -24007, .im = -22301}}, {.s = {.re = -23592, .im = -22739}}, + {.s = {.re = -23170, .im = -23170}}, {.s = {.re = -22739, .im = -23592}}, + {.s = {.re = -22301, .im = -24007}}, {.s = {.re = -21856, .im = -24413}}, + {.s = {.re = -21403, .im = -24811}}, {.s = {.re = -20942, .im = -25201}}, + {.s = {.re = -20475, .im = -25582}}, {.s = {.re = -20000, .im = -25955}}, + {.s = {.re = -19519, .im = -26319}}, {.s = {.re = -19032, .im = -26674}}, + {.s = {.re = -18537, .im = -27019}}, {.s = {.re = -18037, .im = -27356}}, + {.s = {.re = -17530, .im = -27683}}, {.s = {.re = -17018, .im = -28001}}, + {.s = {.re = -16499, .im = -28310}}, {.s = {.re = -15976, .im = -28609}}, + {.s = {.re = -15446, .im = -28898}}, {.s = {.re = -14912, .im = -29177}}, + {.s = {.re = -14372, .im = -29447}}, {.s = {.re = -13828, .im = -29706}}, + {.s = {.re = -13279, .im = -29956}}, {.s = {.re = -12725, .im = -30195}}, + {.s = {.re = -12167, .im = -30424}}, {.s = {.re = -11605, .im = -30643}}, + {.s = {.re = -11039, .im = -30852}}, {.s = {.re = -10469, .im = -31050}}, + {.s = {.re = -9896, .im = -31237}}, {.s = {.re = -9319, .im = -31414}}, + {.s = {.re = -8739, .im = -31580}}, {.s = {.re = -8157, .im = -31736}}, + {.s = {.re = -7571, .im = -31880}}, {.s = {.re = -6983, .im = -32014}}, + {.s = {.re = -6393, .im = -32137}}, {.s = {.re = -5800, .im = -32250}}, + {.s = {.re = -5205, .im = -32351}}, {.s = {.re = -4609, .im = -32441}}, + {.s = {.re = -4011, .im = -32521}}, {.s = {.re = -3412, .im = -32589}}, + {.s = {.re = -2811, .im = -32646}}, {.s = {.re = -2210, .im = -32692}}, + {.s = {.re = -1608, .im = -32728}}, {.s = {.re = -1005, .im = -32752}}, + {.s = {.re = -402, .im = -32765}}, {.s = {.re = 201, .im = -32766}}, + {.s = {.re = 804, .im = -32757}}, {.s = {.re = 1407, .im = -32737}}, + {.s = {.re = 2009, .im = -32705}}, {.s = {.re = 2611, .im = -32663}}, + {.s = {.re = 3212, .im = -32609}}, {.s = {.re = 3811, .im = -32545}}, + {.s = {.re = 4410, .im = -32469}}, {.s = {.re = 5007, .im = -32382}}, + {.s = {.re = 5602, .im = -32285}}, {.s = {.re = 6195, .im = -32176}}, + {.s = {.re = 6786, .im = -32057}}, {.s = {.re = 7375, .im = -31926}}, + {.s = {.re = 7962, .im = -31785}}, {.s = {.re = 8545, .im = -31633}}, + {.s = {.re = 9126, .im = -31470}}, {.s = {.re = 9704, .im = -31297}}, + {.s = {.re = 10278, .im = -31113}}, {.s = {.re = 10849, .im = -30919}}, + {.s = {.re = 11417, .im = -30714}}, {.s = {.re = 11980, .im = -30498}}, + {.s = {.re = 12539, .im = -30273}}, {.s = {.re = 13094, .im = -30037}}, + {.s = {.re = 13645, .im = -29791}}, {.s = {.re = 14191, .im = -29534}}, + {.s = {.re = 14732, .im = -29268}}, {.s = {.re = 15269, .im = -28992}}, + {.s = {.re = 15800, .im = -28706}}, {.s = {.re = 16325, .im = -28411}}, + {.s = {.re = 16846, .im = -28105}}, {.s = {.re = 17360, .im = -27790}}, + {.s = {.re = 17869, .im = -27466}}, {.s = {.re = 18371, .im = -27133}}, + {.s = {.re = 18868, .im = -26790}}, {.s = {.re = 19357, .im = -26438}}, + {.s = {.re = 19841, .im = -26077}}, {.s = {.re = 20317, .im = -25708}}, + {.s = {.re = 20787, .im = -25329}}, {.s = {.re = 21250, .im = -24942}}, + {.s = {.re = 21705, .im = -24547}}, {.s = {.re = 22154, .im = -24143}}, + {.s = {.re = 22594, .im = -23731}}, {.s = {.re = 23027, .im = -23311}}, + {.s = {.re = 23452, .im = -22884}}, {.s = {.re = 23870, .im = -22448}}, + {.s = {.re = 24279, .im = -22005}}, {.s = {.re = 24680, .im = -21554}}, + {.s = {.re = 25072, .im = -21096}}, {.s = {.re = 25456, .im = -20631}}, + {.s = {.re = 25832, .im = -20159}}, {.s = {.re = 26198, .im = -19680}}, + {.s = {.re = 26556, .im = -19195}}, {.s = {.re = 26905, .im = -18703}}, + {.s = {.re = 27245, .im = -18204}}, {.s = {.re = 27575, .im = -17700}}, + {.s = {.re = 27896, .im = -17189}}, {.s = {.re = 28208, .im = -16673}}, + {.s = {.re = 28510, .im = -16151}}, {.s = {.re = 28803, .im = -15623}}, + {.s = {.re = 29085, .im = -15090}}, {.s = {.re = 29358, .im = -14553}}, + {.s = {.re = 29621, .im = -14010}}, {.s = {.re = 29874, .im = -13462}}, + {.s = {.re = 30117, .im = -12910}}, {.s = {.re = 30349, .im = -12353}}, + {.s = {.re = 30571, .im = -11793}}, {.s = {.re = 30783, .im = -11228}}, + {.s = {.re = 30985, .im = -10659}}, {.s = {.re = 31176, .im = -10087}}, + {.s = {.re = 31356, .im = -9512}}, {.s = {.re = 31526, .im = -8933}}, + {.s = {.re = 31685, .im = -8351}}, {.s = {.re = 31833, .im = -7767}}, + {.s = {.re = 31971, .im = -7179}}, {.s = {.re = 32098, .im = -6590}}, + {.s = {.re = 32213, .im = -5998}}, {.s = {.re = 32318, .im = -5404}}, + {.s = {.re = 32412, .im = -4808}}, {.s = {.re = 32495, .im = -4210}}, + {.s = {.re = 32567, .im = -3612}}, {.s = {.re = 32628, .im = -3012}}, + {.s = {.re = 32678, .im = -2410}}, {.s = {.re = 32717, .im = -1809}}, + {.s = {.re = 32745, .im = -1206}}, {.s = {.re = 32761, .im = -603}}, +}; +#endif + +#endif + +size_t RfftInt16GetNeededMemory(int32_t fft_length) { +#if XCHAL_HAVE_HIFI3 || XCHAL_HAVE_HIFI4 || XCHAL_HAVE_HIFI5 + return sizeof(RfftState); +#elif XCHAL_HAVE_HIFI_MINI || XCHAL_HAVE_HIFI2 || XCHAL_HAVE_HIFI_EP + int scratch_size = fft_length * sizeof(int32_t); + return sizeof(RfftState) + scratch_size; +#else + size_t state_size = 0; + kiss_fft_fixed16::kiss_fftr_alloc(fft_length, 0, nullptr, &state_size); + return state_size; +#endif +} + +void* RfftInt16Init(int32_t fft_length, void* state, size_t state_size) { +#if XCHAL_HAVE_HIFI3 || XCHAL_HAVE_HIFI4 || XCHAL_HAVE_HIFI5 + RfftState* rfft_state = (RfftState*)state; + +#if defined XTENSA_NDSP_FFT_MEM_OPTIMIZED + switch (fft_length) { +#if MIN_RFFT_LEN <= 256 && MAX_RFFT_LEN >= 256 + case 256: + rfft_state->handle = twiddles_256; + rfft_state->fft_length_log2 = 8; + rfft_state->fft_length = 256; + rfft_state->output_length = (256 / 2) + 1; + break; +#endif +#if MIN_RFFT_LEN <= 512 && MAX_RFFT_LEN >= 512 + case 512: + rfft_state->handle = twiddles_512; + rfft_state->fft_length_log2 = 9; + rfft_state->fft_length = 512; + rfft_state->output_length = (512 / 2) + 1; + break; +#endif +#if MIN_RFFT_LEN <= 1024 && MAX_RFFT_LEN >= 1024 + case 1024: + rfft_state->handle = twiddles_1024; + rfft_state->fft_length_log2 = 10; + rfft_state->fft_length = 1024; + rfft_state->output_size = (1024 / 2) + 1; + break; +#endif + default: + return nullptr; + } +#else + switch (fft_length) { +#if MIN_RFFT_LEN <= 32 && MAX_RFFT_LEN >= 32 + case 32: + rfft_state->handle = rfft16_32; + break; +#endif +#if MIN_RFFT_LEN <= 64 && MAX_RFFT_LEN >= 64 + case 64: + rfft_state->handle = rfft16_64; + break; +#endif +#if MIN_RFFT_LEN <= 128 && MAX_RFFT_LEN >= 128 + case 128: + rfft_state->handle = rfft16_128; + break; +#endif +#if MIN_RFFT_LEN <= 256 && MAX_RFFT_LEN >= 256 + case 256: + rfft_state->handle = rfft16_256; + break; +#endif +#if MIN_RFFT_LEN <= 512 && MAX_RFFT_LEN >= 512 + case 512: + rfft_state->handle = rfft16_512; + break; +#endif +#if MIN_RFFT_LEN <= 1024 && MAX_RFFT_LEN >= 1024 + case 1024: + rfft_state->handle = rfft16_1024; + break; +#endif +#if MIN_RFFT_LEN <= 2048 && MAX_RFFT_LEN >= 2048 + case 2048: + rfft_state->handle = rfft16_2048; + break; +#endif +#if MIN_RFFT_LEN <= 4096 && MAX_RFFT_LEN >= 4096 + case 4096: + rfft_state->handle = rfft16_4096; + break; +#endif +#if MIN_RFFT_LEN <= 8192 && MAX_RFFT_LEN >= 8192 + case 8192: + rfft_state->handle = rfft16_8192; + break; +#endif + default: + return nullptr; + } +#endif + + return state; +#elif XCHAL_HAVE_HIFI_MINI || XCHAL_HAVE_HIFI2 || XCHAL_HAVE_HIFI_EP + RfftState* rfft_state = (RfftState*)state; + rfft_state->fft_length = fft_length; + rfft_state->scratch = (int32_t*)(rfft_state + 1); + return state; +#else + return kiss_fft_fixed16::kiss_fftr_alloc(fft_length, 0, state, &state_size); +#endif +} + +void RfftInt16Apply(void* state, const int16_t* input, + Complex* output) { +#if XCHAL_HAVE_HIFI3 || XCHAL_HAVE_HIFI4 || XCHAL_HAVE_HIFI5 + RfftState* rfft_state = (RfftState*)state; + +#if defined XTENSA_NDSP_FFT_MEM_OPTIMIZED + int shifts = fft_real16x16_ie((complex_fract16*)output, (int16_t*)input, + (const complex_fract16*)rfft_state->handle, 1, + rfft_state->fft_length, 2); + + if (shifts < rfft_state->fft_length_log2) { + for (int i = 0; i < rfft_state->output_length; i++) { + output[i].real >>= (rfft_state->fft_length_log2 - shifts); + output[i].imag >>= (rfft_state->fft_length_log2 - shifts); + } + } else if (shifts > rfft_state->fft_length_log2) { + for (int i = 0; i < rfft_state->output_length; i++) { + output[i].real <<= (shifts - rfft_state->fft_length_log2); + output[i].imag <<= (shifts - rfft_state->fft_length_log2); + } + } +#else + fft_real16x16((int16_t*)output, (int16_t*)input, rfft_state->handle, 3); +#endif +#elif XCHAL_HAVE_HIFI_MINI || XCHAL_HAVE_HIFI2 || XCHAL_HAVE_HIFI_EP + RfftState* rfft_state = (RfftState*)state; + fft_real_i16_o16_24x24((int16_t*)input, rfft_state->fft_length, + rfft_state->scratch, (int16_t*)output); +#else + kiss_fft_fixed16::kiss_fftr( + static_cast(state), + reinterpret_cast(input), + reinterpret_cast(output)); +#endif +} + +} // namespace tflm_signal diff --git a/signal/src/msb_32.cc b/signal/src/msb_32.cc index 67f26642bef..424a63ec2b5 100644 --- a/signal/src/msb_32.cc +++ b/signal/src/msb_32.cc @@ -17,6 +17,8 @@ limitations under the License. #if defined(XTENSA) #include +#elif defined(HEXAGON) +#include #endif namespace tflite { @@ -29,6 +31,8 @@ uint32_t MostSignificantBit32(uint32_t x) { // XT_NSAU returns the number of left shifts needed to put the MSB in the // leftmost position. Returns 32 if the argument is 0. return 32 - XT_NSAU(x); +#elif defined(HEXAGON) + return (32 - Q6_R_cl0_R(x)); #elif defined(__GNUC__) if (x) { return 32 - __builtin_clz(x); diff --git a/signal/src/msb_64.cc b/signal/src/msb_64.cc index 7416438cab4..ce99590fe06 100644 --- a/signal/src/msb_64.cc +++ b/signal/src/msb_64.cc @@ -17,6 +17,8 @@ limitations under the License. #if defined(XTENSA) #include +#elif defined(HEXAGON) +#include #endif namespace tflite { @@ -33,6 +35,8 @@ uint32_t MostSignificantBit64(uint64_t x) { } // Only if the upper bits are all clear do we want to look at the lower bits. return 32 - XT_NSAU((uint32_t)x); +#elif defined(HEXAGON) + return (64 - Q6_R_cl0_P(x)); #elif defined(__GNUC__) if (x) { return 64 - __builtin_clzll(x); diff --git a/tensorflow/lite/micro/tools/make/Makefile b/tensorflow/lite/micro/tools/make/Makefile index 21f21a1ce05..68751e273e4 100644 --- a/tensorflow/lite/micro/tools/make/Makefile +++ b/tensorflow/lite/micro/tools/make/Makefile @@ -688,7 +688,7 @@ ifneq ($(OPTIMIZED_KERNEL_DIR),) --base_files "$(MICROLITE_CC_KERNEL_SRCS)" \ --specialize_directory $(PATH_TO_OPTIMIZED_KERNELS)) - ifneq ($(filter $(OPTIMIZED_KERNEL_DIR), xtensa),) + ifneq ($(filter $(OPTIMIZED_KERNEL_DIR), xtensa hexagon),) # Check that OPTIMIZED_KERNEL_DIR is valid to avoid unexpected fallback to # reference kernels. See http://b/183546742 for more context. RESULT := $(shell $(MAKEFILE_DIR)/check_optimized_kernel_dir.sh $(PATH_TO_SIGNAL_OPTIMIZED_KERNELS))