Skip to content

Commit

Permalink
ralf: read Huffman code lengths without GetBitContext
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Kostya Shishkov committed Mar 24, 2012
1 parent cb7190c commit 494bce6
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions libavcodec/ralf.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,17 +80,17 @@ static int init_ralf_vlc(VLC *vlc, const uint8_t *data, int elems)
int counts[17], prefixes[18];
int i, cur_len;
int max_bits = 0;
GetBitContext gb;

init_get_bits(&gb, data, elems * 4);
int nb = 0;

for (i = 0; i <= 16; i++)
counts[i] = 0;
for (i = 0; i < elems; i++) {
cur_len = get_bits(&gb, 4) + 1;
cur_len = (nb ? *data & 0xF : *data >> 4) + 1;
counts[cur_len]++;
max_bits = FFMAX(max_bits, cur_len);
lens[i] = cur_len;
data += nb;
nb ^= 1;
}
prefixes[1] = 0;
for (i = 1; i <= 16; i++)
Expand Down

0 comments on commit 494bce6

Please sign in to comment.