OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2013 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 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 tmp32no1, | 128 tmp32no1, |
129 WEBRTC_SPL_WORD16_MIN); | 129 WEBRTC_SPL_WORD16_MIN); |
130 } | 130 } |
131 | 131 |
132 // Copy the current block to the old position | 132 // Copy the current block to the old position |
133 // (aecm->outBuf is shifted elsewhere) | 133 // (aecm->outBuf is shifted elsewhere) |
134 memcpy(aecm->xBuf, aecm->xBuf + PART_LEN, sizeof(int16_t) * PART_LEN); | 134 memcpy(aecm->xBuf, aecm->xBuf + PART_LEN, sizeof(int16_t) * PART_LEN); |
135 memcpy(aecm->dBufNoisy, | 135 memcpy(aecm->dBufNoisy, |
136 aecm->dBufNoisy + PART_LEN, | 136 aecm->dBufNoisy + PART_LEN, |
137 sizeof(int16_t) * PART_LEN); | 137 sizeof(int16_t) * PART_LEN); |
138 if (nearendClean != NULL) | 138 if (nearendClean != nullptr) { |
139 { | |
140 memcpy(aecm->dBufClean, | 139 memcpy(aecm->dBufClean, |
141 aecm->dBufClean + PART_LEN, | 140 aecm->dBufClean + PART_LEN, |
142 sizeof(int16_t) * PART_LEN); | 141 sizeof(int16_t) * PART_LEN); |
143 } | 142 } |
144 } | 143 } |
145 | 144 |
146 // Transforms a time domain signal into the frequency domain, outputting the | 145 // Transforms a time domain signal into the frequency domain, outputting the |
147 // complex valued signal, absolute value and sum of absolute values. | 146 // complex valued signal, absolute value and sum of absolute values. |
148 // | 147 // |
149 // time_signal [in] Pointer to time domain signal | 148 // time_signal [in] Pointer to time domain signal |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
288 uint32_t dfaCleanSum; | 287 uint32_t dfaCleanSum; |
289 uint32_t echoEst32Gained; | 288 uint32_t echoEst32Gained; |
290 uint32_t tmpU32; | 289 uint32_t tmpU32; |
291 | 290 |
292 int32_t tmp32no1; | 291 int32_t tmp32no1; |
293 | 292 |
294 uint16_t xfa[PART_LEN1]; | 293 uint16_t xfa[PART_LEN1]; |
295 uint16_t dfaNoisy[PART_LEN1]; | 294 uint16_t dfaNoisy[PART_LEN1]; |
296 uint16_t dfaClean[PART_LEN1]; | 295 uint16_t dfaClean[PART_LEN1]; |
297 uint16_t* ptrDfaClean = dfaClean; | 296 uint16_t* ptrDfaClean = dfaClean; |
298 const uint16_t* far_spectrum_ptr = NULL; | 297 const uint16_t* far_spectrum_ptr = nullptr; |
299 | 298 |
300 // 32 byte aligned buffers (with +8 or +16). | 299 // 32 byte aligned buffers (with +8 or +16). |
301 // TODO(kma): define fft with ComplexInt16. | 300 // TODO(kma): define fft with ComplexInt16. |
302 int16_t fft_buf[PART_LEN4 + 2 + 16]; // +2 to make a loop safe. | 301 int16_t fft_buf[PART_LEN4 + 2 + 16]; // +2 to make a loop safe. |
303 int32_t echoEst32_buf[PART_LEN1 + 8]; | 302 int32_t echoEst32_buf[PART_LEN1 + 8]; |
304 int32_t dfw_buf[PART_LEN2 + 8]; | 303 int32_t dfw_buf[PART_LEN2 + 8]; |
305 int32_t efw_buf[PART_LEN2 + 8]; | 304 int32_t efw_buf[PART_LEN2 + 8]; |
306 | 305 |
307 int16_t* fft = (int16_t*) (((uintptr_t) fft_buf + 31) & ~ 31); | 306 int16_t* fft = (int16_t*) (((uintptr_t) fft_buf + 31) & ~ 31); |
308 int32_t* echoEst32 = (int32_t*) (((uintptr_t) echoEst32_buf + 31) & ~ 31); | 307 int32_t* echoEst32 = (int32_t*) (((uintptr_t) echoEst32_buf + 31) & ~ 31); |
(...skipping 25 matching lines...) Expand all Loading... |
334 if (aecm->startupState < 2) | 333 if (aecm->startupState < 2) |
335 { | 334 { |
336 aecm->startupState = (aecm->totCount >= CONV_LEN) + | 335 aecm->startupState = (aecm->totCount >= CONV_LEN) + |
337 (aecm->totCount >= CONV_LEN2); | 336 (aecm->totCount >= CONV_LEN2); |
338 } | 337 } |
339 // END: Determine startup state | 338 // END: Determine startup state |
340 | 339 |
341 // Buffer near and far end signals | 340 // Buffer near and far end signals |
342 memcpy(aecm->xBuf + PART_LEN, farend, sizeof(int16_t) * PART_LEN); | 341 memcpy(aecm->xBuf + PART_LEN, farend, sizeof(int16_t) * PART_LEN); |
343 memcpy(aecm->dBufNoisy + PART_LEN, nearendNoisy, sizeof(int16_t) * PART_LEN); | 342 memcpy(aecm->dBufNoisy + PART_LEN, nearendNoisy, sizeof(int16_t) * PART_LEN); |
344 if (nearendClean != NULL) | 343 if (nearendClean != nullptr) { |
345 { | |
346 memcpy(aecm->dBufClean + PART_LEN, | 344 memcpy(aecm->dBufClean + PART_LEN, |
347 nearendClean, | 345 nearendClean, |
348 sizeof(int16_t) * PART_LEN); | 346 sizeof(int16_t) * PART_LEN); |
349 } | 347 } |
350 | 348 |
351 // Transform far end signal from time domain to frequency domain. | 349 // Transform far end signal from time domain to frequency domain. |
352 far_q = TimeToFrequencyDomain(aecm, | 350 far_q = TimeToFrequencyDomain(aecm, |
353 aecm->xBuf, | 351 aecm->xBuf, |
354 dfw, | 352 dfw, |
355 xfa, | 353 xfa, |
356 &xfaSum); | 354 &xfaSum); |
357 | 355 |
358 // Transform noisy near end signal from time domain to frequency domain. | 356 // Transform noisy near end signal from time domain to frequency domain. |
359 zerosDBufNoisy = TimeToFrequencyDomain(aecm, | 357 zerosDBufNoisy = TimeToFrequencyDomain(aecm, |
360 aecm->dBufNoisy, | 358 aecm->dBufNoisy, |
361 dfw, | 359 dfw, |
362 dfaNoisy, | 360 dfaNoisy, |
363 &dfaNoisySum); | 361 &dfaNoisySum); |
364 aecm->dfaNoisyQDomainOld = aecm->dfaNoisyQDomain; | 362 aecm->dfaNoisyQDomainOld = aecm->dfaNoisyQDomain; |
365 aecm->dfaNoisyQDomain = (int16_t)zerosDBufNoisy; | 363 aecm->dfaNoisyQDomain = (int16_t)zerosDBufNoisy; |
366 | 364 |
367 | 365 if (nearendClean == nullptr) { |
368 if (nearendClean == NULL) | |
369 { | |
370 ptrDfaClean = dfaNoisy; | 366 ptrDfaClean = dfaNoisy; |
371 aecm->dfaCleanQDomainOld = aecm->dfaNoisyQDomainOld; | 367 aecm->dfaCleanQDomainOld = aecm->dfaNoisyQDomainOld; |
372 aecm->dfaCleanQDomain = aecm->dfaNoisyQDomain; | 368 aecm->dfaCleanQDomain = aecm->dfaNoisyQDomain; |
373 dfaCleanSum = dfaNoisySum; | 369 dfaCleanSum = dfaNoisySum; |
374 } else | 370 } else |
375 { | 371 { |
376 // Transform clean near end signal from time domain to frequency domain. | 372 // Transform clean near end signal from time domain to frequency domain. |
377 zerosDBufClean = TimeToFrequencyDomain(aecm, | 373 zerosDBufClean = TimeToFrequencyDomain(aecm, |
378 aecm->dBufClean, | 374 aecm->dBufClean, |
379 dfw, | 375 dfw, |
(...skipping 29 matching lines...) Expand all Loading... |
409 | 405 |
410 if (aecm->fixedDelay >= 0) | 406 if (aecm->fixedDelay >= 0) |
411 { | 407 { |
412 // Use fixed delay | 408 // Use fixed delay |
413 delay = aecm->fixedDelay; | 409 delay = aecm->fixedDelay; |
414 } | 410 } |
415 | 411 |
416 // Get aligned far end spectrum | 412 // Get aligned far end spectrum |
417 far_spectrum_ptr = WebRtcAecm_AlignedFarend(aecm, &far_q, delay); | 413 far_spectrum_ptr = WebRtcAecm_AlignedFarend(aecm, &far_q, delay); |
418 zerosXBuf = (int16_t) far_q; | 414 zerosXBuf = (int16_t) far_q; |
419 if (far_spectrum_ptr == NULL) | 415 if (far_spectrum_ptr == nullptr) { |
420 { | |
421 return -1; | 416 return -1; |
422 } | 417 } |
423 | 418 |
424 // Calculate log(energy) and update energy threshold levels | 419 // Calculate log(energy) and update energy threshold levels |
425 WebRtcAecm_CalcEnergies(aecm, | 420 WebRtcAecm_CalcEnergies(aecm, |
426 far_spectrum_ptr, | 421 far_spectrum_ptr, |
427 zerosXBuf, | 422 zerosXBuf, |
428 dfaNoisySum, | 423 dfaNoisySum, |
429 echoEst32); | 424 echoEst32); |
430 | 425 |
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
760 13); | 755 13); |
761 } | 756 } |
762 uImag[PART_LEN] = 0; | 757 uImag[PART_LEN] = 0; |
763 | 758 |
764 for (i = 0; i < PART_LEN1; i++) | 759 for (i = 0; i < PART_LEN1; i++) |
765 { | 760 { |
766 out[i].real = WebRtcSpl_AddSatW16(out[i].real, uReal[i]); | 761 out[i].real = WebRtcSpl_AddSatW16(out[i].real, uReal[i]); |
767 out[i].imag = WebRtcSpl_AddSatW16(out[i].imag, uImag[i]); | 762 out[i].imag = WebRtcSpl_AddSatW16(out[i].imag, uImag[i]); |
768 } | 763 } |
769 } | 764 } |
OLD | NEW |