From: Andreas Steffen Date: Fri, 22 Jul 2016 15:20:23 +0000 (+0200) Subject: Share twiddle factors table between 512 and 1024 point FFT X-Git-Tag: 5.5.1dr1~1^2~11 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=65f2ecb86ddb4fab2cdbc7ac4e9416ff4c26222c;p=thirdparty%2Fstrongswan.git Share twiddle factors table between 512 and 1024 point FFT --- diff --git a/src/libstrongswan/plugins/bliss/bliss_fft.c b/src/libstrongswan/plugins/bliss/bliss_fft.c index 00005cfba3..2355a9f4c7 100644 --- a/src/libstrongswan/plugins/bliss/bliss_fft.c +++ b/src/libstrongswan/plugins/bliss/bliss_fft.c @@ -96,18 +96,19 @@ static void butterfly_last(private_bliss_fft_t *this, uint32_t *x, int i1) METHOD(bliss_fft_t, transform, void, private_bliss_fft_t *this, uint32_t *a, uint32_t *b, bool inverse) { - int stage, i, j, k, m, n, t, iw, i_rev; + int stage, i, j, k, m, n, s, t, iw, i_rev; uint32_t tmp; /* we are going to use the transform size n a lot */ n = this->p->n; + s = this->p->s; if (!inverse) { /* apply linear phase needed for negative wrapped convolution */ for (i = 0; i < n; i++) { - b[i] = bliss_mreduce(a[i] * this->p->wf[i], this->p); + b[i] = bliss_mreduce(a[i] * this->p->wf[s*i], this->p); } } else if (a != b) @@ -137,7 +138,7 @@ METHOD(bliss_fft_t, transform, void, { for (i = 0; i < m; i++) { - iw = inverse ? (n - i * k) : (i * k); + iw = s * (inverse ? (n - i * k) : (i * k)); butterfly(this, b, t + i, t + i + m, iw); } } diff --git a/src/libstrongswan/plugins/bliss/bliss_fft_params.c b/src/libstrongswan/plugins/bliss/bliss_fft_params.c index 074d92a291..db6abea33c 100644 --- a/src/libstrongswan/plugins/bliss/bliss_fft_params.c +++ b/src/libstrongswan/plugins/bliss/bliss_fft_params.c @@ -254,7 +254,7 @@ static uint16_t wf_12289_1024[] = { }; /** - * FFT phase shift and scaling inverse transform for q = 11289 and n = 1024 + * FFT phase shift and scaling inverse transform for q = 12289 and n = 1024 */ static uint16_t wi_12289_1024[] = { 12277, 5265, 9530, 3117, 5712, 816, 10650, 3277, 9246, 4832, @@ -493,137 +493,11 @@ static uint16_t rev_1024[] = { bliss_fft_params_t bliss_fft_12289_1024 = { 12289, 12287, 18, 3186, (1<<18)-1, 1024, 12277, 10, - wr_12289_1024, wf_12289_1024, wi_12289_1024, rev_1024 + wr_12289_1024, wf_12289_1024, wi_12289_1024, 1, rev_1024 }; /** - * FFT twiddle factors in Montgomery form for q = 12289 and n = 512 - */ -static uint16_t wr_12289_512[] = { - 4075, 2031, 9987, 2948, 11973, 3202, 7377, 3728, 4536, 2882, - 975, 6065, 11889, 10431, 12138, 6119, 6364, 4737, 6212, 8455, - 11316, 11026, 2920, 6190, 4789, 8174, 241, 1058, 8724, 5868, - 5874, 7991, 3262, 3969, 5594, 11606, 6843, 11939, 7591, 1404, - 3818, 11713, 5681, 11580, 5862, 3757, 431, 2555, 2344, 11871, - 4080, 1747, 3998, 1489, 11279, 8212, 5456, 12071, 5009, 7967, - 7083, 10596, 2766, 5106, 7373, 6413, 11785, 6507, 3988, 2057, - 10968, 11130, 6844, 2051, 8851, 3570, 6137, 426, 2839, 8333, - 1041, 4774, 9026, 5919, 5435, 10806, 3127, 11637, 7540, 1843, - 1003, 11848, 10302, 9634, 3336, 9597, 522, 12133, 6403, 64, - - 6196, 6906, 3445, 948, 2683, 2447, 1105, 10970, 3643, 9364, - 6383, 1200, 5574, 453, 6221, 5486, 10367, 5942, 11502, 2919, - 3789, 3529, 6008, 10211, 56, 11566, 9115, 10695, 6974, 6956, - 605, 2503, 382, 7796, 2049, 4049, 1050, 1805, 8077, 835, - 1728, 7535, 2127, 6992, 1018, 10996, 4624, 5257, 1254, 49, - 7048, 295, 7822, 3030, 12231, 8210, 654, 9551, 677, 3329, - 5079, 3991, 9260, 2459, 5339, 1512, 5057, 325, 6118, 3963, - 3477, 4046, 6136, 10314, 1579, 6167, 11011, 3772, 11868, 9166, - 10256, 9789, 6821, 8273, 4449, 2908, 1956, 1958, 6760, 9280, - 1323, 5961, 7965, 2281, 8076, 10723, 468, 5369, 12097, 5990, - - 3860, 1954, 9445, 4240, 4948, 8974, 3957, 1360, 8775, 5429, - 8689, 7856, 10930, 5915, 8120, 5766, 6752, 2361, 3532, 922, - 1702, 6554, 6234, 12121, 2169, 9522, 4782, 3656, 3710, 10474, - 4780, 11143, 1190, 6142, 142, 9139, 6874, 347, 9784, 7105, - 1973, 5908, 3602, 9235, 3879, 10706, 8807, 8527, 12142, 3434, - 11404, 1112, 3199, 174, 12237, 10327, 8214, 10258, 2302, 9341, - 316, 9087, 4912, 8561, 7753, 9407, 11314, 6224, 400, 1858, - 151, 6170, 5925, 7552, 6077, 3834, 973, 1263, 9369, 6099, - 7500, 4115, 12048, 11231, 3565, 6421, 6415, 4298, 9027, 8320, - 6695, 683, 5446, 350, 4698, 10885, 8471, 576, 6608, 709, - - 6427, 8532, 11858, 9734, 9945, 418, 8209, 10542, 8291, 10800, - 1010, 4077, 6833, 218, 7280, 4322, 5206, 1693, 9523, 7183, - 4916, 5876, 504, 5782, 8301, 10232, 1321, 1159, 5445, 10238, - 3438, 8719, 6152, 11863, 9450, 3956, 11248, 7515, 3263, 6370, - 6854, 1483, 9162, 652, 4749, 10446, 11286, 441, 1987, 2655, - 8953, 2692, 11767, 156, 5886, 12225, 6093, 5383, 8844, 11341, - 9606, 9842, 11184, 1319, 8646, 2925, 5906, 11089, 6715, 11836, - 6068, 6803, 1922, 6347, 787, 9370, 8500, 8760, 6281, 2078, - 12233, 723, 3174, 1594, 5315, 5333, 11684, 9786, 11907, 4493, - 10240, 8240, 11239, 10484, 4212, 11454, 10561, 4754, 10162, 5297, - - 11271, 1293, 7665, 7032, 11035, 12240, 5241, 11994, 4467, 9259, - 58, 4079, 11635, 2738, 11612, 8960, 7210, 8298, 3029, 9830, - 6950, 10777, 7232, 11964, 6171, 8326, 8812, 8243, 6153, 1975, - 10710, 6122, 1278, 8517, 421, 3123, 2033, 2500, 5468, 4016, - 7840, 9381, 10333, 10331, 5529, 3009, 10966, 6328, 4324, 10008, - 4213, 1566, 11821, 6920, 192, 6299, 8429, 10335, 2844, 8049, - 7341, 3315, 8332, 10929, 3514, 6860, 3600, 4433, 1359, 6374, - 4169, 6523, 5537, 9928, 8757, 11367, 10587, 5735, 6055, 168, - 10120, 2767, 7507, 8633, 8579, 1815, 7509, 1146, 11099, 6147, - 12147, 3150, 5415, 11942, 2505, 5184, 10316, 6381, 8687, 3054, - - 8410, 1583, 3482, 3762, 147, 8855, 885, 11177, 9090, 12115, - 52, 1962, 4075 -}; - -/** - * FFT phase shift in forward transform for q = 12289 and n = 512 - */ -static uint16_t wf_12289_512[] = { - 3186, 8646, 5828, 2925, 8146, 5906, 6747, 11089, 2645, 6715, - 9521, 11836, 2381, 6068, 2396, 6803, 1544, 1922, 8155, 6347, - 3778, 787, 1696, 9370, 4437, 8500, 10963, 8760, 11414, 6281, - 544, 2078, 3510, 12233, 9545, 723, 10849, 3174, 8058, 1594, - 4372, 5315, 2366, 5333, 3248, 11684, 7222, 9786, 243, 11907, - 5860, 4493, 11244, 10240, 10200, 8240, 10512, 11239, 9995, 10484, - 9867, 4212, 9764, 11454, 8241, 10561, 1351, 4754, 11744, 10162, - 6378, 5297, 1484, 11271, 11563, 1293, 1912, 7665, 6915, 7032, - 476, 11035, 12288, 12240, 9888, 5241, 11029, 11994, 10123, 4467, - 9970, 9259, 11287, 58, 2842, 4079, 3247, 11635, 4821, 2738, - - 11272, 11612, 3694, 8960, 8925, 7210, 9198, 8298, 1065, 3029, - 953, 9830, 2399, 6950, 8747, 10777, 11935, 7232, 10276, 11964, - 8653, 6171, 7443, 8326, 2437, 8812, 1673, 8243, 10659, 6153, - 6561, 1975, 10752, 10710, 8652, 6122, 5042, 1278, 1177, 8517, - 11796, 421, 8340, 3123, 5559, 2033, 1305, 2500, 11899, 5468, - 9863, 4016, 160, 7840, 3201, 9381, 4976, 10333, 2468, 10331, - 2370, 5529, 563, 3009, 12262, 10966, 8907, 6328, 2847, 4324, - 2963, 10008, 11121, 4213, 9813, 1566, 3000, 11821, 1646, 6920, - 7277, 192, 9408, 6299, 1426, 8429, 7484, 10335, 2566, 2844, - 4177, 8049, 1153, 7341, 3328, 3315, 2678, 8332, 2731, 10929, - - 7094, 3514, 140, 6860, 4337, 3600, 4354, 4433, 8304, 1359, - 5146, 6374, 5101, 4169, 7657, 6523, 113, 5537, 955, 9928, - 7201, 8757, 11267, 11367, 3978, 10587, 2625, 5735, 10657, 6055, - 1759, 168, 8232, 10120, 4320, 2767, 404, 7507, 11462, 8633, - 5191, 8579, 2545, 1815, 2912, 7509, 11560, 1146, 6998, 11099, - 3135, 6147, 6267, 12147, 5331, 3150, 6882, 5415, 7266, 11942, - 7575, 2505, 12144, 5184, 8236, 10316, 1635, 6381, 5444, 8687, - 7837, 3054, 2178, 8410, 6553, 1583, 3833, 3482, 10861, 3762, - 3, 147, 7203, 8855, 3780, 885, 6498, 11177, 6957, 9090, - 3006, 12115, 3763, 52, 2548, 1962, 10115, 4075, 3051, 2031, - - 1207, 9987, 10092, 2948, 9273, 11973, 9094, 3202, 9430, 7377, - 5092, 3728, 10626, 4536, 1062, 2882, 6039, 975, 10908, 6065, - 2249, 11889, 4978, 10431, 7270, 12138, 4890, 6119, 4895, 6364, - 4611, 4737, 10911, 6212, 9452, 8455, 8758, 11316, 1479, 11026, - 11847, 2920, 7901, 6190, 8374, 4789, 1170, 8174, 7278, 241, - 11809, 1058, 2686, 8724, 9650, 5868, 4885, 5874, 5179, 7991, - 10600, 3262, 81, 3969, 10146, 5594, 3748, 11606, 3400, 6843, - 3504, 11939, 7428, 7591, 3289, 1404, 7351, 3818, 2747, 11713, - 8643, 5681, 8011, 11580, 2126, 5862, 4591, 3757, 12047, 431, - 8830, 2555, 2305, 2344, 4255, 11871, 4096, 4080, 3296, 1747, - - 11869, 3998, 11567, 1489, 11516, 11279, 11955, 8212, 9140, 5456, - 9275, 12071, 1607, 5009, 11950, 7967, 9424, 7083, 2975, 10596, - 3066, 2766, 355, 5106, 4414, 7373, 4896, 6413, 7012, 11785, - 12171, 6507, 11618, 3988, 11077, 2057, 2481, 10968, 9005, 11130, - 4654, 6844, 3553, 2051, 2187, 8851, 3584, 3570, 2884, 6137, - 5777, 426, 8585, 2839, 3932, 8333, 2780, 1041, 1853, 4774, - 435, 9026, 12159, 5919, 7384, 5435, 8246, 10806, 1067, 3127, - 5755, 11637, 4919, 7540, 790, 1843, 4284, 1003, 12280, 11848, - 2969, 10302, 949, 9634, 5084, 3336, 3707, 9597, 3271, 522, - 1000, 12133, 4645, 6403, 6522, 64, 3136, 6196, 8668, 6906, - - 6591, 3445, 9048, 948, 9585, 2683, 8577, 2447, 9302, 1105, - 4989, 10970 -}; - -/** - * FFT phase shift and scaling inverse transform for q = 11289 and n = 512 + * FFT phase shift and scaling inverse transform for q = 12289 and n = 512 */ static uint16_t wi_12289_512[] = { 12265, 6771, 11424, 9011, 6203, 11914, 9021, 6454, 7154, 146, @@ -750,7 +624,7 @@ static uint16_t rev_512[] = { bliss_fft_params_t bliss_fft_12289_512 = { 12289, 12287, 18, 3186, (1<<18)-1, 512, 12265, 9, - wr_12289_512, wf_12289_512, wi_12289_512, rev_512 + wr_12289_1024, wf_12289_1024, wi_12289_512, 2, rev_512 }; /** @@ -774,5 +648,5 @@ static uint16_t wi_17_8[] = { 15, 5, 13, 10, 9, 3, 1, 6 }; static uint16_t rev_8[] = { 0, 4, 2, 6, 1, 5, 3, 7 }; bliss_fft_params_t bliss_fft_17_8 = { - 17, 15, 5, 4, (1<<5)-1, 8, 15, 3, wr_17_8, wf_17_8, wi_17_8, rev_8 + 17, 15, 5, 4, (1<<5)-1, 8, 15, 3, wr_17_8, wf_17_8, wi_17_8, 1, rev_8 }; diff --git a/src/libstrongswan/plugins/bliss/bliss_fft_params.h b/src/libstrongswan/plugins/bliss/bliss_fft_params.h index b38479eee4..0ed49b2cc0 100644 --- a/src/libstrongswan/plugins/bliss/bliss_fft_params.h +++ b/src/libstrongswan/plugins/bliss/bliss_fft_params.h @@ -85,6 +85,11 @@ struct bliss_fft_params_t { */ uint16_t *wi; + /** + * Subsampling of FFT twiddle factors table + */ + uint16_t s; + /** * FFT bit reversal */