Skip to content

Commit

Permalink
[Decode] Complete cur frame in child thread to unlock res (#6509)
Browse files Browse the repository at this point in the history
Currently, main thread is responsiable to complete finished frames to
unlock resource, but all available surfaces maybe locked by multi-frame
submission that causes main thread/ application unable to find a free
surface to continue even previous frames decoding are done, so
application has no chance to call async decode api to complete them.

Co-authored-by: Xu, Zhengguo <[email protected]>
  • Loading branch information
gfxVPLsdm and Jexu authored Feb 27, 2024
1 parent 4b592c2 commit c40736a
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions _studio/mfx_lib/decode/vp9/src/mfx_vp9_dec_decode_hw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,18 @@ class FrameStorage
}
}

void CompleteCurFrame(UMC::FrameMemID frameId)
{
auto find_it = std::find_if(m_submittedFrames.begin(), m_submittedFrames.end(),
[frameId](const UMC_VP9_DECODER::VP9DecoderFrame & item) { return item.currFrame == frameId; });

if (find_it != m_submittedFrames.end() && find_it->isDecoded)
{
UnLockResources(*find_it);
m_submittedFrames.erase(find_it);
}
}

void CompleteFrames()
{
for (auto it = m_submittedFrames.begin(); it != m_submittedFrames.end(); )
Expand Down Expand Up @@ -923,6 +935,7 @@ mfxStatus MFX_CDECL VP9DECODERoutine(void *p_state, void * /* pp_param */, mfxU3
decoder.m_surface_source->SetFreeSurfaceAllowedFlag(false);
}
decoder.m_framesStorage->DecodeFrame(data.currFrameId);
decoder.m_framesStorage->CompleteCurFrame(data.currFrameId);

return MFX_ERR_NONE;
}
Expand Down Expand Up @@ -960,6 +973,7 @@ mfxStatus MFX_CDECL VP9DECODERoutine(void *p_state, void * /* pp_param */, mfxU3
if (data.currFrameId != -1)
decoder.m_surface_source->DecreaseReference(data.currFrameId);
decoder.m_framesStorage->DecodeFrame(data.currFrameId);
decoder.m_framesStorage->CompleteCurFrame(data.currFrameId);

return MFX_TASK_DONE;
}
Expand Down

0 comments on commit c40736a

Please sign in to comment.