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..7e029e91171ac7d319026083436fb30415877b16 100644 |
| --- a/content/common/gpu/media/v4l2_device.cc |
| +++ b/content/common/gpu/media/v4l2_device.cc |
| @@ -13,6 +13,9 @@ |
| namespace content { |
| +V4L2Device::V4L2Device(Type type) : type_(type) { |
| +} |
| + |
| V4L2Device::~V4L2Device() { |
| } |
| @@ -197,4 +200,79 @@ 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 1920x1088."; |
| + max_resolution.SetSize(1920, 1088); |
| + } |
| + return max_resolution; |
| +} |
| + |
| +media::VideoDecodeAccelerator::SupportedProfiles |
| +V4L2Device::GetSupportedDecodeProfiles( |
| + const uint32_t num_formats, const uint32_t pixelformats[]) { |
| + DCHECK_EQ(type_, kDecoder); |
| + media::VideoDecodeAccelerator::SupportedProfiles profiles; |
| + media::VideoDecodeAccelerator::SupportedProfile profile; |
| + profile.min_resolution.SetSize(16, 16); |
|
Pawel Osciak
2015/04/27 05:36:15
Framesize API also supports minimum resolution, th
henryhsu
2015/04/27 07:23:51
Done.
|
| + 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(pixelformats, pixelformats + num_formats, |
| + fmtdesc.pixelformat) == pixelformats + num_formats) |
| + continue; |
| + profile.max_resolution = GetMaxSupportedResolution(fmtdesc.pixelformat); |
| + uint32_t min_profile, max_profile; |
|
Pawel Osciak
2015/04/27 05:36:15
s/uint32_t/int/
henryhsu
2015/04/27 07:23:51
Done.
|
| + switch (fmtdesc.pixelformat) { |
| + case V4L2_PIX_FMT_H264: |
| + case V4L2_PIX_FMT_H264_SLICE: |
| + min_profile = media::H264PROFILE_MIN; |
| + max_profile = media::H264PROFILE_MAX; |
| + break; |
| + case V4L2_PIX_FMT_VP8: |
| + case V4L2_PIX_FMT_VP8_FRAME: |
| + min_profile = media::VP8PROFILE_MIN; |
| + max_profile = media::VP8PROFILE_MAX; |
| + break; |
| + case V4L2_PIX_FMT_VP9: |
| + min_profile = media::VP9PROFILE_MIN; |
| + max_profile = media::VP9PROFILE_MAX; |
| + break; |
| + default: |
| + NOTREACHED() << "Unhandled pixelformat " << std::hex |
| + << fmtdesc.pixelformat; |
| + break; |
|
Pawel Osciak
2015/04/27 05:36:14
NOTREACHED is not a fatal failure in Release, so y
henryhsu
2015/04/27 07:23:51
Done.
|
| + } |
| + for (uint32_t media_profile = min_profile; media_profile <= max_profile; |
|
Pawel Osciak
2015/04/27 05:36:14
s/uint32_t/int/
henryhsu
2015/04/27 07:23:51
Done.
|
| + ++media_profile) { |
| + profile.profile = |
| + static_cast<media::VideoCodecProfile>(media_profile); |
| + profiles.push_back(profile); |
| + } |
| + } |
| + return profiles; |
| +} |
| + |
| } // namespace content |