comparison libgsmfr2/ed_internal.h @ 264:8b21a6b7a3bf

libgsmfr2: beginning to integrate TU-Berlin code guts
author Mychaela Falconia <falcon@freecalypso.org>
date Sun, 14 Apr 2024 00:06:50 +0000
parents
children
comparison
equal deleted inserted replaced
263:ffdcdb27d673 264:8b21a6b7a3bf
1 /*
2 * This header file has been adapted from inc/private.h
3 * in TU-Berlin libgsm source, original notice follows:
4 *
5 * Copyright 1992 by Jutta Degener and Carsten Bormann, Technische
6 * Universitaet Berlin. See the accompanying file "COPYRIGHT" for
7 * details. THERE IS ABSOLUTELY NO WARRANTY FOR THIS SOFTWARE.
8 */
9
10 #define SASR(x, by) ((x) >> (by))
11
12 /*
13 * Prototypes from add.c
14 */
15 extern word gsm_mult (word a, word b);
16 extern longword gsm_L_mult (word a, word b);
17 extern word gsm_mult_r (word a, word b);
18
19 extern word gsm_div (word num, word denum);
20
21 extern word gsm_add ( word a, word b );
22 extern longword gsm_L_add ( longword a, longword b );
23
24 extern word gsm_sub (word a, word b);
25 extern longword gsm_L_sub (longword a, longword b);
26
27 extern word gsm_abs (word a);
28
29 extern word gsm_norm ( longword a );
30
31 extern longword gsm_L_asl (longword a, int n);
32 extern word gsm_asl (word a, int n);
33
34 extern longword gsm_L_asr (longword a, int n);
35 extern word gsm_asr (word a, int n);
36
37 /*
38 * Inlined functions from add.h
39 */
40
41 /*
42 * #define GSM_MULT_R(a, b) (* word a, word b, !(a == b == MIN_WORD) *) \
43 * (0x0FFFF & SASR(((longword)(a) * (longword)(b) + 16384), 15))
44 */
45 #define GSM_MULT_R(a, b) /* word a, word b, !(a == b == MIN_WORD) */ \
46 (SASR( ((longword)(a) * (longword)(b) + 16384), 15 ))
47
48 # define GSM_MULT(a,b) /* word a, word b, !(a == b == MIN_WORD) */ \
49 (SASR( ((longword)(a) * (longword)(b)), 15 ))
50
51 # define GSM_L_MULT(a, b) /* word a, word b */ \
52 (((longword)(a) * (longword)(b)) << 1)
53
54 # define GSM_L_ADD(a, b) \
55 ( (a) < 0 ? ( (b) >= 0 ? (a) + (b) \
56 : (utmp = (ulongword)-((a) + 1) + (ulongword)-((b) + 1)) \
57 >= MAX_LONGWORD ? MIN_LONGWORD : -(longword)utmp-2 ) \
58 : ((b) <= 0 ? (a) + (b) \
59 : (utmp = (ulongword)(a) + (ulongword)(b)) >= MAX_LONGWORD \
60 ? MAX_LONGWORD : utmp))
61
62 /*
63 * # define GSM_ADD(a, b) \
64 * ((ltmp = (longword)(a) + (longword)(b)) >= MAX_WORD \
65 * ? MAX_WORD : ltmp <= MIN_WORD ? MIN_WORD : ltmp)
66 */
67 /* Nonportable, but faster: */
68
69 #define GSM_ADD(a, b) \
70 ((ulongword)((ltmp = (longword)(a) + (longword)(b)) - MIN_WORD) > \
71 MAX_WORD - MIN_WORD ? (ltmp > 0 ? MAX_WORD : MIN_WORD) : ltmp)
72
73 # define GSM_SUB(a, b) \
74 ((ltmp = (longword)(a) - (longword)(b)) >= MAX_WORD \
75 ? MAX_WORD : ltmp <= MIN_WORD ? MIN_WORD : ltmp)
76
77 # define GSM_ABS(a) ((a) < 0 ? ((a) == MIN_WORD ? MAX_WORD : -(a)) : (a))
78
79 /* Use these if necessary:
80
81 # define GSM_MULT_R(a, b) gsm_mult_r(a, b)
82 # define GSM_MULT(a, b) gsm_mult(a, b)
83 # define GSM_L_MULT(a, b) gsm_L_mult(a, b)
84
85 # define GSM_L_ADD(a, b) gsm_L_add(a, b)
86 # define GSM_ADD(a, b) gsm_add(a, b)
87 # define GSM_SUB(a, b) gsm_sub(a, b)
88
89 # define GSM_ABS(a) gsm_abs(a)
90
91 */
92
93 /*
94 * More prototypes from implementations..
95 */
96
97 void Gsm_Long_Term_Predictor ( /* 4x for 160 samples */
98 struct gsmfr_0610_state * S,
99 word * d, /* [0..39] residual signal IN */
100 word * dp, /* [-120..-1] d' IN */
101 word * e, /* [0..40] OUT */
102 word * dpp, /* [0..40] OUT */
103 word * Nc, /* correlation lag OUT */
104 word * bc /* gain factor OUT */);
105
106 void Gsm_LPC_Analysis (
107 struct gsmfr_0610_state * S,
108 word * s, /* 0..159 signals IN/OUT */
109 word * LARc); /* 0..7 LARc's OUT */
110
111 void Gsm_Preprocess (
112 struct gsmfr_0610_state * S,
113 const word * s, word * so);
114
115 void Gsm_Encoding (
116 struct gsmfr_0610_state * S,
117 word * e,
118 word * ep,
119 word * xmaxc,
120 word * Mc,
121 word * xMc);
122
123 void Gsm_Short_Term_Analysis_Filter (
124 struct gsmfr_0610_state * S,
125 const word * LARc, /* coded log area ratio [0..7] IN */
126 word * d /* st res. signal [0..159] IN/OUT */);
127
128 void Gsm_Decoding (
129 struct gsmfr_0610_state * S,
130 word xmaxcr,
131 word Mcr,
132 const word * xMcr, /* [0..12] IN */
133 word * erp); /* [0..39] OUT */
134
135 void Gsm_Long_Term_Synthesis_Filtering (
136 struct gsmfr_0610_state* S,
137 word Ncr,
138 word bcr,
139 word * erp, /* [0..39] IN */
140 word * drp); /* [-120..-1] IN, [0..40] OUT */
141
142 void Gsm_RPE_Decoding (
143 struct gsmfr_0610_state *S,
144 word xmaxcr,
145 word Mcr,
146 const word * xMcr, /* [0..12], 3 bits IN */
147 word * erp); /* [0..39] OUT */
148
149 void Gsm_RPE_Encoding (
150 struct gsmfr_0610_state * S,
151 word * e, /* -5..-1][0..39][40..44 IN/OUT */
152 word * xmaxc, /* OUT */
153 word * Mc, /* OUT */
154 word * xMc); /* [0..12] OUT */
155
156 void Gsm_Short_Term_Synthesis_Filter (
157 struct gsmfr_0610_state * S,
158 const word * LARcr, /* log area ratios [0..7] IN */
159 word * drp, /* received d [0...39] IN */
160 word * s); /* signal s [0..159] OUT */
161
162 void Gsm_Update_of_reconstructed_short_time_residual_signal (
163 word * dpp, /* [0...39] IN */
164 word * ep, /* [0...39] IN */
165 word * dp); /* [-120...-1] IN/OUT */
166
167 /*
168 * Tables from table.c
169 */
170
171 extern word gsm_A[8], gsm_B[8], gsm_MIC[8], gsm_MAC[8];
172 extern word gsm_INVA[8];
173 extern word gsm_DLB[4], gsm_QLB[4];
174 extern word gsm_H[11];
175 extern word gsm_NRFAC[8];
176 extern word gsm_FAC[8];