/*1* Copyright 1992 by Jutta Degener and Carsten Bormann, Technische2* Universitaet Berlin. See the accompanying file "COPYRIGHT" for3* details. THERE IS ABSOLUTELY NO WARRANTY FOR THIS SOFTWARE.4*/56/* $Header: /tmp_amd/presto/export/kbs/jutta/src/gsm/RCS/preprocess.c,v 1.2 1994/05/10 20:18:45 jutta Exp $ */78#include <stdio.h>9#include <assert.h>1011#include "private.h"1213#include "gsm.h"14#include "proto.h"1516/* 4.2.0 .. 4.2.3 PREPROCESSING SECTION17*18* After A-law to linear conversion (or directly from the19* Ato D converter) the following scaling is assumed for20* input to the RPE-LTP algorithm:21*22* in: 0.1.....................1223* S.v.v.v.v.v.v.v.v.v.v.v.v.*.*.*24*25* Where S is the sign bit, v a valid bit, and * a "don't care" bit.26* The original signal is called sop[..]27*28* out: 0.1................... 1229* S.S.v.v.v.v.v.v.v.v.v.v.v.v.0.030*/313233void Gsm_Preprocess P3((S, s, so),34struct gsm_state * S,35word * s,36word * so ) /* [0..159] IN/OUT */37{3839word z1 = S->z1;40longword L_z2 = S->L_z2;41word mp = S->mp;4243word s1;44longword L_s2;4546longword L_temp;4748word msp, lsp;49word SO;5051longword ltmp; /* for ADD */52ulongword utmp; /* for L_ADD */5354register int k = 160;5556while (k--) {5758/* 4.2.1 Downscaling of the input signal59*/60SO = SASR( *s, 3 ) << 2;61s++;6263assert (SO >= -0x4000); /* downscaled by */64assert (SO <= 0x3FFC); /* previous routine. */656667/* 4.2.2 Offset compensation68*69* This part implements a high-pass filter and requires extended70* arithmetic precision for the recursive part of this filter.71* The input of this procedure is the array so[0...159] and the72* output the array sof[ 0...159 ].73*/74/* Compute the non-recursive part75*/7677s1 = SO - z1; /* s1 = gsm_sub( *so, z1 ); */78z1 = SO;7980assert(s1 != MIN_WORD);8182/* Compute the recursive part83*/84L_s2 = s1;85L_s2 <<= 15;8687/* Execution of a 31 bv 16 bits multiplication88*/8990msp = SASR( L_z2, 15 );91lsp = L_z2-((longword)msp<<15); /* gsm_L_sub(L_z2,(msp<<15)); */9293L_s2 += GSM_MULT_R( lsp, 32735 );94L_temp = (longword)msp * 32735; /* GSM_L_MULT(msp,32735) >> 1;*/95L_z2 = GSM_L_ADD( L_temp, L_s2 );9697/* Compute sof[k] with rounding98*/99L_temp = GSM_L_ADD( L_z2, 16384 );100101/* 4.2.3 Preemphasis102*/103104msp = GSM_MULT_R( mp, -28180 );105mp = SASR( L_temp, 15 );106*so++ = GSM_ADD( mp, msp );107}108109S->z1 = z1;110S->L_z2 = L_z2;111S->mp = mp;112}113114115