Fix compiler warnings for VS2010 /W4 in bitstream.c and cabac.c.

- Working towards issue #11.
This commit is contained in:
Ari Koivula 2014-02-21 11:57:25 +02:00
parent 8768f2bb22
commit db3b96b90b
2 changed files with 11 additions and 5 deletions

View file

@ -74,14 +74,14 @@ int floor_log2(unsigned int n) {
int init_exp_golomb(uint32_t len) int init_exp_golomb(uint32_t len)
{ {
uint32_t code_num; uint32_t code_num;
uint32_t M; uint8_t M;
uint32_t info; uint32_t info;
g_exp_table = (bit_table*)malloc(len*sizeof(bit_table)); g_exp_table = (bit_table*)malloc(len*sizeof(bit_table));
if(!g_exp_table) if(!g_exp_table)
return 0; return 0;
for (code_num = 0; code_num < len; code_num++) { for (code_num = 0; code_num < len; code_num++) {
M = (uint32_t)floor_log2(code_num + 1); M = (uint8_t)floor_log2(code_num + 1);
info = code_num + 1 - (uint32_t)pow(2, M); info = code_num + 1 - (uint32_t)pow(2, M);
g_exp_table[code_num].len = M * 2 + 1; g_exp_table[code_num].len = M * 2 + 1;
g_exp_table[code_num].value = (1<<M) | info; g_exp_table[code_num].value = (1<<M) | info;
@ -179,7 +179,7 @@ void bitstream_clear_buffer(bitstream *stream)
*/ */
void bitstream_put(bitstream *stream, uint32_t data, uint8_t bits) void bitstream_put(bitstream *stream, uint32_t data, uint8_t bits)
{ {
uint32_t bitsleft = 32 - stream->cur_bit; uint8_t bitsleft = 32 - stream->cur_bit;
#ifdef VERBOSE #ifdef VERBOSE
uint8_t i=0; uint8_t i=0;
printf_bitstream("put: "); printf_bitstream("put: ");

View file

@ -105,7 +105,7 @@ void cabac_encode_bin(cabac_data *data, uint32_t bin_value)
data->range -= lps; data->range -= lps;
// Not the Most Probable Symbol? // Not the Most Probable Symbol?
if (bin_value != CTX_MPS(data->ctx)) { if (bin_value != (uint32_t)CTX_MPS(data->ctx)) {
int num_bits = g_auc_renorm_table[lps >> 3]; int num_bits = g_auc_renorm_table[lps >> 3];
data->low = (data->low + data->range) << num_bits; data->low = (data->low + data->range) << num_bits;
data->range = lps << num_bits; data->range = lps << num_bits;
@ -162,6 +162,8 @@ void cabac_write(cabac_data *data)
*/ */
void cabac_finish(cabac_data *data) void cabac_finish(cabac_data *data)
{ {
assert(data->bits_left <= 32);
if (data->low >> (32 - data->bits_left)) { if (data->low >> (32 - data->bits_left)) {
bitstream_put(data->stream,data->buffered_byte + 1, 8); bitstream_put(data->stream,data->buffered_byte + 1, 8);
while (data->num_buffered_bytes > 1) { while (data->num_buffered_bytes > 1) {
@ -178,7 +180,11 @@ void cabac_finish(cabac_data *data)
data->num_buffered_bytes--; data->num_buffered_bytes--;
} }
} }
bitstream_put(data->stream, data->low >> 8, 24 - data->bits_left);
{
uint8_t bits = (uint8_t)(24 - data->bits_left);
bitstream_put(data->stream, data->low >> 8, bits);
}
} }
/*! /*!