Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 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 |
| 11 #include "webrtc/modules/video_coding/media_optimization.h" | 11 #include "webrtc/modules/video_coding/media_optimization.h" |
| 12 | 12 |
| 13 // #include <algorithm> | |
|
sprang_webrtc
2017/03/10 12:38:57
remove
stefan-webrtc
2017/03/10 12:39:41
Done.
| |
| 14 #include <limits> | |
| 15 | |
| 13 #include "webrtc/base/logging.h" | 16 #include "webrtc/base/logging.h" |
| 14 #include "webrtc/modules/video_coding/utility/frame_dropper.h" | 17 #include "webrtc/modules/video_coding/utility/frame_dropper.h" |
| 15 #include "webrtc/system_wrappers/include/clock.h" | 18 #include "webrtc/system_wrappers/include/clock.h" |
| 16 | 19 |
| 17 namespace webrtc { | 20 namespace webrtc { |
| 18 namespace media_optimization { | 21 namespace media_optimization { |
| 19 | 22 |
| 20 struct MediaOptimization::EncodedFrameSample { | 23 struct MediaOptimization::EncodedFrameSample { |
| 21 EncodedFrameSample(size_t size_bytes, | 24 EncodedFrameSample(size_t size_bytes, |
| 22 uint32_t timestamp, | 25 uint32_t timestamp, |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 122 return video_target_bitrate_; | 125 return video_target_bitrate_; |
| 123 } | 126 } |
| 124 | 127 |
| 125 uint32_t MediaOptimization::InputFrameRate() { | 128 uint32_t MediaOptimization::InputFrameRate() { |
| 126 CriticalSectionScoped lock(crit_sect_.get()); | 129 CriticalSectionScoped lock(crit_sect_.get()); |
| 127 return InputFrameRateInternal(); | 130 return InputFrameRateInternal(); |
| 128 } | 131 } |
| 129 | 132 |
| 130 uint32_t MediaOptimization::InputFrameRateInternal() { | 133 uint32_t MediaOptimization::InputFrameRateInternal() { |
| 131 ProcessIncomingFrameRate(clock_->TimeInMilliseconds()); | 134 ProcessIncomingFrameRate(clock_->TimeInMilliseconds()); |
| 132 return uint32_t(incoming_frame_rate_ + 0.5f); | 135 uint32_t framerate = static_cast<uint32_t>(std::min<float>( |
| 136 std::numeric_limits<uint32_t>::max(), incoming_frame_rate_ + 0.5f)); | |
| 137 return framerate; | |
| 133 } | 138 } |
| 134 | 139 |
| 135 uint32_t MediaOptimization::SentFrameRate() { | 140 uint32_t MediaOptimization::SentFrameRate() { |
| 136 CriticalSectionScoped lock(crit_sect_.get()); | 141 CriticalSectionScoped lock(crit_sect_.get()); |
| 137 return SentFrameRateInternal(); | 142 return SentFrameRateInternal(); |
| 138 } | 143 } |
| 139 | 144 |
| 140 uint32_t MediaOptimization::SentFrameRateInternal() { | 145 uint32_t MediaOptimization::SentFrameRateInternal() { |
| 141 PurgeOldFrameSamples(clock_->TimeInMilliseconds()); | 146 PurgeOldFrameSamples(clock_->TimeInMilliseconds()); |
| 142 UpdateSentFramerate(); | 147 UpdateSentFramerate(); |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 269 const int64_t diff = | 274 const int64_t diff = |
| 270 incoming_frame_times_[0] - incoming_frame_times_[num - 1]; | 275 incoming_frame_times_[0] - incoming_frame_times_[num - 1]; |
| 271 incoming_frame_rate_ = 0.0; // No frame rate estimate available. | 276 incoming_frame_rate_ = 0.0; // No frame rate estimate available. |
| 272 if (diff > 0) { | 277 if (diff > 0) { |
| 273 incoming_frame_rate_ = nr_of_frames * 1000.0f / static_cast<float>(diff); | 278 incoming_frame_rate_ = nr_of_frames * 1000.0f / static_cast<float>(diff); |
| 274 } | 279 } |
| 275 } | 280 } |
| 276 } | 281 } |
| 277 } // namespace media_optimization | 282 } // namespace media_optimization |
| 278 } // namespace webrtc | 283 } // namespace webrtc |
| OLD | NEW |