comparison amrconv/bitmanip.c @ 184:b092a510141e

tree reorg: move gsm-amr2efr & gsm-efr2amr to amrconv subdir
author Mychaela Falconia <falcon@freecalypso.org>
date Tue, 03 Jan 2023 02:33:45 +0000
parents miscutil/bitmanip.c@41f1ae68d253
children
comparison
equal deleted inserted replaced
183:452c1d5a6268 184:b092a510141e
1 /*
2 * This module provides two utility functions that serve as building blocks
3 * for frame bit reordering operations.
4 */
5
6 #include <stdint.h>
7
8 msb_get_bit(buf, bn)
9 uint8_t *buf;
10 {
11 int pos_byte = bn >> 3;
12 int pos_bit = 7 - (bn & 7);
13
14 return (buf[pos_byte] >> pos_bit) & 1;
15 }
16
17 msb_set_bit(buf, bn, bit)
18 uint8_t *buf;
19 {
20 int pos_byte = bn >> 3;
21 int pos_bit = 7 - (bn & 7);
22
23 if (bit)
24 buf[pos_byte] |= (1 << pos_bit);
25 else
26 buf[pos_byte] &= ~(1 << pos_bit);
27 }