Commit graph

2 commits

Author SHA1 Message Date
Danil Chapovalov
f4b21da965 Extend DivideRoundToNearest to support negative numbers and use for UnitBase
UnitBase own function to divide with rounding overflows when dividend is close to the max int64_t

Bug: b/262999013
Change-Id: I5b0c3f4408165a0f03690cab80bd098e506fc984
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/288521
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Commit-Queue: Danil Chapovalov <danilchap@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#38943}
2022-12-22 11:02:29 +00:00
Danil Chapovalov
33b83fdc95 Introduce integer division helpers with non-default rounding
There are multiple places in webrtc code where alternative than
default rounding is desired. Typically this rounding is inlined.
e.g. as (<x> + <y>/2) / <y> making code more clumpsy (<y> might be long expression)
and unsafe for large values of <x>

This change introduce small helpers to address both concerns.

Bug: None
Change-Id: Icd8dcee80a697b7c50ba0b2e50295087d2be8670
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/153354
Commit-Queue: Danil Chapovalov <danilchap@webrtc.org>
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Reviewed-by: Niels Moller <nisse@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#29222}
2019-09-18 15:08:39 +00:00