Move exp_filter.h to webrtc namespace

Bug: webrtc:42232595
Change-Id: I0da83745a00f27bbb332500e8008cac42bdc4bf8
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/378283
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Commit-Queue: Evan Shrubsole <eshr@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#43968}
diff --git a/modules/audio_coding/codecs/opus/audio_encoder_opus.cc b/modules/audio_coding/codecs/opus/audio_encoder_opus.cc
index 047df0d..1b01feb 100644
--- a/modules/audio_coding/codecs/opus/audio_encoder_opus.cc
+++ b/modules/audio_coding/codecs/opus/audio_encoder_opus.cc
@@ -319,7 +319,7 @@
   // Gets the smoothed packet loss fraction.
   float GetAverage() const {
     float value = smoother_.filtered();
-    return (value == rtc::ExpFilter::kValueUndefined) ? 0.0f : value;
+    return (value == ExpFilter::kValueUndefined) ? 0.0f : value;
   }
 
   // Add new observation to the packet loss fraction smoother.
@@ -334,7 +334,7 @@
   int64_t last_sample_time_ms_;
 
   // An exponential filter is used to smooth the packet loss fraction.
-  rtc::ExpFilter smoother_;
+  ExpFilter smoother_;
 };
 
 std::unique_ptr<AudioEncoderOpusImpl> AudioEncoderOpusImpl::CreateForTesting(
diff --git a/modules/pacing/task_queue_paced_sender.cc b/modules/pacing/task_queue_paced_sender.cc
index ef94a98..5207b78 100644
--- a/modules/pacing/task_queue_paced_sender.cc
+++ b/modules/pacing/task_queue_paced_sender.cc
@@ -261,7 +261,7 @@
     DataRate pacing_rate = pacing_controller_.pacing_rate();
     if (max_hold_back_window_in_packets_ != kNoPacketHoldback &&
         !pacing_rate.IsZero() &&
-        packet_size_.filtered() != rtc::ExpFilter::kValueUndefined) {
+        packet_size_.filtered() != ExpFilter::kValueUndefined) {
       TimeDelta avg_packet_send_time =
           DataSize::Bytes(packet_size_.filtered()) / pacing_rate;
       hold_back_window =
diff --git a/modules/pacing/task_queue_paced_sender.h b/modules/pacing/task_queue_paced_sender.h
index bc46a75..88db41b 100644
--- a/modules/pacing/task_queue_paced_sender.h
+++ b/modules/pacing/task_queue_paced_sender.h
@@ -174,7 +174,7 @@
   bool is_shutdown_ RTC_GUARDED_BY(task_queue_);
 
   // Filtered size of enqueued packets, in bytes.
-  rtc::ExpFilter packet_size_ RTC_GUARDED_BY(task_queue_);
+  ExpFilter packet_size_ RTC_GUARDED_BY(task_queue_);
   bool include_overhead_ RTC_GUARDED_BY(task_queue_);
 
   Stats current_stats_ RTC_GUARDED_BY(task_queue_);
diff --git a/modules/video_coding/codecs/vp8/libvpx_vp8_decoder.cc b/modules/video_coding/codecs/vp8/libvpx_vp8_decoder.cc
index fc6cad6..57d2a17 100644
--- a/modules/video_coding/codecs/vp8/libvpx_vp8_decoder.cc
+++ b/modules/video_coding/codecs/vp8/libvpx_vp8_decoder.cc
@@ -96,8 +96,7 @@
 
   int GetAvg() const {
     float value = smoother_.filtered();
-    return (value == rtc::ExpFilter::kValueUndefined) ? 0
-                                                      : static_cast<int>(value);
+    return (value == ExpFilter::kValueUndefined) ? 0 : static_cast<int>(value);
   }
 
   void Add(float sample) {
@@ -111,7 +110,7 @@
  private:
   const float kAlpha = 0.95f;
   int64_t last_sample_ms_;
-  rtc::ExpFilter smoother_;
+  ExpFilter smoother_;
 };
 
 LibvpxVp8Decoder::LibvpxVp8Decoder(const Environment& env)
diff --git a/modules/video_coding/media_opt_util.h b/modules/video_coding/media_opt_util.h
index ad77f52..bfa3249 100644
--- a/modules/video_coding/media_opt_util.h
+++ b/modules/video_coding/media_opt_util.h
@@ -339,11 +339,11 @@
   int64_t _lastPrUpdateT;
   int64_t _lastPacketPerFrameUpdateT;
   int64_t _lastPacketPerFrameUpdateTKey;
-  rtc::ExpFilter _lossPr255;
+  ExpFilter _lossPr255;
   VCMLossProbabilitySample _lossPrHistory[kLossPrHistorySize];
   uint8_t _shortMaxLossPr255;
-  rtc::ExpFilter _packetsPerFrame;
-  rtc::ExpFilter _packetsPerFrameKey;
+  ExpFilter _packetsPerFrame;
+  ExpFilter _packetsPerFrameKey;
   size_t _codecWidth;
   size_t _codecHeight;
   int _numLayers;
diff --git a/modules/video_coding/utility/frame_dropper.h b/modules/video_coding/utility/frame_dropper.h
index b45b7fe..e801683 100644
--- a/modules/video_coding/utility/frame_dropper.h
+++ b/modules/video_coding/utility/frame_dropper.h
@@ -59,8 +59,8 @@
   void UpdateRatio();
   void CapAccumulator();
 
-  rtc::ExpFilter key_frame_ratio_;
-  rtc::ExpFilter delta_frame_size_avg_kbits_;
+  ExpFilter key_frame_ratio_;
+  ExpFilter delta_frame_size_avg_kbits_;
 
   // Key frames and large delta frames are not immediately accumulated in the
   // bucket since they can immediately overflow the bucket leading to large
@@ -81,7 +81,7 @@
   float accumulator_max_;
   float target_bitrate_;
   bool drop_next_;
-  rtc::ExpFilter drop_ratio_;
+  ExpFilter drop_ratio_;
   int drop_count_;
   float incoming_frame_rate_;
   bool was_below_max_;
diff --git a/modules/video_coding/utility/quality_scaler.cc b/modules/video_coding/utility/quality_scaler.cc
index 6cb4dc9..e8a8f90 100644
--- a/modules/video_coding/utility/quality_scaler.cc
+++ b/modules/video_coding/utility/quality_scaler.cc
@@ -44,7 +44,7 @@
 
   std::optional<int> GetAvg() const {
     float value = smoother_.filtered();
-    if (value == rtc::ExpFilter::kValueUndefined) {
+    if (value == ExpFilter::kValueUndefined) {
       return std::nullopt;
     }
     return static_cast<int>(value);
@@ -61,7 +61,7 @@
  private:
   const float alpha_;
   int64_t last_sample_ms_;
-  rtc::ExpFilter smoother_;
+  ExpFilter smoother_;
 };
 
 // The QualityScaler checks for QP periodically by queuing CheckQpTasks. The
diff --git a/rtc_base/numerics/exp_filter.cc b/rtc_base/numerics/exp_filter.cc
index a58250a..5dbca9b 100644
--- a/rtc_base/numerics/exp_filter.cc
+++ b/rtc_base/numerics/exp_filter.cc
@@ -12,7 +12,7 @@
 
 #include <cmath>
 
-namespace rtc {
+namespace webrtc {
 
 const float ExpFilter::kValueUndefined = -1.0f;
 
@@ -40,4 +40,4 @@
 void ExpFilter::UpdateBase(float alpha) {
   alpha_ = alpha;
 }
-}  // namespace rtc
+}  // namespace webrtc
diff --git a/rtc_base/numerics/exp_filter.h b/rtc_base/numerics/exp_filter.h
index 6bded80..5a520ce 100644
--- a/rtc_base/numerics/exp_filter.h
+++ b/rtc_base/numerics/exp_filter.h
@@ -11,7 +11,7 @@
 #ifndef RTC_BASE_NUMERICS_EXP_FILTER_H_
 #define RTC_BASE_NUMERICS_EXP_FILTER_H_
 
-namespace rtc {
+namespace webrtc {
 
 // This class can be used, for example, for smoothing the result of bandwidth
 // estimation and packet loss estimation.
@@ -43,6 +43,12 @@
   float filtered_;  // Current filter output.
   const float max_;
 };
+}  //  namespace webrtc
+
+// Re-export symbols from the webrtc namespace for backwards compatibility.
+// TODO(bugs.webrtc.org/4222596): Remove once all references are updated.
+namespace rtc {
+using ::webrtc::ExpFilter;
 }  // namespace rtc
 
 #endif  // RTC_BASE_NUMERICS_EXP_FILTER_H_
diff --git a/rtc_base/numerics/exp_filter_unittest.cc b/rtc_base/numerics/exp_filter_unittest.cc
index f5b436f..b3de3a3 100644
--- a/rtc_base/numerics/exp_filter_unittest.cc
+++ b/rtc_base/numerics/exp_filter_unittest.cc
@@ -14,7 +14,7 @@
 
 #include "test/gtest.h"
 
-namespace rtc {
+namespace webrtc {
 
 TEST(ExpFilterTest, FirstTimeOutputEqualInput) {
   // No max value defined.
@@ -69,4 +69,4 @@
   EXPECT_FLOAT_EQ(value, filter.filtered());
 }
 
-}  // namespace rtc
+}  // namespace webrtc
diff --git a/video/adaptation/overuse_frame_detector.cc b/video/adaptation/overuse_frame_detector.cc
index 1739f95..d1f832f 100644
--- a/video/adaptation/overuse_frame_detector.cc
+++ b/video/adaptation/overuse_frame_detector.cc
@@ -79,8 +79,8 @@
         count_(0),
         last_processed_capture_time_us_(-1),
         max_sample_diff_ms_(kDefaultSampleDiffMs * kMaxSampleDiffMarginFactor),
-        filtered_processing_ms_(new rtc::ExpFilter(kWeightFactorProcessing)),
-        filtered_frame_diff_ms_(new rtc::ExpFilter(kWeightFactorFrameDiff)) {
+        filtered_processing_ms_(new ExpFilter(kWeightFactorProcessing)),
+        filtered_frame_diff_ms_(new ExpFilter(kWeightFactorFrameDiff)) {
     Reset();
   }
   ~SendProcessingUsage1() override {}
@@ -212,8 +212,8 @@
   uint64_t count_;
   int64_t last_processed_capture_time_us_;
   float max_sample_diff_ms_;
-  std::unique_ptr<rtc::ExpFilter> filtered_processing_ms_;
-  std::unique_ptr<rtc::ExpFilter> filtered_frame_diff_ms_;
+  std::unique_ptr<ExpFilter> filtered_processing_ms_;
+  std::unique_ptr<ExpFilter> filtered_frame_diff_ms_;
 };
 
 // New cpu load estimator.
diff --git a/video/send_statistics_proxy.h b/video/send_statistics_proxy.h
index ab1605c..a2deab4 100644
--- a/video/send_statistics_proxy.h
+++ b/video/send_statistics_proxy.h
@@ -297,7 +297,7 @@
   VideoEncoderConfig::ContentType content_type_ RTC_GUARDED_BY(mutex_);
   const int64_t start_ms_;
   VideoSendStream::Stats stats_ RTC_GUARDED_BY(mutex_);
-  rtc::ExpFilter encode_time_ RTC_GUARDED_BY(mutex_);
+  ExpFilter encode_time_ RTC_GUARDED_BY(mutex_);
   QualityLimitationReasonTracker quality_limitation_reason_tracker_
       RTC_GUARDED_BY(mutex_);
   rtc::RateTracker media_byte_rate_tracker_ RTC_GUARDED_BY(mutex_);