| 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 |
| 11 #include "webrtc/modules/audio_processing/aecm/aecm_core.h" | 11 #include "webrtc/modules/audio_processing/aecm/aecm_core.h" |
| 12 | 12 |
| 13 #include <assert.h> | |
| 14 #include <stddef.h> | 13 #include <stddef.h> |
| 15 #include <stdlib.h> | 14 #include <stdlib.h> |
| 16 | 15 |
| 17 extern "C" { | 16 extern "C" { |
| 18 #include "webrtc/common_audio/ring_buffer.h" | 17 #include "webrtc/common_audio/ring_buffer.h" |
| 19 #include "webrtc/common_audio/signal_processing/include/real_fft.h" | 18 #include "webrtc/common_audio/signal_processing/include/real_fft.h" |
| 20 } | 19 } |
| 21 #include "webrtc/modules/audio_processing/aecm/echo_control_mobile.h" | 20 #include "webrtc/modules/audio_processing/aecm/echo_control_mobile.h" |
| 22 #include "webrtc/modules/audio_processing/utility/delay_estimator_wrapper.h" | 21 #include "webrtc/modules/audio_processing/utility/delay_estimator_wrapper.h" |
| 23 extern "C" { | 22 extern "C" { |
| 24 #include "webrtc/system_wrappers/include/cpu_features_wrapper.h" | 23 #include "webrtc/system_wrappers/include/cpu_features_wrapper.h" |
| 25 } | 24 } |
| 25 |
| 26 #include "webrtc/base/checks.h" |
| 26 #include "webrtc/typedefs.h" | 27 #include "webrtc/typedefs.h" |
| 27 | 28 |
| 28 // Square root of Hanning window in Q14. | 29 // Square root of Hanning window in Q14. |
| 29 static const ALIGN8_BEG int16_t WebRtcAecm_kSqrtHanning[] ALIGN8_END = { | 30 static const ALIGN8_BEG int16_t WebRtcAecm_kSqrtHanning[] ALIGN8_END = { |
| 30 0, 399, 798, 1196, 1594, 1990, 2386, 2780, 3172, | 31 0, 399, 798, 1196, 1594, 1990, 2386, 2780, 3172, |
| 31 3562, 3951, 4337, 4720, 5101, 5478, 5853, 6224, | 32 3562, 3951, 4337, 4720, 5101, 5478, 5853, 6224, |
| 32 6591, 6954, 7313, 7668, 8019, 8364, 8705, 9040, | 33 6591, 6954, 7313, 7668, 8019, 8364, 8705, 9040, |
| 33 9370, 9695, 10013, 10326, 10633, 10933, 11227, 11514, | 34 9370, 9695, 10013, 10326, 10633, 10933, 11227, 11514, |
| 34 11795, 12068, 12335, 12594, 12845, 13089, 13325, 13553, | 35 11795, 12068, 12335, 12594, 12845, 13089, 13325, 13553, |
| 35 13773, 13985, 14189, 14384, 14571, 14749, 14918, 15079, | 36 13773, 13985, 14189, 14384, 14571, 14749, 14918, 15079, |
| (...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 476 echoEst32Gained = WEBRTC_SPL_UMUL_32_16((uint32_t)aecm->echoFilt[i], | 477 echoEst32Gained = WEBRTC_SPL_UMUL_32_16((uint32_t)aecm->echoFilt[i], |
| 477 supGain >> tmp16no1); | 478 supGain >> tmp16no1); |
| 478 } else | 479 } else |
| 479 { | 480 { |
| 480 // Result in Q-(RESOLUTION_CHANNEL+RESOLUTION_SUPGAIN-16) | 481 // Result in Q-(RESOLUTION_CHANNEL+RESOLUTION_SUPGAIN-16) |
| 481 echoEst32Gained = (aecm->echoFilt[i] >> tmp16no1) * supGain; | 482 echoEst32Gained = (aecm->echoFilt[i] >> tmp16no1) * supGain; |
| 482 } | 483 } |
| 483 } | 484 } |
| 484 | 485 |
| 485 zeros16 = WebRtcSpl_NormW16(aecm->nearFilt[i]); | 486 zeros16 = WebRtcSpl_NormW16(aecm->nearFilt[i]); |
| 486 assert(zeros16 >= 0); // |zeros16| is a norm, hence non-negative. | 487 RTC_DCHECK_GE(zeros16, 0); // |zeros16| is a norm, hence non-negative. |
| 487 dfa_clean_q_domain_diff = aecm->dfaCleanQDomain - aecm->dfaCleanQDomainOld; | 488 dfa_clean_q_domain_diff = aecm->dfaCleanQDomain - aecm->dfaCleanQDomainOld; |
| 488 if (zeros16 < dfa_clean_q_domain_diff && aecm->nearFilt[i]) { | 489 if (zeros16 < dfa_clean_q_domain_diff && aecm->nearFilt[i]) { |
| 489 tmp16no1 = aecm->nearFilt[i] << zeros16; | 490 tmp16no1 = aecm->nearFilt[i] << zeros16; |
| 490 qDomainDiff = zeros16 - dfa_clean_q_domain_diff; | 491 qDomainDiff = zeros16 - dfa_clean_q_domain_diff; |
| 491 tmp16no2 = ptrDfaClean[i] >> -qDomainDiff; | 492 tmp16no2 = ptrDfaClean[i] >> -qDomainDiff; |
| 492 } else { | 493 } else { |
| 493 tmp16no1 = dfa_clean_q_domain_diff < 0 | 494 tmp16no1 = dfa_clean_q_domain_diff < 0 |
| 494 ? aecm->nearFilt[i] >> -dfa_clean_q_domain_diff | 495 ? aecm->nearFilt[i] >> -dfa_clean_q_domain_diff |
| 495 : aecm->nearFilt[i] << dfa_clean_q_domain_diff; | 496 : aecm->nearFilt[i] << dfa_clean_q_domain_diff; |
| 496 qDomainDiff = 0; | 497 qDomainDiff = 0; |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 555 // speech distortion in double-talk. | 556 // speech distortion in double-talk. |
| 556 for (i = 0; i < PART_LEN1; i++) | 557 for (i = 0; i < PART_LEN1; i++) |
| 557 { | 558 { |
| 558 hnl[i] = (int16_t)((hnl[i] * hnl[i]) >> 14); | 559 hnl[i] = (int16_t)((hnl[i] * hnl[i]) >> 14); |
| 559 } | 560 } |
| 560 | 561 |
| 561 for (i = kMinPrefBand; i <= kMaxPrefBand; i++) | 562 for (i = kMinPrefBand; i <= kMaxPrefBand; i++) |
| 562 { | 563 { |
| 563 avgHnl32 += (int32_t)hnl[i]; | 564 avgHnl32 += (int32_t)hnl[i]; |
| 564 } | 565 } |
| 565 assert(kMaxPrefBand - kMinPrefBand + 1 > 0); | 566 RTC_DCHECK_GT(kMaxPrefBand - kMinPrefBand + 1, 0); |
| 566 avgHnl32 /= (kMaxPrefBand - kMinPrefBand + 1); | 567 avgHnl32 /= (kMaxPrefBand - kMinPrefBand + 1); |
| 567 | 568 |
| 568 for (i = kMaxPrefBand; i < PART_LEN1; i++) | 569 for (i = kMaxPrefBand; i < PART_LEN1; i++) |
| 569 { | 570 { |
| 570 if (hnl[i] > (int16_t)avgHnl32) | 571 if (hnl[i] > (int16_t)avgHnl32) |
| 571 { | 572 { |
| 572 hnl[i] = (int16_t)avgHnl32; | 573 hnl[i] = (int16_t)avgHnl32; |
| 573 } | 574 } |
| 574 } | 575 } |
| 575 } | 576 } |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 645 | 646 |
| 646 int16_t randW16[PART_LEN]; | 647 int16_t randW16[PART_LEN]; |
| 647 int16_t uReal[PART_LEN1]; | 648 int16_t uReal[PART_LEN1]; |
| 648 int16_t uImag[PART_LEN1]; | 649 int16_t uImag[PART_LEN1]; |
| 649 int32_t outLShift32; | 650 int32_t outLShift32; |
| 650 int16_t noiseRShift16[PART_LEN1]; | 651 int16_t noiseRShift16[PART_LEN1]; |
| 651 | 652 |
| 652 int16_t shiftFromNearToNoise = kNoiseEstQDomain - aecm->dfaCleanQDomain; | 653 int16_t shiftFromNearToNoise = kNoiseEstQDomain - aecm->dfaCleanQDomain; |
| 653 int16_t minTrackShift; | 654 int16_t minTrackShift; |
| 654 | 655 |
| 655 assert(shiftFromNearToNoise >= 0); | 656 RTC_DCHECK_GE(shiftFromNearToNoise, 0); |
| 656 assert(shiftFromNearToNoise < 16); | 657 RTC_DCHECK_LT(shiftFromNearToNoise, 16); |
| 657 | 658 |
| 658 if (aecm->noiseEstCtr < 100) | 659 if (aecm->noiseEstCtr < 100) |
| 659 { | 660 { |
| 660 // Track the minimum more quickly initially. | 661 // Track the minimum more quickly initially. |
| 661 aecm->noiseEstCtr++; | 662 aecm->noiseEstCtr++; |
| 662 minTrackShift = 6; | 663 minTrackShift = 6; |
| 663 } else | 664 } else |
| 664 { | 665 { |
| 665 minTrackShift = 9; | 666 minTrackShift = 9; |
| 666 } | 667 } |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 759 13); | 760 13); |
| 760 } | 761 } |
| 761 uImag[PART_LEN] = 0; | 762 uImag[PART_LEN] = 0; |
| 762 | 763 |
| 763 for (i = 0; i < PART_LEN1; i++) | 764 for (i = 0; i < PART_LEN1; i++) |
| 764 { | 765 { |
| 765 out[i].real = WebRtcSpl_AddSatW16(out[i].real, uReal[i]); | 766 out[i].real = WebRtcSpl_AddSatW16(out[i].real, uReal[i]); |
| 766 out[i].imag = WebRtcSpl_AddSatW16(out[i].imag, uImag[i]); | 767 out[i].imag = WebRtcSpl_AddSatW16(out[i].imag, uImag[i]); |
| 767 } | 768 } |
| 768 } | 769 } |
| OLD | NEW |