[svn] / trunk / xvidcore / examples / xvid_bench.c Repository:
ViewVC logotype

Diff of /trunk/xvidcore/examples/xvid_bench.c

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

revision 1737, Fri Oct 13 15:16:25 2006 UTC revision 1746, Wed Nov 1 07:12:26 2006 UTC
# Line 19  Line 19 
19   *  along with this program; if not, write to the Free Software   *  along with this program; if not, write to the Free Software
20   *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA   *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
21   *   *
22   * $Id: xvid_bench.c,v 1.30 2006-10-13 15:16:25 Skal Exp $   * $Id: xvid_bench.c,v 1.34 2006-11-01 07:12:26 Skal Exp $
23   *   *
24   ****************************************************************************/   ****************************************************************************/
25    
# Line 58  Line 58 
58  #include "utils/timer.h"  #include "utils/timer.h"
59  #include "quant/quant_matrix.c"  #include "quant/quant_matrix.c"
60  #include "bitstream/cbp.h"  #include "bitstream/cbp.h"
61    #include "bitstream/bitstream.h"
62    
63  #include <math.h>  #include <math.h>
64    
# Line 1725  Line 1726 
1726  for(tst=0; tst<nb_tests; ++tst) (FUNC)(Dst0[0], S*WIDTH, Src0[0], Src0[1], Src0[2], WIDTH, WIDTH/2, WIDTH, HEIGHT, 0); \  for(tst=0; tst<nb_tests; ++tst) (FUNC)(Dst0[0], S*WIDTH, Src0[0], Src0[1], Src0[2], WIDTH, WIDTH/2, WIDTH, HEIGHT, 0); \
1727  LEAVE  LEAVE
1728    
1729  #define WIDTH 64  #define WIDTH 128
1730  #define HEIGHT 64  #define HEIGHT 32
1731  void test_yuv()  void test_yuv()
1732  {  {
1733          const int nb_tests = 200*speed_ref;          const int nb_tests = 200*speed_ref;
# Line 1740  Line 1741 
1741          colorspace_init();          colorspace_init();
1742          ieee_reseed(1);          ieee_reseed(1);
1743          for(i=0; i<(int)sizeof(Src0); ++i) Src0[0][i] = ieee_rand(0,255);          for(i=0; i<(int)sizeof(Src0); ++i) Src0[0][i] = ieee_rand(0,255);
1744            for(i=0; i<(int)sizeof(Dst0); ++i) Dst0[0][i] = 0x5a;
1745    
1746          printf( "\n ===  test YUV ===\n" );          printf( "\n ===  test YUV ===\n" );
1747    
# Line 1774  Line 1776 
1776  #endif  #endif
1777          printf( " --- \n" );          printf( " --- \n" );
1778  }  }
1779    
1780    #define TEST_YV2(FUNC, WITH_UV, WITH_FLIP)        \
1781    ENTER                               \
1782    for(tst=0; tst<nb_tests; ++tst) (FUNC)(Dst0[0], Dst0[1], Dst0[2], WIDTH, WIDTH, \
1783            Src0[0], (WITH_UV) ? Src0[1] : 0, (WITH_UV) ? Src0[2] : 0,  WIDTH, WIDTH, \
1784            WIDTH-2, HEIGHT-2, WITH_FLIP); \
1785    LEAVE
1786    
1787    #define PRINT_NxN(DATA,W,H,STR)   {   \
1788            int i,j; \
1789            for(j=0; j<(H); ++j) { \
1790                    for(i=0; i<(W); ++i) printf( "0x%.2x ", (DATA)[i+j*(STR)] );\
1791                    printf("\n"); \
1792            } \
1793            printf("---\n"); \
1794    }
1795    
1796    static const int yv12_CRCs[2][2] = {
1797            {0x5cab7cf0,0xdab46541}
1798    ,       {0xe8bae865,0x1faf77b7}
1799    };
1800    
1801    void test_yuv2()
1802    {
1803            const int nb_tests = 800*speed_ref;
1804            CPU *cpu;
1805            uint8_t Src0[3][WIDTH*HEIGHT];
1806            uint8_t Dst0[3][WIDTH*HEIGHT];
1807            int with_uv, with_flip;
1808            int i, j;
1809            double t;
1810            int tst, iCrc;
1811    
1812            colorspace_init();
1813            ieee_reseed(1);
1814            for(i=0; i<(int)sizeof(Src0); ++i) Src0[0][i] = ieee_rand(0,255);
1815    
1816            printf( "\n ===  test YV2 ===\n" );
1817            for(with_flip=0; with_flip<=1; ++with_flip) {
1818                    for(with_uv=0; with_uv<=1; ++with_uv) {
1819                            init_cpu(&cpu_list[0]);
1820                            TEST_YV2(yv12_to_yv12_c, with_uv, with_flip);
1821                            printf(" yv12_to_yv12_c   %.3f usec      \tcrc32=0x%08x %s\n",
1822                                    t, iCrc, (iCrc!=yv12_CRCs[with_flip][with_uv])?"| ERROR": "" );
1823                            /* if (!with_uv) PRINT_NxN(Dst0[1], WIDTH/2, HEIGHT/2, WIDTH ); */
1824    
1825    #ifdef ARCH_IS_IA32
1826                            init_cpu(&cpu_list[1]);
1827                            TEST_YV2(yv12_to_yv12_mmx, with_uv, with_flip);
1828                            printf(" yv12_to_yv12_mmx %.3f usec     \tcrc32=0x%08x %s\n",
1829                                    t, iCrc, (iCrc!=yv12_CRCs[with_flip][with_uv])?"| ERROR": "" );
1830                            /* if (!with_uv) PRINT_NxN(Dst0[1], WIDTH/2, HEIGHT/2, WIDTH ); */
1831    
1832                            TEST_YV2(yv12_to_yv12_xmm, with_uv, with_flip);
1833                            printf(" yv12_to_yv12_xmm %.3f usec     \tcrc32=0x%08x %s\n",
1834                                    t, iCrc, (iCrc!=yv12_CRCs[with_flip][with_uv])?"| ERROR": "" );
1835    #endif
1836                    }
1837    
1838                    printf( " --- \n" );
1839            }
1840            printf( " ===== \n" );
1841    }
1842    
1843  #undef WIDTH  #undef WIDTH
1844  #undef HEIGHT  #undef HEIGHT
1845  #undef ENTER  #undef ENTER
# Line 1944  Line 2010 
2010      printf( "ERROR! please post your platform/compiler specs to xvid-devel@xvid.org !\n" );      printf( "ERROR! please post your platform/compiler specs to xvid-devel@xvid.org !\n" );
2011    }    }
2012  }  }
2013    
2014  /*********************************************************************  /*********************************************************************
2015   * test SSIM functions   * test SSIM functions
2016   *********************************************************************/   *********************************************************************/
# Line 1954  Line 2021 
2021  extern int lum_8x8_c(uint8_t* ptr, int stride);  extern int lum_8x8_c(uint8_t* ptr, int stride);
2022  extern int lum_8x8_mmx(uint8_t* ptr, int stride);  extern int lum_8x8_mmx(uint8_t* ptr, int stride);
2023  extern int lum_2x8_c(uint8_t* ptr, int stride);  extern int lum_2x8_c(uint8_t* ptr, int stride);
2024  extern void iconsim_c(uint8_t* ptro, uint8_t* ptrc, int stride, int lumo, int lumc, int* pdevo, int* pdevc, int* pcorr);  extern void consim_c(uint8_t* ptro, uint8_t* ptrc, int stride, int lumo, int lumc, int* pdevo, int* pdevc, int* pcorr);
2025  extern void consim_mmx(uint8_t* ptro, uint8_t* ptrc, int stride, int lumo, int lumc, int* pdevo, int* pdevc, int* pcorr);  extern void consim_mmx(uint8_t* ptro, uint8_t* ptrc, int stride, int lumo, int lumc, int* pdevo, int* pdevc, int* pcorr);
2026  extern void consim_sse2(uint8_t* ptro, uint8_t* ptrc, int stride, int lumo, int lumc, int* pdevo, int* pdevc, int* pcorr);  extern void consim_sse2(uint8_t* ptro, uint8_t* ptrc, int stride, int lumo, int lumc, int* pdevo, int* pdevc, int* pcorr);
2027    
# Line 1992  Line 2059 
2059                          continue;                          continue;
2060                  lum8x8 = lum_8x8_c;                  lum8x8 = lum_8x8_c;
2061                  lum2x8 = lum_2x8_c;                  lum2x8 = lum_2x8_c;
2062                  csim   = iconsim_c;                  csim   = consim_c;
2063                  if (cpu->cpu & XVID_CPU_MMX){                  if (cpu->cpu & XVID_CPU_MMX){
2064                          lum8x8 = lum_8x8_mmx;                          lum8x8 = lum_8x8_mmx;
2065                          csim = consim_mmx;                          csim = consim_mmx;
# Line 2012  Line 2079 
2079    
2080                  t = gettime_usec();                  t = gettime_usec();
2081                  emms();                  emms();
2082                  for(tst=0; tst<nb_tests; ++tst) m = lum2x8(Ref1, 16);                  for(tst=0; tst<nb_tests; ++tst) m = lum2x8(Ref1+8, 16);
2083                  emms();                  emms();
2084                  t = (gettime_usec() - t) / nb_tests;                  t = (gettime_usec() - t) / nb_tests;
2085                  printf("%s - ssim-lum2x8    %.3f usec       m=%d %s\n",                  printf("%s - ssim-lum2x8    %.3f usec       m=%d %s\n",
2086                             cpu->name, t, m,                             cpu->name, t, m,
2087                             (m!=-841)?"| ERROR": "" );                             (m!=681)?"| ERROR": "" );
2088    
2089                  t = gettime_usec();                  t = gettime_usec();
2090                  emms();                  emms();
# Line 2026  Line 2093 
2093                  t = (gettime_usec() - t) / nb_tests;                  t = (gettime_usec() - t) / nb_tests;
2094                  printf("%s - ssim-consim    %.3f usec       devs=[0x%x 0x%x 0x%x] %s\n",                  printf("%s - ssim-consim    %.3f usec       devs=[0x%x 0x%x 0x%x] %s\n",
2095                             cpu->name, t, devs[0], devs[1], devs[2],                             cpu->name, t, devs[0], devs[1], devs[2],
2096                             (devs[0]!=0xeba80 || devs[1]!=0x1053e7 ||  devs[2]!=0x51215)?"| ERROR": "" );                             (devs[0]!=0x1bdf0f || devs[1]!=0x137258 ||  devs[2]!=0xcdb13)?"| ERROR": "" );
   
2097                  printf( " --- \n" );                  printf( " --- \n" );
2098          }          }
2099  }  }
2100    
2101  /*********************************************************************  /*********************************************************************
2102     * test bitstream functions
2103     *********************************************************************/
2104    
2105    #define BIT_BUF_SIZE 2000
2106    
2107    static void test_bits()
2108    {
2109      const int nb_tests = 50*speed_ref;
2110      int tst;
2111      uint32_t Crc;
2112      uint8_t Buf[BIT_BUF_SIZE];
2113      uint32_t Extracted[BIT_BUF_SIZE*8]; /* worst case: bits read 1 by 1 */
2114      int Lens[BIT_BUF_SIZE*8];
2115      double t1;
2116    
2117    
2118      printf( "\n ===  test bitstream ===\n" );
2119      ieee_reseed(1);
2120      Crc = 0;
2121    
2122      t1 = gettime_usec();
2123      for(tst=0; tst<nb_tests; ++tst) {
2124            Bitstream bs;
2125            int m, m2, l, l2;
2126    
2127            for(l=0; l<BIT_BUF_SIZE; ++l)
2128                    Buf[l] = (uint8_t)ieee_rand(0,255);
2129    
2130            l = BIT_BUF_SIZE - ieee_rand(1,BIT_BUF_SIZE/10);
2131            BitstreamInit(&bs, (void*)(Buf+BIT_BUF_SIZE-l), l);
2132    
2133    
2134            BitstreamReset(&bs);
2135            for(l2=l*8, m=0; l2>0; m++) {
2136                    const int b = ieee_rand(1,32);
2137                    Lens[m] = b;
2138                    l2 -= b;
2139                    if (l2<0) break;
2140                    Extracted[m] = BitstreamShowBits(&bs, b);
2141                    BitstreamSkip(&bs, b);
2142    //              printf( "<= %d: %d 0x%x\n", m, b, Extracted[m]);
2143            }
2144    
2145            BitstreamReset(&bs);
2146            for(m2=0; m2<m; ++m2) {
2147                    const int b = Lens[m2];
2148                    const uint32_t v = BitstreamGetBits(&bs, b);
2149                    Crc |= (v!=Extracted[m2]);
2150    //              printf( "=> %d: %d 0x%x %c\n", m2, b, v, " *"[Crc]);
2151            }
2152      }
2153      t1 = (gettime_usec() - t1) / nb_tests;
2154      printf(" test_bits   %.3f usec   %s\n", t1, (Crc!=0)?"| ERROR": "" );
2155    }
2156    
2157    /*********************************************************************
2158   * main   * main
2159   *********************************************************************/   *********************************************************************/
2160    
# Line 2103  Line 2225 
2225          if (what==0 || what==13) test_compiler();          if (what==0 || what==13) test_compiler();
2226          if (what==0 || what==14) test_yuv();          if (what==0 || what==14) test_yuv();
2227          if (what==0 || what==15) test_SSIM();          if (what==0 || what==15) test_SSIM();
2228            if (what==0 || what==16) test_yuv2();
2229            if (what==0 || what==17) test_bits();
2230    
2231          if (what==7) {          if (what==7) {
2232                  test_IEEE1180_compliance(-256, 255, 1);                  test_IEEE1180_compliance(-256, 255, 1);

Legend:
Removed from v.1737  
changed lines
  Added in v.1746

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