comparison rdft.c @ 11513:66da6ffd7ed5 libavcodec

rdft: reorder functions to avoid static prototype
author mru
date Sat, 20 Mar 2010 21:27:06 +0000
parents 1382cfff33bb
children e011e73a902b
comparison
equal deleted inserted replaced
11512:1382cfff33bb 11513:66da6ffd7ed5
48 NULL, NULL, NULL, NULL, 48 NULL, NULL, NULL, NULL,
49 ff_sin_16, ff_sin_32, ff_sin_64, ff_sin_128, ff_sin_256, ff_sin_512, ff_sin_1024, 49 ff_sin_16, ff_sin_32, ff_sin_64, ff_sin_128, ff_sin_256, ff_sin_512, ff_sin_1024,
50 ff_sin_2048, ff_sin_4096, ff_sin_8192, ff_sin_16384, ff_sin_32768, ff_sin_65536, 50 ff_sin_2048, ff_sin_4096, ff_sin_8192, ff_sin_16384, ff_sin_32768, ff_sin_65536,
51 }; 51 };
52 52
53 static void ff_rdft_calc_c(RDFTContext* s, FFTSample* data);
54
55 av_cold int ff_rdft_init(RDFTContext *s, int nbits, enum RDFTransformType trans)
56 {
57 int n = 1 << nbits;
58 int i;
59 const double theta = (trans == DFT_R2C || trans == DFT_C2R ? -1 : 1)*2*M_PI/n;
60
61 s->nbits = nbits;
62 s->inverse = trans == IDFT_C2R || trans == DFT_C2R;
63 s->sign_convention = trans == IDFT_R2C || trans == DFT_C2R ? 1 : -1;
64
65 if (nbits < 4 || nbits > 16)
66 return -1;
67
68 if (ff_fft_init(&s->fft, nbits-1, trans == IDFT_C2R || trans == IDFT_R2C) < 0)
69 return -1;
70
71 ff_init_ff_cos_tabs(nbits);
72 s->tcos = ff_cos_tabs[nbits];
73 s->tsin = ff_sin_tabs[nbits]+(trans == DFT_R2C || trans == DFT_C2R)*(n>>2);
74 #if !CONFIG_HARDCODED_TABLES
75 for (i = 0; i < (n>>2); i++) {
76 s->tsin[i] = sin(i*theta);
77 }
78 #endif
79 s->rdft_calc = ff_rdft_calc_c;
80 return 0;
81 }
82
83 /** Map one real FFT into two parallel real even and odd FFTs. Then interleave 53 /** Map one real FFT into two parallel real even and odd FFTs. Then interleave
84 * the two real FFTs into one complex FFT. Unmangle the results. 54 * the two real FFTs into one complex FFT. Unmangle the results.
85 * ref: http://www.engineeringproductivitytools.com/stuff/T0001/PT10.HTM 55 * ref: http://www.engineeringproductivitytools.com/stuff/T0001/PT10.HTM
86 */ 56 */
87 static void ff_rdft_calc_c(RDFTContext* s, FFTSample* data) 57 static void ff_rdft_calc_c(RDFTContext* s, FFTSample* data)
124 ff_fft_permute(&s->fft, (FFTComplex*)data); 94 ff_fft_permute(&s->fft, (FFTComplex*)data);
125 ff_fft_calc(&s->fft, (FFTComplex*)data); 95 ff_fft_calc(&s->fft, (FFTComplex*)data);
126 } 96 }
127 } 97 }
128 98
99 av_cold int ff_rdft_init(RDFTContext *s, int nbits, enum RDFTransformType trans)
100 {
101 int n = 1 << nbits;
102 int i;
103 const double theta = (trans == DFT_R2C || trans == DFT_C2R ? -1 : 1)*2*M_PI/n;
104
105 s->nbits = nbits;
106 s->inverse = trans == IDFT_C2R || trans == DFT_C2R;
107 s->sign_convention = trans == IDFT_R2C || trans == DFT_C2R ? 1 : -1;
108
109 if (nbits < 4 || nbits > 16)
110 return -1;
111
112 if (ff_fft_init(&s->fft, nbits-1, trans == IDFT_C2R || trans == IDFT_R2C) < 0)
113 return -1;
114
115 ff_init_ff_cos_tabs(nbits);
116 s->tcos = ff_cos_tabs[nbits];
117 s->tsin = ff_sin_tabs[nbits]+(trans == DFT_R2C || trans == DFT_C2R)*(n>>2);
118 #if !CONFIG_HARDCODED_TABLES
119 for (i = 0; i < (n>>2); i++) {
120 s->tsin[i] = sin(i*theta);
121 }
122 #endif
123 s->rdft_calc = ff_rdft_calc_c;
124 return 0;
125 }
126
129 av_cold void ff_rdft_end(RDFTContext *s) 127 av_cold void ff_rdft_end(RDFTContext *s)
130 { 128 {
131 ff_fft_end(&s->fft); 129 ff_fft_end(&s->fft);
132 } 130 }