Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(181)

Side by Side Diff: webrtc/modules/video_coding/sequence_number_util.h

Issue 3012883002: Don't treat picture ids as wrapping in the FrameBuffer2 class. (Closed)
Patch Set: . Created 3 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 // can be set. The unwrapped value is not allowed to wrap. 84 // can be set. The unwrapped value is not allowed to wrap.
85 template <typename T, T M = 0> 85 template <typename T, T M = 0>
86 class SeqNumUnwrapper { 86 class SeqNumUnwrapper {
87 // Use '<' instead of rtc::SafeLt to avoid crbug.com/753488 87 // Use '<' instead of rtc::SafeLt to avoid crbug.com/753488
88 static_assert( 88 static_assert(
89 std::is_unsigned<T>::value && 89 std::is_unsigned<T>::value &&
90 std::numeric_limits<T>::max() < std::numeric_limits<uint64_t>::max(), 90 std::numeric_limits<T>::max() < std::numeric_limits<uint64_t>::max(),
91 "Type unwrapped must be an unsigned integer smaller than uint64_t."); 91 "Type unwrapped must be an unsigned integer smaller than uint64_t.");
92 92
93 public: 93 public:
94 // We want a value that is close to 2^63 for two reasons. Firstly, we 94 // We want a default value that is close to 2^62 for a two reasons. Firstly,
95 // can unwrap wrapping numbers in either direction, and secondly, we avoid 95 // we can unwrap wrapping numbers in either direction, and secondly, the
96 // causing a crash on bad input. We also want the default value to be somewhat 96 // unwrapped numbers can be stored in either int64_t or uint64_t. We also want
97 // human readable, a power of 10 for example. 97 // the default value to be human readable, which makes a power of 10 suitable.
98 static constexpr uint64_t kDefaultStartValue = 10000000000000000000UL; 98 static constexpr uint64_t kDefaultStartValue = 1000000000000000000UL;
philipel 2017/09/08 09:43:54 I removed one '0' to make the default value fit in
99 99
100 SeqNumUnwrapper() : last_unwrapped_(kDefaultStartValue) {} 100 SeqNumUnwrapper() : last_unwrapped_(kDefaultStartValue) {}
101 explicit SeqNumUnwrapper(uint64_t start_at) : last_unwrapped_(start_at) {} 101 explicit SeqNumUnwrapper(uint64_t start_at) : last_unwrapped_(start_at) {}
102 102
103 uint64_t Unwrap(T value) { 103 uint64_t Unwrap(T value) {
104 if (!last_value_) 104 if (!last_value_)
105 last_value_.emplace(value); 105 last_value_.emplace(value);
106 106
107 uint64_t unwrapped = 0; 107 uint64_t unwrapped = 0;
108 if (AheadOrAt<T, M>(value, *last_value_)) { 108 if (AheadOrAt<T, M>(value, *last_value_)) {
(...skipping 10 matching lines...) Expand all
119 } 119 }
120 120
121 private: 121 private:
122 uint64_t last_unwrapped_; 122 uint64_t last_unwrapped_;
123 rtc::Optional<T> last_value_; 123 rtc::Optional<T> last_value_;
124 }; 124 };
125 125
126 } // namespace webrtc 126 } // namespace webrtc
127 127
128 #endif // WEBRTC_MODULES_VIDEO_CODING_SEQUENCE_NUMBER_UTIL_H_ 128 #endif // WEBRTC_MODULES_VIDEO_CODING_SEQUENCE_NUMBER_UTIL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698