From 2afee60a7c37aaf47ffdb3b59dee41b2af95ed2a Mon Sep 17 00:00:00 2001 From: skal Date: Mon, 10 Sep 2012 13:13:51 +0200 Subject: [PATCH] speed up for ARM using 8bit for boolean decoder SBITS=8 is reported 20-30% faster on ARM (where 64bit ops are expensive). Also use 32bits for i32. Change-Id: Id6a7197d805061aeb8832f20432512d0d930ebfa --- src/utils/bit_reader.h | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/utils/bit_reader.h b/src/utils/bit_reader.h index 1ef501a5..7ac5f320 100644 --- a/src/utils/bit_reader.h +++ b/src/utils/bit_reader.h @@ -24,7 +24,20 @@ extern "C" { #endif -#define BITS 32 // can be 32, 16 or 8 +//------------------------------------------------------------------------------ +// BITS can be either 32, 16 or 8. Pick values that fit natural register size. + +#if defined(__i386__) || defined(_M_IX86) // x86 32bit +#define BITS 16 +#elif defined(__arm__) || defined(_M_ARM) // ARM +#define BITS 8 +#else // reasonable default +#define BITS 32 +#endif + +//------------------------------------------------------------------------------ +// Derived types and constants + #define MASK ((((bit_t)1) << (BITS)) - 1) #if (BITS == 32) typedef uint64_t bit_t; // natural register type @@ -38,7 +51,7 @@ typedef uint8_t lbit_t; #endif //------------------------------------------------------------------------------ -// Bitreader and code-tree reader +// Bitreader typedef struct VP8BitReader VP8BitReader; struct VP8BitReader { @@ -151,7 +164,7 @@ static WEBP_INLINE int VP8GetSigned(VP8BitReader* const br, int v) { // ----------------------------------------------------------------------------- -// Bitreader +// Bitreader for lossless format typedef struct { uint64_t val_;