File: libaec.h.in

package info (click to toggle)
libaec 1.1.4-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 6,272 kB
  • sloc: ansic: 3,746; sh: 109; makefile: 75; cpp: 34
file content (194 lines) | stat: -rw-r--r-- 6,761 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
/**
 * @file libaec.h
 *
 * @section LICENSE
 * Copyright 2025 Mathis Rosenhauer, Moritz Hanke, Joerg Behrens, Luis Kornblueh
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above
 *    copyright notice, this list of conditions and the following
 *    disclaimer in the documentation and/or other materials provided
 *    with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
 * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
 * OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 * @section DESCRIPTION
 *
 * Adaptive Entropy Coding library
 *
 */

#ifndef LIBAEC_H
#define LIBAEC_H 1

#define AEC_VERSION_MAJOR @PROJECT_VERSION_MAJOR@
#define AEC_VERSION_MINOR @PROJECT_VERSION_MINOR@
#define AEC_VERSION_PATCH @PROJECT_VERSION_PATCH@
#define AEC_VERSION_STR "@PROJECT_VERSION_MAJOR@.@PROJECT_VERSION_MINOR@.@PROJECT_VERSION_PATCH@"

#include <stddef.h>

#ifdef __cplusplus
extern "C"{
#endif

#if defined _WIN32 || defined __CYGWIN__
#  define LIBAEC_HELPER_DLL_IMPORT __declspec(dllimport)
#  define LIBAEC_HELPER_DLL_EXPORT __declspec(dllexport)
#else
#  if __GNUC__ >= 4
#    define LIBAEC_HELPER_DLL_IMPORT
#    define LIBAEC_HELPER_DLL_EXPORT __attribute__ ((visibility ("default")))
#  else
#    define LIBAEC_HELPER_DLL_IMPORT
#    define LIBAEC_HELPER_DLL_EXPORT
#  endif
#endif

#ifdef LIBAEC_SHARED
#  ifdef LIBAEC_BUILD
#    define LIBAEC_DLL_EXPORTED LIBAEC_HELPER_DLL_EXPORT
#  else
#    define LIBAEC_DLL_EXPORTED LIBAEC_HELPER_DLL_IMPORT
#  endif
#else
#  define LIBAEC_DLL_EXPORTED
#endif

struct internal_state;

struct aec_stream {
    const unsigned char *next_in;

    /* number of bytes available at next_in */
    size_t avail_in;

    /* total number of input bytes read so far */
    size_t total_in;

    unsigned char *next_out;

    /* remaining free space at next_out */
    size_t avail_out;

    /* total number of bytes output so far */
    size_t total_out;

    /* resolution in bits per sample (n = 1, ..., 32) */
    unsigned int bits_per_sample;

    /* block size in samples */
    unsigned int block_size;

    /* Reference sample interval, the number of blocks
     * between consecutive reference samples (up to 4096). */
    unsigned int rsi;

    unsigned int flags;

    struct internal_state *state;
};

/*********************************/
/* Sample data description flags */
/*********************************/

/* Samples are signed. Telling libaec this results in a slightly
 * better compression ratio. Default is unsigned. */
#define AEC_DATA_SIGNED 1

/* 24 bit samples are coded in 3 bytes */
#define AEC_DATA_3BYTE 2

/* Samples are stored with their most significant bit first. This has
 * nothing to do with the endianness of the host. Default is LSB. */
#define AEC_DATA_MSB 4

/* Set if preprocessor should be used */
#define AEC_DATA_PREPROCESS 8

/* Use restricted set of code options */
#define AEC_RESTRICTED 16

/* Pad RSI to byte boundary. Only used for decoding some CCSDS sample
 * data. Do not use this to produce new data as it violates the
 * standard. */
#define AEC_PAD_RSI 32

/* Do not enforce standard regarding legal block sizes. */
#define AEC_NOT_ENFORCE 64

/*************************************/
/* Return codes of library functions */
/*************************************/
#define AEC_OK 0
#define AEC_CONF_ERROR (-1)
#define AEC_STREAM_ERROR (-2)
#define AEC_DATA_ERROR (-3)
#define AEC_MEM_ERROR (-4)
#define AEC_RSI_OFFSETS_ERROR (-5)

/************************/
/* Options for flushing */
/************************/

/* Do not enforce output flushing. More input may be provided with
 * later calls. So far only relevant for encoding. */
#define AEC_NO_FLUSH 0

/* Flush output and end encoding. The last call to aec_encode() must
 * set AEC_FLUSH to drain all output.
 *
 * It is not possible to continue encoding of the same stream after it
 * has been flushed. For one, the last block may be padded zeros after
 * preprocessing. Secondly, the last encoded byte may be padded with
 * fill bits. */
#define AEC_FLUSH 1

/*********************************************/
/* Streaming encoding and decoding functions */
/*********************************************/
LIBAEC_DLL_EXPORTED int aec_encode_init(struct aec_stream *strm);
LIBAEC_DLL_EXPORTED int aec_encode_enable_offsets(struct aec_stream *strm);
LIBAEC_DLL_EXPORTED int aec_encode_count_offsets(struct aec_stream *strm, size_t *rsi_offsets_count);
LIBAEC_DLL_EXPORTED int aec_encode_get_offsets(struct aec_stream *strm, size_t *rsi_offsets, size_t rsi_offsets_count);
LIBAEC_DLL_EXPORTED int aec_buffer_seek(struct aec_stream *strm, size_t offset);
LIBAEC_DLL_EXPORTED int aec_encode(struct aec_stream *strm, int flush);
LIBAEC_DLL_EXPORTED int aec_encode_end(struct aec_stream *strm);

LIBAEC_DLL_EXPORTED int aec_decode_init(struct aec_stream *strm);
LIBAEC_DLL_EXPORTED int aec_decode_enable_offsets(struct aec_stream *strm);
LIBAEC_DLL_EXPORTED int aec_decode_count_offsets(struct aec_stream *strm, size_t *rsi_offsets_count);
LIBAEC_DLL_EXPORTED int aec_decode_get_offsets(struct aec_stream *strm, size_t *rsi_offsets, size_t rsi_offsets_count);
LIBAEC_DLL_EXPORTED int aec_decode(struct aec_stream *strm, int flush);
LIBAEC_DLL_EXPORTED int aec_decode_range(struct aec_stream *strm, const size_t *rsi_offsets, size_t rsi_offsets_count, size_t pos, size_t size);
LIBAEC_DLL_EXPORTED int aec_decode_end(struct aec_stream *strm);

/***************************************************************/
/* Utility functions for encoding or decoding a memory buffer. */
/***************************************************************/
LIBAEC_DLL_EXPORTED int aec_buffer_encode(struct aec_stream *strm);
LIBAEC_DLL_EXPORTED int aec_buffer_decode(struct aec_stream *strm);

#ifdef __cplusplus
}
#endif

#endif /* LIBAEC_H */