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

Side by Side Diff: media/cast/sender/external_video_encoder.cc

Issue 2127373006: Use base::StartWith() in more places when appropriate. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase, resolve conflict Created 4 years, 5 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 | « media/base/key_systems.cc ('k') | storage/common/fileapi/file_system_util.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/cast/sender/external_video_encoder.h" 5 #include "media/cast/sender/external_video_encoder.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/command_line.h" 11 #include "base/command_line.h"
12 #include "base/debug/crash_logging.h" 12 #include "base/debug/crash_logging.h"
13 #include "base/debug/dump_without_crashing.h" 13 #include "base/debug/dump_without_crashing.h"
14 #include "base/format_macros.h" 14 #include "base/format_macros.h"
15 #include "base/logging.h" 15 #include "base/logging.h"
16 #include "base/macros.h" 16 #include "base/macros.h"
17 #include "base/memory/shared_memory.h" 17 #include "base/memory/shared_memory.h"
18 #include "base/message_loop/message_loop.h" 18 #include "base/message_loop/message_loop.h"
19 #include "base/metrics/histogram.h" 19 #include "base/metrics/histogram.h"
20 #include "base/strings/string_number_conversions.h" 20 #include "base/strings/string_number_conversions.h"
21 #include "base/strings/string_util.h"
21 #include "base/strings/stringprintf.h" 22 #include "base/strings/stringprintf.h"
22 #include "build/build_config.h" 23 #include "build/build_config.h"
23 #include "media/base/bind_to_current_loop.h" 24 #include "media/base/bind_to_current_loop.h"
24 #include "media/base/media_switches.h" 25 #include "media/base/media_switches.h"
25 #include "media/base/video_frame.h" 26 #include "media/base/video_frame.h"
26 #include "media/base/video_types.h" 27 #include "media/base/video_types.h"
27 #include "media/base/video_util.h" 28 #include "media/base/video_util.h"
28 #include "media/cast/cast_config.h" 29 #include "media/cast/cast_config.h"
29 #include "media/cast/common/rtp_time.h" 30 #include "media/cast/common/rtp_time.h"
30 #include "media/cast/logging/logging_defines.h" 31 #include "media/cast/logging/logging_defines.h"
(...skipping 26 matching lines...) Expand all
57 // TODO(miu): This is temporary, for lab performance testing, until a 58 // TODO(miu): This is temporary, for lab performance testing, until a
58 // good "works for all" solution is confirmed. 59 // good "works for all" solution is confirmed.
59 // https://code.google.com/p/chrome-os-partner/issues/detail?id=54806 60 // https://code.google.com/p/chrome-os-partner/issues/detail?id=54806
60 int GetConfiguredBacklogRedline() { 61 int GetConfiguredBacklogRedline() {
61 constexpr char kBacklogSwitchValue[] = "backlog"; 62 constexpr char kBacklogSwitchValue[] = "backlog";
62 constexpr int kBacklogDefaultRedline = 6; 63 constexpr int kBacklogDefaultRedline = 6;
63 64
64 const std::string& switch_value = 65 const std::string& switch_value =
65 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( 66 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
66 switches::kCastEncoderUtilHeuristic); 67 switches::kCastEncoderUtilHeuristic);
67 if (switch_value.find(kBacklogSwitchValue) == 0) { 68 if (!base::StartsWith(switch_value, kBacklogSwitchValue,
68 int redline = kBacklogDefaultRedline; 69 base::CompareCase::SENSITIVE)) {
69 if (!base::StringToInt(switch_value.substr(sizeof(kBacklogSwitchValue) - 1), 70 return 0;
70 &redline)) {
71 redline = kBacklogDefaultRedline;
72 }
73 VLOG(1) << "Using 'backlog' heuristic with a redline of " << redline
74 << " to compute encoder utilization.";
75 return redline;
76 } 71 }
77 return 0; 72
73 int redline = kBacklogDefaultRedline;
74 if (!base::StringToInt(switch_value.substr(sizeof(kBacklogSwitchValue) - 1),
75 &redline)) {
76 redline = kBacklogDefaultRedline;
77 }
78 VLOG(1) << "Using 'backlog' heuristic with a redline of " << redline
79 << " to compute encoder utilization.";
80 return redline;
78 } 81 }
79 82
80 } // namespace 83 } // namespace
81 84
82 namespace media { 85 namespace media {
83 namespace cast { 86 namespace cast {
84 87
85 // Container for the associated data of a video frame being processed. 88 // Container for the associated data of a video frame being processed.
86 struct InProgressFrameEncode { 89 struct InProgressFrameEncode {
87 // The source content to encode. 90 // The source content to encode.
(...skipping 863 matching lines...) Expand 10 before | Expand all | Expand 10 after
951 const double kEntropyAtMaxQuantizer = 7.5; 954 const double kEntropyAtMaxQuantizer = 7.5;
952 const double slope = 955 const double slope =
953 (MAX_VP8_QUANTIZER - MIN_VP8_QUANTIZER) / kEntropyAtMaxQuantizer; 956 (MAX_VP8_QUANTIZER - MIN_VP8_QUANTIZER) / kEntropyAtMaxQuantizer;
954 const double quantizer = std::min<double>( 957 const double quantizer = std::min<double>(
955 MAX_VP8_QUANTIZER, MIN_VP8_QUANTIZER + slope * shannon_entropy); 958 MAX_VP8_QUANTIZER, MIN_VP8_QUANTIZER + slope * shannon_entropy);
956 return quantizer; 959 return quantizer;
957 } 960 }
958 961
959 } // namespace cast 962 } // namespace cast
960 } // namespace media 963 } // namespace media
OLDNEW
« no previous file with comments | « media/base/key_systems.cc ('k') | storage/common/fileapi/file_system_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698