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, min_resolution; |
580 switches::kIgnoreResolutionLimitsForAcceleratedVideoDecode)) | 580 device_->GetSupportedResolution(input_format_fourcc, &min_resolution, |
| 581 &max_resolution); |
| 582 if (max_resolution.width() > 1920 && max_resolution.height() > 1088) |
581 input_size = kInputBufferMaxSizeFor4k; | 583 input_size = kInputBufferMaxSizeFor4k; |
582 else | 584 else |
583 input_size = kInputBufferMaxSizeFor1080p; | 585 input_size = kInputBufferMaxSizeFor1080p; |
584 | 586 |
585 struct v4l2_format format; | 587 struct v4l2_format format; |
586 memset(&format, 0, sizeof(format)); | 588 memset(&format, 0, sizeof(format)); |
587 format.type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE; | 589 format.type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE; |
588 format.fmt.pix_mp.pixelformat = input_format_fourcc; | 590 format.fmt.pix_mp.pixelformat = input_format_fourcc; |
589 format.fmt.pix_mp.plane_fmt[0].sizeimage = input_size; | 591 format.fmt.pix_mp.plane_fmt[0].sizeimage = input_size; |
590 format.fmt.pix_mp.num_planes = input_planes_count_; | 592 format.fmt.pix_mp.num_planes = input_planes_count_; |
(...skipping 1903 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2494 SendPictureReady(); | 2496 SendPictureReady(); |
2495 } | 2497 } |
2496 | 2498 |
2497 bool V4L2SliceVideoDecodeAccelerator::CanDecodeOnIOThread() { | 2499 bool V4L2SliceVideoDecodeAccelerator::CanDecodeOnIOThread() { |
2498 return true; | 2500 return true; |
2499 } | 2501 } |
2500 | 2502 |
2501 // static | 2503 // static |
2502 media::VideoDecodeAccelerator::SupportedProfiles | 2504 media::VideoDecodeAccelerator::SupportedProfiles |
2503 V4L2SliceVideoDecodeAccelerator::GetSupportedProfiles() { | 2505 V4L2SliceVideoDecodeAccelerator::GetSupportedProfiles() { |
2504 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 SupportedProfiles(); |
2508 | 2509 |
2509 SupportedProfile profile; | 2510 const uint32_t supported_formats[] = { |
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 return device->GetSupportedDecodeProfiles(arraysize(supported_formats), |
2512 // selection. | 2513 supported_formats); |
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 } | 2514 } |
2541 | 2515 |
2542 } // namespace content | 2516 } // namespace content |
OLD | NEW |