Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(15)

Side by Side Diff: content/common/gpu/media/dxva_video_decode_accelerator.cc

Issue 795633005: Add VDA supported profile to GPUInfo. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix compile error Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 // Data type: UINT32 (treat as BOOL) 96 // Data type: UINT32 (treat as BOOL)
97 // If this attribute is TRUE, the video processor will run in playback mode 97 // If this attribute is TRUE, the video processor will run in playback mode
98 // where it allows callers to allocate output samples and allows last frame 98 // where it allows callers to allocate output samples and allows last frame
99 // regeneration (repaint). 99 // regeneration (repaint).
100 DEFINE_GUID(MF_XVP_PLAYBACK_MODE, 0x3c5d293f, 0xad67, 0x4e29, 0xaf, 0x12, 100 DEFINE_GUID(MF_XVP_PLAYBACK_MODE, 0x3c5d293f, 0xad67, 0x4e29, 0xaf, 0x12,
101 0xcf, 0x3e, 0x23, 0x8a, 0xcc, 0xe9); 101 0xcf, 0x3e, 0x23, 0x8a, 0xcc, 0xe9);
102 } 102 }
103 103
104 namespace content { 104 namespace content {
105 105
106 static const media::VideoCodecProfile kSupportedProfiles[] = {
107 media::H264PROFILE_BASELINE,
108 media::H264PROFILE_MAIN,
109 media::H264PROFILE_HIGH,
110 media::VP8PROFILE_ANY,
111 media::VP9PROFILE_ANY
112 };
113
106 CreateDXGIDeviceManager DXVAVideoDecodeAccelerator::create_dxgi_device_manager_ 114 CreateDXGIDeviceManager DXVAVideoDecodeAccelerator::create_dxgi_device_manager_
107 = NULL; 115 = NULL;
108 116
109 #define RETURN_ON_FAILURE(result, log, ret) \ 117 #define RETURN_ON_FAILURE(result, log, ret) \
110 do { \ 118 do { \
111 if (!(result)) { \ 119 if (!(result)) { \
112 DLOG(ERROR) << log; \ 120 DLOG(ERROR) << log; \
113 return ret; \ 121 return ret; \
114 } \ 122 } \
115 } while (0) 123 } while (0)
(...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after
527 DXVAVideoDecodeAccelerator::~DXVAVideoDecodeAccelerator() { 535 DXVAVideoDecodeAccelerator::~DXVAVideoDecodeAccelerator() {
528 client_ = NULL; 536 client_ = NULL;
529 } 537 }
530 538
531 bool DXVAVideoDecodeAccelerator::Initialize(media::VideoCodecProfile profile, 539 bool DXVAVideoDecodeAccelerator::Initialize(media::VideoCodecProfile profile,
532 Client* client) { 540 Client* client) {
533 client_ = client; 541 client_ = client;
534 542
535 main_thread_task_runner_ = base::MessageLoop::current()->task_runner(); 543 main_thread_task_runner_ = base::MessageLoop::current()->task_runner();
536 544
537 if (profile != media::H264PROFILE_BASELINE && 545 bool profile_supported = false;
538 profile != media::H264PROFILE_MAIN && 546 for (const auto& supported_profile : kSupportedProfiles) {
539 profile != media::H264PROFILE_HIGH && 547 if (profile == supported_profile) {
540 profile != media::VP8PROFILE_ANY && 548 profile_supported = true;
541 profile != media::VP9PROFILE_ANY) { 549 break;
550 }
551 }
552 if (!profile_supported) {
542 RETURN_AND_NOTIFY_ON_FAILURE(false, 553 RETURN_AND_NOTIFY_ON_FAILURE(false,
543 "Unsupported h.264, vp8, or vp9 profile", PLATFORM_FAILURE, false); 554 "Unsupported h.264, vp8, or vp9 profile", PLATFORM_FAILURE, false);
544 } 555 }
545 556
546 // Not all versions of Windows 7 and later include Media Foundation DLLs. 557 // Not all versions of Windows 7 and later include Media Foundation DLLs.
547 // Instead of crashing while delay loading the DLL when calling MFStartup() 558 // Instead of crashing while delay loading the DLL when calling MFStartup()
548 // below, probe whether we can successfully load the DLL now. 559 // below, probe whether we can successfully load the DLL now.
549 // See http://crbug.com/339678 for details. 560 // See http://crbug.com/339678 for details.
550 HMODULE dxgi_manager_dll = NULL; 561 HMODULE dxgi_manager_dll = NULL;
551 if ((dxgi_manager_dll = ::GetModuleHandle(L"MFPlat.dll")) == NULL) { 562 if ((dxgi_manager_dll = ::GetModuleHandle(L"MFPlat.dll")) == NULL) {
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after
904 } 915 }
905 916
906 bool DXVAVideoDecodeAccelerator::CanDecodeOnIOThread() { 917 bool DXVAVideoDecodeAccelerator::CanDecodeOnIOThread() {
907 return false; 918 return false;
908 } 919 }
909 920
910 GLenum DXVAVideoDecodeAccelerator::GetSurfaceInternalFormat() const { 921 GLenum DXVAVideoDecodeAccelerator::GetSurfaceInternalFormat() const {
911 return GL_BGRA_EXT; 922 return GL_BGRA_EXT;
912 } 923 }
913 924
925 // static
926 media::VideoDecodeAccelerator::SupportedProfiles
927 DXVAVideoDecodeAccelerator::GetSupportedProfiles() {
928 // TODO(henryhsu): Need to ensure the profiles are actually supported.
929 SupportedProfiles profiles;
930 for (const auto& supported_profile : kSupportedProfiles) {
931 SupportedProfile profile;
932 profile.profile = supported_profile;
933 // Windows Media Foundation H.264 decoding does not support decoding videos
934 // with any dimension smaller than 48 pixels:
935 // http://msdn.microsoft.com/en-us/library/windows/desktop/dd797815
936 profile.min_resolution.SetSize(48, 48);
937 // Use 1088 to account for 16x16 macroblocks.
938 profile.max_resolution.SetSize(1920, 1088);
939 profiles.push_back(profile);
940 }
941 return profiles;
942 }
943
914 bool DXVAVideoDecodeAccelerator::InitDecoder(media::VideoCodecProfile profile) { 944 bool DXVAVideoDecodeAccelerator::InitDecoder(media::VideoCodecProfile profile) {
915 HMODULE decoder_dll = NULL; 945 HMODULE decoder_dll = NULL;
916 946
917 // Profile must fall within the valid range for one of the supported codecs. 947 // Profile must fall within the valid range for one of the supported codecs.
918 if (profile >= media::H264PROFILE_MIN && profile <= media::H264PROFILE_MAX) { 948 if (profile >= media::H264PROFILE_MIN && profile <= media::H264PROFILE_MAX) {
919 // We mimic the steps CoCreateInstance uses to instantiate the object. This 949 // We mimic the steps CoCreateInstance uses to instantiate the object. This
920 // was previously done because it failed inside the sandbox, and now is done 950 // was previously done because it failed inside the sandbox, and now is done
921 // as a more minimal approach to avoid other side-effects CCI might have (as 951 // as a more minimal approach to avoid other side-effects CCI might have (as
922 // we are still in a reduced sandbox). 952 // we are still in a reduced sandbox).
923 decoder_dll = ::LoadLibrary(L"msmpeg2vdec.dll"); 953 decoder_dll = ::LoadLibrary(L"msmpeg2vdec.dll");
(...skipping 1235 matching lines...) Expand 10 before | Expand all | Expand 10 after
2159 D3DSURFACE_DESC surface_desc; 2189 D3DSURFACE_DESC surface_desc;
2160 hr = surface->GetDesc(&surface_desc); 2190 hr = surface->GetDesc(&surface_desc);
2161 RETURN_ON_HR_FAILURE(hr, "Failed to get surface description", false); 2191 RETURN_ON_HR_FAILURE(hr, "Failed to get surface description", false);
2162 *width = surface_desc.Width; 2192 *width = surface_desc.Width;
2163 *height = surface_desc.Height; 2193 *height = surface_desc.Height;
2164 } 2194 }
2165 return true; 2195 return true;
2166 } 2196 }
2167 2197
2168 } // namespace content 2198 } // namespace content
OLDNEW
« no previous file with comments | « content/common/gpu/media/dxva_video_decode_accelerator.h ('k') | content/common/gpu/media/gpu_video_accelerator_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698