va: encoders: select a way to wait for encoded frames
Intel HD driver doesn't block the encoding operation at vaEndPicture, which is the correct behavior. It's up to the user either to query the surface until its ready or to sync it, before use it.
There are three approaches to it:
- Call
vaSyncSurface
and block the thread. This is whatvah264enc
and ffmpeg do. It's simple and secure, but the throughout efficiency is lower. - Attach a GstTask to encoder's source pad, which is another thread, with a loop, polling an asynchronous queue and if a surface is found query it is the surface is ready, until it is, the frame is finished and pushed. This is what encoders do in gstreamer-vaapi. It's complex and error prone if the task (thread) is not handled correctly, but it's much more efficient pushing down encoded buffers.
- Add an arbitrary delay queue, hoping that surfaces are ready when that delay queue is full. It's simple but quite fragile from my point of view, and it would imply another property to configure it.
- Add some sort of fence before downstream elements map and read the encoded data.
Let's use this issue to discuss the strategy and propose ideas.
cc: @He_Junyan, @ndufresne , @seungha.yang