void fft8_dit_core_p1(int *fr, int *fi) { int plus1a, plus2a, plus3a, plus4a, plus1b, plus2b; int mins1a, mins2a, mins3a, mins4a, mins1b, mins2b, mM1a, mM2a; sum_dif_I(fr[0], fr[1], &plus1a, &mins1a); sum_dif_I(fr[2], fr[3], &plus2a, &mins2a); sum_dif_I(fr[4], fr[5], &plus3a, &mins3a); sum_dif_I(fr[6], fr[7], &plus4a, &mins4a); sum_dif_I(plus1a, plus2a, &plus1b, &mins1b); sum_dif_I(plus3a, plus4a, &plus2b, &mins2b); sum_dif_I(plus1b, plus2b, &fr[0], &fr[4]); sum_dif_I(mins3a, mins4a, &mM1a, &mM2a); int prib1a, prib2a, prib3a, prib4a, prib1b, prib2b; int otnt1a, otnt2a, otnt3a, otnt4a, otnt1b, otnt2b, oT1a, oT2a; sum_dif_I(fi[0], fi[1], &prib1a, &otnt1a); sum_dif_I(fi[2], fi[3], &prib2a, &otnt2a); sum_dif_I(fi[4], fi[5], &prib3a, &otnt3a); sum_dif_I(fi[6], fi[7], &prib4a, &otnt4a); sum_dif_I(prib1a, prib2a, &prib1b, &otnt1b); sum_dif_I(prib3a, prib4a, &prib2b, &otnt2b); sum_dif_I(prib1b, prib2b, &fi[0], &fi[4]); sum_dif_I(otnt3a, otnt4a, &oT1a, &oT2a); mM2a = mult_shf_s16x16(mM2a, 181); sum_dif_I(mins1a, mM2a, &plus1a, &plus2a); prib2b = mult_shf_s16x16(oT1a, 181); sum_dif_I(otnt2a, prib2b, &mins3a, &plus3a); sum_dif_I(plus1a, mins3a, &fr[7], &fr[1]); sum_dif_I(mins1b, otnt2b, &fr[6], &fr[2]); sum_dif_I(plus2a, plus3a, &fr[3], &fr[5]); oT2a = mult_shf_s16x16(oT2a, 181); sum_dif_I( otnt1a, oT2a, &plus1a, &plus2a); plus2b = mult_shf_s16x16(mM1a, 181); sum_dif_I(-mins2a, plus2b, &plus3a, &mins3a); sum_dif_I(plus1a, mins3a, &fi[7], &fi[1]); sum_dif_I(otnt1b,-mins2b, &fi[6], &fi[2]); sum_dif_I(plus2a, plus3a, &fi[3], &fi[5]); }
void fft_radix4_I( int *fr, int *fi, int ldn) { const int n = (1UL<<ldn); int ldm = 0, rdx = 2; for (int i0 = 0; i0 < n; i0 += 4) { int xr,yr,ur,vr, xi,yi,ui,vi; int i1 = i0 + 1; int i2 = i1 + 1; int i3 = i2 + 1; sum_dif_I(fr[i0], fr[i1], xr, ur); sum_dif_I(fr[i2], fr[i3], yr, vi); sum_dif_I(fi[i0], fi[i1], xi, ui); sum_dif_I(fi[i3], fi[i2], yi, vr); sum_dif_I(ui, vi, fi[i1], fi[i3]); sum_dif_I(xi, yi, fi[i0], fi[i2]); sum_dif_I(ur, vr, fr[i1], fr[i3]); sum_dif_I(xr, yr, fr[i0], fr[i2]); } for (ldm = 2 * rdx; ldm <= ldn; ldm += rdx) { int m = (1UL<<ldm); int m4 = (m>>rdx); int phI0 = NWAVE / m; int phI = 0; for (int j = 0; j < m4; j++) { int c,s,c2,s2,c3,s3; s = Sinewave[ phI]; s2 = Sinewave[ 2*phI]; s3 = Sinewave[ 3*phI]; c = Sinewave[ phI + NWAVE/4]; c2 = Sinewave[ 2*phI + NWAVE/4]; c3 = Sinewave[ 3*phI + NWAVE/4]; for (int r = 0; r < n; r += m) { int i0 = j + r; int i1 = i0 + m4; int i2 = i1 + m4; int i3 = i2 + m4; int xr,yr,ur,vr, xi,yi,ui,vi; mult_shf_I( c2, s2, fr[i1], fi[i1], xr, xi); mult_shf_I( c, s, fr[i2], fi[i2], yr, vr); mult_shf_I( c3, s3, fr[i3], fi[i3], vi, yi); int t = yi - vr; yi += vr; vr = t; ur = fr[i0] - xr; xr += fr[i0]; sum_dif_I(ur, vr, fr[i1], fr[i3]); t = yr - vi; yr += vi; vi = t; ui = fi[i0] - xi; xi += fi[i0]; sum_dif_I(ui, vi, fi[i1], fi[i3]); sum_dif_I(xr, yr, fr[i0], fr[i2]); sum_dif_I(xi, yi, fi[i0], fi[i2]); } phI += phI0; } } }
void fft_radix4_I(int *fr, int *fi, int ldn) { const int n = (1UL<<ldn); int ldm = 0, rdx = 2; ldm = (ldn&1); if ( ldm!=0 ) { for (int i0=0; i0<n; i0+=8) { fft8_dit_core_p1(fr+i0, fi+i0); } } else { for (int i0 = 0; i0 < n; i0 += 4) { int xr,yr,ur,vr, xi,yi,ui,vi; int i1 = i0 + 1; int i2 = i1 + 1; int i3 = i2 + 1; sum_dif_I(fr[i0], fr[i1], &xr, &ur); sum_dif_I(fr[i2], fr[i3], &yr, &vi); sum_dif_I(fi[i0], fi[i1], &xi, &ui); sum_dif_I(fi[i3], fi[i2], &yi, &vr); sum_dif_I(ui, vi, &fi[i1], &fi[i3]); sum_dif_I(xi, yi, &fi[i0], &fi[i2]); sum_dif_I(ur, vr, &fr[i1], &fr[i3]); sum_dif_I(xr, yr, &fr[i0], &fr[i2]); } } for (ldm += 2 * rdx; ldm <= ldn; ldm += rdx) { int m = (1UL<<ldm); int m4 = (m>>rdx); int phI0 = NWAVE / m; int phI = 0; for (int j = 0; j < m4; j++) { int c,s,c2,s2,c3,s3; s = pgm_read_word(&Sinewave[ phI]); s2 = pgm_read_word(&Sinewave[ 2*phI]); s3 = pgm_read_word(&Sinewave[ 3*phI]); c = pgm_read_word(&Sinewave[ phI + NWAVE/4]); c2 = pgm_read_word(&Sinewave[ 2*phI + NWAVE/4]); c3 = pgm_read_word(&Sinewave[ 3*phI + NWAVE/4]); for (int r = 0; r < n; r += m) { int i0 = j + r; int i1 = i0 + m4; int i2 = i1 + m4; int i3 = i2 + m4; int xr,yr,ur,vr,xi,yi,ui,vi; mult_shf_I( c2, s2, fr[i1], fi[i1], &xr, &xi); mult_shf_I( c, s, fr[i2], fi[i2], &yr, &vr); mult_shf_I( c3, s3, fr[i3], fi[i3], &vi, &yi); int t = yi - vr; yi += vr; vr = t; ur = fr[i0] - xr; xr += fr[i0]; sum_dif_I(ur, vr, &fr[i1], &fr[i3]); t = yr - vi; yr += vi; vi = t; ui = fi[i0] - xi; xi += fi[i0]; sum_dif_I(ui, vi, &fi[i1], &fi[i3]); sum_dif_I(xr, yr, &fr[i0], &fr[i2]); sum_dif_I(xi, yi, &fi[i0], &fi[i2]); } phI += phI0; } } }