1/*
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.
5 */
6
7/* $Header: /tmp_amd/presto/export/kbs/jutta/src/gsm/RCS/decode.c,v 1.1 1992/10/28 00:15:50 jutta Exp $ */
8
9#include <stdio.h>
10
11#include	"private.h"
12#include	"gsm.h"
13#include	"proto.h"
14
15/*
16 *  4.3 FIXED POINT IMPLEMENTATION OF THE RPE-LTP DECODER
17 */
18
19static void Postprocessing P2((S,s),
20	struct gsm_state	* S,
21	register word 		* s)
22{
23	register int		k;
24	register word		msr = S->msr;
25	register longword	ltmp;	/* for GSM_ADD */
26	register word		tmp;
27
28	for (k = 160; k--; s++) {
29		tmp = GSM_MULT_R( msr, 28180 );
30		msr = GSM_ADD(*s, tmp);  	   /* Deemphasis 	     */
31		*s  = GSM_ADD(msr, msr) & 0xFFF8;  /* Truncation & Upscaling */
32	}
33	S->msr = msr;
34}
35
36void Gsm_Decoder P8((S,LARcr, Ncr,bcr,Mcr,xmaxcr,xMcr,s),
37	struct gsm_state	* S,
38
39	word		* LARcr,	/* [0..7]		IN	*/
40
41	word		* Ncr,		/* [0..3] 		IN 	*/
42	word		* bcr,		/* [0..3]		IN	*/
43	word		* Mcr,		/* [0..3] 		IN 	*/
44	word		* xmaxcr,	/* [0..3]		IN 	*/
45	word		* xMcr,		/* [0..13*4]		IN	*/
46
47	word		* s)		/* [0..159]		OUT 	*/
48{
49	int		j, k;
50	word		erp[40], wt[160];
51	word		* drp = S->dp0 + 120;
52
53	for (j=0; j <= 3; j++, xmaxcr++, bcr++, Ncr++, Mcr++, xMcr += 13) {
54
55		Gsm_RPE_Decoding( S, *xmaxcr, *Mcr, xMcr, erp );
56		Gsm_Long_Term_Synthesis_Filtering( S, *Ncr, *bcr, erp, drp );
57
58		for (k = 0; k <= 39; k++) wt[ j * 40 + k ] =  drp[ k ];
59	}
60
61	Gsm_Short_Term_Synthesis_Filter( S, LARcr, wt, s );
62	Postprocessing(S, s);
63}
64