4 * @author Mathis Rosenhauer, Deutsches Klimarechenzentrum
5 * @author Moritz Hanke, Deutsches Klimarechenzentrum
6 * @author Joerg Behrens, Deutsches Klimarechenzentrum
7 * @author Luis Kornblueh, Max-Planck-Institut fuer Meteorologie
12 * Mathis Rosenhauer, Luis Kornblueh
16 * Deutsches Klimarechenzentrum GmbH Max-Planck-Institut fuer Meteorologie
17 * Bundesstr. 45a Bundesstr. 53
18 * 20146 Hamburg 20146 Hamburg
21 * All rights reserved.
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
27 * 1. Redistributions of source code must retain the above copyright
28 * notice, this list of conditions and the following disclaimer.
29 * 2. Redistributions in binary form must reproduce the above
30 * copyright notice, this list of conditions and the following
31 * disclaimer in the documentation and/or other materials provided
32 * with the distribution.
34 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
35 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
36 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
37 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
38 * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
39 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
40 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
41 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
42 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
43 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
44 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
45 * OF THE POSSIBILITY OF SUCH DAMAGE.
47 * @section DESCRIPTION
49 * Adaptive Entropy Coding library
58 struct internal_state;
61 const unsigned char *next_in;
62 size_t avail_in; /* number of bytes available at
65 size_t total_in; /* total number of input bytes read so
68 unsigned char *next_out;
69 size_t avail_out; /* remaining free space at next_out */
70 size_t total_out; /* total number of bytes output so far */
71 int bits_per_sample; /* resolution in bits per sample (n =
74 int block_size; /* block size in samples */
75 int rsi; /* Reference sample interval, the number
76 * of _blocks_ between consecutive
77 * reference samples (up to 4096).
81 struct internal_state *state;
84 /* Sample data description flags */
85 #define AEC_DATA_SIGNED 1 /* Samples are signed. Telling libaec
86 * this results in a slightly better
87 * compression ratio. Default is
90 #define AEC_DATA_3BYTE 2 /* 24 bit samples are coded in 3 bytes */
91 #define AEC_DATA_MSB 4 /* Samples are stored with their most
92 * significant bit first. This has
93 * nothing to do with the endianness
94 * of the host. Default is LSB.
96 #define AEC_DATA_PREPROCESS 8 /* Set if preprocessor should be used */
98 /* Return codes of library functions */
100 #define AEC_CONF_ERROR (-1)
101 #define AEC_STREAM_ERROR (-2)
102 #define AEC_DATA_ERROR (-3)
103 #define AEC_MEM_ERROR (-4)
105 /* Options for flushing */
106 #define AEC_NO_FLUSH 0 /* Do not enforce output
107 * flushing. More input may be
108 * provided with later calls. So far
109 * only relevant for encoding.
111 #define AEC_FLUSH 1 /* Flush output and end encoding. The
112 * last call to aec_encode() must set
113 * AEC_FLUSH to drain all output.
115 * It is not possible to continue
116 * encoding of the same stream after it
117 * has been flushed because the last byte
118 * may be padded with fill bits.
121 /* Streaming encoding and decoding functions */
122 int aec_encode_init(struct aec_stream *strm);
123 int aec_encode(struct aec_stream *strm, int flush);
124 int aec_encode_end(struct aec_stream *strm);
126 int aec_decode_init(struct aec_stream *strm);
127 int aec_decode(struct aec_stream *strm, int flush);
128 int aec_decode_end(struct aec_stream *strm);
130 /* Utility functions for encoding or decoding a memory buffer. */
131 int aec_buffer_encode(struct aec_stream *strm);
132 int aec_buffer_decode(struct aec_stream *strm);
134 #endif /* LIBAEC_H */