comparison libgsmefr/d1035pf.c @ 53:49dd1ac8e75b

libgsmefr: import most *.c files from ETSI source
author Mychaela Falconia <falcon@freecalypso.org>
date Fri, 25 Nov 2022 16:18:21 +0000
parents
children d273a77d5523
comparison
equal deleted inserted replaced
52:988fd7ff514f 53:49dd1ac8e75b
1 /*************************************************************************
2 *
3 * FUNCTION: dec_10i40_35bits()
4 *
5 * PURPOSE: Builds the innovative codevector from the received
6 * index of algebraic codebook.
7 *
8 * See c1035pf.c for more details about the algebraic codebook structure.
9 *
10 *************************************************************************/
11
12 #include "typedef.h"
13 #include "basic_op.h"
14 #include "count.h"
15
16 #define L_CODE 40 /* codevector length */
17 #define NB_PULSE 10 /* number of pulses */
18 #define NB_TRACK 5 /* number of track */
19
20 void dec_10i40_35bits (
21 Word16 index[], /* (i) : index of 10 pulses (sign+position) */
22 Word16 cod[] /* (o) : algebraic (fixed) codebook excitation */
23 )
24 {
25 static const Word16 dgray[8] = {0, 1, 3, 2, 5, 6, 4, 7};
26 Word16 i, j, pos1, pos2, sign, tmp;
27
28 for (i = 0; i < L_CODE; i++)
29 {
30 cod[i] = 0; move16 ();
31 }
32
33 /* decode the positions and signs of pulses and build the codeword */
34
35 for (j = 0; j < NB_TRACK; j++)
36 {
37 /* compute index i */
38
39 tmp = index[j]; move16 ();
40 i = tmp & 7; logic16 ();
41 i = dgray[i]; move16 ();
42
43 i = extract_l (L_shr (L_mult (i, 5), 1));
44 pos1 = add (i, j); /* position of pulse "j" */
45
46 i = shr (tmp, 3) & 1; logic16 ();
47 test ();
48 if (i == 0)
49 {
50 sign = 4096; move16 (); /* +1.0 */
51 }
52 else
53 {
54 sign = -4096; move16 (); /* -1.0 */
55 }
56
57 cod[pos1] = sign; move16 ();
58
59 /* compute index i */
60
61 i = index[add (j, 5)] & 7; logic16 ();
62 i = dgray[i]; move16 ();
63 i = extract_l (L_shr (L_mult (i, 5), 1));
64
65 pos2 = add (i, j); /* position of pulse "j+5" */
66
67 test ();
68 if (sub (pos2, pos1) < 0)
69 {
70 sign = negate (sign);
71 }
72 cod[pos2] = add (cod[pos2], sign); move16 ();
73 }
74
75 return;
76 }