| 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 2814 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2825 | 2825 |
| 2826 video_context_->VideoProcessorSetStreamColorSpace(d3d11_processor_.get(), 0, | 2826 video_context_->VideoProcessorSetStreamColorSpace(d3d11_processor_.get(), 0, |
| 2827 &d3d11_color_space); | 2827 &d3d11_color_space); |
| 2828 dx11_converter_output_color_space_ = color_space; | 2828 dx11_converter_output_color_space_ = color_space; |
| 2829 } else { | 2829 } else { |
| 2830 dx11_converter_output_color_space_ = gfx::ColorSpace::CreateSRGB(); | 2830 dx11_converter_output_color_space_ = gfx::ColorSpace::CreateSRGB(); |
| 2831 if (use_color_info_ || use_fp16_) { | 2831 if (use_color_info_ || use_fp16_) { |
| 2832 base::win::ScopedComPtr<ID3D11VideoContext1> video_context1; | 2832 base::win::ScopedComPtr<ID3D11VideoContext1> video_context1; |
| 2833 HRESULT hr = video_context_.QueryInterface(video_context1.Receive()); | 2833 HRESULT hr = video_context_.QueryInterface(video_context1.Receive()); |
| 2834 if (SUCCEEDED(hr)) { | 2834 if (SUCCEEDED(hr)) { |
| 2835 if (use_fp16_ && base::CommandLine::ForCurrentProcess()->HasSwitch( | 2835 if (use_fp16_ && |
| 2836 switches::kEnableHDR)) { | 2836 base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 2837 switches::kEnableHDR) && |
| 2838 color_space.IsHDR()) { |
| 2839 // Note, we only use the SCRGBLinear output color space when |
| 2840 // the input is PQ, because nvidia drivers will not convert |
| 2841 // G22 to G10 for some reason. |
| 2837 dx11_converter_output_color_space_ = | 2842 dx11_converter_output_color_space_ = |
| 2838 gfx::ColorSpace::CreateSCRGBLinear(); | 2843 gfx::ColorSpace::CreateSCRGBLinear(); |
| 2839 } | 2844 } |
| 2840 // Since the video processor doesn't support HLG, let's just do the | 2845 // Since the video processor doesn't support HLG, let's just do the |
| 2841 // YUV->RGB conversion and let the output color space be HLG. | 2846 // YUV->RGB conversion and let the output color space be HLG. |
| 2842 // This won't work well unless color management is on, but if color | 2847 // This won't work well unless color management is on, but if color |
| 2843 // management is off we don't support HLG anyways. | 2848 // management is off we don't support HLG anyways. |
| 2844 if (color_space == | 2849 if (color_space == |
| 2845 gfx::ColorSpace(gfx::ColorSpace::PrimaryID::BT2020, | 2850 gfx::ColorSpace(gfx::ColorSpace::PrimaryID::BT2020, |
| 2846 gfx::ColorSpace::TransferID::ARIB_STD_B67, | 2851 gfx::ColorSpace::TransferID::ARIB_STD_B67, |
| 2847 gfx::ColorSpace::MatrixID::BT709, | 2852 gfx::ColorSpace::MatrixID::BT709, |
| 2848 gfx::ColorSpace::RangeID::LIMITED)) { | 2853 gfx::ColorSpace::RangeID::LIMITED)) { |
| 2849 video_context1->VideoProcessorSetStreamColorSpace1( | 2854 video_context1->VideoProcessorSetStreamColorSpace1( |
| 2850 d3d11_processor_.get(), 0, | 2855 d3d11_processor_.get(), 0, |
| 2851 DXGI_COLOR_SPACE_YCBCR_STUDIO_G2084_LEFT_P2020); | 2856 DXGI_COLOR_SPACE_YCBCR_STUDIO_G2084_LEFT_P2020); |
| 2852 video_context1->VideoProcessorSetOutputColorSpace1( | 2857 video_context1->VideoProcessorSetOutputColorSpace1( |
| 2853 d3d11_processor_.get(), | 2858 d3d11_processor_.get(), |
| 2854 DXGI_COLOR_SPACE_RGB_FULL_G2084_NONE_P2020); | 2859 DXGI_COLOR_SPACE_RGB_FULL_G2084_NONE_P2020); |
| 2855 dx11_converter_output_color_space_ = color_space.GetAsFullRangeRGB(); | 2860 dx11_converter_output_color_space_ = color_space.GetAsFullRangeRGB(); |
| 2856 } else { | 2861 } else { |
| 2862 DVLOG(2) << "input color space: " << color_space |
| 2863 << " DXGIColorSpace: " |
| 2864 << gfx::ColorSpaceWin::GetDXGIColorSpace(color_space); |
| 2865 DVLOG(2) << "output color space:" |
| 2866 << dx11_converter_output_color_space_ << " DXGIColorSpace: " |
| 2867 << gfx::ColorSpaceWin::GetDXGIColorSpace( |
| 2868 dx11_converter_output_color_space_); |
| 2857 video_context1->VideoProcessorSetStreamColorSpace1( | 2869 video_context1->VideoProcessorSetStreamColorSpace1( |
| 2858 d3d11_processor_.get(), 0, | 2870 d3d11_processor_.get(), 0, |
| 2859 gfx::ColorSpaceWin::GetDXGIColorSpace(color_space)); | 2871 gfx::ColorSpaceWin::GetDXGIColorSpace(color_space)); |
| 2860 video_context1->VideoProcessorSetOutputColorSpace1( | 2872 video_context1->VideoProcessorSetOutputColorSpace1( |
| 2861 d3d11_processor_.get(), gfx::ColorSpaceWin::GetDXGIColorSpace( | 2873 d3d11_processor_.get(), gfx::ColorSpaceWin::GetDXGIColorSpace( |
| 2862 dx11_converter_output_color_space_)); | 2874 dx11_converter_output_color_space_)); |
| 2863 } | 2875 } |
| 2864 } else { | 2876 } else { |
| 2865 D3D11_VIDEO_PROCESSOR_COLOR_SPACE d3d11_color_space = | 2877 D3D11_VIDEO_PROCESSOR_COLOR_SPACE d3d11_color_space = |
| 2866 gfx::ColorSpaceWin::GetD3D11ColorSpace(color_space); | 2878 gfx::ColorSpaceWin::GetD3D11ColorSpace(color_space); |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2974 base::Bind(&DXVAVideoDecodeAccelerator::DecodePendingInputBuffers, | 2986 base::Bind(&DXVAVideoDecodeAccelerator::DecodePendingInputBuffers, |
| 2975 base::Unretained(this))); | 2987 base::Unretained(this))); |
| 2976 } | 2988 } |
| 2977 | 2989 |
| 2978 uint32_t DXVAVideoDecodeAccelerator::GetTextureTarget() const { | 2990 uint32_t DXVAVideoDecodeAccelerator::GetTextureTarget() const { |
| 2979 bool provide_nv12_textures = share_nv12_textures_ || copy_nv12_textures_; | 2991 bool provide_nv12_textures = share_nv12_textures_ || copy_nv12_textures_; |
| 2980 return provide_nv12_textures ? GL_TEXTURE_EXTERNAL_OES : GL_TEXTURE_2D; | 2992 return provide_nv12_textures ? GL_TEXTURE_EXTERNAL_OES : GL_TEXTURE_2D; |
| 2981 } | 2993 } |
| 2982 | 2994 |
| 2983 } // namespace media | 2995 } // namespace media |
| OLD | NEW |