| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "media/gpu/vaapi_wrapper.h" | 5 #include "media/gpu/vaapi_wrapper.h" |
| 6 | 6 |
| 7 #include <dlfcn.h> | 7 #include <dlfcn.h> |
| 8 #include <string.h> | 8 #include <string.h> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 | 97 |
| 98 } // namespace | 98 } // namespace |
| 99 #endif | 99 #endif |
| 100 | 100 |
| 101 namespace media { | 101 namespace media { |
| 102 | 102 |
| 103 // Maximum framerate of encoded profile. This value is an arbitary limit | 103 // Maximum framerate of encoded profile. This value is an arbitary limit |
| 104 // and not taken from HW documentation. | 104 // and not taken from HW documentation. |
| 105 const int kMaxEncoderFramerate = 30; | 105 const int kMaxEncoderFramerate = 30; |
| 106 | 106 |
| 107 base::LazyInstance<VaapiWrapper::VADisplayState> | |
| 108 VaapiWrapper::va_display_state_ = LAZY_INSTANCE_INITIALIZER; | |
| 109 | |
| 110 base::LazyInstance<VaapiWrapper::LazyProfileInfos> | |
| 111 VaapiWrapper::profile_infos_ = LAZY_INSTANCE_INITIALIZER; | |
| 112 | |
| 113 // Config attributes common for both encode and decode. | 107 // Config attributes common for both encode and decode. |
| 114 static const VAConfigAttrib kCommonVAConfigAttribs[] = { | 108 static const VAConfigAttrib kCommonVAConfigAttribs[] = { |
| 115 {VAConfigAttribRTFormat, VA_RT_FORMAT_YUV420}, | 109 {VAConfigAttribRTFormat, VA_RT_FORMAT_YUV420}, |
| 116 }; | 110 }; |
| 117 | 111 |
| 118 // Attributes required for encode. | 112 // Attributes required for encode. |
| 119 static const VAConfigAttrib kEncodeVAConfigAttribs[] = { | 113 static const VAConfigAttrib kEncodeVAConfigAttribs[] = { |
| 120 {VAConfigAttribRateControl, VA_RC_CBR}, | 114 {VAConfigAttribRateControl, VA_RC_CBR}, |
| 121 {VAConfigAttribEncPackedHeaders, | 115 {VAConfigAttribEncPackedHeaders, |
| 122 VA_ENC_PACKED_HEADER_SEQUENCE | VA_ENC_PACKED_HEADER_PICTURE}, | 116 VA_ENC_PACKED_HEADER_SEQUENCE | VA_ENC_PACKED_HEADER_PICTURE}, |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 } | 164 } |
| 171 | 165 |
| 172 VaapiWrapper::VaapiWrapper() | 166 VaapiWrapper::VaapiWrapper() |
| 173 : va_surface_format_(0), | 167 : va_surface_format_(0), |
| 174 va_display_(NULL), | 168 va_display_(NULL), |
| 175 va_config_id_(VA_INVALID_ID), | 169 va_config_id_(VA_INVALID_ID), |
| 176 va_context_id_(VA_INVALID_ID), | 170 va_context_id_(VA_INVALID_ID), |
| 177 va_vpp_config_id_(VA_INVALID_ID), | 171 va_vpp_config_id_(VA_INVALID_ID), |
| 178 va_vpp_context_id_(VA_INVALID_ID), | 172 va_vpp_context_id_(VA_INVALID_ID), |
| 179 va_vpp_buffer_id_(VA_INVALID_ID) { | 173 va_vpp_buffer_id_(VA_INVALID_ID) { |
| 180 va_lock_ = va_display_state_.Get().va_lock(); | 174 va_lock_ = GetDisplayState()->va_lock(); |
| 181 } | 175 } |
| 182 | 176 |
| 183 VaapiWrapper::~VaapiWrapper() { | 177 VaapiWrapper::~VaapiWrapper() { |
| 184 DestroyPendingBuffers(); | 178 DestroyPendingBuffers(); |
| 185 DestroyCodedBuffers(); | 179 DestroyCodedBuffers(); |
| 186 DestroySurfaces(); | 180 DestroySurfaces(); |
| 187 DeinitializeVpp(); | 181 DeinitializeVpp(); |
| 188 Deinitialize(); | 182 Deinitialize(); |
| 189 } | 183 } |
| 190 | 184 |
| 191 // static | 185 // static |
| 192 scoped_refptr<VaapiWrapper> VaapiWrapper::Create( | 186 scoped_refptr<VaapiWrapper> VaapiWrapper::Create( |
| 193 CodecMode mode, | 187 CodecMode mode, |
| 194 VAProfile va_profile, | 188 VAProfile va_profile, |
| 195 const base::Closure& report_error_to_uma_cb) { | 189 const base::Closure& report_error_to_uma_cb) { |
| 196 if (!profile_infos_.Get().IsProfileSupported(mode, va_profile)) { | 190 if (!GetProfileInfos()->IsProfileSupported(mode, va_profile)) { |
| 197 DVLOG(1) << "Unsupported va_profile: " << va_profile; | 191 DVLOG(1) << "Unsupported va_profile: " << va_profile; |
| 198 return nullptr; | 192 return nullptr; |
| 199 } | 193 } |
| 200 | 194 |
| 201 scoped_refptr<VaapiWrapper> vaapi_wrapper(new VaapiWrapper()); | 195 scoped_refptr<VaapiWrapper> vaapi_wrapper(new VaapiWrapper()); |
| 202 if (vaapi_wrapper->VaInitialize(report_error_to_uma_cb)) { | 196 if (vaapi_wrapper->VaInitialize(report_error_to_uma_cb)) { |
| 203 if (vaapi_wrapper->Initialize(mode, va_profile)) | 197 if (vaapi_wrapper->Initialize(mode, va_profile)) |
| 204 return vaapi_wrapper; | 198 return vaapi_wrapper; |
| 205 } | 199 } |
| 206 LOG(ERROR) << "Failed to create VaapiWrapper for va_profile: " << va_profile; | 200 LOG(ERROR) << "Failed to create VaapiWrapper for va_profile: " << va_profile; |
| 207 return nullptr; | 201 return nullptr; |
| 208 } | 202 } |
| 209 | 203 |
| 210 // static | 204 // static |
| 211 scoped_refptr<VaapiWrapper> VaapiWrapper::CreateForVideoCodec( | 205 scoped_refptr<VaapiWrapper> VaapiWrapper::CreateForVideoCodec( |
| 212 CodecMode mode, | 206 CodecMode mode, |
| 213 VideoCodecProfile profile, | 207 VideoCodecProfile profile, |
| 214 const base::Closure& report_error_to_uma_cb) { | 208 const base::Closure& report_error_to_uma_cb) { |
| 215 VAProfile va_profile = ProfileToVAProfile(profile, mode); | 209 VAProfile va_profile = ProfileToVAProfile(profile, mode); |
| 216 scoped_refptr<VaapiWrapper> vaapi_wrapper = | 210 scoped_refptr<VaapiWrapper> vaapi_wrapper = |
| 217 Create(mode, va_profile, report_error_to_uma_cb); | 211 Create(mode, va_profile, report_error_to_uma_cb); |
| 218 return vaapi_wrapper; | 212 return vaapi_wrapper; |
| 219 } | 213 } |
| 220 | 214 |
| 221 // static | 215 // static |
| 222 VideoEncodeAccelerator::SupportedProfiles | 216 VideoEncodeAccelerator::SupportedProfiles |
| 223 VaapiWrapper::GetSupportedEncodeProfiles() { | 217 VaapiWrapper::GetSupportedEncodeProfiles() { |
| 224 VideoEncodeAccelerator::SupportedProfiles profiles; | 218 VideoEncodeAccelerator::SupportedProfiles profiles; |
| 225 std::vector<ProfileInfo> encode_profile_infos = | 219 std::vector<ProfileInfo> encode_profile_infos = |
| 226 profile_infos_.Get().GetSupportedProfileInfosForCodecMode(kEncode); | 220 GetProfileInfos()->GetSupportedProfileInfosForCodecMode(kEncode); |
| 227 | 221 |
| 228 for (size_t i = 0; i < arraysize(kProfileMap); ++i) { | 222 for (size_t i = 0; i < arraysize(kProfileMap); ++i) { |
| 229 VAProfile va_profile = ProfileToVAProfile(kProfileMap[i].profile, kEncode); | 223 VAProfile va_profile = ProfileToVAProfile(kProfileMap[i].profile, kEncode); |
| 230 if (va_profile == VAProfileNone) | 224 if (va_profile == VAProfileNone) |
| 231 continue; | 225 continue; |
| 232 for (const auto& profile_info : encode_profile_infos) { | 226 for (const auto& profile_info : encode_profile_infos) { |
| 233 if (profile_info.va_profile == va_profile) { | 227 if (profile_info.va_profile == va_profile) { |
| 234 VideoEncodeAccelerator::SupportedProfile profile; | 228 VideoEncodeAccelerator::SupportedProfile profile; |
| 235 profile.profile = kProfileMap[i].profile; | 229 profile.profile = kProfileMap[i].profile; |
| 236 profile.max_resolution = profile_info.max_resolution; | 230 profile.max_resolution = profile_info.max_resolution; |
| 237 profile.max_framerate_numerator = kMaxEncoderFramerate; | 231 profile.max_framerate_numerator = kMaxEncoderFramerate; |
| 238 profile.max_framerate_denominator = 1; | 232 profile.max_framerate_denominator = 1; |
| 239 profiles.push_back(profile); | 233 profiles.push_back(profile); |
| 240 break; | 234 break; |
| 241 } | 235 } |
| 242 } | 236 } |
| 243 } | 237 } |
| 244 return profiles; | 238 return profiles; |
| 245 } | 239 } |
| 246 | 240 |
| 247 // static | 241 // static |
| 248 VideoDecodeAccelerator::SupportedProfiles | 242 VideoDecodeAccelerator::SupportedProfiles |
| 249 VaapiWrapper::GetSupportedDecodeProfiles() { | 243 VaapiWrapper::GetSupportedDecodeProfiles() { |
| 250 VideoDecodeAccelerator::SupportedProfiles profiles; | 244 VideoDecodeAccelerator::SupportedProfiles profiles; |
| 251 std::vector<ProfileInfo> decode_profile_infos = | 245 std::vector<ProfileInfo> decode_profile_infos = |
| 252 profile_infos_.Get().GetSupportedProfileInfosForCodecMode(kDecode); | 246 GetProfileInfos()->GetSupportedProfileInfosForCodecMode(kDecode); |
| 253 | 247 |
| 254 for (size_t i = 0; i < arraysize(kProfileMap); ++i) { | 248 for (size_t i = 0; i < arraysize(kProfileMap); ++i) { |
| 255 VAProfile va_profile = ProfileToVAProfile(kProfileMap[i].profile, kDecode); | 249 VAProfile va_profile = ProfileToVAProfile(kProfileMap[i].profile, kDecode); |
| 256 if (va_profile == VAProfileNone) | 250 if (va_profile == VAProfileNone) |
| 257 continue; | 251 continue; |
| 258 for (const auto& profile_info : decode_profile_infos) { | 252 for (const auto& profile_info : decode_profile_infos) { |
| 259 if (profile_info.va_profile == va_profile) { | 253 if (profile_info.va_profile == va_profile) { |
| 260 VideoDecodeAccelerator::SupportedProfile profile; | 254 VideoDecodeAccelerator::SupportedProfile profile; |
| 261 profile.profile = kProfileMap[i].profile; | 255 profile.profile = kProfileMap[i].profile; |
| 262 profile.max_resolution = profile_info.max_resolution; | 256 profile.max_resolution = profile_info.max_resolution; |
| 263 profile.min_resolution.SetSize(16, 16); | 257 profile.min_resolution.SetSize(16, 16); |
| 264 profiles.push_back(profile); | 258 profiles.push_back(profile); |
| 265 break; | 259 break; |
| 266 } | 260 } |
| 267 } | 261 } |
| 268 } | 262 } |
| 269 return profiles; | 263 return profiles; |
| 270 } | 264 } |
| 271 | 265 |
| 272 // static | 266 // static |
| 273 bool VaapiWrapper::IsJpegDecodeSupported() { | 267 bool VaapiWrapper::IsJpegDecodeSupported() { |
| 274 return profile_infos_.Get().IsProfileSupported(kDecode, | 268 return GetProfileInfos()->IsProfileSupported(kDecode, VAProfileJPEGBaseline); |
| 275 VAProfileJPEGBaseline); | |
| 276 } | 269 } |
| 277 | 270 |
| 278 void VaapiWrapper::TryToSetVADisplayAttributeToLocalGPU() { | 271 void VaapiWrapper::TryToSetVADisplayAttributeToLocalGPU() { |
| 279 base::AutoLock auto_lock(*va_lock_); | 272 base::AutoLock auto_lock(*va_lock_); |
| 280 VADisplayAttribute item = {VADisplayAttribRenderMode, | 273 VADisplayAttribute item = {VADisplayAttribRenderMode, |
| 281 1, // At least support '_LOCAL_OVERLAY'. | 274 1, // At least support '_LOCAL_OVERLAY'. |
| 282 -1, // The maximum possible support 'ALL'. | 275 -1, // The maximum possible support 'ALL'. |
| 283 VA_RENDER_MODE_LOCAL_GPU, | 276 VA_RENDER_MODE_LOCAL_GPU, |
| 284 VA_DISPLAY_ATTRIB_SETTABLE}; | 277 VA_DISPLAY_ATTRIB_SETTABLE}; |
| 285 | 278 |
| 286 VAStatus va_res = vaSetDisplayAttributes(va_display_, &item, 1); | 279 VAStatus va_res = vaSetDisplayAttributes(va_display_, &item, 1); |
| 287 if (va_res != VA_STATUS_SUCCESS) | 280 if (va_res != VA_STATUS_SUCCESS) |
| 288 DVLOG(2) << "vaSetDisplayAttributes unsupported, ignoring by default."; | 281 DVLOG(2) << "vaSetDisplayAttributes unsupported, ignoring by default."; |
| 289 } | 282 } |
| 290 | 283 |
| 291 // static | 284 // static |
| 292 VAProfile VaapiWrapper::ProfileToVAProfile(VideoCodecProfile profile, | 285 VAProfile VaapiWrapper::ProfileToVAProfile(VideoCodecProfile profile, |
| 293 CodecMode mode) { | 286 CodecMode mode) { |
| 294 VAProfile va_profile = VAProfileNone; | 287 VAProfile va_profile = VAProfileNone; |
| 295 for (size_t i = 0; i < arraysize(kProfileMap); ++i) { | 288 for (size_t i = 0; i < arraysize(kProfileMap); ++i) { |
| 296 if (kProfileMap[i].profile == profile) { | 289 if (kProfileMap[i].profile == profile) { |
| 297 va_profile = kProfileMap[i].va_profile; | 290 va_profile = kProfileMap[i].va_profile; |
| 298 break; | 291 break; |
| 299 } | 292 } |
| 300 } | 293 } |
| 301 if (!profile_infos_.Get().IsProfileSupported(mode, va_profile) && | 294 if (!GetProfileInfos()->IsProfileSupported(mode, va_profile) && |
| 302 va_profile == VAProfileH264Baseline) { | 295 va_profile == VAProfileH264Baseline) { |
| 303 // crbug.com/345569: ProfileIDToVideoCodecProfile() currently strips | 296 // crbug.com/345569: ProfileIDToVideoCodecProfile() currently strips |
| 304 // the information whether the profile is constrained or not, so we have no | 297 // the information whether the profile is constrained or not, so we have no |
| 305 // way to know here. Try for baseline first, but if it is not supported, | 298 // way to know here. Try for baseline first, but if it is not supported, |
| 306 // try constrained baseline and hope this is what it actually is | 299 // try constrained baseline and hope this is what it actually is |
| 307 // (which in practice is true for a great majority of cases). | 300 // (which in practice is true for a great majority of cases). |
| 308 if (profile_infos_.Get().IsProfileSupported( | 301 if (GetProfileInfos()->IsProfileSupported( |
| 309 mode, VAProfileH264ConstrainedBaseline)) { | 302 mode, VAProfileH264ConstrainedBaseline)) { |
| 310 va_profile = VAProfileH264ConstrainedBaseline; | 303 va_profile = VAProfileH264ConstrainedBaseline; |
| 311 DVLOG(1) << "Fall back to constrained baseline profile."; | 304 DVLOG(1) << "Fall back to constrained baseline profile."; |
| 312 } | 305 } |
| 313 } | 306 } |
| 314 return va_profile; | 307 return va_profile; |
| 315 } | 308 } |
| 316 | 309 |
| 317 std::vector<VaapiWrapper::ProfileInfo> | 310 std::vector<VaapiWrapper::ProfileInfo> |
| 318 VaapiWrapper::GetSupportedProfileInfosForCodecModeInternal(CodecMode mode) { | 311 VaapiWrapper::GetSupportedProfileInfosForCodecModeInternal(CodecMode mode) { |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 357 if (running_on_chromeos) | 350 if (running_on_chromeos) |
| 358 LOG(ERROR) << kErrorMsg; | 351 LOG(ERROR) << kErrorMsg; |
| 359 else | 352 else |
| 360 DVLOG(1) << kErrorMsg; | 353 DVLOG(1) << kErrorMsg; |
| 361 return false; | 354 return false; |
| 362 } | 355 } |
| 363 | 356 |
| 364 report_error_to_uma_cb_ = report_error_to_uma_cb; | 357 report_error_to_uma_cb_ = report_error_to_uma_cb; |
| 365 | 358 |
| 366 base::AutoLock auto_lock(*va_lock_); | 359 base::AutoLock auto_lock(*va_lock_); |
| 367 | 360 if (!GetDisplayState()->Initialize()) |
| 368 VADisplayState* va_display_state = &va_display_state_.Get(); | |
| 369 if (!va_display_state) { | |
| 370 LOG(ERROR) << "Failed to allocate VA display state"; | |
| 371 return false; | |
| 372 } | |
| 373 | |
| 374 if (!va_display_state->Initialize()) | |
| 375 return false; | 361 return false; |
| 376 | 362 |
| 377 va_display_ = va_display_state->va_display(); | 363 va_display_ = GetDisplayState()->va_display(); |
| 378 return true; | 364 return true; |
| 379 } | 365 } |
| 380 | 366 |
| 381 bool VaapiWrapper::GetSupportedVaProfiles(std::vector<VAProfile>* profiles) { | 367 bool VaapiWrapper::GetSupportedVaProfiles(std::vector<VAProfile>* profiles) { |
| 382 base::AutoLock auto_lock(*va_lock_); | 368 base::AutoLock auto_lock(*va_lock_); |
| 383 // Query the driver for supported profiles. | 369 // Query the driver for supported profiles. |
| 384 int max_profiles = vaMaxNumProfiles(va_display_); | 370 int max_profiles = vaMaxNumProfiles(va_display_); |
| 385 std::vector<VAProfile> supported_profiles( | 371 std::vector<VAProfile> supported_profiles( |
| 386 base::checked_cast<size_t>(max_profiles)); | 372 base::checked_cast<size_t>(max_profiles)); |
| 387 | 373 |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 513 } | 499 } |
| 514 | 500 |
| 515 void VaapiWrapper::Deinitialize() { | 501 void VaapiWrapper::Deinitialize() { |
| 516 base::AutoLock auto_lock(*va_lock_); | 502 base::AutoLock auto_lock(*va_lock_); |
| 517 | 503 |
| 518 if (va_config_id_ != VA_INVALID_ID) { | 504 if (va_config_id_ != VA_INVALID_ID) { |
| 519 VAStatus va_res = vaDestroyConfig(va_display_, va_config_id_); | 505 VAStatus va_res = vaDestroyConfig(va_display_, va_config_id_); |
| 520 VA_LOG_ON_ERROR(va_res, "vaDestroyConfig failed"); | 506 VA_LOG_ON_ERROR(va_res, "vaDestroyConfig failed"); |
| 521 } | 507 } |
| 522 | 508 |
| 523 VADisplayState* va_display_state = &va_display_state_.Get(); | 509 VAStatus va_res = VA_STATUS_SUCCESS; |
| 524 if (va_display_state) { | 510 GetDisplayState()->Deinitialize(&va_res); |
| 525 VAStatus va_res = VA_STATUS_SUCCESS; | 511 VA_LOG_ON_ERROR(va_res, "vaTerminate failed"); |
| 526 va_display_state->Deinitialize(&va_res); | |
| 527 VA_LOG_ON_ERROR(va_res, "vaTerminate failed"); | |
| 528 } | |
| 529 | 512 |
| 530 va_config_id_ = VA_INVALID_ID; | 513 va_config_id_ = VA_INVALID_ID; |
| 531 va_display_ = NULL; | 514 va_display_ = NULL; |
| 532 } | 515 } |
| 533 | 516 |
| 534 bool VaapiWrapper::CreateSurfaces(unsigned int va_format, | 517 bool VaapiWrapper::CreateSurfaces(unsigned int va_format, |
| 535 const gfx::Size& size, | 518 const gfx::Size& size, |
| 536 size_t num_surfaces, | 519 size_t num_surfaces, |
| 537 std::vector<VASurfaceID>* va_surfaces) { | 520 std::vector<VASurfaceID>* va_surfaces) { |
| 538 base::AutoLock auto_lock(*va_lock_); | 521 base::AutoLock auto_lock(*va_lock_); |
| (...skipping 600 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1139 } | 1122 } |
| 1140 | 1123 |
| 1141 // static | 1124 // static |
| 1142 void VaapiWrapper::PreSandboxInitialization() { | 1125 void VaapiWrapper::PreSandboxInitialization() { |
| 1143 #if defined(USE_OZONE) | 1126 #if defined(USE_OZONE) |
| 1144 const char kDriRenderNode0Path[] = "/dev/dri/renderD128"; | 1127 const char kDriRenderNode0Path[] = "/dev/dri/renderD128"; |
| 1145 base::File drm_file = base::File( | 1128 base::File drm_file = base::File( |
| 1146 base::FilePath::FromUTF8Unsafe(kDriRenderNode0Path), | 1129 base::FilePath::FromUTF8Unsafe(kDriRenderNode0Path), |
| 1147 base::File::FLAG_OPEN | base::File::FLAG_READ | base::File::FLAG_WRITE); | 1130 base::File::FLAG_OPEN | base::File::FLAG_READ | base::File::FLAG_WRITE); |
| 1148 if (drm_file.IsValid()) | 1131 if (drm_file.IsValid()) |
| 1149 va_display_state_.Get().SetDrmFd(drm_file.GetPlatformFile()); | 1132 GetDisplayState()->SetDrmFd(drm_file.GetPlatformFile()); |
| 1150 #endif | 1133 #endif |
| 1151 } | 1134 } |
| 1152 | 1135 |
| 1153 // static | 1136 // static |
| 1154 bool VaapiWrapper::PostSandboxInitialization() { | 1137 bool VaapiWrapper::PostSandboxInitialization() { |
| 1155 StubPathMap paths; | 1138 StubPathMap paths; |
| 1156 | 1139 |
| 1157 paths[kModuleVa].push_back("libva.so.1"); | 1140 paths[kModuleVa].push_back("libva.so.1"); |
| 1158 | 1141 |
| 1159 #if defined(USE_X11) | 1142 #if defined(USE_X11) |
| 1160 paths[kModuleVa_x11].push_back("libva-x11.so.1"); | 1143 paths[kModuleVa_x11].push_back("libva-x11.so.1"); |
| 1161 #elif defined(USE_OZONE) | 1144 #elif defined(USE_OZONE) |
| 1162 paths[kModuleVa_drm].push_back("libva-drm.so.1"); | 1145 paths[kModuleVa_drm].push_back("libva-drm.so.1"); |
| 1163 #endif | 1146 #endif |
| 1164 | 1147 |
| 1165 return InitializeStubs(paths); | 1148 return InitializeStubs(paths); |
| 1166 } | 1149 } |
| 1167 | 1150 |
| 1151 // static |
| 1152 VaapiWrapper::VADisplayState* VaapiWrapper::GetDisplayState() { |
| 1153 static VADisplayState* display_state = new VADisplayState(); |
| 1154 return display_state; |
| 1155 } |
| 1156 |
| 1157 // static |
| 1158 VaapiWrapper::LazyProfileInfos* VaapiWrapper::GetProfileInfos() { |
| 1159 static LazyProfileInfos* profile_infos = new LazyProfileInfos(); |
| 1160 return profile_infos; |
| 1161 } |
| 1162 |
| 1168 VaapiWrapper::LazyProfileInfos::LazyProfileInfos() { | 1163 VaapiWrapper::LazyProfileInfos::LazyProfileInfos() { |
| 1169 static_assert(arraysize(supported_profiles_) == kCodecModeMax, | 1164 static_assert(arraysize(supported_profiles_) == kCodecModeMax, |
| 1170 "The array size of supported profile is incorrect."); | 1165 "The array size of supported profile is incorrect."); |
| 1171 scoped_refptr<VaapiWrapper> vaapi_wrapper(new VaapiWrapper()); | 1166 scoped_refptr<VaapiWrapper> vaapi_wrapper(new VaapiWrapper()); |
| 1172 if (!vaapi_wrapper->VaInitialize(base::Bind(&base::DoNothing))) | 1167 if (!vaapi_wrapper->VaInitialize(base::Bind(&base::DoNothing))) |
| 1173 return; | 1168 return; |
| 1174 for (size_t i = 0; i < kCodecModeMax; ++i) { | 1169 for (size_t i = 0; i < kCodecModeMax; ++i) { |
| 1175 supported_profiles_[i] = | 1170 supported_profiles_[i] = |
| 1176 vaapi_wrapper->GetSupportedProfileInfosForCodecModeInternal( | 1171 vaapi_wrapper->GetSupportedProfileInfosForCodecModeInternal( |
| 1177 static_cast<CodecMode>(i)); | 1172 static_cast<CodecMode>(i)); |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1258 drm_fd_.reset(HANDLE_EINTR(dup(fd))); | 1253 drm_fd_.reset(HANDLE_EINTR(dup(fd))); |
| 1259 } | 1254 } |
| 1260 #endif // USE_OZONE | 1255 #endif // USE_OZONE |
| 1261 | 1256 |
| 1262 bool VaapiWrapper::VADisplayState::VAAPIVersionLessThan(int major, int minor) { | 1257 bool VaapiWrapper::VADisplayState::VAAPIVersionLessThan(int major, int minor) { |
| 1263 return (major_version_ < major) || | 1258 return (major_version_ < major) || |
| 1264 (major_version_ == major && minor_version_ < minor); | 1259 (major_version_ == major && minor_version_ < minor); |
| 1265 } | 1260 } |
| 1266 | 1261 |
| 1267 } // namespace media | 1262 } // namespace media |
| OLD | NEW |