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
10 * Copyright 2012 - 2014
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
62 #if _WIN32 && BUILD_SHARED_LIBS
64 # define AEC_SCOPE __declspec(dllexport)
66 # define AEC_SCOPE extern __declspec(dllimport)
69 # define AEC_SCOPE extern
72 struct internal_state;
75 const unsigned char *next_in;
76 size_t avail_in; /* number of bytes available at
79 size_t total_in; /* total number of input bytes read so
82 unsigned char *next_out;
83 size_t avail_out; /* remaining free space at next_out */
84 size_t total_out; /* total number of bytes output so far */
85 int bits_per_sample; /* resolution in bits per sample (n =
88 int block_size; /* block size in samples */
89 int rsi; /* Reference sample interval, the
90 * number of Coded Data Sets between
91 * consecutive reference samples (up
96 struct internal_state *state;
99 /* Sample data description flags */
100 #define AEC_DATA_SIGNED 1 /* Samples are signed. Telling libaec
101 * this results in a slightly better
102 * compression ratio. Default is
105 #define AEC_DATA_3BYTE 2 /* 24 bit samples are coded in 3 bytes */
106 #define AEC_DATA_MSB 4 /* Samples are stored with their most
107 * significant bit first. This has
108 * nothing to do with the endianness
109 * of the host. Default is LSB.
111 #define AEC_DATA_PREPROCESS 8 /* Set if preprocessor should be used */
113 #define AEC_RESTRICTED 16 /* Use restricted set of code options */
114 #define AEC_PAD_RSI 32 /* Pad RSI to byte boundary. Only for
115 * decoding CCSDS sample data. */
117 /* Return codes of library functions */
119 #define AEC_CONF_ERROR (-1)
120 #define AEC_STREAM_ERROR (-2)
121 #define AEC_DATA_ERROR (-3)
122 #define AEC_MEM_ERROR (-4)
124 /* Options for flushing */
125 #define AEC_NO_FLUSH 0 /* Do not enforce output
126 * flushing. More input may be
127 * provided with later calls. So far
128 * only relevant for encoding.
130 #define AEC_FLUSH 1 /* Flush output and end encoding. The
131 * last call to aec_encode() must set
132 * AEC_FLUSH to drain all output.
134 * It is not possible to continue
135 * encoding of the same stream after it
136 * has been flushed because the last byte
137 * may be padded with fill bits.
140 /* Streaming encoding and decoding functions */
141 AEC_SCOPE int aec_encode_init(struct aec_stream *strm);
142 AEC_SCOPE int aec_encode(struct aec_stream *strm, int flush);
143 AEC_SCOPE int aec_encode_end(struct aec_stream *strm);
145 AEC_SCOPE int aec_decode_init(struct aec_stream *strm);
146 AEC_SCOPE int aec_decode(struct aec_stream *strm, int flush);
147 AEC_SCOPE int aec_decode_end(struct aec_stream *strm);
149 /* Utility functions for encoding or decoding a memory buffer. */
150 AEC_SCOPE int aec_buffer_encode(struct aec_stream *strm);
151 AEC_SCOPE int aec_buffer_decode(struct aec_stream *strm);
153 #endif /* LIBAEC_H */