29 #ifndef PGF_BITSTREAM_H
30 #define PGF_BITSTREAM_H
37 static const UINT32
Filled = 0xFFFFFFFF;
40 #define MAKEU64(a, b) ((UINT64) (((UINT32) (a)) | ((UINT64) ((UINT32) (b))) << 32))
79 const UINT32
iHiInt = (pos + k - 1) >> WordWidthLog;
83 if (iLoInt == iHiInt) {
87 return (stream[iLoInt] & val) == val;
90 UINT64 v1 =
MAKEU64(stream[iLoInt], stream[iHiInt]);
91 UINT64 v2 = UINT64(val & mask) << (pos%
WordWidth);
92 return (v1 & v2) == v2;
105 const UINT32
iHiInt = (pos + k - 1) >> WordWidthLog;
110 if (iLoInt == iHiInt) {
116 stream[
iLoInt] &= ~loMask;
118 stream[
iHiInt] &= ~hiMask;
128 inline UINT32 GetValueBlock(UINT32* stream, UINT32
pos, UINT32
k) {
131 const UINT32
iHiInt = (pos + k - 1) >> WordWidthLog;
155 inline void ClearBitBlock(UINT32* stream, UINT32
pos, UINT32
len) {
158 const UINT32
iLastInt = (pos + len - 1) >> WordWidthLog;
163 if (iFirstInt == iLastInt) {
167 for (UINT32 i = iFirstInt + 1; i <=
iLastInt; i++) {
183 const UINT32 iLastInt = (pos + len - 1) >> WordWidthLog;
188 if (iFirstInt == iLastInt) {
192 for (UINT32 i = iFirstInt + 1; i <=
iLastInt; i++) {
206 inline UINT32 SeekBitRange(UINT32* stream, UINT32 pos, UINT32 len) {
211 while (((*word & testMask) == 0) && (count < len)) {
215 word++; testMask = 1;
218 while ((count +
WordWidth <= len) && (*word == 0)) {
235 inline UINT32 SeekBit1Range(UINT32* stream, UINT32 pos, UINT32 len) {
240 while (((*word & testMask) != 0) && (count < len)) {
244 word++; testMask = 1;
272 #endif //PGF_BITSTREAM_H