Chromium Code Reviews| 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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 42 #include "media/gpu/dxva_picture_buffer_win.h" | 42 #include "media/gpu/dxva_picture_buffer_win.h" |
| 43 #include "media/video/video_decode_accelerator.h" | 43 #include "media/video/video_decode_accelerator.h" |
| 44 #include "third_party/angle/include/EGL/egl.h" | 44 #include "third_party/angle/include/EGL/egl.h" |
| 45 #include "third_party/angle/include/EGL/eglext.h" | 45 #include "third_party/angle/include/EGL/eglext.h" |
| 46 #include "ui/gl/gl_bindings.h" | 46 #include "ui/gl/gl_bindings.h" |
| 47 #include "ui/gl/gl_context.h" | 47 #include "ui/gl/gl_context.h" |
| 48 #include "ui/gl/gl_fence.h" | 48 #include "ui/gl/gl_fence.h" |
| 49 #include "ui/gl/gl_surface_egl.h" | 49 #include "ui/gl/gl_surface_egl.h" |
| 50 | 50 |
| 51 namespace { | 51 namespace { |
| 52 #define INTEL_WEBM_MFT_VP9_ENABLE_MASK 0x1 | |
| 53 #define AMD_WEBM_MFT_VP9_ENABLE_MASK 0x2 | |
| 52 | 54 |
| 55 // AMD | |
| 56 // Path is appended on to the PROGRAM_FILES base path. | |
| 57 const wchar_t kAMDVPXDecoderDLLPath[] = | |
| 58 L"Common Files\\ATI Technologies\\Multimedia\\"; | |
| 59 | |
| 60 const wchar_t kAMDVP9DecoderDLLName[] = | |
| 61 #if defined(ARCH_CPU_X86) | |
| 62 L"amf-mft-decvp9-decoder32.dll"; | |
| 63 #elif defined(ARCH_CPU_X86_64) | |
| 64 L"amf-mft-decvp9-decoder64.dll"; | |
| 65 #else | |
| 66 #error Unsupported Windows CPU Architecture | |
| 67 #endif | |
| 68 | |
| 69 const CLSID CLSID_AMDWebmMfVp9Dec = { | |
| 70 0x2d2d728a, | |
| 71 0x67d6, | |
| 72 0x48ab, | |
| 73 {0x89, 0xfb, 0xa6, 0xec, 0x65, 0x55, 0x49, 0x70}}; | |
| 74 | |
| 75 // Intel | |
| 53 // Path is appended on to the PROGRAM_FILES base path. | 76 // Path is appended on to the PROGRAM_FILES base path. |
| 54 const wchar_t kVPXDecoderDLLPath[] = L"Intel\\Media SDK\\"; | 77 const wchar_t kVPXDecoderDLLPath[] = L"Intel\\Media SDK\\"; |
| 55 | 78 |
| 56 const wchar_t kVP8DecoderDLLName[] = | 79 const wchar_t kVP8DecoderDLLName[] = |
| 57 #if defined(ARCH_CPU_X86) | 80 #if defined(ARCH_CPU_X86) |
| 58 L"mfx_mft_vp8vd_32.dll"; | 81 L"mfx_mft_vp8vd_32.dll"; |
| 59 #elif defined(ARCH_CPU_X86_64) | 82 #elif defined(ARCH_CPU_X86_64) |
| 60 L"mfx_mft_vp8vd_64.dll"; | 83 L"mfx_mft_vp8vd_64.dll"; |
| 61 #else | 84 #else |
| 62 #error Unsupported Windows CPU Architecture | 85 #error Unsupported Windows CPU Architecture |
| (...skipping 1318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1381 // fall back to software decoding. See crbug/403440. | 1404 // fall back to software decoding. See crbug/403440. |
| 1382 std::unique_ptr<FileVersionInfo> version_info( | 1405 std::unique_ptr<FileVersionInfo> version_info( |
| 1383 FileVersionInfo::CreateFileVersionInfoForModule(decoder_dll)); | 1406 FileVersionInfo::CreateFileVersionInfoForModule(decoder_dll)); |
| 1384 RETURN_ON_FAILURE(version_info, "unable to get version of msmpeg2vdec.dll", | 1407 RETURN_ON_FAILURE(version_info, "unable to get version of msmpeg2vdec.dll", |
| 1385 false); | 1408 false); |
| 1386 base::string16 file_version = version_info->file_version(); | 1409 base::string16 file_version = version_info->file_version(); |
| 1387 RETURN_ON_FAILURE(file_version.find(L"6.1.7140") == base::string16::npos, | 1410 RETURN_ON_FAILURE(file_version.find(L"6.1.7140") == base::string16::npos, |
| 1388 "blacklisted version of msmpeg2vdec.dll 6.1.7140", false); | 1411 "blacklisted version of msmpeg2vdec.dll 6.1.7140", false); |
| 1389 codec_ = kCodecH264; | 1412 codec_ = kCodecH264; |
| 1390 clsid = __uuidof(CMSH264DecoderMFT); | 1413 clsid = __uuidof(CMSH264DecoderMFT); |
| 1391 } else if (enable_accelerated_vpx_decode_ && | 1414 } else if (enable_accelerated_vpx_decode_ != 0 && |
| 1392 (profile == VP8PROFILE_ANY || profile == VP9PROFILE_PROFILE0 || | 1415 (profile == media::VP8PROFILE_ANY || |
|
jbauman
2016/06/28 20:24:22
Shouldn't need to change this.
kplum
2016/06/28 21:35:14
Acknowledged.
| |
| 1393 profile == VP9PROFILE_PROFILE1 || | 1416 profile == media::VP9PROFILE_PROFILE0 || |
| 1394 profile == VP9PROFILE_PROFILE2 || | 1417 profile == media::VP9PROFILE_PROFILE1 || |
| 1395 profile == VP9PROFILE_PROFILE3)) { | 1418 profile == media::VP9PROFILE_PROFILE2 || |
| 1419 profile == media::VP9PROFILE_PROFILE3)) { | |
| 1396 int program_files_key = base::DIR_PROGRAM_FILES; | 1420 int program_files_key = base::DIR_PROGRAM_FILES; |
| 1397 if (base::win::OSInfo::GetInstance()->wow64_status() == | 1421 if (base::win::OSInfo::GetInstance()->wow64_status() == |
| 1398 base::win::OSInfo::WOW64_ENABLED) { | 1422 base::win::OSInfo::WOW64_ENABLED) { |
| 1399 program_files_key = base::DIR_PROGRAM_FILES6432; | 1423 program_files_key = base::DIR_PROGRAM_FILES6432; |
| 1400 } | 1424 } |
| 1401 | 1425 |
| 1402 base::FilePath dll_path; | 1426 // Intel |
| 1403 RETURN_ON_FAILURE(PathService::Get(program_files_key, &dll_path), | 1427 if (enable_accelerated_vpx_decode_ & INTEL_WEBM_MFT_VP9_ENABLE_MASK) { |
| 1404 "failed to get path for Program Files", false); | 1428 base::FilePath dll_path; |
| 1429 if (PathService::Get(program_files_key, &dll_path)) { | |
| 1430 dll_path = dll_path.Append(kVPXDecoderDLLPath); | |
| 1431 if (profile == media::VP8PROFILE_ANY) { | |
| 1432 codec_ = media::kCodecVP8; | |
| 1433 dll_path = dll_path.Append(kVP8DecoderDLLName); | |
| 1434 clsid = CLSID_WebmMfVp8Dec; | |
| 1435 } else { | |
| 1436 codec_ = media::kCodecVP9; | |
| 1437 dll_path = dll_path.Append(kVP9DecoderDLLName); | |
| 1438 clsid = CLSID_WebmMfVp9Dec; | |
| 1439 } | |
| 1440 decoder_dll = ::LoadLibraryEx(dll_path.value().data(), NULL, | |
| 1441 LOAD_WITH_ALTERED_SEARCH_PATH); | |
| 1442 } | |
| 1443 } | |
| 1444 // AMD | |
| 1445 if (decoder_dll == NULL && | |
| 1446 enable_accelerated_vpx_decode_ & AMD_WEBM_MFT_VP9_ENABLE_MASK && | |
| 1447 profile == media::VP9PROFILE_PROFILE0) { | |
| 1448 base::FilePath dll_path; | |
| 1449 if (PathService::Get(program_files_key, &dll_path)) { | |
| 1450 codec_ = media::kCodecVP9; | |
| 1451 dll_path = dll_path.Append(kAMDVPXDecoderDLLPath); | |
| 1452 dll_path = dll_path.Append(kAMDVP9DecoderDLLName); | |
|
jbauman
2016/06/28 20:24:22
Do you need to try to load this in DXVAVideoDecode
kplum
2016/06/28 21:35:14
Originally I thought I would, but then I noticed I
| |
| 1453 clsid = CLSID_AMDWebmMfVp9Dec; | |
| 1454 decoder_dll = ::LoadLibraryEx(dll_path.value().data(), NULL, | |
| 1455 LOAD_WITH_ALTERED_SEARCH_PATH); | |
| 1456 } | |
| 1457 } | |
| 1458 } | |
| 1405 | 1459 |
| 1406 dll_path = dll_path.Append(kVPXDecoderDLLPath); | 1460 // if nothing selected at this point, or dlls failed to load, |
| 1407 if (profile == VP8PROFILE_ANY) { | 1461 // there is no support for this codec. |
| 1408 codec_ = kCodecVP8; | 1462 if (decoder_dll == NULL) { |
| 1409 dll_path = dll_path.Append(kVP8DecoderDLLName); | |
| 1410 clsid = CLSID_WebmMfVp8Dec; | |
| 1411 } else { | |
| 1412 codec_ = kCodecVP9; | |
| 1413 dll_path = dll_path.Append(kVP9DecoderDLLName); | |
| 1414 clsid = CLSID_WebmMfVp9Dec; | |
| 1415 } | |
| 1416 decoder_dll = ::LoadLibraryEx(dll_path.value().data(), NULL, | |
| 1417 LOAD_WITH_ALTERED_SEARCH_PATH); | |
| 1418 RETURN_ON_FAILURE(decoder_dll, "vpx decoder dll is not loaded", false); | |
| 1419 } else { | |
| 1420 RETURN_ON_FAILURE(false, "Unsupported codec.", false); | 1463 RETURN_ON_FAILURE(false, "Unsupported codec.", false); |
| 1421 } | 1464 } |
| 1422 | 1465 |
| 1423 HRESULT hr = CreateCOMObjectFromDll( | 1466 HRESULT hr = CreateCOMObjectFromDll( |
| 1424 decoder_dll, clsid, __uuidof(IMFTransform), decoder_.ReceiveVoid()); | 1467 decoder_dll, clsid, __uuidof(IMFTransform), decoder_.ReceiveVoid()); |
| 1425 RETURN_ON_HR_FAILURE(hr, "Failed to create decoder instance", false); | 1468 RETURN_ON_HR_FAILURE(hr, "Failed to create decoder instance", false); |
| 1426 | 1469 |
| 1427 RETURN_ON_FAILURE(CheckDecoderDxvaSupport(), | 1470 RETURN_ON_FAILURE(CheckDecoderDxvaSupport(), |
| 1428 "Failed to check decoder DXVA support", false); | 1471 "Failed to check decoder DXVA support", false); |
| 1429 | 1472 |
| (...skipping 1253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2683 SetState(kConfigChange); | 2726 SetState(kConfigChange); |
| 2684 Invalidate(); | 2727 Invalidate(); |
| 2685 Initialize(config_, client_); | 2728 Initialize(config_, client_); |
| 2686 decoder_thread_task_runner_->PostTask( | 2729 decoder_thread_task_runner_->PostTask( |
| 2687 FROM_HERE, | 2730 FROM_HERE, |
| 2688 base::Bind(&DXVAVideoDecodeAccelerator::DecodePendingInputBuffers, | 2731 base::Bind(&DXVAVideoDecodeAccelerator::DecodePendingInputBuffers, |
| 2689 base::Unretained(this))); | 2732 base::Unretained(this))); |
| 2690 } | 2733 } |
| 2691 | 2734 |
| 2692 } // namespace media | 2735 } // namespace media |
| OLD | NEW |