1
|
1
|
867
|
2 /*
|
|
3 Written by Mark Podlipec <podlipec@ici.net>.
|
|
4
|
|
5 Most of this code comes from a GSM 06.10 library by
|
|
6 Jutta Degener and Carsten Bormann, available via
|
|
7 <http://www.pobox.com/~jutta/toast.html>.
|
|
8
|
|
9 That library is distributed with the following copyright:
|
|
10
|
1
|
11 Copyright 1992 by Jutta Degener and Carsten Bormann,
|
|
12 Technische Universitaet Berlin
|
|
13
|
|
14 Any use of this software is permitted provided that this notice is not
|
|
15 removed and that neither the authors nor the Technische Universitaet Berlin
|
|
16 are deemed to have made any representations as to the suitability of this
|
|
17 software for any purpose nor are held responsible for any defects of
|
|
18 this software. THERE IS ABSOLUTELY NO WARRANTY FOR THIS SOFTWARE.
|
|
19
|
|
20 As a matter of courtesy, the authors request to be informed about uses
|
|
21 this software has found, about bugs in this software, and about any
|
|
22 improvements that may be of general interest.
|
|
23
|
|
24 Berlin, 15.09.1992
|
|
25 Jutta Degener
|
|
26 Carsten Bormann
|
867
|
27 */
|
1
|
28
|
|
29
|
|
30 #include <stdio.h>
|
2476
|
31 #include <string.h>
|
1
|
32 #include <assert.h> /* POD optional */
|
|
33 #include "xa_gsm_int.h"
|
|
34
|
|
35 //void XA_MSGSM_Decoder();
|
|
36 static void GSM_Decode();
|
|
37 static void Gsm_RPE_Decoding();
|
|
38
|
|
39 //static short gsm_buf[320];
|
|
40 static XA_GSM_STATE gsm_state;
|
|
41
|
|
42 unsigned char xa_sign_2_ulaw[256];
|
|
43
|
|
44 unsigned char XA_Signed_To_uLaw(long ch)
|
|
45 {
|
|
46 long mask;
|
|
47 if (ch < 0) { ch = -ch; mask = 0x7f; }
|
|
48 else { mask = 0xff; }
|
|
49 if (ch < 32) { ch = 0xF0 | (15 - (ch / 2)); }
|
|
50 else if (ch < 96) { ch = 0xE0 | (15 - (ch - 32) / 4); }
|
|
51 else if (ch < 224) { ch = 0xD0 | (15 - (ch - 96) / 8); }
|
|
52 else if (ch < 480) { ch = 0xC0 | (15 - (ch - 224) / 16); }
|
|
53 else if (ch < 992) { ch = 0xB0 | (15 - (ch - 480) / 32); }
|
|
54 else if (ch < 2016) { ch = 0xA0 | (15 - (ch - 992) / 64); }
|
|
55 else if (ch < 4064) { ch = 0x90 | (15 - (ch - 2016) / 128); }
|
|
56 else if (ch < 8160) { ch = 0x80 | (15 - (ch - 4064) / 256); }
|
|
57 else { ch = 0x80; }
|
|
58 return (mask & ch);
|
|
59 }
|
|
60
|
|
61 void Gen_Signed_2_uLaw()
|
|
62 {
|
|
63 unsigned long i;
|
|
64 for(i=0;i<256;i++)
|
|
65 { unsigned char d;
|
|
66 char ch = i;
|
|
67 long chr = ch;
|
|
68 d = XA_Signed_To_uLaw(chr * 16);
|
|
69 xa_sign_2_ulaw[i] = d;
|
|
70 }
|
|
71 }
|
|
72
|
|
73
|
|
74 void GSM_Init()
|
|
75 {
|
|
76 memset((char *)(&gsm_state), 0, sizeof(XA_GSM_STATE));
|
|
77 gsm_state.nrp = 40;
|
|
78 Gen_Signed_2_uLaw();
|
|
79 }
|
|
80
|
|
81
|
|
82 /* Table 4.3b Quantization levels of the LTP gain quantizer
|
|
83 */
|
|
84 /* bc 0 1 2 3 */
|
|
85 static word gsm_QLB[4] = { 3277, 11469, 21299, 32767 };
|
|
86
|
|
87 /* Table 4.6 Normalized direct mantissa used to compute xM/xmax
|
|
88 */
|
|
89 /* i 0 1 2 3 4 5 6 7 */
|
|
90 static word gsm_FAC[8] = { 18431, 20479, 22527, 24575, 26623, 28671, 30719, 32767 };
|
|
91
|
|
92
|
|
93
|
|
94 /****************/
|
|
95 #define saturate(x) \
|
|
96 ((x) < MIN_WORD ? MIN_WORD : (x) > MAX_WORD ? MAX_WORD: (x))
|
|
97
|
|
98 /****************/
|
|
99 static word gsm_sub (a,b)
|
|
100 word a;
|
|
101 word b;
|
|
102 {
|
|
103 longword diff = (longword)a - (longword)b;
|
|
104 return saturate(diff);
|
|
105 }
|
|
106
|
|
107 /****************/
|
|
108 static word gsm_asr (a,n)
|
|
109 word a;
|
|
110 int n;
|
|
111 {
|
|
112 if (n >= 16) return -(a < 0);
|
|
113 if (n <= -16) return 0;
|
|
114 if (n < 0) return a << -n;
|
|
115
|
|
116 # ifdef SASR
|
|
117 return a >> n;
|
|
118 # else
|
|
119 if (a >= 0) return a >> n;
|
|
120 else return -(word)( -(uword)a >> n );
|
|
121 # endif
|
|
122 }
|
|
123
|
|
124 /****************/
|
|
125 static word gsm_asl (a,n)
|
|
126 word a;
|
|
127 int n;
|
|
128 {
|
|
129 if (n >= 16) return 0;
|
|
130 if (n <= -16) return -(a < 0);
|
|
131 if (n < 0) return gsm_asr(a, -n);
|
|
132 return a << n;
|
|
133 }
|
|
134
|
|
135
|
|
136 /*
|
|
137 * Copyright 1992 by Jutta Degener and Carsten Bormann, Technische
|
|
138 * Universitaet Berlin. See the accompanying file "COPYRIGHT" for
|
|
139 * details. THERE IS ABSOLUTELY NO WARRANTY FOR THIS SOFTWARE.
|
|
140 */
|
|
141
|
|
142 /**** 4.2.17 */
|
|
143 static void RPE_grid_positioning(Mc,xMp,ep)
|
|
144 word Mc; /* grid position IN */
|
|
145 register word * xMp; /* [0..12] IN */
|
|
146 register word * ep; /* [0..39] OUT */
|
|
147 /*
|
|
148 * This procedure computes the reconstructed long term residual signal
|
|
149 * ep[0..39] for the LTP analysis filter. The inputs are the Mc
|
|
150 * which is the grid position selection and the xMp[0..12] decoded
|
|
151 * RPE samples which are upsampled by a factor of 3 by inserting zero
|
|
152 * values.
|
|
153 */
|
|
154 {
|
|
155 int i = 13;
|
|
156
|
|
157 assert(0 <= Mc && Mc <= 3);
|
|
158
|
|
159 switch (Mc) {
|
|
160 case 3: *ep++ = 0;
|
|
161 case 2: do {
|
|
162 *ep++ = 0;
|
|
163 case 1: *ep++ = 0;
|
|
164 case 0: *ep++ = *xMp++;
|
|
165 } while (--i);
|
|
166 }
|
|
167 while (++Mc < 4) *ep++ = 0;
|
|
168
|
|
169 /*
|
|
170
|
|
171 int i, k;
|
|
172 for (k = 0; k <= 39; k++) ep[k] = 0;
|
|
173 for (i = 0; i <= 12; i++) {
|
|
174 ep[ Mc + (3*i) ] = xMp[i];
|
|
175 }
|
|
176 */
|
|
177 }
|
|
178
|
|
179
|
|
180 /**** 4.2.16 */
|
|
181 static void APCM_inverse_quantization (xMc,mant,exp,xMp)
|
|
182 register word * xMc; /* [0..12] IN */
|
|
183 word mant;
|
|
184 word exp;
|
|
185 register word * xMp; /* [0..12] OUT */
|
|
186 /*
|
|
187 * This part is for decoding the RPE sequence of coded xMc[0..12]
|
|
188 * samples to obtain the xMp[0..12] array. Table 4.6 is used to get
|
|
189 * the mantissa of xmaxc (FAC[0..7]).
|
|
190 */
|
|
191 {
|
|
192 int i;
|
|
193 word temp, temp1, temp2, temp3;
|
|
194 longword ltmp;
|
|
195
|
|
196 assert( mant >= 0 && mant <= 7 );
|
|
197
|
|
198 temp1 = gsm_FAC[ mant ]; /* see 4.2-15 for mant */
|
|
199 temp2 = gsm_sub( 6, exp ); /* see 4.2-15 for exp */
|
|
200 temp3 = gsm_asl( 1, gsm_sub( temp2, 1 ));
|
|
201
|
|
202 for (i = 13; i--;) {
|
|
203
|
|
204 assert( *xMc <= 7 && *xMc >= 0 ); /* 3 bit unsigned */
|
|
205
|
|
206 /* temp = gsm_sub( *xMc++ << 1, 7 ); */
|
|
207 temp = (*xMc++ << 1) - 7; /* restore sign */
|
|
208 assert( temp <= 7 && temp >= -7 ); /* 4 bit signed */
|
|
209
|
|
210 temp <<= 12; /* 16 bit signed */
|
|
211 temp = GSM_MULT_R( temp1, temp );
|
|
212 temp = GSM_ADD( temp, temp3 );
|
|
213 *xMp++ = gsm_asr( temp, temp2 );
|
|
214 }
|
|
215 }
|
|
216
|
|
217
|
|
218 /**** 4.12.15 */
|
|
219 static void APCM_quantization_xmaxc_to_exp_mant (xmaxc,exp_out,mant_out)
|
|
220 word xmaxc; /* IN */
|
|
221 word * exp_out; /* OUT */
|
|
222 word * mant_out; /* OUT */
|
|
223 {
|
|
224 word exp, mant;
|
|
225
|
|
226 /* Compute exponent and mantissa of the decoded version of xmaxc
|
|
227 */
|
|
228
|
|
229 exp = 0;
|
|
230 if (xmaxc > 15) exp = SASR(xmaxc, 3) - 1;
|
|
231 mant = xmaxc - (exp << 3);
|
|
232
|
|
233 if (mant == 0) {
|
|
234 exp = -4;
|
|
235 mant = 7;
|
|
236 }
|
|
237 else {
|
|
238 while (mant <= 7) {
|
|
239 mant = mant << 1 | 1;
|
|
240 exp--;
|
|
241 }
|
|
242 mant -= 8;
|
|
243 }
|
|
244
|
|
245 assert( exp >= -4 && exp <= 6 );
|
|
246 assert( mant >= 0 && mant <= 7 );
|
|
247
|
|
248 *exp_out = exp;
|
|
249 *mant_out = mant;
|
|
250 }
|
|
251
|
|
252 static void Gsm_RPE_Decoding (S, xmaxcr, Mcr, xMcr, erp)
|
|
253 XA_GSM_STATE * S;
|
|
254 word xmaxcr;
|
|
255 word Mcr;
|
|
256 word * xMcr; /* [0..12], 3 bits IN */
|
|
257 word * erp; /* [0..39] OUT */
|
|
258
|
|
259 {
|
|
260 word exp, mant;
|
|
261 word xMp[ 13 ];
|
|
262
|
|
263 APCM_quantization_xmaxc_to_exp_mant( xmaxcr, &exp, &mant );
|
|
264 APCM_inverse_quantization( xMcr, mant, exp, xMp );
|
|
265 RPE_grid_positioning( Mcr, xMp, erp );
|
|
266
|
|
267 }
|
|
268
|
|
269
|
|
270 /*
|
|
271 * 4.3 FIXED POINT IMPLEMENTATION OF THE RPE-LTP DECODER
|
|
272 */
|
|
273
|
|
274 static void Postprocessing(S,s)
|
|
275 XA_GSM_STATE * S;
|
|
276 register word * s;
|
|
277 {
|
|
278 register int k;
|
|
279 register word msr = S->msr;
|
|
280 register longword ltmp; /* for GSM_ADD */
|
|
281 register word tmp;
|
|
282
|
|
283 for (k = 160; k--; s++)
|
|
284 {
|
|
285 tmp = GSM_MULT_R( msr, 28180 );
|
|
286 msr = GSM_ADD(*s, tmp); /* Deemphasis */
|
|
287 *s = GSM_ADD(msr, msr) & 0xFFF8; /* Truncation & Upscaling */
|
|
288 }
|
|
289 S->msr = msr;
|
|
290 }
|
|
291
|
|
292 /**** 4.3.2 */
|
|
293 void Gsm_Long_Term_Synthesis_Filtering (S,Ncr,bcr,erp,drp)
|
|
294 XA_GSM_STATE * S;
|
|
295 word Ncr;
|
|
296 word bcr;
|
|
297 register word * erp; /* [0..39] IN */
|
|
298 register word * drp; /* [-120..-1] IN, [-120..40] OUT */
|
|
299
|
|
300 /*
|
|
301 * This procedure uses the bcr and Ncr parameter to realize the
|
|
302 * long term synthesis filtering. The decoding of bcr needs
|
|
303 * table 4.3b.
|
|
304 */
|
|
305 {
|
|
306 register longword ltmp; /* for ADD */
|
|
307 register int k;
|
|
308 word brp, drpp, Nr;
|
|
309
|
|
310 /* Check the limits of Nr.
|
|
311 */
|
|
312 Nr = Ncr < 40 || Ncr > 120 ? S->nrp : Ncr;
|
|
313 S->nrp = Nr;
|
|
314 assert(Nr >= 40 && Nr <= 120);
|
|
315
|
|
316 /* Decoding of the LTP gain bcr
|
|
317 */
|
|
318 brp = gsm_QLB[ bcr ];
|
|
319
|
|
320 /* Computation of the reconstructed short term residual
|
|
321 * signal drp[0..39]
|
|
322 */
|
|
323 assert(brp != MIN_WORD);
|
|
324
|
|
325 for (k = 0; k <= 39; k++) {
|
|
326 drpp = GSM_MULT_R( brp, drp[ k - Nr ] );
|
|
327 drp[k] = GSM_ADD( erp[k], drpp );
|
|
328 }
|
|
329
|
|
330 /*
|
|
331 * Update of the reconstructed short term residual signal
|
|
332 * drp[ -1..-120 ]
|
|
333 */
|
|
334
|
|
335 for (k = 0; k <= 119; k++) drp[ -120 + k ] = drp[ -80 + k ];
|
|
336 }
|
|
337
|
|
338 static void Short_term_synthesis_filtering (S,rrp,k,wt,sr)
|
|
339 XA_GSM_STATE *S;
|
|
340 register word *rrp; /* [0..7] IN */
|
|
341 register int k; /* k_end - k_start */
|
|
342 register word *wt; /* [0..k-1] IN */
|
|
343 register word *sr; /* [0..k-1] OUT */
|
|
344 {
|
|
345 register word * v = S->v;
|
|
346 register int i;
|
|
347 register word sri, tmp1, tmp2;
|
|
348 register longword ltmp; /* for GSM_ADD & GSM_SUB */
|
|
349
|
|
350 while (k--) {
|
|
351 sri = *wt++;
|
|
352 for (i = 8; i--;) {
|
|
353
|
|
354 /* sri = GSM_SUB( sri, gsm_mult_r( rrp[i], v[i] ) );
|
|
355 */
|
|
356 tmp1 = rrp[i];
|
|
357 tmp2 = v[i];
|
|
358 tmp2 = ( tmp1 == MIN_WORD && tmp2 == MIN_WORD
|
|
359 ? MAX_WORD
|
|
360 : 0x0FFFF & (( (longword)tmp1 * (longword)tmp2
|
|
361 + 16384) >> 15)) ;
|
|
362
|
|
363 sri = GSM_SUB( sri, tmp2 );
|
|
364
|
|
365 /* v[i+1] = GSM_ADD( v[i], gsm_mult_r( rrp[i], sri ) );
|
|
366 */
|
|
367 tmp1 = ( tmp1 == MIN_WORD && sri == MIN_WORD
|
|
368 ? MAX_WORD
|
|
369 : 0x0FFFF & (( (longword)tmp1 * (longword)sri
|
|
370 + 16384) >> 15)) ;
|
|
371
|
|
372 v[i+1] = GSM_ADD( v[i], tmp1);
|
|
373 }
|
|
374 *sr++ = v[0] = sri;
|
|
375 }
|
|
376 }
|
|
377
|
|
378 /* 4.2.8 */
|
|
379
|
|
380 static void Decoding_of_the_coded_Log_Area_Ratios (LARc,LARpp)
|
|
381 word * LARc; /* coded log area ratio [0..7] IN */
|
|
382 word * LARpp; /* out: decoded .. */
|
|
383 {
|
|
384 register word temp1 /* , temp2 */;
|
|
385 register long ltmp; /* for GSM_ADD */
|
|
386
|
|
387 /* This procedure requires for efficient implementation
|
|
388 * two tables.
|
|
389 *
|
|
390 * INVA[1..8] = integer( (32768 * 8) / real_A[1..8])
|
|
391 * MIC[1..8] = minimum value of the LARc[1..8]
|
|
392 */
|
|
393
|
|
394 /* Compute the LARpp[1..8]
|
|
395 */
|
|
396
|
|
397 /* for (i = 1; i <= 8; i++, B++, MIC++, INVA++, LARc++, LARpp++) {
|
|
398 *
|
|
399 * temp1 = GSM_ADD( *LARc, *MIC ) << 10;
|
|
400 * temp2 = *B << 1;
|
|
401 * temp1 = GSM_SUB( temp1, temp2 );
|
|
402 *
|
|
403 * assert(*INVA != MIN_WORD);
|
|
404 *
|
|
405 * temp1 = GSM_MULT_R( *INVA, temp1 );
|
|
406 * *LARpp = GSM_ADD( temp1, temp1 );
|
|
407 * }
|
|
408 */
|
|
409
|
|
410 #undef STEP
|
|
411 #define STEP( B, MIC, INVA ) \
|
|
412 temp1 = GSM_ADD( *LARc++, MIC ) << 10; \
|
|
413 temp1 = GSM_SUB( temp1, B << 1 ); \
|
|
414 temp1 = GSM_MULT_R( INVA, temp1 ); \
|
|
415 *LARpp++ = GSM_ADD( temp1, temp1 );
|
|
416
|
|
417 STEP( 0, -32, 13107 );
|
|
418 STEP( 0, -32, 13107 );
|
|
419 STEP( 2048, -16, 13107 );
|
|
420 STEP( -2560, -16, 13107 );
|
|
421
|
|
422 STEP( 94, -8, 19223 );
|
|
423 STEP( -1792, -8, 17476 );
|
|
424 STEP( -341, -4, 31454 );
|
|
425 STEP( -1144, -4, 29708 );
|
|
426
|
|
427 /* NOTE: the addition of *MIC is used to restore
|
|
428 * the sign of *LARc.
|
|
429 */
|
|
430 }
|
|
431
|
|
432 /* 4.2.9 */
|
|
433 /* Computation of the quantized reflection coefficients
|
|
434 */
|
|
435
|
|
436 /* 4.2.9.1 Interpolation of the LARpp[1..8] to get the LARp[1..8]
|
|
437 */
|
|
438
|
|
439 /*
|
|
440 * Within each frame of 160 analyzed speech samples the short term
|
|
441 * analysis and synthesis filters operate with four different sets of
|
|
442 * coefficients, derived from the previous set of decoded LARs(LARpp(j-1))
|
|
443 * and the actual set of decoded LARs (LARpp(j))
|
|
444 *
|
|
445 * (Initial value: LARpp(j-1)[1..8] = 0.)
|
|
446 */
|
|
447
|
|
448 static void Coefficients_0_12 (LARpp_j_1, LARpp_j, LARp)
|
|
449 register word * LARpp_j_1;
|
|
450 register word * LARpp_j;
|
|
451 register word * LARp;
|
|
452 {
|
|
453 register int i;
|
|
454 register longword ltmp;
|
|
455
|
|
456 for (i = 1; i <= 8; i++, LARp++, LARpp_j_1++, LARpp_j++) {
|
|
457 *LARp = GSM_ADD( SASR( *LARpp_j_1, 2 ), SASR( *LARpp_j, 2 ));
|
|
458 *LARp = GSM_ADD( *LARp, SASR( *LARpp_j_1, 1));
|
|
459 }
|
|
460 }
|
|
461
|
|
462 static void Coefficients_13_26 (LARpp_j_1, LARpp_j, LARp)
|
|
463 register word * LARpp_j_1;
|
|
464 register word * LARpp_j;
|
|
465 register word * LARp;
|
|
466 {
|
|
467 register int i;
|
|
468 register longword ltmp;
|
|
469 for (i = 1; i <= 8; i++, LARpp_j_1++, LARpp_j++, LARp++) {
|
|
470 *LARp = GSM_ADD( SASR( *LARpp_j_1, 1), SASR( *LARpp_j, 1 ));
|
|
471 }
|
|
472 }
|
|
473
|
|
474 static void Coefficients_27_39 (LARpp_j_1, LARpp_j, LARp)
|
|
475 register word * LARpp_j_1;
|
|
476 register word * LARpp_j;
|
|
477 register word * LARp;
|
|
478 {
|
|
479 register int i;
|
|
480 register longword ltmp;
|
|
481
|
|
482 for (i = 1; i <= 8; i++, LARpp_j_1++, LARpp_j++, LARp++) {
|
|
483 *LARp = GSM_ADD( SASR( *LARpp_j_1, 2 ), SASR( *LARpp_j, 2 ));
|
|
484 *LARp = GSM_ADD( *LARp, SASR( *LARpp_j, 1 ));
|
|
485 }
|
|
486 }
|
|
487
|
|
488
|
|
489 static void Coefficients_40_159 (LARpp_j, LARp)
|
|
490 register word * LARpp_j;
|
|
491 register word * LARp;
|
|
492 {
|
|
493 register int i;
|
|
494
|
|
495 for (i = 1; i <= 8; i++, LARp++, LARpp_j++)
|
|
496 *LARp = *LARpp_j;
|
|
497 }
|
|
498 /* 4.2.9.2 */
|
|
499
|
|
500 static void LARp_to_rp (LARp)
|
|
501 register word * LARp; /* [0..7] IN/OUT */
|
|
502 /*
|
|
503 * The input of this procedure is the interpolated LARp[0..7] array.
|
|
504 * The reflection coefficients, rp[i], are used in the analysis
|
|
505 * filter and in the synthesis filter.
|
|
506 */
|
|
507 {
|
|
508 register int i;
|
|
509 register word temp;
|
|
510 register longword ltmp;
|
|
511
|
|
512 for (i = 1; i <= 8; i++, LARp++) {
|
|
513
|
|
514 /* temp = GSM_ABS( *LARp );
|
|
515 *
|
|
516 * if (temp < 11059) temp <<= 1;
|
|
517 * else if (temp < 20070) temp += 11059;
|
|
518 * else temp = GSM_ADD( temp >> 2, 26112 );
|
|
519 *
|
|
520 * *LARp = *LARp < 0 ? -temp : temp;
|
|
521 */
|
|
522
|
|
523 if (*LARp < 0) {
|
|
524 temp = *LARp == MIN_WORD ? MAX_WORD : -(*LARp);
|
|
525 *LARp = - ((temp < 11059) ? temp << 1
|
|
526 : ((temp < 20070) ? temp + 11059
|
|
527 : GSM_ADD( temp >> 2, 26112 )));
|
|
528 } else {
|
|
529 temp = *LARp;
|
|
530 *LARp = (temp < 11059) ? temp << 1
|
|
531 : ((temp < 20070) ? temp + 11059
|
|
532 : GSM_ADD( temp >> 2, 26112 ));
|
|
533 }
|
|
534 }
|
|
535 }
|
|
536
|
|
537
|
|
538
|
|
539
|
|
540
|
|
541 /**** */
|
|
542 static void Gsm_Short_Term_Synthesis_Filter (S, LARcr, wt, s)
|
|
543 XA_GSM_STATE * S;
|
|
544 word * LARcr; /* received log area ratios [0..7] IN */
|
|
545 word * wt; /* received d [0..159] IN */
|
|
546 word * s; /* signal s [0..159] OUT */
|
|
547 {
|
|
548 word * LARpp_j = S->LARpp[ S->j ];
|
|
549 word * LARpp_j_1 = S->LARpp[ S->j ^=1 ];
|
|
550
|
|
551 word LARp[8];
|
|
552
|
|
553 #undef FILTER
|
|
554 #if defined(FAST) && defined(USE_FLOAT_MUL)
|
|
555
|
|
556 # define FILTER (* (S->fast \
|
|
557 ? Fast_Short_term_synthesis_filtering \
|
|
558 : Short_term_synthesis_filtering ))
|
|
559 #else
|
|
560 # define FILTER Short_term_synthesis_filtering
|
|
561 #endif
|
|
562
|
|
563 Decoding_of_the_coded_Log_Area_Ratios( LARcr, LARpp_j );
|
|
564
|
|
565 Coefficients_0_12( LARpp_j_1, LARpp_j, LARp );
|
|
566 LARp_to_rp( LARp );
|
|
567 FILTER( S, LARp, 13, wt, s );
|
|
568
|
|
569 Coefficients_13_26( LARpp_j_1, LARpp_j, LARp);
|
|
570 LARp_to_rp( LARp );
|
|
571 FILTER( S, LARp, 14, wt + 13, s + 13 );
|
|
572
|
|
573 Coefficients_27_39( LARpp_j_1, LARpp_j, LARp);
|
|
574 LARp_to_rp( LARp );
|
|
575 FILTER( S, LARp, 13, wt + 27, s + 27 );
|
|
576
|
|
577 Coefficients_40_159( LARpp_j, LARp );
|
|
578 LARp_to_rp( LARp );
|
|
579 FILTER(S, LARp, 120, wt + 40, s + 40);
|
|
580 }
|
|
581
|
|
582
|
|
583
|
|
584
|
|
585 static void GSM_Decode(S,LARcr, Ncr,bcr,Mcr,xmaxcr,xMcr,s)
|
|
586 XA_GSM_STATE *S;
|
|
587 word *LARcr; /* [0..7] IN */
|
|
588 word *Ncr; /* [0..3] IN */
|
|
589 word *bcr; /* [0..3] IN */
|
|
590 word *Mcr; /* [0..3] IN */
|
|
591 word *xmaxcr; /* [0..3] IN */
|
|
592 word *xMcr; /* [0..13*4] IN */
|
|
593 word *s; /* [0..159] OUT */
|
|
594 {
|
|
595 int j, k;
|
|
596 word erp[40], wt[160];
|
|
597 word *drp = S->dp0 + 120;
|
|
598
|
|
599 for (j=0; j <= 3; j++, xmaxcr++, bcr++, Ncr++, Mcr++, xMcr += 13)
|
|
600 {
|
|
601 Gsm_RPE_Decoding( S, *xmaxcr, *Mcr, xMcr, erp );
|
|
602 Gsm_Long_Term_Synthesis_Filtering( S, *Ncr, *bcr, erp, drp );
|
|
603 for (k = 0; k <= 39; k++) wt[ j * 40 + k ] = drp[ k ];
|
|
604 }
|
|
605
|
|
606 Gsm_Short_Term_Synthesis_Filter( S, LARcr, wt, s );
|
|
607 Postprocessing(S, s);
|
|
608 }
|
|
609
|
|
610
|
|
611
|
|
612 /****-------------------------------------------------------------------****
|
|
613 **** Podlipec: For AVI/WAV files GSM 6.10 combines two 33 bytes frames
|
|
614 **** into one 65 byte frame.
|
|
615 ****-------------------------------------------------------------------****/
|
|
616 void XA_MSGSM_Decoder(unsigned char *ibuf,unsigned short *obuf)
|
|
617 { word sr;
|
|
618 word LARc[8], Nc[4], Mc[4], bc[4], xmaxc[4], xmc[13*4];
|
|
619
|
|
620 sr = *ibuf++;
|
|
621
|
|
622 LARc[0] = sr & 0x3f; sr >>= 6;
|
|
623 sr |= (word)*ibuf++ << 2;
|
|
624 LARc[1] = sr & 0x3f; sr >>= 6;
|
|
625 sr |= (word)*ibuf++ << 4;
|
|
626 LARc[2] = sr & 0x1f; sr >>= 5;
|
|
627 LARc[3] = sr & 0x1f; sr >>= 5;
|
|
628 sr |= (word)*ibuf++ << 2;
|
|
629 LARc[4] = sr & 0xf; sr >>= 4;
|
|
630 LARc[5] = sr & 0xf; sr >>= 4;
|
|
631 sr |= (word)*ibuf++ << 2; /* 5 */
|
|
632 LARc[6] = sr & 0x7; sr >>= 3;
|
|
633 LARc[7] = sr & 0x7; sr >>= 3;
|
|
634 sr |= (word)*ibuf++ << 4;
|
|
635 Nc[0] = sr & 0x7f; sr >>= 7;
|
|
636 bc[0] = sr & 0x3; sr >>= 2;
|
|
637 Mc[0] = sr & 0x3; sr >>= 2;
|
|
638 sr |= (word)*ibuf++ << 1;
|
|
639 xmaxc[0] = sr & 0x3f; sr >>= 6;
|
|
640 xmc[0] = sr & 0x7; sr >>= 3;
|
|
641 sr = *ibuf++;
|
|
642 xmc[1] = sr & 0x7; sr >>= 3;
|
|
643 xmc[2] = sr & 0x7; sr >>= 3;
|
|
644 sr |= (word)*ibuf++ << 2;
|
|
645 xmc[3] = sr & 0x7; sr >>= 3;
|
|
646 xmc[4] = sr & 0x7; sr >>= 3;
|
|
647 xmc[5] = sr & 0x7; sr >>= 3;
|
|
648 sr |= (word)*ibuf++ << 1; /* 10 */
|
|
649 xmc[6] = sr & 0x7; sr >>= 3;
|
|
650 xmc[7] = sr & 0x7; sr >>= 3;
|
|
651 xmc[8] = sr & 0x7; sr >>= 3;
|
|
652 sr = *ibuf++;
|
|
653 xmc[9] = sr & 0x7; sr >>= 3;
|
|
654 xmc[10] = sr & 0x7; sr >>= 3;
|
|
655 sr |= (word)*ibuf++ << 2;
|
|
656 xmc[11] = sr & 0x7; sr >>= 3;
|
|
657 xmc[12] = sr & 0x7; sr >>= 3;
|
|
658 sr |= (word)*ibuf++ << 4;
|
|
659 Nc[1] = sr & 0x7f; sr >>= 7;
|
|
660 bc[1] = sr & 0x3; sr >>= 2;
|
|
661 Mc[1] = sr & 0x3; sr >>= 2;
|
|
662 sr |= (word)*ibuf++ << 1;
|
|
663 xmaxc[1] = sr & 0x3f; sr >>= 6;
|
|
664 xmc[13] = sr & 0x7; sr >>= 3;
|
|
665 sr = *ibuf++; /* 15 */
|
|
666 xmc[14] = sr & 0x7; sr >>= 3;
|
|
667 xmc[15] = sr & 0x7; sr >>= 3;
|
|
668 sr |= (word)*ibuf++ << 2;
|
|
669 xmc[16] = sr & 0x7; sr >>= 3;
|
|
670 xmc[17] = sr & 0x7; sr >>= 3;
|
|
671 xmc[18] = sr & 0x7; sr >>= 3;
|
|
672 sr |= (word)*ibuf++ << 1;
|
|
673 xmc[19] = sr & 0x7; sr >>= 3;
|
|
674 xmc[20] = sr & 0x7; sr >>= 3;
|
|
675 xmc[21] = sr & 0x7; sr >>= 3;
|
|
676 sr = *ibuf++;
|
|
677 xmc[22] = sr & 0x7; sr >>= 3;
|
|
678 xmc[23] = sr & 0x7; sr >>= 3;
|
|
679 sr |= (word)*ibuf++ << 2;
|
|
680 xmc[24] = sr & 0x7; sr >>= 3;
|
|
681 xmc[25] = sr & 0x7; sr >>= 3;
|
|
682 sr |= (word)*ibuf++ << 4; /* 20 */
|
|
683 Nc[2] = sr & 0x7f; sr >>= 7;
|
|
684 bc[2] = sr & 0x3; sr >>= 2;
|
|
685 Mc[2] = sr & 0x3; sr >>= 2;
|
|
686 sr |= (word)*ibuf++ << 1;
|
|
687 xmaxc[2] = sr & 0x3f; sr >>= 6;
|
|
688 xmc[26] = sr & 0x7; sr >>= 3;
|
|
689 sr = *ibuf++;
|
|
690 xmc[27] = sr & 0x7; sr >>= 3;
|
|
691 xmc[28] = sr & 0x7; sr >>= 3;
|
|
692 sr |= (word)*ibuf++ << 2;
|
|
693 xmc[29] = sr & 0x7; sr >>= 3;
|
|
694 xmc[30] = sr & 0x7; sr >>= 3;
|
|
695 xmc[31] = sr & 0x7; sr >>= 3;
|
|
696 sr |= (word)*ibuf++ << 1;
|
|
697 xmc[32] = sr & 0x7; sr >>= 3;
|
|
698 xmc[33] = sr & 0x7; sr >>= 3;
|
|
699 xmc[34] = sr & 0x7; sr >>= 3;
|
|
700 sr = *ibuf++; /* 25 */
|
|
701 xmc[35] = sr & 0x7; sr >>= 3;
|
|
702 xmc[36] = sr & 0x7; sr >>= 3;
|
|
703 sr |= (word)*ibuf++ << 2;
|
|
704 xmc[37] = sr & 0x7; sr >>= 3;
|
|
705 xmc[38] = sr & 0x7; sr >>= 3;
|
|
706 sr |= (word)*ibuf++ << 4;
|
|
707 Nc[3] = sr & 0x7f; sr >>= 7;
|
|
708 bc[3] = sr & 0x3; sr >>= 2;
|
|
709 Mc[3] = sr & 0x3; sr >>= 2;
|
|
710 sr |= (word)*ibuf++ << 1;
|
|
711 xmaxc[3] = sr & 0x3f; sr >>= 6;
|
|
712 xmc[39] = sr & 0x7; sr >>= 3;
|
|
713 sr = *ibuf++;
|
|
714 xmc[40] = sr & 0x7; sr >>= 3;
|
|
715 xmc[41] = sr & 0x7; sr >>= 3;
|
|
716 sr |= (word)*ibuf++ << 2; /* 30 */
|
|
717 xmc[42] = sr & 0x7; sr >>= 3;
|
|
718 xmc[43] = sr & 0x7; sr >>= 3;
|
|
719 xmc[44] = sr & 0x7; sr >>= 3;
|
|
720 sr |= (word)*ibuf++ << 1;
|
|
721 xmc[45] = sr & 0x7; sr >>= 3;
|
|
722 xmc[46] = sr & 0x7; sr >>= 3;
|
|
723 xmc[47] = sr & 0x7; sr >>= 3;
|
|
724 sr = *ibuf++;
|
|
725 xmc[48] = sr & 0x7; sr >>= 3;
|
|
726 xmc[49] = sr & 0x7; sr >>= 3;
|
|
727 sr |= (word)*ibuf++ << 2;
|
|
728 xmc[50] = sr & 0x7; sr >>= 3;
|
|
729 xmc[51] = sr & 0x7; sr >>= 3;
|
|
730
|
|
731 GSM_Decode(&gsm_state, LARc, Nc, bc, Mc, xmaxc, xmc, obuf);
|
|
732
|
|
733 /*
|
|
734 carry = sr & 0xf;
|
|
735 sr = carry;
|
|
736 */
|
|
737 /* 2nd frame */
|
|
738 sr &= 0xf;
|
|
739 sr |= (word)*ibuf++ << 4; /* 1 */
|
|
740 LARc[0] = sr & 0x3f; sr >>= 6;
|
|
741 LARc[1] = sr & 0x3f; sr >>= 6;
|
|
742 sr = *ibuf++;
|
|
743 LARc[2] = sr & 0x1f; sr >>= 5;
|
|
744 sr |= (word)*ibuf++ << 3;
|
|
745 LARc[3] = sr & 0x1f; sr >>= 5;
|
|
746 LARc[4] = sr & 0xf; sr >>= 4;
|
|
747 sr |= (word)*ibuf++ << 2;
|
|
748 LARc[5] = sr & 0xf; sr >>= 4;
|
|
749 LARc[6] = sr & 0x7; sr >>= 3;
|
|
750 LARc[7] = sr & 0x7; sr >>= 3;
|
|
751 sr = *ibuf++; /* 5 */
|
|
752 Nc[0] = sr & 0x7f; sr >>= 7;
|
|
753 sr |= (word)*ibuf++ << 1;
|
|
754 bc[0] = sr & 0x3; sr >>= 2;
|
|
755 Mc[0] = sr & 0x3; sr >>= 2;
|
|
756 sr |= (word)*ibuf++ << 5;
|
|
757 xmaxc[0] = sr & 0x3f; sr >>= 6;
|
|
758 xmc[0] = sr & 0x7; sr >>= 3;
|
|
759 xmc[1] = sr & 0x7; sr >>= 3;
|
|
760 sr |= (word)*ibuf++ << 1;
|
|
761 xmc[2] = sr & 0x7; sr >>= 3;
|
|
762 xmc[3] = sr & 0x7; sr >>= 3;
|
|
763 xmc[4] = sr & 0x7; sr >>= 3;
|
|
764 sr = *ibuf++;
|
|
765 xmc[5] = sr & 0x7; sr >>= 3;
|
|
766 xmc[6] = sr & 0x7; sr >>= 3;
|
|
767 sr |= (word)*ibuf++ << 2; /* 10 */
|
|
768 xmc[7] = sr & 0x7; sr >>= 3;
|
|
769 xmc[8] = sr & 0x7; sr >>= 3;
|
|
770 xmc[9] = sr & 0x7; sr >>= 3;
|
|
771 sr |= (word)*ibuf++ << 1;
|
|
772 xmc[10] = sr & 0x7; sr >>= 3;
|
|
773 xmc[11] = sr & 0x7; sr >>= 3;
|
|
774 xmc[12] = sr & 0x7; sr >>= 3;
|
|
775 sr = *ibuf++;
|
|
776 Nc[1] = sr & 0x7f; sr >>= 7;
|
|
777 sr |= (word)*ibuf++ << 1;
|
|
778 bc[1] = sr & 0x3; sr >>= 2;
|
|
779 Mc[1] = sr & 0x3; sr >>= 2;
|
|
780 sr |= (word)*ibuf++ << 5;
|
|
781 xmaxc[1] = sr & 0x3f; sr >>= 6;
|
|
782 xmc[13] = sr & 0x7; sr >>= 3;
|
|
783 xmc[14] = sr & 0x7; sr >>= 3;
|
|
784 sr |= (word)*ibuf++ << 1; /* 15 */
|
|
785 xmc[15] = sr & 0x7; sr >>= 3;
|
|
786 xmc[16] = sr & 0x7; sr >>= 3;
|
|
787 xmc[17] = sr & 0x7; sr >>= 3;
|
|
788 sr = *ibuf++;
|
|
789 xmc[18] = sr & 0x7; sr >>= 3;
|
|
790 xmc[19] = sr & 0x7; sr >>= 3;
|
|
791 sr |= (word)*ibuf++ << 2;
|
|
792 xmc[20] = sr & 0x7; sr >>= 3;
|
|
793 xmc[21] = sr & 0x7; sr >>= 3;
|
|
794 xmc[22] = sr & 0x7; sr >>= 3;
|
|
795 sr |= (word)*ibuf++ << 1;
|
|
796 xmc[23] = sr & 0x7; sr >>= 3;
|
|
797 xmc[24] = sr & 0x7; sr >>= 3;
|
|
798 xmc[25] = sr & 0x7; sr >>= 3;
|
|
799 sr = *ibuf++;
|
|
800 Nc[2] = sr & 0x7f; sr >>= 7;
|
|
801 sr |= (word)*ibuf++ << 1; /* 20 */
|
|
802 bc[2] = sr & 0x3; sr >>= 2;
|
|
803 Mc[2] = sr & 0x3; sr >>= 2;
|
|
804 sr |= (word)*ibuf++ << 5;
|
|
805 xmaxc[2] = sr & 0x3f; sr >>= 6;
|
|
806 xmc[26] = sr & 0x7; sr >>= 3;
|
|
807 xmc[27] = sr & 0x7; sr >>= 3;
|
|
808 sr |= (word)*ibuf++ << 1;
|
|
809 xmc[28] = sr & 0x7; sr >>= 3;
|
|
810 xmc[29] = sr & 0x7; sr >>= 3;
|
|
811 xmc[30] = sr & 0x7; sr >>= 3;
|
|
812 sr = *ibuf++;
|
|
813 xmc[31] = sr & 0x7; sr >>= 3;
|
|
814 xmc[32] = sr & 0x7; sr >>= 3;
|
|
815 sr |= (word)*ibuf++ << 2;
|
|
816 xmc[33] = sr & 0x7; sr >>= 3;
|
|
817 xmc[34] = sr & 0x7; sr >>= 3;
|
|
818 xmc[35] = sr & 0x7; sr >>= 3;
|
|
819 sr |= (word)*ibuf++ << 1; /* 25 */
|
|
820 xmc[36] = sr & 0x7; sr >>= 3;
|
|
821 xmc[37] = sr & 0x7; sr >>= 3;
|
|
822 xmc[38] = sr & 0x7; sr >>= 3;
|
|
823 sr = *ibuf++;
|
|
824 Nc[3] = sr & 0x7f; sr >>= 7;
|
|
825 sr |= (word)*ibuf++ << 1;
|
|
826 bc[3] = sr & 0x3; sr >>= 2;
|
|
827 Mc[3] = sr & 0x3; sr >>= 2;
|
|
828 sr |= (word)*ibuf++ << 5;
|
|
829 xmaxc[3] = sr & 0x3f; sr >>= 6;
|
|
830 xmc[39] = sr & 0x7; sr >>= 3;
|
|
831 xmc[40] = sr & 0x7; sr >>= 3;
|
|
832 sr |= (word)*ibuf++ << 1;
|
|
833 xmc[41] = sr & 0x7; sr >>= 3;
|
|
834 xmc[42] = sr & 0x7; sr >>= 3;
|
|
835 xmc[43] = sr & 0x7; sr >>= 3;
|
|
836 sr = (word)*ibuf++; /* 30 */
|
|
837 xmc[44] = sr & 0x7; sr >>= 3;
|
|
838 xmc[45] = sr & 0x7; sr >>= 3;
|
|
839 sr |= (word)*ibuf++ << 2;
|
|
840 xmc[46] = sr & 0x7; sr >>= 3;
|
|
841 xmc[47] = sr & 0x7; sr >>= 3;
|
|
842 xmc[48] = sr & 0x7; sr >>= 3;
|
|
843 sr |= (word)*ibuf++ << 1;
|
|
844 xmc[49] = sr & 0x7; sr >>= 3;
|
|
845 xmc[50] = sr & 0x7; sr >>= 3;
|
|
846 xmc[51] = sr & 0x7; sr >>= 3;
|
|
847
|
|
848 GSM_Decode(&gsm_state, LARc, Nc, bc, Mc, xmaxc, xmc, &obuf[160]);
|
|
849
|
|
850 /* Return number of source bytes consumed and output samples produced */
|
|
851 // *icnt = 65;
|
|
852 // *ocnt = 320;
|
|
853 return;
|
|
854 }
|
|
855
|
|
856 #define GSM_MAGIC 0xd
|
|
857
|
|
858 void XA_GSM_Decoder(unsigned char *ibuf,unsigned short *obuf)
|
|
859 { word LARc[8], Nc[4], Mc[4], bc[4], xmaxc[4], xmc[13*4];
|
|
860
|
|
861 /* Sanity */
|
|
862 if (((*ibuf >> 4) & 0x0F) != GSM_MAGIC)
|
|
863 { int i;
|
|
864 for(i=0;i<160;i++) obuf[i] = 0;
|
|
865 // *icnt = 33;
|
|
866 // *ocnt = 160;
|
|
867 return;
|
|
868 }
|
|
869
|
|
870 LARc[0] = (*ibuf++ & 0xF) << 2; /* 1 */
|
|
871 LARc[0] |= (*ibuf >> 6) & 0x3;
|
|
872 LARc[1] = *ibuf++ & 0x3F;
|
|
873 LARc[2] = (*ibuf >> 3) & 0x1F;
|
|
874 LARc[3] = (*ibuf++ & 0x7) << 2;
|
|
875 LARc[3] |= (*ibuf >> 6) & 0x3;
|
|
876 LARc[4] = (*ibuf >> 2) & 0xF;
|
|
877 LARc[5] = (*ibuf++ & 0x3) << 2;
|
|
878 LARc[5] |= (*ibuf >> 6) & 0x3;
|
|
879 LARc[6] = (*ibuf >> 3) & 0x7;
|
|
880 LARc[7] = *ibuf++ & 0x7;
|
|
881
|
|
882 Nc[0] = (*ibuf >> 1) & 0x7F;
|
|
883
|
|
884 bc[0] = (*ibuf++ & 0x1) << 1;
|
|
885 bc[0] |= (*ibuf >> 7) & 0x1;
|
|
886
|
|
887 Mc[0] = (*ibuf >> 5) & 0x3;
|
|
888
|
|
889 xmaxc[0] = (*ibuf++ & 0x1F) << 1;
|
|
890 xmaxc[0] |= (*ibuf >> 7) & 0x1;
|
|
891
|
|
892 xmc[0] = (*ibuf >> 4) & 0x7;
|
|
893 xmc[1] = (*ibuf >> 1) & 0x7;
|
|
894 xmc[2] = (*ibuf++ & 0x1) << 2;
|
|
895 xmc[2] |= (*ibuf >> 6) & 0x3;
|
|
896 xmc[3] = (*ibuf >> 3) & 0x7;
|
|
897 xmc[4] = *ibuf++ & 0x7;
|
|
898 xmc[5] = (*ibuf >> 5) & 0x7;
|
|
899 xmc[6] = (*ibuf >> 2) & 0x7;
|
|
900 xmc[7] = (*ibuf++ & 0x3) << 1; /* 10 */
|
|
901 xmc[7] |= (*ibuf >> 7) & 0x1;
|
|
902 xmc[8] = (*ibuf >> 4) & 0x7;
|
|
903 xmc[9] = (*ibuf >> 1) & 0x7;
|
|
904 xmc[10] = (*ibuf++ & 0x1) << 2;
|
|
905 xmc[10] |= (*ibuf >> 6) & 0x3;
|
|
906 xmc[11] = (*ibuf >> 3) & 0x7;
|
|
907 xmc[12] = *ibuf++ & 0x7;
|
|
908
|
|
909 Nc[1] = (*ibuf >> 1) & 0x7F;
|
|
910
|
|
911 bc[1] = (*ibuf++ & 0x1) << 1;
|
|
912 bc[1] |= (*ibuf >> 7) & 0x1;
|
|
913
|
|
914 Mc[1] = (*ibuf >> 5) & 0x3;
|
|
915
|
|
916 xmaxc[1] = (*ibuf++ & 0x1F) << 1;
|
|
917 xmaxc[1] |= (*ibuf >> 7) & 0x1;
|
|
918
|
|
919
|
|
920 xmc[13] = (*ibuf >> 4) & 0x7;
|
|
921 xmc[14] = (*ibuf >> 1) & 0x7;
|
|
922 xmc[15] = (*ibuf++ & 0x1) << 2;
|
|
923 xmc[15] |= (*ibuf >> 6) & 0x3;
|
|
924 xmc[16] = (*ibuf >> 3) & 0x7;
|
|
925 xmc[17] = *ibuf++ & 0x7;
|
|
926 xmc[18] = (*ibuf >> 5) & 0x7;
|
|
927 xmc[19] = (*ibuf >> 2) & 0x7;
|
|
928 xmc[20] = (*ibuf++ & 0x3) << 1;
|
|
929 xmc[20] |= (*ibuf >> 7) & 0x1;
|
|
930 xmc[21] = (*ibuf >> 4) & 0x7;
|
|
931 xmc[22] = (*ibuf >> 1) & 0x7;
|
|
932 xmc[23] = (*ibuf++ & 0x1) << 2;
|
|
933 xmc[23] |= (*ibuf >> 6) & 0x3;
|
|
934 xmc[24] = (*ibuf >> 3) & 0x7;
|
|
935 xmc[25] = *ibuf++ & 0x7;
|
|
936
|
|
937 Nc[2] = (*ibuf >> 1) & 0x7F;
|
|
938
|
|
939 bc[2] = (*ibuf++ & 0x1) << 1; /* 20 */
|
|
940 bc[2] |= (*ibuf >> 7) & 0x1;
|
|
941
|
|
942 Mc[2] = (*ibuf >> 5) & 0x3;
|
|
943
|
|
944 xmaxc[2] = (*ibuf++ & 0x1F) << 1;
|
|
945 xmaxc[2] |= (*ibuf >> 7) & 0x1;
|
|
946
|
|
947
|
|
948 xmc[26] = (*ibuf >> 4) & 0x7;
|
|
949 xmc[27] = (*ibuf >> 1) & 0x7;
|
|
950 xmc[28] = (*ibuf++ & 0x1) << 2;
|
|
951 xmc[28] |= (*ibuf >> 6) & 0x3;
|
|
952 xmc[29] = (*ibuf >> 3) & 0x7;
|
|
953 xmc[30] = *ibuf++ & 0x7;
|
|
954 xmc[31] = (*ibuf >> 5) & 0x7;
|
|
955 xmc[32] = (*ibuf >> 2) & 0x7;
|
|
956 xmc[33] = (*ibuf++ & 0x3) << 1;
|
|
957 xmc[33] |= (*ibuf >> 7) & 0x1;
|
|
958 xmc[34] = (*ibuf >> 4) & 0x7;
|
|
959 xmc[35] = (*ibuf >> 1) & 0x7;
|
|
960 xmc[36] = (*ibuf++ & 0x1) << 2;
|
|
961 xmc[36] |= (*ibuf >> 6) & 0x3;
|
|
962 xmc[37] = (*ibuf >> 3) & 0x7;
|
|
963 xmc[38] = *ibuf++ & 0x7;
|
|
964
|
|
965 Nc[3] = (*ibuf >> 1) & 0x7F;
|
|
966
|
|
967 bc[3] = (*ibuf++ & 0x1) << 1;
|
|
968 bc[3] |= (*ibuf >> 7) & 0x1;
|
|
969
|
|
970 Mc[3] = (*ibuf >> 5) & 0x3;
|
|
971
|
|
972 xmaxc[3] = (*ibuf++ & 0x1F) << 1;
|
|
973 xmaxc[3] |= (*ibuf >> 7) & 0x1;
|
|
974
|
|
975 xmc[39] = (*ibuf >> 4) & 0x7;
|
|
976 xmc[40] = (*ibuf >> 1) & 0x7;
|
|
977 xmc[41] = (*ibuf++ & 0x1) << 2;
|
|
978 xmc[41] |= (*ibuf >> 6) & 0x3;
|
|
979 xmc[42] = (*ibuf >> 3) & 0x7;
|
|
980 xmc[43] = *ibuf++ & 0x7; /* 30 */
|
|
981 xmc[44] = (*ibuf >> 5) & 0x7;
|
|
982 xmc[45] = (*ibuf >> 2) & 0x7;
|
|
983 xmc[46] = (*ibuf++ & 0x3) << 1;
|
|
984 xmc[46] |= (*ibuf >> 7) & 0x1;
|
|
985 xmc[47] = (*ibuf >> 4) & 0x7;
|
|
986 xmc[48] = (*ibuf >> 1) & 0x7;
|
|
987 xmc[49] = (*ibuf++ & 0x1) << 2;
|
|
988 xmc[49] |= (*ibuf >> 6) & 0x3;
|
|
989 xmc[50] = (*ibuf >> 3) & 0x7;
|
|
990 xmc[51] = *ibuf & 0x7; /* 33 */
|
|
991
|
|
992 GSM_Decode(&gsm_state, LARc, Nc, bc, Mc, xmaxc, xmc, obuf);
|
|
993
|
|
994 /* Return number of source bytes consumed and output samples produced */
|
|
995 // *icnt = 33;
|
|
996 // *ocnt = 160;
|
|
997 }
|