Index: webrtc/modules/audio_coding/neteq/expand.cc |
diff --git a/webrtc/modules/audio_coding/neteq/expand.cc b/webrtc/modules/audio_coding/neteq/expand.cc |
index ffe4370e4e61e8766c50ce8efcf22c96bd9723bf..b640f268650e9f24189f0e6b43651b768f5c18dc 100644 |
--- a/webrtc/modules/audio_coding/neteq/expand.cc |
+++ b/webrtc/modules/audio_coding/neteq/expand.cc |
@@ -675,12 +675,13 @@ void Expand::AnalyzeSignal(int16_t* random_vector) { |
parameters.ar_filter, |
kUnvoicedLpcOrder + 1, |
128); |
- int16_t unvoiced_prescale; |
- if (WebRtcSpl_MaxAbsValueW16(unvoiced_vector, 128) > 4000) { |
- unvoiced_prescale = 4; |
- } else { |
- unvoiced_prescale = 0; |
- } |
+ int16_t unvoiced_max_abs = WebRtcSpl_MaxAbsValueW16(unvoiced_vector, 128); |
kwiberg-webrtc
2016/12/15 14:11:16
const?
Also, won't the calculation break if the a
ivoc
2016/12/15 15:12:20
Wow, good catch. I added an if-statement to increa
|
+ // The maximum value of the dot product is 2^7 * 2^(2*n) = 2^(2*n + 7), so |
kwiberg-webrtc
2016/12/15 14:11:16
"is less than", since unvoiced_max_abs < 2^n.
Als
ivoc
2016/12/15 15:12:20
Done.
|
+ // to prevent overflows we want 2n + 7 <= 31, which means we should shift by |
+ // 2n + 7 - 31 bits, if this value is greater than zero. |
+ int16_t unvoiced_prescale = |
kwiberg-webrtc
2016/12/15 14:11:16
const int?
ivoc
2016/12/15 15:12:20
Due to the newly added if statement, this can no l
|
+ std::max(0, 2 * WebRtcSpl_GetSizeInBits(unvoiced_max_abs) - 24); |
+ |
int32_t unvoiced_energy = WebRtcSpl_DotProductWithScale(unvoiced_vector, |
unvoiced_vector, |
128, |