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

Side by Side Diff: webrtc/modules/audio_coding/neteq/tools/neteq_delay_analyzer.cc

Issue 2933053002: Fix a numerical issue in NetEq delay plotting (Closed)
Patch Set: Created 3 years, 6 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2017 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
11 #include "webrtc/modules/audio_coding/neteq/tools/neteq_delay_analyzer.h" 11 #include "webrtc/modules/audio_coding/neteq/tools/neteq_delay_analyzer.h"
12 12
13 #include <algorithm> 13 #include <algorithm>
14 #include <limits> 14 #include <limits>
15 #include <utility> 15 #include <utility>
16 16
17 #include <webrtc/base/checks.h>
18
17 namespace webrtc { 19 namespace webrtc {
18 namespace test { 20 namespace test {
19 namespace { 21 namespace {
20 // Helper function for NetEqDelayAnalyzer::CreateGraphs. Returns the 22 // Helper function for NetEqDelayAnalyzer::CreateGraphs. Returns the
21 // interpolated value of a function at the point x. Vector x_vec contains the 23 // interpolated value of a function at the point x. Vector x_vec contains the
22 // sample points, and y_vec contains the function values at these points. The 24 // sample points, and y_vec contains the function values at these points. The
23 // return value is a linear interpolation between y_vec values. 25 // return value is a linear interpolation between y_vec values.
24 double LinearInterpolate(double x, 26 double LinearInterpolate(double x,
25 const std::vector<int64_t>& x_vec, 27 const std::vector<int64_t>& x_vec,
26 const std::vector<int64_t>& y_vec) { 28 const std::vector<int64_t>& y_vec) {
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 nominal_get_audio_time_ms.begin() + 1, [](int64_t& x) { return x + 10; }); 110 nominal_get_audio_time_ms.begin() + 1, [](int64_t& x) { return x + 10; });
109 RTC_DCHECK( 111 RTC_DCHECK(
110 std::is_sorted(get_audio_time_ms_.begin(), get_audio_time_ms_.end())); 112 std::is_sorted(get_audio_time_ms_.begin(), get_audio_time_ms_.end()));
111 113
112 std::vector<double> rtp_timestamps_ms; 114 std::vector<double> rtp_timestamps_ms;
113 double offset = std::numeric_limits<double>::max(); 115 double offset = std::numeric_limits<double>::max();
114 TimestampUnwrapper unwrapper; 116 TimestampUnwrapper unwrapper;
115 // This loop traverses data_ and populates rtp_timestamps_ms as well as 117 // This loop traverses data_ and populates rtp_timestamps_ms as well as
116 // calculates the base offset. 118 // calculates the base offset.
117 for (auto& d : data_) { 119 for (auto& d : data_) {
118 rtp_timestamps_ms.push_back(unwrapper.Unwrap(d.first) / 120 rtp_timestamps_ms.push_back(
119 (last_sample_rate_hz_ / 1000.f)); 121 unwrapper.Unwrap(d.first) /
ivoc 2017/06/12 10:19:19 Are you sure this change has any effect? I tried t
hlundin-webrtc 2017/06/12 11:54:58 The machine instructions change quite a bit: https
122 rtc::CheckedDivExact(last_sample_rate_hz_, 1000));
120 offset = 123 offset =
121 std::min(offset, d.second.arrival_time_ms - rtp_timestamps_ms.back()); 124 std::min(offset, d.second.arrival_time_ms - rtp_timestamps_ms.back());
122 } 125 }
123 126
124 // Calculate send times in seconds for each packet. This is the (unwrapped) 127 // Calculate send times in seconds for each packet. This is the (unwrapped)
125 // RTP timestamp in ms divided by 1000. 128 // RTP timestamp in ms divided by 1000.
126 send_time_s->resize(rtp_timestamps_ms.size()); 129 send_time_s->resize(rtp_timestamps_ms.size());
127 std::transform(rtp_timestamps_ms.begin(), rtp_timestamps_ms.end(), 130 std::transform(rtp_timestamps_ms.begin(), rtp_timestamps_ms.end(),
128 send_time_s->begin(), [rtp_timestamps_ms](double x) { 131 send_time_s->begin(), [rtp_timestamps_ms](double x) {
129 return (x - rtp_timestamps_ms[0]) / 1000.f; 132 return (x - rtp_timestamps_ms[0]) / 1000.f;
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 } 167 }
165 } 168 }
166 RTC_DCHECK(data_it == data_.end()); 169 RTC_DCHECK(data_it == data_.end());
167 RTC_DCHECK_EQ(send_time_s->size(), corrected_arrival_delay_ms->size()); 170 RTC_DCHECK_EQ(send_time_s->size(), corrected_arrival_delay_ms->size());
168 RTC_DCHECK_EQ(send_time_s->size(), playout_delay_ms->size()); 171 RTC_DCHECK_EQ(send_time_s->size(), playout_delay_ms->size());
169 RTC_DCHECK_EQ(send_time_s->size(), target_delay_ms->size()); 172 RTC_DCHECK_EQ(send_time_s->size(), target_delay_ms->size());
170 } 173 }
171 174
172 } // namespace test 175 } // namespace test
173 } // namespace webrtc 176 } // namespace webrtc
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698