Reformatting
[platform/upstream/libaec.git] / src / libaec.h
1 #ifndef LIBAEC_H
2 #define LIBAEC_H
3
4 #include <inttypes.h>
5 #include <stddef.h>
6
7 struct internal_state;
8
9 struct aec_stream {
10     const uint8_t *next_in;
11     size_t avail_in;         /* number of bytes available at
12                               * next_in */
13     size_t total_in;         /* total number of input bytes read so
14                               * far */
15     uint8_t *next_out;
16     size_t avail_out;        /* remaining free space at next_out */
17     size_t total_out;        /* total number of bytes output so far */
18     uint32_t bit_per_sample; /* resolution in bits per sample (n =
19                               * 1,..., 32) */
20     uint32_t block_size;     /* block size in samples (J = 8 or 16) */
21     uint32_t rsi;            /* Reference sample interval, the number of
22                                 blocks between consecutive reference
23                                 samples. */
24     uint32_t flags;
25
26     struct internal_state *state;
27 };
28
29 /* Coder flags */
30 #define AEC_DATA_UNSIGNED     0
31 #define AEC_DATA_SIGNED       1
32 #define AEC_DATA_3BYTE        2  /* 24 bit samples coded in 3 bytes */
33 #define AEC_DATA_LSB          0
34 #define AEC_DATA_MSB         16
35 #define AEC_DATA_PREPROCESS  32  /* Set if preprocessor should be used */
36
37 /* Return codes of library functions */
38 #define AEC_OK            0
39 #define AEC_CONF_ERROR   (-1)
40 #define AEC_STREAM_ERROR (-2)
41 #define AEC_DATA_ERROR   (-3)
42 #define AEC_MEM_ERROR    (-4)
43
44 /* Options for flushing */
45 #define AEC_NO_FLUSH      0 /* Do not enforce output flushing. More
46                             * input may be provided with later
47                             * calls. So far only relevant for
48                             * encoding.
49                             */
50 #define AEC_FLUSH         1 /* Flush output and end encoding. The last
51                             * call to aec_encode() must set AEC_FLUSH to
52                             * drain all output.
53                             *
54                             * It is not possible to continue encoding
55                             * of the same stream after it has been
56                             * flushed because the last byte may be
57                             * padded with fill bits.
58                             */
59
60 int aec_decode_init(struct aec_stream *strm);
61 int aec_decode(struct aec_stream *strm, int flush);
62 int aec_decode_end(struct aec_stream *strm);
63
64 int aec_encode_init(struct aec_stream *strm);
65 int aec_encode(struct aec_stream *strm, int flush);
66 int aec_encode_end(struct aec_stream *strm);
67
68 #endif /* LIBAEC_H */