Fixed Windows static lib buid.
[platform/upstream/libaec.git] / src / libaec.h
1 /**
2  * @file libaec.h
3  *
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
8  *
9  * @section LICENSE
10  * Copyright 2012 - 2014
11  *
12  * Mathis Rosenhauer,                 Luis Kornblueh
13  * Moritz Hanke,
14  * Joerg Behrens
15  *
16  * Deutsches Klimarechenzentrum GmbH  Max-Planck-Institut fuer Meteorologie
17  * Bundesstr. 45a                     Bundesstr. 53
18  * 20146 Hamburg                      20146 Hamburg
19  * Germany                            Germany
20  *
21  * All rights reserved.
22  *
23  * Redistribution and use in source and binary forms, with or without
24  * modification, are permitted provided that the following conditions
25  * are met:
26  *
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.
33  *
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.
46  *
47  * @section DESCRIPTION
48  *
49  * Adaptive Entropy Coding library
50  *
51  */
52
53 #ifndef LIBAEC_H
54 #define LIBAEC_H 1
55
56 #include <stddef.h>
57
58 #if HAVE_CONFIG_H
59 #  include <config.h>
60 #endif
61
62 #if _WIN32 && BUILD_SHARED_LIBS
63 #  ifdef DLL_EXPORT
64 #    define AEC_SCOPE __declspec(dllexport)
65 #  else
66 #    define AEC_SCOPE extern __declspec(dllimport)
67 #  endif
68 #else
69 #  define AEC_SCOPE extern
70 #endif
71
72 struct internal_state;
73
74 struct aec_stream {
75     const unsigned char *next_in;
76     size_t avail_in;            /* number of bytes available at
77                                  * next_in
78                                  */
79     size_t total_in;            /* total number of input bytes read so
80                                  * far
81                                  */
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 =
86                                  * 1, ..., 32)
87                                  */
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
92                                  * to 4096).
93                                  */
94     int flags;
95
96     struct internal_state *state;
97 };
98
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
103                                   * unsigned.
104                                   */
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.
110                                   */
111 #define AEC_DATA_PREPROCESS 8    /* Set if preprocessor should be used */
112
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. */
116
117 /* Return codes of library functions */
118 #define AEC_OK            0
119 #define AEC_CONF_ERROR   (-1)
120 #define AEC_STREAM_ERROR (-2)
121 #define AEC_DATA_ERROR   (-3)
122 #define AEC_MEM_ERROR    (-4)
123
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.
129                                   */
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.
133                                   *
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.
138                                   */
139
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);
144
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);
148
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);
152
153 #endif /* LIBAEC_H */