libvoipcodecs 0.0.1
ilbc/ilbc.h
1/*
2 * iLBC - a library for the iLBC codec
3 *
4 * ilbc.h - The iLBC low bit rate speech codec.
5 *
6 * Adapted by Steve Underwood <steveu@coppice.org> from the reference
7 * iLBC code supplied in RFC3951.
8 *
9 * Copyright (C) The Internet Society (2004).
10 * All Rights Reserved.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 *
21 * $Id: ilbc.h,v 1.1.1.1 2008/02/15 12:15:55 steveu Exp $
22 */
23
24#if !defined(_ILBC_ILBC_H_)
25#define _ILBC_ILBC_H_
26
27#define ILBC_BLOCK_LEN_20MS 160
28#define ILBC_BLOCK_LEN_30MS 240
29#define ILBC_BLOCK_LEN_MAX 240
30
31#define ILBC_NO_OF_BYTES_20MS 38
32#define ILBC_NO_OF_BYTES_30MS 50
33#define ILBC_NO_OF_BYTES_MAX 50
34
35#define ILBC_NUM_SUB_MAX 6
36
37#define SUBL 40
38
39#define ENH_BLOCKL 80 /* block length */
40#define ENH_NBLOCKS_TOT 8 /* ENH_NBLOCKS + ENH_NBLOCKS_EXTRA */
41#define ENH_BUFL (ENH_NBLOCKS_TOT*ENH_BLOCKL)
42
43#define ILBC_LPC_FILTERORDER 10
44#define LPC_LOOKBACK 60
45
46#define CB_NSTAGES 3
47
48#define STATE_BITS 3
49#define BYTE_LEN 8
50#define ILBC_ULP_CLASSES 3
51
52typedef struct
53{
54 int lsf_bits[6][ILBC_ULP_CLASSES + 2];
55 int start_bits[ILBC_ULP_CLASSES + 2];
56 int startfirst_bits[ILBC_ULP_CLASSES + 2];
57 int scale_bits[ILBC_ULP_CLASSES + 2];
58 int state_bits[ILBC_ULP_CLASSES + 2];
59 int extra_cb_index[CB_NSTAGES][ILBC_ULP_CLASSES + 2];
60 int extra_cb_gain[CB_NSTAGES][ILBC_ULP_CLASSES + 2];
61 int cb_index[ILBC_NUM_SUB_MAX][CB_NSTAGES][ILBC_ULP_CLASSES + 2];
62 int cb_gain[ILBC_NUM_SUB_MAX][CB_NSTAGES][ILBC_ULP_CLASSES + 2];
64
65/* Type definition encoder instance */
66typedef struct
67{
68 /* flag for frame size mode */
69 int mode;
70
71 /* basic parameters for different frame sizes */
72 int blockl;
73 int nsub;
74 int nasub;
75 int no_of_bytes;
76 int lpc_n;
77 int state_short_len;
78 const ilbc_ulp_inst_t *ULP_inst;
79
80 /* analysis filter state */
81 float anaMem[ILBC_LPC_FILTERORDER];
82
83 /* old lsf parameters for interpolation */
84 float lsfold[ILBC_LPC_FILTERORDER];
85 float lsfdeqold[ILBC_LPC_FILTERORDER];
86
87 /* signal buffer for LP analysis */
88 float lpc_buffer[LPC_LOOKBACK + ILBC_BLOCK_LEN_MAX];
89
90 /* state of input HP filter */
91 float hpimem[4];
93
94/* Type definition decoder instance */
95typedef struct
96{
97 /* Flag for frame size mode */
98 int mode;
99
100 /* Basic parameters for different frame sizes */
101 int blockl;
102 int nsub;
103 int nasub;
104 int no_of_bytes;
105 int lpc_n;
106 int state_short_len;
107 const ilbc_ulp_inst_t *ULP_inst;
108
109 /* Synthesis filter state */
110 float syntMem[ILBC_LPC_FILTERORDER];
111
112 /* Old LSF for interpolation */
113 float lsfdeqold[ILBC_LPC_FILTERORDER];
114
115 /* Pitch lag estimated in enhancer and used in PLC */
116 int last_lag;
117
118 /* PLC state information */
119 int prevLag, consPLICount, prevPLI, prev_enh_pl;
120 float prevLpc[ILBC_LPC_FILTERORDER + 1];
121 float prevResidual[ILBC_NUM_SUB_MAX*SUBL];
122 float per;
123 unsigned long seed;
124
125 /* Previous synthesis filter parameters */
126 float old_syntdenum[(ILBC_LPC_FILTERORDER + 1)*ILBC_NUM_SUB_MAX];
127
128 /* State of output HP filter */
129 float hpomem[4];
130
131 /* Enhancer state information */
132 int use_enhancer;
133 float enh_buf[ENH_BUFL];
134 float enh_period[ENH_NBLOCKS_TOT];
136
137ilbc_encode_state_t *ilbc_encode_init(ilbc_encode_state_t *s, /* (i/o) Encoder instance */
138 int mode); /* (i) frame size mode */
139
140int ilbc_encode(ilbc_encode_state_t *s, /* (i/o) the general encoder state */
141 uint8_t bytes[], /* (o) encoded data bits iLBC */
142 const int16_t amp[], /* (o) speech vector to encode */
143 int len);
144
145ilbc_decode_state_t *ilbc_decode_init(ilbc_decode_state_t *s, /* (i/o) Decoder instance */
146 int mode, /* (i) frame size mode */
147 int use_enhancer); /* (i) 1 to use enhancer
148 0 to run without enhancer */
149
150int ilbc_decode(ilbc_decode_state_t *s, /* (i/o) the decoder state structure */
151 int16_t amp[], /* (o) decoded signal block */
152 const uint8_t bytes[], /* (i) encoded signal bits */
153 int len);
154
155int ilbc_fillin(ilbc_decode_state_t *s, /* (i/o) the decoder state structure */
156 int16_t amp[], /* (o) decoded signal block */
157 int len);
158
159#endif
Definition ilbc/ilbc.h:96
Definition ilbc/ilbc.h:67
Definition ilbc/ilbc.h:53