blob: 9390f2bf3f001fcf2f2585ae85bb2c5e343c9bef [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 *
turaj@webrtc.orgb0dff122012-12-03 17:43:52 +000068 * Note that the decoder of iSAC full-band operates at 32 kHz, that is the
69 * decoded signal is at 32 kHz.
70 * NETEQ_ISAC_FB_CODEC Enable iSAC-FB
71 *
niklase@google.com470e71d2011-07-07 08:21:25 +000072 * NETEQ_G722_CODEC Enable G.722
73 *
74 * NETEQ_G729_CODEC Enable G.729
75 *
76 * NETEQ_G729_1_CODEC Enable G.729.1
77 *
78 * NETEQ_G726_CODEC Enable G.726
79 *
80 * NETEQ_G722_1_CODEC Enable G722.1
81 *
82 * NETEQ_G722_1C_CODEC Enable G722.1 Annex C
83 *
tina.legrand@webrtc.orga7d83872012-10-18 10:00:52 +000084 * NETEQ_OPUS_CODEC Enable Opus
85 *
niklase@google.com470e71d2011-07-07 08:21:25 +000086 * NETEQ_SPEEX_CODEC Enable Speex (at 8 and 16 kHz sample rate)
87 *
tina.legrand@webrtc.orgdf697752012-02-08 10:22:21 +000088 * NETEQ_CELT_CODEC Enable Celt (at 32 kHz sample rate)
89 *
niklase@google.com470e71d2011-07-07 08:21:25 +000090 * NETEQ_GSMFR_CODEC Enable GSM-FR
91 *
92 * NETEQ_AMR_CODEC Enable AMR (narrowband)
93 *
94 * NETEQ_AMRWB_CODEC Enable AMR-WB
95 *
96 * NETEQ_CNG_CODEC Enable DTX with the CNG payload
97 *
98 * NETEQ_ATEVENT_DECODE Enable AVT event and play out the corresponding DTMF tone
99 *
100 ***** Test flags ******
101 *
102 * WEBRTC_NETEQ_40BITACC_TEST Run NetEQ with simulated 40-bit accumulator to run
103 * bit-exact to a DSP implementation where the main (splib
104 * and NetEQ) functions have been 40-bit optimized
105 *
106 *****************************************************************************************
107 */
108
109#if !defined NETEQ_DEFINES_H
110#define NETEQ_DEFINES_H
111
112/* Data block structure for MCU to DSP communication:
113 *
114 *
115 * First 3 16-bit words are pre-header that contains instructions and timestamp update
116 * Fourth 16-bit word is length of data block 1
117 * Rest is payload data
118 *
119 * 0 48 64 80
120 * -------------...----------------------------------------------------------------------
121 * | PreHeader ... | Length 1 | Payload data 1 ...... | Lenght 2| Data block 2.... | ...
122 * -------------...----------------------------------------------------------------------
123 *
124 *
125 * Preheader:
126 * 4 MSB can be either of:
127 */
128
129#define DSP_INSTR_NORMAL 0x1000
130/* Payload data will contain the encoded frames */
131
132#define DSP_INSTR_MERGE 0x2000
133/* Payload data block 1 will contain the encoded frame */
134/* Info block will contain the number of missing samples */
135
136#define DSP_INSTR_EXPAND 0x3000
137/* Payload data will be empty */
138
139#define DSP_INSTR_ACCELERATE 0x4000
140/* Payload data will contain the encoded frame */
141
142#define DSP_INSTR_DO_RFC3389CNG 0x5000
143/* Payload data will contain the SID frame if there is one*/
144
145#define DSP_INSTR_DTMF_GENERATE 0x6000
pbos@webrtc.org0946a562013-04-09 00:28:06 +0000146/* Payload data will be one int16_t with the current DTMF value and one
147 * int16_t with the current volume value
niklase@google.com470e71d2011-07-07 08:21:25 +0000148 */
149#define DSP_INSTR_NORMAL_ONE_DESC 0x7000
150/* No encoded frames */
151
152#define DSP_INSTR_DO_CODEC_INTERNAL_CNG 0x8000
153/* Codec has a built-in VAD/DTX scheme (use the above for "no transmission") */
154
155#define DSP_INSTR_PREEMPTIVE_EXPAND 0x9000
156/* Payload data will contain the encoded frames, if any */
157
158#define DSP_INSTR_DO_ALTERNATIVE_PLC 0xB000
159/* NetEQ switched off and packet missing... */
160
161#define DSP_INSTR_DO_ALTERNATIVE_PLC_INC_TS 0xC000
162/* NetEQ switched off and packet missing... */
163
164#define DSP_INSTR_DO_AUDIO_REPETITION 0xD000
165/* NetEQ switched off and packet missing... */
166
167#define DSP_INSTR_DO_AUDIO_REPETITION_INC_TS 0xE000
168/* NetEQ switched off and packet missing... */
169
170#define DSP_INSTR_FADE_TO_BGN 0xF000
171/* Exception handling: fade out to BGN (expand) */
172
173/*
174 * Next 4 bits signal additional data that needs to be transmitted
175 */
176
177#define DSP_CODEC_NO_CHANGE 0x0100
178#define DSP_CODEC_NEW_CODEC 0x0200
179#define DSP_CODEC_ADD_LATE_PKT 0x0300
180#define DSP_CODEC_RESET 0x0400
181#define DSP_DTMF_PAYLOAD 0x0010
182
183/*
184 * The most significant bit of the payload-length
185 * is used to flag whether the associated payload
186 * is redundant payload. This currently useful only for
187 * iSAC, where redundant payloads have to be treated
188 * differently. Every time the length is read it must be
189 * masked by DSP_CODEC_MASK_RED_FLAG to ignore the flag.
190 * Use DSP_CODEC_RED_FLAG to set or retrieve the flag.
191 */
192#define DSP_CODEC_MASK_RED_FLAG 0x7FFF
193#define DSP_CODEC_RED_FLAG 0x8000
194
195/*
196 * The first block of payload data consist of decode function pointers,
197 * and then the speech blocks.
198 *
199 */
200
201
202/*
203 * The playout modes that NetEq produced (i.e. gives more info about if the
204 * Accelerate was successful or not)
205 */
206
207#define MODE_NORMAL 0x0000
208#define MODE_EXPAND 0x0001
209#define MODE_MERGE 0x0002
210#define MODE_SUCCESS_ACCELERATE 0x0003
211#define MODE_UNSUCCESS_ACCELERATE 0x0004
212#define MODE_RFC3389CNG 0x0005
213#define MODE_LOWEN_ACCELERATE 0x0006
214#define MODE_DTMF 0x0007
215#define MODE_ONE_DESCRIPTOR 0x0008
216#define MODE_CODEC_INTERNAL_CNG 0x0009
217#define MODE_SUCCESS_PREEMPTIVE 0x000A
218#define MODE_UNSUCCESS_PREEMPTIVE 0x000B
219#define MODE_LOWEN_PREEMPTIVE 0x000C
220#define MODE_FADE_TO_BGN 0x000D
221
222#define MODE_ERROR 0x0010
223
224#define MODE_AWAITING_CODEC_PTR 0x0100
225
226#define MODE_BGN_ONLY 0x0200
227
228#define MODE_MASTER_DTMF_SIGNAL 0x0400
229
230#define MODE_USING_STEREO 0x0800
231
232
233
234/***********************/
235/* Group codec defines */
236/***********************/
237
238#if (defined(NETEQ_ALL_SPECIAL_CODECS))
239 #define NETEQ_CNG_CODEC
240 #define NETEQ_ATEVENT_DECODE
241 #define NETEQ_RED_CODEC
242 #define NETEQ_VAD
243 #define NETEQ_ARBITRARY_CODEC
244#endif
245
246#if (defined(NETEQ_ALL_NB_CODECS)) /* Except RED, DTMF and CNG */
247 #define NETEQ_PCM16B_CODEC
248 #define NETEQ_G711_CODEC
249 #define NETEQ_ILBC_CODEC
250 #define NETEQ_G729_CODEC
251 #define NETEQ_G726_CODEC
252 #define NETEQ_GSMFR_CODEC
tina.legrand@webrtc.orga7d83872012-10-18 10:00:52 +0000253 #define NETEQ_OPUS_CODEC
niklase@google.com470e71d2011-07-07 08:21:25 +0000254 #define NETEQ_AMR_CODEC
255#endif
256
257#if (defined(NETEQ_ALL_WB_CODECS)) /* Except RED, DTMF and CNG */
258 #define NETEQ_ISAC_CODEC
259 #define NETEQ_G722_CODEC
260 #define NETEQ_G722_1_CODEC
261 #define NETEQ_G729_1_CODEC
tina.legrand@webrtc.orga7d83872012-10-18 10:00:52 +0000262 #define NETEQ_OPUS_CODEC
niklase@google.com470e71d2011-07-07 08:21:25 +0000263 #define NETEQ_SPEEX_CODEC
264 #define NETEQ_AMRWB_CODEC
265 #define NETEQ_WIDEBAND
266#endif
267
268#if (defined(NETEQ_ALL_WB32_CODECS)) /* AAC, RED, DTMF and CNG */
269 #define NETEQ_ISAC_SWB_CODEC
270 #define NETEQ_32KHZ_WIDEBAND
271 #define NETEQ_G722_1C_CODEC
tina.legrand@webrtc.orgdf697752012-02-08 10:22:21 +0000272 #define NETEQ_CELT_CODEC
tina.legrand@webrtc.orga7d83872012-10-18 10:00:52 +0000273 #define NETEQ_OPUS_CODEC
niklase@google.com470e71d2011-07-07 08:21:25 +0000274#endif
275
276#if (defined(NETEQ_VOICEENGINE_CODECS))
277 /* Special codecs */
278 #define NETEQ_CNG_CODEC
279 #define NETEQ_ATEVENT_DECODE
280 #define NETEQ_RED_CODEC
281 #define NETEQ_VAD
282 #define NETEQ_ARBITRARY_CODEC
283
284 /* Narrowband codecs */
285 #define NETEQ_PCM16B_CODEC
286 #define NETEQ_G711_CODEC
287 #define NETEQ_ILBC_CODEC
tina.legrand@webrtc.org84519ec2011-09-01 07:47:31 +0000288 #define NETEQ_AMR_CODEC
289 #define NETEQ_G729_CODEC
290 #define NETEQ_GSMFR_CODEC
niklase@google.com470e71d2011-07-07 08:21:25 +0000291
292 /* Wideband codecs */
293 #define NETEQ_WIDEBAND
294 #define NETEQ_ISAC_CODEC
295 #define NETEQ_G722_CODEC
tina.legrand@webrtc.org84519ec2011-09-01 07:47:31 +0000296 #define NETEQ_G722_1_CODEC
297 #define NETEQ_G729_1_CODEC
298 #define NETEQ_AMRWB_CODEC
299 #define NETEQ_SPEEX_CODEC
niklase@google.com470e71d2011-07-07 08:21:25 +0000300
301 /* Super wideband 32kHz codecs */
302 #define NETEQ_ISAC_SWB_CODEC
303 #define NETEQ_32KHZ_WIDEBAND
tina.legrand@webrtc.org84519ec2011-09-01 07:47:31 +0000304 #define NETEQ_G722_1C_CODEC
tina.legrand@webrtc.orgdf697752012-02-08 10:22:21 +0000305 #define NETEQ_CELT_CODEC
niklase@google.com470e71d2011-07-07 08:21:25 +0000306
tina.legrand@webrtc.orga7d83872012-10-18 10:00:52 +0000307 /* Fullband 48 kHz codecs */
308 #define NETEQ_OPUS_CODEC
turaj@webrtc.orgb0dff122012-12-03 17:43:52 +0000309 #define NETEQ_ISAC_FB_CODEC
niklase@google.com470e71d2011-07-07 08:21:25 +0000310#endif
311
312#if (defined(NETEQ_ALL_CODECS))
313 /* Special codecs */
314 #define NETEQ_CNG_CODEC
315 #define NETEQ_ATEVENT_DECODE
316 #define NETEQ_RED_CODEC
317 #define NETEQ_VAD
318 #define NETEQ_ARBITRARY_CODEC
319
320 /* Narrowband codecs */
321 #define NETEQ_PCM16B_CODEC
322 #define NETEQ_G711_CODEC
323 #define NETEQ_ILBC_CODEC
324 #define NETEQ_G729_CODEC
325 #define NETEQ_G726_CODEC
326 #define NETEQ_GSMFR_CODEC
327 #define NETEQ_AMR_CODEC
328
329 /* Wideband codecs */
330 #define NETEQ_WIDEBAND
331 #define NETEQ_ISAC_CODEC
332 #define NETEQ_G722_CODEC
333 #define NETEQ_G722_1_CODEC
334 #define NETEQ_G729_1_CODEC
335 #define NETEQ_SPEEX_CODEC
336 #define NETEQ_AMRWB_CODEC
337
338 /* Super wideband 32kHz codecs */
339 #define NETEQ_ISAC_SWB_CODEC
340 #define NETEQ_32KHZ_WIDEBAND
341 #define NETEQ_G722_1C_CODEC
tina.legrand@webrtc.orgdf697752012-02-08 10:22:21 +0000342 #define NETEQ_CELT_CODEC
niklase@google.com470e71d2011-07-07 08:21:25 +0000343
344 /* Super wideband 48kHz codecs */
345 #define NETEQ_48KHZ_WIDEBAND
tina.legrand@webrtc.orga7d83872012-10-18 10:00:52 +0000346 #define NETEQ_OPUS_CODEC
turaj@webrtc.orgb0dff122012-12-03 17:43:52 +0000347 #define NETEQ_ISAC_FB
niklase@google.com470e71d2011-07-07 08:21:25 +0000348#endif
349
350/* Max output size from decoding one frame */
351#if defined(NETEQ_48KHZ_WIDEBAND)
tina.legrand@webrtc.orga7d83872012-10-18 10:00:52 +0000352 #define NETEQ_MAX_FRAME_SIZE 5760 /* 120 ms super wideband */
353 #define NETEQ_MAX_OUTPUT_SIZE 6480 /* 120+15 ms super wideband (120 ms
354 * decoded + 15 ms for merge overlap) */
niklase@google.com470e71d2011-07-07 08:21:25 +0000355#elif defined(NETEQ_32KHZ_WIDEBAND)
tina.legrand@webrtc.orga7d83872012-10-18 10:00:52 +0000356 #define NETEQ_MAX_FRAME_SIZE 3840 /* 120 ms super wideband */
357 #define NETEQ_MAX_OUTPUT_SIZE 4320 /* 120+15 ms super wideband (120 ms
358 * decoded + 15 ms for merge overlap) */
niklase@google.com470e71d2011-07-07 08:21:25 +0000359#elif defined(NETEQ_WIDEBAND)
tina.legrand@webrtc.orga7d83872012-10-18 10:00:52 +0000360 #define NETEQ_MAX_FRAME_SIZE 1920 /* 120 ms wideband */
361 #define NETEQ_MAX_OUTPUT_SIZE 2160 /* 120+15 ms wideband (120 ms decoded +
362 * 15 ms for merge overlap) */
niklase@google.com470e71d2011-07-07 08:21:25 +0000363#else
tina.legrand@webrtc.orga7d83872012-10-18 10:00:52 +0000364 #define NETEQ_MAX_FRAME_SIZE 960 /* 120 ms narrowband */
365 #define NETEQ_MAX_OUTPUT_SIZE 1080 /* 120+15 ms narrowband (120 ms decoded
366 * + 15 ms for merge overlap) */
niklase@google.com470e71d2011-07-07 08:21:25 +0000367#endif
368
369
370/* Enable stereo */
371#define NETEQ_STEREO
372
373#endif /* #if !defined NETEQ_DEFINES_H */
374