annotate libmpcodecs/native/xa_gsm.c @ 30773:e40e03e0b5df

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