| OLD | NEW |
| 1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "media/capture/content/video_capture_oracle.h" | 5 #include "media/capture/content/video_capture_oracle.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/format_macros.h" | 9 #include "base/format_macros.h" |
| 10 #include "base/numerics/safe_conversions.h" | 10 #include "base/numerics/safe_conversions.h" |
| (...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 328 return frame_timestamps_[frame_number % kMaxFrameTimestamps]; | 328 return frame_timestamps_[frame_number % kMaxFrameTimestamps]; |
| 329 } | 329 } |
| 330 | 330 |
| 331 void VideoCaptureOracle::SetFrameTimestamp(int frame_number, | 331 void VideoCaptureOracle::SetFrameTimestamp(int frame_number, |
| 332 base::TimeTicks timestamp) { | 332 base::TimeTicks timestamp) { |
| 333 DCHECK(IsFrameInRecentHistory(frame_number)); | 333 DCHECK(IsFrameInRecentHistory(frame_number)); |
| 334 frame_timestamps_[frame_number % kMaxFrameTimestamps] = timestamp; | 334 frame_timestamps_[frame_number % kMaxFrameTimestamps] = timestamp; |
| 335 } | 335 } |
| 336 | 336 |
| 337 bool VideoCaptureOracle::IsFrameInRecentHistory(int frame_number) const { | 337 bool VideoCaptureOracle::IsFrameInRecentHistory(int frame_number) const { |
| 338 return ((next_frame_number_ - frame_number) < kMaxFrameTimestamps && | 338 // Adding (next_frame_number_ >= 0) helps the compiler deduce that there |
| 339 frame_number <= next_frame_number_ && frame_number >= 0); | 339 // is no possibility of overflow here. |
| 340 return (frame_number >= 0 && next_frame_number_ >= 0 && |
| 341 frame_number <= next_frame_number_ && |
| 342 (next_frame_number_ - frame_number) < kMaxFrameTimestamps); |
| 340 } | 343 } |
| 341 | 344 |
| 342 void VideoCaptureOracle::CommitCaptureSizeAndReset( | 345 void VideoCaptureOracle::CommitCaptureSizeAndReset( |
| 343 base::TimeTicks last_frame_time) { | 346 base::TimeTicks last_frame_time) { |
| 344 capture_size_ = resolution_chooser_.capture_size(); | 347 capture_size_ = resolution_chooser_.capture_size(); |
| 345 VLOG(2) << "Now proposing a capture size of " << capture_size_.ToString(); | 348 VLOG(2) << "Now proposing a capture size of " << capture_size_.ToString(); |
| 346 | 349 |
| 347 // Reset each short-term feedback accumulator with a stable-state starting | 350 // Reset each short-term feedback accumulator with a stable-state starting |
| 348 // value. | 351 // value. |
| 349 const base::TimeTicks ignore_before_time = JustAfter(last_frame_time); | 352 const base::TimeTicks ignore_before_time = JustAfter(last_frame_time); |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 513 // Content is not animating, so permit an immediate increase in the capture | 516 // Content is not animating, so permit an immediate increase in the capture |
| 514 // area. This allows the system to quickly improve the quality of | 517 // area. This allows the system to quickly improve the quality of |
| 515 // non-animating content (frame drops are not much of a concern). | 518 // non-animating content (frame drops are not much of a concern). |
| 516 VLOG(2) << "Proposing a " | 519 VLOG(2) << "Proposing a " |
| 517 << (100.0 * (increased_area - current_area) / current_area) | 520 << (100.0 * (increased_area - current_area) / current_area) |
| 518 << "% increase in capture area for non-animating content. :-)"; | 521 << "% increase in capture area for non-animating content. :-)"; |
| 519 return increased_area; | 522 return increased_area; |
| 520 } | 523 } |
| 521 | 524 |
| 522 } // namespace media | 525 } // namespace media |
| OLD | NEW |