/src/libsndfile/src/GSM610/decode.c
Line | Count | Source |
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 int16_t * s) |
18 | 7.00k | { |
19 | 7.00k | register int k ; |
20 | 7.00k | register int16_t msr = S->msr ; |
21 | 7.00k | register int16_t tmp ; |
22 | | |
23 | 1.12M | for (k = 160 ; k-- ; s++) |
24 | 1.12M | { tmp = GSM_MULT_R (msr, 28180) ; |
25 | 1.12M | msr = GSM_ADD (*s, tmp) ; /* Deemphasis */ |
26 | 1.12M | *s = GSM_ADD (msr, msr) & 0xFFF8 ; /* Truncation & Upscaling */ |
27 | 1.12M | } |
28 | 7.00k | S->msr = msr ; |
29 | 7.00k | } |
30 | | |
31 | | void Gsm_Decoder ( |
32 | | struct gsm_state * S, |
33 | | |
34 | | int16_t * LARcr, /* [0..7] IN */ |
35 | | |
36 | | int16_t * Ncr, /* [0..3] IN */ |
37 | | int16_t * bcr, /* [0..3] IN */ |
38 | | int16_t * Mcr, /* [0..3] IN */ |
39 | | int16_t * xmaxcr, /* [0..3] IN */ |
40 | | int16_t * xMcr, /* [0..13*4] IN */ |
41 | | |
42 | | int16_t * s) /* [0..159] OUT */ |
43 | 7.00k | { |
44 | 7.00k | int j, k ; |
45 | 7.00k | int16_t erp [40], wt [160] ; |
46 | 7.00k | int16_t *drp = S->dp0 + 120 ; |
47 | | |
48 | 35.0k | for (j = 0 ; j <= 3 ; j++, xmaxcr++, bcr++, Ncr++, Mcr++, xMcr += 13) |
49 | 28.0k | { Gsm_RPE_Decoding (/*-S,-*/ *xmaxcr, *Mcr, xMcr, erp) ; |
50 | 28.0k | Gsm_Long_Term_Synthesis_Filtering (S, *Ncr, *bcr, erp, drp) ; |
51 | | |
52 | 1.14M | for (k = 0 ; k <= 39 ; k++) wt [j * 40 + k] = drp [k] ; |
53 | 28.0k | } |
54 | | |
55 | 7.00k | Gsm_Short_Term_Synthesis_Filter (S, LARcr, wt, s) ; |
56 | 7.00k | Postprocessing (S, s) ; |
57 | 7.00k | } |
58 | | |