Index: webrtc/modules/remote_bitrate_estimator/aimd_rate_control.cc |
diff --git a/webrtc/modules/remote_bitrate_estimator/aimd_rate_control.cc b/webrtc/modules/remote_bitrate_estimator/aimd_rate_control.cc |
index a1a9baf352038d29de47caba122cc98c2d73935f..ceea21e41b196f3c43f54eda2dc488c0d74d1646 100644 |
--- a/webrtc/modules/remote_bitrate_estimator/aimd_rate_control.cc |
+++ b/webrtc/modules/remote_bitrate_estimator/aimd_rate_control.cc |
@@ -26,20 +26,19 @@ AimdRateControl::AimdRateControl(uint32_t min_bitrate_bps) |
: min_configured_bitrate_bps_(min_bitrate_bps), |
max_configured_bitrate_bps_(30000000), |
current_bitrate_bps_(max_configured_bitrate_bps_), |
- max_hold_rate_bps_(0), |
avg_max_bitrate_kbps_(-1.0f), |
var_max_bitrate_kbps_(0.4f), |
rate_control_state_(kRcHold), |
- came_from_state_(kRcDecrease), |
rate_control_region_(kRcMaxUnknown), |
time_last_bitrate_change_(-1), |
current_input_(kBwNormal, 0, 1.0), |
updated_(false), |
time_first_incoming_estimate_(-1), |
bitrate_is_initialized_(false), |
- beta_(0.9f), |
+ beta_(0.85f), |
rtt_(kDefaultRttMs), |
- time_of_last_log_(-1) {} |
+ time_of_last_log_(-1) { |
+} |
RateControlType AimdRateControl::GetControlType() const { |
return kAimdControl; |
@@ -98,8 +97,7 @@ void AimdRateControl::SetRtt(int64_t rtt) { |
rtt_ = rtt; |
} |
-RateControlRegion AimdRateControl::Update(const RateControlInput* input, |
- int64_t now_ms) { |
+void AimdRateControl::Update(const RateControlInput* input, int64_t now_ms) { |
assert(input); |
// Set the initial bit rate value to what we're receiving the first half |
@@ -125,7 +123,6 @@ RateControlRegion AimdRateControl::Update(const RateControlInput* input, |
updated_ = true; |
current_input_ = *input; |
} |
- return rate_control_region_; |
} |
void AimdRateControl::SetEstimate(int bitrate_bps, int64_t now_ms) { |
@@ -148,22 +145,16 @@ uint32_t AimdRateControl::ChangeBitrate(uint32_t current_bitrate_bps, |
// variance and the current incoming bit rate. |
const float std_max_bit_rate = sqrt(var_max_bitrate_kbps_ * |
avg_max_bitrate_kbps_); |
- bool fast_recovery_after_hold = false; |
switch (rate_control_state_) { |
- case kRcHold: { |
- max_hold_rate_bps_ = std::max(max_hold_rate_bps_, incoming_bitrate_bps); |
+ case kRcHold: |
break; |
- } |
- case kRcIncrease: { |
- if (avg_max_bitrate_kbps_ >= 0) { |
- if (incoming_bitrate_kbps > avg_max_bitrate_kbps_ + |
+ |
+ case kRcIncrease: |
+ if (avg_max_bitrate_kbps_ >= 0 && |
+ incoming_bitrate_kbps > avg_max_bitrate_kbps_ + |
3 * std_max_bit_rate) { |
- ChangeRegion(kRcMaxUnknown); |
- avg_max_bitrate_kbps_ = -1.0; |
- } else if (incoming_bitrate_kbps > avg_max_bitrate_kbps_ + |
- 2.5 * std_max_bit_rate) { |
- ChangeRegion(kRcAboveMax); |
- } |
+ ChangeRegion(kRcMaxUnknown); |
+ avg_max_bitrate_kbps_ = -1.0; |
} |
mflodman
2015/07/03 08:29:55
Why was the kRcAboveMax removed?
Gaetano Carlucci
2015/07/03 10:54:28
kRcNearMax, kRcAboveMax and kRcMaxUnknown were int
stefan-webrtc
2015/07/03 13:45:10
We decided to simplify back-off and have the back-
|
if (rate_control_region_ == kRcNearMax) { |
// Approximate the over-use estimator delay to 100 ms. |
@@ -178,18 +169,10 @@ uint32_t AimdRateControl::ChangeBitrate(uint32_t current_bitrate_bps, |
current_bitrate_bps += multiplicative_increase_bps; |
} |
- if (max_hold_rate_bps_ > 0 && |
- beta_ * max_hold_rate_bps_ > current_bitrate_bps) { |
- current_bitrate_bps = static_cast<uint32_t>(beta_ * max_hold_rate_bps_); |
- avg_max_bitrate_kbps_ = beta_ * max_hold_rate_bps_ / 1000.0f; |
- ChangeRegion(kRcNearMax); |
- fast_recovery_after_hold = true; |
- } |
- max_hold_rate_bps_ = 0; |
time_last_bitrate_change_ = now_ms; |
break; |
- } |
- case kRcDecrease: { |
+ |
+ case kRcDecrease: |
if (incoming_bitrate_bps < min_configured_bitrate_bps_) { |
current_bitrate_bps = min_configured_bitrate_bps_; |
} else { |
@@ -219,12 +202,11 @@ uint32_t AimdRateControl::ChangeBitrate(uint32_t current_bitrate_bps, |
ChangeState(kRcHold); |
time_last_bitrate_change_ = now_ms; |
break; |
- } |
+ |
default: |
assert(false); |
} |
- if (!fast_recovery_after_hold && (incoming_bitrate_bps > 100000 || |
- current_bitrate_bps > 150000) && |
+ if ((incoming_bitrate_bps > 100000 || current_bitrate_bps > 150000) && |
current_bitrate_bps > 1.5 * incoming_bitrate_bps) { |
// Allow changing the bit rate if we are operating at very low rates |
// Don't change the bit rate if the send side is too far off |
@@ -252,8 +234,9 @@ uint32_t AimdRateControl::AdditiveRateIncrease( |
assert(response_time_ms > 0); |
double beta = 0.0; |
if (last_ms > 0) { |
- beta = std::min((now_ms - last_ms) / |
- static_cast<double>(response_time_ms), 1.0); |
+ beta = 0.5 * |
+ std::min((now_ms - last_ms) / static_cast<double>(response_time_ms), |
+ 1.0); |
} |
double bits_per_frame = static_cast<double>(current_bitrate_bps_) / 30.0; |
double packets_per_frame = std::ceil(bits_per_frame / (8.0 * 1200.0)); |
@@ -311,21 +294,9 @@ void AimdRateControl::ChangeState(const RateControlInput& input, |
void AimdRateControl::ChangeRegion(RateControlRegion region) { |
rate_control_region_ = region; |
- switch (rate_control_region_) { |
- case kRcAboveMax: |
- case kRcMaxUnknown: |
- beta_ = 0.9f; |
- break; |
- case kRcNearMax: |
- beta_ = 0.95f; |
- break; |
- default: |
- assert(false); |
- } |
} |
void AimdRateControl::ChangeState(RateControlState new_state) { |
- came_from_state_ = rate_control_state_; |
rate_control_state_ = new_state; |
} |
} // namespace webrtc |