libae.h 2.46 KB
Newer Older
1 2
#ifndef LIBAE_H
#define LIBAE_H
3 4

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

struct internal_state;

typedef struct _ae_stream
{
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;
28 29 30 31
} ae_stream;

typedef ae_stream *ae_streamp;

32
/* Coder flags */
33 34
#define AE_DATA_UNSIGNED     0
#define AE_DATA_SIGNED       1
35 36
#define AE_DATA_3BYTE        2  /* 24 bit samples coded in 3 bytes */
#define AE_DATA_LSB          0
37 38
#define AE_DATA_MSB         16
#define AE_DATA_PREPROCESS  32  /* Set if preprocessor should be used */
39 40

/* Return codes of library functions */
41
#define AE_OK            0
42
#define AE_CONF_ERROR   (-1)
43 44 45 46
#define AE_STREAM_ERROR (-2)
#define AE_DATA_ERROR   (-3)
#define AE_MEM_ERROR    (-4)

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

int ae_decode_init(ae_streamp strm);
int ae_decode(ae_streamp strm, int flush);
65
int ae_decode_end(ae_streamp strm);
66

67 68
int ae_encode_init(ae_streamp strm);
int ae_encode(ae_streamp strm, int flush);
69
int ae_encode_end(ae_streamp strm);
70 71

#endif /* LIBAE_H */