Bug 797671: Import Webrtc.org code from stable branch 3.12 (rev 2820) rs=jesup
[gecko.git] / media / webrtc / trunk / src / modules / audio_coding / neteq / neteq_defines.h
blob404a30b0e70049af9f48926cf8d549daac35cdad
1 /*
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
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 */
11 /*****************************************************************************************
13 * Compilation flags in NetEQ:
15 *****************************************************************************************
17 ***** Platform flags ******
19 * SCRATCH Run NetEQ with "Scratch memory" to save some stack memory.
20 * Definition can be used on all platforms
22 ***** Summary flags ******
24 * NETEQ_ALL_SPECIAL_CODECS Add support for special codecs (CN/RED/DTMF)
26 * NETEQ_ALL_NB_CODECS Add support for all NB codecs (except CN/RED/DTMF)
28 * NETEQ_ALL_WB_CODECS Add support for all WB codecs (except CN/RED/DTMF)
30 * NETEQ_VOICEENGINE_CODECS Support for all NB, WB and SWB32 codecs and CN, RED and DTMF
32 * NETEQ_ALL_CODECS Support for all NB, WB, SWB 32kHz and SWB 48kHz as well as
33 * CN, RED and DTMF
35 ***** Sampling frequency ******
36 * (Note: usually not needed when Summary flags are used)
38 * NETEQ_WIDEBAND Wideband enabled
40 * NETEQ_32KHZ_WIDEBAND Super wideband @ 32kHz enabled
42 * NETEQ_48KHZ_WIDEBAND Super wideband @ 48kHz enabled
44 ***** Special Codec ******
45 * (Note: not needed if NETEQ_ALL_CODECS is used)
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
51 * NETEQ_CNG_CODEC Enable DTX with the CN payload
53 * NETEQ_ATEVENT_DECODE Enable AVT event and play out the corresponding DTMF tone
55 ***** Speech Codecs *****
56 * (Note: Not needed if Summary flags are used)
58 * NETEQ_G711_CODEC Enable G.711 u- and A-law
60 * NETEQ_PCM16B_CODEC Enable uncompressed 16-bit
62 * NETEQ_ILBC_CODEC Enable iLBC
64 * NETEQ_ISAC_CODEC Enable iSAC
66 * NETEQ_ISAC_SWB_CODEC Enable iSAC-SWB
68 * NETEQ_OPUS_CODEC Enable Opus
70 * NETEQ_G722_CODEC Enable G.722
72 * NETEQ_G729_CODEC Enable G.729
74 * NETEQ_G729_1_CODEC Enable G.729.1
76 * NETEQ_G726_CODEC Enable G.726
78 * NETEQ_G722_1_CODEC Enable G722.1
80 * NETEQ_G722_1C_CODEC Enable G722.1 Annex C
82 * NETEQ_SPEEX_CODEC Enable Speex (at 8 and 16 kHz sample rate)
84 * NETEQ_CELT_CODEC Enable Celt (at 32 kHz sample rate)
86 * NETEQ_GSMFR_CODEC Enable GSM-FR
88 * NETEQ_AMR_CODEC Enable AMR (narrowband)
90 * NETEQ_AMRWB_CODEC Enable AMR-WB
92 * NETEQ_CNG_CODEC Enable DTX with the CNG payload
94 * NETEQ_ATEVENT_DECODE Enable AVT event and play out the corresponding DTMF tone
96 ***** Test flags ******
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
102 *****************************************************************************************
105 #if !defined NETEQ_DEFINES_H
106 #define NETEQ_DEFINES_H
108 /* Data block structure for MCU to DSP communication:
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
115 * 0 48 64 80
116 * -------------...----------------------------------------------------------------------
117 * | PreHeader ... | Length 1 | Payload data 1 ...... | Lenght 2| Data block 2.... | ...
118 * -------------...----------------------------------------------------------------------
121 * Preheader:
122 * 4 MSB can be either of:
125 #define DSP_INSTR_NORMAL 0x1000
126 /* Payload data will contain the encoded frames */
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 */
132 #define DSP_INSTR_EXPAND 0x3000
133 /* Payload data will be empty */
135 #define DSP_INSTR_ACCELERATE 0x4000
136 /* Payload data will contain the encoded frame */
138 #define DSP_INSTR_DO_RFC3389CNG 0x5000
139 /* Payload data will contain the SID frame if there is one*/
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
145 #define DSP_INSTR_NORMAL_ONE_DESC 0x7000
146 /* No encoded frames */
148 #define DSP_INSTR_DO_CODEC_INTERNAL_CNG 0x8000
149 /* Codec has a built-in VAD/DTX scheme (use the above for "no transmission") */
151 #define DSP_INSTR_PREEMPTIVE_EXPAND 0x9000
152 /* Payload data will contain the encoded frames, if any */
154 #define DSP_INSTR_DO_ALTERNATIVE_PLC 0xB000
155 /* NetEQ switched off and packet missing... */
157 #define DSP_INSTR_DO_ALTERNATIVE_PLC_INC_TS 0xC000
158 /* NetEQ switched off and packet missing... */
160 #define DSP_INSTR_DO_AUDIO_REPETITION 0xD000
161 /* NetEQ switched off and packet missing... */
163 #define DSP_INSTR_DO_AUDIO_REPETITION_INC_TS 0xE000
164 /* NetEQ switched off and packet missing... */
166 #define DSP_INSTR_FADE_TO_BGN 0xF000
167 /* Exception handling: fade out to BGN (expand) */
170 * Next 4 bits signal additional data that needs to be transmitted
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
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.
188 #define DSP_CODEC_MASK_RED_FLAG 0x7FFF
189 #define DSP_CODEC_RED_FLAG 0x8000
192 * The first block of payload data consist of decode function pointers,
193 * and then the speech blocks.
199 * The playout modes that NetEq produced (i.e. gives more info about if the
200 * Accelerate was successful or not)
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
218 #define MODE_ERROR 0x0010
220 #define MODE_AWAITING_CODEC_PTR 0x0100
222 #define MODE_BGN_ONLY 0x0200
224 #define MODE_MASTER_DTMF_SIGNAL 0x0400
226 #define MODE_USING_STEREO 0x0800
230 /***********************/
231 /* Group codec defines */
232 /***********************/
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
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_OPUS_CODEC
247 #define NETEQ_G729_CODEC
248 #define NETEQ_G726_CODEC
249 #define NETEQ_GSMFR_CODEC
250 #define NETEQ_AMR_CODEC
251 #endif
253 #if (defined(NETEQ_ALL_WB_CODECS)) /* Except RED, DTMF and CNG */
254 #define NETEQ_ISAC_CODEC
255 #define NETEQ_OPUS_CODEC
256 #define NETEQ_G722_CODEC
257 #define NETEQ_G722_1_CODEC
258 #define NETEQ_G729_1_CODEC
259 #define NETEQ_SPEEX_CODEC
260 #define NETEQ_AMRWB_CODEC
261 #define NETEQ_WIDEBAND
262 #endif
264 #if (defined(NETEQ_ALL_WB32_CODECS)) /* AAC, RED, DTMF and CNG */
265 #define NETEQ_ISAC_SWB_CODEC
266 #define NETEQ_OPUS_CODEC
267 #define NETEQ_32KHZ_WIDEBAND
268 #define NETEQ_G722_1C_CODEC
269 #define NETEQ_CELT_CODEC
270 #endif
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
280 /* Narrowband codecs */
281 #define NETEQ_PCM16B_CODEC
282 #define NETEQ_G711_CODEC
283 #define NETEQ_ILBC_CODEC
284 #define NETEQ_AMR_CODEC
285 #define NETEQ_G729_CODEC
286 #define NETEQ_GSMFR_CODEC
288 /* Wideband codecs */
289 #define NETEQ_WIDEBAND
290 #define NETEQ_ISAC_CODEC
291 #define NETEQ_G722_CODEC
292 #define NETEQ_G722_1_CODEC
293 #define NETEQ_G729_1_CODEC
294 #define NETEQ_AMRWB_CODEC
295 #define NETEQ_SPEEX_CODEC
297 /* Super wideband 32kHz codecs */
298 #define NETEQ_ISAC_SWB_CODEC
299 #define NETEQ_32KHZ_WIDEBAND
300 #define NETEQ_G722_1C_CODEC
301 #define NETEQ_CELT_CODEC
302 #define NETEQ_OPUS_CODEC
304 /* hack in 48 kHz support */
305 #define NETEQ_48KHZ_WIDEBAND
307 #endif
309 #if (defined(NETEQ_ALL_CODECS))
310 /* Special codecs */
311 #define NETEQ_CNG_CODEC
312 #define NETEQ_ATEVENT_DECODE
313 #define NETEQ_RED_CODEC
314 #define NETEQ_VAD
315 #define NETEQ_ARBITRARY_CODEC
317 /* Narrowband codecs */
318 #define NETEQ_PCM16B_CODEC
319 #define NETEQ_G711_CODEC
320 #define NETEQ_ILBC_CODEC
321 #define NETEQ_G729_CODEC
322 #define NETEQ_G726_CODEC
323 #define NETEQ_GSMFR_CODEC
324 #define NETEQ_AMR_CODEC
326 /* Wideband codecs */
327 #define NETEQ_WIDEBAND
328 #define NETEQ_ISAC_CODEC
329 #define NETEQ_G722_CODEC
330 #define NETEQ_G722_1_CODEC
331 #define NETEQ_G729_1_CODEC
332 #define NETEQ_SPEEX_CODEC
333 #define NETEQ_AMRWB_CODEC
335 /* Super wideband 32kHz codecs */
336 #define NETEQ_ISAC_SWB_CODEC
337 #define NETEQ_32KHZ_WIDEBAND
338 #define NETEQ_G722_1C_CODEC
339 #define NETEQ_CELT_CODEC
341 /* Super wideband 48kHz codecs */
342 #define NETEQ_48KHZ_WIDEBAND
343 #define NETEQ_OPUS_CODEC
344 #endif
346 /* Define this unconditionally, since the defines above
347 * don't seem to be active and we need the larger frame
348 * size for opus_decode.
350 #define NETEQ_48KHZ_WIDEBAND
352 /* Max output size from decoding one frame */
353 #if defined(NETEQ_48KHZ_WIDEBAND)
354 #define NETEQ_MAX_FRAME_SIZE 5760 /* 120 ms super wideband */
355 #define NETEQ_MAX_OUTPUT_SIZE 6480 /* 120+15 ms super wideband (120 ms decoded + 15 ms for merge overlap) */
356 #elif defined(NETEQ_32KHZ_WIDEBAND)
357 #define NETEQ_MAX_FRAME_SIZE 3840 /* 120 ms super wideband */
358 #define NETEQ_MAX_OUTPUT_SIZE 4320 /* 120+15 ms super wideband (120 ms decoded + 15 ms for merge overlap) */
359 #elif defined(NETEQ_WIDEBAND)
360 #define NETEQ_MAX_FRAME_SIZE 1920 /* 120 ms wideband */
361 #define NETEQ_MAX_OUTPUT_SIZE 2160 /* 120+15 ms wideband (120 ms decoded + 15 ms for merge overlap) */
362 #else
363 #define NETEQ_MAX_FRAME_SIZE 960 /* 120 ms narrowband */
364 #define NETEQ_MAX_OUTPUT_SIZE 1080 /* 120+15 ms narrowband (120 ms decoded + 15 ms for merge overlap) */
365 #endif
368 /* Enable stereo */
369 #define NETEQ_STEREO
371 #endif /* #if !defined NETEQ_DEFINES_H */