comparison 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
comparison
equal deleted inserted replaced
399:3618b5cf25a6 400:ffd48f0a2ab5
1 /*
2 * A cleaner reimplementation of AMR Prm2bits() function.
3 */
4
5 #include "typedef.h"
6 #include "namespace.h"
7 #include "bitno.h"
8 #include "prm2bits.h"
9
10 void Prm2bits(enum Mode mode, const Word16 prm[], Word16 bits[])
11 {
12 const Word16 *t = bitno[mode];
13 unsigned nparam = prmno[mode];
14 unsigned n, p, mask;
15 Word16 *b = bits;
16
17 for (n = 0; n < nparam; n++) {
18 p = prm[n];
19 mask = 1 << (*t++ - 1);
20 for (; mask; mask >>= 1) {
21 if (p & mask)
22 *b++ = 1;
23 else
24 *b++ = 0;
25 }
26 }
27 }