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 */
97 #define AEC_DATA_RESTRICT 16 /* Use restricted set of code options */
99 /* Return codes of library functions */
101 #define AEC_CONF_ERROR (-1)
102 #define AEC_STREAM_ERROR (-2)
103 #define AEC_DATA_ERROR (-3)
104 #define AEC_MEM_ERROR (-4)
106 /* Options for flushing */
107 #define AEC_NO_FLUSH 0 /* Do not enforce output
108 * flushing. More input may be
109 * provided with later calls. So far
110 * only relevant for encoding.
112 #define AEC_FLUSH 1 /* Flush output and end encoding. The
113 * last call to aec_encode() must set
114 * AEC_FLUSH to drain all output.
116 * It is not possible to continue
117 * encoding of the same stream after it
118 * has been flushed because the last byte
119 * may be padded with fill bits.
122 /* Streaming encoding and decoding functions */
123 int aec_encode_init(struct aec_stream *strm);
124 int aec_encode(struct aec_stream *strm, int flush);
125 int aec_encode_end(struct aec_stream *strm);
127 int aec_decode_init(struct aec_stream *strm);
128 int aec_decode(struct aec_stream *strm, int flush);
129 int aec_decode_end(struct aec_stream *strm);
131 /* Utility functions for encoding or decoding a memory buffer. */
132 int aec_buffer_encode(struct aec_stream *strm);
133 int aec_buffer_decode(struct aec_stream *strm);
135 #endif /* LIBAEC_H */