comparison libtwamr/bits2prm.c @ 254:f931e704adc5

libtwamr: bits and parameter packing
author Mychaela Falconia <falcon@freecalypso.org>
date Fri, 05 Apr 2024 07:41:31 +0000
parents
children
comparison
equal deleted inserted replaced
253:54f6bc41ed10 254:f931e704adc5
1 /*
2 * A cleaner reimplementation of AMR Bits2prm() function.
3 */
4
5 #include "typedef.h"
6 #include "namespace.h"
7 #include "bitno.h"
8 #include "bits2prm.h"
9
10 void Bits2prm(enum Mode mode, const Word16 bits[], Word16 prm[])
11 {
12 const Word16 *p = bits;
13 const Word16 *t = bitno[mode];
14 unsigned nparam = prmno[mode];
15 unsigned n, m, acc;
16
17 for (n = 0; n < nparam; n++) {
18 acc = 0;
19 for (m = 0; m < *t; m++) {
20 acc <<= 1;
21 if (*p)
22 acc |= 1;
23 p++;
24 }
25 prm[n] = acc;
26 t++;
27 }
28 }