Go to the source code of this file.
|
#define | MAKEU64(a, b) ((UINT64) (((UINT32) (a)) | ((UINT64) ((UINT32) (b))) << 32)) |
| Make 64 bit unsigned integer from two 32 bit unsigned integers. More...
|
|
|
void | SetBit (UINT32 *stream, UINT32 pos) |
|
void | ClearBit (UINT32 *stream, UINT32 pos) |
|
bool | GetBit (UINT32 *stream, UINT32 pos) |
|
bool | CompareBitBlock (UINT32 *stream, UINT32 pos, UINT32 k, UINT32 val) |
|
void | SetValueBlock (UINT32 *stream, UINT32 pos, UINT32 val, UINT32 k) |
|
UINT32 | GetValueBlock (UINT32 *stream, UINT32 pos, UINT32 k) |
|
void | ClearBitBlock (UINT32 *stream, UINT32 pos, UINT32 len) |
|
void | SetBitBlock (UINT32 *stream, UINT32 pos, UINT32 len) |
|
UINT32 | SeekBitRange (UINT32 *stream, UINT32 pos, UINT32 len) |
|
UINT32 | SeekBit1Range (UINT32 *stream, UINT32 pos, UINT32 len) |
|
UINT32 | AlignWordPos (UINT32 pos) |
|
UINT32 | NumberOfWords (UINT32 pos) |
|
|
static const UINT32 | Filled = 0xFFFFFFFF |
|
◆ MAKEU64
#define MAKEU64 |
( |
|
a, |
|
|
|
b |
|
) |
| ((UINT64) (((UINT32) (a)) | ((UINT64) ((UINT32) (b))) << 32)) |
Make 64 bit unsigned integer from two 32 bit unsigned integers.
Definition at line 40 of file BitStream.h.
◆ AlignWordPos()
UINT32 AlignWordPos |
( |
UINT32 |
pos | ) |
|
|
inline |
Compute bit position of the next 32-bit word
- Parameters
-
pos | current bit stream position |
- Returns
- bit position of next 32-bit word
Definition at line 260 of file BitStream.h.
◆ ClearBit()
void ClearBit |
( |
UINT32 * |
stream, |
|
|
UINT32 |
pos |
|
) |
| |
|
inline |
Set one bit of a bit stream to 0
- Parameters
-
stream | A bit stream stored in array of unsigned integers |
pos | A valid zero-based position in the bit stream |
Definition at line 56 of file BitStream.h.
◆ ClearBitBlock()
void ClearBitBlock |
( |
UINT32 * |
stream, |
|
|
UINT32 |
pos, |
|
|
UINT32 |
len |
|
) |
| |
|
inline |
Clear block of size at least len at position pos in stream
- Parameters
-
stream | A bit stream stored in array of unsigned integers |
pos | A valid zero-based position in the bit stream |
len | Number of bits set to 0 |
Definition at line 155 of file BitStream.h.
155 {
156 ASSERT(len > 0);
158 const UINT32 iLastInt = (pos + len - 1) >>
WordWidthLog;
159
161
162
163 if (iFirstInt == iLastInt) {
164 stream[iFirstInt] &= ~(startMask );
165 } else {
166 stream[iFirstInt] &= ~startMask;
167 for (UINT32 i = iFirstInt + 1; i <= iLastInt; i++) {
168 stream[i] = 0;
169 }
170
171 }
172}
static const UINT32 Filled
◆ CompareBitBlock()
bool CompareBitBlock |
( |
UINT32 * |
stream, |
|
|
UINT32 |
pos, |
|
|
UINT32 |
k, |
|
|
UINT32 |
val |
|
) |
| |
|
inline |
Compare k-bit binary representation of stream at position pos with val
- Parameters
-
stream | A bit stream stored in array of unsigned integers |
pos | A valid zero-based position in the bit stream |
k | Number of bits to compare |
val | Value to compare with |
- Returns
- true if equal
Definition at line 77 of file BitStream.h.
77 {
80 ASSERT(iLoInt <= iHiInt);
82
83 if (iLoInt == iHiInt) {
84
85 val &= mask;
87 return (stream[iLoInt] & val) == val;
88 } else {
89
90 UINT64 v1 =
MAKEU64(stream[iLoInt], stream[iHiInt]);
91 UINT64 v2 = UINT64(val & mask) << (pos%
WordWidth);
92 return (v1 & v2) == v2;
93 }
94}
#define MAKEU64(a, b)
Make 64 bit unsigned integer from two 32 bit unsigned integers.
◆ GetBit()
bool GetBit |
( |
UINT32 * |
stream, |
|
|
UINT32 |
pos |
|
) |
| |
|
inline |
Return one bit of a bit stream
- Parameters
-
stream | A bit stream stored in array of unsigned integers |
pos | A valid zero-based position in the bit stream |
- Returns
- bit at position pos of bit stream stream
Definition at line 65 of file BitStream.h.
◆ GetValueBlock()
UINT32 GetValueBlock |
( |
UINT32 * |
stream, |
|
|
UINT32 |
pos, |
|
|
UINT32 |
k |
|
) |
| |
|
inline |
Read k-bit number from stream at position pos
- Parameters
-
stream | A bit stream stored in array of unsigned integers |
pos | A valid zero-based position in the bit stream |
k | Number of bits to read: 1 <= k <= 32 |
Definition at line 128 of file BitStream.h.
128 {
129 UINT32 count, hiCount;
134
135 if (iLoInt == iHiInt) {
136
137 count = stream[iLoInt] & (loMask & hiMask);
139 } else {
140
141 count = stream[iLoInt] & loMask;
143 hiCount = stream[iHiInt] & hiMask;
145 count |= hiCount;
146 }
147 return count;
148}
◆ NumberOfWords()
UINT32 NumberOfWords |
( |
UINT32 |
pos | ) |
|
|
inline |
Compute number of the 32-bit words
- Parameters
-
pos | Current bit stream position |
- Returns
- Number of 32-bit words
Definition at line 269 of file BitStream.h.
◆ SeekBit1Range()
UINT32 SeekBit1Range |
( |
UINT32 * |
stream, |
|
|
UINT32 |
pos, |
|
|
UINT32 |
len |
|
) |
| |
|
inline |
Returns the distance to the next 0 in stream at position pos. If no 0 is found within len bits, then len is returned.
- Parameters
-
stream | A bit stream stored in array of unsigned integers |
pos | A valid zero-based position in the bit stream |
len | size of search area (in bits) return The distance to the next 0 in stream at position pos |
Definition at line 235 of file BitStream.h.
235 {
236 UINT32 count = 0;
239
240 while (((*word & testMask) != 0) && (count < len)) {
241 count++;
242 testMask <<= 1;
243 if (!testMask) {
244 word++; testMask = 1;
245
246
248 word++;
250 }
251 }
252 }
253 return count;
254}
◆ SeekBitRange()
UINT32 SeekBitRange |
( |
UINT32 * |
stream, |
|
|
UINT32 |
pos, |
|
|
UINT32 |
len |
|
) |
| |
|
inline |
Returns the distance to the next 1 in stream at position pos. If no 1 is found within len bits, then len is returned.
- Parameters
-
stream | A bit stream stored in array of unsigned integers |
pos | A valid zero-based position in the bit stream |
len | size of search area (in bits) return The distance to the next 1 in stream at position pos |
Definition at line 206 of file BitStream.h.
206 {
207 UINT32 count = 0;
210
211 while (((*word & testMask) == 0) && (count < len)) {
212 count++;
213 testMask <<= 1;
214 if (!testMask) {
215 word++; testMask = 1;
216
217
218 while ((count +
WordWidth <= len) && (*word == 0)) {
219 word++;
221 }
222 }
223 }
224
225 return count;
226}
◆ SetBit()
void SetBit |
( |
UINT32 * |
stream, |
|
|
UINT32 |
pos |
|
) |
| |
|
inline |
Set one bit of a bit stream to 1
- Parameters
-
stream | A bit stream stored in array of unsigned integers |
pos | A valid zero-based position in the bit stream |
Definition at line 48 of file BitStream.h.
◆ SetBitBlock()
void SetBitBlock |
( |
UINT32 * |
stream, |
|
|
UINT32 |
pos, |
|
|
UINT32 |
len |
|
) |
| |
|
inline |
Set block of size at least len at position pos in stream
- Parameters
-
stream | A bit stream stored in array of unsigned integers |
pos | A valid zero-based position in the bit stream |
len | Number of bits set to 1 |
Definition at line 179 of file BitStream.h.
179 {
180 ASSERT(len > 0);
181
183 const UINT32 iLastInt = (pos + len - 1) >>
WordWidthLog;
184
186
187
188 if (iFirstInt == iLastInt) {
189 stream[iFirstInt] |= (startMask );
190 } else {
191 stream[iFirstInt] |= startMask;
192 for (UINT32 i = iFirstInt + 1; i <= iLastInt; i++) {
194 }
195
196 }
197}
◆ SetValueBlock()
void SetValueBlock |
( |
UINT32 * |
stream, |
|
|
UINT32 |
pos, |
|
|
UINT32 |
val, |
|
|
UINT32 |
k |
|
) |
| |
|
inline |
Store k-bit binary representation of val in stream at position pos
- Parameters
-
stream | A bit stream stored in array of unsigned integers |
pos | A valid zero-based position in the bit stream |
val | Value to store in stream at position pos |
k | Number of bits of integer representation of val |
Definition at line 102 of file BitStream.h.
102 {
106 ASSERT(iLoInt <= iHiInt);
107 const UINT32 loMask =
Filled << offset;
109
110 if (iLoInt == iHiInt) {
111
112 stream[iLoInt] &= ~(loMask & hiMask);
113 stream[iLoInt] |= val << offset;
114 } else {
115
116 stream[iLoInt] &= ~loMask;
117 stream[iLoInt] |= val << offset;
118 stream[iHiInt] &= ~hiMask;
119 stream[iHiInt] |= val >> (
WordWidth - offset);
120 }
121}
◆ Filled
const UINT32 Filled = 0xFFFFFFFF |
|
static |