Chromium Code Reviews| Index: webrtc/modules/remote_bitrate_estimator/overuse_estimator.cc |
| diff --git a/webrtc/modules/remote_bitrate_estimator/overuse_estimator.cc b/webrtc/modules/remote_bitrate_estimator/overuse_estimator.cc |
| index cf7df2673be3fb232ef33ed3a04056554203dc20..7ad23222fac9c095f18523f7f0916915e200fedc 100644 |
| --- a/webrtc/modules/remote_bitrate_estimator/overuse_estimator.cc |
| +++ b/webrtc/modules/remote_bitrate_estimator/overuse_estimator.cc |
| @@ -16,6 +16,7 @@ |
| #include <stdlib.h> |
| #include <string.h> |
| +#include "webrtc/base/checks.h" |
| #include "webrtc/modules/remote_bitrate_estimator/include/bwe_defines.h" |
| #include "webrtc/system_wrappers/interface/logging.h" |
| @@ -24,21 +25,15 @@ namespace webrtc { |
| enum { kMinFramePeriodHistoryLength = 60 }; |
| enum { kDeltaCounterMax = 1000 }; |
| -OveruseEstimator::OveruseEstimator(const OverUseDetectorOptions& options) |
| - : options_(options), |
| - num_of_deltas_(0), |
| - slope_(options_.initial_slope), |
| - offset_(options_.initial_offset), |
| - prev_offset_(options_.initial_offset), |
| - E_(), |
| - process_noise_(), |
| - avg_noise_(options_.initial_avg_noise), |
| - var_noise_(options_.initial_var_noise), |
| - ts_delta_hist_() { |
| - memcpy(E_, options_.initial_e, sizeof(E_)); |
| - memcpy(process_noise_, options_.initial_process_noise, |
| - sizeof(process_noise_)); |
| -} |
| +OveruseEstimator::OveruseEstimator() |
| + : num_of_deltas_(0), |
| + offset_(0), |
| + prev_offset_(offset_), |
| + e_(0.1), |
| + process_noise_(0.01), |
|
Gaetano Carlucci
2015/10/06 13:50:25
We can run some tests to verity this setting of th
stefan-webrtc
2015/11/24 16:08:03
We'll have to tune this, but for now I'll keep it
|
| + avg_noise_(0), |
| + var_noise_(50), |
| + ts_delta_hist_() {} |
| OveruseEstimator::~OveruseEstimator() { |
| ts_delta_hist_.clear(); |
| @@ -46,11 +41,9 @@ OveruseEstimator::~OveruseEstimator() { |
| void OveruseEstimator::Update(int64_t t_delta, |
| double ts_delta, |
|
terelius
2015/10/12 12:04:41
s/t_delta/recv_t_delta or something similar?
s/ts_
stefan-webrtc
2015/11/24 16:08:03
Done.
|
| - int size_delta, |
| BandwidthUsage current_hypothesis) { |
| const double min_frame_period = UpdateMinFramePeriod(ts_delta); |
| const double t_ts_delta = t_delta - ts_delta; |
| - double fs_delta = size_delta; |
| ++num_of_deltas_; |
| if (num_of_deltas_ > kDeltaCounterMax) { |
| @@ -58,19 +51,14 @@ void OveruseEstimator::Update(int64_t t_delta, |
| } |
| // Update the Kalman filter. |
| - E_[0][0] += process_noise_[0]; |
| - E_[1][1] += process_noise_[1]; |
| + e_ += process_noise_; |
| if ((current_hypothesis == kBwOverusing && offset_ < prev_offset_) || |
| (current_hypothesis == kBwUnderusing && offset_ > prev_offset_)) { |
| - E_[1][1] += 10 * process_noise_[1]; |
| + e_ += 10 * process_noise_; |
| } |
| - const double h[2] = {fs_delta, 1.0}; |
| - const double Eh[2] = {E_[0][0]*h[0] + E_[0][1]*h[1], |
| - E_[1][0]*h[0] + E_[1][1]*h[1]}; |
| - |
| - const double residual = t_ts_delta - slope_*h[0] - offset_; |
| + const double residual = t_ts_delta - offset_; |
| const bool in_stable_state = (current_hypothesis == kBwNormal); |
| const double max_residual = 3.0 * sqrt(var_noise_); |
| @@ -82,35 +70,17 @@ void OveruseEstimator::Update(int64_t t_delta, |
| UpdateNoiseEstimate(residual < 0 ? -max_residual : max_residual, |
| min_frame_period, in_stable_state); |
| } |
| - |
| - const double denom = var_noise_ + h[0]*Eh[0] + h[1]*Eh[1]; |
| - |
| - const double K[2] = {Eh[0] / denom, |
| - Eh[1] / denom}; |
| - |
| - const double IKh[2][2] = {{1.0 - K[0]*h[0], -K[0]*h[1]}, |
| - {-K[1]*h[0], 1.0 - K[1]*h[1]}}; |
| - const double e00 = E_[0][0]; |
| - const double e01 = E_[0][1]; |
| + const double k = e_ / (var_noise_ + e_); |
| // Update state. |
| - E_[0][0] = e00 * IKh[0][0] + E_[1][0] * IKh[0][1]; |
| - E_[0][1] = e01 * IKh[0][0] + E_[1][1] * IKh[0][1]; |
| - E_[1][0] = e00 * IKh[1][0] + E_[1][0] * IKh[1][1]; |
| - E_[1][1] = e01 * IKh[1][0] + E_[1][1] * IKh[1][1]; |
| - |
| - // The covariance matrix must be positive semi-definite. |
| - bool positive_semi_definite = E_[0][0] + E_[1][1] >= 0 && |
| - E_[0][0] * E_[1][1] - E_[0][1] * E_[1][0] >= 0 && E_[0][0] >= 0; |
| - assert(positive_semi_definite); |
| - if (!positive_semi_definite) { |
| - LOG(LS_ERROR) << "The over-use estimator's covariance matrix is no longer " |
| - "semi-definite."; |
| - } |
| + e_ = e_ * (1.0 - k); |
| + |
| + // The covariance matrix must be positive. |
| + RTC_DCHECK(e_ >= 0.0); |
| + if (e_ < 0) |
| + LOG(LS_ERROR) << "The over-use estimator's covariance is negative!"; |
| - slope_ = slope_ + K[0] * residual; |
| - prev_offset_ = offset_; |
| - offset_ = offset_ + K[1] * residual; |
| + offset_ = offset_ + k * residual; |
| } |
| double OveruseEstimator::UpdateMinFramePeriod(double ts_delta) { |