Coverage Report

Created: 2026-09-03 06:44

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/c-blosc2/_deps/zfp-src/include/zfp/bitstream.inl
Line
Count
Source
1
/*
2
High-speed in-memory bit stream I/O that supports reading and writing between
3
0 and 64 bits at a time.  The implementation, which relies heavily on bit
4
shifts, has been carefully written to ensure that all shifts are between
5
zero and one less the width of the type being shifted to avoid undefined
6
behavior.  This occasionally causes somewhat convoluted code.
7
8
The following assumptions and restrictions apply:
9
10
1. The user must allocate a memory buffer large enough to hold the bit stream,
11
   whether for reading, writing, or both.  This buffer is associated with the
12
   bit stream via stream_open(buffer, bytes), which allocates and returns a
13
   pointer to an opaque bit stream struct.  Call stream_close(stream) to
14
   deallocate this struct.
15
16
2. The stream is either in a read or write state (or, initially, in both
17
   states).  When done writing, call stream_flush(stream) before entering
18
   read mode to ensure any buffered bits are output.  To enter read mode,
19
   call stream_rewind(stream) or stream_rseek(stream, offset) to position
20
   the stream at the beginning or at a particular bit offset.  Conversely,
21
   stream_rewind(stream) or stream_wseek(stream, offset) positions the
22
   stream for writing.  In read mode, the following functions may be called:
23
24
     size_t stream_size(stream);
25
     bitstream_offset stream_rtell(stream);
26
     void stream_rewind(stream);
27
     void stream_rseek(stream, offset);
28
     void stream_skip(stream, n);
29
     bitstream_count stream_align(stream);
30
     uint stream_read_bit(stream);
31
     uint64 stream_read_bits(stream, n);
32
33
   Each of the above read calls has a corresponding write call:
34
35
     size_t stream_size(stream);
36
     bitstream_offset stream_wtell(stream);
37
     void stream_rewind(stream);
38
     void stream_wseek(stream, offset);
39
     void stream_pad(stream, n);
40
     bitstream_count stream_flush(stream);
41
     uint stream_write_bit(stream, bit);
42
     uint64 stream_write_bits(stream, value, n);
43
44
3. The stream buffer is an unsigned integer of a user-specified type given
45
   by the BIT_STREAM_WORD_TYPE macro.  Bits are read and written in units of
46
   this integer word type.  Supported types are 8, 16, 32, or 64 bits wide.
47
   The bit width of the buffer is denoted by 'wsize' and can be accessed
48
   either via the global constant stream_word_bits or stream_alignment().
49
   A small wsize allows for fine granularity reads and writes, and may be
50
   preferable when working with many small blocks of data that require
51
   non-sequential access.  The default maximum size of 64 bits ensures maximum
52
   speed.  Note that even when wsize < 64, it is still possible to read and
53
   write up to 64 bits at a time using stream_read_bits() and
54
   stream_write_bits().
55
56
4. If BIT_STREAM_STRIDED is defined, words read from or written to the stream
57
   may be accessed noncontiguously by setting a power-of-two block size (which
58
   by default is one word) and a block stride (defaults to zero blocks).  The
59
   word pointer is always incremented by one word each time a word is accessed.
60
   Once advanced past a block boundary, the word pointer is also advanced by
61
   the stride to the next block.  This feature may be used to store blocks of
62
   data interleaved, e.g., for progressive coding or for noncontiguous parallel
63
   access to the bit stream  Note that the block size is measured in words,
64
   while the stride is measured in multiples of the block size.  Strided access
65
   can have a significant performance penalty.
66
67
5. Multiple bits are read and written in order of least to most significant
68
   bit.  Thus, the statement
69
70
       value = stream_write_bits(stream, value, n);
71
72
   is essentially equivalent to (but faster than)
73
74
       for (i = 0; i < n; i++, value >>= 1)
75
         stream_write_bit(stream, value & 1);
76
77
   when 0 <= n <= 64.  The same holds for read calls, and thus
78
79
       value = stream_read_bits(stream, n);
80
81
   is essentially equivalent to
82
83
       for (i = 0, value = 0; i < n; i++)
84
         value += (uint64)stream_read_bit(stream) << i;
85
86
   Note that it is possible to write fewer bits than the argument 'value'
87
   holds (possibly even no bits), in which case any unwritten bits are
88
   shifted right to the least significant position and returned.  That is,
89
   value = stream_write_bits(stream, value, n); is equivalent to
90
91
       for (i = 0; i < n; i++)
92
         value = stream_write_bits(stream, value, 1);
93
94
6. Although the stream_wseek(stream, offset) call allows positioning the
95
   stream for writing at any bit offset without any data loss (i.e. all
96
   previously written bits preceding the offset remain valid), for efficiency
97
   the stream_flush(stream) operation will zero all bits up to the next
98
   multiple of wsize bits, thus overwriting bits that were previously stored
99
   at that location.  Consequently, random write access is effectively
100
   supported only at wsize granularity.  For sequential access, the largest
101
   possible wsize is preferred due to higher speed.
102
103
7. It is up to the user to adhere to these rules.  For performance reasons,
104
   no error checking is done, and in particular buffer overruns are not
105
   caught.
106
*/
107
108
#include <limits.h>
109
#include <stdlib.h>
110
111
#ifndef inline_
112
  #define inline_
113
#endif
114
115
#include "zfp/bitstream.h"
116
117
/* satisfy compiler when args unused */
118
0
#define unused_(x) ((void)(x))
119
120
/* bit stream word/buffer type; granularity of stream I/O operations */
121
#ifdef BIT_STREAM_WORD_TYPE
122
  /* may be 8-, 16-, 32-, or 64-bit unsigned integer type */
123
  typedef BIT_STREAM_WORD_TYPE bitstream_word;
124
#else
125
  /* use maximum word size by default for highest speed */
126
  typedef uint64 bitstream_word;
127
#endif
128
129
/* number of bits in a buffered word */
130
0
#define wsize ((bitstream_count)(sizeof(bitstream_word) * CHAR_BIT))
131
132
/* bit stream structure (opaque to caller) */
133
struct bitstream {
134
  bitstream_count bits;  /* number of buffered bits (0 <= bits < wsize) */
135
  bitstream_word buffer; /* incoming/outgoing bits (buffer < 2^bits) */
136
  bitstream_word* ptr;   /* pointer to next word to be read/written */
137
  bitstream_word* begin; /* beginning of stream */
138
  bitstream_word* end;   /* end of stream (not enforced) */
139
#ifdef BIT_STREAM_STRIDED
140
  size_t mask;           /* one less the block size in number of words */
141
  ptrdiff_t delta;       /* number of words between consecutive blocks */
142
#endif
143
};
144
145
/* private functions ------------------------------------------------------- */
146
147
/* read a single word from memory */
148
static bitstream_word
149
stream_read_word(bitstream* s)
150
0
{
151
0
  bitstream_word w = *s->ptr++;
152
#ifdef BIT_STREAM_STRIDED
153
  if (!((s->ptr - s->begin) & s->mask))
154
    s->ptr += s->delta;
155
#endif
156
0
  return w;
157
0
}
Unexecuted instantiation: bitstream.c:stream_read_word
Unexecuted instantiation: encode1f.c:stream_read_word
Unexecuted instantiation: encode1d.c:stream_read_word
Unexecuted instantiation: encode1i.c:stream_read_word
Unexecuted instantiation: encode1l.c:stream_read_word
Unexecuted instantiation: decode1f.c:stream_read_word
Unexecuted instantiation: decode1d.c:stream_read_word
Unexecuted instantiation: decode1i.c:stream_read_word
Unexecuted instantiation: decode1l.c:stream_read_word
Unexecuted instantiation: encode2f.c:stream_read_word
Unexecuted instantiation: encode2d.c:stream_read_word
Unexecuted instantiation: encode2i.c:stream_read_word
Unexecuted instantiation: encode2l.c:stream_read_word
Unexecuted instantiation: decode2f.c:stream_read_word
Unexecuted instantiation: decode2d.c:stream_read_word
Unexecuted instantiation: decode2i.c:stream_read_word
Unexecuted instantiation: decode2l.c:stream_read_word
Unexecuted instantiation: encode3f.c:stream_read_word
Unexecuted instantiation: encode3d.c:stream_read_word
Unexecuted instantiation: encode3i.c:stream_read_word
Unexecuted instantiation: encode3l.c:stream_read_word
Unexecuted instantiation: decode3f.c:stream_read_word
Unexecuted instantiation: decode3d.c:stream_read_word
Unexecuted instantiation: decode3i.c:stream_read_word
Unexecuted instantiation: decode3l.c:stream_read_word
Unexecuted instantiation: encode4f.c:stream_read_word
Unexecuted instantiation: encode4d.c:stream_read_word
Unexecuted instantiation: encode4i.c:stream_read_word
Unexecuted instantiation: encode4l.c:stream_read_word
Unexecuted instantiation: decode4f.c:stream_read_word
Unexecuted instantiation: decode4d.c:stream_read_word
Unexecuted instantiation: decode4i.c:stream_read_word
Unexecuted instantiation: decode4l.c:stream_read_word
158
159
/* write a single word to memory */
160
static void
161
stream_write_word(bitstream* s, bitstream_word value)
162
0
{
163
0
  *s->ptr++ = value;
164
#ifdef BIT_STREAM_STRIDED
165
  if (!((s->ptr - s->begin) & s->mask))
166
    s->ptr += s->delta;
167
#endif
168
0
}
Unexecuted instantiation: bitstream.c:stream_write_word
Unexecuted instantiation: encode1f.c:stream_write_word
Unexecuted instantiation: encode1d.c:stream_write_word
Unexecuted instantiation: encode1i.c:stream_write_word
Unexecuted instantiation: encode1l.c:stream_write_word
Unexecuted instantiation: decode1f.c:stream_write_word
Unexecuted instantiation: decode1d.c:stream_write_word
Unexecuted instantiation: decode1i.c:stream_write_word
Unexecuted instantiation: decode1l.c:stream_write_word
Unexecuted instantiation: encode2f.c:stream_write_word
Unexecuted instantiation: encode2d.c:stream_write_word
Unexecuted instantiation: encode2i.c:stream_write_word
Unexecuted instantiation: encode2l.c:stream_write_word
Unexecuted instantiation: decode2f.c:stream_write_word
Unexecuted instantiation: decode2d.c:stream_write_word
Unexecuted instantiation: decode2i.c:stream_write_word
Unexecuted instantiation: decode2l.c:stream_write_word
Unexecuted instantiation: encode3f.c:stream_write_word
Unexecuted instantiation: encode3d.c:stream_write_word
Unexecuted instantiation: encode3i.c:stream_write_word
Unexecuted instantiation: encode3l.c:stream_write_word
Unexecuted instantiation: decode3f.c:stream_write_word
Unexecuted instantiation: decode3d.c:stream_write_word
Unexecuted instantiation: decode3i.c:stream_write_word
Unexecuted instantiation: decode3l.c:stream_write_word
Unexecuted instantiation: encode4f.c:stream_write_word
Unexecuted instantiation: encode4d.c:stream_write_word
Unexecuted instantiation: encode4i.c:stream_write_word
Unexecuted instantiation: encode4l.c:stream_write_word
Unexecuted instantiation: decode4f.c:stream_write_word
Unexecuted instantiation: decode4d.c:stream_write_word
Unexecuted instantiation: decode4i.c:stream_write_word
Unexecuted instantiation: decode4l.c:stream_write_word
169
170
/* public functions -------------------------------------------------------- */
171
172
/* word size in bits (equals bitstream_word_bits) */
173
inline_ bitstream_count
174
stream_alignment(void)
175
0
{
176
0
  return wsize;
177
0
}
Unexecuted instantiation: stream_alignment
Unexecuted instantiation: encode1f.c:stream_alignment
Unexecuted instantiation: encode1d.c:stream_alignment
Unexecuted instantiation: encode1i.c:stream_alignment
Unexecuted instantiation: encode1l.c:stream_alignment
Unexecuted instantiation: decode1f.c:stream_alignment
Unexecuted instantiation: decode1d.c:stream_alignment
Unexecuted instantiation: decode1i.c:stream_alignment
Unexecuted instantiation: decode1l.c:stream_alignment
Unexecuted instantiation: encode2f.c:stream_alignment
Unexecuted instantiation: encode2d.c:stream_alignment
Unexecuted instantiation: encode2i.c:stream_alignment
Unexecuted instantiation: encode2l.c:stream_alignment
Unexecuted instantiation: decode2f.c:stream_alignment
Unexecuted instantiation: decode2d.c:stream_alignment
Unexecuted instantiation: decode2i.c:stream_alignment
Unexecuted instantiation: decode2l.c:stream_alignment
Unexecuted instantiation: encode3f.c:stream_alignment
Unexecuted instantiation: encode3d.c:stream_alignment
Unexecuted instantiation: encode3i.c:stream_alignment
Unexecuted instantiation: encode3l.c:stream_alignment
Unexecuted instantiation: decode3f.c:stream_alignment
Unexecuted instantiation: decode3d.c:stream_alignment
Unexecuted instantiation: decode3i.c:stream_alignment
Unexecuted instantiation: decode3l.c:stream_alignment
Unexecuted instantiation: encode4f.c:stream_alignment
Unexecuted instantiation: encode4d.c:stream_alignment
Unexecuted instantiation: encode4i.c:stream_alignment
Unexecuted instantiation: encode4l.c:stream_alignment
Unexecuted instantiation: decode4f.c:stream_alignment
Unexecuted instantiation: decode4d.c:stream_alignment
Unexecuted instantiation: decode4i.c:stream_alignment
Unexecuted instantiation: decode4l.c:stream_alignment
178
179
/* pointer to beginning of stream */
180
inline_ void*
181
stream_data(const bitstream* s)
182
0
{
183
0
  return s->begin;
184
0
}
Unexecuted instantiation: stream_data
Unexecuted instantiation: encode1f.c:stream_data
Unexecuted instantiation: encode1d.c:stream_data
Unexecuted instantiation: encode1i.c:stream_data
Unexecuted instantiation: encode1l.c:stream_data
Unexecuted instantiation: decode1f.c:stream_data
Unexecuted instantiation: decode1d.c:stream_data
Unexecuted instantiation: decode1i.c:stream_data
Unexecuted instantiation: decode1l.c:stream_data
Unexecuted instantiation: encode2f.c:stream_data
Unexecuted instantiation: encode2d.c:stream_data
Unexecuted instantiation: encode2i.c:stream_data
Unexecuted instantiation: encode2l.c:stream_data
Unexecuted instantiation: decode2f.c:stream_data
Unexecuted instantiation: decode2d.c:stream_data
Unexecuted instantiation: decode2i.c:stream_data
Unexecuted instantiation: decode2l.c:stream_data
Unexecuted instantiation: encode3f.c:stream_data
Unexecuted instantiation: encode3d.c:stream_data
Unexecuted instantiation: encode3i.c:stream_data
Unexecuted instantiation: encode3l.c:stream_data
Unexecuted instantiation: decode3f.c:stream_data
Unexecuted instantiation: decode3d.c:stream_data
Unexecuted instantiation: decode3i.c:stream_data
Unexecuted instantiation: decode3l.c:stream_data
Unexecuted instantiation: encode4f.c:stream_data
Unexecuted instantiation: encode4d.c:stream_data
Unexecuted instantiation: encode4i.c:stream_data
Unexecuted instantiation: encode4l.c:stream_data
Unexecuted instantiation: decode4f.c:stream_data
Unexecuted instantiation: decode4d.c:stream_data
Unexecuted instantiation: decode4i.c:stream_data
Unexecuted instantiation: decode4l.c:stream_data
185
186
/* current byte size of stream (if flushed) */
187
inline_ size_t
188
stream_size(const bitstream* s)
189
0
{
190
0
  return (size_t)(s->ptr - s->begin) * sizeof(bitstream_word);
191
0
}
Unexecuted instantiation: stream_size
Unexecuted instantiation: encode1f.c:stream_size
Unexecuted instantiation: encode1d.c:stream_size
Unexecuted instantiation: encode1i.c:stream_size
Unexecuted instantiation: encode1l.c:stream_size
Unexecuted instantiation: decode1f.c:stream_size
Unexecuted instantiation: decode1d.c:stream_size
Unexecuted instantiation: decode1i.c:stream_size
Unexecuted instantiation: decode1l.c:stream_size
Unexecuted instantiation: encode2f.c:stream_size
Unexecuted instantiation: encode2d.c:stream_size
Unexecuted instantiation: encode2i.c:stream_size
Unexecuted instantiation: encode2l.c:stream_size
Unexecuted instantiation: decode2f.c:stream_size
Unexecuted instantiation: decode2d.c:stream_size
Unexecuted instantiation: decode2i.c:stream_size
Unexecuted instantiation: decode2l.c:stream_size
Unexecuted instantiation: encode3f.c:stream_size
Unexecuted instantiation: encode3d.c:stream_size
Unexecuted instantiation: encode3i.c:stream_size
Unexecuted instantiation: encode3l.c:stream_size
Unexecuted instantiation: decode3f.c:stream_size
Unexecuted instantiation: decode3d.c:stream_size
Unexecuted instantiation: decode3i.c:stream_size
Unexecuted instantiation: decode3l.c:stream_size
Unexecuted instantiation: encode4f.c:stream_size
Unexecuted instantiation: encode4d.c:stream_size
Unexecuted instantiation: encode4i.c:stream_size
Unexecuted instantiation: encode4l.c:stream_size
Unexecuted instantiation: decode4f.c:stream_size
Unexecuted instantiation: decode4d.c:stream_size
Unexecuted instantiation: decode4i.c:stream_size
Unexecuted instantiation: decode4l.c:stream_size
192
193
/* byte capacity of stream */
194
inline_ size_t
195
stream_capacity(const bitstream* s)
196
0
{
197
0
  return (size_t)(s->end - s->begin) * sizeof(bitstream_word);
198
0
}
Unexecuted instantiation: stream_capacity
Unexecuted instantiation: encode1f.c:stream_capacity
Unexecuted instantiation: encode1d.c:stream_capacity
Unexecuted instantiation: encode1i.c:stream_capacity
Unexecuted instantiation: encode1l.c:stream_capacity
Unexecuted instantiation: decode1f.c:stream_capacity
Unexecuted instantiation: decode1d.c:stream_capacity
Unexecuted instantiation: decode1i.c:stream_capacity
Unexecuted instantiation: decode1l.c:stream_capacity
Unexecuted instantiation: encode2f.c:stream_capacity
Unexecuted instantiation: encode2d.c:stream_capacity
Unexecuted instantiation: encode2i.c:stream_capacity
Unexecuted instantiation: encode2l.c:stream_capacity
Unexecuted instantiation: decode2f.c:stream_capacity
Unexecuted instantiation: decode2d.c:stream_capacity
Unexecuted instantiation: decode2i.c:stream_capacity
Unexecuted instantiation: decode2l.c:stream_capacity
Unexecuted instantiation: encode3f.c:stream_capacity
Unexecuted instantiation: encode3d.c:stream_capacity
Unexecuted instantiation: encode3i.c:stream_capacity
Unexecuted instantiation: encode3l.c:stream_capacity
Unexecuted instantiation: decode3f.c:stream_capacity
Unexecuted instantiation: decode3d.c:stream_capacity
Unexecuted instantiation: decode3i.c:stream_capacity
Unexecuted instantiation: decode3l.c:stream_capacity
Unexecuted instantiation: encode4f.c:stream_capacity
Unexecuted instantiation: encode4d.c:stream_capacity
Unexecuted instantiation: encode4i.c:stream_capacity
Unexecuted instantiation: encode4l.c:stream_capacity
Unexecuted instantiation: decode4f.c:stream_capacity
Unexecuted instantiation: decode4d.c:stream_capacity
Unexecuted instantiation: decode4i.c:stream_capacity
Unexecuted instantiation: decode4l.c:stream_capacity
199
200
/* number of words per block */
201
inline_ size_t
202
stream_stride_block(const bitstream* s)
203
0
{
204
#ifdef BIT_STREAM_STRIDED
205
  return s->mask + 1;
206
#else
207
0
  unused_(s);
208
0
  return 1;
209
0
#endif
210
0
}
Unexecuted instantiation: stream_stride_block
Unexecuted instantiation: encode1f.c:stream_stride_block
Unexecuted instantiation: encode1d.c:stream_stride_block
Unexecuted instantiation: encode1i.c:stream_stride_block
Unexecuted instantiation: encode1l.c:stream_stride_block
Unexecuted instantiation: decode1f.c:stream_stride_block
Unexecuted instantiation: decode1d.c:stream_stride_block
Unexecuted instantiation: decode1i.c:stream_stride_block
Unexecuted instantiation: decode1l.c:stream_stride_block
Unexecuted instantiation: encode2f.c:stream_stride_block
Unexecuted instantiation: encode2d.c:stream_stride_block
Unexecuted instantiation: encode2i.c:stream_stride_block
Unexecuted instantiation: encode2l.c:stream_stride_block
Unexecuted instantiation: decode2f.c:stream_stride_block
Unexecuted instantiation: decode2d.c:stream_stride_block
Unexecuted instantiation: decode2i.c:stream_stride_block
Unexecuted instantiation: decode2l.c:stream_stride_block
Unexecuted instantiation: encode3f.c:stream_stride_block
Unexecuted instantiation: encode3d.c:stream_stride_block
Unexecuted instantiation: encode3i.c:stream_stride_block
Unexecuted instantiation: encode3l.c:stream_stride_block
Unexecuted instantiation: decode3f.c:stream_stride_block
Unexecuted instantiation: decode3d.c:stream_stride_block
Unexecuted instantiation: decode3i.c:stream_stride_block
Unexecuted instantiation: decode3l.c:stream_stride_block
Unexecuted instantiation: encode4f.c:stream_stride_block
Unexecuted instantiation: encode4d.c:stream_stride_block
Unexecuted instantiation: encode4i.c:stream_stride_block
Unexecuted instantiation: encode4l.c:stream_stride_block
Unexecuted instantiation: decode4f.c:stream_stride_block
Unexecuted instantiation: decode4d.c:stream_stride_block
Unexecuted instantiation: decode4i.c:stream_stride_block
Unexecuted instantiation: decode4l.c:stream_stride_block
211
212
/* number of blocks between consecutive stream blocks */
213
inline_ ptrdiff_t
214
stream_stride_delta(const bitstream* s)
215
0
{
216
#ifdef BIT_STREAM_STRIDED
217
  return s->delta / (s->mask + 1);
218
#else
219
0
  unused_(s);
220
0
  return 0;
221
0
#endif
222
0
}
Unexecuted instantiation: stream_stride_delta
Unexecuted instantiation: encode1f.c:stream_stride_delta
Unexecuted instantiation: encode1d.c:stream_stride_delta
Unexecuted instantiation: encode1i.c:stream_stride_delta
Unexecuted instantiation: encode1l.c:stream_stride_delta
Unexecuted instantiation: decode1f.c:stream_stride_delta
Unexecuted instantiation: decode1d.c:stream_stride_delta
Unexecuted instantiation: decode1i.c:stream_stride_delta
Unexecuted instantiation: decode1l.c:stream_stride_delta
Unexecuted instantiation: encode2f.c:stream_stride_delta
Unexecuted instantiation: encode2d.c:stream_stride_delta
Unexecuted instantiation: encode2i.c:stream_stride_delta
Unexecuted instantiation: encode2l.c:stream_stride_delta
Unexecuted instantiation: decode2f.c:stream_stride_delta
Unexecuted instantiation: decode2d.c:stream_stride_delta
Unexecuted instantiation: decode2i.c:stream_stride_delta
Unexecuted instantiation: decode2l.c:stream_stride_delta
Unexecuted instantiation: encode3f.c:stream_stride_delta
Unexecuted instantiation: encode3d.c:stream_stride_delta
Unexecuted instantiation: encode3i.c:stream_stride_delta
Unexecuted instantiation: encode3l.c:stream_stride_delta
Unexecuted instantiation: decode3f.c:stream_stride_delta
Unexecuted instantiation: decode3d.c:stream_stride_delta
Unexecuted instantiation: decode3i.c:stream_stride_delta
Unexecuted instantiation: decode3l.c:stream_stride_delta
Unexecuted instantiation: encode4f.c:stream_stride_delta
Unexecuted instantiation: encode4d.c:stream_stride_delta
Unexecuted instantiation: encode4i.c:stream_stride_delta
Unexecuted instantiation: encode4l.c:stream_stride_delta
Unexecuted instantiation: decode4f.c:stream_stride_delta
Unexecuted instantiation: decode4d.c:stream_stride_delta
Unexecuted instantiation: decode4i.c:stream_stride_delta
Unexecuted instantiation: decode4l.c:stream_stride_delta
223
224
/* read single bit (0 or 1) */
225
inline_ uint
226
stream_read_bit(bitstream* s)
227
0
{
228
0
  uint bit;
229
0
  if (!s->bits) {
230
0
    s->buffer = stream_read_word(s);
231
0
    s->bits = wsize;
232
0
  }
233
0
  s->bits--;
234
0
  bit = (uint)s->buffer & 1u;
235
0
  s->buffer >>= 1;
236
0
  return bit;
237
0
}
Unexecuted instantiation: stream_read_bit
Unexecuted instantiation: encode1f.c:stream_read_bit
Unexecuted instantiation: encode1d.c:stream_read_bit
Unexecuted instantiation: encode1i.c:stream_read_bit
Unexecuted instantiation: encode1l.c:stream_read_bit
Unexecuted instantiation: decode1f.c:stream_read_bit
Unexecuted instantiation: decode1d.c:stream_read_bit
Unexecuted instantiation: decode1i.c:stream_read_bit
Unexecuted instantiation: decode1l.c:stream_read_bit
Unexecuted instantiation: encode2f.c:stream_read_bit
Unexecuted instantiation: encode2d.c:stream_read_bit
Unexecuted instantiation: encode2i.c:stream_read_bit
Unexecuted instantiation: encode2l.c:stream_read_bit
Unexecuted instantiation: decode2f.c:stream_read_bit
Unexecuted instantiation: decode2d.c:stream_read_bit
Unexecuted instantiation: decode2i.c:stream_read_bit
Unexecuted instantiation: decode2l.c:stream_read_bit
Unexecuted instantiation: encode3f.c:stream_read_bit
Unexecuted instantiation: encode3d.c:stream_read_bit
Unexecuted instantiation: encode3i.c:stream_read_bit
Unexecuted instantiation: encode3l.c:stream_read_bit
Unexecuted instantiation: decode3f.c:stream_read_bit
Unexecuted instantiation: decode3d.c:stream_read_bit
Unexecuted instantiation: decode3i.c:stream_read_bit
Unexecuted instantiation: decode3l.c:stream_read_bit
Unexecuted instantiation: encode4f.c:stream_read_bit
Unexecuted instantiation: encode4d.c:stream_read_bit
Unexecuted instantiation: encode4i.c:stream_read_bit
Unexecuted instantiation: encode4l.c:stream_read_bit
Unexecuted instantiation: decode4f.c:stream_read_bit
Unexecuted instantiation: decode4d.c:stream_read_bit
Unexecuted instantiation: decode4i.c:stream_read_bit
Unexecuted instantiation: decode4l.c:stream_read_bit
238
239
/* write single bit (must be 0 or 1) */
240
inline_ uint
241
stream_write_bit(bitstream* s, uint bit)
242
0
{
243
0
  s->buffer += (bitstream_word)bit << s->bits;
244
0
  if (++s->bits == wsize) {
245
0
    stream_write_word(s, s->buffer);
246
0
    s->buffer = 0;
247
0
    s->bits = 0;
248
0
  }
249
0
  return bit;
250
0
}
Unexecuted instantiation: stream_write_bit
Unexecuted instantiation: encode1f.c:stream_write_bit
Unexecuted instantiation: encode1d.c:stream_write_bit
Unexecuted instantiation: encode1i.c:stream_write_bit
Unexecuted instantiation: encode1l.c:stream_write_bit
Unexecuted instantiation: decode1f.c:stream_write_bit
Unexecuted instantiation: decode1d.c:stream_write_bit
Unexecuted instantiation: decode1i.c:stream_write_bit
Unexecuted instantiation: decode1l.c:stream_write_bit
Unexecuted instantiation: encode2f.c:stream_write_bit
Unexecuted instantiation: encode2d.c:stream_write_bit
Unexecuted instantiation: encode2i.c:stream_write_bit
Unexecuted instantiation: encode2l.c:stream_write_bit
Unexecuted instantiation: decode2f.c:stream_write_bit
Unexecuted instantiation: decode2d.c:stream_write_bit
Unexecuted instantiation: decode2i.c:stream_write_bit
Unexecuted instantiation: decode2l.c:stream_write_bit
Unexecuted instantiation: encode3f.c:stream_write_bit
Unexecuted instantiation: encode3d.c:stream_write_bit
Unexecuted instantiation: encode3i.c:stream_write_bit
Unexecuted instantiation: encode3l.c:stream_write_bit
Unexecuted instantiation: decode3f.c:stream_write_bit
Unexecuted instantiation: decode3d.c:stream_write_bit
Unexecuted instantiation: decode3i.c:stream_write_bit
Unexecuted instantiation: decode3l.c:stream_write_bit
Unexecuted instantiation: encode4f.c:stream_write_bit
Unexecuted instantiation: encode4d.c:stream_write_bit
Unexecuted instantiation: encode4i.c:stream_write_bit
Unexecuted instantiation: encode4l.c:stream_write_bit
Unexecuted instantiation: decode4f.c:stream_write_bit
Unexecuted instantiation: decode4d.c:stream_write_bit
Unexecuted instantiation: decode4i.c:stream_write_bit
Unexecuted instantiation: decode4l.c:stream_write_bit
251
252
/* read 0 <= n <= 64 bits */
253
inline_ uint64
254
stream_read_bits(bitstream* s, bitstream_count n)
255
0
{
256
0
  uint64 value = s->buffer;
257
0
  if (s->bits < n) {
258
    /* keep fetching wsize bits until enough bits are buffered */
259
0
    do {
260
      /* assert: 0 <= s->bits < n <= 64 */
261
0
      s->buffer = stream_read_word(s);
262
0
      value += (uint64)s->buffer << s->bits;
263
0
      s->bits += wsize;
264
0
    } while (sizeof(s->buffer) < sizeof(value) && s->bits < n);
265
    /* assert: 1 <= n <= s->bits < n + wsize */
266
0
    s->bits -= n;
267
0
    if (!s->bits) {
268
      /* value holds exactly n bits; no need for masking */
269
0
      s->buffer = 0;
270
0
    }
271
0
    else {
272
      /* assert: 1 <= s->bits < wsize */
273
0
      s->buffer >>= wsize - s->bits;
274
      /* assert: 1 <= n <= 64 */
275
0
      value &= ((uint64)2 << (n - 1)) - 1;
276
0
    }
277
0
  }
278
0
  else {
279
    /* assert: 0 <= n <= s->bits < wsize <= 64 */
280
0
    s->bits -= n;
281
0
    s->buffer >>= n;
282
0
    value &= ((uint64)1 << n) - 1;
283
0
  }
284
0
  return value;
285
0
}
Unexecuted instantiation: stream_read_bits
Unexecuted instantiation: encode1f.c:stream_read_bits
Unexecuted instantiation: encode1d.c:stream_read_bits
Unexecuted instantiation: encode1i.c:stream_read_bits
Unexecuted instantiation: encode1l.c:stream_read_bits
Unexecuted instantiation: decode1f.c:stream_read_bits
Unexecuted instantiation: decode1d.c:stream_read_bits
Unexecuted instantiation: decode1i.c:stream_read_bits
Unexecuted instantiation: decode1l.c:stream_read_bits
Unexecuted instantiation: encode2f.c:stream_read_bits
Unexecuted instantiation: encode2d.c:stream_read_bits
Unexecuted instantiation: encode2i.c:stream_read_bits
Unexecuted instantiation: encode2l.c:stream_read_bits
Unexecuted instantiation: decode2f.c:stream_read_bits
Unexecuted instantiation: decode2d.c:stream_read_bits
Unexecuted instantiation: decode2i.c:stream_read_bits
Unexecuted instantiation: decode2l.c:stream_read_bits
Unexecuted instantiation: encode3f.c:stream_read_bits
Unexecuted instantiation: encode3d.c:stream_read_bits
Unexecuted instantiation: encode3i.c:stream_read_bits
Unexecuted instantiation: encode3l.c:stream_read_bits
Unexecuted instantiation: decode3f.c:stream_read_bits
Unexecuted instantiation: decode3d.c:stream_read_bits
Unexecuted instantiation: decode3i.c:stream_read_bits
Unexecuted instantiation: decode3l.c:stream_read_bits
Unexecuted instantiation: encode4f.c:stream_read_bits
Unexecuted instantiation: encode4d.c:stream_read_bits
Unexecuted instantiation: encode4i.c:stream_read_bits
Unexecuted instantiation: encode4l.c:stream_read_bits
Unexecuted instantiation: decode4f.c:stream_read_bits
Unexecuted instantiation: decode4d.c:stream_read_bits
Unexecuted instantiation: decode4i.c:stream_read_bits
Unexecuted instantiation: decode4l.c:stream_read_bits
286
287
/* write 0 <= n <= 64 low bits of value and return remaining bits */
288
inline_ uint64
289
stream_write_bits(bitstream* s, uint64 value, bitstream_count n)
290
0
{
291
  /* append bit string to buffer */
292
0
  s->buffer += (bitstream_word)(value << s->bits);
293
0
  s->bits += n;
294
  /* is buffer full? */
295
0
  if (s->bits >= wsize) {
296
    /* 1 <= n <= 64; decrement n to ensure valid right shifts below */
297
0
    value >>= 1;
298
0
    n--;
299
    /* assert: 0 <= n < 64; wsize <= s->bits <= wsize + n */
300
0
    do {
301
      /* output wsize bits while buffer is full */
302
0
      s->bits -= wsize;
303
      /* assert: 0 <= s->bits <= n */
304
0
      stream_write_word(s, s->buffer);
305
      /* assert: 0 <= n - s->bits < 64 */
306
0
      s->buffer = (bitstream_word)(value >> (n - s->bits));
307
0
    } while (sizeof(s->buffer) < sizeof(value) && s->bits >= wsize);
308
0
  }
309
  /* assert: 0 <= s->bits < wsize */
310
0
  s->buffer &= ((bitstream_word)1 << s->bits) - 1;
311
  /* assert: 0 <= n < 64 */
312
0
  return value >> n;
313
0
}
Unexecuted instantiation: stream_write_bits
Unexecuted instantiation: encode1f.c:stream_write_bits
Unexecuted instantiation: encode1d.c:stream_write_bits
Unexecuted instantiation: encode1i.c:stream_write_bits
Unexecuted instantiation: encode1l.c:stream_write_bits
Unexecuted instantiation: decode1f.c:stream_write_bits
Unexecuted instantiation: decode1d.c:stream_write_bits
Unexecuted instantiation: decode1i.c:stream_write_bits
Unexecuted instantiation: decode1l.c:stream_write_bits
Unexecuted instantiation: encode2f.c:stream_write_bits
Unexecuted instantiation: encode2d.c:stream_write_bits
Unexecuted instantiation: encode2i.c:stream_write_bits
Unexecuted instantiation: encode2l.c:stream_write_bits
Unexecuted instantiation: decode2f.c:stream_write_bits
Unexecuted instantiation: decode2d.c:stream_write_bits
Unexecuted instantiation: decode2i.c:stream_write_bits
Unexecuted instantiation: decode2l.c:stream_write_bits
Unexecuted instantiation: encode3f.c:stream_write_bits
Unexecuted instantiation: encode3d.c:stream_write_bits
Unexecuted instantiation: encode3i.c:stream_write_bits
Unexecuted instantiation: encode3l.c:stream_write_bits
Unexecuted instantiation: decode3f.c:stream_write_bits
Unexecuted instantiation: decode3d.c:stream_write_bits
Unexecuted instantiation: decode3i.c:stream_write_bits
Unexecuted instantiation: decode3l.c:stream_write_bits
Unexecuted instantiation: encode4f.c:stream_write_bits
Unexecuted instantiation: encode4d.c:stream_write_bits
Unexecuted instantiation: encode4i.c:stream_write_bits
Unexecuted instantiation: encode4l.c:stream_write_bits
Unexecuted instantiation: decode4f.c:stream_write_bits
Unexecuted instantiation: decode4d.c:stream_write_bits
Unexecuted instantiation: decode4i.c:stream_write_bits
Unexecuted instantiation: decode4l.c:stream_write_bits
314
315
/* return bit offset to next bit to be read */
316
inline_ bitstream_offset
317
stream_rtell(const bitstream* s)
318
0
{
319
0
  return (bitstream_offset)(s->ptr - s->begin) * wsize - s->bits;
320
0
}
Unexecuted instantiation: stream_rtell
Unexecuted instantiation: encode1f.c:stream_rtell
Unexecuted instantiation: encode1d.c:stream_rtell
Unexecuted instantiation: encode1i.c:stream_rtell
Unexecuted instantiation: encode1l.c:stream_rtell
Unexecuted instantiation: decode1f.c:stream_rtell
Unexecuted instantiation: decode1d.c:stream_rtell
Unexecuted instantiation: decode1i.c:stream_rtell
Unexecuted instantiation: decode1l.c:stream_rtell
Unexecuted instantiation: encode2f.c:stream_rtell
Unexecuted instantiation: encode2d.c:stream_rtell
Unexecuted instantiation: encode2i.c:stream_rtell
Unexecuted instantiation: encode2l.c:stream_rtell
Unexecuted instantiation: decode2f.c:stream_rtell
Unexecuted instantiation: decode2d.c:stream_rtell
Unexecuted instantiation: decode2i.c:stream_rtell
Unexecuted instantiation: decode2l.c:stream_rtell
Unexecuted instantiation: encode3f.c:stream_rtell
Unexecuted instantiation: encode3d.c:stream_rtell
Unexecuted instantiation: encode3i.c:stream_rtell
Unexecuted instantiation: encode3l.c:stream_rtell
Unexecuted instantiation: decode3f.c:stream_rtell
Unexecuted instantiation: decode3d.c:stream_rtell
Unexecuted instantiation: decode3i.c:stream_rtell
Unexecuted instantiation: decode3l.c:stream_rtell
Unexecuted instantiation: encode4f.c:stream_rtell
Unexecuted instantiation: encode4d.c:stream_rtell
Unexecuted instantiation: encode4i.c:stream_rtell
Unexecuted instantiation: encode4l.c:stream_rtell
Unexecuted instantiation: decode4f.c:stream_rtell
Unexecuted instantiation: decode4d.c:stream_rtell
Unexecuted instantiation: decode4i.c:stream_rtell
Unexecuted instantiation: decode4l.c:stream_rtell
321
322
/* return bit offset to next bit to be written */
323
inline_ bitstream_offset
324
stream_wtell(const bitstream* s)
325
0
{
326
0
  return (bitstream_offset)(s->ptr - s->begin) * wsize + s->bits;
327
0
}
Unexecuted instantiation: stream_wtell
Unexecuted instantiation: encode1f.c:stream_wtell
Unexecuted instantiation: encode1d.c:stream_wtell
Unexecuted instantiation: encode1i.c:stream_wtell
Unexecuted instantiation: encode1l.c:stream_wtell
Unexecuted instantiation: decode1f.c:stream_wtell
Unexecuted instantiation: decode1d.c:stream_wtell
Unexecuted instantiation: decode1i.c:stream_wtell
Unexecuted instantiation: decode1l.c:stream_wtell
Unexecuted instantiation: encode2f.c:stream_wtell
Unexecuted instantiation: encode2d.c:stream_wtell
Unexecuted instantiation: encode2i.c:stream_wtell
Unexecuted instantiation: encode2l.c:stream_wtell
Unexecuted instantiation: decode2f.c:stream_wtell
Unexecuted instantiation: decode2d.c:stream_wtell
Unexecuted instantiation: decode2i.c:stream_wtell
Unexecuted instantiation: decode2l.c:stream_wtell
Unexecuted instantiation: encode3f.c:stream_wtell
Unexecuted instantiation: encode3d.c:stream_wtell
Unexecuted instantiation: encode3i.c:stream_wtell
Unexecuted instantiation: encode3l.c:stream_wtell
Unexecuted instantiation: decode3f.c:stream_wtell
Unexecuted instantiation: decode3d.c:stream_wtell
Unexecuted instantiation: decode3i.c:stream_wtell
Unexecuted instantiation: decode3l.c:stream_wtell
Unexecuted instantiation: encode4f.c:stream_wtell
Unexecuted instantiation: encode4d.c:stream_wtell
Unexecuted instantiation: encode4i.c:stream_wtell
Unexecuted instantiation: encode4l.c:stream_wtell
Unexecuted instantiation: decode4f.c:stream_wtell
Unexecuted instantiation: decode4d.c:stream_wtell
Unexecuted instantiation: decode4i.c:stream_wtell
Unexecuted instantiation: decode4l.c:stream_wtell
328
329
/* position stream for reading or writing at beginning */
330
inline_ void
331
stream_rewind(bitstream* s)
332
0
{
333
0
  s->ptr = s->begin;
334
0
  s->buffer = 0;
335
0
  s->bits = 0;
336
0
}
Unexecuted instantiation: stream_rewind
Unexecuted instantiation: encode1f.c:stream_rewind
Unexecuted instantiation: encode1d.c:stream_rewind
Unexecuted instantiation: encode1i.c:stream_rewind
Unexecuted instantiation: encode1l.c:stream_rewind
Unexecuted instantiation: decode1f.c:stream_rewind
Unexecuted instantiation: decode1d.c:stream_rewind
Unexecuted instantiation: decode1i.c:stream_rewind
Unexecuted instantiation: decode1l.c:stream_rewind
Unexecuted instantiation: encode2f.c:stream_rewind
Unexecuted instantiation: encode2d.c:stream_rewind
Unexecuted instantiation: encode2i.c:stream_rewind
Unexecuted instantiation: encode2l.c:stream_rewind
Unexecuted instantiation: decode2f.c:stream_rewind
Unexecuted instantiation: decode2d.c:stream_rewind
Unexecuted instantiation: decode2i.c:stream_rewind
Unexecuted instantiation: decode2l.c:stream_rewind
Unexecuted instantiation: encode3f.c:stream_rewind
Unexecuted instantiation: encode3d.c:stream_rewind
Unexecuted instantiation: encode3i.c:stream_rewind
Unexecuted instantiation: encode3l.c:stream_rewind
Unexecuted instantiation: decode3f.c:stream_rewind
Unexecuted instantiation: decode3d.c:stream_rewind
Unexecuted instantiation: decode3i.c:stream_rewind
Unexecuted instantiation: decode3l.c:stream_rewind
Unexecuted instantiation: encode4f.c:stream_rewind
Unexecuted instantiation: encode4d.c:stream_rewind
Unexecuted instantiation: encode4i.c:stream_rewind
Unexecuted instantiation: encode4l.c:stream_rewind
Unexecuted instantiation: decode4f.c:stream_rewind
Unexecuted instantiation: decode4d.c:stream_rewind
Unexecuted instantiation: decode4i.c:stream_rewind
Unexecuted instantiation: decode4l.c:stream_rewind
337
338
/* position stream for reading at given bit offset */
339
inline_ void
340
stream_rseek(bitstream* s, bitstream_offset offset)
341
0
{
342
0
  bitstream_count n = (bitstream_count)(offset % wsize);
343
0
  s->ptr = s->begin + (size_t)(offset / wsize);
344
0
  if (n) {
345
0
    s->buffer = stream_read_word(s) >> n;
346
0
    s->bits = wsize - n;
347
0
  }
348
0
  else {
349
0
    s->buffer = 0;
350
0
    s->bits = 0;
351
0
  }
352
0
}
Unexecuted instantiation: stream_rseek
Unexecuted instantiation: encode1f.c:stream_rseek
Unexecuted instantiation: encode1d.c:stream_rseek
Unexecuted instantiation: encode1i.c:stream_rseek
Unexecuted instantiation: encode1l.c:stream_rseek
Unexecuted instantiation: decode1f.c:stream_rseek
Unexecuted instantiation: decode1d.c:stream_rseek
Unexecuted instantiation: decode1i.c:stream_rseek
Unexecuted instantiation: decode1l.c:stream_rseek
Unexecuted instantiation: encode2f.c:stream_rseek
Unexecuted instantiation: encode2d.c:stream_rseek
Unexecuted instantiation: encode2i.c:stream_rseek
Unexecuted instantiation: encode2l.c:stream_rseek
Unexecuted instantiation: decode2f.c:stream_rseek
Unexecuted instantiation: decode2d.c:stream_rseek
Unexecuted instantiation: decode2i.c:stream_rseek
Unexecuted instantiation: decode2l.c:stream_rseek
Unexecuted instantiation: encode3f.c:stream_rseek
Unexecuted instantiation: encode3d.c:stream_rseek
Unexecuted instantiation: encode3i.c:stream_rseek
Unexecuted instantiation: encode3l.c:stream_rseek
Unexecuted instantiation: decode3f.c:stream_rseek
Unexecuted instantiation: decode3d.c:stream_rseek
Unexecuted instantiation: decode3i.c:stream_rseek
Unexecuted instantiation: decode3l.c:stream_rseek
Unexecuted instantiation: encode4f.c:stream_rseek
Unexecuted instantiation: encode4d.c:stream_rseek
Unexecuted instantiation: encode4i.c:stream_rseek
Unexecuted instantiation: encode4l.c:stream_rseek
Unexecuted instantiation: decode4f.c:stream_rseek
Unexecuted instantiation: decode4d.c:stream_rseek
Unexecuted instantiation: decode4i.c:stream_rseek
Unexecuted instantiation: decode4l.c:stream_rseek
353
354
/* position stream for writing at given bit offset */
355
inline_ void
356
stream_wseek(bitstream* s, bitstream_offset offset)
357
0
{
358
0
  bitstream_count n = (bitstream_count)(offset % wsize);
359
0
  s->ptr = s->begin + (size_t)(offset / wsize);
360
0
  if (n) {
361
0
    bitstream_word buffer = *s->ptr;
362
0
    buffer &= ((bitstream_word)1 << n) - 1;
363
0
    s->buffer = buffer;
364
0
    s->bits = n;
365
0
  }
366
0
  else {
367
0
    s->buffer = 0;
368
0
    s->bits = 0;
369
0
  }
370
0
}
Unexecuted instantiation: stream_wseek
Unexecuted instantiation: encode1f.c:stream_wseek
Unexecuted instantiation: encode1d.c:stream_wseek
Unexecuted instantiation: encode1i.c:stream_wseek
Unexecuted instantiation: encode1l.c:stream_wseek
Unexecuted instantiation: decode1f.c:stream_wseek
Unexecuted instantiation: decode1d.c:stream_wseek
Unexecuted instantiation: decode1i.c:stream_wseek
Unexecuted instantiation: decode1l.c:stream_wseek
Unexecuted instantiation: encode2f.c:stream_wseek
Unexecuted instantiation: encode2d.c:stream_wseek
Unexecuted instantiation: encode2i.c:stream_wseek
Unexecuted instantiation: encode2l.c:stream_wseek
Unexecuted instantiation: decode2f.c:stream_wseek
Unexecuted instantiation: decode2d.c:stream_wseek
Unexecuted instantiation: decode2i.c:stream_wseek
Unexecuted instantiation: decode2l.c:stream_wseek
Unexecuted instantiation: encode3f.c:stream_wseek
Unexecuted instantiation: encode3d.c:stream_wseek
Unexecuted instantiation: encode3i.c:stream_wseek
Unexecuted instantiation: encode3l.c:stream_wseek
Unexecuted instantiation: decode3f.c:stream_wseek
Unexecuted instantiation: decode3d.c:stream_wseek
Unexecuted instantiation: decode3i.c:stream_wseek
Unexecuted instantiation: decode3l.c:stream_wseek
Unexecuted instantiation: encode4f.c:stream_wseek
Unexecuted instantiation: encode4d.c:stream_wseek
Unexecuted instantiation: encode4i.c:stream_wseek
Unexecuted instantiation: encode4l.c:stream_wseek
Unexecuted instantiation: decode4f.c:stream_wseek
Unexecuted instantiation: decode4d.c:stream_wseek
Unexecuted instantiation: decode4i.c:stream_wseek
Unexecuted instantiation: decode4l.c:stream_wseek
371
372
/* skip over the next n bits (n >= 0) */
373
inline_ void
374
stream_skip(bitstream* s, bitstream_size n)
375
0
{
376
0
  stream_rseek(s, stream_rtell(s) + n);
377
0
}
Unexecuted instantiation: stream_skip
Unexecuted instantiation: encode1f.c:stream_skip
Unexecuted instantiation: encode1d.c:stream_skip
Unexecuted instantiation: encode1i.c:stream_skip
Unexecuted instantiation: encode1l.c:stream_skip
Unexecuted instantiation: decode1f.c:stream_skip
Unexecuted instantiation: decode1d.c:stream_skip
Unexecuted instantiation: decode1i.c:stream_skip
Unexecuted instantiation: decode1l.c:stream_skip
Unexecuted instantiation: encode2f.c:stream_skip
Unexecuted instantiation: encode2d.c:stream_skip
Unexecuted instantiation: encode2i.c:stream_skip
Unexecuted instantiation: encode2l.c:stream_skip
Unexecuted instantiation: decode2f.c:stream_skip
Unexecuted instantiation: decode2d.c:stream_skip
Unexecuted instantiation: decode2i.c:stream_skip
Unexecuted instantiation: decode2l.c:stream_skip
Unexecuted instantiation: encode3f.c:stream_skip
Unexecuted instantiation: encode3d.c:stream_skip
Unexecuted instantiation: encode3i.c:stream_skip
Unexecuted instantiation: encode3l.c:stream_skip
Unexecuted instantiation: decode3f.c:stream_skip
Unexecuted instantiation: decode3d.c:stream_skip
Unexecuted instantiation: decode3i.c:stream_skip
Unexecuted instantiation: decode3l.c:stream_skip
Unexecuted instantiation: encode4f.c:stream_skip
Unexecuted instantiation: encode4d.c:stream_skip
Unexecuted instantiation: encode4i.c:stream_skip
Unexecuted instantiation: encode4l.c:stream_skip
Unexecuted instantiation: decode4f.c:stream_skip
Unexecuted instantiation: decode4d.c:stream_skip
Unexecuted instantiation: decode4i.c:stream_skip
Unexecuted instantiation: decode4l.c:stream_skip
378
379
/* append n zero-bits to stream (n >= 0) */
380
inline_ void
381
stream_pad(bitstream* s, bitstream_size n)
382
0
{
383
0
  bitstream_offset bits = s->bits;
384
0
  for (bits += n; bits >= wsize; bits -= wsize) {
385
0
    stream_write_word(s, s->buffer);
386
0
    s->buffer = 0;
387
0
  }
388
0
  s->bits = (bitstream_count)bits;
389
0
}
Unexecuted instantiation: stream_pad
Unexecuted instantiation: encode1f.c:stream_pad
Unexecuted instantiation: encode1d.c:stream_pad
Unexecuted instantiation: encode1i.c:stream_pad
Unexecuted instantiation: encode1l.c:stream_pad
Unexecuted instantiation: decode1f.c:stream_pad
Unexecuted instantiation: decode1d.c:stream_pad
Unexecuted instantiation: decode1i.c:stream_pad
Unexecuted instantiation: decode1l.c:stream_pad
Unexecuted instantiation: encode2f.c:stream_pad
Unexecuted instantiation: encode2d.c:stream_pad
Unexecuted instantiation: encode2i.c:stream_pad
Unexecuted instantiation: encode2l.c:stream_pad
Unexecuted instantiation: decode2f.c:stream_pad
Unexecuted instantiation: decode2d.c:stream_pad
Unexecuted instantiation: decode2i.c:stream_pad
Unexecuted instantiation: decode2l.c:stream_pad
Unexecuted instantiation: encode3f.c:stream_pad
Unexecuted instantiation: encode3d.c:stream_pad
Unexecuted instantiation: encode3i.c:stream_pad
Unexecuted instantiation: encode3l.c:stream_pad
Unexecuted instantiation: decode3f.c:stream_pad
Unexecuted instantiation: decode3d.c:stream_pad
Unexecuted instantiation: decode3i.c:stream_pad
Unexecuted instantiation: decode3l.c:stream_pad
Unexecuted instantiation: encode4f.c:stream_pad
Unexecuted instantiation: encode4d.c:stream_pad
Unexecuted instantiation: encode4i.c:stream_pad
Unexecuted instantiation: encode4l.c:stream_pad
Unexecuted instantiation: decode4f.c:stream_pad
Unexecuted instantiation: decode4d.c:stream_pad
Unexecuted instantiation: decode4i.c:stream_pad
Unexecuted instantiation: decode4l.c:stream_pad
390
391
/* align stream on next word boundary */
392
inline_ bitstream_count
393
stream_align(bitstream* s)
394
0
{
395
0
  bitstream_count bits = s->bits;
396
0
  if (bits)
397
0
    stream_skip(s, bits);
398
0
  return bits;
399
0
}
Unexecuted instantiation: stream_align
Unexecuted instantiation: encode1f.c:stream_align
Unexecuted instantiation: encode1d.c:stream_align
Unexecuted instantiation: encode1i.c:stream_align
Unexecuted instantiation: encode1l.c:stream_align
Unexecuted instantiation: decode1f.c:stream_align
Unexecuted instantiation: decode1d.c:stream_align
Unexecuted instantiation: decode1i.c:stream_align
Unexecuted instantiation: decode1l.c:stream_align
Unexecuted instantiation: encode2f.c:stream_align
Unexecuted instantiation: encode2d.c:stream_align
Unexecuted instantiation: encode2i.c:stream_align
Unexecuted instantiation: encode2l.c:stream_align
Unexecuted instantiation: decode2f.c:stream_align
Unexecuted instantiation: decode2d.c:stream_align
Unexecuted instantiation: decode2i.c:stream_align
Unexecuted instantiation: decode2l.c:stream_align
Unexecuted instantiation: encode3f.c:stream_align
Unexecuted instantiation: encode3d.c:stream_align
Unexecuted instantiation: encode3i.c:stream_align
Unexecuted instantiation: encode3l.c:stream_align
Unexecuted instantiation: decode3f.c:stream_align
Unexecuted instantiation: decode3d.c:stream_align
Unexecuted instantiation: decode3i.c:stream_align
Unexecuted instantiation: decode3l.c:stream_align
Unexecuted instantiation: encode4f.c:stream_align
Unexecuted instantiation: encode4d.c:stream_align
Unexecuted instantiation: encode4i.c:stream_align
Unexecuted instantiation: encode4l.c:stream_align
Unexecuted instantiation: decode4f.c:stream_align
Unexecuted instantiation: decode4d.c:stream_align
Unexecuted instantiation: decode4i.c:stream_align
Unexecuted instantiation: decode4l.c:stream_align
400
401
/* write any remaining buffered bits and align stream on next word boundary */
402
inline_ bitstream_count
403
stream_flush(bitstream* s)
404
0
{
405
0
  bitstream_count bits = (wsize - s->bits) % wsize;
406
0
  if (bits)
407
0
    stream_pad(s, bits);
408
0
  return bits;
409
0
}
Unexecuted instantiation: stream_flush
Unexecuted instantiation: encode1f.c:stream_flush
Unexecuted instantiation: encode1d.c:stream_flush
Unexecuted instantiation: encode1i.c:stream_flush
Unexecuted instantiation: encode1l.c:stream_flush
Unexecuted instantiation: decode1f.c:stream_flush
Unexecuted instantiation: decode1d.c:stream_flush
Unexecuted instantiation: decode1i.c:stream_flush
Unexecuted instantiation: decode1l.c:stream_flush
Unexecuted instantiation: encode2f.c:stream_flush
Unexecuted instantiation: encode2d.c:stream_flush
Unexecuted instantiation: encode2i.c:stream_flush
Unexecuted instantiation: encode2l.c:stream_flush
Unexecuted instantiation: decode2f.c:stream_flush
Unexecuted instantiation: decode2d.c:stream_flush
Unexecuted instantiation: decode2i.c:stream_flush
Unexecuted instantiation: decode2l.c:stream_flush
Unexecuted instantiation: encode3f.c:stream_flush
Unexecuted instantiation: encode3d.c:stream_flush
Unexecuted instantiation: encode3i.c:stream_flush
Unexecuted instantiation: encode3l.c:stream_flush
Unexecuted instantiation: decode3f.c:stream_flush
Unexecuted instantiation: decode3d.c:stream_flush
Unexecuted instantiation: decode3i.c:stream_flush
Unexecuted instantiation: decode3l.c:stream_flush
Unexecuted instantiation: encode4f.c:stream_flush
Unexecuted instantiation: encode4d.c:stream_flush
Unexecuted instantiation: encode4i.c:stream_flush
Unexecuted instantiation: encode4l.c:stream_flush
Unexecuted instantiation: decode4f.c:stream_flush
Unexecuted instantiation: decode4d.c:stream_flush
Unexecuted instantiation: decode4i.c:stream_flush
Unexecuted instantiation: decode4l.c:stream_flush
410
411
/* copy n bits from one bit stream to another */
412
inline_ void
413
stream_copy(bitstream* dst, bitstream* src, bitstream_size n)
414
0
{
415
0
  while (n > wsize) {
416
0
    bitstream_word w = (bitstream_word)stream_read_bits(src, wsize);
417
0
    stream_write_bits(dst, w, wsize);
418
0
    n -= wsize;
419
0
  }
420
0
  if (n) {
421
0
    bitstream_word w = (bitstream_word)stream_read_bits(src, (bitstream_count)n);
422
0
    stream_write_bits(dst, w, (bitstream_count)n);
423
0
  }
424
0
}
Unexecuted instantiation: stream_copy
Unexecuted instantiation: encode1f.c:stream_copy
Unexecuted instantiation: encode1d.c:stream_copy
Unexecuted instantiation: encode1i.c:stream_copy
Unexecuted instantiation: encode1l.c:stream_copy
Unexecuted instantiation: decode1f.c:stream_copy
Unexecuted instantiation: decode1d.c:stream_copy
Unexecuted instantiation: decode1i.c:stream_copy
Unexecuted instantiation: decode1l.c:stream_copy
Unexecuted instantiation: encode2f.c:stream_copy
Unexecuted instantiation: encode2d.c:stream_copy
Unexecuted instantiation: encode2i.c:stream_copy
Unexecuted instantiation: encode2l.c:stream_copy
Unexecuted instantiation: decode2f.c:stream_copy
Unexecuted instantiation: decode2d.c:stream_copy
Unexecuted instantiation: decode2i.c:stream_copy
Unexecuted instantiation: decode2l.c:stream_copy
Unexecuted instantiation: encode3f.c:stream_copy
Unexecuted instantiation: encode3d.c:stream_copy
Unexecuted instantiation: encode3i.c:stream_copy
Unexecuted instantiation: encode3l.c:stream_copy
Unexecuted instantiation: decode3f.c:stream_copy
Unexecuted instantiation: decode3d.c:stream_copy
Unexecuted instantiation: decode3i.c:stream_copy
Unexecuted instantiation: decode3l.c:stream_copy
Unexecuted instantiation: encode4f.c:stream_copy
Unexecuted instantiation: encode4d.c:stream_copy
Unexecuted instantiation: encode4i.c:stream_copy
Unexecuted instantiation: encode4l.c:stream_copy
Unexecuted instantiation: decode4f.c:stream_copy
Unexecuted instantiation: decode4d.c:stream_copy
Unexecuted instantiation: decode4i.c:stream_copy
Unexecuted instantiation: decode4l.c:stream_copy
425
426
#ifdef BIT_STREAM_STRIDED
427
/* set block size in number of words and spacing in number of blocks */
428
inline_ int
429
stream_set_stride(bitstream* s, size_t block, ptrdiff_t delta)
430
{
431
  /* ensure block size is a power of two */
432
  if (block & (block - 1))
433
    return 0;
434
  s->mask = block - 1;
435
  s->delta = delta * block;
436
  return 1;
437
}
438
#endif
439
440
/* allocate and initialize bit stream to user-allocated buffer */
441
inline_ bitstream*
442
stream_open(void* buffer, size_t bytes)
443
0
{
444
0
  bitstream* s = (bitstream*)malloc(sizeof(bitstream));
445
0
  if (s) {
446
0
    s->begin = (bitstream_word*)buffer;
447
0
    s->end = s->begin + bytes / sizeof(bitstream_word);
448
#ifdef BIT_STREAM_STRIDED
449
    stream_set_stride(s, 0, 0);
450
#endif
451
0
    stream_rewind(s);
452
0
  }
453
0
  return s;
454
0
}
Unexecuted instantiation: stream_open
Unexecuted instantiation: encode1f.c:stream_open
Unexecuted instantiation: encode1d.c:stream_open
Unexecuted instantiation: encode1i.c:stream_open
Unexecuted instantiation: encode1l.c:stream_open
Unexecuted instantiation: decode1f.c:stream_open
Unexecuted instantiation: decode1d.c:stream_open
Unexecuted instantiation: decode1i.c:stream_open
Unexecuted instantiation: decode1l.c:stream_open
Unexecuted instantiation: encode2f.c:stream_open
Unexecuted instantiation: encode2d.c:stream_open
Unexecuted instantiation: encode2i.c:stream_open
Unexecuted instantiation: encode2l.c:stream_open
Unexecuted instantiation: decode2f.c:stream_open
Unexecuted instantiation: decode2d.c:stream_open
Unexecuted instantiation: decode2i.c:stream_open
Unexecuted instantiation: decode2l.c:stream_open
Unexecuted instantiation: encode3f.c:stream_open
Unexecuted instantiation: encode3d.c:stream_open
Unexecuted instantiation: encode3i.c:stream_open
Unexecuted instantiation: encode3l.c:stream_open
Unexecuted instantiation: decode3f.c:stream_open
Unexecuted instantiation: decode3d.c:stream_open
Unexecuted instantiation: decode3i.c:stream_open
Unexecuted instantiation: decode3l.c:stream_open
Unexecuted instantiation: encode4f.c:stream_open
Unexecuted instantiation: encode4d.c:stream_open
Unexecuted instantiation: encode4i.c:stream_open
Unexecuted instantiation: encode4l.c:stream_open
Unexecuted instantiation: decode4f.c:stream_open
Unexecuted instantiation: decode4d.c:stream_open
Unexecuted instantiation: decode4i.c:stream_open
Unexecuted instantiation: decode4l.c:stream_open
455
456
/* close and deallocate bit stream */
457
inline_ void
458
stream_close(bitstream* s)
459
0
{
460
0
  free(s);
461
0
}
Unexecuted instantiation: stream_close
Unexecuted instantiation: encode1f.c:stream_close
Unexecuted instantiation: encode1d.c:stream_close
Unexecuted instantiation: encode1i.c:stream_close
Unexecuted instantiation: encode1l.c:stream_close
Unexecuted instantiation: decode1f.c:stream_close
Unexecuted instantiation: decode1d.c:stream_close
Unexecuted instantiation: decode1i.c:stream_close
Unexecuted instantiation: decode1l.c:stream_close
Unexecuted instantiation: encode2f.c:stream_close
Unexecuted instantiation: encode2d.c:stream_close
Unexecuted instantiation: encode2i.c:stream_close
Unexecuted instantiation: encode2l.c:stream_close
Unexecuted instantiation: decode2f.c:stream_close
Unexecuted instantiation: decode2d.c:stream_close
Unexecuted instantiation: decode2i.c:stream_close
Unexecuted instantiation: decode2l.c:stream_close
Unexecuted instantiation: encode3f.c:stream_close
Unexecuted instantiation: encode3d.c:stream_close
Unexecuted instantiation: encode3i.c:stream_close
Unexecuted instantiation: encode3l.c:stream_close
Unexecuted instantiation: decode3f.c:stream_close
Unexecuted instantiation: decode3d.c:stream_close
Unexecuted instantiation: decode3i.c:stream_close
Unexecuted instantiation: decode3l.c:stream_close
Unexecuted instantiation: encode4f.c:stream_close
Unexecuted instantiation: encode4d.c:stream_close
Unexecuted instantiation: encode4i.c:stream_close
Unexecuted instantiation: encode4l.c:stream_close
Unexecuted instantiation: decode4f.c:stream_close
Unexecuted instantiation: decode4d.c:stream_close
Unexecuted instantiation: decode4i.c:stream_close
Unexecuted instantiation: decode4l.c:stream_close
462
463
/* make a copy of bit stream to shared memory buffer */
464
inline_ bitstream*
465
stream_clone(const bitstream* s)
466
0
{
467
0
  bitstream* c = (bitstream*)malloc(sizeof(bitstream));
468
0
  if (c)
469
0
    *c = *s;
470
0
  return c;
471
0
}
Unexecuted instantiation: stream_clone
Unexecuted instantiation: encode1f.c:stream_clone
Unexecuted instantiation: encode1d.c:stream_clone
Unexecuted instantiation: encode1i.c:stream_clone
Unexecuted instantiation: encode1l.c:stream_clone
Unexecuted instantiation: decode1f.c:stream_clone
Unexecuted instantiation: decode1d.c:stream_clone
Unexecuted instantiation: decode1i.c:stream_clone
Unexecuted instantiation: decode1l.c:stream_clone
Unexecuted instantiation: encode2f.c:stream_clone
Unexecuted instantiation: encode2d.c:stream_clone
Unexecuted instantiation: encode2i.c:stream_clone
Unexecuted instantiation: encode2l.c:stream_clone
Unexecuted instantiation: decode2f.c:stream_clone
Unexecuted instantiation: decode2d.c:stream_clone
Unexecuted instantiation: decode2i.c:stream_clone
Unexecuted instantiation: decode2l.c:stream_clone
Unexecuted instantiation: encode3f.c:stream_clone
Unexecuted instantiation: encode3d.c:stream_clone
Unexecuted instantiation: encode3i.c:stream_clone
Unexecuted instantiation: encode3l.c:stream_clone
Unexecuted instantiation: decode3f.c:stream_clone
Unexecuted instantiation: decode3d.c:stream_clone
Unexecuted instantiation: decode3i.c:stream_clone
Unexecuted instantiation: decode3l.c:stream_clone
Unexecuted instantiation: encode4f.c:stream_clone
Unexecuted instantiation: encode4d.c:stream_clone
Unexecuted instantiation: encode4i.c:stream_clone
Unexecuted instantiation: encode4l.c:stream_clone
Unexecuted instantiation: decode4f.c:stream_clone
Unexecuted instantiation: decode4d.c:stream_clone
Unexecuted instantiation: decode4i.c:stream_clone
Unexecuted instantiation: decode4l.c:stream_clone
472
473
#undef unused_