comparison intercom/gsm/preproce.c @ 2:13be24d74cd2

import intercom-0.4.1
author Peter Meerwald <pmeerw@cosy.sbg.ac.at>
date Fri, 25 Jun 2010 09:57:52 +0200
parents
children
comparison
equal deleted inserted replaced
1:9cadc470e3da 2:13be24d74cd2
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: /home/kbs/jutta/src/gsm/gsm-1.0/src/RCS/preprocess.c,v 1.1 1992/10/28 00:15:50 jutta Exp $ */
8
9 #include <stdio.h>
10 #include <assert.h>
11
12 #include "private.h"
13
14 #include "gsm.h"
15 #include "proto.h"
16
17 /* 4.2.0 .. 4.2.3 PREPROCESSING SECTION
18 *
19 * After A-law to linear conversion (or directly from the
20 * Ato D converter) the following scaling is assumed for
21 * input to the RPE-LTP algorithm:
22 *
23 * in: 0.1.....................12
24 * S.v.v.v.v.v.v.v.v.v.v.v.v.*.*.*
25 *
26 * Where S is the sign bit, v a valid bit, and * a "don't care" bit.
27 * The original signal is called sop[..]
28 *
29 * out: 0.1................... 12
30 * S.S.v.v.v.v.v.v.v.v.v.v.v.v.0.0
31 */
32
33
34 void Gsm_Preprocess P3((S, s, so),
35 struct gsm_state *S, word * s, word * so)
36 { /* [0..159] IN/OUT */
37
38 word z1 = S->z1;
39 longword L_z2 = S->L_z2;
40 word mp = S->mp;
41
42 word s1;
43 longword L_s2;
44
45 longword L_temp;
46
47 word msp, lsp;
48 word SO;
49
50 longword ltmp; /* for ADD */
51 ulongword utmp; /* for L_ADD */
52
53 register int k = 160;
54
55 while (k--) {
56
57 /* 4.2.1 Downscaling of the input signal
58 */
59 SO = SASR(*s, 3) << 2;
60 s++;
61
62 assert(SO >= -0x4000); /* downscaled by */
63 assert(SO <= 0x3FFC); /* previous routine. */
64
65
66 /* 4.2.2 Offset compensation
67 *
68 * This part implements a high-pass filter and requires extended
69 * arithmetic precision for the recursive part of this filter.
70 * The input of this procedure is the array so[0...159] and the
71 * output the array sof[ 0...159 ].
72 */
73 /* Compute the non-recursive part
74 */
75
76 s1 = SO - z1; /* s1 = gsm_sub( *so, z1 ); */
77 z1 = SO;
78
79 assert(s1 != MIN_WORD);
80
81 /* Compute the recursive part
82 */
83 L_s2 = s1;
84 L_s2 <<= 15;
85
86 /* Execution of a 31 bv 16 bits multiplication
87 */
88
89 msp = SASR(L_z2, 15);
90 lsp = L_z2 - ((longword) msp << 15); /* gsm_L_sub(L_z2,(msp<<15)); */
91
92 L_s2 += GSM_MULT_R(lsp, 32735);
93 L_temp = (longword) msp *32735; /* GSM_L_MULT(msp,32735) >> 1; */
94 L_z2 = GSM_L_ADD(L_temp, L_s2);
95
96 /* Compute sof[k] with rounding
97 */
98 L_temp = GSM_L_ADD(L_z2, 16384);
99
100 /* 4.2.3 Preemphasis
101 */
102
103 msp = GSM_MULT_R(mp, -28180);
104 mp = SASR(L_temp, 15);
105 *so++ = GSM_ADD(mp, msp);
106 }
107
108 S->z1 = z1;
109 S->L_z2 = L_z2;
110 S->mp = mp;
111 }

Repositories maintained by Peter Meerwald, pmeerw@pmeerw.net.