From 0ac1d993be7e2ee6611aeb0291bc173e69444442 Mon Sep 17 00:00:00 2001 From: Ruslan Burakov Date: Tue, 14 May 2019 18:06:52 +0200 Subject: [PATCH] Remove streaming_mode as it is always false. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I489b72985f36fd98413ecf729f7d69476c342851 Bug: webrtc:10618 Change-Id: I489b72985f36fd98413ecf729f7d69476c342851 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/136803 Reviewed-by: Jakob Ivarsson‎ Reviewed-by: Henrik Lundin Commit-Queue: Ruslan Burakov Cr-Commit-Position: refs/heads/master@{#27948} --- modules/audio_coding/neteq/decision_logic.cc | 1 - modules/audio_coding/neteq/delay_manager.cc | 49 ------------------- modules/audio_coding/neteq/delay_manager.h | 13 +---- .../neteq/mock/mock_delay_manager.h | 3 -- .../audio_coding/neteq/neteq_impl_unittest.cc | 1 - 5 files changed, 1 insertion(+), 66 deletions(-) diff --git a/modules/audio_coding/neteq/decision_logic.cc b/modules/audio_coding/neteq/decision_logic.cc index 91e828792e..40e421d672 100644 --- a/modules/audio_coding/neteq/decision_logic.cc +++ b/modules/audio_coding/neteq/decision_logic.cc @@ -66,7 +66,6 @@ DecisionLogic::DecisionLogic(int fs_hz, timescale_countdown_( tick_timer_->GetNewCountdown(kMinTimescaleInterval + 1)), num_consecutive_expands_(0) { - delay_manager_->set_streaming_mode(false); SetSampleRate(fs_hz, output_size_samples); } diff --git a/modules/audio_coding/neteq/delay_manager.cc b/modules/audio_coding/neteq/delay_manager.cc index 4e2f3c78b0..9340b8192a 100644 --- a/modules/audio_coding/neteq/delay_manager.cc +++ b/modules/audio_coding/neteq/delay_manager.cc @@ -31,10 +31,6 @@ namespace { 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 kMaxBaseMinimumDelayMs = 10000; 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. target_level_(base_target_level_ << 8), // In Q8 domain. packet_len_ms_(0), - streaming_mode_(false), last_seq_no_(0), last_timestamp_(0), minimum_delay_ms_(0), maximum_delay_ms_(0), - iat_cumulative_sum_(0), - max_iat_cumulative_sum_(0), peak_detector_(*peak_detector), last_pack_cng_or_dtmf_(1), frame_length_change_experiment_( @@ -212,9 +205,6 @@ int DelayManager::Update(uint16_t sequence_number, bool reordered = false; if (packet_len_ms > 0) { // 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 // 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. target_level_ = CalculateTargetLevel(iat_packets, reordered); - if (streaming_mode_) { - target_level_ = std::max(target_level_, max_iat_cumulative_sum_); - } LimitTargetLevel(); } // End if (packet_len_ms > 0). @@ -305,32 +292,6 @@ int DelayManager::CalculateRelativePacketArrivalDelay() const { 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(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 // 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 @@ -363,9 +324,6 @@ void DelayManager::LimitTargetLevel() { int DelayManager::CalculateTargetLevel(int iat_packets, bool reordered) { int limit_probability = histogram_quantile_; - if (streaming_mode_) { - limit_probability = kLimitProbabilityStreaming; - } int bucket_index = histogram_->Quantile(limit_probability); int target_level; @@ -415,15 +373,11 @@ int DelayManager::SetPacketAudioLength(int length_ms) { void DelayManager::Reset() { packet_len_ms_ = 0; // Packet size unknown. - streaming_mode_ = false; peak_detector_.Reset(); histogram_->Reset(); base_target_level_ = 4; target_level_ = base_target_level_ << 8; 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; } @@ -538,9 +492,6 @@ int DelayManager::GetBaseMinimumDelay() const { int DelayManager::base_target_level() const { return base_target_level_; } -void DelayManager::set_streaming_mode(bool value) { - streaming_mode_ = value; -} int DelayManager::last_pack_cng_or_dtmf() const { return last_pack_cng_or_dtmf_; } diff --git a/modules/audio_coding/neteq/delay_manager.h b/modules/audio_coding/neteq/delay_manager.h index e54e950d82..9066f7fcf4 100644 --- a/modules/audio_coding/neteq/delay_manager.h +++ b/modules/audio_coding/neteq/delay_manager.h @@ -102,8 +102,7 @@ class DelayManager { // packets in Q8. virtual void BufferLimits(int* lower_limit, int* higher_limit) const; - // Gets the target buffer level, in (fractions of) packets in Q8. This value - // includes any extra delay set through the set_extra_delay_ms() method. + // Gets the target buffer level, in (fractions of) packets in Q8. virtual int TargetLevel() const; // 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 int GetBaseMinimumDelay() const; virtual int base_target_level() const; - virtual void set_streaming_mode(bool value); virtual int last_pack_cng_or_dtmf() const; virtual void set_last_pack_cng_or_dtmf(int value); @@ -150,10 +148,6 @@ class DelayManager { // Calculate relative packet arrival delay from |delay_history_|. 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 // |minimum_delay_ms_|, |base_minimum_delay_ms_| and |maximum_delay_ms_| // and buffer size. @@ -192,15 +186,10 @@ class DelayManager { int target_level_; // Currently preferred buffer level in (fractions) // of packets (Q8), before adding any extra delay. 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. uint32_t last_timestamp_; // Timestamp for the last received packet. int minimum_delay_ms_; // Externally set minimum 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 max_iat_stopwatch_; DelayPeakDetector& peak_detector_; int last_pack_cng_or_dtmf_; const bool frame_length_change_experiment_; diff --git a/modules/audio_coding/neteq/mock/mock_delay_manager.h b/modules/audio_coding/neteq/mock/mock_delay_manager.h index 3a128ceed5..f935f7522c 100644 --- a/modules/audio_coding/neteq/mock/mock_delay_manager.h +++ b/modules/audio_coding/neteq/mock/mock_delay_manager.h @@ -50,16 +50,13 @@ class MockDelayManager : public DelayManager { MOCK_METHOD1(SetPacketAudioLength, int(int length_ms)); MOCK_METHOD0(Reset, void()); MOCK_CONST_METHOD0(PeakFound, bool()); - MOCK_METHOD1(UpdateCounters, void(int elapsed_time_ms)); MOCK_METHOD0(ResetPacketIatCount, void()); MOCK_CONST_METHOD2(BufferLimits, void(int* lower_limit, int* higher_limit)); MOCK_METHOD1(SetBaseMinimumDelay, bool(int delay_ms)); MOCK_CONST_METHOD0(GetBaseMinimumDelay, int()); MOCK_CONST_METHOD0(TargetLevel, int()); MOCK_METHOD0(RegisterEmptyPacket, void()); - MOCK_METHOD1(set_extra_delay_ms, void(int16_t delay)); 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_METHOD1(set_last_pack_cng_or_dtmf, void(int value)); }; diff --git a/modules/audio_coding/neteq/neteq_impl_unittest.cc b/modules/audio_coding/neteq/neteq_impl_unittest.cc index 826952635f..2b0d5832ae 100644 --- a/modules/audio_coding/neteq/neteq_impl_unittest.cc +++ b/modules/audio_coding/neteq/neteq_impl_unittest.cc @@ -104,7 +104,6 @@ class NetEqImplTest : public ::testing::Test { config_.enable_rtx_handling, delay_peak_detector_, tick_timer_, deps.stats.get(), absl::make_unique(50, 32745))); mock_delay_manager_ = mock.get(); - EXPECT_CALL(*mock_delay_manager_, set_streaming_mode(false)).Times(1); deps.delay_manager = std::move(mock); } delay_manager_ = deps.delay_manager.get();