cmake: only enable C (not C++)
[platform/upstream/libaec.git] / src / libaec.h
1 /**
2  * @file libaec.h
3  *
4  * @section LICENSE
5  * Copyright 2012 - 2017
6  *
7  * Mathis Rosenhauer, Moritz Hanke, Joerg Behrens
8  * Deutsches Klimarechenzentrum GmbH
9  * Bundesstr. 45a
10  * 20146 Hamburg Germany
11  *
12  * Luis Kornblueh
13  * Max-Planck-Institut fuer Meteorologie
14  * Bundesstr. 53
15  * 20146 Hamburg
16  * Germany
17  *
18  * All rights reserved.
19  *
20  * Redistribution and use in source and binary forms, with or without
21  * modification, are permitted provided that the following conditions
22  * are met:
23  *
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.
30  *
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.
43  *
44  * @section DESCRIPTION
45  *
46  * Adaptive Entropy Coding library
47  *
48  */
49
50 #ifndef LIBAEC_H
51 #define LIBAEC_H 1
52
53 #include <stddef.h>
54
55 #ifdef __cplusplus
56 extern "C"{
57 #endif
58
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)
65 #else
66 #  define LIBAEC_DLL_EXPORTED
67 #endif
68
69 struct internal_state;
70
71 struct aec_stream {
72     const unsigned char *next_in;
73
74     /* number of bytes available at next_in */
75     size_t avail_in;
76
77     /* total number of input bytes read so far */
78     size_t total_in;
79
80     unsigned char *next_out;
81
82     /* remaining free space at next_out */
83     size_t avail_out;
84
85     /* total number of bytes output so far */
86     size_t total_out;
87
88     /* resolution in bits per sample (n = 1, ..., 32) */
89     unsigned int bits_per_sample;
90
91     /* block size in samples */
92     unsigned int block_size;
93
94     /* Reference sample interval, the number of Coded Data Sets
95      * between consecutive reference samples (up to 4096). */
96     unsigned int rsi;
97
98     unsigned int flags;
99
100     struct internal_state *state;
101 };
102
103 /*********************************/
104 /* Sample data description flags */
105 /*********************************/
106
107 /* Samples are signed. Telling libaec this results in a slightly
108  * better compression ratio. Default is unsigned. */
109 #define AEC_DATA_SIGNED 1
110
111 /* 24 bit samples are coded in 3 bytes */
112 #define AEC_DATA_3BYTE 2
113
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
117
118 /* Set if preprocessor should be used */
119 #define AEC_DATA_PREPROCESS 8
120
121 /* Use restricted set of code options */
122 #define AEC_RESTRICTED 16
123
124 /* Pad RSI to byte boundary. Only for decoding CCSDS sample data. */
125 #define AEC_PAD_RSI 32
126
127 /* Do not enforce standard regarding legal block sizes. */
128 #define AEC_NOT_ENFORCE 64
129
130 /*************************************/
131 /* Return codes of library functions */
132 /*************************************/
133 #define AEC_OK 0
134 #define AEC_CONF_ERROR (-1)
135 #define AEC_STREAM_ERROR (-2)
136 #define AEC_DATA_ERROR (-3)
137 #define AEC_MEM_ERROR (-4)
138
139 /************************/
140 /* Options for flushing */
141 /************************/
142
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
146
147 /* Flush output and end encoding. The last call to aec_encode() must
148  * set AEC_FLUSH to drain all output.
149  *
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
152  * bits. */
153 #define AEC_FLUSH 1
154
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);
161
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);
165
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);
171
172 #ifdef __cplusplus
173 }
174 #endif
175
176 #endif /* LIBAEC_H */