6 static int hufvals[] = {
7 1, 1, 1, 1, 1, 1, 1, 1,
8 2, 2, 2, 2, 2, 2, 2, 2,
9 4, 4, 4, 4, 4, 4, 4, 4,
10 8, 8, 8, 8, 8, 8, 8, 8,
11 3, 3, 3, 3, 5, 5, 5, 5,
12 10, 10, 10, 10, 12, 12, 12, 12,
13 15, 15, 15, 15, 6, 6, 7, 7,
14 9, 9, 11, 11, 13, 13, 0, 14
17 static int huflens[] = {
18 3, 3, 3, 3, 3, 3, 3, 3,
19 3, 3, 3, 3, 3, 3, 3, 3,
20 3, 3, 3, 3, 3, 3, 3, 3,
21 3, 3, 3, 3, 3, 3, 3, 3,
22 4, 4, 4, 4, 4, 4, 4, 4,
23 4, 4, 4, 4, 4, 4, 4, 4,
24 4, 4, 4, 4, 5, 5, 5, 5,
25 5, 5, 5, 5, 5, 5, 6, 6
29 static int bits_to_go; /* Number of bits still in buffer */
32 start_inputing_bits(void)
38 input_huffman(Biobuf *infile)
45 fprint(2, "input_huffman: unexpected EOF\n");
48 buffer = (buffer<<8) | c;
51 c = (buffer >> (bits_to_go-6)) & 0x3f;
52 bits_to_go -= huflens[c];
57 input_nybble(Biobuf *infile)
64 fprint(2, "input_nybble: unexpected EOF\n");
67 buffer = (buffer<<8) | c;
72 * pick off the first 4 bits
75 return (buffer>>bits_to_go) & 0x0f;