diff --git a/c2_components/src/mfx_c2_decoder_component.cpp b/c2_components/src/mfx_c2_decoder_component.cpp index 11df780d..68f4d0ec 100755 --- a/c2_components/src/mfx_c2_decoder_component.cpp +++ b/c2_components/src/mfx_c2_decoder_component.cpp @@ -2004,6 +2004,8 @@ void MfxC2DecoderComponent::DoWork(std::unique_ptr&& work) { MFX_DEBUG_TRACE_FUNC; + if (!work) return; + if (m_bFlushing) { m_flushedWorks.push_back(std::move(work)); return; @@ -2334,19 +2336,20 @@ void MfxC2DecoderComponent::WaitWork(MfxC2FrameOut&& frame_out, mfxSyncPoint syn MfxC2FrameOut frameOutVpp; std::shared_ptr mfx_surface_vpp; - if(m_vppConversion) { - AllocateFrame(&frameOutVpp, true); - mfx_surface_vpp = frameOutVpp.GetMfxFrameSurface(); - - if (mfx_surface_vpp) { - mfxSyncPoint syncp; - mfx_res = m_vpp->RunFrameVPPAsync(mfx_surface.get(), mfx_surface_vpp.get(), NULL, &syncp); - if (MFX_ERR_NONE == mfx_res) -#ifdef USE_ONEVPL - mfx_res = MFXVideoCORE_SyncOperation(m_mfxSession, syncp, MFX_TIMEOUT_INFINITE); -#else - mfx_res = m_pSession->SyncOperation(syncp, MFX_TIMEOUT_INFINITE); -#endif + if (m_vppConversion) { + res = AllocateFrame(&frameOutVpp, true); + if (res == C2_OK) { + mfx_surface_vpp = frameOutVpp.GetMfxFrameSurface(); + if (mfx_surface_vpp.get()) { + mfxSyncPoint syncp; + mfx_res = m_vpp->RunFrameVPPAsync(mfx_surface.get(), mfx_surface_vpp.get(), NULL, &syncp); + if (MFX_ERR_NONE == mfx_res) + #ifdef USE_ONEVPL + mfx_res = MFXVideoCORE_SyncOperation(m_mfxSession, syncp, MFX_TIMEOUT_INFINITE); + #else + mfx_res = m_pSession->SyncOperation(syncp, MFX_TIMEOUT_INFINITE); + #endif + } } } @@ -2387,6 +2390,10 @@ void MfxC2DecoderComponent::WaitWork(MfxC2FrameOut&& frame_out, mfxSyncPoint syn rect = C2Rect(mfx_surface->Info.CropW, mfx_surface->Info.CropH) .at(mfx_surface->Info.CropX, mfx_surface->Info.CropY); } else { + if (mfx_surface_vpp.get() == nullptr) { + res = C2_CORRUPTED; + break; + } rect = C2Rect(mfx_surface_vpp->Info.CropW, mfx_surface_vpp->Info.CropH) .at(mfx_surface_vpp->Info.CropX, mfx_surface_vpp->Info.CropY); } diff --git a/c2_utils/src/mfx_gralloc1.cpp b/c2_utils/src/mfx_gralloc1.cpp index 96addbfb..038260c9 100755 --- a/c2_utils/src/mfx_gralloc1.cpp +++ b/c2_utils/src/mfx_gralloc1.cpp @@ -278,13 +278,16 @@ buffer_handle_t MfxGralloc1Module::ImportBuffer(const buffer_handle_t rawHandle) MFX_DEBUG_TRACE_FUNC; c2_status_t res = C2_OK; buffer_handle_t *outBuffer = nullptr; - int32_t gr1_res = (*m_grImportBufferFunc)(m_gralloc1_dev, rawHandle, outBuffer); + buffer_handle_t out = nullptr; + int32_t gr1_res = (*m_grImportBufferFunc)(m_gralloc1_dev, rawHandle, outBuffer); if (GRALLOC1_ERROR_NONE != gr1_res || nullptr == outBuffer) { MFX_DEBUG_TRACE_I32(gr1_res); res = C2_BAD_STATE; } - buffer_handle_t out = const_cast(*outBuffer); + + if (outBuffer) + out = const_cast(*outBuffer); MFX_DEBUG_TRACE__android_c2_status_t(res); return out;