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