mirror of
https://github.com/ultravideo/uvg266.git
synced 2024-11-27 11:24:05 +00:00
const bit_table for exp_golomb
This commit is contained in:
parent
763b775d3e
commit
288a4537ba
|
@ -63,7 +63,7 @@ void printf_bitstream(char *msg, ...)
|
|||
}
|
||||
#endif
|
||||
|
||||
bit_table *g_exp_table;
|
||||
const bit_table *g_exp_table;
|
||||
|
||||
//From wikipedia
|
||||
//http://en.wikipedia.org/wiki/Binary_logarithm#Algorithm
|
||||
|
@ -89,17 +89,20 @@ int init_exp_golomb(uint32_t len)
|
|||
uint32_t code_num;
|
||||
uint8_t M;
|
||||
uint32_t info;
|
||||
g_exp_table = (bit_table*)malloc(len*sizeof(bit_table));
|
||||
if(!g_exp_table)
|
||||
bit_table* exp_table;
|
||||
exp_table = (bit_table*)malloc(len*sizeof(bit_table));
|
||||
if(!exp_table)
|
||||
return 0;
|
||||
|
||||
for (code_num = 0; code_num < len; code_num++) {
|
||||
M = (uint8_t)floor_log2(code_num + 1);
|
||||
info = code_num + 1 - (uint32_t)pow(2, M);
|
||||
g_exp_table[code_num].len = M * 2 + 1;
|
||||
g_exp_table[code_num].value = (1<<M) | info;
|
||||
exp_table[code_num].len = M * 2 + 1;
|
||||
exp_table[code_num].value = (1<<M) | info;
|
||||
}
|
||||
|
||||
g_exp_table = exp_table;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
|
@ -58,7 +58,7 @@ typedef struct
|
|||
uint32_t value;
|
||||
} bit_table;
|
||||
|
||||
extern bit_table *g_exp_table;
|
||||
extern const bit_table *g_exp_table;
|
||||
|
||||
int floor_log2(unsigned int n);
|
||||
|
||||
|
|
Loading…
Reference in a new issue