| 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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 | 65 |
| 66 const wchar_t kVP9DecoderDLLName[] = | 66 const wchar_t kVP9DecoderDLLName[] = |
| 67 #if defined(ARCH_CPU_X86) | 67 #if defined(ARCH_CPU_X86) |
| 68 L"mfx_mft_vp9vd_32.dll"; | 68 L"mfx_mft_vp9vd_32.dll"; |
| 69 #elif defined(ARCH_CPU_X86_64) | 69 #elif defined(ARCH_CPU_X86_64) |
| 70 L"mfx_mft_vp9vd_64.dll"; | 70 L"mfx_mft_vp9vd_64.dll"; |
| 71 #else | 71 #else |
| 72 #error Unsupported Windows CPU Architecture | 72 #error Unsupported Windows CPU Architecture |
| 73 #endif | 73 #endif |
| 74 | 74 |
| 75 const wchar_t kMSVP9DecoderDLLName[] = L"MSVP9DEC.dll"; |
| 76 |
| 75 const CLSID CLSID_WebmMfVp8Dec = { | 77 const CLSID CLSID_WebmMfVp8Dec = { |
| 76 0x451e3cb7, | 78 0x451e3cb7, |
| 77 0x2622, | 79 0x2622, |
| 78 0x4ba5, | 80 0x4ba5, |
| 79 {0x8e, 0x1d, 0x44, 0xb3, 0xc4, 0x1d, 0x09, 0x24}}; | 81 {0x8e, 0x1d, 0x44, 0xb3, 0xc4, 0x1d, 0x09, 0x24}}; |
| 80 | 82 |
| 81 const CLSID CLSID_WebmMfVp9Dec = { | 83 const CLSID CLSID_WebmMfVp9Dec = { |
| 82 0x07ab4bd2, | 84 0x07ab4bd2, |
| 83 0x1979, | 85 0x1979, |
| 84 0x4fcd, | 86 0x4fcd, |
| (...skipping 601 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 686 "GL fences are unsupported", PLATFORM_FAILURE, | 688 "GL fences are unsupported", PLATFORM_FAILURE, |
| 687 false); | 689 false); |
| 688 | 690 |
| 689 State state = GetState(); | 691 State state = GetState(); |
| 690 RETURN_AND_NOTIFY_ON_FAILURE((state == kUninitialized), | 692 RETURN_AND_NOTIFY_ON_FAILURE((state == kUninitialized), |
| 691 "Initialize: invalid state: " << state, | 693 "Initialize: invalid state: " << state, |
| 692 ILLEGAL_STATE, false); | 694 ILLEGAL_STATE, false); |
| 693 | 695 |
| 694 InitializeMediaFoundation(); | 696 InitializeMediaFoundation(); |
| 695 | 697 |
| 698 config_ = config; |
| 699 |
| 696 RETURN_AND_NOTIFY_ON_FAILURE(InitDecoder(config.profile), | 700 RETURN_AND_NOTIFY_ON_FAILURE(InitDecoder(config.profile), |
| 697 "Failed to initialize decoder", PLATFORM_FAILURE, | 701 "Failed to initialize decoder", PLATFORM_FAILURE, |
| 698 false); | 702 false); |
| 699 | 703 |
| 700 RETURN_AND_NOTIFY_ON_FAILURE(GetStreamsInfoAndBufferReqs(), | 704 RETURN_AND_NOTIFY_ON_FAILURE(GetStreamsInfoAndBufferReqs(), |
| 701 "Failed to get input/output stream info.", | 705 "Failed to get input/output stream info.", |
| 702 PLATFORM_FAILURE, false); | 706 PLATFORM_FAILURE, false); |
| 703 | 707 |
| 704 RETURN_AND_NOTIFY_ON_FAILURE( | 708 RETURN_AND_NOTIFY_ON_FAILURE( |
| 705 SendMFTMessage(MFT_MESSAGE_NOTIFY_BEGIN_STREAMING, 0), | 709 SendMFTMessage(MFT_MESSAGE_NOTIFY_BEGIN_STREAMING, 0), |
| 706 "Send MFT_MESSAGE_NOTIFY_BEGIN_STREAMING notification failed", | 710 "Send MFT_MESSAGE_NOTIFY_BEGIN_STREAMING notification failed", |
| 707 PLATFORM_FAILURE, false); | 711 PLATFORM_FAILURE, false); |
| 708 | 712 |
| 709 RETURN_AND_NOTIFY_ON_FAILURE( | 713 RETURN_AND_NOTIFY_ON_FAILURE( |
| 710 SendMFTMessage(MFT_MESSAGE_NOTIFY_START_OF_STREAM, 0), | 714 SendMFTMessage(MFT_MESSAGE_NOTIFY_START_OF_STREAM, 0), |
| 711 "Send MFT_MESSAGE_NOTIFY_START_OF_STREAM notification failed", | 715 "Send MFT_MESSAGE_NOTIFY_START_OF_STREAM notification failed", |
| 712 PLATFORM_FAILURE, false); | 716 PLATFORM_FAILURE, false); |
| 713 | 717 |
| 714 config_ = config; | |
| 715 | |
| 716 config_change_detector_.reset(new H264ConfigChangeDetector); | 718 config_change_detector_.reset(new H264ConfigChangeDetector); |
| 717 | 719 |
| 718 SetState(kNormal); | 720 SetState(kNormal); |
| 719 | 721 |
| 720 StartDecoderThread(); | 722 StartDecoderThread(); |
| 721 return true; | 723 return true; |
| 722 } | 724 } |
| 723 | 725 |
| 724 bool DXVAVideoDecodeAccelerator::CreateD3DDevManager() { | 726 bool DXVAVideoDecodeAccelerator::CreateD3DDevManager() { |
| 725 TRACE_EVENT0("gpu", "DXVAVideoDecodeAccelerator_CreateD3DDevManager"); | 727 TRACE_EVENT0("gpu", "DXVAVideoDecodeAccelerator_CreateD3DDevManager"); |
| (...skipping 679 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1405 base::string16 file_version = version_info->file_version(); | 1407 base::string16 file_version = version_info->file_version(); |
| 1406 RETURN_ON_FAILURE(file_version.find(L"6.1.7140") == base::string16::npos, | 1408 RETURN_ON_FAILURE(file_version.find(L"6.1.7140") == base::string16::npos, |
| 1407 "blacklisted version of msmpeg2vdec.dll 6.1.7140", false); | 1409 "blacklisted version of msmpeg2vdec.dll 6.1.7140", false); |
| 1408 codec_ = kCodecH264; | 1410 codec_ = kCodecH264; |
| 1409 clsid = __uuidof(CMSH264DecoderMFT); | 1411 clsid = __uuidof(CMSH264DecoderMFT); |
| 1410 } else if (enable_accelerated_vpx_decode_ && | 1412 } else if (enable_accelerated_vpx_decode_ && |
| 1411 (profile == VP8PROFILE_ANY || profile == VP9PROFILE_PROFILE0 || | 1413 (profile == VP8PROFILE_ANY || profile == VP9PROFILE_PROFILE0 || |
| 1412 profile == VP9PROFILE_PROFILE1 || | 1414 profile == VP9PROFILE_PROFILE1 || |
| 1413 profile == VP9PROFILE_PROFILE2 || | 1415 profile == VP9PROFILE_PROFILE2 || |
| 1414 profile == VP9PROFILE_PROFILE3)) { | 1416 profile == VP9PROFILE_PROFILE3)) { |
| 1415 int program_files_key = base::DIR_PROGRAM_FILES; | 1417 if (profile != VP8PROFILE_ANY) { |
| 1416 if (base::win::OSInfo::GetInstance()->wow64_status() == | 1418 codec_ = kCodecVP9; |
| 1417 base::win::OSInfo::WOW64_ENABLED) { | 1419 clsid = CLSID_MSVPxDecoder; |
| 1418 program_files_key = base::DIR_PROGRAM_FILES6432; | 1420 decoder_dll = ::LoadLibrary(kMSVP9DecoderDLLName); |
| 1421 if (decoder_dll) |
| 1422 using_ms_vp9_mft_ = true; |
| 1419 } | 1423 } |
| 1424 if (!decoder_dll) { |
| 1425 int program_files_key = base::DIR_PROGRAM_FILES; |
| 1426 if (base::win::OSInfo::GetInstance()->wow64_status() == |
| 1427 base::win::OSInfo::WOW64_ENABLED) { |
| 1428 program_files_key = base::DIR_PROGRAM_FILES6432; |
| 1429 } |
| 1420 | 1430 |
| 1421 base::FilePath dll_path; | 1431 base::FilePath dll_path; |
| 1422 RETURN_ON_FAILURE(PathService::Get(program_files_key, &dll_path), | 1432 RETURN_ON_FAILURE(PathService::Get(program_files_key, &dll_path), |
| 1423 "failed to get path for Program Files", false); | 1433 "failed to get path for Program Files", false); |
| 1424 | 1434 |
| 1425 dll_path = dll_path.Append(kVPXDecoderDLLPath); | 1435 dll_path = dll_path.Append(kVPXDecoderDLLPath); |
| 1426 if (profile == VP8PROFILE_ANY) { | 1436 if (profile == VP8PROFILE_ANY) { |
| 1427 codec_ = kCodecVP8; | 1437 codec_ = kCodecVP8; |
| 1428 dll_path = dll_path.Append(kVP8DecoderDLLName); | 1438 dll_path = dll_path.Append(kVP8DecoderDLLName); |
| 1429 clsid = CLSID_WebmMfVp8Dec; | 1439 clsid = CLSID_WebmMfVp8Dec; |
| 1430 } else { | 1440 } else { |
| 1431 codec_ = kCodecVP9; | 1441 codec_ = kCodecVP9; |
| 1432 dll_path = dll_path.Append(kVP9DecoderDLLName); | 1442 dll_path = dll_path.Append(kVP9DecoderDLLName); |
| 1433 clsid = CLSID_WebmMfVp9Dec; | 1443 clsid = CLSID_WebmMfVp9Dec; |
| 1444 } |
| 1445 decoder_dll = ::LoadLibraryEx(dll_path.value().data(), NULL, |
| 1446 LOAD_WITH_ALTERED_SEARCH_PATH); |
| 1434 } | 1447 } |
| 1435 decoder_dll = ::LoadLibraryEx(dll_path.value().data(), NULL, | |
| 1436 LOAD_WITH_ALTERED_SEARCH_PATH); | |
| 1437 RETURN_ON_FAILURE(decoder_dll, "vpx decoder dll is not loaded", false); | 1448 RETURN_ON_FAILURE(decoder_dll, "vpx decoder dll is not loaded", false); |
| 1438 } else { | 1449 } else { |
| 1439 RETURN_ON_FAILURE(false, "Unsupported codec.", false); | 1450 RETURN_ON_FAILURE(false, "Unsupported codec.", false); |
| 1440 } | 1451 } |
| 1441 | 1452 |
| 1442 HRESULT hr = CreateCOMObjectFromDll( | 1453 HRESULT hr = CreateCOMObjectFromDll( |
| 1443 decoder_dll, clsid, __uuidof(IMFTransform), decoder_.ReceiveVoid()); | 1454 decoder_dll, clsid, __uuidof(IMFTransform), decoder_.ReceiveVoid()); |
| 1444 RETURN_ON_HR_FAILURE(hr, "Failed to create decoder instance", false); | 1455 RETURN_ON_HR_FAILURE(hr, "Failed to create decoder instance", false); |
| 1445 | 1456 |
| 1446 RETURN_ON_FAILURE(CheckDecoderDxvaSupport(), | 1457 RETURN_ON_FAILURE(CheckDecoderDxvaSupport(), |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1558 } else if (codec_ == kCodecVP8) { | 1569 } else if (codec_ == kCodecVP8) { |
| 1559 hr = media_type->SetGUID(MF_MT_SUBTYPE, MEDIASUBTYPE_VP80); | 1570 hr = media_type->SetGUID(MF_MT_SUBTYPE, MEDIASUBTYPE_VP80); |
| 1560 } else if (codec_ == kCodecVP9) { | 1571 } else if (codec_ == kCodecVP9) { |
| 1561 hr = media_type->SetGUID(MF_MT_SUBTYPE, MEDIASUBTYPE_VP90); | 1572 hr = media_type->SetGUID(MF_MT_SUBTYPE, MEDIASUBTYPE_VP90); |
| 1562 } else { | 1573 } else { |
| 1563 NOTREACHED(); | 1574 NOTREACHED(); |
| 1564 RETURN_ON_FAILURE(false, "Unsupported codec on input media type.", false); | 1575 RETURN_ON_FAILURE(false, "Unsupported codec on input media type.", false); |
| 1565 } | 1576 } |
| 1566 RETURN_ON_HR_FAILURE(hr, "Failed to set subtype", false); | 1577 RETURN_ON_HR_FAILURE(hr, "Failed to set subtype", false); |
| 1567 | 1578 |
| 1568 // Not sure about this. msdn recommends setting this value on the input | 1579 if (using_ms_vp9_mft_) { |
| 1569 // media type. | 1580 hr = MFSetAttributeSize(media_type.get(), MF_MT_FRAME_SIZE, |
| 1570 hr = media_type->SetUINT32(MF_MT_INTERLACE_MODE, | 1581 config_.initial_expected_coded_size.width(), |
| 1571 MFVideoInterlace_MixedInterlaceOrProgressive); | 1582 config_.initial_expected_coded_size.height()); |
| 1572 RETURN_ON_HR_FAILURE(hr, "Failed to set interlace mode", false); | 1583 RETURN_ON_HR_FAILURE(hr, "Failed to set attribute size", false); |
| 1584 |
| 1585 hr = media_type->SetUINT32(MF_MT_INTERLACE_MODE, |
| 1586 MFVideoInterlace_Progressive); |
| 1587 RETURN_ON_HR_FAILURE(hr, "Failed to set interlace mode", false); |
| 1588 } else { |
| 1589 // Not sure about this. msdn recommends setting this value on the input |
| 1590 // media type. |
| 1591 hr = media_type->SetUINT32(MF_MT_INTERLACE_MODE, |
| 1592 MFVideoInterlace_MixedInterlaceOrProgressive); |
| 1593 RETURN_ON_HR_FAILURE(hr, "Failed to set interlace mode", false); |
| 1594 } |
| 1573 | 1595 |
| 1574 hr = decoder_->SetInputType(0, media_type.get(), 0); // No flags | 1596 hr = decoder_->SetInputType(0, media_type.get(), 0); // No flags |
| 1575 RETURN_ON_HR_FAILURE(hr, "Failed to set decoder input type", false); | 1597 RETURN_ON_HR_FAILURE(hr, "Failed to set decoder input type", false); |
| 1576 return true; | 1598 return true; |
| 1577 } | 1599 } |
| 1578 | 1600 |
| 1579 bool DXVAVideoDecodeAccelerator::SetDecoderOutputMediaType( | 1601 bool DXVAVideoDecodeAccelerator::SetDecoderOutputMediaType( |
| 1580 const GUID& subtype) { | 1602 const GUID& subtype) { |
| 1581 bool result = SetTransformOutputType(decoder_.get(), subtype, 0, 0); | 1603 bool result = SetTransformOutputType(decoder_.get(), subtype, 0, 0); |
| 1582 | 1604 |
| (...skipping 1149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2732 SetState(kConfigChange); | 2754 SetState(kConfigChange); |
| 2733 Invalidate(); | 2755 Invalidate(); |
| 2734 Initialize(config_, client_); | 2756 Initialize(config_, client_); |
| 2735 decoder_thread_task_runner_->PostTask( | 2757 decoder_thread_task_runner_->PostTask( |
| 2736 FROM_HERE, | 2758 FROM_HERE, |
| 2737 base::Bind(&DXVAVideoDecodeAccelerator::DecodePendingInputBuffers, | 2759 base::Bind(&DXVAVideoDecodeAccelerator::DecodePendingInputBuffers, |
| 2738 base::Unretained(this))); | 2760 base::Unretained(this))); |
| 2739 } | 2761 } |
| 2740 | 2762 |
| 2741 } // namespace media | 2763 } // namespace media |
| OLD | NEW |