Chromium Code Reviews| OLD | NEW |
|---|---|
| 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/video/capture/video_capture_device.h" | 5 #include "media/video/capture/video_capture_device.h" |
| 6 | 6 |
| 7 #include <cmath> | |
| 8 | |
| 7 #include "base/i18n/timezone.h" | 9 #include "base/i18n/timezone.h" |
| 8 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
| 9 | 11 |
| 10 namespace media { | 12 namespace media { |
| 11 | 13 |
| 12 const std::string VideoCaptureDevice::Name::GetNameAndModel() const { | 14 const std::string VideoCaptureDevice::Name::GetNameAndModel() const { |
| 13 const std::string model_id = GetModel(); | 15 const std::string model_id = GetModel(); |
| 14 if (model_id.empty()) | 16 if (model_id.empty()) |
| 15 return device_name_; | 17 return device_name_; |
| 16 const std::string suffix = " (" + model_id + ")"; | 18 const std::string suffix = " (" + model_id + ")"; |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 78 } | 80 } |
| 79 return kPowerLine60Hz; | 81 return kPowerLine60Hz; |
| 80 } | 82 } |
| 81 | 83 |
| 82 bool VideoCaptureDevice::InitializeImageCapture( | 84 bool VideoCaptureDevice::InitializeImageCapture( |
| 83 const ImageCaptureFormat& image_format, | 85 const ImageCaptureFormat& image_format, |
| 84 scoped_ptr<ImageClient> client) { | 86 scoped_ptr<ImageClient> client) { |
| 85 return false; | 87 return false; |
| 86 } | 88 } |
| 87 | 89 |
| 90 uint64_t DiffVideoCaptureFormat(const VideoCaptureFormat& requested, | |
| 91 const VideoCaptureFormat& supported) { | |
| 92 const uint64_t diff_width = | |
| 93 std::abs(requested.frame_size.width() - supported.frame_size.width()); | |
| 94 const uint64_t diff_height = | |
| 95 std::abs(requested.frame_size.height() - supported.frame_size.height()); | |
| 96 // We need to distinguish between rational frame rates (e.g. 29.97 and 30.0). | |
| 97 // Therefore, multiply with a large constant before converting to int. | |
| 98 const uint64_t diff_frame_rate = static_cast<uint64_t>( | |
| 99 kFrameRatePrecision * | |
| 100 std::fabs(requested.frame_rate - supported.frame_rate)); | |
| 101 const uint64_t diff_color_format = supported.pixel_format; | |
|
mcasas
2014/10/13 08:18:45
s/diff_color_format/diff_pixel_format/g
Forgot to
| |
| 102 | |
| 103 const int resolution_bit_size = 16; | |
|
mcasas
2014/10/13 08:18:45
s/resolution_bit_size/kResolutionBitSize/
this al
| |
| 104 const int frame_rate_bit_size = 24; | |
| 105 const int color_format_bit_size = 8; | |
| 106 | |
| 107 DCHECK(diff_width < (1 << resolution_bit_size)); | |
| 108 DCHECK(diff_height < (1 << resolution_bit_size)); | |
| 109 DCHECK(diff_frame_rate < (1 << frame_rate_bit_size)); | |
| 110 DCHECK(diff_color_format < (1 << color_format_bit_size)); | |
| 111 | |
| 112 uint64_t distance = diff_height; | |
|
mcasas
2014/10/13 08:18:45
From this point on, this seems to be an obscure li
| |
| 113 distance = diff_width | (distance << resolution_bit_size); | |
| 114 distance = diff_frame_rate | (distance << frame_rate_bit_size); | |
| 115 distance = diff_color_format | (distance << color_format_bit_size); | |
| 116 return distance; | |
| 117 } | |
| 118 | |
| 88 } // namespace media | 119 } // namespace media |
| OLD | NEW |