| 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 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 } | 155 } |
| 156 | 156 |
| 157 VaapiWrapper::~VaapiWrapper() { | 157 VaapiWrapper::~VaapiWrapper() { |
| 158 DestroyPendingBuffers(); | 158 DestroyPendingBuffers(); |
| 159 DestroyCodedBuffers(); | 159 DestroyCodedBuffers(); |
| 160 DestroySurfaces(); | 160 DestroySurfaces(); |
| 161 DeinitializeVpp(); | 161 DeinitializeVpp(); |
| 162 Deinitialize(); | 162 Deinitialize(); |
| 163 } | 163 } |
| 164 | 164 |
| 165 // static |
| 165 scoped_ptr<VaapiWrapper> VaapiWrapper::Create( | 166 scoped_ptr<VaapiWrapper> VaapiWrapper::Create( |
| 166 CodecMode mode, | 167 CodecMode mode, |
| 167 media::VideoCodecProfile profile, | 168 media::VideoCodecProfile profile, |
| 168 const base::Closure& report_error_to_uma_cb) { | 169 const base::Closure& report_error_to_uma_cb) { |
| 169 scoped_ptr<VaapiWrapper> vaapi_wrapper(new VaapiWrapper()); | 170 scoped_ptr<VaapiWrapper> vaapi_wrapper(new VaapiWrapper()); |
| 170 | 171 |
| 171 if (!vaapi_wrapper->Initialize(mode, profile, report_error_to_uma_cb)) | 172 if (!vaapi_wrapper->Initialize(mode, profile, report_error_to_uma_cb)) |
| 172 vaapi_wrapper.reset(); | 173 vaapi_wrapper.reset(); |
| 173 | 174 |
| 174 return vaapi_wrapper.Pass(); | 175 return vaapi_wrapper.Pass(); |
| 175 } | 176 } |
| 176 | 177 |
| 178 // static |
| 177 std::vector<media::VideoCodecProfile> VaapiWrapper::GetSupportedEncodeProfiles( | 179 std::vector<media::VideoCodecProfile> VaapiWrapper::GetSupportedEncodeProfiles( |
| 178 const base::Closure& report_error_to_uma_cb) { | 180 const base::Closure& report_error_to_uma_cb) { |
| 179 std::vector<media::VideoCodecProfile> supported_profiles; | 181 std::vector<media::VideoCodecProfile> supported_profiles; |
| 180 | 182 |
| 181 scoped_ptr<VaapiWrapper> wrapper(new VaapiWrapper()); | 183 scoped_ptr<VaapiWrapper> wrapper(new VaapiWrapper()); |
| 182 if (!wrapper->VaInitialize(report_error_to_uma_cb)) { | 184 if (!wrapper->VaInitialize(report_error_to_uma_cb)) { |
| 183 return supported_profiles; | 185 return supported_profiles; |
| 184 } | 186 } |
| 185 | 187 |
| 186 std::vector<VAProfile> va_profiles; | 188 std::vector<VAProfile> va_profiles; |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 331 (attribs[i].value & required_attribs[i].value) != | 333 (attribs[i].value & required_attribs[i].value) != |
| 332 required_attribs[i].value) { | 334 required_attribs[i].value) { |
| 333 DVLOG(1) << "Unsupported value " << required_attribs[i].value | 335 DVLOG(1) << "Unsupported value " << required_attribs[i].value |
| 334 << " for attribute type " << required_attribs[i].type; | 336 << " for attribute type " << required_attribs[i].type; |
| 335 return false; | 337 return false; |
| 336 } | 338 } |
| 337 } | 339 } |
| 338 return true; | 340 return true; |
| 339 } | 341 } |
| 340 | 342 |
| 343 bool VaapiWrapper::GetVaCodecMaxResolution(gfx::Size* resolution) { |
| 344 base::AutoLock auto_lock(va_lock_); |
| 345 unsigned int width = 0, height = 0; |
| 346 VAStatus va_res = vaGetCodecResolution(va_display_, &width, &height); |
| 347 VA_SUCCESS_OR_RETURN(va_res, "vaGetCodecResolution failed", false); |
| 348 resolution->SetSize(width, height); |
| 349 return true; |
| 350 } |
| 351 |
| 341 bool VaapiWrapper::Initialize(CodecMode mode, | 352 bool VaapiWrapper::Initialize(CodecMode mode, |
| 342 media::VideoCodecProfile profile, | 353 media::VideoCodecProfile profile, |
| 343 const base::Closure& report_error_to_uma_cb) { | 354 const base::Closure& report_error_to_uma_cb) { |
| 344 if (!VaInitialize(report_error_to_uma_cb)) | 355 if (!VaInitialize(report_error_to_uma_cb)) |
| 345 return false; | 356 return false; |
| 346 std::vector<VAProfile> supported_va_profiles; | 357 std::vector<VAProfile> supported_va_profiles; |
| 347 if (!GetSupportedVaProfiles(&supported_va_profiles)) | 358 if (!GetSupportedVaProfiles(&supported_va_profiles)) |
| 348 return false; | 359 return false; |
| 349 VAProfile va_profile = ProfileToVAProfile(profile, supported_va_profiles); | 360 VAProfile va_profile = ProfileToVAProfile(profile, supported_va_profiles); |
| 350 if (va_profile == VAProfileNone) { | 361 if (va_profile == VAProfileNone) { |
| (...skipping 555 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 906 #if defined(USE_X11) | 917 #if defined(USE_X11) |
| 907 paths[kModuleVa_x11].push_back("libva-x11.so.1"); | 918 paths[kModuleVa_x11].push_back("libva-x11.so.1"); |
| 908 #elif defined(USE_OZONE) | 919 #elif defined(USE_OZONE) |
| 909 paths[kModuleVa_drm].push_back("libva-drm.so.1"); | 920 paths[kModuleVa_drm].push_back("libva-drm.so.1"); |
| 910 #endif | 921 #endif |
| 911 | 922 |
| 912 return InitializeStubs(paths); | 923 return InitializeStubs(paths); |
| 913 } | 924 } |
| 914 | 925 |
| 915 } // namespace content | 926 } // namespace content |
| OLD | NEW |