Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(23)

Unified Diff: webrtc/modules/audio_coding/neteq/delay_manager.cc

Issue 2408653002: NetEq: Convert AverageIAT from int to float calculations (Closed)
Patch Set: Fix Android checksum Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: webrtc/modules/audio_coding/neteq/delay_manager.cc
diff --git a/webrtc/modules/audio_coding/neteq/delay_manager.cc b/webrtc/modules/audio_coding/neteq/delay_manager.cc
index a6efdab8dccc0ca01e727140b706ecb77a6cacc7..559cd25c73bf874aceb4e905b2e7245d65c71697 100644
--- a/webrtc/modules/audio_coding/neteq/delay_manager.cc
+++ b/webrtc/modules/audio_coding/neteq/delay_manager.cc
@@ -319,22 +319,16 @@ void DelayManager::Reset() {
last_pack_cng_or_dtmf_ = 1;
}
-int DelayManager::AverageIAT() const {
- int32_t sum_q24 = 0;
- // Using an int for the upper limit of the following for-loop so the
- // loop-counter can be int. Otherwise we need a cast where |sum_q24| is
- // updated.
- const int iat_vec_size = static_cast<int>(iat_vector_.size());
- assert(iat_vector_.size() == 65); // Algorithm is hard-coded for this size.
- for (int i = 0; i < iat_vec_size; ++i) {
- // Shift 6 to fit worst case: 2^30 * 64.
- sum_q24 += (iat_vector_[i] >> 6) * i;
+double DelayManager::EstimatedClockDriftPpm() const {
+ double sum = 0.0;
+ // Calculate the expected value based on the probabilities in |iat_vector_|.
+ for (size_t i = 0; i < iat_vector_.size(); ++i) {
+ sum += static_cast<double>(iat_vector_[i]) * i;
}
- // Subtract the nominal inter-arrival time 1 = 2^24 in Q24.
- sum_q24 -= (1 << 24);
- // Multiply with 1000000 / 2^24 = 15625 / 2^18 to get in parts-per-million.
- // Shift 7 to Q17 first, then multiply with 15625 and shift another 11.
- return ((sum_q24 >> 7) * 15625) >> 11;
+ // The probabilities in |iat_vector_| are in Q30. Divide by 1 << 30 to convert
+ // to Q0; subtract 1 to make a zero clockdrift represent as 0; mulitply by
+ // 1000000 to produce parts-per-million (ppm).
+ return (sum / (1 << 30) - 1) * 1000000;
kwiberg-webrtc 2016/10/13 08:30:24 Now that you use floating-point numbers, what's th
hlundin-webrtc 2016/10/13 10:05:25 To get ppm...?
}
bool DelayManager::PeakFound() const {
« no previous file with comments | « webrtc/modules/audio_coding/neteq/delay_manager.h ('k') | webrtc/modules/audio_coding/neteq/mock/mock_delay_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698