OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 if ((mode==20)||(mode==30)) { | 83 if ((mode==20)||(mode==30)) { |
84 WebRtcIlbcfix_InitEncode((IlbcEncoder*) iLBCenc_inst, mode); | 84 WebRtcIlbcfix_InitEncode((IlbcEncoder*) iLBCenc_inst, mode); |
85 return(0); | 85 return(0); |
86 } else { | 86 } else { |
87 return(-1); | 87 return(-1); |
88 } | 88 } |
89 } | 89 } |
90 | 90 |
91 int WebRtcIlbcfix_Encode(IlbcEncoderInstance* iLBCenc_inst, | 91 int WebRtcIlbcfix_Encode(IlbcEncoderInstance* iLBCenc_inst, |
92 const int16_t* speechIn, | 92 const int16_t* speechIn, |
93 int16_t len, | 93 size_t len, |
94 uint8_t* encoded) { | 94 uint8_t* encoded) { |
95 int16_t pos = 0; | 95 size_t pos = 0; |
96 int16_t encpos = 0; | 96 size_t encpos = 0; |
97 | 97 |
98 if ((len != ((IlbcEncoder*)iLBCenc_inst)->blockl) && | 98 if ((len != ((IlbcEncoder*)iLBCenc_inst)->blockl) && |
99 #ifdef SPLIT_10MS | 99 #ifdef SPLIT_10MS |
100 (len != 80) && | 100 (len != 80) && |
101 #endif | 101 #endif |
102 (len != 2*((IlbcEncoder*)iLBCenc_inst)->blockl) && | 102 (len != 2*((IlbcEncoder*)iLBCenc_inst)->blockl) && |
103 (len != 3*((IlbcEncoder*)iLBCenc_inst)->blockl)) | 103 (len != 3*((IlbcEncoder*)iLBCenc_inst)->blockl)) |
104 { | 104 { |
105 /* A maximum of 3 frames/packet is allowed */ | 105 /* A maximum of 3 frames/packet is allowed */ |
106 return(-1); | 106 return(-1); |
107 } else { | 107 } else { |
108 | 108 |
109 /* call encoder */ | 109 /* call encoder */ |
110 while (pos<len) { | 110 while (pos<len) { |
111 WebRtcIlbcfix_EncodeImpl((uint16_t*)&encoded[2 * encpos], &speechIn[pos], | 111 WebRtcIlbcfix_EncodeImpl((uint16_t*)&encoded[2 * encpos], &speechIn[pos], |
112 (IlbcEncoder*)iLBCenc_inst); | 112 (IlbcEncoder*)iLBCenc_inst); |
113 #ifdef SPLIT_10MS | 113 #ifdef SPLIT_10MS |
114 pos += 80; | 114 pos += 80; |
115 if(((IlbcEncoder*)iLBCenc_inst)->section == 0) | 115 if(((IlbcEncoder*)iLBCenc_inst)->section == 0) |
116 #else | 116 #else |
117 pos += ((IlbcEncoder*)iLBCenc_inst)->blockl; | 117 pos += ((IlbcEncoder*)iLBCenc_inst)->blockl; |
118 #endif | 118 #endif |
119 encpos += ((IlbcEncoder*)iLBCenc_inst)->no_of_words; | 119 encpos += ((IlbcEncoder*)iLBCenc_inst)->no_of_words; |
120 } | 120 } |
121 return (encpos*2); | 121 return (int)(encpos*2); |
122 } | 122 } |
123 } | 123 } |
124 | 124 |
125 int16_t WebRtcIlbcfix_DecoderInit(IlbcDecoderInstance* iLBCdec_inst, | 125 int16_t WebRtcIlbcfix_DecoderInit(IlbcDecoderInstance* iLBCdec_inst, |
126 int16_t mode) { | 126 int16_t mode) { |
127 if ((mode==20)||(mode==30)) { | 127 if ((mode==20)||(mode==30)) { |
128 WebRtcIlbcfix_InitDecode((IlbcDecoder*) iLBCdec_inst, mode, 1); | 128 WebRtcIlbcfix_InitDecode((IlbcDecoder*) iLBCdec_inst, mode, 1); |
129 return(0); | 129 return(0); |
130 } else { | 130 } else { |
131 return(-1); | 131 return(-1); |
132 } | 132 } |
133 } | 133 } |
134 int16_t WebRtcIlbcfix_DecoderInit20Ms(IlbcDecoderInstance *iLBCdec_inst) { | 134 int16_t WebRtcIlbcfix_DecoderInit20Ms(IlbcDecoderInstance *iLBCdec_inst) { |
135 WebRtcIlbcfix_InitDecode((IlbcDecoder*) iLBCdec_inst, 20, 1); | 135 WebRtcIlbcfix_InitDecode((IlbcDecoder*) iLBCdec_inst, 20, 1); |
136 return(0); | 136 return(0); |
137 } | 137 } |
138 int16_t WebRtcIlbcfix_Decoderinit30Ms(IlbcDecoderInstance *iLBCdec_inst) { | 138 int16_t WebRtcIlbcfix_Decoderinit30Ms(IlbcDecoderInstance *iLBCdec_inst) { |
139 WebRtcIlbcfix_InitDecode((IlbcDecoder*) iLBCdec_inst, 30, 1); | 139 WebRtcIlbcfix_InitDecode((IlbcDecoder*) iLBCdec_inst, 30, 1); |
140 return(0); | 140 return(0); |
141 } | 141 } |
142 | 142 |
143 | 143 |
144 int WebRtcIlbcfix_Decode(IlbcDecoderInstance* iLBCdec_inst, | 144 int WebRtcIlbcfix_Decode(IlbcDecoderInstance* iLBCdec_inst, |
145 const uint8_t* encoded, | 145 const uint8_t* encoded, |
146 int16_t len, | 146 size_t len, |
147 int16_t* decoded, | 147 int16_t* decoded, |
148 int16_t* speechType) | 148 int16_t* speechType) |
149 { | 149 { |
150 int i=0; | 150 size_t i=0; |
151 /* Allow for automatic switching between the frame sizes | 151 /* Allow for automatic switching between the frame sizes |
152 (although you do get some discontinuity) */ | 152 (although you do get some discontinuity) */ |
153 if ((len==((IlbcDecoder*)iLBCdec_inst)->no_of_bytes)|| | 153 if ((len==((IlbcDecoder*)iLBCdec_inst)->no_of_bytes)|| |
154 (len==2*((IlbcDecoder*)iLBCdec_inst)->no_of_bytes)|| | 154 (len==2*((IlbcDecoder*)iLBCdec_inst)->no_of_bytes)|| |
155 (len==3*((IlbcDecoder*)iLBCdec_inst)->no_of_bytes)) { | 155 (len==3*((IlbcDecoder*)iLBCdec_inst)->no_of_bytes)) { |
156 /* ok, do nothing */ | 156 /* ok, do nothing */ |
157 } else { | 157 } else { |
158 /* Test if the mode has changed */ | 158 /* Test if the mode has changed */ |
159 if (((IlbcDecoder*)iLBCdec_inst)->mode==20) { | 159 if (((IlbcDecoder*)iLBCdec_inst)->mode==20) { |
160 if ((len==NO_OF_BYTES_30MS)|| | 160 if ((len==NO_OF_BYTES_30MS)|| |
(...skipping 23 matching lines...) Expand all Loading... |
184 while ((i*((IlbcDecoder*)iLBCdec_inst)->no_of_bytes)<len) { | 184 while ((i*((IlbcDecoder*)iLBCdec_inst)->no_of_bytes)<len) { |
185 WebRtcIlbcfix_DecodeImpl( | 185 WebRtcIlbcfix_DecodeImpl( |
186 &decoded[i * ((IlbcDecoder*)iLBCdec_inst)->blockl], | 186 &decoded[i * ((IlbcDecoder*)iLBCdec_inst)->blockl], |
187 (const uint16_t*)&encoded | 187 (const uint16_t*)&encoded |
188 [2 * i * ((IlbcDecoder*)iLBCdec_inst)->no_of_words], | 188 [2 * i * ((IlbcDecoder*)iLBCdec_inst)->no_of_words], |
189 (IlbcDecoder*)iLBCdec_inst, 1); | 189 (IlbcDecoder*)iLBCdec_inst, 1); |
190 i++; | 190 i++; |
191 } | 191 } |
192 /* iLBC does not support VAD/CNG yet */ | 192 /* iLBC does not support VAD/CNG yet */ |
193 *speechType=1; | 193 *speechType=1; |
194 return(i*((IlbcDecoder*)iLBCdec_inst)->blockl); | 194 return (int)(i*((IlbcDecoder*)iLBCdec_inst)->blockl); |
195 } | 195 } |
196 | 196 |
197 int WebRtcIlbcfix_Decode20Ms(IlbcDecoderInstance* iLBCdec_inst, | 197 int WebRtcIlbcfix_Decode20Ms(IlbcDecoderInstance* iLBCdec_inst, |
198 const uint8_t* encoded, | 198 const uint8_t* encoded, |
199 int16_t len, | 199 size_t len, |
200 int16_t* decoded, | 200 int16_t* decoded, |
201 int16_t* speechType) | 201 int16_t* speechType) |
202 { | 202 { |
203 int i=0; | 203 size_t i=0; |
204 if ((len==((IlbcDecoder*)iLBCdec_inst)->no_of_bytes)|| | 204 if ((len==((IlbcDecoder*)iLBCdec_inst)->no_of_bytes)|| |
205 (len==2*((IlbcDecoder*)iLBCdec_inst)->no_of_bytes)|| | 205 (len==2*((IlbcDecoder*)iLBCdec_inst)->no_of_bytes)|| |
206 (len==3*((IlbcDecoder*)iLBCdec_inst)->no_of_bytes)) { | 206 (len==3*((IlbcDecoder*)iLBCdec_inst)->no_of_bytes)) { |
207 /* ok, do nothing */ | 207 /* ok, do nothing */ |
208 } else { | 208 } else { |
209 return(-1); | 209 return(-1); |
210 } | 210 } |
211 | 211 |
212 while ((i*((IlbcDecoder*)iLBCdec_inst)->no_of_bytes)<len) { | 212 while ((i*((IlbcDecoder*)iLBCdec_inst)->no_of_bytes)<len) { |
213 WebRtcIlbcfix_DecodeImpl( | 213 WebRtcIlbcfix_DecodeImpl( |
214 &decoded[i * ((IlbcDecoder*)iLBCdec_inst)->blockl], | 214 &decoded[i * ((IlbcDecoder*)iLBCdec_inst)->blockl], |
215 (const uint16_t*)&encoded | 215 (const uint16_t*)&encoded |
216 [2 * i * ((IlbcDecoder*)iLBCdec_inst)->no_of_words], | 216 [2 * i * ((IlbcDecoder*)iLBCdec_inst)->no_of_words], |
217 (IlbcDecoder*)iLBCdec_inst, 1); | 217 (IlbcDecoder*)iLBCdec_inst, 1); |
218 i++; | 218 i++; |
219 } | 219 } |
220 /* iLBC does not support VAD/CNG yet */ | 220 /* iLBC does not support VAD/CNG yet */ |
221 *speechType=1; | 221 *speechType=1; |
222 return(i*((IlbcDecoder*)iLBCdec_inst)->blockl); | 222 return (int)(i*((IlbcDecoder*)iLBCdec_inst)->blockl); |
223 } | 223 } |
224 | 224 |
225 int WebRtcIlbcfix_Decode30Ms(IlbcDecoderInstance* iLBCdec_inst, | 225 int WebRtcIlbcfix_Decode30Ms(IlbcDecoderInstance* iLBCdec_inst, |
226 const uint8_t* encoded, | 226 const uint8_t* encoded, |
227 int16_t len, | 227 size_t len, |
228 int16_t* decoded, | 228 int16_t* decoded, |
229 int16_t* speechType) | 229 int16_t* speechType) |
230 { | 230 { |
231 int i=0; | 231 size_t i=0; |
232 if ((len==((IlbcDecoder*)iLBCdec_inst)->no_of_bytes)|| | 232 if ((len==((IlbcDecoder*)iLBCdec_inst)->no_of_bytes)|| |
233 (len==2*((IlbcDecoder*)iLBCdec_inst)->no_of_bytes)|| | 233 (len==2*((IlbcDecoder*)iLBCdec_inst)->no_of_bytes)|| |
234 (len==3*((IlbcDecoder*)iLBCdec_inst)->no_of_bytes)) { | 234 (len==3*((IlbcDecoder*)iLBCdec_inst)->no_of_bytes)) { |
235 /* ok, do nothing */ | 235 /* ok, do nothing */ |
236 } else { | 236 } else { |
237 return(-1); | 237 return(-1); |
238 } | 238 } |
239 | 239 |
240 while ((i*((IlbcDecoder*)iLBCdec_inst)->no_of_bytes)<len) { | 240 while ((i*((IlbcDecoder*)iLBCdec_inst)->no_of_bytes)<len) { |
241 WebRtcIlbcfix_DecodeImpl( | 241 WebRtcIlbcfix_DecodeImpl( |
242 &decoded[i * ((IlbcDecoder*)iLBCdec_inst)->blockl], | 242 &decoded[i * ((IlbcDecoder*)iLBCdec_inst)->blockl], |
243 (const uint16_t*)&encoded | 243 (const uint16_t*)&encoded |
244 [2 * i * ((IlbcDecoder*)iLBCdec_inst)->no_of_words], | 244 [2 * i * ((IlbcDecoder*)iLBCdec_inst)->no_of_words], |
245 (IlbcDecoder*)iLBCdec_inst, 1); | 245 (IlbcDecoder*)iLBCdec_inst, 1); |
246 i++; | 246 i++; |
247 } | 247 } |
248 /* iLBC does not support VAD/CNG yet */ | 248 /* iLBC does not support VAD/CNG yet */ |
249 *speechType=1; | 249 *speechType=1; |
250 return(i*((IlbcDecoder*)iLBCdec_inst)->blockl); | 250 return (int)(i*((IlbcDecoder*)iLBCdec_inst)->blockl); |
251 } | 251 } |
252 | 252 |
253 int16_t WebRtcIlbcfix_DecodePlc(IlbcDecoderInstance* iLBCdec_inst, | 253 size_t WebRtcIlbcfix_DecodePlc(IlbcDecoderInstance* iLBCdec_inst, |
254 int16_t* decoded, | 254 int16_t* decoded, |
255 int16_t noOfLostFrames) { | 255 size_t noOfLostFrames) { |
256 int i; | 256 size_t i; |
257 uint16_t dummy; | 257 uint16_t dummy; |
258 | 258 |
259 for (i=0;i<noOfLostFrames;i++) { | 259 for (i=0;i<noOfLostFrames;i++) { |
260 /* call decoder */ | 260 /* call decoder */ |
261 WebRtcIlbcfix_DecodeImpl( | 261 WebRtcIlbcfix_DecodeImpl( |
262 &decoded[i * ((IlbcDecoder*)iLBCdec_inst)->blockl], &dummy, | 262 &decoded[i * ((IlbcDecoder*)iLBCdec_inst)->blockl], &dummy, |
263 (IlbcDecoder*)iLBCdec_inst, 0); | 263 (IlbcDecoder*)iLBCdec_inst, 0); |
264 } | 264 } |
265 return (noOfLostFrames*((IlbcDecoder*)iLBCdec_inst)->blockl); | 265 return (noOfLostFrames*((IlbcDecoder*)iLBCdec_inst)->blockl); |
266 } | 266 } |
267 | 267 |
268 int16_t WebRtcIlbcfix_NetEqPlc(IlbcDecoderInstance* iLBCdec_inst, | 268 size_t WebRtcIlbcfix_NetEqPlc(IlbcDecoderInstance* iLBCdec_inst, |
269 int16_t* decoded, | 269 int16_t* decoded, |
270 int16_t noOfLostFrames) { | 270 size_t noOfLostFrames) { |
271 /* Two input parameters not used, but needed for function pointers in NetEQ */ | 271 /* Two input parameters not used, but needed for function pointers in NetEQ */ |
272 (void)(decoded = NULL); | 272 (void)(decoded = NULL); |
273 (void)(noOfLostFrames = 0); | 273 (void)(noOfLostFrames = 0); |
274 | 274 |
275 WebRtcSpl_MemSetW16(((IlbcDecoder*)iLBCdec_inst)->enh_buf, 0, ENH_BUFL); | 275 WebRtcSpl_MemSetW16(((IlbcDecoder*)iLBCdec_inst)->enh_buf, 0, ENH_BUFL); |
276 ((IlbcDecoder*)iLBCdec_inst)->prev_enh_pl = 2; | 276 ((IlbcDecoder*)iLBCdec_inst)->prev_enh_pl = 2; |
277 | 277 |
278 return (0); | 278 return (0); |
279 } | 279 } |
280 | 280 |
281 void WebRtcIlbcfix_version(char *version) | 281 void WebRtcIlbcfix_version(char *version) |
282 { | 282 { |
283 strcpy((char*)version, "1.1.1"); | 283 strcpy((char*)version, "1.1.1"); |
284 } | 284 } |
OLD | NEW |