FreeRDP
rfx_bitstream.h File Reference
This graph shows which files directly or indirectly include this file:

Data Structures

struct  RFX_BITSTREAM
 

Macros

#define rfx_bitstream_attach(bs, _buffer, _nbytes)
 
#define rfx_bitstream_get_bits(bs, _nbits, _r)
 
#define rfx_bitstream_put_bits(bs, _bits, _nbits)
 
#define rfx_bitstream_flush(bs)
 
#define rfx_bitstream_eos(_bs)   ((_bs)->byte_pos >= (_bs)->nbytes)
 
#define rfx_bitstream_left(_bs)
 
#define rfx_bitstream_get_processed_bytes(_bs)    ((_bs)->bits_left < 8 ? (_bs)->byte_pos + 1 : (_bs)->byte_pos)
 

Macro Definition Documentation

◆ rfx_bitstream_attach

#define rfx_bitstream_attach (   bs,
  _buffer,
  _nbytes 
)
Value:
do \
{ \
bs->buffer = (BYTE*)(_buffer); \
bs->nbytes = (_nbytes); \
bs->byte_pos = 0; \
bs->bits_left = 8; \
} while (0)
unsigned char BYTE
Definition: LOMHash.c:3

◆ rfx_bitstream_eos

#define rfx_bitstream_eos (   _bs)    ((_bs)->byte_pos >= (_bs)->nbytes)

◆ rfx_bitstream_flush

#define rfx_bitstream_flush (   bs)
Value:
do \
{ \
if (bs->bits_left != 8) \
{ \
int _nbits = 8 - bs->bits_left; \
rfx_bitstream_put_bits(bs, 0, _nbits); \
} \
} while (0)

◆ rfx_bitstream_get_bits

#define rfx_bitstream_get_bits (   bs,
  _nbits,
  _r 
)
Value:
do \
{ \
int nbits = _nbits; \
int b; \
UINT16 n = 0; \
while (bs->byte_pos < bs->nbytes && nbits > 0) \
{ \
b = nbits; \
if (b > bs->bits_left) \
b = bs->bits_left; \
if (n) \
n <<= b; \
n |= (bs->buffer[bs->byte_pos] >> (bs->bits_left - b)) & ((1 << b) - 1); \
bs->bits_left -= b; \
nbits -= b; \
if (bs->bits_left == 0) \
{ \
bs->bits_left = 8; \
bs->byte_pos++; \
} \
} \
_r = n; \
} while (0)

◆ rfx_bitstream_get_processed_bytes

#define rfx_bitstream_get_processed_bytes (   _bs)     ((_bs)->bits_left < 8 ? (_bs)->byte_pos + 1 : (_bs)->byte_pos)

◆ rfx_bitstream_left

#define rfx_bitstream_left (   _bs)
Value:
((_bs)->byte_pos >= (_bs)->nbytes \
? 0 \
: ((_bs)->nbytes - (_bs)->byte_pos - 1) * 8 + (_bs)->bits_left)

◆ rfx_bitstream_put_bits

#define rfx_bitstream_put_bits (   bs,
  _bits,
  _nbits 
)
Value:
do \
{ \
UINT16 bits = (_bits); \
int nbits = (_nbits); \
int b; \
while (bs->byte_pos < bs->nbytes && nbits > 0) \
{ \
b = nbits; \
if (b > bs->bits_left) \
b = bs->bits_left; \
bs->buffer[bs->byte_pos] |= ((bits >> (nbits - b)) & ((1 << b) - 1)) \
<< (bs->bits_left - b); \
bs->bits_left -= b; \
nbits -= b; \
if (bs->bits_left == 0) \
{ \
bs->bits_left = 8; \
bs->byte_pos++; \
} \
} \
} while (0)