[svn] / branches / dev-api-4 / xvidcore / examples / xvid_bench.c Repository:
ViewVC logotype

Diff of /branches/dev-api-4/xvidcore/examples/xvid_bench.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 279, Wed Jul 10 13:23:29 2002 UTC revision 684, Wed Nov 27 21:09:10 2002 UTC
# Line 35  Line 35 
35    
36  #include <stdio.h>  #include <stdio.h>
37  #include <stdlib.h>  #include <stdlib.h>
38  #include <sys/time.h>  // for gettimeofday  #ifdef  WIN32
39  #include <string.h>    // for memset  #include <time.h>  /* for clock */
40    #else
41    #include <sys/time.h>  /* for gettimeofday */
42    #endif
43    #include <string.h>    /* for memset */
44  #include <assert.h>  #include <assert.h>
45    
46  #include "xvid.h"  #include "xvid.h"
47    
48  // inner guts  /* inner guts */
49  #include "dct/idct.h"  #include "dct/idct.h"
50  #include "dct/fdct.h"  #include "dct/fdct.h"
51  #include "image/colorspace.h"  #include "image/colorspace.h"
# Line 56  Line 60 
60  #include "bitstream/cbp.h"  #include "bitstream/cbp.h"
61    
62  #include <math.h>  #include <math.h>
63  const int speed_ref = 100;  // on slow machines, decrease this value  #ifndef M_PI
64    #  define M_PI     3.14159265359
65    #  define M_PI_2   1.5707963268
66    #endif
67    const int speed_ref = 100;  /* on slow machines, decrease this value */
68    
69  /*********************************************************************  /*********************************************************************
70   * misc   * misc
# Line 65  Line 73 
73   /* returns time in micro-s*/   /* returns time in micro-s*/
74  double gettime_usec()  double gettime_usec()
75  {  {
76    #ifdef  WIN32
77      return clock()*1000;
78    #else
79    struct timeval  tv;    struct timeval  tv;
80    gettimeofday(&tv, 0);    gettimeofday(&tv, 0);
81    return tv.tv_sec*1.0e6 + tv.tv_usec;    return tv.tv_sec*1.0e6 + tv.tv_usec;
82    #endif
83  }  }
84    
85   /* 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 */
# Line 103  Line 115 
115  , { "3DNOW ", XVID_CPU_3DNOW }  , { "3DNOW ", XVID_CPU_3DNOW }
116  , { "3DNOWE", XVID_CPU_3DNOWEXT }  , { "3DNOWE", XVID_CPU_3DNOWEXT }
117  , { "IA64  ", XVID_CPU_IA64 }  , { "IA64  ", XVID_CPU_IA64 }
118  //, { "TSC   ", XVID_CPU_TSC }  /*, { "TSC   ", XVID_CPU_TSC } */
119  , { 0, 0 } }  , { 0, 0 } }
120    
121  , cpu_short_list[] =  , cpu_short_list[] =
122  { { "PLAINC", 0 }  { { "PLAINC", 0 }
123  , { "MMX   ", XVID_CPU_MMX }  , { "MMX   ", XVID_CPU_MMX }
124  //, { "MMXEXT", XVID_CPU_MMXEXT | XVID_CPU_MMX }  /*, { "MMXEXT", XVID_CPU_MMXEXT | XVID_CPU_MMX } */
125  , { "IA64  ", XVID_CPU_IA64 }  , { "IA64  ", XVID_CPU_IA64 }
126  , { 0, 0 } }  , { 0, 0 } }
127    
# Line 127  Line 139 
139    
140    cpu_type = check_cpu_features() & cpu->cpu;    cpu_type = check_cpu_features() & cpu->cpu;
141    xinit.cpu_flags = cpu_type | XVID_CPU_FORCE;    xinit.cpu_flags = cpu_type | XVID_CPU_FORCE;
142    //    xinit.cpu_flags = XVID_CPU_MMX | XVID_CPU_FORCE;    /*    xinit.cpu_flags = XVID_CPU_MMX | XVID_CPU_FORCE; */
143    xerr = xvid_init(NULL, 0, &xinit, NULL);    xerr = xvid_init(NULL, 0, &xinit, NULL);
144    if (cpu->cpu>0 && (cpu_type==0 || xerr!=XVID_ERR_OK)) {    if (cpu->cpu>0 && (cpu_type==0 || xerr!=XVID_ERR_OK)) {
145      printf( "%s - skipped...\n", cpu->name );      printf( "%s - skipped...\n", cpu->name );
# Line 285  Line 297 
297    const int nb_tests = 2000*speed_ref;    const int nb_tests = 2000*speed_ref;
298    CPU *cpu;    CPU *cpu;
299    const uint8_t Src0[16*9] = {    const uint8_t Src0[16*9] = {
300          // try to have every possible combinaison of rounding...          /* try to have every possible combinaison of rounding... */
301        0, 0, 1, 0, 2, 0, 3, 0, 4             ,0,0,0, 0,0,0,0        0, 0, 1, 0, 2, 0, 3, 0, 4             ,0,0,0, 0,0,0,0
302      , 0, 1, 1, 1, 2, 1, 3, 1, 3             ,0,0,0, 0,0,0,0      , 0, 1, 1, 1, 2, 1, 3, 1, 3             ,0,0,0, 0,0,0,0
303      , 0, 2, 1, 2, 2, 2, 3, 2, 2             ,0,0,0, 0,0,0,0      , 0, 2, 1, 2, 2, 2, 3, 2, 2             ,0,0,0, 0,0,0,0
# Line 335  Line 347 
347      if (iCrc!=8103) printf( "*** CRC ERROR! ***\n" );      if (iCrc!=8103) printf( "*** CRC ERROR! ***\n" );
348    
349    
350         // this is a new function, as of 06.06.2002         /* this is a new function, as of 06.06.2002 */
351  #if 0  #if 0
352      TEST_MB2(interpolate8x8_avrg);      TEST_MB2(interpolate8x8_avrg);
353      printf( "%s - interpolate8x8_c %.3f usec       iCrc=%d\n", cpu->name, t, iCrc );      printf( "%s - interpolate8x8_c %.3f usec       iCrc=%d\n", cpu->name, t, iCrc );
# Line 457  Line 469 
469      TEST_TRANSFER3(transfer_8to16sub2, Dst16, Src8, Ref1, Ref2);      TEST_TRANSFER3(transfer_8to16sub2, Dst16, Src8, Ref1, Ref2);
470      printf( "%s - 8to16sub2 %.3f usec       crc=%d\n", cpu->name, t, s );      printf( "%s - 8to16sub2 %.3f usec       crc=%d\n", cpu->name, t, s );
471      if (s!=20384) printf( "*** CRC ERROR! ***\n" );      if (s!=20384) printf( "*** CRC ERROR! ***\n" );
472  //    for(i=0; i<64; ++i) printf( "[%d]", Dst16[i]);  /*    for(i=0; i<64; ++i) printf( "[%d]", Dst16[i]); */
473  //    printf("\n");  /*    printf("\n"); */
474  #endif  #endif
475      printf( " --- \n" );      printf( " --- \n" );
476    }    }
# Line 511  Line 523 
523    
524    printf( "\n =====  test quant =====\n" );    printf( "\n =====  test quant =====\n" );
525    
526      // we deliberately enfringe the norm's specified range [-127,127],      /* we deliberately enfringe the norm's specified range [-127,127], */
527      // to test the robustness of the iquant module      /* to test the robustness of the iquant module */
528    for(i=0; i<64; ++i) {    for(i=0; i<64; ++i) {
529      Src[i] = 1 + (i-32) * (i&6);      Src[i] = 1 + (i-32) * (i&6);
530      Dst[i] = 0;      Dst[i] = 0;
# Line 599  Line 611 
611    printf( "\n =====  test cbp =====\n" );    printf( "\n =====  test cbp =====\n" );
612    
613    for(i=0; i<6*64; ++i) {    for(i=0; i<6*64; ++i) {
614      Src1[i] = (i*i*3/8192)&(i/64)&1;  // 'random'      Src1[i] = (i*i*3/8192)&(i/64)&1;  /* 'random' */
615      Src2[i] = (i<3*64);               // half-full      Src2[i] = (i<3*64);               /* half-full */
616      Src3[i] = ((i+32)>3*64);      Src3[i] = ((i+32)>3*64);
617      Src4[i] = (i==(3*64+2) || i==(5*64+9));      Src4[i] = (i==(3*64+2) || i==(5*64+9));
618    }    }
# Line 755  Line 767 
767    }    }
768  }  }
769    
770  //////////////////////////////////////////////////////////  /*//////////////////////////////////////////////////////// */
771  /* Pseudo-random generator specified by IEEE 1180 */  /* Pseudo-random generator specified by IEEE 1180 */
772    
773  static long ieee_seed = 1;  static long ieee_seed = 1;
# Line 842  Line 854 
854    static const double ILimits[5] = { 1., 0.06, 0.02, 0.015, 0.0015 };    static const double ILimits[5] = { 1., 0.06, 0.02, 0.015, 0.0015 };
855    int Loops = 10000;    int Loops = 10000;
856    int i, m, n;    int i, m, n;
857    short Blk0[64];     // reference    short Blk0[64];     /* reference */
858    short Blk[64], iBlk[64];    short Blk[64], iBlk[64];
859    short Ref_FDCT[64];    short Ref_FDCT[64];
860    short Ref_IDCT[64];    short Ref_IDCT[64];
861    
862    STATS_8x8 FStats; // forward dct stats    STATS_8x8 FStats; /* forward dct stats */
863    STATS_8x8 IStats; // inverse dct stats    STATS_8x8 IStats; /* inverse dct stats */
864    
865    CPU *cpu;    CPU *cpu;
866    
# Line 871  Line 883 
883        for(i=0; i<64; ++i)        for(i=0; i<64; ++i)
884          Blk0[i] = (short)ieee_rand(Min,Max) * Sign;          Blk0[i] = (short)ieee_rand(Min,Max) * Sign;
885    
886          // hmm, I'm not quite sure this is exactly          /* hmm, I'm not quite sure this is exactly */
887          // the tests described in the norm. check...          /* the tests described in the norm. check... */
888    
889        memcpy(Ref_FDCT, Blk0, 64*sizeof(short));        memcpy(Ref_FDCT, Blk0, 64*sizeof(short));
890        ref_fdct(Ref_FDCT);        ref_fdct(Ref_FDCT);
# Line 898  Line 910 
910    
911    
912      printf( "\n  -- FDCT report --\n" );      printf( "\n  -- FDCT report --\n" );
913  //    print_stats(&FStats);  /*    print_stats(&FStats); */
914      report_stats(&FStats, 0); // so far I know, IEEE1180 says nothing for fdct      report_stats(&FStats, 0); /* so far I know, IEEE1180 says nothing for fdct */
915    
916      for(i=0; i<64; i++) Blk[i] = 0;      for(i=0; i<64; i++) Blk[i] = 0;
917      emms(); fdct(Blk); emms();      emms(); fdct(Blk); emms();
# Line 907  Line 919 
919      printf( "FDCT(0) == 0 ?  %s\n", (m!=0) ? "NOPE!" : "yup." );      printf( "FDCT(0) == 0 ?  %s\n", (m!=0) ? "NOPE!" : "yup." );
920    
921      printf( "\n  -- IDCT report --\n" );      printf( "\n  -- IDCT report --\n" );
922  //    print_stats(&IStats);  /*    print_stats(&IStats); */
923      report_stats(&IStats, ILimits);      report_stats(&IStats, ILimits);
924    
925    
# Line 921  Line 933 
933    
934  void test_dct_saturation(int Min, int Max)  void test_dct_saturation(int Min, int Max)
935  {  {
936      // test behaviour on input range fringe      /* test behaviour on input range fringe */
937    
938    int i, n, p;    int i, n, p;
939    CPU *cpu;    CPU *cpu;
940  //  const short IDCT_MAX =  2047;  // 12bits input  /*  const short IDCT_MAX =  2047;  // 12bits input */
941  //  const short IDCT_MIN = -2048;  /*  const short IDCT_MIN = -2048; */
942  //  const short IDCT_OUT =   256;  // 9bits ouput  /*  const short IDCT_OUT =   256;  // 9bits ouput */
943    const int Partitions = 4;    const int Partitions = 4;
944    const int Loops = 10000 / Partitions;    const int Loops = 10000 / Partitions;
945    
# Line 944  Line 956 
956      printf( "\n===== IEEE test for %s Min=%d Max=%d =====\n",      printf( "\n===== IEEE test for %s Min=%d Max=%d =====\n",
957        cpu->name, Min, Max );        cpu->name, Min, Max );
958    
959                // FDCT tests //                /* FDCT tests // */
960    
961      init_stats(&Stats);      init_stats(&Stats);
962    
963        // test each computation channels separately        /* test each computation channels separately */
964      for(i=0; i<64; i++) Blk[i] = Blk0[i] = ((i/8)==(i%8)) ? Max : 0;      for(i=0; i<64; i++) Blk[i] = Blk0[i] = ((i/8)==(i%8)) ? Max : 0;
965      ref_fdct(Blk0);      ref_fdct(Blk0);
966      emms(); fdct(Blk); emms();      emms(); fdct(Blk); emms();
# Line 959  Line 971 
971      emms(); fdct(Blk); emms();      emms(); fdct(Blk); emms();
972      store_stats(&Stats, Blk, Blk0);      store_stats(&Stats, Blk, Blk0);
973    
974        // randomly saturated inputs        /* randomly saturated inputs */
975      for(p=0; p<Partitions; ++p)      for(p=0; p<Partitions; ++p)
976      {      {
977        for(n=0; n<Loops; ++n)        for(n=0; n<Loops; ++n)
# Line 975  Line 987 
987      report_stats(&Stats, 0);      report_stats(&Stats, 0);
988    
989    
990                // IDCT tests //                /* IDCT tests */
991  #if 0  #if 0
992        // no finished yet        /* no finished yet */
993    
994      init_stats(&Stats);      init_stats(&Stats);
995    
996      // test each computation channel separately      /* test each computation channel separately */
997      for(i=0; i<64; i++) Blk[i] = Blk0[i] = ((i/8)==(i%8)) ? IDCT_MAX : 0;      for(i=0; i<64; i++) Blk[i] = Blk0[i] = ((i/8)==(i%8)) ? IDCT_MAX : 0;
998      ref_idct(Blk0);      ref_idct(Blk0);
999      emms(); idct(Blk); emms();      emms(); idct(Blk); emms();
# Line 994  Line 1006 
1006      for(i=0; i<64; i++) { CLAMP(Blk0[i], IDCT_OUT); CLAMP(Blk[i], IDCT_OUT); }      for(i=0; i<64; i++) { CLAMP(Blk0[i], IDCT_OUT); CLAMP(Blk[i], IDCT_OUT); }
1007      store_stats(&Stats, Blk, Blk0);      store_stats(&Stats, Blk, Blk0);
1008    
1009        // randomly saturated inputs        /* randomly saturated inputs */
1010      for(p=0; p<Partitions; ++p)      for(p=0; p<Partitions; ++p)
1011      {      {
1012        for(n=0; n<Loops; ++n)        for(n=0; n<Loops; ++n)
# Line 1063  Line 1075 
1075    }    }
1076    else printf( "Input size: %d\n", buf_size);    else printf( "Input size: %d\n", buf_size);
1077    
1078    buf = malloc(buf_size); // should be enuf'    buf = malloc(buf_size); /* should be enuf' */
1079    rgb_out = calloc(4, width*height);  // <-room for _RGB24    rgb_out = calloc(4, width*height);  /* <-room for _RGB24 */
1080    if (buf==0 || rgb_out==0) {    if (buf==0 || rgb_out==0) {
1081      printf( "malloc failed!\n" );      printf( "malloc failed!\n" );
1082      goto End;      goto End;

Legend:
Removed from v.279  
changed lines
  Added in v.684

No admin address has been configured
ViewVC Help
Powered by ViewVC 1.0.4