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

Side by Side Diff: media/capture/content/video_capture_oracle.cc

Issue 2888783004: NOINLINE in VideoCaptureOracle::IsFrameInRecentHistory to address issue 723090 (Closed)
Patch Set: Created 3 years, 7 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/compiler_specific.h"
9 #include "base/format_macros.h" 10 #include "base/format_macros.h"
10 #include "base/numerics/safe_conversions.h" 11 #include "base/numerics/safe_conversions.h"
11 #include "base/strings/stringprintf.h" 12 #include "base/strings/stringprintf.h"
12 13
13 namespace media { 14 namespace media {
14 15
15 namespace { 16 namespace {
16 17
17 // When a non-compositor event arrives after animation has halted, this 18 // When a non-compositor event arrives after animation has halted, this
18 // controls how much time must elapse before deciding to allow a capture. 19 // controls how much time must elapse before deciding to allow a capture.
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after
377 DCHECK(IsFrameInRecentHistory(frame_number)); 378 DCHECK(IsFrameInRecentHistory(frame_number));
378 return frame_timestamps_[frame_number % kMaxFrameTimestamps]; 379 return frame_timestamps_[frame_number % kMaxFrameTimestamps];
379 } 380 }
380 381
381 void VideoCaptureOracle::SetFrameTimestamp(int frame_number, 382 void VideoCaptureOracle::SetFrameTimestamp(int frame_number,
382 base::TimeTicks timestamp) { 383 base::TimeTicks timestamp) {
383 DCHECK(IsFrameInRecentHistory(frame_number)); 384 DCHECK(IsFrameInRecentHistory(frame_number));
384 frame_timestamps_[frame_number % kMaxFrameTimestamps] = timestamp; 385 frame_timestamps_[frame_number % kMaxFrameTimestamps] = timestamp;
385 } 386 }
386 387
387 bool VideoCaptureOracle::IsFrameInRecentHistory(int frame_number) const { 388 NOINLINE bool VideoCaptureOracle::IsFrameInRecentHistory(
389 int frame_number) const {
388 // Adding (next_frame_number_ >= 0) helps the compiler deduce that there 390 // Adding (next_frame_number_ >= 0) helps the compiler deduce that there
389 // is no possibility of overflow here. 391 // is no possibility of overflow here. NOINLINE is also required to ensure the
392 // compiler can make this deduction (some compilers fail to otherwise...).
390 return (frame_number >= 0 && next_frame_number_ >= 0 && 393 return (frame_number >= 0 && next_frame_number_ >= 0 &&
391 frame_number <= next_frame_number_ && 394 frame_number <= next_frame_number_ &&
392 (next_frame_number_ - frame_number) < kMaxFrameTimestamps); 395 (next_frame_number_ - frame_number) < kMaxFrameTimestamps);
393 } 396 }
394 397
395 void VideoCaptureOracle::CommitCaptureSizeAndReset( 398 void VideoCaptureOracle::CommitCaptureSizeAndReset(
396 base::TimeTicks last_frame_time) { 399 base::TimeTicks last_frame_time) {
397 capture_size_ = resolution_chooser_.capture_size(); 400 capture_size_ = resolution_chooser_.capture_size();
398 VLOG(2) << "Now proposing a capture size of " << capture_size_.ToString(); 401 VLOG(2) << "Now proposing a capture size of " << capture_size_.ToString();
399 402
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
566 // Content is not animating, so permit an immediate increase in the capture 569 // Content is not animating, so permit an immediate increase in the capture
567 // area. This allows the system to quickly improve the quality of 570 // area. This allows the system to quickly improve the quality of
568 // non-animating content (frame drops are not much of a concern). 571 // non-animating content (frame drops are not much of a concern).
569 VLOG(2) << "Proposing a " 572 VLOG(2) << "Proposing a "
570 << (100.0 * (increased_area - current_area) / current_area) 573 << (100.0 * (increased_area - current_area) / current_area)
571 << "% increase in capture area for non-animating content. :-)"; 574 << "% increase in capture area for non-animating content. :-)";
572 return increased_area; 575 return increased_area;
573 } 576 }
574 577
575 } // namespace media 578 } // namespace media
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698