Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Coverity issues #193

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 20 additions & 13 deletions c2_components/src/mfx_c2_decoder_component.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2004,6 +2004,8 @@ void MfxC2DecoderComponent::DoWork(std::unique_ptr<C2Work>&& work)
{
MFX_DEBUG_TRACE_FUNC;

if (!work) return;

if (m_bFlushing) {
m_flushedWorks.push_back(std::move(work));
return;
Expand Down Expand Up @@ -2334,19 +2336,20 @@ void MfxC2DecoderComponent::WaitWork(MfxC2FrameOut&& frame_out, mfxSyncPoint syn

MfxC2FrameOut frameOutVpp;
std::shared_ptr<mfxFrameSurface1> 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
}
}
}

Expand Down Expand Up @@ -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);
}
Expand Down
7 changes: 5 additions & 2 deletions c2_utils/src/mfx_gralloc1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<buffer_handle_t>(*outBuffer);

if (outBuffer)
out = const_cast<buffer_handle_t>(*outBuffer);

MFX_DEBUG_TRACE__android_c2_status_t(res);
return out;
Expand Down