libaec.h 2.5 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
typedef struct _aec_stream
10
{
11 12 13 14 15 16 17 18 19 20 21
    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) */
22 23 24
    uint32_t rsi;            /* Reference sample interval, the number of
                                blocks between consecutive reference
                                samples. */
25
    uint32_t flags;
26

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

Mathis Rosenhauer's avatar
Mathis Rosenhauer committed
30
typedef aec_stream *aec_streamp;
31

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

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

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

Mathis Rosenhauer's avatar
Mathis Rosenhauer committed
63 64 65
int aec_decode_init(aec_streamp strm);
int aec_decode(aec_streamp strm, int flush);
int aec_decode_end(aec_streamp strm);
66

Mathis Rosenhauer's avatar
Mathis Rosenhauer committed
67 68 69
int aec_encode_init(aec_streamp strm);
int aec_encode(aec_streamp strm, int flush);
int aec_encode_end(aec_streamp strm);
70

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