2
/******************************************************************
4
iLBC Speech Coder ANSI-C Source Code
8
Copyright (C) The Internet Society (2004).
11
******************************************************************/
14
#ifndef __iLBC_ILBCDEFINE_H
15
#define __iLBC_ILBCDEFINE_H
17
/* general codec settings */
19
#define FS (float)8000.0
20
#define BLOCKL_20MS 160
21
#define BLOCKL_30MS 240
22
#define BLOCKL_MAX 240
36
#define STATE_SHORT_LEN_30MS 58
37
#define STATE_SHORT_LEN_20MS 57
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
48
#define LPC_ASYMDIFF 20
49
#define LPC_BW (float)60.0
50
#define LPC_WN (float)1.0001
52
#define LSF_NUMBER_OF_STEPS 4
53
#define LPC_HALFORDER (LPC_FILTERORDER/2)
60
#define CB_FILTERLEN 2*4
61
#define CB_HALFFILTERLEN 4
62
#define CB_RESRANGE 34
63
#define CB_MAXGAIN (float)1.3
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
79
#define ENH_VECTL (ENH_BLOCKL+2*ENH_FL0)
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 +
90
#define ENH_BUFL (ENH_NBLOCKS_TOT)*ENH_BLOCKL
91
#define ENH_ALPHA0 (float)0.05
95
#define FILTERORDER_DS 7
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
107
#define ULP_CLASSES 3
109
/* help parameters */
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
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];
132
/* type definition encoder instance */
138
typedef struct iLBC_Enc_Inst_t_ {
140
/* flag for frame size mode */
143
/* basic parameters for different frame sizes */
147
int no_of_bytes, no_of_words;
150
const iLBC_ULP_Inst_t *ULP_inst;
152
/* analysis filter state */
153
float anaMem[LPC_FILTERORDER];
155
/* old lsf parameters for interpolation */
156
float lsfold[LPC_FILTERORDER];
157
float lsfdeqold[LPC_FILTERORDER];
159
/* signal buffer for LP analysis */
160
float lpc_buffer[LPC_LOOKBACK + BLOCKL_MAX];
162
/* state of input HP filter */
167
/* type definition decoder instance */
168
typedef struct iLBC_Dec_Inst_t_ {
170
/* flag for frame size mode */
173
/* basic parameters for different frame sizes */
177
int no_of_bytes, no_of_words;
180
const iLBC_ULP_Inst_t *ULP_inst;
182
/* synthesis filter state */
183
float syntMem[LPC_FILTERORDER];
185
/* old LSF for interpolation */
191
float lsfdeqold[LPC_FILTERORDER];
193
/* pitch lag estimated in enhancer and used in PLC */
196
/* PLC state information */
197
int prevLag, consPLICount, prevPLI, prev_enh_pl;
198
float prevLpc[LPC_FILTERORDER+1];
199
float prevResidual[NSUB_MAX*SUBL];
203
/* previous synthesis filter parameters */
204
float old_syntdenum[(LPC_FILTERORDER + 1)*NSUB_MAX];
206
/* state of output HP filter */
209
/* enhancer state information */
211
float enh_buf[ENH_BUFL];
212
float enh_period[ENH_NBLOCKS_TOT];