Mercurial > libavcodec.hg
annotate fft-test.c @ 10917:895df334c326 libavcodec
Set h->cbp for ff_h264_filter_mb_fast().
author | michael |
---|---|
date | Mon, 18 Jan 2010 16:11:13 +0000 |
parents | 177ebc61c3d6 |
children | 0985f1f7ab72 |
rev | line source |
---|---|
3699
c537a97eec66
Add official LGPL license headers to the files that were missing them.
diego
parents:
2967
diff
changeset
|
1 /* |
c537a97eec66
Add official LGPL license headers to the files that were missing them.
diego
parents:
2967
diff
changeset
|
2 * (c) 2002 Fabrice Bellard |
c537a97eec66
Add official LGPL license headers to the files that were missing them.
diego
parents:
2967
diff
changeset
|
3 * |
3947
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3699
diff
changeset
|
4 * This file is part of FFmpeg. |
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3699
diff
changeset
|
5 * |
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3699
diff
changeset
|
6 * FFmpeg is free software; you can redistribute it and/or |
3699
c537a97eec66
Add official LGPL license headers to the files that were missing them.
diego
parents:
2967
diff
changeset
|
7 * modify it under the terms of the GNU Lesser General Public |
c537a97eec66
Add official LGPL license headers to the files that were missing them.
diego
parents:
2967
diff
changeset
|
8 * License as published by the Free Software Foundation; either |
3947
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3699
diff
changeset
|
9 * version 2.1 of the License, or (at your option) any later version. |
3699
c537a97eec66
Add official LGPL license headers to the files that were missing them.
diego
parents:
2967
diff
changeset
|
10 * |
3947
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3699
diff
changeset
|
11 * FFmpeg is distributed in the hope that it will be useful, |
3699
c537a97eec66
Add official LGPL license headers to the files that were missing them.
diego
parents:
2967
diff
changeset
|
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
c537a97eec66
Add official LGPL license headers to the files that were missing them.
diego
parents:
2967
diff
changeset
|
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
c537a97eec66
Add official LGPL license headers to the files that were missing them.
diego
parents:
2967
diff
changeset
|
14 * Lesser General Public License for more details. |
c537a97eec66
Add official LGPL license headers to the files that were missing them.
diego
parents:
2967
diff
changeset
|
15 * |
c537a97eec66
Add official LGPL license headers to the files that were missing them.
diego
parents:
2967
diff
changeset
|
16 * You should have received a copy of the GNU Lesser General Public |
3947
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3699
diff
changeset
|
17 * License along with FFmpeg; if not, write to the Free Software |
3699
c537a97eec66
Add official LGPL license headers to the files that were missing them.
diego
parents:
2967
diff
changeset
|
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
c537a97eec66
Add official LGPL license headers to the files that were missing them.
diego
parents:
2967
diff
changeset
|
19 */ |
c537a97eec66
Add official LGPL license headers to the files that were missing them.
diego
parents:
2967
diff
changeset
|
20 |
1106 | 21 /** |
8718
e9d9d946f213
Use full internal pathname in doxygen @file directives.
diego
parents:
7546
diff
changeset
|
22 * @file libavcodec/fft-test.c |
1106 | 23 * FFT and MDCT tests. |
24 */ | |
25 | |
9199
ea0e5e9a520f
Replace random() usage in test programs by av_lfg_*().
diego
parents:
8718
diff
changeset
|
26 #include "libavutil/lfg.h" |
781 | 27 #include "dsputil.h" |
28 #include <math.h> | |
980 | 29 #include <unistd.h> |
781 | 30 #include <sys/time.h> |
5118
3b190bc34546
Add some #includes to allow compilation without HAVE_AV_CONFIG_H.
diego
parents:
4760
diff
changeset
|
31 #include <stdlib.h> |
3b190bc34546
Add some #includes to allow compilation without HAVE_AV_CONFIG_H.
diego
parents:
4760
diff
changeset
|
32 #include <string.h> |
781 | 33 |
4760 | 34 #undef exit |
35 | |
781 | 36 /* reference fft */ |
37 | |
38 #define MUL16(a,b) ((a) * (b)) | |
39 | |
40 #define CMAC(pre, pim, are, aim, bre, bim) \ | |
41 {\ | |
42 pre += (MUL16(are, bre) - MUL16(aim, bim));\ | |
43 pim += (MUL16(are, bim) + MUL16(bre, aim));\ | |
44 } | |
45 | |
46 FFTComplex *exptab; | |
47 | |
9295
b225f51903af
Mark non-exported functions in test and example programs as static.
diego
parents:
9199
diff
changeset
|
48 static void fft_ref_init(int nbits, int inverse) |
781 | 49 { |
50 int n, i; | |
5418
95234f2e0bdd
make the reference code use double instead of float where it is easy
michael
parents:
5417
diff
changeset
|
51 double c1, s1, alpha; |
781 | 52 |
53 n = 1 << nbits; | |
54 exptab = av_malloc((n / 2) * sizeof(FFTComplex)); | |
55 | |
10807 | 56 for (i = 0; i < (n/2); i++) { |
781 | 57 alpha = 2 * M_PI * (float)i / (float)n; |
58 c1 = cos(alpha); | |
59 s1 = sin(alpha); | |
60 if (!inverse) | |
61 s1 = -s1; | |
62 exptab[i].re = c1; | |
63 exptab[i].im = s1; | |
64 } | |
65 } | |
66 | |
9295
b225f51903af
Mark non-exported functions in test and example programs as static.
diego
parents:
9199
diff
changeset
|
67 static void fft_ref(FFTComplex *tabr, FFTComplex *tab, int nbits) |
781 | 68 { |
69 int n, i, j, k, n2; | |
5418
95234f2e0bdd
make the reference code use double instead of float where it is easy
michael
parents:
5417
diff
changeset
|
70 double tmp_re, tmp_im, s, c; |
781 | 71 FFTComplex *q; |
72 | |
73 n = 1 << nbits; | |
74 n2 = n >> 1; | |
10807 | 75 for (i = 0; i < n; i++) { |
781 | 76 tmp_re = 0; |
77 tmp_im = 0; | |
78 q = tab; | |
10807 | 79 for (j = 0; j < n; j++) { |
781 | 80 k = (i * j) & (n - 1); |
81 if (k >= n2) { | |
82 c = -exptab[k - n2].re; | |
83 s = -exptab[k - n2].im; | |
84 } else { | |
85 c = exptab[k].re; | |
86 s = exptab[k].im; | |
87 } | |
88 CMAC(tmp_re, tmp_im, c, s, q->re, q->im); | |
89 q++; | |
90 } | |
91 tabr[i].re = tmp_re; | |
92 tabr[i].im = tmp_im; | |
93 } | |
94 } | |
95 | |
9295
b225f51903af
Mark non-exported functions in test and example programs as static.
diego
parents:
9199
diff
changeset
|
96 static void imdct_ref(float *out, float *in, int nbits) |
781 | 97 { |
5442 | 98 int n = 1<<nbits; |
781 | 99 int k, i, a; |
5418
95234f2e0bdd
make the reference code use double instead of float where it is easy
michael
parents:
5417
diff
changeset
|
100 double sum, f; |
781 | 101 |
10807 | 102 for (i = 0; i < n; i++) { |
781 | 103 sum = 0; |
10807 | 104 for (k = 0; k < n/2; k++) { |
781 | 105 a = (2 * i + 1 + (n / 2)) * (2 * k + 1); |
106 f = cos(M_PI * a / (double)(2 * n)); | |
107 sum += f * in[k]; | |
108 } | |
109 out[i] = -sum; | |
110 } | |
111 } | |
112 | |
113 /* NOTE: no normalisation by 1 / N is done */ | |
9295
b225f51903af
Mark non-exported functions in test and example programs as static.
diego
parents:
9199
diff
changeset
|
114 static void mdct_ref(float *output, float *input, int nbits) |
781 | 115 { |
5442 | 116 int n = 1<<nbits; |
781 | 117 int k, i; |
5418
95234f2e0bdd
make the reference code use double instead of float where it is easy
michael
parents:
5417
diff
changeset
|
118 double a, s; |
781 | 119 |
120 /* do it by hand */ | |
10807 | 121 for (k = 0; k < n/2; k++) { |
781 | 122 s = 0; |
10807 | 123 for (i = 0; i < n; i++) { |
781 | 124 a = (2*M_PI*(2*i+1+n/2)*(2*k+1) / (4 * n)); |
125 s += input[i] * cos(a); | |
126 } | |
127 output[k] = s; | |
128 } | |
129 } | |
130 | |
131 | |
10074
c4a83f3a5c9f
bring back some randomness in fft-test. (regression in r18070)
lorenm
parents:
9674
diff
changeset
|
132 static float frandom(AVLFG *prng) |
781 | 133 { |
10074
c4a83f3a5c9f
bring back some randomness in fft-test. (regression in r18070)
lorenm
parents:
9674
diff
changeset
|
134 return (int16_t)av_lfg_get(prng) / 32768.0; |
781 | 135 } |
136 | |
9295
b225f51903af
Mark non-exported functions in test and example programs as static.
diego
parents:
9199
diff
changeset
|
137 static int64_t gettime(void) |
781 | 138 { |
139 struct timeval tv; | |
140 gettimeofday(&tv,NULL); | |
1064 | 141 return (int64_t)tv.tv_sec * 1000000 + tv.tv_usec; |
781 | 142 } |
143 | |
9674
dac20d8df581
Support for testing (i)MDCT output scale factor in fft-test tool.
serge
parents:
9658
diff
changeset
|
144 static void check_diff(float *tab1, float *tab2, int n, double scale) |
781 | 145 { |
146 int i; | |
5417 | 147 double max= 0; |
148 double error= 0; | |
781 | 149 |
10807 | 150 for (i = 0; i < n; i++) { |
9674
dac20d8df581
Support for testing (i)MDCT output scale factor in fft-test tool.
serge
parents:
9658
diff
changeset
|
151 double e= fabsf(tab1[i] - (tab2[i] / scale)); |
5417 | 152 if (e >= 1e-3) { |
2967 | 153 av_log(NULL, AV_LOG_ERROR, "ERROR %d: %f %f\n", |
781 | 154 i, tab1[i], tab2[i]); |
155 } | |
5417 | 156 error+= e*e; |
157 if(e>max) max= e; | |
781 | 158 } |
5417 | 159 av_log(NULL, AV_LOG_INFO, "max:%f e:%g\n", max, sqrt(error)/n); |
781 | 160 } |
161 | |
162 | |
9295
b225f51903af
Mark non-exported functions in test and example programs as static.
diego
parents:
9199
diff
changeset
|
163 static void help(void) |
781 | 164 { |
2593
786ccf72ccd5
printf -> av_log patch by (Benjamin Larsson <>banan student.ltu se)
michael
parents:
1879
diff
changeset
|
165 av_log(NULL, AV_LOG_INFO,"usage: fft-test [-h] [-s] [-i] [-n b]\n" |
781 | 166 "-h print this help\n" |
167 "-s speed test\n" | |
168 "-m (I)MDCT test\n" | |
169 "-i inverse transform test\n" | |
170 "-n b set the transform size to 2^b\n" | |
9674
dac20d8df581
Support for testing (i)MDCT output scale factor in fft-test tool.
serge
parents:
9658
diff
changeset
|
171 "-f x set scale factor for output data of (I)MDCT to x\n" |
781 | 172 ); |
173 exit(1); | |
174 } | |
175 | |
10846
8dbceaa5fa2f
fft-test: Replace do_mdct with a tf_transform enum and switch on it.
alexc
parents:
10807
diff
changeset
|
176 enum tf_transform { |
8dbceaa5fa2f
fft-test: Replace do_mdct with a tf_transform enum and switch on it.
alexc
parents:
10807
diff
changeset
|
177 TRANSFORM_FFT, |
8dbceaa5fa2f
fft-test: Replace do_mdct with a tf_transform enum and switch on it.
alexc
parents:
10807
diff
changeset
|
178 TRANSFORM_MDCT, |
10847 | 179 TRANSFORM_RDFT, |
10846
8dbceaa5fa2f
fft-test: Replace do_mdct with a tf_transform enum and switch on it.
alexc
parents:
10807
diff
changeset
|
180 }; |
781 | 181 |
182 int main(int argc, char **argv) | |
183 { | |
184 FFTComplex *tab, *tab1, *tab_ref; | |
7546 | 185 FFTSample *tab2; |
781 | 186 int it, i, c; |
187 int do_speed = 0; | |
10846
8dbceaa5fa2f
fft-test: Replace do_mdct with a tf_transform enum and switch on it.
alexc
parents:
10807
diff
changeset
|
188 enum tf_transform transform = TRANSFORM_FFT; |
781 | 189 int do_inverse = 0; |
190 FFTContext s1, *s = &s1; | |
10199 | 191 FFTContext m1, *m = &m1; |
10847 | 192 RDFTContext r1, *r = &r1; |
193 int fft_nbits, fft_size, fft_size_2; | |
9674
dac20d8df581
Support for testing (i)MDCT output scale factor in fft-test tool.
serge
parents:
9658
diff
changeset
|
194 double scale = 1.0; |
10074
c4a83f3a5c9f
bring back some randomness in fft-test. (regression in r18070)
lorenm
parents:
9674
diff
changeset
|
195 AVLFG prng; |
c4a83f3a5c9f
bring back some randomness in fft-test. (regression in r18070)
lorenm
parents:
9674
diff
changeset
|
196 av_lfg_init(&prng, 1); |
781 | 197 |
198 fft_nbits = 9; | |
199 for(;;) { | |
10847 | 200 c = getopt(argc, argv, "hsimrn:f:"); |
781 | 201 if (c == -1) |
202 break; | |
203 switch(c) { | |
204 case 'h': | |
205 help(); | |
206 break; | |
207 case 's': | |
208 do_speed = 1; | |
209 break; | |
210 case 'i': | |
211 do_inverse = 1; | |
212 break; | |
213 case 'm': | |
10846
8dbceaa5fa2f
fft-test: Replace do_mdct with a tf_transform enum and switch on it.
alexc
parents:
10807
diff
changeset
|
214 transform = TRANSFORM_MDCT; |
781 | 215 break; |
10847 | 216 case 'r': |
217 transform = TRANSFORM_RDFT; | |
218 break; | |
781 | 219 case 'n': |
220 fft_nbits = atoi(optarg); | |
221 break; | |
9674
dac20d8df581
Support for testing (i)MDCT output scale factor in fft-test tool.
serge
parents:
9658
diff
changeset
|
222 case 'f': |
dac20d8df581
Support for testing (i)MDCT output scale factor in fft-test tool.
serge
parents:
9658
diff
changeset
|
223 scale = atof(optarg); |
dac20d8df581
Support for testing (i)MDCT output scale factor in fft-test tool.
serge
parents:
9658
diff
changeset
|
224 break; |
781 | 225 } |
226 } | |
227 | |
228 fft_size = 1 << fft_nbits; | |
10847 | 229 fft_size_2 = fft_size >> 1; |
781 | 230 tab = av_malloc(fft_size * sizeof(FFTComplex)); |
231 tab1 = av_malloc(fft_size * sizeof(FFTComplex)); | |
232 tab_ref = av_malloc(fft_size * sizeof(FFTComplex)); | |
233 tab2 = av_malloc(fft_size * sizeof(FFTSample)); | |
234 | |
10846
8dbceaa5fa2f
fft-test: Replace do_mdct with a tf_transform enum and switch on it.
alexc
parents:
10807
diff
changeset
|
235 switch (transform) { |
8dbceaa5fa2f
fft-test: Replace do_mdct with a tf_transform enum and switch on it.
alexc
parents:
10807
diff
changeset
|
236 case TRANSFORM_MDCT: |
9674
dac20d8df581
Support for testing (i)MDCT output scale factor in fft-test tool.
serge
parents:
9658
diff
changeset
|
237 av_log(NULL, AV_LOG_INFO,"Scale factor is set to %f\n", scale); |
781 | 238 if (do_inverse) |
2593
786ccf72ccd5
printf -> av_log patch by (Benjamin Larsson <>banan student.ltu se)
michael
parents:
1879
diff
changeset
|
239 av_log(NULL, AV_LOG_INFO,"IMDCT"); |
781 | 240 else |
2593
786ccf72ccd5
printf -> av_log patch by (Benjamin Larsson <>banan student.ltu se)
michael
parents:
1879
diff
changeset
|
241 av_log(NULL, AV_LOG_INFO,"MDCT"); |
9674
dac20d8df581
Support for testing (i)MDCT output scale factor in fft-test tool.
serge
parents:
9658
diff
changeset
|
242 ff_mdct_init(m, fft_nbits, do_inverse, scale); |
10846
8dbceaa5fa2f
fft-test: Replace do_mdct with a tf_transform enum and switch on it.
alexc
parents:
10807
diff
changeset
|
243 break; |
8dbceaa5fa2f
fft-test: Replace do_mdct with a tf_transform enum and switch on it.
alexc
parents:
10807
diff
changeset
|
244 case TRANSFORM_FFT: |
781 | 245 if (do_inverse) |
2593
786ccf72ccd5
printf -> av_log patch by (Benjamin Larsson <>banan student.ltu se)
michael
parents:
1879
diff
changeset
|
246 av_log(NULL, AV_LOG_INFO,"IFFT"); |
781 | 247 else |
2593
786ccf72ccd5
printf -> av_log patch by (Benjamin Larsson <>banan student.ltu se)
michael
parents:
1879
diff
changeset
|
248 av_log(NULL, AV_LOG_INFO,"FFT"); |
1879
dd63cb7e5080
fft_*() renamed into ff_fft_*() patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents:
1106
diff
changeset
|
249 ff_fft_init(s, fft_nbits, do_inverse); |
781 | 250 fft_ref_init(fft_nbits, do_inverse); |
10846
8dbceaa5fa2f
fft-test: Replace do_mdct with a tf_transform enum and switch on it.
alexc
parents:
10807
diff
changeset
|
251 break; |
10847 | 252 case TRANSFORM_RDFT: |
253 if (do_inverse) | |
254 av_log(NULL, AV_LOG_INFO,"IRDFT"); | |
255 else | |
256 av_log(NULL, AV_LOG_INFO,"RDFT"); | |
257 ff_rdft_init(r, fft_nbits, do_inverse ? IRDFT : RDFT); | |
258 fft_ref_init(fft_nbits, do_inverse); | |
259 break; | |
781 | 260 } |
2593
786ccf72ccd5
printf -> av_log patch by (Benjamin Larsson <>banan student.ltu se)
michael
parents:
1879
diff
changeset
|
261 av_log(NULL, AV_LOG_INFO," %d test\n", fft_size); |
781 | 262 |
263 /* generate random data */ | |
264 | |
10807 | 265 for (i = 0; i < fft_size; i++) { |
10074
c4a83f3a5c9f
bring back some randomness in fft-test. (regression in r18070)
lorenm
parents:
9674
diff
changeset
|
266 tab1[i].re = frandom(&prng); |
c4a83f3a5c9f
bring back some randomness in fft-test. (regression in r18070)
lorenm
parents:
9674
diff
changeset
|
267 tab1[i].im = frandom(&prng); |
781 | 268 } |
269 | |
270 /* checking result */ | |
2593
786ccf72ccd5
printf -> av_log patch by (Benjamin Larsson <>banan student.ltu se)
michael
parents:
1879
diff
changeset
|
271 av_log(NULL, AV_LOG_INFO,"Checking...\n"); |
781 | 272 |
10846
8dbceaa5fa2f
fft-test: Replace do_mdct with a tf_transform enum and switch on it.
alexc
parents:
10807
diff
changeset
|
273 switch (transform) { |
8dbceaa5fa2f
fft-test: Replace do_mdct with a tf_transform enum and switch on it.
alexc
parents:
10807
diff
changeset
|
274 case TRANSFORM_MDCT: |
781 | 275 if (do_inverse) { |
5442 | 276 imdct_ref((float *)tab_ref, (float *)tab1, fft_nbits); |
7546 | 277 ff_imdct_calc(m, tab2, (float *)tab1); |
9674
dac20d8df581
Support for testing (i)MDCT output scale factor in fft-test tool.
serge
parents:
9658
diff
changeset
|
278 check_diff((float *)tab_ref, tab2, fft_size, scale); |
781 | 279 } else { |
5442 | 280 mdct_ref((float *)tab_ref, (float *)tab1, fft_nbits); |
2967 | 281 |
7546 | 282 ff_mdct_calc(m, tab2, (float *)tab1); |
781 | 283 |
9674
dac20d8df581
Support for testing (i)MDCT output scale factor in fft-test tool.
serge
parents:
9658
diff
changeset
|
284 check_diff((float *)tab_ref, tab2, fft_size / 2, scale); |
781 | 285 } |
10846
8dbceaa5fa2f
fft-test: Replace do_mdct with a tf_transform enum and switch on it.
alexc
parents:
10807
diff
changeset
|
286 break; |
8dbceaa5fa2f
fft-test: Replace do_mdct with a tf_transform enum and switch on it.
alexc
parents:
10807
diff
changeset
|
287 case TRANSFORM_FFT: |
781 | 288 memcpy(tab, tab1, fft_size * sizeof(FFTComplex)); |
1879
dd63cb7e5080
fft_*() renamed into ff_fft_*() patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents:
1106
diff
changeset
|
289 ff_fft_permute(s, tab); |
dd63cb7e5080
fft_*() renamed into ff_fft_*() patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents:
1106
diff
changeset
|
290 ff_fft_calc(s, tab); |
2967 | 291 |
781 | 292 fft_ref(tab_ref, tab1, fft_nbits); |
9674
dac20d8df581
Support for testing (i)MDCT output scale factor in fft-test tool.
serge
parents:
9658
diff
changeset
|
293 check_diff((float *)tab_ref, (float *)tab, fft_size * 2, 1.0); |
10846
8dbceaa5fa2f
fft-test: Replace do_mdct with a tf_transform enum and switch on it.
alexc
parents:
10807
diff
changeset
|
294 break; |
10847 | 295 case TRANSFORM_RDFT: |
296 if (do_inverse) { | |
297 tab1[ 0].im = 0; | |
298 tab1[fft_size_2].im = 0; | |
299 for (i = 1; i < fft_size_2; i++) { | |
300 tab1[fft_size_2+i].re = tab1[fft_size_2-i].re; | |
301 tab1[fft_size_2+i].im = -tab1[fft_size_2-i].im; | |
302 } | |
303 | |
304 memcpy(tab2, tab1, fft_size * sizeof(FFTSample)); | |
305 tab2[1] = tab1[fft_size_2].re; | |
306 | |
307 ff_rdft_calc(r, tab2); | |
308 fft_ref(tab_ref, tab1, fft_nbits); | |
309 for (i = 0; i < fft_size; i++) { | |
310 tab[i].re = tab2[i]; | |
311 tab[i].im = 0; | |
312 } | |
313 check_diff((float *)tab_ref, (float *)tab, fft_size * 2, 0.5); | |
314 } else { | |
315 for (i = 0; i < fft_size; i++) { | |
316 tab2[i] = tab1[i].re; | |
317 tab1[i].im = 0; | |
318 } | |
319 ff_rdft_calc(r, tab2); | |
320 fft_ref(tab_ref, tab1, fft_nbits); | |
321 tab_ref[0].im = tab_ref[fft_size_2].re; | |
322 check_diff((float *)tab_ref, (float *)tab2, fft_size, 1.0); | |
323 } | |
781 | 324 } |
325 | |
326 /* do a speed test */ | |
327 | |
328 if (do_speed) { | |
1064 | 329 int64_t time_start, duration; |
781 | 330 int nb_its; |
331 | |
2593
786ccf72ccd5
printf -> av_log patch by (Benjamin Larsson <>banan student.ltu se)
michael
parents:
1879
diff
changeset
|
332 av_log(NULL, AV_LOG_INFO,"Speed test...\n"); |
781 | 333 /* we measure during about 1 seconds */ |
334 nb_its = 1; | |
335 for(;;) { | |
336 time_start = gettime(); | |
10807 | 337 for (it = 0; it < nb_its; it++) { |
10846
8dbceaa5fa2f
fft-test: Replace do_mdct with a tf_transform enum and switch on it.
alexc
parents:
10807
diff
changeset
|
338 switch (transform) { |
8dbceaa5fa2f
fft-test: Replace do_mdct with a tf_transform enum and switch on it.
alexc
parents:
10807
diff
changeset
|
339 case TRANSFORM_MDCT: |
781 | 340 if (do_inverse) { |
7546 | 341 ff_imdct_calc(m, (float *)tab, (float *)tab1); |
781 | 342 } else { |
7546 | 343 ff_mdct_calc(m, (float *)tab, (float *)tab1); |
781 | 344 } |
10846
8dbceaa5fa2f
fft-test: Replace do_mdct with a tf_transform enum and switch on it.
alexc
parents:
10807
diff
changeset
|
345 break; |
8dbceaa5fa2f
fft-test: Replace do_mdct with a tf_transform enum and switch on it.
alexc
parents:
10807
diff
changeset
|
346 case TRANSFORM_FFT: |
781 | 347 memcpy(tab, tab1, fft_size * sizeof(FFTComplex)); |
1879
dd63cb7e5080
fft_*() renamed into ff_fft_*() patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents:
1106
diff
changeset
|
348 ff_fft_calc(s, tab); |
10846
8dbceaa5fa2f
fft-test: Replace do_mdct with a tf_transform enum and switch on it.
alexc
parents:
10807
diff
changeset
|
349 break; |
10847 | 350 case TRANSFORM_RDFT: |
351 memcpy(tab2, tab1, fft_size * sizeof(FFTSample)); | |
352 ff_rdft_calc(r, tab2); | |
353 break; | |
781 | 354 } |
355 } | |
356 duration = gettime() - time_start; | |
357 if (duration >= 1000000) | |
358 break; | |
359 nb_its *= 2; | |
360 } | |
2967 | 361 av_log(NULL, AV_LOG_INFO,"time: %0.1f us/transform [total time=%0.2f s its=%d]\n", |
362 (double)duration / nb_its, | |
781 | 363 (double)duration / 1000000.0, |
364 nb_its); | |
365 } | |
2967 | 366 |
10846
8dbceaa5fa2f
fft-test: Replace do_mdct with a tf_transform enum and switch on it.
alexc
parents:
10807
diff
changeset
|
367 switch (transform) { |
8dbceaa5fa2f
fft-test: Replace do_mdct with a tf_transform enum and switch on it.
alexc
parents:
10807
diff
changeset
|
368 case TRANSFORM_MDCT: |
969 | 369 ff_mdct_end(m); |
10846
8dbceaa5fa2f
fft-test: Replace do_mdct with a tf_transform enum and switch on it.
alexc
parents:
10807
diff
changeset
|
370 break; |
8dbceaa5fa2f
fft-test: Replace do_mdct with a tf_transform enum and switch on it.
alexc
parents:
10807
diff
changeset
|
371 case TRANSFORM_FFT: |
1879
dd63cb7e5080
fft_*() renamed into ff_fft_*() patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents:
1106
diff
changeset
|
372 ff_fft_end(s); |
10846
8dbceaa5fa2f
fft-test: Replace do_mdct with a tf_transform enum and switch on it.
alexc
parents:
10807
diff
changeset
|
373 break; |
10847 | 374 case TRANSFORM_RDFT: |
375 ff_rdft_end(r); | |
376 break; | |
781 | 377 } |
378 return 0; | |
379 } |