| 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..3532a1a3091613651b95dd650b56284d3813e14e 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,72 @@ 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);
|
| + 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);
|
| + 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
|
|
|