| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 return M - (sub - a); | 36 return M - (sub - a); |
| 37 return a - sub; | 37 return a - sub; |
| 38 } | 38 } |
| 39 | 39 |
| 40 // Calculates the forward difference between two wrapping numbers. | 40 // Calculates the forward difference between two wrapping numbers. |
| 41 // | 41 // |
| 42 // Example: | 42 // Example: |
| 43 // uint8_t x = 253; | 43 // uint8_t x = 253; |
| 44 // uint8_t y = 2; | 44 // uint8_t y = 2; |
| 45 // | 45 // |
| 46 // ForwardDiff(x, y) == 4 | 46 // ForwardDiff(x, y) == 5 |
| 47 // | 47 // |
| 48 // 252 253 254 255 0 1 2 3 | 48 // 252 253 254 255 0 1 2 3 |
| 49 // ################################################# | 49 // ################################################# |
| 50 // | | x | | | | | y | | | 50 // | | x | | | | | y | | |
| 51 // ################################################# | 51 // ################################################# |
| 52 // |----->----->----->----->-----> | 52 // |----->----->----->----->-----> |
| 53 // | 53 // |
| 54 // ForwardDiff(y, x) == 251 | 54 // ForwardDiff(y, x) == 251 |
| 55 // | 55 // |
| 56 // 252 253 254 255 0 1 2 3 | 56 // 252 253 254 255 0 1 2 3 |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 template <typename T> | 126 template <typename T> |
| 127 inline T MinDiff(T a, T b) { | 127 inline T MinDiff(T a, T b) { |
| 128 static_assert(std::is_unsigned<T>::value, | 128 static_assert(std::is_unsigned<T>::value, |
| 129 "Type must be an unsigned integer."); | 129 "Type must be an unsigned integer."); |
| 130 return std::min(ForwardDiff(a, b), ReverseDiff(a, b)); | 130 return std::min(ForwardDiff(a, b), ReverseDiff(a, b)); |
| 131 } | 131 } |
| 132 | 132 |
| 133 } // namespace webrtc | 133 } // namespace webrtc |
| 134 | 134 |
| 135 #endif // WEBRTC_BASE_MOD_OPS_H_ | 135 #endif // WEBRTC_BASE_MOD_OPS_H_ |
| OLD | NEW |