From 55a59337c87614f49c87b846ecf3393b2241d5a6 Mon Sep 17 00:00:00 2001 From: yazdan0a Date: Mon, 2 Sep 2024 21:15:39 -0500 Subject: [PATCH] Minor format to extrapolate local time - Removing unnecessary else {} blocks for better readability. - Consistent naming of: timestamp_diff with explicit typecast. BUG=None Change-Id: I35161ffed245737c789336316f0cfb6821b12349 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/361060 Reviewed-by: Florent Castelli Reviewed-by: Harald Alvestrand Reviewed-by: Danil Chapovalov Commit-Queue: Danil Chapovalov Cr-Commit-Position: refs/heads/main@{#42939} --- .../timing/timestamp_extrapolator.cc | 28 ++++++++++--------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/modules/video_coding/timing/timestamp_extrapolator.cc b/modules/video_coding/timing/timestamp_extrapolator.cc index e87a46ad1e..15605033c8 100644 --- a/modules/video_coding/timing/timestamp_extrapolator.cc +++ b/modules/video_coding/timing/timestamp_extrapolator.cc @@ -129,7 +129,8 @@ std::optional TimestampExtrapolator::ExtrapolateLocalTime( if (!first_unwrapped_timestamp_) { return std::nullopt; - } else if (packet_count_ < kStartUpFilterDelayInPackets) { + } + if (packet_count_ < kStartUpFilterDelayInPackets) { constexpr double kRtpTicksPerMs = 90; TimeDelta diff = TimeDelta::Millis( (unwrapped_ts90khz - *prev_unwrapped_timestamp_) / kRtpTicksPerMs); @@ -139,19 +140,20 @@ std::optional TimestampExtrapolator::ExtrapolateLocalTime( return std::nullopt; } return prev_ + diff; - } else if (w_[0] < 1e-3) { - return start_; - } else { - double timestampDiff = unwrapped_ts90khz - *first_unwrapped_timestamp_; - TimeDelta diff = TimeDelta::Millis( - static_cast((timestampDiff - w_[1]) / w_[0] + 0.5)); - if (start_.us() + diff.us() < 0) { - // Prevent the construction of a negative Timestamp. - // This scenario can occur when the RTP timestamp wraps around. - return std::nullopt; - } - return start_ + diff; } + if (w_[0] < 1e-3) { + return start_; + } + double timestamp_diff = + static_cast(unwrapped_ts90khz - *first_unwrapped_timestamp_); + TimeDelta diff = TimeDelta::Millis( + static_cast((timestamp_diff - w_[1]) / w_[0] + 0.5)); + if (start_.us() + diff.us() < 0) { + // Prevent the construction of a negative Timestamp. + // This scenario can occur when the RTP timestamp wraps around. + return std::nullopt; + } + return start_ + diff; } bool TimestampExtrapolator::DelayChangeDetection(double error) {