Decoder: turn FSM switch into functions
[platform/upstream/libaec.git] / src / decode.h
1 #ifndef DECODE_H
2 #define DECODE_H
3
4 #include <config.h>
5
6 #if HAVE_STDINT_H
7 # include <stdint.h>
8 #endif
9
10 #include "libaec.h"
11
12 #define M_CONTINUE 1
13 #define M_EXIT 0
14
15 #define SAFE (strm->avail_in >= state->in_blklen        \
16               && strm->avail_out >= state->out_blklen)
17
18 #define ROS 5
19 #define MIN(a, b) (((a) < (b))? (a): (b))
20
21 struct internal_state {
22     int (*mode)(struct aec_stream *);
23     int id;            /* option ID */
24     int id_len;        /* bit length of code option identification key */
25     int (**id_table)(struct aec_stream *); /* table maps IDs to states */
26     void (*put_sample)(struct aec_stream *, int64_t);
27     int ref_int;       /* reference sample is every ref_int samples */
28     int64_t last_out;  /* previous output for post-processing */
29     int64_t xmin;      /* minimum integer for post-processing */
30     int64_t xmax;      /* maximum integer for post-processing */
31     int in_blklen;     /* length of uncompressed input block
32                           should be the longest possible block */
33     int out_blklen;    /* length of output block in bytes */
34     int n, i;          /* counter for samples */
35     int64_t *block;    /* block buffer for split-sample options */
36     int se;            /* set if second extension option is selected */
37     uint64_t acc;      /* accumulator for currently used bit sequence */
38     int bitp;          /* bit pointer to the next unused bit in accumulator */
39     int fs;            /* last fundamental sequence in accumulator */
40     int ref;           /* 1 if current block has reference sample */
41     int pp;            /* 1 if postprocessor has to be used */
42     int byte_per_sample;
43     size_t samples_out;
44 } decode_state;
45
46 #endif /* DECODE_H */