~ubuntu-branches/debian/experimental/spice/experimental

« back to all changes in this revision

Viewing changes to celt/libcelt/entcode.c

  • Committer: Package Import Robot
  • Author(s): Liang Guo
  • Date: 2011-07-23 12:21:04 UTC
  • mfrom: (0.1.1)
  • Revision ID: package-import@ubuntu.com-20110723122104-xjpvz3fs8na069hf
Tags: 0.8.2-1
Initial release (Closes: #560721)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#ifdef HAVE_CONFIG_H
 
2
#include "config.h"
 
3
#endif
 
4
 
 
5
#include "entcode.h"
 
6
 
 
7
 
 
8
 
 
9
 
 
10
 
 
11
 
 
12
 
 
13
int ec_ilog(ec_uint32 _v){
 
14
#if defined(EC_CLZ)
 
15
  return EC_CLZ0-EC_CLZ(_v);
 
16
#else
 
17
  /*On a Pentium M, this branchless version tested as the fastest on
 
18
     1,000,000,000 random 32-bit integers, edging out a similar version with
 
19
     branches, and a 256-entry LUT version.*/
 
20
  int ret;
 
21
  int m;
 
22
  ret=!!_v;
 
23
  m=!!(_v&0xFFFF0000)<<4;
 
24
  _v>>=m;
 
25
  ret|=m;
 
26
  m=!!(_v&0xFF00)<<3;
 
27
  _v>>=m;
 
28
  ret|=m;
 
29
  m=!!(_v&0xF0)<<2;
 
30
  _v>>=m;
 
31
  ret|=m;
 
32
  m=!!(_v&0xC)<<1;
 
33
  _v>>=m;
 
34
  ret|=m;
 
35
  ret+=!!(_v&0x2);
 
36
  return ret;
 
37
#endif
 
38
}
 
39