Chromium Code Reviews| Index: content/common/gpu/media/v4l2_device.cc |
| diff --git a/content/common/gpu/media/v4l2_device.cc b/content/common/gpu/media/v4l2_device.cc |
| index 7629bac5e19109bc35c7eb065b72950a5b4582e0..a391d1384fc8d5546e310b8f8fef958b64b9c334 100644 |
| --- a/content/common/gpu/media/v4l2_device.cc |
| +++ b/content/common/gpu/media/v4l2_device.cc |
| @@ -197,4 +197,70 @@ gfx::Size V4L2Device::CodedSizeFromV4L2Format(struct v4l2_format format) { |
| return coded_size; |
| } |
| +gfx::Size V4L2Device::GetMaxSupportedResolution(uint32_t pixelformat) { |
| + gfx::Size max_resolution; |
| + v4l2_frmsizeenum frame_size; |
| + memset(&frame_size, 0, sizeof(frame_size)); |
| + frame_size.pixel_format = pixelformat; |
| + for (; Ioctl(VIDIOC_ENUM_FRAMESIZES, &frame_size) == 0; ++frame_size.index) { |
| + if (frame_size.type == V4L2_FRMSIZE_TYPE_DISCRETE && |
| + frame_size.discrete.width >= |
| + base::checked_cast<uint32_t>(max_resolution.width()) && |
| + frame_size.discrete.height >= |
| + base::checked_cast<uint32_t>(max_resolution.height())) { |
| + max_resolution.SetSize(frame_size.discrete.width, |
| + frame_size.discrete.height); |
| + } else if (frame_size.type == V4L2_FRMSIZE_TYPE_STEPWISE || |
| + frame_size.type == V4L2_FRMSIZE_TYPE_CONTINUOUS) { |
| + max_resolution.SetSize(frame_size.stepwise.max_width, |
| + frame_size.stepwise.max_height); |
| + break; |
| + } |
| + } |
| + if (max_resolution.IsEmpty()) { |
| + LOG(ERROR) << "GetMaxSupportedResolution failed for fourcc " << std::hex |
| + << pixelformat << ", fall back to 1088p"; |
|
wuchengli
2015/04/23 07:11:44
1088p is not a common usage. To avoid confusion, s
henryhsu
2015/04/23 08:21:54
Done.
|
| + max_resolution.SetSize(1920, 1088); |
| + } |
| + return max_resolution; |
| +} |
| + |
| +media::VideoDecodeAccelerator::SupportedProfiles |
| +V4L2Device::GetSupportedDecodeProfiles(std::vector<uint32_t> fourcc_formats) { |
|
wuchengli
2015/04/23 07:11:44
Let's move "const Type type_;" from GenericV4L2Dev
henryhsu
2015/04/23 08:21:53
Done.
|
| + media::VideoDecodeAccelerator::SupportedProfiles profiles; |
| + media::VideoDecodeAccelerator::SupportedProfile profile; |
| + profile.min_resolution.SetSize(16, 16); |
| + v4l2_fmtdesc fmtdesc; |
| + memset(&fmtdesc, 0, sizeof(fmtdesc)); |
| + fmtdesc.type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE; |
| + |
| + for (; Ioctl(VIDIOC_ENUM_FMT, &fmtdesc) == 0; ++fmtdesc.index) { |
| + if (std::find(fourcc_formats.begin(), fourcc_formats.end(), |
| + fmtdesc.pixelformat) == fourcc_formats.end()) |
| + continue; |
| + profile.max_resolution = GetMaxSupportedResolution(fmtdesc.pixelformat); |
| + switch (fmtdesc.pixelformat) { |
| + case V4L2_PIX_FMT_H264: |
| + case V4L2_PIX_FMT_H264_SLICE: |
| + for (uint32 media_profile = media::H264PROFILE_MIN; |
| + media_profile <= media::H264PROFILE_MAX; ++media_profile) { |
| + profile.profile = |
| + static_cast<media::VideoCodecProfile>(media_profile); |
| + profiles.push_back(profile); |
| + } |
| + break; |
| + case V4L2_PIX_FMT_VP8: |
| + case V4L2_PIX_FMT_VP8_FRAME: |
| + profile.profile = media::VP8PROFILE_ANY; |
| + profiles.push_back(profile); |
| + break; |
| + case V4L2_PIX_FMT_VP9: |
| + profile.profile = media::VP9PROFILE_ANY; |
| + profiles.push_back(profile); |
| + break; |
| + } |
| + } |
| + return profiles; |
| +} |
| + |
| } // namespace content |