OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/dxva_video_decode_accelerator_win.h" | 5 #include "media/gpu/dxva_video_decode_accelerator_win.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 | 8 |
9 #if !defined(OS_WIN) | 9 #if !defined(OS_WIN) |
10 #error This file should only be built on Windows. | 10 #error This file should only be built on Windows. |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 #include "media/video/video_decode_accelerator.h" | 44 #include "media/video/video_decode_accelerator.h" |
45 #include "third_party/angle/include/EGL/egl.h" | 45 #include "third_party/angle/include/EGL/egl.h" |
46 #include "third_party/angle/include/EGL/eglext.h" | 46 #include "third_party/angle/include/EGL/eglext.h" |
47 #include "ui/gl/gl_bindings.h" | 47 #include "ui/gl/gl_bindings.h" |
48 #include "ui/gl/gl_context.h" | 48 #include "ui/gl/gl_context.h" |
49 #include "ui/gl/gl_fence.h" | 49 #include "ui/gl/gl_fence.h" |
50 #include "ui/gl/gl_surface_egl.h" | 50 #include "ui/gl/gl_surface_egl.h" |
51 | 51 |
52 namespace { | 52 namespace { |
53 | 53 |
| 54 // AMD |
| 55 // Path is appended on to the PROGRAM_FILES base path. |
| 56 const wchar_t kAMDVPXDecoderDLLPath[] = |
| 57 L"Common Files\\ATI Technologies\\Multimedia\\"; |
| 58 |
| 59 const wchar_t kAMDVP9DecoderDLLName[] = |
| 60 #if defined(ARCH_CPU_X86) |
| 61 L"amf-mft-decvp9-decoder32.dll"; |
| 62 #elif defined(ARCH_CPU_X86_64) |
| 63 L"amf-mft-decvp9-decoder64.dll"; |
| 64 #else |
| 65 #error Unsupported Windows CPU Architecture |
| 66 #endif |
| 67 |
| 68 const CLSID CLSID_AMDWebmMfVp9Dec = { |
| 69 0x2d2d728a, |
| 70 0x67d6, |
| 71 0x48ab, |
| 72 {0x89, 0xfb, 0xa6, 0xec, 0x65, 0x55, 0x49, 0x70}}; |
| 73 |
| 74 // Intel |
54 // Path is appended on to the PROGRAM_FILES base path. | 75 // Path is appended on to the PROGRAM_FILES base path. |
55 const wchar_t kVPXDecoderDLLPath[] = L"Intel\\Media SDK\\"; | 76 const wchar_t kVPXDecoderDLLPath[] = L"Intel\\Media SDK\\"; |
56 | 77 |
57 const wchar_t kVP8DecoderDLLName[] = | 78 const wchar_t kVP8DecoderDLLName[] = |
58 #if defined(ARCH_CPU_X86) | 79 #if defined(ARCH_CPU_X86) |
59 L"mfx_mft_vp8vd_32.dll"; | 80 L"mfx_mft_vp8vd_32.dll"; |
60 #elif defined(ARCH_CPU_X86_64) | 81 #elif defined(ARCH_CPU_X86_64) |
61 L"mfx_mft_vp8vd_64.dll"; | 82 L"mfx_mft_vp8vd_64.dll"; |
62 #else | 83 #else |
63 #error Unsupported Windows CPU Architecture | 84 #error Unsupported Windows CPU Architecture |
(...skipping 1351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1415 base::string16 file_version = version_info->file_version(); | 1436 base::string16 file_version = version_info->file_version(); |
1416 RETURN_ON_FAILURE(file_version.find(L"6.1.7140") == base::string16::npos, | 1437 RETURN_ON_FAILURE(file_version.find(L"6.1.7140") == base::string16::npos, |
1417 "blacklisted version of msmpeg2vdec.dll 6.1.7140", false); | 1438 "blacklisted version of msmpeg2vdec.dll 6.1.7140", false); |
1418 codec_ = kCodecH264; | 1439 codec_ = kCodecH264; |
1419 clsid = __uuidof(CMSH264DecoderMFT); | 1440 clsid = __uuidof(CMSH264DecoderMFT); |
1420 } else if (enable_accelerated_vpx_decode_ && | 1441 } else if (enable_accelerated_vpx_decode_ && |
1421 (profile == VP8PROFILE_ANY || profile == VP9PROFILE_PROFILE0 || | 1442 (profile == VP8PROFILE_ANY || profile == VP9PROFILE_PROFILE0 || |
1422 profile == VP9PROFILE_PROFILE1 || | 1443 profile == VP9PROFILE_PROFILE1 || |
1423 profile == VP9PROFILE_PROFILE2 || | 1444 profile == VP9PROFILE_PROFILE2 || |
1424 profile == VP9PROFILE_PROFILE3)) { | 1445 profile == VP9PROFILE_PROFILE3)) { |
1425 if (profile != VP8PROFILE_ANY) { | 1446 if (profile != VP8PROFILE_ANY && |
| 1447 (enable_accelerated_vpx_decode_ & |
| 1448 gpu::GpuPreferences::VPX_VENDOR_MICROSOFT)) { |
1426 codec_ = kCodecVP9; | 1449 codec_ = kCodecVP9; |
1427 clsid = CLSID_MSVPxDecoder; | 1450 clsid = CLSID_MSVPxDecoder; |
1428 decoder_dll = ::LoadLibrary(kMSVP9DecoderDLLName); | 1451 decoder_dll = ::LoadLibrary(kMSVP9DecoderDLLName); |
1429 if (decoder_dll) | 1452 if (decoder_dll) |
1430 using_ms_vp9_mft_ = true; | 1453 using_ms_vp9_mft_ = true; |
1431 } | 1454 } |
1432 if (!decoder_dll) { | 1455 |
1433 int program_files_key = base::DIR_PROGRAM_FILES; | 1456 int program_files_key = base::DIR_PROGRAM_FILES; |
1434 if (base::win::OSInfo::GetInstance()->wow64_status() == | 1457 if (base::win::OSInfo::GetInstance()->wow64_status() == |
1435 base::win::OSInfo::WOW64_ENABLED) { | 1458 base::win::OSInfo::WOW64_ENABLED) { |
1436 program_files_key = base::DIR_PROGRAM_FILES6432; | 1459 program_files_key = base::DIR_PROGRAM_FILES6432; |
| 1460 } |
| 1461 |
| 1462 // Intel |
| 1463 if (!decoder_dll && (enable_accelerated_vpx_decode_ & |
| 1464 gpu::GpuPreferences::VPX_VENDOR_INTEL)) { |
| 1465 base::FilePath dll_path; |
| 1466 if (PathService::Get(program_files_key, &dll_path)) { |
| 1467 dll_path = dll_path.Append(kVPXDecoderDLLPath); |
| 1468 if (profile == VP8PROFILE_ANY) { |
| 1469 codec_ = media::kCodecVP8; |
| 1470 dll_path = dll_path.Append(kVP8DecoderDLLName); |
| 1471 clsid = CLSID_WebmMfVp8Dec; |
| 1472 } else { |
| 1473 codec_ = media::kCodecVP9; |
| 1474 dll_path = dll_path.Append(kVP9DecoderDLLName); |
| 1475 clsid = CLSID_WebmMfVp9Dec; |
| 1476 } |
| 1477 decoder_dll = ::LoadLibraryEx(dll_path.value().data(), NULL, |
| 1478 LOAD_WITH_ALTERED_SEARCH_PATH); |
1437 } | 1479 } |
| 1480 } |
| 1481 // AMD |
| 1482 if (!decoder_dll && |
| 1483 enable_accelerated_vpx_decode_ & gpu::GpuPreferences::VPX_VENDOR_AMD && |
| 1484 profile == VP9PROFILE_PROFILE0) { |
| 1485 base::FilePath dll_path; |
| 1486 if (PathService::Get(program_files_key, &dll_path)) { |
| 1487 codec_ = media::kCodecVP9; |
| 1488 dll_path = dll_path.Append(kAMDVPXDecoderDLLPath); |
| 1489 dll_path = dll_path.Append(kAMDVP9DecoderDLLName); |
| 1490 clsid = CLSID_AMDWebmMfVp9Dec; |
| 1491 decoder_dll = ::LoadLibraryEx(dll_path.value().data(), NULL, |
| 1492 LOAD_WITH_ALTERED_SEARCH_PATH); |
| 1493 } |
| 1494 } |
| 1495 } |
1438 | 1496 |
1439 base::FilePath dll_path; | 1497 if (!decoder_dll) { |
1440 RETURN_ON_FAILURE(PathService::Get(program_files_key, &dll_path), | |
1441 "failed to get path for Program Files", false); | |
1442 | |
1443 dll_path = dll_path.Append(kVPXDecoderDLLPath); | |
1444 if (profile == VP8PROFILE_ANY) { | |
1445 codec_ = kCodecVP8; | |
1446 dll_path = dll_path.Append(kVP8DecoderDLLName); | |
1447 clsid = CLSID_WebmMfVp8Dec; | |
1448 } else { | |
1449 codec_ = kCodecVP9; | |
1450 dll_path = dll_path.Append(kVP9DecoderDLLName); | |
1451 clsid = CLSID_WebmMfVp9Dec; | |
1452 } | |
1453 decoder_dll = ::LoadLibraryEx(dll_path.value().data(), NULL, | |
1454 LOAD_WITH_ALTERED_SEARCH_PATH); | |
1455 } | |
1456 RETURN_ON_FAILURE(decoder_dll, "vpx decoder dll is not loaded", false); | |
1457 } else { | |
1458 RETURN_ON_FAILURE(false, "Unsupported codec.", false); | 1498 RETURN_ON_FAILURE(false, "Unsupported codec.", false); |
1459 } | 1499 } |
1460 | 1500 |
1461 HRESULT hr = CreateCOMObjectFromDll( | 1501 HRESULT hr = CreateCOMObjectFromDll( |
1462 decoder_dll, clsid, __uuidof(IMFTransform), decoder_.ReceiveVoid()); | 1502 decoder_dll, clsid, __uuidof(IMFTransform), decoder_.ReceiveVoid()); |
1463 RETURN_ON_HR_FAILURE(hr, "Failed to create decoder instance", false); | 1503 RETURN_ON_HR_FAILURE(hr, "Failed to create decoder instance", false); |
1464 | 1504 |
1465 RETURN_ON_FAILURE(CheckDecoderDxvaSupport(), | 1505 RETURN_ON_FAILURE(CheckDecoderDxvaSupport(), |
1466 "Failed to check decoder DXVA support", false); | 1506 "Failed to check decoder DXVA support", false); |
1467 | 1507 |
(...skipping 1294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2762 SetState(kConfigChange); | 2802 SetState(kConfigChange); |
2763 Invalidate(); | 2803 Invalidate(); |
2764 Initialize(config_, client_); | 2804 Initialize(config_, client_); |
2765 decoder_thread_task_runner_->PostTask( | 2805 decoder_thread_task_runner_->PostTask( |
2766 FROM_HERE, | 2806 FROM_HERE, |
2767 base::Bind(&DXVAVideoDecodeAccelerator::DecodePendingInputBuffers, | 2807 base::Bind(&DXVAVideoDecodeAccelerator::DecodePendingInputBuffers, |
2768 base::Unretained(this))); | 2808 base::Unretained(this))); |
2769 } | 2809 } |
2770 | 2810 |
2771 } // namespace media | 2811 } // namespace media |
OLD | NEW |