| 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_win.h" | 5 #include "content/common/gpu/media/dxva_video_decode_accelerator_win.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 <codecapi.h> | 11 #include <codecapi.h> |
| 12 #include <dxgi1_2.h> | 12 #include <dxgi1_2.h> |
| 13 #include <ks.h> | 13 #include <ks.h> |
| 14 #include <mfapi.h> | 14 #include <mfapi.h> |
| 15 #include <mferror.h> | 15 #include <mferror.h> |
| 16 #include <ntverp.h> | 16 #include <ntverp.h> |
| 17 #include <stddef.h> | 17 #include <stddef.h> |
| 18 #include <string.h> | 18 #include <string.h> |
| 19 #include <wmcodecdsp.h> | 19 #include <wmcodecdsp.h> |
| 20 | 20 |
| 21 #include "base/base_paths_win.h" | 21 #include "base/base_paths_win.h" |
| 22 #include "base/bind.h" | 22 #include "base/bind.h" |
| 23 #include "base/callback.h" | 23 #include "base/callback.h" |
| 24 #include "base/command_line.h" | |
| 25 #include "base/debug/alias.h" | 24 #include "base/debug/alias.h" |
| 26 #include "base/file_version_info.h" | 25 #include "base/file_version_info.h" |
| 27 #include "base/files/file_path.h" | 26 #include "base/files/file_path.h" |
| 28 #include "base/logging.h" | 27 #include "base/logging.h" |
| 29 #include "base/macros.h" | 28 #include "base/macros.h" |
| 30 #include "base/memory/scoped_ptr.h" | 29 #include "base/memory/scoped_ptr.h" |
| 31 #include "base/memory/shared_memory.h" | 30 #include "base/memory/shared_memory.h" |
| 32 #include "base/message_loop/message_loop.h" | 31 #include "base/message_loop/message_loop.h" |
| 33 #include "base/path_service.h" | 32 #include "base/path_service.h" |
| 34 #include "base/trace_event/trace_event.h" | 33 #include "base/trace_event/trace_event.h" |
| 35 #include "base/win/windows_version.h" | 34 #include "base/win/windows_version.h" |
| 36 #include "build/build_config.h" | 35 #include "build/build_config.h" |
| 37 #include "content/public/common/content_switches.h" | |
| 38 #include "media/base/win/mf_initializer.h" | 36 #include "media/base/win/mf_initializer.h" |
| 39 #include "media/video/video_decode_accelerator.h" | 37 #include "media/video/video_decode_accelerator.h" |
| 40 #include "third_party/angle/include/EGL/egl.h" | 38 #include "third_party/angle/include/EGL/egl.h" |
| 41 #include "third_party/angle/include/EGL/eglext.h" | 39 #include "third_party/angle/include/EGL/eglext.h" |
| 42 #include "ui/gl/gl_bindings.h" | 40 #include "ui/gl/gl_bindings.h" |
| 43 #include "ui/gl/gl_context.h" | 41 #include "ui/gl/gl_context.h" |
| 44 #include "ui/gl/gl_fence.h" | 42 #include "ui/gl/gl_fence.h" |
| 45 #include "ui/gl/gl_surface_egl.h" | 43 #include "ui/gl/gl_surface_egl.h" |
| 46 #include "ui/gl/gl_switches.h" | |
| 47 | 44 |
| 48 namespace { | 45 namespace { |
| 49 | 46 |
| 50 // Path is appended on to the PROGRAM_FILES base path. | 47 // Path is appended on to the PROGRAM_FILES base path. |
| 51 const wchar_t kVPXDecoderDLLPath[] = L"Intel\\Media SDK\\"; | 48 const wchar_t kVPXDecoderDLLPath[] = L"Intel\\Media SDK\\"; |
| 52 | 49 |
| 53 const wchar_t kVP8DecoderDLLName[] = | 50 const wchar_t kVP8DecoderDLLName[] = |
| 54 #if defined(ARCH_CPU_X86) | 51 #if defined(ARCH_CPU_X86) |
| 55 L"mfx_mft_vp8vd_32.dll"; | 52 L"mfx_mft_vp8vd_32.dll"; |
| 56 #elif defined(ARCH_CPU_X86_64) | 53 #elif defined(ARCH_CPU_X86_64) |
| (...skipping 612 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 669 int32_t buffer_id, | 666 int32_t buffer_id, |
| 670 IMFSample* sample) | 667 IMFSample* sample) |
| 671 : input_buffer_id(buffer_id), picture_buffer_id(-1) { | 668 : input_buffer_id(buffer_id), picture_buffer_id(-1) { |
| 672 output_sample.Attach(sample); | 669 output_sample.Attach(sample); |
| 673 } | 670 } |
| 674 | 671 |
| 675 DXVAVideoDecodeAccelerator::PendingSampleInfo::~PendingSampleInfo() {} | 672 DXVAVideoDecodeAccelerator::PendingSampleInfo::~PendingSampleInfo() {} |
| 676 | 673 |
| 677 DXVAVideoDecodeAccelerator::DXVAVideoDecodeAccelerator( | 674 DXVAVideoDecodeAccelerator::DXVAVideoDecodeAccelerator( |
| 678 const base::Callback<bool(void)>& make_context_current, | 675 const base::Callback<bool(void)>& make_context_current, |
| 679 gfx::GLContext* gl_context) | 676 gfx::GLContext* gl_context, |
| 677 bool enable_accelerated_vpx_decode) |
| 680 : client_(NULL), | 678 : client_(NULL), |
| 681 dev_manager_reset_token_(0), | 679 dev_manager_reset_token_(0), |
| 682 dx11_dev_manager_reset_token_(0), | 680 dx11_dev_manager_reset_token_(0), |
| 683 egl_config_(NULL), | 681 egl_config_(NULL), |
| 684 state_(kUninitialized), | 682 state_(kUninitialized), |
| 685 pictures_requested_(false), | 683 pictures_requested_(false), |
| 686 inputs_before_decode_(0), | 684 inputs_before_decode_(0), |
| 687 sent_drain_message_(false), | 685 sent_drain_message_(false), |
| 688 make_context_current_(make_context_current), | 686 make_context_current_(make_context_current), |
| 689 codec_(media::kUnknownVideoCodec), | 687 codec_(media::kUnknownVideoCodec), |
| 690 decoder_thread_("DXVAVideoDecoderThread"), | 688 decoder_thread_("DXVAVideoDecoderThread"), |
| 691 pending_flush_(false), | 689 pending_flush_(false), |
| 692 use_dx11_(false), | 690 use_dx11_(false), |
| 693 use_keyed_mutex_(false), | 691 use_keyed_mutex_(false), |
| 694 dx11_video_format_converter_media_type_needs_init_(true), | 692 dx11_video_format_converter_media_type_needs_init_(true), |
| 695 gl_context_(gl_context), | 693 gl_context_(gl_context), |
| 696 using_angle_device_(false), | 694 using_angle_device_(false), |
| 695 enable_accelerated_vpx_decode_(enable_accelerated_vpx_decode), |
| 697 weak_this_factory_(this) { | 696 weak_this_factory_(this) { |
| 698 weak_ptr_ = weak_this_factory_.GetWeakPtr(); | 697 weak_ptr_ = weak_this_factory_.GetWeakPtr(); |
| 699 memset(&input_stream_info_, 0, sizeof(input_stream_info_)); | 698 memset(&input_stream_info_, 0, sizeof(input_stream_info_)); |
| 700 memset(&output_stream_info_, 0, sizeof(output_stream_info_)); | 699 memset(&output_stream_info_, 0, sizeof(output_stream_info_)); |
| 701 } | 700 } |
| 702 | 701 |
| 703 DXVAVideoDecodeAccelerator::~DXVAVideoDecodeAccelerator() { | 702 DXVAVideoDecodeAccelerator::~DXVAVideoDecodeAccelerator() { |
| 704 client_ = NULL; | 703 client_ = NULL; |
| 705 } | 704 } |
| 706 | 705 |
| (...skipping 541 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1248 FileVersionInfo::CreateFileVersionInfoForModule(decoder_dll)); | 1247 FileVersionInfo::CreateFileVersionInfoForModule(decoder_dll)); |
| 1249 RETURN_ON_FAILURE(version_info, | 1248 RETURN_ON_FAILURE(version_info, |
| 1250 "unable to get version of msmpeg2vdec.dll", | 1249 "unable to get version of msmpeg2vdec.dll", |
| 1251 false); | 1250 false); |
| 1252 base::string16 file_version = version_info->file_version(); | 1251 base::string16 file_version = version_info->file_version(); |
| 1253 RETURN_ON_FAILURE(file_version.find(L"6.1.7140") == base::string16::npos, | 1252 RETURN_ON_FAILURE(file_version.find(L"6.1.7140") == base::string16::npos, |
| 1254 "blacklisted version of msmpeg2vdec.dll 6.1.7140", | 1253 "blacklisted version of msmpeg2vdec.dll 6.1.7140", |
| 1255 false); | 1254 false); |
| 1256 codec_ = media::kCodecH264; | 1255 codec_ = media::kCodecH264; |
| 1257 clsid = __uuidof(CMSH264DecoderMFT); | 1256 clsid = __uuidof(CMSH264DecoderMFT); |
| 1258 } else if ((profile == media::VP8PROFILE_ANY || | 1257 } else if (enable_accelerated_vpx_decode_ && |
| 1259 profile == media::VP9PROFILE_ANY) && | 1258 (profile == media::VP8PROFILE_ANY || |
| 1260 base::CommandLine::ForCurrentProcess()->HasSwitch( | 1259 profile == media::VP9PROFILE_ANY)) { |
| 1261 switches::kEnableAcceleratedVpxDecode)) { | |
| 1262 int program_files_key = base::DIR_PROGRAM_FILES; | 1260 int program_files_key = base::DIR_PROGRAM_FILES; |
| 1263 if (base::win::OSInfo::GetInstance()->wow64_status() == | 1261 if (base::win::OSInfo::GetInstance()->wow64_status() == |
| 1264 base::win::OSInfo::WOW64_ENABLED) { | 1262 base::win::OSInfo::WOW64_ENABLED) { |
| 1265 program_files_key = base::DIR_PROGRAM_FILES6432; | 1263 program_files_key = base::DIR_PROGRAM_FILES6432; |
| 1266 } | 1264 } |
| 1267 | 1265 |
| 1268 base::FilePath dll_path; | 1266 base::FilePath dll_path; |
| 1269 RETURN_ON_FAILURE(PathService::Get(program_files_key, &dll_path), | 1267 RETURN_ON_FAILURE(PathService::Get(program_files_key, &dll_path), |
| 1270 "failed to get path for Program Files", false); | 1268 "failed to get path for Program Files", false); |
| 1271 | 1269 |
| (...skipping 1178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2450 hr = transform->SetOutputType(0, media_type.get(), 0); // No flags | 2448 hr = transform->SetOutputType(0, media_type.get(), 0); // No flags |
| 2451 RETURN_ON_HR_FAILURE(hr, "Failed to set output type", false); | 2449 RETURN_ON_HR_FAILURE(hr, "Failed to set output type", false); |
| 2452 return true; | 2450 return true; |
| 2453 } | 2451 } |
| 2454 media_type.Release(); | 2452 media_type.Release(); |
| 2455 } | 2453 } |
| 2456 return false; | 2454 return false; |
| 2457 } | 2455 } |
| 2458 | 2456 |
| 2459 } // namespace content | 2457 } // namespace content |
| OLD | NEW |