]> git.sesse.net Git - fjl/blob - dehuff.h
Compile with debugging by default.
[fjl] / dehuff.h
1 #ifndef _DEHUFF_H
2 #define _DEHUFF_H 1
3
4 #include <stddef.h>
5 #include <stdint.h>
6 #include <sys/types.h>
7
8 // A function to read bytes from some input source. The bytes should be
9 // already unstuffed (and thus without markers).
10 // A return value of -1 indicates error, a return value of 0 indicates EOF.
11 typedef ssize_t (raw_input_func_t)(void*, uint8_t*, size_t);
12
13 struct huffman_table {
14         unsigned num_codes[17];     // BITS
15         unsigned char codes[256];   // HUFFVAL
16         
17         // Derived values.
18         unsigned huffsize[256];
19         unsigned huffcode[256];
20         int maxcode[16];
21         int mincode[16];
22         unsigned valptr[16];
23 };
24
25 enum coefficient_class {
26         DC_CLASS = 0,
27         AC_CLASS,
28         NUM_COEFF_CLASSES
29 };
30 typedef struct huffman_table huffman_tables_t[NUM_COEFF_CLASSES][4];
31
32 void read_huffman_tables(huffman_tables_t* dst, raw_input_func_t* input_func, void* userdata);
33
34 #endif /* !defined(_DEHUFF_H) */