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 gfx::Size V4L2Device::GetMaxSupportedResolution(unsigned int pixelformat) { | |
201 gfx::Size max_resolution; | |
202 v4l2_frmsizeenum frame_size; | |
203 memset(&frame_size, 0, sizeof(frame_size)); | |
204 frame_size.pixel_format = pixelformat; | |
205 for (; Ioctl(VIDIOC_ENUM_FRAMESIZES, &frame_size) == 0; ++frame_size.index) { | |
206 if (frame_size.type == V4L2_FRMIVAL_TYPE_DISCRETE) { | |
Pawel Osciak
2015/04/22 08:50:55
This define is for framerate enumeration. The corr
henryhsu
2015/04/23 03:56:42
Done.
| |
207 if (frame_size.discrete.width > | |
Pawel Osciak
2015/04/22 08:50:55
Perhaps merge into the if above?
henryhsu
2015/04/23 03:56:42
Done.
| |
208 static_cast<unsigned int>(max_resolution.width()) && | |
Pawel Osciak
2015/04/22 08:50:55
I'd prefer base::checked_cast on frame_size.discre
henryhsu
2015/04/23 03:56:42
Done.
| |
209 frame_size.discrete.height > | |
210 static_cast<unsigned int>(max_resolution.height())) { | |
211 max_resolution.SetSize(frame_size.discrete.width, | |
Pawel Osciak
2015/04/22 08:50:55
If you get say 640x360 and next 640x480, I think t
Pawel Osciak
2015/04/22 10:01:38
Sorry, not this, but probably s/>/>=/ ?
henryhsu
2015/04/23 03:56:42
Use || may have the case: first is 640x480, second
| |
212 frame_size.discrete.height); | |
213 } | |
214 } else if (frame_size.type == V4L2_FRMIVAL_TYPE_STEPWISE || | |
215 frame_size.type == V4L2_FRMIVAL_TYPE_CONTINUOUS) { | |
216 max_resolution.SetSize(frame_size.stepwise.max_width, | |
217 frame_size.stepwise.max_height); | |
Pawel Osciak
2015/04/22 08:50:55
You could break here to avoid an additional ioctl
henryhsu
2015/04/23 03:56:42
Done.
| |
218 } | |
219 } | |
220 if (max_resolution.IsEmpty()) { | |
221 LOG(ERROR) << "GetMaxSupportedResolution failed for format " | |
Pawel Osciak
2015/04/22 08:50:55
s/format/fourcc/
henryhsu
2015/04/23 03:56:42
Done.
| |
222 << std::hex << pixelformat; | |
223 max_resolution.SetSize(1920, 1088); | |
Pawel Osciak
2015/04/22 08:50:55
Please also say that we are falling back to 1088p
henryhsu
2015/04/23 03:56:42
Done.
| |
224 } | |
225 return max_resolution; | |
226 } | |
227 | |
200 } // namespace content | 228 } // namespace content |
OLD | NEW |