--- trunk/xvidcore/examples/xvid_bench.c 2002/11/27 21:08:35 683 +++ trunk/xvidcore/examples/xvid_bench.c 2002/11/27 21:09:10 684 @@ -35,13 +35,17 @@ #include #include -#include // for gettimeofday -#include // for memset +#ifdef WIN32 +#include /* for clock */ +#else +#include /* for gettimeofday */ +#endif +#include /* for memset */ #include #include "xvid.h" -// inner guts +/* inner guts */ #include "dct/idct.h" #include "dct/fdct.h" #include "image/colorspace.h" @@ -56,7 +60,11 @@ #include "bitstream/cbp.h" #include -const int speed_ref = 100; // on slow machines, decrease this value +#ifndef M_PI +# define M_PI 3.14159265359 +# define M_PI_2 1.5707963268 +#endif +const int speed_ref = 100; /* on slow machines, decrease this value */ /********************************************************************* * misc @@ -65,9 +73,13 @@ /* returns time in micro-s*/ double gettime_usec() { +#ifdef WIN32 + return clock()*1000; +#else struct timeval tv; gettimeofday(&tv, 0); return tv.tv_sec*1.0e6 + tv.tv_usec; +#endif } /* returns squared deviates (mean(v*v)-mean(v)^2) of a 8x8 block */ @@ -103,13 +115,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 } } @@ -127,7 +139,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 ); @@ -285,7 +297,7 @@ const int nb_tests = 2000*speed_ref; CPU *cpu; const uint8_t Src0[16*9] = { - // try to have every possible combinaison of rounding... + /* try to have every possible combinaison of rounding... */ 0, 0, 1, 0, 2, 0, 3, 0, 4 ,0,0,0, 0,0,0,0 , 0, 1, 1, 1, 2, 1, 3, 1, 3 ,0,0,0, 0,0,0,0 , 0, 2, 1, 2, 2, 2, 3, 2, 2 ,0,0,0, 0,0,0,0 @@ -335,7 +347,7 @@ if (iCrc!=8103) printf( "*** CRC ERROR! ***\n" ); - // this is a new function, as of 06.06.2002 + /* this is a new function, as of 06.06.2002 */ #if 0 TEST_MB2(interpolate8x8_avrg); printf( "%s - interpolate8x8_c %.3f usec iCrc=%d\n", cpu->name, t, iCrc ); @@ -457,8 +469,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" ); } @@ -511,8 +523,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; @@ -599,8 +611,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)); } @@ -755,7 +767,7 @@ } } -////////////////////////////////////////////////////////// +/*//////////////////////////////////////////////////////// */ /* Pseudo-random generator specified by IEEE 1180 */ static long ieee_seed = 1; @@ -842,13 +854,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; @@ -871,8 +883,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); @@ -898,8 +910,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(); @@ -907,7 +919,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); @@ -921,13 +933,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; @@ -944,11 +956,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(); @@ -959,7 +971,7 @@ emms(); fdct(Blk); emms(); store_stats(&Stats, Blk, Blk0); - // randomly saturated inputs + /* randomly saturated inputs */ for(p=0; p