libaec.h 2.47 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
    size_t avail_in;         /* number of bytes available at
                              * next_in */
    size_t total_in;         /* total number of input bytes read so
                              * far */
14
    unsigned char *next_out;
15 16
    size_t avail_out;        /* remaining free space at next_out */
    size_t total_out;        /* total number of bytes output so far */
17
    int bit_per_sample;      /* resolution in bits per sample (n =
18
                              * 1,..., 32) */
19 20
    int block_size;          /* block size in samples */
    int rsi;                 /* Reference sample interval, the number of
21 22
                                blocks between consecutive reference
                                samples. */
23
    int flags;
24

25
    struct internal_state *state;
Mathis Rosenhauer's avatar
Mathis Rosenhauer committed
26
};
27

28
/* Coder flags */
Mathis Rosenhauer's avatar
Mathis Rosenhauer committed
29 30 31 32 33 34
#define AEC_DATA_UNSIGNED     0
#define AEC_DATA_SIGNED       1
#define AEC_DATA_3BYTE        2  /* 24 bit samples coded in 3 bytes */
#define AEC_DATA_LSB          0
#define AEC_DATA_MSB         16
#define AEC_DATA_PREPROCESS  32  /* Set if preprocessor should be used */
35 36

/* Return codes of library functions */
Mathis Rosenhauer's avatar
Mathis Rosenhauer committed
37 38 39 40 41
#define AEC_OK            0
#define AEC_CONF_ERROR   (-1)
#define AEC_STREAM_ERROR (-2)
#define AEC_DATA_ERROR   (-3)
#define AEC_MEM_ERROR    (-4)
42

43
/* Options for flushing */
Mathis Rosenhauer's avatar
Mathis Rosenhauer committed
44
#define AEC_NO_FLUSH      0 /* Do not enforce output flushing. More
45 46 47 48
                             * input may be provided with later
                             * calls. So far only relevant for
                             * encoding.
                             */
Mathis Rosenhauer's avatar
Mathis Rosenhauer committed
49
#define AEC_FLUSH         1 /* Flush output and end encoding. The last
50 51 52 53 54 55 56 57
                             * 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.
                             */
58

Mathis Rosenhauer's avatar
Mathis Rosenhauer committed
59 60 61
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);
62

Mathis Rosenhauer's avatar
Mathis Rosenhauer committed
63 64 65
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);
66

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