From 07418d9dd8c486c4b3842a4268b272ed6f1b9c54 Mon Sep 17 00:00:00 2001 From: Gregory Maxwell Date: Tue, 27 Nov 2012 12:51:20 -0500 Subject: [PATCH] Guard _BitScanReverse on MSVC so that MSVC 6 doesn't break. This also adds some extra casts to shut up compiler warnings reported on MSVC 6 where there is implicit truncation for the arguments of bitexact_cos(). Lacking access to CLZ/BSR will make the code a fair bit slower but that is better than failing to compile. --- celt/bands.c | 4 ++-- celt/ecintrin.h | 2 +- celt/entcode.c | 5 +++++ 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/celt/bands.c b/celt/bands.c index 8883f40a..35eb83e5 100644 --- a/celt/bands.c +++ b/celt/bands.c @@ -923,8 +923,8 @@ static unsigned quant_band(int encode, const CELTMode *m, int i, celt_norm *X, c fill &= ((1<= 1400) # include /*In _DEBUG mode this is not an intrinsic by default.*/ # pragma intrinsic(_BitScanReverse) diff --git a/celt/entcode.c b/celt/entcode.c index 02ac690b..fa5d7c7c 100644 --- a/celt/entcode.c +++ b/celt/entcode.c @@ -33,6 +33,11 @@ #include "arch.h" #if !defined(EC_CLZ) +/*This is a fallback for systems where we don't know how to access + a BSR or CLZ instruction (see ecintrin.h). + If you are optimizing Opus on a new platform and it has a native CLZ or + BZR (e.g. cell, MIPS, x86, etc) then making it available to Opus will be + an easy performance win.*/ int ec_ilog(opus_uint32 _v){ /*On a Pentium M, this branchless version tested as the fastest on 1,000,000,000 random 32-bit integers, edging out a similar version with