summaryrefslogtreecommitdiff
path: root/apps/codecs/libalac/alac.c
diff options
context:
space:
mode:
authorAndrew Mahone <andrew.mahone@gmail.com>2009-12-09 02:24:45 +0000
committerAndrew Mahone <andrew.mahone@gmail.com>2009-12-09 02:24:45 +0000
commit85aad9b3972208b0e34ba0241ebb5314118ae05e (patch)
tree27724c068f90b517d4bf9be6ed78d34a01eeba9b /apps/codecs/libalac/alac.c
parent3683bb67db4d5d59a55aabed6eaed72233323ee7 (diff)
downloadrockbox-85aad9b3972208b0e34ba0241ebb5314118ae05e.tar.gz
rockbox-85aad9b3972208b0e34ba0241ebb5314118ae05e.zip
Extend av_log2 in codeclib into a generic for scanning for set bits, which can provide either log2 or leading-zero-count output, and can force mapping 0 input to 0 output if needed (otherwise 0 input produces undefined result). Replace av_log2 in lib/codeclib.h, floor_log2 and wl_min_lzc in libfaad/common.c and common.h, and count_leading_zeros in libalac/alac.c with macros using bs_generic.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@23903 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/codecs/libalac/alac.c')
-rw-r--r--apps/codecs/libalac/alac.c41
1 files changed, 1 insertions, 40 deletions
diff --git a/apps/codecs/libalac/alac.c b/apps/codecs/libalac/alac.c
index f94ff0fa9d..1f7867b648 100644
--- a/apps/codecs/libalac/alac.c
+++ b/apps/codecs/libalac/alac.c
@@ -166,46 +166,7 @@ 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. 169#define count_leading_zeros(x) bs_generic(x, BS_CLZ|BS_SHORT)
170 */
171#if (defined(CPU_ARM) && (ARM_ARCH > 4))
172static inline int count_leading_zeros(uint32_t v)
173{
174 return __builtin_clz(v);
175}
176#else
177
178static const unsigned char bittab[16] ICONST_ATTR = {
179 0, 1, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4
180};
181
182static inline int count_leading_zeros(int input)
183{
184 int output = 32;
185
186#if 0
187 /* Experimentation has shown that the following test is always false,
188 so we don't bother to perform it. */
189 if (input & 0xffff0000)
190 {
191 input >>= 16;
192 output -= 16;
193 }
194#endif
195 if (input & 0xff00)
196 {
197 input >>= 8;
198 output -= 8;
199 }
200 if (input & 0xf0)
201 {
202 input >>= 4;
203 output -= 4;
204 }
205 output -= bittab[input];
206 return output;
207}
208#endif
209 170
210void basterdised_rice_decompress(alac_file *alac, 171void basterdised_rice_decompress(alac_file *alac,
211 int32_t *output_buffer, 172 int32_t *output_buffer,