3131#include " wwdebug.h"
3232
3333// -----------------------------------------------------------------------------
34- // cBitPacker::cBitPacker(UINT buffer_size) :
34+ // cBitPacker::cBitPacker(uint32_t buffer_size) :
3535cBitPacker::cBitPacker () :
3636 // BufferSize(buffer_size),
3737 BitWritePosition(0 ),
3838 BitReadPosition(0 )
3939{
4040 // WWASSERT(BufferSize > 0);
4141
42- // Buffer = new BYTE [BufferSize];
42+ // Buffer = new uint8_t [BufferSize];
4343 // WWASSERT(Buffer != NULL);
4444 // memset(Buffer, 0, BufferSize);
4545 memset (Buffer, 0 , MAX_BUFFER_SIZE);
@@ -73,7 +73,7 @@ cBitPacker& cBitPacker::operator=(const cBitPacker& rhs)
7373// If you use optimized Add_Bits() you need to also use optimize Get_Bits().
7474//
7575
76- void cBitPacker::Add_Bits (ULONG value, UINT num_bits)
76+ void cBitPacker::Add_Bits (uint32_t value, uint32_t num_bits)
7777{
7878 //
7979 // N.B. Presently you cannot use this class with an atomic type of more
@@ -83,14 +83,14 @@ void cBitPacker::Add_Bits(ULONG value, UINT num_bits)
8383#if 0 // Old version
8484 WWASSERT(num_bits > 0 && num_bits <= MAX_BITS);
8585
86- ULONG mask = 1 << (num_bits - 1);
86+ uint32_t mask = 1 << (num_bits - 1);
8787 while (mask > 0) {
8888
8989 //WWASSERT(BitWritePosition < BufferSize * 8);
9090 WWASSERT(BitWritePosition < MAX_BUFFER_SIZE * 8);
9191
92- UINT byte_num = BitWritePosition / 8;
93- UINT bit_offset = BitWritePosition % 8;
92+ uint32_t byte_num = BitWritePosition / 8;
93+ uint32_t bit_offset = BitWritePosition % 8;
9494 bool bit_value = (value & mask) != 0;
9595 Buffer[byte_num] |= bit_value << bit_offset;
9696
@@ -106,17 +106,17 @@ void cBitPacker::Add_Bits(ULONG value, UINT num_bits)
106106 WWASSERT (BitWritePosition+num_bits <= MAX_BUFFER_SIZE * 8 );
107107
108108 // Fill the remaining bits of the write byte first
109- UINT byte_num = BitWritePosition >> 3 ;
110- UINT bit_offset = BitWritePosition & 0x7 ;
109+ uint32_t byte_num = BitWritePosition >> 3 ;
110+ uint32_t bit_offset = BitWritePosition & 0x7 ;
111111 BitWritePosition+=num_bits; // Advance the write position
112112
113113 // If write buffer is not byte aligned, write the remaining bits first
114114 value <<= 32 -num_bits;
115115 if (bit_offset) {
116- UINT bit_count = 8 - bit_offset;
116+ uint32_t bit_count = 8 - bit_offset;
117117 if (bit_count>num_bits) bit_count=num_bits;
118118
119- ULONG bit_value = value;
119+ uint32_t bit_value = value;
120120 value <<= bit_count; // Remove the copied bits
121121 num_bits -= bit_count;
122122 bit_value >>= (24 +bit_offset);
@@ -141,7 +141,7 @@ void cBitPacker::Add_Bits(ULONG value, UINT num_bits)
141141// This method needs optimization
142142// 02-14-2002 Jani: Optimized. See Add_Bits() for notes.
143143//
144- void cBitPacker::Get_Bits (ULONG & value, UINT num_bits)
144+ void cBitPacker::Get_Bits (uint32_t & value, uint32_t num_bits)
145145{
146146#if 0 // Old version
147147 WWASSERT(num_bits > 0 && num_bits <= MAX_BITS);
@@ -152,8 +152,8 @@ void cBitPacker::Get_Bits(ULONG & value, UINT num_bits)
152152 //WWASSERT(BitReadPosition < BufferSize * 8);
153153 WWASSERT(BitReadPosition < MAX_BUFFER_SIZE * 8);
154154 WWASSERT(BitReadPosition < BitWritePosition);
155- UINT byte_num = BitReadPosition / 8;
156- UINT bit_offset = BitReadPosition % 8;
155+ uint32_t byte_num = BitReadPosition / 8;
156+ uint32_t bit_offset = BitReadPosition % 8;
157157 bool b = (Buffer[byte_num] & (1 << bit_offset)) != 0;
158158
159159 value += (b << bit);
@@ -167,14 +167,14 @@ void cBitPacker::Get_Bits(ULONG & value, UINT num_bits)
167167 WWASSERT (BitReadPosition+num_bits <= MAX_BUFFER_SIZE * 8 );
168168 WWASSERT (BitReadPosition+num_bits <= BitWritePosition);
169169
170- UINT read_len=num_bits;
171- UINT byte_num = BitReadPosition / 8 ;
172- UINT bit_offset = BitReadPosition % 8 ;
170+ uint32_t read_len=num_bits;
171+ uint32_t byte_num = BitReadPosition / 8 ;
172+ uint32_t bit_offset = BitReadPosition % 8 ;
173173 BitReadPosition += num_bits;
174174
175- UINT bit_count = 8 - bit_offset;
175+ uint32_t bit_count = 8 - bit_offset;
176176 if (bit_count>num_bits) bit_count=num_bits;
177- value = (ULONG (Buffer[byte_num++]) << (bit_offset+24 ));
177+ value = (uint32_t (Buffer[byte_num++]) << (bit_offset+24 ));
178178 num_bits-=bit_count;
179179
180180 int shift;
@@ -190,7 +190,7 @@ void cBitPacker::Get_Bits(ULONG & value, UINT num_bits)
190190// This method is only for use by a packet class when data is received.
191191//
192192
193- void cBitPacker::Set_Bit_Write_Position (UINT position)
193+ void cBitPacker::Set_Bit_Write_Position (uint32_t position)
194194{
195195 // WWASSERT(position <= BufferSize * 8);
196196 WWASSERT (position <= MAX_BUFFER_SIZE * 8 );
@@ -219,7 +219,7 @@ void cBitPacker::Increment_Bit_Position(int num_bits)
219219}
220220
221221//-----------------------------------------------------------------------------
222- UINT cBitPacker::Get_Compressed_Size_Bytes() const
222+ uint32_t cBitPacker::Get_Compressed_Size_Bytes() const
223223{
224224 return (int) ceil(BitWritePosition / 8.0f);
225225}
0 commit comments