From 2f650fa822290f3f3a51ca11e9218f1ac8d12f94 Mon Sep 17 00:00:00 2001 From: Rasmus Brandt Date: Wed, 21 Sep 2022 09:39:44 +0200 Subject: [PATCH] JitterEstimator: remove unnecessary helper functions Move functionality to closer where the values are used instead, as per previous CL comment. Bug: webrtc:14151 Change-Id: I6b7ca02da197420a1f5da930ba87021e6f557444 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/275204 Commit-Queue: Rasmus Brandt Reviewed-by: Philip Eliasson Cr-Commit-Position: refs/heads/main@{#38148} --- .../video_coding/timing/jitter_estimator.cc | 25 +++++++------------ .../video_coding/timing/jitter_estimator.h | 5 ---- 2 files changed, 9 insertions(+), 21 deletions(-) diff --git a/modules/video_coding/timing/jitter_estimator.cc b/modules/video_coding/timing/jitter_estimator.cc index 2416ed02ed..62757787a1 100644 --- a/modules/video_coding/timing/jitter_estimator.cc +++ b/modules/video_coding/timing/jitter_estimator.cc @@ -243,7 +243,8 @@ void JitterEstimator::UpdateEstimate(TimeDelta frame_delay, // https://en.wikipedia.org/wiki/68-95-99.7_rule. Note that neither of the // estimated means are true sample means, which implies that they are possibly // not normally distributed. Hence, this rejection method is just a heuristic. - double num_stddev_delay_outlier = GetNumStddevDelayOutlier(); + double num_stddev_delay_outlier = + config_.num_stddev_delay_outlier.value_or(kNumStdDevDelayOutlier); // Delay outlier rejection is two-sided. bool abs_delay_is_not_outlier = fabs(delay_deviation_ms) < @@ -253,10 +254,12 @@ void JitterEstimator::UpdateEstimate(TimeDelta frame_delay, // median-filtered version, even if configured to use latter for the // calculation in `CalculateEstimate()`. // Size outlier rejection is one-sided. + double num_stddev_size_outlier = + config_.num_stddev_size_outlier.value_or(kNumStdDevSizeOutlier); bool size_is_positive_outlier = frame_size.bytes() > avg_frame_size_bytes_ + - GetNumStddevSizeOutlier() * sqrt(var_frame_size_bytes2_); + num_stddev_size_outlier * sqrt(var_frame_size_bytes2_); // Only update the Kalman filter if the sample is not considered an extreme // outlier. Even if it is an extreme outlier from a delay point of view, if @@ -269,13 +272,16 @@ void JitterEstimator::UpdateEstimate(TimeDelta frame_delay, // delayed. The next frame is of normal size (delta frame), and thus deltaFS // will be << 0. This removes all frame samples which arrives after a key // frame. + double congestion_rejection_factor = + config_.congestion_rejection_factor.value_or( + kCongestionRejectionFactor); double filtered_max_frame_size_bytes = config_.MaxFrameSizePercentileEnabled() ? max_frame_size_bytes_percentile_.GetFilteredValue() : max_frame_size_bytes_; bool is_not_congested = delta_frame_bytes > - GetCongestionRejectionFactor() * filtered_max_frame_size_bytes; + congestion_rejection_factor * filtered_max_frame_size_bytes; if (is_not_congested || config_.estimate_noise_when_congested) { // Update the variance of the deviation from the line given by the Kalman @@ -320,19 +326,6 @@ JitterEstimator::Config JitterEstimator::GetConfigForTest() const { return config_; } -double JitterEstimator::GetNumStddevDelayOutlier() const { - return config_.num_stddev_delay_outlier.value_or(kNumStdDevDelayOutlier); -} - -double JitterEstimator::GetNumStddevSizeOutlier() const { - return config_.num_stddev_size_outlier.value_or(kNumStdDevSizeOutlier); -} - -double JitterEstimator::GetCongestionRejectionFactor() const { - return config_.congestion_rejection_factor.value_or( - kCongestionRejectionFactor); -} - // Estimates the random jitter by calculating the variance of the sample // distance from the line given by the Kalman filter. void JitterEstimator::EstimateRandomJitter(double d_dT) { diff --git a/modules/video_coding/timing/jitter_estimator.h b/modules/video_coding/timing/jitter_estimator.h index 769bb12a0c..a89a4bf1fd 100644 --- a/modules/video_coding/timing/jitter_estimator.h +++ b/modules/video_coding/timing/jitter_estimator.h @@ -143,11 +143,6 @@ class JitterEstimator { Config GetConfigForTest() const; private: - // These functions return values that could be overriden through the config. - double GetNumStddevDelayOutlier() const; - double GetNumStddevSizeOutlier() const; - double GetCongestionRejectionFactor() const; - // Updates the random jitter estimate, i.e. the variance of the time // deviations from the line given by the Kalman filter. //