/*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/code.c,v 1.3 1996/07/02 09:59:05 jutta Exp $ */78#include <string.h>910#include "private.h"11#include "gsm.h"12#include "proto.h"1314/*15* 4.2 FIXED POINT IMPLEMENTATION OF THE RPE-LTP CODER16*/1718void Gsm_Coder P8((S,s,LARc,Nc,bc,Mc,xmaxc,xMc),1920struct gsm_state * S,2122word * s, /* [0..159] samples IN */2324/*25* The RPE-LTD coder works on a frame by frame basis. The length of26* the frame is equal to 160 samples. Some computations are done27* once per frame to produce at the output of the coder the28* LARc[1..8] parameters which are the coded LAR coefficients and29* also to realize the inverse filtering operation for the entire30* frame (160 samples of signal d[0..159]). These parts produce at31* the output of the coder:32*/3334word * LARc, /* [0..7] LAR coefficients OUT */3536/*37* Procedure 4.2.11 to 4.2.18 are to be executed four times per38* frame. That means once for each sub-segment RPE-LTP analysis of39* 40 samples. These parts produce at the output of the coder:40*/4142word * Nc, /* [0..3] LTP lag OUT */43word * bc, /* [0..3] coded LTP gain OUT */44word * Mc, /* [0..3] RPE grid selection OUT */45word * xmaxc,/* [0..3] Coded maximum amplitude OUT */46word * xMc /* [13*4] normalized RPE samples OUT */47)48{49int k;50word * dp = S->dp0 + 120; /* [ -120...-1 ] */51word * dpp = dp; /* [ 0...39 ] */5253word so[160];5455Gsm_Preprocess (S, s, so);56Gsm_LPC_Analysis (S, so, LARc);57Gsm_Short_Term_Analysis_Filter (S, LARc, so);5859for (k = 0; k <= 3; k++, xMc += 13) {6061Gsm_Long_Term_Predictor ( S,62so+k*40, /* d [0..39] IN */63dp, /* dp [-120..-1] IN */64S->e + 5, /* e [0..39] OUT */65dpp, /* dpp [0..39] OUT */66Nc++,67bc++);6869Gsm_RPE_Encoding ( S,70S->e + 5,/* e ][0..39][ IN/OUT */71xmaxc++, Mc++, xMc );72/*73* Gsm_Update_of_reconstructed_short_time_residual_signal74* ( dpp, S->e + 5, dp );75*/7677{ register int i;78register longword ltmp;79for (i = 0; i <= 39; i++)80dp[ i ] = GSM_ADD( S->e[5 + i], dpp[i] );81}82dp += 40;83dpp += 40;8485}86(void)memcpy( (char *)S->dp0, (char *)(S->dp0 + 160),87120 * sizeof(*S->dp0) );88}899091