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 /apps/codecs/libalac | |
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
Diffstat (limited to 'apps/codecs/libalac')
-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) | |||
166 | alac->input_buffer_bitaccumulator *= -1; | 166 | alac->input_buffer_bitaccumulator *= -1; |
167 | } | 167 | } |
168 | 168 | ||
169 | /* ARMv5+ has a clz instruction equivalent to our function. | ||
170 | */ | ||
171 | #if (defined(CPU_ARM) && (ARM_ARCH > 4)) | ||
172 | static inline int count_leading_zeros(uint32_t v) | ||
173 | { | ||
174 | return __builtin_clz(v); | ||
175 | } | ||
176 | #else | ||
177 | |||
169 | static const unsigned char bittab[16] ICONST_ATTR = { | 178 | static const unsigned char bittab[16] ICONST_ATTR = { |
170 | 0, 1, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4 | 179 | 0, 1, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4 |
171 | }; | 180 | }; |
@@ -196,9 +205,7 @@ static inline int count_leading_zeros(int input) | |||
196 | output -= bittab[input]; | 205 | output -= bittab[input]; |
197 | return output; | 206 | return output; |
198 | } | 207 | } |
199 | 208 | #endif | |
200 | |||
201 | |||
202 | 209 | ||
203 | void basterdised_rice_decompress(alac_file *alac, | 210 | void basterdised_rice_decompress(alac_file *alac, |
204 | int32_t *output_buffer, | 211 | int32_t *output_buffer, |