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: /cvsroot/sox/sox/libgsm/preprocess.c,v 1.1 2007/09/06 16:50:55 cbagwell Exp $ */
16 /* 4.2.0 .. 4.2.3 PREPROCESSING SECTION
18 * After A-law to linear conversion (or directly from the
19 * Ato D converter) the following scaling is assumed for
20 * input to the RPE-LTP algorithm:
22 * in: 0.1.....................12
23 * S.v.v.v.v.v.v.v.v.v.v.v.v.*.*.*
25 * Where S is the sign bit, v a valid bit, and * a "don't care" bit.
26 * The original signal is called sop[..]
28 * out: 0.1................... 12
29 * S.S.v.v.v.v.v.v.v.v.v.v.v.v.0.0
36 word
* so
) /* [0..159] IN/OUT */
40 longword L_z2
= S
->L_z2
;
51 longword ltmp
; /* for ADD */
52 ulongword utmp
; /* for L_ADD */
58 /* 4.2.1 Downscaling of the input signal
60 SO
= SASR( *s
, 3 ) << 2;
63 assert (SO
>= -0x4000); /* downscaled by */
64 assert (SO
<= 0x3FFC); /* previous routine. */
67 /* 4.2.2 Offset compensation
69 * This part implements a high-pass filter and requires extended
70 * arithmetic precision for the recursive part of this filter.
71 * The input of this procedure is the array so[0...159] and the
72 * output the array sof[ 0...159 ].
74 /* Compute the non-recursive part
77 s1
= SO
- z1
; /* s1 = gsm_sub( *so, z1 ); */
80 assert(s1
!= MIN_WORD
);
82 /* Compute the recursive part
87 /* Execution of a 31 bv 16 bits multiplication
90 msp
= SASR( L_z2
, 15 );
91 lsp
= L_z2
-((longword
)msp
<<15); /* gsm_L_sub(L_z2,(msp<<15)); */
93 L_s2
+= GSM_MULT_R( lsp
, 32735 );
94 L_temp
= (longword
)msp
* 32735; /* GSM_L_MULT(msp,32735) >> 1;*/
95 L_z2
= GSM_L_ADD( L_temp
, L_s2
);
97 /* Compute sof[k] with rounding
99 L_temp
= GSM_L_ADD( L_z2
, 16384 );
104 msp
= GSM_MULT_R( mp
, -28180 );
105 mp
= SASR( L_temp
, 15 );
106 *so
++ = GSM_ADD( mp
, msp
);