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 449 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
460 correlation_scale = std::max(0, correlation_scale); | 460 correlation_scale = std::max(0, correlation_scale); |
461 | 461 |
462 // Calculate the correlation, store in |correlation_vector2|. | 462 // Calculate the correlation, store in |correlation_vector2|. |
463 WebRtcSpl_CrossCorrelation( | 463 WebRtcSpl_CrossCorrelation( |
464 correlation_vector2, | 464 correlation_vector2, |
465 &(audio_history[signal_length - correlation_length]), | 465 &(audio_history[signal_length - correlation_length]), |
466 &(audio_history[signal_length - correlation_length - start_index]), | 466 &(audio_history[signal_length - correlation_length - start_index]), |
467 correlation_length, correlation_lags, correlation_scale, -1); | 467 correlation_length, correlation_lags, correlation_scale, -1); |
468 | 468 |
469 // Find maximizing index. | 469 // Find maximizing index. |
470 best_index = static_cast<size_t>( | 470 best_index = WebRtcSpl_MaxIndexW32(correlation_vector2, correlation_lags); |
471 WebRtcSpl_MaxIndexW32(correlation_vector2, correlation_lags)); | |
472 int32_t max_correlation = correlation_vector2[best_index]; | 471 int32_t max_correlation = correlation_vector2[best_index]; |
473 // Compensate index with start offset. | 472 // Compensate index with start offset. |
474 best_index = best_index + start_index; | 473 best_index = best_index + start_index; |
475 | 474 |
476 // Calculate energies. | 475 // Calculate energies. |
477 int32_t energy1 = WebRtcSpl_DotProductWithScale( | 476 int32_t energy1 = WebRtcSpl_DotProductWithScale( |
478 &(audio_history[signal_length - correlation_length]), | 477 &(audio_history[signal_length - correlation_length]), |
479 &(audio_history[signal_length - correlation_length]), | 478 &(audio_history[signal_length - correlation_length]), |
480 correlation_length, correlation_scale); | 479 correlation_length, correlation_scale); |
481 int32_t energy2 = WebRtcSpl_DotProductWithScale( | 480 int32_t energy2 = WebRtcSpl_DotProductWithScale( |
(...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
954 const size_t kMaxRandSamples = RandomVector::kRandomTableSize; | 953 const size_t kMaxRandSamples = RandomVector::kRandomTableSize; |
955 while (samples_generated < length) { | 954 while (samples_generated < length) { |
956 size_t rand_length = std::min(length - samples_generated, kMaxRandSamples); | 955 size_t rand_length = std::min(length - samples_generated, kMaxRandSamples); |
957 random_vector_->IncreaseSeedIncrement(seed_increment); | 956 random_vector_->IncreaseSeedIncrement(seed_increment); |
958 random_vector_->Generate(rand_length, &random_vector[samples_generated]); | 957 random_vector_->Generate(rand_length, &random_vector[samples_generated]); |
959 samples_generated += rand_length; | 958 samples_generated += rand_length; |
960 } | 959 } |
961 } | 960 } |
962 | 961 |
963 } // namespace webrtc | 962 } // namespace webrtc |
OLD | NEW |