[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 225, Wed Jun 19 14:27:08 2002 UTC branches/dev-api-4/xvidcore/examples/xvid_bench.c revision 1197, Sun Nov 2 23:02:52 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.6 2003-11-02 23:02:52 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.0e6f + 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  , { 0, 0 } }  #endif
134    //, { "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;
149    XVID_INIT_PARAM xinit;  
150            /* Get the available CPU flags */
151            memset(&xinfo, 0, sizeof(xinfo));
152            xinfo.version = XVID_VERSION;
153            xvid_global(NULL, XVID_GBL_INFO, &xinfo, NULL);
154    
155    cpu_type = check_cpu_features() & cpu->cpu;          /* Are we trying to test a subset of the host CPU features */
156    xinit.cpu_flags = cpu_type | XVID_CPU_FORCE;          if ((xinfo.cpu_flags & cpu->cpu) == cpu->cpu) {
157    //    xinit.cpu_flags = XVID_CPU_MMX | XVID_CPU_FORCE;                  int xerr;
158    xerr = xvid_init(NULL, 0, &xinit, NULL);                  xvid_gbl_init_t xinit;
159    if (cpu->cpu>0 && (cpu_type==0 || xerr!=XVID_ERR_OK)) {                  memset(&xinit, 0, sizeof(xinit));
160      printf( "%s - skipped...\n", cpu->name );                  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 161  Line 199 
199    
200    for(cpu = cpu_list; cpu->name!=0; ++cpu)    for(cpu = cpu_list; cpu->name!=0; ++cpu)
201    {    {
202      double t;                  double t, PSNR, MSE;
     int iCrc, fCrc;  
203    
204      if (!init_cpu(cpu))      if (!init_cpu(cpu))
205        continue;        continue;
# Line 178  Line 215 
215      }      }
216      emms();      emms();
217      t = (gettime_usec() - t - overhead) / nb_tests;      t = (gettime_usec() - t - overhead) / nb_tests;
218      iCrc=0; fCrc=0;                  MSE = 0.;
219      for(i=0; i<8*8; ++i) {      for(i=0; i<8*8; ++i) {
220        iCrc += ABS(iDst[i] - iDst0[i]);                          double delta = 1.0*(iDst[i] - iDst0[i]);
221        fCrc += fDst[i]^i;                          MSE += delta*delta;
222      }      }
223      printf( "%s -  %.3f usec       iCrc=%d  fCrc=%d\n",                  PSNR = (MSE==0.) ? 1.e6 : -4.3429448*log( MSE/64. );
224        cpu->name, t, iCrc, fCrc );                  printf( "%s -  %.3f usec       PSNR=%.3f  MSE=%.3f\n",
225        // the norm tolerates ~1 bit of diff per coeff                                  cpu->name, t, PSNR, MSE );
226      if (ABS(iCrc)>=64) printf( "*** CRC ERROR! ***\n" );                  if (ABS(MSE)>=64) printf( "*** CRC ERROR! ***\n" );
227    }    }
228  }  }
229    
# Line 283  Line 320 
320    const int nb_tests = 2000*speed_ref;    const int nb_tests = 2000*speed_ref;
321    CPU *cpu;    CPU *cpu;
322    const uint8_t Src0[16*9] = {    const uint8_t Src0[16*9] = {
323          // try to have every possible combinaison of rounding...                  /* try to have every possible combinaison of rounding... */
324        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
325      , 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
326      , 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 332  Line 369 
369      printf( "%s -           round1 %.3f usec       iCrc=%d\n", cpu->name, t, iCrc );      printf( "%s -           round1 %.3f usec       iCrc=%d\n", cpu->name, t, iCrc );
370      if (iCrc!=8103) printf( "*** CRC ERROR! ***\n" );      if (iCrc!=8103) printf( "*** CRC ERROR! ***\n" );
371    
372    
373                    /* this is a new function, as of 06.06.2002 */
374    #if 0
375                    TEST_MB2(interpolate8x8_avrg);
376                    printf( "%s - interpolate8x8_c %.3f usec       iCrc=%d\n", cpu->name, t, iCrc );
377                    if (iCrc!=8107) printf( "*** CRC ERROR! ***\n" );
378    #endif
379    
380      printf( " --- \n" );      printf( " --- \n" );
381    }    }
382  }  }
# Line 413  Line 458 
458    
459    printf( "\n ===  test transfer ===\n" );    printf( "\n ===  test transfer ===\n" );
460    
461    for(cpu = cpu_short_list; cpu->name!=0; ++cpu)          for(cpu = cpu_list; cpu->name!=0; ++cpu)
462    {    {
463      double t, overhead;      double t, overhead;
464      int tst, s;      int tst, s;
# Line 443  Line 488 
488      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; }
489      printf( "crc2=%d\n", s);      printf( "crc2=%d\n", s);
490      if (s!=16256) printf( "*** CRC ERROR! ***\n" );      if (s!=16256) printf( "*** CRC ERROR! ***\n" );
491    #if 1
492      TEST_TRANSFER3(transfer_8to16sub2, Dst16, Src8, Ref1, Ref2);      TEST_TRANSFER3(transfer_8to16sub2, Dst16, Src8, Ref1, Ref2);
493      printf( "%s - 8to16sub2 %.3f usec       crc=%d\n", cpu->name, t, s );      printf( "%s - 8to16sub2 %.3f usec       crc=%d\n", cpu->name, t, s );
494      if (s!=20384) printf( "*** CRC ERROR! ***\n" );      if (s!=20384) printf( "*** CRC ERROR! ***\n" );
495    //    for(i=0; i<64; ++i) printf( "[%d]", Dst16[i]);
496    //    printf("\n");
497    #endif
498      printf( " --- \n" );      printf( " --- \n" );
499    }    }
500  }  }
# Line 458  Line 505 
505    
506  #define TEST_QUANT(FUNC, DST, SRC)            \  #define TEST_QUANT(FUNC, DST, SRC)            \
507      t = gettime_usec();                       \      t = gettime_usec();                       \
508    for(s=0,qm=1; qm<=255; ++qm) {              \
509      for(i=0; i<8*8; ++i) Quant[i] = qm;       \
510      set_inter_matrix( Quant );                \
511      emms();                                   \      emms();                                   \
512      for(q=1; q<=max_Q; ++q) {                 \
513      for(tst=0; tst<nb_tests; ++tst)           \      for(tst=0; tst<nb_tests; ++tst)           \
       for(s=0, q=1; q<=max_Q; ++q) {          \  
514          (FUNC)((DST), (SRC), q);              \          (FUNC)((DST), (SRC), q);              \
515          for(i=0; i<64; ++i) s+=(DST)[i]^i;    \          for(i=0; i<64; ++i) s+=(DST)[i]^i^qm;   \
516        }                                       \        }                                       \
517      emms();                                   \      emms();                                   \
518      t = (gettime_usec()-t-overhead)/nb_tests;  }                                           \
519    t = (gettime_usec()-t-overhead)/nb_tests/qm;\
520    s = (s&0xffff)^(s>>16)
521    
522  #define TEST_QUANT2(FUNC, DST, SRC, MULT)     \  #define TEST_QUANT2(FUNC, DST, SRC)             \
523      t = gettime_usec();                       \      t = gettime_usec();                       \
524    for(s=0,qm=1; qm<=255; ++qm) {              \
525      for(i=0; i<8*8; ++i) Quant[i] = qm;       \
526      set_intra_matrix( Quant );                \
527      emms();                                   \      emms();                                   \
528      for(q=1; q<=max_Q; ++q) {                 \
529      for(tst=0; tst<nb_tests; ++tst)           \      for(tst=0; tst<nb_tests; ++tst)           \
530        for(s=0, q=1; q<=max_Q; ++q) {          \            (FUNC)((DST), (SRC), q, q);           \
531          (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;    \  
532        }                                       \        }                                       \
533      emms();                                   \      emms();                                   \
534      t = (gettime_usec()-t-overhead)/nb_tests;  }                                           \
535    t = (gettime_usec()-t-overhead)/nb_tests/qm;\
536    s = (s&0xffff)^(s>>16)
537    
538  void test_quant()  void test_quant()
539  {  {
540    const int nb_tests = 150*speed_ref;          const int nb_tests = 1*speed_ref;
541    const int max_Q = 31;    const int max_Q = 31;
542    int i;          int i, qm;
543    CPU *cpu;    CPU *cpu;
544    int16_t  Src[8*8], Dst[8*8];    int16_t  Src[8*8], Dst[8*8];
545            uint8_t Quant[8*8];
546    
547    printf( "\n =====  test quant =====\n" );    printf( "\n =====  test quant =====\n" );
548    
549    /* we deliberately enfringe the norm's specified range [-127,127], */
550    /* to test the robustness of the iquant module */
551    for(i=0; i<64; ++i) {    for(i=0; i<64; ++i) {
552      Src[i] = i-32;                  Src[i] = 1 + (i-32) * (i&6);
553      Dst[i] = 0;      Dst[i] = 0;
554    }    }
555    
556            for(cpu = cpu_list; cpu->name!=0; ++cpu)
   for(cpu = cpu_short_list; cpu->name!=0; ++cpu)  
557    {    {
558      double t, overhead;      double t, overhead;
559      int tst, s, q;                  int tst, q;
560                    uint32_t s;
561    
562      if (!init_cpu(cpu))      if (!init_cpu(cpu))
563        continue;        continue;
564    
     set_inter_matrix( get_default_inter_matrix() );  
     set_intra_matrix( get_default_intra_matrix() );  
565      overhead = -gettime_usec();      overhead = -gettime_usec();
566      for(tst=0; tst<nb_tests; ++tst)                  for(s=0,qm=1; qm<=255; ++qm) {
567        for(s=0, q=1; q<=max_Q; ++q)                          for(i=0; i<8*8; ++i) Quant[i] = qm;
568          for(i=0; i<64; ++i) s+=Dst[i]^i;                          set_inter_matrix( Quant );
569                            for(q=1; q<=max_Q; ++q)
570                                    for(i=0; i<64; ++i) s+=Dst[i]^i^qm;
571                    }
572      overhead += gettime_usec();      overhead += gettime_usec();
573    
574      TEST_QUANT2(quant4_intra, Dst, Src, 7);  #if 1
575      printf( "%s -   quant4_intra %.3f usec       crc=%d\n", cpu->name, t, s );                  TEST_QUANT2(quant_mpeg_intra, Dst, Src);
576      if (s!=55827) printf( "*** CRC ERROR! ***\n" );                  printf( "%s -   quant_mpeg_intra %.3f usec       crc=%d\n", cpu->name, t, s );
577                    if (s!=29809) printf( "*** CRC ERROR! ***\n" );
578      TEST_QUANT(quant4_inter, Dst, Src);  
579      printf( "%s -   quant4_inter %.3f usec       crc=%d\n", cpu->name, t, s );                  TEST_QUANT(quant_mpeg_inter, Dst, Src);
580      if (s!=58201) printf( "*** CRC ERROR! ***\n" );                  printf( "%s -   quant_mpeg_inter %.3f usec       crc=%d\n", cpu->name, t, s );
581                    if (s!=12574) printf( "*** CRC ERROR! ***\n" );
582    #endif
583      TEST_QUANT2(dequant4_intra, Dst, Src, 7);  #if 1
584      printf( "%s - dequant4_intra %.3f usec       crc=%d\n", cpu->name, t, s );                  TEST_QUANT2(dequant_mpeg_intra, Dst, Src);
585      if (s!=193340) printf( "*** CRC ERROR! ***\n" );                  printf( "%s - dequant_mpeg_intra %.3f usec       crc=%d\n", cpu->name, t, s );
586                    if (s!=24052) printf( "*** CRC ERROR! ***\n" );
587      TEST_QUANT(dequant4_inter, Dst, Src);  
588      printf( "%s - dequant4_inter %.3f usec       crc=%d\n", cpu->name, t, s );                  TEST_QUANT(dequant_mpeg_inter, Dst, Src);
589      if (s!=116483) printf( "*** CRC ERROR! ***\n" );                  printf( "%s - dequant_mpeg_inter %.3f usec       crc=%d\n", cpu->name, t, s );
590                    if (s!=63847) printf( "*** CRC ERROR! ***\n" );
591      TEST_QUANT2(quant_intra, Dst, Src, 7);  #endif
592      printf( "%s -    quant_intra %.3f usec       crc=%d\n", cpu->name, t, s );  #if 1
593      if (s!=56885) printf( "*** CRC ERROR! ***\n" );                  TEST_QUANT2(quant_h263_intra, Dst, Src);
594                    printf( "%s -   quant_h263_intra %.3f usec       crc=%d\n", cpu->name, t, s );
595      TEST_QUANT(quant_inter, Dst, Src);                  if (s!=25662) printf( "*** CRC ERROR! ***\n" );
596      printf( "%s -    quant_inter %.3f usec       crc=%d\n", cpu->name, t, s );  
597      if (s!=58056) printf( "*** CRC ERROR! ***\n" );                  TEST_QUANT(quant_h263_inter, Dst, Src);
598                    printf( "%s -   quant_h263_inter %.3f usec       crc=%d\n", cpu->name, t, s );
599      TEST_QUANT2(dequant_intra, Dst, Src, 7);                  if (s!=23972) printf( "*** CRC ERROR! ***\n" );
600      printf( "%s -  dequant_intra %.3f usec       crc=%d\n", cpu->name, t, s );  #endif
601      if (s!=-7936) printf( "*** CRC ERROR! ***\n" );  #if 1
602                    TEST_QUANT2(dequant_h263_intra, Dst, Src);
603      TEST_QUANT(dequant_inter, Dst, Src);                  printf( "%s - dequant_h263_intra %.3f usec       crc=%d\n", cpu->name, t, s );
604      printf( "%s -  dequant_inter %.3f usec       crc=%d\n", cpu->name, t, s );                  if (s!=49900) printf( "*** CRC ERROR! ***\n" );
605  //    { int k,l; for(k=0; k<8; ++k) { for(l=0; l<8; ++l) printf( "[%.4d]", Dst[k*8+l]); printf("\n"); } }  
606      if (s!=-33217) printf( "*** CRC ERROR! ***\n" );                  TEST_QUANT(dequant_h263_inter, Dst, Src);
607                    printf( "%s - dequant_h263_inter %.3f usec       crc=%d\n", cpu->name, t, s );
608                    if (s!=48899) printf( "*** CRC ERROR! ***\n" );
609    #endif
610      printf( " --- \n" );      printf( " --- \n" );
611    }    }
612  }  }
# Line 571  Line 634 
634    printf( "\n =====  test cbp =====\n" );    printf( "\n =====  test cbp =====\n" );
635    
636    for(i=0; i<6*64; ++i) {    for(i=0; i<6*64; ++i) {
637      Src1[i] = (i*i*3/8192)&(i/64)&1;  // 'random'                  Src1[i] = (i*i*3/8192)&(i/64)&1;  /* 'random' */
638      Src2[i] = (i<3*64);               // half-full                  Src2[i] = (i<3*64);               /* half-full */
639      Src3[i] = ((i+32)>3*64);      Src3[i] = ((i+32)>3*64);
640      Src4[i] = (i==(3*64+2) || i==(5*64+9));      Src4[i] = (i==(3*64+2) || i==(5*64+9));
641    }    }
642    
643    for(cpu = cpu_short_list2; cpu->name!=0; ++cpu)          for(cpu = cpu_list; cpu->name!=0; ++cpu)
644    {    {
645      double t;      double t;
646      int tst, cbp;      int tst, cbp;
# Line 602  Line 665 
665  }  }
666    
667  /*********************************************************************  /*********************************************************************
668     * fdct/idct IEEE1180 compliance
669     *********************************************************************/
670    
671    typedef struct {
672            long Errors[64];
673            long Sqr_Errors[64];
674            long Max_Errors[64];
675            long Nb;
676    } STATS_8x8;
677    
678    void init_stats(STATS_8x8 *S)
679    {
680            int i;
681            for(i=0; i<64; ++i) {
682                    S->Errors[i]     = 0;
683                    S->Sqr_Errors[i] = 0;
684                    S->Max_Errors[i] = 0;
685            }
686            S->Nb = 0;
687    }
688    
689    void store_stats(STATS_8x8 *S, short Blk[64], short Ref[64])
690    {
691            int i;
692            for(i=0; i<64; ++i)
693            {
694                    short Err = Blk[i] - Ref[i];
695                    S->Errors[i] += Err;
696                    S->Sqr_Errors[i] += Err * Err;
697                    if (Err<0) Err = -Err;
698                    if (S->Max_Errors[i]<Err)
699                            S->Max_Errors[i] = Err;
700            }
701            S->Nb++;
702    }
703    
704    void print_stats(STATS_8x8 *S)
705    {
706            int i;
707            double Norm;
708    
709            assert(S->Nb>0);
710            Norm = 1. / (double)S->Nb;
711            printf("\n== Max absolute values of errors ==\n");
712            for(i=0; i<64; i++) {
713                    printf("  %4ld", S->Max_Errors[i]);
714                    if ((i&7)==7) printf("\n");
715            }
716    
717            printf("\n== Mean square errors ==\n");
718            for(i=0; i<64; i++)
719            {
720                    double Err = Norm * (double)S->Sqr_Errors[i];
721                    printf(" %.3f", Err);
722                    if ((i&7)==7) printf("\n");
723            }
724    
725            printf("\n== Mean errors ==\n");
726            for(i=0; i<64; i++)
727            {
728                    double Err = Norm * (double)S->Errors[i];
729                    printf(" %.3f", Err);
730                    if ((i&7)==7) printf("\n");
731            }
732            printf("\n");
733    }
734    
735    static const char *CHECK(double v, double l) {
736            if (fabs(v)<=l) return "ok";
737            else return "FAIL!";
738    }
739    
740    void report_stats(STATS_8x8 *S, const double *Limits)
741    {
742            int i;
743            double Norm, PE, PMSE, OMSE, PME, OME;
744    
745            assert(S->Nb>0);
746            Norm = 1. / (double)S->Nb;
747            PE = 0.;
748            for(i=0; i<64; i++) {
749                    if (PE<S->Max_Errors[i])
750                            PE = S->Max_Errors[i];
751            }
752    
753            PMSE = 0.;
754            OMSE = 0.;
755            for(i=0; i<64; i++)
756            {
757                    double Err = Norm * (double)S->Sqr_Errors[i];
758                    OMSE += Err;
759                    if (PMSE < Err) PMSE = Err;
760            }
761            OMSE /= 64.;
762    
763            PME = 0.;
764            OME = 0.;
765            for(i=0; i<64; i++)
766            {
767                    double Err = Norm * (double)S->Errors[i];
768                    OME += Err;
769                    Err = fabs(Err);
770                    if (PME < Err) PME = Err;
771            }
772            OME /= 64.;
773    
774            printf( "Peak error:   %4.4f\n", PE );
775            printf( "Peak MSE:     %4.4f\n", PMSE );
776            printf( "Overall MSE:  %4.4f\n", OMSE );
777            printf( "Peak ME:      %4.4f\n", PME );
778            printf( "Overall ME:   %4.4f\n", OME );
779    
780            if (Limits!=0)
781            {
782                    printf( "[PE<=%.4f %s]  ", Limits[0], CHECK(PE,   Limits[0]) );
783                    printf( "\n" );
784                    printf( "[PMSE<=%.4f %s]", Limits[1], CHECK(PMSE, Limits[1]) );
785                    printf( "[OMSE<=%.4f %s]", Limits[2], CHECK(OMSE, Limits[2]) );
786                    printf( "\n" );
787                    printf( "[PME<=%.4f %s] ", Limits[3], CHECK(PME , Limits[3]) );
788                    printf( "[OME<=%.4f %s] ", Limits[4], CHECK(OME , Limits[4]) );
789                    printf( "\n" );
790            }
791    }
792    
793    ///* ////////////////////////////////////////////////////// */
794    /* Pseudo-random generator specified by IEEE 1180 */
795    
796    static long ieee_seed = 1;
797    static void ieee_reseed(long s) {
798            ieee_seed = s;
799    }
800    static long ieee_rand(int Min, int Max)
801    {
802            static double z = (double) 0x7fffffff;
803    
804            long i,j;
805            double x;
806    
807            ieee_seed = (ieee_seed * 1103515245) + 12345;
808            i = ieee_seed & 0x7ffffffe;
809            x = ((double) i) / z;
810            x *= (Max-Min+1);
811            j = (long)x;
812            j = j + Min;
813            assert(j>=Min && j<=Max);
814            return (short)j;
815    }
816    
817    #define CLAMP(x, M)   (x) = ((x)<-(M)) ? (-(M)) : ((x)>=(M) ? ((M)-1) : (x))
818    
819    static double Cos[8][8];
820    static void init_ref_dct()
821    {
822            int i, j;
823            for(i=0; i<8; i++)
824            {
825                    double scale = (i == 0) ? sqrt(0.125) : 0.5;
826                    for (j=0; j<8; j++)
827                            Cos[i][j] = scale*cos( (M_PI/8.0)*i*(j + 0.5) );
828            }
829    }
830    
831    void ref_idct(short *M)
832    {
833            int i, j, k;
834            double Tmp[8][8];
835    
836            for(i=0; i<8; i++) {
837                    for(j=0; j<8; j++)
838                    {
839                            double Sum = 0.0;
840                            for (k=0; k<8; k++) Sum += Cos[k][j]*M[8*i+k];
841                            Tmp[i][j] = Sum;
842                    }
843            }
844            for(i=0; i<8; i++) {
845                    for(j=0; j<8; j++) {
846                            double Sum = 0.0;
847                            for (k=0; k<8; k++) Sum += Cos[k][i]*Tmp[k][j];
848                            M[8*i+j] = (short)floor(Sum + .5);
849                    }
850            }
851    }
852    
853    void ref_fdct(short *M)
854    {
855            int i, j, k;
856            double Tmp[8][8];
857    
858            for(i=0; i<8; i++) {
859                    for(j=0; j<8; j++)
860                    {
861                            double Sum = 0.0;
862                            for (k=0; k<8; k++) Sum += Cos[j][k]*M[8*i+k];
863                            Tmp[i][j] = Sum;
864                    }
865            }
866            for(i=0; i<8; i++) {
867                    for(j=0; j<8; j++) {
868                            double Sum = 0.0;
869                            for (k=0; k<8; k++) Sum += Cos[i][k]*Tmp[k][j];
870                            M[8*i+j] = (short)floor(Sum + 0.5);
871                    }
872            }
873    }
874    
875    void test_IEEE1180_compliance(int Min, int Max, int Sign)
876    {
877            static const double ILimits[5] = { 1., 0.06, 0.02, 0.015, 0.0015 };
878            int Loops = 10000;
879            int i, m, n;
880            short Blk0[64];     /* reference */
881            short Blk[64], iBlk[64];
882            short Ref_FDCT[64];
883            short Ref_IDCT[64];
884    
885            STATS_8x8 FStats; /* forward dct stats */
886            STATS_8x8 IStats; /* inverse dct stats */
887    
888            CPU *cpu;
889    
890            init_ref_dct();
891    
892            for(cpu = cpu_list; cpu->name!=0; ++cpu)
893            {
894                    if (!init_cpu(cpu))
895                            continue;
896    
897                    printf( "\n===== IEEE test for %s ==== (Min=%d Max=%d Sign=%d Loops=%d)\n",
898                                    cpu->name, Min, Max, Sign, Loops);
899    
900                    init_stats(&IStats);
901                    init_stats(&FStats);
902    
903                    ieee_reseed(1);
904                    for(n=0; n<Loops; ++n)
905                    {
906                            for(i=0; i<64; ++i)
907                                    Blk0[i] = (short)ieee_rand(Min,Max) * Sign;
908    
909                            /* hmm, I'm not quite sure this is exactly */
910                            /* the tests described in the norm. check... */
911    
912                            memcpy(Ref_FDCT, Blk0, 64*sizeof(short));
913                            ref_fdct(Ref_FDCT);
914                            for(i=0; i<64; i++) CLAMP( Ref_FDCT[i], 2048 );
915    
916                            memcpy(Blk, Blk0, 64*sizeof(short));
917                            emms(); fdct(Blk); emms();
918                            for(i=0; i<64; i++) CLAMP( Blk[i], 2048 );
919    
920                            store_stats(&FStats, Blk, Ref_FDCT);
921    
922    
923                            memcpy(Ref_IDCT, Ref_FDCT, 64*sizeof(short));
924                            ref_idct(Ref_IDCT);
925                            for (i=0; i<64; i++) CLAMP( Ref_IDCT[i], 256 );
926    
927                            memcpy(iBlk, Ref_FDCT, 64*sizeof(short));
928                            emms(); idct(iBlk); emms();
929                            for(i=0; i<64; i++) CLAMP( iBlk[i], 256 );
930    
931                            store_stats(&IStats, iBlk, Ref_IDCT);
932                    }
933    
934    
935                    printf( "\n  -- FDCT report --\n" );
936    //    print_stats(&FStats);
937                    report_stats(&FStats, 0); /* so far I know, IEEE1180 says nothing for fdct */
938    
939                    for(i=0; i<64; i++) Blk[i] = 0;
940                    emms(); fdct(Blk); emms();
941                    for(m=i=0; i<64; i++) if (Blk[i]!=0) m++;
942                    printf( "FDCT(0) == 0 ?  %s\n", (m!=0) ? "NOPE!" : "yup." );
943    
944                    printf( "\n  -- IDCT report --\n" );
945    //    print_stats(&IStats);
946                    report_stats(&IStats, ILimits);
947    
948    
949                    for(i=0; i<64; i++) Blk[i] = 0;
950                    emms(); idct(Blk); emms();
951                    for(m=i=0; i<64; i++) if (Blk[i]!=0) m++;
952                    printf( "IDCT(0) == 0 ?  %s\n", (m!=0) ? "NOPE!" : "yup." );
953            }
954    }
955    
956    
957    void test_dct_saturation(int Min, int Max)
958    {
959    /* test behaviour on input range fringe */
960    
961            int i, n, p;
962            CPU *cpu;
963    //  const short IDCT_MAX =  2047;  /* 12bits input */
964    //  const short IDCT_MIN = -2048;
965    //  const short IDCT_OUT =   256;  /* 9bits ouput */
966            const int Partitions = 4;
967            const int Loops = 10000 / Partitions;
968    
969            init_ref_dct();
970    
971            for(cpu = cpu_list; cpu->name!=0; ++cpu)
972            {
973                    short Blk0[64], Blk[64];
974                    STATS_8x8 Stats;
975    
976                    if (!init_cpu(cpu))
977                            continue;
978    
979                    printf( "\n===== IEEE test for %s Min=%d Max=%d =====\n",
980                                    cpu->name, Min, Max );
981    
982                    /* FDCT tests // */
983    
984                    init_stats(&Stats);
985    
986                    /* test each computation channels separately */
987                    for(i=0; i<64; i++) Blk[i] = Blk0[i] = ((i/8)==(i%8)) ? Max : 0;
988                    ref_fdct(Blk0);
989                    emms(); fdct(Blk); emms();
990                    store_stats(&Stats, Blk, Blk0);
991    
992                    for(i=0; i<64; i++) Blk[i] = Blk0[i] = ((i/8)==(i%8)) ? Min : 0;
993                    ref_fdct(Blk0);
994                    emms(); fdct(Blk); emms();
995                    store_stats(&Stats, Blk, Blk0);
996    
997                    /* randomly saturated inputs */
998                    for(p=0; p<Partitions; ++p)
999                    {
1000                            for(n=0; n<Loops; ++n)
1001                            {
1002                                    for(i=0; i<64; ++i)
1003                                            Blk0[i] = Blk[i] = (ieee_rand(0,Partitions)>=p)? Max : Min;
1004                                    ref_fdct(Blk0);
1005                                    emms(); fdct(Blk); emms();
1006                                    store_stats(&Stats, Blk, Blk0);
1007                            }
1008                    }
1009                    printf( "\n  -- FDCT saturation report --\n" );
1010                    report_stats(&Stats, 0);
1011    
1012    
1013                    /* IDCT tests // */
1014    #if 0
1015                    /* no finished yet */
1016    
1017                    init_stats(&Stats);
1018    
1019    /* test each computation channel separately */
1020                    for(i=0; i<64; i++) Blk[i] = Blk0[i] = ((i/8)==(i%8)) ? IDCT_MAX : 0;
1021                    ref_idct(Blk0);
1022                    emms(); idct(Blk); emms();
1023                    for(i=0; i<64; i++) { CLAMP(Blk0[i], IDCT_OUT); CLAMP(Blk[i], IDCT_OUT); }
1024                    store_stats(&Stats, Blk, Blk0);
1025    
1026                    for(i=0; i<64; i++) Blk[i] = Blk0[i] = ((i/8)==(i%8)) ? IDCT_MIN : 0;
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                    /* randomly saturated inputs */
1033                    for(p=0; p<Partitions; ++p)
1034                    {
1035                            for(n=0; n<Loops; ++n)
1036                            {
1037                                    for(i=0; i<64; ++i)
1038                                            Blk0[i] = Blk[i] = (ieee_rand(0,Partitions)>=p)? IDCT_MAX : IDCT_MIN;
1039                                    ref_idct(Blk0);
1040                                    emms(); idct(Blk); emms();
1041                                    for(i=0; i<64; i++) { CLAMP(Blk0[i],IDCT_OUT); CLAMP(Blk[i],IDCT_OUT); }
1042                                    store_stats(&Stats, Blk, Blk0);
1043                            }
1044                    }
1045    
1046                    printf( "\n  -- IDCT saturation report --\n" );
1047                    print_stats(&Stats);
1048                    report_stats(&Stats, 0);
1049    #endif
1050            }
1051    }
1052    
1053    /*********************************************************************
1054   * measure raw decoding speed   * measure raw decoding speed
1055   *********************************************************************/   *********************************************************************/
1056    
# Line 610  Line 1059 
1059    FILE *f = 0;    FILE *f = 0;
1060    void *dechandle = 0;    void *dechandle = 0;
1061    int xerr;    int xerr;
1062          XVID_INIT_PARAM xinit;          xvid_gbl_init_t xinit;
1063          XVID_DEC_PARAM xparam;          xvid_dec_create_t xparam;
1064          XVID_DEC_FRAME xframe;          xvid_dec_frame_t xframe;
1065          double t = 0.;          double t = 0.;
1066          int nb = 0;          int nb = 0;
1067    uint8_t *buf = 0;    uint8_t *buf = 0;
# Line 620  Line 1069 
1069    int buf_size, pos;    int buf_size, pos;
1070    uint32_t chksum = 0;    uint32_t chksum = 0;
1071    
1072          xinit.cpu_flags = 0;          memset(&xinit, 0, sizeof(xinit));
1073          xvid_init(NULL, 0, &xinit, NULL);          xinit.cpu_flags = XVID_CPU_MMX | XVID_CPU_FORCE;
1074          printf( "API version: %d, core build:%d\n", xinit.api_version, xinit.core_build);          xinit.version = XVID_VERSION;
1075            xvid_global(NULL, 0, &xinit, NULL);
1076    
1077            memset(&xparam, 0, sizeof(xparam));
1078          xparam.width = width;          xparam.width = width;
1079          xparam.height = height;          xparam.height = height;
1080            xparam.version = XVID_VERSION;
1081          xerr = xvid_decore(NULL, XVID_DEC_CREATE, &xparam, NULL);          xerr = xvid_decore(NULL, XVID_DEC_CREATE, &xparam, NULL);
1082          if (xerr!=XVID_ERR_OK) {          if (xerr==XVID_ERR_FAIL) {
1083            printf("can't init decoder (err=%d)\n", xerr);            printf("can't init decoder (err=%d)\n", xerr);
1084            return;            return;
1085          }          }
# Line 649  Line 1100 
1100    }    }
1101    else printf( "Input size: %d\n", buf_size);    else printf( "Input size: %d\n", buf_size);
1102    
1103    buf = malloc(buf_size); // should be enuf'          buf = malloc(buf_size); /* should be enuf' */
1104    rgb_out = calloc(4, width*height);  // <-room for _RGB24          rgb_out = calloc(4, width*height);  /* <-room for _RGB24 */
1105    if (buf==0 || rgb_out==0) {    if (buf==0 || rgb_out==0) {
1106      printf( "malloc failed!\n" );      printf( "malloc failed!\n" );
1107      goto End;      goto End;
# Line 665  Line 1116 
1116    pos = 0;    pos = 0;
1117    t = -gettime_usec();    t = -gettime_usec();
1118    while(1) {    while(1) {
1119                    memset(&xframe, 0, sizeof(xframe));
1120                    xframe.version = XVID_VERSION;
1121      xframe.bitstream = buf + pos;      xframe.bitstream = buf + pos;
1122      xframe.length = buf_size - pos;      xframe.length = buf_size - pos;
1123      xframe.image = rgb_out;                  xframe.output.plane[0] = rgb_out;
1124      xframe.stride = width;                  xframe.output.stride[0] = width;
1125      xframe.colorspace = XVID_CSP_RGB24;                  xframe.output.csp = XVID_CSP_BGR;
1126      xerr = xvid_decore(dechandle, XVID_DEC_DECODE, &xframe, 0);      xerr = xvid_decore(dechandle, XVID_DEC_DECODE, &xframe, 0);
1127      nb++;      nb++;
1128      pos += xframe.length;      pos += xframe.length;
# Line 680  Line 1133 
1133      }      }
1134      if (pos==buf_size)      if (pos==buf_size)
1135        break;        break;
1136      if (xerr!=XVID_ERR_OK) {                  if (xerr==XVID_ERR_FAIL) {
1137            printf("decoding failed for frame #%d (err=%d)!\n", nb, xerr);            printf("decoding failed for frame #%d (err=%d)!\n", nb, xerr);
1138            break;            break;
1139          }          }
# Line 696  Line 1149 
1149    if (buf!=0) free(buf);    if (buf!=0) free(buf);
1150    if (dechandle!=0) {    if (dechandle!=0) {
1151      xerr= xvid_decore(dechandle, XVID_DEC_DESTROY, NULL, NULL);      xerr= xvid_decore(dechandle, XVID_DEC_DESTROY, NULL, NULL);
1152      if (xerr!=XVID_ERR_OK)                  if (xerr==XVID_ERR_FAIL)
1153              printf("destroy-decoder failed (err=%d)!\n", xerr);              printf("destroy-decoder failed (err=%d)!\n", xerr);
1154    }    }
1155    if (f!=0) fclose(f);    if (f!=0) fclose(f);
# Line 712  Line 1165 
1165    
1166    printf( "\n =====  (de)quant4_intra saturation bug? =====\n" );    printf( "\n =====  (de)quant4_intra saturation bug? =====\n" );
1167    
1168    for(cpu = cpu_short_list; cpu->name!=0; ++cpu)          for(cpu = cpu_list; cpu->name!=0; ++cpu)
1169    {    {
1170      int i;      int i;
1171      int16_t  Src[8*8], Dst[8*8];      int16_t  Src[8*8], Dst[8*8];
# Line 722  Line 1175 
1175    
1176      for(i=0; i<64; ++i) Src[i] = i-32;      for(i=0; i<64; ++i) Src[i] = i-32;
1177      set_intra_matrix( get_default_intra_matrix() );      set_intra_matrix( get_default_intra_matrix() );
1178      dequant4_intra(Dst, Src, 32, 5);                  dequant_mpeg_intra(Dst, Src, 31, 5);
1179      printf( "dequant4_intra with CPU=%s:  ", cpu->name);                  printf( "dequant_mpeg_intra with CPU=%s:  ", cpu->name);
1180      printf( "  Out[]= " );      printf( "  Out[]= " );
1181      for(i=0; i<64; ++i) printf( "[%d]", Dst[i]);      for(i=0; i<64; ++i) printf( "[%d]", Dst[i]);
1182      printf( "\n" );      printf( "\n" );
# Line 731  Line 1184 
1184    
1185    printf( "\n =====  (de)quant4_inter saturation bug? =====\n" );    printf( "\n =====  (de)quant4_inter saturation bug? =====\n" );
1186    
1187    for(cpu = cpu_short_list; cpu->name!=0; ++cpu)          for(cpu = cpu_list; cpu->name!=0; ++cpu)
1188    {    {
1189      int i;      int i;
1190      int16_t  Src[8*8], Dst[8*8];      int16_t  Src[8*8], Dst[8*8];
# Line 741  Line 1194 
1194    
1195      for(i=0; i<64; ++i) Src[i] = i-32;      for(i=0; i<64; ++i) Src[i] = i-32;
1196      set_inter_matrix( get_default_inter_matrix() );      set_inter_matrix( get_default_inter_matrix() );
1197      dequant4_inter(Dst, Src, 32);                  dequant_mpeg_inter(Dst, Src, 31);
1198      printf( "dequant4_inter with CPU=%s:  ", cpu->name);                  printf( "dequant_mpeg_inter with CPU=%s:  ", cpu->name);
1199      printf( "  Out[]= " );      printf( "  Out[]= " );
1200      for(i=0; i<64; ++i) printf( "[%d]", Dst[i]);      for(i=0; i<64; ++i) printf( "[%d]", Dst[i]);
1201      printf( "\n" );      printf( "\n" );
# Line 754  Line 1207 
1207    CPU *cpu;    CPU *cpu;
1208    short Blk[8*8], Blk0[8*8];    short Blk[8*8], Blk0[8*8];
1209    
1210    printf( "\n =====  fdct/idct saturation diffs =====\n" );          printf( "\n =====  fdct/idct precision diffs =====\n" );
1211    
1212    for(cpu = cpu_short_list; cpu->name!=0; ++cpu)          for(cpu = cpu_list; cpu->name!=0; ++cpu)
1213    {    {
1214      int i;      int i;
1215    
# Line 780  Line 1233 
1233    }    }
1234  }  }
1235    
1236    void test_quant_bug()
1237    {
1238            const int max_Q = 31;
1239            int i, n, qm, q;
1240            CPU *cpu;
1241            int16_t  Src[8*8], Dst[8*8];
1242            uint8_t Quant[8*8];
1243            CPU cpu_bug_list[] = { { "PLAINC", 0 }, { "MMX   ", XVID_CPU_MMX }, {0,0} };
1244            uint16_t Crcs_Inter[2][32];
1245            uint16_t Crcs_Intra[2][32];
1246            printf( "\n =====  test MPEG4-quantize bug =====\n" );
1247    
1248            for(i=0; i<64; ++i) Src[i] = 2048*(i-32)/32;
1249    
1250    #if 1
1251            for(qm=1; qm<=255; ++qm)
1252            {
1253                    for(i=0; i<8*8; ++i) Quant[i] = qm;
1254                    set_inter_matrix( Quant );
1255    
1256                    for(n=0, cpu = cpu_bug_list; cpu->name!=0; ++cpu, ++n)
1257                    {
1258                            uint16_t s;
1259    
1260                            if (!init_cpu(cpu))
1261                                    continue;
1262    
1263                            for(q=1; q<=max_Q; ++q) {
1264                                    emms();
1265                                    quant_mpeg_inter( Dst, Src, q );
1266                                    emms();
1267                                    for(s=0, i=0; i<64; ++i) s+=((uint16_t)Dst[i])^i;
1268                                    Crcs_Inter[n][q] = s;
1269                            }
1270                    }
1271    
1272                    for(q=1; q<=max_Q; ++q)
1273                            for(i=0; i<n-1; ++i)
1274                                    if (Crcs_Inter[i][q]!=Crcs_Inter[i+1][q])
1275                                            printf( "Discrepancy Inter: qm=%d, q=%d  -> %d/%d !\n",
1276                                                            qm, q, Crcs_Inter[i][q], Crcs_Inter[i+1][q]);
1277            }
1278    #endif
1279    
1280    #if 1
1281            for(qm=1; qm<=255; ++qm)
1282            {
1283                    for(i=0; i<8*8; ++i) Quant[i] = qm;
1284                    set_intra_matrix( Quant );
1285    
1286                    for(n=0, cpu = cpu_bug_list; cpu->name!=0; ++cpu, ++n)
1287                    {
1288                            uint16_t s;
1289    
1290                            if (!init_cpu(cpu))
1291                                    continue;
1292    
1293                            for(q=1; q<=max_Q; ++q) {
1294                                    emms();
1295                                    quant_mpeg_intra( Dst, Src, q, q);
1296                                    emms();
1297                                    for(s=0, i=0; i<64; ++i) s+=((uint16_t)Dst[i])^i;
1298                                    Crcs_Intra[n][q] = s;
1299                            }
1300                    }
1301    
1302                    for(q=1; q<=max_Q; ++q)
1303                            for(i=0; i<n-1; ++i)
1304                                    if (Crcs_Intra[i][q]!=Crcs_Intra[i+1][q])
1305                                            printf( "Discrepancy Intra: qm=%d, q=%d  -> %d/%d!\n",
1306                                                            qm, q, Crcs_Inter[i][q], Crcs_Inter[i+1][q]);
1307            }
1308    #endif
1309    }
1310    
1311  /*********************************************************************  /*********************************************************************
1312   * main   * main
# Line 796  Line 1323 
1323    if (what==0 || what==5) test_quant();    if (what==0 || what==5) test_quant();
1324    if (what==0 || what==6) test_cbp();    if (what==0 || what==6) test_cbp();
1325    
1326    if (what==8) {          if (what==7) {
1327                    test_IEEE1180_compliance(-256, 255, 1);
1328                    test_IEEE1180_compliance(-256, 255,-1);
1329                    test_IEEE1180_compliance(  -5,   5, 1);
1330                    test_IEEE1180_compliance(  -5,   5,-1);
1331                    test_IEEE1180_compliance(-300, 300, 1);
1332                    test_IEEE1180_compliance(-300, 300,-1);
1333            }
1334            if (what==8) test_dct_saturation(-256, 255);
1335    
1336            if (what==9) {
1337      int width, height;      int width, height;
1338      if (argc<5) {      if (argc<5) {
1339        printf("usage: %s %d [bitstream] [width] [height]\n", argv[0], what);        printf("usage: %s %d [bitstream] [width] [height]\n", argv[0], what);
# Line 808  Line 1345 
1345    }    }
1346    
1347    if (what==-1) {    if (what==-1) {
     test_bugs1();  
1348      test_dct_precision_diffs();      test_dct_precision_diffs();
1349                    test_bugs1();
1350    }    }
1351            if (what==-2)
1352                    test_quant_bug();
1353    
1354    return 0;    return 0;
1355  }  }
1356    
1357  /*********************************************************************  /*********************************************************************
1358   * 'Reference' output (except for timing) on a PIII 1.13Ghz/linux   * 'Reference' output (except for timing) on a PIII 1.13Ghz/linux
1359   *********************************************************************/   *********************************************************************/
1360    
1361    /* as of 07/01/2002, there's a problem with mpeg4-quantization */
1362  /*  /*
1363    
1364   ===== test fdct/idct =====   ===== test fdct/idct =====
1365  PLAINC -  2.631 usec       iCrc=3  fCrc=-85  PLAINC -  3.312 usec       PSNR=13.291  MSE=3.000
1366  MMX    -  0.596 usec       iCrc=3  fCrc=-67  MMX    -  0.591 usec       PSNR=13.291  MSE=3.000
1367  MMXEXT -  0.608 usec       iCrc=3  fCrc=-67  MMXEXT -  0.577 usec       PSNR=13.291  MSE=3.000
1368  SSE2   -  0.605 usec       iCrc=3  fCrc=-67  SSE2   -  0.588 usec       PSNR=13.291  MSE=3.000
1369  3DNOW  - skipped...  3DNOW  - skipped...
1370  3DNOWE - skipped...  3DNOWE - skipped...
1371    
1372   ===  test block motion ===   ===  test block motion ===
1373  PLAINC - interp- h-round0 1.031 usec       iCrc=8107  PLAINC - interp- h-round0 0.911 usec       iCrc=8107
1374  PLAINC -           round1 1.022 usec       iCrc=8100  PLAINC -           round1 0.863 usec       iCrc=8100
1375  PLAINC - interp- v-round0 1.002 usec       iCrc=8108  PLAINC - interp- v-round0 0.860 usec       iCrc=8108
1376  PLAINC -           round1 1.011 usec       iCrc=8105  PLAINC -           round1 0.857 usec       iCrc=8105
1377  PLAINC - interp-hv-round0 1.623 usec       iCrc=8112  PLAINC - interp-hv-round0 2.103 usec       iCrc=8112
1378  PLAINC -           round1 1.621 usec       iCrc=8103  PLAINC -           round1 2.050 usec       iCrc=8103
 PLAINC - interpolate8x8_c 0.229 usec       iCrc=8107  
1379   ---   ---
1380  MMX    - interp- h-round0 0.105 usec       iCrc=8107  MMX    - interp- h-round0 0.105 usec       iCrc=8107
1381  MMX    -           round1 0.105 usec       iCrc=8100  MMX    -           round1 0.106 usec       iCrc=8100
1382  MMX    - interp- v-round0 0.106 usec       iCrc=8108  MMX    - interp- v-round0 0.106 usec       iCrc=8108
1383  MMX    -           round1 0.107 usec       iCrc=8105  MMX    -           round1 0.106 usec       iCrc=8105
1384  MMX    - interp-hv-round0 0.145 usec       iCrc=8112  MMX    - interp-hv-round0 0.145 usec       iCrc=8112
1385  MMX    -           round1 0.145 usec       iCrc=8103  MMX    -           round1 0.145 usec       iCrc=8103
 MMX    - interpolate8x8_c 0.229 usec       iCrc=8107  
1386   ---   ---
1387  MMXEXT - interp- h-round0 0.027 usec       iCrc=8107  MMXEXT - interp- h-round0 0.028 usec       iCrc=8107
1388  MMXEXT -           round1 0.041 usec       iCrc=8100  MMXEXT -           round1 0.041 usec       iCrc=8100
1389  MMXEXT - interp- v-round0 0.027 usec       iCrc=8108  MMXEXT - interp- v-round0 0.027 usec       iCrc=8108
1390  MMXEXT -           round1 0.040 usec       iCrc=8105  MMXEXT -           round1 0.041 usec       iCrc=8105
1391  MMXEXT - interp-hv-round0 0.070 usec       iCrc=8112  MMXEXT - interp-hv-round0 0.066 usec       iCrc=8112
1392  MMXEXT -           round1 0.066 usec       iCrc=8103  MMXEXT -           round1 0.065 usec       iCrc=8103
 MMXEXT - interpolate8x8_c 0.027 usec       iCrc=8107  
1393   ---   ---
1394  SSE2   - interp- h-round0 0.106 usec       iCrc=8107  SSE2   - interp- h-round0 0.109 usec       iCrc=8107
1395  SSE2   -           round1 0.105 usec       iCrc=8100  SSE2   -           round1 0.105 usec       iCrc=8100
1396  SSE2   - interp- v-round0 0.106 usec       iCrc=8108  SSE2   - interp- v-round0 0.106 usec       iCrc=8108
1397  SSE2   -           round1 0.106 usec       iCrc=8105  SSE2   -           round1 0.109 usec       iCrc=8105
1398  SSE2   - interp-hv-round0 0.145 usec       iCrc=8112  SSE2   - interp-hv-round0 0.145 usec       iCrc=8112
1399  SSE2   -           round1 0.145 usec       iCrc=8103  SSE2   -           round1 0.145 usec       iCrc=8103
 SSE2   - interpolate8x8_c 0.237 usec       iCrc=8107  
1400   ---   ---
1401  3DNOW  - skipped...  3DNOW  - skipped...
1402  3DNOWE - skipped...  3DNOWE - skipped...
1403    
1404   ======  test SAD ======   ======  test SAD ======
1405  PLAINC - sad8    0.296 usec       sad=3776  PLAINC - sad8    0.251 usec       sad=3776
1406  PLAINC - sad16   1.599 usec       sad=27214  PLAINC - sad16   1.601 usec       sad=27214
1407  PLAINC - sad16bi 2.350 usec       sad=26274  PLAINC - sad16bi 2.371 usec       sad=26274
1408  PLAINC - dev16   1.610 usec       sad=3344  PLAINC - dev16   1.564 usec       sad=3344
1409   ---   ---
1410  MMX    - sad8    0.057 usec       sad=3776  MMX    - sad8    0.057 usec       sad=3776
1411  MMX    - sad16   0.178 usec       sad=27214  MMX    - sad16   0.182 usec       sad=27214
1412  MMX    - sad16bi 2.381 usec       sad=26274  MMX    - sad16bi 2.462 usec       sad=26274
1413  MMX    - dev16   0.312 usec       sad=3344  MMX    - dev16   0.311 usec       sad=3344
1414   ---   ---
1415  MMXEXT - sad8    0.036 usec       sad=3776  MMXEXT - sad8    0.036 usec       sad=3776
1416  MMXEXT - sad16   0.106 usec       sad=27214  MMXEXT - sad16   0.109 usec       sad=27214
1417  MMXEXT - sad16bi 0.182 usec       sad=26274  MMXEXT - sad16bi 0.143 usec       sad=26274
1418  MMXEXT - dev16   0.193 usec       sad=3344  MMXEXT - dev16   0.192 usec       sad=3344
1419   ---   ---
1420  SSE2   - sad8    0.057 usec       sad=3776  SSE2   - sad8    0.057 usec       sad=3776
1421  SSE2   - sad16   0.178 usec       sad=27214  SSE2   - sad16   0.179 usec       sad=27214
1422  SSE2   - sad16bi 2.427 usec       sad=26274  SSE2   - sad16bi 2.456 usec       sad=26274
1423  SSE2   - dev16   0.313 usec       sad=3344  SSE2   - dev16   0.321 usec       sad=3344
1424   ---   ---
1425  3DNOW  - skipped...  3DNOW  - skipped...
1426  3DNOWE - skipped...  3DNOWE - skipped...
1427    
1428   ===  test transfer ===   ===  test transfer ===
1429  PLAINC - 8to16     0.124 usec       crc=28288  PLAINC - 8to16     0.151 usec       crc=28288
1430  PLAINC - 16to8     0.753 usec       crc=28288  PLAINC - 16to8     1.113 usec       crc=28288
1431  PLAINC - 8to8      0.041 usec       crc=20352  PLAINC - 8to8      0.043 usec       crc=20352
1432  PLAINC - 16to8add  0.916 usec       crc=25536  PLAINC - 16to8add  1.069 usec       crc=25536
1433  PLAINC - 8to16sub  0.812 usec       crc1=28064 crc2=16256  PLAINC - 8to16sub  0.631 usec       crc1=28064 crc2=16256
1434  PLAINC - 8to16sub2 0.954 usec       crc=20384  PLAINC - 8to16sub2 0.597 usec       crc=20384
1435   ---  ---
1436  MMX    - 8to16     0.037 usec       crc=28288  MMX    - 8to16     0.032 usec       crc=28288
1437  MMX    - 16to8     0.016 usec       crc=28288  MMX    - 16to8     0.024 usec       crc=28288
1438  MMX    - 8to8      0.018 usec       crc=20352  MMX    - 8to8      0.020 usec       crc=20352
1439  MMX    - 16to8add  0.044 usec       crc=25536  MMX    - 16to8add  0.043 usec       crc=25536
1440  MMX    - 8to16sub  0.065 usec       crc1=28064 crc2=16256  MMX    - 8to16sub  0.066 usec       crc1=28064 crc2=16256
1441  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  
1442   ---   ---
1443    
1444   =====  test quant =====   =====  test quant =====
1445  PLAINC -   quant4_intra 78.889 usec       crc=55827  PLAINC -   quant4_intra 74.248 usec       crc=29809
1446  PLAINC -   quant4_inter 71.957 usec       crc=58201  PLAINC -   quant4_inter 70.850 usec       crc=12574
1447  PLAINC - dequant4_intra 34.968 usec       crc=193340  PLAINC - dequant4_intra 40.628 usec       crc=24052
1448  PLAINC - dequant4_inter 40.792 usec       crc=116483  PLAINC - dequant4_inter 45.691 usec       crc=63847
1449  PLAINC -    quant_intra 30.845 usec       crc=56885  PLAINC -    quant_intra 43.357 usec       crc=25662
1450  PLAINC -    quant_inter 34.842 usec       crc=58056  PLAINC -    quant_inter 33.410 usec       crc=23972
1451  PLAINC -  dequant_intra 33.211 usec       crc=-7936  PLAINC -  dequant_intra 36.384 usec       crc=49900
1452  PLAINC -  dequant_inter 45.486 usec       crc=-33217  PLAINC -  dequant_inter 48.930 usec       crc=48899
1453   ---  ---
1454  MMX    -   quant4_intra 9.030 usec       crc=55827  MMX    -   quant4_intra 7.445 usec       crc=3459
1455  MMX    -   quant4_inter 8.234 usec       crc=58201  *** CRC ERROR! ***
1456  MMX    - dequant4_intra 18.330 usec       crc=193340  MMX    -   quant4_inter 5.384 usec       crc=51072
1457  MMX    - dequant4_inter 19.181 usec       crc=116483  *** CRC ERROR! ***
1458  MMX    -    quant_intra 7.124 usec       crc=56885  MMX    - dequant4_intra 5.515 usec       crc=24052
1459  MMX    -    quant_inter 6.861 usec       crc=58056  MMX    - dequant4_inter 7.745 usec       crc=63847
1460  MMX    -  dequant_intra 9.048 usec       crc=-7936  MMX    -    quant_intra 4.661 usec       crc=25662
1461  MMX    -  dequant_inter 8.203 usec       crc=-33217  MMX    -    quant_inter 4.406 usec       crc=23972
1462   ---  MMX    -  dequant_intra 4.928 usec       crc=49900
1463  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  
1464   ---   ---
1465    
1466   =====  test cbp =====   =====  test cbp =====
1467  PLAINC -   calc_cbp#1 0.545 usec       cbp=0x15  PLAINC -   calc_cbp#1 0.371 usec       cbp=0x15
1468  PLAINC -   calc_cbp#2 0.540 usec       cbp=0x38  PLAINC -   calc_cbp#2 0.432 usec       cbp=0x38
1469  PLAINC -   calc_cbp#3 0.477 usec       cbp=0xf  PLAINC -   calc_cbp#3 0.339 usec       cbp=0xf
1470  PLAINC -   calc_cbp#4 0.739 usec       cbp=0x5  PLAINC -   calc_cbp#4 0.506 usec       cbp=0x5
1471   ---   ---
1472  MMX    -   calc_cbp#1 0.136 usec       cbp=0x15  MMX    -   calc_cbp#1 0.136 usec       cbp=0x15
1473  MMX    -   calc_cbp#2 0.131 usec       cbp=0x38  MMX    -   calc_cbp#2 0.134 usec       cbp=0x38
1474  MMX    -   calc_cbp#3 0.132 usec       cbp=0xf  MMX    -   calc_cbp#3 0.138 usec       cbp=0xf
1475  MMX    -   calc_cbp#4 0.135 usec       cbp=0x5  MMX    -   calc_cbp#4 0.135 usec       cbp=0x5
1476   ---   ---
1477  SSE2   -   calc_cbp#1 0.135 usec       cbp=0x15  SSE2   -   calc_cbp#1 0.136 usec       cbp=0x15
1478  SSE2   -   calc_cbp#2 0.131 usec       cbp=0x38  SSE2   -   calc_cbp#2 0.133 usec       cbp=0x38
1479  SSE2   -   calc_cbp#3 0.134 usec       cbp=0xf  SSE2   -   calc_cbp#3 0.133 usec       cbp=0xf
1480  SSE2   -   calc_cbp#4 0.136 usec       cbp=0x5  SSE2   -   calc_cbp#4 0.141 usec       cbp=0x5
1481   ---   ---
1482    
1483  */  */

Legend:
Removed from v.225  
changed lines
  Added in v.1197

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