diff options
author | Nils Wallménius <nils@rockbox.org> | 2009-11-29 10:57:21 +0000 |
---|---|---|
committer | Nils Wallménius <nils@rockbox.org> | 2009-11-29 10:57:21 +0000 |
commit | 727984b4ff75df5729e5b34af20e04b2c90d19c1 (patch) | |
tree | d02a7ee09b065912ae082cbf5e8e1a527ae400a0 | |
parent | 3c1cffae70dfe4eb6c561c8483402739546e8c91 (diff) | |
download | rockbox-727984b4ff75df5729e5b34af20e04b2c90d19c1.tar.gz rockbox-727984b4ff75df5729e5b34af20e04b2c90d19c1.zip |
Use clz instruction to count leading zeroes on armv5+, gives about 2% speedup with one sample on the Gigabeat S
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@23781 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r-- | apps/codecs/libalac/alac.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/apps/codecs/libalac/alac.c b/apps/codecs/libalac/alac.c index 112ad20bad..f94ff0fa9d 100644 --- a/apps/codecs/libalac/alac.c +++ b/apps/codecs/libalac/alac.c @@ -166,6 +166,15 @@ static inline void unreadbits(alac_file *alac, int bits) alac->input_buffer_bitaccumulator *= -1; } +/* ARMv5+ has a clz instruction equivalent to our function. + */ +#if (defined(CPU_ARM) && (ARM_ARCH > 4)) +static inline int count_leading_zeros(uint32_t v) +{ + return __builtin_clz(v); +} +#else + static const unsigned char bittab[16] ICONST_ATTR = { 0, 1, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4 }; @@ -196,9 +205,7 @@ static inline int count_leading_zeros(int input) output -= bittab[input]; return output; } - - - +#endif void basterdised_rice_decompress(alac_file *alac, int32_t *output_buffer, |