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