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 663 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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 if (WebRtcSpl_MaxAbsValueW16(unvoiced_vector, 128) > 4000) { |
680 unvoiced_prescale = 4; | 680 unvoiced_prescale = 4; |
681 } else { | 681 } else { |
682 unvoiced_prescale = 0; | 682 unvoiced_prescale = 0; |
683 } | 683 } |
684 int32_t unvoiced_energy = WebRtcSpl_DotProductWithScale(unvoiced_vector, | 684 int32_t unvoiced_energy = WebRtcSpl_DotProductWithScale_64b( |
hlundin-webrtc
2016/12/12 21:40:41
Will you not end up with the same overflow problem
ivoc
2016/12/13 08:43:09
Oops, good catch, I'll change this to int64_t.
kwiberg-webrtc
2016/12/13 08:45:36
I would imagine so. Since all the partial sums are
| |
685 unvoiced_vector, | 685 unvoiced_vector, unvoiced_vector, 128, unvoiced_prescale); |
686 128, | |
687 unvoiced_prescale); | |
688 | 686 |
689 // Normalize |unvoiced_energy| to 28 or 29 bits to preserve sqrt() accuracy. | 687 // Normalize |unvoiced_energy| to 28 or 29 bits to preserve sqrt() accuracy. |
690 int16_t unvoiced_scale = WebRtcSpl_NormW32(unvoiced_energy) - 3; | 688 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 | 689 // 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 | 690 // from dividing with 128 earlier. This will make the total scale factor |
693 // even, which is suitable for the sqrt. | 691 // even, which is suitable for the sqrt. |
694 unvoiced_scale += ((unvoiced_scale & 0x1) ^ 0x1); | 692 unvoiced_scale += ((unvoiced_scale & 0x1) ^ 0x1); |
695 unvoiced_energy = WEBRTC_SPL_SHIFT_W32(unvoiced_energy, unvoiced_scale); | 693 unvoiced_energy = WEBRTC_SPL_SHIFT_W32(unvoiced_energy, unvoiced_scale); |
696 int16_t unvoiced_gain = | 694 int16_t unvoiced_gain = |
697 static_cast<int16_t>(WebRtcSpl_SqrtFloor(unvoiced_energy)); | 695 static_cast<int16_t>(WebRtcSpl_SqrtFloor(unvoiced_energy)); |
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
961 const size_t kMaxRandSamples = RandomVector::kRandomTableSize; | 959 const size_t kMaxRandSamples = RandomVector::kRandomTableSize; |
962 while (samples_generated < length) { | 960 while (samples_generated < length) { |
963 size_t rand_length = std::min(length - samples_generated, kMaxRandSamples); | 961 size_t rand_length = std::min(length - samples_generated, kMaxRandSamples); |
964 random_vector_->IncreaseSeedIncrement(seed_increment); | 962 random_vector_->IncreaseSeedIncrement(seed_increment); |
965 random_vector_->Generate(rand_length, &random_vector[samples_generated]); | 963 random_vector_->Generate(rand_length, &random_vector[samples_generated]); |
966 samples_generated += rand_length; | 964 samples_generated += rand_length; |
967 } | 965 } |
968 } | 966 } |
969 | 967 |
970 } // namespace webrtc | 968 } // namespace webrtc |
OLD | NEW |