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