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 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 data[k * kNumChannels] += offset; | 108 data[k * kNumChannels] += offset; |
109 weighted_average += data[k * kNumChannels] * weights[k * kNumChannels]; | 109 weighted_average += data[k * kNumChannels] * weights[k * kNumChannels]; |
110 } | 110 } |
111 return weighted_average; | 111 return weighted_average; |
112 } | 112 } |
113 | 113 |
114 // An s16 x s32 -> s32 multiplication that's allowed to overflow. (It's still | 114 // An s16 x s32 -> s32 multiplication that's allowed to overflow. (It's still |
115 // undefined behavior, so not a good idea; this just makes UBSan ignore the | 115 // undefined behavior, so not a good idea; this just makes UBSan ignore the |
116 // violation, so that our old code can continue to do what it's always been | 116 // violation, so that our old code can continue to do what it's always been |
117 // doing.) | 117 // doing.) |
118 static inline int32_t OverflowingMulS16ByS32ToS32(int16_t a, int32_t b) | 118 static inline int32_t RTC_NO_SANITIZE("signed-integer-overflow") |
119 RTC_NO_SANITIZE("signed-integer-overflow") { | 119 OverflowingMulS16ByS32ToS32(int16_t a, int32_t b) { |
120 return a * b; | 120 return a * b; |
121 } | 121 } |
122 | 122 |
123 // Calculates the probabilities for both speech and background noise using | 123 // Calculates the probabilities for both speech and background noise using |
124 // Gaussian Mixture Models (GMM). A hypothesis-test is performed to decide which | 124 // Gaussian Mixture Models (GMM). A hypothesis-test is performed to decide which |
125 // type of signal is most probable. | 125 // type of signal is most probable. |
126 // | 126 // |
127 // - self [i/o] : Pointer to VAD instance | 127 // - self [i/o] : Pointer to VAD instance |
128 // - features [i] : Feature vector of length |kNumChannels| | 128 // - features [i] : Feature vector of length |kNumChannels| |
129 // = log10(energy in frequency band) | 129 // = log10(energy in frequency band) |
(...skipping 547 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
677 | 677 |
678 // Get power in the bands | 678 // Get power in the bands |
679 total_power = WebRtcVad_CalculateFeatures(inst, speech_frame, frame_length, | 679 total_power = WebRtcVad_CalculateFeatures(inst, speech_frame, frame_length, |
680 feature_vector); | 680 feature_vector); |
681 | 681 |
682 // Make a VAD | 682 // Make a VAD |
683 inst->vad = GmmProbability(inst, feature_vector, total_power, frame_length); | 683 inst->vad = GmmProbability(inst, feature_vector, total_power, frame_length); |
684 | 684 |
685 return inst->vad; | 685 return inst->vad; |
686 } | 686 } |
OLD | NEW |