| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 <libdrm/drm_fourcc.h> | 5 #include <libdrm/drm_fourcc.h> |
| 6 #include <linux/videodev2.h> | 6 #include <linux/videodev2.h> |
| 7 #include <string.h> | 7 #include <string.h> |
| 8 | 8 |
| 9 #include "base/numerics/safe_conversions.h" | 9 #include "base/numerics/safe_conversions.h" |
| 10 #include "build/build_config.h" | 10 #include "build/build_config.h" |
| 11 #include "content/common/gpu/media/generic_v4l2_device.h" | 11 #include "media/gpu/generic_v4l2_device.h" |
| 12 #if defined(ARCH_CPU_ARMEL) | 12 #if defined(ARCH_CPU_ARMEL) |
| 13 #include "content/common/gpu/media/tegra_v4l2_device.h" | 13 #include "media/gpu/tegra_v4l2_device.h" |
| 14 #endif | 14 #endif |
| 15 | 15 |
| 16 namespace content { | 16 namespace media { |
| 17 | 17 |
| 18 V4L2Device::V4L2Device(Type type) : type_(type) { | 18 V4L2Device::V4L2Device(Type type) : type_(type) {} |
| 19 } | |
| 20 | 19 |
| 21 V4L2Device::~V4L2Device() { | 20 V4L2Device::~V4L2Device() {} |
| 22 } | |
| 23 | 21 |
| 24 // static | 22 // static |
| 25 scoped_refptr<V4L2Device> V4L2Device::Create(Type type) { | 23 scoped_refptr<V4L2Device> V4L2Device::Create(Type type) { |
| 26 DVLOG(3) << __PRETTY_FUNCTION__; | 24 DVLOG(3) << __PRETTY_FUNCTION__; |
| 27 | 25 |
| 28 scoped_refptr<GenericV4L2Device> generic_device(new GenericV4L2Device(type)); | 26 scoped_refptr<GenericV4L2Device> generic_device(new GenericV4L2Device(type)); |
| 29 if (generic_device->Initialize()) | 27 if (generic_device->Initialize()) |
| 30 return generic_device; | 28 return generic_device; |
| 31 | 29 |
| 32 #if defined(ARCH_CPU_ARMEL) | 30 #if defined(ARCH_CPU_ARMEL) |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 default: | 77 default: |
| 80 LOG(FATAL) << "Add more cases as needed"; | 78 LOG(FATAL) << "Add more cases as needed"; |
| 81 return 0; | 79 return 0; |
| 82 } | 80 } |
| 83 } | 81 } |
| 84 | 82 |
| 85 // static | 83 // static |
| 86 uint32_t V4L2Device::VideoCodecProfileToV4L2PixFmt( | 84 uint32_t V4L2Device::VideoCodecProfileToV4L2PixFmt( |
| 87 media::VideoCodecProfile profile, | 85 media::VideoCodecProfile profile, |
| 88 bool slice_based) { | 86 bool slice_based) { |
| 89 if (profile >= media::H264PROFILE_MIN && | 87 if (profile >= media::H264PROFILE_MIN && profile <= media::H264PROFILE_MAX) { |
| 90 profile <= media::H264PROFILE_MAX) { | |
| 91 if (slice_based) | 88 if (slice_based) |
| 92 return V4L2_PIX_FMT_H264_SLICE; | 89 return V4L2_PIX_FMT_H264_SLICE; |
| 93 else | 90 else |
| 94 return V4L2_PIX_FMT_H264; | 91 return V4L2_PIX_FMT_H264; |
| 95 } else if (profile >= media::VP8PROFILE_MIN && | 92 } else if (profile >= media::VP8PROFILE_MIN && |
| 96 profile <= media::VP8PROFILE_MAX) { | 93 profile <= media::VP8PROFILE_MAX) { |
| 97 if (slice_based) | 94 if (slice_based) |
| 98 return V4L2_PIX_FMT_VP8_FRAME; | 95 return V4L2_PIX_FMT_VP8_FRAME; |
| 99 else | 96 else |
| 100 return V4L2_PIX_FMT_VP8; | 97 return V4L2_PIX_FMT_VP8; |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 238 max_resolution->SetSize(frame_size.stepwise.max_width, | 235 max_resolution->SetSize(frame_size.stepwise.max_width, |
| 239 frame_size.stepwise.max_height); | 236 frame_size.stepwise.max_height); |
| 240 min_resolution->SetSize(frame_size.stepwise.min_width, | 237 min_resolution->SetSize(frame_size.stepwise.min_width, |
| 241 frame_size.stepwise.min_height); | 238 frame_size.stepwise.min_height); |
| 242 break; | 239 break; |
| 243 } | 240 } |
| 244 } | 241 } |
| 245 if (max_resolution->IsEmpty()) { | 242 if (max_resolution->IsEmpty()) { |
| 246 max_resolution->SetSize(1920, 1088); | 243 max_resolution->SetSize(1920, 1088); |
| 247 LOG(ERROR) << "GetSupportedResolution failed to get maximum resolution for " | 244 LOG(ERROR) << "GetSupportedResolution failed to get maximum resolution for " |
| 248 << "fourcc " << std::hex << pixelformat | 245 << "fourcc " << std::hex << pixelformat << ", fall back to " |
| 249 << ", fall back to " << max_resolution->ToString(); | 246 << max_resolution->ToString(); |
| 250 } | 247 } |
| 251 if (min_resolution->IsEmpty()) { | 248 if (min_resolution->IsEmpty()) { |
| 252 min_resolution->SetSize(16, 16); | 249 min_resolution->SetSize(16, 16); |
| 253 LOG(ERROR) << "GetSupportedResolution failed to get minimum resolution for " | 250 LOG(ERROR) << "GetSupportedResolution failed to get minimum resolution for " |
| 254 << "fourcc " << std::hex << pixelformat | 251 << "fourcc " << std::hex << pixelformat << ", fall back to " |
| 255 << ", fall back to " << min_resolution->ToString(); | 252 << min_resolution->ToString(); |
| 256 } | 253 } |
| 257 } | 254 } |
| 258 | 255 |
| 259 media::VideoDecodeAccelerator::SupportedProfiles | 256 media::VideoDecodeAccelerator::SupportedProfiles |
| 260 V4L2Device::GetSupportedDecodeProfiles(const size_t num_formats, | 257 V4L2Device::GetSupportedDecodeProfiles(const size_t num_formats, |
| 261 const uint32_t pixelformats[]) { | 258 const uint32_t pixelformats[]) { |
| 262 DCHECK_EQ(type_, kDecoder); | 259 DCHECK_EQ(type_, kDecoder); |
| 263 media::VideoDecodeAccelerator::SupportedProfiles profiles; | 260 media::VideoDecodeAccelerator::SupportedProfiles profiles; |
| 264 media::VideoDecodeAccelerator::SupportedProfile profile; | 261 media::VideoDecodeAccelerator::SupportedProfile profile; |
| 265 v4l2_fmtdesc fmtdesc; | 262 v4l2_fmtdesc fmtdesc; |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 314 // Try to find requested profile among the returned supported_profiles. | 311 // Try to find requested profile among the returned supported_profiles. |
| 315 const auto iter = std::find_if( | 312 const auto iter = std::find_if( |
| 316 supported_profiles.begin(), supported_profiles.end(), | 313 supported_profiles.begin(), supported_profiles.end(), |
| 317 [profile](const media::VideoDecodeAccelerator::SupportedProfile& p) { | 314 [profile](const media::VideoDecodeAccelerator::SupportedProfile& p) { |
| 318 return profile == p.profile; | 315 return profile == p.profile; |
| 319 }); | 316 }); |
| 320 | 317 |
| 321 return iter != supported_profiles.end(); | 318 return iter != supported_profiles.end(); |
| 322 } | 319 } |
| 323 | 320 |
| 324 } // namespace content | 321 } // namespace media |
| OLD | NEW |