| 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 "content/common/gpu/media/vaapi_wrapper.h" | 5 #include "content/common/gpu/media/vaapi_wrapper.h" |
| 6 | 6 |
| 7 #include <dlfcn.h> | 7 #include <dlfcn.h> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/callback_helpers.h" | 10 #include "base/callback_helpers.h" |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 | 135 |
| 136 VaapiWrapper::~VaapiWrapper() { | 136 VaapiWrapper::~VaapiWrapper() { |
| 137 DestroyPendingBuffers(); | 137 DestroyPendingBuffers(); |
| 138 DestroyCodedBuffers(); | 138 DestroyCodedBuffers(); |
| 139 DestroySurfaces(); | 139 DestroySurfaces(); |
| 140 DeinitializeVpp(); | 140 DeinitializeVpp(); |
| 141 Deinitialize(); | 141 Deinitialize(); |
| 142 } | 142 } |
| 143 | 143 |
| 144 // static | 144 // static |
| 145 scoped_ptr<VaapiWrapper> VaapiWrapper::Create( | 145 scoped_refptr<VaapiWrapper> VaapiWrapper::Create( |
| 146 CodecMode mode, | 146 CodecMode mode, |
| 147 VAProfile va_profile, | 147 VAProfile va_profile, |
| 148 const base::Closure& report_error_to_uma_cb) { | 148 const base::Closure& report_error_to_uma_cb) { |
| 149 if (!profile_infos_.Get().IsProfileSupported(mode, va_profile)) { | 149 if (!profile_infos_.Get().IsProfileSupported(mode, va_profile)) { |
| 150 DVLOG(1) << "Unsupported va_profile: " << va_profile; | 150 DVLOG(1) << "Unsupported va_profile: " << va_profile; |
| 151 return nullptr; | 151 return nullptr; |
| 152 } | 152 } |
| 153 | 153 |
| 154 scoped_ptr<VaapiWrapper> vaapi_wrapper(new VaapiWrapper()); | 154 scoped_refptr<VaapiWrapper> vaapi_wrapper(new VaapiWrapper()); |
| 155 if (vaapi_wrapper->VaInitialize(report_error_to_uma_cb)) { | 155 if (vaapi_wrapper->VaInitialize(report_error_to_uma_cb)) { |
| 156 if (vaapi_wrapper->Initialize(mode, va_profile)) | 156 if (vaapi_wrapper->Initialize(mode, va_profile)) |
| 157 return vaapi_wrapper.Pass(); | 157 return vaapi_wrapper.Pass(); |
| 158 } | 158 } |
| 159 LOG(ERROR) << "Failed to create VaapiWrapper for va_profile: " << va_profile; | 159 LOG(ERROR) << "Failed to create VaapiWrapper for va_profile: " << va_profile; |
| 160 return nullptr; | 160 return nullptr; |
| 161 } | 161 } |
| 162 | 162 |
| 163 // static | 163 // static |
| 164 scoped_ptr<VaapiWrapper> VaapiWrapper::CreateForVideoCodec( | 164 scoped_refptr<VaapiWrapper> VaapiWrapper::CreateForVideoCodec( |
| 165 CodecMode mode, | 165 CodecMode mode, |
| 166 media::VideoCodecProfile profile, | 166 media::VideoCodecProfile profile, |
| 167 const base::Closure& report_error_to_uma_cb) { | 167 const base::Closure& report_error_to_uma_cb) { |
| 168 VAProfile va_profile = ProfileToVAProfile(profile, mode); | 168 VAProfile va_profile = ProfileToVAProfile(profile, mode); |
| 169 scoped_ptr<VaapiWrapper> vaapi_wrapper = | 169 scoped_refptr<VaapiWrapper> vaapi_wrapper = |
| 170 Create(mode, va_profile, report_error_to_uma_cb); | 170 Create(mode, va_profile, report_error_to_uma_cb); |
| 171 return vaapi_wrapper.Pass(); | 171 return vaapi_wrapper.Pass(); |
| 172 } | 172 } |
| 173 | 173 |
| 174 // static | 174 // static |
| 175 media::VideoEncodeAccelerator::SupportedProfiles | 175 media::VideoEncodeAccelerator::SupportedProfiles |
| 176 VaapiWrapper::GetSupportedEncodeProfiles() { | 176 VaapiWrapper::GetSupportedEncodeProfiles() { |
| 177 media::VideoEncodeAccelerator::SupportedProfiles profiles; | 177 media::VideoEncodeAccelerator::SupportedProfiles profiles; |
| 178 const base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess(); | 178 const base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess(); |
| 179 if (cmd_line->HasSwitch(switches::kDisableVaapiAcceleratedVideoEncode)) | 179 if (cmd_line->HasSwitch(switches::kDisableVaapiAcceleratedVideoEncode)) |
| (...skipping 876 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1056 #elif defined(USE_OZONE) | 1056 #elif defined(USE_OZONE) |
| 1057 paths[kModuleVa_drm].push_back("libva-drm.so.1"); | 1057 paths[kModuleVa_drm].push_back("libva-drm.so.1"); |
| 1058 #endif | 1058 #endif |
| 1059 | 1059 |
| 1060 return InitializeStubs(paths); | 1060 return InitializeStubs(paths); |
| 1061 } | 1061 } |
| 1062 | 1062 |
| 1063 VaapiWrapper::LazyProfileInfos::LazyProfileInfos() { | 1063 VaapiWrapper::LazyProfileInfos::LazyProfileInfos() { |
| 1064 static_assert(arraysize(supported_profiles_) == kCodecModeMax, | 1064 static_assert(arraysize(supported_profiles_) == kCodecModeMax, |
| 1065 "The array size of supported profile is incorrect."); | 1065 "The array size of supported profile is incorrect."); |
| 1066 scoped_ptr<VaapiWrapper> vaapi_wrapper(new VaapiWrapper()); | 1066 scoped_refptr<VaapiWrapper> vaapi_wrapper(new VaapiWrapper()); |
| 1067 if (!vaapi_wrapper->VaInitialize(base::Bind(&base::DoNothing))) | 1067 if (!vaapi_wrapper->VaInitialize(base::Bind(&base::DoNothing))) |
| 1068 return; | 1068 return; |
| 1069 for (size_t i = 0; i < kCodecModeMax; ++i) { | 1069 for (size_t i = 0; i < kCodecModeMax; ++i) { |
| 1070 supported_profiles_[i] = | 1070 supported_profiles_[i] = |
| 1071 vaapi_wrapper->GetSupportedProfileInfosForCodecModeInternal( | 1071 vaapi_wrapper->GetSupportedProfileInfosForCodecModeInternal( |
| 1072 static_cast<CodecMode>(i)); | 1072 static_cast<CodecMode>(i)); |
| 1073 } | 1073 } |
| 1074 } | 1074 } |
| 1075 | 1075 |
| 1076 VaapiWrapper::LazyProfileInfos::~LazyProfileInfos() { | 1076 VaapiWrapper::LazyProfileInfos::~LazyProfileInfos() { |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1151 drm_fd_.reset(HANDLE_EINTR(dup(fd))); | 1151 drm_fd_.reset(HANDLE_EINTR(dup(fd))); |
| 1152 } | 1152 } |
| 1153 #endif // USE_OZONE | 1153 #endif // USE_OZONE |
| 1154 | 1154 |
| 1155 bool VaapiWrapper::VADisplayState::VAAPIVersionLessThan(int major, int minor) { | 1155 bool VaapiWrapper::VADisplayState::VAAPIVersionLessThan(int major, int minor) { |
| 1156 return (major_version_ < major) || | 1156 return (major_version_ < major) || |
| 1157 (major_version_ == major && minor_version_ < minor); | 1157 (major_version_ == major && minor_version_ < minor); |
| 1158 } | 1158 } |
| 1159 | 1159 |
| 1160 } // namespace content | 1160 } // namespace content |
| OLD | NEW |