libaec.h 3.49 KB
Newer Older
Mathis Rosenhauer's avatar
Mathis Rosenhauer committed
1 2
#ifndef LIBAEC_H
#define LIBAEC_H
3

4
#include <stddef.h>
5 6 7

struct internal_state;

Mathis Rosenhauer's avatar
Mathis Rosenhauer committed
8
struct aec_stream {
9
    const unsigned char *next_in;
10 11 12 13 14 15
    size_t avail_in;            /* number of bytes available at
                                 * next_in
                                 */
    size_t total_in;            /* total number of input bytes read so
                                 * far
                                 */
16
    unsigned char *next_out;
17 18 19 20 21 22 23 24 25 26
    size_t avail_out;           /* remaining free space at next_out */
    size_t total_out;           /* total number of bytes output so far */
    int bit_per_sample;         /* resolution in bits per sample (n =
                                 * 1, ..., 32)
                                 */
    int block_size;             /* block size in samples */
    int rsi;                    /* Reference sample interval, the number
                                 * of _blocks_ between consecutive
                                 * reference samples (up to 4096).
                                 */
27
    int flags;
28

29
    struct internal_state *state;
Mathis Rosenhauer's avatar
Mathis Rosenhauer committed
30
};
31

32 33 34 35 36 37 38 39 40 41 42 43 44
/* Sample data description flags */
#define AEC_DATA_UNSIGNED     0  /* Samples are unsigned integers (default) */
#define AEC_DATA_SIGNED       1  /* Samples are signed. Telling libaec
                                  * this results in a slightly better
                                  * compression ratio.
                                  */
#define AEC_DATA_3BYTE        2  /* 24 bit samples are coded in 3 bytes */
#define AEC_DATA_MSB         16  /* Samples are stored with their most
                                  * significant bit first. This has
                                  * nothing to do with the endianness
                                  * of the host.
                                  */
#define AEC_DATA_LSB          0  /* Samples are stored LSB first (default) */
Mathis Rosenhauer's avatar
Mathis Rosenhauer committed
45
#define AEC_DATA_PREPROCESS  32  /* Set if preprocessor should be used */
46 47

/* Return codes of library functions */
Mathis Rosenhauer's avatar
Mathis Rosenhauer committed
48 49 50 51 52
#define AEC_OK            0
#define AEC_CONF_ERROR   (-1)
#define AEC_STREAM_ERROR (-2)
#define AEC_DATA_ERROR   (-3)
#define AEC_MEM_ERROR    (-4)
53

54
/* Options for flushing */
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
#define AEC_NO_FLUSH      0      /* Do not enforce output
                                  * flushing. More input may be
                                  * provided with later calls. So far
                                  * only relevant for encoding.
                                  */
#define AEC_FLUSH         1      /* 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 because the last byte
                                  * may be padded with fill bits.
                                  */

/* Streaming encoding and decoding functions */
int aec_encode_init(struct aec_stream *strm);
int aec_encode(struct aec_stream *strm, int flush);
int aec_encode_end(struct aec_stream *strm);
74

Mathis Rosenhauer's avatar
Mathis Rosenhauer committed
75 76 77
int aec_decode_init(struct aec_stream *strm);
int aec_decode(struct aec_stream *strm, int flush);
int aec_decode_end(struct aec_stream *strm);
78

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

Mathis Rosenhauer's avatar
Mathis Rosenhauer committed
83
#endif /* LIBAEC_H */