obs-qsv11: Fix various issues detected by Coverity

This commit is contained in:
Richard Stanway 2017-02-25 17:17:12 +01:00
parent d2e9e47bb4
commit a1083d4252
3 changed files with 13 additions and 9 deletions

View File

@ -517,18 +517,21 @@ mfxStatus QSV_Encoder_Internal::Encode(uint64_t ts, uint8_t *pDataY,
}
mfxFrameSurface1 *pSurface = m_pmfxSurfaces[nSurfIdx];
if (m_bUseD3D11 || m_bD3D9HACK)
if (m_bUseD3D11 || m_bD3D9HACK) {
sts = m_mfxAllocator.Lock(m_mfxAllocator.pthis,
pSurface->Data.MemId, &(pSurface->Data));
MSDK_CHECK_RESULT(sts, MFX_ERR_NONE, sts);
}
sts = LoadNV12(pSurface, pDataY, pDataUV, strideY, strideUV);
MSDK_CHECK_RESULT(sts, MFX_ERR_NONE, sts);
pSurface->Data.TimeStamp = ts;
if (m_bUseD3D11 || m_bD3D9HACK)
if (m_bUseD3D11 || m_bD3D9HACK) {
sts = m_mfxAllocator.Unlock(m_mfxAllocator.pthis,
pSurface->Data.MemId, &(pSurface->Data));
MSDK_CHECK_RESULT(sts, MFX_ERR_NONE, sts);
MSDK_CHECK_RESULT(sts, MFX_ERR_NONE, sts);
}
for (;;) {
// Encode a frame asychronously (returns immediately)
@ -592,10 +595,8 @@ mfxStatus QSV_Encoder_Internal::ClearData()
delete m_outBitstream.Data;
if (m_pmfxENC != NULL) {
delete m_pmfxENC;
m_pmfxENC = NULL;
}
delete m_pmfxENC;
m_pmfxENC = NULL;
if (m_bUseD3D11 || m_bD3D9HACK)
Release();

View File

@ -148,7 +148,7 @@ mfxStatus LoadRawFrame(mfxFrameSurface1* pSurface, FILE* fSource)
if (MFX_ERR_NONE != sts)
return sts;
// load V
ReadPlaneData(w, h, buf, ptr, pitch, 1, fSource);
sts = ReadPlaneData(w, h, buf, ptr, pitch, 1, fSource);
if (MFX_ERR_NONE != sts)
return sts;

View File

@ -686,6 +686,8 @@ static bool obs_qsv_encode(void *data, struct encoder_frame *frame,
mfxU64 qsvPTS = frame->pts * 90000 / voi->fps_num;
// FIXME: remove null check from the top of this function
// if we actually do expect null frames to complete output.
if (frame)
ret = qsv_encoder_encode(
obsqsv->context,
@ -701,6 +703,7 @@ static bool obs_qsv_encode(void *data, struct encoder_frame *frame,
if (ret < 0) {
warn("encode failed");
LeaveCriticalSection(&g_QsvCs);
return false;
}