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

#include <inttypes.h>
5
#include <stddef.h>
6 7 8

struct internal_state;

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

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

29
/* Coder flags */
Mathis Rosenhauer's avatar
Mathis Rosenhauer committed
30 31 32 33 34 35
#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 */
36 37

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

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

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

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

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