Reland "Fix overflow due to rounding in AbsoluteSendTime::To24Bits"

This reverts commit 791294a647bfba8ebd26821a78020a2bb2f82b9b.

Reason for revert: downstream test adjusted

Original change's description:
> Revert "Fix overflow due to rounding in AbsoluteSendTime::To24Bits"
>
> 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 <asapersson@webrtc.org>
> > Auto-Submit: Danil Chapovalov <danilchap@webrtc.org>
> > Reviewed-by: Åsa Persson <asapersson@webrtc.org>
> > 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 <danilchap@webrtc.org>
> Bot-Commit: rubber-stamper@appspot.gserviceaccount.com <rubber-stamper@appspot.gserviceaccount.com>
> Auto-Submit: Danil Chapovalov <danilchap@webrtc.org>
> Cr-Commit-Position: refs/heads/main@{#37473}

Bug: None
Change-Id: I99bcc6c6b7c08cd9621bdce336cd5793f78ee657
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/268190
Bot-Commit: rubber-stamper@appspot.gserviceaccount.com <rubber-stamper@appspot.gserviceaccount.com>
Reviewed-by: Åsa Persson <asapersson@webrtc.org>
Commit-Queue: Danil Chapovalov <danilchap@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#37498}
This commit is contained in:
Danil Chapovalov
2022-07-08 14:12:43 +00:00
committed by WebRTC LUCI CQ
parent 9c125c6603
commit 52747f1744

View File

@ -26,7 +26,6 @@
#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 {
@ -45,7 +44,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 = DivideRoundToNearest(time_us << 18, 1'000'000);
int64_t time6x18 = (time_us << 18) / 1'000'000;
RTC_DCHECK_GE(time6x18, 0);
RTC_DCHECK_LT(time6x18, 1 << 24);
return static_cast<uint32_t>(time6x18);