From 791294a647bfba8ebd26821a78020a2bb2f82b9b Mon Sep 17 00:00:00 2001 From: Danil Chapovalov Date: Thu, 7 Jul 2022 07:18:01 +0000 Subject: [PATCH] Revert "Fix overflow due to rounding in AbsoluteSendTime::To24Bits" MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit a17651f7d8748905d902eedf34471a0c227ca789. Reason for revert: triggers failure in downstream test Original change's description: > Fix overflow due to rounding in AbsoluteSendTime::To24Bits > > Actual rounding is not important for this time as long it is consistent > during the call: only difference between two absolute send time matter > Rounding down avoids producing 1 < 24 when value is close to the wrap around boundary. > > Bug: None > Change-Id: Ibbf5bae21bc37eccdc5d4c130a59796ee5108017 > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/268001 > Commit-Queue: Åsa Persson > Auto-Submit: Danil Chapovalov > Reviewed-by: Åsa Persson > Cr-Commit-Position: refs/heads/main@{#37468} Bug: None Change-Id: I90a9c1b174b918b7ede58c3bbdb879b1b67da7b2 No-Presubmit: true No-Tree-Checks: true No-Try: true Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/268120 Commit-Queue: Danil Chapovalov Bot-Commit: rubber-stamper@appspot.gserviceaccount.com Auto-Submit: Danil Chapovalov Cr-Commit-Position: refs/heads/main@{#37473} --- modules/rtp_rtcp/source/rtp_header_extensions.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/rtp_rtcp/source/rtp_header_extensions.h b/modules/rtp_rtcp/source/rtp_header_extensions.h index d80e0da4f8..62b19293ba 100644 --- a/modules/rtp_rtcp/source/rtp_header_extensions.h +++ b/modules/rtp_rtcp/source/rtp_header_extensions.h @@ -26,6 +26,7 @@ #include "api/video/video_rotation.h" #include "api/video/video_timing.h" #include "modules/rtp_rtcp/include/rtp_rtcp_defines.h" +#include "rtc_base/numerics/divide_round.h" namespace webrtc { @@ -44,7 +45,7 @@ class AbsoluteSendTime { static constexpr uint32_t To24Bits(Timestamp time) { int64_t time_us = time.us() % (int64_t{1 << 6} * 1'000'000); - int64_t time6x18 = (time_us << 18) / 1'000'000; + int64_t time6x18 = DivideRoundToNearest(time_us << 18, 1'000'000); RTC_DCHECK_GE(time6x18, 0); RTC_DCHECK_LT(time6x18, 1 << 24); return static_cast(time6x18);