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 $ */
17 /* 4.2.0 .. 4.2.3 PREPROCESSING SECTION
19 * After A-law to linear conversion (or directly from the
20 * Ato D converter) the following scaling is assumed for
21 * input to the RPE-LTP algorithm:
23 * in: 0.1.....................12
24 * S.v.v.v.v.v.v.v.v.v.v.v.v.*.*.*
26 * Where S is the sign bit, v a valid bit, and * a "don't care" bit.
27 * The original signal is called sop[..]
29 * out: 0.1................... 12
30 * S.S.v.v.v.v.v.v.v.v.v.v.v.v.0.0
34 void Gsm_Preprocess P3((S, s, so),
37 word * so ) /* [0..159] IN/OUT */
41 longword L_z2 = S->L_z2;
52 longword ltmp; /* for ADD */
53 ulongword utmp; /* for L_ADD */
59 /* 4.2.1 Downscaling of the input signal
61 SO = SASR( *s, 3 ) << 2;
64 assert (SO >= -0x4000); /* downscaled by */
65 assert (SO <= 0x3FFC); /* previous routine. */
68 /* 4.2.2 Offset compensation
70 * This part implements a high-pass filter and requires extended
71 * arithmetic precision for the recursive part of this filter.
72 * The input of this procedure is the array so[0...159] and the
73 * output the array sof[ 0...159 ].
75 /* Compute the non-recursive part
78 s1 = SO - z1; /* s1 = gsm_sub( *so, z1 ); */
81 assert(s1 != MIN_WORD);
83 /* Compute the recursive part
88 /* Execution of a 31 bv 16 bits multiplication
91 msp = SASR( L_z2, 15 );
92 lsp = L_z2-((longword)msp<<15); /* gsm_L_sub(L_z2,(msp<<15)); */
94 L_s2 += GSM_MULT_R( lsp, 32735 );
95 L_temp = (longword)msp * 32735; /* GSM_L_MULT(msp,32735) >> 1;*/
96 L_z2 = GSM_L_ADD( L_temp, L_s2 );
98 /* Compute sof[k] with rounding
100 L_temp = GSM_L_ADD( L_z2, 16384 );
105 msp = GSM_MULT_R( mp, -28180 );
106 mp = SASR( L_temp, 15 );
107 *so++ = GSM_ADD( mp, msp );