add wide version of silog2

This commit is contained in:
Josh Coalson 2002-10-04 05:24:10 +00:00
parent 881a36d0e8
commit bf26db9129
2 changed files with 25 additions and 0 deletions

View File

@ -98,3 +98,27 @@ unsigned FLAC__bitmath_silog2(int v)
}
}
}
unsigned FLAC__bitmath_silog2_wide(FLAC__int64 v)
{
while(1) {
if(v == 0) {
return 0;
}
else if(v > 0) {
unsigned l = 0;
while(v) {
l++;
v >>= 1;
}
return l+1;
}
else if(v == -1) {
return 2;
}
else {
v++;
v = -v;
}
}
}

View File

@ -24,5 +24,6 @@
unsigned FLAC__bitmath_ilog2(unsigned v);
unsigned FLAC__bitmath_silog2(int v);
unsigned FLAC__bitmath_silog2_wide(FLAC__int64 v);
#endif