e121c1c34e41776761b1a7122ab90e1325611eef
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.
10 /* Added by Erik de Castro Lopo */
16 #error "This code is not designed to be compiled with a C++ compiler."
18 /* Added by Erik de Castro Lopo */
22 typedef short word
; /* 16 bit signed int */
23 typedef int longword
; /* 32 bit signed int */
25 typedef unsigned short uword
; /* unsigned word */
26 typedef unsigned int ulongword
; /* unsigned longword */
31 word z1
; /* preprocessing.c, Offset_com. */
32 longword L_z2
; /* Offset_com. */
33 int mp
; /* Preemphasis */
35 word u
[8] ; /* short_term_aly_filter.c */
36 word LARpp
[2][8] ; /* */
39 word ltp_cut
; /* long_term.c, LTP crosscorr. */
40 word nrp
; /* 40 */ /* long_term.c, synthesis */
41 word v
[9] ; /* short_term.c, synthesis */
42 word msr
; /* decoder.c, Postprocessing */
44 char verbose
; /* only used if !NDEBUG */
45 char fast
; /* only used if FAST */
47 char wav_fmt
; /* only used if WAV49 defined */
48 unsigned char frame_index
; /* odd/even chaining */
49 unsigned char frame_chain
; /* half-byte to carry forward */
51 /* Moved here from code.c where it was defined as static */
55 typedef struct gsm_state GSM_STATE
;
57 #define MIN_WORD (-32767 - 1)
58 #define MAX_WORD 32767
60 #define MIN_LONGWORD (-2147483647 - 1)
61 #define MAX_LONGWORD 2147483647
63 /* Signed arithmetic shift right. */
65 SASR_W (word x
, word by
)
69 static inline longword
70 SASR_L (longword x
, word by
)
75 * Prototypes from add.c
77 word
gsm_mult (word a
, word b
) ;
78 longword
gsm_L_mult (word a
, word b
) ;
79 word
gsm_mult_r (word a
, word b
) ;
81 word
gsm_div (word num
, word denum
) ;
83 word
gsm_add (word a
, word b
) ;
84 longword
gsm_L_add (longword a
, longword b
) ;
86 word
gsm_sub (word a
, word b
) ;
87 longword
gsm_L_sub (longword a
, longword b
) ;
89 word
gsm_abs (word a
) ;
91 word
gsm_norm (longword a
) ;
93 longword
gsm_L_asl (longword a
, int n
) ;
94 word
gsm_asl (word a
, int n
) ;
96 longword
gsm_L_asr (longword a
, int n
) ;
97 word
gsm_asr (word a
, int n
) ;
100 * Inlined functions from add.h
103 static inline longword
104 GSM_MULT_R (word a
, word b
)
105 { return (((longword
) (a
)) * ((longword
) (b
)) + 16384) >> 15 ;
108 static inline longword
109 GSM_MULT (word a
, word b
)
110 { return (((longword
) (a
)) * ((longword
) (b
))) >> 15 ;
113 static inline longword
114 GSM_L_MULT (word a
, word b
)
115 { return ((longword
) (a
)) * ((longword
) (b
)) << 1 ;
118 static inline longword
119 GSM_L_ADD (longword a
, longword b
)
123 { utmp
= (ulongword
)-((a
) + 1) + (ulongword
)-((b
) + 1) ;
124 return (utmp
>= (ulongword
) MAX_LONGWORD
) ? MIN_LONGWORD
: -(longword
)utmp
-2 ;
128 { utmp
= (ulongword
) a
+ (ulongword
) b
;
129 return (utmp
>= (ulongword
) MAX_LONGWORD
) ? MAX_LONGWORD
: utmp
;
135 static inline longword
136 GSM_ADD (word a
, word b
)
139 ltmp
= ((longword
) a
) + ((longword
) b
) ;
141 if (ltmp
>= MAX_WORD
)
143 if (ltmp
<= MIN_WORD
)
149 static inline longword
150 GSM_SUB (word a
, word b
)
153 ltmp
= ((longword
) a
) - ((longword
) b
) ;
155 if (ltmp
>= MAX_WORD
)
157 else if (ltmp
<= MIN_WORD
)
175 * More prototypes from implementations..
178 struct gsm_state
* S
,
179 word
* s
, /* [0..159] samples IN */
180 word
* LARc
, /* [0..7] LAR coefficients OUT */
181 word
* Nc
, /* [0..3] LTP lag OUT */
182 word
* bc
, /* [0..3] coded LTP gain OUT */
183 word
* Mc
, /* [0..3] RPE grid selection OUT */
184 word
* xmaxc
,/* [0..3] Coded maximum amplitude OUT */
185 word
* xMc
) ;/* [13*4] normalized RPE samples OUT */
187 void Gsm_Long_Term_Predictor ( /* 4x for 160 samples */
188 struct gsm_state
* S
,
189 word
* d
, /* [0..39] residual signal IN */
190 word
* dp
, /* [-120..-1] d' IN */
191 word
* e
, /* [0..40] OUT */
192 word
* dpp
, /* [0..40] OUT */
193 word
* Nc
, /* correlation lag OUT */
194 word
* bc
) ; /* gain factor OUT */
196 void Gsm_LPC_Analysis (
197 struct gsm_state
* S
,
198 word
* s
, /* 0..159 signals IN/OUT */
199 word
* LARc
) ; /* 0..7 LARc's OUT */
201 void Gsm_Preprocess (
202 struct gsm_state
* S
,
203 word
* s
, word
* so
) ;
206 struct gsm_state
* S
,
213 void Gsm_Short_Term_Analysis_Filter (
214 struct gsm_state
* S
,
215 word
* LARc
, /* coded log area ratio [0..7] IN */
216 word
* d
) ; /* st res. signal [0..159] IN/OUT */
219 struct gsm_state
* S
,
220 word
* LARcr
, /* [0..7] IN */
221 word
* Ncr
, /* [0..3] IN */
222 word
* bcr
, /* [0..3] IN */
223 word
* Mcr
, /* [0..3] IN */
224 word
* xmaxcr
, /* [0..3] IN */
225 word
* xMcr
, /* [0..13*4] IN */
226 word
* s
) ; /* [0..159] OUT */
229 struct gsm_state
* S
,
232 word
* xMcr
, /* [0..12] IN */
233 word
* erp
) ; /* [0..39] OUT */
235 void Gsm_Long_Term_Synthesis_Filtering (
239 word
* erp
, /* [0..39] IN */
240 word
* drp
) ; /* [-120..-1] IN, [0..40] OUT */
242 void Gsm_RPE_Decoding (
243 /*-struct gsm_state *S,-*/
246 word
* xMcr
, /* [0..12], 3 bits IN */
247 word
* erp
) ; /* [0..39] OUT */
249 void Gsm_RPE_Encoding (
250 /*-struct gsm_state * S,-*/
251 word
* e
, /* -5..-1][0..39][40..44 IN/OUT */
252 word
* xmaxc
, /* OUT */
254 word
* xMc
) ; /* [0..12] OUT */
256 void Gsm_Short_Term_Synthesis_Filter (
257 struct gsm_state
* S
,
258 word
* LARcr
, /* log area ratios [0..7] IN */
259 word
* drp
, /* received d [0...39] IN */
260 word
* s
) ; /* signal s [0..159] OUT */
262 void Gsm_Update_of_reconstructed_short_time_residual_signal (
263 word
* dpp
, /* [0...39] IN */
264 word
* ep
, /* [0...39] IN */
265 word
* dp
) ; /* [-120...-1] IN/OUT */
268 * Tables from table.c
272 extern word gsm_A
[8], gsm_B
[8], gsm_MIC
[8], gsm_MAC
[8] ;
273 extern word gsm_INVA
[8] ;
274 extern word gsm_DLB
[4], gsm_QLB
[4] ;
275 extern word gsm_H
[11] ;
276 extern word gsm_NRFAC
[8] ;
277 extern word gsm_FAC
[8] ;
279 #endif /* GSM_TABLE_C */
286 # define gsm_debug_words(a, b, c, d) /* nil */
287 # define gsm_debug_longwords(a, b, c, d) /* nil */
288 # define gsm_debug_word(a, b) /* nil */
289 # define gsm_debug_longword(a, b) /* nil */
291 #else /* !NDEBUG => DEBUG */
293 void gsm_debug_words (char * name
, int, int, word
*) ;
294 void gsm_debug_longwords (char * name
, int, int, longword
*) ;
295 void gsm_debug_longword (char * name
, longword
) ;
296 void gsm_debug_word (char * name
, word
) ;
300 #endif /* PRIVATE_H */