FreeCalypso > hg > gsm-codec-lib
diff libtwamr/prm2bits.c @ 400:ffd48f0a2ab5
libtwamr: implement Prm2bits() like Bits2prm()
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Mon, 06 May 2024 19:34:59 +0000 |
parents | libtwamr/bits2prm.c@f931e704adc5 |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libtwamr/prm2bits.c Mon May 06 19:34:59 2024 +0000 @@ -0,0 +1,27 @@ +/* + * A cleaner reimplementation of AMR Prm2bits() function. + */ + +#include "typedef.h" +#include "namespace.h" +#include "bitno.h" +#include "prm2bits.h" + +void Prm2bits(enum Mode mode, const Word16 prm[], Word16 bits[]) +{ + const Word16 *t = bitno[mode]; + unsigned nparam = prmno[mode]; + unsigned n, p, mask; + Word16 *b = bits; + + for (n = 0; n < nparam; n++) { + p = prm[n]; + mask = 1 << (*t++ - 1); + for (; mask; mask >>= 1) { + if (p & mask) + *b++ = 1; + else + *b++ = 0; + } + } +}