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 658 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
669 sizeof(int16_t) * kUnvoicedLpcOrder); | 669 sizeof(int16_t) * kUnvoicedLpcOrder); |
670 memcpy(unvoiced_vector - kUnvoicedLpcOrder, | 670 memcpy(unvoiced_vector - kUnvoicedLpcOrder, |
671 &(audio_history[signal_length - 128 - kUnvoicedLpcOrder]), | 671 &(audio_history[signal_length - 128 - kUnvoicedLpcOrder]), |
672 sizeof(int16_t) * kUnvoicedLpcOrder); | 672 sizeof(int16_t) * kUnvoicedLpcOrder); |
673 WebRtcSpl_FilterMAFastQ12(&audio_history[signal_length - 128], | 673 WebRtcSpl_FilterMAFastQ12(&audio_history[signal_length - 128], |
674 unvoiced_vector, | 674 unvoiced_vector, |
675 parameters.ar_filter, | 675 parameters.ar_filter, |
676 kUnvoicedLpcOrder + 1, | 676 kUnvoicedLpcOrder + 1, |
677 128); | 677 128); |
678 int16_t unvoiced_prescale; | 678 int16_t unvoiced_prescale; |
679 if (WebRtcSpl_MaxAbsValueW16(unvoiced_vector, 128) > 4000) { | 679 int16_t unvoiced_max_abs = WebRtcSpl_MaxAbsValueW16(unvoiced_vector, 128); |
680 if (unvoiced_max_abs > 16383) { | |
681 unvoiced_prescale = 6; | |
kwiberg-webrtc
2016/12/13 13:09:46
So, let's see... you sum 2^7 values that are all l
| |
682 } else if (unvoiced_max_abs > 4000) { | |
680 unvoiced_prescale = 4; | 683 unvoiced_prescale = 4; |
kwiberg-webrtc
2016/12/13 13:09:46
Sum of 2^7 values that are all less than 2^28, and
| |
681 } else { | 684 } else { |
682 unvoiced_prescale = 0; | 685 unvoiced_prescale = 0; |
kwiberg-webrtc
2016/12/13 13:09:46
Sum of 2^7 values that are all less than 2^24 (act
| |
683 } | 686 } |
684 int32_t unvoiced_energy = WebRtcSpl_DotProductWithScale(unvoiced_vector, | 687 int32_t unvoiced_energy = WebRtcSpl_DotProductWithScale(unvoiced_vector, |
685 unvoiced_vector, | 688 unvoiced_vector, |
686 128, | 689 128, |
687 unvoiced_prescale); | 690 unvoiced_prescale); |
688 | 691 |
689 // Normalize |unvoiced_energy| to 28 or 29 bits to preserve sqrt() accuracy. | 692 // Normalize |unvoiced_energy| to 28 or 29 bits to preserve sqrt() accuracy. |
690 int16_t unvoiced_scale = WebRtcSpl_NormW32(unvoiced_energy) - 3; | 693 int16_t unvoiced_scale = WebRtcSpl_NormW32(unvoiced_energy) - 3; |
691 // Make sure we do an odd number of shifts since we already have 7 shifts | 694 // Make sure we do an odd number of shifts since we already have 7 shifts |
692 // from dividing with 128 earlier. This will make the total scale factor | 695 // from dividing with 128 earlier. This will make the total scale factor |
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
961 const size_t kMaxRandSamples = RandomVector::kRandomTableSize; | 964 const size_t kMaxRandSamples = RandomVector::kRandomTableSize; |
962 while (samples_generated < length) { | 965 while (samples_generated < length) { |
963 size_t rand_length = std::min(length - samples_generated, kMaxRandSamples); | 966 size_t rand_length = std::min(length - samples_generated, kMaxRandSamples); |
964 random_vector_->IncreaseSeedIncrement(seed_increment); | 967 random_vector_->IncreaseSeedIncrement(seed_increment); |
965 random_vector_->Generate(rand_length, &random_vector[samples_generated]); | 968 random_vector_->Generate(rand_length, &random_vector[samples_generated]); |
966 samples_generated += rand_length; | 969 samples_generated += rand_length; |
967 } | 970 } |
968 } | 971 } |
969 | 972 |
970 } // namespace webrtc | 973 } // namespace webrtc |
OLD | NEW |