FreeCalypso > hg > gsm-codec-lib
annotate libgsmfr2/short_term.c @ 506:2d6da062c452
libgsmhr1/sp_rom.[ch]: import original
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Wed, 19 Jun 2024 01:55:54 +0000 |
parents | d320a8fa3392 |
children |
rev | line source |
---|---|
271
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 /* |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2 * This C source file has been adapted from TU-Berlin libgsm source, |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
3 * original notice follows: |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
4 * |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
5 * Copyright 1992 by Jutta Degener and Carsten Bormann, Technische |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
6 * Universitaet Berlin. See the accompanying file "COPYRIGHT" for |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
7 * details. THERE IS ABSOLUTELY NO WARRANTY FOR THIS SOFTWARE. |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
8 */ |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
9 |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
10 #include <stdint.h> |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
11 #include "tw_gsmfr.h" |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
12 #include "typedef.h" |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
13 #include "ed_state.h" |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
14 #include "ed_internal.h" |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
15 |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
16 /* |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
17 * SHORT TERM ANALYSIS FILTERING SECTION |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
18 */ |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
19 |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
20 /* 4.2.8 */ |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
21 |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
22 static void Decoding_of_the_coded_Log_Area_Ratios ( |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
23 const word * LARc, /* coded log area ratio [0..7] IN */ |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
24 word * LARpp) /* out: decoded .. */ |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
25 { |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
26 register word temp1 /* , temp2 */; |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
27 register long ltmp; /* for GSM_ADD */ |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
28 |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
29 /* This procedure requires for efficient implementation |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
30 * two tables. |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
31 * |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
32 * INVA[1..8] = integer( (32768 * 8) / real_A[1..8]) |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
33 * MIC[1..8] = minimum value of the LARc[1..8] |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
34 */ |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
35 |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
36 /* Compute the LARpp[1..8] |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
37 */ |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
38 |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
39 /* for (i = 1; i <= 8; i++, B++, MIC++, INVA++, LARc++, LARpp++) { |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
40 * |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
41 * temp1 = GSM_ADD( *LARc, *MIC ) << 10; |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
42 * temp2 = *B << 1; |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
43 * temp1 = GSM_SUB( temp1, temp2 ); |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
44 * |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
45 * assert(*INVA != MIN_WORD); |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
46 * |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
47 * temp1 = GSM_MULT_R( *INVA, temp1 ); |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
48 * *LARpp = GSM_ADD( temp1, temp1 ); |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
49 * } |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
50 */ |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
51 |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
52 #undef STEP |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
53 #define STEP( B_TIMES_TWO, MIC, INVA ) \ |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
54 temp1 = GSM_ADD( *LARc++, MIC ) << 10; \ |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
55 temp1 = GSM_SUB( temp1, B_TIMES_TWO ); \ |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
56 temp1 = GSM_MULT_R( INVA, temp1 ); \ |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
57 *LARpp++ = GSM_ADD( temp1, temp1 ); |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
58 |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
59 STEP( 0, -32, 13107 ); |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
60 STEP( 0, -32, 13107 ); |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
61 STEP( 4096, -16, 13107 ); |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
62 STEP( -5120, -16, 13107 ); |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
63 |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
64 STEP( 188, -8, 19223 ); |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
65 STEP( -3584, -8, 17476 ); |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
66 STEP( -682, -4, 31454 ); |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
67 STEP( -2288, -4, 29708 ); |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
68 |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
69 /* NOTE: the addition of *MIC is used to restore |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
70 * the sign of *LARc. |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
71 */ |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
72 } |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
73 |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
74 /* 4.2.9 */ |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
75 /* Computation of the quantized reflection coefficients |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
76 */ |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
77 |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
78 /* 4.2.9.1 Interpolation of the LARpp[1..8] to get the LARp[1..8] |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
79 */ |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
80 |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
81 /* |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
82 * Within each frame of 160 analyzed speech samples the short term |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
83 * analysis and synthesis filters operate with four different sets of |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
84 * coefficients, derived from the previous set of decoded LARs(LARpp(j-1)) |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
85 * and the actual set of decoded LARs (LARpp(j)) |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
86 * |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
87 * (Initial value: LARpp(j-1)[1..8] = 0.) |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
88 */ |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
89 |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
90 static void Coefficients_0_12 ( |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
91 register word * LARpp_j_1, |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
92 register word * LARpp_j, |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
93 register word * LARp) |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
94 { |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
95 register int i; |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
96 register longword ltmp; |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
97 |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
98 for (i = 1; i <= 8; i++, LARp++, LARpp_j_1++, LARpp_j++) { |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
99 *LARp = GSM_ADD( SASR( *LARpp_j_1, 2 ), SASR( *LARpp_j, 2 )); |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
100 *LARp = GSM_ADD( *LARp, SASR( *LARpp_j_1, 1)); |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
101 } |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
102 } |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
103 |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
104 static void Coefficients_13_26 ( |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
105 register word * LARpp_j_1, |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
106 register word * LARpp_j, |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
107 register word * LARp) |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
108 { |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
109 register int i; |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
110 register longword ltmp; |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
111 for (i = 1; i <= 8; i++, LARpp_j_1++, LARpp_j++, LARp++) { |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
112 *LARp = GSM_ADD( SASR( *LARpp_j_1, 1), SASR( *LARpp_j, 1 )); |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
113 } |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
114 } |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
115 |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
116 static void Coefficients_27_39 ( |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
117 register word * LARpp_j_1, |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
118 register word * LARpp_j, |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
119 register word * LARp) |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
120 { |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
121 register int i; |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
122 register longword ltmp; |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
123 |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
124 for (i = 1; i <= 8; i++, LARpp_j_1++, LARpp_j++, LARp++) { |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
125 *LARp = GSM_ADD( SASR( *LARpp_j_1, 2 ), SASR( *LARpp_j, 2 )); |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
126 *LARp = GSM_ADD( *LARp, SASR( *LARpp_j, 1 )); |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
127 } |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
128 } |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
129 |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
130 static void Coefficients_40_159 ( |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
131 register word * LARpp_j, |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
132 register word * LARp) |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
133 { |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
134 register int i; |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
135 |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
136 for (i = 1; i <= 8; i++, LARp++, LARpp_j++) |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
137 *LARp = *LARpp_j; |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
138 } |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
139 |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
140 /* 4.2.9.2 */ |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
141 |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
142 static void LARp_to_rp ( |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
143 register word * LARp) /* [0..7] IN/OUT */ |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
144 /* |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
145 * The input of this procedure is the interpolated LARp[0..7] array. |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
146 * The reflection coefficients, rp[i], are used in the analysis |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
147 * filter and in the synthesis filter. |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
148 */ |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
149 { |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
150 register int i; |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
151 register word temp; |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
152 register longword ltmp; |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
153 |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
154 for (i = 1; i <= 8; i++, LARp++) { |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
155 |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
156 /* temp = GSM_ABS( *LARp ); |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
157 * |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
158 * if (temp < 11059) temp <<= 1; |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
159 * else if (temp < 20070) temp += 11059; |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
160 * else temp = GSM_ADD( temp >> 2, 26112 ); |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
161 * |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
162 * *LARp = *LARp < 0 ? -temp : temp; |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
163 */ |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
164 |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
165 if (*LARp < 0) { |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
166 temp = *LARp == MIN_WORD ? MAX_WORD : -(*LARp); |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
167 *LARp = - ((temp < 11059) ? temp << 1 |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
168 : ((temp < 20070) ? temp + 11059 |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
169 : GSM_ADD( temp >> 2, 26112 ))); |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
170 } else { |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
171 temp = *LARp; |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
172 *LARp = (temp < 11059) ? temp << 1 |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
173 : ((temp < 20070) ? temp + 11059 |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
174 : GSM_ADD( temp >> 2, 26112 )); |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
175 } |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
176 } |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
177 } |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
178 |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
179 /* 4.2.10 */ |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
180 static void Short_term_analysis_filtering ( |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
181 struct gsmfr_0610_state * S, |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
182 register word * rp, /* [0..7] IN */ |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
183 register int k_n, /* k_end - k_start */ |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
184 register word * s /* [0..n-1] IN/OUT */ |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
185 ) |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
186 /* |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
187 * This procedure computes the short term residual signal d[..] to be fed |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
188 * to the RPE-LTP loop from the s[..] signal and from the local rp[..] |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
189 * array (quantized reflection coefficients). As the call of this |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
190 * procedure can be done in many ways (see the interpolation of the LAR |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
191 * coefficient), it is assumed that the computation begins with index |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
192 * k_start (for arrays d[..] and s[..]) and stops with index k_end |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
193 * (k_start and k_end are defined in 4.2.9.1). This procedure also |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
194 * needs to keep the array u[0..7] in memory for each call. |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
195 */ |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
196 { |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
197 register word * u = S->u; |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
198 register int i; |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
199 register word di, zzz, ui, sav, rpi; |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
200 register longword ltmp; |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
201 |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
202 for (; k_n--; s++) { |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
203 |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
204 di = sav = *s; |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
205 |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
206 for (i = 0; i < 8; i++) { /* YYY */ |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
207 |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
208 ui = u[i]; |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
209 rpi = rp[i]; |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
210 u[i] = sav; |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
211 |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
212 zzz = GSM_MULT_R(rpi, di); |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
213 sav = GSM_ADD( ui, zzz); |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
214 |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
215 zzz = GSM_MULT_R(rpi, ui); |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
216 di = GSM_ADD( di, zzz ); |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
217 } |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
218 |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
219 *s = di; |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
220 } |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
221 } |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
222 |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
223 static void Short_term_synthesis_filtering ( |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
224 struct gsmfr_0610_state * S, |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
225 register word * rrp, /* [0..7] IN */ |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
226 register int k, /* k_end - k_start */ |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
227 register word * wt, /* [0..k-1] IN */ |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
228 register word * sr /* [0..k-1] OUT */ |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
229 ) |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
230 { |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
231 register word * v = S->v; |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
232 register int i; |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
233 register word sri, tmp1, tmp2; |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
234 register longword ltmp; /* for GSM_ADD & GSM_SUB */ |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
235 |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
236 while (k--) { |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
237 sri = *wt++; |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
238 for (i = 8; i--;) { |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
239 |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
240 /* sri = GSM_SUB( sri, gsm_mult_r( rrp[i], v[i] ) ); |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
241 */ |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
242 tmp1 = rrp[i]; |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
243 tmp2 = v[i]; |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
244 tmp2 = ( tmp1 == MIN_WORD && tmp2 == MIN_WORD |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
245 ? MAX_WORD |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
246 : 0x0FFFF & (( (longword)tmp1 * (longword)tmp2 |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
247 + 16384) >> 15)) ; |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
248 |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
249 sri = GSM_SUB( sri, tmp2 ); |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
250 |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
251 /* v[i+1] = GSM_ADD( v[i], gsm_mult_r( rrp[i], sri ) ); |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
252 */ |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
253 tmp1 = ( tmp1 == MIN_WORD && sri == MIN_WORD |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
254 ? MAX_WORD |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
255 : 0x0FFFF & (( (longword)tmp1 * (longword)sri |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
256 + 16384) >> 15)) ; |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
257 |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
258 v[i+1] = GSM_ADD( v[i], tmp1); |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
259 } |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
260 *sr++ = v[0] = sri; |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
261 } |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
262 } |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
263 |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
264 void Gsm_Short_Term_Analysis_Filter ( |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
265 struct gsmfr_0610_state * S, |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
266 |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
267 const word * LARc, /* coded log area ratio [0..7] IN */ |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
268 word * s /* signal [0..159] IN/OUT */ |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
269 ) |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
270 { |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
271 word * LARpp_j = S->LARpp[ S->j ]; |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
272 word * LARpp_j_1 = S->LARpp[ S->j ^= 1 ]; |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
273 |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
274 word LARp[8]; |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
275 |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
276 #undef FILTER |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
277 # define FILTER Short_term_analysis_filtering |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
278 |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
279 Decoding_of_the_coded_Log_Area_Ratios( LARc, LARpp_j ); |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
280 |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
281 Coefficients_0_12( LARpp_j_1, LARpp_j, LARp ); |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
282 LARp_to_rp( LARp ); |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
283 FILTER( S, LARp, 13, s); |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
284 |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
285 Coefficients_13_26( LARpp_j_1, LARpp_j, LARp); |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
286 LARp_to_rp( LARp ); |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
287 FILTER( S, LARp, 14, s + 13); |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
288 |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
289 Coefficients_27_39( LARpp_j_1, LARpp_j, LARp); |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
290 LARp_to_rp( LARp ); |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
291 FILTER( S, LARp, 13, s + 27); |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
292 |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
293 Coefficients_40_159( LARpp_j, LARp); |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
294 LARp_to_rp( LARp ); |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
295 FILTER( S, LARp, 120, s + 40); |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
296 } |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
297 |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
298 void Gsm_Short_Term_Synthesis_Filter ( |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
299 struct gsmfr_0610_state * S, |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
300 |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
301 const word * LARcr, /* received log area ratios [0..7] IN */ |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
302 word * wt, /* received d [0..159] IN */ |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
303 |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
304 word * s /* signal s [0..159] OUT */ |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
305 ) |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
306 { |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
307 word * LARpp_j = S->LARpp[ S->j ]; |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
308 word * LARpp_j_1 = S->LARpp[ S->j ^=1 ]; |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
309 |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
310 word LARp[8]; |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
311 |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
312 #undef FILTER |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
313 # define FILTER Short_term_synthesis_filtering |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
314 |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
315 Decoding_of_the_coded_Log_Area_Ratios( LARcr, LARpp_j ); |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
316 |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
317 Coefficients_0_12( LARpp_j_1, LARpp_j, LARp ); |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
318 LARp_to_rp( LARp ); |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
319 FILTER( S, LARp, 13, wt, s ); |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
320 |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
321 Coefficients_13_26( LARpp_j_1, LARpp_j, LARp); |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
322 LARp_to_rp( LARp ); |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
323 FILTER( S, LARp, 14, wt + 13, s + 13 ); |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
324 |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
325 Coefficients_27_39( LARpp_j_1, LARpp_j, LARp); |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
326 LARp_to_rp( LARp ); |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
327 FILTER( S, LARp, 13, wt + 27, s + 27 ); |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
328 |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
329 Coefficients_40_159( LARpp_j, LARp ); |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
330 LARp_to_rp( LARp ); |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
331 FILTER(S, LARp, 120, wt + 40, s + 40); |
d320a8fa3392
libgsmfr2: integrate short_term.c from libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
332 } |