FreeCalypso > hg > gsm-codec-lib
diff miscutil/bitmanip.c @ 107:41f1ae68d253
amr2efr & efr2amr cosmetic: cleaner approach to bit reshuffling
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sun, 27 Nov 2022 21:02:07 +0000 |
parents | d86f866489e9 |
children |
line wrap: on
line diff
--- a/miscutil/bitmanip.c Sun Nov 27 06:25:06 2022 +0000 +++ b/miscutil/bitmanip.c Sun Nov 27 21:02:07 2022 +0000 @@ -20,5 +20,8 @@ int pos_byte = bn >> 3; int pos_bit = 7 - (bn & 7); - buf[pos_byte] |= (bit << pos_bit); + if (bit) + buf[pos_byte] |= (1 << pos_bit); + else + buf[pos_byte] &= ~(1 << pos_bit); }