diff --git a/src/bitstream.c b/src/bitstream.c index ca44347e..be53f088 100644 --- a/src/bitstream.c +++ b/src/bitstream.c @@ -61,16 +61,16 @@ void printf_bitstream(char *msg, ...) const bit_table_t *g_exp_table; -//From wikipedia -//http://en.wikipedia.org/wiki/Binary_logarithm#Algorithm static int floor_log2(unsigned int n) { + assert(n != 0); + int pos = 0; if (n >= 1<<16) { n >>= 16; pos += 16; } if (n >= 1<< 8) { n >>= 8; pos += 8; } if (n >= 1<< 4) { n >>= 4; pos += 4; } if (n >= 1<< 2) { n >>= 2; pos += 2; } if (n >= 1<< 1) { pos += 1; } - return ((n == 0) ? (-1) : pos); + return pos; } /**