Commit 494bce62 authored by Kostya Shishkov's avatar Kostya Shishkov

ralf: read Huffman code lengths without GetBitContext

Those descriptions are stored in nibbles, so they are easy to extract.
And this way we don't need to pad tables for possible bit reader overreads.
parent cb7190cd
...@@ -80,17 +80,17 @@ static int init_ralf_vlc(VLC *vlc, const uint8_t *data, int elems) ...@@ -80,17 +80,17 @@ static int init_ralf_vlc(VLC *vlc, const uint8_t *data, int elems)
int counts[17], prefixes[18]; int counts[17], prefixes[18];
int i, cur_len; int i, cur_len;
int max_bits = 0; int max_bits = 0;
GetBitContext gb; int nb = 0;
init_get_bits(&gb, data, elems * 4);
for (i = 0; i <= 16; i++) for (i = 0; i <= 16; i++)
counts[i] = 0; counts[i] = 0;
for (i = 0; i < elems; i++) { for (i = 0; i < elems; i++) {
cur_len = get_bits(&gb, 4) + 1; cur_len = (nb ? *data & 0xF : *data >> 4) + 1;
counts[cur_len]++; counts[cur_len]++;
max_bits = FFMAX(max_bits, cur_len); max_bits = FFMAX(max_bits, cur_len);
lens[i] = cur_len; lens[i] = cur_len;
data += nb;
nb ^= 1;
} }
prefixes[1] = 0; prefixes[1] = 0;
for (i = 1; i <= 16; i++) for (i = 1; i <= 16; i++)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment