2
|
1 /*
|
|
2 * Copyright 1992 by Jutta Degener and Carsten Bormann, Technische
|
|
3 * Universitaet Berlin. See the accompanying file "COPYRIGHT" for
|
|
4 * details. THERE IS ABSOLUTELY NO WARRANTY FOR THIS SOFTWARE.
|
|
5 */
|
|
6
|
|
7 /* $Header: /home/kbs/jutta/src/gsm/gsm-1.0/src/RCS/gsm_encode.c,v 1.1 1992/10/28 00:15:50 jutta Exp $ */
|
|
8
|
|
9 #include "private.h"
|
|
10 #include "gsm.h"
|
|
11 #include "proto.h"
|
|
12
|
|
13 void gsm_encode P3((s, source, c), gsm s, gsm_signal * source,
|
|
14 gsm_byte * c)
|
|
15 {
|
|
16 word LARc[8], Nc[4], Mc[4], bc[4], xmaxc[4], xmc[13 * 4];
|
|
17
|
|
18 Gsm_Coder(s, source, LARc, Nc, bc, Mc, xmaxc, xmc);
|
|
19
|
|
20
|
|
21 /* variable size
|
|
22
|
|
23 GSM_MAGIC 4
|
|
24
|
|
25 LARc[0] 6
|
|
26 LARc[1] 6
|
|
27 LARc[2] 5
|
|
28 LARc[3] 5
|
|
29 LARc[4] 4
|
|
30 LARc[5] 4
|
|
31 LARc[6] 3
|
|
32 LARc[7] 3
|
|
33
|
|
34 Nc[0] 7
|
|
35 bc[0] 2
|
|
36 Mc[0] 2
|
|
37 xmaxc[0] 6
|
|
38 xmc[0] 3
|
|
39 xmc[1] 3
|
|
40 xmc[2] 3
|
|
41 xmc[3] 3
|
|
42 xmc[4] 3
|
|
43 xmc[5] 3
|
|
44 xmc[6] 3
|
|
45 xmc[7] 3
|
|
46 xmc[8] 3
|
|
47 xmc[9] 3
|
|
48 xmc[10] 3
|
|
49 xmc[11] 3
|
|
50 xmc[12] 3
|
|
51
|
|
52 Nc[1] 7
|
|
53 bc[1] 2
|
|
54 Mc[1] 2
|
|
55 xmaxc[1] 6
|
|
56 xmc[13] 3
|
|
57 xmc[14] 3
|
|
58 xmc[15] 3
|
|
59 xmc[16] 3
|
|
60 xmc[17] 3
|
|
61 xmc[18] 3
|
|
62 xmc[19] 3
|
|
63 xmc[20] 3
|
|
64 xmc[21] 3
|
|
65 xmc[22] 3
|
|
66 xmc[23] 3
|
|
67 xmc[24] 3
|
|
68 xmc[25] 3
|
|
69
|
|
70 Nc[2] 7
|
|
71 bc[2] 2
|
|
72 Mc[2] 2
|
|
73 xmaxc[2] 6
|
|
74 xmc[26] 3
|
|
75 xmc[27] 3
|
|
76 xmc[28] 3
|
|
77 xmc[29] 3
|
|
78 xmc[30] 3
|
|
79 xmc[31] 3
|
|
80 xmc[32] 3
|
|
81 xmc[33] 3
|
|
82 xmc[34] 3
|
|
83 xmc[35] 3
|
|
84 xmc[36] 3
|
|
85 xmc[37] 3
|
|
86 xmc[38] 3
|
|
87
|
|
88 Nc[3] 7
|
|
89 bc[3] 2
|
|
90 Mc[3] 2
|
|
91 xmaxc[3] 6
|
|
92 xmc[39] 3
|
|
93 xmc[40] 3
|
|
94 xmc[41] 3
|
|
95 xmc[42] 3
|
|
96 xmc[43] 3
|
|
97 xmc[44] 3
|
|
98 xmc[45] 3
|
|
99 xmc[46] 3
|
|
100 xmc[47] 3
|
|
101 xmc[48] 3
|
|
102 xmc[49] 3
|
|
103 xmc[50] 3
|
|
104 xmc[51] 3
|
|
105 */
|
|
106
|
|
107
|
|
108 *c++ = ((GSM_MAGIC & 0xF) << 4) /* 1 */
|
|
109 |((LARc[0] >> 2) & 0xF);
|
|
110 *c++ = ((LARc[0] & 0x3) << 6)
|
|
111 | (LARc[1] & 0x3F);
|
|
112 *c++ = ((LARc[2] & 0x1F) << 3)
|
|
113 | ((LARc[3] >> 2) & 0x7);
|
|
114 *c++ = ((LARc[3] & 0x3) << 6)
|
|
115 | ((LARc[4] & 0xF) << 2)
|
|
116 | ((LARc[5] >> 2) & 0x3);
|
|
117 *c++ = ((LARc[5] & 0x3) << 6)
|
|
118 | ((LARc[6] & 0x7) << 3)
|
|
119 | (LARc[7] & 0x7);
|
|
120 *c++ = ((Nc[0] & 0x7F) << 1)
|
|
121 | ((bc[0] >> 1) & 0x1);
|
|
122 *c++ = ((bc[0] & 0x1) << 7)
|
|
123 | ((Mc[0] & 0x3) << 5)
|
|
124 | ((xmaxc[0] >> 1) & 0x1F);
|
|
125 *c++ = ((xmaxc[0] & 0x1) << 7)
|
|
126 | ((xmc[0] & 0x7) << 4)
|
|
127 | ((xmc[1] & 0x7) << 1)
|
|
128 | ((xmc[2] >> 2) & 0x1);
|
|
129 *c++ = ((xmc[2] & 0x3) << 6)
|
|
130 | ((xmc[3] & 0x7) << 3)
|
|
131 | (xmc[4] & 0x7);
|
|
132 *c++ = ((xmc[5] & 0x7) << 5) /* 10 */
|
|
133 |((xmc[6] & 0x7) << 2)
|
|
134 | ((xmc[7] >> 1) & 0x3);
|
|
135 *c++ = ((xmc[7] & 0x1) << 7)
|
|
136 | ((xmc[8] & 0x7) << 4)
|
|
137 | ((xmc[9] & 0x7) << 1)
|
|
138 | ((xmc[10] >> 2) & 0x1);
|
|
139 *c++ = ((xmc[10] & 0x3) << 6)
|
|
140 | ((xmc[11] & 0x7) << 3)
|
|
141 | (xmc[12] & 0x7);
|
|
142 *c++ = ((Nc[1] & 0x7F) << 1)
|
|
143 | ((bc[1] >> 1) & 0x1);
|
|
144 *c++ = ((bc[1] & 0x1) << 7)
|
|
145 | ((Mc[1] & 0x3) << 5)
|
|
146 | ((xmaxc[1] >> 1) & 0x1F);
|
|
147 *c++ = ((xmaxc[1] & 0x1) << 7)
|
|
148 | ((xmc[13] & 0x7) << 4)
|
|
149 | ((xmc[14] & 0x7) << 1)
|
|
150 | ((xmc[15] >> 2) & 0x1);
|
|
151 *c++ = ((xmc[15] & 0x3) << 6)
|
|
152 | ((xmc[16] & 0x7) << 3)
|
|
153 | (xmc[17] & 0x7);
|
|
154 *c++ = ((xmc[18] & 0x7) << 5)
|
|
155 | ((xmc[19] & 0x7) << 2)
|
|
156 | ((xmc[20] >> 1) & 0x3);
|
|
157 *c++ = ((xmc[20] & 0x1) << 7)
|
|
158 | ((xmc[21] & 0x7) << 4)
|
|
159 | ((xmc[22] & 0x7) << 1)
|
|
160 | ((xmc[23] >> 2) & 0x1);
|
|
161 *c++ = ((xmc[23] & 0x3) << 6)
|
|
162 | ((xmc[24] & 0x7) << 3)
|
|
163 | (xmc[25] & 0x7);
|
|
164 *c++ = ((Nc[2] & 0x7F) << 1) /* 20 */
|
|
165 |((bc[2] >> 1) & 0x1);
|
|
166 *c++ = ((bc[2] & 0x1) << 7)
|
|
167 | ((Mc[2] & 0x3) << 5)
|
|
168 | ((xmaxc[2] >> 1) & 0x1F);
|
|
169 *c++ = ((xmaxc[2] & 0x1) << 7)
|
|
170 | ((xmc[26] & 0x7) << 4)
|
|
171 | ((xmc[27] & 0x7) << 1)
|
|
172 | ((xmc[28] >> 2) & 0x1);
|
|
173 *c++ = ((xmc[28] & 0x3) << 6)
|
|
174 | ((xmc[29] & 0x7) << 3)
|
|
175 | (xmc[30] & 0x7);
|
|
176 *c++ = ((xmc[31] & 0x7) << 5)
|
|
177 | ((xmc[32] & 0x7) << 2)
|
|
178 | ((xmc[33] >> 1) & 0x3);
|
|
179 *c++ = ((xmc[33] & 0x1) << 7)
|
|
180 | ((xmc[34] & 0x7) << 4)
|
|
181 | ((xmc[35] & 0x7) << 1)
|
|
182 | ((xmc[36] >> 2) & 0x1);
|
|
183 *c++ = ((xmc[36] & 0x3) << 6)
|
|
184 | ((xmc[37] & 0x7) << 3)
|
|
185 | (xmc[38] & 0x7);
|
|
186 *c++ = ((Nc[3] & 0x7F) << 1)
|
|
187 | ((bc[3] >> 1) & 0x1);
|
|
188 *c++ = ((bc[3] & 0x1) << 7)
|
|
189 | ((Mc[3] & 0x3) << 5)
|
|
190 | ((xmaxc[3] >> 1) & 0x1F);
|
|
191 *c++ = ((xmaxc[3] & 0x1) << 7)
|
|
192 | ((xmc[39] & 0x7) << 4)
|
|
193 | ((xmc[40] & 0x7) << 1)
|
|
194 | ((xmc[41] >> 2) & 0x1);
|
|
195 *c++ = ((xmc[41] & 0x3) << 6) /* 30 */
|
|
196 |((xmc[42] & 0x7) << 3)
|
|
197 | (xmc[43] & 0x7);
|
|
198 *c++ = ((xmc[44] & 0x7) << 5)
|
|
199 | ((xmc[45] & 0x7) << 2)
|
|
200 | ((xmc[46] >> 1) & 0x3);
|
|
201 *c++ = ((xmc[46] & 0x1) << 7)
|
|
202 | ((xmc[47] & 0x7) << 4)
|
|
203 | ((xmc[48] & 0x7) << 1)
|
|
204 | ((xmc[49] >> 2) & 0x1);
|
|
205 *c++ = ((xmc[49] & 0x3) << 6)
|
|
206 | ((xmc[50] & 0x7) << 3)
|
|
207 | (xmc[51] & 0x7);
|
|
208 }
|