From 85aad9b3972208b0e34ba0241ebb5314118ae05e Mon Sep 17 00:00:00 2001 From: Andrew Mahone Date: Wed, 9 Dec 2009 02:24:45 +0000 Subject: 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 --- apps/codecs/libalac/alac.c | 41 +---------------------------------------- 1 file changed, 1 insertion(+), 40 deletions(-) (limited to 'apps/codecs/libalac/alac.c') 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) 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 -}; - -static inline int count_leading_zeros(int input) -{ - int output = 32; - -#if 0 - /* Experimentation has shown that the following test is always false, - so we don't bother to perform it. */ - if (input & 0xffff0000) - { - input >>= 16; - output -= 16; - } -#endif - if (input & 0xff00) - { - input >>= 8; - output -= 8; - } - if (input & 0xf0) - { - input >>= 4; - output -= 4; - } - output -= bittab[input]; - return output; -} -#endif +#define count_leading_zeros(x) bs_generic(x, BS_CLZ|BS_SHORT) void basterdised_rice_decompress(alac_file *alac, int32_t *output_buffer, -- cgit v1.2.3