Skip to content

Commit

Permalink
Fix livelock in QSV encoder when QSV fails to process frames
Browse files Browse the repository at this point in the history
When QSVHelper.exe gets stuck the surfaces are never released, hence
idle_tasks remains empty
  • Loading branch information
palana committed Sep 10, 2014
1 parent 56efd38 commit 90580da
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions Source/Encoder_QSV.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1097,7 +1097,7 @@ class QSVEncoder : public VideoEncoder

bool Encode(LPVOID picInPtr, List<DataPacket> &packets, List<PacketType> &packetTypes, DWORD outputTimestamp, DWORD &out_pts) override
{
if(!process_waiter.wait_timeout())
if(helper_killed || !process_waiter.wait_timeout())
{
int code = 0;
if(!GetExitCodeProcess(process_waiter.list[0], (LPDWORD)&code))
Expand Down Expand Up @@ -1128,10 +1128,10 @@ class QSVEncoder : public VideoEncoder
{
ProcessEncodedFrame(packets, packetTypes, outputTimestamp, out_pts, idle_tasks.Num() ? 0 : 1000);
}
while(!idle_tasks.Num());
while(!helper_killed && !idle_tasks.Num());
profileOut;

if(!queued)
if(!helper_killed && !queued)
QueueEncodeTask((mfxFrameSurface1*)picInPtr, outputTimestamp);

return true;
Expand Down

0 comments on commit 90580da

Please sign in to comment.