11 , m_windowColor(RGB(0, 0, 0))
13 , m_aspectRatioMode(
Qt::KeepAspectRatio)
36 IMFGetService *service = NULL;
38 if (SUCCEEDED(evr->QueryInterface(IID_PPV_ARGS(&service)))
39 && SUCCEEDED(service->GetService(MR_VIDEO_RENDER_SERVICE, IID_PPV_ARGS(&m_displayControl)))) {
41 service->GetService(MR_VIDEO_MIXER_SERVICE, IID_PPV_ARGS(&m_processor));
46 m_dirtyValues = DXVA2_ProcAmp_Brightness | DXVA2_ProcAmp_Contrast | DXVA2_ProcAmp_Hue | DXVA2_ProcAmp_Saturation;
53 return m_displayControl != NULL;
56void EvrVideoWindowControl::clear()
59 m_displayControl->Release();
60 m_displayControl = NULL;
63 m_processor->Release();
72 m_displayControl->SetVideoWindow(HWND(m_windowId));
79 if (m_displayControl) {
80 RECT displayRect = {
rect.left(),
rect.top(),
rect.right() + 1,
rect.bottom() + 1 };
83 RECT sourceRect = { 0, 0, sourceSize.
width(), sourceSize.
height() };
89 sourceRect.left = (sourceRect.right - clippedSize.
width()) / 2;
90 sourceRect.top = (sourceRect.bottom - clippedSize.
height()) / 2;
91 sourceRect.right = sourceRect.left + clippedSize.
width();
92 sourceRect.bottom = sourceRect.top + clippedSize.
height();
95 if (sourceSize.
width() > 0 && sourceSize.
height() > 0) {
96 MFVideoNormalizedRect sourceNormRect;
97 sourceNormRect.left = float(sourceRect.left) / float(sourceRect.right);
98 sourceNormRect.top = float(sourceRect.top) / float(sourceRect.bottom);
99 sourceNormRect.right = float(sourceRect.right) / float(sourceRect.right);
100 sourceNormRect.bottom = float(sourceRect.bottom) / float(sourceRect.bottom);
101 m_displayControl->SetVideoPosition(&sourceNormRect, &displayRect);
103 m_displayControl->SetVideoPosition(NULL, &displayRect);
110 if (m_fullScreen == fullScreen)
116 m_aspectRatioMode =
mode;
118 if (m_displayControl) {
122 m_displayControl->SetAspectRatioMode(MFVideoARMode_None);
126 m_displayControl->SetAspectRatioMode(MFVideoARMode_PreservePicture);
130 m_displayControl->SetAspectRatioMode(MFVideoARMode_PreservePicture);
141 if (m_brightness == brightness)
144 m_brightness = brightness;
146 m_dirtyValues |= DXVA2_ProcAmp_Brightness;
153 if (m_contrast == contrast)
156 m_contrast = contrast;
158 m_dirtyValues |= DXVA2_ProcAmp_Contrast;
170 m_dirtyValues |= DXVA2_ProcAmp_Hue;
177 if (m_saturation == saturation)
180 m_saturation = saturation;
182 m_dirtyValues |= DXVA2_ProcAmp_Saturation;
190 DXVA2_ProcAmpValues
values;
191 if (m_dirtyValues & DXVA2_ProcAmp_Brightness) {
192 values.Brightness = scaleProcAmpValue(DXVA2_ProcAmp_Brightness, m_brightness);
194 if (m_dirtyValues & DXVA2_ProcAmp_Contrast) {
195 values.Contrast = scaleProcAmpValue(DXVA2_ProcAmp_Contrast, m_contrast);
197 if (m_dirtyValues & DXVA2_ProcAmp_Hue) {
198 values.Hue = scaleProcAmpValue(DXVA2_ProcAmp_Hue, m_hue);
200 if (m_dirtyValues & DXVA2_ProcAmp_Saturation) {
201 values.Saturation = scaleProcAmpValue(DXVA2_ProcAmp_Saturation, m_saturation);
204 if (SUCCEEDED(m_processor->SetProcAmpValues(m_dirtyValues, &
values))) {
210DXVA2_Fixed32 EvrVideoWindowControl::scaleProcAmpValue(DWORD prop,
float value)
const
212 float scaledValue = 0.0;
214 DXVA2_ValueRange
range;
215 if (SUCCEEDED(m_processor->GetProcAmpRange(prop, &
range))) {
216 scaledValue = DXVA2FixedToFloat(
range.DefaultValue);
218 scaledValue += float(
value) * (DXVA2FixedToFloat(
range.MaxValue) - DXVA2FixedToFloat(
range.DefaultValue));
220 scaledValue -= float(
value) * (DXVA2FixedToFloat(
range.MinValue) - DXVA2FixedToFloat(
range.DefaultValue));
223 return DXVA2FloatToFixed(scaledValue);
228#include "moc_evrvideowindowcontrol_p.cpp"
void setWinId(WId id) override
bool setEvr(IUnknown *evr)
void setDisplayRect(const QRect &rect) override
void setHue(float hue) override
void setContrast(float contrast) override
void setFullScreen(bool fullScreen) override
~EvrVideoWindowControl() override
EvrVideoWindowControl(QVideoSink *parent=0)
void setSaturation(float saturation) override
void setBrightness(float brightness) override
void setAspectRatioMode(Qt::AspectRatioMode mode) override
void applyImageControls()
\inmodule QtCore\reentrant
constexpr int height() const noexcept
Returns the height.
constexpr int width() const noexcept
Returns the width.
void scale(int w, int h, Qt::AspectRatioMode mode) noexcept
Scales the size to a rectangle with the given width and height, according to the specified mode:
The QVideoSink class represents a generic sink for video data.
Combined button and popup list for selecting options.
@ KeepAspectRatioByExpanding
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
GLenum GLsizei GLsizei GLint * values
[15]
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent