aboutsummaryrefslogtreecommitdiff
path: root/lpg/libqr/qr-bitstream.h
blob: 298e53bd403fc4560a159d12741c7576c05d8c38 (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
#ifndef QR_BITSTREAM_H
#define QR_BITSTREAM_H

#include <stddef.h>

/**
 * Note: when writing / reading multiple bits, the
 * _most_ significant bits come first in the stream.
 * (That is, the order you would naturally write the
 * number in binary)
 */

struct qr_bitstream;

struct qr_bitstream * qr_bitstream_create(void);
int                qr_bitstream_resize(struct qr_bitstream *, size_t bits);
void               qr_bitstream_destroy(struct qr_bitstream *);
struct qr_bitstream * qr_bitstream_copy(const struct qr_bitstream *);

void qr_bitstream_seek(struct qr_bitstream *, size_t pos);
size_t qr_bitstream_tell(const struct qr_bitstream *);
size_t qr_bitstream_remaining(const struct qr_bitstream *);
size_t qr_bitstream_size(const struct qr_bitstream *);

unsigned int qr_bitstream_read(struct qr_bitstream *, size_t bits);

void qr_bitstream_unpack(struct qr_bitstream *,
                      unsigned int * result,
                      size_t         count,
                      size_t         bitsize);

int qr_bitstream_write(struct qr_bitstream *,
                    unsigned int value,
                    size_t       bits);

int qr_bitstream_pack(struct qr_bitstream *,
                   const unsigned int * values,
                   size_t               count,
                   size_t               bitsize);

int qr_bitstream_cat(struct qr_bitstream *, const struct qr_bitstream * src);

#endif