0
|
1 |
// Copyright (c) 2000-2010 Nokia Corporation and/or its subsidiary(-ies).
|
|
2 |
// All rights reserved.
|
|
3 |
// This component and the accompanying materials are made available
|
|
4 |
// under the terms of "Eclipse Public License v1.0"
|
|
5 |
// which accompanies this distribution, and is available
|
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
7 |
//
|
|
8 |
// Initial Contributors:
|
|
9 |
// Nokia Corporation - initial contribution.
|
|
10 |
//
|
|
11 |
// Contributors:
|
|
12 |
//
|
|
13 |
// Description:
|
|
14 |
// Polymorphic DLL implementation of GSM 6.10 full rate (FR) speech coder
|
|
15 |
// and decoder objects.
|
|
16 |
// This codec is based on ANSI C simulation codes. For this implementation
|
|
17 |
// (polymorphic DLL) the original ANSI C codes have been modified slightly:
|
|
18 |
// - The original .c files were renamed to .cpp files.
|
|
19 |
// - All global varibles (codec's state) are now encoder's or decoder's
|
|
20 |
// private member variables.
|
|
21 |
// - Because codec's state is in the codec object, an extra variable -
|
|
22 |
// a pointer codec object - have been added to some original routines.
|
|
23 |
// - Global tables are now const C++ tables in tables.h header file.
|
|
24 |
// - VAD and DTX modules have been removed from the original routines.
|
|
25 |
// - Due to error in GNU tool chain all array indexes of type [i-1] in
|
|
26 |
// rpeltp.cpp have been removed and changed to [j] type.
|
|
27 |
// - multr, L_add, L_mac from basicop.cpp inlined
|
|
28 |
// INCLUDES
|
|
29 |
//
|
|
30 |
//
|
|
31 |
|
|
32 |
#include "gsm610fr.h"
|
|
33 |
#include "codec.h"
|
|
34 |
#include <e32uid.h>
|
|
35 |
|
|
36 |
#include "rpeltp.h"
|
|
37 |
|
|
38 |
// LOCAL FUNCTIONS
|
|
39 |
//===================================================================
|
|
40 |
/*
|
|
41 |
-----------------------------------------------------------------------------
|
|
42 |
|
|
43 |
GSM610FR_Encoder
|
|
44 |
|
|
45 |
ConstructL
|
|
46 |
|
|
47 |
This function implements the second phase construction of GSM610FR_Encoder
|
|
48 |
class. Function binds the encoder to given input and output streams and
|
|
49 |
resets encoder.
|
|
50 |
|
|
51 |
Parameters: RReadStream aInStrm Handle to input stream (16 bit
|
|
52 |
PCM speech data)
|
|
53 |
RWriteStream aOutStrm Handle to output stream (encoded
|
|
54 |
speech data)
|
|
55 |
|
|
56 |
Return Values: none
|
|
57 |
|
|
58 |
-----------------------------------------------------------------------------
|
|
59 |
*/
|
|
60 |
void CGSM610FR_Encoder::ConstructL()
|
|
61 |
{
|
|
62 |
::reset_encoder(this);
|
|
63 |
iOddFrame = TRUE;
|
|
64 |
}
|
|
65 |
|
|
66 |
|
|
67 |
/*
|
|
68 |
-----------------------------------------------------------------------------
|
|
69 |
|
|
70 |
GSM610FR_Encoder
|
|
71 |
|
|
72 |
~GSM610FR_Encoder
|
|
73 |
|
|
74 |
Empty encoder destructor.
|
|
75 |
|
|
76 |
Parameters: none
|
|
77 |
|
|
78 |
Return Values: none
|
|
79 |
|
|
80 |
-----------------------------------------------------------------------------
|
|
81 |
*/
|
|
82 |
CGSM610FR_Encoder::~CGSM610FR_Encoder()
|
|
83 |
{
|
|
84 |
}
|
|
85 |
|
|
86 |
|
|
87 |
/*
|
|
88 |
-----------------------------------------------------------------------------
|
|
89 |
|
|
90 |
GSM610FR_Encoder
|
|
91 |
|
|
92 |
StartL
|
|
93 |
|
|
94 |
Start encoder object. Initialize codec status.
|
|
95 |
|
|
96 |
Parameters: none
|
|
97 |
|
|
98 |
Return Values: none
|
|
99 |
|
|
100 |
-----------------------------------------------------------------------------
|
|
101 |
*/
|
|
102 |
void CGSM610FR_Encoder::StartL()
|
|
103 |
{
|
|
104 |
::reset_encoder(this);
|
|
105 |
iOddFrame = TRUE;
|
|
106 |
}
|
|
107 |
|
|
108 |
|
|
109 |
/*
|
|
110 |
-----------------------------------------------------------------------------
|
|
111 |
|
|
112 |
GSM610FR_Encoder
|
|
113 |
|
|
114 |
ExecuteL
|
|
115 |
|
|
116 |
Execute encoder object. Read one speech frame from the input stream,
|
|
117 |
RPELTP encode it and write the encoded frame to output stream.
|
|
118 |
|
|
119 |
Parameters: none
|
|
120 |
|
|
121 |
Return Values: none
|
|
122 |
|
|
123 |
Leave Handling:
|
|
124 |
|
|
125 |
If the length of data available in the input stream is less than
|
|
126 |
FRAMESIZE then the function leaves with KErrEof.
|
|
127 |
|
|
128 |
-----------------------------------------------------------------------------
|
|
129 |
*/
|
|
130 |
void CGSM610FR_Encoder::ExecuteL(TUint8* aInBuf, TUint8* aOutBuf)
|
|
131 |
{
|
|
132 |
TInt16* inBufPtr = (TInt16*) aInBuf;
|
|
133 |
|
|
134 |
|
|
135 |
for (TInt frame = 0; frame < 2; frame++)
|
|
136 |
{
|
|
137 |
::RPELTP_encoder(this, inBufPtr, &iCodeBuf);
|
|
138 |
|
|
139 |
if ( iOddFrame )
|
|
140 |
{
|
|
141 |
PackFrame0 (&iCodeBuf, (TInt8*) aOutBuf);
|
|
142 |
}
|
|
143 |
else
|
|
144 |
{
|
|
145 |
PackFrame1 (&iCodeBuf, (TInt8*) aOutBuf);
|
|
146 |
}
|
|
147 |
|
|
148 |
iOddFrame = !iOddFrame;
|
|
149 |
inBufPtr += FRAMESIZE;
|
|
150 |
}
|
|
151 |
|
|
152 |
}
|
|
153 |
/*
|
|
154 |
-----------------------------------------------------------------------------
|
|
155 |
|
|
156 |
GSM610FR_Encoder
|
|
157 |
|
|
158 |
StopL
|
|
159 |
|
|
160 |
Stop encoder object. Flush out last frames, if necessary.
|
|
161 |
|
|
162 |
Parameters: none
|
|
163 |
|
|
164 |
Return Values: none
|
|
165 |
|
|
166 |
-----------------------------------------------------------------------------
|
|
167 |
*/
|
|
168 |
void CGSM610FR_Encoder::StopL()
|
|
169 |
{
|
|
170 |
}
|
|
171 |
|
|
172 |
void CGSM610FR_Encoder::Release()
|
|
173 |
{
|
|
174 |
delete this;
|
|
175 |
}
|
|
176 |
|
|
177 |
/*
|
|
178 |
-----------------------------------------------------------------------------
|
|
179 |
|
|
180 |
GSM610FR_Encoder
|
|
181 |
|
|
182 |
PackFrame0
|
|
183 |
|
|
184 |
Pack the codewords of the even frame into pack buffer.
|
|
185 |
|
|
186 |
Packing as in MS gsm610 encoder.
|
|
187 |
|
|
188 |
Parameters: struct codes* aCodeBuf Code words for one speech frame.
|
|
189 |
|
|
190 |
Return Values: none
|
|
191 |
|
|
192 |
|
|
193 |
-----------------------------------------------------------------------------
|
|
194 |
*/
|
|
195 |
void CGSM610FR_Encoder::PackFrame0(struct codes* aCodeBuf, TInt8* pbuf)
|
|
196 |
{
|
|
197 |
TInt16* LAR = aCodeBuf->LARc;
|
|
198 |
|
|
199 |
// pack the LARc[0..7] into the first 4.5 bytes
|
|
200 |
*pbuf++ = (TUint8)(((LAR[0] ) & 0x3F) | ((LAR[1] << 6) & 0xC0));
|
|
201 |
*pbuf++ = (TUint8)(((LAR[1] >> 2) & 0x0F) | ((LAR[2] << 4) & 0xF0));
|
|
202 |
*pbuf++ = (TUint8)(((LAR[2] >> 4) & 0x01) | ((LAR[3] << 1) & 0x3E) | ((LAR[4] << 6) & 0xC0));
|
|
203 |
*pbuf++ = (TUint8)(((LAR[4] >> 2) & 0x03) | ((LAR[5] << 2) & 0x3C) | ((LAR[6] << 6) & 0xC0));
|
|
204 |
*pbuf = (TUint8)(((LAR[6] >> 2) & 0x01) | ((LAR[7] << 1) & 0x0E));
|
|
205 |
|
|
206 |
// pack Nc, bc, Mc, xmaxc, and xMc for each of the 4 sub-frames
|
|
207 |
for(TInt i = 0; i < 4; i++)
|
|
208 |
{
|
|
209 |
struct sfcodes& c = aCodeBuf->sfc[i];
|
|
210 |
*pbuf++ |= ((c.Nc << 4) & 0xF0);
|
|
211 |
*pbuf++ = (TUint8)(((c.Nc >> 4) & 0x07) | ((c.bc << 3) & 0x18) | ((c.Mc << 5) & 0x60) | ((c.xmaxc << 7) & 0x80));
|
|
212 |
*pbuf++ = (TUint8)(((c.xmaxc >> 1) & 0x1F) | ((c.xMc[0] << 5) & 0xE0));
|
|
213 |
*pbuf++ = (TUint8)((c.xMc[1] & 0x07) | ((c.xMc[2] << 3) & 0x38) | ((c.xMc[3] << 6) & 0xC0));
|
|
214 |
*pbuf++ = (TUint8)(((c.xMc[3] >> 2) & 0x01) | ((c.xMc[4] << 1) & 0x0E) | ((c.xMc[5] << 4) & 0x70) | ((c.xMc[6] << 7) & 0x80));
|
|
215 |
*pbuf++ = (TUint8)(((c.xMc[6] >> 1) & 0x03) | ((c.xMc[7] << 2) & 0x1C) | ((c.xMc[8] << 5) & 0xE0));
|
|
216 |
*pbuf++ = (TUint8)((c.xMc[9] & 0x07) | ((c.xMc[10] << 3) & 0x38) | ((c.xMc[11] << 6) & 0xC0));
|
|
217 |
*pbuf = (TUint8)(((c.xMc[11] >> 2) & 0x01) | ((c.xMc[12] << 1) & 0x0E));
|
|
218 |
}
|
|
219 |
}
|
|
220 |
|
|
221 |
|
|
222 |
/*
|
|
223 |
-----------------------------------------------------------------------------
|
|
224 |
|
|
225 |
GSM610FR_Encoder
|
|
226 |
|
|
227 |
PackFrame1
|
|
228 |
|
|
229 |
Pack the codewords of the odd frame into pack buffer.
|
|
230 |
|
|
231 |
Packing as in MS gsm610 encoder.
|
|
232 |
|
|
233 |
Parameters: struct codes* aCodeBuf Code words for one speech frame.
|
|
234 |
|
|
235 |
Return Values: none
|
|
236 |
|
|
237 |
|
|
238 |
-----------------------------------------------------------------------------
|
|
239 |
*/
|
|
240 |
void CGSM610FR_Encoder::PackFrame1(struct codes* aCodeBuf, TInt8* pbuf)
|
|
241 |
{
|
|
242 |
TInt16* LAR = aCodeBuf->LARc;
|
|
243 |
|
|
244 |
pbuf += (PACKSIZE / 2);
|
|
245 |
TInt8 pbufZero = pbuf[0];
|
|
246 |
|
|
247 |
// pack the LARc[0..7] into the first 4.5 bytes, starting with the msb of the first byte
|
|
248 |
*pbuf++ = (TUint8) (pbufZero | ((LAR[0] << 4) & 0xF0));
|
|
249 |
*pbuf++ = (TUint8)(((LAR[0] >> 4) & 0x03) | ((LAR[1] << 2) & 0xFC));
|
|
250 |
*pbuf++ = (TUint8)(((LAR[2] ) & 0x1F) | ((LAR[3] << 5) & 0xE0));
|
|
251 |
*pbuf++ = (TUint8)(((LAR[3] >> 3) & 0x03) | ((LAR[4] << 2) & 0x3C) | ((LAR[5] << 6) & 0xC0));
|
|
252 |
*pbuf++ = (TUint8)(((LAR[5] >> 2) & 0x03) | ((LAR[6] << 2) & 0x1C) | ((LAR[7] << 5) & 0xE0));
|
|
253 |
|
|
254 |
// pack Nc, bc, Mc, xmaxc, and xMc for each of the 4 sub-frames
|
|
255 |
for(TInt i = 0; i < 4; i++)
|
|
256 |
{
|
|
257 |
struct sfcodes& c = aCodeBuf->sfc[i];
|
|
258 |
*pbuf++ = (TUint8)((c.Nc & 0x7F) | ((c.bc << 7) & 0x80));
|
|
259 |
*pbuf++ = (TUint8)(((c.bc >> 1) & 0x01) | ((c.Mc << 1) & 0x06) | ((c.xmaxc << 3) & 0xF8));
|
|
260 |
*pbuf++ = (TUint8)(((c.xmaxc >> 5) & 0x01) | ((c.xMc[0] << 1) & 0x0E) | ((c.xMc[1] << 4) & 0x70) | ((c.xMc[2] << 7) & 0x80));
|
|
261 |
*pbuf++ = (TUint8)(((c.xMc[2] >> 1) & 0x03) | ((c.xMc[3] << 2) & 0x1C) | ((c.xMc[4] << 5) & 0xE0));
|
|
262 |
*pbuf++ = (TUint8)(((c.xMc[5]) & 0x07) | ((c.xMc[6] << 3) & 0x38) | ((c.xMc[7] << 6) & 0xC0));
|
|
263 |
*pbuf++ = (TUint8)(((c.xMc[7] >> 2) & 0x01) | ((c.xMc[8] << 1) & 0x0E) | ((c.xMc[9] << 4) & 0x70) | ((c.xMc[10] << 7) & 0x80));
|
|
264 |
*pbuf++ = (TUint8)(((c.xMc[10] >> 1) & 0x03) | ((c.xMc[11] << 2) & 0x1C) | ((c.xMc[12] << 5) & 0xE0));
|
|
265 |
}
|
|
266 |
}
|
|
267 |
|
|
268 |
/*
|
|
269 |
-----------------------------------------------------------------------------
|
|
270 |
|
|
271 |
GSM610FR_Decoder
|
|
272 |
|
|
273 |
ConstructL
|
|
274 |
|
|
275 |
This function implements the second phase construction of GSM610FR_Decoder
|
|
276 |
class. Function binds the decoder to given input and output streams and
|
|
277 |
resets decoder.
|
|
278 |
|
|
279 |
Parameters: RReadStream aInStrm Handle to input stream (encoded
|
|
280 |
speech data)
|
|
281 |
|
|
282 |
RWriteStream aOutStrm Handle to output stream (16 bit
|
|
283 |
PCM speech data)
|
|
284 |
|
|
285 |
Return Values: none
|
|
286 |
|
|
287 |
-----------------------------------------------------------------------------
|
|
288 |
*/
|
|
289 |
void CGSM610FR_Decoder::ConstructL()
|
|
290 |
{
|
|
291 |
::reset_decoder(this);
|
|
292 |
iOddFrame = TRUE;
|
|
293 |
}
|
|
294 |
|
|
295 |
|
|
296 |
/*
|
|
297 |
-----------------------------------------------------------------------------
|
|
298 |
|
|
299 |
GSM610FR_Decoder
|
|
300 |
|
|
301 |
~GSM610FR_Decoder
|
|
302 |
|
|
303 |
Empty decoder destructor.
|
|
304 |
|
|
305 |
Parameters: none
|
|
306 |
|
|
307 |
Return Values: none
|
|
308 |
|
|
309 |
-----------------------------------------------------------------------------
|
|
310 |
*/
|
|
311 |
CGSM610FR_Decoder::~CGSM610FR_Decoder()
|
|
312 |
{
|
|
313 |
}
|
|
314 |
|
|
315 |
|
|
316 |
/*
|
|
317 |
-----------------------------------------------------------------------------
|
|
318 |
|
|
319 |
GSM610FR_Decoder
|
|
320 |
|
|
321 |
StartL
|
|
322 |
|
|
323 |
Start decoder object. Initialize codec status.
|
|
324 |
|
|
325 |
Parameters: none
|
|
326 |
|
|
327 |
Return Values: none
|
|
328 |
|
|
329 |
-----------------------------------------------------------------------------
|
|
330 |
*/
|
|
331 |
void CGSM610FR_Decoder::StartL()
|
|
332 |
{
|
|
333 |
::reset_decoder(this);
|
|
334 |
iOddFrame = TRUE;
|
|
335 |
}
|
|
336 |
|
|
337 |
|
|
338 |
/*
|
|
339 |
-----------------------------------------------------------------------------
|
|
340 |
|
|
341 |
GSM610FR_Decoder
|
|
342 |
|
|
343 |
ExecuteL
|
|
344 |
|
|
345 |
Execute decoder object. Read one encoded speech frame from the input
|
|
346 |
stream RPELTP decode it and write the decoded frame to output stream.
|
|
347 |
|
|
348 |
Parameters: none
|
|
349 |
|
|
350 |
Return Values: none
|
|
351 |
|
|
352 |
Leave Handling:
|
|
353 |
|
|
354 |
If the length of data available in the input stream is less than size
|
|
355 |
of one encoded speech frame then the function leaves with KErrEof.
|
|
356 |
|
|
357 |
-----------------------------------------------------------------------------
|
|
358 |
*/
|
|
359 |
void CGSM610FR_Decoder::ExecuteL(TUint8* aInBuf, TUint8* aOutBuf)
|
|
360 |
{
|
|
361 |
|
|
362 |
TInt16* outBufPtr = (TInt16*) aOutBuf;
|
|
363 |
|
|
364 |
|
|
365 |
// Process both odd and even frames
|
|
366 |
|
|
367 |
for (TInt frame = 0; frame < 2; frame++)
|
|
368 |
{
|
|
369 |
if ( iOddFrame )
|
|
370 |
{
|
|
371 |
UnpackFrame0(&iCodeBuf, (TInt8*) aInBuf);
|
|
372 |
}
|
|
373 |
else
|
|
374 |
{
|
|
375 |
UnpackFrame1(&iCodeBuf, (TInt8*) aInBuf);
|
|
376 |
}
|
|
377 |
|
|
378 |
|
|
379 |
::RPELTP_decoder(this, &iCodeBuf, outBufPtr);
|
|
380 |
|
|
381 |
iOddFrame = !iOddFrame;
|
|
382 |
outBufPtr += FRAMESIZE;
|
|
383 |
|
|
384 |
}
|
|
385 |
|
|
386 |
}
|
|
387 |
|
|
388 |
/*
|
|
389 |
-----------------------------------------------------------------------------
|
|
390 |
|
|
391 |
GSM610FR_Decoder
|
|
392 |
|
|
393 |
StopL
|
|
394 |
|
|
395 |
Stop decoder object. Flush out last frames, if necessary.
|
|
396 |
|
|
397 |
Parameters: none
|
|
398 |
|
|
399 |
Return Values: none
|
|
400 |
|
|
401 |
-----------------------------------------------------------------------------
|
|
402 |
*/
|
|
403 |
void CGSM610FR_Decoder::StopL()
|
|
404 |
{
|
|
405 |
}
|
|
406 |
|
|
407 |
void CGSM610FR_Decoder::Release()
|
|
408 |
{
|
|
409 |
delete this;
|
|
410 |
}
|
|
411 |
|
|
412 |
/*
|
|
413 |
-----------------------------------------------------------------------------
|
|
414 |
|
|
415 |
GSM610FR_Decoder
|
|
416 |
|
|
417 |
UnpackFrame0
|
|
418 |
|
|
419 |
Unpack the codewords of the even frame from pack buffer.
|
|
420 |
|
|
421 |
Packing as in MS gsm610 encoder.
|
|
422 |
|
|
423 |
Parameters: struct codes* aCodeBuf Code words for one speech frame
|
|
424 |
are unpacked into this structure.
|
|
425 |
|
|
426 |
Return Values: none
|
|
427 |
|
|
428 |
|
|
429 |
-----------------------------------------------------------------------------
|
|
430 |
*/
|
|
431 |
void CGSM610FR_Decoder::UnpackFrame0(struct codes* aCodeBuf, TInt8* pbuf)
|
|
432 |
{
|
|
433 |
TInt16* LAR = aCodeBuf->LARc;
|
|
434 |
|
|
435 |
// unpack the LAR[0..7] from the first 4.5 bytes
|
|
436 |
LAR[0] = (TInt16)((pbuf[0] & 0x3F));
|
|
437 |
LAR[1] = (TInt16)(((pbuf[0] & 0xC0) >> 6) | ((pbuf[1] & 0x0F) << 2));
|
|
438 |
LAR[2] = (TInt16)(((pbuf[1] & 0xF0) >> 4) | ((pbuf[2] & 0x01) << 4));
|
|
439 |
LAR[3] = (TInt16)(((pbuf[2] & 0x3E) >> 1));
|
|
440 |
LAR[4] = (TInt16)(((pbuf[2] & 0xC0) >> 6) | ((pbuf[3] & 0x03) << 2));
|
|
441 |
LAR[5] = (TInt16)(((pbuf[3] & 0x3C) >> 2));
|
|
442 |
LAR[6] = (TInt16)(((pbuf[3] & 0xC0) >> 6) | ((pbuf[4] & 0x01) << 2));
|
|
443 |
LAR[7] = (TInt16)(((pbuf[4] & 0x0E) >> 1));
|
|
444 |
|
|
445 |
// unpack Nc, bc, Mc, xmaxc, and xMc for each of the 4 sub-frames
|
|
446 |
for(TInt i = 0; i < 4; i++)
|
|
447 |
{
|
|
448 |
struct sfcodes& c = aCodeBuf->sfc[i];
|
|
449 |
#define sfb(x) (pbuf[4+i*7+x])
|
|
450 |
c.Nc = (TInt16)(((sfb(0) & 0xF0) >> 4) | ((sfb(1) & 0x07) << 4));
|
|
451 |
c.bc = (TInt16)(((sfb(1) & 0x18) >> 3));
|
|
452 |
c.Mc = (TInt16)(((sfb(1) & 0x60) >> 5));
|
|
453 |
c.xmaxc = (TInt16)(((sfb(1) & 0x80) >> 7) | ((sfb(2) & 0x1F) << 1));
|
|
454 |
c.xMc[0] = (TInt16)(((sfb(2) & 0xE0) >> 5));
|
|
455 |
c.xMc[1] = (TInt16)((sfb(3) & 0x07));
|
|
456 |
c.xMc[2] = (TInt16)(((sfb(3) & 0x3C) >> 3));
|
|
457 |
c.xMc[3] = (TInt16)(((sfb(3) & 0xC0) >> 6) | ((sfb(4) & 0x01) << 2));
|
|
458 |
c.xMc[4] = (TInt16)(((sfb(4) & 0x0E) >> 1));
|
|
459 |
c.xMc[5] = (TInt16)(((sfb(4) & 0x70) >> 4));
|
|
460 |
c.xMc[6] = (TInt16)(((sfb(4) & 0x80) >> 7) | ((sfb(5) & 0x03) << 1));
|
|
461 |
c.xMc[7] = (TInt16)(((sfb(5) & 0x1C) >> 2));
|
|
462 |
c.xMc[8] = (TInt16)(((sfb(5) & 0xE0) >> 5));
|
|
463 |
c.xMc[9] = (TInt16)((sfb(6) & 0x07));
|
|
464 |
c.xMc[10] = (TInt16)(((sfb(6) & 0x38) >> 3));
|
|
465 |
c.xMc[11] = (TInt16)(((sfb(6) & 0xC0) >> 6) | ((sfb(7) & 0x01) << 2));
|
|
466 |
c.xMc[12] = (TInt16)(((sfb(7) & 0x0E) >> 1));
|
|
467 |
#undef sfb
|
|
468 |
}
|
|
469 |
}
|
|
470 |
|
|
471 |
|
|
472 |
/*
|
|
473 |
-----------------------------------------------------------------------------
|
|
474 |
|
|
475 |
GSM610FR_Decoder
|
|
476 |
|
|
477 |
UnpackFrame1
|
|
478 |
|
|
479 |
Unpack the codewords of the odd frame from pack buffer.
|
|
480 |
|
|
481 |
Packing as in MS gsm610 encoder.
|
|
482 |
|
|
483 |
Parameters: struct codes* aCodeBuf Code words for one speech frame
|
|
484 |
are unpacked into this structure.
|
|
485 |
|
|
486 |
Return Values: none
|
|
487 |
|
|
488 |
|
|
489 |
-----------------------------------------------------------------------------
|
|
490 |
*/
|
|
491 |
void CGSM610FR_Decoder::UnpackFrame1(struct codes* aCodeBuf, TInt8* pbuf)
|
|
492 |
{
|
|
493 |
TInt16* LAR = aCodeBuf->LARc;
|
|
494 |
|
|
495 |
// unpack the LAR[0..7] from the first 4.5 bytes
|
|
496 |
LAR[0] = (TInt16)(((pbuf[32] & 0xF0) >> 4) | ((pbuf[33] & 0x03) << 4));
|
|
497 |
LAR[1] = (TInt16)(((pbuf[33] & 0xFC) >> 2));
|
|
498 |
LAR[2] = (TInt16)(((pbuf[34] & 0x1F)));
|
|
499 |
LAR[3] = (TInt16)(((pbuf[34] & 0xE0) >> 5) | ((pbuf[35] & 0x03) << 3));
|
|
500 |
LAR[4] = (TInt16)(((pbuf[35] & 0x3C) >> 2));
|
|
501 |
LAR[5] = (TInt16)(((pbuf[35] & 0xC0) >> 6) | ((pbuf[36] & 0x03) << 2));
|
|
502 |
LAR[6] = (TInt16)(((pbuf[36] & 0x1C) >> 2));
|
|
503 |
LAR[7] = (TInt16)(((pbuf[36] & 0xE0) >> 5));
|
|
504 |
|
|
505 |
// unpack Nc, bc, Mc, xmaxc, and xMc for each of the 4 sub-frames
|
|
506 |
for(TInt i = 0; i < 4; i++)
|
|
507 |
{
|
|
508 |
struct sfcodes& c = aCodeBuf->sfc[i];
|
|
509 |
#define sfb(x) (pbuf[37+i*7+x])
|
|
510 |
c.Nc = (TInt16)(sfb(0) & 0x7F);
|
|
511 |
c.bc = (TInt16)(((sfb(0) & 0x80) >> 7) | ((sfb(1) & 0x01) << 1));
|
|
512 |
c.Mc = (TInt16)(((sfb(1) & 0x06) >> 1));
|
|
513 |
c.xmaxc = (TInt16)(((sfb(1) & 0xF8) >> 3) | ((sfb(2) & 0x01) << 5));
|
|
514 |
c.xMc[0] = (TInt16)(((sfb(2) & 0x0E) >> 1));
|
|
515 |
c.xMc[1] = (TInt16)(((sfb(2) & 0x70) >> 4));
|
|
516 |
c.xMc[2] = (TInt16)(((sfb(2) & 0x80) >> 7) | ((sfb(3) & 0x03) << 1));
|
|
517 |
c.xMc[3] = (TInt16)(((sfb(3) & 0x1C) >> 2));
|
|
518 |
c.xMc[4] = (TInt16)(((sfb(3) & 0xE0) >> 5));
|
|
519 |
c.xMc[5] = (TInt16)(((sfb(4) & 0x07)));
|
|
520 |
c.xMc[6] = (TInt16)(((sfb(4) & 0x38) >> 3));
|
|
521 |
c.xMc[7] = (TInt16)(((sfb(4) & 0xC0) >> 6) | ((sfb(5) & 0x01) << 2));
|
|
522 |
c.xMc[8] = (TInt16)(((sfb(5) & 0x0E) >> 1));
|
|
523 |
c.xMc[9] = (TInt16)(((sfb(5) & 0x70) >> 4));
|
|
524 |
c.xMc[10] = (TInt16)(((sfb(5) & 0x80) >> 7) | ((sfb(6) & 0x03) << 1));
|
|
525 |
c.xMc[11] = (TInt16)(((sfb(6) & 0x1C) >> 2));
|
|
526 |
c.xMc[12] = (TInt16)(((sfb(6) & 0xE0) >> 5));
|
|
527 |
|
|
528 |
#undef sfb
|
|
529 |
}
|
|
530 |
}
|
|
531 |
|
|
532 |
|
|
533 |
//-----------------------------------------------------------------------------
|
|
534 |
// End of File
|
|
535 |
//-----------------------------------------------------------------------------
|