diff options
| author | Andrew Mahone <andrew.mahone@gmail.com> | 2009-12-09 02:24:45 +0000 |
|---|---|---|
| committer | Andrew Mahone <andrew.mahone@gmail.com> | 2009-12-09 02:24:45 +0000 |
| commit | 85aad9b3972208b0e34ba0241ebb5314118ae05e (patch) | |
| tree | 27724c068f90b517d4bf9be6ed78d34a01eeba9b /apps/codecs/lib/codeclib.c | |
| parent | 3683bb67db4d5d59a55aabed6eaed72233323ee7 (diff) | |
| download | rockbox-85aad9b3972208b0e34ba0241ebb5314118ae05e.zip rockbox-85aad9b3972208b0e34ba0241ebb5314118ae05e.tar.gz rockbox-85aad9b3972208b0e34ba0241ebb5314118ae05e.tar.bz2 rockbox-85aad9b3972208b0e34ba0241ebb5314118ae05e.tar.xz | |
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/lib/codeclib.c')
| -rw-r--r-- | apps/codecs/lib/codeclib.c | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/apps/codecs/lib/codeclib.c b/apps/codecs/lib/codeclib.c index 1c624e0..3a13706 100644 --- a/apps/codecs/lib/codeclib.c +++ b/apps/codecs/lib/codeclib.c @@ -33,6 +33,15 @@ unsigned char* mp3buf; // The actual MP3 buffer from Rockbox unsigned char* mallocbuf; // 512K from the start of MP3 buffer unsigned char* filebuf; // The rest of the MP3 buffer +unsigned bs_log2(unsigned x) +{ return bs_generic(x, BS_LOG2); } +unsigned bs_log2_0(unsigned x) +{ return bs_generic(x, BS_LOG2|BS_0_0); } +unsigned bs_clz(unsigned x) +{ return bs_generic(x, BS_CLZ); } +unsigned bs_clz_0(unsigned x) +{ return bs_generic(x, BS_CLZ|BS_0_0); } + int codec_init(void) { mem_ptr = 0; @@ -139,7 +148,7 @@ void qsort(void *base, size_t nmemb, size_t size, } /* From ffmpeg - libavutil/common.h */ -const uint8_t ff_log2_tab[256] ICONST_ATTR = { +const uint8_t bs_log2_tab[256] ICONST_ATTR = { 0,0,1,1,2,2,2,2,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4, 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5, 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6, @@ -150,6 +159,17 @@ const uint8_t ff_log2_tab[256] ICONST_ATTR = { 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7 }; +const uint8_t bs_clz_tab[256] ICONST_ATTR = { + 8,7,6,6,5,5,5,5,4,4,4,4,4,4,4,4,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3, + 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2, + 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, + 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +}; + #ifdef RB_PROFILE void __cyg_profile_func_enter(void *this_fn, void *call_site) { #ifdef CPU_COLDFIRE |