| OLD | NEW |
| 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 <libdrm/drm_fourcc.h> | 5 #include <libdrm/drm_fourcc.h> |
| 6 #include <linux/videodev2.h> | 6 #include <linux/videodev2.h> |
| 7 | 7 |
| 8 #include "base/numerics/safe_conversions.h" | 8 #include "base/numerics/safe_conversions.h" |
| 9 #include "content/common/gpu/media/generic_v4l2_device.h" | 9 #include "content/common/gpu/media/generic_v4l2_device.h" |
| 10 #if defined(ARCH_CPU_ARMEL) | 10 #if defined(ARCH_CPU_ARMEL) |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 | 190 |
| 191 // Sanity checks. Calculated coded size has to contain given visible size | 191 // Sanity checks. Calculated coded size has to contain given visible size |
| 192 // and fulfill buffer byte size requirements. | 192 // and fulfill buffer byte size requirements. |
| 193 DCHECK(gfx::Rect(coded_size).Contains(gfx::Rect(visible_size))); | 193 DCHECK(gfx::Rect(coded_size).Contains(gfx::Rect(visible_size))); |
| 194 DCHECK_LE(sizeimage, | 194 DCHECK_LE(sizeimage, |
| 195 media::VideoFrame::AllocationSize(frame_format, coded_size)); | 195 media::VideoFrame::AllocationSize(frame_format, coded_size)); |
| 196 | 196 |
| 197 return coded_size; | 197 return coded_size; |
| 198 } | 198 } |
| 199 | 199 |
| 200 // static |
| 201 gfx::Size V4L2Device::GetMaxSupportedResolution( |
| 202 const scoped_refptr<V4L2Device>& device, |
| 203 unsigned int pixelformat) { |
| 204 gfx::Size max_resolution; |
| 205 v4l2_frmsizeenum frame_size; |
| 206 memset(&frame_size, 0, sizeof(frame_size)); |
| 207 frame_size.pixel_format = pixelformat; |
| 208 for (; device->Ioctl(VIDIOC_ENUM_FRAMESIZES, &frame_size) == 0; |
| 209 ++frame_size.index) { |
| 210 if (frame_size.type == V4L2_FRMIVAL_TYPE_DISCRETE) { |
| 211 if (frame_size.discrete.width > |
| 212 static_cast<unsigned int>(max_resolution.width()) && |
| 213 frame_size.discrete.height > |
| 214 static_cast<unsigned int>(max_resolution.height())) { |
| 215 max_resolution.SetSize(frame_size.discrete.width, |
| 216 frame_size.discrete.height); |
| 217 } |
| 218 } else if (frame_size.type == V4L2_FRMIVAL_TYPE_STEPWISE || |
| 219 frame_size.type == V4L2_FRMIVAL_TYPE_CONTINUOUS) { |
| 220 max_resolution.SetSize(frame_size.stepwise.max_width, |
| 221 frame_size.stepwise.max_height); |
| 222 } |
| 223 } |
| 224 if (max_resolution.IsEmpty()) { |
| 225 LOG(ERROR) << "GetMaxSupportedResolution failed for format " |
| 226 << std::hex << pixelformat; |
| 227 max_resolution.SetSize(1920, 1088); |
| 228 } |
| 229 return max_resolution; |
| 230 } |
| 231 |
| 200 } // namespace content | 232 } // namespace content |
| OLD | NEW |