Skip to content

Commit

Permalink
[dxva] clear video views on creation.
Browse files Browse the repository at this point in the history
  • Loading branch information
afedchin committed Jul 7, 2017
1 parent b800bce commit 3a0be26
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions xbmc/cores/VideoPlayer/DVDCodecs/Video/DXVA.cpp
Expand Up @@ -434,6 +434,7 @@ bool CDXVAContext::CreateSurfaces(D3D11_VIDEO_DECODER_DESC format, unsigned int
{
HRESULT hr = S_OK;
ID3D11Device* pDevice = g_Windowing.Get3D11Device();
ID3D11DeviceContext1* pContext = g_Windowing.GetImmediateContext();

CD3D11_TEXTURE2D_DESC texDesc(format.OutputFormat,
FFALIGN(format.SampleWidth, alignment),
Expand All @@ -451,6 +452,7 @@ bool CDXVAContext::CreateSurfaces(D3D11_VIDEO_DECODER_DESC format, unsigned int
vdovDesc.DecodeProfile = format.Guid;
vdovDesc.Texture2D.ArraySlice = 0;
vdovDesc.ViewDimension = D3D11_VDOV_DIMENSION_TEXTURE2D;
float clearColor[] = { 0.0625f, 0.5f, 0.5f, 1.0f }; // black color in YUV

size_t i;
for (i = 0; i < count; ++i)
Expand All @@ -462,6 +464,7 @@ bool CDXVAContext::CreateSurfaces(D3D11_VIDEO_DECODER_DESC format, unsigned int
CLog::Log(LOGERROR, "%s - failed creating surfaces", __FUNCTION__);
break;
}
pContext->ClearView(surfaces[i], clearColor, nullptr, 0);
}
SAFE_RELEASE(texture);

Expand Down
3 changes: 3 additions & 0 deletions xbmc/cores/VideoPlayer/VideoRenderers/HwDecRender/DXVAHD.cpp
Expand Up @@ -361,6 +361,7 @@ bool CProcessorHD::CreateSurfaces()
HRESULT hr;
size_t idx;
ID3D11Device* pD3DDevice = g_Windowing.Get3D11Device();
ID3D11DeviceContext1* pContext = g_Windowing.GetImmediateContext();

// we cannot use texture array (like in decoder) for USAGE_DYNAMIC, so create separate textures
CD3D11_TEXTURE2D_DESC texDesc(m_textureFormat, FFALIGN(m_width, 16), FFALIGN(m_height, 16), 1, 1, D3D11_BIND_DECODER, D3D11_USAGE_DYNAMIC, D3D11_CPU_ACCESS_WRITE);
Expand All @@ -371,6 +372,7 @@ bool CProcessorHD::CreateSurfaces()
ID3D11VideoProcessorInputView* views[32] = { nullptr };
CLog::Log(LOGDEBUG, "%s - Creating %d processor surfaces with format %d.", __FUNCTION__, m_size, m_textureFormat);

float clearColor[] = { 0.0625f, 0.5f, 0.5f, 1.0f }; // black color in YUV
for (idx = 0; idx < m_size; idx++)
{
ID3D11Texture2D* pTexture = nullptr;
Expand All @@ -382,6 +384,7 @@ bool CProcessorHD::CreateSurfaces()
SAFE_RELEASE(pTexture);
if (FAILED(hr))
break;
pContext->ClearView(views[idx], clearColor, nullptr, 0);
}

if (idx != m_size)
Expand Down

0 comments on commit 3a0be26

Please sign in to comment.