29bool EvrVideoWindowControl::setEvr(IUnknown *evr)
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));
44 setDisplayRect(m_displayRect);
45 setAspectRatioMode(m_aspectRatioMode);
46 m_dirtyValues = DXVA2_ProcAmp_Brightness | DXVA2_ProcAmp_Contrast | DXVA2_ProcAmp_Hue | DXVA2_ProcAmp_Saturation;
53 return m_displayControl != NULL;
75void EvrVideoWindowControl::setDisplayRect(
const QRect &rect)
79 if (m_displayControl) {
80 RECT displayRect = { rect.left(), rect.top(), rect.right() + 1, rect.bottom() + 1 };
81 QSize sourceSize = nativeSize();
83 RECT sourceRect = { 0, 0, sourceSize.width(), sourceSize.height() };
85 if (m_aspectRatioMode == Qt::KeepAspectRatioByExpanding) {
86 QSize clippedSize = rect.size();
87 clippedSize.scale(sourceRect.right, sourceRect.bottom, Qt::KeepAspectRatio);
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);
114void EvrVideoWindowControl::setAspectRatioMode(Qt::AspectRatioMode mode)
116 m_aspectRatioMode = mode;
118 if (m_displayControl) {
120 case Qt::IgnoreAspectRatio:
122 m_displayControl->SetAspectRatioMode(MFVideoARMode_None);
124 case Qt::KeepAspectRatio:
126 m_displayControl->SetAspectRatioMode(MFVideoARMode_PreservePicture);
128 case Qt::KeepAspectRatioByExpanding:
130 m_displayControl->SetAspectRatioMode(MFVideoARMode_PreservePicture);
135 setDisplayRect(m_displayRect);
187void EvrVideoWindowControl::applyImageControls()
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))) {