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 | |
|
Pawel Osciak
2015/04/22 08:50:56
Ditto.
henryhsu
2015/04/23 03:56:43
Done.
| |
| 462 profile.max_resolution = device->GetMaxSupportedResolution( | |
| 463 fmtdesc.pixelformat); | |
| 469 switch (fmtdesc.pixelformat) { | 464 switch (fmtdesc.pixelformat) { |
| 470 case V4L2_PIX_FMT_H264: | 465 case V4L2_PIX_FMT_H264: |
| 471 for (uint32 media_profile = media::H264PROFILE_MIN; | 466 for (uint32 media_profile = media::H264PROFILE_MIN; |
| 472 media_profile <= media::H264PROFILE_MAX; ++media_profile) { | 467 media_profile <= media::H264PROFILE_MAX; ++media_profile) { |
| 473 profile.profile = | 468 profile.profile = |
| 474 static_cast<media::VideoCodecProfile>(media_profile); | 469 static_cast<media::VideoCodecProfile>(media_profile); |
| 475 profiles.push_back(profile); | 470 profiles.push_back(profile); |
| 476 } | 471 } |
| 477 break; | 472 break; |
| 478 case V4L2_PIX_FMT_VP8: | 473 case V4L2_PIX_FMT_VP8: |
| (...skipping 1313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1792 DCHECK(!output_streamon_); | 1787 DCHECK(!output_streamon_); |
| 1793 | 1788 |
| 1794 __u32 input_format_fourcc = | 1789 __u32 input_format_fourcc = |
| 1795 V4L2Device::VideoCodecProfileToV4L2PixFmt(video_profile_, false); | 1790 V4L2Device::VideoCodecProfileToV4L2PixFmt(video_profile_, false); |
| 1796 if (!input_format_fourcc) { | 1791 if (!input_format_fourcc) { |
| 1797 NOTREACHED(); | 1792 NOTREACHED(); |
| 1798 return false; | 1793 return false; |
| 1799 } | 1794 } |
| 1800 | 1795 |
| 1801 size_t input_size; | 1796 size_t input_size; |
| 1802 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 1797 gfx::Size max_resolution = device_->GetMaxSupportedResolution( |
| 1803 switches::kIgnoreResolutionLimitsForAcceleratedVideoDecode)) | 1798 input_format_fourcc); |
| 1799 if (max_resolution.width() >= 4096 && max_resolution.height() >= 2160) | |
| 1804 input_size = kInputBufferMaxSizeFor4k; | 1800 input_size = kInputBufferMaxSizeFor4k; |
| 1805 else | 1801 else |
| 1806 input_size = kInputBufferMaxSizeFor1080p; | 1802 input_size = kInputBufferMaxSizeFor1080p; |
| 1807 | 1803 |
| 1808 struct v4l2_format format; | 1804 struct v4l2_format format; |
| 1809 memset(&format, 0, sizeof(format)); | 1805 memset(&format, 0, sizeof(format)); |
| 1810 format.type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE; | 1806 format.type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE; |
| 1811 format.fmt.pix_mp.pixelformat = input_format_fourcc; | 1807 format.fmt.pix_mp.pixelformat = input_format_fourcc; |
| 1812 format.fmt.pix_mp.plane_fmt[0].sizeimage = input_size; | 1808 format.fmt.pix_mp.plane_fmt[0].sizeimage = input_size; |
| 1813 format.fmt.pix_mp.num_planes = 1; | 1809 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), | 2053 gfx::Size new_coded_size(base::checked_cast<int>(format.fmt.pix_mp.width), |
| 2058 base::checked_cast<int>(format.fmt.pix_mp.height)); | 2054 base::checked_cast<int>(format.fmt.pix_mp.height)); |
| 2059 if (coded_size_ != new_coded_size) { | 2055 if (coded_size_ != new_coded_size) { |
| 2060 DVLOG(3) << "IsResolutionChangeNecessary(): Resolution change detected"; | 2056 DVLOG(3) << "IsResolutionChangeNecessary(): Resolution change detected"; |
| 2061 return true; | 2057 return true; |
| 2062 } | 2058 } |
| 2063 return false; | 2059 return false; |
| 2064 } | 2060 } |
| 2065 | 2061 |
| 2066 } // namespace content | 2062 } // namespace content |
| OLD | NEW |