24 |
* Don't take the checksums and crc too seriouly, they aren't |
* Don't take the checksums and crc too seriouly, they aren't |
25 |
* bullet-proof (should plug some .md5 here)... |
* bullet-proof (should plug some .md5 here)... |
26 |
* |
* |
27 |
* compiles with something like: |
* compiles best at xvidcore/src-dir with something like |
28 |
* gcc -o xvid_bench xvid_bench.c -I../src/ -lxvidcore -lm |
* |
29 |
|
* gcc -DARCH_IS_IA32 -DARCH_IS_32BIT -o xvid_bench xvid_bench.c \ |
30 |
|
* ../build/generic/libxvidcore.a -lm |
31 |
* |
* |
32 |
* History: |
* History: |
33 |
* |
* |
34 |
* 06.06.2002 initial coding -Skal- |
* 06.06.2002 initial coding -Skal- |
35 |
|
* 27.02.2003 minor changes (compile, sad16v) <gruel@web.de> |
36 |
* |
* |
37 |
*************************************************************************/ |
*************************************************************************/ |
38 |
|
|
39 |
#include <stdio.h> |
#include <stdio.h> |
40 |
#include <stdlib.h> |
#include <stdlib.h> |
|
#include <sys/time.h> // for gettimeofday |
|
41 |
#include <string.h> // for memset |
#include <string.h> // for memset |
42 |
#include <assert.h> |
#include <assert.h> |
43 |
|
|
44 |
|
#ifndef WIN32 |
45 |
|
#include <sys/time.h> // for gettimeofday |
46 |
|
#else |
47 |
|
#include <time.h> |
48 |
|
#endif |
49 |
|
|
50 |
|
|
51 |
#include "xvid.h" |
#include "xvid.h" |
52 |
|
|
53 |
// inner guts |
// inner guts |
65 |
#include "bitstream/cbp.h" |
#include "bitstream/cbp.h" |
66 |
|
|
67 |
#include <math.h> |
#include <math.h> |
68 |
|
|
69 |
|
#ifndef M_PI |
70 |
|
#define M_PI 3.14159265358979323846 |
71 |
|
#endif |
72 |
|
|
73 |
const int speed_ref = 100; // on slow machines, decrease this value |
const int speed_ref = 100; // on slow machines, decrease this value |
74 |
|
|
75 |
/********************************************************************* |
/********************************************************************* |
79 |
/* returns time in micro-s*/ |
/* returns time in micro-s*/ |
80 |
double gettime_usec() |
double gettime_usec() |
81 |
{ |
{ |
82 |
|
#ifndef WIN32 |
83 |
struct timeval tv; |
struct timeval tv; |
84 |
gettimeofday(&tv, 0); |
gettimeofday(&tv, 0); |
85 |
return tv.tv_sec*1.0e6 + tv.tv_usec; |
return tv.tv_sec*1.0e6 + tv.tv_usec; |
86 |
|
#else |
87 |
|
clock_t clk; |
88 |
|
clk = clock(); |
89 |
|
return clk * 1000000 / CLOCKS_PER_SEC; |
90 |
|
#endif |
91 |
} |
} |
92 |
|
|
93 |
/* returns squared deviates (mean(v*v)-mean(v)^2) of a 8x8 block */ |
/* returns squared deviates (mean(v*v)-mean(v)^2) of a 8x8 block */ |
219 |
void test_sad() |
void test_sad() |
220 |
{ |
{ |
221 |
const int nb_tests = 2000*speed_ref; |
const int nb_tests = 2000*speed_ref; |
222 |
int tst; |
int tst,dummy[4]; |
223 |
CPU *cpu; |
CPU *cpu; |
224 |
int i; |
int i; |
225 |
uint8_t Cur[16*16], Ref1[16*16], Ref2[16*16]; |
uint8_t Cur[16*16], Ref1[16*16], Ref2[16*16]; |
248 |
|
|
249 |
t = gettime_usec(); |
t = gettime_usec(); |
250 |
emms(); |
emms(); |
251 |
for(tst=0; tst<nb_tests; ++tst) s = sad16(Cur, Ref1, 16, -1); |
for(tst=0; tst<nb_tests; ++tst) s = sad16(Cur, Ref1, 16, 65535); |
252 |
emms(); |
emms(); |
253 |
t = (gettime_usec() - t) / nb_tests; |
t = (gettime_usec() - t) / nb_tests; |
254 |
printf( "%s - sad16 %.3f usec sad=%d\n", cpu->name, t, s ); |
printf( "%s - sad16 %.3f usec sad=%d\n", cpu->name, t, s ); |
256 |
|
|
257 |
t = gettime_usec(); |
t = gettime_usec(); |
258 |
emms(); |
emms(); |
259 |
|
for(tst=0; tst<nb_tests; ++tst) s = sad16v(Cur, Ref1, 16, dummy); |
260 |
|
emms(); |
261 |
|
t = (gettime_usec() - t) / nb_tests; |
262 |
|
printf( "%s - sad16v %.3f usec sad=%d\n", cpu->name, t, s ); |
263 |
|
if (s!=27214) printf( "*** CRC ERROR! ***\n" ); |
264 |
|
|
265 |
|
t = gettime_usec(); |
266 |
|
emms(); |
267 |
for(tst=0; tst<nb_tests; ++tst) s = sad16bi(Cur, Ref1, Ref2, 16); |
for(tst=0; tst<nb_tests; ++tst) s = sad16bi(Cur, Ref1, Ref2, 16); |
268 |
emms(); |
emms(); |
269 |
t = (gettime_usec() - t) / nb_tests; |
t = (gettime_usec() - t) / nb_tests; |