How to flush v4l2 decoder when meet eof

I use v4l2 nvdec in noblocking mode, i reference 00_video_decode sample. but i don’t understand how to draining all decoded frame from capture_plane when demuxer meet eof.

In 00_video_decode sample, after read h264 func meet eof, for each time in loop, dequeue one
buffer from ouput_plane and don’t return it back. then check capture_plane to try to dequeue a decoded frame.
we can see the condition of exit loop is “if ( (eos) && (ctx.dec->output_plane.getNumQueuedBuffers() == 0) )
{
cout << “Done processing all the buffers returning \n”;
return true;
}”
Cause I dequeue one buffer from output_plane each time in loop after we got eof. it eventually can quit loop. But I think it doesn’t mean all decoded frame dequeue from capture_plane. For example ,when got eof, i dequeue one buf from output_plane, then go to checkout capture_plane ,if loop run fast, i will get errno == EAGAIN from capture_plane.dqBuffer(v4l2_capture_buf, &capture_buffer, NULL, 0); func ,I’m sure the EAGAIN means decoder is working, try again later,(doesn’t means decoder is finish job,no more frame can be dequeue). then we break and go back to the top of loop to continue dequeue buffer from output_plane. output_plane’s NumQueuedBuffers -1; After several times loop,we quit loop from “if ( (eos) && (ctx.dec->output_plane.getNumQueuedBuffers() == 0) )
{
cout << “Done processing all the buffers returning \n”;
return true;
}”. But decoder may not finish decompress job.

How can i get the signal that, all compress frame i enqueue in output_plane has been decoded and dequeue from capture_plane( I can’t try again and again in loop to checkout the ret of dequeue func, cause i can’t tell the different about all frame is decoded,or one frame is decoding when errno == EAGAIN )

HI,
There is discussion in topic 195515 and please try this solution:
Jetson h264 decoder flush deadlock - #20 by DaneLLL

It is to make sure both capture and output planes get EoS and then we can terminate the decoding.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.