Remove streaming_mode as it is always false.

Change-Id: I489b72985f36fd98413ecf729f7d69476c342851

Bug: webrtc:10618
Change-Id: I489b72985f36fd98413ecf729f7d69476c342851
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/136803
Reviewed-by: Jakob Ivarsson‎ <jakobi@webrtc.org>
Reviewed-by: Henrik Lundin <henrik.lundin@webrtc.org>
Commit-Queue: Ruslan Burakov <kuddai@google.com>
Cr-Commit-Position: refs/heads/master@{#27948}
This commit is contained in:
Ruslan Burakov
2019-05-14 18:06:52 +02:00
committed by Commit Bot
parent 4fd42974b1
commit 0ac1d993be
5 changed files with 1 additions and 66 deletions

View File

@ -66,7 +66,6 @@ DecisionLogic::DecisionLogic(int fs_hz,
timescale_countdown_( timescale_countdown_(
tick_timer_->GetNewCountdown(kMinTimescaleInterval + 1)), tick_timer_->GetNewCountdown(kMinTimescaleInterval + 1)),
num_consecutive_expands_(0) { num_consecutive_expands_(0) {
delay_manager_->set_streaming_mode(false);
SetSampleRate(fs_hz, output_size_samples); SetSampleRate(fs_hz, output_size_samples);
} }

View File

@ -31,10 +31,6 @@
namespace { namespace {
constexpr int kLimitProbability = 1020054733; // 19/20 in Q30. constexpr int kLimitProbability = 1020054733; // 19/20 in Q30.
constexpr int kLimitProbabilityStreaming = 1073204953; // 1999/2000 in Q30.
constexpr int kMaxStreamingPeakPeriodMs = 600000; // 10 minutes in ms.
constexpr int kCumulativeSumDrift = 2; // Drift term for cumulative sum
// |iat_cumulative_sum_|.
constexpr int kMinBaseMinimumDelayMs = 0; constexpr int kMinBaseMinimumDelayMs = 0;
constexpr int kMaxBaseMinimumDelayMs = 10000; constexpr int kMaxBaseMinimumDelayMs = 10000;
constexpr int kIatFactor = 32745; // 0.9993 in Q15. constexpr int kIatFactor = 32745; // 0.9993 in Q15.
@ -129,13 +125,10 @@ DelayManager::DelayManager(size_t max_packets_in_buffer,
base_target_level_(4), // In Q0 domain. base_target_level_(4), // In Q0 domain.
target_level_(base_target_level_ << 8), // In Q8 domain. target_level_(base_target_level_ << 8), // In Q8 domain.
packet_len_ms_(0), packet_len_ms_(0),
streaming_mode_(false),
last_seq_no_(0), last_seq_no_(0),
last_timestamp_(0), last_timestamp_(0),
minimum_delay_ms_(0), minimum_delay_ms_(0),
maximum_delay_ms_(0), maximum_delay_ms_(0),
iat_cumulative_sum_(0),
max_iat_cumulative_sum_(0),
peak_detector_(*peak_detector), peak_detector_(*peak_detector),
last_pack_cng_or_dtmf_(1), last_pack_cng_or_dtmf_(1),
frame_length_change_experiment_( frame_length_change_experiment_(
@ -212,9 +205,6 @@ int DelayManager::Update(uint16_t sequence_number,
bool reordered = false; bool reordered = false;
if (packet_len_ms > 0) { if (packet_len_ms > 0) {
// Cannot update statistics unless |packet_len_ms| is valid. // Cannot update statistics unless |packet_len_ms| is valid.
if (streaming_mode_) {
UpdateCumulativeSums(packet_len_ms, sequence_number);
}
// Inter-arrival time (IAT) in integer "packet times" (rounding down). This // Inter-arrival time (IAT) in integer "packet times" (rounding down). This
// is the value added to the inter-arrival time histogram. // is the value added to the inter-arrival time histogram.
@ -265,9 +255,6 @@ int DelayManager::Update(uint16_t sequence_number,
} }
// Calculate new |target_level_| based on updated statistics. // Calculate new |target_level_| based on updated statistics.
target_level_ = CalculateTargetLevel(iat_packets, reordered); target_level_ = CalculateTargetLevel(iat_packets, reordered);
if (streaming_mode_) {
target_level_ = std::max(target_level_, max_iat_cumulative_sum_);
}
LimitTargetLevel(); LimitTargetLevel();
} // End if (packet_len_ms > 0). } // End if (packet_len_ms > 0).
@ -305,32 +292,6 @@ int DelayManager::CalculateRelativePacketArrivalDelay() const {
return relative_delay; return relative_delay;
} }
void DelayManager::UpdateCumulativeSums(int packet_len_ms,
uint16_t sequence_number) {
// Calculate IAT in Q8, including fractions of a packet (i.e., more
// accurate than |iat_packets|.
int iat_packets_q8 =
(packet_iat_stopwatch_->ElapsedMs() << 8) / packet_len_ms;
// Calculate cumulative sum IAT with sequence number compensation. The sum
// is zero if there is no clock-drift.
iat_cumulative_sum_ +=
(iat_packets_q8 -
(static_cast<int>(sequence_number - last_seq_no_) << 8));
// Subtract drift term.
iat_cumulative_sum_ -= kCumulativeSumDrift;
// Ensure not negative.
iat_cumulative_sum_ = std::max(iat_cumulative_sum_, 0);
if (iat_cumulative_sum_ > max_iat_cumulative_sum_) {
// Found a new maximum.
max_iat_cumulative_sum_ = iat_cumulative_sum_;
max_iat_stopwatch_ = tick_timer_->GetNewStopwatch();
}
if (max_iat_stopwatch_->ElapsedMs() > kMaxStreamingPeakPeriodMs) {
// Too long since the last maximum was observed; decrease max value.
max_iat_cumulative_sum_ -= kCumulativeSumDrift;
}
}
// Enforces upper and lower limits for |target_level_|. The upper limit is // Enforces upper and lower limits for |target_level_|. The upper limit is
// chosen to be minimum of i) 75% of |max_packets_in_buffer_|, to leave some // chosen to be minimum of i) 75% of |max_packets_in_buffer_|, to leave some
// headroom for natural fluctuations around the target, and ii) equivalent of // headroom for natural fluctuations around the target, and ii) equivalent of
@ -363,9 +324,6 @@ void DelayManager::LimitTargetLevel() {
int DelayManager::CalculateTargetLevel(int iat_packets, bool reordered) { int DelayManager::CalculateTargetLevel(int iat_packets, bool reordered) {
int limit_probability = histogram_quantile_; int limit_probability = histogram_quantile_;
if (streaming_mode_) {
limit_probability = kLimitProbabilityStreaming;
}
int bucket_index = histogram_->Quantile(limit_probability); int bucket_index = histogram_->Quantile(limit_probability);
int target_level; int target_level;
@ -415,15 +373,11 @@ int DelayManager::SetPacketAudioLength(int length_ms) {
void DelayManager::Reset() { void DelayManager::Reset() {
packet_len_ms_ = 0; // Packet size unknown. packet_len_ms_ = 0; // Packet size unknown.
streaming_mode_ = false;
peak_detector_.Reset(); peak_detector_.Reset();
histogram_->Reset(); histogram_->Reset();
base_target_level_ = 4; base_target_level_ = 4;
target_level_ = base_target_level_ << 8; target_level_ = base_target_level_ << 8;
packet_iat_stopwatch_ = tick_timer_->GetNewStopwatch(); packet_iat_stopwatch_ = tick_timer_->GetNewStopwatch();
max_iat_stopwatch_ = tick_timer_->GetNewStopwatch();
iat_cumulative_sum_ = 0;
max_iat_cumulative_sum_ = 0;
last_pack_cng_or_dtmf_ = 1; last_pack_cng_or_dtmf_ = 1;
} }
@ -538,9 +492,6 @@ int DelayManager::GetBaseMinimumDelay() const {
int DelayManager::base_target_level() const { int DelayManager::base_target_level() const {
return base_target_level_; return base_target_level_;
} }
void DelayManager::set_streaming_mode(bool value) {
streaming_mode_ = value;
}
int DelayManager::last_pack_cng_or_dtmf() const { int DelayManager::last_pack_cng_or_dtmf() const {
return last_pack_cng_or_dtmf_; return last_pack_cng_or_dtmf_;
} }

View File

@ -102,8 +102,7 @@ class DelayManager {
// packets in Q8. // packets in Q8.
virtual void BufferLimits(int* lower_limit, int* higher_limit) const; virtual void BufferLimits(int* lower_limit, int* higher_limit) const;
// Gets the target buffer level, in (fractions of) packets in Q8. This value // Gets the target buffer level, in (fractions of) packets in Q8.
// includes any extra delay set through the set_extra_delay_ms() method.
virtual int TargetLevel() const; virtual int TargetLevel() const;
// Informs the delay manager whether or not the last decoded packet contained // Informs the delay manager whether or not the last decoded packet contained
@ -122,7 +121,6 @@ class DelayManager {
virtual bool SetBaseMinimumDelay(int delay_ms); virtual bool SetBaseMinimumDelay(int delay_ms);
virtual int GetBaseMinimumDelay() const; virtual int GetBaseMinimumDelay() const;
virtual int base_target_level() const; virtual int base_target_level() const;
virtual void set_streaming_mode(bool value);
virtual int last_pack_cng_or_dtmf() const; virtual int last_pack_cng_or_dtmf() const;
virtual void set_last_pack_cng_or_dtmf(int value); virtual void set_last_pack_cng_or_dtmf(int value);
@ -150,10 +148,6 @@ class DelayManager {
// Calculate relative packet arrival delay from |delay_history_|. // Calculate relative packet arrival delay from |delay_history_|.
int CalculateRelativePacketArrivalDelay() const; int CalculateRelativePacketArrivalDelay() const;
// Updates |iat_cumulative_sum_| and |max_iat_cumulative_sum_|. (These are
// used by the streaming mode.) This method is called by Update().
void UpdateCumulativeSums(int packet_len_ms, uint16_t sequence_number);
// Updates |effective_minimum_delay_ms_| delay based on current // Updates |effective_minimum_delay_ms_| delay based on current
// |minimum_delay_ms_|, |base_minimum_delay_ms_| and |maximum_delay_ms_| // |minimum_delay_ms_|, |base_minimum_delay_ms_| and |maximum_delay_ms_|
// and buffer size. // and buffer size.
@ -192,15 +186,10 @@ class DelayManager {
int target_level_; // Currently preferred buffer level in (fractions) int target_level_; // Currently preferred buffer level in (fractions)
// of packets (Q8), before adding any extra delay. // of packets (Q8), before adding any extra delay.
int packet_len_ms_; // Length of audio in each incoming packet [ms]. int packet_len_ms_; // Length of audio in each incoming packet [ms].
bool streaming_mode_;
uint16_t last_seq_no_; // Sequence number for last received packet. uint16_t last_seq_no_; // Sequence number for last received packet.
uint32_t last_timestamp_; // Timestamp for the last received packet. uint32_t last_timestamp_; // Timestamp for the last received packet.
int minimum_delay_ms_; // Externally set minimum delay. int minimum_delay_ms_; // Externally set minimum delay.
int maximum_delay_ms_; // Externally set maximum allowed delay. int maximum_delay_ms_; // Externally set maximum allowed delay.
int iat_cumulative_sum_; // Cumulative sum of delta inter-arrival times.
int max_iat_cumulative_sum_; // Max of |iat_cumulative_sum_|.
// Time elapsed since maximum was observed.
std::unique_ptr<TickTimer::Stopwatch> max_iat_stopwatch_;
DelayPeakDetector& peak_detector_; DelayPeakDetector& peak_detector_;
int last_pack_cng_or_dtmf_; int last_pack_cng_or_dtmf_;
const bool frame_length_change_experiment_; const bool frame_length_change_experiment_;

View File

@ -50,16 +50,13 @@ class MockDelayManager : public DelayManager {
MOCK_METHOD1(SetPacketAudioLength, int(int length_ms)); MOCK_METHOD1(SetPacketAudioLength, int(int length_ms));
MOCK_METHOD0(Reset, void()); MOCK_METHOD0(Reset, void());
MOCK_CONST_METHOD0(PeakFound, bool()); MOCK_CONST_METHOD0(PeakFound, bool());
MOCK_METHOD1(UpdateCounters, void(int elapsed_time_ms));
MOCK_METHOD0(ResetPacketIatCount, void()); MOCK_METHOD0(ResetPacketIatCount, void());
MOCK_CONST_METHOD2(BufferLimits, void(int* lower_limit, int* higher_limit)); MOCK_CONST_METHOD2(BufferLimits, void(int* lower_limit, int* higher_limit));
MOCK_METHOD1(SetBaseMinimumDelay, bool(int delay_ms)); MOCK_METHOD1(SetBaseMinimumDelay, bool(int delay_ms));
MOCK_CONST_METHOD0(GetBaseMinimumDelay, int()); MOCK_CONST_METHOD0(GetBaseMinimumDelay, int());
MOCK_CONST_METHOD0(TargetLevel, int()); MOCK_CONST_METHOD0(TargetLevel, int());
MOCK_METHOD0(RegisterEmptyPacket, void()); MOCK_METHOD0(RegisterEmptyPacket, void());
MOCK_METHOD1(set_extra_delay_ms, void(int16_t delay));
MOCK_CONST_METHOD0(base_target_level, int()); MOCK_CONST_METHOD0(base_target_level, int());
MOCK_METHOD1(set_streaming_mode, void(bool value));
MOCK_CONST_METHOD0(last_pack_cng_or_dtmf, int()); MOCK_CONST_METHOD0(last_pack_cng_or_dtmf, int());
MOCK_METHOD1(set_last_pack_cng_or_dtmf, void(int value)); MOCK_METHOD1(set_last_pack_cng_or_dtmf, void(int value));
}; };

View File

@ -104,7 +104,6 @@ class NetEqImplTest : public ::testing::Test {
config_.enable_rtx_handling, delay_peak_detector_, tick_timer_, config_.enable_rtx_handling, delay_peak_detector_, tick_timer_,
deps.stats.get(), absl::make_unique<Histogram>(50, 32745))); deps.stats.get(), absl::make_unique<Histogram>(50, 32745)));
mock_delay_manager_ = mock.get(); mock_delay_manager_ = mock.get();
EXPECT_CALL(*mock_delay_manager_, set_streaming_mode(false)).Times(1);
deps.delay_manager = std::move(mock); deps.delay_manager = std::move(mock);
} }
delay_manager_ = deps.delay_manager.get(); delay_manager_ = deps.delay_manager.get();