Debian Codegraph @

converter/other/jbig/libjbig/include/jbig_ar.h

raw
1 /*
2 * Header file for the arithmetic encoder and decoder of
3 * the portable JBIG compression library
4 *
5 * Markus Kuhn -- http://www.cl.cam.ac.uk/~mgk25/jbigkit/
6 */
7
8 #ifndef JBG_AR_H
9 #define JBG_AR_H
10
11 /*
12 * Status of arithmetic encoder
13 */
14
15 struct jbg_arenc_state {
16 unsigned char st[4096]; /* probability status for contexts, MSB = MPS */
17 unsigned long c; /* register C: base of coding interval, *
18 * layout as in Table 23 */
19 unsigned long a; /* register A: normalized size of coding interval */
20 long sc; /* number of buffered 0xff values that might still overflow */
21 int ct; /* bit shift counter, determines when next byte will be written */
22 int buffer; /* buffer for most recent output byte != 0xff */
23 void (*byte_out)(int, void *); /* function that receives all PSCD bytes */
24 void *file; /* parameter passed to byte_out */
25 };
26
27 /*
28 * Status of arithmetic decoder
29 */
30
31 struct jbg_ardec_state {
32 unsigned char st[4096]; /* probability status for contexts, MSB = MPS */
33 unsigned long c; /* register C: base of coding interval, *
34 * layout as in Table 25 */
35 unsigned long a; /* register A: normalized size of coding interval */
36 unsigned char *pscd_ptr; /* pointer to next PSCD data byte */
37 unsigned char *pscd_end; /* pointer to byte after PSCD */
38 int ct; /* bit-shift counter, determines when next byte will be read;
39 * special value -1 signals that zero-padding has started */
40 int startup; /* boolean flag that controls initial fill of s->c */
41 int nopadding; /* boolean flag that triggers return -2 between
42 * reaching PSCD end and decoding the first symbol
43 * that might never have been encoded in the first
44 * place */
45 };
46
47 void arith_encode_init(struct jbg_arenc_state *s, int reuse_st);
48 void arith_encode_flush(struct jbg_arenc_state *s);
49 void arith_encode(struct jbg_arenc_state *s, int cx, int pix);
50 void arith_decode_init(struct jbg_ardec_state *s, int reuse_st);
51 int arith_decode(struct jbg_ardec_state *s, int cx);
52
53 #endif /* JBG_AR_H */