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. |
11 #endif // !defined(OS_WIN) | 11 #endif // !defined(OS_WIN) |
12 | 12 |
13 #include <codecapi.h> | 13 #include <codecapi.h> |
14 #include <dxgi1_2.h> | 14 #include <dxgi1_2.h> |
15 #include <ks.h> | 15 #include <ks.h> |
16 #include <mfapi.h> | 16 #include <mfapi.h> |
17 #include <mferror.h> | 17 #include <mferror.h> |
18 #include <ntverp.h> | 18 #include <ntverp.h> |
| 19 #include <objbase.h> |
19 #include <stddef.h> | 20 #include <stddef.h> |
20 #include <string.h> | 21 #include <string.h> |
21 #include <wmcodecdsp.h> | 22 #include <wmcodecdsp.h> |
22 | 23 |
23 #include "base/atomicops.h" | 24 #include "base/atomicops.h" |
24 #include "base/base_paths_win.h" | 25 #include "base/base_paths_win.h" |
25 #include "base/bind.h" | 26 #include "base/bind.h" |
26 #include "base/callback.h" | 27 #include "base/callback.h" |
27 #include "base/command_line.h" | 28 #include "base/command_line.h" |
28 #include "base/debug/alias.h" | 29 #include "base/debug/alias.h" |
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
329 | 330 |
330 using GetClassObject = | 331 using GetClassObject = |
331 HRESULT(WINAPI*)(const CLSID& clsid, const IID& iid, void** object); | 332 HRESULT(WINAPI*)(const CLSID& clsid, const IID& iid, void** object); |
332 | 333 |
333 GetClassObject get_class_object = reinterpret_cast<GetClassObject>( | 334 GetClassObject get_class_object = reinterpret_cast<GetClassObject>( |
334 GetProcAddress(dll, "DllGetClassObject")); | 335 GetProcAddress(dll, "DllGetClassObject")); |
335 RETURN_ON_FAILURE(get_class_object, "Failed to get DllGetClassObject pointer", | 336 RETURN_ON_FAILURE(get_class_object, "Failed to get DllGetClassObject pointer", |
336 E_FAIL); | 337 E_FAIL); |
337 | 338 |
338 base::win::ScopedComPtr<IClassFactory> factory; | 339 base::win::ScopedComPtr<IClassFactory> factory; |
339 HRESULT hr = | 340 HRESULT hr = get_class_object(clsid, IID_PPV_ARGS(&factory)); |
340 get_class_object(clsid, __uuidof(IClassFactory), factory.ReceiveVoid()); | |
341 RETURN_ON_HR_FAILURE(hr, "DllGetClassObject failed", hr); | 341 RETURN_ON_HR_FAILURE(hr, "DllGetClassObject failed", hr); |
342 | 342 |
343 hr = factory->CreateInstance(NULL, iid, object); | 343 hr = factory->CreateInstance(NULL, iid, object); |
344 return hr; | 344 return hr; |
345 } | 345 } |
346 | 346 |
347 H264ConfigChangeDetector::H264ConfigChangeDetector() | 347 H264ConfigChangeDetector::H264ConfigChangeDetector() |
348 : last_sps_id_(0), | 348 : last_sps_id_(0), |
349 last_pps_id_(0), | 349 last_pps_id_(0), |
350 config_changed_(false), | 350 config_changed_(false), |
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
714 } | 714 } |
715 | 715 |
716 bool DXVAVideoDecodeAccelerator::CreateVideoProcessor() { | 716 bool DXVAVideoDecodeAccelerator::CreateVideoProcessor() { |
717 if (!use_color_info_) | 717 if (!use_color_info_) |
718 return false; | 718 return false; |
719 | 719 |
720 // TODO(Hubbe): Don't try again if we tried and failed already. | 720 // TODO(Hubbe): Don't try again if we tried and failed already. |
721 if (video_processor_service_.Get()) | 721 if (video_processor_service_.Get()) |
722 return true; | 722 return true; |
723 HRESULT hr = DXVA2CreateVideoService(d3d9_device_ex_.Get(), | 723 HRESULT hr = DXVA2CreateVideoService(d3d9_device_ex_.Get(), |
724 IID_IDirectXVideoProcessorService, | 724 IID_PPV_ARGS(&video_processor_service_)); |
725 video_processor_service_.ReceiveVoid()); | |
726 RETURN_ON_HR_FAILURE(hr, "DXVA2CreateVideoService failed", false); | 725 RETURN_ON_HR_FAILURE(hr, "DXVA2CreateVideoService failed", false); |
727 | 726 |
728 // TODO(Hubbe): Use actual video settings. | 727 // TODO(Hubbe): Use actual video settings. |
729 DXVA2_VideoDesc inputDesc; | 728 DXVA2_VideoDesc inputDesc; |
730 inputDesc.SampleWidth = 1920; | 729 inputDesc.SampleWidth = 1920; |
731 inputDesc.SampleHeight = 1080; | 730 inputDesc.SampleHeight = 1080; |
732 inputDesc.SampleFormat.VideoChromaSubsampling = | 731 inputDesc.SampleFormat.VideoChromaSubsampling = |
733 DXVA2_VideoChromaSubsampling_MPEG2; | 732 DXVA2_VideoChromaSubsampling_MPEG2; |
734 inputDesc.SampleFormat.NominalRange = DXVA2_NominalRange_16_235; | 733 inputDesc.SampleFormat.NominalRange = DXVA2_NominalRange_16_235; |
735 inputDesc.SampleFormat.VideoTransferMatrix = DXVA2_VideoTransferMatrix_BT709; | 734 inputDesc.SampleFormat.VideoTransferMatrix = DXVA2_VideoTransferMatrix_BT709; |
(...skipping 566 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1302 { | 1301 { |
1303 TRACE_EVENT0("gpu,startup", | 1302 TRACE_EVENT0("gpu,startup", |
1304 "GetMaxH264Resolution. QueryDeviceObjectFromANGLE"); | 1303 "GetMaxH264Resolution. QueryDeviceObjectFromANGLE"); |
1305 | 1304 |
1306 device = gl::QueryD3D11DeviceObjectFromANGLE(); | 1305 device = gl::QueryD3D11DeviceObjectFromANGLE(); |
1307 if (!device.Get()) | 1306 if (!device.Get()) |
1308 return max_resolution; | 1307 return max_resolution; |
1309 } | 1308 } |
1310 | 1309 |
1311 base::win::ScopedComPtr<ID3D11VideoDevice> video_device; | 1310 base::win::ScopedComPtr<ID3D11VideoDevice> video_device; |
1312 hr = device.QueryInterface(__uuidof(ID3D11VideoDevice), | 1311 hr = device.QueryInterface(IID_PPV_ARGS(&video_device)); |
1313 video_device.ReceiveVoid()); | |
1314 if (FAILED(hr)) | 1312 if (FAILED(hr)) |
1315 return max_resolution; | 1313 return max_resolution; |
1316 | 1314 |
1317 GUID decoder_guid = {}; | 1315 GUID decoder_guid = {}; |
1318 | 1316 |
1319 { | 1317 { |
1320 TRACE_EVENT0("gpu,startup", | 1318 TRACE_EVENT0("gpu,startup", |
1321 "GetMaxH264Resolution. H.264 guid search begin"); | 1319 "GetMaxH264Resolution. H.264 guid search begin"); |
1322 // Enumerate supported video profiles and look for the H264 profile. | 1320 // Enumerate supported video profiles and look for the H264 profile. |
1323 bool found = false; | 1321 bool found = false; |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1502 decoder_dll = ::LoadLibraryEx(dll_path.value().data(), NULL, | 1500 decoder_dll = ::LoadLibraryEx(dll_path.value().data(), NULL, |
1503 LOAD_WITH_ALTERED_SEARCH_PATH); | 1501 LOAD_WITH_ALTERED_SEARCH_PATH); |
1504 } | 1502 } |
1505 } | 1503 } |
1506 } | 1504 } |
1507 | 1505 |
1508 if (!decoder_dll) { | 1506 if (!decoder_dll) { |
1509 RETURN_ON_FAILURE(false, "Unsupported codec.", false); | 1507 RETURN_ON_FAILURE(false, "Unsupported codec.", false); |
1510 } | 1508 } |
1511 | 1509 |
1512 HRESULT hr = CreateCOMObjectFromDll( | 1510 HRESULT hr = CreateCOMObjectFromDll(decoder_dll, clsid, |
1513 decoder_dll, clsid, __uuidof(IMFTransform), decoder_.ReceiveVoid()); | 1511 IID_PPV_ARGS(&decoder_)); |
1514 RETURN_ON_HR_FAILURE(hr, "Failed to create decoder instance", false); | 1512 RETURN_ON_HR_FAILURE(hr, "Failed to create decoder instance", false); |
1515 | 1513 |
1516 RETURN_ON_FAILURE(CheckDecoderDxvaSupport(), | 1514 RETURN_ON_FAILURE(CheckDecoderDxvaSupport(), |
1517 "Failed to check decoder DXVA support", false); | 1515 "Failed to check decoder DXVA support", false); |
1518 | 1516 |
1519 ULONG_PTR device_manager_to_use = NULL; | 1517 ULONG_PTR device_manager_to_use = NULL; |
1520 if (use_dx11_) { | 1518 if (use_dx11_) { |
1521 CHECK(create_dxgi_device_manager_); | 1519 CHECK(create_dxgi_device_manager_); |
1522 RETURN_AND_NOTIFY_ON_FAILURE(CreateDX11DevManager(), | 1520 RETURN_AND_NOTIFY_ON_FAILURE(CreateDX11DevManager(), |
1523 "Failed to initialize DX11 device and manager", | 1521 "Failed to initialize DX11 device and manager", |
(...skipping 1462 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2986 base::Bind(&DXVAVideoDecodeAccelerator::DecodePendingInputBuffers, | 2984 base::Bind(&DXVAVideoDecodeAccelerator::DecodePendingInputBuffers, |
2987 base::Unretained(this))); | 2985 base::Unretained(this))); |
2988 } | 2986 } |
2989 | 2987 |
2990 uint32_t DXVAVideoDecodeAccelerator::GetTextureTarget() const { | 2988 uint32_t DXVAVideoDecodeAccelerator::GetTextureTarget() const { |
2991 bool provide_nv12_textures = share_nv12_textures_ || copy_nv12_textures_; | 2989 bool provide_nv12_textures = share_nv12_textures_ || copy_nv12_textures_; |
2992 return provide_nv12_textures ? GL_TEXTURE_EXTERNAL_OES : GL_TEXTURE_2D; | 2990 return provide_nv12_textures ? GL_TEXTURE_EXTERNAL_OES : GL_TEXTURE_2D; |
2993 } | 2991 } |
2994 | 2992 |
2995 } // namespace media | 2993 } // namespace media |
OLD | NEW |