OLD | NEW |
1 /* | 1 /* |
2 * http://www.kurims.kyoto-u.ac.jp/~ooura/fft.html | 2 * http://www.kurims.kyoto-u.ac.jp/~ooura/fft.html |
3 * Copyright Takuya OOURA, 1996-2001 | 3 * Copyright Takuya OOURA, 1996-2001 |
4 * | 4 * |
5 * You may use, copy, modify and distribute this code for any purpose (include | 5 * You may use, copy, modify and distribute this code for any purpose (include |
6 * commercial use) and without fee. Please refer to this package when you modify | 6 * commercial use) and without fee. Please refer to this package when you modify |
7 * this code. | 7 * this code. |
8 * | 8 * |
9 * Changes: | 9 * Changes: |
10 * Trivial type modifications by the WebRTC authors. | 10 * Trivial type modifications by the WebRTC authors. |
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
282 | 282 |
283 | 283 |
284 Appendix : | 284 Appendix : |
285 The cos/sin table is recalculated when the larger table required. | 285 The cos/sin table is recalculated when the larger table required. |
286 w[] and ip[] are compatible with all routines. | 286 w[] and ip[] are compatible with all routines. |
287 */ | 287 */ |
288 | 288 |
289 static void makewt(int nw, int *ip, float *w); | 289 static void makewt(int nw, int *ip, float *w); |
290 static void makect(int nc, int *ip, float *c); | 290 static void makect(int nc, int *ip, float *c); |
291 static void bitrv2(int n, int *ip, float *a); | 291 static void bitrv2(int n, int *ip, float *a); |
| 292 #if 0 // Not used. |
292 static void bitrv2conj(int n, int *ip, float *a); | 293 static void bitrv2conj(int n, int *ip, float *a); |
| 294 #endif |
293 static void cftfsub(int n, float *a, float *w); | 295 static void cftfsub(int n, float *a, float *w); |
294 static void cftbsub(int n, float *a, float *w); | 296 static void cftbsub(int n, float *a, float *w); |
295 static void cft1st(int n, float *a, float *w); | 297 static void cft1st(int n, float *a, float *w); |
296 static void cftmdl(int n, int l, float *a, float *w); | 298 static void cftmdl(int n, int l, float *a, float *w); |
297 static void rftfsub(int n, float *a, int nc, float *c); | 299 static void rftfsub(int n, float *a, int nc, float *c); |
298 static void rftbsub(int n, float *a, int nc, float *c); | 300 static void rftbsub(int n, float *a, int nc, float *c); |
299 #if 0 // Not used. | 301 #if 0 // Not used. |
300 static void dctsub(int n, float *a, int nc, float *c) | 302 static void dctsub(int n, float *a, int nc, float *c) |
301 static void dstsub(int n, float *a, int nc, float *c) | 303 static void dstsub(int n, float *a, int nc, float *c) |
302 #endif | 304 #endif |
303 | 305 |
304 | 306 |
| 307 #if 0 // Not used. |
305 void WebRtc_cdft(int n, int isgn, float *a, int *ip, float *w) | 308 void WebRtc_cdft(int n, int isgn, float *a, int *ip, float *w) |
306 { | 309 { |
307 if (n > (ip[0] << 2)) { | 310 if (n > (ip[0] << 2)) { |
308 makewt(n >> 2, ip, w); | 311 makewt(n >> 2, ip, w); |
309 } | 312 } |
310 if (n > 4) { | 313 if (n > 4) { |
311 if (isgn >= 0) { | 314 if (isgn >= 0) { |
312 bitrv2(n, ip + 2, a); | 315 bitrv2(n, ip + 2, a); |
313 cftfsub(n, a, w); | 316 cftfsub(n, a, w); |
314 } else { | 317 } else { |
315 bitrv2conj(n, ip + 2, a); | 318 bitrv2conj(n, ip + 2, a); |
316 cftbsub(n, a, w); | 319 cftbsub(n, a, w); |
317 } | 320 } |
318 } else if (n == 4) { | 321 } else if (n == 4) { |
319 cftfsub(n, a, w); | 322 cftfsub(n, a, w); |
320 } | 323 } |
321 } | 324 } |
| 325 #endif |
322 | 326 |
323 | 327 |
324 void WebRtc_rdft(int n, int isgn, float *a, int *ip, float *w) | 328 void WebRtc_rdft(int n, int isgn, float *a, int *ip, float *w) |
325 { | 329 { |
326 int nw, nc; | 330 int nw, nc; |
327 float xi; | 331 float xi; |
328 | 332 |
329 nw = ip[0]; | 333 nw = ip[0]; |
330 if (n > (nw << 2)) { | 334 if (n > (nw << 2)) { |
331 nw = n >> 2; | 335 nw = n >> 2; |
(...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
782 yi = a[k1 + 1]; | 786 yi = a[k1 + 1]; |
783 a[j1] = yr; | 787 a[j1] = yr; |
784 a[j1 + 1] = yi; | 788 a[j1 + 1] = yi; |
785 a[k1] = xr; | 789 a[k1] = xr; |
786 a[k1 + 1] = xi; | 790 a[k1 + 1] = xi; |
787 } | 791 } |
788 } | 792 } |
789 } | 793 } |
790 } | 794 } |
791 | 795 |
792 | 796 #if 0 // Not used. |
793 static void bitrv2conj(int n, int *ip, float *a) | 797 static void bitrv2conj(int n, int *ip, float *a) |
794 { | 798 { |
795 int j, j1, k, k1, l, m, m2; | 799 int j, j1, k, k1, l, m, m2; |
796 float xr, xi, yr, yi; | 800 float xr, xi, yr, yi; |
797 | 801 |
798 ip[0] = 0; | 802 ip[0] = 0; |
799 l = n; | 803 l = n; |
800 m = 1; | 804 m = 1; |
801 while ((m << 3) < l) { | 805 while ((m << 3) < l) { |
802 l >>= 1; | 806 l >>= 1; |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
890 a[j1 + 1] = yi; | 894 a[j1 + 1] = yi; |
891 a[k1] = xr; | 895 a[k1] = xr; |
892 a[k1 + 1] = xi; | 896 a[k1 + 1] = xi; |
893 } | 897 } |
894 k1 = 2 * k + ip[k]; | 898 k1 = 2 * k + ip[k]; |
895 a[k1 + 1] = -a[k1 + 1]; | 899 a[k1 + 1] = -a[k1 + 1]; |
896 a[k1 + m2 + 1] = -a[k1 + m2 + 1]; | 900 a[k1 + m2 + 1] = -a[k1 + m2 + 1]; |
897 } | 901 } |
898 } | 902 } |
899 } | 903 } |
900 | 904 #endif |
901 | 905 |
902 static void cftfsub(int n, float *a, float *w) | 906 static void cftfsub(int n, float *a, float *w) |
903 { | 907 { |
904 int j, j1, j2, j3, l; | 908 int j, j1, j2, j3, l; |
905 float x0r, x0i, x1r, x1i, x2r, x2i, x3r, x3i; | 909 float x0r, x0i, x1r, x1i, x2r, x2i, x3r, x3i; |
906 | 910 |
907 l = 2; | 911 l = 2; |
908 if (n > 8) { | 912 if (n > 8) { |
909 cft1st(n, a, w); | 913 cft1st(n, a, w); |
910 l = 8; | 914 l = 8; |
(...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1317 kk += ks; | 1321 kk += ks; |
1318 wkr = c[kk] - c[nc - kk]; | 1322 wkr = c[kk] - c[nc - kk]; |
1319 wki = c[kk] + c[nc - kk]; | 1323 wki = c[kk] + c[nc - kk]; |
1320 xr = wki * a[k] - wkr * a[j]; | 1324 xr = wki * a[k] - wkr * a[j]; |
1321 a[k] = wkr * a[k] + wki * a[j]; | 1325 a[k] = wkr * a[k] + wki * a[j]; |
1322 a[j] = xr; | 1326 a[j] = xr; |
1323 } | 1327 } |
1324 a[m] *= c[0]; | 1328 a[m] *= c[0]; |
1325 } | 1329 } |
1326 #endif // Not used. | 1330 #endif // Not used. |
OLD | NEW |