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

Side by Side Diff: webrtc/modules/remote_bitrate_estimator/inter_arrival.cc

Issue 1376423002: Make overuse estimator one dimensional. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Further cleanups. Created 5 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2013 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 13 matching lines...) Expand all
24 double timestamp_to_ms_coeff, 24 double timestamp_to_ms_coeff,
25 bool enable_burst_grouping) 25 bool enable_burst_grouping)
26 : kTimestampGroupLengthTicks(timestamp_group_length_ticks), 26 : kTimestampGroupLengthTicks(timestamp_group_length_ticks),
27 current_timestamp_group_(), 27 current_timestamp_group_(),
28 prev_timestamp_group_(), 28 prev_timestamp_group_(),
29 timestamp_to_ms_coeff_(timestamp_to_ms_coeff), 29 timestamp_to_ms_coeff_(timestamp_to_ms_coeff),
30 burst_grouping_(enable_burst_grouping) {} 30 burst_grouping_(enable_burst_grouping) {}
31 31
32 bool InterArrival::ComputeDeltas(uint32_t timestamp, 32 bool InterArrival::ComputeDeltas(uint32_t timestamp,
33 int64_t arrival_time_ms, 33 int64_t arrival_time_ms,
34 size_t packet_size,
35 uint32_t* timestamp_delta, 34 uint32_t* timestamp_delta,
36 int64_t* arrival_time_delta_ms, 35 int64_t* arrival_time_delta_ms) {
37 int* packet_size_delta) {
38 assert(timestamp_delta != NULL); 36 assert(timestamp_delta != NULL);
39 assert(arrival_time_delta_ms != NULL); 37 assert(arrival_time_delta_ms != NULL);
40 assert(packet_size_delta != NULL);
41 bool calculated_deltas = false; 38 bool calculated_deltas = false;
42 if (current_timestamp_group_.IsFirstPacket()) { 39 if (current_timestamp_group_.IsFirstPacket()) {
43 // We don't have enough data to update the filter, so we store it until we 40 // We don't have enough data to update the filter, so we store it until we
44 // have two frames of data to process. 41 // have two frames of data to process.
45 current_timestamp_group_.timestamp = timestamp; 42 current_timestamp_group_.timestamp = timestamp;
46 current_timestamp_group_.first_timestamp = timestamp; 43 current_timestamp_group_.first_timestamp = timestamp;
47 } else if (!PacketInOrder(timestamp)) { 44 } else if (!PacketInOrder(timestamp)) {
48 return false; 45 return false;
49 } else if (NewTimestampGroup(arrival_time_ms, timestamp)) { 46 } else if (NewTimestampGroup(arrival_time_ms, timestamp)) {
50 // First packet of a later frame, the previous frame sample is ready. 47 // First packet of a later frame, the previous frame sample is ready.
51 if (prev_timestamp_group_.complete_time_ms >= 0) { 48 if (prev_timestamp_group_.complete_time_ms >= 0) {
52 *timestamp_delta = current_timestamp_group_.timestamp - 49 *timestamp_delta = current_timestamp_group_.timestamp -
53 prev_timestamp_group_.timestamp; 50 prev_timestamp_group_.timestamp;
54 *arrival_time_delta_ms = current_timestamp_group_.complete_time_ms - 51 *arrival_time_delta_ms = current_timestamp_group_.complete_time_ms -
55 prev_timestamp_group_.complete_time_ms; 52 prev_timestamp_group_.complete_time_ms;
56 if (*arrival_time_delta_ms < 0) { 53 if (*arrival_time_delta_ms < 0) {
57 // The group of packets has been reordered since receiving its local 54 // The group of packets has been reordered since receiving its local
58 // arrival timestamp. 55 // arrival timestamp.
59 LOG(LS_WARNING) << "Packets are being reordered on the path from the " 56 LOG(LS_WARNING) << "Packets are being reordered on the path from the "
60 "socket to the bandwidth estimator. Ignoring this " 57 "socket to the bandwidth estimator. Ignoring this "
61 "packet for bandwidth estimation."; 58 "packet for bandwidth estimation.";
62 return false; 59 return false;
63 } 60 }
64 assert(*arrival_time_delta_ms >= 0); 61 assert(*arrival_time_delta_ms >= 0);
65 *packet_size_delta = static_cast<int>(current_timestamp_group_.size) -
66 static_cast<int>(prev_timestamp_group_.size);
67 calculated_deltas = true; 62 calculated_deltas = true;
68 } 63 }
69 prev_timestamp_group_ = current_timestamp_group_; 64 prev_timestamp_group_ = current_timestamp_group_;
70 // The new timestamp is now the current frame. 65 // The new timestamp is now the current frame.
71 current_timestamp_group_.first_timestamp = timestamp; 66 current_timestamp_group_.first_timestamp = timestamp;
72 current_timestamp_group_.timestamp = timestamp; 67 current_timestamp_group_.timestamp = timestamp;
73 current_timestamp_group_.size = 0;
74 } 68 }
75 else { 69 else {
76 current_timestamp_group_.timestamp = LatestTimestamp( 70 current_timestamp_group_.timestamp = LatestTimestamp(
77 current_timestamp_group_.timestamp, timestamp); 71 current_timestamp_group_.timestamp, timestamp);
78 } 72 }
79 // Accumulate the frame size.
80 current_timestamp_group_.size += packet_size;
81 current_timestamp_group_.complete_time_ms = arrival_time_ms; 73 current_timestamp_group_.complete_time_ms = arrival_time_ms;
terelius 2015/10/12 12:04:40 = max(complete_time_ms, arrival_time_ms); maybe?
stefan-webrtc 2015/11/24 16:08:03 Done.
82 74
83 return calculated_deltas; 75 return calculated_deltas;
84 } 76 }
85 77
86 bool InterArrival::PacketInOrder(uint32_t timestamp) { 78 bool InterArrival::PacketInOrder(uint32_t timestamp) {
87 if (current_timestamp_group_.IsFirstPacket()) { 79 if (current_timestamp_group_.IsFirstPacket()) {
88 return true; 80 return true;
89 } else { 81 } else {
90 // Assume that a diff which is bigger than half the timestamp interval 82 // Assume that a diff which is bigger than half the timestamp interval
91 // (32 bits) must be due to reordering. This code is almost identical to 83 // (32 bits) must be due to reordering. This code is almost identical to
(...skipping 29 matching lines...) Expand all
121 current_timestamp_group_.complete_time_ms; 113 current_timestamp_group_.complete_time_ms;
122 uint32_t timestamp_diff = timestamp - current_timestamp_group_.timestamp; 114 uint32_t timestamp_diff = timestamp - current_timestamp_group_.timestamp;
123 int64_t ts_delta_ms = timestamp_to_ms_coeff_ * timestamp_diff + 0.5; 115 int64_t ts_delta_ms = timestamp_to_ms_coeff_ * timestamp_diff + 0.5;
124 if (ts_delta_ms == 0) 116 if (ts_delta_ms == 0)
125 return true; 117 return true;
126 int propagation_delta_ms = arrival_time_delta_ms - ts_delta_ms; 118 int propagation_delta_ms = arrival_time_delta_ms - ts_delta_ms;
127 return propagation_delta_ms < 0 && 119 return propagation_delta_ms < 0 &&
128 arrival_time_delta_ms <= kBurstDeltaThresholdMs; 120 arrival_time_delta_ms <= kBurstDeltaThresholdMs;
129 } 121 }
130 } // namespace webrtc 122 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698