OLD | NEW |
---|---|
(Empty) | |
1 /* | |
2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. | |
3 * | |
4 * Use of this source code is governed by a BSD-style license | |
5 * that can be found in the LICENSE file in the root of the source | |
6 * tree. An additional intellectual property rights grant can be found | |
7 * in the file PATENTS. All contributing project authors may | |
8 * be found in the AUTHORS file in the root of the source tree. | |
9 */ | |
10 | |
11 #include "webrtc/modules/rtp_rtcp/source/time_util.h" | |
12 | |
13 #include <algorithm> | |
14 | |
15 namespace webrtc { | |
16 namespace { | |
17 // TODO(danilchap): Make generic, optimize and move to base. | |
18 inline int64_t DivideRoundToNearest(int64_t x, uint32_t y) { | |
19 return (x + y/2) / y; | |
20 } | |
21 } // namespace | |
22 | |
23 int64_t CompactNtpRttToMs(uint32_t compact_ntp_interval) { | |
24 if (compact_ntp_interval > 0x80000000) | |
25 return 1; | |
26 int64_t value = static_cast<int64_t>(compact_ntp_interval); | |
27 value = DivideRoundToNearest(value * 1000, 1 << 16); | |
stefan-webrtc
2016/03/04 14:07:33
I think you should comment on how and why this div
danilchap
2016/03/04 15:05:50
negative case handled before division (otherwise d
| |
28 return std::max<int64_t>(value, 1); | |
29 } | |
30 } // namespace webrtc | |
OLD | NEW |