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 17 matching lines...) Expand all Loading... |
28 #include "base/files/file_path.h" | 28 #include "base/files/file_path.h" |
29 #include "base/location.h" | 29 #include "base/location.h" |
30 #include "base/logging.h" | 30 #include "base/logging.h" |
31 #include "base/macros.h" | 31 #include "base/macros.h" |
32 #include "base/memory/shared_memory.h" | 32 #include "base/memory/shared_memory.h" |
33 #include "base/path_service.h" | 33 #include "base/path_service.h" |
34 #include "base/single_thread_task_runner.h" | 34 #include "base/single_thread_task_runner.h" |
35 #include "base/stl_util.h" | 35 #include "base/stl_util.h" |
36 #include "base/threading/thread_task_runner_handle.h" | 36 #include "base/threading/thread_task_runner_handle.h" |
37 #include "base/trace_event/trace_event.h" | 37 #include "base/trace_event/trace_event.h" |
| 38 #include "base/win/scoped_co_mem.h" |
38 #include "base/win/windows_version.h" | 39 #include "base/win/windows_version.h" |
39 #include "build/build_config.h" | 40 #include "build/build_config.h" |
40 #include "gpu/command_buffer/service/gpu_preferences.h" | 41 #include "gpu/command_buffer/service/gpu_preferences.h" |
41 #include "gpu/config/gpu_driver_bug_workarounds.h" | 42 #include "gpu/config/gpu_driver_bug_workarounds.h" |
42 #include "media/base/win/mf_helpers.h" | 43 #include "media/base/win/mf_helpers.h" |
43 #include "media/base/win/mf_initializer.h" | 44 #include "media/base/win/mf_initializer.h" |
44 #include "media/gpu/dxva_picture_buffer_win.h" | 45 #include "media/gpu/dxva_picture_buffer_win.h" |
45 #include "media/video/video_decode_accelerator.h" | 46 #include "media/video/video_decode_accelerator.h" |
46 #include "third_party/angle/include/EGL/egl.h" | 47 #include "third_party/angle/include/EGL/egl.h" |
47 #include "third_party/angle/include/EGL/eglext.h" | 48 #include "third_party/angle/include/EGL/eglext.h" |
(...skipping 526 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
574 | 575 |
575 // On Windows 8+ mfplat.dll provides the MFCreateDXGIDeviceManager API. | 576 // On Windows 8+ mfplat.dll provides the MFCreateDXGIDeviceManager API. |
576 // On Windows 7 mshtmlmedia.dll provides it. | 577 // On Windows 7 mshtmlmedia.dll provides it. |
577 | 578 |
578 // TODO(ananta) | 579 // TODO(ananta) |
579 // The code below works, as in we can create the DX11 device manager for | 580 // The code below works, as in we can create the DX11 device manager for |
580 // Windows 7. However the IMFTransform we use for texture conversion and | 581 // Windows 7. However the IMFTransform we use for texture conversion and |
581 // copy does not exist on Windows 7. Look into an alternate approach | 582 // copy does not exist on Windows 7. Look into an alternate approach |
582 // and enable the code below. | 583 // and enable the code below. |
583 #if defined(ENABLE_DX11_FOR_WIN7) | 584 #if defined(ENABLE_DX11_FOR_WIN7) |
| 585 LOG(ERROR) << "DO THIS!"; |
584 if (base::win::GetVersion() == base::win::VERSION_WIN7) { | 586 if (base::win::GetVersion() == base::win::VERSION_WIN7) { |
585 dxgi_manager_dll = ::GetModuleHandle(L"mshtmlmedia.dll"); | 587 dxgi_manager_dll = ::GetModuleHandle(L"mshtmlmedia.dll"); |
586 RETURN_ON_FAILURE(dxgi_manager_dll, | 588 RETURN_ON_FAILURE(dxgi_manager_dll, |
587 "mshtmlmedia.dll is required for decoding", false); | 589 "mshtmlmedia.dll is required for decoding", false); |
588 } | 590 } |
589 #endif | 591 #endif |
590 // If we don't find the MFCreateDXGIDeviceManager API we fallback to D3D9 | 592 // If we don't find the MFCreateDXGIDeviceManager API we fallback to D3D9 |
591 // decoding. | 593 // decoding. |
592 if (dxgi_manager_dll && !create_dxgi_device_manager_) { | 594 if (dxgi_manager_dll && !create_dxgi_device_manager_) { |
| 595 LOG(ERROR) << "DX9 DECODING"; |
593 create_dxgi_device_manager_ = reinterpret_cast<CreateDXGIDeviceManager>( | 596 create_dxgi_device_manager_ = reinterpret_cast<CreateDXGIDeviceManager>( |
594 ::GetProcAddress(dxgi_manager_dll, "MFCreateDXGIDeviceManager")); | 597 ::GetProcAddress(dxgi_manager_dll, "MFCreateDXGIDeviceManager")); |
595 } | 598 } |
596 | 599 |
597 RETURN_AND_NOTIFY_ON_FAILURE( | 600 RETURN_AND_NOTIFY_ON_FAILURE( |
598 gl::g_driver_egl.ext.b_EGL_ANGLE_surface_d3d_texture_2d_share_handle, | 601 gl::g_driver_egl.ext.b_EGL_ANGLE_surface_d3d_texture_2d_share_handle, |
599 "EGL_ANGLE_surface_d3d_texture_2d_share_handle unavailable", | 602 "EGL_ANGLE_surface_d3d_texture_2d_share_handle unavailable", |
600 PLATFORM_FAILURE, false); | 603 PLATFORM_FAILURE, false); |
601 | 604 |
602 RETURN_AND_NOTIFY_ON_FAILURE(gl::GLFence::IsSupported(), | 605 RETURN_AND_NOTIFY_ON_FAILURE(gl::GLFence::IsSupported(), |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
693 hr = device_manager_->ResetDevice(d3d9_device_ex_.get(), | 696 hr = device_manager_->ResetDevice(d3d9_device_ex_.get(), |
694 dev_manager_reset_token_); | 697 dev_manager_reset_token_); |
695 RETURN_ON_HR_FAILURE(hr, "Failed to reset device", false); | 698 RETURN_ON_HR_FAILURE(hr, "Failed to reset device", false); |
696 | 699 |
697 hr = d3d9_device_ex_->CreateQuery(D3DQUERYTYPE_EVENT, query_.Receive()); | 700 hr = d3d9_device_ex_->CreateQuery(D3DQUERYTYPE_EVENT, query_.Receive()); |
698 RETURN_ON_HR_FAILURE(hr, "Failed to create D3D device query", false); | 701 RETURN_ON_HR_FAILURE(hr, "Failed to create D3D device query", false); |
699 // Ensure query_ API works (to avoid an infinite loop later in | 702 // Ensure query_ API works (to avoid an infinite loop later in |
700 // CopyOutputSampleDataToPictureBuffer). | 703 // CopyOutputSampleDataToPictureBuffer). |
701 hr = query_->Issue(D3DISSUE_END); | 704 hr = query_->Issue(D3DISSUE_END); |
702 RETURN_ON_HR_FAILURE(hr, "Failed to issue END test query", false); | 705 RETURN_ON_HR_FAILURE(hr, "Failed to issue END test query", false); |
| 706 |
| 707 CreateVideoProcessor(); |
703 return true; | 708 return true; |
704 } | 709 } |
705 | 710 |
| 711 bool DXVAVideoDecodeAccelerator::CreateVideoProcessor() { |
| 712 // TODO(Hubbe): Don't try again if we failed tried and failed already. |
| 713 if (video_processor_service_.get()) |
| 714 return true; |
| 715 HRESULT hr = DXVA2CreateVideoService(d3d9_device_ex_.get(), |
| 716 IID_IDirectXVideoProcessorService, |
| 717 video_processor_service_.ReceiveVoid()); |
| 718 RETURN_ON_HR_FAILURE(hr, "DXVA2CreateVideoService failed", false); |
| 719 |
| 720 // TODO(Hubbe): Use actual video settings. |
| 721 DXVA2_VideoDesc inputDesc; |
| 722 inputDesc.SampleWidth = 1920; |
| 723 inputDesc.SampleHeight = 1080; |
| 724 inputDesc.SampleFormat.VideoChromaSubsampling = |
| 725 DXVA2_VideoChromaSubsampling_MPEG2; |
| 726 inputDesc.SampleFormat.NominalRange = DXVA2_NominalRange_16_235; |
| 727 inputDesc.SampleFormat.VideoTransferMatrix = DXVA2_VideoTransferMatrix_BT709; |
| 728 inputDesc.SampleFormat.VideoLighting = DXVA2_VideoLighting_dim; |
| 729 inputDesc.SampleFormat.VideoPrimaries = DXVA2_VideoPrimaries_BT709; |
| 730 inputDesc.SampleFormat.VideoTransferFunction = DXVA2_VideoTransFunc_709; |
| 731 inputDesc.SampleFormat.SampleFormat = DXVA2_SampleProgressiveFrame; |
| 732 inputDesc.Format = (D3DFORMAT)MAKEFOURCC('N', 'V', '1', '2'); |
| 733 inputDesc.InputSampleFreq.Numerator = 30; |
| 734 inputDesc.InputSampleFreq.Denominator = 1; |
| 735 inputDesc.OutputFrameFreq.Numerator = 30; |
| 736 inputDesc.OutputFrameFreq.Denominator = 1; |
| 737 |
| 738 UINT guid_count = 0; |
| 739 base::win::ScopedCoMem<GUID> guids; |
| 740 hr = video_processor_service_->GetVideoProcessorDeviceGuids( |
| 741 &inputDesc, &guid_count, &guids); |
| 742 RETURN_ON_HR_FAILURE(hr, "GetVideoProcessorDeviceGuids failed", false); |
| 743 |
| 744 for (UINT g = 0; g < guid_count; g++) { |
| 745 DXVA2_VideoProcessorCaps caps; |
| 746 hr = video_processor_service_->GetVideoProcessorCaps( |
| 747 guids[g], &inputDesc, D3DFMT_X8R8G8B8, &caps); |
| 748 if (hr) |
| 749 continue; |
| 750 |
| 751 if (!(caps.VideoProcessorOperations & DXVA2_VideoProcess_YUV2RGB)) |
| 752 continue; |
| 753 |
| 754 // if (!(caps.VideoProcessorOperations & |
| 755 // DXVA2_VideoProcess_YUV2RGBExtended)) |
| 756 // continue; |
| 757 |
| 758 base::win::ScopedCoMem<D3DFORMAT> formats; |
| 759 UINT format_count = 0; |
| 760 hr = video_processor_service_->GetVideoProcessorRenderTargets( |
| 761 guids[g], &inputDesc, &format_count, &formats); |
| 762 if (hr) |
| 763 continue; |
| 764 |
| 765 UINT f; |
| 766 for (f = 0; f < format_count; f++) { |
| 767 if (formats[f] == D3DFMT_X8R8G8B8) { |
| 768 break; |
| 769 } |
| 770 } |
| 771 if (f == format_count) |
| 772 continue; |
| 773 |
| 774 // Create video processor |
| 775 hr = video_processor_service_->CreateVideoProcessor( |
| 776 guids[g], &inputDesc, D3DFMT_X8R8G8B8, 0, processor_.Receive()); |
| 777 if (hr) |
| 778 continue; |
| 779 |
| 780 DXVA2_ValueRange range; |
| 781 processor_->GetProcAmpRange(DXVA2_ProcAmp_Brightness, &range); |
| 782 default_procamp_values_.Brightness = range.DefaultValue; |
| 783 processor_->GetProcAmpRange(DXVA2_ProcAmp_Contrast, &range); |
| 784 default_procamp_values_.Contrast = range.DefaultValue; |
| 785 processor_->GetProcAmpRange(DXVA2_ProcAmp_Hue, &range); |
| 786 default_procamp_values_.Hue = range.DefaultValue; |
| 787 processor_->GetProcAmpRange(DXVA2_ProcAmp_Saturation, &range); |
| 788 default_procamp_values_.Saturation = range.DefaultValue; |
| 789 |
| 790 return true; |
| 791 } |
| 792 return false; |
| 793 } |
| 794 |
706 bool DXVAVideoDecodeAccelerator::CreateDX11DevManager() { | 795 bool DXVAVideoDecodeAccelerator::CreateDX11DevManager() { |
707 // The device may exist if the last state was a config change. | 796 // The device may exist if the last state was a config change. |
708 if (d3d11_device_.get()) | 797 if (d3d11_device_.get()) |
709 return true; | 798 return true; |
710 HRESULT hr = create_dxgi_device_manager_(&dx11_dev_manager_reset_token_, | 799 HRESULT hr = create_dxgi_device_manager_(&dx11_dev_manager_reset_token_, |
711 d3d11_device_manager_.Receive()); | 800 d3d11_device_manager_.Receive()); |
712 RETURN_ON_HR_FAILURE(hr, "MFCreateDXGIDeviceManager failed", false); | 801 RETURN_ON_HR_FAILURE(hr, "MFCreateDXGIDeviceManager failed", false); |
713 | 802 |
714 angle_device_ = | 803 angle_device_ = |
715 QueryDeviceObjectFromANGLE<ID3D11Device>(EGL_D3D11_DEVICE_ANGLE); | 804 QueryDeviceObjectFromANGLE<ID3D11Device>(EGL_D3D11_DEVICE_ANGLE); |
(...skipping 1042 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1758 HandleResolutionChanged(width, height); | 1847 HandleResolutionChanged(width, height); |
1759 return; | 1848 return; |
1760 } | 1849 } |
1761 | 1850 |
1762 pending_sample->picture_buffer_id = index->second->id(); | 1851 pending_sample->picture_buffer_id = index->second->id(); |
1763 index->second->set_bound(); | 1852 index->second->set_bound(); |
1764 | 1853 |
1765 // We only propagate the input color space if we can give the raw YUV data | 1854 // We only propagate the input color space if we can give the raw YUV data |
1766 // back to the browser process. When we cannot return the YUV data, we | 1855 // back to the browser process. When we cannot return the YUV data, we |
1767 // have to do a copy to an RGBA texture, which makes proper color | 1856 // have to do a copy to an RGBA texture, which makes proper color |
1768 // management difficult as some fidelity is lost. Also, we currently let | 1857 // management difficult as some fidelity is lost. Also, for dx11 we |
1769 // the drivers decide how to actually do the YUV to RGB conversion, which | 1858 // currently let the drivers decide how to actually do the YUV to RGB |
1770 // means that even if we wanted to try to color-adjust the RGB output, we | 1859 // conversion, which means that even if we wanted to try to color-adjust |
1771 // don't actually know exactly what color space it is in anymore. | 1860 // the RGB output, we don't actually know exactly what color space it is |
| 1861 // in anymore. |
1772 // TODO(hubbe): Figure out a way to always return the raw YUV data. | 1862 // TODO(hubbe): Figure out a way to always return the raw YUV data. |
1773 if (share_nv12_textures_ || copy_nv12_textures_) { | 1863 if (share_nv12_textures_ || copy_nv12_textures_ || !use_dx11_) { |
1774 index->second->set_color_space(pending_sample->color_space); | 1864 index->second->set_color_space(pending_sample->color_space); |
1775 } | 1865 } |
1776 | 1866 |
1777 if (share_nv12_textures_) { | 1867 if (share_nv12_textures_) { |
1778 main_thread_task_runner_->PostTask( | 1868 main_thread_task_runner_->PostTask( |
1779 FROM_HERE, | 1869 FROM_HERE, |
1780 base::Bind(&DXVAVideoDecodeAccelerator::BindPictureBufferToSample, | 1870 base::Bind(&DXVAVideoDecodeAccelerator::BindPictureBufferToSample, |
1781 weak_ptr_, pending_sample->output_sample, | 1871 weak_ptr_, pending_sample->output_sample, |
1782 pending_sample->picture_buffer_id, | 1872 pending_sample->picture_buffer_id, |
1783 pending_sample->input_buffer_id)); | 1873 pending_sample->input_buffer_id)); |
(...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2216 decoder_thread_.init_com_with_mta(false); | 2306 decoder_thread_.init_com_with_mta(false); |
2217 decoder_thread_.Start(); | 2307 decoder_thread_.Start(); |
2218 decoder_thread_task_runner_ = decoder_thread_.task_runner(); | 2308 decoder_thread_task_runner_ = decoder_thread_.task_runner(); |
2219 } | 2309 } |
2220 | 2310 |
2221 bool DXVAVideoDecodeAccelerator::OutputSamplesPresent() { | 2311 bool DXVAVideoDecodeAccelerator::OutputSamplesPresent() { |
2222 base::AutoLock lock(decoder_lock_); | 2312 base::AutoLock lock(decoder_lock_); |
2223 return !pending_output_samples_.empty(); | 2313 return !pending_output_samples_.empty(); |
2224 } | 2314 } |
2225 | 2315 |
2226 void DXVAVideoDecodeAccelerator::CopySurface(IDirect3DSurface9* src_surface, | 2316 void DXVAVideoDecodeAccelerator::CopySurface( |
2227 IDirect3DSurface9* dest_surface, | 2317 IDirect3DSurface9* src_surface, |
2228 int picture_buffer_id, | 2318 IDirect3DSurface9* dest_surface, |
2229 int input_buffer_id) { | 2319 int picture_buffer_id, |
| 2320 int input_buffer_id, |
| 2321 const gfx::ColorSpace& color_space) { |
2230 TRACE_EVENT0("media", "DXVAVideoDecodeAccelerator::CopySurface"); | 2322 TRACE_EVENT0("media", "DXVAVideoDecodeAccelerator::CopySurface"); |
2231 if (!decoder_thread_task_runner_->BelongsToCurrentThread()) { | 2323 if (!decoder_thread_task_runner_->BelongsToCurrentThread()) { |
2232 decoder_thread_task_runner_->PostTask( | 2324 decoder_thread_task_runner_->PostTask( |
2233 FROM_HERE, base::Bind(&DXVAVideoDecodeAccelerator::CopySurface, | 2325 FROM_HERE, base::Bind(&DXVAVideoDecodeAccelerator::CopySurface, |
2234 base::Unretained(this), src_surface, dest_surface, | 2326 base::Unretained(this), src_surface, dest_surface, |
2235 picture_buffer_id, input_buffer_id)); | 2327 picture_buffer_id, input_buffer_id, color_space)); |
2236 return; | 2328 return; |
2237 } | 2329 } |
2238 | 2330 |
2239 HRESULT hr = d3d9_device_ex_->StretchRect(src_surface, NULL, dest_surface, | 2331 HRESULT hr; |
2240 NULL, D3DTEXF_NONE); | 2332 if (processor_) { |
2241 RETURN_ON_HR_FAILURE(hr, "Colorspace conversion via StretchRect failed", ); | 2333 D3DSURFACE_DESC src_desc; |
| 2334 src_surface->GetDesc(&src_desc); |
| 2335 int width = src_desc.Width; |
| 2336 int height = src_desc.Height; |
| 2337 RECT rect = {0, 0, width, height}; |
| 2338 DXVA2_VideoSample sample = {0}; |
| 2339 sample.End = 1000; |
| 2340 sample.SampleFormat.SampleFormat = DXVA2_SampleProgressiveFrame; |
| 2341 switch (color_space.range_) { |
| 2342 case gfx::ColorSpace::RangeID::LIMITED: |
| 2343 sample.SampleFormat.NominalRange = DXVA2_NominalRange_16_235; |
| 2344 break; |
| 2345 case gfx::ColorSpace::RangeID::FULL: |
| 2346 sample.SampleFormat.NominalRange = DXVA2_NominalRange_0_255; |
| 2347 break; |
| 2348 } |
2242 | 2349 |
| 2350 switch (color_space.transfer_) { |
| 2351 case gfx::ColorSpace::MatrixID::BT709: |
| 2352 sample.SampleFormat.VideoTransferMatrix = |
| 2353 DXVA2_VideoTransferMatrix_BT709; |
| 2354 break; |
| 2355 case gfx::ColorSpace::MatrixID::BT470BG: |
| 2356 case gfx::ColorSpace::MatrixID::SMPTE170M: |
| 2357 sample.SampleFormat.VideoTransferMatrix = |
| 2358 DXVA2_VideoTransferMatrix_BT601; |
| 2359 break; |
| 2360 case gfx::ColorSpace::MatrixID::SMPTE240M: |
| 2361 sample.SampleFormat.VideoTransferMatrix = |
| 2362 DXVA2_VideoTransferMatrix_SMPTE240M; |
| 2363 break; |
| 2364 } |
| 2365 |
| 2366 switch (color_space.primaries_) { |
| 2367 case gfx::ColorSpace::PrimaryID::BT709: |
| 2368 sample.SampleFormat.VideoPrimaries = DXVA2_VideoPrimaries_BT709; |
| 2369 break; |
| 2370 case gfx::ColorSpace::PrimaryID::BT470M: |
| 2371 sample.SampleFormat.VideoPrimaries = DXVA2_VideoPrimaries_BT470_2_SysM; |
| 2372 break; |
| 2373 case gfx::ColorSpace::PrimaryID::BT470BG: |
| 2374 sample.SampleFormat.VideoPrimaries = DXVA2_VideoPrimaries_BT470_2_SysBG; |
| 2375 break; |
| 2376 case gfx::ColorSpace::PrimaryID::SMPTE170M: |
| 2377 sample.SampleFormat.VideoPrimaries = DXVA2_VideoPrimaries_SMPTE170M; |
| 2378 break; |
| 2379 case gfx::ColorSpace::PrimaryID::SMPTE240M: |
| 2380 sample.SampleFormat.VideoPrimaries = DXVA2_VideoPrimaries_SMPTE240M; |
| 2381 break; |
| 2382 } |
| 2383 |
| 2384 switch (color_space.transfer_) { |
| 2385 case gfx::ColorSpace::TransferID::BT709: |
| 2386 case gfx::ColorSpace::TransferID::SMPTE170M: |
| 2387 sample.SampleFormat.VideoTransferFunction = DXVA2_VideoTransFunc_709; |
| 2388 break; |
| 2389 case gfx::ColorSpace::TransferID::SMPTE240M: |
| 2390 sample.SampleFormat.VideoTransferFunction = DXVA2_VideoTransFunc_240M; |
| 2391 break; |
| 2392 case gfx::ColorSpace::TransferID::GAMMA22: |
| 2393 sample.SampleFormat.VideoTransferFunction = DXVA2_VideoTransFunc_22; |
| 2394 break; |
| 2395 case gfx::ColorSpace::TransferID::GAMMA28: |
| 2396 sample.SampleFormat.VideoTransferFunction = DXVA2_VideoTransFunc_28; |
| 2397 break; |
| 2398 case gfx::ColorSpace::TransferID::LINEAR: |
| 2399 sample.SampleFormat.VideoTransferFunction = DXVA2_VideoTransFunc_10; |
| 2400 break; |
| 2401 case gfx::ColorSpace::TransferID::IEC61966_2_1: |
| 2402 sample.SampleFormat.VideoTransferFunction = DXVA2_VideoTransFunc_sRGB; |
| 2403 break; |
| 2404 } |
| 2405 sample.SrcSurface = src_surface; |
| 2406 sample.SrcRect = rect; |
| 2407 sample.DstRect = rect; |
| 2408 sample.PlanarAlpha = DXVA2_Fixed32OpaqueAlpha(); |
| 2409 |
| 2410 DXVA2_VideoProcessBltParams params = {0}; |
| 2411 params.TargetFrame = 0; |
| 2412 params.TargetRect = rect; |
| 2413 params.ConstrictionSize = {width, height}; |
| 2414 params.BackgroundColor = {0, 0, 0, 0xFFFF}; |
| 2415 params.ProcAmpValues = default_procamp_values_; |
| 2416 |
| 2417 params.Alpha = DXVA2_Fixed32OpaqueAlpha(); |
| 2418 |
| 2419 hr = processor_->VideoProcessBlt(dest_surface, ¶ms, &sample, 1, NULL); |
| 2420 if (hr != S_OK) { |
| 2421 LOG(ERROR) << "VideoProcessBlt failed with code " << hr |
| 2422 << " E_INVALIDARG= " << E_INVALIDARG; |
| 2423 |
| 2424 // Release the processor and fall back to StretchRect() |
| 2425 processor_ = NULL; |
| 2426 } |
| 2427 } |
| 2428 |
| 2429 if (!processor_) { |
| 2430 hr = d3d9_device_ex_->StretchRect(src_surface, NULL, dest_surface, NULL, |
| 2431 D3DTEXF_NONE); |
| 2432 RETURN_ON_HR_FAILURE(hr, "Colorspace conversion via StretchRect failed", ); |
| 2433 } |
2243 // Ideally, this should be done immediately before the draw call that uses | 2434 // Ideally, this should be done immediately before the draw call that uses |
2244 // the texture. Flush it once here though. | 2435 // the texture. Flush it once here though. |
2245 hr = query_->Issue(D3DISSUE_END); | 2436 hr = query_->Issue(D3DISSUE_END); |
2246 RETURN_ON_HR_FAILURE(hr, "Failed to issue END", ); | 2437 RETURN_ON_HR_FAILURE(hr, "Failed to issue END", ); |
2247 | 2438 |
2248 // If we are sharing the ANGLE device we don't need to wait for the Flush to | 2439 // If we are sharing the ANGLE device we don't need to wait for the Flush to |
2249 // complete. | 2440 // complete. |
2250 if (using_angle_device_) { | 2441 if (using_angle_device_) { |
2251 main_thread_task_runner_->PostTask( | 2442 main_thread_task_runner_->PostTask( |
2252 FROM_HERE, base::Bind(&DXVAVideoDecodeAccelerator::CopySurfaceComplete, | 2443 FROM_HERE, base::Bind(&DXVAVideoDecodeAccelerator::CopySurfaceComplete, |
(...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2730 SetState(kConfigChange); | 2921 SetState(kConfigChange); |
2731 Invalidate(); | 2922 Invalidate(); |
2732 Initialize(config_, client_); | 2923 Initialize(config_, client_); |
2733 decoder_thread_task_runner_->PostTask( | 2924 decoder_thread_task_runner_->PostTask( |
2734 FROM_HERE, | 2925 FROM_HERE, |
2735 base::Bind(&DXVAVideoDecodeAccelerator::DecodePendingInputBuffers, | 2926 base::Bind(&DXVAVideoDecodeAccelerator::DecodePendingInputBuffers, |
2736 base::Unretained(this))); | 2927 base::Unretained(this))); |
2737 } | 2928 } |
2738 | 2929 |
2739 } // namespace media | 2930 } // namespace media |
OLD | NEW |