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

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

Issue 1204843004: Revert of Video Capture: extract storage info from pixel format in VideoCaptureFormat. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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/video_capture_types.h ('k') | media/capture/screen_capture_device_core.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 10
11 namespace media { 11 namespace media {
12 12
13 VideoCaptureFormat::VideoCaptureFormat() 13 VideoCaptureFormat::VideoCaptureFormat()
14 : frame_rate(0.0f), 14 : frame_rate(0.0f), pixel_format(PIXEL_FORMAT_UNKNOWN) {}
15 pixel_format(PIXEL_FORMAT_UNKNOWN),
16 pixel_storage(PIXEL_STORAGE_CPU) {
17 }
18 15
19 VideoCaptureFormat::VideoCaptureFormat(const gfx::Size& frame_size, 16 VideoCaptureFormat::VideoCaptureFormat(const gfx::Size& frame_size,
20 float frame_rate, 17 float frame_rate,
21 VideoPixelFormat pixel_format) 18 VideoPixelFormat pixel_format)
22 : frame_size(frame_size), 19 : frame_size(frame_size),
23 frame_rate(frame_rate), 20 frame_rate(frame_rate),
24 pixel_format(pixel_format), 21 pixel_format(pixel_format) {}
25 pixel_storage(PIXEL_STORAGE_CPU) {}
26
27 VideoCaptureFormat::VideoCaptureFormat(const gfx::Size& frame_size,
28 float frame_rate,
29 VideoPixelFormat pixel_format,
30 VideoPixelStorage pixel_storage)
31 : frame_size(frame_size),
32 frame_rate(frame_rate),
33 pixel_format(pixel_format),
34 pixel_storage(pixel_storage) {}
35 22
36 bool VideoCaptureFormat::IsValid() const { 23 bool VideoCaptureFormat::IsValid() const {
37 return (frame_size.width() < media::limits::kMaxDimension) && 24 return (frame_size.width() < media::limits::kMaxDimension) &&
38 (frame_size.height() < media::limits::kMaxDimension) && 25 (frame_size.height() < media::limits::kMaxDimension) &&
39 (frame_size.GetArea() >= 0) && 26 (frame_size.GetArea() >= 0) &&
40 (frame_size.GetArea() < media::limits::kMaxCanvas) && 27 (frame_size.GetArea() < media::limits::kMaxCanvas) &&
41 (frame_rate >= 0.0f) && 28 (frame_rate >= 0.0f) &&
42 (frame_rate < media::limits::kMaxFramesPerSecond) && 29 (frame_rate < media::limits::kMaxFramesPerSecond) &&
43 (pixel_format >= 0) && (pixel_format < PIXEL_FORMAT_MAX) && 30 (pixel_format >= 0) &&
44 (pixel_storage != PIXEL_STORAGE_TEXTURE || 31 (pixel_format < PIXEL_FORMAT_MAX);
45 pixel_format == PIXEL_FORMAT_ARGB);
46 } 32 }
47 33
48 size_t VideoCaptureFormat::ImageAllocationSize() const { 34 size_t VideoCaptureFormat::ImageAllocationSize() const {
49 size_t result_frame_size = frame_size.GetArea(); 35 size_t result_frame_size = frame_size.GetArea();
50 switch (pixel_format) { 36 switch (pixel_format) {
51 case PIXEL_FORMAT_I420: 37 case PIXEL_FORMAT_I420:
52 case PIXEL_FORMAT_YV12: 38 case PIXEL_FORMAT_YV12:
53 case PIXEL_FORMAT_NV12: 39 case PIXEL_FORMAT_NV12:
54 case PIXEL_FORMAT_NV21: 40 case PIXEL_FORMAT_NV21:
55 result_frame_size = result_frame_size * 3 / 2; 41 result_frame_size = result_frame_size * 3 / 2;
56 break; 42 break;
57 case PIXEL_FORMAT_UYVY: 43 case PIXEL_FORMAT_UYVY:
58 case PIXEL_FORMAT_YUY2: 44 case PIXEL_FORMAT_YUY2:
59 result_frame_size *= 2; 45 result_frame_size *= 2;
60 break; 46 break;
61 case PIXEL_FORMAT_RGB24: 47 case PIXEL_FORMAT_RGB24:
62 result_frame_size *= 3; 48 result_frame_size *= 3;
63 break; 49 break;
64 case PIXEL_FORMAT_RGB32: 50 case PIXEL_FORMAT_RGB32:
65 case PIXEL_FORMAT_ARGB: 51 case PIXEL_FORMAT_ARGB:
52 // GpuMemoryBuffer is an endianness-agnostic 32bpp pixel format until
53 // http://crbug.com/439520 is closed.
54 case PIXEL_FORMAT_GPUMEMORYBUFFER:
66 result_frame_size *= 4; 55 result_frame_size *= 4;
67 break; 56 break;
68 case PIXEL_FORMAT_MJPEG: 57 case PIXEL_FORMAT_MJPEG:
58 case PIXEL_FORMAT_TEXTURE:
69 result_frame_size = 0; 59 result_frame_size = 0;
70 break; 60 break;
71 default: // Sizes for the rest of the formats are unknown. 61 default: // Sizes for the rest of the formats are unknown.
72 NOTREACHED() << "Unknown pixel format provided."; 62 NOTREACHED() << "Unknown pixel format provided.";
73 break; 63 break;
74 } 64 }
75 return result_frame_size; 65 return result_frame_size;
76 } 66 }
77 67
78 std::string VideoCaptureFormat::ToString() const { 68 std::string VideoCaptureFormat::ToString() const {
79 return base::StringPrintf( 69 return base::StringPrintf("resolution: %s, fps: %.3f, pixel format: %s",
80 "(%s)@%.3ffps, pixel format: %s storage: %s.", 70 frame_size.ToString().c_str(),
81 frame_size.ToString().c_str(), frame_rate, 71 frame_rate,
82 PixelFormatToString(pixel_format).c_str(), 72 PixelFormatToString(pixel_format).c_str());
83 PixelStorageToString(pixel_storage).c_str());
84 } 73 }
85 74
86 std::string VideoCaptureFormat::PixelFormatToString(VideoPixelFormat format) { 75 std::string VideoCaptureFormat::PixelFormatToString(VideoPixelFormat format) {
87 switch (format) { 76 switch (format) {
88 case PIXEL_FORMAT_UNKNOWN: 77 case PIXEL_FORMAT_UNKNOWN:
89 return "UNKNOWN"; 78 return "UNKNOWN";
90 case PIXEL_FORMAT_I420: 79 case PIXEL_FORMAT_I420:
91 return "I420"; 80 return "I420";
92 case PIXEL_FORMAT_YUY2: 81 case PIXEL_FORMAT_YUY2:
93 return "YUY2"; 82 return "YUY2";
94 case PIXEL_FORMAT_UYVY: 83 case PIXEL_FORMAT_UYVY:
95 return "UYVY"; 84 return "UYVY";
96 case PIXEL_FORMAT_RGB24: 85 case PIXEL_FORMAT_RGB24:
97 return "RGB24"; 86 return "RGB24";
98 case PIXEL_FORMAT_RGB32: 87 case PIXEL_FORMAT_RGB32:
99 return "RGB32"; 88 return "RGB32";
100 case PIXEL_FORMAT_ARGB: 89 case PIXEL_FORMAT_ARGB:
101 return "ARGB"; 90 return "ARGB";
102 case PIXEL_FORMAT_MJPEG: 91 case PIXEL_FORMAT_MJPEG:
103 return "MJPEG"; 92 return "MJPEG";
104 case PIXEL_FORMAT_NV12: 93 case PIXEL_FORMAT_NV12:
105 return "NV12"; 94 return "NV12";
106 case PIXEL_FORMAT_NV21: 95 case PIXEL_FORMAT_NV21:
107 return "NV21"; 96 return "NV21";
108 case PIXEL_FORMAT_YV12: 97 case PIXEL_FORMAT_YV12:
109 return "YV12"; 98 return "YV12";
99 case PIXEL_FORMAT_TEXTURE:
100 return "TEXTURE";
101 case PIXEL_FORMAT_GPUMEMORYBUFFER:
102 return "GPUMEMORYBUFFER";
110 case PIXEL_FORMAT_MAX: 103 case PIXEL_FORMAT_MAX:
111 break; 104 break;
112 } 105 }
113 NOTREACHED() << "Invalid VideoPixelFormat provided: " << format; 106 NOTREACHED() << "Invalid VideoPixelFormat provided: " << format;
114 return ""; 107 return "";
115 } 108 }
116 109
117 std::string VideoCaptureFormat::PixelStorageToString(
118 VideoPixelStorage storage) {
119 switch (storage) {
120 case PIXEL_STORAGE_CPU:
121 return "CPU";
122 case PIXEL_STORAGE_TEXTURE:
123 return "TEXTURE";
124 case PIXEL_STORAGE_GPUMEMORYBUFFER:
125 return "GPUMEMORYBUFFER";
126 }
127 NOTREACHED() << "Invalid VideoPixelStorage provided: " << storage;
128 return "";
129 }
130
131 VideoCaptureParams::VideoCaptureParams() 110 VideoCaptureParams::VideoCaptureParams()
132 : resolution_change_policy(RESOLUTION_POLICY_FIXED_RESOLUTION) 111 : resolution_change_policy(RESOLUTION_POLICY_FIXED_RESOLUTION)
133 #if defined(OS_LINUX) 112 #if defined(OS_LINUX)
134 , use_native_gpu_memory_buffers(false) 113 , use_native_gpu_memory_buffers(false)
135 #endif 114 #endif
136 {} 115 {}
137 116
138 } // namespace media 117 } // namespace media
OLDNEW
« no previous file with comments | « media/base/video_capture_types.h ('k') | media/capture/screen_capture_device_core.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698