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