[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 1615, Tue May 17 15:55:24 2005 UTC revision 1616, Tue May 17 21:03:32 2005 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.17 2005-05-17 15:40:11 Skal Exp $   * $Id: xvid_bench.c,v 1.18 2005-05-17 21:03:32 Skal Exp $
23   *   *
24   ****************************************************************************/   ****************************************************************************/
25    
# Line 1588  Line 1588 
1588          }          }
1589  #endif  #endif
1590  }  }
1591    /*********************************************************************/
1592    
1593    static uint32_t __inline log2bin_v1(uint32_t value)
1594    {
1595      int n = 0;
1596      while (value) {
1597        value >>= 1;
1598        n++;
1599      }
1600      return n;
1601    }
1602    
1603    static const uint8_t log2_tab_16[256] =  { 0, 1, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4 };
1604    
1605    static uint32_t __inline log2bin_v2(uint32_t value)
1606    {
1607      int n = 0;
1608      if (value & 0xffff0000) {
1609        value >>= 16;
1610        n += 16;
1611      }
1612      if (value & 0xff00) {
1613        value >>= 8;
1614        n += 8;
1615      }
1616      if (value & 0xf0) {
1617        value >>= 4;
1618        n += 4;
1619      }
1620     return n + log2_tab_16[value];
1621    }
1622    
1623    void test_log2bin()
1624    {
1625            const int nb_tests = 3000*speed_ref;
1626      int n, crc1=0, crc2=0;
1627      uint32_t s, s0;
1628      double t1, t2;
1629    
1630      t1 = gettime_usec();
1631      s0 = (int)(t1*31.241);
1632      for(s=s0, n=0; n<nb_tests; ++n, s=(s*12363+31)&0x7fffffff)
1633        crc1 += log2bin_v1(s);
1634      t1 = (gettime_usec()-t1) / nb_tests;
1635    
1636      t2 = gettime_usec();
1637      for(s=s0, n=0; n<nb_tests; ++n, s=(s*12363+31)&0x7fffffff)
1638        crc2 += log2bin_v2(s);
1639      t2 = (gettime_usec() - t2) / nb_tests;
1640      printf( "log2bin_v1: %.3f sec  crc=%d\n", t1, crc1 );
1641      printf( "log2bin_v2: %.3f sec  crc=%d\n", t2, crc2 );
1642      if (crc1!=crc2) printf( " CRC ERROR !\n" );
1643    }
1644    
1645  /*********************************************************************  /*********************************************************************
1646   * main   * main
# Line 1655  Line 1708 
1708          if (what==0 || what==5) test_quant();          if (what==0 || what==5) test_quant();
1709          if (what==0 || what==6) test_cbp();          if (what==0 || what==6) test_cbp();
1710          if (what==0 || what==10) test_sse();          if (what==0 || what==10) test_sse();
1711            if (what==0 || what==11) test_log2bin();
1712    
1713    
1714          if (what==7) {          if (what==7) {
1715                  test_IEEE1180_compliance(-256, 255, 1);                  test_IEEE1180_compliance(-256, 255, 1);

Legend:
Removed from v.1615  
changed lines
  Added in v.1616

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