Debian Codegraph @

gsm/private.h

raw symbols SCIP
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: /usr/local/cvsroot/rplay/gsm/private.h,v 1.1.1.1 1998/07/14 22:35:24 mrb Exp $*/
8
9 #ifndef PRIVATE_H
10 #define PRIVATE_H
11
12 typedef short word; /* 16 bit signed int */
13 typedef long longword; /* 32 bit signed int */
14
15 typedef unsigned short uword; /* unsigned word */
16 typedef unsigned long ulongword; /* unsigned longword */
17
18 struct gsm_state {
19
20 word dp0[ 280 ];
21
22 word z1; /* preprocessing.c, Offset_com. */
23 longword L_z2; /* Offset_com. */
24 int mp; /* Preemphasis */
25
26 word u[8]; /* short_term_aly_filter.c */
27 word LARpp[2][8]; /* */
28 word j; /* */
29
30 word ltp_cut; /* long_term.c, LTP crosscorr. */
31 word nrp; /* 40 */ /* long_term.c, synthesis */
32 word v[9]; /* short_term.c, synthesis */
33 word msr; /* decoder.c, Postprocessing */
34
35 char verbose; /* only used if !NDEBUG */
36 char fast; /* only used if FAST */
37
38 };
39
40
41 #define MIN_WORD ((-32767)-1)
42 #define MAX_WORD ( 32767)
43
44 #define MIN_LONGWORD ((-2147483647)-1)
45 #define MAX_LONGWORD ( 2147483647)
46
47 #ifdef SASR /* >> is a signed arithmetic shift right */
48 #undef SASR
49 #define SASR(x, by) ((x) >> (by))
50 #endif /* SASR */
51
52
53 #include "proto.h"
54
55 /*
56 * Prototypes from add.c
57 */
58 extern word gsm_mult P((word a, word b));
59 extern longword gsm_L_mult P((word a, word b));
60 extern word gsm_mult_r P((word a, word b));
61
62 extern word gsm_div P((word num, word denum));
63
64 extern word gsm_add P(( word a, word b ));
65 extern longword gsm_L_add P(( longword a, longword b ));
66
67 extern word gsm_sub P((word a, word b));
68 extern longword gsm_L_sub P((longword a, longword b));
69
70 extern word gsm_abs P((word a));
71
72 extern word gsm_norm P(( longword a ));
73
74 extern longword gsm_L_asl P((longword a, int n));
75 extern word gsm_asl P((word a, int n));
76
77 extern longword gsm_L_asr P((longword a, int n));
78 extern word gsm_asr P((word a, int n));
79
80 /*
81 * Inlined functions from add.h
82 */
83
84 /*
85 * #define GSM_MULT_R(a, b) (* word a, word b, !(a == b == MIN_WORD) *) \
86 * (0x0FFFF & SASR(((longword)(a) * (longword)(b) + 16384), 15))
87 */
88 #define GSM_MULT_R(a, b) /* word a, word b, !(a == b == MIN_WORD) */ \
89 (SASR( ((longword)(a) * (longword)(b) + 16384), 15 ))
90
91 # define GSM_MULT(a,b) /* word a, word b, !(a == b == MIN_WORD) */ \
92 (SASR( ((longword)(a) * (longword)(b)), 15 ))
93
94 # define GSM_L_MULT(a, b) /* word a, word b */ \
95 (((longword)(a) * (longword)(b)) << 1)
96
97 # define GSM_L_ADD(a, b) \
98 ( (a) < 0 ? ( (b) >= 0 ? (a) + (b) \
99 : (utmp = (ulongword)-((a) + 1) + (ulongword)-((b) + 1)) \
100 >= MAX_LONGWORD ? MIN_LONGWORD : -(longword)utmp-2 ) \
101 : ((b) <= 0 ? (a) + (b) \
102 : (utmp = (ulongword)(a) + (ulongword)(b)) >= MAX_LONGWORD \
103 ? MAX_LONGWORD : utmp))
104
105 /*
106 * # define GSM_ADD(a, b) \
107 * ((ltmp = (longword)(a) + (longword)(b)) >= MAX_WORD \
108 * ? MAX_WORD : ltmp <= MIN_WORD ? MIN_WORD : ltmp)
109 */
110 /* Nonportable, but faster: */
111
112 #define GSM_ADD(a, b) \
113 ((ulongword)((ltmp = (longword)(a) + (longword)(b)) - MIN_WORD) > \
114 MAX_WORD - MIN_WORD ? (ltmp > 0 ? MAX_WORD : MIN_WORD) : ltmp)
115
116 # define GSM_SUB(a, b) \
117 ((ltmp = (longword)(a) - (longword)(b)) >= MAX_WORD \
118 ? MAX_WORD : ltmp <= MIN_WORD ? MIN_WORD : ltmp)
119
120 # define GSM_ABS(a) ((a) < 0 ? ((a) == MIN_WORD ? MAX_WORD : -(a)) : (a))
121
122 /* Use these if necessary:
123
124 # define GSM_MULT_R(a, b) gsm_mult_r(a, b)
125 # define GSM_MULT(a, b) gsm_mult(a, b)
126 # define GSM_L_MULT(a, b) gsm_L_mult(a, b)
127
128 # define GSM_L_ADD(a, b) gsm_L_add(a, b)
129 # define GSM_ADD(a, b) gsm_add(a, b)
130 # define GSM_SUB(a, b) gsm_sub(a, b)
131
132 # define GSM_ABS(a) gsm_abs(a)
133
134 */
135
136 /*
137 * More prototypes from implementations..
138 */
139 extern void Gsm_Coder P((
140 struct gsm_state * S,
141 word * s, /* [0..159] samples IN */
142 word * LARc, /* [0..7] LAR coefficients OUT */
143 word * Nc, /* [0..3] LTP lag OUT */
144 word * bc, /* [0..3] coded LTP gain OUT */
145 word * Mc, /* [0..3] RPE grid selection OUT */
146 word * xmaxc,/* [0..3] Coded maximum amplitude OUT */
147 word * xMc /* [13*4] normalized RPE samples OUT */));
148
149 extern void Gsm_Long_Term_Predictor P(( /* 4x for 160 samples */
150 struct gsm_state * S,
151 word * d, /* [0..39] residual signal IN */
152 word * dp, /* [-120..-1] d' IN */
153 word * e, /* [0..40] OUT */
154 word * dpp, /* [0..40] OUT */
155 word * Nc, /* correlation lag OUT */
156 word * bc /* gain factor OUT */));
157
158 extern void Gsm_LPC_Analysis P((
159 struct gsm_state * S,
160 word * s, /* 0..159 signals IN/OUT */
161 word * LARc)); /* 0..7 LARc's OUT */
162
163 extern void Gsm_Preprocess P((
164 struct gsm_state * S,
165 word * s, word * so));
166
167 extern void Gsm_Encoding P((
168 struct gsm_state * S,
169 word * e,
170 word * ep,
171 word * xmaxc,
172 word * Mc,
173 word * xMc));
174
175 extern void Gsm_Short_Term_Analysis_Filter P((
176 struct gsm_state * S,
177 word * LARc, /* coded log area ratio [0..7] IN */
178 word * d /* st res. signal [0..159] IN/OUT */));
179
180 extern void Gsm_Decoder P((
181 struct gsm_state * S,
182 word * LARcr, /* [0..7] IN */
183 word * Ncr, /* [0..3] IN */
184 word * bcr, /* [0..3] IN */
185 word * Mcr, /* [0..3] IN */
186 word * xmaxcr, /* [0..3] IN */
187 word * xMcr, /* [0..13*4] IN */
188 word * s)); /* [0..159] OUT */
189
190 extern void Gsm_Decoding P((
191 struct gsm_state * S,
192 word xmaxcr,
193 word Mcr,
194 word * xMcr, /* [0..12] IN */
195 word * erp)); /* [0..39] OUT */
196
197 extern void Gsm_Long_Term_Synthesis_Filtering P((
198 struct gsm_state* S,
199 word Ncr,
200 word bcr,
201 word * erp, /* [0..39] IN */
202 word * drp)); /* [-120..-1] IN, [0..40] OUT */
203
204 void Gsm_RPE_Decoding P((
205 struct gsm_state *S,
206 word xmaxcr,
207 word Mcr,
208 word * xMcr, /* [0..12], 3 bits IN */
209 word * erp)); /* [0..39] OUT */
210
211 void Gsm_RPE_Encoding P((
212 struct gsm_state * S,
213 word * e, /* -5..-1][0..39][40..44 IN/OUT */
214 word * xmaxc, /* OUT */
215 word * Mc, /* OUT */
216 word * xMc)); /* [0..12] OUT */
217
218 extern void Gsm_Short_Term_Synthesis_Filter P((
219 struct gsm_state * S,
220 word * LARcr, /* log area ratios [0..7] IN */
221 word * drp, /* received d [0...39] IN */
222 word * s)); /* signal s [0..159] OUT */
223
224 extern void Gsm_Update_of_reconstructed_short_time_residual_signal P((
225 word * dpp, /* [0...39] IN */
226 word * ep, /* [0...39] IN */
227 word * dp)); /* [-120...-1] IN/OUT */
228
229 /*
230 * Tables from table.c
231 */
232 #ifndef GSM_TABLE_C
233
234 extern word gsm_A[8], gsm_B[8], gsm_MIC[8], gsm_MAC[8];
235 extern word gsm_INVA[8];
236 extern word gsm_DLB[4], gsm_QLB[4];
237 extern word gsm_H[11];
238 extern word gsm_NRFAC[8];
239 extern word gsm_FAC[8];
240
241 #endif /* GSM_TABLE_C */
242
243 /*
244 * Debugging
245 */
246 #ifdef NDEBUG
247
248 # define gsm_debug_words(a, b, c, d) /* nil */
249 # define gsm_debug_longwords(a, b, c, d) /* nil */
250 # define gsm_debug_word(a, b) /* nil */
251 # define gsm_debug_longword(a, b) /* nil */
252
253 #else /* !NDEBUG => DEBUG */
254
255 extern void gsm_debug_words P((char * name, int, int, word *));
256 extern void gsm_debug_longwords P((char * name, int, int, longword *));
257 extern void gsm_debug_longword P((char * name, longword));
258 extern void gsm_debug_word P((char * name, word));
259
260 #endif /* !NDEBUG */
261
262 #include "unproto.h"
263
264 #endif /* PRIVATE_H */