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