libsndfile source files.
[Faustine.git] / interpretor / libsndfile-1.0.25 / src / GSM610 / decode.c
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 #include <stdio.h>
8
9 #include "gsm610_priv.h"
10
11 /*
12 * 4.3 FIXED POINT IMPLEMENTATION OF THE RPE-LTP DECODER
13 */
14
15 static void Postprocessing (
16 struct gsm_state * S,
17 register word * s)
18 {
19 register int k;
20 register word msr = S->msr;
21 register word tmp;
22
23 for (k = 160; k--; s++) {
24 tmp = GSM_MULT_R( msr, 28180 );
25 msr = GSM_ADD(*s, tmp); /* Deemphasis */
26 *s = GSM_ADD(msr, msr) & 0xFFF8; /* Truncation & Upscaling */
27 }
28 S->msr = msr;
29 }
30
31 void Gsm_Decoder (
32 struct gsm_state * S,
33
34 word * LARcr, /* [0..7] IN */
35
36 word * Ncr, /* [0..3] IN */
37 word * bcr, /* [0..3] IN */
38 word * Mcr, /* [0..3] IN */
39 word * xmaxcr, /* [0..3] IN */
40 word * xMcr, /* [0..13*4] IN */
41
42 word * s) /* [0..159] OUT */
43 {
44 int j, k;
45 word erp[40], wt[160];
46 word * drp = S->dp0 + 120;
47
48 for (j=0; j <= 3; j++, xmaxcr++, bcr++, Ncr++, Mcr++, xMcr += 13) {
49
50 Gsm_RPE_Decoding( /*-S,-*/ *xmaxcr, *Mcr, xMcr, erp );
51 Gsm_Long_Term_Synthesis_Filtering( S, *Ncr, *bcr, erp, drp );
52
53 for (k = 0; k <= 39; k++) wt[ j * 40 + k ] = drp[ k ];
54 }
55
56 Gsm_Short_Term_Synthesis_Filter( S, LARcr, wt, s );
57 Postprocessing(S, s);
58 }
59