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 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 sprintf(filename, "aec_delay%d.dat", webrtc_aec_instance_count); | 157 sprintf(filename, "aec_delay%d.dat", webrtc_aec_instance_count); |
158 aecpc->delayFile = fopen(filename, "wb"); | 158 aecpc->delayFile = fopen(filename, "wb"); |
159 webrtc_aec_instance_count++; | 159 webrtc_aec_instance_count++; |
160 } | 160 } |
161 #endif | 161 #endif |
162 | 162 |
163 return aecpc; | 163 return aecpc; |
164 } | 164 } |
165 | 165 |
166 void WebRtcAec_Free(void* aecInst) { | 166 void WebRtcAec_Free(void* aecInst) { |
167 Aec* aecpc = aecInst; | 167 Aec* aecpc = (Aec*)aecInst; |
168 | 168 |
169 if (aecpc == NULL) { | 169 if (aecpc == NULL) { |
170 return; | 170 return; |
171 } | 171 } |
172 | 172 |
173 WebRtc_FreeBuffer(aecpc->far_pre_buf); | 173 WebRtc_FreeBuffer(aecpc->far_pre_buf); |
174 | 174 |
175 #ifdef WEBRTC_AEC_DEBUG_DUMP | 175 #ifdef WEBRTC_AEC_DEBUG_DUMP |
176 fclose(aecpc->bufFile); | 176 fclose(aecpc->bufFile); |
177 fclose(aecpc->skewFile); | 177 fclose(aecpc->skewFile); |
178 fclose(aecpc->delayFile); | 178 fclose(aecpc->delayFile); |
179 #endif | 179 #endif |
180 | 180 |
181 WebRtcAec_FreeAec(aecpc->aec); | 181 WebRtcAec_FreeAec(aecpc->aec); |
182 WebRtcAec_FreeResampler(aecpc->resampler); | 182 WebRtcAec_FreeResampler(aecpc->resampler); |
183 free(aecpc); | 183 free(aecpc); |
184 } | 184 } |
185 | 185 |
186 int32_t WebRtcAec_Init(void* aecInst, int32_t sampFreq, int32_t scSampFreq) { | 186 int32_t WebRtcAec_Init(void* aecInst, int32_t sampFreq, int32_t scSampFreq) { |
187 Aec* aecpc = aecInst; | 187 Aec* aecpc = (Aec*)aecInst; |
188 AecConfig aecConfig; | 188 AecConfig aecConfig; |
189 | 189 |
190 if (sampFreq != 8000 && sampFreq != 16000 && sampFreq != 32000 && | 190 if (sampFreq != 8000 && sampFreq != 16000 && sampFreq != 32000 && |
191 sampFreq != 48000) { | 191 sampFreq != 48000) { |
192 return AEC_BAD_PARAMETER_ERROR; | 192 return AEC_BAD_PARAMETER_ERROR; |
193 } | 193 } |
194 aecpc->sampFreq = sampFreq; | 194 aecpc->sampFreq = sampFreq; |
195 | 195 |
196 if (scSampFreq < 1 || scSampFreq > 96000) { | 196 if (scSampFreq < 1 || scSampFreq > 96000) { |
197 return AEC_BAD_PARAMETER_ERROR; | 197 return AEC_BAD_PARAMETER_ERROR; |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
258 } | 258 } |
259 | 259 |
260 return 0; | 260 return 0; |
261 } | 261 } |
262 | 262 |
263 // Returns any error that is caused when buffering the | 263 // Returns any error that is caused when buffering the |
264 // far-end signal. | 264 // far-end signal. |
265 int32_t WebRtcAec_GetBufferFarendError(void* aecInst, | 265 int32_t WebRtcAec_GetBufferFarendError(void* aecInst, |
266 const float* farend, | 266 const float* farend, |
267 size_t nrOfSamples) { | 267 size_t nrOfSamples) { |
268 Aec* aecpc = aecInst; | 268 Aec* aecpc = (Aec*)aecInst; |
269 | 269 |
270 if (!farend) | 270 if (!farend) |
271 return AEC_NULL_POINTER_ERROR; | 271 return AEC_NULL_POINTER_ERROR; |
272 | 272 |
273 if (aecpc->initFlag != initCheck) | 273 if (aecpc->initFlag != initCheck) |
274 return AEC_UNINITIALIZED_ERROR; | 274 return AEC_UNINITIALIZED_ERROR; |
275 | 275 |
276 // number of samples == 160 for SWB input | 276 // number of samples == 160 for SWB input |
277 if (nrOfSamples != 80 && nrOfSamples != 160) | 277 if (nrOfSamples != 80 && nrOfSamples != 160) |
278 return AEC_BAD_PARAMETER_ERROR; | 278 return AEC_BAD_PARAMETER_ERROR; |
279 | 279 |
280 return 0; | 280 return 0; |
281 } | 281 } |
282 | 282 |
283 // only buffer L band for farend | 283 // only buffer L band for farend |
284 int32_t WebRtcAec_BufferFarend(void* aecInst, | 284 int32_t WebRtcAec_BufferFarend(void* aecInst, |
285 const float* farend, | 285 const float* farend, |
286 size_t nrOfSamples) { | 286 size_t nrOfSamples) { |
287 Aec* aecpc = aecInst; | 287 Aec* aecpc = (Aec*)aecInst; |
288 size_t newNrOfSamples = nrOfSamples; | 288 size_t newNrOfSamples = nrOfSamples; |
289 float new_farend[MAX_RESAMP_LEN]; | 289 float new_farend[MAX_RESAMP_LEN]; |
290 const float* farend_ptr = farend; | 290 const float* farend_ptr = farend; |
291 | 291 |
292 // Get any error caused by buffering the farend signal. | 292 // Get any error caused by buffering the farend signal. |
293 int32_t error_code = | 293 int32_t error_code = |
294 WebRtcAec_GetBufferFarendError(aecInst, farend, nrOfSamples); | 294 WebRtcAec_GetBufferFarendError(aecInst, farend, nrOfSamples); |
295 | 295 |
296 if (error_code != 0) | 296 if (error_code != 0) |
297 return error_code; | 297 return error_code; |
(...skipping 30 matching lines...) Expand all Loading... |
328 return 0; | 328 return 0; |
329 } | 329 } |
330 | 330 |
331 int32_t WebRtcAec_Process(void* aecInst, | 331 int32_t WebRtcAec_Process(void* aecInst, |
332 const float* const* nearend, | 332 const float* const* nearend, |
333 size_t num_bands, | 333 size_t num_bands, |
334 float* const* out, | 334 float* const* out, |
335 size_t nrOfSamples, | 335 size_t nrOfSamples, |
336 int16_t msInSndCardBuf, | 336 int16_t msInSndCardBuf, |
337 int32_t skew) { | 337 int32_t skew) { |
338 Aec* aecpc = aecInst; | 338 Aec* aecpc = (Aec*)aecInst; |
339 int32_t retVal = 0; | 339 int32_t retVal = 0; |
340 | 340 |
341 if (out == NULL) { | 341 if (out == NULL) { |
342 return AEC_NULL_POINTER_ERROR; | 342 return AEC_NULL_POINTER_ERROR; |
343 } | 343 } |
344 | 344 |
345 if (aecpc->initFlag != initCheck) { | 345 if (aecpc->initFlag != initCheck) { |
346 return AEC_UNINITIALIZED_ERROR; | 346 return AEC_UNINITIALIZED_ERROR; |
347 } | 347 } |
348 | 348 |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
517 metrics->aNlp.min = kOffsetLevel; | 517 metrics->aNlp.min = kOffsetLevel; |
518 } | 518 } |
519 | 519 |
520 return 0; | 520 return 0; |
521 } | 521 } |
522 | 522 |
523 int WebRtcAec_GetDelayMetrics(void* handle, | 523 int WebRtcAec_GetDelayMetrics(void* handle, |
524 int* median, | 524 int* median, |
525 int* std, | 525 int* std, |
526 float* fraction_poor_delays) { | 526 float* fraction_poor_delays) { |
527 Aec* self = handle; | 527 Aec* self = (Aec*)handle; |
528 if (median == NULL) { | 528 if (median == NULL) { |
529 return AEC_NULL_POINTER_ERROR; | 529 return AEC_NULL_POINTER_ERROR; |
530 } | 530 } |
531 if (std == NULL) { | 531 if (std == NULL) { |
532 return AEC_NULL_POINTER_ERROR; | 532 return AEC_NULL_POINTER_ERROR; |
533 } | 533 } |
534 if (self->initFlag != initCheck) { | 534 if (self->initFlag != initCheck) { |
535 return AEC_UNINITIALIZED_ERROR; | 535 return AEC_UNINITIALIZED_ERROR; |
536 } | 536 } |
537 if (WebRtcAec_GetDelayMetricsCore(self->aec, median, std, | 537 if (WebRtcAec_GetDelayMetricsCore(self->aec, median, std, |
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
866 } | 866 } |
867 } else { | 867 } else { |
868 self->timeForDelayChange = 0; | 868 self->timeForDelayChange = 0; |
869 } | 869 } |
870 self->lastDelayDiff = delay_difference; | 870 self->lastDelayDiff = delay_difference; |
871 | 871 |
872 if (self->timeForDelayChange > 25) { | 872 if (self->timeForDelayChange > 25) { |
873 self->knownDelay = WEBRTC_SPL_MAX((int)self->filtDelay - 256, 0); | 873 self->knownDelay = WEBRTC_SPL_MAX((int)self->filtDelay - 256, 0); |
874 } | 874 } |
875 } | 875 } |
OLD | NEW |