[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

trunk/xvidcore/examples/xvid_bench.c revision 257, Fri Jul 5 14:54:15 2002 UTC branches/dev-api-4/xvidcore/examples/xvid_bench.c revision 1176, Thu Oct 9 18:50:22 2003 UTC
# Line 1  Line 1 
1  /**************************************************************************  /*****************************************************************************
2   *   *
3   *      XVID MPEG-4 VIDEO CODEC - Unit tests and benches   *  XVID MPEG-4 VIDEO CODEC
4     *  - Unit tests and benches -
5     *
6     *  Copyright(C) 2002 Pascal Massimino <skal@planet-d.net>
7   *   *
8   *      This program is free software; you can redistribute it and/or modify   *      This program is free software; you can redistribute it and/or modify
9   *      it under the terms of the GNU General Public License as published by   *      it under the terms of the GNU General Public License as published by
# Line 14  Line 17 
17   *   *
18   *      You should have received a copy of the GNU General Public License   *      You should have received a copy of the GNU General Public License
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., 675 Mass Ave, Cambridge, MA 02139, USA.   *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
21     *
22     * $Id: xvid_bench.c,v 1.9.2.5 2003-10-09 18:50:22 edgomez Exp $
23   *   *
24   *************************************************************************/   ****************************************************************************/
25    
26  /************************************************************************  /*****************************************************************************
27   *   *
28   *  'Reference' output is at the end of file.   *  'Reference' output is at the end of file.
29   *  Don't take the checksums and crc too seriouly, they aren't   *  Don't take the checksums and crc too seriouly, they aren't
30   *  bullet-proof...   *  bullet-proof (should plug some .md5 here)...
31   *   *
32   *   compiles with something like:   *   compiles with something like:
33   *   gcc -o xvid_bench xvid_bench.c  -I../src/ -lxvidcore -lm   *   gcc -o xvid_bench xvid_bench.c  -I../src/ -lxvidcore -lm
34   *   *
35   *      History:   ****************************************************************************/
  *  
  *      06.06.2002  initial coding      -Skal-  
  *  
  *************************************************************************/  
36    
37  #include <stdio.h>  #include <stdio.h>
38  #include <stdlib.h>  #include <stdlib.h>
39  #include <sys/time.h>  // for gettimeofday  #include <string.h>    /* for memset */
 #include <string.h>    // for memset  
40  #include <assert.h>  #include <assert.h>
41    
42    #ifndef WIN32
43    #include <sys/time.h>   /* for gettimeofday */
44    #else
45    #include <time.h>
46    #endif
47    
48    
49  #include "xvid.h"  #include "xvid.h"
50    
51  // inner guts  // inner guts
# Line 47  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"
61  #include "quant/quant_matrix.c"  #include "quant/quant_matrix.c"
62  #include "bitstream/cbp.h"  #include "bitstream/cbp.h"
63    
64  const int speed_ref = 100;  // on slow machines, decrease this value  #include <math.h>
65    
66    #ifndef M_PI
67    #define M_PI            3.14159265358979323846
68    #endif
69    
70    const int speed_ref = 100;  /* on slow machines, decrease this value */
71    
72  /*********************************************************************  /*********************************************************************
73   * misc   * misc
# Line 64  Line 76 
76   /* returns time in micro-s*/   /* returns time in micro-s*/
77  double gettime_usec()  double gettime_usec()
78  {  {
79    #ifndef WIN32
80    struct timeval  tv;    struct timeval  tv;
81    gettimeofday(&tv, 0);    gettimeofday(&tv, 0);
82    return tv.tv_sec*1.0e6 + tv.tv_usec;    return tv.tv_sec*1.0e6 + tv.tv_usec;
83    #else
84            clock_t clk;
85            clk = clock();
86            return clk * 1000000 / CLOCKS_PER_SEC;
87    #endif
88  }  }
89    
90   /* 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 96  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    #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;    int xerr, cpu_type;
149    XVID_INIT_PARAM xinit;          xvid_gbl_init_t xinit;
150    
151    cpu_type = check_cpu_features() & cpu->cpu;          memset(&xinit, 0, sizeof(xinit));
152    xinit.cpu_flags = cpu_type | XVID_CPU_FORCE;          xinit.cpu_flags = cpu->cpu | XVID_CPU_FORCE;
153    //    xinit.cpu_flags = XVID_CPU_MMX | XVID_CPU_FORCE;          xinit.version = XVID_VERSION;
154    xerr = xvid_init(NULL, 0, &xinit, NULL);          xerr = xvid_global(NULL, 0, &xinit, NULL);
155    if (cpu->cpu>0 && (cpu_type==0 || xerr!=XVID_ERR_OK)) {          if (cpu->cpu>0 && xerr==XVID_ERR_FAIL) {
156      printf( "%s - skipped...\n", cpu->name );      printf( "%s - skipped...\n", cpu->name );
157      return 0;      return 0;
158    }    }
# Line 163  Line 187 
187    
188    for(cpu = cpu_list; cpu->name!=0; ++cpu)    for(cpu = cpu_list; cpu->name!=0; ++cpu)
189    {    {
190      double t;                  double t, PSNR, MSE;
     int iCrc, fCrc;  
191    
192      if (!init_cpu(cpu))      if (!init_cpu(cpu))
193        continue;        continue;
# Line 180  Line 203 
203      }      }
204      emms();      emms();
205      t = (gettime_usec() - t - overhead) / nb_tests;      t = (gettime_usec() - t - overhead) / nb_tests;
206      iCrc=0; fCrc=0;                  MSE = 0.;
207      for(i=0; i<8*8; ++i) {      for(i=0; i<8*8; ++i) {
208        iCrc += ABS(iDst[i] - iDst0[i]);                          double delta = 1.0*(iDst[i] - iDst0[i]);
209        fCrc += fDst[i]^i;                          MSE += delta*delta;
210      }      }
211      printf( "%s -  %.3f usec       iCrc=%d  fCrc=%d\n",                  PSNR = (MSE==0.) ? 1.e6 : -4.3429448*log( MSE/64. );
212        cpu->name, t, iCrc, fCrc );                  printf( "%s -  %.3f usec       PSNR=%.3f  MSE=%.3f\n",
213        // the norm tolerates ~1 bit of diff per coeff                                  cpu->name, t, PSNR, MSE );
214      if (ABS(iCrc)>=64) printf( "*** CRC ERROR! ***\n" );                  if (ABS(MSE)>=64) printf( "*** CRC ERROR! ***\n" );
215    }    }
216  }  }
217    
# Line 285  Line 308 
308    const int nb_tests = 2000*speed_ref;    const int nb_tests = 2000*speed_ref;
309    CPU *cpu;    CPU *cpu;
310    const uint8_t Src0[16*9] = {    const uint8_t Src0[16*9] = {
311          // try to have every possible combinaison of rounding...                  /* try to have every possible combinaison of rounding... */
312        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
313      , 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
314      , 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 334  Line 357 
357      printf( "%s -           round1 %.3f usec       iCrc=%d\n", cpu->name, t, iCrc );      printf( "%s -           round1 %.3f usec       iCrc=%d\n", cpu->name, t, iCrc );
358      if (iCrc!=8103) printf( "*** CRC ERROR! ***\n" );      if (iCrc!=8103) printf( "*** CRC ERROR! ***\n" );
359    
360    
361                    /* this is a new function, as of 06.06.2002 */
362    #if 0
363                    TEST_MB2(interpolate8x8_avrg);
364                    printf( "%s - interpolate8x8_c %.3f usec       iCrc=%d\n", cpu->name, t, iCrc );
365                    if (iCrc!=8107) printf( "*** CRC ERROR! ***\n" );
366    #endif
367    
368      printf( " --- \n" );      printf( " --- \n" );
369    }    }
370  }  }
# Line 415  Line 446 
446    
447    printf( "\n ===  test transfer ===\n" );    printf( "\n ===  test transfer ===\n" );
448    
449    for(cpu = cpu_short_list; cpu->name!=0; ++cpu)          for(cpu = cpu_list; cpu->name!=0; ++cpu)
450    {    {
451      double t, overhead;      double t, overhead;
452      int tst, s;      int tst, s;
# Line 445  Line 476 
476      s = 0; for(i=0; i<8*32; ++i) { s += (Src8[i]-Ref1[i])&i; }      s = 0; for(i=0; i<8*32; ++i) { s += (Src8[i]-Ref1[i])&i; }
477      printf( "crc2=%d\n", s);      printf( "crc2=%d\n", s);
478      if (s!=16256) printf( "*** CRC ERROR! ***\n" );      if (s!=16256) printf( "*** CRC ERROR! ***\n" );
479    #if 1
480      TEST_TRANSFER3(transfer_8to16sub2, Dst16, Src8, Ref1, Ref2);      TEST_TRANSFER3(transfer_8to16sub2, Dst16, Src8, Ref1, Ref2);
481      printf( "%s - 8to16sub2 %.3f usec       crc=%d\n", cpu->name, t, s );      printf( "%s - 8to16sub2 %.3f usec       crc=%d\n", cpu->name, t, s );
482      if (s!=20384) printf( "*** CRC ERROR! ***\n" );      if (s!=20384) printf( "*** CRC ERROR! ***\n" );
483    //    for(i=0; i<64; ++i) printf( "[%d]", Dst16[i]);
484    //    printf("\n");
485    #endif
486      printf( " --- \n" );      printf( " --- \n" );
487    }    }
488  }  }
# Line 460  Line 493 
493    
494  #define TEST_QUANT(FUNC, DST, SRC)            \  #define TEST_QUANT(FUNC, DST, SRC)            \
495      t = gettime_usec();                       \      t = gettime_usec();                       \
496    for(s=0,qm=1; qm<=255; ++qm) {              \
497      for(i=0; i<8*8; ++i) Quant[i] = qm;       \
498      set_inter_matrix( Quant );                \
499      emms();                                   \      emms();                                   \
500      for(q=1; q<=max_Q; ++q) {                 \
501      for(tst=0; tst<nb_tests; ++tst)           \      for(tst=0; tst<nb_tests; ++tst)           \
       for(s=0, q=1; q<=max_Q; ++q) {          \  
502          (FUNC)((DST), (SRC), q);              \          (FUNC)((DST), (SRC), q);              \
503          for(i=0; i<64; ++i) s+=(DST)[i]^i;    \          for(i=0; i<64; ++i) s+=(DST)[i]^i^qm;   \
504        }                                       \        }                                       \
505      emms();                                   \      emms();                                   \
506      t = (gettime_usec()-t-overhead)/nb_tests;  }                                           \
507    t = (gettime_usec()-t-overhead)/nb_tests/qm;\
508    s = (s&0xffff)^(s>>16)
509    
510  #define TEST_QUANT2(FUNC, DST, SRC, MULT)     \  #define TEST_QUANT2(FUNC, DST, SRC)             \
511      t = gettime_usec();                       \      t = gettime_usec();                       \
512    for(s=0,qm=1; qm<=255; ++qm) {              \
513      for(i=0; i<8*8; ++i) Quant[i] = qm;       \
514      set_intra_matrix( Quant );                \
515      emms();                                   \      emms();                                   \
516      for(q=1; q<=max_Q; ++q) {                 \
517      for(tst=0; tst<nb_tests; ++tst)           \      for(tst=0; tst<nb_tests; ++tst)           \
518        for(s=0, q=1; q<=max_Q; ++q) {          \            (FUNC)((DST), (SRC), q, q);           \
519          (FUNC)((DST), (SRC), q, MULT);        \          for(i=0; i<64; ++i) s+=(DST)[i]^i^qm;   \
         for(i=0; i<64; ++i) s+=(DST)[i]^i;    \  
520        }                                       \        }                                       \
521      emms();                                   \      emms();                                   \
522      t = (gettime_usec()-t-overhead)/nb_tests;  }                                           \
523    t = (gettime_usec()-t-overhead)/nb_tests/qm;\
524    s = (s&0xffff)^(s>>16)
525    
526  void test_quant()  void test_quant()
527  {  {
528    const int nb_tests = 150*speed_ref;          const int nb_tests = 1*speed_ref;
529    const int max_Q = 31;    const int max_Q = 31;
530    int i;          int i, qm;
531    CPU *cpu;    CPU *cpu;
532    int16_t  Src[8*8], Dst[8*8];    int16_t  Src[8*8], Dst[8*8];
533            uint8_t Quant[8*8];
534    
535    printf( "\n =====  test quant =====\n" );    printf( "\n =====  test quant =====\n" );
536    
537    /* we deliberately enfringe the norm's specified range [-127,127], */
538    /* to test the robustness of the iquant module */
539    for(i=0; i<64; ++i) {    for(i=0; i<64; ++i) {
540      Src[i] = i-32;                  Src[i] = 1 + (i-32) * (i&6);
541      Dst[i] = 0;      Dst[i] = 0;
542    }    }
543    
544            for(cpu = cpu_list; cpu->name!=0; ++cpu)
   for(cpu = cpu_short_list; cpu->name!=0; ++cpu)  
545    {    {
546      double t, overhead;      double t, overhead;
547      int tst, s, q;                  int tst, q;
548                    uint32_t s;
549    
550      if (!init_cpu(cpu))      if (!init_cpu(cpu))
551        continue;        continue;
552    
     set_inter_matrix( get_default_inter_matrix() );  
     set_intra_matrix( get_default_intra_matrix() );  
553      overhead = -gettime_usec();      overhead = -gettime_usec();
554      for(tst=0; tst<nb_tests; ++tst)                  for(s=0,qm=1; qm<=255; ++qm) {
555        for(s=0, q=1; q<=max_Q; ++q)                          for(i=0; i<8*8; ++i) Quant[i] = qm;
556          for(i=0; i<64; ++i) s+=Dst[i]^i;                          set_inter_matrix( Quant );
557                            for(q=1; q<=max_Q; ++q)
558                                    for(i=0; i<64; ++i) s+=Dst[i]^i^qm;
559                    }
560      overhead += gettime_usec();      overhead += gettime_usec();
561    
562      TEST_QUANT2(quant4_intra, Dst, Src, 7);  #if 1
563      printf( "%s -   quant4_intra %.3f usec       crc=%d\n", cpu->name, t, s );                  TEST_QUANT2(quant_mpeg_intra, Dst, Src);
564      if (s!=55827) printf( "*** CRC ERROR! ***\n" );                  printf( "%s -   quant_mpeg_intra %.3f usec       crc=%d\n", cpu->name, t, s );
565                    if (s!=29809) printf( "*** CRC ERROR! ***\n" );
566      TEST_QUANT(quant4_inter, Dst, Src);  
567      printf( "%s -   quant4_inter %.3f usec       crc=%d\n", cpu->name, t, s );                  TEST_QUANT(quant_mpeg_inter, Dst, Src);
568      if (s!=58201) printf( "*** CRC ERROR! ***\n" );                  printf( "%s -   quant_mpeg_inter %.3f usec       crc=%d\n", cpu->name, t, s );
569                    if (s!=12574) printf( "*** CRC ERROR! ***\n" );
570    #endif
571      TEST_QUANT2(dequant4_intra, Dst, Src, 7);  #if 1
572      printf( "%s - dequant4_intra %.3f usec       crc=%d\n", cpu->name, t, s );                  TEST_QUANT2(dequant_mpeg_intra, Dst, Src);
573      if (s!=193340) printf( "*** CRC ERROR! ***\n" );                  printf( "%s - dequant_mpeg_intra %.3f usec       crc=%d\n", cpu->name, t, s );
574                    if (s!=24052) printf( "*** CRC ERROR! ***\n" );
575      TEST_QUANT(dequant4_inter, Dst, Src);  
576      printf( "%s - dequant4_inter %.3f usec       crc=%d\n", cpu->name, t, s );                  TEST_QUANT(dequant_mpeg_inter, Dst, Src);
577      if (s!=116483) printf( "*** CRC ERROR! ***\n" );                  printf( "%s - dequant_mpeg_inter %.3f usec       crc=%d\n", cpu->name, t, s );
578                    if (s!=63847) printf( "*** CRC ERROR! ***\n" );
579      TEST_QUANT2(quant_intra, Dst, Src, 7);  #endif
580      printf( "%s -    quant_intra %.3f usec       crc=%d\n", cpu->name, t, s );  #if 1
581      if (s!=56885) printf( "*** CRC ERROR! ***\n" );                  TEST_QUANT2(quant_h263_intra, Dst, Src);
582                    printf( "%s -   quant_h263_intra %.3f usec       crc=%d\n", cpu->name, t, s );
583      TEST_QUANT(quant_inter, Dst, Src);                  if (s!=25662) printf( "*** CRC ERROR! ***\n" );
584      printf( "%s -    quant_inter %.3f usec       crc=%d\n", cpu->name, t, s );  
585      if (s!=58056) printf( "*** CRC ERROR! ***\n" );                  TEST_QUANT(quant_h263_inter, Dst, Src);
586                    printf( "%s -   quant_h263_inter %.3f usec       crc=%d\n", cpu->name, t, s );
587      TEST_QUANT2(dequant_intra, Dst, Src, 7);                  if (s!=23972) printf( "*** CRC ERROR! ***\n" );
588      printf( "%s -  dequant_intra %.3f usec       crc=%d\n", cpu->name, t, s );  #endif
589      if (s!=-7936) printf( "*** CRC ERROR! ***\n" );  #if 1
590                    TEST_QUANT2(dequant_h263_intra, Dst, Src);
591      TEST_QUANT(dequant_inter, Dst, Src);                  printf( "%s - dequant_h263_intra %.3f usec       crc=%d\n", cpu->name, t, s );
592      printf( "%s -  dequant_inter %.3f usec       crc=%d\n", cpu->name, t, s );                  if (s!=49900) printf( "*** CRC ERROR! ***\n" );
593  //    { int k,l; for(k=0; k<8; ++k) { for(l=0; l<8; ++l) printf( "[%.4d]", Dst[k*8+l]); printf("\n"); } }  
594      if (s!=-33217) printf( "*** CRC ERROR! ***\n" );                  TEST_QUANT(dequant_h263_inter, Dst, Src);
595                    printf( "%s - dequant_h263_inter %.3f usec       crc=%d\n", cpu->name, t, s );
596                    if (s!=48899) printf( "*** CRC ERROR! ***\n" );
597    #endif
598      printf( " --- \n" );      printf( " --- \n" );
599    }    }
600  }  }
# Line 573  Line 622 
622    printf( "\n =====  test cbp =====\n" );    printf( "\n =====  test cbp =====\n" );
623    
624    for(i=0; i<6*64; ++i) {    for(i=0; i<6*64; ++i) {
625      Src1[i] = (i*i*3/8192)&(i/64)&1;  // 'random'                  Src1[i] = (i*i*3/8192)&(i/64)&1;  /* 'random' */
626      Src2[i] = (i<3*64);               // half-full                  Src2[i] = (i<3*64);               /* half-full */
627      Src3[i] = ((i+32)>3*64);      Src3[i] = ((i+32)>3*64);
628      Src4[i] = (i==(3*64+2) || i==(5*64+9));      Src4[i] = (i==(3*64+2) || i==(5*64+9));
629    }    }
630    
631    for(cpu = cpu_short_list2; cpu->name!=0; ++cpu)          for(cpu = cpu_list; cpu->name!=0; ++cpu)
632    {    {
633      double t;      double t;
634      int tst, cbp;      int tst, cbp;
# Line 604  Line 653 
653  }  }
654    
655  /*********************************************************************  /*********************************************************************
656     * fdct/idct IEEE1180 compliance
657     *********************************************************************/
658    
659    typedef struct {
660            long Errors[64];
661            long Sqr_Errors[64];
662            long Max_Errors[64];
663            long Nb;
664    } STATS_8x8;
665    
666    void init_stats(STATS_8x8 *S)
667    {
668            int i;
669            for(i=0; i<64; ++i) {
670                    S->Errors[i]     = 0;
671                    S->Sqr_Errors[i] = 0;
672                    S->Max_Errors[i] = 0;
673            }
674            S->Nb = 0;
675    }
676    
677    void store_stats(STATS_8x8 *S, short Blk[64], short Ref[64])
678    {
679            int i;
680            for(i=0; i<64; ++i)
681            {
682                    short Err = Blk[i] - Ref[i];
683                    S->Errors[i] += Err;
684                    S->Sqr_Errors[i] += Err * Err;
685                    if (Err<0) Err = -Err;
686                    if (S->Max_Errors[i]<Err)
687                            S->Max_Errors[i] = Err;
688            }
689            S->Nb++;
690    }
691    
692    void print_stats(STATS_8x8 *S)
693    {
694            int i;
695            double Norm;
696    
697            assert(S->Nb>0);
698            Norm = 1. / (double)S->Nb;
699            printf("\n== Max absolute values of errors ==\n");
700            for(i=0; i<64; i++) {
701                    printf("  %4ld", S->Max_Errors[i]);
702                    if ((i&7)==7) printf("\n");
703            }
704    
705            printf("\n== Mean square errors ==\n");
706            for(i=0; i<64; i++)
707            {
708                    double Err = Norm * (double)S->Sqr_Errors[i];
709                    printf(" %.3f", Err);
710                    if ((i&7)==7) printf("\n");
711            }
712    
713            printf("\n== Mean errors ==\n");
714            for(i=0; i<64; i++)
715            {
716                    double Err = Norm * (double)S->Errors[i];
717                    printf(" %.3f", Err);
718                    if ((i&7)==7) printf("\n");
719            }
720            printf("\n");
721    }
722    
723    static const char *CHECK(double v, double l) {
724            if (fabs(v)<=l) return "ok";
725            else return "FAIL!";
726    }
727    
728    void report_stats(STATS_8x8 *S, const double *Limits)
729    {
730            int i;
731            double Norm, PE, PMSE, OMSE, PME, OME;
732    
733            assert(S->Nb>0);
734            Norm = 1. / (double)S->Nb;
735            PE = 0.;
736            for(i=0; i<64; i++) {
737                    if (PE<S->Max_Errors[i])
738                            PE = S->Max_Errors[i];
739            }
740    
741            PMSE = 0.;
742            OMSE = 0.;
743            for(i=0; i<64; i++)
744            {
745                    double Err = Norm * (double)S->Sqr_Errors[i];
746                    OMSE += Err;
747                    if (PMSE < Err) PMSE = Err;
748            }
749            OMSE /= 64.;
750    
751            PME = 0.;
752            OME = 0.;
753            for(i=0; i<64; i++)
754            {
755                    double Err = Norm * (double)S->Errors[i];
756                    OME += Err;
757                    Err = fabs(Err);
758                    if (PME < Err) PME = Err;
759            }
760            OME /= 64.;
761    
762            printf( "Peak error:   %4.4f\n", PE );
763            printf( "Peak MSE:     %4.4f\n", PMSE );
764            printf( "Overall MSE:  %4.4f\n", OMSE );
765            printf( "Peak ME:      %4.4f\n", PME );
766            printf( "Overall ME:   %4.4f\n", OME );
767    
768            if (Limits!=0)
769            {
770                    printf( "[PE<=%.4f %s]  ", Limits[0], CHECK(PE,   Limits[0]) );
771                    printf( "\n" );
772                    printf( "[PMSE<=%.4f %s]", Limits[1], CHECK(PMSE, Limits[1]) );
773                    printf( "[OMSE<=%.4f %s]", Limits[2], CHECK(OMSE, Limits[2]) );
774                    printf( "\n" );
775                    printf( "[PME<=%.4f %s] ", Limits[3], CHECK(PME , Limits[3]) );
776                    printf( "[OME<=%.4f %s] ", Limits[4], CHECK(OME , Limits[4]) );
777                    printf( "\n" );
778            }
779    }
780    
781    ///* ////////////////////////////////////////////////////// */
782    /* Pseudo-random generator specified by IEEE 1180 */
783    
784    static long ieee_seed = 1;
785    static void ieee_reseed(long s) {
786            ieee_seed = s;
787    }
788    static long ieee_rand(int Min, int Max)
789    {
790            static double z = (double) 0x7fffffff;
791    
792            long i,j;
793            double x;
794    
795            ieee_seed = (ieee_seed * 1103515245) + 12345;
796            i = ieee_seed & 0x7ffffffe;
797            x = ((double) i) / z;
798            x *= (Max-Min+1);
799            j = (long)x;
800            j = j + Min;
801            assert(j>=Min && j<=Max);
802            return (short)j;
803    }
804    
805    #define CLAMP(x, M)   (x) = ((x)<-(M)) ? (-(M)) : ((x)>=(M) ? ((M)-1) : (x))
806    
807    static double Cos[8][8];
808    static void init_ref_dct()
809    {
810            int i, j;
811            for(i=0; i<8; i++)
812            {
813                    double scale = (i == 0) ? sqrt(0.125) : 0.5;
814                    for (j=0; j<8; j++)
815                            Cos[i][j] = scale*cos( (M_PI/8.0)*i*(j + 0.5) );
816            }
817    }
818    
819    void ref_idct(short *M)
820    {
821            int i, j, k;
822            double Tmp[8][8];
823    
824            for(i=0; i<8; i++) {
825                    for(j=0; j<8; j++)
826                    {
827                            double Sum = 0.0;
828                            for (k=0; k<8; k++) Sum += Cos[k][j]*M[8*i+k];
829                            Tmp[i][j] = Sum;
830                    }
831            }
832            for(i=0; i<8; i++) {
833                    for(j=0; j<8; j++) {
834                            double Sum = 0.0;
835                            for (k=0; k<8; k++) Sum += Cos[k][i]*Tmp[k][j];
836                            M[8*i+j] = (short)floor(Sum + .5);
837                    }
838            }
839    }
840    
841    void ref_fdct(short *M)
842    {
843            int i, j, k;
844            double Tmp[8][8];
845    
846            for(i=0; i<8; i++) {
847                    for(j=0; j<8; j++)
848                    {
849                            double Sum = 0.0;
850                            for (k=0; k<8; k++) Sum += Cos[j][k]*M[8*i+k];
851                            Tmp[i][j] = Sum;
852                    }
853            }
854            for(i=0; i<8; i++) {
855                    for(j=0; j<8; j++) {
856                            double Sum = 0.0;
857                            for (k=0; k<8; k++) Sum += Cos[i][k]*Tmp[k][j];
858                            M[8*i+j] = (short)floor(Sum + 0.5);
859                    }
860            }
861    }
862    
863    void test_IEEE1180_compliance(int Min, int Max, int Sign)
864    {
865            static const double ILimits[5] = { 1., 0.06, 0.02, 0.015, 0.0015 };
866            int Loops = 10000;
867            int i, m, n;
868            short Blk0[64];     /* reference */
869            short Blk[64], iBlk[64];
870            short Ref_FDCT[64];
871            short Ref_IDCT[64];
872    
873            STATS_8x8 FStats; /* forward dct stats */
874            STATS_8x8 IStats; /* inverse dct stats */
875    
876            CPU *cpu;
877    
878            init_ref_dct();
879    
880            for(cpu = cpu_list; cpu->name!=0; ++cpu)
881            {
882                    if (!init_cpu(cpu))
883                            continue;
884    
885                    printf( "\n===== IEEE test for %s ==== (Min=%d Max=%d Sign=%d Loops=%d)\n",
886                                    cpu->name, Min, Max, Sign, Loops);
887    
888                    init_stats(&IStats);
889                    init_stats(&FStats);
890    
891                    ieee_reseed(1);
892                    for(n=0; n<Loops; ++n)
893                    {
894                            for(i=0; i<64; ++i)
895                                    Blk0[i] = (short)ieee_rand(Min,Max) * Sign;
896    
897                            /* hmm, I'm not quite sure this is exactly */
898                            /* the tests described in the norm. check... */
899    
900                            memcpy(Ref_FDCT, Blk0, 64*sizeof(short));
901                            ref_fdct(Ref_FDCT);
902                            for(i=0; i<64; i++) CLAMP( Ref_FDCT[i], 2048 );
903    
904                            memcpy(Blk, Blk0, 64*sizeof(short));
905                            emms(); fdct(Blk); emms();
906                            for(i=0; i<64; i++) CLAMP( Blk[i], 2048 );
907    
908                            store_stats(&FStats, Blk, Ref_FDCT);
909    
910    
911                            memcpy(Ref_IDCT, Ref_FDCT, 64*sizeof(short));
912                            ref_idct(Ref_IDCT);
913                            for (i=0; i<64; i++) CLAMP( Ref_IDCT[i], 256 );
914    
915                            memcpy(iBlk, Ref_FDCT, 64*sizeof(short));
916                            emms(); idct(iBlk); emms();
917                            for(i=0; i<64; i++) CLAMP( iBlk[i], 256 );
918    
919                            store_stats(&IStats, iBlk, Ref_IDCT);
920                    }
921    
922    
923                    printf( "\n  -- FDCT report --\n" );
924    //    print_stats(&FStats);
925                    report_stats(&FStats, 0); /* so far I know, IEEE1180 says nothing for fdct */
926    
927                    for(i=0; i<64; i++) Blk[i] = 0;
928                    emms(); fdct(Blk); emms();
929                    for(m=i=0; i<64; i++) if (Blk[i]!=0) m++;
930                    printf( "FDCT(0) == 0 ?  %s\n", (m!=0) ? "NOPE!" : "yup." );
931    
932                    printf( "\n  -- IDCT report --\n" );
933    //    print_stats(&IStats);
934                    report_stats(&IStats, ILimits);
935    
936    
937                    for(i=0; i<64; i++) Blk[i] = 0;
938                    emms(); idct(Blk); emms();
939                    for(m=i=0; i<64; i++) if (Blk[i]!=0) m++;
940                    printf( "IDCT(0) == 0 ?  %s\n", (m!=0) ? "NOPE!" : "yup." );
941            }
942    }
943    
944    
945    void test_dct_saturation(int Min, int Max)
946    {
947    /* test behaviour on input range fringe */
948    
949            int i, n, p;
950            CPU *cpu;
951    //  const short IDCT_MAX =  2047;  /* 12bits input */
952    //  const short IDCT_MIN = -2048;
953    //  const short IDCT_OUT =   256;  /* 9bits ouput */
954            const int Partitions = 4;
955            const int Loops = 10000 / Partitions;
956    
957            init_ref_dct();
958    
959            for(cpu = cpu_list; cpu->name!=0; ++cpu)
960            {
961                    short Blk0[64], Blk[64];
962                    STATS_8x8 Stats;
963    
964                    if (!init_cpu(cpu))
965                            continue;
966    
967                    printf( "\n===== IEEE test for %s Min=%d Max=%d =====\n",
968                                    cpu->name, Min, Max );
969    
970                    /* FDCT tests // */
971    
972                    init_stats(&Stats);
973    
974                    /* test each computation channels separately */
975                    for(i=0; i<64; i++) Blk[i] = Blk0[i] = ((i/8)==(i%8)) ? Max : 0;
976                    ref_fdct(Blk0);
977                    emms(); fdct(Blk); emms();
978                    store_stats(&Stats, Blk, Blk0);
979    
980                    for(i=0; i<64; i++) Blk[i] = Blk0[i] = ((i/8)==(i%8)) ? Min : 0;
981                    ref_fdct(Blk0);
982                    emms(); fdct(Blk); emms();
983                    store_stats(&Stats, Blk, Blk0);
984    
985                    /* randomly saturated inputs */
986                    for(p=0; p<Partitions; ++p)
987                    {
988                            for(n=0; n<Loops; ++n)
989                            {
990                                    for(i=0; i<64; ++i)
991                                            Blk0[i] = Blk[i] = (ieee_rand(0,Partitions)>=p)? Max : Min;
992                                    ref_fdct(Blk0);
993                                    emms(); fdct(Blk); emms();
994                                    store_stats(&Stats, Blk, Blk0);
995                            }
996                    }
997                    printf( "\n  -- FDCT saturation report --\n" );
998                    report_stats(&Stats, 0);
999    
1000    
1001                    /* IDCT tests // */
1002    #if 0
1003                    /* no finished yet */
1004    
1005                    init_stats(&Stats);
1006    
1007    /* test each computation channel separately */
1008                    for(i=0; i<64; i++) Blk[i] = Blk0[i] = ((i/8)==(i%8)) ? IDCT_MAX : 0;
1009                    ref_idct(Blk0);
1010                    emms(); idct(Blk); emms();
1011                    for(i=0; i<64; i++) { CLAMP(Blk0[i], IDCT_OUT); CLAMP(Blk[i], IDCT_OUT); }
1012                    store_stats(&Stats, Blk, Blk0);
1013    
1014                    for(i=0; i<64; i++) Blk[i] = Blk0[i] = ((i/8)==(i%8)) ? IDCT_MIN : 0;
1015                    ref_idct(Blk0);
1016                    emms(); idct(Blk); emms();
1017                    for(i=0; i<64; i++) { CLAMP(Blk0[i], IDCT_OUT); CLAMP(Blk[i], IDCT_OUT); }
1018                    store_stats(&Stats, Blk, Blk0);
1019    
1020                    /* randomly saturated inputs */
1021                    for(p=0; p<Partitions; ++p)
1022                    {
1023                            for(n=0; n<Loops; ++n)
1024                            {
1025                                    for(i=0; i<64; ++i)
1026                                            Blk0[i] = Blk[i] = (ieee_rand(0,Partitions)>=p)? IDCT_MAX : IDCT_MIN;
1027                                    ref_idct(Blk0);
1028                                    emms(); idct(Blk); emms();
1029                                    for(i=0; i<64; i++) { CLAMP(Blk0[i],IDCT_OUT); CLAMP(Blk[i],IDCT_OUT); }
1030                                    store_stats(&Stats, Blk, Blk0);
1031                            }
1032                    }
1033    
1034                    printf( "\n  -- IDCT saturation report --\n" );
1035                    print_stats(&Stats);
1036                    report_stats(&Stats, 0);
1037    #endif
1038            }
1039    }
1040    
1041    /*********************************************************************
1042   * measure raw decoding speed   * measure raw decoding speed
1043   *********************************************************************/   *********************************************************************/
1044    
# Line 612  Line 1047 
1047    FILE *f = 0;    FILE *f = 0;
1048    void *dechandle = 0;    void *dechandle = 0;
1049    int xerr;    int xerr;
1050          XVID_INIT_PARAM xinit;          xvid_gbl_init_t xinit;
1051          XVID_DEC_PARAM xparam;          xvid_dec_create_t xparam;
1052          XVID_DEC_FRAME xframe;          xvid_dec_frame_t xframe;
1053          double t = 0.;          double t = 0.;
1054          int nb = 0;          int nb = 0;
1055    uint8_t *buf = 0;    uint8_t *buf = 0;
# Line 622  Line 1057 
1057    int buf_size, pos;    int buf_size, pos;
1058    uint32_t chksum = 0;    uint32_t chksum = 0;
1059    
1060          xinit.cpu_flags = 0;          memset(&xinit, 0, sizeof(xinit));
1061          xvid_init(NULL, 0, &xinit, NULL);          xinit.cpu_flags = XVID_CPU_MMX | XVID_CPU_FORCE;
1062          printf( "API version: %d, core build:%d\n", xinit.api_version, xinit.core_build);          xinit.version = XVID_VERSION;
1063            xvid_global(NULL, 0, &xinit, NULL);
1064    
1065            memset(&xparam, 0, sizeof(xparam));
1066          xparam.width = width;          xparam.width = width;
1067          xparam.height = height;          xparam.height = height;
1068            xparam.version = XVID_VERSION;
1069          xerr = xvid_decore(NULL, XVID_DEC_CREATE, &xparam, NULL);          xerr = xvid_decore(NULL, XVID_DEC_CREATE, &xparam, NULL);
1070          if (xerr!=XVID_ERR_OK) {          if (xerr==XVID_ERR_FAIL) {
1071            printf("can't init decoder (err=%d)\n", xerr);            printf("can't init decoder (err=%d)\n", xerr);
1072            return;            return;
1073          }          }
# Line 651  Line 1088 
1088    }    }
1089    else printf( "Input size: %d\n", buf_size);    else printf( "Input size: %d\n", buf_size);
1090    
1091    buf = malloc(buf_size); // should be enuf'          buf = malloc(buf_size); /* should be enuf' */
1092    rgb_out = calloc(4, width*height);  // <-room for _RGB24          rgb_out = calloc(4, width*height);  /* <-room for _RGB24 */
1093    if (buf==0 || rgb_out==0) {    if (buf==0 || rgb_out==0) {
1094      printf( "malloc failed!\n" );      printf( "malloc failed!\n" );
1095      goto End;      goto End;
# Line 667  Line 1104 
1104    pos = 0;    pos = 0;
1105    t = -gettime_usec();    t = -gettime_usec();
1106    while(1) {    while(1) {
1107                    memset(&xframe, 0, sizeof(xframe));
1108                    xframe.version = XVID_VERSION;
1109      xframe.bitstream = buf + pos;      xframe.bitstream = buf + pos;
1110      xframe.length = buf_size - pos;      xframe.length = buf_size - pos;
1111      xframe.image = rgb_out;                  xframe.output.plane[0] = rgb_out;
1112      xframe.stride = width;                  xframe.output.stride[0] = width;
1113      xframe.colorspace = XVID_CSP_RGB24;                  xframe.output.csp = XVID_CSP_BGR;
1114      xerr = xvid_decore(dechandle, XVID_DEC_DECODE, &xframe, 0);      xerr = xvid_decore(dechandle, XVID_DEC_DECODE, &xframe, 0);
1115      nb++;      nb++;
1116      pos += xframe.length;      pos += xframe.length;
# Line 682  Line 1121 
1121      }      }
1122      if (pos==buf_size)      if (pos==buf_size)
1123        break;        break;
1124      if (xerr!=XVID_ERR_OK) {                  if (xerr==XVID_ERR_FAIL) {
1125            printf("decoding failed for frame #%d (err=%d)!\n", nb, xerr);            printf("decoding failed for frame #%d (err=%d)!\n", nb, xerr);
1126            break;            break;
1127          }          }
# Line 698  Line 1137 
1137    if (buf!=0) free(buf);    if (buf!=0) free(buf);
1138    if (dechandle!=0) {    if (dechandle!=0) {
1139      xerr= xvid_decore(dechandle, XVID_DEC_DESTROY, NULL, NULL);      xerr= xvid_decore(dechandle, XVID_DEC_DESTROY, NULL, NULL);
1140      if (xerr!=XVID_ERR_OK)                  if (xerr==XVID_ERR_FAIL)
1141              printf("destroy-decoder failed (err=%d)!\n", xerr);              printf("destroy-decoder failed (err=%d)!\n", xerr);
1142    }    }
1143    if (f!=0) fclose(f);    if (f!=0) fclose(f);
# Line 714  Line 1153 
1153    
1154    printf( "\n =====  (de)quant4_intra saturation bug? =====\n" );    printf( "\n =====  (de)quant4_intra saturation bug? =====\n" );
1155    
1156    for(cpu = cpu_short_list; cpu->name!=0; ++cpu)          for(cpu = cpu_list; cpu->name!=0; ++cpu)
1157    {    {
1158      int i;      int i;
1159      int16_t  Src[8*8], Dst[8*8];      int16_t  Src[8*8], Dst[8*8];
# Line 724  Line 1163 
1163    
1164      for(i=0; i<64; ++i) Src[i] = i-32;      for(i=0; i<64; ++i) Src[i] = i-32;
1165      set_intra_matrix( get_default_intra_matrix() );      set_intra_matrix( get_default_intra_matrix() );
1166      dequant4_intra(Dst, Src, 32, 5);                  dequant_mpeg_intra(Dst, Src, 31, 5);
1167      printf( "dequant4_intra with CPU=%s:  ", cpu->name);                  printf( "dequant_mpeg_intra with CPU=%s:  ", cpu->name);
1168      printf( "  Out[]= " );      printf( "  Out[]= " );
1169      for(i=0; i<64; ++i) printf( "[%d]", Dst[i]);      for(i=0; i<64; ++i) printf( "[%d]", Dst[i]);
1170      printf( "\n" );      printf( "\n" );
# Line 733  Line 1172 
1172    
1173    printf( "\n =====  (de)quant4_inter saturation bug? =====\n" );    printf( "\n =====  (de)quant4_inter saturation bug? =====\n" );
1174    
1175    for(cpu = cpu_short_list; cpu->name!=0; ++cpu)          for(cpu = cpu_list; cpu->name!=0; ++cpu)
1176    {    {
1177      int i;      int i;
1178      int16_t  Src[8*8], Dst[8*8];      int16_t  Src[8*8], Dst[8*8];
# Line 743  Line 1182 
1182    
1183      for(i=0; i<64; ++i) Src[i] = i-32;      for(i=0; i<64; ++i) Src[i] = i-32;
1184      set_inter_matrix( get_default_inter_matrix() );      set_inter_matrix( get_default_inter_matrix() );
1185      dequant4_inter(Dst, Src, 32);                  dequant_mpeg_inter(Dst, Src, 31);
1186      printf( "dequant4_inter with CPU=%s:  ", cpu->name);                  printf( "dequant_mpeg_inter with CPU=%s:  ", cpu->name);
1187      printf( "  Out[]= " );      printf( "  Out[]= " );
1188      for(i=0; i<64; ++i) printf( "[%d]", Dst[i]);      for(i=0; i<64; ++i) printf( "[%d]", Dst[i]);
1189      printf( "\n" );      printf( "\n" );
# Line 756  Line 1195 
1195    CPU *cpu;    CPU *cpu;
1196    short Blk[8*8], Blk0[8*8];    short Blk[8*8], Blk0[8*8];
1197    
1198    printf( "\n =====  fdct/idct saturation diffs =====\n" );          printf( "\n =====  fdct/idct precision diffs =====\n" );
1199    
1200    for(cpu = cpu_short_list; cpu->name!=0; ++cpu)          for(cpu = cpu_list; cpu->name!=0; ++cpu)
1201    {    {
1202      int i;      int i;
1203    
# Line 782  Line 1221 
1221    }    }
1222  }  }
1223    
1224    void test_quant_bug()
1225    {
1226            const int max_Q = 31;
1227            int i, n, qm, q;
1228            CPU *cpu;
1229            int16_t  Src[8*8], Dst[8*8];
1230            uint8_t Quant[8*8];
1231            CPU cpu_bug_list[] = { { "PLAINC", 0 }, { "MMX   ", XVID_CPU_MMX }, {0,0} };
1232            uint16_t Crcs_Inter[2][32];
1233            uint16_t Crcs_Intra[2][32];
1234            printf( "\n =====  test MPEG4-quantize bug =====\n" );
1235    
1236            for(i=0; i<64; ++i) Src[i] = 2048*(i-32)/32;
1237    
1238    #if 1
1239            for(qm=1; qm<=255; ++qm)
1240            {
1241                    for(i=0; i<8*8; ++i) Quant[i] = qm;
1242                    set_inter_matrix( Quant );
1243    
1244                    for(n=0, cpu = cpu_bug_list; cpu->name!=0; ++cpu, ++n)
1245                    {
1246                            uint16_t s;
1247    
1248                            if (!init_cpu(cpu))
1249                                    continue;
1250    
1251                            for(q=1; q<=max_Q; ++q) {
1252                                    emms();
1253                                    quant_mpeg_inter( Dst, Src, q );
1254                                    emms();
1255                                    for(s=0, i=0; i<64; ++i) s+=((uint16_t)Dst[i])^i;
1256                                    Crcs_Inter[n][q] = s;
1257                            }
1258                    }
1259    
1260                    for(q=1; q<=max_Q; ++q)
1261                            for(i=0; i<n-1; ++i)
1262                                    if (Crcs_Inter[i][q]!=Crcs_Inter[i+1][q])
1263                                            printf( "Discrepancy Inter: qm=%d, q=%d  -> %d/%d !\n",
1264                                                            qm, q, Crcs_Inter[i][q], Crcs_Inter[i+1][q]);
1265            }
1266    #endif
1267    
1268    #if 1
1269            for(qm=1; qm<=255; ++qm)
1270            {
1271                    for(i=0; i<8*8; ++i) Quant[i] = qm;
1272                    set_intra_matrix( Quant );
1273    
1274                    for(n=0, cpu = cpu_bug_list; cpu->name!=0; ++cpu, ++n)
1275                    {
1276                            uint16_t s;
1277    
1278                            if (!init_cpu(cpu))
1279                                    continue;
1280    
1281                            for(q=1; q<=max_Q; ++q) {
1282                                    emms();
1283                                    quant_mpeg_intra( Dst, Src, q, q);
1284                                    emms();
1285                                    for(s=0, i=0; i<64; ++i) s+=((uint16_t)Dst[i])^i;
1286                                    Crcs_Intra[n][q] = s;
1287                            }
1288                    }
1289    
1290                    for(q=1; q<=max_Q; ++q)
1291                            for(i=0; i<n-1; ++i)
1292                                    if (Crcs_Intra[i][q]!=Crcs_Intra[i+1][q])
1293                                            printf( "Discrepancy Intra: qm=%d, q=%d  -> %d/%d!\n",
1294                                                            qm, q, Crcs_Inter[i][q], Crcs_Inter[i+1][q]);
1295            }
1296    #endif
1297    }
1298    
1299  /*********************************************************************  /*********************************************************************
1300   * main   * main
# Line 798  Line 1311 
1311    if (what==0 || what==5) test_quant();    if (what==0 || what==5) test_quant();
1312    if (what==0 || what==6) test_cbp();    if (what==0 || what==6) test_cbp();
1313    
1314    if (what==8) {          if (what==7) {
1315                    test_IEEE1180_compliance(-256, 255, 1);
1316    #if 0
1317                    test_IEEE1180_compliance(-256, 255,-1);
1318                    test_IEEE1180_compliance(  -5,   5, 1);
1319                    test_IEEE1180_compliance(  -5,   5,-1);
1320                    test_IEEE1180_compliance(-300, 300, 1);
1321                    test_IEEE1180_compliance(-300, 300,-1);
1322    #endif
1323            }
1324            if (what==8) test_dct_saturation(-256, 255);
1325    
1326            if (what==9) {
1327      int width, height;      int width, height;
1328      if (argc<5) {      if (argc<5) {
1329        printf("usage: %s %d [bitstream] [width] [height]\n", argv[0], what);        printf("usage: %s %d [bitstream] [width] [height]\n", argv[0], what);
# Line 810  Line 1335 
1335    }    }
1336    
1337    if (what==-1) {    if (what==-1) {
     test_bugs1();  
1338      test_dct_precision_diffs();      test_dct_precision_diffs();
1339                    test_bugs1();
1340    }    }
1341            if (what==-2)
1342                    test_quant_bug();
1343    
1344    return 0;    return 0;
1345  }  }
1346    
1347  /*********************************************************************  /*********************************************************************
1348   * 'Reference' output (except for timing) on a PIII 1.13Ghz/linux   * 'Reference' output (except for timing) on a PIII 1.13Ghz/linux
1349   *********************************************************************/   *********************************************************************/
1350    
1351    /* as of 07/01/2002, there's a problem with mpeg4-quantization */
1352  /*  /*
1353    
1354   ===== test fdct/idct =====   ===== test fdct/idct =====
1355  PLAINC -  2.631 usec       iCrc=3  fCrc=-85  PLAINC -  3.312 usec       PSNR=13.291  MSE=3.000
1356  MMX    -  0.596 usec       iCrc=3  fCrc=-67  MMX    -  0.591 usec       PSNR=13.291  MSE=3.000
1357  MMXEXT -  0.608 usec       iCrc=3  fCrc=-67  MMXEXT -  0.577 usec       PSNR=13.291  MSE=3.000
1358  SSE2   -  0.605 usec       iCrc=3  fCrc=-67  SSE2   -  0.588 usec       PSNR=13.291  MSE=3.000
1359  3DNOW  - skipped...  3DNOW  - skipped...
1360  3DNOWE - skipped...  3DNOWE - skipped...
1361    
1362   ===  test block motion ===   ===  test block motion ===
1363  PLAINC - interp- h-round0 1.031 usec       iCrc=8107  PLAINC - interp- h-round0 0.911 usec       iCrc=8107
1364  PLAINC -           round1 1.022 usec       iCrc=8100  PLAINC -           round1 0.863 usec       iCrc=8100
1365  PLAINC - interp- v-round0 1.002 usec       iCrc=8108  PLAINC - interp- v-round0 0.860 usec       iCrc=8108
1366  PLAINC -           round1 1.011 usec       iCrc=8105  PLAINC -           round1 0.857 usec       iCrc=8105
1367  PLAINC - interp-hv-round0 1.623 usec       iCrc=8112  PLAINC - interp-hv-round0 2.103 usec       iCrc=8112
1368  PLAINC -           round1 1.621 usec       iCrc=8103  PLAINC -           round1 2.050 usec       iCrc=8103
 PLAINC - interpolate8x8_c 0.229 usec       iCrc=8107  
1369   ---   ---
1370  MMX    - interp- h-round0 0.105 usec       iCrc=8107  MMX    - interp- h-round0 0.105 usec       iCrc=8107
1371  MMX    -           round1 0.105 usec       iCrc=8100  MMX    -           round1 0.106 usec       iCrc=8100
1372  MMX    - interp- v-round0 0.106 usec       iCrc=8108  MMX    - interp- v-round0 0.106 usec       iCrc=8108
1373  MMX    -           round1 0.107 usec       iCrc=8105  MMX    -           round1 0.106 usec       iCrc=8105
1374  MMX    - interp-hv-round0 0.145 usec       iCrc=8112  MMX    - interp-hv-round0 0.145 usec       iCrc=8112
1375  MMX    -           round1 0.145 usec       iCrc=8103  MMX    -           round1 0.145 usec       iCrc=8103
 MMX    - interpolate8x8_c 0.229 usec       iCrc=8107  
1376   ---   ---
1377  MMXEXT - interp- h-round0 0.027 usec       iCrc=8107  MMXEXT - interp- h-round0 0.028 usec       iCrc=8107
1378  MMXEXT -           round1 0.041 usec       iCrc=8100  MMXEXT -           round1 0.041 usec       iCrc=8100
1379  MMXEXT - interp- v-round0 0.027 usec       iCrc=8108  MMXEXT - interp- v-round0 0.027 usec       iCrc=8108
1380  MMXEXT -           round1 0.040 usec       iCrc=8105  MMXEXT -           round1 0.041 usec       iCrc=8105
1381  MMXEXT - interp-hv-round0 0.070 usec       iCrc=8112  MMXEXT - interp-hv-round0 0.066 usec       iCrc=8112
1382  MMXEXT -           round1 0.066 usec       iCrc=8103  MMXEXT -           round1 0.065 usec       iCrc=8103
 MMXEXT - interpolate8x8_c 0.027 usec       iCrc=8107  
1383   ---   ---
1384  SSE2   - interp- h-round0 0.106 usec       iCrc=8107  SSE2   - interp- h-round0 0.109 usec       iCrc=8107
1385  SSE2   -           round1 0.105 usec       iCrc=8100  SSE2   -           round1 0.105 usec       iCrc=8100
1386  SSE2   - interp- v-round0 0.106 usec       iCrc=8108  SSE2   - interp- v-round0 0.106 usec       iCrc=8108
1387  SSE2   -           round1 0.106 usec       iCrc=8105  SSE2   -           round1 0.109 usec       iCrc=8105
1388  SSE2   - interp-hv-round0 0.145 usec       iCrc=8112  SSE2   - interp-hv-round0 0.145 usec       iCrc=8112
1389  SSE2   -           round1 0.145 usec       iCrc=8103  SSE2   -           round1 0.145 usec       iCrc=8103
 SSE2   - interpolate8x8_c 0.237 usec       iCrc=8107  
1390   ---   ---
1391  3DNOW  - skipped...  3DNOW  - skipped...
1392  3DNOWE - skipped...  3DNOWE - skipped...
1393    
1394   ======  test SAD ======   ======  test SAD ======
1395  PLAINC - sad8    0.296 usec       sad=3776  PLAINC - sad8    0.251 usec       sad=3776
1396  PLAINC - sad16   1.599 usec       sad=27214  PLAINC - sad16   1.601 usec       sad=27214
1397  PLAINC - sad16bi 2.350 usec       sad=26274  PLAINC - sad16bi 2.371 usec       sad=26274
1398  PLAINC - dev16   1.610 usec       sad=3344  PLAINC - dev16   1.564 usec       sad=3344
1399   ---   ---
1400  MMX    - sad8    0.057 usec       sad=3776  MMX    - sad8    0.057 usec       sad=3776
1401  MMX    - sad16   0.178 usec       sad=27214  MMX    - sad16   0.182 usec       sad=27214
1402  MMX    - sad16bi 2.381 usec       sad=26274  MMX    - sad16bi 2.462 usec       sad=26274
1403  MMX    - dev16   0.312 usec       sad=3344  MMX    - dev16   0.311 usec       sad=3344
1404   ---   ---
1405  MMXEXT - sad8    0.036 usec       sad=3776  MMXEXT - sad8    0.036 usec       sad=3776
1406  MMXEXT - sad16   0.106 usec       sad=27214  MMXEXT - sad16   0.109 usec       sad=27214
1407  MMXEXT - sad16bi 0.182 usec       sad=26274  MMXEXT - sad16bi 0.143 usec       sad=26274
1408  MMXEXT - dev16   0.193 usec       sad=3344  MMXEXT - dev16   0.192 usec       sad=3344
1409   ---   ---
1410  SSE2   - sad8    0.057 usec       sad=3776  SSE2   - sad8    0.057 usec       sad=3776
1411  SSE2   - sad16   0.178 usec       sad=27214  SSE2   - sad16   0.179 usec       sad=27214
1412  SSE2   - sad16bi 2.427 usec       sad=26274  SSE2   - sad16bi 2.456 usec       sad=26274
1413  SSE2   - dev16   0.313 usec       sad=3344  SSE2   - dev16   0.321 usec       sad=3344
1414   ---   ---
1415  3DNOW  - skipped...  3DNOW  - skipped...
1416  3DNOWE - skipped...  3DNOWE - skipped...
1417    
1418   ===  test transfer ===   ===  test transfer ===
1419  PLAINC - 8to16     0.124 usec       crc=28288  PLAINC - 8to16     0.151 usec       crc=28288
1420  PLAINC - 16to8     0.753 usec       crc=28288  PLAINC - 16to8     1.113 usec       crc=28288
1421  PLAINC - 8to8      0.041 usec       crc=20352  PLAINC - 8to8      0.043 usec       crc=20352
1422  PLAINC - 16to8add  0.916 usec       crc=25536  PLAINC - 16to8add  1.069 usec       crc=25536
1423  PLAINC - 8to16sub  0.812 usec       crc1=28064 crc2=16256  PLAINC - 8to16sub  0.631 usec       crc1=28064 crc2=16256
1424  PLAINC - 8to16sub2 0.954 usec       crc=20384  PLAINC - 8to16sub2 0.597 usec       crc=20384
1425   ---  ---
1426  MMX    - 8to16     0.037 usec       crc=28288  MMX    - 8to16     0.032 usec       crc=28288
1427  MMX    - 16to8     0.016 usec       crc=28288  MMX    - 16to8     0.024 usec       crc=28288
1428  MMX    - 8to8      0.018 usec       crc=20352  MMX    - 8to8      0.020 usec       crc=20352
1429  MMX    - 16to8add  0.044 usec       crc=25536  MMX    - 16to8add  0.043 usec       crc=25536
1430  MMX    - 8to16sub  0.065 usec       crc1=28064 crc2=16256  MMX    - 8to16sub  0.066 usec       crc1=28064 crc2=16256
1431  MMX    - 8to16sub2 0.110 usec       crc=20384  MMX    - 8to16sub2 0.111 usec       crc=20384
  ---  
 MMXEXT - 8to16     0.032 usec       crc=28288  
 MMXEXT - 16to8     0.023 usec       crc=28288  
 MMXEXT - 8to8      0.018 usec       crc=20352  
 MMXEXT - 16to8add  0.041 usec       crc=25536  
 MMXEXT - 8to16sub  0.065 usec       crc1=28064 crc2=16256  
 MMXEXT - 8to16sub2 0.069 usec       crc=20384  
1432   ---   ---
1433    
1434   =====  test quant =====   =====  test quant =====
1435  PLAINC -   quant4_intra 78.889 usec       crc=55827  PLAINC -   quant4_intra 74.248 usec       crc=29809
1436  PLAINC -   quant4_inter 71.957 usec       crc=58201  PLAINC -   quant4_inter 70.850 usec       crc=12574
1437  PLAINC - dequant4_intra 34.968 usec       crc=193340  PLAINC - dequant4_intra 40.628 usec       crc=24052
1438  PLAINC - dequant4_inter 40.792 usec       crc=116483  PLAINC - dequant4_inter 45.691 usec       crc=63847
1439  PLAINC -    quant_intra 30.845 usec       crc=56885  PLAINC -    quant_intra 43.357 usec       crc=25662
1440  PLAINC -    quant_inter 34.842 usec       crc=58056  PLAINC -    quant_inter 33.410 usec       crc=23972
1441  PLAINC -  dequant_intra 33.211 usec       crc=-7936  PLAINC -  dequant_intra 36.384 usec       crc=49900
1442  PLAINC -  dequant_inter 45.486 usec       crc=-33217  PLAINC -  dequant_inter 48.930 usec       crc=48899
1443   ---  ---
1444  MMX    -   quant4_intra 9.030 usec       crc=55827  MMX    -   quant4_intra 7.445 usec       crc=3459
1445  MMX    -   quant4_inter 8.234 usec       crc=58201  *** CRC ERROR! ***
1446  MMX    - dequant4_intra 18.330 usec       crc=193340  MMX    -   quant4_inter 5.384 usec       crc=51072
1447  MMX    - dequant4_inter 19.181 usec       crc=116483  *** CRC ERROR! ***
1448  MMX    -    quant_intra 7.124 usec       crc=56885  MMX    - dequant4_intra 5.515 usec       crc=24052
1449  MMX    -    quant_inter 6.861 usec       crc=58056  MMX    - dequant4_inter 7.745 usec       crc=63847
1450  MMX    -  dequant_intra 9.048 usec       crc=-7936  MMX    -    quant_intra 4.661 usec       crc=25662
1451  MMX    -  dequant_inter 8.203 usec       crc=-33217  MMX    -    quant_inter 4.406 usec       crc=23972
1452   ---  MMX    -  dequant_intra 4.928 usec       crc=49900
1453  MMXEXT -   quant4_intra 9.045 usec       crc=55827  MMX    -  dequant_inter 4.532 usec       crc=48899
 MMXEXT -   quant4_inter 8.232 usec       crc=58201  
 MMXEXT - dequant4_intra 18.250 usec       crc=193340  
 MMXEXT - dequant4_inter 19.256 usec       crc=116483  
 MMXEXT -    quant_intra 7.121 usec       crc=56885  
 MMXEXT -    quant_inter 6.855 usec       crc=58056  
 MMXEXT -  dequant_intra 9.034 usec       crc=-7936  
 MMXEXT -  dequant_inter 8.202 usec       crc=-33217  
1454   ---   ---
1455    
1456   =====  test cbp =====   =====  test cbp =====
1457  PLAINC -   calc_cbp#1 0.545 usec       cbp=0x15  PLAINC -   calc_cbp#1 0.371 usec       cbp=0x15
1458  PLAINC -   calc_cbp#2 0.540 usec       cbp=0x38  PLAINC -   calc_cbp#2 0.432 usec       cbp=0x38
1459  PLAINC -   calc_cbp#3 0.477 usec       cbp=0xf  PLAINC -   calc_cbp#3 0.339 usec       cbp=0xf
1460  PLAINC -   calc_cbp#4 0.739 usec       cbp=0x5  PLAINC -   calc_cbp#4 0.506 usec       cbp=0x5
1461   ---   ---
1462  MMX    -   calc_cbp#1 0.136 usec       cbp=0x15  MMX    -   calc_cbp#1 0.136 usec       cbp=0x15
1463  MMX    -   calc_cbp#2 0.131 usec       cbp=0x38  MMX    -   calc_cbp#2 0.134 usec       cbp=0x38
1464  MMX    -   calc_cbp#3 0.132 usec       cbp=0xf  MMX    -   calc_cbp#3 0.138 usec       cbp=0xf
1465  MMX    -   calc_cbp#4 0.135 usec       cbp=0x5  MMX    -   calc_cbp#4 0.135 usec       cbp=0x5
1466   ---   ---
1467  SSE2   -   calc_cbp#1 0.135 usec       cbp=0x15  SSE2   -   calc_cbp#1 0.136 usec       cbp=0x15
1468  SSE2   -   calc_cbp#2 0.131 usec       cbp=0x38  SSE2   -   calc_cbp#2 0.133 usec       cbp=0x38
1469  SSE2   -   calc_cbp#3 0.134 usec       cbp=0xf  SSE2   -   calc_cbp#3 0.133 usec       cbp=0xf
1470  SSE2   -   calc_cbp#4 0.136 usec       cbp=0x5  SSE2   -   calc_cbp#4 0.141 usec       cbp=0x5
1471   ---   ---
1472    
1473  */  */

Legend:
Removed from v.257  
changed lines
  Added in v.1176

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