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 "content/common/gpu/media/dxva_video_decode_accelerator.h" | 5 #include "content/common/gpu/media/dxva_video_decode_accelerator.h" |
6 | 6 |
7 #if !defined(OS_WIN) | 7 #if !defined(OS_WIN) |
8 #error This file should only be built on Windows. | 8 #error This file should only be built on Windows. |
9 #endif // !defined(OS_WIN) | 9 #endif // !defined(OS_WIN) |
10 | 10 |
11 #include <ks.h> | 11 #include <ks.h> |
12 #include <codecapi.h> | 12 #include <codecapi.h> |
13 #include <mfapi.h> | 13 #include <mfapi.h> |
14 #include <mferror.h> | 14 #include <mferror.h> |
15 #include <wmcodecdsp.h> | 15 #include <wmcodecdsp.h> |
16 | 16 |
17 #include "base/bind.h" | 17 #include "base/bind.h" |
18 #include "base/callback.h" | 18 #include "base/callback.h" |
19 #include "base/command_line.h" | 19 #include "base/command_line.h" |
20 #include "base/debug/trace_event.h" | 20 #include "base/debug/trace_event.h" |
21 #include "base/logging.h" | 21 #include "base/logging.h" |
22 #include "base/memory/scoped_handle.h" | 22 #include "base/memory/scoped_handle.h" |
23 #include "base/memory/scoped_ptr.h" | 23 #include "base/memory/scoped_ptr.h" |
24 #include "base/memory/shared_memory.h" | 24 #include "base/memory/shared_memory.h" |
25 #include "base/message_loop/message_loop.h" | 25 #include "base/message_loop/message_loop.h" |
| 26 #include "base/win/windows_version.h" |
26 #include "media/video/video_decode_accelerator.h" | 27 #include "media/video/video_decode_accelerator.h" |
27 #include "ui/gl/gl_bindings.h" | 28 #include "ui/gl/gl_bindings.h" |
28 #include "ui/gl/gl_surface_egl.h" | 29 #include "ui/gl/gl_surface_egl.h" |
29 #include "ui/gl/gl_switches.h" | 30 #include "ui/gl/gl_switches.h" |
30 | 31 |
31 namespace content { | 32 namespace content { |
32 | 33 |
33 // We only request 5 picture buffers from the client which are used to hold the | 34 // We only request 5 picture buffers from the client which are used to hold the |
34 // decoded samples. These buffers are then reused when the client tells us that | 35 // decoded samples. These buffers are then reused when the client tells us that |
35 // it is done with the buffer. | 36 // it is done with the buffer. |
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
388 for (int i = 0; i < arraysize(kDecodingDlls); ++i) { | 389 for (int i = 0; i < arraysize(kDecodingDlls); ++i) { |
389 if (!::LoadLibrary(kDecodingDlls[i])) { | 390 if (!::LoadLibrary(kDecodingDlls[i])) { |
390 DLOG(ERROR) << "Failed to load decoder dll: " << kDecodingDlls[i] | 391 DLOG(ERROR) << "Failed to load decoder dll: " << kDecodingDlls[i] |
391 << ", Error: " << ::GetLastError(); | 392 << ", Error: " << ::GetLastError(); |
392 return; | 393 return; |
393 } | 394 } |
394 } | 395 } |
395 | 396 |
396 RETURN_ON_FAILURE(CreateD3DDevManager(), | 397 RETURN_ON_FAILURE(CreateD3DDevManager(), |
397 "Failed to initialize D3D device and manager",); | 398 "Failed to initialize D3D device and manager",); |
| 399 |
| 400 if (base::win::GetVersion() == base::win::VERSION_WIN8) { |
| 401 // On Windows 8+ mf.dll forwards to mfcore.dll. It does not exist in |
| 402 // Windows 7. Loading mfcore.dll fails on Windows 8.1 in the |
| 403 // sandbox. |
| 404 if (!LoadLibrary(L"mfcore.dll")) { |
| 405 DLOG(ERROR) << "Failed to load mfcore.dll, Error: " << ::GetLastError(); |
| 406 return; |
| 407 } |
| 408 // MFStartup needs to be called once outside the sandbox. It fails on |
| 409 // Windows 8.1 with E_NOTIMPL if it is called the first time in the |
| 410 // sandbox. |
| 411 RETURN_ON_HR_FAILURE(MFStartup(MF_VERSION, MFSTARTUP_FULL), |
| 412 "MFStartup failed.",); |
| 413 } |
| 414 |
398 pre_sandbox_init_done_ = true; | 415 pre_sandbox_init_done_ = true; |
399 } | 416 } |
400 | 417 |
401 // static | 418 // static |
402 bool DXVAVideoDecodeAccelerator::CreateD3DDevManager() { | 419 bool DXVAVideoDecodeAccelerator::CreateD3DDevManager() { |
403 HRESULT hr = Direct3DCreate9Ex(D3D_SDK_VERSION, &d3d9_); | 420 HRESULT hr = Direct3DCreate9Ex(D3D_SDK_VERSION, &d3d9_); |
404 RETURN_ON_HR_FAILURE(hr, "Direct3DCreate9Ex failed", false); | 421 RETURN_ON_HR_FAILURE(hr, "Direct3DCreate9Ex failed", false); |
405 | 422 |
406 D3DPRESENT_PARAMETERS present_params = {0}; | 423 D3DPRESENT_PARAMETERS present_params = {0}; |
407 present_params.BackBufferWidth = 1; | 424 present_params.BackBufferWidth = 1; |
(...skipping 757 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1165 | 1182 |
1166 for (index = picture_buffers.begin(); | 1183 for (index = picture_buffers.begin(); |
1167 index != picture_buffers.end(); | 1184 index != picture_buffers.end(); |
1168 ++index) { | 1185 ++index) { |
1169 DVLOG(1) << "Dismissing picture id: " << index->second->id(); | 1186 DVLOG(1) << "Dismissing picture id: " << index->second->id(); |
1170 client_->DismissPictureBuffer(index->second->id()); | 1187 client_->DismissPictureBuffer(index->second->id()); |
1171 } | 1188 } |
1172 } | 1189 } |
1173 | 1190 |
1174 } // namespace content | 1191 } // namespace content |
OLD | NEW |