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

Side by Side Diff: webrtc/modules/audio_coding/neteq/rtcp.cc

Issue 2460393002: NetEq jitter calculation now done in int64_t. (Closed)
Patch Set: Created 4 years, 1 month 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 | « webrtc/modules/audio_coding/neteq/rtcp.h ('k') | 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) 2011 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2011 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 29 matching lines...) Expand all
40 cycles_++; 40 cycles_++;
41 } 41 }
42 max_seq_no_ = rtp_header.sequenceNumber; 42 max_seq_no_ = rtp_header.sequenceNumber;
43 } 43 }
44 44
45 // Calculate jitter according to RFC 3550, and update previous timestamps. 45 // Calculate jitter according to RFC 3550, and update previous timestamps.
46 // Note that the value in |jitter_| is in Q4. 46 // Note that the value in |jitter_| is in Q4.
47 if (received_packets_ > 1) { 47 if (received_packets_ > 1) {
48 int32_t ts_diff = receive_timestamp - (rtp_header.timestamp - transit_); 48 int32_t ts_diff = receive_timestamp - (rtp_header.timestamp - transit_);
49 ts_diff = WEBRTC_SPL_ABS_W32(ts_diff); 49 ts_diff = WEBRTC_SPL_ABS_W32(ts_diff);
50 int32_t jitter_diff = (ts_diff << 4) - jitter_; 50 uint64_t jitter_diff = (uint64_t{ts_diff} << 4) - jitter_;
ossu 2016/10/31 14:11:01 Uh... I spoke too soon. Clearly this could be nega
51 // Calculate 15 * jitter_ / 16 + jitter_diff / 16 (with proper rounding). 51 // Calculate 15 * jitter_ / 16 + jitter_diff / 16 (with proper rounding).
52 jitter_ = jitter_ + ((jitter_diff + 8) >> 4); 52 jitter_ = jitter_ + ((jitter_diff + 8) >> 4);
53 } 53 }
54 transit_ = rtp_header.timestamp - receive_timestamp; 54 transit_ = rtp_header.timestamp - receive_timestamp;
55 } 55 }
56 56
57 void Rtcp::GetStatistics(bool no_reset, RtcpStatistics* stats) { 57 void Rtcp::GetStatistics(bool no_reset, RtcpStatistics* stats) {
58 // Extended highest sequence number received. 58 // Extended highest sequence number received.
59 stats->extended_max_sequence_number = 59 stats->extended_max_sequence_number =
60 (static_cast<int>(cycles_) << 16) + max_seq_no_; 60 (static_cast<int>(cycles_) << 16) + max_seq_no_;
(...skipping 26 matching lines...) Expand all
87 if (expected_since_last == 0 || lost <= 0 || received_packets_ == 0) { 87 if (expected_since_last == 0 || lost <= 0 || received_packets_ == 0) {
88 stats->fraction_lost = 0; 88 stats->fraction_lost = 0;
89 } else { 89 } else {
90 stats->fraction_lost = std::min(0xFFU, (lost << 8) / expected_since_last); 90 stats->fraction_lost = std::min(0xFFU, (lost << 8) / expected_since_last);
91 } 91 }
92 92
93 stats->jitter = jitter_ >> 4; // Scaling from Q4. 93 stats->jitter = jitter_ >> 4; // Scaling from Q4.
94 } 94 }
95 95
96 } // namespace webrtc 96 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/audio_coding/neteq/rtcp.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698