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 501 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
512 // |audio_history|. | 512 // |audio_history|. |
513 size_t expansion_length = max_lag_ + overlap_length_; | 513 size_t expansion_length = max_lag_ + overlap_length_; |
514 const int16_t* vector1 = &(audio_history[signal_length - expansion_length]); | 514 const int16_t* vector1 = &(audio_history[signal_length - expansion_length]); |
515 const int16_t* vector2 = vector1 - distortion_lag; | 515 const int16_t* vector2 = vector1 - distortion_lag; |
516 // Normalize the second vector to the same energy as the first. | 516 // Normalize the second vector to the same energy as the first. |
517 energy1 = WebRtcSpl_DotProductWithScale(vector1, vector1, expansion_length, | 517 energy1 = WebRtcSpl_DotProductWithScale(vector1, vector1, expansion_length, |
518 correlation_scale); | 518 correlation_scale); |
519 energy2 = WebRtcSpl_DotProductWithScale(vector2, vector2, expansion_length, | 519 energy2 = WebRtcSpl_DotProductWithScale(vector2, vector2, expansion_length, |
520 correlation_scale); | 520 correlation_scale); |
521 // Confirm that amplitude ratio sqrt(energy1 / energy2) is within 0.5 - 2.0, | 521 // Confirm that amplitude ratio sqrt(energy1 / energy2) is within 0.5 - 2.0, |
522 // i.e., energy1 / energy1 is within 0.25 - 4. | 522 // i.e., energy1 / energy2 is within 0.25 - 4. |
523 int16_t amplitude_ratio; | 523 int16_t amplitude_ratio; |
524 if ((energy1 / 4 < energy2) && (energy1 > energy2 / 4)) { | 524 if ((energy1 / 4 < energy2) && (energy1 > energy2 / 4)) { |
525 // Energy constraint fulfilled. Use both vectors and scale them | 525 // Energy constraint fulfilled. Use both vectors and scale them |
526 // accordingly. | 526 // accordingly. |
527 int32_t scaled_energy2 = std::max(16 - WebRtcSpl_NormW32(energy2), 0); | 527 int32_t scaled_energy2 = std::max(16 - WebRtcSpl_NormW32(energy2), 0); |
528 int32_t scaled_energy1 = scaled_energy2 - 13; | 528 int32_t scaled_energy1 = scaled_energy2 - 13; |
529 // Calculate scaled_energy1 / scaled_energy2 in Q13. | 529 // Calculate scaled_energy1 / scaled_energy2 in Q13. |
530 int32_t energy_ratio = WebRtcSpl_DivW32W16( | 530 int32_t energy_ratio = WebRtcSpl_DivW32W16( |
531 WEBRTC_SPL_SHIFT_W32(energy1, -scaled_energy1), | 531 WEBRTC_SPL_SHIFT_W32(energy1, -scaled_energy1), |
532 static_cast<int16_t>(energy2 >> scaled_energy2)); | 532 static_cast<int16_t>(energy2 >> scaled_energy2)); |
(...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
953 const size_t kMaxRandSamples = RandomVector::kRandomTableSize; | 953 const size_t kMaxRandSamples = RandomVector::kRandomTableSize; |
954 while (samples_generated < length) { | 954 while (samples_generated < length) { |
955 size_t rand_length = std::min(length - samples_generated, kMaxRandSamples); | 955 size_t rand_length = std::min(length - samples_generated, kMaxRandSamples); |
956 random_vector_->IncreaseSeedIncrement(seed_increment); | 956 random_vector_->IncreaseSeedIncrement(seed_increment); |
957 random_vector_->Generate(rand_length, &random_vector[samples_generated]); | 957 random_vector_->Generate(rand_length, &random_vector[samples_generated]); |
958 samples_generated += rand_length; | 958 samples_generated += rand_length; |
959 } | 959 } |
960 } | 960 } |
961 | 961 |
962 } // namespace webrtc | 962 } // namespace webrtc |
OLD | NEW |