Mercurial > libavcodec.hg
comparison fft.c @ 10496:74b0c1a0851e libavcodec
Add ff_init_ff_cos_tabs function and use it in rdft.c to ensure that the
necessary ff_cos_tabs tables are initialized.
Fixes issue 1507 (QDM2 broken since r20237 without hardcoded tables).
author | reimar |
---|---|
date | Thu, 05 Nov 2009 18:29:06 +0000 |
parents | 63910f7ba293 |
children | e45c852b6820 |
comparison
equal
deleted
inserted
replaced
10495:8e91a3efdbd2 | 10496:74b0c1a0851e |
---|---|
59 m >>= 1; | 59 m >>= 1; |
60 if(inverse == !(i&m)) return split_radix_permutation(i, m, inverse)*4 + 1; | 60 if(inverse == !(i&m)) return split_radix_permutation(i, m, inverse)*4 + 1; |
61 else return split_radix_permutation(i, m, inverse)*4 - 1; | 61 else return split_radix_permutation(i, m, inverse)*4 - 1; |
62 } | 62 } |
63 | 63 |
64 av_cold void ff_init_ff_cos_tabs(int index) | |
65 { | |
66 #if !CONFIG_HARDCODED_TABLES | |
67 int i; | |
68 int m = 1<<index; | |
69 double freq = 2*M_PI/m; | |
70 FFTSample *tab = ff_cos_tabs[index]; | |
71 for(i=0; i<=m/4; i++) | |
72 tab[i] = cos(i*freq); | |
73 for(i=1; i<m/4; i++) | |
74 tab[m/2-i] = tab[i]; | |
75 #endif | |
76 } | |
77 | |
64 av_cold int ff_fft_init(FFTContext *s, int nbits, int inverse) | 78 av_cold int ff_fft_init(FFTContext *s, int nbits, int inverse) |
65 { | 79 { |
66 int i, j, m, n; | 80 int i, j, m, n; |
67 float alpha, c1, s1, s2; | 81 float alpha, c1, s1, s2; |
68 int av_unused has_vectors; | 82 int av_unused has_vectors; |
94 if (ARCH_ARM) ff_fft_init_arm(s); | 108 if (ARCH_ARM) ff_fft_init_arm(s); |
95 if (HAVE_ALTIVEC) ff_fft_init_altivec(s); | 109 if (HAVE_ALTIVEC) ff_fft_init_altivec(s); |
96 if (HAVE_MMX) ff_fft_init_mmx(s); | 110 if (HAVE_MMX) ff_fft_init_mmx(s); |
97 | 111 |
98 if (s->split_radix) { | 112 if (s->split_radix) { |
99 #if !CONFIG_HARDCODED_TABLES | |
100 for(j=4; j<=nbits; j++) { | 113 for(j=4; j<=nbits; j++) { |
101 int m = 1<<j; | 114 ff_init_ff_cos_tabs(j); |
102 double freq = 2*M_PI/m; | |
103 FFTSample *tab = ff_cos_tabs[j]; | |
104 for(i=0; i<=m/4; i++) | |
105 tab[i] = cos(i*freq); | |
106 for(i=1; i<m/4; i++) | |
107 tab[m/2-i] = tab[i]; | |
108 } | 115 } |
109 #endif | |
110 for(i=0; i<n; i++) | 116 for(i=0; i<n; i++) |
111 s->revtab[-split_radix_permutation(i, n, s->inverse) & (n-1)] = i; | 117 s->revtab[-split_radix_permutation(i, n, s->inverse) & (n-1)] = i; |
112 s->tmp_buf = av_malloc(n * sizeof(FFTComplex)); | 118 s->tmp_buf = av_malloc(n * sizeof(FFTComplex)); |
113 } else { | 119 } else { |
114 int np, nblocks, np2, l; | 120 int np, nblocks, np2, l; |