Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(206)

Unified Diff: webrtc/common_audio/smoothing_filter.cc

Issue 2510373002: Revert of Move smoothing filter to common audio. (Closed)
Patch Set: Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webrtc/common_audio/smoothing_filter.h ('k') | webrtc/common_audio/smoothing_filter_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/common_audio/smoothing_filter.cc
diff --git a/webrtc/common_audio/smoothing_filter.cc b/webrtc/common_audio/smoothing_filter.cc
deleted file mode 100644
index 1cf9580d2adfeea7821b36e759651b8b2cd58281..0000000000000000000000000000000000000000
--- a/webrtc/common_audio/smoothing_filter.cc
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
- *
- * Use of this source code is governed by a BSD-style license
- * that can be found in the LICENSE file in the root of the source
- * tree. An additional intellectual property rights grant can be found
- * in the file PATENTS. All contributing project authors may
- * be found in the AUTHORS file in the root of the source tree.
- */
-
-#include <cmath>
-
-#include "webrtc/common_audio/smoothing_filter.h"
-
-namespace webrtc {
-
-SmoothingFilterImpl::SmoothingFilterImpl(int time_constant_ms,
- const Clock* clock)
- : time_constant_ms_(time_constant_ms),
- clock_(clock),
- first_sample_received_(false),
- initialized_(false),
- first_sample_time_ms_(0),
- last_sample_time_ms_(0),
- filter_(0.0) {}
-
-void SmoothingFilterImpl::AddSample(float sample) {
- if (!first_sample_received_) {
- last_sample_time_ms_ = first_sample_time_ms_ = clock_->TimeInMilliseconds();
- first_sample_received_ = true;
- RTC_DCHECK_EQ(rtc::ExpFilter::kValueUndefined, filter_.filtered());
-
- // Since this is first sample, any value for argument 1 should work.
- filter_.Apply(0.0f, sample);
- return;
- }
-
- int64_t now_ms = clock_->TimeInMilliseconds();
- if (!initialized_) {
- float duration = now_ms - first_sample_time_ms_;
- if (duration < static_cast<int64_t>(time_constant_ms_)) {
- filter_.UpdateBase(exp(1.0f / duration));
- } else {
- initialized_ = true;
- filter_.UpdateBase(exp(1.0f / time_constant_ms_));
- }
- }
-
- // The filter will do the following:
- // float alpha = pow(base, last_update_time_ms_ - now_ms);
- // filtered_ = alpha * filtered_ + (1 - alpha) * sample;
- filter_.Apply(static_cast<float>(last_sample_time_ms_ - now_ms), sample);
- last_sample_time_ms_ = now_ms;
-}
-
-rtc::Optional<float> SmoothingFilterImpl::GetAverage() const {
- float value = filter_.filtered();
- return value == rtc::ExpFilter::kValueUndefined ? rtc::Optional<float>()
- : rtc::Optional<float>(value);
-}
-
-} // namespace webrtc
« no previous file with comments | « webrtc/common_audio/smoothing_filter.h ('k') | webrtc/common_audio/smoothing_filter_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698