OLD | NEW |
1 /* Copyright (c) 2001-2011 Timothy B. Terriberry | 1 /* Copyright (c) 2001-2011 Timothy B. Terriberry |
2 */ | 2 */ |
3 /* | 3 /* |
4 Redistribution and use in source and binary forms, with or without | 4 Redistribution and use in source and binary forms, with or without |
5 modification, are permitted provided that the following conditions | 5 modification, are permitted provided that the following conditions |
6 are met: | 6 are met: |
7 | 7 |
8 - Redistributions of source code must retain the above copyright | 8 - Redistributions of source code must retain the above copyright |
9 notice, this list of conditions and the following disclaimer. | 9 notice, this list of conditions and the following disclaimer. |
10 | 10 |
(...skipping 15 matching lines...) Expand all Loading... |
26 */ | 26 */ |
27 | 27 |
28 #ifdef HAVE_CONFIG_H | 28 #ifdef HAVE_CONFIG_H |
29 #include "config.h" | 29 #include "config.h" |
30 #endif | 30 #endif |
31 | 31 |
32 #include "entcode.h" | 32 #include "entcode.h" |
33 #include "arch.h" | 33 #include "arch.h" |
34 | 34 |
35 #if !defined(EC_CLZ) | 35 #if !defined(EC_CLZ) |
| 36 /*This is a fallback for systems where we don't know how to access |
| 37 a BSR or CLZ instruction (see ecintrin.h). |
| 38 If you are optimizing Opus on a new platform and it has a native CLZ or |
| 39 BZR (e.g. cell, MIPS, x86, etc) then making it available to Opus will be |
| 40 an easy performance win.*/ |
36 int ec_ilog(opus_uint32 _v){ | 41 int ec_ilog(opus_uint32 _v){ |
37 /*On a Pentium M, this branchless version tested as the fastest on | 42 /*On a Pentium M, this branchless version tested as the fastest on |
38 1,000,000,000 random 32-bit integers, edging out a similar version with | 43 1,000,000,000 random 32-bit integers, edging out a similar version with |
39 branches, and a 256-entry LUT version.*/ | 44 branches, and a 256-entry LUT version.*/ |
40 int ret; | 45 int ret; |
41 int m; | 46 int m; |
42 ret=!!_v; | 47 ret=!!_v; |
43 m=!!(_v&0xFFFF0000)<<4; | 48 m=!!(_v&0xFFFF0000)<<4; |
44 _v>>=m; | 49 _v>>=m; |
45 ret|=m; | 50 ret|=m; |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 r=_this->rng>>(l-16); | 84 r=_this->rng>>(l-16); |
80 for(i=BITRES;i-->0;){ | 85 for(i=BITRES;i-->0;){ |
81 int b; | 86 int b; |
82 r=r*r>>15; | 87 r=r*r>>15; |
83 b=(int)(r>>16); | 88 b=(int)(r>>16); |
84 l=l<<1|b; | 89 l=l<<1|b; |
85 r>>=b; | 90 r>>=b; |
86 } | 91 } |
87 return nbits-l; | 92 return nbits-l; |
88 } | 93 } |
OLD | NEW |