revert r3871
TBR= solenberg@webrtc.org Review URL: https://webrtc-codereview.appspot.com/1331004 git-svn-id: http://webrtc.googlecode.com/svn/trunk@3872 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
parent
9756017717
commit
a73d52ca52
@ -13,6 +13,9 @@
|
||||
|
||||
#include "typedefs.h"
|
||||
|
||||
#define BWE_MAX(a,b) ((a)>(b)?(a):(b))
|
||||
#define BWE_MIN(a,b) ((a)<(b)?(a):(b))
|
||||
|
||||
namespace webrtc {
|
||||
enum BandwidthUsage
|
||||
{
|
||||
|
@ -8,7 +8,6 @@
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#include <algorithm>
|
||||
#include <math.h>
|
||||
#include <stdlib.h> // fabsf
|
||||
#if _WIN32
|
||||
@ -27,10 +26,6 @@ extern MatlabEngine eng; // global variable defined elsewhere
|
||||
enum { kOverUsingTimeThreshold = 100 };
|
||||
enum { kMinFramePeriodHistoryLength = 60 };
|
||||
|
||||
namespace {
|
||||
const uint16_t kMaxDeltas = 60;
|
||||
}
|
||||
|
||||
namespace webrtc {
|
||||
OveruseDetector::OveruseDetector(const OverUseDetectorOptions& options)
|
||||
: options_(options),
|
||||
@ -254,7 +249,7 @@ void OveruseDetector::UpdateKalman(int64_t t_delta,
|
||||
const double residual = t_ts_delta - slope_*h[0] - offset_;
|
||||
|
||||
const bool stable_state =
|
||||
(std::min(num_of_deltas_, kMaxDeltas) * fabsf(offset_) < threshold_);
|
||||
(BWE_MIN(num_of_deltas_, 60) * fabsf(offset_) < threshold_);
|
||||
// We try to filter out very late frames. For instance periodic key
|
||||
// frames doesn't fit the Gaussian model well.
|
||||
if (fabsf(residual) < 3 * sqrt(var_noise_)) {
|
||||
@ -311,8 +306,7 @@ void OveruseDetector::UpdateKalman(int64_t t_delta,
|
||||
plots_.plot1_->Plot();
|
||||
|
||||
plots_.plot2_->Append("offset", offset_);
|
||||
plots_.plot2_->Append("limitPos", threshold_ /
|
||||
std::min(num_of_deltas_, kMaxDeltas));
|
||||
plots_.plot2_->Append("limitPos", threshold_/BWE_MIN(num_of_deltas_, 60));
|
||||
plots_.plot2_->Plot();
|
||||
|
||||
plots_.plot3_->Append("noiseVar", var_noise_);
|
||||
@ -328,7 +322,7 @@ double OveruseDetector::UpdateMinFramePeriod(double ts_delta) {
|
||||
}
|
||||
std::list<double>::iterator it = ts_delta_hist_.begin();
|
||||
for (; it != ts_delta_hist_.end(); it++) {
|
||||
min_frame_period = std::min(*it, min_frame_period);
|
||||
min_frame_period = BWE_MIN(*it, min_frame_period);
|
||||
}
|
||||
ts_delta_hist_.push_back(ts_delta);
|
||||
return min_frame_period;
|
||||
@ -363,7 +357,7 @@ BandwidthUsage OveruseDetector::Detect(double ts_delta) {
|
||||
if (num_of_deltas_ < 2) {
|
||||
return kBwNormal;
|
||||
}
|
||||
const double T = std::min(num_of_deltas_, kMaxDeltas) * offset_;
|
||||
const double T = BWE_MIN(num_of_deltas_, 60) * offset_;
|
||||
if (fabsf(T) > threshold_) {
|
||||
if (offset_ > 0) {
|
||||
if (time_over_using_ == -1) {
|
||||
|
@ -35,15 +35,13 @@ class RemoteBitrateEstimatorMultiStream : public RemoteBitrateEstimator {
|
||||
RemoteBitrateObserver* observer,
|
||||
Clock* clock);
|
||||
|
||||
virtual ~RemoteBitrateEstimatorMultiStream() {}
|
||||
~RemoteBitrateEstimatorMultiStream() {}
|
||||
|
||||
// Stores an RTCP SR (NTP, RTP timestamp) tuple for a specific SSRC to be used
|
||||
// in future RTP timestamp to NTP time conversions. As soon as any SSRC has
|
||||
// two tuples the RemoteBitrateEstimator will switch to multi-stream mode.
|
||||
virtual void IncomingRtcp(unsigned int ssrc,
|
||||
uint32_t ntp_secs,
|
||||
uint32_t ntp_frac,
|
||||
uint32_t rtp_timestamp);
|
||||
void IncomingRtcp(unsigned int ssrc, uint32_t ntp_secs, uint32_t ntp_frac,
|
||||
uint32_t rtp_timestamp);
|
||||
|
||||
// Called for each incoming packet. The first SSRC will immediately be used
|
||||
// for over-use detection. Subsequent SSRCs will only be used when at least
|
||||
@ -51,10 +49,10 @@ class RemoteBitrateEstimatorMultiStream : public RemoteBitrateEstimator {
|
||||
// incoming payload bitrate estimate and the over-use detector.
|
||||
// If an over-use is detected the remote bitrate estimate will be updated.
|
||||
// Note that |payload_size| is the packet size excluding headers.
|
||||
virtual void IncomingPacket(unsigned int ssrc,
|
||||
int payload_size,
|
||||
int64_t arrival_time,
|
||||
uint32_t rtp_timestamp);
|
||||
void IncomingPacket(unsigned int ssrc,
|
||||
int payload_size,
|
||||
int64_t arrival_time,
|
||||
uint32_t rtp_timestamp);
|
||||
|
||||
// Triggers a new estimate calculation.
|
||||
// Implements the Module interface.
|
||||
@ -65,13 +63,13 @@ class RemoteBitrateEstimatorMultiStream : public RemoteBitrateEstimator {
|
||||
virtual void OnRttUpdate(uint32_t rtt);
|
||||
|
||||
// Removes all data for |ssrc|.
|
||||
virtual void RemoveStream(unsigned int ssrc);
|
||||
void RemoveStream(unsigned int ssrc);
|
||||
|
||||
// Returns true if a valid estimate exists and sets |bitrate_bps| to the
|
||||
// estimated payload bitrate in bits per second. |ssrcs| is the list of ssrcs
|
||||
// currently being received and of which the bitrate estimate is based upon.
|
||||
virtual bool LatestEstimate(std::vector<unsigned int>* ssrcs,
|
||||
unsigned int* bitrate_bps) const;
|
||||
bool LatestEstimate(std::vector<unsigned int>* ssrcs,
|
||||
unsigned int* bitrate_bps) const;
|
||||
|
||||
private:
|
||||
typedef std::map<unsigned int, synchronization::RtcpList> StreamMap;
|
||||
|
@ -35,20 +35,18 @@ class RemoteBitrateEstimatorSingleStream : public RemoteBitrateEstimator {
|
||||
|
||||
virtual ~RemoteBitrateEstimatorSingleStream() {}
|
||||
|
||||
virtual void IncomingRtcp(unsigned int ssrc,
|
||||
uint32_t ntp_secs,
|
||||
uint32_t ntp_frac,
|
||||
uint32_t rtp_timestamp) {}
|
||||
void IncomingRtcp(unsigned int ssrc, uint32_t ntp_secs, uint32_t ntp_frac,
|
||||
uint32_t rtp_timestamp) {}
|
||||
|
||||
// Called for each incoming packet. If this is a new SSRC, a new
|
||||
// BitrateControl will be created. Updates the incoming payload bitrate
|
||||
// estimate and the over-use detector. If an over-use is detected the
|
||||
// remote bitrate estimate will be updated. Note that |payload_size| is the
|
||||
// packet size excluding headers.
|
||||
virtual void IncomingPacket(unsigned int ssrc,
|
||||
int payload_size,
|
||||
int64_t arrival_time,
|
||||
uint32_t rtp_timestamp);
|
||||
void IncomingPacket(unsigned int ssrc,
|
||||
int payload_size,
|
||||
int64_t arrival_time,
|
||||
uint32_t rtp_timestamp);
|
||||
|
||||
// Triggers a new estimate calculation.
|
||||
// Implements the Module interface.
|
||||
@ -59,13 +57,13 @@ class RemoteBitrateEstimatorSingleStream : public RemoteBitrateEstimator {
|
||||
virtual void OnRttUpdate(uint32_t rtt);
|
||||
|
||||
// Removes all data for |ssrc|.
|
||||
virtual void RemoveStream(unsigned int ssrc);
|
||||
void RemoveStream(unsigned int ssrc);
|
||||
|
||||
// Returns true if a valid estimate exists and sets |bitrate_bps| to the
|
||||
// estimated payload bitrate in bits per second. |ssrcs| is the list of ssrcs
|
||||
// currently being received and of which the bitrate estimate is based upon.
|
||||
virtual bool LatestEstimate(std::vector<unsigned int>* ssrcs,
|
||||
unsigned int* bitrate_bps) const;
|
||||
bool LatestEstimate(std::vector<unsigned int>* ssrcs,
|
||||
unsigned int* bitrate_bps) const;
|
||||
|
||||
private:
|
||||
typedef std::map<unsigned int, OveruseDetector> SsrcOveruseDetectorMap;
|
||||
|
@ -10,7 +10,6 @@
|
||||
|
||||
#include "modules/remote_bitrate_estimator/remote_rate_control.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <assert.h>
|
||||
#include <math.h>
|
||||
#include <string.h>
|
||||
@ -92,7 +91,7 @@ bool RemoteRateControl::ValidEstimate() const {
|
||||
|
||||
bool RemoteRateControl::TimeToReduceFurther(
|
||||
int64_t time_now, unsigned int incoming_bitrate) const {
|
||||
const int bitrate_reduction_interval = std::max(std::min(_rtt, 200u), 10u);
|
||||
const int bitrate_reduction_interval = BWE_MAX(BWE_MIN(_rtt, 200), 10);
|
||||
if (time_now - _lastBitRateChange >= bitrate_reduction_interval) {
|
||||
return true;
|
||||
}
|
||||
@ -113,7 +112,7 @@ int32_t RemoteRateControl::SetConfiguredBitRates(
|
||||
}
|
||||
_minConfiguredBitRate = minBitRateBps;
|
||||
_maxConfiguredBitRate = maxBitRateBps;
|
||||
_currentBitRate = std::min(std::max(minBitRateBps, _currentBitRate),
|
||||
_currentBitRate = BWE_MIN(BWE_MAX(minBitRateBps, _currentBitRate),
|
||||
maxBitRateBps);
|
||||
return 0;
|
||||
}
|
||||
@ -215,7 +214,7 @@ uint32_t RemoteRateControl::ChangeBitRate(uint32_t currentBitRate,
|
||||
{
|
||||
case kRcHold:
|
||||
{
|
||||
_maxHoldRate = std::max(_maxHoldRate, incomingBitRate);
|
||||
_maxHoldRate = BWE_MAX(_maxHoldRate, incomingBitRate);
|
||||
break;
|
||||
}
|
||||
case kRcIncrease:
|
||||
@ -277,7 +276,7 @@ uint32_t RemoteRateControl::ChangeBitRate(uint32_t currentBitRate,
|
||||
{
|
||||
currentBitRate = static_cast<uint32_t>(_beta * _avgMaxBitRate * 1000 + 0.5f);
|
||||
}
|
||||
currentBitRate = std::min(currentBitRate, _currentBitRate);
|
||||
currentBitRate = BWE_MIN(currentBitRate, _currentBitRate);
|
||||
}
|
||||
ChangeRegion(kRcNearMax);
|
||||
|
||||
@ -394,7 +393,7 @@ void RemoteRateControl::UpdateMaxBitRateEstimate(float incomingBitRateKbps)
|
||||
}
|
||||
// Estimate the max bit rate variance and normalize the variance
|
||||
// with the average max bit rate.
|
||||
const float norm = std::max(_avgMaxBitRate, 1.0f);
|
||||
const float norm = BWE_MAX(_avgMaxBitRate, 1.0f);
|
||||
_varMaxBitRate = (1 - alpha) * _varMaxBitRate +
|
||||
alpha * (_avgMaxBitRate - incomingBitRateKbps) *
|
||||
(_avgMaxBitRate - incomingBitRateKbps) /
|
||||
|
Loading…
x
Reference in New Issue
Block a user