libpgf  6.12.24
PGF - Progressive Graphics File
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
BitStream.h File Reference
#include "PGFtypes.h"

Go to the source code of this file.

Macros

#define MAKEU64(a, b)   ((UINT64) (((UINT32) (a)) | ((UINT64) ((UINT32) (b))) << 32))
 Make 64 bit unsigned integer from two 32 bit unsigned integers.
 

Functions

*Set one bit of a bit stream
to *param stream A bit stream
stored in array of unsigned
integers *param pos A valid
zero based position in the bit
stream *void 
SetBit (UINT32 *stream, UINT32 pos)
 
*Set one bit of a bit stream
to *param stream A bit stream
stored in array of unsigned
integers *param pos A valid
zero based position in the bit
stream *void 
ClearBit (UINT32 *stream, UINT32 pos)
 
*Return one bit of a bit
stream *param stream A bit
stream stored in array of
unsigned integers *param pos A
valid zero based position in
the bit stream *return bit at
position pos of bit stream
stream *bool 
GetBit (UINT32 *stream, UINT32 pos)
 
*Compare k bit binary
representation of stream at
position pos with val *param
stream A bit stream stored in
array of unsigned integers
*param pos A valid zero based
position in the bit stream
*param k Number of bits to
compare *param val Value to
compare with *return true if
equal *bool 
CompareBitBlock (UINT32 *stream, UINT32 pos, UINT32 k, UINT32 val)
 
*Store k bit binary
representation of val in
stream at position pos *param
stream A bit stream stored in
array of unsigned integers
*param pos A valid zero based
position in the bit stream
*param val Value to store in
stream at position pos *param
k Number of bits of integer
representation of val *void 
SetValueBlock (UINT32 *stream, UINT32 pos, UINT32 val, UINT32 k)
 
 if (iLoInt==iHiInt)
 
 if (iFirstInt==iLastInt)
 
 for (UINT32 i=iFirstInt+1;i<=iLastInt;i++)
 
*Set block of size at least
len at position pos in stream
*param stream A bit stream
stored in array of unsigned
integers *param pos A valid
zero based position in the bit
stream *param len Number of
bits set to *void 
SetBitBlock (UINT32 *stream, UINT32 pos, UINT32 len)
 
*Returns the distance to the
next in stream at position pos
*If no is found within len
then len is returned *param
stream A bit stream stored in
array of unsigned integers
*param pos A valid zero based
position in the bit stream
*param len size of search 
area (in bits)*return The distance to the next 1 in stream at position pos */inline UINT32 SeekBitRange(UINT32 *stream
 
 while (((*word &testMask)==0)&&(count< len))
 
 while (((*word &testMask)!=0)&&(count< len))
 
*Compute bit position of the
next bit word *param pos
current bit stream position
*return bit position of next
bit word *UINT32 
AlignWordPos (UINT32 pos)
 
*Compute number of the bit
words *param pos Current bit
stream position *return Number
of bit words *UINT32 
NumberOfWords (UINT32 pos)
 

Variables

*file Bitstream h *brief PGF
bit stream operations *author
C Stamm *static const UINT32 
Filled = 0xFFFFFFFF
 
*Read k bit number from stream
at position pos *param stream
A bit stream stored in array
of unsigned integers *param
pos A valid zero based
position in the bit stream
*param k Number of bits to 
read
 
*Read k bit number from stream
at position pos *param stream
A bit stream stored in array
of unsigned integers *param
pos A valid zero based
position in the bit stream
*param k Number of bits to
UINT32 
pos
 
*Read k bit number from stream
at position pos *param stream
A bit stream stored in array
of unsigned integers *param
pos A valid zero based
position in the bit stream
*param k Number of bits to
UINT32 UINT32 
k
 
const UINT32 iLoInt = pos >> WordWidthLog
 
const UINT32 iHiInt = (pos + k - 1) >> WordWidthLog
 
const UINT32 loMask = Filled << (pos%WordWidth)
 
const UINT32 hiMask = Filled >> (WordWidth - 1 - ((pos + k - 1)%WordWidth))
 
 else
 
 count = pos%WordWidth
 
 hiCount = stream[iHiInt] & hiMask
 
const UINT32 iFirstInt = pos >> WordWidthLog
 
const UINT32 iLastInt = (pos + len - 1) >> WordWidthLog
 
const UINT32 startMask = Filled << (pos%WordWidth)
 
*Returns the distance to the
next in stream at position pos
*If no is found within len 
bits
 
*Returns the distance to the
next in stream at position pos
*If no is found within len
then len is returned *param
stream A bit stream stored in
array of unsigned integers
*param pos A valid zero based
position in the bit stream
*param len size of search
UINT32 UINT32 
len
 
UINT32 testMask = 1 << (pos%WordWidth)
 
UINT32 * word = stream + (pos >> WordWidthLog)
 

Macro Definition Documentation

#define MAKEU64 (   a,
 
)    ((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.

Function Documentation

* Compute bit position of the next bit word* param pos current bit stream position* return bit position of next bit word* UINT32 AlignWordPos ( UINT32  pos)
inline

Definition at line 260 of file BitStream.h.

{
// return ((pos + WordWidth - 1) >> WordWidthLog) << WordWidthLog;
return DWWIDTHBITS(pos);
}
*Returns the distance to the next in stream at position pos *If no is found within len then len is returned *param stream A bit stream stored in array of unsigned integers *param pos A valid zero based position in the bit stream *param len size of search area ( in  bits)
* Set one bit of a bit stream to* param stream A bit stream stored in array of unsigned integers* param pos A valid zero based position in the bit stream* void ClearBit ( UINT32 *  stream,
UINT32  pos 
)
inline

Definition at line 56 of file BitStream.h.

{
stream[pos >> WordWidthLog] &= ~(1 << (pos%WordWidth));
}
* Compare k bit binary representation of stream at position pos with val* param stream A bit stream stored in array of unsigned integers* param pos A valid zero based position in the bit stream* param k Number of bits to compare* param val Value to compare with* return true if equal* bool CompareBitBlock ( UINT32 *  stream,
UINT32  pos,
UINT32  k,
UINT32  val 
)
inline

Definition at line 77 of file BitStream.h.

{
const UINT32 iLoInt = pos >> WordWidthLog;
const UINT32 iHiInt = (pos + k - 1) >> WordWidthLog;
ASSERT(iLoInt <= iHiInt);
const UINT32 mask = (Filled >> (WordWidth - k));
if (iLoInt == iHiInt) {
// fits into one integer
val &= mask;
val <<= (pos%WordWidth);
return (stream[iLoInt] & val) == val;
} else {
// must be splitted over integer boundary
UINT64 v1 = MAKEU64(stream[iLoInt], stream[iHiInt]);
UINT64 v2 = UINT64(val & mask) << (pos%WordWidth);
return (v1 & v2) == v2;
}
}
for ( )

Definition at line 167 of file BitStream.h.

{ // changed <=
stream[i] = 0;
}
* Return one bit of a bit stream* param stream A bit stream stored in array of unsigned integers* param pos A valid zero based position in the bit stream* return bit at position pos of bit stream stream* bool GetBit ( UINT32 *  stream,
UINT32  pos 
)
inline

Definition at line 65 of file BitStream.h.

{
return (stream[pos >> WordWidthLog] & (1 << (pos%WordWidth))) > 0;
}
if ( iLoInt  = iHiInt)

Definition at line 135 of file BitStream.h.

{
// inside integer boundary
count = stream[iLoInt] & (loMask & hiMask);
} else {
if ( iFirstInt  = iLastInt)

Definition at line 163 of file BitStream.h.

{
stream[iFirstInt] &= ~(startMask /*& endMask*/);
} else {
* Compute number of the bit words* param pos Current bit stream position* return Number of bit words* UINT32 NumberOfWords ( UINT32  pos)
inline

Definition at line 269 of file BitStream.h.

{
return (pos + WordWidth - 1) >> WordWidthLog;
}
* Set one bit of a bit stream to* param stream A bit stream stored in array of unsigned integers* param pos A valid zero based position in the bit stream* void SetBit ( UINT32 *  stream,
UINT32  pos 
)
inline

Definition at line 48 of file BitStream.h.

{
stream[pos >> WordWidthLog] |= (1 << (pos%WordWidth));
}
* Set block of size at least len at position pos in stream* param stream A bit stream stored in array of unsigned integers* param pos A valid zero based position in the bit stream* param len Number of bits set to* void SetBitBlock ( UINT32 *  stream,
UINT32  pos,
UINT32  len 
)
inline

Definition at line 179 of file BitStream.h.

{
ASSERT(len > 0);
const UINT32 iFirstInt = pos >> WordWidthLog;
const UINT32 iLastInt = (pos + len - 1) >> WordWidthLog;
const UINT32 startMask = Filled << (pos%WordWidth);
// const UINT32 endMask=Filled>>(WordWidth-1-((pos+len-1)%WordWidth));
if (iFirstInt == iLastInt) {
stream[iFirstInt] |= (startMask /*& endMask*/);
} else {
stream[iFirstInt] |= startMask;
for (UINT32 i = iFirstInt + 1; i <= iLastInt; i++) { // changed <=
stream[i] = Filled;
}
//stream[iLastInt] &= ~endMask;
}
}
* Store k bit binary representation of val in stream at position pos* param stream A bit stream stored in array of unsigned integers* param pos A valid zero based position in the bit stream* param val Value to store in stream at position pos* param k Number of bits of integer representation of val* void SetValueBlock ( UINT32 *  stream,
UINT32  pos,
UINT32  val,
UINT32  k 
)
inline

Definition at line 102 of file BitStream.h.

{
const UINT32 offset = pos%WordWidth;
const UINT32 iLoInt = pos >> WordWidthLog;
const UINT32 iHiInt = (pos + k - 1) >> WordWidthLog;
ASSERT(iLoInt <= iHiInt);
const UINT32 loMask = Filled << offset;
const UINT32 hiMask = Filled >> (WordWidth - 1 - ((pos + k - 1)%WordWidth));
if (iLoInt == iHiInt) {
// fits into one integer
stream[iLoInt] &= ~(loMask & hiMask); // clear bits
stream[iLoInt] |= val << offset; // write value
} else {
// must be splitted over integer boundary
stream[iLoInt] &= ~loMask; // clear bits
stream[iLoInt] |= val << offset; // write lower part of value
stream[iHiInt] &= ~hiMask; // clear bits
stream[iHiInt] |= val >> (WordWidth - offset); // write higher part of value
}
}
while ( ((*word &testMask)==0)&&(count< len )

Definition at line 211 of file BitStream.h.

{
count++;
testMask <<= 1;
if (!testMask) {
word++; testMask = 1;
// fast steps if all bits in a word are zero
while ((count + WordWidth <= len) && (*word == 0)) {
word++;
}
}
}
while ( ((*word &testMask)!=0)&&(count< len )

Definition at line 240 of file BitStream.h.

{
count++;
testMask <<= 1;
if (!testMask) {
word++; testMask = 1;
// fast steps if all bits in a word are one
while ((count + WordWidth <= len) && (*word == Filled)) {
word++;
}
}
}

Variable Documentation

*Returns the distance to the next in stream at position pos *If no is found within len bits

Definition at line 201 of file BitStream.h.

return count = pos%WordWidth

Definition at line 142 of file BitStream.h.

else
Initial value:
{
count = stream[iLoInt] & loMask

Definition at line 139 of file BitStream.h.

* file Bitstream h* brief PGF bit stream operations* author C Stamm* static const UINT32 Filled = 0xFFFFFFFF
static

Definition at line 37 of file BitStream.h.

hiCount = stream[iHiInt] & hiMask

Definition at line 143 of file BitStream.h.

const UINT32 hiMask = Filled >> (WordWidth - 1 - ((pos + k - 1)%WordWidth))

Definition at line 133 of file BitStream.h.

const UINT32 iFirstInt = pos >> WordWidthLog

Definition at line 157 of file BitStream.h.

const UINT32 iHiInt = (pos + k - 1) >> WordWidthLog

Definition at line 131 of file BitStream.h.

const UINT32 iLastInt = (pos + len - 1) >> WordWidthLog

Definition at line 158 of file BitStream.h.

const UINT32 iLoInt = pos >> WordWidthLog

Definition at line 130 of file BitStream.h.

* Read k bit number from stream at position pos* param stream A bit stream stored in array of unsigned integers* param pos A valid zero based position in the bit stream* param k Number of bits to UINT32 UINT32 k
Initial value:
{
UINT32 count, hiCount

Definition at line 128 of file BitStream.h.

return len
Initial value:
{
UINT32 count = 0

Definition at line 206 of file BitStream.h.

const UINT32 loMask = Filled << (pos%WordWidth)

Definition at line 132 of file BitStream.h.

*Returns the distance to the next in stream at position pos *If no is found within len then len is returned *param stream A bit stream stored in array of unsigned integers *param pos A valid zero based position in the bit stream *param len size of search UINT32 pos

Definition at line 128 of file BitStream.h.

* Read k bit number from stream at position pos* param stream A bit stream stored in array of unsigned integers* param pos A valid zero based position in the bit stream* param k Number of bits to read

Definition at line 128 of file BitStream.h.

const UINT32 startMask = Filled << (pos%WordWidth)

Definition at line 160 of file BitStream.h.

UINT32 testMask = 1 << (pos%WordWidth)

Definition at line 208 of file BitStream.h.

UINT32 * word = stream + (pos >> WordWidthLog)

Definition at line 209 of file BitStream.h.