11 #include "DVDCodecs/Video/DXVA.h" 12 #include "VideoRenderers/Windows/RendererBase.h" 13 #include "guilib/D3DResource.h" 17 #include <wrl/client.h> 27 D3D11_VIDEO_PROCESSOR_FILTER filter;
28 D3D11_VIDEO_PROCESSOR_FILTER_CAPS cap;
34 {D3D11_VIDEO_PROCESSOR_FILTER_BRIGHTNESS,
35 D3D11_VIDEO_PROCESSOR_FILTER_CAPS_BRIGHTNESS,
"Brightness"},
36 {D3D11_VIDEO_PROCESSOR_FILTER_CONTRAST,
37 D3D11_VIDEO_PROCESSOR_FILTER_CAPS_CONTRAST,
"Contrast"},
38 {D3D11_VIDEO_PROCESSOR_FILTER_HUE,
39 D3D11_VIDEO_PROCESSOR_FILTER_CAPS_HUE,
"Hue"},
40 {D3D11_VIDEO_PROCESSOR_FILTER_SATURATION,
41 D3D11_VIDEO_PROCESSOR_FILTER_CAPS_SATURATION,
"Saturation"},
42 {D3D11_VIDEO_PROCESSOR_FILTER_NOISE_REDUCTION,
43 D3D11_VIDEO_PROCESSOR_FILTER_CAPS_NOISE_REDUCTION,
"Noise Reduction"},
44 {D3D11_VIDEO_PROCESSOR_FILTER_EDGE_ENHANCEMENT,
45 D3D11_VIDEO_PROCESSOR_FILTER_CAPS_EDGE_ENHANCEMENT,
"Edge Enhancement"},
46 {D3D11_VIDEO_PROCESSOR_FILTER_ANAMORPHIC_SCALING,
47 D3D11_VIDEO_PROCESSOR_FILTER_CAPS_ANAMORPHIC_SCALING,
"Anamorphic Scaling"},
48 {D3D11_VIDEO_PROCESSOR_FILTER_STEREO_ADJUSTMENT,
49 D3D11_VIDEO_PROCESSOR_FILTER_CAPS_STEREO_ADJUSTMENT,
"Stereo Adjustment"}};
52 constexpr
size_t NUM_FILTERS = ARRAYSIZE(PROCAMP_FILTERS);
57 D3D11_VIDEO_PROCESSOR_FILTER_RANGE Range;
64 uint32_t m_procIndex{0};
65 D3D11_VIDEO_PROCESSOR_CAPS m_vcaps{};
66 D3D11_VIDEO_PROCESSOR_RATE_CONVERSION_CAPS m_rateCaps{};
68 bool m_hasMetadataHDR10Support{
false};
80 std::vector<DXGI_FORMAT> m_input;
81 std::vector<DXGI_FORMAT> m_output;
87 DXGI_FORMAT m_inputFormat{DXGI_FORMAT_UNKNOWN};
88 DXGI_COLOR_SPACE_TYPE m_inputCS{DXGI_COLOR_SPACE_RESERVED};
89 DXGI_FORMAT m_outputFormat{DXGI_FORMAT_UNKNOWN};
90 DXGI_COLOR_SPACE_TYPE m_outputCS{DXGI_COLOR_SPACE_RESERVED};
94 const DXGI_COLOR_SPACE_TYPE& inputCS,
95 const DXGI_FORMAT& outputFormat,
96 const DXGI_COLOR_SPACE_TYPE& outputCS)
97 : m_inputFormat(inputFormat),
99 m_outputFormat(outputFormat),
104 const std::string ToString()
const;
108 return m_inputFormat != other.m_inputFormat ||
109 m_inputCS != other.m_inputCS && m_outputFormat != other.m_outputFormat ||
110 m_outputCS != other.m_outputCS;
114 using ProcessorConversions = std::vector<ProcessorConversion>;
118 AVColorPrimaries m_colorPrimaries{AVCOL_PRI_UNSPECIFIED};
119 AVColorSpace m_colorSpace{AVCOL_SPC_UNSPECIFIED};
120 AVColorTransferCharacteristic m_colorTransfer{AVCOL_TRC_UNSPECIFIED};
121 bool m_fullRange{
false};
122 bool m_hdrOutput{
false};
128 m_colorPrimaries = picture.color_primaries;
129 m_colorSpace = picture.color_space;
130 m_colorTransfer = picture.color_transfer;
131 m_fullRange = picture.color_range == 1;
132 m_hdrOutput = isHdrOutput;
136 const AVColorSpace& colorSpace,
137 const AVColorTransferCharacteristic& colorTransfer,
140 : m_colorPrimaries(colorPrimaries),
141 m_colorSpace(colorSpace),
142 m_colorTransfer(colorTransfer),
143 m_fullRange(fullRange),
144 m_hdrOutput(hdrOutput)
150 return m_colorPrimaries != other.m_colorPrimaries || m_colorTransfer != other.m_colorTransfer ||
151 m_fullRange != other.m_fullRange || m_hdrOutput != other.m_hdrOutput;
157 AVColorPrimaries primaries = AVCOL_PRI_UNSPECIFIED;
158 AVColorSpace color_space = AVCOL_SPC_UNSPECIFIED;
159 AVColorTransferCharacteristic color_transfer = AVCOL_TRC_UNSPECIFIED;
160 bool full_range =
false;
161 AVChromaLocation chroma_location = AVCHROMA_LOC_UNSPECIFIED;
165 primaries = picture.color_primaries;
166 color_space = picture.color_space;
167 color_transfer = picture.color_transfer;
168 full_range = picture.color_range == 1;
169 chroma_location = picture.chroma_position;
173 AVColorSpace color_space,
174 AVColorTransferCharacteristic color_transfer,
176 AVChromaLocation chroma_location)
178 this->primaries = primaries;
179 this->color_space = color_space;
180 this->color_transfer = color_transfer;
181 this->full_range = full_range;
182 this->chroma_location = chroma_location;
192 bool Open(
unsigned int width,
unsigned int height, DXGI_FORMAT input_dxgi_format);
196 void OnCreateDevice()
override 198 std::unique_lock<CCriticalSection> lock(m_section);
199 if (m_width > 0 && m_height > 0)
203 void OnDestroyDevice(
bool)
override 205 std::unique_lock<CCriticalSection> lock(m_section);
219 bool CheckConversion(DXGI_FORMAT inputFormat,
220 DXGI_COLOR_SPACE_TYPE inputCS,
221 DXGI_FORMAT outputFormat,
222 DXGI_COLOR_SPACE_TYPE outputCS);
228 bool IsFormatSupportedInput(DXGI_FORMAT format);
234 bool IsFormatSupportedOutput(DXGI_FORMAT format);
241 void LogSupportedConversions(
const DXGI_FORMAT inputFormat,
242 const DXGI_COLOR_SPACE_TYPE inputNativeCS);
244 bool IsInitialized()
const {
return m_pEnumerator; }
252 ComPtr<ID3D11VideoProcessor> CreateVideoProcessor(UINT RateConversionIndex);
253 ComPtr<ID3D11VideoProcessorInputView> CreateVideoProcessorInputView(
254 ID3D11Resource* pResource,
const D3D11_VIDEO_PROCESSOR_INPUT_VIEW_DESC* pDesc);
255 ComPtr<ID3D11VideoProcessorOutputView> CreateVideoProcessorOutputView(
256 ID3D11Resource* pResource,
const D3D11_VIDEO_PROCESSOR_OUTPUT_VIEW_DESC* pDesc);
274 bool OpenEnumerator();
282 ProcessorFormats GetProcessorFormats(
bool inputFormats,
bool outputFormats)
const;
287 std::vector<DXGI_FORMAT> GetProcessorRGBOutputFormats()
const;
297 bool CheckConversionInternal(DXGI_FORMAT inputFormat,
298 DXGI_COLOR_SPACE_TYPE inputCS,
299 DXGI_FORMAT outputFormat,
300 DXGI_COLOR_SPACE_TYPE outputCS)
const;
306 bool IsFormatSupportedInternal(DXGI_FORMAT format,
307 D3D11_VIDEO_PROCESSOR_FORMAT_SUPPORT support)
const;
318 ProcessorConversions ListConversions(
319 DXGI_FORMAT inputFormat,
320 const std::vector<DXGI_COLOR_SPACE_TYPE>& inputColorSpaces,
321 const std::vector<DXGI_FORMAT>& outputFormats,
322 const std::vector<DXGI_COLOR_SPACE_TYPE>& outputColorSpaces)
const;
346 AVChromaLocation AlternativeChromaSiting(
const AVChromaLocation& location)
const;
348 CCriticalSection m_section;
350 uint32_t m_width = 0;
351 uint32_t m_height = 0;
353 ComPtr<ID3D11VideoDevice> m_pVideoDevice;
354 ComPtr<ID3D11VideoProcessorEnumerator> m_pEnumerator;
355 ComPtr<ID3D11VideoProcessorEnumerator1> m_pEnumerator1;
356 DXGI_FORMAT m_input_dxgi_format{DXGI_FORMAT_UNKNOWN};
bool IsEnumerator1Available()
Returns the availability of the interface ID3D11VideoProcessorEnumerator1 (Windows 10 supporting HDR ...
Definition: DXVAEnumeratorHD.h:250
Definition: DXVAEnumeratorHD.h:54
Definition: DXVAEnumeratorHD.h:186
Definition: DXVAEnumeratorHD.h:155
Definition: DXVAEnumeratorHD.h:25
Definition: DXVAEnumeratorHD.h:85
Definition: D3DResource.h:36
Definition: DVDVideoCodec.h:36
Definition: DXVAEnumeratorHD.h:60
Definition: DXVAEnumeratorHD.h:116