Mercurial > libavcodec.hg
annotate dct-test.c @ 3798:6e7b9a44800c libavcodec
vorbis.h -> vorbis_data.c
move tables from vorbis.h to a C file so they can be used later in
vorbis_enc.c
author | ods15 |
---|---|
date | Sat, 30 Sep 2006 18:47:15 +0000 |
parents | c537a97eec66 |
children | c8c591fe26f8 |
rev | line source |
---|---|
3699
c537a97eec66
Add official LGPL license headers to the files that were missing them.
diego
parents:
3398
diff
changeset
|
1 /* |
c537a97eec66
Add official LGPL license headers to the files that were missing them.
diego
parents:
3398
diff
changeset
|
2 * (c) 2001 Fabrice Bellard |
c537a97eec66
Add official LGPL license headers to the files that were missing them.
diego
parents:
3398
diff
changeset
|
3 * |
c537a97eec66
Add official LGPL license headers to the files that were missing them.
diego
parents:
3398
diff
changeset
|
4 * This library is free software; you can redistribute it and/or |
c537a97eec66
Add official LGPL license headers to the files that were missing them.
diego
parents:
3398
diff
changeset
|
5 * 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:
3398
diff
changeset
|
6 * License as published by the Free Software Foundation; either |
c537a97eec66
Add official LGPL license headers to the files that were missing them.
diego
parents:
3398
diff
changeset
|
7 * version 2 of the License, or (at your option) any later version. |
c537a97eec66
Add official LGPL license headers to the files that were missing them.
diego
parents:
3398
diff
changeset
|
8 * |
c537a97eec66
Add official LGPL license headers to the files that were missing them.
diego
parents:
3398
diff
changeset
|
9 * This library is distributed in the hope that it will be useful, |
c537a97eec66
Add official LGPL license headers to the files that were missing them.
diego
parents:
3398
diff
changeset
|
10 * 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:
3398
diff
changeset
|
11 * 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:
3398
diff
changeset
|
12 * Lesser General Public License for more details. |
c537a97eec66
Add official LGPL license headers to the files that were missing them.
diego
parents:
3398
diff
changeset
|
13 * |
c537a97eec66
Add official LGPL license headers to the files that were missing them.
diego
parents:
3398
diff
changeset
|
14 * You should have received a copy of the GNU Lesser General Public |
c537a97eec66
Add official LGPL license headers to the files that were missing them.
diego
parents:
3398
diff
changeset
|
15 * License along with this library; if not, write to the Free Software |
c537a97eec66
Add official LGPL license headers to the files that were missing them.
diego
parents:
3398
diff
changeset
|
16 * 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:
3398
diff
changeset
|
17 */ |
c537a97eec66
Add official LGPL license headers to the files that were missing them.
diego
parents:
3398
diff
changeset
|
18 |
1106 | 19 /** |
20 * @file dct-test.c | |
2967 | 21 * DCT test. (c) 2001 Fabrice Bellard. |
1106 | 22 * Started from sample code by Juan J. Sierralta P. |
23 */ | |
24 | |
0 | 25 #include <stdlib.h> |
26 #include <stdio.h> | |
27 #include <string.h> | |
28 #include <sys/time.h> | |
29 #include <unistd.h> | |
30 | |
31 #include "dsputil.h" | |
32 | |
633 | 33 #include "simple_idct.h" |
1557 | 34 #include "faandct.h" |
33 | 35 |
980 | 36 #ifndef MAX |
37 #define MAX(a, b) (((a) > (b)) ? (a) : (b)) | |
38 #endif | |
39 | |
2872 | 40 #undef printf |
41 | |
42 void *fast_memcpy(void *a, const void *b, size_t c){return memcpy(a,b,c);}; | |
43 | |
33 | 44 /* reference fdct/idct */ |
0 | 45 extern void fdct(DCTELEM *block); |
33 | 46 extern void idct(DCTELEM *block); |
2872 | 47 extern void ff_idct_xvid_mmx(DCTELEM *block); |
48 extern void ff_idct_xvid_mmx2(DCTELEM *block); | |
0 | 49 extern void init_fdct(); |
50 | |
33 | 51 extern void j_rev_dct(DCTELEM *data); |
52 extern void ff_mmx_idct(DCTELEM *data); | |
53 extern void ff_mmxext_idct(DCTELEM *data); | |
54 | |
633 | 55 extern void odivx_idct_c (short *block); |
56 | |
0 | 57 #define AANSCALE_BITS 12 |
58 static const unsigned short aanscales[64] = { | |
59 /* precomputed values scaled up by 14 bits */ | |
60 16384, 22725, 21407, 19266, 16384, 12873, 8867, 4520, | |
61 22725, 31521, 29692, 26722, 22725, 17855, 12299, 6270, | |
62 21407, 29692, 27969, 25172, 21407, 16819, 11585, 5906, | |
63 19266, 26722, 25172, 22654, 19266, 15137, 10426, 5315, | |
64 16384, 22725, 21407, 19266, 16384, 12873, 8867, 4520, | |
65 12873, 17855, 16819, 15137, 12873, 10114, 6967, 3552, | |
66 8867, 12299, 11585, 10426, 8867, 6967, 4799, 2446, | |
67 4520, 6270, 5906, 5315, 4520, 3552, 2446, 1247 | |
68 }; | |
69 | |
1064 | 70 uint8_t cropTbl[256 + 2 * MAX_NEG_CROP]; |
633 | 71 |
1064 | 72 int64_t gettime(void) |
0 | 73 { |
74 struct timeval tv; | |
75 gettimeofday(&tv,NULL); | |
1064 | 76 return (int64_t)tv.tv_sec * 1000000 + tv.tv_usec; |
0 | 77 } |
78 | |
79 #define NB_ITS 20000 | |
80 #define NB_ITS_SPEED 50000 | |
81 | |
33 | 82 static short idct_mmx_perm[64]; |
83 | |
633 | 84 static short idct_simple_mmx_perm[64]={ |
2979 | 85 0x00, 0x08, 0x04, 0x09, 0x01, 0x0C, 0x05, 0x0D, |
86 0x10, 0x18, 0x14, 0x19, 0x11, 0x1C, 0x15, 0x1D, | |
87 0x20, 0x28, 0x24, 0x29, 0x21, 0x2C, 0x25, 0x2D, | |
88 0x12, 0x1A, 0x16, 0x1B, 0x13, 0x1E, 0x17, 0x1F, | |
89 0x02, 0x0A, 0x06, 0x0B, 0x03, 0x0E, 0x07, 0x0F, | |
90 0x30, 0x38, 0x34, 0x39, 0x31, 0x3C, 0x35, 0x3D, | |
91 0x22, 0x2A, 0x26, 0x2B, 0x23, 0x2E, 0x27, 0x2F, | |
92 0x32, 0x3A, 0x36, 0x3B, 0x33, 0x3E, 0x37, 0x3F, | |
633 | 93 }; |
94 | |
33 | 95 void idct_mmx_init(void) |
96 { | |
97 int i; | |
98 | |
99 /* the mmx/mmxext idct uses a reordered input, so we patch scan tables */ | |
100 for (i = 0; i < 64; i++) { | |
2979 | 101 idct_mmx_perm[i] = (i & 0x38) | ((i & 6) >> 1) | ((i & 1) << 2); |
102 // idct_simple_mmx_perm[i] = simple_block_permute_op(i); | |
33 | 103 } |
104 } | |
105 | |
106 static DCTELEM block[64] __attribute__ ((aligned (8))); | |
107 static DCTELEM block1[64] __attribute__ ((aligned (8))); | |
633 | 108 static DCTELEM block_org[64] __attribute__ ((aligned (8))); |
33 | 109 |
110 void dct_error(const char *name, int is_idct, | |
111 void (*fdct_func)(DCTELEM *block), | |
633 | 112 void (*fdct_ref)(DCTELEM *block), int test) |
0 | 113 { |
114 int it, i, scale; | |
115 int err_inf, v; | |
1064 | 116 int64_t err2, ti, ti1, it1; |
117 int64_t sysErr[64], sysErrMax=0; | |
633 | 118 int maxout=0; |
119 int blockSumErrMax=0, blockSumErr; | |
0 | 120 |
121 srandom(0); | |
122 | |
123 err_inf = 0; | |
124 err2 = 0; | |
633 | 125 for(i=0; i<64; i++) sysErr[i]=0; |
0 | 126 for(it=0;it<NB_ITS;it++) { |
633 | 127 for(i=0;i<64;i++) |
128 block1[i] = 0; | |
129 switch(test){ | |
2967 | 130 case 0: |
633 | 131 for(i=0;i<64;i++) |
132 block1[i] = (random() % 512) -256; | |
635 | 133 if (is_idct){ |
633 | 134 fdct(block1); |
635 | 135 |
136 for(i=0;i<64;i++) | |
137 block1[i]>>=3; | |
138 } | |
633 | 139 break; |
140 case 1:{ | |
141 int num= (random()%10)+1; | |
142 for(i=0;i<num;i++) | |
143 block1[random()%64] = (random() % 512) -256; | |
144 }break; | |
145 case 2: | |
146 block1[0]= (random()%4096)-2048; | |
147 block1[63]= (block1[0]&1)^1; | |
148 break; | |
149 } | |
33 | 150 |
633 | 151 #if 0 // simulate mismatch control |
152 { int sum=0; | |
153 for(i=0;i<64;i++) | |
154 sum+=block1[i]; | |
155 | |
2967 | 156 if((sum&1)==0) block1[63]^=1; |
633 | 157 } |
158 #endif | |
159 | |
160 for(i=0; i<64; i++) | |
161 block_org[i]= block1[i]; | |
33 | 162 |
163 if (fdct_func == ff_mmx_idct || | |
633 | 164 fdct_func == j_rev_dct || fdct_func == ff_mmxext_idct) { |
165 for(i=0;i<64;i++) | |
33 | 166 block[idct_mmx_perm[i]] = block1[i]; |
720 | 167 } else if(fdct_func == ff_simple_idct_mmx ) { |
633 | 168 for(i=0;i<64;i++) |
169 block[idct_simple_mmx_perm[i]] = block1[i]; | |
170 | |
2979 | 171 } else { |
633 | 172 for(i=0; i<64; i++) |
173 block[i]= block1[i]; | |
33 | 174 } |
633 | 175 #if 0 // simulate mismatch control for tested IDCT but not the ref |
176 { int sum=0; | |
177 for(i=0;i<64;i++) | |
178 sum+=block[i]; | |
179 | |
2967 | 180 if((sum&1)==0) block[63]^=1; |
633 | 181 } |
182 #endif | |
33 | 183 |
0 | 184 fdct_func(block); |
33 | 185 emms(); /* for ff_mmx_idct */ |
186 | |
2967 | 187 if (fdct_func == fdct_ifast |
188 #ifndef FAAN_POSTSCALE | |
1562
bf452704100f
optionally merge postscale into quantization table for the float aan dct
michael
parents:
1557
diff
changeset
|
189 || fdct_func == ff_faandct |
bf452704100f
optionally merge postscale into quantization table for the float aan dct
michael
parents:
1557
diff
changeset
|
190 #endif |
bf452704100f
optionally merge postscale into quantization table for the float aan dct
michael
parents:
1557
diff
changeset
|
191 ) { |
0 | 192 for(i=0; i<64; i++) { |
635 | 193 scale = 8*(1 << (AANSCALE_BITS + 11)) / aanscales[i]; |
633 | 194 block[i] = (block[i] * scale /*+ (1<<(AANSCALE_BITS-1))*/) >> AANSCALE_BITS; |
195 } | |
196 } | |
197 | |
33 | 198 fdct_ref(block1); |
0 | 199 |
633 | 200 blockSumErr=0; |
0 | 201 for(i=0;i<64;i++) { |
202 v = abs(block[i] - block1[i]); | |
203 if (v > err_inf) | |
204 err_inf = v; | |
205 err2 += v * v; | |
2979 | 206 sysErr[i] += block[i] - block1[i]; |
207 blockSumErr += v; | |
208 if( abs(block[i])>maxout) maxout=abs(block[i]); | |
0 | 209 } |
633 | 210 if(blockSumErrMax < blockSumErr) blockSumErrMax= blockSumErr; |
211 #if 0 // print different matrix pairs | |
212 if(blockSumErr){ | |
213 printf("\n"); | |
214 for(i=0; i<64; i++){ | |
215 if((i&7)==0) printf("\n"); | |
216 printf("%4d ", block_org[i]); | |
217 } | |
218 for(i=0; i<64; i++){ | |
219 if((i&7)==0) printf("\n"); | |
220 printf("%4d ", block[i] - block1[i]); | |
221 } | |
222 } | |
223 #endif | |
0 | 224 } |
633 | 225 for(i=0; i<64; i++) sysErrMax= MAX(sysErrMax, ABS(sysErr[i])); |
2967 | 226 |
633 | 227 #if 1 // dump systematic errors |
228 for(i=0; i<64; i++){ | |
2979 | 229 if(i%8==0) printf("\n"); |
633 | 230 printf("%5d ", (int)sysErr[i]); |
231 } | |
232 printf("\n"); | |
233 #endif | |
2967 | 234 |
633 | 235 printf("%s %s: err_inf=%d err2=%0.8f syserr=%0.8f maxout=%d blockSumErr=%d\n", |
33 | 236 is_idct ? "IDCT" : "DCT", |
633 | 237 name, err_inf, (double)err2 / NB_ITS / 64.0, (double)sysErrMax / NB_ITS, maxout, blockSumErrMax); |
238 #if 1 //Speed test | |
0 | 239 /* speed test */ |
633 | 240 for(i=0;i<64;i++) |
241 block1[i] = 0; | |
242 switch(test){ | |
2967 | 243 case 0: |
633 | 244 for(i=0;i<64;i++) |
245 block1[i] = (random() % 512) -256; | |
635 | 246 if (is_idct){ |
633 | 247 fdct(block1); |
635 | 248 |
249 for(i=0;i<64;i++) | |
250 block1[i]>>=3; | |
251 } | |
633 | 252 break; |
253 case 1:{ | |
254 case 2: | |
255 block1[0] = (random() % 512) -256; | |
256 block1[1] = (random() % 512) -256; | |
257 block1[2] = (random() % 512) -256; | |
258 block1[3] = (random() % 512) -256; | |
259 }break; | |
260 } | |
0 | 261 |
33 | 262 if (fdct_func == ff_mmx_idct || |
633 | 263 fdct_func == j_rev_dct || fdct_func == ff_mmxext_idct) { |
264 for(i=0;i<64;i++) | |
33 | 265 block[idct_mmx_perm[i]] = block1[i]; |
720 | 266 } else if(fdct_func == ff_simple_idct_mmx ) { |
633 | 267 for(i=0;i<64;i++) |
268 block[idct_simple_mmx_perm[i]] = block1[i]; | |
269 } else { | |
270 for(i=0; i<64; i++) | |
271 block[i]= block1[i]; | |
33 | 272 } |
273 | |
0 | 274 ti = gettime(); |
275 it1 = 0; | |
276 do { | |
277 for(it=0;it<NB_ITS_SPEED;it++) { | |
633 | 278 for(i=0; i<64; i++) |
279 block[i]= block1[i]; | |
280 // memcpy(block, block1, sizeof(DCTELEM) * 64); | |
281 // dont memcpy especially not fastmemcpy because it does movntq !!! | |
0 | 282 fdct_func(block); |
283 } | |
284 it1 += NB_ITS_SPEED; | |
285 ti1 = gettime() - ti; | |
286 } while (ti1 < 1000000); | |
33 | 287 emms(); |
0 | 288 |
633 | 289 printf("%s %s: %0.1f kdct/s\n", |
33 | 290 is_idct ? "IDCT" : "DCT", |
0 | 291 name, (double)it1 * 1000.0 / (double)ti1); |
633 | 292 #endif |
0 | 293 } |
294 | |
1064 | 295 static uint8_t img_dest[64] __attribute__ ((aligned (8))); |
296 static uint8_t img_dest1[64] __attribute__ ((aligned (8))); | |
720 | 297 |
1064 | 298 void idct248_ref(uint8_t *dest, int linesize, int16_t *block) |
720 | 299 { |
300 static int init; | |
301 static double c8[8][8]; | |
302 static double c4[4][4]; | |
303 double block1[64], block2[64], block3[64]; | |
304 double s, sum, v; | |
305 int i, j, k; | |
306 | |
307 if (!init) { | |
308 init = 1; | |
309 | |
310 for(i=0;i<8;i++) { | |
311 sum = 0; | |
312 for(j=0;j<8;j++) { | |
313 s = (i==0) ? sqrt(1.0/8.0) : sqrt(1.0/4.0); | |
314 c8[i][j] = s * cos(M_PI * i * (j + 0.5) / 8.0); | |
315 sum += c8[i][j] * c8[i][j]; | |
316 } | |
317 } | |
2967 | 318 |
720 | 319 for(i=0;i<4;i++) { |
320 sum = 0; | |
321 for(j=0;j<4;j++) { | |
322 s = (i==0) ? sqrt(1.0/4.0) : sqrt(1.0/2.0); | |
323 c4[i][j] = s * cos(M_PI * i * (j + 0.5) / 4.0); | |
324 sum += c4[i][j] * c4[i][j]; | |
325 } | |
326 } | |
327 } | |
328 | |
329 /* butterfly */ | |
722
ff90043f4a2d
in fact IDCT248 needs to be normalized as I suspected
bellard
parents:
720
diff
changeset
|
330 s = 0.5 * sqrt(2.0); |
720 | 331 for(i=0;i<4;i++) { |
332 for(j=0;j<8;j++) { | |
722
ff90043f4a2d
in fact IDCT248 needs to be normalized as I suspected
bellard
parents:
720
diff
changeset
|
333 block1[8*(2*i)+j] = (block[8*(2*i)+j] + block[8*(2*i+1)+j]) * s; |
ff90043f4a2d
in fact IDCT248 needs to be normalized as I suspected
bellard
parents:
720
diff
changeset
|
334 block1[8*(2*i+1)+j] = (block[8*(2*i)+j] - block[8*(2*i+1)+j]) * s; |
720 | 335 } |
336 } | |
337 | |
338 /* idct8 on lines */ | |
339 for(i=0;i<8;i++) { | |
340 for(j=0;j<8;j++) { | |
341 sum = 0; | |
342 for(k=0;k<8;k++) | |
343 sum += c8[k][j] * block1[8*i+k]; | |
344 block2[8*i+j] = sum; | |
345 } | |
346 } | |
347 | |
348 /* idct4 */ | |
349 for(i=0;i<8;i++) { | |
350 for(j=0;j<4;j++) { | |
351 /* top */ | |
352 sum = 0; | |
353 for(k=0;k<4;k++) | |
354 sum += c4[k][j] * block2[8*(2*k)+i]; | |
355 block3[8*(2*j)+i] = sum; | |
356 | |
357 /* bottom */ | |
358 sum = 0; | |
359 for(k=0;k<4;k++) | |
360 sum += c4[k][j] * block2[8*(2*k+1)+i]; | |
361 block3[8*(2*j+1)+i] = sum; | |
362 } | |
363 } | |
364 | |
365 /* clamp and store the result */ | |
366 for(i=0;i<8;i++) { | |
367 for(j=0;j<8;j++) { | |
722
ff90043f4a2d
in fact IDCT248 needs to be normalized as I suspected
bellard
parents:
720
diff
changeset
|
368 v = block3[8*i+j]; |
720 | 369 if (v < 0) |
370 v = 0; | |
371 else if (v > 255) | |
372 v = 255; | |
373 dest[i * linesize + j] = (int)rint(v); | |
374 } | |
375 } | |
376 } | |
377 | |
2967 | 378 void idct248_error(const char *name, |
1064 | 379 void (*idct248_put)(uint8_t *dest, int line_size, int16_t *block)) |
720 | 380 { |
381 int it, i, it1, ti, ti1, err_max, v; | |
382 | |
383 srandom(0); | |
2967 | 384 |
720 | 385 /* just one test to see if code is correct (precision is less |
386 important here) */ | |
387 err_max = 0; | |
388 for(it=0;it<NB_ITS;it++) { | |
2967 | 389 |
722
ff90043f4a2d
in fact IDCT248 needs to be normalized as I suspected
bellard
parents:
720
diff
changeset
|
390 /* XXX: use forward transform to generate values */ |
720 | 391 for(i=0;i<64;i++) |
722
ff90043f4a2d
in fact IDCT248 needs to be normalized as I suspected
bellard
parents:
720
diff
changeset
|
392 block1[i] = (random() % 256) - 128; |
ff90043f4a2d
in fact IDCT248 needs to be normalized as I suspected
bellard
parents:
720
diff
changeset
|
393 block1[0] += 1024; |
ff90043f4a2d
in fact IDCT248 needs to be normalized as I suspected
bellard
parents:
720
diff
changeset
|
394 |
720 | 395 for(i=0; i<64; i++) |
396 block[i]= block1[i]; | |
397 idct248_ref(img_dest1, 8, block); | |
2967 | 398 |
722
ff90043f4a2d
in fact IDCT248 needs to be normalized as I suspected
bellard
parents:
720
diff
changeset
|
399 for(i=0; i<64; i++) |
ff90043f4a2d
in fact IDCT248 needs to be normalized as I suspected
bellard
parents:
720
diff
changeset
|
400 block[i]= block1[i]; |
ff90043f4a2d
in fact IDCT248 needs to be normalized as I suspected
bellard
parents:
720
diff
changeset
|
401 idct248_put(img_dest, 8, block); |
2967 | 402 |
722
ff90043f4a2d
in fact IDCT248 needs to be normalized as I suspected
bellard
parents:
720
diff
changeset
|
403 for(i=0;i<64;i++) { |
ff90043f4a2d
in fact IDCT248 needs to be normalized as I suspected
bellard
parents:
720
diff
changeset
|
404 v = abs((int)img_dest[i] - (int)img_dest1[i]); |
ff90043f4a2d
in fact IDCT248 needs to be normalized as I suspected
bellard
parents:
720
diff
changeset
|
405 if (v == 255) |
ff90043f4a2d
in fact IDCT248 needs to be normalized as I suspected
bellard
parents:
720
diff
changeset
|
406 printf("%d %d\n", img_dest[i], img_dest1[i]); |
ff90043f4a2d
in fact IDCT248 needs to be normalized as I suspected
bellard
parents:
720
diff
changeset
|
407 if (v > err_max) |
ff90043f4a2d
in fact IDCT248 needs to be normalized as I suspected
bellard
parents:
720
diff
changeset
|
408 err_max = v; |
ff90043f4a2d
in fact IDCT248 needs to be normalized as I suspected
bellard
parents:
720
diff
changeset
|
409 } |
720 | 410 #if 0 |
411 printf("ref=\n"); | |
412 for(i=0;i<8;i++) { | |
413 int j; | |
414 for(j=0;j<8;j++) { | |
415 printf(" %3d", img_dest1[i*8+j]); | |
416 } | |
417 printf("\n"); | |
418 } | |
2967 | 419 |
720 | 420 printf("out=\n"); |
421 for(i=0;i<8;i++) { | |
422 int j; | |
423 for(j=0;j<8;j++) { | |
424 printf(" %3d", img_dest[i*8+j]); | |
425 } | |
426 printf("\n"); | |
427 } | |
428 #endif | |
429 } | |
430 printf("%s %s: err_inf=%d\n", | |
431 1 ? "IDCT248" : "DCT248", | |
432 name, err_max); | |
433 | |
434 ti = gettime(); | |
435 it1 = 0; | |
436 do { | |
437 for(it=0;it<NB_ITS_SPEED;it++) { | |
438 for(i=0; i<64; i++) | |
439 block[i]= block1[i]; | |
440 // memcpy(block, block1, sizeof(DCTELEM) * 64); | |
441 // dont memcpy especially not fastmemcpy because it does movntq !!! | |
442 idct248_put(img_dest, 8, block); | |
443 } | |
444 it1 += NB_ITS_SPEED; | |
445 ti1 = gettime() - ti; | |
446 } while (ti1 < 1000000); | |
447 emms(); | |
448 | |
449 printf("%s %s: %0.1f kdct/s\n", | |
450 1 ? "IDCT248" : "DCT248", | |
451 name, (double)it1 * 1000.0 / (double)ti1); | |
452 } | |
453 | |
33 | 454 void help(void) |
455 { | |
633 | 456 printf("dct-test [-i] [<test-number>]\n" |
457 "test-number 0 -> test with random matrixes\n" | |
458 " 1 -> test with random sparse matrixes\n" | |
459 " 2 -> do 3. test from mpeg4 std\n" | |
720 | 460 "-i test IDCT implementations\n" |
461 "-4 test IDCT248 implementations\n"); | |
33 | 462 exit(1); |
463 } | |
464 | |
0 | 465 int main(int argc, char **argv) |
466 { | |
720 | 467 int test_idct = 0, test_248_dct = 0; |
633 | 468 int c,i; |
469 int test=1; | |
33 | 470 |
0 | 471 init_fdct(); |
33 | 472 idct_mmx_init(); |
0 | 473 |
633 | 474 for(i=0;i<256;i++) cropTbl[i + MAX_NEG_CROP] = i; |
475 for(i=0;i<MAX_NEG_CROP;i++) { | |
476 cropTbl[i] = 0; | |
477 cropTbl[i + MAX_NEG_CROP + 256] = 255; | |
478 } | |
2967 | 479 |
33 | 480 for(;;) { |
720 | 481 c = getopt(argc, argv, "ih4"); |
33 | 482 if (c == -1) |
483 break; | |
484 switch(c) { | |
485 case 'i': | |
486 test_idct = 1; | |
487 break; | |
720 | 488 case '4': |
489 test_248_dct = 1; | |
490 break; | |
633 | 491 default : |
33 | 492 case 'h': |
493 help(); | |
494 break; | |
495 } | |
496 } | |
2967 | 497 |
633 | 498 if(optind <argc) test= atoi(argv[optind]); |
2967 | 499 |
33 | 500 printf("ffmpeg DCT/IDCT test\n"); |
501 | |
720 | 502 if (test_248_dct) { |
503 idct248_error("SIMPLE-C", simple_idct248_put); | |
33 | 504 } else { |
720 | 505 if (!test_idct) { |
506 dct_error("REF-DBL", 0, fdct, fdct, test); /* only to verify code ! */ | |
507 dct_error("IJG-AAN-INT", 0, fdct_ifast, fdct, test); | |
508 dct_error("IJG-LLM-INT", 0, ff_jpeg_fdct_islow, fdct, test); | |
509 dct_error("MMX", 0, ff_fdct_mmx, fdct, test); | |
1574 | 510 dct_error("MMX2", 0, ff_fdct_mmx2, fdct, test); |
1557 | 511 dct_error("FAAN", 0, ff_faandct, fdct, test); |
720 | 512 } else { |
513 dct_error("REF-DBL", 1, idct, idct, test); | |
514 dct_error("INT", 1, j_rev_dct, idct, test); | |
515 dct_error("LIBMPEG2-MMX", 1, ff_mmx_idct, idct, test); | |
516 dct_error("LIBMPEG2-MMXEXT", 1, ff_mmxext_idct, idct, test); | |
517 dct_error("SIMPLE-C", 1, simple_idct, idct, test); | |
518 dct_error("SIMPLE-MMX", 1, ff_simple_idct_mmx, idct, test); | |
2872 | 519 dct_error("XVID-MMX", 1, ff_idct_xvid_mmx, idct, test); |
520 dct_error("XVID-MMX2", 1, ff_idct_xvid_mmx2, idct, test); | |
720 | 521 // dct_error("ODIVX-C", 1, odivx_idct_c, idct); |
522 //printf(" test against odivx idct\n"); | |
2979 | 523 // dct_error("REF", 1, idct, odivx_idct_c); |
720 | 524 // dct_error("INT", 1, j_rev_dct, odivx_idct_c); |
525 // dct_error("MMX", 1, ff_mmx_idct, odivx_idct_c); | |
526 // dct_error("MMXEXT", 1, ff_mmxext_idct, odivx_idct_c); | |
527 // dct_error("SIMPLE-C", 1, simple_idct, odivx_idct_c); | |
528 // dct_error("SIMPLE-MMX", 1, ff_simple_idct_mmx, odivx_idct_c); | |
529 // dct_error("ODIVX-C", 1, odivx_idct_c, odivx_idct_c); | |
530 } | |
33 | 531 } |
0 | 532 return 0; |
533 } |