FreeCalypso > hg > gsm-codec-lib
annotate libtwamr/d2_11pf.c @ 458:e26b974f7ba3
doc/AMR-study-utils: update for the current situation
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Fri, 10 May 2024 18:45:36 +0000 |
parents | c75327562b5e |
children |
rev | line source |
---|---|
331
c75327562b5e
libtwamr: integrate d2_11pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 /* |
c75327562b5e
libtwamr: integrate d2_11pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2 ******************************************************************************** |
c75327562b5e
libtwamr: integrate d2_11pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
3 * |
c75327562b5e
libtwamr: integrate d2_11pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
4 * GSM AMR-NB speech codec R98 Version 7.6.0 December 12, 2001 |
c75327562b5e
libtwamr: integrate d2_11pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
5 * R99 Version 3.3.0 |
c75327562b5e
libtwamr: integrate d2_11pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
6 * REL-4 Version 4.1.0 |
c75327562b5e
libtwamr: integrate d2_11pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
7 * |
c75327562b5e
libtwamr: integrate d2_11pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
8 ******************************************************************************** |
c75327562b5e
libtwamr: integrate d2_11pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
9 * |
c75327562b5e
libtwamr: integrate d2_11pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
10 * File : d2_11pf.c |
c75327562b5e
libtwamr: integrate d2_11pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
11 * Purpose : Algebraic codebook decoder |
c75327562b5e
libtwamr: integrate d2_11pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
12 * |
c75327562b5e
libtwamr: integrate d2_11pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
13 ******************************************************************************** |
c75327562b5e
libtwamr: integrate d2_11pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
14 */ |
c75327562b5e
libtwamr: integrate d2_11pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
15 |
c75327562b5e
libtwamr: integrate d2_11pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
16 /* |
c75327562b5e
libtwamr: integrate d2_11pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
17 ******************************************************************************** |
c75327562b5e
libtwamr: integrate d2_11pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
18 * MODULE INCLUDE FILE AND VERSION ID |
c75327562b5e
libtwamr: integrate d2_11pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
19 ******************************************************************************** |
c75327562b5e
libtwamr: integrate d2_11pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
20 */ |
c75327562b5e
libtwamr: integrate d2_11pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
21 #include "namespace.h" |
c75327562b5e
libtwamr: integrate d2_11pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
22 #include "d2_11pf.h" |
c75327562b5e
libtwamr: integrate d2_11pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
23 |
c75327562b5e
libtwamr: integrate d2_11pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
24 /* |
c75327562b5e
libtwamr: integrate d2_11pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
25 ******************************************************************************** |
c75327562b5e
libtwamr: integrate d2_11pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
26 * INCLUDE FILES |
c75327562b5e
libtwamr: integrate d2_11pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
27 ******************************************************************************** |
c75327562b5e
libtwamr: integrate d2_11pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
28 */ |
c75327562b5e
libtwamr: integrate d2_11pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
29 #include "typedef.h" |
c75327562b5e
libtwamr: integrate d2_11pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
30 #include "basic_op.h" |
c75327562b5e
libtwamr: integrate d2_11pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
31 #include "no_count.h" |
c75327562b5e
libtwamr: integrate d2_11pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
32 #include "cnst.h" |
c75327562b5e
libtwamr: integrate d2_11pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
33 |
c75327562b5e
libtwamr: integrate d2_11pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
34 /* |
c75327562b5e
libtwamr: integrate d2_11pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
35 ******************************************************************************** |
c75327562b5e
libtwamr: integrate d2_11pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
36 * LOCAL VARIABLES AND TABLES |
c75327562b5e
libtwamr: integrate d2_11pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
37 ******************************************************************************** |
c75327562b5e
libtwamr: integrate d2_11pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
38 */ |
c75327562b5e
libtwamr: integrate d2_11pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
39 #define NB_PULSE 2 /* number of pulses */ |
c75327562b5e
libtwamr: integrate d2_11pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
40 |
c75327562b5e
libtwamr: integrate d2_11pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
41 /* |
c75327562b5e
libtwamr: integrate d2_11pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
42 ******************************************************************************** |
c75327562b5e
libtwamr: integrate d2_11pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
43 * PUBLIC PROGRAM CODE |
c75327562b5e
libtwamr: integrate d2_11pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
44 ******************************************************************************** |
c75327562b5e
libtwamr: integrate d2_11pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
45 */ |
c75327562b5e
libtwamr: integrate d2_11pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
46 /************************************************************************* |
c75327562b5e
libtwamr: integrate d2_11pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
47 * |
c75327562b5e
libtwamr: integrate d2_11pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
48 * FUNCTION: decode_2i40_11bits (decod_ACELP()) |
c75327562b5e
libtwamr: integrate d2_11pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
49 * |
c75327562b5e
libtwamr: integrate d2_11pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
50 * PURPOSE: Algebraic codebook decoder |
c75327562b5e
libtwamr: integrate d2_11pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
51 * |
c75327562b5e
libtwamr: integrate d2_11pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
52 *************************************************************************/ |
c75327562b5e
libtwamr: integrate d2_11pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
53 |
c75327562b5e
libtwamr: integrate d2_11pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
54 void decode_2i40_11bits( |
c75327562b5e
libtwamr: integrate d2_11pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
55 Word16 sign, /* i : signs of 2 pulses. */ |
c75327562b5e
libtwamr: integrate d2_11pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
56 Word16 index, /* i : Positions of the 2 pulses. */ |
c75327562b5e
libtwamr: integrate d2_11pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
57 Word16 cod[] /* o : algebraic (fixed) codebook excitation */ |
c75327562b5e
libtwamr: integrate d2_11pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
58 ) |
c75327562b5e
libtwamr: integrate d2_11pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
59 { |
c75327562b5e
libtwamr: integrate d2_11pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
60 Word16 i, j; |
c75327562b5e
libtwamr: integrate d2_11pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
61 Word16 pos[NB_PULSE]; |
c75327562b5e
libtwamr: integrate d2_11pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
62 |
c75327562b5e
libtwamr: integrate d2_11pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
63 /* Decode the positions */ |
c75327562b5e
libtwamr: integrate d2_11pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
64 |
c75327562b5e
libtwamr: integrate d2_11pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
65 j = index & 1; logic16 (); |
c75327562b5e
libtwamr: integrate d2_11pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
66 index = shr(index, 1); |
c75327562b5e
libtwamr: integrate d2_11pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
67 i = index & 7; logic16 (); |
c75327562b5e
libtwamr: integrate d2_11pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
68 |
c75327562b5e
libtwamr: integrate d2_11pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
69 i = add(i, shl(i, 2)); /* pos0 =i*5+1+j*2 */ |
c75327562b5e
libtwamr: integrate d2_11pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
70 i = add(i, 1); |
c75327562b5e
libtwamr: integrate d2_11pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
71 j = shl(j, 1); |
c75327562b5e
libtwamr: integrate d2_11pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
72 pos[0] = add(i, j); move16 (); |
c75327562b5e
libtwamr: integrate d2_11pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
73 |
c75327562b5e
libtwamr: integrate d2_11pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
74 index = shr(index, 3); |
c75327562b5e
libtwamr: integrate d2_11pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
75 j = index & 3; logic16 (); |
c75327562b5e
libtwamr: integrate d2_11pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
76 index = shr(index, 2); |
c75327562b5e
libtwamr: integrate d2_11pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
77 i = index & 7; logic16 (); |
c75327562b5e
libtwamr: integrate d2_11pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
78 |
c75327562b5e
libtwamr: integrate d2_11pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
79 test(); |
c75327562b5e
libtwamr: integrate d2_11pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
80 if (sub(j, 3) == 0) |
c75327562b5e
libtwamr: integrate d2_11pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
81 { |
c75327562b5e
libtwamr: integrate d2_11pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
82 i = add(i, shl(i, 2)); /* pos1 =i*5+4 */ |
c75327562b5e
libtwamr: integrate d2_11pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
83 pos[1] = add(i, 4); move16 (); |
c75327562b5e
libtwamr: integrate d2_11pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
84 } |
c75327562b5e
libtwamr: integrate d2_11pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
85 else |
c75327562b5e
libtwamr: integrate d2_11pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
86 { |
c75327562b5e
libtwamr: integrate d2_11pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
87 i = add(i, shl(i, 2)); /* pos1 =i*5+j */ |
c75327562b5e
libtwamr: integrate d2_11pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
88 pos[1] = add(i, j); move16 (); |
c75327562b5e
libtwamr: integrate d2_11pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
89 } |
c75327562b5e
libtwamr: integrate d2_11pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
90 |
c75327562b5e
libtwamr: integrate d2_11pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
91 /* decode the signs and build the codeword */ |
c75327562b5e
libtwamr: integrate d2_11pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
92 |
c75327562b5e
libtwamr: integrate d2_11pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
93 for (i = 0; i < L_SUBFR; i++) { |
c75327562b5e
libtwamr: integrate d2_11pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
94 cod[i] = 0; move16 (); |
c75327562b5e
libtwamr: integrate d2_11pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
95 } |
c75327562b5e
libtwamr: integrate d2_11pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
96 |
c75327562b5e
libtwamr: integrate d2_11pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
97 for (j = 0; j < NB_PULSE; j++) { |
c75327562b5e
libtwamr: integrate d2_11pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
98 i = sign & 1; logic16 (); |
c75327562b5e
libtwamr: integrate d2_11pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
99 sign = shr(sign, 1); |
c75327562b5e
libtwamr: integrate d2_11pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
100 |
c75327562b5e
libtwamr: integrate d2_11pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
101 test (); |
c75327562b5e
libtwamr: integrate d2_11pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
102 if (i != 0) { |
c75327562b5e
libtwamr: integrate d2_11pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
103 cod[pos[j]] = 8191; move16 (); /* +1.0 */ |
c75327562b5e
libtwamr: integrate d2_11pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
104 } else { |
c75327562b5e
libtwamr: integrate d2_11pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
105 cod[pos[j]] = -8192; move16 (); /* -1.0 */ |
c75327562b5e
libtwamr: integrate d2_11pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
106 } |
c75327562b5e
libtwamr: integrate d2_11pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
107 } |
c75327562b5e
libtwamr: integrate d2_11pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
108 |
c75327562b5e
libtwamr: integrate d2_11pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
109 return; |
c75327562b5e
libtwamr: integrate d2_11pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
110 } |