summaryrefslogtreecommitdiff
path: root/src/libae.h
blob: b7a6da695b62b6d90089a34fe95e8897b86b7da6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#ifndef LIBAE_H
#define LIBAE_H

#include <inttypes.h>

struct internal_state;

typedef struct _ae_stream
{
    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) */
    uint32_t segment_size;   /* set of blocks between consecutive
                              * reference samples */
    uint32_t flags; 

    struct internal_state *state;
} ae_stream;

typedef ae_stream *ae_streamp;

/* Coder flags */
#define AE_DATA_UNSIGNED   0
#define AE_DATA_SIGNED     1
#define AE_DATA_PREPROCESS 2 /* Set if preprocessor should be used */


/* Return codes of library functions */
#define AE_OK            0
#define AE_STREAM_END    1
#define AE_ERRNO        (-1)
#define AE_STREAM_ERROR (-2)
#define AE_DATA_ERROR   (-3)
#define AE_MEM_ERROR    (-4)

/* 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
                            * encoding. */
#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
                            * padded with fill bits. */

int ae_decode_init(ae_streamp strm);
int ae_decode(ae_streamp strm, int flush);

int ae_encode_init(ae_streamp strm);
int ae_encode(ae_streamp strm, int flush);

#endif /* LIBAE_H */