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

Side by Side Diff: media/base/video_capture_types.cc

Issue 1439533004: Remove dead code paths around PIXEL_STORAGE_TEXTURE in capture pipeline. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: mcasas's second round comments REBASE Created 5 years, 1 month 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/video_capture_types.h ('k') | media/base/video_frame.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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/base/video_capture_types.h" 5 #include "media/base/video_capture_types.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/strings/stringprintf.h" 8 #include "base/strings/stringprintf.h"
9 #include "media/base/limits.h" 9 #include "media/base/limits.h"
10 #include "media/base/video_frame.h" 10 #include "media/base/video_frame.h"
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 pixel_storage(pixel_storage) { 50 pixel_storage(pixel_storage) {
51 } 51 }
52 52
53 bool VideoCaptureFormat::IsValid() const { 53 bool VideoCaptureFormat::IsValid() const {
54 return (frame_size.width() < media::limits::kMaxDimension) && 54 return (frame_size.width() < media::limits::kMaxDimension) &&
55 (frame_size.height() < media::limits::kMaxDimension) && 55 (frame_size.height() < media::limits::kMaxDimension) &&
56 (frame_size.GetArea() >= 0) && 56 (frame_size.GetArea() >= 0) &&
57 (frame_size.GetArea() < media::limits::kMaxCanvas) && 57 (frame_size.GetArea() < media::limits::kMaxCanvas) &&
58 (frame_rate >= 0.0f) && 58 (frame_rate >= 0.0f) &&
59 (frame_rate < media::limits::kMaxFramesPerSecond) && 59 (frame_rate < media::limits::kMaxFramesPerSecond) &&
60 (pixel_storage != PIXEL_STORAGE_TEXTURE || 60 (pixel_format >= PIXEL_FORMAT_UNKNOWN &&
61 pixel_format == PIXEL_FORMAT_ARGB); 61 pixel_format <= PIXEL_FORMAT_MAX) &&
62 (pixel_storage == PIXEL_STORAGE_CPU ||
63 pixel_storage == PIXEL_STORAGE_GPUMEMORYBUFFER);
62 } 64 }
63 65
64 size_t VideoCaptureFormat::ImageAllocationSize() const { 66 size_t VideoCaptureFormat::ImageAllocationSize() const {
65 return VideoFrame::AllocationSize(pixel_format, frame_size); 67 return VideoFrame::AllocationSize(pixel_format, frame_size);
66 } 68 }
67 69
68 //static 70 //static
69 std::string VideoCaptureFormat::ToString(const VideoCaptureFormat& format) { 71 std::string VideoCaptureFormat::ToString(const VideoCaptureFormat& format) {
70 return base::StringPrintf( 72 return base::StringPrintf(
71 "(%s)@%.3ffps, pixel format: %s storage: %s.", 73 "(%s)@%.3ffps, pixel format: %s storage: %s.",
72 format.frame_size.ToString().c_str(), format.frame_rate, 74 format.frame_size.ToString().c_str(), format.frame_rate,
73 VideoPixelFormatToString(format.pixel_format).c_str(), 75 VideoPixelFormatToString(format.pixel_format).c_str(),
74 PixelStorageToString(format.pixel_storage).c_str()); 76 PixelStorageToString(format.pixel_storage).c_str());
75 } 77 }
76 78
77 // static 79 // static
78 std::string VideoCaptureFormat::PixelStorageToString( 80 std::string VideoCaptureFormat::PixelStorageToString(
79 VideoPixelStorage storage) { 81 VideoPixelStorage storage) {
80 switch (storage) { 82 switch (storage) {
81 case PIXEL_STORAGE_CPU: 83 case PIXEL_STORAGE_CPU:
82 return "CPU"; 84 return "CPU";
83 case PIXEL_STORAGE_TEXTURE:
84 return "TEXTURE";
85 case PIXEL_STORAGE_GPUMEMORYBUFFER: 85 case PIXEL_STORAGE_GPUMEMORYBUFFER:
86 return "GPUMEMORYBUFFER"; 86 return "GPUMEMORYBUFFER";
87 } 87 }
88 NOTREACHED() << "Invalid VideoPixelStorage provided: " 88 NOTREACHED() << "Invalid VideoPixelStorage provided: "
89 << static_cast<int>(storage); 89 << static_cast<int>(storage);
90 return std::string(); 90 return std::string();
91 } 91 }
92 92
93 // static 93 // static
94 bool VideoCaptureFormat::ComparePixelFormatPreference( 94 bool VideoCaptureFormat::ComparePixelFormatPreference(
95 const VideoPixelFormat& lhs, 95 const VideoPixelFormat& lhs,
96 const VideoPixelFormat& rhs) { 96 const VideoPixelFormat& rhs) {
97 const auto& format_lhs = std::find( 97 const auto& format_lhs = std::find(
98 kSupportedCapturePixelFormats, 98 kSupportedCapturePixelFormats,
99 kSupportedCapturePixelFormats + arraysize(kSupportedCapturePixelFormats), 99 kSupportedCapturePixelFormats + arraysize(kSupportedCapturePixelFormats),
100 lhs); 100 lhs);
101 const auto& format_rhs = std::find( 101 const auto& format_rhs = std::find(
102 kSupportedCapturePixelFormats, 102 kSupportedCapturePixelFormats,
103 kSupportedCapturePixelFormats + arraysize(kSupportedCapturePixelFormats), 103 kSupportedCapturePixelFormats + arraysize(kSupportedCapturePixelFormats),
104 rhs); 104 rhs);
105 return format_lhs < format_rhs; 105 return format_lhs < format_rhs;
106 } 106 }
107 107
108 VideoCaptureParams::VideoCaptureParams() 108 VideoCaptureParams::VideoCaptureParams()
109 : resolution_change_policy(RESOLUTION_POLICY_FIXED_RESOLUTION), 109 : resolution_change_policy(RESOLUTION_POLICY_FIXED_RESOLUTION),
110 power_line_frequency(PowerLineFrequency::FREQUENCY_DEFAULT) {} 110 power_line_frequency(PowerLineFrequency::FREQUENCY_DEFAULT) {}
111 111
112 bool VideoCaptureParams::IsValid() const {
113 return requested_format.IsValid() &&
114 resolution_change_policy >= RESOLUTION_POLICY_FIXED_RESOLUTION &&
115 resolution_change_policy <= RESOLUTION_POLICY_LAST &&
116 power_line_frequency >= PowerLineFrequency::FREQUENCY_DEFAULT &&
117 power_line_frequency <= PowerLineFrequency::FREQUENCY_MAX;
118 }
119
112 } // namespace media 120 } // namespace media
OLDNEW
« no previous file with comments | « media/base/video_capture_types.h ('k') | media/base/video_frame.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698