Chromium Code Reviews| 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 <dlfcn.h> | 5 #include <dlfcn.h> |
| 6 #include <errno.h> | 6 #include <errno.h> |
| 7 #include <fcntl.h> | 7 #include <fcntl.h> |
| 8 #include <linux/videodev2.h> | 8 #include <linux/videodev2.h> |
| 9 #include <poll.h> | 9 #include <poll.h> |
| 10 #include <sys/eventfd.h> | 10 #include <sys/eventfd.h> |
| (...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 447 // static | 447 // static |
| 448 media::VideoDecodeAccelerator::SupportedProfiles | 448 media::VideoDecodeAccelerator::SupportedProfiles |
| 449 V4L2VideoDecodeAccelerator::GetSupportedProfiles() { | 449 V4L2VideoDecodeAccelerator::GetSupportedProfiles() { |
| 450 SupportedProfiles profiles; | 450 SupportedProfiles profiles; |
| 451 scoped_refptr<V4L2Device> device = V4L2Device::Create(V4L2Device::kDecoder); | 451 scoped_refptr<V4L2Device> device = V4L2Device::Create(V4L2Device::kDecoder); |
| 452 if (!device) | 452 if (!device) |
| 453 return profiles; | 453 return profiles; |
| 454 | 454 |
| 455 SupportedProfile profile; | 455 SupportedProfile profile; |
| 456 profile.min_resolution.SetSize(16, 16); | 456 profile.min_resolution.SetSize(16, 16); |
| 457 // NOTE: additional autodetection logic may require updating input buffer size | |
| 458 // selection. | |
| 459 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | |
| 460 switches::kIgnoreResolutionLimitsForAcceleratedVideoDecode)) | |
| 461 profile.max_resolution.SetSize(4096, 2160); | |
| 462 else | |
| 463 profile.max_resolution.SetSize(1920, 1088); | |
| 464 | |
| 465 v4l2_fmtdesc fmtdesc; | 457 v4l2_fmtdesc fmtdesc; |
| 466 memset(&fmtdesc, 0, sizeof(fmtdesc)); | 458 memset(&fmtdesc, 0, sizeof(fmtdesc)); |
| 467 fmtdesc.type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE; | 459 fmtdesc.type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE; |
| 468 for (; device->Ioctl(VIDIOC_ENUM_FMT, &fmtdesc) == 0; ++fmtdesc.index) { | 460 for (; device->Ioctl(VIDIOC_ENUM_FMT, &fmtdesc) == 0; ++fmtdesc.index) { |
| 461 // Get maximum resolution for each format | |
| 462 profile.max_resolution = V4L2Device::GetSupportedMaxResolution( | |
| 463 device, fmtdesc.pixelformat); | |
| 464 if (profile.max_resolution.IsEmpty()) { | |
| 465 LOG(ERROR) << "GetSupportedMaxResolution failed for format " | |
| 466 << std::hex << fmtdesc.pixelformat; | |
| 467 profile.max_resolution.SetSize(1920, 1088); | |
|
wuchengli
2015/04/20 14:05:16
This should be handled in V4L2Device::GetSupported
henryhsu
2015/04/21 05:56:27
Done.
| |
| 468 } | |
| 469 switch (fmtdesc.pixelformat) { | 469 switch (fmtdesc.pixelformat) { |
| 470 case V4L2_PIX_FMT_H264: | 470 case V4L2_PIX_FMT_H264: |
| 471 for (uint32 media_profile = media::H264PROFILE_MIN; | 471 for (uint32 media_profile = media::H264PROFILE_MIN; |
| 472 media_profile <= media::H264PROFILE_MAX; ++media_profile) { | 472 media_profile <= media::H264PROFILE_MAX; ++media_profile) { |
| 473 profile.profile = | 473 profile.profile = |
| 474 static_cast<media::VideoCodecProfile>(media_profile); | 474 static_cast<media::VideoCodecProfile>(media_profile); |
| 475 profiles.push_back(profile); | 475 profiles.push_back(profile); |
| 476 } | 476 } |
| 477 break; | 477 break; |
| 478 case V4L2_PIX_FMT_VP8: | 478 case V4L2_PIX_FMT_VP8: |
| (...skipping 1313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1792 DCHECK(!output_streamon_); | 1792 DCHECK(!output_streamon_); |
| 1793 | 1793 |
| 1794 __u32 input_format_fourcc = | 1794 __u32 input_format_fourcc = |
| 1795 V4L2Device::VideoCodecProfileToV4L2PixFmt(video_profile_, false); | 1795 V4L2Device::VideoCodecProfileToV4L2PixFmt(video_profile_, false); |
| 1796 if (!input_format_fourcc) { | 1796 if (!input_format_fourcc) { |
| 1797 NOTREACHED(); | 1797 NOTREACHED(); |
| 1798 return false; | 1798 return false; |
| 1799 } | 1799 } |
| 1800 | 1800 |
| 1801 size_t input_size; | 1801 size_t input_size; |
| 1802 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 1802 gfx::Size max_resolution = V4L2Device::GetSupportedMaxResolution( |
| 1803 switches::kIgnoreResolutionLimitsForAcceleratedVideoDecode)) | 1803 device_, input_format_fourcc); |
| 1804 if (max_resolution.width() >= 4096 && max_resolution.height() >= 2160) | |
| 1804 input_size = kInputBufferMaxSizeFor4k; | 1805 input_size = kInputBufferMaxSizeFor4k; |
| 1805 else | 1806 else |
| 1806 input_size = kInputBufferMaxSizeFor1080p; | 1807 input_size = kInputBufferMaxSizeFor1080p; |
| 1807 | 1808 |
| 1808 struct v4l2_format format; | 1809 struct v4l2_format format; |
| 1809 memset(&format, 0, sizeof(format)); | 1810 memset(&format, 0, sizeof(format)); |
| 1810 format.type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE; | 1811 format.type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE; |
| 1811 format.fmt.pix_mp.pixelformat = input_format_fourcc; | 1812 format.fmt.pix_mp.pixelformat = input_format_fourcc; |
| 1812 format.fmt.pix_mp.plane_fmt[0].sizeimage = input_size; | 1813 format.fmt.pix_mp.plane_fmt[0].sizeimage = input_size; |
| 1813 format.fmt.pix_mp.num_planes = 1; | 1814 format.fmt.pix_mp.num_planes = 1; |
| (...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2057 gfx::Size new_coded_size(base::checked_cast<int>(format.fmt.pix_mp.width), | 2058 gfx::Size new_coded_size(base::checked_cast<int>(format.fmt.pix_mp.width), |
| 2058 base::checked_cast<int>(format.fmt.pix_mp.height)); | 2059 base::checked_cast<int>(format.fmt.pix_mp.height)); |
| 2059 if (coded_size_ != new_coded_size) { | 2060 if (coded_size_ != new_coded_size) { |
| 2060 DVLOG(3) << "IsResolutionChangeNecessary(): Resolution change detected"; | 2061 DVLOG(3) << "IsResolutionChangeNecessary(): Resolution change detected"; |
| 2061 return true; | 2062 return true; |
| 2062 } | 2063 } |
| 2063 return false; | 2064 return false; |
| 2064 } | 2065 } |
| 2065 | 2066 |
| 2066 } // namespace content | 2067 } // namespace content |
| OLD | NEW |