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 |
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); |