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