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

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

Issue 1219303002: Fix issue where the first audio packets significantly impacts initial BWE negatively. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Fix test. Created 5 years, 5 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) 2014 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2014 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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 void AimdRateControl::SetRtt(int64_t rtt) { 95 void AimdRateControl::SetRtt(int64_t rtt) {
96 rtt_ = rtt; 96 rtt_ = rtt;
97 } 97 }
98 98
99 void AimdRateControl::Update(const RateControlInput* input, int64_t now_ms) { 99 void AimdRateControl::Update(const RateControlInput* input, int64_t now_ms) {
100 assert(input); 100 assert(input);
101 101
102 // Set the initial bit rate value to what we're receiving the first half 102 // Set the initial bit rate value to what we're receiving the first half
103 // second. 103 // second.
104 if (!bitrate_is_initialized_) { 104 if (!bitrate_is_initialized_) {
105 const int64_t kInitializationTimeMs =
106 std::max<int64_t>(kBitrateWindowMs, 5000);
pbos-webrtc 2015/07/09 15:14:55 Just compile assert that kBitrateWindowMs < kIniti
stefan-webrtc 2015/07/09 15:24:27 Done.
105 if (time_first_incoming_estimate_ < 0) { 107 if (time_first_incoming_estimate_ < 0) {
106 if (input->_incomingBitRate > 0) { 108 if (input->_incomingBitRate > 0) {
107 time_first_incoming_estimate_ = now_ms; 109 time_first_incoming_estimate_ = now_ms;
108 } 110 }
109 } else if (now_ms - time_first_incoming_estimate_ > 500 && 111 } else if (now_ms - time_first_incoming_estimate_ > kInitializationTimeMs &&
110 input->_incomingBitRate > 0) { 112 input->_incomingBitRate > 0) {
111 current_bitrate_bps_ = input->_incomingBitRate; 113 current_bitrate_bps_ = input->_incomingBitRate;
112 bitrate_is_initialized_ = true; 114 bitrate_is_initialized_ = true;
113 } 115 }
114 } 116 }
115 117
116 if (updated_ && current_input_._bwState == kBwOverusing) { 118 if (updated_ && current_input_._bwState == kBwOverusing) {
117 // Only update delay factor and incoming bit rate. We always want to react 119 // Only update delay factor and incoming bit rate. We always want to react
118 // on an over-use. 120 // on an over-use.
119 current_input_._noiseVar = input->_noiseVar; 121 current_input_._noiseVar = input->_noiseVar;
120 current_input_._incomingBitRate = input->_incomingBitRate; 122 current_input_._incomingBitRate = input->_incomingBitRate;
121 } else { 123 } else {
122 updated_ = true; 124 updated_ = true;
123 current_input_ = *input; 125 current_input_ = *input;
124 } 126 }
125 } 127 }
126 128
127 void AimdRateControl::SetEstimate(int bitrate_bps, int64_t now_ms) { 129 void AimdRateControl::SetEstimate(int bitrate_bps, int64_t now_ms) {
128 updated_ = true; 130 updated_ = true;
129 bitrate_is_initialized_ = true; 131 bitrate_is_initialized_ = true;
130 current_bitrate_bps_ = ChangeBitrate(bitrate_bps, bitrate_bps, now_ms); 132 current_bitrate_bps_ = ChangeBitrate(bitrate_bps, bitrate_bps, now_ms);
131 } 133 }
132 134
133 uint32_t AimdRateControl::ChangeBitrate(uint32_t current_bitrate_bps, 135 uint32_t AimdRateControl::ChangeBitrate(uint32_t current_bitrate_bps,
134 uint32_t incoming_bitrate_bps, 136 uint32_t incoming_bitrate_bps,
135 int64_t now_ms) { 137 int64_t now_ms) {
136 if (!updated_) { 138 if (!updated_) {
137 return current_bitrate_bps_; 139 return current_bitrate_bps_;
138 } 140 }
141 if (!bitrate_is_initialized_ && current_input_._bwState != kBwOverusing) {
pbos-webrtc 2015/07/09 15:14:55 remove {}s comment that we pass this if we're ove
142 return current_bitrate_bps_;
143 }
139 updated_ = false; 144 updated_ = false;
140 ChangeState(current_input_, now_ms); 145 ChangeState(current_input_, now_ms);
141 // Calculated here because it's used in multiple places. 146 // Calculated here because it's used in multiple places.
142 const float incoming_bitrate_kbps = incoming_bitrate_bps / 1000.0f; 147 const float incoming_bitrate_kbps = incoming_bitrate_bps / 1000.0f;
143 // Calculate the max bit rate std dev given the normalized 148 // Calculate the max bit rate std dev given the normalized
144 // variance and the current incoming bit rate. 149 // variance and the current incoming bit rate.
145 const float std_max_bit_rate = sqrt(var_max_bitrate_kbps_ * 150 const float std_max_bit_rate = sqrt(var_max_bitrate_kbps_ *
146 avg_max_bitrate_kbps_); 151 avg_max_bitrate_kbps_);
147 switch (rate_control_state_) { 152 switch (rate_control_state_) {
148 case kRcHold: 153 case kRcHold:
(...skipping 16 matching lines...) Expand all
165 } else { 170 } else {
166 uint32_t multiplicative_increase_bps = MultiplicativeRateIncrease( 171 uint32_t multiplicative_increase_bps = MultiplicativeRateIncrease(
167 now_ms, time_last_bitrate_change_, current_bitrate_bps); 172 now_ms, time_last_bitrate_change_, current_bitrate_bps);
168 current_bitrate_bps += multiplicative_increase_bps; 173 current_bitrate_bps += multiplicative_increase_bps;
169 } 174 }
170 175
171 time_last_bitrate_change_ = now_ms; 176 time_last_bitrate_change_ = now_ms;
172 break; 177 break;
173 178
174 case kRcDecrease: 179 case kRcDecrease:
180 bitrate_is_initialized_ = true;
175 if (incoming_bitrate_bps < min_configured_bitrate_bps_) { 181 if (incoming_bitrate_bps < min_configured_bitrate_bps_) {
176 current_bitrate_bps = min_configured_bitrate_bps_; 182 current_bitrate_bps = min_configured_bitrate_bps_;
177 } else { 183 } else {
178 // Set bit rate to something slightly lower than max 184 // Set bit rate to something slightly lower than max
179 // to get rid of any self-induced delay. 185 // to get rid of any self-induced delay.
180 current_bitrate_bps = static_cast<uint32_t>(beta_ * 186 current_bitrate_bps = static_cast<uint32_t>(beta_ *
181 incoming_bitrate_bps + 0.5); 187 incoming_bitrate_bps + 0.5);
182 if (current_bitrate_bps > current_bitrate_bps_) { 188 if (current_bitrate_bps > current_bitrate_bps_) {
183 // Avoid increasing the rate when over-using. 189 // Avoid increasing the rate when over-using.
184 if (rate_control_region_ != kRcMaxUnknown) { 190 if (rate_control_region_ != kRcMaxUnknown) {
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 } 299 }
294 300
295 void AimdRateControl::ChangeRegion(RateControlRegion region) { 301 void AimdRateControl::ChangeRegion(RateControlRegion region) {
296 rate_control_region_ = region; 302 rate_control_region_ = region;
297 } 303 }
298 304
299 void AimdRateControl::ChangeState(RateControlState new_state) { 305 void AimdRateControl::ChangeState(RateControlState new_state) {
300 rate_control_state_ = new_state; 306 rate_control_state_ = new_state;
301 } 307 }
302 } // namespace webrtc 308 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698