blob: 78364890827a19eb1a16d2820fb8188844eccd95 [file] [log] [blame]
niklase@google.com470e71d2011-07-07 08:21:25 +00001/*
leozwang@webrtc.org91b359e2012-02-28 17:26:14 +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 * ilbc.h
13 *
14 * This header file contains all of the API's for iLBC.
15 *
16 */
17
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020018#ifndef MODULES_AUDIO_CODING_CODECS_ILBC_ILBC_H_
19#define MODULES_AUDIO_CODING_CODECS_ILBC_ILBC_H_
niklase@google.com470e71d2011-07-07 08:21:25 +000020
Peter Kastingdce40cf2015-08-24 14:52:23 -070021#include <stddef.h>
22
niklase@google.com470e71d2011-07-07 08:21:25 +000023/*
24 * Define the fixpoint numeric formats
25 */
26
Mirko Bonadei71207422017-09-15 13:58:09 +020027#include "typedefs.h" // NOLINT(build/include)
niklase@google.com470e71d2011-07-07 08:21:25 +000028
29/*
30 * Solution to support multiple instances
31 * Customer has to cast instance to proper type
32 */
33
pbos@webrtc.orge728ee02014-12-17 13:43:55 +000034typedef struct iLBC_encinst_t_ IlbcEncoderInstance;
niklase@google.com470e71d2011-07-07 08:21:25 +000035
pbos@webrtc.orge728ee02014-12-17 13:43:55 +000036typedef struct iLBC_decinst_t_ IlbcDecoderInstance;
niklase@google.com470e71d2011-07-07 08:21:25 +000037
38/*
39 * Comfort noise constants
40 */
41
42#define ILBC_SPEECH 1
43#define ILBC_CNG 2
44
45#ifdef __cplusplus
46extern "C" {
47#endif
48
49 /****************************************************************************
50 * WebRtcIlbcfix_XxxAssign(...)
51 *
52 * These functions assigns the encoder/decoder instance to the specified
53 * memory location
54 *
55 * Input:
kjellander@webrtc.org3c652b62015-11-18 23:07:57 +010056 * - XXX_xxxinst : Pointer to created instance that should be
57 * assigned
58 * - ILBCXXX_inst_Addr : Pointer to the desired memory space
59 * - size : The size that this structure occupies (in Word16)
niklase@google.com470e71d2011-07-07 08:21:25 +000060 *
61 * Return value : 0 - Ok
62 * -1 - Error
63 */
64
pbos@webrtc.orge728ee02014-12-17 13:43:55 +000065 int16_t WebRtcIlbcfix_EncoderAssign(IlbcEncoderInstance **iLBC_encinst,
pbos@webrtc.org0946a562013-04-09 00:28:06 +000066 int16_t *ILBCENC_inst_Addr,
67 int16_t *size);
pbos@webrtc.orge728ee02014-12-17 13:43:55 +000068 int16_t WebRtcIlbcfix_DecoderAssign(IlbcDecoderInstance **iLBC_decinst,
pbos@webrtc.org0946a562013-04-09 00:28:06 +000069 int16_t *ILBCDEC_inst_Addr,
70 int16_t *size);
niklase@google.com470e71d2011-07-07 08:21:25 +000071
72
73 /****************************************************************************
74 * WebRtcIlbcfix_XxxAssign(...)
75 *
76 * These functions create a instance to the specified structure
77 *
78 * Input:
kjellander@webrtc.org3c652b62015-11-18 23:07:57 +010079 * - XXX_inst : Pointer to created instance that should be created
niklase@google.com470e71d2011-07-07 08:21:25 +000080 *
kjellander@webrtc.org3c652b62015-11-18 23:07:57 +010081 * Return value : 0 - Ok
82 * -1 - Error
niklase@google.com470e71d2011-07-07 08:21:25 +000083 */
84
pbos@webrtc.orge728ee02014-12-17 13:43:55 +000085 int16_t WebRtcIlbcfix_EncoderCreate(IlbcEncoderInstance **iLBC_encinst);
86 int16_t WebRtcIlbcfix_DecoderCreate(IlbcDecoderInstance **iLBC_decinst);
niklase@google.com470e71d2011-07-07 08:21:25 +000087
88 /****************************************************************************
89 * WebRtcIlbcfix_XxxFree(...)
90 *
91 * These functions frees the dynamic memory of a specified instance
92 *
93 * Input:
94 * - XXX_inst : Pointer to created instance that should be freed
95 *
96 * Return value : 0 - Ok
97 * -1 - Error
98 */
99
pbos@webrtc.orge728ee02014-12-17 13:43:55 +0000100 int16_t WebRtcIlbcfix_EncoderFree(IlbcEncoderInstance *iLBC_encinst);
101 int16_t WebRtcIlbcfix_DecoderFree(IlbcDecoderInstance *iLBC_decinst);
niklase@google.com470e71d2011-07-07 08:21:25 +0000102
103
104 /****************************************************************************
105 * WebRtcIlbcfix_EncoderInit(...)
106 *
107 * This function initializes a iLBC instance
108 *
109 * Input:
110 * - iLBCenc_inst : iLBC instance, i.e. the user that should receive
111 * be initialized
112 * - frameLen : The frame length of the codec 20/30 (ms)
113 *
114 * Return value : 0 - Ok
115 * -1 - Error
116 */
117
pbos@webrtc.orge728ee02014-12-17 13:43:55 +0000118 int16_t WebRtcIlbcfix_EncoderInit(IlbcEncoderInstance *iLBCenc_inst,
pbos@webrtc.org0946a562013-04-09 00:28:06 +0000119 int16_t frameLen);
niklase@google.com470e71d2011-07-07 08:21:25 +0000120
121 /****************************************************************************
122 * WebRtcIlbcfix_Encode(...)
123 *
124 * This function encodes one iLBC frame. Input speech length has be a
125 * multiple of the frame length.
126 *
127 * Input:
128 * - iLBCenc_inst : iLBC instance, i.e. the user that should encode
129 * a package
130 * - speechIn : Input speech vector
131 * - len : Samples in speechIn (160, 240, 320 or 480)
132 *
133 * Output:
134 * - encoded : The encoded data vector
135 *
136 * Return value : >0 - Length (in bytes) of coded data
137 * -1 - Error
138 */
139
Peter Kastinga8b335c2015-06-11 18:51:20 -0700140 int WebRtcIlbcfix_Encode(IlbcEncoderInstance *iLBCenc_inst,
141 const int16_t *speechIn,
Peter Kastingdce40cf2015-08-24 14:52:23 -0700142 size_t len,
Peter Kastinga8b335c2015-06-11 18:51:20 -0700143 uint8_t* encoded);
niklase@google.com470e71d2011-07-07 08:21:25 +0000144
145 /****************************************************************************
146 * WebRtcIlbcfix_DecoderInit(...)
147 *
148 * This function initializes a iLBC instance with either 20 or 30 ms frames
149 * Alternatively the WebRtcIlbcfix_DecoderInit_XXms can be used. Then it's
150 * not needed to specify the frame length with a variable.
151 *
152 * Input:
pbos@webrtc.orge728ee02014-12-17 13:43:55 +0000153 * - IlbcDecoderInstance : iLBC decoder instance
154 * - frameLen : The frame length of the codec 20/30 (ms)
niklase@google.com470e71d2011-07-07 08:21:25 +0000155 *
pbos@webrtc.orge728ee02014-12-17 13:43:55 +0000156 * Return value : 0 - Ok
157 * -1 - Error
niklase@google.com470e71d2011-07-07 08:21:25 +0000158 */
159
pbos@webrtc.orge728ee02014-12-17 13:43:55 +0000160 int16_t WebRtcIlbcfix_DecoderInit(IlbcDecoderInstance *iLBCdec_inst,
pbos@webrtc.org0946a562013-04-09 00:28:06 +0000161 int16_t frameLen);
Karl Wiberg43766482015-08-27 15:22:11 +0200162 void WebRtcIlbcfix_DecoderInit20Ms(IlbcDecoderInstance* iLBCdec_inst);
163 void WebRtcIlbcfix_Decoderinit30Ms(IlbcDecoderInstance* iLBCdec_inst);
niklase@google.com470e71d2011-07-07 08:21:25 +0000164
165 /****************************************************************************
166 * WebRtcIlbcfix_Decode(...)
167 *
168 * This function decodes a packet with iLBC frame(s). Output speech length
169 * will be a multiple of 160 or 240 samples ((160 or 240)*frames/packet).
170 *
171 * Input:
172 * - iLBCdec_inst : iLBC instance, i.e. the user that should decode
173 * a packet
174 * - encoded : Encoded iLBC frame(s)
175 * - len : Bytes in encoded vector
176 *
177 * Output:
178 * - decoded : The decoded vector
179 * - speechType : 1 normal, 2 CNG
180 *
181 * Return value : >0 - Samples in decoded vector
182 * -1 - Error
183 */
184
Peter Kastinga8b335c2015-06-11 18:51:20 -0700185 int WebRtcIlbcfix_Decode(IlbcDecoderInstance* iLBCdec_inst,
186 const uint8_t* encoded,
Peter Kastingdce40cf2015-08-24 14:52:23 -0700187 size_t len,
Peter Kastinga8b335c2015-06-11 18:51:20 -0700188 int16_t* decoded,
189 int16_t* speechType);
190 int WebRtcIlbcfix_Decode20Ms(IlbcDecoderInstance* iLBCdec_inst,
jmarusic@webrtc.org71b35a42015-02-17 16:02:18 +0000191 const uint8_t* encoded,
Peter Kastingdce40cf2015-08-24 14:52:23 -0700192 size_t len,
jmarusic@webrtc.org71b35a42015-02-17 16:02:18 +0000193 int16_t* decoded,
194 int16_t* speechType);
Peter Kastinga8b335c2015-06-11 18:51:20 -0700195 int WebRtcIlbcfix_Decode30Ms(IlbcDecoderInstance* iLBCdec_inst,
196 const uint8_t* encoded,
Peter Kastingdce40cf2015-08-24 14:52:23 -0700197 size_t len,
Peter Kastinga8b335c2015-06-11 18:51:20 -0700198 int16_t* decoded,
199 int16_t* speechType);
niklase@google.com470e71d2011-07-07 08:21:25 +0000200
201 /****************************************************************************
202 * WebRtcIlbcfix_DecodePlc(...)
203 *
204 * This function conducts PLC for iLBC frame(s). Output speech length
205 * will be a multiple of 160 or 240 samples.
206 *
207 * Input:
208 * - iLBCdec_inst : iLBC instance, i.e. the user that should perform
209 * a PLC
210 * - noOfLostFrames : Number of PLC frames to produce
211 *
212 * Output:
213 * - decoded : The "decoded" vector
214 *
Peter Kastingdce40cf2015-08-24 14:52:23 -0700215 * Return value : Samples in decoded PLC vector
niklase@google.com470e71d2011-07-07 08:21:25 +0000216 */
217
Peter Kastingdce40cf2015-08-24 14:52:23 -0700218 size_t WebRtcIlbcfix_DecodePlc(IlbcDecoderInstance *iLBCdec_inst,
219 int16_t *decoded,
220 size_t noOfLostFrames);
niklase@google.com470e71d2011-07-07 08:21:25 +0000221
222 /****************************************************************************
223 * WebRtcIlbcfix_NetEqPlc(...)
224 *
225 * This function updates the decoder when a packet loss has occured, but it
226 * does not produce any PLC data. Function can be used if another PLC method
227 * is used (i.e NetEq).
228 *
229 * Input:
230 * - iLBCdec_inst : iLBC instance that should be updated
231 * - noOfLostFrames : Number of lost frames
232 *
233 * Output:
234 * - decoded : The "decoded" vector (nothing in this case)
235 *
Peter Kastingdce40cf2015-08-24 14:52:23 -0700236 * Return value : Samples in decoded PLC vector
niklase@google.com470e71d2011-07-07 08:21:25 +0000237 */
238
Peter Kastingdce40cf2015-08-24 14:52:23 -0700239 size_t WebRtcIlbcfix_NetEqPlc(IlbcDecoderInstance *iLBCdec_inst,
240 int16_t *decoded,
241 size_t noOfLostFrames);
niklase@google.com470e71d2011-07-07 08:21:25 +0000242
243 /****************************************************************************
244 * WebRtcIlbcfix_version(...)
245 *
246 * This function returns the version number of iLBC
247 *
248 * Output:
249 * - version : Version number of iLBC (maximum 20 char)
250 */
251
leozwang@webrtc.org91b359e2012-02-28 17:26:14 +0000252 void WebRtcIlbcfix_version(char *version);
niklase@google.com470e71d2011-07-07 08:21:25 +0000253
254#ifdef __cplusplus
255}
256#endif
257
Mirko Bonadei92ea95e2017-09-15 06:47:31 +0200258#endif // MODULES_AUDIO_CODING_CODECS_ILBC_ILBC_H_