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

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

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

Powered by Google App Engine
This is Rietveld 408576698