comparison libgsmefr/d_homing.c @ 53:49dd1ac8e75b

libgsmefr: import most *.c files from ETSI source
author Mychaela Falconia <falcon@freecalypso.org>
date Fri, 25 Nov 2022 16:18:21 +0000
parents
children c87ccddf3fd1
comparison
equal deleted inserted replaced
52:988fd7ff514f 53:49dd1ac8e75b
1 /**************************************************************************
2 *
3 * File Name: d_homing.c
4 *
5 * Purpose:
6 * This file contains the following functions:
7 *
8 * decoder_homing_frame_test() checks if a frame of input speech
9 * parameters matches the Decoder Homing
10 * Frame pattern.
11 *
12 * decoder_reset() called by reset_dec() to reset all of
13 * the state variables for the decoder
14 *
15 * reset_dec() calls functions to reset the state
16 * variables for the decoder, and for
17 * the receive DTX and Comfort Noise.
18 *
19 **************************************************************************/
20
21 #include "typedef.h"
22 #include "cnst.h"
23 #include "dtx.h"
24 #include "codec.h"
25 #include "d_homing.h"
26 #include "q_plsf_5.tab"
27
28 #define PRM_NO 57
29
30 /***************************************************************************
31 *
32 * FUNCTION NAME: decoder_homing_frame_test
33 *
34 * PURPOSE:
35 * Checks if a frame of input speech parameters matches the Decoder
36 * Homing Frame pattern, which is:
37 *
38 * parameter decimal value hexidecimal value
39 * --------- ------------- -----------------
40 * LPC 1 4 0x0004
41 * LPC 2 47 0x002F
42 * LPC 3 180 0x00B4
43 * LPC 4 144 0x0090
44 * LPC 5 62 0x003E
45 * LTP-LAG 1 342 0x0156
46 * LTP-GAIN 1 11 0x000B
47 * PULSE1_1 0 0x0000
48 * PULSE1_2 1 0x0001
49 * PULSE1_3 15 0x000F
50 * PULSE1_4 1 0x0001
51 * PULSE1_5 13 0x000D
52 * PULSE1_6 0 0x0000
53 * PULSE1_7 3 0x0003
54 * PULSE1_8 0 0x0000
55 * PULSE1_9 3 0x0003
56 * PULSE1_10 0 0x0000
57 * FCB-GAIN 1 3 0x0003
58 * LTP-LAG 2 54 0x0036
59 * LTP-GAIN 2 1 0x0001
60 * PULSE2_1 8 0x0008
61 * PULSE2_2 8 0x0008
62 * PULSE2_3 5 0x0005
63 * PULSE2_4 8 0x0008
64 * PULSE2_5 1 0x0001
65 * PULSE2_6 0 0x0000
66 * PULSE2_7 0 0x0000
67 * PULSE2_8 1 0x0001
68 * PULSE2_9 1 0x0001
69 * PULSE2_10 0 0x0000
70 * FCB-GAIN 2 0 0x0000
71 * LTP-LAG 3 342 0x0156
72 * LTP-GAIN 3 0 0x0000
73 * PULSE3_1 0 0x0000
74 * PULSE3_2 0 0x0000
75 * PULSE3_3 0 0x0000
76 * PULSE3_4 0 0x0000
77 * PULSE3_5 0 0x0000
78 * PULSE3_6 0 0x0000
79 * PULSE3_7 0 0x0000
80 * PULSE3_8 0 0x0000
81 * PULSE3_9 0 0x0000
82 * PULSE3_10 0 0x0000
83 * FCB-GAIN 3 0 0x0000
84 * LTP-LAG 4 54 0x0036
85 * LTP-GAIN 4 11 0x000B
86 * PULSE4_1 0 0x0000
87 * PULSE4_2 0 0x0000
88 * PULSE4_3 0 0x0000
89 * PULSE4_4 0 0x0000
90 * PULSE4_5 0 0x0000
91 * PULSE4_6 0 0x0000
92 * PULSE4_7 0 0x0000
93 * PULSE4_8 0 0x0000
94 * PULSE4_9 0 0x0000
95 * PULSE4_10 0 0x0000
96 * FCB-GAIN 4 0 0x0000
97 *
98 * INPUT:
99 * parm[] one frame of speech parameters in parallel format
100 *
101 * nbr_of_params
102 * the number of consecutive parameters in parm[] to match
103 *
104 * OUTPUT:
105 * None
106 *
107 * RETURN:
108 * 0 input frame does not match the Decoder Homing Frame pattern.
109 * 1 input frame matches the Decoder Homing Frame pattern.
110 *
111 **************************************************************************/
112
113 Word16 decoder_homing_frame_test (Word16 parm[], Word16 nbr_of_params)
114 {
115 static const Word16 dhf_mask[PRM_NO] =
116 {
117 0x0004, /* LPC 1 */
118 0x002f, /* LPC 2 */
119 0x00b4, /* LPC 3 */
120 0x0090, /* LPC 4 */
121 0x003e, /* LPC 5 */
122
123 0x0156, /* LTP-LAG 1 */
124 0x000b, /* LTP-GAIN 1 */
125 0x0000, /* PULSE 1_1 */
126 0x0001, /* PULSE 1_2 */
127 0x000f, /* PULSE 1_3 */
128 0x0001, /* PULSE 1_4 */
129 0x000d, /* PULSE 1_5 */
130 0x0000, /* PULSE 1_6 */
131 0x0003, /* PULSE 1_7 */
132 0x0000, /* PULSE 1_8 */
133 0x0003, /* PULSE 1_9 */
134 0x0000, /* PULSE 1_10 */
135 0x0003, /* FCB-GAIN 1 */
136
137 0x0036, /* LTP-LAG 2 */
138 0x0001, /* LTP-GAIN 2 */
139 0x0008, /* PULSE 2_1 */
140 0x0008, /* PULSE 2_2 */
141 0x0005, /* PULSE 2_3 */
142 0x0008, /* PULSE 2_4 */
143 0x0001, /* PULSE 2_5 */
144 0x0000, /* PULSE 2_6 */
145 0x0000, /* PULSE 2_7 */
146 0x0001, /* PULSE 2_8 */
147 0x0001, /* PULSE 2_9 */
148 0x0000, /* PULSE 2_10 */
149 0x0000, /* FCB-GAIN 2 */
150
151 0x0156, /* LTP-LAG 3 */
152 0x0000, /* LTP-GAIN 3 */
153 0x0000, /* PULSE 3_1 */
154 0x0000, /* PULSE 3_2 */
155 0x0000, /* PULSE 3_3 */
156 0x0000, /* PULSE 3_4 */
157 0x0000, /* PULSE 3_5 */
158 0x0000, /* PULSE 3_6 */
159 0x0000, /* PULSE 3_7 */
160 0x0000, /* PULSE 3_8 */
161 0x0000, /* PULSE 3_9 */
162 0x0000, /* PULSE 3_10 */
163 0x0000, /* FCB-GAIN 3 */
164
165 0x0036, /* LTP-LAG 4 */
166 0x000b, /* LTP-GAIN 4 */
167 0x0000, /* PULSE 4_1 */
168 0x0000, /* PULSE 4_2 */
169 0x0000, /* PULSE 4_3 */
170 0x0000, /* PULSE 4_4 */
171 0x0000, /* PULSE 4_5 */
172 0x0000, /* PULSE 4_6 */
173 0x0000, /* PULSE 4_7 */
174 0x0000, /* PULSE 4_8 */
175 0x0000, /* PULSE 4_9 */
176 0x0000, /* PULSE 4_10 */
177 0x0000 /* FCB-GAIN 4 */ };
178
179 Word16 i, j;
180
181 for (i = 0; i < nbr_of_params; i++)
182 {
183 j = parm[i] ^ dhf_mask[i];
184
185 if (j)
186 break;
187 }
188
189 return !j;
190 }
191
192 /***************************************************************************
193 *
194 * FUNCTION NAME: decoder_reset
195 *
196 * PURPOSE:
197 * resets all of the state variables for the decoder
198 *
199 * INPUT:
200 * None
201 *
202 * OUTPUT:
203 * None
204 *
205 * RETURN:
206 * None
207 *
208 **************************************************************************/
209
210 void decoder_reset (void)
211 {
212 /* External declarations for decoder variables which need to be reset */
213
214 /* variable defined in decoder.c */
215 /* ----------------------------- */
216 extern Word16 synth_buf[L_FRAME + M];
217
218 /* variable defined in agc.c */
219 /* -------------------------- */
220 extern Word16 past_gain;
221
222 /* variables defined in d_gains.c */
223 /* ------------------------------ */
224 /* Error concealment */
225 extern Word16 pbuf[5], past_gain_pit, prev_gp, gbuf[5], past_gain_code,
226 prev_gc;
227
228 /* CNI */
229 extern Word16 gcode0_CN, gain_code_old_CN, gain_code_new_CN;
230 extern Word16 gain_code_muting_CN;
231
232 /* Memories of gain dequantization: */
233 extern Word16 past_qua_en[4], pred[4];
234
235 /* variables defined in d_plsf_5.c */
236 /* ------------------------------ */
237 /* Past quantized prediction error */
238 extern Word16 past_r2_q[M];
239
240 /* Past dequantized lsfs */
241 extern Word16 past_lsf_q[M];
242
243 /* CNI */
244 extern Word16 lsf_p_CN[M], lsf_new_CN[M], lsf_old_CN[M];
245
246 /* variables defined in dec_lag6.c */
247 /* ------------------------------ */
248 extern Word16 old_T0;
249
250 /* variable defined in preemph.c */
251 /* ------------------------------ */
252 extern Word16 mem_pre;
253
254 Word16 i;
255
256 /* reset all the decoder state variables */
257 /* ------------------------------------- */
258
259 /* Variable in decoder.c: */
260 for (i = 0; i < M; i++)
261 {
262 synth_buf[i] = 0;
263 }
264
265 /* Variables in dec_12k2.c: */
266 Init_Decoder_12k2 ();
267
268 /* Variable in agc.c: */
269 past_gain = 4096;
270
271 /* Variables in d_gains.c: */
272 for (i = 0; i < 5; i++)
273 {
274 pbuf[i] = 410; /* Error concealment */
275 gbuf[i] = 1; /* Error concealment */
276 }
277
278 past_gain_pit = 0; /* Error concealment */
279 prev_gp = 4096; /* Error concealment */
280 past_gain_code = 0; /* Error concealment */
281 prev_gc = 1; /* Error concealment */
282 gcode0_CN = 0; /* CNI */
283 gain_code_old_CN = 0; /* CNI */
284 gain_code_new_CN = 0; /* CNI */
285 gain_code_muting_CN = 0; /* CNI */
286
287 for (i = 0; i < 4; i++)
288 {
289 past_qua_en[i] = -2381; /* past quantized energies */
290 }
291
292 pred[0] = 44; /* MA prediction coeff */
293 pred[1] = 37; /* MA prediction coeff */
294 pred[2] = 22; /* MA prediction coeff */
295 pred[3] = 12; /* MA prediction coeff */
296
297 /* Variables in d_plsf_5.c: */
298 for (i = 0; i < M; i++)
299 {
300 past_r2_q[i] = 0; /* Past quantized prediction error */
301 past_lsf_q[i] = mean_lsf[i]; /* Past dequantized lsfs */
302 lsf_p_CN[i] = mean_lsf[i]; /* CNI */
303 lsf_new_CN[i] = mean_lsf[i]; /* CNI */
304 lsf_old_CN[i] = mean_lsf[i]; /* CNI */
305 }
306
307 /* Variable in dec_lag6.c: */
308 old_T0 = 40; /* Old integer lag */
309
310 /* Variable in preemph.c: */
311 mem_pre = 0; /* Filter memory */
312
313 /* Variables in pstfilt2.c: */
314 Init_Post_Filter ();
315
316 return;
317 }
318
319 /***************************************************************************
320 *
321 * FUNCTION NAME: reset_dec
322 *
323 * PURPOSE:
324 * resets all of the state variables for the decoder, and for the
325 * receive DTX and Comfort Noise.
326 *
327 * INPUT:
328 * None
329 *
330 * OUTPUT:
331 * None
332 *
333 * RETURN:
334 * None
335 *
336 **************************************************************************/
337
338 void reset_dec (void)
339 {
340 decoder_reset (); /* reset all the state variables in the speech decoder*/
341 reset_rx_dtx (); /* reset all the receive DTX and CN state variables */
342
343 return;
344 }