Repository navigation
Expand file tree
/
Copy pathbitstream.h
More file actions
97 lines (67 loc) · 2.58 KB
/
Copy pathbitstream.h
File metadata and controls
97 lines (67 loc) · 2.58 KB
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#ifndef ZFP_BITSTREAM_H
#define ZFP_BITSTREAM_H
#include <stddef.h>
#include "zfp/types.h"
#include "zfp/system.h"
/* forward declaration of opaque type */
typedef struct bitstream bitstream;
extern_ const size_t stream_word_bits; /* bit stream granularity */
#ifndef inline_
#ifdef __cplusplus
extern "C" {
#endif
/* allocate and initialize bit stream */
bitstream* stream_open(void* buffer, size_t bytes);
/* close and deallocate bit stream */
void stream_close(bitstream* stream);
/* make a copy of bit stream to shared memory buffer */
bitstream* stream_clone(const bitstream* stream);
/* word size in bits (equal to stream_word_bits) */
size_t stream_alignment();
/* pointer to beginning of stream */
void* stream_data(const bitstream* stream);
/* current byte size of stream (if flushed) */
size_t stream_size(const bitstream* stream);
/* byte capacity of stream */
size_t stream_capacity(const bitstream* stream);
/* number of words per block */
size_t stream_stride_block(const bitstream* stream);
/* number of blocks between consecutive blocks */
ptrdiff_t stream_stride_delta(const bitstream* stream);
/* read single bit (0 or 1) */
uint stream_read_bit(bitstream* stream);
/* write single bit */
uint stream_write_bit(bitstream* stream, uint bit);
/* read 0 <= n <= 64 bits */
uint64 stream_read_bits(bitstream* stream, uint n);
/* write 0 <= n <= 64 low bits of value and return remaining bits */
uint64 stream_write_bits(bitstream* stream, uint64 value, uint n);
/* return bit offset to next bit to be read */
size_t stream_rtell(const bitstream* stream);
/* return bit offset to next bit to be written */
size_t stream_wtell(const bitstream* stream);
/* rewind stream to beginning */
void stream_rewind(bitstream* stream);
/* position stream for reading at given bit offset */
void stream_rseek(bitstream* stream, size_t offset);
/* position stream for writing at given bit offset */
void stream_wseek(bitstream* stream, size_t offset);
/* skip over the next n bits */
void stream_skip(bitstream* stream, uint n);
/* append n zero-bits to stream */
void stream_pad(bitstream* stream, uint n);
/* align stream on next word boundary */
size_t stream_align(bitstream* stream);
/* flush out any remaining buffered bits */
size_t stream_flush(bitstream* stream);
/* copy n bits from one bit stream to another */
void stream_copy(bitstream* dst, bitstream* src, size_t n);
#ifdef BIT_STREAM_STRIDED
/* set block size in number of words and spacing in number of blocks */
int stream_set_stride(bitstream* stream, size_t block, ptrdiff_t delta);
#endif
#ifdef __cplusplus
}
#endif
#endif /* !inline_ */
#endif