mirror of
https://github.com/ultravideo/uvg266.git
synced 2024-11-24 02:24:07 +00:00
Fix coverity warning.
- False positive about a shift with -1 when code_num overflows.
This commit is contained in:
parent
cf2a406aba
commit
62285c405c
|
@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue