diff --git a/codec/console/dec/src/d3d9_utils.cpp b/codec/console/dec/src/d3d9_utils.cpp index 324d0f0e..b84cc8b0 100644 --- a/codec/console/dec/src/d3d9_utils.cpp +++ b/codec/console/dec/src/d3d9_utils.cpp @@ -75,7 +75,8 @@ CD3D9Utils::CD3D9Utils() { m_lpD3D9 = NULL; m_lpD3D9Device = NULL; m_lpD3D9RawSurfaceShare = NULL; - + m_nWidth = 0; + m_nHeight = 0; // coverity scan uninitial ZeroMemory (&m_d3dpp, sizeof (m_d3dpp)); } @@ -147,6 +148,16 @@ HRESULT CD3D9Utils::Process (void* pDst[3], SBufferInfo* pInfo, FILE* pFp) { HRESULT CD3D9Utils::Render (void* pDst[3], SBufferInfo* pInfo) { HRESULT hResult = E_FAIL; + if (!pInfo) + return E_FAIL; + + if (m_nWidth != pInfo->UsrData.sSystemBuffer.iWidth + || m_nHeight != pInfo->UsrData.sSystemBuffer.iHeight) { + m_nWidth = pInfo->UsrData.sSystemBuffer.iWidth; + m_nHeight = pInfo->UsrData.sSystemBuffer.iHeight; + SAFE_RELEASE (m_lpD3D9RawSurfaceShare); + SAFE_RELEASE (m_lpD3D9Device); + } hResult = InitResource (NULL, pInfo); if (SUCCEEDED (hResult)) hResult = Dump2Surface (pDst, m_lpD3D9RawSurfaceShare, pInfo->UsrData.sSystemBuffer.iWidth, @@ -245,6 +256,8 @@ CD3D9ExUtils::CD3D9ExUtils() { m_lpD3D9Device = NULL; m_lpD3D9RawSurfaceShare = NULL; + m_nWidth = 0; + m_nHeight = 0; // coverity scan uninitial ZeroMemory (&m_d3dpp, sizeof (m_d3dpp)); } @@ -316,6 +329,16 @@ HRESULT CD3D9ExUtils::Process (void* pDst[3], SBufferInfo* pInfo, FILE* pFp) { HRESULT CD3D9ExUtils::Render (void* pDst[3], SBufferInfo* pInfo) { HRESULT hResult = E_FAIL; + if (!pInfo) + return E_FAIL; + + if (m_nWidth != pInfo->UsrData.sSystemBuffer.iWidth + || m_nHeight != pInfo->UsrData.sSystemBuffer.iHeight) { + m_nWidth = pInfo->UsrData.sSystemBuffer.iWidth; + m_nHeight = pInfo->UsrData.sSystemBuffer.iHeight; + SAFE_RELEASE (m_lpD3D9RawSurfaceShare); + SAFE_RELEASE (m_lpD3D9Device); + } hResult = InitResource (NULL, pInfo); if (SUCCEEDED (hResult)) hResult = Dump2Surface (pDst, m_lpD3D9RawSurfaceShare, pInfo->UsrData.sSystemBuffer.iWidth, @@ -386,6 +409,9 @@ HRESULT CD3D9ExUtils::InitResource (void* pSharedHandle, SBufferInfo* pInfo) { m_d3dpp.hDeviceWindow = m_hWnd; m_d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE; hResult = m_lpD3D9->CreateDeviceEx (uiAdapter, D3DDevType, NULL, dwBehaviorFlags, &m_d3dpp, NULL, &m_lpD3D9Device); + if (FAILED (hResult)) { + return hResult; + } iWidth = pInfo->UsrData.sSystemBuffer.iWidth; iHeight = pInfo->UsrData.sSystemBuffer.iHeight; D3Dformat = (D3DFORMAT)NV12_FORMAT;