[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 1707, Mon Jun 5 21:30:49 2006 UTC revision 1731, Wed Oct 11 14:55:28 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.28 2006-06-05 21:30:49 Skal Exp $   * $Id: xvid_bench.c,v 1.29 2006-10-11 14:55:28 Skal Exp $
23   *   *
24   ****************************************************************************/   ****************************************************************************/
25    
# Line 1944  Line 1944 
1944      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" );
1945    }    }
1946  }  }
1947    /*********************************************************************
1948     * test SSIM functions
1949     *********************************************************************/
1950    
1951    typedef int (*lumfunc)(uint8_t* ptr, int stride);
1952    typedef void (*csfunc)(uint8_t* ptro, uint8_t* ptrc, int stride, int lumo, int lumc, int* pdevo, int* pdevc, int* pcorr);
1953    
1954    extern int lum_8x8_c(uint8_t* ptr, int stride);
1955    extern int lum_8x8_mmx(uint8_t* ptr, int stride);
1956    extern int lum_2x8_c(uint8_t* ptr, int stride);
1957    extern void iconsim_c(uint8_t* ptro, uint8_t* ptrc, int stride, int lumo, int lumc, int* pdevo, int* pdevc, int* pcorr);
1958    extern void consim_mmx(uint8_t* ptro, uint8_t* ptrc, int stride, int lumo, int lumc, int* pdevo, int* pdevc, int* pcorr);
1959    extern void consim_sse2(uint8_t* ptro, uint8_t* ptrc, int stride, int lumo, int lumc, int* pdevo, int* pdevc, int* pcorr);
1960    
1961    void test_SSIM()
1962    {
1963            const int nb_tests = 3000*speed_ref;
1964            int tst;
1965            CPU *cpu;
1966            int i;
1967            int devs[3];
1968            long lumo, lumc;
1969            DECLARE_ALIGNED_MATRIX(Ref1, 16, 16, uint8_t, 16);
1970            DECLARE_ALIGNED_MATRIX(Ref2, 16, 16, uint8_t, 16);
1971            lumfunc lum8x8;
1972            lumfunc lum2x8;
1973            csfunc  csim;
1974    
1975            ieee_reseed(1);
1976            printf( "\n ======  test SSIM ======\n" );
1977            for(i=0; i<16*16;++i) {
1978                    long v1, v2;
1979                    v1 = ieee_rand(-256, 511);
1980                    v2 = ieee_rand(-256, 511);
1981                    Ref1[i] = (v1<0) ? 0 : (v1>255) ? 255 : v1;
1982                    Ref2[i] = (v2<0) ? 0 : (v2>255) ? 255 : v2;
1983            }
1984            lumc = ieee_rand(0, 255);
1985            lumo = ieee_rand(0, 255);
1986    
1987            for(cpu = cpu_list; cpu->name!=0; ++cpu)
1988            {
1989                    double t;
1990                    int m;
1991                    if (!init_cpu(cpu))
1992                            continue;
1993                    lum8x8 = lum_8x8_c;
1994                    lum2x8 = lum_2x8_c;
1995                    csim   = iconsim_c;
1996                    if (cpu->cpu & XVID_CPU_MMX){
1997                            lum8x8 = lum_8x8_mmx;
1998                            csim = consim_mmx;
1999                    }
2000                    if (cpu->cpu & XVID_CPU_MMX){
2001                            csim = consim_sse2;
2002                    }
2003    
2004                    t = gettime_usec();
2005                    emms();
2006                    for(tst=0; tst<nb_tests; ++tst) m = lum8x8(Ref1, 16);
2007                    emms();
2008                    t = (gettime_usec() - t) / nb_tests;
2009                    printf("%s - ssim-lum8x8    %.3f usec       m=%d %s\n",
2010                               cpu->name, t, m,
2011                               (m!=8230)?"| ERROR": "" );
2012    
2013                    t = gettime_usec();
2014                    emms();
2015                    for(tst=0; tst<nb_tests; ++tst) m = lum2x8(Ref1, 16);
2016                    emms();
2017                    t = (gettime_usec() - t) / nb_tests;
2018                    printf("%s - ssim-lum2x8    %.3f usec       m=%d %s\n",
2019                               cpu->name, t, m,
2020                               (m!=-841)?"| ERROR": "" );
2021    
2022                    t = gettime_usec();
2023                    emms();
2024                    for(tst=0; tst<nb_tests; ++tst) csim(Ref1, Ref2, 16, lumo, lumc, devs+0, devs+1, devs+2);
2025                    emms();
2026                    t = (gettime_usec() - t) / nb_tests;
2027                    printf("%s - ssim-lum2x8    %.3f usec       devs=[0x%x 0x%x 0x%x] %s\n",
2028                               cpu->name, t, devs[0], devs[1], devs[2],
2029                               (devs[0]!=0xeba80 || devs[1]!=0x1053e7 ||  devs[2]!=0x51215)?"| ERROR": "" );
2030    
2031                    printf( " --- \n" );
2032            }
2033    }
2034    
2035  /*********************************************************************  /*********************************************************************
2036   * main   * main
# Line 2015  Line 2102 
2102          if (what==0 || what==12) test_gcd();          if (what==0 || what==12) test_gcd();
2103          if (what==0 || what==13) test_compiler();          if (what==0 || what==13) test_compiler();
2104          if (what==0 || what==14) test_yuv();          if (what==0 || what==14) test_yuv();
2105            if (what==0 || what==15) test_SSIM();
2106    
2107    
2108          if (what==7) {          if (what==7) {

Legend:
Removed from v.1707  
changed lines
  Added in v.1731

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