36 #ifndef SWITCH_BITPACK_H
37 #define SWITCH_BITPACK_H
41 static char bb[80] =
"";
47 for (i = 7; i >= 0; i--) {
48 x[j++] = (byte & (1 << i)) ?
'1' :
'0';
83 memset(pack, 0,
sizeof(*pack));
88 pack->cur = pack->buf;
103 this_byte &= SWITCH_BITPACKED_MASKS[pack->
over];
104 this_byte <<= pack->
under;
110 this_byte &= SWITCH_REVERSE_BITPACKED_MASKS[mask];
178 mask = SWITCH_BITS_PER_BYTE - unpack->
under;
180 under_in = this_byte & SWITCH_REVERSE_BITPACKED_MASKS[mask];
182 *unpack->
cur |= under_in;
184 mask = unpack->
under;
185 under_in = this_byte & SWITCH_BITPACKED_MASKS[mask];
186 *unpack->
cur <<= mask;
187 *unpack->
cur |= under_in;
195 this_byte &= SWITCH_BITPACKED_MASKS[unpack->
frame_bits];
200 this_byte &= SWITCH_BITPACKED_MASKS[unpack->
frame_bits];
239 a = in & SWITCH_BITPACKED_MASKS[rem];
248 b = in & SWITCH_BITPACKED_MASKS[nxt];
#define SWITCH_END_EXTERN_C
static const uint8_t SWITCH_REVERSE_BITPACKED_MASKS[]
switch_bitpack_mode_t mode
static const uint8_t SWITCH_BITPACKED_MASKS[]
#define SWITCH_BITS_PER_BYTE
switch_byte_t switch_byte_t * buf
DoxyDefine(void switch_bitpack_init(switch_bitpack_t *pack, int32_t bitlen, switch_byte_t *buf, uint32_t buflen, switch_bitpack_mode_t mode)) static inline int8_t switch_bitpack_init(switch_bitpack_t *pack
Initialize a bitpack object.
switch_byte_t switch_byte_t uint32_t switch_bitpack_mode_t mode
static void pack_check_over(switch_bitpack_t *pack)
switch_byte_t switch_byte_t uint32_t buflen
#define SWITCH_BEGIN_EXTERN_C