forked from len0rd/rockbox
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
This commit is contained in:
parent
3683bb67db
commit
85aad9b397
6 changed files with 96 additions and 141 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue