[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 851, Sat Feb 15 15:22:19 2003 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
# Line 27  Line 32 
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"
# Line 56  Line 62 
62  #include "bitstream/cbp.h"  #include "bitstream/cbp.h"
63    
64  #include <math.h>  #include <math.h>
65  const int speed_ref = 100;  // on slow machines, decrease this value  
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 65  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 97  Line 114 
114    
115  CPU cpu_list[] =  CPU cpu_list[] =
116  { { "PLAINC", 0 }  { { "PLAINC", 0 }
117    #ifdef ARCH_IS_IA32
118  , { "MMX   ", XVID_CPU_MMX }  , { "MMX   ", XVID_CPU_MMX }
119  , { "MMXEXT", XVID_CPU_MMXEXT | XVID_CPU_MMX }  , { "MMXEXT", XVID_CPU_MMXEXT | XVID_CPU_MMX }
120  , { "SSE2  ", XVID_CPU_SSE2 | XVID_CPU_MMX }  , { "SSE2  ", XVID_CPU_SSE2 | XVID_CPU_MMX }
121  , { "3DNOW ", XVID_CPU_3DNOW }  , { "3DNOW ", XVID_CPU_3DNOW }
122  , { "3DNOWE", XVID_CPU_3DNOWEXT }  , { "3DNOWE", XVID_CPU_3DNOWEXT }
123  , { "IA64  ", XVID_CPU_IA64 }  #endif
124    //, { "IA64  ", XVID_CPU_IA64 }
125  //, { "TSC   ", XVID_CPU_TSC }  //, { "TSC   ", XVID_CPU_TSC }
126  , { 0, 0 } }    , { 0, 0 } };
127    
128  , cpu_short_list[] =  CPU  cpu_short_list[] =
129  { { "PLAINC", 0 }  { { "PLAINC", 0 }
130    #ifdef ARCH_IS_IA32
131  , { "MMX   ", XVID_CPU_MMX }  , { "MMX   ", XVID_CPU_MMX }
132  //, { "MMXEXT", XVID_CPU_MMXEXT | XVID_CPU_MMX }  //, { "MMXEXT", XVID_CPU_MMXEXT | XVID_CPU_MMX }
133  , { "IA64  ", XVID_CPU_IA64 }  #endif
134  , { 0, 0 } }  //, { "IA64  ", XVID_CPU_IA64 }
135      , { 0, 0 } };
136    
137  , cpu_short_list2[] =  CPU cpu_short_list2[] =
138  { { "PLAINC", 0 }  { { "PLAINC", 0 }
139    #ifdef ARCH_IS_IA32
140  , { "MMX   ", XVID_CPU_MMX }  , { "MMX   ", XVID_CPU_MMX }
141  , { "SSE2  ", XVID_CPU_SSE2 | XVID_CPU_MMX }  , { "SSE2  ", XVID_CPU_SSE2 | XVID_CPU_MMX }
142    #endif
143  , { 0, 0 } };  , { 0, 0 } };
144    
145    
146  int init_cpu(CPU *cpu)  int init_cpu(CPU *cpu)
147  {  {
148    int xerr, cpu_type;          xvid_gbl_info_t xinfo;
   XVID_INIT_PARAM xinit;  
149    
150    cpu_type = check_cpu_features() & cpu->cpu;          /* Get the available CPU flags */
151    xinit.cpu_flags = cpu_type | XVID_CPU_FORCE;          memset(&xinfo, 0, sizeof(xinfo));
152    //    xinit.cpu_flags = XVID_CPU_MMX | XVID_CPU_FORCE;          xinfo.version = XVID_VERSION;
153    xerr = xvid_init(NULL, 0, &xinit, NULL);          xvid_global(NULL, XVID_GBL_INFO, &xinfo, NULL);
154    if (cpu->cpu>0 && (cpu_type==0 || xerr!=XVID_ERR_OK)) {  
155      printf( "%s - skipped...\n", cpu->name );          /* Are we trying to test a subset of the host CPU features */
156            if ((xinfo.cpu_flags & cpu->cpu) == cpu->cpu) {
157                    int xerr;
158                    xvid_gbl_init_t xinit;
159                    memset(&xinit, 0, sizeof(xinit));
160                    xinit.cpu_flags = cpu->cpu | XVID_CPU_FORCE;
161                    xinit.version = XVID_VERSION;
162                    xerr = xvid_global(NULL, XVID_GBL_INIT, &xinit, NULL);
163                    if (xerr==XVID_ERR_FAIL) {
164                            /* libxvidcore failed to init */
165      return 0;      return 0;
166    }    }
167            } else {
168                    /* The host CPU doesn't support some required feature for this test */
169                    return(0);
170            }
171    return 1;    return 1;
172  }  }
173    
# Line 285  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 335  Line 370 
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                  /* this is a new function, as of 06.06.2002 */
374  #if 0  #if 0
375      TEST_MB2(interpolate8x8_avrg);      TEST_MB2(interpolate8x8_avrg);
376      printf( "%s - interpolate8x8_c %.3f usec       iCrc=%d\n", cpu->name, t, iCrc );      printf( "%s - interpolate8x8_c %.3f usec       iCrc=%d\n", cpu->name, t, iCrc );
# Line 423  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 511  Line 546 
546    
547    printf( "\n =====  test quant =====\n" );    printf( "\n =====  test quant =====\n" );
548    
549      // we deliberately enfringe the norm's specified range [-127,127],  /* we deliberately enfringe the norm's specified range [-127,127], */
550      // to test the robustness of the iquant module  /* to test the robustness of the iquant module */
551    for(i=0; i<64; ++i) {    for(i=0; i<64; ++i) {
552      Src[i] = 1 + (i-32) * (i&6);      Src[i] = 1 + (i-32) * (i&6);
553      Dst[i] = 0;      Dst[i] = 0;
554    }    }
555    
556    for(cpu = cpu_short_list; cpu->name!=0; ++cpu)          for(cpu = cpu_list; cpu->name!=0; ++cpu)
557    {    {
558      double t, overhead;      double t, overhead;
559      int tst, q;      int tst, q;
# Line 537  Line 572 
572      overhead += gettime_usec();      overhead += gettime_usec();
573    
574  #if 1  #if 1
575      TEST_QUANT2(quant4_intra, Dst, Src);                  TEST_QUANT2(quant_mpeg_intra, Dst, Src);
576      printf( "%s -   quant4_intra %.3f usec       crc=%d\n", cpu->name, t, s );                  printf( "%s -   quant_mpeg_intra %.3f usec       crc=%d\n", cpu->name, t, s );
577      if (s!=29809) printf( "*** CRC ERROR! ***\n" );      if (s!=29809) printf( "*** CRC ERROR! ***\n" );
578    
579      TEST_QUANT(quant4_inter, Dst, Src);                  TEST_QUANT(quant_mpeg_inter, Dst, Src);
580      printf( "%s -   quant4_inter %.3f usec       crc=%d\n", cpu->name, t, s );                  printf( "%s -   quant_mpeg_inter %.3f usec       crc=%d\n", cpu->name, t, s );
581      if (s!=12574) printf( "*** CRC ERROR! ***\n" );      if (s!=12574) printf( "*** CRC ERROR! ***\n" );
582  #endif  #endif
583  #if 1  #if 1
584      TEST_QUANT2(dequant4_intra, Dst, Src);                  TEST_QUANT2(dequant_mpeg_intra, Dst, Src);
585      printf( "%s - dequant4_intra %.3f usec       crc=%d\n", cpu->name, t, s );                  printf( "%s - dequant_mpeg_intra %.3f usec       crc=%d\n", cpu->name, t, s );
586      if (s!=24052) printf( "*** CRC ERROR! ***\n" );      if (s!=24052) printf( "*** CRC ERROR! ***\n" );
587    
588      TEST_QUANT(dequant4_inter, Dst, Src);                  TEST_QUANT(dequant_mpeg_inter, Dst, Src);
589      printf( "%s - dequant4_inter %.3f usec       crc=%d\n", cpu->name, t, s );                  printf( "%s - dequant_mpeg_inter %.3f usec       crc=%d\n", cpu->name, t, s );
590      if (s!=63847) printf( "*** CRC ERROR! ***\n" );      if (s!=63847) printf( "*** CRC ERROR! ***\n" );
591  #endif  #endif
592  #if 1  #if 1
593      TEST_QUANT2(quant_intra, Dst, Src);                  TEST_QUANT2(quant_h263_intra, Dst, Src);
594      printf( "%s -    quant_intra %.3f usec       crc=%d\n", cpu->name, t, s );                  printf( "%s -   quant_h263_intra %.3f usec       crc=%d\n", cpu->name, t, s );
595      if (s!=25662) printf( "*** CRC ERROR! ***\n" );      if (s!=25662) printf( "*** CRC ERROR! ***\n" );
596    
597      TEST_QUANT(quant_inter, Dst, Src);                  TEST_QUANT(quant_h263_inter, Dst, Src);
598      printf( "%s -    quant_inter %.3f usec       crc=%d\n", cpu->name, t, s );                  printf( "%s -   quant_h263_inter %.3f usec       crc=%d\n", cpu->name, t, s );
599      if (s!=23972) printf( "*** CRC ERROR! ***\n" );      if (s!=23972) printf( "*** CRC ERROR! ***\n" );
600  #endif  #endif
601  #if 1  #if 1
602      TEST_QUANT2(dequant_intra, Dst, Src);                  TEST_QUANT2(dequant_h263_intra, Dst, Src);
603      printf( "%s -  dequant_intra %.3f usec       crc=%d\n", cpu->name, t, s );                  printf( "%s - dequant_h263_intra %.3f usec       crc=%d\n", cpu->name, t, s );
604      if (s!=49900) printf( "*** CRC ERROR! ***\n" );      if (s!=49900) printf( "*** CRC ERROR! ***\n" );
605    
606      TEST_QUANT(dequant_inter, Dst, Src);                  TEST_QUANT(dequant_h263_inter, Dst, Src);
607      printf( "%s -  dequant_inter %.3f usec       crc=%d\n", cpu->name, t, s );                  printf( "%s - dequant_h263_inter %.3f usec       crc=%d\n", cpu->name, t, s );
608      if (s!=48899) printf( "*** CRC ERROR! ***\n" );      if (s!=48899) printf( "*** CRC ERROR! ***\n" );
609  #endif  #endif
610      printf( " --- \n" );      printf( " --- \n" );
# Line 599  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 755  Line 790 
790    }    }
791  }  }
792    
793  //////////////////////////////////////////////////////////  ///* ////////////////////////////////////////////////////// */
794  /* Pseudo-random generator specified by IEEE 1180 */  /* Pseudo-random generator specified by IEEE 1180 */
795    
796  static long ieee_seed = 1;  static long ieee_seed = 1;
# Line 842  Line 877 
877    static const double ILimits[5] = { 1., 0.06, 0.02, 0.015, 0.0015 };    static const double ILimits[5] = { 1., 0.06, 0.02, 0.015, 0.0015 };
878    int Loops = 10000;    int Loops = 10000;
879    int i, m, n;    int i, m, n;
880    short Blk0[64];     // reference          short Blk0[64];     /* reference */
881    short Blk[64], iBlk[64];    short Blk[64], iBlk[64];
882    short Ref_FDCT[64];    short Ref_FDCT[64];
883    short Ref_IDCT[64];    short Ref_IDCT[64];
884    
885    STATS_8x8 FStats; // forward dct stats          STATS_8x8 FStats; /* forward dct stats */
886    STATS_8x8 IStats; // inverse dct stats          STATS_8x8 IStats; /* inverse dct stats */
887    
888    CPU *cpu;    CPU *cpu;
889    
# Line 871  Line 906 
906        for(i=0; i<64; ++i)        for(i=0; i<64; ++i)
907          Blk0[i] = (short)ieee_rand(Min,Max) * Sign;          Blk0[i] = (short)ieee_rand(Min,Max) * Sign;
908    
909          // hmm, I'm not quite sure this is exactly                          /* hmm, I'm not quite sure this is exactly */
910          // the tests described in the norm. check...                          /* the tests described in the norm. check... */
911    
912        memcpy(Ref_FDCT, Blk0, 64*sizeof(short));        memcpy(Ref_FDCT, Blk0, 64*sizeof(short));
913        ref_fdct(Ref_FDCT);        ref_fdct(Ref_FDCT);
# Line 899  Line 934 
934    
935      printf( "\n  -- FDCT report --\n" );      printf( "\n  -- FDCT report --\n" );
936  //    print_stats(&FStats);  //    print_stats(&FStats);
937      report_stats(&FStats, 0); // so far I know, IEEE1180 says nothing for fdct                  report_stats(&FStats, 0); /* so far I know, IEEE1180 says nothing for fdct */
938    
939      for(i=0; i<64; i++) Blk[i] = 0;      for(i=0; i<64; i++) Blk[i] = 0;
940      emms(); fdct(Blk); emms();      emms(); fdct(Blk); emms();
# Line 921  Line 956 
956    
957  void test_dct_saturation(int Min, int Max)  void test_dct_saturation(int Min, int Max)
958  {  {
959      // test behaviour on input range fringe  /* test behaviour on input range fringe */
960    
961    int i, n, p;    int i, n, p;
962    CPU *cpu;    CPU *cpu;
963  //  const short IDCT_MAX =  2047;  // 12bits input  //  const short IDCT_MAX =  2047;  /* 12bits input */
964  //  const short IDCT_MIN = -2048;  //  const short IDCT_MIN = -2048;
965  //  const short IDCT_OUT =   256;  // 9bits ouput  //  const short IDCT_OUT =   256;  /* 9bits ouput */
966    const int Partitions = 4;    const int Partitions = 4;
967    const int Loops = 10000 / Partitions;    const int Loops = 10000 / Partitions;
968    
# Line 944  Line 979 
979      printf( "\n===== IEEE test for %s Min=%d Max=%d =====\n",      printf( "\n===== IEEE test for %s Min=%d Max=%d =====\n",
980        cpu->name, Min, Max );        cpu->name, Min, Max );
981    
982                // FDCT tests //                  /* FDCT tests // */
983    
984      init_stats(&Stats);      init_stats(&Stats);
985    
986        // test each computation channels separately                  /* test each computation channels separately */
987      for(i=0; i<64; i++) Blk[i] = Blk0[i] = ((i/8)==(i%8)) ? Max : 0;      for(i=0; i<64; i++) Blk[i] = Blk0[i] = ((i/8)==(i%8)) ? Max : 0;
988      ref_fdct(Blk0);      ref_fdct(Blk0);
989      emms(); fdct(Blk); emms();      emms(); fdct(Blk); emms();
# Line 959  Line 994 
994      emms(); fdct(Blk); emms();      emms(); fdct(Blk); emms();
995      store_stats(&Stats, Blk, Blk0);      store_stats(&Stats, Blk, Blk0);
996    
997        // randomly saturated inputs                  /* randomly saturated inputs */
998      for(p=0; p<Partitions; ++p)      for(p=0; p<Partitions; ++p)
999      {      {
1000        for(n=0; n<Loops; ++n)        for(n=0; n<Loops; ++n)
# Line 975  Line 1010 
1010      report_stats(&Stats, 0);      report_stats(&Stats, 0);
1011    
1012    
1013                // IDCT tests //                  /* IDCT tests // */
1014  #if 0  #if 0
1015        // no finished yet                  /* no finished yet */
1016    
1017      init_stats(&Stats);      init_stats(&Stats);
1018    
1019      // test each computation channel separately  /* test each computation channel separately */
1020      for(i=0; i<64; i++) Blk[i] = Blk0[i] = ((i/8)==(i%8)) ? IDCT_MAX : 0;      for(i=0; i<64; i++) Blk[i] = Blk0[i] = ((i/8)==(i%8)) ? IDCT_MAX : 0;
1021      ref_idct(Blk0);      ref_idct(Blk0);
1022      emms(); idct(Blk); emms();      emms(); idct(Blk); emms();
# Line 994  Line 1029 
1029      for(i=0; i<64; i++) { CLAMP(Blk0[i], IDCT_OUT); CLAMP(Blk[i], IDCT_OUT); }      for(i=0; i<64; i++) { CLAMP(Blk0[i], IDCT_OUT); CLAMP(Blk[i], IDCT_OUT); }
1030      store_stats(&Stats, Blk, Blk0);      store_stats(&Stats, Blk, Blk0);
1031    
1032        // randomly saturated inputs                  /* randomly saturated inputs */
1033      for(p=0; p<Partitions; ++p)      for(p=0; p<Partitions; ++p)
1034      {      {
1035        for(n=0; n<Loops; ++n)        for(n=0; n<Loops; ++n)
# Line 1024  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 1034  Line 1069 
1069    int buf_size, pos;    int buf_size, pos;
1070    uint32_t chksum = 0;    uint32_t chksum = 0;
1071    
1072            memset(&xinit, 0, sizeof(xinit));
1073          xinit.cpu_flags = XVID_CPU_MMX | XVID_CPU_FORCE;          xinit.cpu_flags = XVID_CPU_MMX | XVID_CPU_FORCE;
1074          xvid_init(NULL, 0, &xinit, NULL);          xinit.version = XVID_VERSION;
1075          printf( "API version: %d, core build:%d\n", xinit.api_version, xinit.core_build);          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 1063  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 1079  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 1094  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 1110  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 1126  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 1136  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, 31, 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 1145  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 1155  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, 31);                  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 1170  Line 1209 
1209    
1210    printf( "\n =====  fdct/idct precision 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 1223  Line 1262 
1262    
1263        for(q=1; q<=max_Q; ++q) {        for(q=1; q<=max_Q; ++q) {
1264          emms();          emms();
1265          quant4_inter( Dst, Src, q );                                  quant_mpeg_inter( Dst, Src, q );
1266          emms();          emms();
1267          for(s=0, i=0; i<64; ++i) s+=((uint16_t)Dst[i])^i;          for(s=0, i=0; i<64; ++i) s+=((uint16_t)Dst[i])^i;
1268          Crcs_Inter[n][q] = s;          Crcs_Inter[n][q] = s;
# Line 1253  Line 1292 
1292    
1293        for(q=1; q<=max_Q; ++q) {        for(q=1; q<=max_Q; ++q) {
1294          emms();          emms();
1295          quant4_intra( Dst, Src, q, q);                                  quant_mpeg_intra( Dst, Src, q, q);
1296          emms();          emms();
1297          for(s=0, i=0; i<64; ++i) s+=((uint16_t)Dst[i])^i;          for(s=0, i=0; i<64; ++i) s+=((uint16_t)Dst[i])^i;
1298          Crcs_Intra[n][q] = s;          Crcs_Intra[n][q] = s;
# Line 1286  Line 1325 
1325    
1326    if (what==7) {    if (what==7) {
1327      test_IEEE1180_compliance(-256, 255, 1);      test_IEEE1180_compliance(-256, 255, 1);
 #if 0  
1328      test_IEEE1180_compliance(-256, 255,-1);      test_IEEE1180_compliance(-256, 255,-1);
1329      test_IEEE1180_compliance(  -5,   5, 1);      test_IEEE1180_compliance(  -5,   5, 1);
1330      test_IEEE1180_compliance(  -5,   5,-1);      test_IEEE1180_compliance(  -5,   5,-1);
1331      test_IEEE1180_compliance(-300, 300, 1);      test_IEEE1180_compliance(-300, 300, 1);
1332      test_IEEE1180_compliance(-300, 300,-1);      test_IEEE1180_compliance(-300, 300,-1);
 #endif  
1333    }    }
1334    if (what==8) test_dct_saturation(-256, 255);    if (what==8) test_dct_saturation(-256, 255);
1335    

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

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