diff options
author | Anton Fedchin <afedchin@ruswizards.com> | 2015-12-30 16:55:12 +0300 |
---|---|---|
committer | Anton Fedchin <afedchin@ruswizards.com> | 2015-12-30 16:55:12 +0300 |
commit | 68b48a05551add0e71d57c81e2af3873a1c632de (patch) | |
tree | 6eca9d93eef9ce8d7faab90b50fae77bd59d41bd | |
parent | c1f7e1c552ca6b0d8042644d9d02a6e9059276df (diff) |
[WinRenderer] Added support of rotated videos.
-rw-r--r-- | xbmc/cores/VideoRenderers/DXVAHD.cpp | 4 | ||||
-rw-r--r-- | xbmc/cores/VideoRenderers/DXVAHD.h | 2 | ||||
-rw-r--r-- | xbmc/cores/VideoRenderers/WinRenderer.cpp | 37 |
3 files changed, 36 insertions, 7 deletions
diff --git a/xbmc/cores/VideoRenderers/DXVAHD.cpp b/xbmc/cores/VideoRenderers/DXVAHD.cpp index 470669c70e..472fdf01ad 100644 --- a/xbmc/cores/VideoRenderers/DXVAHD.cpp +++ b/xbmc/cores/VideoRenderers/DXVAHD.cpp @@ -569,7 +569,7 @@ ID3D11VideoProcessorInputView* CProcessorHD::GetInputView(ID3D11View* view) return inputView; } -bool CProcessorHD::Render(CRect src, CRect dst, ID3D11Resource* target, ID3D11View** views, DWORD flags, UINT frameIdx) +bool CProcessorHD::Render(CRect src, CRect dst, ID3D11Resource* target, ID3D11View** views, DWORD flags, UINT frameIdx, UINT rotation) { HRESULT hr; CSingleLock lock(m_section); @@ -714,6 +714,8 @@ bool CProcessorHD::Render(CRect src, CRect dst, ID3D11Resource* target, ID3D11Vi , 0, 100, 50); ApplyFilter(D3D11_VIDEO_PROCESSOR_FILTER_CONTRAST, CMediaSettings::GetInstance().GetCurrentVideoSettings().m_Contrast , 0, 100, 50); + // Rotation + m_pVideoContext->VideoProcessorSetStreamRotation(m_pVideoProcessor, DEFAULT_STREAM_INDEX, (rotation != 0), (D3D11_VIDEO_PROCESSOR_ROTATION)(rotation / 90)); // // Create Output View of Output Surfaces. diff --git a/xbmc/cores/VideoRenderers/DXVAHD.h b/xbmc/cores/VideoRenderers/DXVAHD.h index 154668f12b..802f96fd8c 100644 --- a/xbmc/cores/VideoRenderers/DXVAHD.h +++ b/xbmc/cores/VideoRenderers/DXVAHD.h @@ -51,7 +51,7 @@ public: virtual bool Open(UINT width, UINT height, unsigned int flags, unsigned int format, unsigned int extended_format); virtual void Close(); virtual CRenderPicture *Convert(DVDVideoPicture* picture); - virtual bool Render(CRect src, CRect dst, ID3D11Resource* target, ID3D11View **views, DWORD flags, UINT frameIdx); + virtual bool Render(CRect src, CRect dst, ID3D11Resource* target, ID3D11View **views, DWORD flags, UINT frameIdx, UINT rotation); virtual unsigned Size() { if (m_pVideoProcessor) return m_size; return 0; } virtual unsigned PastRefs() { return m_max_back_refs; } virtual void ApplySupportedFormats(std::vector<ERenderFormat> * formats); diff --git a/xbmc/cores/VideoRenderers/WinRenderer.cpp b/xbmc/cores/VideoRenderers/WinRenderer.cpp index 2721189020..4821b9b83d 100644 --- a/xbmc/cores/VideoRenderers/WinRenderer.cpp +++ b/xbmc/cores/VideoRenderers/WinRenderer.cpp @@ -235,6 +235,7 @@ bool CWinRenderer::Configure(unsigned int width, unsigned int height, unsigned i m_iFlags = flags; m_format = format; m_extended_format = extended_format; + m_renderOrientation = orientation; // calculate the input frame aspect ratio CalculateFrameAspectRatio(d_width, d_height); @@ -777,12 +778,12 @@ void CWinRenderer::ScaleGUIShader() unsigned int contrast = (unsigned int)(CMediaSettings::GetInstance().GetCurrentVideoSettings().m_Contrast *.01f * 255.0f); // we have to divide by two here/multiply by two later unsigned int brightness = (unsigned int)(CMediaSettings::GetInstance().GetCurrentVideoSettings().m_Brightness * .01f * 255.0f); - CRect tu = { m_sourceRect.x1 / srcWidth, m_sourceRect.y1 / srcHeight, m_sourceRect.x2 / srcWidth, m_sourceRect.y2 / srcHeight }; - g_Windowing.GetGUIShader()->SetSampler(m_TextureFilter); + CRect tu = { m_sourceRect.x1 / srcWidth, m_sourceRect.y1 / srcHeight, m_sourceRect.x2 / srcWidth, m_sourceRect.y2 / srcHeight }; + CRect destRect = CRect(m_rotatedDestCoords[0], m_rotatedDestCoords[2]); // pass contrast and brightness as diffuse color elements (see shader code) - CD3DTexture::DrawQuad(m_destRect, D3DCOLOR_ARGB(255, contrast, brightness, 255), &m_SWTarget, &tu, + CD3DTexture::DrawQuad(destRect, D3DCOLOR_ARGB(255, contrast, brightness, 255), &m_SWTarget, &tu, !cbcontrol ? SHADER_METHOD_RENDER_VIDEO : SHADER_METHOD_RENDER_VIDEO_CONTROL); } @@ -811,7 +812,32 @@ void CWinRenderer::Stage1() ID3D11RenderTargetView *oldRTView = nullptr; ID3D11DepthStencilView* oldDSView = nullptr; pContext->OMGetRenderTargets(1, &oldRTView, &oldDSView); // select destination rectangle - CRect destRect = m_bUseHQScaler ? m_sourceRect : g_graphicsContext.StereoCorrection(m_destRect); + CRect destRect; + if (m_bUseHQScaler) + { + if (m_renderOrientation > 0) + { + // we need to rotate source coordinates for HQ scaller + // so we using ReorderDrawPoints with source coords. + + // save coords + CRect oldDest = m_destRect; + saveRotatedCoords(); + + m_destRect = m_sourceRect; + ReorderDrawPoints(); + // get rotated coords + destRect = CRect(m_rotatedDestCoords[0], m_rotatedDestCoords[2]); + + // restore coords + restoreRotatedCoords(); + m_destRect = oldDest; + } + else + destRect = m_sourceRect; + } + else + destRect = g_graphicsContext.StereoCorrection(CRect(m_rotatedDestCoords[0], m_rotatedDestCoords[2])); // select target view ID3D11RenderTargetView* pRTView = m_bUseHQScaler ? m_IntermediateTarget.GetRenderTarget() : oldRTView; // change destination for HQ scallers @@ -909,7 +935,7 @@ void CWinRenderer::RenderProcessor(DWORD flags) break; } - m_processor->Render(m_sourceRect, destRect, m_IntermediateTarget.Get(), views, flags, image->frameIdx); + m_processor->Render(m_sourceRect, destRect, m_IntermediateTarget.Get(), views, flags, image->frameIdx, m_renderOrientation); if (m_bUseHQScaler) { @@ -1046,6 +1072,7 @@ bool CWinRenderer::Supports(ERENDERFEATURE feature) feature == RENDERFEATURE_ZOOM || feature == RENDERFEATURE_VERTICAL_SHIFT || feature == RENDERFEATURE_PIXEL_RATIO || + feature == RENDERFEATURE_ROTATION || feature == RENDERFEATURE_POSTPROCESS) return true; |