GNU Radio 3.5.1 C++ API
|
00001 /* 00002 * Copyright 1992 by Jutta Degener and Carsten Bormann, Technische 00003 * Universitaet Berlin. See the accompanying file "COPYRIGHT" for 00004 * details. THERE IS ABSOLUTELY NO WARRANTY FOR THIS SOFTWARE. 00005 */ 00006 00007 /*$Header$*/ 00008 00009 #ifndef PRIVATE_H 00010 #define PRIVATE_H 00011 00012 typedef short word; /* 16 bit signed int */ 00013 typedef long longword; /* 32 bit signed int */ 00014 00015 typedef unsigned short uword; /* unsigned word */ 00016 typedef unsigned long ulongword; /* unsigned longword */ 00017 00018 struct gsm_state { 00019 00020 word dp0[ 280 ]; 00021 00022 word z1; /* preprocessing.c, Offset_com. */ 00023 longword L_z2; /* Offset_com. */ 00024 int mp; /* Preemphasis */ 00025 00026 word u[8]; /* short_term_aly_filter.c */ 00027 word LARpp[2][8]; /* */ 00028 word j; /* */ 00029 00030 word ltp_cut; /* long_term.c, LTP crosscorr. */ 00031 word nrp; /* 40 */ /* long_term.c, synthesis */ 00032 word v[9]; /* short_term.c, synthesis */ 00033 word msr; /* decoder.c, Postprocessing */ 00034 00035 char verbose; /* only used if !NDEBUG */ 00036 char fast; /* only used if FAST */ 00037 00038 char wav_fmt; /* only used if WAV49 defined */ 00039 unsigned char frame_index; /* odd/even chaining */ 00040 unsigned char frame_chain; /* half-byte to carry forward */ 00041 }; 00042 00043 00044 #define MIN_WORD (-32767 - 1) 00045 #define MAX_WORD 32767 00046 00047 #define MIN_LONGWORD (-2147483647 - 1) 00048 #define MAX_LONGWORD 2147483647 00049 00050 #ifdef SASR /* flag: >> is a signed arithmetic shift right */ 00051 #undef SASR 00052 #define SASR(x, by) ((x) >> (by)) 00053 #else 00054 #define SASR(x, by) ((x) >= 0 ? (x) >> (by) : (~(-((x) + 1) >> (by)))) 00055 #endif /* SASR */ 00056 00057 #include "proto.h" 00058 00059 /* 00060 * Prototypes from add.c 00061 */ 00062 extern word gsm_mult P((word a, word b)); 00063 extern longword gsm_L_mult P((word a, word b)); 00064 extern word gsm_mult_r P((word a, word b)); 00065 00066 extern word gsm_div P((word num, word denum)); 00067 00068 extern word gsm_add P(( word a, word b )); 00069 extern longword gsm_L_add P(( longword a, longword b )); 00070 00071 extern word gsm_sub P((word a, word b)); 00072 extern longword gsm_L_sub P((longword a, longword b)); 00073 00074 extern word gsm_abs P((word a)); 00075 00076 extern word gsm_norm P(( longword a )); 00077 00078 extern longword gsm_L_asl P((longword a, int n)); 00079 extern word gsm_asl P((word a, int n)); 00080 00081 extern longword gsm_L_asr P((longword a, int n)); 00082 extern word gsm_asr P((word a, int n)); 00083 00084 /* 00085 * Inlined functions from add.h 00086 */ 00087 00088 /* 00089 * #define GSM_MULT_R(a, b) (* word a, word b, !(a == b == MIN_WORD) *) \ 00090 * (0x0FFFF & SASR(((longword)(a) * (longword)(b) + 16384), 15)) 00091 */ 00092 #define GSM_MULT_R(a, b) /* word a, word b, !(a == b == MIN_WORD) */ \ 00093 (SASR( ((longword)(a) * (longword)(b) + 16384), 15 )) 00094 00095 # define GSM_MULT(a,b) /* word a, word b, !(a == b == MIN_WORD) */ \ 00096 (SASR( ((longword)(a) * (longword)(b)), 15 )) 00097 00098 # define GSM_L_MULT(a, b) /* word a, word b */ \ 00099 (((longword)(a) * (longword)(b)) << 1) 00100 00101 # define GSM_L_ADD(a, b) \ 00102 ( (a) < 0 ? ( (b) >= 0 ? (a) + (b) \ 00103 : (utmp = (ulongword)-((a) + 1) + (ulongword)-((b) + 1)) \ 00104 >= MAX_LONGWORD ? MIN_LONGWORD : -(longword)utmp-2 ) \ 00105 : ((b) <= 0 ? (a) + (b) \ 00106 : (utmp = (ulongword)(a) + (ulongword)(b)) >= MAX_LONGWORD \ 00107 ? MAX_LONGWORD : utmp)) 00108 00109 /* 00110 * # define GSM_ADD(a, b) \ 00111 * ((ltmp = (longword)(a) + (longword)(b)) >= MAX_WORD \ 00112 * ? MAX_WORD : ltmp <= MIN_WORD ? MIN_WORD : ltmp) 00113 */ 00114 /* Nonportable, but faster: */ 00115 00116 #define GSM_ADD(a, b) \ 00117 ((ulongword)((ltmp = (longword)(a) + (longword)(b)) - MIN_WORD) > \ 00118 MAX_WORD - MIN_WORD ? (ltmp > 0 ? MAX_WORD : MIN_WORD) : ltmp) 00119 00120 # define GSM_SUB(a, b) \ 00121 ((ltmp = (longword)(a) - (longword)(b)) >= MAX_WORD \ 00122 ? MAX_WORD : ltmp <= MIN_WORD ? MIN_WORD : ltmp) 00123 00124 # define GSM_ABS(a) ((a) < 0 ? ((a) == MIN_WORD ? MAX_WORD : -(a)) : (a)) 00125 00126 /* Use these if necessary: 00127 00128 # define GSM_MULT_R(a, b) gsm_mult_r(a, b) 00129 # define GSM_MULT(a, b) gsm_mult(a, b) 00130 # define GSM_L_MULT(a, b) gsm_L_mult(a, b) 00131 00132 # define GSM_L_ADD(a, b) gsm_L_add(a, b) 00133 # define GSM_ADD(a, b) gsm_add(a, b) 00134 # define GSM_SUB(a, b) gsm_sub(a, b) 00135 00136 # define GSM_ABS(a) gsm_abs(a) 00137 00138 */ 00139 00140 /* 00141 * More prototypes from implementations.. 00142 */ 00143 extern void Gsm_Coder P(( 00144 struct gsm_state * S, 00145 word * s, /* [0..159] samples IN */ 00146 word * LARc, /* [0..7] LAR coefficients OUT */ 00147 word * Nc, /* [0..3] LTP lag OUT */ 00148 word * bc, /* [0..3] coded LTP gain OUT */ 00149 word * Mc, /* [0..3] RPE grid selection OUT */ 00150 word * xmaxc,/* [0..3] Coded maximum amplitude OUT */ 00151 word * xMc /* [13*4] normalized RPE samples OUT */)); 00152 00153 extern void Gsm_Long_Term_Predictor P(( /* 4x for 160 samples */ 00154 struct gsm_state * S, 00155 word * d, /* [0..39] residual signal IN */ 00156 word * dp, /* [-120..-1] d' IN */ 00157 word * e, /* [0..40] OUT */ 00158 word * dpp, /* [0..40] OUT */ 00159 word * Nc, /* correlation lag OUT */ 00160 word * bc /* gain factor OUT */)); 00161 00162 extern void Gsm_LPC_Analysis P(( 00163 struct gsm_state * S, 00164 word * s, /* 0..159 signals IN/OUT */ 00165 word * LARc)); /* 0..7 LARc's OUT */ 00166 00167 extern void Gsm_Preprocess P(( 00168 struct gsm_state * S, 00169 word * s, word * so)); 00170 00171 extern void Gsm_Encoding P(( 00172 struct gsm_state * S, 00173 word * e, 00174 word * ep, 00175 word * xmaxc, 00176 word * Mc, 00177 word * xMc)); 00178 00179 extern void Gsm_Short_Term_Analysis_Filter P(( 00180 struct gsm_state * S, 00181 word * LARc, /* coded log area ratio [0..7] IN */ 00182 word * d /* st res. signal [0..159] IN/OUT */)); 00183 00184 extern void Gsm_Decoder P(( 00185 struct gsm_state * S, 00186 word * LARcr, /* [0..7] IN */ 00187 word * Ncr, /* [0..3] IN */ 00188 word * bcr, /* [0..3] IN */ 00189 word * Mcr, /* [0..3] IN */ 00190 word * xmaxcr, /* [0..3] IN */ 00191 word * xMcr, /* [0..13*4] IN */ 00192 word * s)); /* [0..159] OUT */ 00193 00194 extern void Gsm_Decoding P(( 00195 struct gsm_state * S, 00196 word xmaxcr, 00197 word Mcr, 00198 word * xMcr, /* [0..12] IN */ 00199 word * erp)); /* [0..39] OUT */ 00200 00201 extern void Gsm_Long_Term_Synthesis_Filtering P(( 00202 struct gsm_state* S, 00203 word Ncr, 00204 word bcr, 00205 word * erp, /* [0..39] IN */ 00206 word * drp)); /* [-120..-1] IN, [0..40] OUT */ 00207 00208 void Gsm_RPE_Decoding P(( 00209 struct gsm_state *S, 00210 word xmaxcr, 00211 word Mcr, 00212 word * xMcr, /* [0..12], 3 bits IN */ 00213 word * erp)); /* [0..39] OUT */ 00214 00215 void Gsm_RPE_Encoding P(( 00216 struct gsm_state * S, 00217 word * e, /* -5..-1][0..39][40..44 IN/OUT */ 00218 word * xmaxc, /* OUT */ 00219 word * Mc, /* OUT */ 00220 word * xMc)); /* [0..12] OUT */ 00221 00222 extern void Gsm_Short_Term_Synthesis_Filter P(( 00223 struct gsm_state * S, 00224 word * LARcr, /* log area ratios [0..7] IN */ 00225 word * drp, /* received d [0...39] IN */ 00226 word * s)); /* signal s [0..159] OUT */ 00227 00228 extern void Gsm_Update_of_reconstructed_short_time_residual_signal P(( 00229 word * dpp, /* [0...39] IN */ 00230 word * ep, /* [0...39] IN */ 00231 word * dp)); /* [-120...-1] IN/OUT */ 00232 00233 /* 00234 * Tables from table.c 00235 */ 00236 #ifndef GSM_TABLE_C 00237 00238 extern word gsm_A[8], gsm_B[8], gsm_MIC[8], gsm_MAC[8]; 00239 extern word gsm_INVA[8]; 00240 extern word gsm_DLB[4], gsm_QLB[4]; 00241 extern word gsm_H[11]; 00242 extern word gsm_NRFAC[8]; 00243 extern word gsm_FAC[8]; 00244 00245 #endif /* GSM_TABLE_C */ 00246 00247 /* 00248 * Debugging 00249 */ 00250 #ifdef NDEBUG 00251 00252 # define gsm_debug_words(a, b, c, d) /* nil */ 00253 # define gsm_debug_longwords(a, b, c, d) /* nil */ 00254 # define gsm_debug_word(a, b) /* nil */ 00255 # define gsm_debug_longword(a, b) /* nil */ 00256 00257 #else /* !NDEBUG => DEBUG */ 00258 00259 extern void gsm_debug_words P((char * name, int, int, word *)); 00260 extern void gsm_debug_longwords P((char * name, int, int, longword *)); 00261 extern void gsm_debug_longword P((char * name, longword)); 00262 extern void gsm_debug_word P((char * name, word)); 00263 00264 #endif /* !NDEBUG */ 00265 00266 #include "unproto.h" 00267 00268 #endif /* PRIVATE_H */