diff --git a/plugins/obs-qsv11/QSV_Encoder_Internal.cpp b/plugins/obs-qsv11/QSV_Encoder_Internal.cpp index 49f2a01dd..570a20e25 100644 --- a/plugins/obs-qsv11/QSV_Encoder_Internal.cpp +++ b/plugins/obs-qsv11/QSV_Encoder_Internal.cpp @@ -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(); diff --git a/plugins/obs-qsv11/common_utils.cpp b/plugins/obs-qsv11/common_utils.cpp index 15ab60d2c..76594ba78 100644 --- a/plugins/obs-qsv11/common_utils.cpp +++ b/plugins/obs-qsv11/common_utils.cpp @@ -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; diff --git a/plugins/obs-qsv11/obs-qsv11.c b/plugins/obs-qsv11/obs-qsv11.c index b57f8a18a..e014269f4 100644 --- a/plugins/obs-qsv11/obs-qsv11.c +++ b/plugins/obs-qsv11/obs-qsv11.c @@ -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; }