Mercurial > libavcodec.hg
comparison dct-test.c @ 7155:83e7ee1790a8 libavcodec
Make code independent/less dependent on dsputil.
This also makes the mmx parts work again ...
author | michael |
---|---|
date | Sat, 28 Jun 2008 10:42:31 +0000 |
parents | cf7e5dcefe48 |
children | eebc7209c47f |
comparison
equal
deleted
inserted
replaced
7154:a9ed669e8cd1 | 7155:83e7ee1790a8 |
---|---|
31 #include <sys/time.h> | 31 #include <sys/time.h> |
32 #include <unistd.h> | 32 #include <unistd.h> |
33 #include <math.h> | 33 #include <math.h> |
34 | 34 |
35 #include "libavutil/common.h" | 35 #include "libavutil/common.h" |
36 #include "dsputil.h" | |
37 | 36 |
38 #include "simple_idct.h" | 37 #include "simple_idct.h" |
39 #include "faandct.h" | 38 #include "faandct.h" |
40 #include "faanidct.h" | 39 #include "faanidct.h" |
41 #include "i386/idct_xvid.h" | 40 #include "i386/idct_xvid.h" |
76 #ifndef FAAN_POSTSCALE | 75 #ifndef FAAN_POSTSCALE |
77 #define FAAN_SCALE SCALE_PERM | 76 #define FAAN_SCALE SCALE_PERM |
78 #else | 77 #else |
79 #define FAAN_SCALE NO_PERM | 78 #define FAAN_SCALE NO_PERM |
80 #endif | 79 #endif |
80 | |
81 static int cpu_flags; | |
81 | 82 |
82 struct algo algos[] = { | 83 struct algo algos[] = { |
83 {"REF-DBL", 0, fdct, fdct, NO_PERM}, | 84 {"REF-DBL", 0, fdct, fdct, NO_PERM}, |
84 {"FAAN", 0, ff_faandct, fdct, FAAN_SCALE}, | 85 {"FAAN", 0, ff_faandct, fdct, FAAN_SCALE}, |
85 {"FAANI", 1, ff_faanidct, idct, NO_PERM}, | 86 {"FAANI", 1, ff_faanidct, idct, NO_PERM}, |
170 | 171 |
171 static DCTELEM block[64] __attribute__ ((aligned (16))); | 172 static DCTELEM block[64] __attribute__ ((aligned (16))); |
172 static DCTELEM block1[64] __attribute__ ((aligned (8))); | 173 static DCTELEM block1[64] __attribute__ ((aligned (8))); |
173 static DCTELEM block_org[64] __attribute__ ((aligned (8))); | 174 static DCTELEM block_org[64] __attribute__ ((aligned (8))); |
174 | 175 |
176 static inline void mmx_emms(void) | |
177 { | |
178 #ifdef HAVE_MMX | |
179 if (cpu_flags & MM_MMX) | |
180 asm volatile ("emms\n\t"); | |
181 #endif | |
182 } | |
183 | |
175 void dct_error(const char *name, int is_idct, | 184 void dct_error(const char *name, int is_idct, |
176 void (*fdct_func)(DCTELEM *block), | 185 void (*fdct_func)(DCTELEM *block), |
177 void (*fdct_ref)(DCTELEM *block), int form, int test) | 186 void (*fdct_ref)(DCTELEM *block), int form, int test) |
178 { | 187 { |
179 int it, i, scale; | 188 int it, i, scale; |
247 if((sum&1)==0) block[63]^=1; | 256 if((sum&1)==0) block[63]^=1; |
248 } | 257 } |
249 #endif | 258 #endif |
250 | 259 |
251 fdct_func(block); | 260 fdct_func(block); |
252 emms_c(); /* for ff_mmx_idct */ | 261 mmx_emms(); |
253 | 262 |
254 if (form == SCALE_PERM) { | 263 if (form == SCALE_PERM) { |
255 for(i=0; i<64; i++) { | 264 for(i=0; i<64; i++) { |
256 scale = 8*(1 << (AANSCALE_BITS + 11)) / aanscales[i]; | 265 scale = 8*(1 << (AANSCALE_BITS + 11)) / aanscales[i]; |
257 block[i] = (block[i] * scale /*+ (1<<(AANSCALE_BITS-1))*/) >> AANSCALE_BITS; | 266 block[i] = (block[i] * scale /*+ (1<<(AANSCALE_BITS-1))*/) >> AANSCALE_BITS; |
344 fdct_func(block); | 353 fdct_func(block); |
345 } | 354 } |
346 it1 += NB_ITS_SPEED; | 355 it1 += NB_ITS_SPEED; |
347 ti1 = gettime() - ti; | 356 ti1 = gettime() - ti; |
348 } while (ti1 < 1000000); | 357 } while (ti1 < 1000000); |
349 emms_c(); | 358 mmx_emms(); |
350 | 359 |
351 printf("%s %s: %0.1f kdct/s\n", | 360 printf("%s %s: %0.1f kdct/s\n", |
352 is_idct ? "IDCT" : "DCT", | 361 is_idct ? "IDCT" : "DCT", |
353 name, (double)it1 * 1000.0 / (double)ti1); | 362 name, (double)it1 * 1000.0 / (double)ti1); |
354 #endif | 363 #endif |
504 idct248_put(img_dest, 8, block); | 513 idct248_put(img_dest, 8, block); |
505 } | 514 } |
506 it1 += NB_ITS_SPEED; | 515 it1 += NB_ITS_SPEED; |
507 ti1 = gettime() - ti; | 516 ti1 = gettime() - ti; |
508 } while (ti1 < 1000000); | 517 } while (ti1 < 1000000); |
509 emms_c(); | 518 mmx_emms(); |
510 | 519 |
511 printf("%s %s: %0.1f kdct/s\n", | 520 printf("%s %s: %0.1f kdct/s\n", |
512 1 ? "IDCT248" : "DCT248", | 521 1 ? "IDCT248" : "DCT248", |
513 name, (double)it1 * 1000.0 / (double)ti1); | 522 name, (double)it1 * 1000.0 / (double)ti1); |
514 } | 523 } |
526 int main(int argc, char **argv) | 535 int main(int argc, char **argv) |
527 { | 536 { |
528 int test_idct = 0, test_248_dct = 0; | 537 int test_idct = 0, test_248_dct = 0; |
529 int c,i; | 538 int c,i; |
530 int test=1; | 539 int test=1; |
531 int cpu_flags = mm_support(); | 540 cpu_flags = mm_support(); |
532 | 541 |
533 init_fdct(); | 542 init_fdct(); |
534 idct_mmx_init(); | 543 idct_mmx_init(); |
535 | 544 |
536 for(i=0;i<256;i++) cropTbl[i + MAX_NEG_CROP] = i; | 545 for(i=0;i<256;i++) cropTbl[i + MAX_NEG_CROP] = i; |