38 unsigned int pbit_bytesize = num_bits / 8;
51 unsigned int num_nibbles);
53 unsigned int num_nibbles);
59 const ubit_t *in,
unsigned int in_ofs,
60 unsigned int num_bits,
int lsb_mode);
63 const pbit_t *in,
unsigned int in_ofs,
64 unsigned int num_bits,
int lsb_mode);
66#define OSMO_BIN_SPEC "%d%d%d%d%d%d%d%d"
67#define OSMO_BIN_PRINT(byte) \
68 (byte & 0x80 ? 1 : 0), \
69 (byte & 0x40 ? 1 : 0), \
70 (byte & 0x20 ? 1 : 0), \
71 (byte & 0x10 ? 1 : 0), \
72 (byte & 0x08 ? 1 : 0), \
73 (byte & 0x04 ? 1 : 0), \
74 (byte & 0x02 ? 1 : 0), \
77#define OSMO_BIT_SPEC "%c%c%c%c%c%c%c%c"
78#define OSMO_BIT_PRINT_EX(byte, ch) \
79 (byte & 0x80 ? ch : '.'), \
80 (byte & 0x40 ? ch : '.'), \
81 (byte & 0x20 ? ch : '.'), \
82 (byte & 0x10 ? ch : '.'), \
83 (byte & 0x08 ? ch : '.'), \
84 (byte & 0x04 ? ch : '.'), \
85 (byte & 0x02 ? ch : '.'), \
86 (byte & 0x01 ? ch : '.')
88#define OSMO_BIT_PRINT(byte) OSMO_BIT_PRINT_EX(byte, '1')
117static inline uint16_t
osmo_rol16(uint16_t in,
unsigned shift)
119 return (in << shift) | (in >> (16 - shift));
int osmo_ubit2pbit(pbit_t *out, const ubit_t *in, unsigned int num_bits)
convert unpacked bits to packed bits, return length in bytes
Definition: bits.c:41
uint8_t pbit_t
packed bits (8 bits in a byte).
Definition: bits.h:30
static unsigned int osmo_pbit_bytesize(unsigned int num_bits)
determine how many bytes we would need for num_bits packed bits
Definition: bits.h:36
osmo_br_mode
bit-reversal mode for osmo_bit_reversal()
Definition: bits.h:93
void osmo_sbit2ubit(ubit_t *out, const sbit_t *in, unsigned int num_bits)
convert soft bits to unpacked bits
Definition: bits.c:129
int osmo_ubit2pbit_ext(pbit_t *out, unsigned int out_ofs, const ubit_t *in, unsigned int in_ofs, unsigned int num_bits, int lsb_mode)
convert unpacked bits to packed bits (extended options)
Definition: bits.c:187
int osmo_pbit2ubit(ubit_t *out, const pbit_t *in, unsigned int num_bits)
convert packed bits to unpacked bits, return length in bytes
Definition: bits.c:142
uint8_t ubit_t
unpacked bit (0 or 1): 1 bit per byte
Definition: bits.h:24
void osmo_nibble_shift_left_unal(uint8_t *out, const uint8_t *in, unsigned int num_nibbles)
Shift unaligned input to octet-aligned output.
Definition: bits.c:96
int osmo_pbit2ubit_ext(ubit_t *out, unsigned int out_ofs, const pbit_t *in, unsigned int in_ofs, unsigned int num_bits, int lsb_mode)
convert packed bits to unpacked bits (extended options)
Definition: bits.c:212
uint32_t osmo_revbytebits_32(uint32_t x)
reverse the bit-order in each byte of a dword
Definition: bits.c:281
void osmo_ubit2sbit(sbit_t *out, const ubit_t *in, unsigned int num_bits)
convert unpacked bits to soft bits
Definition: bits.c:117
void osmo_revbytebits_buf(uint8_t *buf, int len)
reverse bit-order of each byte in a buffer
Definition: bits.c:305
int8_t sbit_t
soft bit with value (-127...127), as commonly used in communications receivers such as [viterbi] deco...
Definition: bits.h:21
static uint16_t osmo_rol16(uint16_t in, unsigned shift)
left circular shift
Definition: bits.h:117
void osmo_nibble_shift_right(uint8_t *out, const uint8_t *in, unsigned int num_nibbles)
Shift unaligned input to octet-aligned output.
Definition: bits.c:69
uint32_t osmo_bit_reversal(uint32_t x, enum osmo_br_mode k)
generalized bit reversal function
Definition: bits.c:264
uint32_t osmo_revbytebits_8(uint8_t x)
reverse the bit order in a byte
Definition: bits.c:294
@ OSMO_BR_BITS_IN_DWORD
reverse all bits in a 32bit dword
Definition: bits.h:95
@ OSMO_BR_BYTES_IN_DWORD
reverse byte order in a 32bit dword
Definition: bits.h:97
@ OSMO_BR_BITS_IN_BYTE
reverse bits of each byte in a 32bit dword
Definition: bits.h:99
@ OSMO_BR_WORD_SWAP
swap the two 16bit words in a 32bit dword
Definition: bits.h:101
static size_t len(const char *str)
uint32_t x
Definition: jhash.h:0