OLD | NEW |
---|---|
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 <fcntl.h> | 5 #include <fcntl.h> |
6 #include <linux/videodev2.h> | 6 #include <linux/videodev2.h> |
7 #include <poll.h> | 7 #include <poll.h> |
8 #include <sys/eventfd.h> | 8 #include <sys/eventfd.h> |
9 #include <sys/ioctl.h> | 9 #include <sys/ioctl.h> |
10 #include <sys/mman.h> | 10 #include <sys/mman.h> |
(...skipping 558 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
569 DCHECK_EQ(state_, kUninitialized); | 569 DCHECK_EQ(state_, kUninitialized); |
570 | 570 |
571 __u32 input_format_fourcc = | 571 __u32 input_format_fourcc = |
572 V4L2Device::VideoCodecProfileToV4L2PixFmt(video_profile_, true); | 572 V4L2Device::VideoCodecProfileToV4L2PixFmt(video_profile_, true); |
573 if (!input_format_fourcc) { | 573 if (!input_format_fourcc) { |
574 NOTREACHED(); | 574 NOTREACHED(); |
575 return false; | 575 return false; |
576 } | 576 } |
577 | 577 |
578 size_t input_size; | 578 size_t input_size; |
579 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 579 gfx::Size max_resolution = device_->GetMaxSupportedResolution( |
580 switches::kIgnoreResolutionLimitsForAcceleratedVideoDecode)) | 580 input_format_fourcc); |
581 if (max_resolution.width() >= 1920 && max_resolution.height() >= 1080) | |
wuchengli
2015/04/23 07:11:44
This should be >, not >=.
s/1080/1088/ because th
henryhsu
2015/04/23 08:21:54
Done.
| |
581 input_size = kInputBufferMaxSizeFor4k; | 582 input_size = kInputBufferMaxSizeFor4k; |
582 else | 583 else |
583 input_size = kInputBufferMaxSizeFor1080p; | 584 input_size = kInputBufferMaxSizeFor1080p; |
584 | 585 |
585 struct v4l2_format format; | 586 struct v4l2_format format; |
586 memset(&format, 0, sizeof(format)); | 587 memset(&format, 0, sizeof(format)); |
587 format.type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE; | 588 format.type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE; |
588 format.fmt.pix_mp.pixelformat = input_format_fourcc; | 589 format.fmt.pix_mp.pixelformat = input_format_fourcc; |
589 format.fmt.pix_mp.plane_fmt[0].sizeimage = input_size; | 590 format.fmt.pix_mp.plane_fmt[0].sizeimage = input_size; |
590 format.fmt.pix_mp.num_planes = input_planes_count_; | 591 format.fmt.pix_mp.num_planes = input_planes_count_; |
(...skipping 1906 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2497 bool V4L2SliceVideoDecodeAccelerator::CanDecodeOnIOThread() { | 2498 bool V4L2SliceVideoDecodeAccelerator::CanDecodeOnIOThread() { |
2498 return true; | 2499 return true; |
2499 } | 2500 } |
2500 | 2501 |
2501 // static | 2502 // static |
2502 media::VideoDecodeAccelerator::SupportedProfiles | 2503 media::VideoDecodeAccelerator::SupportedProfiles |
2503 V4L2SliceVideoDecodeAccelerator::GetSupportedProfiles() { | 2504 V4L2SliceVideoDecodeAccelerator::GetSupportedProfiles() { |
2504 SupportedProfiles profiles; | 2505 SupportedProfiles profiles; |
2505 scoped_refptr<V4L2Device> device = V4L2Device::Create(V4L2Device::kDecoder); | 2506 scoped_refptr<V4L2Device> device = V4L2Device::Create(V4L2Device::kDecoder); |
2506 if (!device) | 2507 if (!device) |
2507 return profiles; | 2508 return profiles; |
wuchengli
2015/04/23 07:11:44
return SupportedProfiles(). remove |profiles|
henryhsu
2015/04/23 08:21:54
Done.
| |
2508 | 2509 |
2509 SupportedProfile profile; | 2510 return device->GetSupportedDecodeProfiles(std::vector<uint32_t>( |
2510 profile.min_resolution.SetSize(16, 16); | 2511 {V4L2_PIX_FMT_H264_SLICE, V4L2_PIX_FMT_VP8_FRAME})); |
2511 // NOTE: additional autodetection logic may require updating input buffer size | |
2512 // selection. | |
2513 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | |
2514 switches::kIgnoreResolutionLimitsForAcceleratedVideoDecode)) | |
2515 profile.max_resolution.SetSize(4096, 2160); | |
2516 else | |
2517 profile.max_resolution.SetSize(1920, 1088); | |
2518 | |
2519 v4l2_fmtdesc fmtdesc; | |
2520 memset(&fmtdesc, 0, sizeof(fmtdesc)); | |
2521 fmtdesc.type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE; | |
2522 for (; device->Ioctl(VIDIOC_ENUM_FMT, &fmtdesc) == 0; ++fmtdesc.index) { | |
2523 switch (fmtdesc.pixelformat) { | |
2524 case V4L2_PIX_FMT_H264_SLICE: | |
2525 for (uint32 media_profile = media::H264PROFILE_MIN; | |
2526 media_profile <= media::H264PROFILE_MAX; ++media_profile) { | |
2527 profile.profile = | |
2528 static_cast<media::VideoCodecProfile>(media_profile); | |
2529 profiles.push_back(profile); | |
2530 } | |
2531 break; | |
2532 case V4L2_PIX_FMT_VP8_FRAME: | |
2533 profile.profile = media::VP8PROFILE_ANY; | |
2534 profiles.push_back(profile); | |
2535 break; | |
2536 } | |
2537 } | |
2538 | |
2539 return profiles; | |
2540 } | 2512 } |
2541 | 2513 |
2542 } // namespace content | 2514 } // namespace content |
OLD | NEW |