annotate libtwamr/prm2bits.c @ 468:4104b0390fab

efrtest: new program gsmefr-dlcap-sync
author Mychaela Falconia <falcon@freecalypso.org>
date Mon, 13 May 2024 07:21:09 +0000
parents ffd48f0a2ab5
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
254
f931e704adc5 libtwamr: bits and parameter packing
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 /*
400
ffd48f0a2ab5 libtwamr: implement Prm2bits() like Bits2prm()
Mychaela Falconia <falcon@freecalypso.org>
parents: 254
diff changeset
2 * A cleaner reimplementation of AMR Prm2bits() function.
254
f931e704adc5 libtwamr: bits and parameter packing
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 */
f931e704adc5 libtwamr: bits and parameter packing
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4
f931e704adc5 libtwamr: bits and parameter packing
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5 #include "typedef.h"
f931e704adc5 libtwamr: bits and parameter packing
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6 #include "namespace.h"
f931e704adc5 libtwamr: bits and parameter packing
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 #include "bitno.h"
400
ffd48f0a2ab5 libtwamr: implement Prm2bits() like Bits2prm()
Mychaela Falconia <falcon@freecalypso.org>
parents: 254
diff changeset
8 #include "prm2bits.h"
254
f931e704adc5 libtwamr: bits and parameter packing
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9
400
ffd48f0a2ab5 libtwamr: implement Prm2bits() like Bits2prm()
Mychaela Falconia <falcon@freecalypso.org>
parents: 254
diff changeset
10 void Prm2bits(enum Mode mode, const Word16 prm[], Word16 bits[])
254
f931e704adc5 libtwamr: bits and parameter packing
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11 {
f931e704adc5 libtwamr: bits and parameter packing
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12 const Word16 *t = bitno[mode];
f931e704adc5 libtwamr: bits and parameter packing
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13 unsigned nparam = prmno[mode];
400
ffd48f0a2ab5 libtwamr: implement Prm2bits() like Bits2prm()
Mychaela Falconia <falcon@freecalypso.org>
parents: 254
diff changeset
14 unsigned n, p, mask;
ffd48f0a2ab5 libtwamr: implement Prm2bits() like Bits2prm()
Mychaela Falconia <falcon@freecalypso.org>
parents: 254
diff changeset
15 Word16 *b = bits;
254
f931e704adc5 libtwamr: bits and parameter packing
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16
f931e704adc5 libtwamr: bits and parameter packing
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17 for (n = 0; n < nparam; n++) {
400
ffd48f0a2ab5 libtwamr: implement Prm2bits() like Bits2prm()
Mychaela Falconia <falcon@freecalypso.org>
parents: 254
diff changeset
18 p = prm[n];
ffd48f0a2ab5 libtwamr: implement Prm2bits() like Bits2prm()
Mychaela Falconia <falcon@freecalypso.org>
parents: 254
diff changeset
19 mask = 1 << (*t++ - 1);
ffd48f0a2ab5 libtwamr: implement Prm2bits() like Bits2prm()
Mychaela Falconia <falcon@freecalypso.org>
parents: 254
diff changeset
20 for (; mask; mask >>= 1) {
ffd48f0a2ab5 libtwamr: implement Prm2bits() like Bits2prm()
Mychaela Falconia <falcon@freecalypso.org>
parents: 254
diff changeset
21 if (p & mask)
ffd48f0a2ab5 libtwamr: implement Prm2bits() like Bits2prm()
Mychaela Falconia <falcon@freecalypso.org>
parents: 254
diff changeset
22 *b++ = 1;
ffd48f0a2ab5 libtwamr: implement Prm2bits() like Bits2prm()
Mychaela Falconia <falcon@freecalypso.org>
parents: 254
diff changeset
23 else
ffd48f0a2ab5 libtwamr: implement Prm2bits() like Bits2prm()
Mychaela Falconia <falcon@freecalypso.org>
parents: 254
diff changeset
24 *b++ = 0;
254
f931e704adc5 libtwamr: bits and parameter packing
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25 }
f931e704adc5 libtwamr: bits and parameter packing
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
26 }
f931e704adc5 libtwamr: bits and parameter packing
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
27 }