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 432 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 443 } | 443 } |
| 444 | 444 |
| 445 bool V4L2VideoDecodeAccelerator::CanDecodeOnIOThread() { return true; } | 445 bool V4L2VideoDecodeAccelerator::CanDecodeOnIOThread() { return true; } |
| 446 | 446 |
| 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; |
|
wuchengli
2015/04/23 07:11:44
return SupportedProfiles(). remove |profiles|
henryhsu
2015/04/23 08:21:54
Done.
| |
| 454 | 454 |
| 455 SupportedProfile profile; | 455 return device->GetSupportedDecodeProfiles(std::vector<uint32_t>( |
| 456 profile.min_resolution.SetSize(16, 16); | 456 {V4L2_PIX_FMT_H264, V4L2_PIX_FMT_VP8, V4L2_PIX_FMT_VP9})); |
| 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; | |
| 466 memset(&fmtdesc, 0, sizeof(fmtdesc)); | |
| 467 fmtdesc.type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE; | |
| 468 for (; device->Ioctl(VIDIOC_ENUM_FMT, &fmtdesc) == 0; ++fmtdesc.index) { | |
| 469 switch (fmtdesc.pixelformat) { | |
| 470 case V4L2_PIX_FMT_H264: | |
| 471 for (uint32 media_profile = media::H264PROFILE_MIN; | |
| 472 media_profile <= media::H264PROFILE_MAX; ++media_profile) { | |
| 473 profile.profile = | |
| 474 static_cast<media::VideoCodecProfile>(media_profile); | |
| 475 profiles.push_back(profile); | |
| 476 } | |
| 477 break; | |
| 478 case V4L2_PIX_FMT_VP8: | |
| 479 profile.profile = media::VP8PROFILE_ANY; | |
| 480 profiles.push_back(profile); | |
| 481 break; | |
| 482 case V4L2_PIX_FMT_VP9: | |
| 483 profile.profile = media::VP9PROFILE_ANY; | |
| 484 profiles.push_back(profile); | |
| 485 break; | |
| 486 } | |
| 487 } | |
| 488 | |
| 489 return profiles; | |
| 490 } | 457 } |
| 491 | 458 |
| 492 void V4L2VideoDecodeAccelerator::DecodeTask( | 459 void V4L2VideoDecodeAccelerator::DecodeTask( |
| 493 const media::BitstreamBuffer& bitstream_buffer) { | 460 const media::BitstreamBuffer& bitstream_buffer) { |
| 494 DVLOG(3) << "DecodeTask(): input_id=" << bitstream_buffer.id(); | 461 DVLOG(3) << "DecodeTask(): input_id=" << bitstream_buffer.id(); |
| 495 DCHECK_EQ(decoder_thread_.message_loop(), base::MessageLoop::current()); | 462 DCHECK_EQ(decoder_thread_.message_loop(), base::MessageLoop::current()); |
| 496 DCHECK_NE(decoder_state_, kUninitialized); | 463 DCHECK_NE(decoder_state_, kUninitialized); |
| 497 TRACE_EVENT1("Video Decoder", "V4L2VDA::DecodeTask", "input_id", | 464 TRACE_EVENT1("Video Decoder", "V4L2VDA::DecodeTask", "input_id", |
| 498 bitstream_buffer.id()); | 465 bitstream_buffer.id()); |
| 499 | 466 |
| (...skipping 1292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1792 DCHECK(!output_streamon_); | 1759 DCHECK(!output_streamon_); |
| 1793 | 1760 |
| 1794 __u32 input_format_fourcc = | 1761 __u32 input_format_fourcc = |
| 1795 V4L2Device::VideoCodecProfileToV4L2PixFmt(video_profile_, false); | 1762 V4L2Device::VideoCodecProfileToV4L2PixFmt(video_profile_, false); |
| 1796 if (!input_format_fourcc) { | 1763 if (!input_format_fourcc) { |
| 1797 NOTREACHED(); | 1764 NOTREACHED(); |
| 1798 return false; | 1765 return false; |
| 1799 } | 1766 } |
| 1800 | 1767 |
| 1801 size_t input_size; | 1768 size_t input_size; |
| 1802 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 1769 gfx::Size max_resolution = |
| 1803 switches::kIgnoreResolutionLimitsForAcceleratedVideoDecode)) | 1770 device_->GetMaxSupportedResolution(input_format_fourcc); |
| 1771 if (max_resolution.width() >= 1920 && max_resolution.height() >= 1080) | |
|
wuchengli
2015/04/23 07:11:44
s/>=/>/
henryhsu
2015/04/23 08:21:54
Done.
| |
| 1804 input_size = kInputBufferMaxSizeFor4k; | 1772 input_size = kInputBufferMaxSizeFor4k; |
| 1805 else | 1773 else |
| 1806 input_size = kInputBufferMaxSizeFor1080p; | 1774 input_size = kInputBufferMaxSizeFor1080p; |
| 1807 | 1775 |
| 1808 struct v4l2_format format; | 1776 struct v4l2_format format; |
| 1809 memset(&format, 0, sizeof(format)); | 1777 memset(&format, 0, sizeof(format)); |
| 1810 format.type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE; | 1778 format.type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE; |
| 1811 format.fmt.pix_mp.pixelformat = input_format_fourcc; | 1779 format.fmt.pix_mp.pixelformat = input_format_fourcc; |
| 1812 format.fmt.pix_mp.plane_fmt[0].sizeimage = input_size; | 1780 format.fmt.pix_mp.plane_fmt[0].sizeimage = input_size; |
| 1813 format.fmt.pix_mp.num_planes = 1; | 1781 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), | 2025 gfx::Size new_coded_size(base::checked_cast<int>(format.fmt.pix_mp.width), |
| 2058 base::checked_cast<int>(format.fmt.pix_mp.height)); | 2026 base::checked_cast<int>(format.fmt.pix_mp.height)); |
| 2059 if (coded_size_ != new_coded_size) { | 2027 if (coded_size_ != new_coded_size) { |
| 2060 DVLOG(3) << "IsResolutionChangeNecessary(): Resolution change detected"; | 2028 DVLOG(3) << "IsResolutionChangeNecessary(): Resolution change detected"; |
| 2061 return true; | 2029 return true; |
| 2062 } | 2030 } |
| 2063 return false; | 2031 return false; |
| 2064 } | 2032 } |
| 2065 | 2033 |
| 2066 } // namespace content | 2034 } // namespace content |
| OLD | NEW |