Mercurial > hg > audiostuff
comparison intercom/ilbc/iLBC_define.h @ 2:13be24d74cd2
import intercom-0.4.1
| author | Peter Meerwald <pmeerw@cosy.sbg.ac.at> |
|---|---|
| date | Fri, 25 Jun 2010 09:57:52 +0200 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| 1:9cadc470e3da | 2:13be24d74cd2 |
|---|---|
| 1 | |
| 2 /****************************************************************** | |
| 3 | |
| 4 iLBC Speech Coder ANSI-C Source Code | |
| 5 | |
| 6 iLBC_define.h | |
| 7 | |
| 8 Copyright (C) The Internet Society (2004). | |
| 9 All Rights Reserved. | |
| 10 | |
| 11 ******************************************************************/ | |
| 12 #include <string.h> | |
| 13 | |
| 14 #ifndef __iLBC_ILBCDEFINE_H | |
| 15 #define __iLBC_ILBCDEFINE_H | |
| 16 | |
| 17 /* general codec settings */ | |
| 18 | |
| 19 #define FS (float)8000.0 | |
| 20 #define BLOCKL_20MS 160 | |
| 21 #define BLOCKL_30MS 240 | |
| 22 #define BLOCKL_MAX 240 | |
| 23 #define NSUB_20MS 4 | |
| 24 #define NSUB_30MS 6 | |
| 25 #define NSUB_MAX 6 | |
| 26 #define NASUB_20MS 2 | |
| 27 | |
| 28 | |
| 29 | |
| 30 | |
| 31 | |
| 32 #define NASUB_30MS 4 | |
| 33 #define NASUB_MAX 4 | |
| 34 #define SUBL 40 | |
| 35 #define STATE_LEN 80 | |
| 36 #define STATE_SHORT_LEN_30MS 58 | |
| 37 #define STATE_SHORT_LEN_20MS 57 | |
| 38 | |
| 39 /* LPC settings */ | |
| 40 | |
| 41 #define LPC_FILTERORDER 10 | |
| 42 #define LPC_CHIRP_SYNTDENUM (float)0.9025 | |
| 43 #define LPC_CHIRP_WEIGHTDENUM (float)0.4222 | |
| 44 #define LPC_LOOKBACK 60 | |
| 45 #define LPC_N_20MS 1 | |
| 46 #define LPC_N_30MS 2 | |
| 47 #define LPC_N_MAX 2 | |
| 48 #define LPC_ASYMDIFF 20 | |
| 49 #define LPC_BW (float)60.0 | |
| 50 #define LPC_WN (float)1.0001 | |
| 51 #define LSF_NSPLIT 3 | |
| 52 #define LSF_NUMBER_OF_STEPS 4 | |
| 53 #define LPC_HALFORDER (LPC_FILTERORDER/2) | |
| 54 | |
| 55 /* cb settings */ | |
| 56 | |
| 57 #define CB_NSTAGES 3 | |
| 58 #define CB_EXPAND 2 | |
| 59 #define CB_MEML 147 | |
| 60 #define CB_FILTERLEN 2*4 | |
| 61 #define CB_HALFFILTERLEN 4 | |
| 62 #define CB_RESRANGE 34 | |
| 63 #define CB_MAXGAIN (float)1.3 | |
| 64 | |
| 65 /* enhancer */ | |
| 66 | |
| 67 #define ENH_BLOCKL 80 /* block length */ | |
| 68 #define ENH_BLOCKL_HALF (ENH_BLOCKL/2) | |
| 69 #define ENH_HL 3 /* 2*ENH_HL+1 is number blocks | |
| 70 in said second sequence */ | |
| 71 #define ENH_SLOP 2 /* max difference estimated and | |
| 72 correct pitch period */ | |
| 73 #define ENH_PLOCSL 20 /* pitch-estimates and pitch- | |
| 74 locations buffer length */ | |
| 75 #define ENH_OVERHANG 2 | |
| 76 #define ENH_UPS0 4 /* upsampling rate */ | |
| 77 #define ENH_FL0 3 /* 2*FLO+1 is the length of | |
| 78 each filter */ | |
| 79 #define ENH_VECTL (ENH_BLOCKL+2*ENH_FL0) | |
| 80 | |
| 81 | |
| 82 | |
| 83 | |
| 84 | |
| 85 #define ENH_CORRDIM (2*ENH_SLOP+1) | |
| 86 #define ENH_NBLOCKS (BLOCKL_MAX/ENH_BLOCKL) | |
| 87 #define ENH_NBLOCKS_EXTRA 5 | |
| 88 #define ENH_NBLOCKS_TOT 8 /* ENH_NBLOCKS + | |
| 89 ENH_NBLOCKS_EXTRA */ | |
| 90 #define ENH_BUFL (ENH_NBLOCKS_TOT)*ENH_BLOCKL | |
| 91 #define ENH_ALPHA0 (float)0.05 | |
| 92 | |
| 93 /* Down sampling */ | |
| 94 | |
| 95 #define FILTERORDER_DS 7 | |
| 96 #define DELAY_DS 3 | |
| 97 #define FACTOR_DS 2 | |
| 98 | |
| 99 /* bit stream defs */ | |
| 100 | |
| 101 #define NO_OF_BYTES_20MS 38 | |
| 102 #define NO_OF_BYTES_30MS 50 | |
| 103 #define NO_OF_WORDS_20MS 19 | |
| 104 #define NO_OF_WORDS_30MS 25 | |
| 105 #define STATE_BITS 3 | |
| 106 #define BYTE_LEN 8 | |
| 107 #define ULP_CLASSES 3 | |
| 108 | |
| 109 /* help parameters */ | |
| 110 | |
| 111 #define FLOAT_MAX (float)1.0e37 | |
| 112 #define EPS (float)2.220446049250313e-016 | |
| 113 #define PI (float)3.14159265358979323846 | |
| 114 #define MIN_SAMPLE -32768 | |
| 115 #define MAX_SAMPLE 32767 | |
| 116 #define TWO_PI (float)6.283185307 | |
| 117 #define PI2 (float)0.159154943 | |
| 118 | |
| 119 /* type definition encoder instance */ | |
| 120 typedef struct iLBC_ULP_Inst_t_ { | |
| 121 int lsf_bits[6][ULP_CLASSES + 2]; | |
| 122 int start_bits[ULP_CLASSES + 2]; | |
| 123 int startfirst_bits[ULP_CLASSES + 2]; | |
| 124 int scale_bits[ULP_CLASSES + 2]; | |
| 125 int state_bits[ULP_CLASSES + 2]; | |
| 126 int extra_cb_index[CB_NSTAGES][ULP_CLASSES + 2]; | |
| 127 int extra_cb_gain[CB_NSTAGES][ULP_CLASSES + 2]; | |
| 128 int cb_index[NSUB_MAX][CB_NSTAGES][ULP_CLASSES + 2]; | |
| 129 int cb_gain[NSUB_MAX][CB_NSTAGES][ULP_CLASSES + 2]; | |
| 130 } iLBC_ULP_Inst_t; | |
| 131 | |
| 132 /* type definition encoder instance */ | |
| 133 | |
| 134 | |
| 135 | |
| 136 | |
| 137 | |
| 138 typedef struct iLBC_Enc_Inst_t_ { | |
| 139 | |
| 140 /* flag for frame size mode */ | |
| 141 int mode; | |
| 142 | |
| 143 /* basic parameters for different frame sizes */ | |
| 144 int blockl; | |
| 145 int nsub; | |
| 146 int nasub; | |
| 147 int no_of_bytes, no_of_words; | |
| 148 int lpc_n; | |
| 149 int state_short_len; | |
| 150 const iLBC_ULP_Inst_t *ULP_inst; | |
| 151 | |
| 152 /* analysis filter state */ | |
| 153 float anaMem[LPC_FILTERORDER]; | |
| 154 | |
| 155 /* old lsf parameters for interpolation */ | |
| 156 float lsfold[LPC_FILTERORDER]; | |
| 157 float lsfdeqold[LPC_FILTERORDER]; | |
| 158 | |
| 159 /* signal buffer for LP analysis */ | |
| 160 float lpc_buffer[LPC_LOOKBACK + BLOCKL_MAX]; | |
| 161 | |
| 162 /* state of input HP filter */ | |
| 163 float hpimem[4]; | |
| 164 | |
| 165 } iLBC_Enc_Inst_t; | |
| 166 | |
| 167 /* type definition decoder instance */ | |
| 168 typedef struct iLBC_Dec_Inst_t_ { | |
| 169 | |
| 170 /* flag for frame size mode */ | |
| 171 int mode; | |
| 172 | |
| 173 /* basic parameters for different frame sizes */ | |
| 174 int blockl; | |
| 175 int nsub; | |
| 176 int nasub; | |
| 177 int no_of_bytes, no_of_words; | |
| 178 int lpc_n; | |
| 179 int state_short_len; | |
| 180 const iLBC_ULP_Inst_t *ULP_inst; | |
| 181 | |
| 182 /* synthesis filter state */ | |
| 183 float syntMem[LPC_FILTERORDER]; | |
| 184 | |
| 185 /* old LSF for interpolation */ | |
| 186 | |
| 187 | |
| 188 | |
| 189 | |
| 190 | |
| 191 float lsfdeqold[LPC_FILTERORDER]; | |
| 192 | |
| 193 /* pitch lag estimated in enhancer and used in PLC */ | |
| 194 int last_lag; | |
| 195 | |
| 196 /* PLC state information */ | |
| 197 int prevLag, consPLICount, prevPLI, prev_enh_pl; | |
| 198 float prevLpc[LPC_FILTERORDER + 1]; | |
| 199 float prevResidual[NSUB_MAX * SUBL]; | |
| 200 float per; | |
| 201 unsigned long seed; | |
| 202 | |
| 203 /* previous synthesis filter parameters */ | |
| 204 float old_syntdenum[(LPC_FILTERORDER + 1) * NSUB_MAX]; | |
| 205 | |
| 206 /* state of output HP filter */ | |
| 207 float hpomem[4]; | |
| 208 | |
| 209 /* enhancer state information */ | |
| 210 int use_enhancer; | |
| 211 float enh_buf[ENH_BUFL]; | |
| 212 float enh_period[ENH_NBLOCKS_TOT]; | |
| 213 | |
| 214 } iLBC_Dec_Inst_t; | |
| 215 | |
| 216 #endif |
