--- trunk/xvidcore/examples/xvid_bench.c 2002/11/27 21:09:10 684 +++ trunk/xvidcore/examples/xvid_bench.c 2003/02/26 19:05:20 898 @@ -24,28 +24,33 @@ * Don't take the checksums and crc too seriouly, they aren't * bullet-proof (should plug some .md5 here)... * - * compiles with something like: - * gcc -o xvid_bench xvid_bench.c -I../src/ -lxvidcore -lm + * compiles best at xvidcore/src-dir with something like + * + * gcc -DARCH_IS_IA32 -DARCH_IS_32BIT -o xvid_bench xvid_bench.c \ + * ../build/generic/libxvidcore.a -lm * * History: * * 06.06.2002 initial coding -Skal- + * 27.02.2003 minor changes (compile, sad16v) * *************************************************************************/ #include #include -#ifdef WIN32 -#include /* for clock */ +#include // for memset +#include + +#ifndef WIN32 +#include // for gettimeofday #else -#include /* for gettimeofday */ +#include #endif -#include /* for memset */ -#include + #include "xvid.h" -/* inner guts */ +// inner guts #include "dct/idct.h" #include "dct/fdct.h" #include "image/colorspace.h" @@ -60,11 +65,12 @@ #include "bitstream/cbp.h" #include + #ifndef M_PI -# define M_PI 3.14159265359 -# define M_PI_2 1.5707963268 +#define M_PI 3.14159265358979323846 #endif -const int speed_ref = 100; /* on slow machines, decrease this value */ + +const int speed_ref = 100; // on slow machines, decrease this value /********************************************************************* * misc @@ -73,12 +79,14 @@ /* returns time in micro-s*/ double gettime_usec() { -#ifdef WIN32 - return clock()*1000; -#else +#ifndef WIN32 struct timeval tv; gettimeofday(&tv, 0); return tv.tv_sec*1.0e6 + tv.tv_usec; +#else + clock_t clk; + clk = clock(); + return clk * 1000000 / CLOCKS_PER_SEC; #endif } @@ -115,13 +123,13 @@ , { "3DNOW ", XVID_CPU_3DNOW } , { "3DNOWE", XVID_CPU_3DNOWEXT } , { "IA64 ", XVID_CPU_IA64 } -/*, { "TSC ", XVID_CPU_TSC } */ +//, { "TSC ", XVID_CPU_TSC } , { 0, 0 } } , cpu_short_list[] = { { "PLAINC", 0 } , { "MMX ", XVID_CPU_MMX } -/*, { "MMXEXT", XVID_CPU_MMXEXT | XVID_CPU_MMX } */ +//, { "MMXEXT", XVID_CPU_MMXEXT | XVID_CPU_MMX } , { "IA64 ", XVID_CPU_IA64 } , { 0, 0 } } @@ -139,7 +147,7 @@ cpu_type = check_cpu_features() & cpu->cpu; xinit.cpu_flags = cpu_type | XVID_CPU_FORCE; - /* xinit.cpu_flags = XVID_CPU_MMX | XVID_CPU_FORCE; */ + // xinit.cpu_flags = XVID_CPU_MMX | XVID_CPU_FORCE; xerr = xvid_init(NULL, 0, &xinit, NULL); if (cpu->cpu>0 && (cpu_type==0 || xerr!=XVID_ERR_OK)) { printf( "%s - skipped...\n", cpu->name ); @@ -211,7 +219,7 @@ void test_sad() { const int nb_tests = 2000*speed_ref; - int tst; + int tst,dummy[4]; CPU *cpu; int i; uint8_t Cur[16*16], Ref1[16*16], Ref2[16*16]; @@ -240,7 +248,7 @@ t = gettime_usec(); emms(); - for(tst=0; tstname, t, s ); @@ -248,6 +256,14 @@ t = gettime_usec(); emms(); + for(tst=0; tstname, t, s ); + if (s!=27214) printf( "*** CRC ERROR! ***\n" ); + + t = gettime_usec(); + emms(); for(tst=0; tstname, t, iCrc ); @@ -469,8 +485,8 @@ TEST_TRANSFER3(transfer_8to16sub2, Dst16, Src8, Ref1, Ref2); printf( "%s - 8to16sub2 %.3f usec crc=%d\n", cpu->name, t, s ); if (s!=20384) printf( "*** CRC ERROR! ***\n" ); -/* for(i=0; i<64; ++i) printf( "[%d]", Dst16[i]); */ -/* printf("\n"); */ +// for(i=0; i<64; ++i) printf( "[%d]", Dst16[i]); +// printf("\n"); #endif printf( " --- \n" ); } @@ -523,8 +539,8 @@ printf( "\n ===== test quant =====\n" ); - /* we deliberately enfringe the norm's specified range [-127,127], */ - /* to test the robustness of the iquant module */ + // we deliberately enfringe the norm's specified range [-127,127], + // to test the robustness of the iquant module for(i=0; i<64; ++i) { Src[i] = 1 + (i-32) * (i&6); Dst[i] = 0; @@ -611,8 +627,8 @@ printf( "\n ===== test cbp =====\n" ); for(i=0; i<6*64; ++i) { - Src1[i] = (i*i*3/8192)&(i/64)&1; /* 'random' */ - Src2[i] = (i<3*64); /* half-full */ + Src1[i] = (i*i*3/8192)&(i/64)&1; // 'random' + Src2[i] = (i<3*64); // half-full Src3[i] = ((i+32)>3*64); Src4[i] = (i==(3*64+2) || i==(5*64+9)); } @@ -767,7 +783,7 @@ } } -/*//////////////////////////////////////////////////////// */ +////////////////////////////////////////////////////////// /* Pseudo-random generator specified by IEEE 1180 */ static long ieee_seed = 1; @@ -854,13 +870,13 @@ static const double ILimits[5] = { 1., 0.06, 0.02, 0.015, 0.0015 }; int Loops = 10000; int i, m, n; - short Blk0[64]; /* reference */ + short Blk0[64]; // reference short Blk[64], iBlk[64]; short Ref_FDCT[64]; short Ref_IDCT[64]; - STATS_8x8 FStats; /* forward dct stats */ - STATS_8x8 IStats; /* inverse dct stats */ + STATS_8x8 FStats; // forward dct stats + STATS_8x8 IStats; // inverse dct stats CPU *cpu; @@ -883,8 +899,8 @@ for(i=0; i<64; ++i) Blk0[i] = (short)ieee_rand(Min,Max) * Sign; - /* hmm, I'm not quite sure this is exactly */ - /* the tests described in the norm. check... */ + // hmm, I'm not quite sure this is exactly + // the tests described in the norm. check... memcpy(Ref_FDCT, Blk0, 64*sizeof(short)); ref_fdct(Ref_FDCT); @@ -910,8 +926,8 @@ printf( "\n -- FDCT report --\n" ); -/* print_stats(&FStats); */ - report_stats(&FStats, 0); /* so far I know, IEEE1180 says nothing for fdct */ +// print_stats(&FStats); + report_stats(&FStats, 0); // so far I know, IEEE1180 says nothing for fdct for(i=0; i<64; i++) Blk[i] = 0; emms(); fdct(Blk); emms(); @@ -919,7 +935,7 @@ printf( "FDCT(0) == 0 ? %s\n", (m!=0) ? "NOPE!" : "yup." ); printf( "\n -- IDCT report --\n" ); -/* print_stats(&IStats); */ +// print_stats(&IStats); report_stats(&IStats, ILimits); @@ -933,13 +949,13 @@ void test_dct_saturation(int Min, int Max) { - /* test behaviour on input range fringe */ + // test behaviour on input range fringe int i, n, p; CPU *cpu; -/* const short IDCT_MAX = 2047; // 12bits input */ -/* const short IDCT_MIN = -2048; */ -/* const short IDCT_OUT = 256; // 9bits ouput */ +// const short IDCT_MAX = 2047; // 12bits input +// const short IDCT_MIN = -2048; +// const short IDCT_OUT = 256; // 9bits ouput const int Partitions = 4; const int Loops = 10000 / Partitions; @@ -956,11 +972,11 @@ printf( "\n===== IEEE test for %s Min=%d Max=%d =====\n", cpu->name, Min, Max ); - /* FDCT tests // */ + // FDCT tests // init_stats(&Stats); - /* test each computation channels separately */ + // test each computation channels separately for(i=0; i<64; i++) Blk[i] = Blk0[i] = ((i/8)==(i%8)) ? Max : 0; ref_fdct(Blk0); emms(); fdct(Blk); emms(); @@ -971,7 +987,7 @@ emms(); fdct(Blk); emms(); store_stats(&Stats, Blk, Blk0); - /* randomly saturated inputs */ + // randomly saturated inputs for(p=0; p