~ubuntu-branches/ubuntu/raring/lmms/raring-proposed

« back to all changes in this revision

Viewing changes to plugins/ladspa_effect/swh/gsm/private.h

  • Committer: Charlie Smotherman
  • Date: 2012-12-05 22:08:38 UTC
  • mfrom: (33.1.7 lmms_0.4.13)
  • Revision ID: cjsmo@cableone.net-20121205220838-09pjfzew9m5023hr
* New  Upstream release.
  - Minor tweaking to ZynAddSubFX, CALF, SWH plugins  and Stefan Fendt's RC
    filters.
  - Added UI fixes: Magnentic effect of knobs and Piano-roll fixes
  - Updated German localization and copyright year
* debian/lmms-common.install:
  - added /usr/share/applications so the lmms.desktop file will correctly
    install (LP: #863366)
  - This should also fix the Software Center not displaying lmms in sound
    and video (LP: #824231)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
 
 
22
typedef short                           word;           /* 16 bit signed int    */
 
23
typedef int                                     longword;       /* 32 bit signed int    */
 
24
 
 
25
typedef unsigned short          uword;          /* unsigned word        */
 
26
typedef unsigned int            ulongword;      /* unsigned longword    */
 
27
 
 
28
struct 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
 */
 
72
extern word     gsm_mult                (word a, word b);
 
73
extern longword gsm_L_mult      (word a, word b);
 
74
extern word     gsm_mult_r              (word a, word b);
 
75
 
 
76
extern word     gsm_div                 (word num, word denum);
 
77
 
 
78
extern word     gsm_add                 (word a, word b );
 
79
extern longword gsm_L_add       (longword a, longword b );
 
80
 
 
81
extern word     gsm_sub                 (word a, word b);
 
82
extern longword gsm_L_sub       (longword a, longword b);
 
83
 
 
84
extern word     gsm_abs                 (word a);
 
85
 
 
86
extern word     gsm_norm                (longword a );
 
87
 
 
88
extern longword gsm_L_asl       (longword a, int n);
 
89
extern word     gsm_asl                 (word a, int n);
 
90
 
 
91
extern longword gsm_L_asr       (longword a, int n);
 
92
extern 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
 */
 
153
extern 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
 
 
163
extern 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
 
 
172
extern 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
 
 
177
extern void Gsm_Preprocess P((
 
178
                struct gsm_state * S,
 
179
                word * s, word * so));
 
180
 
 
181
extern 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
 
 
189
extern 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
 
 
194
extern 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
 
 
204
extern 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
 
 
211
extern 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
 
 
218
void 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
 
 
225
void 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
 
 
232
extern 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
 
 
238
extern 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
 
 
248
extern word gsm_A[8], gsm_B[8], gsm_MIC[8], gsm_MAC[8];
 
249
extern word gsm_INVA[8];
 
250
extern word gsm_DLB[4], gsm_QLB[4];
 
251
extern word gsm_H[11];
 
252
extern word gsm_NRFAC[8];
 
253
extern 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 */