5 * Copyright 2012 - 2017
7 * Mathis Rosenhauer, Moritz Hanke, Joerg Behrens
8 * Deutsches Klimarechenzentrum GmbH
10 * 20146 Hamburg Germany
13 * Max-Planck-Institut fuer Meteorologie
18 * All rights reserved.
20 * Redistribution and use in source and binary forms, with or without
21 * modification, are permitted provided that the following conditions
24 * 1. Redistributions of source code must retain the above copyright
25 * notice, this list of conditions and the following disclaimer.
26 * 2. Redistributions in binary form must reproduce the above
27 * copyright notice, this list of conditions and the following
28 * disclaimer in the documentation and/or other materials provided
29 * with the distribution.
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
34 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
35 * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
36 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
37 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
38 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
39 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
40 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
41 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
42 * OF THE POSSIBILITY OF SUCH DAMAGE.
44 * @section DESCRIPTION
46 * Adaptive Entropy Coding library
59 #if BUILDING_LIBAEC && HAVE_VISIBILITY
60 # define LIBAEC_DLL_EXPORTED __attribute__((__visibility__("default")))
61 #elif BUILDING_LIBAEC && defined _MSC_VER
62 # define LIBAEC_DLL_EXPORTED __declspec(dllexport)
63 #elif defined _MSC_VER
64 # define LIBAEC_DLL_EXPORTED __declspec(dllimport)
66 # define LIBAEC_DLL_EXPORTED
69 struct internal_state;
72 const unsigned char *next_in;
74 /* number of bytes available at next_in */
77 /* total number of input bytes read so far */
80 unsigned char *next_out;
82 /* remaining free space at next_out */
85 /* total number of bytes output so far */
88 /* resolution in bits per sample (n = 1, ..., 32) */
89 unsigned int bits_per_sample;
91 /* block size in samples */
92 unsigned int block_size;
94 /* Reference sample interval, the number of Coded Data Sets
95 * between consecutive reference samples (up to 4096). */
100 struct internal_state *state;
103 /*********************************/
104 /* Sample data description flags */
105 /*********************************/
107 /* Samples are signed. Telling libaec this results in a slightly
108 * better compression ratio. Default is unsigned. */
109 #define AEC_DATA_SIGNED 1
111 /* 24 bit samples are coded in 3 bytes */
112 #define AEC_DATA_3BYTE 2
114 /* Samples are stored with their most significant bit first. This has
115 * nothing to do with the endianness of the host. Default is LSB. */
116 #define AEC_DATA_MSB 4
118 /* Set if preprocessor should be used */
119 #define AEC_DATA_PREPROCESS 8
121 /* Use restricted set of code options */
122 #define AEC_RESTRICTED 16
124 /* Pad RSI to byte boundary. Only for decoding CCSDS sample data. */
125 #define AEC_PAD_RSI 32
127 /* Do not enforce standard regarding legal block sizes. */
128 #define AEC_NOT_ENFORCE 64
130 /*************************************/
131 /* Return codes of library functions */
132 /*************************************/
134 #define AEC_CONF_ERROR (-1)
135 #define AEC_STREAM_ERROR (-2)
136 #define AEC_DATA_ERROR (-3)
137 #define AEC_MEM_ERROR (-4)
139 /************************/
140 /* Options for flushing */
141 /************************/
143 /* Do not enforce output flushing. More input may be provided with
144 * later calls. So far only relevant for encoding. */
145 #define AEC_NO_FLUSH 0
147 /* Flush output and end encoding. The last call to aec_encode() must
148 * set AEC_FLUSH to drain all output.
150 * It is not possible to continue encoding of the same stream after it
151 * has been flushed because the last byte may be padded with fill
155 /*********************************************/
156 /* Streaming encoding and decoding functions */
157 /*********************************************/
158 LIBAEC_DLL_EXPORTED int aec_encode_init(struct aec_stream *strm);
159 LIBAEC_DLL_EXPORTED int aec_encode(struct aec_stream *strm, int flush);
160 LIBAEC_DLL_EXPORTED int aec_encode_end(struct aec_stream *strm);
162 LIBAEC_DLL_EXPORTED int aec_decode_init(struct aec_stream *strm);
163 LIBAEC_DLL_EXPORTED int aec_decode(struct aec_stream *strm, int flush);
164 LIBAEC_DLL_EXPORTED int aec_decode_end(struct aec_stream *strm);
166 /***************************************************************/
167 /* Utility functions for encoding or decoding a memory buffer. */
168 /***************************************************************/
169 LIBAEC_DLL_EXPORTED int aec_buffer_encode(struct aec_stream *strm);
170 LIBAEC_DLL_EXPORTED int aec_buffer_decode(struct aec_stream *strm);
176 #endif /* LIBAEC_H */