From ef4a2cfc450b37356298e6daa1e0badaf7d6d4b2 Mon Sep 17 00:00:00 2001 From: Johannes Kron Date: Wed, 10 Aug 2022 22:39:51 +0000 Subject: [PATCH] Remove condition that will never be active Remove check if `prev_estimate_` is less than 10 us since it can never be less than 1 ms. Bug: None Change-Id: If151390d22fa0b6ecdc36af64168d3e2049c7b6b Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/271203 Reviewed-by: Philip Eliasson Commit-Queue: Johannes Kron Cr-Commit-Position: refs/heads/main@{#37745} --- modules/video_coding/timing/jitter_estimator.cc | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/modules/video_coding/timing/jitter_estimator.cc b/modules/video_coding/timing/jitter_estimator.cc index e5d13d9443..8ce5dc998e 100644 --- a/modules/video_coding/timing/jitter_estimator.cc +++ b/modules/video_coding/timing/jitter_estimator.cc @@ -234,17 +234,15 @@ TimeDelta JitterEstimator::CalculateEstimate() { TimeDelta ret = TimeDelta::Millis(retMs); - constexpr TimeDelta kMinPrevEstimate = TimeDelta::Micros(10); + constexpr TimeDelta kMinEstimate = TimeDelta::Millis(1); constexpr TimeDelta kMaxEstimate = TimeDelta::Seconds(10); // A very low estimate (or negative) is neglected. - if (ret < TimeDelta::Millis(1)) { - if (!prev_estimate_ || prev_estimate_ <= kMinPrevEstimate) { - ret = TimeDelta::Millis(1); - } else { - ret = *prev_estimate_; - } - } - if (ret > kMaxEstimate) { // Sanity + if (ret < kMinEstimate) { + ret = prev_estimate_.value_or(kMinEstimate); + // Sanity check to make sure that no other method has set `prev_estimate_` + // to a value lower than `kMinEstimate`. + RTC_DCHECK_GE(ret, kMinEstimate); + } else if (ret > kMaxEstimate) { // Sanity ret = kMaxEstimate; } prev_estimate_ = ret;