FreeCalypso > hg > gsmhr-codec-ref
annotate sp_sfrm.c @ 3:a6db7d8d6df4
change compile-time quiet control to runtime,
and suppress all noisy output
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sat, 15 Jun 2024 00:09:40 +0000 |
parents | 9008dbc8ca74 |
children |
rev | line source |
---|---|
0
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 /*************************************************************************** |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
3 * File Name: sp_sfrm.c |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
4 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
5 * Purpose: Contains all functions for subframe based processing in the |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
6 * speech encoder. Subframe based processing determines the synthetic |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
7 * LPC excitation signal, which is composed of the adaptive codebook |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
8 * (long-term predictor) vector (in voiced modes), the vector-sum |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
9 * codebook vector (two of these in unvoiced mode), and the vector- |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
10 * quantized gains applied to these vectors. |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
11 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
12 * Below is a listing of all the functions appearing in the file. |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
13 * The functions are arranged according to their purpose. Under |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
14 * each heading, the ordering is hierarchical. |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
15 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
16 * sfrmAnalysis |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
17 * decorr |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
18 * closedLoopLagSearch |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
19 * hnwFilt |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
20 * g_quant_vl |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
21 * g_corr2 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
22 * gainTweak |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
23 * v_srch |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
24 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
25 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
26 ***************************************************************************/ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
27 /*_________________________________________________________________________ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
28 | | |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
29 | Include Files | |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
30 |_________________________________________________________________________| |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
31 */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
32 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
33 #include <stdio.h> |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
34 #include "mathhalf.h" |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
35 #include "sp_rom.h" |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
36 #include "sp_dec.h" |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
37 #include "sp_frm.h" |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
38 #include "sp_sfrm.h" |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
39 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
40 /*_________________________________________________________________________ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
41 | | |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
42 | Local Defines | |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
43 |_________________________________________________________________________| |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
44 */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
45 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
46 #define CG_INT_MACS 6 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
47 #define C_BITS_UV 7 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
48 #define C_BITS_UV_1 C_BITS_UV-1 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
49 #define C_BITS_V 9 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
50 #define C_BITS_V_1 C_BITS_V-1 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
51 #define DELTA_LEVELS 16 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
52 #define GSP0_NUM 32 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
53 #define GSP0_VECTOR_SIZE 5 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
54 #define GTWEAKMAX 0x5A82 /* sqrt(2)/2 */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
55 #define LMAX 142 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
56 #define LSMAX (LMAX + CG_INT_MACS/2) |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
57 #define HNW_BUFF_LEN LSMAX |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
58 #define LSP_MASK 0xffff |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
59 #define LTP_LEN 147 /* maximum ltp lag */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
60 #define MAX_CANDIDATE 6 /* maximum number of lag candidates */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
61 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
62 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
63 /*_________________________________________________________________________ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
64 | | |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
65 | State variables (globals) | |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
66 |_________________________________________________________________________| |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
67 */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
68 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
69 Shortword pswLtpStateBase[LTP_LEN + S_LEN]; |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
70 Shortword pswHState[NP]; |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
71 Shortword pswHNWState[HNW_BUFF_LEN]; |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
72 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
73 /*************************************************************************** |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
74 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
75 * FUNCTION NAME: closedLoopLagSearch |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
76 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
77 * PURPOSE: |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
78 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
79 * Performs the closed loop search of a list of candidate lags to |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
80 * determine the best fractional lag. |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
81 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
82 * INPUTS: |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
83 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
84 * pswLagList[0:iNumLags] - list of candidate lags |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
85 * iNumLags - number of candidate lags in LagList |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
86 * pswLtpState[0:5] - array of past excitations (LTP state) |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
87 * pswHCoefs[0:9] - coefficient array of spectral weighting filter |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
88 * pswPVect[0:39] - speech sub frame data |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
89 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
90 * OUTPUTS: |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
91 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
92 * pswLag - pointer to put best lag from list of candidates |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
93 * *pswLtpShift - Number of shifts applied to weighted LTP vector. |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
94 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
95 * RETURN VALUE: |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
96 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
97 * siLagCode - code corresponding to the best lag |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
98 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
99 * IMPLEMENTATION: |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
100 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
101 * Generate excitation vectors for all candidate lags. Find the candidate |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
102 * lag that maximizes C**2/G using the calculated excitation. |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
103 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
104 * DESCRIPTION: |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
105 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
106 * The function closedLoopLagSearch() searches a very small subset of the |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
107 * available LTP lags. The lags to be searched are defined by the open |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
108 * loop lag search. This information is passed in as a list of |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
109 * oversampled lag values. These values are translated into LTP |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
110 * vectors extracted from the LTP history. |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
111 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
112 * GSM document 06.20's b sub L prime variable is called |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
113 * ppswTVect[L][n] in the C code. The document's variable p(n) is |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
114 * named pswPVect[] in the C code. |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
115 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
116 * The function performs a simple maximization of the cross correlation |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
117 * of the weighted LTP vector and the weighted speech vector divided |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
118 * by the autocorrelation of the weighted LTP vector. The function is |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
119 * encumbered slightly by the necessity of scaling. |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
120 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
121 * REFERENCE: Sub-clause 4.1.8.5 of GSM Recommendation 06.20 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
122 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
123 * KEYWORDS: closed loop, LTP lag search, adaptive codebook search |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
124 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
125 **************************************************************************/ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
126 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
127 int closedLoopLagSearch(Shortword pswLagList[], int iNumLags, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
128 Shortword pswLtpState[], Shortword pswHCoefs[], |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
129 Shortword pswPVect[], |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
130 Shortword *pswLag, Shortword *pswLtpShift) |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
131 { |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
132 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
133 /*_________________________________________________________________________ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
134 | | |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
135 | Automatic Variables | |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
136 |_________________________________________________________________________| |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
137 */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
138 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
139 Longword L_Energy, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
140 L_ccNorm, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
141 L_cgNorm, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
142 L_CrossCorr; |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
143 Longword pL_CCBuf[MAX_CANDIDATE], |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
144 pL_CGBuf[MAX_CANDIDATE]; |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
145 Shortword swCCMax, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
146 swCCShiftCnt, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
147 swCGShiftCnt, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
148 swGMax, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
149 swLTPEnergy, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
150 swSampleA, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
151 pswCCBuf[MAX_CANDIDATE], |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
152 pswCGBuf[MAX_CANDIDATE], |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
153 ppswTVect[N_SUB][S_LEN]; |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
154 Shortword i, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
155 j, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
156 siLagOffset, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
157 siLagCode; |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
158 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
159 /*_________________________________________________________________________ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
160 | | |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
161 | Executable Code | |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
162 |_________________________________________________________________________| |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
163 */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
164 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
165 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
166 *pswLtpShift = 0; /* Energy in weighted ltp vector = |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
167 * [0..0x7ff] */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
168 for (i = 0; i < iNumLags; i++) |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
169 { |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
170 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
171 /* Construct the excitation vector for lag i */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
172 /* ----------------------------------------- */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
173 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
174 fp_ex(pswLagList[i], &pswLtpState[LTP_LEN]); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
175 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
176 /* Perform all pole filtering */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
177 /* -------------------------- */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
178 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
179 lpcZsIir(&pswLtpState[LTP_LEN], pswHCoefs, ppswTVect[i]); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
180 } |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
181 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
182 /* scale the pitch vector s.t. its energy is strictly */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
183 /* less than 1.0 */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
184 /*----------------------------------------------------*/ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
185 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
186 swSampleA = shr(ppswTVect[0][0], 2); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
187 L_Energy = L_mac(0x001dff4cL, swSampleA, swSampleA); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
188 for (j = 1; j < S_LEN; j++) |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
189 { |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
190 swSampleA = shr(ppswTVect[0][j], 2); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
191 L_Energy = L_mac(L_Energy, swSampleA, swSampleA); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
192 } |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
193 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
194 /* add in the energy of the first sample of the subsequent lags */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
195 /*--------------------------------------------------------------*/ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
196 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
197 for (i = 1; i < iNumLags; i++) |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
198 { |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
199 swSampleA = shr(ppswTVect[i][0], 2); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
200 L_Energy = L_mac(L_Energy, swSampleA, swSampleA); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
201 } |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
202 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
203 /* An upper bound on the weighted pitch vectors energy */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
204 /*-----------------------------------------------------*/ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
205 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
206 swLTPEnergy = round(L_Energy); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
207 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
208 if (sub(swLTPEnergy, 0x07ff) > 0) |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
209 { /* E = (0x7ff.. 0x7fff] */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
210 if (sub(swLTPEnergy, 0x1fff) > 0) |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
211 { |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
212 *pswLtpShift = 2; /* E = (0x1fff..0x7fff] */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
213 } |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
214 else |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
215 { |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
216 *pswLtpShift = 1; /* E = (0x7ff.. 0x1fff] */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
217 } |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
218 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
219 } |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
220 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
221 for (i = 0; i < iNumLags; i++) |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
222 { |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
223 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
224 /* shift all vectors down s.t. the largest is has energy < 1.0 */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
225 /*-------------------------------------------------------------*/ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
226 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
227 for (j = 0; j < S_LEN; j++) |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
228 ppswTVect[i][j] = shr(ppswTVect[i][j], *pswLtpShift); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
229 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
230 /* Calculate the energy of the subframe */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
231 /* ------------------------------------ */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
232 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
233 L_Energy = L_mult(ppswTVect[i][0], ppswTVect[i][0]); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
234 for (j = 1; j < S_LEN; j++) |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
235 L_Energy = L_mac(L_Energy, ppswTVect[i][j], ppswTVect[i][j]); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
236 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
237 pL_CGBuf[i] = L_Energy; |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
238 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
239 /* Cross correlate the normalized speech frame and the filtered |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
240 * subframe */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
241 /* --------------------------------------------------------------------- |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
242 * */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
243 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
244 L_CrossCorr = L_mult(ppswTVect[i][0], pswPVect[0]); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
245 for (j = 1; j < S_LEN; j++) |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
246 L_CrossCorr = L_mac(L_CrossCorr, ppswTVect[i][j], pswPVect[j]); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
247 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
248 pL_CCBuf[i] = L_CrossCorr; |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
249 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
250 } |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
251 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
252 /* find the shift count associated with the largest CC and G */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
253 /* ---------------------------------------------------------- */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
254 L_ccNorm = L_abs(pL_CCBuf[0]); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
255 L_cgNorm = pL_CGBuf[0]; |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
256 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
257 for (i = 1; i < iNumLags; i++) |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
258 { |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
259 L_ccNorm |= L_abs(pL_CCBuf[i]); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
260 L_cgNorm |= pL_CGBuf[i]; |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
261 } |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
262 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
263 swCCShiftCnt = norm_l(L_ccNorm); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
264 swCGShiftCnt = norm_l(L_cgNorm); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
265 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
266 for (i = 0; i < iNumLags; i++) |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
267 { |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
268 pswCCBuf[i] = round(L_shl(pL_CCBuf[i], swCCShiftCnt)); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
269 pswCGBuf[i] = round(L_shl(pL_CGBuf[i], swCGShiftCnt)); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
270 } |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
271 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
272 /* Maximize C**2/G */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
273 /* --------------- */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
274 siLagOffset = maxCCOverGWithSign(pswCCBuf, pswCGBuf, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
275 &swCCMax, &swGMax, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
276 iNumLags); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
277 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
278 /* Determine the offset of the max value into CC buffer */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
279 /* ---------------------------------------------------- */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
280 *pswLag = pswLagList[siLagOffset]; |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
281 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
282 /* Store Lag Code for best lag result */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
283 /* ---------------------------------- */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
284 quantLag(*pswLag, &siLagCode); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
285 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
286 return (siLagCode); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
287 } |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
288 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
289 /***************************************************************************** |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
290 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
291 * FUNCTION NAME: decorr |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
292 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
293 * PURPOSE: Decorrelates(orthogonalizes) a set of vectors from a given |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
294 * vector. |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
295 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
296 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
297 * INPUTS: iNumVects - number of vectors to decorrelate |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
298 * pswGivenVect[0..39] - array of given vectors |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
299 * pswVects[0..359] (voice) [0..279] (unvoiced) - array of |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
300 * contiguous vectors to be decorrelated |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
301 * OUTPUTS: pswVects[0..359] (voice) [0..279] (unvoiced) - output vectors |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
302 * are written back over input vectors |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
303 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
304 * RETURN VALUE: none |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
305 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
306 * IMPLEMENTATION: |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
307 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
308 * REFERENCE: Sub-clause 4.1.10.1 of GSM Recommendation 06.20 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
309 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
310 * KEYWORDS: decorrelate, codewords, codevectors, orthogonalize, encoder |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
311 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
312 ****************************************************************************/ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
313 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
314 void decorr(int iNumVects, Shortword pswGivenVect[], |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
315 Shortword pswVects[]) |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
316 { |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
317 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
318 /*___________________________________________________________________________ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
319 | | |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
320 | Automatic Variables | |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
321 |___________________________________________________________________________| |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
322 */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
323 int i, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
324 iLoopCnt; |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
325 Shortword swNorm_energy, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
326 swTemp; |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
327 Shortword swEShift, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
328 swCShift, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
329 swShiftSum, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
330 swQShift; |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
331 Longword L_Energy, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
332 L_Temp1, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
333 L_Temp2, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
334 L_Accum; |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
335 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
336 /*___________________________________________________________________________ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
337 | | |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
338 | Executable Code | |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
339 |___________________________________________________________________________| |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
340 */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
341 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
342 /* Compute normalized energy in given vector */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
343 /*-------------------------------------------*/ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
344 swEShift = g_corr1(pswGivenVect, &L_Energy); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
345 swNorm_energy = extract_h(L_Energy); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
346 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
347 if (swNorm_energy == 0) |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
348 { |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
349 return; |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
350 } |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
351 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
352 /* Decorrelate vectors */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
353 /*---------------------*/ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
354 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
355 for (iLoopCnt = 0; iLoopCnt < iNumVects; iLoopCnt++) |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
356 { |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
357 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
358 swCShift = g_corr2(pswGivenVect, &pswVects[iLoopCnt * S_LEN], |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
359 &L_Temp1); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
360 L_Temp2 = L_Temp1; |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
361 L_Temp1 = L_abs(L_Temp1); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
362 swCShift = sub(swCShift, 1); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
363 swShiftSum = sub(swCShift, swEShift); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
364 L_Temp1 = L_shr(L_Temp1, 1); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
365 swTemp = divide_s(round(L_Temp1), swNorm_energy); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
366 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
367 if (L_Temp2 > 0) |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
368 swTemp = negate(swTemp); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
369 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
370 swQShift = norm_s(swTemp); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
371 swTemp = shl(swTemp, swQShift); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
372 swQShift = add(swShiftSum, swQShift); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
373 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
374 if (swQShift > 0) |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
375 { |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
376 swTemp = shift_r(swTemp, negate(swQShift)); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
377 swQShift = 0; |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
378 } |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
379 else |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
380 swQShift = negate(swQShift); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
381 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
382 for (i = 0; i < S_LEN; i++) |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
383 { |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
384 L_Accum = L_msu(0x00008000L, pswVects[i + iLoopCnt * S_LEN], SW_MIN); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
385 pswVects[iLoopCnt * S_LEN + i] = extract_h(L_mac(L_Accum, swTemp, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
386 shl(pswGivenVect[i], swQShift))); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
387 } |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
388 } |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
389 } |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
390 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
391 /*************************************************************************** |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
392 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
393 * FUNCTION NAME: g_corr2 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
394 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
395 * PURPOSE: Calculates correlation between subframe vectors. |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
396 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
397 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
398 * INPUT: |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
399 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
400 * pswIn[0:39] |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
401 * A subframe vector. |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
402 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
403 * pswIn2[0:39] |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
404 * A subframe vector. |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
405 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
406 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
407 * OUTPUT: |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
408 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
409 * *pL_out |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
410 * A Longword containing the normalized correlation |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
411 * between the input vectors. |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
412 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
413 * RETURN: |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
414 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
415 * swOut |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
416 * Number of right shifts which the accumulator was |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
417 * shifted to normalize it. Negative number implies |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
418 * a left shift, and therefore an energy larger than |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
419 * 1.0. |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
420 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
421 * REFERENCE: Sub-clauses 4.1.10.1 and 4.1.11.1 of GSM |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
422 * Recommendation 06.20 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
423 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
424 * keywords: energy, autocorrelation, correlation, g_corr2 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
425 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
426 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
427 **************************************************************************/ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
428 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
429 Shortword g_corr2(Shortword *pswIn, Shortword *pswIn2, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
430 Longword *pL_out) |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
431 { |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
432 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
433 /*_________________________________________________________________________ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
434 | | |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
435 | Automatic Variables | |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
436 |_________________________________________________________________________| |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
437 */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
438 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
439 Longword L_sum; |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
440 Shortword swEngyLShft; |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
441 int i; |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
442 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
443 /*_________________________________________________________________________ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
444 | | |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
445 | Executable Code | |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
446 |_________________________________________________________________________| |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
447 */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
448 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
449 /* Calculate energy in subframe vector (40 samples) */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
450 /*--------------------------------------------------*/ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
451 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
452 L_sum = L_mult(pswIn[0], pswIn2[0]); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
453 for (i = 1; i < S_LEN; i++) |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
454 { |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
455 L_sum = L_mac(L_sum, pswIn[i], pswIn2[i]); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
456 } |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
457 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
458 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
459 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
460 if (L_sum != 0) |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
461 { |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
462 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
463 /* Normalize the energy in the output Longword */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
464 /*---------------------------------------------*/ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
465 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
466 swEngyLShft = norm_l(L_sum); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
467 *pL_out = L_shl(L_sum, swEngyLShft); /* normalize output |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
468 * Longword */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
469 } |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
470 else |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
471 { |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
472 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
473 /* Special case: energy is zero */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
474 /*------------------------------*/ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
475 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
476 *pL_out = L_sum; |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
477 swEngyLShft = 0; |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
478 } |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
479 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
480 return (swEngyLShft); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
481 } |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
482 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
483 /*************************************************************************** |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
484 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
485 * FUNCTION NAME: g_quant_vl |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
486 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
487 * PURPOSE: |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
488 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
489 * Joint quantization of excitation gains. |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
490 * GS represents the subframe energy relative to the frame energy. |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
491 * P0 represents the relative contribution of the first exctitation |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
492 * source to the total excitation. |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
493 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
494 * INPUTS: |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
495 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
496 * swUVCode - voicing level (Mode 0-3) |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
497 * pswWInput[0:39] - weighted input p(n) (used in mode 0-3) |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
498 * swWIShift - weighted input shift factor (right shift, 0,1, or 2) |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
499 * pswWLTPVec[0:39] - weighted pitch excitation vector (used in mode 1-3) |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
500 * pswWVSVec1[0:39] - weighted 1st v-s codevector (used in mode 0-3) |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
501 * pswWVSVec2[0:39] - weighted 2nd v-s codevector (used in mode 0) |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
502 * snsRs00 - square root of RS/pitch excitation energy (used in mode 1-3) |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
503 * snsRs11 - square root of RS/1st v-s codevector energy |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
504 * (used in mode 0-3) |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
505 * snsRs22 - square root of RS/2nd v-s codevector energy (used in mode 0) |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
506 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
507 * pppsrGsp0[0:3][0:31][0:4] - lookup table |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
508 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
509 * OUTPUTS: |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
510 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
511 * None |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
512 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
513 * RETURN VALUE: |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
514 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
515 * siCode - output quantized gain code (5 bits) |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
516 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
517 * IMPLEMENTATION: |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
518 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
519 * Calculates first the parameters required for error equation 7.21: |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
520 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
521 * Rcc(k,j) k = 0,1, j=k,1 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
522 * Rx(k) k = 0,1 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
523 * RS |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
524 * Rpc(k) k = 0,1 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
525 * a,b,c,d,e |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
526 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
527 * The constant terms in equation 7.21 are stored in ROM instead of GS |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
528 * and P0. There is one vector quantizer for each voicing state. |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
529 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
530 * REFERENCE: Sub-clause 4.1.11 and 4.1.11.1 of GSM Recommendation 06.20 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
531 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
532 * KEYWORDS: gain quantization, energy domain transforms, p0, gs |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
533 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
534 **************************************************************************/ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
535 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
536 Shortword g_quant_vl(Shortword swUVCode, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
537 Shortword pswWInput[], Shortword swWIShift, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
538 Shortword pswWLTPVec[], |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
539 Shortword pswWVSVec1[], Shortword pswWVSVec2[], |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
540 struct NormSw snsRs00, struct NormSw snsRs11, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
541 struct NormSw snsRs22) |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
542 { |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
543 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
544 /*_________________________________________________________________________ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
545 | | |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
546 | Automatic Variables | |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
547 |_________________________________________________________________________| |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
548 */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
549 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
550 Longword L_Temp, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
551 L_Temp2; |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
552 Shortword swShift; |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
553 struct NormSw ErrorTerm[6]; |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
554 Shortword i, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
555 siCode, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
556 siNormShift, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
557 siNormMin; |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
558 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
559 /*_________________________________________________________________________ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
560 | | |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
561 | Executable Code | |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
562 |_________________________________________________________________________| |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
563 */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
564 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
565 /* Test voicing level, mode 0-3 */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
566 /* ---------------------------- */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
567 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
568 if (swUVCode == 0) |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
569 { |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
570 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
571 /* Unvoiced */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
572 /* -------- */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
573 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
574 /* Compute cross correlation Rpc(0) */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
575 /* -------------------------------- */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
576 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
577 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
578 ErrorTerm[0].sh = g_corr2(pswWInput, pswWVSVec1, &L_Temp); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
579 ErrorTerm[0].man = round(L_Temp); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
580 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
581 /* Compute cross correlation Rpc(1) */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
582 /* -------------------------------- */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
583 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
584 ErrorTerm[1].sh = g_corr2(pswWInput, pswWVSVec2, &L_Temp); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
585 ErrorTerm[1].man = round(L_Temp); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
586 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
587 /* Compute cross correlation Rcc(0,1) */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
588 /* ---------------------------------- */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
589 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
590 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
591 ErrorTerm[2].sh = g_corr2(pswWVSVec1, pswWVSVec2, &L_Temp); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
592 ErrorTerm[2].man = round(L_Temp); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
593 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
594 /* Compute correlation Rcc(0,0) */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
595 /* ---------------------------- */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
596 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
597 ErrorTerm[3].sh = g_corr1(pswWVSVec1, &L_Temp); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
598 ErrorTerm[3].man = round(L_Temp); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
599 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
600 /* Compute correlation Rcc(1,1) */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
601 /* ---------------------------- */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
602 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
603 ErrorTerm[4].sh = g_corr1(pswWVSVec2, &L_Temp); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
604 ErrorTerm[4].man = round(L_Temp); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
605 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
606 /* Compute correlation Rpp */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
607 /* ----------------------- */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
608 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
609 ErrorTerm[5].sh = g_corr1(pswWInput, &L_Temp); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
610 ErrorTerm[5].man = round(L_Temp); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
611 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
612 /* Compute gain tweak factor, adjusts A and B error coefs */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
613 /* ------------------------------------------------------ */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
614 gainTweak(&ErrorTerm[0]); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
615 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
616 /* Compute error coefficient A, equation 5.22 */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
617 /* ------------------------------------------ */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
618 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
619 L_Temp = L_mult(ErrorTerm[0].man, snsRs11.man); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
620 swShift = norm_s(extract_h(L_Temp)); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
621 ErrorTerm[0].sh = add(ErrorTerm[0].sh, swShift); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
622 ErrorTerm[0].man = round(L_shl(L_Temp, swShift)); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
623 ErrorTerm[0].sh = add(ErrorTerm[0].sh, snsRs11.sh); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
624 siNormMin = ErrorTerm[0].sh; |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
625 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
626 /* Compute error coefficient B, equation 5.23 */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
627 /* ------------------------------------------ */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
628 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
629 L_Temp = L_mult(ErrorTerm[1].man, snsRs22.man); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
630 swShift = norm_s(extract_h(L_Temp)); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
631 ErrorTerm[1].sh = add(ErrorTerm[1].sh, swShift); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
632 ErrorTerm[1].man = round(L_shl(L_Temp, swShift)); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
633 ErrorTerm[1].sh = add(ErrorTerm[1].sh, snsRs22.sh); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
634 if (sub(ErrorTerm[1].sh, siNormMin) < 0) |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
635 siNormMin = ErrorTerm[1].sh; |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
636 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
637 /* Compute error coefficient C, equation 5.24 */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
638 /* ------------------------------------------ */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
639 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
640 L_Temp = L_mult(ErrorTerm[2].man, snsRs11.man); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
641 swShift = norm_s(extract_h(L_Temp)); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
642 ErrorTerm[2].sh = add(ErrorTerm[2].sh, swShift); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
643 ErrorTerm[2].man = round(L_shl(L_Temp, swShift)); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
644 L_Temp = L_mult(ErrorTerm[2].man, snsRs22.man); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
645 swShift = norm_s(extract_h(L_Temp)); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
646 ErrorTerm[2].sh = add(ErrorTerm[2].sh, swShift); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
647 ErrorTerm[2].man = round(L_shl(L_Temp, swShift)); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
648 ErrorTerm[2].sh = add(ErrorTerm[2].sh, snsRs11.sh); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
649 ErrorTerm[2].sh = add(ErrorTerm[2].sh, snsRs22.sh); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
650 ErrorTerm[2].sh = add(ErrorTerm[2].sh, swWIShift); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
651 if (sub(ErrorTerm[2].sh, siNormMin) < 0) |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
652 siNormMin = ErrorTerm[2].sh; |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
653 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
654 /* Compute error coefficient D, equation 5.25 */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
655 /* ------------------------------------------ */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
656 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
657 L_Temp = L_mult(ErrorTerm[3].man, snsRs11.man); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
658 swShift = norm_s(extract_h(L_Temp)); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
659 ErrorTerm[3].sh = add(ErrorTerm[3].sh, swShift); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
660 ErrorTerm[3].man = round(L_shl(L_Temp, swShift)); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
661 L_Temp = L_mult(ErrorTerm[3].man, snsRs11.man); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
662 swShift = norm_s(extract_h(L_Temp)); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
663 ErrorTerm[3].sh = add(ErrorTerm[3].sh, swShift); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
664 ErrorTerm[3].man = round(L_shl(L_Temp, swShift)); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
665 ErrorTerm[3].sh = add(ErrorTerm[3].sh, snsRs11.sh); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
666 ErrorTerm[3].sh = add(ErrorTerm[3].sh, snsRs11.sh); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
667 ErrorTerm[3].sh = add(ErrorTerm[3].sh, swWIShift); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
668 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
669 if (sub(ErrorTerm[3].sh, siNormMin) < 0) |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
670 siNormMin = ErrorTerm[3].sh; |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
671 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
672 /* Compute error coefficient E, equation 5.26 */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
673 /* ------------------------------------------ */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
674 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
675 L_Temp = L_mult(ErrorTerm[4].man, snsRs22.man); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
676 swShift = norm_s(extract_h(L_Temp)); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
677 ErrorTerm[4].sh = add(ErrorTerm[4].sh, swShift); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
678 ErrorTerm[4].man = round(L_shl(L_Temp, swShift)); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
679 L_Temp = L_mult(ErrorTerm[4].man, snsRs22.man); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
680 swShift = norm_s(extract_h(L_Temp)); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
681 ErrorTerm[4].sh = add(ErrorTerm[4].sh, swShift); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
682 ErrorTerm[4].man = round(L_shl(L_Temp, swShift)); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
683 ErrorTerm[4].sh = add(ErrorTerm[4].sh, snsRs22.sh); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
684 ErrorTerm[4].sh = add(ErrorTerm[4].sh, snsRs22.sh); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
685 ErrorTerm[4].sh = add(ErrorTerm[4].sh, swWIShift); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
686 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
687 if (sub(ErrorTerm[4].sh, siNormMin) < 0) |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
688 siNormMin = ErrorTerm[4].sh; |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
689 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
690 } |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
691 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
692 else |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
693 { /* Voicing level */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
694 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
695 /* Voiced */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
696 /* ------ */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
697 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
698 /* Compute cross correlation Rpc(0) */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
699 /* -------------------------------- */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
700 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
701 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
702 ErrorTerm[0].sh = g_corr2(pswWInput, pswWLTPVec, &L_Temp); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
703 ErrorTerm[0].man = round(L_Temp); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
704 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
705 /* Compute cross correlation Rpc(1) */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
706 /* -------------------------------- */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
707 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
708 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
709 ErrorTerm[1].sh = g_corr2(pswWInput, pswWVSVec1, &L_Temp); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
710 ErrorTerm[1].man = round(L_Temp); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
711 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
712 /* Compute cross correlation Rcc(0,1) */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
713 /* ---------------------------------- */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
714 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
715 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
716 ErrorTerm[2].sh = g_corr2(pswWLTPVec, pswWVSVec1, &L_Temp); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
717 ErrorTerm[2].man = round(L_Temp); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
718 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
719 /* Compute correlation Rcc(0,0) */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
720 /* ---------------------------- */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
721 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
722 ErrorTerm[3].sh = g_corr1(pswWLTPVec, &L_Temp); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
723 ErrorTerm[3].man = round(L_Temp); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
724 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
725 /* Compute correlation Rcc(1,1) */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
726 /* ---------------------------- */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
727 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
728 ErrorTerm[4].sh = g_corr1(pswWVSVec1, &L_Temp); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
729 ErrorTerm[4].man = round(L_Temp); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
730 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
731 /* Compute correlation Rpp */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
732 /* ----------------------- */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
733 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
734 ErrorTerm[5].sh = g_corr1(pswWInput, &L_Temp); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
735 ErrorTerm[5].man = round(L_Temp); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
736 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
737 /* Compute gain tweak factor, adjusts A and B error coefs */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
738 /* ------------------------------------------------------ */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
739 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
740 gainTweak(&ErrorTerm[0]); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
741 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
742 /* Compute error coefficient A, equation 5.22 */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
743 /* ------------------------------------------ */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
744 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
745 L_Temp = L_mult(ErrorTerm[0].man, snsRs00.man); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
746 swShift = norm_s(extract_h(L_Temp)); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
747 ErrorTerm[0].sh = add(ErrorTerm[0].sh, swShift); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
748 ErrorTerm[0].man = round(L_shl(L_Temp, swShift)); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
749 ErrorTerm[0].sh = add(ErrorTerm[0].sh, snsRs00.sh); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
750 siNormMin = ErrorTerm[0].sh; |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
751 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
752 /* Compute error coefficient B, equation 5.23 */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
753 /* ------------------------------------------ */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
754 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
755 L_Temp = L_mult(ErrorTerm[1].man, snsRs11.man); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
756 swShift = norm_s(extract_h(L_Temp)); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
757 ErrorTerm[1].sh = add(ErrorTerm[1].sh, swShift); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
758 ErrorTerm[1].man = round(L_shl(L_Temp, swShift)); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
759 ErrorTerm[1].sh = add(ErrorTerm[1].sh, snsRs11.sh); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
760 if (sub(ErrorTerm[1].sh, siNormMin) < 0) |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
761 siNormMin = ErrorTerm[1].sh; |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
762 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
763 /* Compute error coefficient C, equation 5.24 */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
764 /* ------------------------------------------ */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
765 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
766 L_Temp = L_mult(ErrorTerm[2].man, snsRs00.man); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
767 swShift = norm_s(extract_h(L_Temp)); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
768 ErrorTerm[2].sh = add(ErrorTerm[2].sh, swShift); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
769 ErrorTerm[2].man = round(L_shl(L_Temp, swShift)); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
770 L_Temp = L_mult(ErrorTerm[2].man, snsRs11.man); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
771 swShift = norm_s(extract_h(L_Temp)); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
772 ErrorTerm[2].sh = add(ErrorTerm[2].sh, swShift); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
773 ErrorTerm[2].man = round(L_shl(L_Temp, swShift)); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
774 ErrorTerm[2].sh = add(ErrorTerm[2].sh, snsRs00.sh); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
775 ErrorTerm[2].sh = add(ErrorTerm[2].sh, snsRs11.sh); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
776 ErrorTerm[2].sh = add(ErrorTerm[2].sh, swWIShift); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
777 if (sub(ErrorTerm[2].sh, siNormMin) < 0) |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
778 siNormMin = ErrorTerm[2].sh; |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
779 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
780 /* Compute error coefficient D, equation 5.25 */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
781 /* ------------------------------------------ */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
782 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
783 L_Temp = L_mult(ErrorTerm[3].man, snsRs00.man); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
784 swShift = norm_s(extract_h(L_Temp)); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
785 ErrorTerm[3].sh = add(ErrorTerm[3].sh, swShift); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
786 ErrorTerm[3].man = round(L_shl(L_Temp, swShift)); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
787 L_Temp = L_mult(ErrorTerm[3].man, snsRs00.man); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
788 swShift = norm_s(extract_h(L_Temp)); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
789 ErrorTerm[3].sh = add(ErrorTerm[3].sh, swShift); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
790 ErrorTerm[3].man = round(L_shl(L_Temp, swShift)); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
791 ErrorTerm[3].sh = add(ErrorTerm[3].sh, snsRs00.sh); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
792 ErrorTerm[3].sh = add(ErrorTerm[3].sh, snsRs00.sh); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
793 ErrorTerm[3].sh = add(ErrorTerm[3].sh, swWIShift); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
794 if (sub(ErrorTerm[3].sh, siNormMin) < 0) |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
795 siNormMin = ErrorTerm[3].sh; |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
796 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
797 /* Compute error coefficient E, equation 5.26 */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
798 /* ------------------------------------------ */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
799 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
800 L_Temp = L_mult(ErrorTerm[4].man, snsRs11.man); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
801 swShift = norm_s(extract_h(L_Temp)); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
802 ErrorTerm[4].sh = add(ErrorTerm[4].sh, swShift); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
803 ErrorTerm[4].man = round(L_shl(L_Temp, swShift)); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
804 L_Temp = L_mult(ErrorTerm[4].man, snsRs11.man); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
805 swShift = norm_s(extract_h(L_Temp)); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
806 ErrorTerm[4].sh = add(ErrorTerm[4].sh, swShift); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
807 ErrorTerm[4].man = round(L_shl(L_Temp, swShift)); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
808 ErrorTerm[4].sh = add(ErrorTerm[4].sh, snsRs11.sh); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
809 ErrorTerm[4].sh = add(ErrorTerm[4].sh, snsRs11.sh); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
810 ErrorTerm[4].sh = add(ErrorTerm[4].sh, swWIShift); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
811 if (sub(ErrorTerm[4].sh, siNormMin) < 0) |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
812 siNormMin = ErrorTerm[4].sh; |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
813 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
814 } /* Voicing level */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
815 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
816 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
817 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
818 /* Normalize all error coefficients to same shift count */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
819 /* ---------------------------------------------------- */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
820 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
821 for (i = 0; i < GSP0_VECTOR_SIZE; i++) |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
822 { |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
823 L_Temp = L_deposit_h(ErrorTerm[i].man); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
824 siNormShift = sub(ErrorTerm[i].sh, siNormMin); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
825 if (siNormShift > 0) |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
826 L_Temp = L_shr(L_Temp, siNormShift); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
827 ErrorTerm[i].man = round(L_Temp); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
828 } |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
829 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
830 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
831 /* Codebook search, find max of error equation 5.21 */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
832 /* ------------------------------------------------ */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
833 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
834 L_Temp2 = 0x80000000; |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
835 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
836 for (i = 0; i < GSP0_NUM; i++) |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
837 { |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
838 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
839 L_Temp = L_mult(pppsrGsp0[swUVCode][i][0], ErrorTerm[0].man); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
840 L_Temp = L_mac(L_Temp, pppsrGsp0[swUVCode][i][1], ErrorTerm[1].man); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
841 L_Temp = L_mac(L_Temp, pppsrGsp0[swUVCode][i][2], ErrorTerm[2].man); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
842 L_Temp = L_mac(L_Temp, pppsrGsp0[swUVCode][i][3], ErrorTerm[3].man); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
843 L_Temp = L_mac(L_Temp, pppsrGsp0[swUVCode][i][4], ErrorTerm[4].man); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
844 if (L_sub(L_Temp2, L_Temp) < 0) |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
845 { |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
846 L_Temp2 = L_Temp; |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
847 siCode = i; /* Save best code */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
848 } |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
849 } |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
850 return (siCode); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
851 } |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
852 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
853 /*************************************************************************** |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
854 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
855 * FUNCTION NAME: gainTweak |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
856 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
857 * PURPOSE: |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
858 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
859 * Calculates gain bias factor, limits it, and |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
860 * applies it to A and B error coefficients. |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
861 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
862 * INPUTS: |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
863 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
864 * psErrorTerm[0:5] - array (6) of error coefficients in floating |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
865 * point format |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
866 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
867 * OUTPUTS: |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
868 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
869 * psErrorTerm[0:5] - array of gain adjusted A and B error coefficients |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
870 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
871 * RETURN VALUE: |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
872 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
873 * None |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
874 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
875 * IMPLEMENTATION: |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
876 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
877 * The gain tweak is: |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
878 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
879 * Rpp*Rcc(0,0)*Rcc(1,1) - Rpp*Rcc(0,1)*Rcc(0,1) |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
880 *sqrt(---------------------------------------------------------------------) |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
881 * Rcc(0,0)*Rpc(1)*Rpc(1)-2*Rcc(0,1)*Rpc(0)*Rpc(1)+Rcc(1,1)*Rpc(0)*Rpc(0) |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
882 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
883 * REFERENCE: Sub-clause 4.1.11.1 of GSM Recommendation 06.20 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
884 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
885 * KEYWORDS: gain tweak, g_quant_vl |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
886 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
887 **************************************************************************/ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
888 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
889 void gainTweak(struct NormSw *psErrorTerm) |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
890 { |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
891 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
892 /*_________________________________________________________________________ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
893 | | |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
894 | Automatic Variables | |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
895 |_________________________________________________________________________| |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
896 */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
897 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
898 Longword L_Temp; |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
899 Shortword swTemp, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
900 swNum, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
901 swDenom, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
902 swGainTweak, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
903 swShift; |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
904 struct NormSw terms[5]; |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
905 Shortword i, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
906 siNormShift, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
907 siNorm; |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
908 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
909 /*_________________________________________________________________________ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
910 | | |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
911 | Executable Code | |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
912 |_________________________________________________________________________| |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
913 */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
914 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
915 /* Calculate third order terms in the gain tweak factor, while |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
916 * maintaining the largest exponent */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
917 /* ---------------------------------------------------- */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
918 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
919 /* Compute Rpp*Rcc(0,0)*Rcc(1,1) */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
920 /* ----------------------------- */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
921 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
922 L_Temp = L_mult(psErrorTerm[3].man, psErrorTerm[5].man); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
923 swShift = norm_s(extract_h(L_Temp)); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
924 terms[0].sh = add(psErrorTerm[3].sh, swShift); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
925 terms[0].man = round(L_shl(L_Temp, swShift)); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
926 L_Temp = L_mult(terms[0].man, psErrorTerm[4].man); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
927 swShift = norm_s(extract_h(L_Temp)); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
928 terms[0].sh = add(terms[0].sh, swShift); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
929 terms[0].man = round(L_shl(L_Temp, swShift)); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
930 terms[0].sh = add(terms[0].sh, psErrorTerm[4].sh); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
931 terms[0].sh = add(terms[0].sh, psErrorTerm[5].sh); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
932 /* Init. siNorm */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
933 siNorm = terms[0].sh; |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
934 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
935 /* Compute Rpp*Rcc(0,1)*Rcc(0,1) */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
936 /* ----------------------------- */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
937 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
938 L_Temp = L_mult(psErrorTerm[2].man, psErrorTerm[2].man); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
939 swShift = norm_s(extract_h(L_Temp)); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
940 terms[1].sh = add(psErrorTerm[2].sh, swShift); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
941 terms[1].man = round(L_shl(L_Temp, swShift)); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
942 L_Temp = L_mult(terms[1].man, psErrorTerm[5].man); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
943 swShift = norm_s(extract_h(L_Temp)); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
944 terms[1].sh = add(terms[1].sh, swShift); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
945 terms[1].man = round(L_shl(L_Temp, swShift)); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
946 terms[1].sh = add(terms[1].sh, psErrorTerm[2].sh); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
947 terms[1].sh = add(terms[1].sh, psErrorTerm[5].sh); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
948 if (sub(terms[1].sh, siNorm) < 0) |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
949 siNorm = terms[1].sh; |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
950 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
951 /* Compute Rcc(0,0)*Rpc(1)*Rpc(1) */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
952 /* ------------------------------ */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
953 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
954 L_Temp = L_mult(psErrorTerm[1].man, psErrorTerm[1].man); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
955 swShift = norm_s(extract_h(L_Temp)); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
956 terms[2].sh = add(psErrorTerm[1].sh, swShift); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
957 terms[2].man = round(L_shl(L_Temp, swShift)); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
958 L_Temp = L_mult(terms[2].man, psErrorTerm[3].man); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
959 swShift = norm_s(extract_h(L_Temp)); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
960 terms[2].sh = add(terms[2].sh, swShift); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
961 terms[2].man = round(L_shl(L_Temp, swShift)); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
962 terms[2].sh = add(terms[2].sh, psErrorTerm[1].sh); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
963 terms[2].sh = add(terms[2].sh, psErrorTerm[3].sh); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
964 if (sub(terms[2].sh, siNorm) < 0) |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
965 siNorm = terms[2].sh; |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
966 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
967 /* Compute 2*Rcc(0,1)*Rpc(0)*Rpc(1) */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
968 /* -------------------------------- */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
969 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
970 L_Temp = L_mult(psErrorTerm[0].man, psErrorTerm[1].man); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
971 swShift = norm_s(extract_h(L_Temp)); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
972 terms[3].sh = add(psErrorTerm[0].sh, swShift); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
973 terms[3].man = round(L_shl(L_Temp, swShift)); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
974 L_Temp = L_mult(terms[3].man, psErrorTerm[2].man); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
975 swShift = norm_s(extract_h(L_Temp)); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
976 terms[3].sh = add(terms[3].sh, swShift); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
977 terms[3].man = round(L_shl(L_Temp, swShift)); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
978 terms[3].sh = add(terms[3].sh, psErrorTerm[1].sh); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
979 terms[3].sh = add(terms[3].sh, psErrorTerm[2].sh); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
980 terms[3].sh = sub(terms[3].sh, 1); /* Multiply by 2 */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
981 if (sub(terms[3].sh, siNorm) < 0) |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
982 siNorm = terms[3].sh; |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
983 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
984 /* Compute Rcc(1,1)*Rpc(0)*Rpc(0) */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
985 /* ------------------------------ */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
986 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
987 L_Temp = L_mult(psErrorTerm[0].man, psErrorTerm[4].man); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
988 swShift = norm_s(extract_h(L_Temp)); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
989 terms[4].sh = add(psErrorTerm[0].sh, swShift); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
990 terms[4].man = round(L_shl(L_Temp, swShift)); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
991 L_Temp = L_mult(terms[4].man, psErrorTerm[0].man); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
992 swShift = norm_s(extract_h(L_Temp)); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
993 terms[4].sh = add(terms[4].sh, swShift); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
994 terms[4].man = round(L_shl(L_Temp, swShift)); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
995 terms[4].sh = add(terms[4].sh, psErrorTerm[0].sh); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
996 terms[4].sh = add(terms[4].sh, psErrorTerm[4].sh); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
997 if (sub(terms[4].sh, siNorm) < 0) |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
998 siNorm = terms[4].sh; |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
999 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1000 /* Normalize all terms to same shift count */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1001 /* --------------------------------------- */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1002 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1003 for (i = 0; i < 5; i++) |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1004 { |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1005 L_Temp = L_deposit_h(terms[i].man); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1006 siNormShift = sub(terms[i].sh, siNorm); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1007 if (siNormShift > 0) |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1008 { |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1009 L_Temp = L_shr(L_Temp, siNormShift); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1010 } |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1011 terms[i].man = round(L_Temp); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1012 } |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1013 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1014 /* Calculate numerator */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1015 /* ------------------- */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1016 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1017 /* Rpp*Rcc(0,0)*Rcc(1,1) - Rpp*Rcc(0,1)*Rcc(0,1) */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1018 /* --------------------------------------------- */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1019 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1020 swNum = sub(terms[0].man, terms[1].man); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1021 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1022 /* Skip gain tweak if numerator =< 0 */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1023 /* --------------------------------- */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1024 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1025 if (swNum <= 0) |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1026 return; |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1027 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1028 /* Calculate denominator */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1029 /* --------------------- */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1030 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1031 /* Rcc(0,0)*Rpc(1)*Rpc(1)-2*Rcc(0,1)*Rpc(0)*Rpc(1)+Rcc(1,1)*Rpc(0)*Rpc(0) */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1032 /*----------------------------------------------------------------------*/ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1033 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1034 swDenom = sub(terms[2].man, terms[3].man); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1035 swDenom = add(swDenom, terms[4].man); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1036 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1037 /* Skip gain tweak if denominator =< 0 */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1038 /* ----------------------------------- */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1039 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1040 if (swDenom <= 0) |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1041 return; |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1042 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1043 /* Compare numerator to denominator, skip if tweak =< 1 */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1044 /* ---------------------------------------------------- */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1045 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1046 swTemp = sub(swNum, swDenom); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1047 if (swTemp <= 0) |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1048 return; |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1049 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1050 /* Normalize and do divide */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1051 /* ----------------------- */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1052 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1053 swShift = norm_s(swNum); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1054 siNormShift = sub(swShift, 1); /* Multiply by 2 */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1055 swNum = shl(swNum, swShift); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1056 swNum = shr(swNum, 1); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1057 swShift = norm_s(swDenom); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1058 siNormShift = sub(siNormShift, swShift); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1059 swDenom = shl(swDenom, swShift); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1060 swTemp = divide_s(swNum, swDenom); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1061 swShift = norm_s(swTemp); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1062 siNormShift = add(siNormShift, swShift); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1063 L_Temp = L_shl(L_deposit_h(swTemp), swShift); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1064 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1065 /* Calculate square root */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1066 /* --------------------- */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1067 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1068 swTemp = sqroot(L_Temp); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1069 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1070 /* If odd no. of shifts compensate by sqrt(0.5) */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1071 /* -------------------------------------------- */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1072 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1073 if (siNormShift & 1) |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1074 { |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1075 L_Temp = L_mult(0x5a82, swTemp); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1076 siNormShift = sub(siNormShift, 1); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1077 } |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1078 else |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1079 L_Temp = L_deposit_h(swTemp); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1080 siNormShift = shr(siNormShift, 1); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1081 swShift = norm_s(extract_h(L_Temp)); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1082 siNormShift = add(siNormShift, swShift); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1083 swGainTweak = round(L_shl(L_Temp, swShift)); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1084 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1085 /* If exponent > -1, skip gain tweak */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1086 /* --------------------------------- */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1087 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1088 if (add(1, siNormShift) > 0) |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1089 return; |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1090 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1091 /* If exponent < -1, limit gain tweak to GTWEAKMAX */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1092 /* ----------------------------------------------- */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1093 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1094 if (add(1, siNormShift) < 0) |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1095 swGainTweak = GTWEAKMAX; |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1096 else |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1097 { |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1098 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1099 /* If exponent = -1, compare to GTWEAKMAX */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1100 /* -------------------------------------- */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1101 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1102 if (sub(GTWEAKMAX, swGainTweak) < 0) |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1103 swGainTweak = GTWEAKMAX; |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1104 } |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1105 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1106 /* Multiply gain tweak factor on A and B error terms */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1107 /* ------------------------------------------------- */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1108 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1109 L_Temp = L_mult(swGainTweak, psErrorTerm[0].man); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1110 swShift = norm_s(extract_h(L_Temp)); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1111 psErrorTerm[0].sh = add(psErrorTerm[0].sh, swShift); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1112 psErrorTerm[0].sh = sub(psErrorTerm[0].sh, 1); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1113 psErrorTerm[0].man = round(L_shl(L_Temp, swShift)); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1114 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1115 L_Temp = L_mult(swGainTweak, psErrorTerm[1].man); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1116 swShift = norm_s(extract_h(L_Temp)); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1117 psErrorTerm[1].sh = add(psErrorTerm[1].sh, swShift); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1118 psErrorTerm[1].sh = sub(psErrorTerm[1].sh, 1); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1119 psErrorTerm[1].man = round(L_shl(L_Temp, swShift)); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1120 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1121 } |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1122 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1123 /*************************************************************************** |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1124 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1125 * FUNCTION NAME: hnwFilt |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1126 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1127 * PURPOSE: |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1128 * Performs the filtering operation for harmonic noise weighting. |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1129 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1130 * INPUTS: |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1131 * pswInSample[0:39] - array of input speech signal, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1132 * pswInSample points to the "oldest" sample of the |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1133 * current subframe to be hnw filtered, S_LEN samples |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1134 * will be stored in this array, this data is not |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1135 * explicitly modified. |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1136 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1137 * pswState[0:183] - array of state of samples, the most |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1138 * recent sample is the tail of the state buffer, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1139 * used only for full- state filtering, this data is |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1140 * not modified |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1141 * pswInCoef[0:5] - array of unmodified filter coefficients |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1142 * iStateOffset - address offset from a sample in the subframe back |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1143 * to the oldest element of the state used in the interpolating |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1144 * filter for that sample. Although the subframe samples and |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1145 * state information can come from different buffers, this |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1146 * offset represents the case in which the state and sample |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1147 * information are in the same buffer |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1148 * swZeroState - indicate if the interpolating filter should be |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1149 * "zero-state" filtering or "full-state" filtering: |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1150 * 0 ==> zero-state filtering |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1151 * !0 ==> full-state filtering |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1152 * iNumSamples - the number of samples that are to be filtered, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1153 * required to be less than or equal to S_LEN in order to |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1154 * correctly match speech samples with sample states for the |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1155 * filtering procedure |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1156 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1157 * OUTPUTS: |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1158 * pswOutSample[0:39] - array of output filtered speech signal, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1159 * pswOutSample points to the "oldest" sample location, S_LEN |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1160 * filtered samples will be stored at the buffer associated with |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1161 * this array, can implicitly overwrite input samples with |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1162 * with filtered samples by setting pswOutSample = pswInSample |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1163 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1164 * RETURN VALUE: |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1165 * none |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1166 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1167 * IMPLEMENTATION: |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1168 * The harmonic noise weighting filter is implemented in reverse |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1169 * temporal order, from most recent input sample backwards through |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1170 * the input sample array. The procedure follows the equation: |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1171 * x(n) = x(n) - PW_COEF*x(n - lag) |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1172 * where the PW_COEF is the pitch weighting for the current |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1173 * subframe and lag is the full-resolution lag for the current |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1174 * subframe. x(n - lag) is found by implementing a CG_INT_MACS- |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1175 * order FIR interpolating filter |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1176 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1177 * Harmonic noise weighting is discussed in secion 5.5. |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1178 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1179 * REFERENCE: Sub-clause 4.1.9 of GSM Recommendation 06.20 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1180 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1181 * KEYWORDS: T_SUB, LAG, HNW_FILT, PW_COEF, CG_INT_MACS, S_LEN, LSMAX |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1182 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1183 **************************************************************************/ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1184 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1185 void hnwFilt(Shortword pswInSample[], |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1186 Shortword pswOutSample[], |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1187 Shortword pswState[], |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1188 Shortword pswInCoef[], |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1189 int iStateOffset, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1190 Shortword swZeroState, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1191 int iNumSamples) |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1192 { |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1193 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1194 /*_________________________________________________________________________ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1195 | | |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1196 | Automatic Variables | |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1197 |_________________________________________________________________________| |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1198 */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1199 Longword L_temp; |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1200 int i, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1201 j; |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1202 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1203 int iStatIndx = S_LEN - 1 + iStateOffset; |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1204 int iStatIndx1 = S_LEN + iStateOffset; |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1205 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1206 /*_________________________________________________________________________ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1207 | | |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1208 | Executable Code | |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1209 |_________________________________________________________________________| |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1210 */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1211 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1212 if (swZeroState == 0) |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1213 { |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1214 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1215 /* zero state response assumes input and output arrays are the same */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1216 /*------------------------------------------------------------------*/ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1217 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1218 for (i = 0; i < iNumSamples; i++) |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1219 { |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1220 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1221 /* get input with rounding */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1222 /*-------------------------*/ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1223 L_temp = L_mac((long) 16384, pswInSample[S_LEN - i - 1], 0x4000); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1224 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1225 for (j = 5; (j >= 0) && (iStatIndx - i + j >= 0); j--) |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1226 /* evaluate taps 1 - 6 that point to input */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1227 /*-----------------------------------------*/ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1228 L_temp = L_mac(L_temp, pswInSample[iStatIndx - i + j], pswInCoef[j]); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1229 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1230 pswOutSample[S_LEN - 1 - i] = extract_h(L_shl(L_temp, 1)); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1231 } |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1232 } |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1233 else |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1234 { |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1235 for (i = 0; i < iNumSamples; i++) |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1236 { |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1237 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1238 /* get input with rounding */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1239 /*-------------------------*/ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1240 L_temp = L_mac((long) 16384, pswInSample[S_LEN - i - 1], 0x4000); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1241 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1242 for (j = 5; (j >= 0) && (iStatIndx - i + j >= 0); j--) |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1243 /* evaluate taps 1 - 6 that point to input */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1244 /*-----------------------------------------*/ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1245 L_temp = L_mac(L_temp, pswInSample[iStatIndx - i + j], pswInCoef[j]); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1246 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1247 for (; (j >= 0); j--) |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1248 /* evaluate taps 1 - 6 that point to state */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1249 /*----------------------------------------*/ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1250 L_temp = L_mac(L_temp, pswState[iStatIndx1 - i + j], pswInCoef[j]); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1251 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1252 pswOutSample[S_LEN - 1 - i] = extract_h(L_shl(L_temp, 1)); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1253 } |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1254 } |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1255 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1256 } |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1257 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1258 /*************************************************************************** |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1259 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1260 * FUNCTION NAME: sfrmAnalysis |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1261 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1262 * PURPOSE: |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1263 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1264 * Determines the synthetic excitation for a subframe. |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1265 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1266 * INPUTS: |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1267 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1268 * pswWSpeech |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1269 * Input weighted speech vector to be matched. |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1270 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1271 * swVoicingMode |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1272 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1273 * Voicing mode 0,1,2 or 3. 0 is unvoiced. A |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1274 * frame parameter. |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1275 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1276 * snsSqrtRs |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1277 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1278 * Normalized estimate of the excitation energy |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1279 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1280 * pswHCoefs |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1281 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1282 * Coefficientss used in weighted synthesis filter, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1283 * H(z), (a negated version is used). pswHCoefs[0] |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1284 * is t=-1 tap, pswHCoefs[9] is t=-10 tap. |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1285 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1286 * pswLagList |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1287 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1288 * List of lags to be searched in the long-term |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1289 * predictor, determined by the open-loop lag search. |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1290 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1291 * siNumLags |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1292 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1293 * Number of lags in pswLagList. |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1294 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1295 * swPitch |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1296 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1297 * Fundamental pitch value to be used in harmonic- |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1298 * noise-weighting, actualPitch*OS_FCTR. |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1299 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1300 * swHNWCoef |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1301 * Coefficient of the harmonic-noise-weighting filter. |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1302 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1303 * ppsrCGIntFilt[0:5][0:5] |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1304 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1305 * polyphase interpolation filter, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1306 * ppsrCGIntFilt[iTap][iPhase], OS_FCTR phases, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1307 * CG_INT_MACS taps per phase. Used to construct |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1308 * sequences delayed by fractional lags for Harmonic- |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1309 * Noise-Weighting. |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1310 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1311 * pppsrUvCodeVec[0:1][0:6][0:39] |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1312 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1313 * unvoiced codebooks: |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1314 * pppsrUvCodeVec[codeBook][vectorNumber][time] |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1315 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1316 * pppsrVcdCodeVec[0][0:8][0:39] |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1317 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1318 * voiced codebook: |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1319 * pppsrVcdCodeVect[codebook(=0)][vectorNumber][time] |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1320 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1321 * swSP |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1322 * speech flag (DTX mode) |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1323 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1324 * OUTPUTS: |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1325 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1326 * psiLagCode |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1327 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1328 * Lag code: frame- or delta-, or zero if unvoiced. |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1329 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1330 * psiVSCode1 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1331 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1332 * First vector-sum codebook code. |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1333 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1334 * psiVSCode2 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1335 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1336 * Second vector-sum codebook code, or zero if voiced. |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1337 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1338 * psiGsp0Code |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1339 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1340 * Gain quantizer code. |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1341 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1342 * DESCRIPTION: |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1343 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1344 * sfrmAnalysis() is the calling function for the subframe analysis |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1345 * functions. All subframe based processing is done by it and its |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1346 * daughter functions. All functions in this file are called by |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1347 * sfrmAnalysis() or one of its daughter functions. As can be seen |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1348 * above, this routine will select the LTP lag, the VSELP |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1349 * codevector(s) and the GSP0 codeword. It is called by |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1350 * speechEncoder(). |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1351 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1352 * The subframe processing can follow one of two paths depending on |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1353 * whether the frame is voiced or unvoiced. These two paths are now |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1354 * described. |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1355 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1356 * First the zero input response of H(z) is calculated (lpcZiIir()); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1357 * then subtracted from the weighted speech (W(z)). The outcome, p(n) |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1358 * or pswWSVec[], will be the vector matched by the first excitation |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1359 * vector (either adaptive or first VSELP codevector). The p(n) |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1360 * vector is scaled to prevent overflow. |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1361 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1362 * If the frame is voiced, the closed loop lag search (closedLoop()) |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1363 * is performed. An adaptive codevector lag is selected. Using the |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1364 * open loop "pitch" value, the harmonic noise weighting |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1365 * coefficients are obtained. The adaptive codevector is |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1366 * reconstructed (fp_ex()), and weighted through the (zero state) |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1367 * spectral (lpcZsIir()) and harmonic noise weighting filters |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1368 * (hnwFilt()). |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1369 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1370 * The basis vectors are also filtered through the weighting |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1371 * filters. If the frame is unvoiced, there is no spectral noise |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1372 * weighting. |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1373 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1374 * If voiced the VSELP basis vectors are decorrelated (decorr()) |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1375 * from the selected adaptive (LTP) codevector, and the VSELP |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1376 * codevector search is initiated (v_srch()). |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1377 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1378 * If unvoiced, the first VSELP codevector search is performed |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1379 * (without any decorrelation). After a vector from the first VSELP |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1380 * codebook has been selected, the second set of basis vectors are |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1381 * decorrelated from the selected vector. |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1382 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1383 * Once all the excitation vectors have been selected, the gain |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1384 * quantizer is called, g_quant_vl(). |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1385 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1386 * Finally, once all subframe parameters have been found, the |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1387 * selected excitation is scaled according to GSP0 (scaleExcite()), |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1388 * and the composite excitation is entered into the long term |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1389 * predictor history. The final excitation is also used to update |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1390 * H(z) and C(z). |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1391 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1392 * REFERENCE: Sub-clauses 4.1.8.5, 4.1.9 - 4.1.12 of GSM |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1393 * Recommendation 06.20 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1394 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1395 * Keywords: codewords, lag, codevectors, gsp0, decoding, analysis, t_sub |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1396 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1397 **************************************************************************/ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1398 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1399 void sfrmAnalysis(Shortword *pswWSpeech, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1400 Shortword swVoicingMode, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1401 struct NormSw snsSqrtRs, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1402 Shortword *pswHCoefs, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1403 Shortword *pswLagList, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1404 short siNumLags, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1405 Shortword swPitch, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1406 Shortword swHNWCoef, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1407 short *psiLagCode, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1408 short *psiVSCode1, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1409 short *psiVSCode2, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1410 short *psiGsp0Code, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1411 Shortword swSP) |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1412 { |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1413 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1414 /*_________________________________________________________________________ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1415 | | |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1416 | Static Variables | |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1417 |_________________________________________________________________________| |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1418 */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1419 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1420 static short siPrevLagCode; |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1421 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1422 /*_________________________________________________________________________ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1423 | | |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1424 | Automatic Variables | |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1425 |_________________________________________________________________________| |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1426 */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1427 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1428 short i, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1429 j, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1430 siCode, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1431 siIntPitch, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1432 siRemainder; |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1433 short siHnwOffset, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1434 siHnwNum, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1435 siNumBasisVecs; |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1436 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1437 Shortword swLag, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1438 swPnEnergy, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1439 swPnShift, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1440 swSampleA; |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1441 Shortword swLtpShift; |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1442 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1443 Longword L_PnEnergy; |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1444 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1445 struct NormSw snsRs00, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1446 snsRs11, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1447 snsRs22; |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1448 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1449 Shortword pswWSVec[S_LEN], |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1450 pswTempVec[S_LEN]; |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1451 Shortword pswPVec[S_LEN], |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1452 pswWPVec[S_LEN]; |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1453 Shortword ppswVselpEx[2][S_LEN], |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1454 ppswWVselpEx[2][S_LEN]; |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1455 Shortword pswWBasisVecs[9 * S_LEN], |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1456 pswBitArray[9]; |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1457 Shortword pswHNWCoefs[CG_INT_MACS]; |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1458 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1459 Shortword *pswLtpStateOut; |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1460 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1461 /*_________________________________________________________________________ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1462 | | |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1463 | Executable Code | |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1464 |_________________________________________________________________________| |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1465 */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1466 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1467 pswLtpStateOut = pswLtpStateBase + LTP_LEN; |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1468 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1469 if (swSP == 1) /* DTX mode */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1470 { /* DTX mode */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1471 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1472 /* if not in CNI mode */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1473 /*--------------------*/ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1474 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1475 /* Get the zero-input response of H(z) */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1476 /*-------------------------------------*/ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1477 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1478 lpcZiIir(pswHCoefs, pswHState, pswTempVec); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1479 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1480 /* Subtract the zero-input response of H(z) from W(z)-weighted speech. */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1481 /* The result is the vector to match for the adaptive codebook (long- */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1482 /* term-predictor) search in voiced modes, or the vector to match for */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1483 /* all synthetic excitation searches in unvoiced mode. */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1484 /*---------------------------------------------------------------------*/ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1485 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1486 for (i = 0; i < S_LEN; i++) |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1487 { |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1488 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1489 pswWSVec[i] = sub(pswWSpeech[i], pswTempVec[i]); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1490 } |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1491 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1492 /* scale the weighted speech vector (p[n]) s.t. its energy is strictly */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1493 /* less than 1.0 */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1494 /*---------------------------------------------------------------------*/ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1495 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1496 swSampleA = shr(pswWSVec[0], 2); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1497 L_PnEnergy = L_mac(0x001dff4cL, swSampleA, swSampleA); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1498 for (i = 1; i < S_LEN; i++) |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1499 { |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1500 swSampleA = shr(pswWSVec[i], 2); /* reduces energy by 16 */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1501 L_PnEnergy = L_mac(L_PnEnergy, swSampleA, swSampleA); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1502 } |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1503 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1504 swPnEnergy = round(L_PnEnergy); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1505 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1506 if (sub(swPnEnergy, 0x7ff) <= 0) |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1507 { /* E = [0..0x7ff] */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1508 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1509 swPnShift = 0; |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1510 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1511 } |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1512 else |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1513 { |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1514 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1515 if (sub(swPnEnergy, 0x1fff) <= 0) |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1516 { /* E = (0x7ff.. 0x1fff] */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1517 swPnShift = 1; |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1518 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1519 } |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1520 else |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1521 { |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1522 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1523 swPnShift = 2; /* E = (0x1fff..0x7fff] */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1524 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1525 } |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1526 } |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1527 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1528 /* shift pswWSVect down by the shift factor */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1529 /*------------------------------------------*/ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1530 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1531 for (i = 0; i < S_LEN; i++) |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1532 pswWSVec[i] = shr(pswWSVec[i], swPnShift); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1533 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1534 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1535 if (swVoicingMode > 0) |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1536 { |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1537 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1538 /* Do restricted adaptive codebook (long-term-predictor) search: */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1539 /* the search is restricted to the lags passed in from the */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1540 /* open-loop lag search */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1541 /*---------------------------------------------------------------*/ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1542 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1543 siCode = closedLoopLagSearch(pswLagList, siNumLags, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1544 pswLtpStateBase, pswHCoefs, pswWSVec, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1545 &swLag, &swLtpShift); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1546 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1547 /* Construct frame-lag code if this is the first subframe, */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1548 /* or delta-lag code if it is not the first subframe */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1549 /*---------------------------------------------------------*/ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1550 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1551 if (swVoicingMode > 0) |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1552 { |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1553 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1554 if (giSfrmCnt == 0) |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1555 { |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1556 siPrevLagCode = siCode; |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1557 *psiLagCode = siCode; |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1558 } |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1559 else |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1560 { |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1561 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1562 *psiLagCode = add(sub(siCode, siPrevLagCode), DELTA_LEVELS / 2); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1563 siPrevLagCode = siCode; |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1564 } |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1565 } |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1566 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1567 /* From the value of the fundamental pitch obtained in the open-loop */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1568 /* lag search, get the correct phase of the interpolating filter, */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1569 /* and scale the coefficients by the Harmonic-Noise-Weighting */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1570 /* coefficient. The result is the interpolating coefficients scaled */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1571 /* by the HNW coefficient. These will be used in all C(z) filtering */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1572 /*-------------------------------------------------------------------*/ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1573 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1574 get_ipjj(swPitch, &siIntPitch, &siRemainder); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1575 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1576 for (i = 0; i < CG_INT_MACS; i++) |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1577 { |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1578 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1579 pswHNWCoefs[i] = mult_r(negate(ppsrCGIntFilt[i][siRemainder]), |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1580 swHNWCoef); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1581 } |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1582 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1583 /* Calculate a few values which will speed up C(z) filtering: */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1584 /* "HnwOffset" is the distance in samples from the input sample of */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1585 /* the C(z) filter to the first sample tapped by the interpolating */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1586 /* filter. "HnwNum" is the number of samples which need to be */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1587 /* filtered by C(z) in the zero-state case. */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1588 /*-----------------------------------------------------------------*/ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1589 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1590 siHnwOffset = sub(-CG_INT_MACS / 2, siIntPitch); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1591 siHnwNum = sub(S_LEN + CG_INT_MACS / 2 - 1, siIntPitch); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1592 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1593 /* Perform C(z) filter on W(z)-weighted speech, get zero-input */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1594 /* response of H(z)C(z) combo, subtract zero-input response */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1595 /* of H(z)C(z) from W(z)C(z)-weighted speech. The result is */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1596 /* the vector to match for the rest of the synthetic */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1597 /* excitation searches in the voiced modes */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1598 /*-------------------------------------------------------------*/ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1599 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1600 hnwFilt(pswWSpeech, pswWSVec, &pswWSpeech[-1], pswHNWCoefs, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1601 siHnwOffset, 1, S_LEN); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1602 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1603 hnwFilt(pswTempVec, pswTempVec, &pswHNWState[HNW_BUFF_LEN - 1], |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1604 pswHNWCoefs, siHnwOffset, 1, S_LEN); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1605 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1606 for (i = 0; i < S_LEN; i++) |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1607 { |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1608 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1609 pswWSVec[i] = shr(sub(pswWSVec[i], pswTempVec[i]), swPnShift); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1610 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1611 } |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1612 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1613 /* Recontruct adaptive codebook (long-term-predictor) vector, */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1614 /* weight it through H(z) and C(z), each with zero state */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1615 /*------------------------------------------------------------*/ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1616 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1617 fp_ex(swLag, pswLtpStateOut); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1618 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1619 for (i = 0; i < S_LEN; i++) |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1620 pswPVec[i] = pswLtpStateOut[i]; |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1621 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1622 lpcZsIir(pswPVec, pswHCoefs, pswWPVec); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1623 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1624 if (siHnwNum > 0) |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1625 { |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1626 hnwFilt(pswWPVec, pswWPVec, NULL, pswHNWCoefs, siHnwOffset, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1627 0, siHnwNum); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1628 } |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1629 for (i = 0; i < S_LEN; i++) |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1630 { |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1631 pswPVec[i] = shr(pswPVec[i], swLtpShift); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1632 pswWPVec[i] = shr(pswWPVec[i], swLtpShift); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1633 } |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1634 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1635 } |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1636 else |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1637 { |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1638 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1639 /* Unvoiced mode: clear all voiced variables */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1640 /*-------------------------------------------*/ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1641 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1642 swLag = 0; |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1643 *psiLagCode = 0; |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1644 siHnwNum = 0; |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1645 } |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1646 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1647 /* "NumBasisVecs" will be the number of basis vectors in */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1648 /* the vector-sum codebook(s) */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1649 /*-------------------------------------------------------*/ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1650 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1651 if (swVoicingMode > 0) |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1652 siNumBasisVecs = C_BITS_V; |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1653 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1654 else |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1655 siNumBasisVecs = C_BITS_UV; |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1656 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1657 /* Filter the basis vectors through H(z) with zero state, and if */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1658 /* voiced, through C(z) with zero state */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1659 /*----------------------------------------------------------------*/ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1660 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1661 for (i = 0; i < siNumBasisVecs; i++) |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1662 { |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1663 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1664 if (swVoicingMode > 0) |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1665 { |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1666 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1667 lpcZsIir((Shortword *) pppsrVcdCodeVec[0][i], pswHCoefs, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1668 &pswWBasisVecs[i * S_LEN]); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1669 } |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1670 else |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1671 { |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1672 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1673 lpcZsIir((Shortword *) pppsrUvCodeVec[0][i], pswHCoefs, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1674 &pswWBasisVecs[i * S_LEN]); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1675 } |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1676 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1677 if (siHnwNum > 0) |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1678 { |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1679 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1680 hnwFilt(&pswWBasisVecs[i * S_LEN], &pswWBasisVecs[i * S_LEN], |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1681 NULL, pswHNWCoefs, siHnwOffset, 0, siHnwNum); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1682 } |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1683 } |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1684 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1685 /* If voiced, make the H(z)C(z)-weighted basis vectors orthogonal to */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1686 /* the H(z)C(z)-weighted adaptive codebook vector */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1687 /*-------------------------------------------------------------------*/ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1688 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1689 if (swVoicingMode > 0) |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1690 decorr(siNumBasisVecs, pswWPVec, pswWBasisVecs); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1691 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1692 /* Do the vector-sum codebook search on the H(z)C(z)-weighted, */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1693 /* orthogonalized basis vectors */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1694 /*-------------------------------------------------------------*/ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1695 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1696 *psiVSCode1 = v_srch(pswWSVec, pswWBasisVecs, siNumBasisVecs); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1697 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1698 /* Construct the chosen vector-sum codebook vector from basis vectors */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1699 /*--------------------------------------------------------------------*/ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1700 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1701 b_con(*psiVSCode1, siNumBasisVecs, pswBitArray); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1702 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1703 if (swVoicingMode > 0) |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1704 v_con((Shortword *) pppsrVcdCodeVec[0][0], ppswVselpEx[0], pswBitArray, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1705 siNumBasisVecs); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1706 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1707 else |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1708 v_con((Shortword *) pppsrUvCodeVec[0][0], ppswVselpEx[0], pswBitArray, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1709 siNumBasisVecs); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1710 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1711 if (swVoicingMode == 0) |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1712 { |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1713 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1714 /* Construct the H(z)-weighted 1st-codebook vector */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1715 /*-------------------------------------------------*/ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1716 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1717 v_con(pswWBasisVecs, ppswWVselpEx[0], pswBitArray, siNumBasisVecs); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1718 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1719 /* Filter the 2nd basis vector set through H(z) with zero state */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1720 /*--------------------------------------------------------------*/ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1721 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1722 for (i = 0; i < siNumBasisVecs; i++) |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1723 { |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1724 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1725 lpcZsIir((Shortword *) pppsrUvCodeVec[1][i], pswHCoefs, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1726 &pswWBasisVecs[i * S_LEN]); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1727 } |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1728 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1729 /* Make the 2nd set of H(z)-weighted basis vectors orthogonal to the */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1730 /* H(z)-weighted 1st-codebook vector */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1731 /*-------------------------------------------------------------------*/ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1732 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1733 decorr(siNumBasisVecs, ppswWVselpEx[0], pswWBasisVecs); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1734 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1735 /* Do the vector-sum codebook search on the H(z)-weighted, */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1736 /* orthogonalized, 2nd basis vector set */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1737 /*---------------------------------------------------------*/ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1738 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1739 *psiVSCode2 = v_srch(pswWSVec, pswWBasisVecs, siNumBasisVecs); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1740 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1741 /* Construct the chosen vector-sum codebook vector from the 2nd set */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1742 /* of basis vectors */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1743 /*------------------------------------------------------------------*/ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1744 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1745 b_con(*psiVSCode2, siNumBasisVecs, pswBitArray); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1746 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1747 v_con((Shortword *) pppsrUvCodeVec[1][0], ppswVselpEx[1], pswBitArray, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1748 siNumBasisVecs); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1749 } |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1750 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1751 else |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1752 *psiVSCode2 = 0; |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1753 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1754 /* Filter the 1st-codebook vector through H(z) (also through C(z) */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1755 /* if appropriate) */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1756 /*----------------------------------------------------------------*/ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1757 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1758 lpcZsIir(ppswVselpEx[0], pswHCoefs, ppswWVselpEx[0]); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1759 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1760 if (siHnwNum > 0) |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1761 { |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1762 hnwFilt(ppswWVselpEx[0], ppswWVselpEx[0], NULL, pswHNWCoefs, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1763 siHnwOffset, 0, siHnwNum); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1764 } |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1765 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1766 if (swVoicingMode == 0) |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1767 { |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1768 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1769 /* Filter the 2nd-codebook vector through H(z) */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1770 /*---------------------------------------------*/ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1771 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1772 lpcZsIir(ppswVselpEx[1], pswHCoefs, ppswWVselpEx[1]); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1773 } |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1774 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1775 /* Get the square-root of the ratio of residual energy to */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1776 /* excitation vector energy for each of the excitation sources */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1777 /*-------------------------------------------------------------*/ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1778 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1779 if (swVoicingMode > 0) |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1780 { |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1781 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1782 rs_rrNs(pswPVec, snsSqrtRs, &snsRs00); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1783 } |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1784 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1785 rs_rrNs(ppswVselpEx[0], snsSqrtRs, &snsRs11); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1786 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1787 if (swVoicingMode == 0) |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1788 { |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1789 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1790 rs_rrNs(ppswVselpEx[1], snsSqrtRs, &snsRs22); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1791 } |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1792 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1793 /* Determine the vector-quantized gains for each of the excitations */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1794 /*------------------------------------------------------------------*/ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1795 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1796 *psiGsp0Code = g_quant_vl(swVoicingMode, pswWSVec, swPnShift, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1797 pswWPVec, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1798 ppswWVselpEx[0], ppswWVselpEx[1], snsRs00, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1799 snsRs11, snsRs22); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1800 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1801 } /* DTX mode */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1802 else /* DTX mode */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1803 { /* DTX mode */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1804 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1805 /* swSP == 0, currently in comfort noise insertion mode */ /* DTX mode */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1806 /*------------------------------------------------------*/ /* DTX mode */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1807 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1808 /* generate the random codevector */ /* DTX mode */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1809 siNumBasisVecs = C_BITS_UV; /* DTX mode */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1810 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1811 /* build codevector 1 */ /* DTX mode */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1812 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1813 b_con(*psiVSCode1, siNumBasisVecs, pswBitArray); /* DTX mode */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1814 v_con((Shortword *) pppsrUvCodeVec[0][0], ppswVselpEx[0], /* DTX mode */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1815 pswBitArray, siNumBasisVecs); /* DTX mode */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1816 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1817 /* build codevector 2 */ /* DTX mode */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1818 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1819 b_con(*psiVSCode2, siNumBasisVecs, pswBitArray); /* DTX mode */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1820 v_con((Shortword *) pppsrUvCodeVec[1][0], ppswVselpEx[1], /* DTX mode */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1821 pswBitArray, siNumBasisVecs); /* DTX mode */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1822 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1823 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1824 /* get rs_rr for the two vectors */ /* DTX mode */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1825 rs_rrNs(ppswVselpEx[0], snsSqrtRs, &snsRs11); /* DTX mode */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1826 rs_rrNs(ppswVselpEx[1], snsSqrtRs, &snsRs22); /* DTX mode */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1827 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1828 } /* DTX mode */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1829 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1830 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1831 /* Scale the excitations, each by its gain, and add them. Put the */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1832 /* result at the end of the adaptive codebook (long-term-predictor */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1833 /* state) */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1834 /*-----------------------------------------------------------------*/ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1835 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1836 if (swVoicingMode == 0) |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1837 { |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1838 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1839 /* unvoiced */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1840 /* -------- */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1841 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1842 scaleExcite(ppswVselpEx[0], |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1843 pppsrGsp0[swVoicingMode][*psiGsp0Code][0], |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1844 snsRs11, ppswVselpEx[0]); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1845 scaleExcite(ppswVselpEx[1], |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1846 pppsrGsp0[swVoicingMode][*psiGsp0Code][1], |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1847 snsRs22, ppswVselpEx[1]); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1848 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1849 /* now combine the two scaled excitations */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1850 /* -------------------------------------- */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1851 for (i = 0; i < S_LEN; i++) |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1852 pswTempVec[i] = add(ppswVselpEx[0][i], ppswVselpEx[1][i]); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1853 } |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1854 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1855 else |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1856 { |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1857 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1858 /* voiced */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1859 /* ------ */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1860 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1861 scaleExcite(pswPVec, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1862 pppsrGsp0[swVoicingMode][*psiGsp0Code][0], |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1863 snsRs00, pswPVec); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1864 scaleExcite(ppswVselpEx[0], |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1865 pppsrGsp0[swVoicingMode][*psiGsp0Code][1], |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1866 snsRs11, ppswVselpEx[0]); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1867 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1868 /* now combine the two scaled excitations */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1869 /* -------------------------------------- */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1870 for (i = 0; i < S_LEN; i++) |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1871 pswTempVec[i] = add(pswPVec[i], ppswVselpEx[0][i]); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1872 } |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1873 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1874 /* Update the long-term-predictor state using the synthetic excitation */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1875 /*---------------------------------------------------------------------*/ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1876 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1877 for (i = -LTP_LEN; i < -S_LEN; i++) |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1878 pswLtpStateOut[i] = pswLtpStateOut[i + S_LEN]; |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1879 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1880 for (i = -S_LEN, j = 0; j < S_LEN; i++, j++) |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1881 pswLtpStateOut[i] = pswTempVec[j]; |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1882 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1883 /* Filter the synthetic excitation through the weighting filters, */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1884 /* H(z) and C(z), only to update filter states (Note that C(z) */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1885 /* state may be updated without filtering, since it is an FIR) */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1886 /* */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1887 /* First, perform one subframe's worth of delay on C(z) state */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1888 /*----------------------------------------------------------------*/ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1889 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1890 for (i = 0; i < HNW_BUFF_LEN - S_LEN; i++) |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1891 pswHNWState[i] = pswHNWState[i + S_LEN]; |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1892 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1893 /* Second, perform H(z) filter on excitation, output goes into */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1894 /* C(z) state */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1895 /*-------------------------------------------------------------*/ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1896 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1897 lpcIir(pswTempVec, pswHCoefs, pswHState, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1898 &pswHNWState[HNW_BUFF_LEN - S_LEN]); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1899 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1900 } /* end of sfrmAnalysis() */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1901 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1902 /*************************************************************************** |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1903 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1904 * FUNCTION NAME: v_srch |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1905 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1906 * PURPOSE: |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1907 * The purpose of this function is search a vector-sum codebook for the |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1908 * optimal vector |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1909 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1910 * INPUTS: |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1911 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1912 * pswWInput[0:S_LEN] |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1913 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1914 * the weighted input speech frame, with the zero-input |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1915 * response of H(z) subtracted |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1916 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1917 * pswWBasisVecs[0:S_LEN*siNumBasis] |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1918 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1919 * weighted, decorrelated vector-sum codebook basis |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1920 * vectors |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1921 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1922 * siNumBasis |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1923 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1924 * number of basis vectors |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1925 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1926 * OUTPUTS: |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1927 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1928 * none |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1929 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1930 * RETURN VALUE: |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1931 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1932 * sw1 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1933 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1934 * output code |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1935 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1936 * REFERENCE: Sub-clause 4.1.10.2 of GSM Recommendation 06.20 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1937 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1938 * KEYWORDS: v_srch, codebook, search |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1939 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1940 **************************************************************************/ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1941 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1942 Shortword v_srch(Shortword pswWInput[], Shortword pswWBasisVecs[], |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1943 short int siNumBasis) |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1944 { |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1945 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1946 /*_________________________________________________________________________ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1947 | | |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1948 | Local Constants | |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1949 |_________________________________________________________________________| |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1950 */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1951 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1952 #define V_ARRAY_SIZE ( 1 << (C_BITS_V-1) ) - 1 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1953 #define UN_ARRAY_SIZE ( 1 << (C_BITS_UV-1) ) - 1 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1954 #define MINUS_HALF -0x4000 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1955 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1956 /*_________________________________________________________________________ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1957 | | |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1958 | Local Static Variables | |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1959 |_________________________________________________________________________| |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1960 */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1961 static Shortword |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1962 pswUpdateIndexV[V_ARRAY_SIZE] = |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1963 { |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1964 0x00, 0x09, 0x48, 0x12, 0x00, 0x51, 0x48, 0x1b, 0x00, 0x09, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1965 0x48, 0x5a, 0x00, 0x51, 0x48, 0x24, 0x00, 0x09, 0x48, 0x12, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1966 0x00, 0x51, 0x48, 0x63, 0x00, 0x09, 0x48, 0x5a, 0x00, 0x51, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1967 0x48, 0x2d, 0x00, 0x09, 0x48, 0x12, 0x00, 0x51, 0x48, 0x1b, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1968 0x00, 0x09, 0x48, 0x5a, 0x00, 0x51, 0x48, 0x6c, 0x00, 0x09, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1969 0x48, 0x12, 0x00, 0x51, 0x48, 0x63, 0x00, 0x09, 0x48, 0x5a, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1970 0x00, 0x51, 0x48, 0x36, 0x00, 0x09, 0x48, 0x12, 0x00, 0x51, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1971 0x48, 0x1b, 0x00, 0x09, 0x48, 0x5a, 0x00, 0x51, 0x48, 0x24, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1972 0x00, 0x09, 0x48, 0x12, 0x00, 0x51, 0x48, 0x63, 0x00, 0x09, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1973 0x48, 0x5a, 0x00, 0x51, 0x48, 0x75, 0x00, 0x09, 0x48, 0x12, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1974 0x00, 0x51, 0x48, 0x1b, 0x00, 0x09, 0x48, 0x5a, 0x00, 0x51, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1975 0x48, 0x6c, 0x00, 0x09, 0x48, 0x12, 0x00, 0x51, 0x48, 0x63, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1976 0x00, 0x09, 0x48, 0x5a, 0x00, 0x51, 0x48, 0x3f, 0x00, 0x09, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1977 0x48, 0x12, 0x00, 0x51, 0x48, 0x1b, 0x00, 0x09, 0x48, 0x5a, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1978 0x00, 0x51, 0x48, 0x24, 0x00, 0x09, 0x48, 0x12, 0x00, 0x51, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1979 0x48, 0x63, 0x00, 0x09, 0x48, 0x5a, 0x00, 0x51, 0x48, 0x2d, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1980 0x00, 0x09, 0x48, 0x12, 0x00, 0x51, 0x48, 0x1b, 0x00, 0x09, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1981 0x48, 0x5a, 0x00, 0x51, 0x48, 0x6c, 0x00, 0x09, 0x48, 0x12, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1982 0x00, 0x51, 0x48, 0x63, 0x00, 0x09, 0x48, 0x5a, 0x00, 0x51, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1983 0x48, 0x7e, 0x00, 0x09, 0x48, 0x12, 0x00, 0x51, 0x48, 0x1b, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1984 0x00, 0x09, 0x48, 0x5a, 0x00, 0x51, 0x48, 0x24, 0x00, 0x09, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1985 0x48, 0x12, 0x00, 0x51, 0x48, 0x63, 0x00, 0x09, 0x48, 0x5a, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1986 0x00, 0x51, 0x48, 0x75, 0x00, 0x09, 0x48, 0x12, 0x00, 0x51, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1987 0x48, 0x1b, 0x00, 0x09, 0x48, 0x5a, 0x00, 0x51, 0x48, 0x6c, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1988 0x00, 0x09, 0x48, 0x12, 0x00, 0x51, 0x48, 0x63, 0x00, 0x09, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1989 0x48, 0x5a, 0x00, 0x51, 0x48, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1990 }, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1991 pswBitIndexV[V_ARRAY_SIZE] = |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1992 { |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1993 0x01, 0x02, 0x01, 0x03, 0x01, 0x02, 0x01, 0x04, 0x01, 0x02, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1994 0x01, 0x03, 0x01, 0x02, 0x01, 0x05, 0x01, 0x02, 0x01, 0x03, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1995 0x01, 0x02, 0x01, 0x04, 0x01, 0x02, 0x01, 0x03, 0x01, 0x02, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1996 0x01, 0x06, 0x01, 0x02, 0x01, 0x03, 0x01, 0x02, 0x01, 0x04, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1997 0x01, 0x02, 0x01, 0x03, 0x01, 0x02, 0x01, 0x05, 0x01, 0x02, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1998 0x01, 0x03, 0x01, 0x02, 0x01, 0x04, 0x01, 0x02, 0x01, 0x03, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1999 0x01, 0x02, 0x01, 0x07, 0x01, 0x02, 0x01, 0x03, 0x01, 0x02, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2000 0x01, 0x04, 0x01, 0x02, 0x01, 0x03, 0x01, 0x02, 0x01, 0x05, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2001 0x01, 0x02, 0x01, 0x03, 0x01, 0x02, 0x01, 0x04, 0x01, 0x02, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2002 0x01, 0x03, 0x01, 0x02, 0x01, 0x06, 0x01, 0x02, 0x01, 0x03, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2003 0x01, 0x02, 0x01, 0x04, 0x01, 0x02, 0x01, 0x03, 0x01, 0x02, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2004 0x01, 0x05, 0x01, 0x02, 0x01, 0x03, 0x01, 0x02, 0x01, 0x04, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2005 0x01, 0x02, 0x01, 0x03, 0x01, 0x02, 0x01, 0x00, 0x01, 0x02, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2006 0x01, 0x03, 0x01, 0x02, 0x01, 0x04, 0x01, 0x02, 0x01, 0x03, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2007 0x01, 0x02, 0x01, 0x05, 0x01, 0x02, 0x01, 0x03, 0x01, 0x02, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2008 0x01, 0x04, 0x01, 0x02, 0x01, 0x03, 0x01, 0x02, 0x01, 0x06, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2009 0x01, 0x02, 0x01, 0x03, 0x01, 0x02, 0x01, 0x04, 0x01, 0x02, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2010 0x01, 0x03, 0x01, 0x02, 0x01, 0x05, 0x01, 0x02, 0x01, 0x03, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2011 0x01, 0x02, 0x01, 0x04, 0x01, 0x02, 0x01, 0x03, 0x01, 0x02, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2012 0x01, 0x07, 0x01, 0x02, 0x01, 0x03, 0x01, 0x02, 0x01, 0x04, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2013 0x01, 0x02, 0x01, 0x03, 0x01, 0x02, 0x01, 0x05, 0x01, 0x02, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2014 0x01, 0x03, 0x01, 0x02, 0x01, 0x04, 0x01, 0x02, 0x01, 0x03, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2015 0x01, 0x02, 0x01, 0x06, 0x01, 0x02, 0x01, 0x03, 0x01, 0x02, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2016 0x01, 0x04, 0x01, 0x02, 0x01, 0x03, 0x01, 0x02, 0x01, 0x05, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2017 0x01, 0x02, 0x01, 0x03, 0x01, 0x02, 0x01, 0x04, 0x01, 0x02, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2018 0x01, 0x03, 0x01, 0x02, 0x01, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2019 }, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2020 pswModNextBitV[C_BITS_V] = |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2021 { |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2022 1, 2, 3, 4, 5, 6, 7, 0, 1, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2023 }, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2024 pswUpdateIndexUn[UN_ARRAY_SIZE] = |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2025 { |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2026 0x00, 0x07, 0x2a, 0x0e, 0x00, 0x31, 0x2a, 0x15, 0x00, 0x07, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2027 0x2a, 0x38, 0x00, 0x31, 0x2a, 0x1c, 0x00, 0x07, 0x2a, 0x0e, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2028 0x00, 0x31, 0x2a, 0x3f, 0x00, 0x07, 0x2a, 0x38, 0x00, 0x31, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2029 0x2a, 0x23, 0x00, 0x07, 0x2a, 0x0e, 0x00, 0x31, 0x2a, 0x15, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2030 0x00, 0x07, 0x2a, 0x38, 0x00, 0x31, 0x2a, 0x46, 0x00, 0x07, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2031 0x2a, 0x0e, 0x00, 0x31, 0x2a, 0x3f, 0x00, 0x07, 0x2a, 0x38, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2032 0x00, 0x31, 0x2a, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2033 }, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2034 pswBitIndexUn[UN_ARRAY_SIZE] = |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2035 { |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2036 0x01, 0x02, 0x01, 0x03, 0x01, 0x02, 0x01, 0x04, 0x01, 0x02, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2037 0x01, 0x03, 0x01, 0x02, 0x01, 0x05, 0x01, 0x02, 0x01, 0x03, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2038 0x01, 0x02, 0x01, 0x04, 0x01, 0x02, 0x01, 0x03, 0x01, 0x02, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2039 0x01, 0x00, 0x01, 0x02, 0x01, 0x03, 0x01, 0x02, 0x01, 0x04, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2040 0x01, 0x02, 0x01, 0x03, 0x01, 0x02, 0x01, 0x05, 0x01, 0x02, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2041 0x01, 0x03, 0x01, 0x02, 0x01, 0x04, 0x01, 0x02, 0x01, 0x03, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2042 0x01, 0x02, 0x01, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2043 }, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2044 pswModNextBitUV[C_BITS_UV] = |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2045 { |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2046 1, 2, 3, 4, 5, 0, 1, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2047 }; |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2048 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2049 /*_________________________________________________________________________ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2050 | | |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2051 | Automatic Variables | |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2052 |_________________________________________________________________________| |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2053 */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2054 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2055 Shortword **pppswDubD[C_BITS_V - 1], |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2056 *ppswD[C_BITS_V - 1], |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2057 pswCGUpdates[2 * C_BITS_V * (C_BITS_V - 1)], |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2058 pswDSpace[2 * C_BITS_V * (C_BITS_V - 1)], |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2059 *ppswDPSpace[C_BITS_V * (C_BITS_V - 1)], |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2060 pswBits[C_BITS_V - 1], |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2061 *pswUpdatePtr, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2062 *pswUIndex, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2063 *pswBIndex, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2064 *pswModNextBit, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2065 *psw0, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2066 *psw1, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2067 *psw2, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2068 swC0, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2069 swG0, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2070 swCC, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2071 swG, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2072 swCCMax, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2073 swGMax, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2074 sw1; |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2075 Longword pL_R[C_BITS_V], |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2076 L_R, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2077 L_MaxC, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2078 L_C0, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2079 L_D, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2080 L_G0, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2081 L_C, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2082 L_G, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2083 L_1; |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2084 short int siI, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2085 siJ, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2086 siK, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2087 siEBits, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2088 siShiftCnt, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2089 siBitIndex, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2090 siBest, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2091 siMask; |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2092 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2093 /*_________________________________________________________________________ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2094 | | |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2095 | Executable Code | |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2096 |_________________________________________________________________________| |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2097 */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2098 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2099 /* initialize variables based on voicing mode */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2100 /* ------------------------------------------ */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2101 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2102 if (sub(siNumBasis, C_BITS_V) == 0) |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2103 { |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2104 siEBits = C_BITS_V_1; |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2105 pswUIndex = pswUpdateIndexV; |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2106 pswBIndex = pswBitIndexV; |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2107 pswModNextBit = pswModNextBitV; |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2108 } |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2109 else |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2110 { |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2111 siEBits = C_BITS_UV_1; |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2112 pswUIndex = pswUpdateIndexUn; |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2113 pswBIndex = pswBitIndexUn; |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2114 pswModNextBit = pswModNextBitUV; |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2115 } |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2116 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2117 /* initialize pointers */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2118 /* ------------------- */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2119 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2120 for (siI = 0; siI < siNumBasis - 1; siI++) |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2121 { |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2122 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2123 pppswDubD[siI] = &ppswDPSpace[siI * siNumBasis]; |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2124 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2125 for (siJ = 0; siJ < siNumBasis; siJ++) |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2126 { |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2127 ppswDPSpace[(siI * siNumBasis) + siJ] = |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2128 &pswDSpace[(siI * siNumBasis * 2) + (siJ * 2)]; |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2129 } |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2130 ppswD[siI] = &pswDSpace[siI * siNumBasis]; |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2131 } |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2132 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2133 /* compute correlations (Rm) between given vector and basis vectors, */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2134 /* store in double precision; maintain max C for later scaling of Rm's */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2135 /* ------------------------------------------------------------------- */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2136 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2137 L_MaxC = 0L; |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2138 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2139 for (siI = 0; siI < siNumBasis; siI++) |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2140 { |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2141 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2142 L_R = L_mult(pswWBasisVecs[siI * S_LEN], pswWInput[0]); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2143 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2144 for (siJ = 1; siJ < S_LEN; siJ++) |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2145 { |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2146 L_R = L_mac(L_R, pswWBasisVecs[siJ + (siI * S_LEN)], pswWInput[siJ]); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2147 } |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2148 pL_R[siI] = L_R; |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2149 L_R = L_abs(L_R); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2150 L_MaxC = L_add(L_R, L_MaxC); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2151 } |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2152 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2153 /* normalize max C to get scaling shift count */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2154 /* scale Rm's and calculate C(0) */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2155 /* ------------------------------------------ */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2156 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2157 /* max abs(C) after scale is <= 0.5 */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2158 siShiftCnt = add(-1, norm_l(L_MaxC)); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2159 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2160 L_C0 = 0L; |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2161 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2162 for (siI = 0; siI < siNumBasis; siI++) |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2163 { |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2164 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2165 L_R = L_shl(pL_R[siI], siShiftCnt); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2166 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2167 L_C0 = L_sub(L_C0, L_R); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2168 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2169 pL_R[siI] = L_shl(L_R, 1); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2170 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2171 } |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2172 swC0 = extract_h(L_C0); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2173 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2174 /* compute correlations (Dmj, for m != j) between the basis vectors */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2175 /* store in double precision */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2176 /* ---------------------------------------------------------------- */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2177 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2178 for (siI = 0; siI < siNumBasis - 1; siI++) |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2179 { |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2180 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2181 for (siJ = siI + 1; siJ < siNumBasis; siJ++) |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2182 { |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2183 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2184 L_D = L_mult(pswWBasisVecs[siI * S_LEN], pswWBasisVecs[siJ * S_LEN]); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2185 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2186 for (siK = 1; siK < S_LEN; siK++) |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2187 { |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2188 L_D = L_mac(L_D, pswWBasisVecs[siK + (siI * S_LEN)], |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2189 pswWBasisVecs[siK + (siJ * S_LEN)]); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2190 } |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2191 pppswDubD[siI][siJ][0] = extract_h(L_D); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2192 pppswDubD[siI][siJ][1] = extract_l(L_D); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2193 } |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2194 } |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2195 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2196 /* compute the sum of the Djj's (to be used for scaling the Dmj's and */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2197 /* for computing G(0)); normalize it, get shift count for scaling Dmj's */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2198 /* -------------------------------------------------------------------- */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2199 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2200 psw1 = pswWBasisVecs; |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2201 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2202 L_G0 = L_mult(psw1[0], psw1[0]); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2203 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2204 for (siI = 1; siI < siNumBasis * S_LEN; siI++) |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2205 { |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2206 L_G0 = L_mac(L_G0, psw1[siI], psw1[siI]); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2207 } |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2208 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2209 siShiftCnt = add(-4, norm_l(L_G0)); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2210 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2211 L_G0 = L_shl(L_G0, siShiftCnt); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2212 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2213 /* scale Dmj's and compute G(0) */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2214 /* ---------------------------- */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2215 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2216 for (siI = 0; siI < siNumBasis - 1; siI++) |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2217 { |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2218 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2219 for (siJ = siI + 1; siJ < siNumBasis; siJ++) |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2220 { |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2221 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2222 L_D = L_deposit_h(pppswDubD[siI][siJ][0]); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2223 L_D = L_add(L_D, (LSP_MASK & L_deposit_l(pppswDubD[siI][siJ][1]))); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2224 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2225 L_D = L_shl(L_D, siShiftCnt); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2226 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2227 L_D = L_shl(L_D, 1); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2228 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2229 L_G0 = L_add(L_D, L_G0); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2230 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2231 L_D = L_shl(L_D, 1); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2232 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2233 ppswD[siI][siJ] = round(L_D); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2234 } |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2235 } |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2236 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2237 swG0 = extract_h(L_G0); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2238 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2239 /* build array of update values for codebook search */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2240 /* ------------------------------------------------ */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2241 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2242 for (siI = 0; siI < siEBits; siI++) |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2243 { |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2244 pswCGUpdates[siI * (siEBits + 1)] = round(pL_R[siI]); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2245 } |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2246 psw0 = &pswCGUpdates[siEBits]; |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2247 psw1 = &pswCGUpdates[1]; |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2248 psw2 = &pswCGUpdates[2 * siEBits]; |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2249 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2250 for (siI = 0; siI < siEBits - 1; siI++) |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2251 { |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2252 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2253 for (siJ = siI + 1; siJ < siEBits; siJ++) |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2254 { |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2255 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2256 L_1 = L_deposit_h(ppswD[siI][siJ]); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2257 L_1 = L_shl(L_1, 1); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2258 psw1[siJ - 1 + (siI * siEBits)] = extract_h(L_1); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2259 psw2[siI + (siEBits * (siJ - 1))] = extract_h(L_1); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2260 } |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2261 psw0[siI * (siEBits + 1)] = negate(ppswD[siI][siEBits]); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2262 } |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2263 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2264 psw0[siI * (siEBits + 1)] = negate(ppswD[siEBits - 1][siEBits]); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2265 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2266 /* copy to negative side of array */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2267 /* ------------------------------ */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2268 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2269 psw0 = &pswCGUpdates[(siEBits + 1) * siEBits]; |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2270 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2271 for (siI = 0; siI < (siEBits + 1) * siEBits; siI++) |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2272 { |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2273 psw0[siI] = negate(pswCGUpdates[siI]); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2274 } |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2275 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2276 /* initialize array of bits (magnitude = 0.5) */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2277 /* ------------------------------------------ */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2278 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2279 for (siI = 0; siI < siEBits; siI++) |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2280 { |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2281 pswBits[siI] = MINUS_HALF; |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2282 } |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2283 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2284 /* initialize and do codebook search */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2285 /* --------------------------------- */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2286 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2287 swGMax = swG0; |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2288 swCCMax = mult_r(swC0, swC0); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2289 L_C = L_deposit_h(swC0); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2290 L_G = L_deposit_h(swG0); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2291 siBest = 0; |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2292 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2293 for (siI = 0; siI < (1 << siEBits) - 1; siI++) |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2294 { |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2295 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2296 pswUpdatePtr = &pswCGUpdates[pswUIndex[siI]]; |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2297 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2298 siBitIndex = pswBIndex[siI]; |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2299 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2300 L_C = L_msu(L_C, pswUpdatePtr[0], 0x8000); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2301 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2302 for (siJ = 0; siJ < siEBits - 1; siJ++) |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2303 { |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2304 L_G = L_mac(L_G, pswUpdatePtr[siJ + 1], pswBits[siBitIndex]); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2305 siBitIndex = pswModNextBit[siBitIndex]; |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2306 } |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2307 L_G = L_msu(L_G, pswUpdatePtr[siJ + 1], 0x8000); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2308 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2309 pswBits[siBitIndex] = negate(pswBits[siBitIndex]); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2310 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2311 sw1 = extract_h(L_C); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2312 swCC = mult_r(sw1, sw1); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2313 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2314 swG = extract_h(L_G); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2315 L_1 = L_mult(swG, swCCMax); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2316 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2317 L_1 = L_msu(L_1, swGMax, swCC); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2318 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2319 if (L_1 < 0) |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2320 { |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2321 swCCMax = swCC; |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2322 swGMax = swG; |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2323 siBest = add(siI, 1); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2324 } |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2325 } |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2326 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2327 /* generate code for positive correlation; */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2328 /* compute correlation, if negative, invert code */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2329 /* --------------------------------------------- */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2330 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2331 sw1 = siBest ^ (shr(siBest, 1)); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2332 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2333 siMask = 0x1; |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2334 L_1 = 0L; |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2335 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2336 for (siI = 0; siI < siNumBasis; siI++) |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2337 { |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2338 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2339 if ((sw1 & siMask) == 0) |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2340 { |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2341 L_1 = L_sub(L_1, pL_R[siI]); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2342 } |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2343 else |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2344 { |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2345 L_1 = L_add(L_1, pL_R[siI]); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2346 } |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2347 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2348 siMask = shl(siMask, 1); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2349 } |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2350 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2351 if (L_1 < 0) |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2352 { |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2353 sw1 = sw1 ^ (sub(shl(1, siNumBasis), 1)); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2354 } |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2355 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2356 /* return code */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2357 /* ----------- */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2358 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2359 return (sw1); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2360 } |