mirror of
https://github.com/webmproject/libwebp.git
synced 2024-12-26 05:38:22 +01:00
msvc: add intrinsic based BitsLog2Floor
Change-Id: Ic0c7d2f03e300c6699e130916a759403e672f9d8
This commit is contained in:
parent
8a69c7d8af
commit
e1f769fe1c
@ -37,6 +37,14 @@ extern "C" {
|
||||
static WEBP_INLINE int BitsLog2Floor(uint32_t n) {
|
||||
return n == 0 ? -1 : 31 ^ __builtin_clz(n);
|
||||
}
|
||||
#elif defined(_MSC_VER) && (defined(_M_X64) || defined(_M_IX86))
|
||||
#include <intrin.h>
|
||||
#pragma intrinsic(_BitScanReverse)
|
||||
|
||||
static WEBP_INLINE int BitsLog2Floor(uint32_t n) {
|
||||
unsigned long first_set_bit;
|
||||
return _BitScanReverse(&first_set_bit, n) ? first_set_bit : -1;
|
||||
}
|
||||
#else
|
||||
static WEBP_INLINE int BitsLog2Floor(uint32_t n) {
|
||||
int log = 0;
|
||||
|
Loading…
Reference in New Issue
Block a user