Reland "Cleanup of video packet overhead calculation."
This is a reland of 890bc3069cbababa19b40ec02684253d60e051b2 Zero bitrate caused division by zero in DCHECK for max bitrate. Added unit tests to ensure that setting zero bitrate does not crash. > Original change's description: > > Cleanup of video packet overhead calculation. > > > > This CL updates the video packet overhead calculation to make it more > > clear. This prepares for future work on improving the accuracy of the > > calculation. > > > > Bug: webrtc:9883 > > Change-Id: I1d623a3e0de45be7b6e4a1f9e3cbe54fd2b8a45a > > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/138077 > > Commit-Queue: Sebastian Jansson <srte@webrtc.org> > > Reviewed-by: Erik Språng <sprang@webrtc.org> > > Cr-Commit-Position: refs/heads/master@{#28040} Bug: webrtc:10674 Change-Id: I156d1ee5546ede7e43ae1d9a298dcaba6071230f Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/140890 Reviewed-by: Niels Moller <nisse@webrtc.org> Reviewed-by: Erik Språng <sprang@webrtc.org> Commit-Queue: Sebastian Jansson <srte@webrtc.org> Cr-Commit-Position: refs/heads/master@{#28212}
This commit is contained in:
committed by
Commit Bot
parent
646e096e03
commit
cf41eb1ce1
@ -126,11 +126,11 @@ inline Frequency operator/(const DataRate rate, const DataSize size) {
|
||||
size.bytes());
|
||||
}
|
||||
inline DataRate operator*(const DataSize size, const Frequency frequency) {
|
||||
int64_t millihertz = frequency.millihertz<int64_t>();
|
||||
int64_t kMaxBeforeConversion =
|
||||
std::numeric_limits<int64_t>::max() / 8 / millihertz;
|
||||
RTC_DCHECK_LE(size.bytes(), kMaxBeforeConversion);
|
||||
int64_t millibits_per_second = size.bytes() * 8 * millihertz;
|
||||
RTC_DCHECK(frequency.IsZero() ||
|
||||
size.bytes() <= std::numeric_limits<int64_t>::max() / 8 /
|
||||
frequency.millihertz<int64_t>());
|
||||
int64_t millibits_per_second =
|
||||
size.bytes() * 8 * frequency.millihertz<int64_t>();
|
||||
return DataRate::bps((millibits_per_second + 500) / 1000);
|
||||
}
|
||||
inline DataRate operator*(const Frequency frequency, const DataSize size) {
|
||||
|
||||
Reference in New Issue
Block a user