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.
7
/* $Header: /tmp_amd/presto/export/kbs/jutta/src/gsm/RCS/preprocess.c,v 1.2 1994/05/10 20:18:45 jutta Exp $ */
18
/* 4.2.0 .. 4.2.3 PREPROCESSING SECTION
20
* After A-law to linear conversion (or directly from the
21
* Ato D converter) the following scaling is assumed for
22
* input to the RPE-LTP algorithm:
24
* in: 0.1.....................12
25
* S.v.v.v.v.v.v.v.v.v.v.v.v.*.*.*
27
* Where S is the sign bit, v a valid bit, and * a "don't care" bit.
28
* The original signal is called sop[..]
30
* out: 0.1................... 12
31
* S.S.v.v.v.v.v.v.v.v.v.v.v.v.0.0
35
void Gsm_Preprocess P3((S, s, so),
38
word * so ) /* [0..159] IN/OUT */
42
longword L_z2 = S->L_z2;
53
longword ltmp; /* for ADD */
54
ulongword utmp; /* for L_ADD */
60
/* 4.2.1 Downscaling of the input signal
62
SO = SASR( *s, 3 ) << 2;
65
assert (SO >= -0x4000); /* downscaled by */
66
assert (SO <= 0x3FFC); /* previous routine. */
69
/* 4.2.2 Offset compensation
71
* This part implements a high-pass filter and requires extended
72
* arithmetic precision for the recursive part of this filter.
73
* The input of this procedure is the array so[0...159] and the
74
* output the array sof[ 0...159 ].
76
/* Compute the non-recursive part
79
s1 = SO - z1; /* s1 = gsm_sub( *so, z1 ); */
82
assert(s1 != MIN_WORD);
84
/* Compute the recursive part
89
/* Execution of a 31 bv 16 bits multiplication
92
msp = SASR( L_z2, 15 );
93
lsp = L_z2-((longword)msp<<15); /* gsm_L_sub(L_z2,(msp<<15)); */
95
L_s2 += GSM_MULT_R( lsp, 32735 );
96
L_temp = (longword)msp * 32735; /* GSM_L_MULT(msp,32735) >> 1;*/
97
L_z2 = GSM_L_ADD( L_temp, L_s2 );
99
/* Compute sof[k] with rounding
101
L_temp = GSM_L_ADD( L_z2, 16384 );
106
msp = GSM_MULT_R( mp, -28180 );
107
mp = SASR( L_temp, 15 );
108
*so++ = GSM_ADD( mp, msp );