blob: 79cb144d8e535f3ffeb1fb152729bf07149f44bc [file] [log] [blame]
niklase@google.com470e71d2011-07-07 08:21:25 +00001/*
tina.legrand@webrtc.orgdf697752012-02-08 10:22:21 +00002 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
niklase@google.com470e71d2011-07-07 08:21:25 +00003 *
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
11/*****************************************************************************************
12 *
13 * Compilation flags in NetEQ:
14 *
15 *****************************************************************************************
16 *
17 ***** Platform flags ******
18 *
19 * SCRATCH Run NetEQ with "Scratch memory" to save some stack memory.
20 * Definition can be used on all platforms
21 *
22 ***** Summary flags ******
23 *
24 * NETEQ_ALL_SPECIAL_CODECS Add support for special codecs (CN/RED/DTMF)
25 *
26 * NETEQ_ALL_NB_CODECS Add support for all NB codecs (except CN/RED/DTMF)
27 *
28 * NETEQ_ALL_WB_CODECS Add support for all WB codecs (except CN/RED/DTMF)
29 *
30 * NETEQ_VOICEENGINE_CODECS Support for all NB, WB and SWB32 codecs and CN, RED and DTMF
31 *
32 * NETEQ_ALL_CODECS Support for all NB, WB, SWB 32kHz and SWB 48kHz as well as
33 * CN, RED and DTMF
34 *
35 ***** Sampling frequency ******
36 * (Note: usually not needed when Summary flags are used)
37 *
38 * NETEQ_WIDEBAND Wideband enabled
39 *
40 * NETEQ_32KHZ_WIDEBAND Super wideband @ 32kHz enabled
41 *
42 * NETEQ_48KHZ_WIDEBAND Super wideband @ 48kHz enabled
43 *
44 ***** Special Codec ******
45 * (Note: not needed if NETEQ_ALL_CODECS is used)
46 *
47 * NETEQ_RED_CODEC With this flag you enable NetEQ to understand redundancy in
48 * the RTP. NetEQ will use the redundancy if it's the same
49 * codec
50 *
51 * NETEQ_CNG_CODEC Enable DTX with the CN payload
52 *
53 * NETEQ_ATEVENT_DECODE Enable AVT event and play out the corresponding DTMF tone
54 *
55 ***** Speech Codecs *****
56 * (Note: Not needed if Summary flags are used)
57 *
58 * NETEQ_G711_CODEC Enable G.711 u- and A-law
59 *
60 * NETEQ_PCM16B_CODEC Enable uncompressed 16-bit
61 *
62 * NETEQ_ILBC_CODEC Enable iLBC
63 *
64 * NETEQ_ISAC_CODEC Enable iSAC
65 *
66 * NETEQ_ISAC_SWB_CODEC Enable iSAC-SWB
67 *
68 * NETEQ_G722_CODEC Enable G.722
69 *
70 * NETEQ_G729_CODEC Enable G.729
71 *
72 * NETEQ_G729_1_CODEC Enable G.729.1
73 *
74 * NETEQ_G726_CODEC Enable G.726
75 *
76 * NETEQ_G722_1_CODEC Enable G722.1
77 *
78 * NETEQ_G722_1C_CODEC Enable G722.1 Annex C
79 *
tina.legrand@webrtc.orga7d83872012-10-18 10:00:52 +000080 * NETEQ_OPUS_CODEC Enable Opus
81 *
niklase@google.com470e71d2011-07-07 08:21:25 +000082 * NETEQ_SPEEX_CODEC Enable Speex (at 8 and 16 kHz sample rate)
83 *
tina.legrand@webrtc.orgdf697752012-02-08 10:22:21 +000084 * NETEQ_CELT_CODEC Enable Celt (at 32 kHz sample rate)
85 *
niklase@google.com470e71d2011-07-07 08:21:25 +000086 * NETEQ_GSMFR_CODEC Enable GSM-FR
87 *
88 * NETEQ_AMR_CODEC Enable AMR (narrowband)
89 *
90 * NETEQ_AMRWB_CODEC Enable AMR-WB
91 *
92 * NETEQ_CNG_CODEC Enable DTX with the CNG payload
93 *
94 * NETEQ_ATEVENT_DECODE Enable AVT event and play out the corresponding DTMF tone
95 *
96 ***** Test flags ******
97 *
98 * WEBRTC_NETEQ_40BITACC_TEST Run NetEQ with simulated 40-bit accumulator to run
99 * bit-exact to a DSP implementation where the main (splib
100 * and NetEQ) functions have been 40-bit optimized
101 *
102 *****************************************************************************************
103 */
104
105#if !defined NETEQ_DEFINES_H
106#define NETEQ_DEFINES_H
107
108/* Data block structure for MCU to DSP communication:
109 *
110 *
111 * First 3 16-bit words are pre-header that contains instructions and timestamp update
112 * Fourth 16-bit word is length of data block 1
113 * Rest is payload data
114 *
115 * 0 48 64 80
116 * -------------...----------------------------------------------------------------------
117 * | PreHeader ... | Length 1 | Payload data 1 ...... | Lenght 2| Data block 2.... | ...
118 * -------------...----------------------------------------------------------------------
119 *
120 *
121 * Preheader:
122 * 4 MSB can be either of:
123 */
124
125#define DSP_INSTR_NORMAL 0x1000
126/* Payload data will contain the encoded frames */
127
128#define DSP_INSTR_MERGE 0x2000
129/* Payload data block 1 will contain the encoded frame */
130/* Info block will contain the number of missing samples */
131
132#define DSP_INSTR_EXPAND 0x3000
133/* Payload data will be empty */
134
135#define DSP_INSTR_ACCELERATE 0x4000
136/* Payload data will contain the encoded frame */
137
138#define DSP_INSTR_DO_RFC3389CNG 0x5000
139/* Payload data will contain the SID frame if there is one*/
140
141#define DSP_INSTR_DTMF_GENERATE 0x6000
142/* Payload data will be one WebRtc_Word16 with the current DTMF value and one
143 * WebRtc_Word16 with the current volume value
144 */
145#define DSP_INSTR_NORMAL_ONE_DESC 0x7000
146/* No encoded frames */
147
148#define DSP_INSTR_DO_CODEC_INTERNAL_CNG 0x8000
149/* Codec has a built-in VAD/DTX scheme (use the above for "no transmission") */
150
151#define DSP_INSTR_PREEMPTIVE_EXPAND 0x9000
152/* Payload data will contain the encoded frames, if any */
153
154#define DSP_INSTR_DO_ALTERNATIVE_PLC 0xB000
155/* NetEQ switched off and packet missing... */
156
157#define DSP_INSTR_DO_ALTERNATIVE_PLC_INC_TS 0xC000
158/* NetEQ switched off and packet missing... */
159
160#define DSP_INSTR_DO_AUDIO_REPETITION 0xD000
161/* NetEQ switched off and packet missing... */
162
163#define DSP_INSTR_DO_AUDIO_REPETITION_INC_TS 0xE000
164/* NetEQ switched off and packet missing... */
165
166#define DSP_INSTR_FADE_TO_BGN 0xF000
167/* Exception handling: fade out to BGN (expand) */
168
169/*
170 * Next 4 bits signal additional data that needs to be transmitted
171 */
172
173#define DSP_CODEC_NO_CHANGE 0x0100
174#define DSP_CODEC_NEW_CODEC 0x0200
175#define DSP_CODEC_ADD_LATE_PKT 0x0300
176#define DSP_CODEC_RESET 0x0400
177#define DSP_DTMF_PAYLOAD 0x0010
178
179/*
180 * The most significant bit of the payload-length
181 * is used to flag whether the associated payload
182 * is redundant payload. This currently useful only for
183 * iSAC, where redundant payloads have to be treated
184 * differently. Every time the length is read it must be
185 * masked by DSP_CODEC_MASK_RED_FLAG to ignore the flag.
186 * Use DSP_CODEC_RED_FLAG to set or retrieve the flag.
187 */
188#define DSP_CODEC_MASK_RED_FLAG 0x7FFF
189#define DSP_CODEC_RED_FLAG 0x8000
190
191/*
192 * The first block of payload data consist of decode function pointers,
193 * and then the speech blocks.
194 *
195 */
196
197
198/*
199 * The playout modes that NetEq produced (i.e. gives more info about if the
200 * Accelerate was successful or not)
201 */
202
203#define MODE_NORMAL 0x0000
204#define MODE_EXPAND 0x0001
205#define MODE_MERGE 0x0002
206#define MODE_SUCCESS_ACCELERATE 0x0003
207#define MODE_UNSUCCESS_ACCELERATE 0x0004
208#define MODE_RFC3389CNG 0x0005
209#define MODE_LOWEN_ACCELERATE 0x0006
210#define MODE_DTMF 0x0007
211#define MODE_ONE_DESCRIPTOR 0x0008
212#define MODE_CODEC_INTERNAL_CNG 0x0009
213#define MODE_SUCCESS_PREEMPTIVE 0x000A
214#define MODE_UNSUCCESS_PREEMPTIVE 0x000B
215#define MODE_LOWEN_PREEMPTIVE 0x000C
216#define MODE_FADE_TO_BGN 0x000D
217
218#define MODE_ERROR 0x0010
219
220#define MODE_AWAITING_CODEC_PTR 0x0100
221
222#define MODE_BGN_ONLY 0x0200
223
224#define MODE_MASTER_DTMF_SIGNAL 0x0400
225
226#define MODE_USING_STEREO 0x0800
227
228
229
230/***********************/
231/* Group codec defines */
232/***********************/
233
234#if (defined(NETEQ_ALL_SPECIAL_CODECS))
235 #define NETEQ_CNG_CODEC
236 #define NETEQ_ATEVENT_DECODE
237 #define NETEQ_RED_CODEC
238 #define NETEQ_VAD
239 #define NETEQ_ARBITRARY_CODEC
240#endif
241
242#if (defined(NETEQ_ALL_NB_CODECS)) /* Except RED, DTMF and CNG */
243 #define NETEQ_PCM16B_CODEC
244 #define NETEQ_G711_CODEC
245 #define NETEQ_ILBC_CODEC
246 #define NETEQ_G729_CODEC
247 #define NETEQ_G726_CODEC
248 #define NETEQ_GSMFR_CODEC
tina.legrand@webrtc.orga7d83872012-10-18 10:00:52 +0000249 #define NETEQ_OPUS_CODEC
niklase@google.com470e71d2011-07-07 08:21:25 +0000250 #define NETEQ_AMR_CODEC
251#endif
252
253#if (defined(NETEQ_ALL_WB_CODECS)) /* Except RED, DTMF and CNG */
254 #define NETEQ_ISAC_CODEC
255 #define NETEQ_G722_CODEC
256 #define NETEQ_G722_1_CODEC
257 #define NETEQ_G729_1_CODEC
tina.legrand@webrtc.orga7d83872012-10-18 10:00:52 +0000258 #define NETEQ_OPUS_CODEC
niklase@google.com470e71d2011-07-07 08:21:25 +0000259 #define NETEQ_SPEEX_CODEC
260 #define NETEQ_AMRWB_CODEC
261 #define NETEQ_WIDEBAND
262#endif
263
264#if (defined(NETEQ_ALL_WB32_CODECS)) /* AAC, RED, DTMF and CNG */
265 #define NETEQ_ISAC_SWB_CODEC
266 #define NETEQ_32KHZ_WIDEBAND
267 #define NETEQ_G722_1C_CODEC
tina.legrand@webrtc.orgdf697752012-02-08 10:22:21 +0000268 #define NETEQ_CELT_CODEC
tina.legrand@webrtc.orga7d83872012-10-18 10:00:52 +0000269 #define NETEQ_OPUS_CODEC
niklase@google.com470e71d2011-07-07 08:21:25 +0000270#endif
271
272#if (defined(NETEQ_VOICEENGINE_CODECS))
273 /* Special codecs */
274 #define NETEQ_CNG_CODEC
275 #define NETEQ_ATEVENT_DECODE
276 #define NETEQ_RED_CODEC
277 #define NETEQ_VAD
278 #define NETEQ_ARBITRARY_CODEC
279
280 /* Narrowband codecs */
281 #define NETEQ_PCM16B_CODEC
282 #define NETEQ_G711_CODEC
283 #define NETEQ_ILBC_CODEC
tina.legrand@webrtc.org84519ec2011-09-01 07:47:31 +0000284 #define NETEQ_AMR_CODEC
285 #define NETEQ_G729_CODEC
286 #define NETEQ_GSMFR_CODEC
niklase@google.com470e71d2011-07-07 08:21:25 +0000287
288 /* Wideband codecs */
289 #define NETEQ_WIDEBAND
290 #define NETEQ_ISAC_CODEC
291 #define NETEQ_G722_CODEC
tina.legrand@webrtc.org84519ec2011-09-01 07:47:31 +0000292 #define NETEQ_G722_1_CODEC
293 #define NETEQ_G729_1_CODEC
294 #define NETEQ_AMRWB_CODEC
295 #define NETEQ_SPEEX_CODEC
niklase@google.com470e71d2011-07-07 08:21:25 +0000296
297 /* Super wideband 32kHz codecs */
298 #define NETEQ_ISAC_SWB_CODEC
299 #define NETEQ_32KHZ_WIDEBAND
tina.legrand@webrtc.org84519ec2011-09-01 07:47:31 +0000300 #define NETEQ_G722_1C_CODEC
tina.legrand@webrtc.orgdf697752012-02-08 10:22:21 +0000301 #define NETEQ_CELT_CODEC
niklase@google.com470e71d2011-07-07 08:21:25 +0000302
tina.legrand@webrtc.orga7d83872012-10-18 10:00:52 +0000303 /* Fullband 48 kHz codecs */
304 #define NETEQ_OPUS_CODEC
niklase@google.com470e71d2011-07-07 08:21:25 +0000305#endif
306
307#if (defined(NETEQ_ALL_CODECS))
308 /* Special codecs */
309 #define NETEQ_CNG_CODEC
310 #define NETEQ_ATEVENT_DECODE
311 #define NETEQ_RED_CODEC
312 #define NETEQ_VAD
313 #define NETEQ_ARBITRARY_CODEC
314
315 /* Narrowband codecs */
316 #define NETEQ_PCM16B_CODEC
317 #define NETEQ_G711_CODEC
318 #define NETEQ_ILBC_CODEC
319 #define NETEQ_G729_CODEC
320 #define NETEQ_G726_CODEC
321 #define NETEQ_GSMFR_CODEC
322 #define NETEQ_AMR_CODEC
323
324 /* Wideband codecs */
325 #define NETEQ_WIDEBAND
326 #define NETEQ_ISAC_CODEC
327 #define NETEQ_G722_CODEC
328 #define NETEQ_G722_1_CODEC
329 #define NETEQ_G729_1_CODEC
330 #define NETEQ_SPEEX_CODEC
331 #define NETEQ_AMRWB_CODEC
332
333 /* Super wideband 32kHz codecs */
334 #define NETEQ_ISAC_SWB_CODEC
335 #define NETEQ_32KHZ_WIDEBAND
336 #define NETEQ_G722_1C_CODEC
tina.legrand@webrtc.orgdf697752012-02-08 10:22:21 +0000337 #define NETEQ_CELT_CODEC
niklase@google.com470e71d2011-07-07 08:21:25 +0000338
339 /* Super wideband 48kHz codecs */
340 #define NETEQ_48KHZ_WIDEBAND
tina.legrand@webrtc.orga7d83872012-10-18 10:00:52 +0000341 #define NETEQ_OPUS_CODEC
niklase@google.com470e71d2011-07-07 08:21:25 +0000342#endif
343
344/* Max output size from decoding one frame */
345#if defined(NETEQ_48KHZ_WIDEBAND)
tina.legrand@webrtc.orga7d83872012-10-18 10:00:52 +0000346 #define NETEQ_MAX_FRAME_SIZE 5760 /* 120 ms super wideband */
347 #define NETEQ_MAX_OUTPUT_SIZE 6480 /* 120+15 ms super wideband (120 ms
348 * decoded + 15 ms for merge overlap) */
niklase@google.com470e71d2011-07-07 08:21:25 +0000349#elif defined(NETEQ_32KHZ_WIDEBAND)
tina.legrand@webrtc.orga7d83872012-10-18 10:00:52 +0000350 #define NETEQ_MAX_FRAME_SIZE 3840 /* 120 ms super wideband */
351 #define NETEQ_MAX_OUTPUT_SIZE 4320 /* 120+15 ms super wideband (120 ms
352 * decoded + 15 ms for merge overlap) */
niklase@google.com470e71d2011-07-07 08:21:25 +0000353#elif defined(NETEQ_WIDEBAND)
tina.legrand@webrtc.orga7d83872012-10-18 10:00:52 +0000354 #define NETEQ_MAX_FRAME_SIZE 1920 /* 120 ms wideband */
355 #define NETEQ_MAX_OUTPUT_SIZE 2160 /* 120+15 ms wideband (120 ms decoded +
356 * 15 ms for merge overlap) */
niklase@google.com470e71d2011-07-07 08:21:25 +0000357#else
tina.legrand@webrtc.orga7d83872012-10-18 10:00:52 +0000358 #define NETEQ_MAX_FRAME_SIZE 960 /* 120 ms narrowband */
359 #define NETEQ_MAX_OUTPUT_SIZE 1080 /* 120+15 ms narrowband (120 ms decoded
360 * + 15 ms for merge overlap) */
niklase@google.com470e71d2011-07-07 08:21:25 +0000361#endif
362
363
364/* Enable stereo */
365#define NETEQ_STEREO
366
367#endif /* #if !defined NETEQ_DEFINES_H */
368