[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 1054, Mon Jun 9 13:55:56 2003 UTC revision 1199, Mon Nov 3 19:58:16 2003 UTC
# Line 19  Line 19 
19   *  along with this program; if not, write to the Free Software   *  along with this program; if not, write to the Free Software
20   *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA   *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
21   *   *
22   * $Id: xvid_bench.c,v 1.9.2.2 2003-06-09 13:49:00 edgomez Exp $   * $Id: xvid_bench.c,v 1.9.2.7 2003-11-03 19:58:16 edgomez Exp $
23   *   *
24   ****************************************************************************/   ****************************************************************************/
25    
# Line 54  Line 54 
54  #include "image/colorspace.h"  #include "image/colorspace.h"
55  #include "image/interpolate8x8.h"  #include "image/interpolate8x8.h"
56  #include "utils/mem_transfer.h"  #include "utils/mem_transfer.h"
57  #include "quant/quant_h263.h"  #include "quant/quant.h"
 #include "quant/quant_mpeg4.h"  
58  #include "motion/sad.h"  #include "motion/sad.h"
59  #include "utils/emms.h"  #include "utils/emms.h"
60  #include "utils/timer.h"  #include "utils/timer.h"
# Line 115  Line 114 
114    
115  CPU cpu_list[] =  CPU cpu_list[] =
116  { { "PLAINC", 0 }  { { "PLAINC", 0 }
117    #ifdef ARCH_IS_IA32
118  , { "MMX   ", XVID_CPU_MMX }  , { "MMX   ", XVID_CPU_MMX }
119  , { "MMXEXT", XVID_CPU_MMXEXT | XVID_CPU_MMX }  , { "MMXEXT", XVID_CPU_MMXEXT | XVID_CPU_MMX }
120  , { "SSE2  ", XVID_CPU_SSE2 | XVID_CPU_MMX }  , { "SSE2  ", XVID_CPU_SSE2 | XVID_CPU_MMX }
121  , { "3DNOW ", XVID_CPU_3DNOW }  , { "3DNOW ", XVID_CPU_3DNOW }
122  , { "3DNOWE", XVID_CPU_3DNOWEXT }  , { "3DNOWE", XVID_CPU_3DNOWEXT }
123  , { "IA64  ", XVID_CPU_IA64 }  #endif
124    //, { "IA64  ", XVID_CPU_IA64 }
125  //, { "TSC   ", XVID_CPU_TSC }  //, { "TSC   ", XVID_CPU_TSC }
126  , { 0, 0 } }    , { 0, 0 } };
127    
128  , cpu_short_list[] =  CPU  cpu_short_list[] =
129  { { "PLAINC", 0 }  { { "PLAINC", 0 }
130    #ifdef ARCH_IS_IA32
131  , { "MMX   ", XVID_CPU_MMX }  , { "MMX   ", XVID_CPU_MMX }
132  //, { "MMXEXT", XVID_CPU_MMXEXT | XVID_CPU_MMX }  //, { "MMXEXT", XVID_CPU_MMXEXT | XVID_CPU_MMX }
133  , { "IA64  ", XVID_CPU_IA64 }  #endif
134  , { 0, 0 } }  //, { "IA64  ", XVID_CPU_IA64 }
135      , { 0, 0 } };
136    
137  , cpu_short_list2[] =  CPU cpu_short_list2[] =
138  { { "PLAINC", 0 }  { { "PLAINC", 0 }
139    #ifdef ARCH_IS_IA32
140  , { "MMX   ", XVID_CPU_MMX }  , { "MMX   ", XVID_CPU_MMX }
141  , { "SSE2  ", XVID_CPU_SSE2 | XVID_CPU_MMX }  , { "SSE2  ", XVID_CPU_SSE2 | XVID_CPU_MMX }
142    #endif
143  , { 0, 0 } };  , { 0, 0 } };
144    
145    
146  int init_cpu(CPU *cpu)  int init_cpu(CPU *cpu)
147  {  {
148    int xerr, cpu_type;          xvid_gbl_info_t xinfo;
   XVID_INIT_PARAM xinit;  
149    
150    cpu_type = check_cpu_features() & cpu->cpu;          /* Get the available CPU flags */
151    xinit.cpu_flags = cpu_type | XVID_CPU_FORCE;          memset(&xinfo, 0, sizeof(xinfo));
152    /* xinit.cpu_flags = XVID_CPU_MMX | XVID_CPU_FORCE; */          xinfo.version = XVID_VERSION;
153    xerr = xvid_init(NULL, 0, &xinit, NULL);          xvid_global(NULL, XVID_GBL_INFO, &xinfo, NULL);
154    if (cpu->cpu>0 && (cpu_type==0 || xerr!=XVID_ERR_OK)) {  
155      printf( "%s - skipped...\n", cpu->name );          /* Are we trying to test a subset of the host CPU features */
156            if ((xinfo.cpu_flags & cpu->cpu) == cpu->cpu) {
157                    int xerr;
158                    xvid_gbl_init_t xinit;
159                    memset(&xinit, 0, sizeof(xinit));
160                    xinit.cpu_flags = cpu->cpu | XVID_CPU_FORCE;
161                    xinit.version = XVID_VERSION;
162                    xerr = xvid_global(NULL, XVID_GBL_INIT, &xinit, NULL);
163                    if (xerr==XVID_ERR_FAIL) {
164                            /* libxvidcore failed to init */
165      return 0;      return 0;
166    }    }
167            } else {
168                    /* The host CPU doesn't support some required feature for this test */
169                    return(0);
170            }
171    return 1;    return 1;
172  }  }
173    
# Line 166  Line 183 
183    int tst;    int tst;
184    CPU *cpu;    CPU *cpu;
185    int i;    int i;
186    short iDst0[8*8], iDst[8*8], fDst[8*8];          DECLARE_ALIGNED_MATRIX(iDst0, 8, 8, short, 16);
187            DECLARE_ALIGNED_MATRIX(iDst,  8, 8, short, 16);
188            DECLARE_ALIGNED_MATRIX(fDst,  8, 8, short, 16);
189    double overhead;    double overhead;
190    
191    printf( "\n ===== test fdct/idct =====\n" );    printf( "\n ===== test fdct/idct =====\n" );
# Line 441  Line 460 
460    
461    printf( "\n ===  test transfer ===\n" );    printf( "\n ===  test transfer ===\n" );
462    
463    for(cpu = cpu_short_list; cpu->name!=0; ++cpu)          for(cpu = cpu_list; cpu->name!=0; ++cpu)
464    {    {
465      double t, overhead;      double t, overhead;
466      int tst, s;      int tst, s;
# Line 536  Line 555 
555      Dst[i] = 0;      Dst[i] = 0;
556    }    }
557    
558    for(cpu = cpu_short_list; cpu->name!=0; ++cpu)          for(cpu = cpu_list; cpu->name!=0; ++cpu)
559    {    {
560      double t, overhead;      double t, overhead;
561      int tst, q;      int tst, q;
# Line 555  Line 574 
574      overhead += gettime_usec();      overhead += gettime_usec();
575    
576  #if 1  #if 1
577      TEST_QUANT2(quant4_intra, Dst, Src);                  TEST_QUANT2(quant_mpeg_intra, Dst, Src);
578      printf( "%s -   quant4_intra %.3f usec       crc=%d\n", cpu->name, t, s );                  printf( "%s -   quant_mpeg_intra %.3f usec       crc=%d\n", cpu->name, t, s );
579      if (s!=29809) printf( "*** CRC ERROR! ***\n" );      if (s!=29809) printf( "*** CRC ERROR! ***\n" );
580    
581      TEST_QUANT(quant4_inter, Dst, Src);                  TEST_QUANT(quant_mpeg_inter, Dst, Src);
582      printf( "%s -   quant4_inter %.3f usec       crc=%d\n", cpu->name, t, s );                  printf( "%s -   quant_mpeg_inter %.3f usec       crc=%d\n", cpu->name, t, s );
583      if (s!=12574) printf( "*** CRC ERROR! ***\n" );      if (s!=12574) printf( "*** CRC ERROR! ***\n" );
584  #endif  #endif
585  #if 1  #if 1
586      TEST_QUANT2(dequant4_intra, Dst, Src);                  TEST_QUANT2(dequant_mpeg_intra, Dst, Src);
587      printf( "%s - dequant4_intra %.3f usec       crc=%d\n", cpu->name, t, s );                  printf( "%s - dequant_mpeg_intra %.3f usec       crc=%d\n", cpu->name, t, s );
588      if (s!=24052) printf( "*** CRC ERROR! ***\n" );      if (s!=24052) printf( "*** CRC ERROR! ***\n" );
589    
590      TEST_QUANT(dequant4_inter, Dst, Src);                  TEST_QUANT(dequant_mpeg_inter, Dst, Src);
591      printf( "%s - dequant4_inter %.3f usec       crc=%d\n", cpu->name, t, s );                  printf( "%s - dequant_mpeg_inter %.3f usec       crc=%d\n", cpu->name, t, s );
592      if (s!=63847) printf( "*** CRC ERROR! ***\n" );      if (s!=63847) printf( "*** CRC ERROR! ***\n" );
593  #endif  #endif
594  #if 1  #if 1
595      TEST_QUANT2(quant_intra, Dst, Src);                  TEST_QUANT2(quant_h263_intra, Dst, Src);
596      printf( "%s -    quant_intra %.3f usec       crc=%d\n", cpu->name, t, s );                  printf( "%s -   quant_h263_intra %.3f usec       crc=%d\n", cpu->name, t, s );
597      if (s!=25662) printf( "*** CRC ERROR! ***\n" );      if (s!=25662) printf( "*** CRC ERROR! ***\n" );
598    
599      TEST_QUANT(quant_inter, Dst, Src);                  TEST_QUANT(quant_h263_inter, Dst, Src);
600      printf( "%s -    quant_inter %.3f usec       crc=%d\n", cpu->name, t, s );                  printf( "%s -   quant_h263_inter %.3f usec       crc=%d\n", cpu->name, t, s );
601      if (s!=23972) printf( "*** CRC ERROR! ***\n" );      if (s!=23972) printf( "*** CRC ERROR! ***\n" );
602  #endif  #endif
603  #if 1  #if 1
604      TEST_QUANT2(dequant_intra, Dst, Src);                  TEST_QUANT2(dequant_h263_intra, Dst, Src);
605      printf( "%s -  dequant_intra %.3f usec       crc=%d\n", cpu->name, t, s );                  printf( "%s - dequant_h263_intra %.3f usec       crc=%d\n", cpu->name, t, s );
606      if (s!=49900) printf( "*** CRC ERROR! ***\n" );      if (s!=49900) printf( "*** CRC ERROR! ***\n" );
607    
608      TEST_QUANT(dequant_inter, Dst, Src);                  TEST_QUANT(dequant_h263_inter, Dst, Src);
609      printf( "%s -  dequant_inter %.3f usec       crc=%d\n", cpu->name, t, s );                  printf( "%s - dequant_h263_inter %.3f usec       crc=%d\n", cpu->name, t, s );
610      if (s!=48899) printf( "*** CRC ERROR! ***\n" );      if (s!=48899) printf( "*** CRC ERROR! ***\n" );
611  #endif  #endif
612      printf( " --- \n" );      printf( " --- \n" );
# Line 623  Line 642 
642      Src4[i] = (i==(3*64+2) || i==(5*64+9));      Src4[i] = (i==(3*64+2) || i==(5*64+9));
643    }    }
644    
645    for(cpu = cpu_short_list2; cpu->name!=0; ++cpu)          for(cpu = cpu_list; cpu->name!=0; ++cpu)
646    {    {
647      double t;      double t;
648      int tst, cbp;      int tst, cbp;
# Line 860  Line 879 
879    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 };
880    int Loops = 10000;    int Loops = 10000;
881    int i, m, n;    int i, m, n;
882    short Blk0[64];     /* reference */          DECLARE_ALIGNED_MATRIX(Blk0, 8, 8, short, 16); /* reference */
883    short Blk[64], iBlk[64];          DECLARE_ALIGNED_MATRIX(Blk,  8, 8, short, 16);
884    short Ref_FDCT[64];          DECLARE_ALIGNED_MATRIX(iBlk, 8, 8, short, 16);
885    short Ref_IDCT[64];          DECLARE_ALIGNED_MATRIX(Ref_FDCT, 8, 8, short, 16);
886            DECLARE_ALIGNED_MATRIX(Ref_IDCT, 8, 8, short, 16);
887    
888    STATS_8x8 FStats; /* forward dct stats */    STATS_8x8 FStats; /* forward dct stats */
889    STATS_8x8 IStats; /* inverse dct stats */    STATS_8x8 IStats; /* inverse dct stats */
# Line 1042  Line 1062 
1062    FILE *f = 0;    FILE *f = 0;
1063    void *dechandle = 0;    void *dechandle = 0;
1064    int xerr;    int xerr;
1065          XVID_INIT_PARAM xinit;          xvid_gbl_init_t xinit;
1066          XVID_DEC_PARAM xparam;          xvid_dec_create_t xparam;
1067          XVID_DEC_FRAME xframe;          xvid_dec_frame_t xframe;
1068          double t = 0.;          double t = 0.;
1069          int nb = 0;          int nb = 0;
1070    uint8_t *buf = 0;    uint8_t *buf = 0;
# Line 1052  Line 1072 
1072    int buf_size, pos;    int buf_size, pos;
1073    uint32_t chksum = 0;    uint32_t chksum = 0;
1074    
1075            memset(&xinit, 0, sizeof(xinit));
1076          xinit.cpu_flags = XVID_CPU_MMX | XVID_CPU_FORCE;          xinit.cpu_flags = XVID_CPU_MMX | XVID_CPU_FORCE;
1077          xvid_init(NULL, 0, &xinit, NULL);          xinit.version = XVID_VERSION;
1078          printf( "API version: %d, core build:%d\n", xinit.api_version, xinit.core_build);          xvid_global(NULL, 0, &xinit, NULL);
   
1079    
1080            memset(&xparam, 0, sizeof(xparam));
1081          xparam.width = width;          xparam.width = width;
1082          xparam.height = height;          xparam.height = height;
1083            xparam.version = XVID_VERSION;
1084          xerr = xvid_decore(NULL, XVID_DEC_CREATE, &xparam, NULL);          xerr = xvid_decore(NULL, XVID_DEC_CREATE, &xparam, NULL);
1085          if (xerr!=XVID_ERR_OK) {          if (xerr==XVID_ERR_FAIL) {
1086            printf("can't init decoder (err=%d)\n", xerr);            printf("can't init decoder (err=%d)\n", xerr);
1087            return;            return;
1088          }          }
# Line 1097  Line 1119 
1119    pos = 0;    pos = 0;
1120    t = -gettime_usec();    t = -gettime_usec();
1121    while(1) {    while(1) {
1122                    memset(&xframe, 0, sizeof(xframe));
1123                    xframe.version = XVID_VERSION;
1124      xframe.bitstream = buf + pos;      xframe.bitstream = buf + pos;
1125      xframe.length = buf_size - pos;      xframe.length = buf_size - pos;
1126      xframe.image = rgb_out;                  xframe.output.plane[0] = rgb_out;
1127      xframe.stride = width;                  xframe.output.stride[0] = width;
1128      xframe.colorspace = XVID_CSP_RGB24;                  xframe.output.csp = XVID_CSP_BGR;
1129      xerr = xvid_decore(dechandle, XVID_DEC_DECODE, &xframe, 0);      xerr = xvid_decore(dechandle, XVID_DEC_DECODE, &xframe, 0);
1130      nb++;      nb++;
1131      pos += xframe.length;      pos += xframe.length;
# Line 1112  Line 1136 
1136      }      }
1137      if (pos==buf_size)      if (pos==buf_size)
1138        break;        break;
1139      if (xerr!=XVID_ERR_OK) {                  if (xerr==XVID_ERR_FAIL) {
1140            printf("decoding failed for frame #%d (err=%d)!\n", nb, xerr);            printf("decoding failed for frame #%d (err=%d)!\n", nb, xerr);
1141            break;            break;
1142          }          }
# Line 1128  Line 1152 
1152    if (buf!=0) free(buf);    if (buf!=0) free(buf);
1153    if (dechandle!=0) {    if (dechandle!=0) {
1154      xerr= xvid_decore(dechandle, XVID_DEC_DESTROY, NULL, NULL);      xerr= xvid_decore(dechandle, XVID_DEC_DESTROY, NULL, NULL);
1155      if (xerr!=XVID_ERR_OK)                  if (xerr==XVID_ERR_FAIL)
1156              printf("destroy-decoder failed (err=%d)!\n", xerr);              printf("destroy-decoder failed (err=%d)!\n", xerr);
1157    }    }
1158    if (f!=0) fclose(f);    if (f!=0) fclose(f);
# Line 1144  Line 1168 
1168    
1169    printf( "\n =====  (de)quant4_intra saturation bug? =====\n" );    printf( "\n =====  (de)quant4_intra saturation bug? =====\n" );
1170    
1171    for(cpu = cpu_short_list; cpu->name!=0; ++cpu)          for(cpu = cpu_list; cpu->name!=0; ++cpu)
1172    {    {
1173      int i;      int i;
1174      int16_t  Src[8*8], Dst[8*8];      int16_t  Src[8*8], Dst[8*8];
# Line 1154  Line 1178 
1178    
1179      for(i=0; i<64; ++i) Src[i] = i-32;      for(i=0; i<64; ++i) Src[i] = i-32;
1180      set_intra_matrix( get_default_intra_matrix() );      set_intra_matrix( get_default_intra_matrix() );
1181      dequant4_intra(Dst, Src, 31, 5);                  dequant_mpeg_intra(Dst, Src, 31, 5);
1182      printf( "dequant4_intra with CPU=%s:  ", cpu->name);                  printf( "dequant_mpeg_intra with CPU=%s:  ", cpu->name);
1183      printf( "  Out[]= " );      printf( "  Out[]= " );
1184      for(i=0; i<64; ++i) printf( "[%d]", Dst[i]);      for(i=0; i<64; ++i) printf( "[%d]", Dst[i]);
1185      printf( "\n" );      printf( "\n" );
# Line 1163  Line 1187 
1187    
1188    printf( "\n =====  (de)quant4_inter saturation bug? =====\n" );    printf( "\n =====  (de)quant4_inter saturation bug? =====\n" );
1189    
1190    for(cpu = cpu_short_list; cpu->name!=0; ++cpu)          for(cpu = cpu_list; cpu->name!=0; ++cpu)
1191    {    {
1192      int i;      int i;
1193      int16_t  Src[8*8], Dst[8*8];      int16_t  Src[8*8], Dst[8*8];
# Line 1173  Line 1197 
1197    
1198      for(i=0; i<64; ++i) Src[i] = i-32;      for(i=0; i<64; ++i) Src[i] = i-32;
1199      set_inter_matrix( get_default_inter_matrix() );      set_inter_matrix( get_default_inter_matrix() );
1200      dequant4_inter(Dst, Src, 31);                  dequant_mpeg_inter(Dst, Src, 31);
1201      printf( "dequant4_inter with CPU=%s:  ", cpu->name);                  printf( "dequant_mpeg_inter with CPU=%s:  ", cpu->name);
1202      printf( "  Out[]= " );      printf( "  Out[]= " );
1203      for(i=0; i<64; ++i) printf( "[%d]", Dst[i]);      for(i=0; i<64; ++i) printf( "[%d]", Dst[i]);
1204      printf( "\n" );      printf( "\n" );
# Line 1188  Line 1212 
1212    
1213    printf( "\n =====  fdct/idct precision diffs =====\n" );    printf( "\n =====  fdct/idct precision diffs =====\n" );
1214    
1215    for(cpu = cpu_short_list; cpu->name!=0; ++cpu)          for(cpu = cpu_list; cpu->name!=0; ++cpu)
1216    {    {
1217      int i;      int i;
1218    
# Line 1241  Line 1265 
1265    
1266        for(q=1; q<=max_Q; ++q) {        for(q=1; q<=max_Q; ++q) {
1267          emms();          emms();
1268          quant4_inter( Dst, Src, q );                                  quant_mpeg_inter( Dst, Src, q );
1269          emms();          emms();
1270          for(s=0, i=0; i<64; ++i) s+=((uint16_t)Dst[i])^i;          for(s=0, i=0; i<64; ++i) s+=((uint16_t)Dst[i])^i;
1271          Crcs_Inter[n][q] = s;          Crcs_Inter[n][q] = s;
# Line 1271  Line 1295 
1295    
1296        for(q=1; q<=max_Q; ++q) {        for(q=1; q<=max_Q; ++q) {
1297          emms();          emms();
1298          quant4_intra( Dst, Src, q, q);                                  quant_mpeg_intra( Dst, Src, q, q);
1299          emms();          emms();
1300          for(s=0, i=0; i<64; ++i) s+=((uint16_t)Dst[i])^i;          for(s=0, i=0; i<64; ++i) s+=((uint16_t)Dst[i])^i;
1301          Crcs_Intra[n][q] = s;          Crcs_Intra[n][q] = s;
# Line 1304  Line 1328 
1328    
1329    if (what==7) {    if (what==7) {
1330      test_IEEE1180_compliance(-256, 255, 1);      test_IEEE1180_compliance(-256, 255, 1);
 #if 0  
1331      test_IEEE1180_compliance(-256, 255,-1);      test_IEEE1180_compliance(-256, 255,-1);
1332      test_IEEE1180_compliance(  -5,   5, 1);      test_IEEE1180_compliance(  -5,   5, 1);
1333      test_IEEE1180_compliance(  -5,   5,-1);      test_IEEE1180_compliance(  -5,   5,-1);
1334      test_IEEE1180_compliance(-300, 300, 1);      test_IEEE1180_compliance(-300, 300, 1);
1335      test_IEEE1180_compliance(-300, 300,-1);      test_IEEE1180_compliance(-300, 300,-1);
 #endif  
1336    }    }
1337    if (what==8) test_dct_saturation(-256, 255);    if (what==8) test_dct_saturation(-256, 255);
1338    

Legend:
Removed from v.1054  
changed lines
  Added in v.1199

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